2 * Driver for the NXP SAA7164 PCIe bridge
4 * Copyright (c) 2010-2015 Steven Toth <stoth@kernellabs.com>
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.
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
15 * GNU General Public License for more details.
18 #include <linux/init.h>
19 #include <linux/module.h>
20 #include <linux/pci.h>
21 #include <linux/delay.h>
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.
31 #define REGLEN_16bit 2
33 struct saa7164_board saa7164_boards
[] = {
34 [SAA7164_BOARD_UNKNOWN
] = {
35 /* Bridge will not load any firmware, without knowing
36 * the rev this would be fatal. */
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
,
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
,
51 [SAA7164_BOARD_HAUPPAUGE_HVR2200
] = {
52 .name
= "Hauppauge WinTV-HVR2200",
53 .porta
= SAA7164_MPEG_DVB
,
54 .portb
= SAA7164_MPEG_DVB
,
55 .portc
= SAA7164_MPEG_ENCODER
,
56 .portd
= SAA7164_MPEG_ENCODER
,
57 .porte
= SAA7164_MPEG_VBI
,
58 .portf
= SAA7164_MPEG_VBI
,
59 .chiprev
= SAA7164_CHIP_REV3
,
62 .type
= SAA7164_UNIT_EEPROM
,
64 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
65 .i2c_bus_addr
= 0xa0 >> 1,
66 .i2c_reg_len
= REGLEN_8bit
,
69 .type
= SAA7164_UNIT_TUNER
,
71 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
72 .i2c_bus_addr
= 0xc0 >> 1,
73 .i2c_reg_len
= REGLEN_8bit
,
76 .type
= SAA7164_UNIT_TUNER
,
78 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
79 .i2c_bus_addr
= 0xc0 >> 1,
80 .i2c_reg_len
= REGLEN_8bit
,
83 .type
= SAA7164_UNIT_DIGITAL_DEMODULATOR
,
85 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
86 .i2c_bus_addr
= 0x10 >> 1,
87 .i2c_reg_len
= REGLEN_8bit
,
90 .type
= SAA7164_UNIT_DIGITAL_DEMODULATOR
,
92 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
93 .i2c_bus_addr
= 0x12 >> 1,
94 .i2c_reg_len
= REGLEN_8bit
,
97 [SAA7164_BOARD_HAUPPAUGE_HVR2200_2
] = {
98 .name
= "Hauppauge WinTV-HVR2200",
99 .porta
= SAA7164_MPEG_DVB
,
100 .portb
= SAA7164_MPEG_DVB
,
101 .portc
= SAA7164_MPEG_ENCODER
,
102 .portd
= SAA7164_MPEG_ENCODER
,
103 .porte
= SAA7164_MPEG_VBI
,
104 .portf
= SAA7164_MPEG_VBI
,
105 .chiprev
= SAA7164_CHIP_REV2
,
108 .type
= SAA7164_UNIT_EEPROM
,
110 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
111 .i2c_bus_addr
= 0xa0 >> 1,
112 .i2c_reg_len
= REGLEN_8bit
,
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
,
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
,
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
,
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
,
143 [SAA7164_BOARD_HAUPPAUGE_HVR2200_3
] = {
144 .name
= "Hauppauge WinTV-HVR2200",
145 .porta
= SAA7164_MPEG_DVB
,
146 .portb
= SAA7164_MPEG_DVB
,
147 .portc
= SAA7164_MPEG_ENCODER
,
148 .portd
= SAA7164_MPEG_ENCODER
,
149 .porte
= SAA7164_MPEG_VBI
,
150 .portf
= SAA7164_MPEG_VBI
,
151 .chiprev
= SAA7164_CHIP_REV2
,
154 .type
= SAA7164_UNIT_EEPROM
,
156 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
157 .i2c_bus_addr
= 0xa0 >> 1,
158 .i2c_reg_len
= REGLEN_8bit
,
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
,
168 .type
= SAA7164_UNIT_ANALOG_DEMODULATOR
,
170 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
171 .i2c_bus_addr
= 0x84 >> 1,
172 .i2c_reg_len
= REGLEN_8bit
,
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
,
182 .type
= SAA7164_UNIT_ANALOG_DEMODULATOR
,
184 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
185 .i2c_bus_addr
= 0x84 >> 1,
186 .i2c_reg_len
= REGLEN_8bit
,
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
,
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
,
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
,
214 .type
= SAA7164_UNIT_EEPROM
,
216 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
217 .i2c_bus_addr
= 0xa0 >> 1,
218 .i2c_reg_len
= REGLEN_8bit
,
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
,
228 .type
= SAA7164_UNIT_ANALOG_DEMODULATOR
,
230 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
231 .i2c_bus_addr
= 0x84 >> 1,
232 .i2c_reg_len
= REGLEN_8bit
,
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
,
242 .type
= SAA7164_UNIT_ANALOG_DEMODULATOR
,
244 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
245 .i2c_bus_addr
= 0x84 >> 1,
246 .i2c_reg_len
= REGLEN_8bit
,
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
,
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
,
263 [SAA7164_BOARD_HAUPPAUGE_HVR2250
] = {
264 .name
= "Hauppauge WinTV-HVR2250",
265 .porta
= SAA7164_MPEG_DVB
,
266 .portb
= SAA7164_MPEG_DVB
,
267 .portc
= SAA7164_MPEG_ENCODER
,
268 .portd
= SAA7164_MPEG_ENCODER
,
269 .porte
= SAA7164_MPEG_VBI
,
270 .portf
= SAA7164_MPEG_VBI
,
271 .chiprev
= SAA7164_CHIP_REV3
,
274 .type
= SAA7164_UNIT_EEPROM
,
276 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
277 .i2c_bus_addr
= 0xa0 >> 1,
278 .i2c_reg_len
= REGLEN_8bit
,
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
,
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
,
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
,
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
,
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
,
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
,
323 [SAA7164_BOARD_HAUPPAUGE_HVR2250_2
] = {
324 .name
= "Hauppauge WinTV-HVR2250",
325 .porta
= SAA7164_MPEG_DVB
,
326 .portb
= SAA7164_MPEG_DVB
,
327 .portc
= SAA7164_MPEG_ENCODER
,
328 .portd
= SAA7164_MPEG_ENCODER
,
329 .porte
= SAA7164_MPEG_VBI
,
330 .portf
= SAA7164_MPEG_VBI
,
331 .chiprev
= SAA7164_CHIP_REV3
,
334 .type
= SAA7164_UNIT_EEPROM
,
336 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
337 .i2c_bus_addr
= 0xa0 >> 1,
338 .i2c_reg_len
= REGLEN_8bit
,
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
,
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
,
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
,
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
,
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
,
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
,
383 [SAA7164_BOARD_HAUPPAUGE_HVR2250_3
] = {
384 .name
= "Hauppauge WinTV-HVR2250",
385 .porta
= SAA7164_MPEG_DVB
,
386 .portb
= SAA7164_MPEG_DVB
,
387 .portc
= SAA7164_MPEG_ENCODER
,
388 .portd
= SAA7164_MPEG_ENCODER
,
389 .porte
= SAA7164_MPEG_VBI
,
390 .portf
= SAA7164_MPEG_VBI
,
391 .chiprev
= SAA7164_CHIP_REV3
,
394 .type
= SAA7164_UNIT_EEPROM
,
396 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
397 .i2c_bus_addr
= 0xa0 >> 1,
398 .i2c_reg_len
= REGLEN_8bit
,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
450 .type
= SAA7164_UNIT_EEPROM
,
452 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
453 .i2c_bus_addr
= 0xa0 >> 1,
454 .i2c_reg_len
= REGLEN_8bit
,
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
,
464 .type
= SAA7164_UNIT_ANALOG_DEMODULATOR
,
466 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
467 .i2c_bus_addr
= 0x84 >> 1,
468 .i2c_reg_len
= REGLEN_8bit
,
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
,
478 .type
= SAA7164_UNIT_ANALOG_DEMODULATOR
,
480 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
481 .i2c_bus_addr
= 0x84 >> 1,
482 .i2c_reg_len
= REGLEN_8bit
,
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
,
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
,
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
,
510 .type
= SAA7164_UNIT_EEPROM
,
512 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
513 .i2c_bus_addr
= 0xa0 >> 1,
514 .i2c_reg_len
= REGLEN_8bit
,
517 .type
= SAA7164_UNIT_TUNER
,
519 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
520 .i2c_bus_addr
= 0xc0 >> 1,
521 .i2c_reg_len
= REGLEN_0bit
,
524 .type
= SAA7164_UNIT_DIGITAL_DEMODULATOR
,
526 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
527 .i2c_bus_addr
= 0xb2 >> 1,
528 .i2c_reg_len
= REGLEN_8bit
,
531 .type
= SAA7164_UNIT_TUNER
,
533 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
534 .i2c_bus_addr
= 0xc0 >> 1,
535 .i2c_reg_len
= REGLEN_0bit
,
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
,
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
,
556 .type
= SAA7164_UNIT_EEPROM
,
558 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
559 .i2c_bus_addr
= 0xa0 >> 1,
560 .i2c_reg_len
= REGLEN_8bit
,
563 .type
= SAA7164_UNIT_TUNER
,
565 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
566 .i2c_bus_addr
= 0xc0 >> 1,
567 .i2c_reg_len
= REGLEN_0bit
,
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
,
577 .type
= SAA7164_UNIT_TUNER
,
579 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
580 .i2c_bus_addr
= 0xc0 >> 1,
581 .i2c_reg_len
= REGLEN_0bit
,
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
,
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
,
602 .type
= SAA7164_UNIT_EEPROM
,
604 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
605 .i2c_bus_addr
= 0xa0 >> 1,
606 .i2c_reg_len
= REGLEN_8bit
,
609 .type
= SAA7164_UNIT_TUNER
,
611 .i2c_bus_nr
= SAA7164_I2C_BUS_0
,
612 .i2c_bus_addr
= 0xc0 >> 1,
613 .i2c_reg_len
= REGLEN_0bit
,
616 .type
= SAA7164_UNIT_DIGITAL_DEMODULATOR
,
618 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
619 .i2c_bus_addr
= 0xc8 >> 1,
620 .i2c_reg_len
= REGLEN_0bit
,
623 .type
= SAA7164_UNIT_TUNER
,
625 .i2c_bus_nr
= SAA7164_I2C_BUS_1
,
626 .i2c_bus_addr
= 0xc0 >> 1,
627 .i2c_reg_len
= REGLEN_0bit
,
630 .type
= SAA7164_UNIT_DIGITAL_DEMODULATOR
,
632 .i2c_bus_nr
= SAA7164_I2C_BUS_2
,
633 .i2c_bus_addr
= 0xcc >> 1,
634 .i2c_reg_len
= REGLEN_0bit
,
638 const unsigned int saa7164_bcount
= ARRAY_SIZE(saa7164_boards
);
640 /* ------------------------------------------------------------------ */
641 /* PCI subsystem IDs */
643 struct saa7164_subid saa7164_subids
[] = {
647 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2250
,
651 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2250
,
655 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2200
,
659 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2200_2
,
663 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2200_3
,
667 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2250_3
,
671 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2250_2
,
675 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2250_2
,
679 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2200_4
,
683 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2200_5
,
687 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2255
,
688 /* Prototype card left here for documenation purposes.
689 .card = SAA7164_BOARD_HAUPPAUGE_HVR2255proto,
694 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2205
,
698 .card
= SAA7164_BOARD_HAUPPAUGE_HVR2205
,
701 const unsigned int saa7164_idcount
= ARRAY_SIZE(saa7164_subids
);
703 void saa7164_card_list(struct saa7164_dev
*dev
)
707 if (0 == dev
->pci
->subsystem_vendor
&&
708 0 == dev
->pci
->subsystem_device
) {
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"
715 dev
->name
, dev
->name
, dev
->name
, dev
->name
, dev
->name
);
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
);
725 printk(KERN_ERR
"%s: Here are valid choices for the card=<n> insmod option:\n",
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
);
733 /* TODO: clean this define up into the -cards.c structs */
734 #define PCIEBRIDGE_UNITID 2
736 void saa7164_gpio_setup(struct saa7164_dev
*dev
)
738 switch (dev
->board
) {
739 case SAA7164_BOARD_HAUPPAUGE_HVR2200
:
740 case SAA7164_BOARD_HAUPPAUGE_HVR2200_2
:
741 case SAA7164_BOARD_HAUPPAUGE_HVR2200_3
:
742 case SAA7164_BOARD_HAUPPAUGE_HVR2200_4
:
743 case SAA7164_BOARD_HAUPPAUGE_HVR2200_5
:
744 case SAA7164_BOARD_HAUPPAUGE_HVR2250
:
745 case SAA7164_BOARD_HAUPPAUGE_HVR2250_2
:
746 case SAA7164_BOARD_HAUPPAUGE_HVR2250_3
:
747 case SAA7164_BOARD_HAUPPAUGE_HVR2255proto
:
748 case SAA7164_BOARD_HAUPPAUGE_HVR2255
:
749 case SAA7164_BOARD_HAUPPAUGE_HVR2205
:
752 GPIO 2: s5h1411 / tda10048-1 demod reset
753 GPIO 3: s5h1411 / tda10048-2 demod reset
754 GPIO 7: IRBlaster Zilog reset
758 * GPIO 2: lgdg3306-1 demod reset
759 * GPIO 3: lgdt3306-2 demod reset
763 * GPIO 2: si2168-1 demod reset
764 * GPIO 3: si2168-2 demod reset
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);
773 saa7164_api_set_gpiobit(dev
, PCIEBRIDGE_UNITID
, 2);
774 saa7164_api_set_gpiobit(dev
, PCIEBRIDGE_UNITID
, 3);
779 static void hauppauge_eeprom(struct saa7164_dev
*dev
, u8
*eeprom_data
)
783 tveeprom_hauppauge_analog(&tv
, eeprom_data
);
785 /* Make sure we support the board model */
788 /* Development board - Limit circulation */
789 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
790 * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
792 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
793 * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
796 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
797 * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
800 /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
801 * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
805 /* WinTV-HVR2200 (PCIe, Retail, full-height)
806 * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
809 /* WinTV-HVR2200 (PCIe, Retail, half-height)
810 * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
813 /* First production board rev B2I6 */
814 /* WinTV-HVR2205 (PCIe, Retail, full-height bracket)
815 * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
818 /* First production board rev B2I6 */
819 /* WinTV-HVR2205 (PCIe, Retail, half-height bracket)
820 * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
823 /* First production board rev B1I6 */
824 /* WinTV-HVR2255 (PCIe, Retail, full-height bracket)
825 * ATSC/QAM (SI2157/LGDT3306) and basic analog, FM */
828 printk(KERN_ERR
"%s: Warning: Unknown Hauppauge model #%d\n",
829 dev
->name
, tv
.model
);
833 printk(KERN_INFO
"%s: Hauppauge eeprom: model=%d\n", dev
->name
,
837 void saa7164_card_setup(struct saa7164_dev
*dev
)
839 static u8 eeprom
[256];
841 if (dev
->i2c_bus
[0].i2c_rc
== 0) {
842 if (saa7164_api_read_eeprom(dev
, &eeprom
[0],
847 switch (dev
->board
) {
848 case SAA7164_BOARD_HAUPPAUGE_HVR2200
:
849 case SAA7164_BOARD_HAUPPAUGE_HVR2200_2
:
850 case SAA7164_BOARD_HAUPPAUGE_HVR2200_3
:
851 case SAA7164_BOARD_HAUPPAUGE_HVR2200_4
:
852 case SAA7164_BOARD_HAUPPAUGE_HVR2200_5
:
853 case SAA7164_BOARD_HAUPPAUGE_HVR2250
:
854 case SAA7164_BOARD_HAUPPAUGE_HVR2250_2
:
855 case SAA7164_BOARD_HAUPPAUGE_HVR2250_3
:
856 case SAA7164_BOARD_HAUPPAUGE_HVR2255proto
:
857 case SAA7164_BOARD_HAUPPAUGE_HVR2255
:
858 case SAA7164_BOARD_HAUPPAUGE_HVR2205
:
859 hauppauge_eeprom(dev
, &eeprom
[0]);
864 /* With most other drivers, the kernel expects to communicate with subdrivers
865 * through i2c. This bridge does not allow that, it does not expose any direct
866 * access to I2C. Instead we have to communicate through the device f/w for
867 * register access to 'processing units'. Each unit has a unique
868 * id, regardless of how the physical implementation occurs across
869 * the three physical i2c busses. The being said if we want leverge of
870 * the existing kernel drivers for tuners and demods we have to 'speak i2c',
871 * to this bridge implements 3 virtual i2c buses. This is a helper function
874 * Description: Translate the kernels notion of an i2c address and bus into
875 * the appropriate unitid.
877 int saa7164_i2caddr_to_unitid(struct saa7164_i2c
*bus
, int addr
)
879 /* For a given bus and i2c device address, return the saa7164 unique
880 * unitid. < 0 on error */
882 struct saa7164_dev
*dev
= bus
->dev
;
883 struct saa7164_unit
*unit
;
886 for (i
= 0; i
< SAA7164_MAX_UNITS
; i
++) {
887 unit
= &saa7164_boards
[dev
->board
].unit
[i
];
889 if (unit
->type
== SAA7164_UNIT_UNDEFINED
)
891 if ((bus
->nr
== unit
->i2c_bus_nr
) &&
892 (addr
== unit
->i2c_bus_addr
))
899 /* The 7164 API needs to know the i2c register length in advance.
900 * this is a helper function. Based on a specific chip addr and bus return the
903 int saa7164_i2caddr_to_reglen(struct saa7164_i2c
*bus
, int addr
)
905 /* For a given bus and i2c device address, return the
906 * saa7164 registry address width. < 0 on error
909 struct saa7164_dev
*dev
= bus
->dev
;
910 struct saa7164_unit
*unit
;
913 for (i
= 0; i
< SAA7164_MAX_UNITS
; i
++) {
914 unit
= &saa7164_boards
[dev
->board
].unit
[i
];
916 if (unit
->type
== SAA7164_UNIT_UNDEFINED
)
919 if ((bus
->nr
== unit
->i2c_bus_nr
) &&
920 (addr
== unit
->i2c_bus_addr
))
921 return unit
->i2c_reg_len
;
926 /* TODO: implement a 'findeeprom' functio like the above and fix any other
927 * eeprom related todo's in -api.c.
930 /* Translate a unitid into a x readable device name, for display purposes. */
931 char *saa7164_unitid_name(struct saa7164_dev
*dev
, u8 unitid
)
933 char *undefed
= "UNDEFINED";
934 char *bridge
= "BRIDGE";
935 struct saa7164_unit
*unit
;
941 for (i
= 0; i
< SAA7164_MAX_UNITS
; i
++) {
942 unit
= &saa7164_boards
[dev
->board
].unit
[i
];
944 if (unit
->type
== SAA7164_UNIT_UNDEFINED
)
947 if (unitid
== unit
->id
)