]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/media/pci/saa7164/saa7164-cards.c
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / drivers / media / pci / saa7164 / saa7164-cards.c
CommitLineData
443c1228
ST
1/*
2 * Driver for the NXP SAA7164 PCIe bridge
3 *
63a412ec 4 * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
443c1228
ST
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
443c1228
ST
16 */
17
18#include <linux/init.h>
19#include <linux/module.h>
20#include <linux/pci.h>
21#include <linux/delay.h>
22
23#include "saa7164.h"
24
25/* The Bridge API needs to understand register widths (in bytes) for the
26 * attached I2C devices, so we can simplify the virtual i2c mechansms
27 * and keep the -i2c.c implementation clean.
28 */
504b29cb 29#define REGLEN_0bit 0
443c1228
ST
30#define REGLEN_8bit 1
31#define REGLEN_16bit 2
32
33struct saa7164_board saa7164_boards[] = {
34 [SAA7164_BOARD_UNKNOWN] = {
35 /* Bridge will not load any firmware, without knowing
36 * the rev this would be fatal. */
37 .name = "Unknown",
38 },
39 [SAA7164_BOARD_UNKNOWN_REV2] = {
40 /* Bridge will load the v2 f/w and dump descriptors */
41 /* Required during new board bringup */
42 .name = "Generic Rev2",
43 .chiprev = SAA7164_CHIP_REV2,
44 },
45 [SAA7164_BOARD_UNKNOWN_REV3] = {
46 /* Bridge will load the v2 f/w and dump descriptors */
47 /* Required during new board bringup */
48 .name = "Generic Rev3",
49 .chiprev = SAA7164_CHIP_REV3,
50 },
51 [SAA7164_BOARD_HAUPPAUGE_HVR2200] = {
52 .name = "Hauppauge WinTV-HVR2200",
53 .porta = SAA7164_MPEG_DVB,
54 .portb = SAA7164_MPEG_DVB,
7615e434
ST
55 .portc = SAA7164_MPEG_ENCODER,
56 .portd = SAA7164_MPEG_ENCODER,
e8ce2f21
ST
57 .porte = SAA7164_MPEG_VBI,
58 .portf = SAA7164_MPEG_VBI,
443c1228
ST
59 .chiprev = SAA7164_CHIP_REV3,
60 .unit = {{
30015c1e 61 .id = 0x1d,
443c1228
ST
62 .type = SAA7164_UNIT_EEPROM,
63 .name = "4K EEPROM",
64 .i2c_bus_nr = SAA7164_I2C_BUS_0,
65 .i2c_bus_addr = 0xa0 >> 1,
66 .i2c_reg_len = REGLEN_8bit,
67 }, {
68 .id = 0x04,
69 .type = SAA7164_UNIT_TUNER,
70 .name = "TDA18271-1",
71 .i2c_bus_nr = SAA7164_I2C_BUS_1,
72 .i2c_bus_addr = 0xc0 >> 1,
73 .i2c_reg_len = REGLEN_8bit,
74 }, {
75 .id = 0x1b,
76 .type = SAA7164_UNIT_TUNER,
77 .name = "TDA18271-2",
78 .i2c_bus_nr = SAA7164_I2C_BUS_2,
79 .i2c_bus_addr = 0xc0 >> 1,
80 .i2c_reg_len = REGLEN_8bit,
81 }, {
82 .id = 0x1e,
83 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
84 .name = "TDA10048-1",
85 .i2c_bus_nr = SAA7164_I2C_BUS_1,
86 .i2c_bus_addr = 0x10 >> 1,
87 .i2c_reg_len = REGLEN_8bit,
88 }, {
89 .id = 0x1f,
90 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
91 .name = "TDA10048-2",
92 .i2c_bus_nr = SAA7164_I2C_BUS_2,
93 .i2c_bus_addr = 0x12 >> 1,
94 .i2c_reg_len = REGLEN_8bit,
95 } },
96 },
97 [SAA7164_BOARD_HAUPPAUGE_HVR2200_2] = {
98 .name = "Hauppauge WinTV-HVR2200",
99 .porta = SAA7164_MPEG_DVB,
100 .portb = SAA7164_MPEG_DVB,
7615e434
ST
101 .portc = SAA7164_MPEG_ENCODER,
102 .portd = SAA7164_MPEG_ENCODER,
e8ce2f21
ST
103 .porte = SAA7164_MPEG_VBI,
104 .portf = SAA7164_MPEG_VBI,
443c1228
ST
105 .chiprev = SAA7164_CHIP_REV2,
106 .unit = {{
107 .id = 0x06,
108 .type = SAA7164_UNIT_EEPROM,
109 .name = "4K EEPROM",
110 .i2c_bus_nr = SAA7164_I2C_BUS_0,
111 .i2c_bus_addr = 0xa0 >> 1,
112 .i2c_reg_len = REGLEN_8bit,
113 }, {
114 .id = 0x04,
115 .type = SAA7164_UNIT_TUNER,
116 .name = "TDA18271-1",
117 .i2c_bus_nr = SAA7164_I2C_BUS_1,
118 .i2c_bus_addr = 0xc0 >> 1,
119 .i2c_reg_len = REGLEN_8bit,
120 }, {
121 .id = 0x05,
122 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
123 .name = "TDA10048-1",
124 .i2c_bus_nr = SAA7164_I2C_BUS_1,
125 .i2c_bus_addr = 0x10 >> 1,
126 .i2c_reg_len = REGLEN_8bit,
127 }, {
128 .id = 0x1e,
129 .type = SAA7164_UNIT_TUNER,
130 .name = "TDA18271-2",
131 .i2c_bus_nr = SAA7164_I2C_BUS_2,
132 .i2c_bus_addr = 0xc0 >> 1,
133 .i2c_reg_len = REGLEN_8bit,
134 }, {
135 .id = 0x1f,
136 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
137 .name = "TDA10048-2",
138 .i2c_bus_nr = SAA7164_I2C_BUS_2,
139 .i2c_bus_addr = 0x12 >> 1,
140 .i2c_reg_len = REGLEN_8bit,
141 } },
142 },
143 [SAA7164_BOARD_HAUPPAUGE_HVR2200_3] = {
144 .name = "Hauppauge WinTV-HVR2200",
145 .porta = SAA7164_MPEG_DVB,
146 .portb = SAA7164_MPEG_DVB,
7615e434
ST
147 .portc = SAA7164_MPEG_ENCODER,
148 .portd = SAA7164_MPEG_ENCODER,
e8ce2f21
ST
149 .porte = SAA7164_MPEG_VBI,
150 .portf = SAA7164_MPEG_VBI,
443c1228
ST
151 .chiprev = SAA7164_CHIP_REV2,
152 .unit = {{
30015c1e 153 .id = 0x1d,
443c1228
ST
154 .type = SAA7164_UNIT_EEPROM,
155 .name = "4K EEPROM",
156 .i2c_bus_nr = SAA7164_I2C_BUS_0,
157 .i2c_bus_addr = 0xa0 >> 1,
158 .i2c_reg_len = REGLEN_8bit,
159 }, {
160 .id = 0x04,
161 .type = SAA7164_UNIT_TUNER,
162 .name = "TDA18271-1",
163 .i2c_bus_nr = SAA7164_I2C_BUS_1,
164 .i2c_bus_addr = 0xc0 >> 1,
165 .i2c_reg_len = REGLEN_8bit,
166 }, {
167 .id = 0x05,
168 .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
169 .name = "TDA8290-1",
170 .i2c_bus_nr = SAA7164_I2C_BUS_1,
171 .i2c_bus_addr = 0x84 >> 1,
172 .i2c_reg_len = REGLEN_8bit,
173 }, {
174 .id = 0x1b,
175 .type = SAA7164_UNIT_TUNER,
176 .name = "TDA18271-2",
177 .i2c_bus_nr = SAA7164_I2C_BUS_2,
178 .i2c_bus_addr = 0xc0 >> 1,
179 .i2c_reg_len = REGLEN_8bit,
180 }, {
181 .id = 0x1c,
182 .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
183 .name = "TDA8290-2",
184 .i2c_bus_nr = SAA7164_I2C_BUS_2,
185 .i2c_bus_addr = 0x84 >> 1,
186 .i2c_reg_len = REGLEN_8bit,
187 }, {
188 .id = 0x1e,
189 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
190 .name = "TDA10048-1",
191 .i2c_bus_nr = SAA7164_I2C_BUS_1,
192 .i2c_bus_addr = 0x10 >> 1,
193 .i2c_reg_len = REGLEN_8bit,
194 }, {
195 .id = 0x1f,
196 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
197 .name = "TDA10048-2",
198 .i2c_bus_nr = SAA7164_I2C_BUS_2,
199 .i2c_bus_addr = 0x12 >> 1,
200 .i2c_reg_len = REGLEN_8bit,
201 } },
202 },
62dd28d0
TJ
203 [SAA7164_BOARD_HAUPPAUGE_HVR2200_4] = {
204 .name = "Hauppauge WinTV-HVR2200",
205 .porta = SAA7164_MPEG_DVB,
206 .portb = SAA7164_MPEG_DVB,
207 .portc = SAA7164_MPEG_ENCODER,
208 .portd = SAA7164_MPEG_ENCODER,
209 .porte = SAA7164_MPEG_VBI,
210 .portf = SAA7164_MPEG_VBI,
211 .chiprev = SAA7164_CHIP_REV3,
212 .unit = {{
213 .id = 0x1d,
214 .type = SAA7164_UNIT_EEPROM,
215 .name = "4K EEPROM",
216 .i2c_bus_nr = SAA7164_I2C_BUS_0,
217 .i2c_bus_addr = 0xa0 >> 1,
218 .i2c_reg_len = REGLEN_8bit,
219 }, {
220 .id = 0x04,
221 .type = SAA7164_UNIT_TUNER,
222 .name = "TDA18271-1",
223 .i2c_bus_nr = SAA7164_I2C_BUS_1,
224 .i2c_bus_addr = 0xc0 >> 1,
225 .i2c_reg_len = REGLEN_8bit,
226 }, {
227 .id = 0x05,
228 .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
229 .name = "TDA8290-1",
230 .i2c_bus_nr = SAA7164_I2C_BUS_1,
231 .i2c_bus_addr = 0x84 >> 1,
232 .i2c_reg_len = REGLEN_8bit,
233 }, {
234 .id = 0x1b,
235 .type = SAA7164_UNIT_TUNER,
236 .name = "TDA18271-2",
237 .i2c_bus_nr = SAA7164_I2C_BUS_2,
238 .i2c_bus_addr = 0xc0 >> 1,
239 .i2c_reg_len = REGLEN_8bit,
240 }, {
241 .id = 0x1c,
242 .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
243 .name = "TDA8290-2",
244 .i2c_bus_nr = SAA7164_I2C_BUS_2,
245 .i2c_bus_addr = 0x84 >> 1,
246 .i2c_reg_len = REGLEN_8bit,
247 }, {
248 .id = 0x1e,
249 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
250 .name = "TDA10048-1",
251 .i2c_bus_nr = SAA7164_I2C_BUS_1,
252 .i2c_bus_addr = 0x10 >> 1,
253 .i2c_reg_len = REGLEN_8bit,
254 }, {
255 .id = 0x1f,
256 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
257 .name = "TDA10048-2",
258 .i2c_bus_nr = SAA7164_I2C_BUS_2,
259 .i2c_bus_addr = 0x12 >> 1,
260 .i2c_reg_len = REGLEN_8bit,
261 } },
262 },
443c1228
ST
263 [SAA7164_BOARD_HAUPPAUGE_HVR2250] = {
264 .name = "Hauppauge WinTV-HVR2250",
265 .porta = SAA7164_MPEG_DVB,
266 .portb = SAA7164_MPEG_DVB,
7615e434
ST
267 .portc = SAA7164_MPEG_ENCODER,
268 .portd = SAA7164_MPEG_ENCODER,
e8ce2f21
ST
269 .porte = SAA7164_MPEG_VBI,
270 .portf = SAA7164_MPEG_VBI,
443c1228
ST
271 .chiprev = SAA7164_CHIP_REV3,
272 .unit = {{
273 .id = 0x22,
274 .type = SAA7164_UNIT_EEPROM,
275 .name = "4K EEPROM",
276 .i2c_bus_nr = SAA7164_I2C_BUS_0,
277 .i2c_bus_addr = 0xa0 >> 1,
278 .i2c_reg_len = REGLEN_8bit,
279 }, {
280 .id = 0x04,
281 .type = SAA7164_UNIT_TUNER,
282 .name = "TDA18271-1",
283 .i2c_bus_nr = SAA7164_I2C_BUS_1,
284 .i2c_bus_addr = 0xc0 >> 1,
285 .i2c_reg_len = REGLEN_8bit,
286 }, {
287 .id = 0x07,
288 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
289 .name = "CX24228/S5H1411-1 (TOP)",
290 .i2c_bus_nr = SAA7164_I2C_BUS_1,
291 .i2c_bus_addr = 0x32 >> 1,
292 .i2c_reg_len = REGLEN_8bit,
293 }, {
294 .id = 0x08,
295 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
296 .name = "CX24228/S5H1411-1 (QAM)",
297 .i2c_bus_nr = SAA7164_I2C_BUS_1,
298 .i2c_bus_addr = 0x34 >> 1,
299 .i2c_reg_len = REGLEN_8bit,
300 }, {
301 .id = 0x1e,
302 .type = SAA7164_UNIT_TUNER,
303 .name = "TDA18271-2",
304 .i2c_bus_nr = SAA7164_I2C_BUS_2,
305 .i2c_bus_addr = 0xc0 >> 1,
306 .i2c_reg_len = REGLEN_8bit,
307 }, {
308 .id = 0x20,
309 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
310 .name = "CX24228/S5H1411-2 (TOP)",
311 .i2c_bus_nr = SAA7164_I2C_BUS_2,
312 .i2c_bus_addr = 0x32 >> 1,
313 .i2c_reg_len = REGLEN_8bit,
314 }, {
315 .id = 0x23,
316 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
317 .name = "CX24228/S5H1411-2 (QAM)",
318 .i2c_bus_nr = SAA7164_I2C_BUS_2,
319 .i2c_bus_addr = 0x34 >> 1,
320 .i2c_reg_len = REGLEN_8bit,
321 } },
322 },
323 [SAA7164_BOARD_HAUPPAUGE_HVR2250_2] = {
324 .name = "Hauppauge WinTV-HVR2250",
325 .porta = SAA7164_MPEG_DVB,
326 .portb = SAA7164_MPEG_DVB,
7615e434
ST
327 .portc = SAA7164_MPEG_ENCODER,
328 .portd = SAA7164_MPEG_ENCODER,
e8ce2f21 329 .porte = SAA7164_MPEG_VBI,
e8ce2f21 330 .portf = SAA7164_MPEG_VBI,
443c1228
ST
331 .chiprev = SAA7164_CHIP_REV3,
332 .unit = {{
30015c1e 333 .id = 0x28,
443c1228
ST
334 .type = SAA7164_UNIT_EEPROM,
335 .name = "4K EEPROM",
336 .i2c_bus_nr = SAA7164_I2C_BUS_0,
337 .i2c_bus_addr = 0xa0 >> 1,
338 .i2c_reg_len = REGLEN_8bit,
339 }, {
340 .id = 0x04,
341 .type = SAA7164_UNIT_TUNER,
342 .name = "TDA18271-1",
343 .i2c_bus_nr = SAA7164_I2C_BUS_1,
344 .i2c_bus_addr = 0xc0 >> 1,
345 .i2c_reg_len = REGLEN_8bit,
346 }, {
347 .id = 0x07,
348 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
349 .name = "CX24228/S5H1411-1 (TOP)",
350 .i2c_bus_nr = SAA7164_I2C_BUS_1,
351 .i2c_bus_addr = 0x32 >> 1,
352 .i2c_reg_len = REGLEN_8bit,
353 }, {
354 .id = 0x08,
355 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
356 .name = "CX24228/S5H1411-1 (QAM)",
357 .i2c_bus_nr = SAA7164_I2C_BUS_1,
358 .i2c_bus_addr = 0x34 >> 1,
359 .i2c_reg_len = REGLEN_8bit,
360 }, {
361 .id = 0x24,
362 .type = SAA7164_UNIT_TUNER,
363 .name = "TDA18271-2",
364 .i2c_bus_nr = SAA7164_I2C_BUS_2,
365 .i2c_bus_addr = 0xc0 >> 1,
366 .i2c_reg_len = REGLEN_8bit,
367 }, {
368 .id = 0x26,
369 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
370 .name = "CX24228/S5H1411-2 (TOP)",
371 .i2c_bus_nr = SAA7164_I2C_BUS_2,
372 .i2c_bus_addr = 0x32 >> 1,
373 .i2c_reg_len = REGLEN_8bit,
374 }, {
375 .id = 0x29,
376 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
377 .name = "CX24228/S5H1411-2 (QAM)",
378 .i2c_bus_nr = SAA7164_I2C_BUS_2,
379 .i2c_bus_addr = 0x34 >> 1,
380 .i2c_reg_len = REGLEN_8bit,
381 } },
382 },
e3335222
ST
383 [SAA7164_BOARD_HAUPPAUGE_HVR2250_3] = {
384 .name = "Hauppauge WinTV-HVR2250",
385 .porta = SAA7164_MPEG_DVB,
386 .portb = SAA7164_MPEG_DVB,
7615e434
ST
387 .portc = SAA7164_MPEG_ENCODER,
388 .portd = SAA7164_MPEG_ENCODER,
e8ce2f21
ST
389 .porte = SAA7164_MPEG_VBI,
390 .portf = SAA7164_MPEG_VBI,
e3335222
ST
391 .chiprev = SAA7164_CHIP_REV3,
392 .unit = {{
30015c1e 393 .id = 0x26,
e3335222
ST
394 .type = SAA7164_UNIT_EEPROM,
395 .name = "4K EEPROM",
396 .i2c_bus_nr = SAA7164_I2C_BUS_0,
397 .i2c_bus_addr = 0xa0 >> 1,
398 .i2c_reg_len = REGLEN_8bit,
399 }, {
400 .id = 0x04,
401 .type = SAA7164_UNIT_TUNER,
402 .name = "TDA18271-1",
403 .i2c_bus_nr = SAA7164_I2C_BUS_1,
404 .i2c_bus_addr = 0xc0 >> 1,
405 .i2c_reg_len = REGLEN_8bit,
406 }, {
407 .id = 0x07,
408 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
409 .name = "CX24228/S5H1411-1 (TOP)",
410 .i2c_bus_nr = SAA7164_I2C_BUS_1,
411 .i2c_bus_addr = 0x32 >> 1,
412 .i2c_reg_len = REGLEN_8bit,
413 }, {
414 .id = 0x08,
415 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
416 .name = "CX24228/S5H1411-1 (QAM)",
417 .i2c_bus_nr = SAA7164_I2C_BUS_1,
418 .i2c_bus_addr = 0x34 >> 1,
419 .i2c_reg_len = REGLEN_8bit,
420 }, {
421 .id = 0x22,
422 .type = SAA7164_UNIT_TUNER,
423 .name = "TDA18271-2",
424 .i2c_bus_nr = SAA7164_I2C_BUS_2,
425 .i2c_bus_addr = 0xc0 >> 1,
426 .i2c_reg_len = REGLEN_8bit,
427 }, {
428 .id = 0x24,
429 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
430 .name = "CX24228/S5H1411-2 (TOP)",
431 .i2c_bus_nr = SAA7164_I2C_BUS_2,
432 .i2c_bus_addr = 0x32 >> 1,
433 .i2c_reg_len = REGLEN_8bit,
434 }, {
435 .id = 0x27,
436 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
437 .name = "CX24228/S5H1411-2 (QAM)",
438 .i2c_bus_nr = SAA7164_I2C_BUS_2,
439 .i2c_bus_addr = 0x34 >> 1,
440 .i2c_reg_len = REGLEN_8bit,
441 } },
442 },
de2fb698
ST
443 [SAA7164_BOARD_HAUPPAUGE_HVR2200_5] = {
444 .name = "Hauppauge WinTV-HVR2200",
445 .porta = SAA7164_MPEG_DVB,
446 .portb = SAA7164_MPEG_DVB,
447 .chiprev = SAA7164_CHIP_REV3,
448 .unit = {{
449 .id = 0x23,
450 .type = SAA7164_UNIT_EEPROM,
451 .name = "4K EEPROM",
452 .i2c_bus_nr = SAA7164_I2C_BUS_0,
453 .i2c_bus_addr = 0xa0 >> 1,
454 .i2c_reg_len = REGLEN_8bit,
455 }, {
456 .id = 0x04,
457 .type = SAA7164_UNIT_TUNER,
458 .name = "TDA18271-1",
459 .i2c_bus_nr = SAA7164_I2C_BUS_1,
460 .i2c_bus_addr = 0xc0 >> 1,
461 .i2c_reg_len = REGLEN_8bit,
462 }, {
463 .id = 0x05,
464 .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
465 .name = "TDA8290-1",
466 .i2c_bus_nr = SAA7164_I2C_BUS_1,
467 .i2c_bus_addr = 0x84 >> 1,
468 .i2c_reg_len = REGLEN_8bit,
469 }, {
470 .id = 0x21,
471 .type = SAA7164_UNIT_TUNER,
472 .name = "TDA18271-2",
473 .i2c_bus_nr = SAA7164_I2C_BUS_2,
474 .i2c_bus_addr = 0xc0 >> 1,
475 .i2c_reg_len = REGLEN_8bit,
476 }, {
477 .id = 0x22,
478 .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
479 .name = "TDA8290-2",
480 .i2c_bus_nr = SAA7164_I2C_BUS_2,
481 .i2c_bus_addr = 0x84 >> 1,
482 .i2c_reg_len = REGLEN_8bit,
483 }, {
484 .id = 0x24,
485 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
486 .name = "TDA10048-1",
487 .i2c_bus_nr = SAA7164_I2C_BUS_1,
488 .i2c_bus_addr = 0x10 >> 1,
489 .i2c_reg_len = REGLEN_8bit,
490 }, {
491 .id = 0x25,
492 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
493 .name = "TDA10048-2",
494 .i2c_bus_nr = SAA7164_I2C_BUS_2,
495 .i2c_bus_addr = 0x12 >> 1,
496 .i2c_reg_len = REGLEN_8bit,
497 } },
498 },
504b29cb
ST
499 [SAA7164_BOARD_HAUPPAUGE_HVR2255proto] = {
500 .name = "Hauppauge WinTV-HVR2255(proto)",
501 .porta = SAA7164_MPEG_DVB,
502 .portb = SAA7164_MPEG_DVB,
503 .portc = SAA7164_MPEG_ENCODER,
504 .portd = SAA7164_MPEG_ENCODER,
505 .porte = SAA7164_MPEG_VBI,
506 .portf = SAA7164_MPEG_VBI,
507 .chiprev = SAA7164_CHIP_REV3,
508 .unit = {{
509 .id = 0x27,
510 .type = SAA7164_UNIT_EEPROM,
511 .name = "4K EEPROM",
512 .i2c_bus_nr = SAA7164_I2C_BUS_0,
513 .i2c_bus_addr = 0xa0 >> 1,
514 .i2c_reg_len = REGLEN_8bit,
515 }, {
516 .id = 0x04,
517 .type = SAA7164_UNIT_TUNER,
518 .name = "SI2157-1",
519 .i2c_bus_nr = SAA7164_I2C_BUS_0,
520 .i2c_bus_addr = 0xc0 >> 1,
521 .i2c_reg_len = REGLEN_0bit,
522 }, {
523 .id = 0x06,
524 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
525 .name = "LGDT3306",
526 .i2c_bus_nr = SAA7164_I2C_BUS_2,
527 .i2c_bus_addr = 0xb2 >> 1,
528 .i2c_reg_len = REGLEN_8bit,
529 }, {
530 .id = 0x24,
531 .type = SAA7164_UNIT_TUNER,
532 .name = "SI2157-2",
533 .i2c_bus_nr = SAA7164_I2C_BUS_1,
534 .i2c_bus_addr = 0xc0 >> 1,
535 .i2c_reg_len = REGLEN_0bit,
536 }, {
537 .id = 0x26,
538 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
539 .name = "LGDT3306-2",
540 .i2c_bus_nr = SAA7164_I2C_BUS_2,
541 .i2c_bus_addr = 0x1c >> 1,
542 .i2c_reg_len = REGLEN_8bit,
543 } },
544 },
545 [SAA7164_BOARD_HAUPPAUGE_HVR2255] = {
546 .name = "Hauppauge WinTV-HVR2255",
547 .porta = SAA7164_MPEG_DVB,
548 .portb = SAA7164_MPEG_DVB,
549 .portc = SAA7164_MPEG_ENCODER,
550 .portd = SAA7164_MPEG_ENCODER,
551 .porte = SAA7164_MPEG_VBI,
552 .portf = SAA7164_MPEG_VBI,
553 .chiprev = SAA7164_CHIP_REV3,
554 .unit = {{
555 .id = 0x28,
556 .type = SAA7164_UNIT_EEPROM,
557 .name = "4K EEPROM",
558 .i2c_bus_nr = SAA7164_I2C_BUS_0,
559 .i2c_bus_addr = 0xa0 >> 1,
560 .i2c_reg_len = REGLEN_8bit,
561 }, {
562 .id = 0x04,
563 .type = SAA7164_UNIT_TUNER,
564 .name = "SI2157-1",
565 .i2c_bus_nr = SAA7164_I2C_BUS_0,
566 .i2c_bus_addr = 0xc0 >> 1,
567 .i2c_reg_len = REGLEN_0bit,
568 }, {
569 .id = 0x06,
570 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
571 .name = "LGDT3306-1",
572 .i2c_bus_nr = SAA7164_I2C_BUS_2,
573 .i2c_bus_addr = 0xb2 >> 1,
574 .i2c_reg_len = REGLEN_8bit,
575 }, {
576 .id = 0x25,
577 .type = SAA7164_UNIT_TUNER,
578 .name = "SI2157-2",
579 .i2c_bus_nr = SAA7164_I2C_BUS_1,
580 .i2c_bus_addr = 0xc0 >> 1,
581 .i2c_reg_len = REGLEN_0bit,
582 }, {
583 .id = 0x27,
584 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
585 .name = "LGDT3306-2",
586 .i2c_bus_nr = SAA7164_I2C_BUS_2,
587 .i2c_bus_addr = 0x1c >> 1,
588 .i2c_reg_len = REGLEN_8bit,
589 } },
590 },
591 [SAA7164_BOARD_HAUPPAUGE_HVR2205] = {
592 .name = "Hauppauge WinTV-HVR2205",
593 .porta = SAA7164_MPEG_DVB,
594 .portb = SAA7164_MPEG_DVB,
595 .portc = SAA7164_MPEG_ENCODER,
596 .portd = SAA7164_MPEG_ENCODER,
597 .porte = SAA7164_MPEG_VBI,
598 .portf = SAA7164_MPEG_VBI,
599 .chiprev = SAA7164_CHIP_REV3,
600 .unit = {{
601 .id = 0x28,
602 .type = SAA7164_UNIT_EEPROM,
603 .name = "4K EEPROM",
604 .i2c_bus_nr = SAA7164_I2C_BUS_0,
605 .i2c_bus_addr = 0xa0 >> 1,
606 .i2c_reg_len = REGLEN_8bit,
607 }, {
608 .id = 0x04,
609 .type = SAA7164_UNIT_TUNER,
610 .name = "SI2157-1",
611 .i2c_bus_nr = SAA7164_I2C_BUS_0,
612 .i2c_bus_addr = 0xc0 >> 1,
613 .i2c_reg_len = REGLEN_0bit,
614 }, {
615 .id = 0x06,
616 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
617 .name = "SI2168-1",
618 .i2c_bus_nr = SAA7164_I2C_BUS_2,
619 .i2c_bus_addr = 0xc8 >> 1,
d9768728 620 .i2c_reg_len = REGLEN_0bit,
504b29cb
ST
621 }, {
622 .id = 0x25,
623 .type = SAA7164_UNIT_TUNER,
624 .name = "SI2157-2",
625 .i2c_bus_nr = SAA7164_I2C_BUS_1,
626 .i2c_bus_addr = 0xc0 >> 1,
627 .i2c_reg_len = REGLEN_0bit,
628 }, {
629 .id = 0x27,
630 .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
631 .name = "SI2168-2",
632 .i2c_bus_nr = SAA7164_I2C_BUS_2,
633 .i2c_bus_addr = 0xcc >> 1,
d9768728 634 .i2c_reg_len = REGLEN_0bit,
504b29cb
ST
635 } },
636 },
443c1228
ST
637};
638const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
639
640/* ------------------------------------------------------------------ */
641/* PCI subsystem IDs */
642
643struct saa7164_subid saa7164_subids[] = {
644 {
645 .subvendor = 0x0070,
646 .subdevice = 0x8880,
647 .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
648 }, {
649 .subvendor = 0x0070,
650 .subdevice = 0x8810,
651 .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
652 }, {
653 .subvendor = 0x0070,
654 .subdevice = 0x8980,
655 .card = SAA7164_BOARD_HAUPPAUGE_HVR2200,
656 }, {
657 .subvendor = 0x0070,
658 .subdevice = 0x8900,
659 .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_2,
660 }, {
661 .subvendor = 0x0070,
662 .subdevice = 0x8901,
663 .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_3,
664 }, {
665 .subvendor = 0x0070,
666 .subdevice = 0x88A1,
e3335222 667 .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_3,
443c1228
ST
668 }, {
669 .subvendor = 0x0070,
670 .subdevice = 0x8891,
671 .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
3a360ced
ST
672 }, {
673 .subvendor = 0x0070,
674 .subdevice = 0x8851,
675 .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
62dd28d0
TJ
676 }, {
677 .subvendor = 0x0070,
678 .subdevice = 0x8940,
679 .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_4,
de2fb698
ST
680 }, {
681 .subvendor = 0x0070,
682 .subdevice = 0x8953,
683 .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_5,
504b29cb
ST
684 }, {
685 .subvendor = 0x0070,
686 .subdevice = 0xf111,
687 .card = SAA7164_BOARD_HAUPPAUGE_HVR2255,
688 /* Prototype card left here for documenation purposes.
689 .card = SAA7164_BOARD_HAUPPAUGE_HVR2255proto,
690 */
691 }, {
692 .subvendor = 0x0070,
693 .subdevice = 0xf123,
694 .card = SAA7164_BOARD_HAUPPAUGE_HVR2205,
695 }, {
696 .subvendor = 0x0070,
697 .subdevice = 0xf120,
698 .card = SAA7164_BOARD_HAUPPAUGE_HVR2205,
443c1228
ST
699 },
700};
701const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
702
703void saa7164_card_list(struct saa7164_dev *dev)
704{
705 int i;
706
707 if (0 == dev->pci->subsystem_vendor &&
708 0 == dev->pci->subsystem_device) {
709 printk(KERN_ERR
710 "%s: Board has no valid PCIe Subsystem ID and can't\n"
711 "%s: be autodetected. Pass card=<n> insmod option to\n"
712 "%s: workaround that. Send complaints to the vendor\n"
713 "%s: of the TV card. Best regards,\n"
714 "%s: -- tux\n",
715 dev->name, dev->name, dev->name, dev->name, dev->name);
716 } else {
717 printk(KERN_ERR
718 "%s: Your board isn't known (yet) to the driver.\n"
719 "%s: Try to pick one of the existing card configs via\n"
720 "%s: card=<n> insmod option. Updating to the latest\n"
721 "%s: version might help as well.\n",
722 dev->name, dev->name, dev->name, dev->name);
723 }
724
24f711c1
MCC
725 printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod option:\n",
726 dev->name);
443c1228
ST
727
728 for (i = 0; i < saa7164_bcount; i++)
729 printk(KERN_ERR "%s: card=%d -> %s\n",
730 dev->name, i, saa7164_boards[i].name);
731}
732
733/* TODO: clean this define up into the -cards.c structs */
734#define PCIEBRIDGE_UNITID 2
735
736void saa7164_gpio_setup(struct saa7164_dev *dev)
737{
443c1228
ST
738 switch (dev->board) {
739 case SAA7164_BOARD_HAUPPAUGE_HVR2200:
740 case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
741 case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
62dd28d0 742 case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
de2fb698 743 case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
443c1228
ST
744 case SAA7164_BOARD_HAUPPAUGE_HVR2250:
745 case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
e3335222 746 case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
504b29cb
ST
747 case SAA7164_BOARD_HAUPPAUGE_HVR2255proto:
748 case SAA7164_BOARD_HAUPPAUGE_HVR2255:
749 case SAA7164_BOARD_HAUPPAUGE_HVR2205:
443c1228 750 /*
504b29cb 751 HVR2200 / HVR2250
443c1228
ST
752 GPIO 2: s5h1411 / tda10048-1 demod reset
753 GPIO 3: s5h1411 / tda10048-2 demod reset
754 GPIO 7: IRBlaster Zilog reset
755 */
756
504b29cb
ST
757 /* HVR2255
758 * GPIO 2: lgdg3306-1 demod reset
759 * GPIO 3: lgdt3306-2 demod reset
760 */
761
762 /* HVR2205
763 * GPIO 2: si2168-1 demod reset
764 * GPIO 3: si2168-2 demod reset
765 */
766
443c1228
ST
767 /* Reset parts by going in and out of reset */
768 saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
769 saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
770
bc250684 771 msleep(20);
443c1228
ST
772
773 saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
774 saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
775 break;
776 }
443c1228
ST
777}
778
779static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
780{
781 struct tveeprom tv;
782
783 /* TODO: Assumption: eeprom on bus 0 */
784 tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
785 eeprom_data);
786
787 /* Make sure we support the board model */
788 switch (tv.model) {
789 case 88001:
790 /* Development board - Limit circulation */
791 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
792 * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
793 case 88021:
794 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
795 * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
796 break;
797 case 88041:
798 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
799 * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
800 break;
801 case 88061:
802 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
803 * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
804 break;
805 case 89519:
806 case 89609:
807 /* WinTV-HVR2200 (PCIe, Retail, full-height)
808 * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
809 break;
810 case 89619:
811 /* WinTV-HVR2200 (PCIe, Retail, half-height)
812 * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
813 break;
504b29cb
ST
814 case 151009:
815 /* First production board rev B2I6 */
816 /* WinTV-HVR2205 (PCIe, Retail, full-height bracket)
817 * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
818 break;
819 case 151609:
820 /* First production board rev B2I6 */
821 /* WinTV-HVR2205 (PCIe, Retail, half-height bracket)
822 * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
823 break;
824 case 151061:
825 /* First production board rev B1I6 */
826 /* WinTV-HVR2255 (PCIe, Retail, full-height bracket)
827 * ATSC/QAM (SI2157/LGDT3306) and basic analog, FM */
828 break;
443c1228
ST
829 default:
830 printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
831 dev->name, tv.model);
832 break;
833 }
834
835 printk(KERN_INFO "%s: Hauppauge eeprom: model=%d\n", dev->name,
836 tv.model);
837}
838
839void saa7164_card_setup(struct saa7164_dev *dev)
840{
841 static u8 eeprom[256];
842
843 if (dev->i2c_bus[0].i2c_rc == 0) {
844 if (saa7164_api_read_eeprom(dev, &eeprom[0],
845 sizeof(eeprom)) < 0)
846 return;
847 }
848
849 switch (dev->board) {
850 case SAA7164_BOARD_HAUPPAUGE_HVR2200:
851 case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
852 case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
62dd28d0 853 case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
de2fb698 854 case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
443c1228 855 case SAA7164_BOARD_HAUPPAUGE_HVR2250:
c303e3e1 856 case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
e3335222 857 case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
504b29cb
ST
858 case SAA7164_BOARD_HAUPPAUGE_HVR2255proto:
859 case SAA7164_BOARD_HAUPPAUGE_HVR2255:
860 case SAA7164_BOARD_HAUPPAUGE_HVR2205:
443c1228
ST
861 hauppauge_eeprom(dev, &eeprom[0]);
862 break;
863 }
864}
865
866/* With most other drivers, the kernel expects to communicate with subdrivers
867 * through i2c. This bridge does not allow that, it does not expose any direct
868 * access to I2C. Instead we have to communicate through the device f/w for
869 * register access to 'processing units'. Each unit has a unique
870 * id, regardless of how the physical implementation occurs across
871 * the three physical i2c busses. The being said if we want leverge of
872 * the existing kernel drivers for tuners and demods we have to 'speak i2c',
873 * to this bridge implements 3 virtual i2c buses. This is a helper function
874 * for those.
875 *
876 * Description: Translate the kernels notion of an i2c address and bus into
877 * the appropriate unitid.
878 */
879int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr)
880{
881 /* For a given bus and i2c device address, return the saa7164 unique
882 * unitid. < 0 on error */
883
884 struct saa7164_dev *dev = bus->dev;
885 struct saa7164_unit *unit;
886 int i;
887
888 for (i = 0; i < SAA7164_MAX_UNITS; i++) {
889 unit = &saa7164_boards[dev->board].unit[i];
890
891 if (unit->type == SAA7164_UNIT_UNDEFINED)
892 continue;
893 if ((bus->nr == unit->i2c_bus_nr) &&
894 (addr == unit->i2c_bus_addr))
895 return unit->id;
896 }
897
898 return -1;
899}
900
901/* The 7164 API needs to know the i2c register length in advance.
902 * this is a helper function. Based on a specific chip addr and bus return the
903 * reg length.
904 */
905int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr)
906{
907 /* For a given bus and i2c device address, return the
908 * saa7164 registry address width. < 0 on error
909 */
910
911 struct saa7164_dev *dev = bus->dev;
912 struct saa7164_unit *unit;
913 int i;
914
915 for (i = 0; i < SAA7164_MAX_UNITS; i++) {
916 unit = &saa7164_boards[dev->board].unit[i];
917
918 if (unit->type == SAA7164_UNIT_UNDEFINED)
919 continue;
920
921 if ((bus->nr == unit->i2c_bus_nr) &&
922 (addr == unit->i2c_bus_addr))
923 return unit->i2c_reg_len;
924 }
925
926 return -1;
927}
928/* TODO: implement a 'findeeprom' functio like the above and fix any other
929 * eeprom related todo's in -api.c.
930 */
931
932/* Translate a unitid into a x readable device name, for display purposes. */
933char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid)
934{
935 char *undefed = "UNDEFINED";
936 char *bridge = "BRIDGE";
937 struct saa7164_unit *unit;
938 int i;
939
940 if (unitid == 0)
941 return bridge;
942
943 for (i = 0; i < SAA7164_MAX_UNITS; i++) {
944 unit = &saa7164_boards[dev->board].unit[i];
945
946 if (unit->type == SAA7164_UNIT_UNDEFINED)
947 continue;
948
949 if (unitid == unit->id)
950 return unit->name;
951 }
952
953 return undefed;
954}
955