media: cx23885: Add support for Hauppauge PCIe HVR1265 K4
[sfrench/cifs-2.6.git] / drivers / media / pci / cx23885 / cx23885-cards.c
1 /*
2  *  Driver for the Conexant CX23885 PCIe bridge
3  *
4  *  Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
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.
16  */
17
18 #include "cx23885.h"
19
20 #include <linux/init.h>
21 #include <linux/module.h>
22 #include <linux/pci.h>
23 #include <linux/delay.h>
24 #include <media/drv-intf/cx25840.h>
25 #include <linux/firmware.h>
26 #include <misc/altera.h>
27
28 #include "tuner-xc2028.h"
29 #include "netup-eeprom.h"
30 #include "netup-init.h"
31 #include "altera-ci.h"
32 #include "xc4000.h"
33 #include "xc5000.h"
34 #include "cx23888-ir.h"
35
36 static unsigned int netup_card_rev = 4;
37 module_param(netup_card_rev, int, 0644);
38 MODULE_PARM_DESC(netup_card_rev,
39                 "NetUP Dual DVB-T/C CI card revision");
40 static unsigned int enable_885_ir;
41 module_param(enable_885_ir, int, 0644);
42 MODULE_PARM_DESC(enable_885_ir,
43                  "Enable integrated IR controller for supported\n"
44                  "\t\t    CX2388[57] boards that are wired for it:\n"
45                  "\t\t\tHVR-1250 (reported safe)\n"
46                  "\t\t\tTerraTec Cinergy T PCIe Dual (not well tested, appears to be safe)\n"
47                  "\t\t\tTeVii S470 (reported unsafe)\n"
48                  "\t\t    This can cause an interrupt storm with some cards.\n"
49                  "\t\t    Default: 0 [Disabled]");
50
51 /* ------------------------------------------------------------------ */
52 /* board config info                                                  */
53
54 struct cx23885_board cx23885_boards[] = {
55         [CX23885_BOARD_UNKNOWN] = {
56                 .name           = "UNKNOWN/GENERIC",
57                 /* Ensure safe default for unknown boards */
58                 .clk_freq       = 0,
59                 .input          = {{
60                         .type   = CX23885_VMUX_COMPOSITE1,
61                         .vmux   = 0,
62                 }, {
63                         .type   = CX23885_VMUX_COMPOSITE2,
64                         .vmux   = 1,
65                 }, {
66                         .type   = CX23885_VMUX_COMPOSITE3,
67                         .vmux   = 2,
68                 }, {
69                         .type   = CX23885_VMUX_COMPOSITE4,
70                         .vmux   = 3,
71                 } },
72         },
73         [CX23885_BOARD_HAUPPAUGE_HVR1800lp] = {
74                 .name           = "Hauppauge WinTV-HVR1800lp",
75                 .portc          = CX23885_MPEG_DVB,
76                 .input          = {{
77                         .type   = CX23885_VMUX_TELEVISION,
78                         .vmux   = 0,
79                         .gpio0  = 0xff00,
80                 }, {
81                         .type   = CX23885_VMUX_DEBUG,
82                         .vmux   = 0,
83                         .gpio0  = 0xff01,
84                 }, {
85                         .type   = CX23885_VMUX_COMPOSITE1,
86                         .vmux   = 1,
87                         .gpio0  = 0xff02,
88                 }, {
89                         .type   = CX23885_VMUX_SVIDEO,
90                         .vmux   = 2,
91                         .gpio0  = 0xff02,
92                 } },
93         },
94         [CX23885_BOARD_HAUPPAUGE_HVR1800] = {
95                 .name           = "Hauppauge WinTV-HVR1800",
96                 .porta          = CX23885_ANALOG_VIDEO,
97                 .portb          = CX23885_MPEG_ENCODER,
98                 .portc          = CX23885_MPEG_DVB,
99                 .tuner_type     = TUNER_PHILIPS_TDA8290,
100                 .tuner_addr     = 0x42, /* 0x84 >> 1 */
101                 .tuner_bus      = 1,
102                 .input          = {{
103                         .type   = CX23885_VMUX_TELEVISION,
104                         .vmux   =       CX25840_VIN7_CH3 |
105                                         CX25840_VIN5_CH2 |
106                                         CX25840_VIN2_CH1,
107                         .amux   = CX25840_AUDIO8,
108                         .gpio0  = 0,
109                 }, {
110                         .type   = CX23885_VMUX_COMPOSITE1,
111                         .vmux   =       CX25840_VIN7_CH3 |
112                                         CX25840_VIN4_CH2 |
113                                         CX25840_VIN6_CH1,
114                         .amux   = CX25840_AUDIO7,
115                         .gpio0  = 0,
116                 }, {
117                         .type   = CX23885_VMUX_SVIDEO,
118                         .vmux   =       CX25840_VIN7_CH3 |
119                                         CX25840_VIN4_CH2 |
120                                         CX25840_VIN8_CH1 |
121                                         CX25840_SVIDEO_ON,
122                         .amux   = CX25840_AUDIO7,
123                         .gpio0  = 0,
124                 } },
125         },
126         [CX23885_BOARD_HAUPPAUGE_HVR1250] = {
127                 .name           = "Hauppauge WinTV-HVR1250",
128                 .porta          = CX23885_ANALOG_VIDEO,
129                 .portc          = CX23885_MPEG_DVB,
130 #ifdef MT2131_NO_ANALOG_SUPPORT_YET
131                 .tuner_type     = TUNER_PHILIPS_TDA8290,
132                 .tuner_addr     = 0x42, /* 0x84 >> 1 */
133                 .tuner_bus      = 1,
134 #endif
135                 .force_bff      = 1,
136                 .input          = {{
137 #ifdef MT2131_NO_ANALOG_SUPPORT_YET
138                         .type   = CX23885_VMUX_TELEVISION,
139                         .vmux   =       CX25840_VIN7_CH3 |
140                                         CX25840_VIN5_CH2 |
141                                         CX25840_VIN2_CH1,
142                         .amux   = CX25840_AUDIO8,
143                         .gpio0  = 0xff00,
144                 }, {
145 #endif
146                         .type   = CX23885_VMUX_COMPOSITE1,
147                         .vmux   =       CX25840_VIN7_CH3 |
148                                         CX25840_VIN4_CH2 |
149                                         CX25840_VIN6_CH1,
150                         .amux   = CX25840_AUDIO7,
151                         .gpio0  = 0xff02,
152                 }, {
153                         .type   = CX23885_VMUX_SVIDEO,
154                         .vmux   =       CX25840_VIN7_CH3 |
155                                         CX25840_VIN4_CH2 |
156                                         CX25840_VIN8_CH1 |
157                                         CX25840_SVIDEO_ON,
158                         .amux   = CX25840_AUDIO7,
159                         .gpio0  = 0xff02,
160                 } },
161         },
162         [CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP] = {
163                 .name           = "DViCO FusionHDTV5 Express",
164                 .portb          = CX23885_MPEG_DVB,
165         },
166         [CX23885_BOARD_HAUPPAUGE_HVR1500Q] = {
167                 .name           = "Hauppauge WinTV-HVR1500Q",
168                 .portc          = CX23885_MPEG_DVB,
169         },
170         [CX23885_BOARD_HAUPPAUGE_HVR1500] = {
171                 .name           = "Hauppauge WinTV-HVR1500",
172                 .porta          = CX23885_ANALOG_VIDEO,
173                 .portc          = CX23885_MPEG_DVB,
174                 .tuner_type     = TUNER_XC2028,
175                 .tuner_addr     = 0x61, /* 0xc2 >> 1 */
176                 .input          = {{
177                         .type   = CX23885_VMUX_TELEVISION,
178                         .vmux   =       CX25840_VIN7_CH3 |
179                                         CX25840_VIN5_CH2 |
180                                         CX25840_VIN2_CH1,
181                         .gpio0  = 0,
182                 }, {
183                         .type   = CX23885_VMUX_COMPOSITE1,
184                         .vmux   =       CX25840_VIN7_CH3 |
185                                         CX25840_VIN4_CH2 |
186                                         CX25840_VIN6_CH1,
187                         .gpio0  = 0,
188                 }, {
189                         .type   = CX23885_VMUX_SVIDEO,
190                         .vmux   =       CX25840_VIN7_CH3 |
191                                         CX25840_VIN4_CH2 |
192                                         CX25840_VIN8_CH1 |
193                                         CX25840_SVIDEO_ON,
194                         .gpio0  = 0,
195                 } },
196         },
197         [CX23885_BOARD_HAUPPAUGE_HVR1200] = {
198                 .name           = "Hauppauge WinTV-HVR1200",
199                 .portc          = CX23885_MPEG_DVB,
200         },
201         [CX23885_BOARD_HAUPPAUGE_HVR1700] = {
202                 .name           = "Hauppauge WinTV-HVR1700",
203                 .portc          = CX23885_MPEG_DVB,
204         },
205         [CX23885_BOARD_HAUPPAUGE_HVR1400] = {
206                 .name           = "Hauppauge WinTV-HVR1400",
207                 .portc          = CX23885_MPEG_DVB,
208         },
209         [CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP] = {
210                 .name           = "DViCO FusionHDTV7 Dual Express",
211                 .portb          = CX23885_MPEG_DVB,
212                 .portc          = CX23885_MPEG_DVB,
213         },
214         [CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP] = {
215                 .name           = "DViCO FusionHDTV DVB-T Dual Express",
216                 .portb          = CX23885_MPEG_DVB,
217                 .portc          = CX23885_MPEG_DVB,
218         },
219         [CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H] = {
220                 .name           = "Leadtek Winfast PxDVR3200 H",
221                 .portc          = CX23885_MPEG_DVB,
222         },
223         [CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200] = {
224                 .name           = "Leadtek Winfast PxPVR2200",
225                 .porta          = CX23885_ANALOG_VIDEO,
226                 .tuner_type     = TUNER_XC2028,
227                 .tuner_addr     = 0x61,
228                 .tuner_bus      = 1,
229                 .input          = {{
230                         .type   = CX23885_VMUX_TELEVISION,
231                         .vmux   = CX25840_VIN2_CH1 |
232                                   CX25840_VIN5_CH2,
233                         .amux   = CX25840_AUDIO8,
234                         .gpio0  = 0x704040,
235                 }, {
236                         .type   = CX23885_VMUX_COMPOSITE1,
237                         .vmux   = CX25840_COMPOSITE1,
238                         .amux   = CX25840_AUDIO7,
239                         .gpio0  = 0x704040,
240                 }, {
241                         .type   = CX23885_VMUX_SVIDEO,
242                         .vmux   = CX25840_SVIDEO_LUMA3 |
243                                   CX25840_SVIDEO_CHROMA4,
244                         .amux   = CX25840_AUDIO7,
245                         .gpio0  = 0x704040,
246                 }, {
247                         .type   = CX23885_VMUX_COMPONENT,
248                         .vmux   = CX25840_VIN7_CH1 |
249                                   CX25840_VIN6_CH2 |
250                                   CX25840_VIN8_CH3 |
251                                   CX25840_COMPONENT_ON,
252                         .amux   = CX25840_AUDIO7,
253                         .gpio0  = 0x704040,
254                 } },
255         },
256         [CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000] = {
257                 .name           = "Leadtek Winfast PxDVR3200 H XC4000",
258                 .porta          = CX23885_ANALOG_VIDEO,
259                 .portc          = CX23885_MPEG_DVB,
260                 .tuner_type     = TUNER_XC4000,
261                 .tuner_addr     = 0x61,
262                 .radio_type     = UNSET,
263                 .radio_addr     = ADDR_UNSET,
264                 .input          = {{
265                         .type   = CX23885_VMUX_TELEVISION,
266                         .vmux   = CX25840_VIN2_CH1 |
267                                   CX25840_VIN5_CH2 |
268                                   CX25840_NONE0_CH3,
269                 }, {
270                         .type   = CX23885_VMUX_COMPOSITE1,
271                         .vmux   = CX25840_COMPOSITE1,
272                 }, {
273                         .type   = CX23885_VMUX_SVIDEO,
274                         .vmux   = CX25840_SVIDEO_LUMA3 |
275                                   CX25840_SVIDEO_CHROMA4,
276                 }, {
277                         .type   = CX23885_VMUX_COMPONENT,
278                         .vmux   = CX25840_VIN7_CH1 |
279                                   CX25840_VIN6_CH2 |
280                                   CX25840_VIN8_CH3 |
281                                   CX25840_COMPONENT_ON,
282                 } },
283         },
284         [CX23885_BOARD_COMPRO_VIDEOMATE_E650F] = {
285                 .name           = "Compro VideoMate E650F",
286                 .portc          = CX23885_MPEG_DVB,
287         },
288         [CX23885_BOARD_TBS_6920] = {
289                 .name           = "TurboSight TBS 6920",
290                 .portb          = CX23885_MPEG_DVB,
291         },
292         [CX23885_BOARD_TBS_6980] = {
293                 .name           = "TurboSight TBS 6980",
294                 .portb          = CX23885_MPEG_DVB,
295                 .portc          = CX23885_MPEG_DVB,
296         },
297         [CX23885_BOARD_TBS_6981] = {
298                 .name           = "TurboSight TBS 6981",
299                 .portb          = CX23885_MPEG_DVB,
300                 .portc          = CX23885_MPEG_DVB,
301         },
302         [CX23885_BOARD_TEVII_S470] = {
303                 .name           = "TeVii S470",
304                 .portb          = CX23885_MPEG_DVB,
305         },
306         [CX23885_BOARD_DVBWORLD_2005] = {
307                 .name           = "DVBWorld DVB-S2 2005",
308                 .portb          = CX23885_MPEG_DVB,
309         },
310         [CX23885_BOARD_NETUP_DUAL_DVBS2_CI] = {
311                 .ci_type        = 1,
312                 .name           = "NetUP Dual DVB-S2 CI",
313                 .portb          = CX23885_MPEG_DVB,
314                 .portc          = CX23885_MPEG_DVB,
315         },
316         [CX23885_BOARD_HAUPPAUGE_HVR1270] = {
317                 .name           = "Hauppauge WinTV-HVR1270",
318                 .portc          = CX23885_MPEG_DVB,
319         },
320         [CX23885_BOARD_HAUPPAUGE_HVR1275] = {
321                 .name           = "Hauppauge WinTV-HVR1275",
322                 .portc          = CX23885_MPEG_DVB,
323         },
324         [CX23885_BOARD_HAUPPAUGE_HVR1255] = {
325                 .name           = "Hauppauge WinTV-HVR1255",
326                 .porta          = CX23885_ANALOG_VIDEO,
327                 .portc          = CX23885_MPEG_DVB,
328                 .tuner_type     = TUNER_ABSENT,
329                 .tuner_addr     = 0x42, /* 0x84 >> 1 */
330                 .force_bff      = 1,
331                 .input          = {{
332                         .type   = CX23885_VMUX_TELEVISION,
333                         .vmux   =       CX25840_VIN7_CH3 |
334                                         CX25840_VIN5_CH2 |
335                                         CX25840_VIN2_CH1 |
336                                         CX25840_DIF_ON,
337                         .amux   = CX25840_AUDIO8,
338                 }, {
339                         .type   = CX23885_VMUX_COMPOSITE1,
340                         .vmux   =       CX25840_VIN7_CH3 |
341                                         CX25840_VIN4_CH2 |
342                                         CX25840_VIN6_CH1,
343                         .amux   = CX25840_AUDIO7,
344                 }, {
345                         .type   = CX23885_VMUX_SVIDEO,
346                         .vmux   =       CX25840_VIN7_CH3 |
347                                         CX25840_VIN4_CH2 |
348                                         CX25840_VIN8_CH1 |
349                                         CX25840_SVIDEO_ON,
350                         .amux   = CX25840_AUDIO7,
351                 } },
352         },
353         [CX23885_BOARD_HAUPPAUGE_HVR1255_22111] = {
354                 .name           = "Hauppauge WinTV-HVR1255",
355                 .porta          = CX23885_ANALOG_VIDEO,
356                 .portc          = CX23885_MPEG_DVB,
357                 .tuner_type     = TUNER_ABSENT,
358                 .tuner_addr     = 0x42, /* 0x84 >> 1 */
359                 .force_bff      = 1,
360                 .input          = {{
361                         .type   = CX23885_VMUX_TELEVISION,
362                         .vmux   =       CX25840_VIN7_CH3 |
363                                         CX25840_VIN5_CH2 |
364                                         CX25840_VIN2_CH1 |
365                                         CX25840_DIF_ON,
366                         .amux   = CX25840_AUDIO8,
367                 }, {
368                         .type   = CX23885_VMUX_SVIDEO,
369                         .vmux   =       CX25840_VIN7_CH3 |
370                                         CX25840_VIN4_CH2 |
371                                         CX25840_VIN8_CH1 |
372                                         CX25840_SVIDEO_ON,
373                         .amux   = CX25840_AUDIO7,
374                 } },
375         },
376         [CX23885_BOARD_HAUPPAUGE_HVR1210] = {
377                 .name           = "Hauppauge WinTV-HVR1210",
378                 .portc          = CX23885_MPEG_DVB,
379         },
380         [CX23885_BOARD_MYGICA_X8506] = {
381                 .name           = "Mygica X8506 DMB-TH",
382                 .tuner_type = TUNER_XC5000,
383                 .tuner_addr = 0x61,
384                 .tuner_bus      = 1,
385                 .porta          = CX23885_ANALOG_VIDEO,
386                 .portb          = CX23885_MPEG_DVB,
387                 .input          = {
388                         {
389                                 .type   = CX23885_VMUX_TELEVISION,
390                                 .vmux   = CX25840_COMPOSITE2,
391                         },
392                         {
393                                 .type   = CX23885_VMUX_COMPOSITE1,
394                                 .vmux   = CX25840_COMPOSITE8,
395                         },
396                         {
397                                 .type   = CX23885_VMUX_SVIDEO,
398                                 .vmux   = CX25840_SVIDEO_LUMA3 |
399                                                 CX25840_SVIDEO_CHROMA4,
400                         },
401                         {
402                                 .type   = CX23885_VMUX_COMPONENT,
403                                 .vmux   = CX25840_COMPONENT_ON |
404                                         CX25840_VIN1_CH1 |
405                                         CX25840_VIN6_CH2 |
406                                         CX25840_VIN7_CH3,
407                         },
408                 },
409         },
410         [CX23885_BOARD_MAGICPRO_PROHDTVE2] = {
411                 .name           = "Magic-Pro ProHDTV Extreme 2",
412                 .tuner_type = TUNER_XC5000,
413                 .tuner_addr = 0x61,
414                 .tuner_bus      = 1,
415                 .porta          = CX23885_ANALOG_VIDEO,
416                 .portb          = CX23885_MPEG_DVB,
417                 .input          = {
418                         {
419                                 .type   = CX23885_VMUX_TELEVISION,
420                                 .vmux   = CX25840_COMPOSITE2,
421                         },
422                         {
423                                 .type   = CX23885_VMUX_COMPOSITE1,
424                                 .vmux   = CX25840_COMPOSITE8,
425                         },
426                         {
427                                 .type   = CX23885_VMUX_SVIDEO,
428                                 .vmux   = CX25840_SVIDEO_LUMA3 |
429                                                 CX25840_SVIDEO_CHROMA4,
430                         },
431                         {
432                                 .type   = CX23885_VMUX_COMPONENT,
433                                 .vmux   = CX25840_COMPONENT_ON |
434                                         CX25840_VIN1_CH1 |
435                                         CX25840_VIN6_CH2 |
436                                         CX25840_VIN7_CH3,
437                         },
438                 },
439         },
440         [CX23885_BOARD_HAUPPAUGE_HVR1850] = {
441                 .name           = "Hauppauge WinTV-HVR1850",
442                 .porta          = CX23885_ANALOG_VIDEO,
443                 .portb          = CX23885_MPEG_ENCODER,
444                 .portc          = CX23885_MPEG_DVB,
445                 .tuner_type     = TUNER_ABSENT,
446                 .tuner_addr     = 0x42, /* 0x84 >> 1 */
447                 .force_bff      = 1,
448                 .input          = {{
449                         .type   = CX23885_VMUX_TELEVISION,
450                         .vmux   =       CX25840_VIN7_CH3 |
451                                         CX25840_VIN5_CH2 |
452                                         CX25840_VIN2_CH1 |
453                                         CX25840_DIF_ON,
454                         .amux   = CX25840_AUDIO8,
455                 }, {
456                         .type   = CX23885_VMUX_COMPOSITE1,
457                         .vmux   =       CX25840_VIN7_CH3 |
458                                         CX25840_VIN4_CH2 |
459                                         CX25840_VIN6_CH1,
460                         .amux   = CX25840_AUDIO7,
461                 }, {
462                         .type   = CX23885_VMUX_SVIDEO,
463                         .vmux   =       CX25840_VIN7_CH3 |
464                                         CX25840_VIN4_CH2 |
465                                         CX25840_VIN8_CH1 |
466                                         CX25840_SVIDEO_ON,
467                         .amux   = CX25840_AUDIO7,
468                 } },
469         },
470         [CX23885_BOARD_COMPRO_VIDEOMATE_E800] = {
471                 .name           = "Compro VideoMate E800",
472                 .portc          = CX23885_MPEG_DVB,
473         },
474         [CX23885_BOARD_HAUPPAUGE_HVR1290] = {
475                 .name           = "Hauppauge WinTV-HVR1290",
476                 .portc          = CX23885_MPEG_DVB,
477         },
478         [CX23885_BOARD_MYGICA_X8558PRO] = {
479                 .name           = "Mygica X8558 PRO DMB-TH",
480                 .portb          = CX23885_MPEG_DVB,
481                 .portc          = CX23885_MPEG_DVB,
482         },
483         [CX23885_BOARD_LEADTEK_WINFAST_PXTV1200] = {
484                 .name           = "LEADTEK WinFast PxTV1200",
485                 .porta          = CX23885_ANALOG_VIDEO,
486                 .tuner_type     = TUNER_XC2028,
487                 .tuner_addr     = 0x61,
488                 .tuner_bus      = 1,
489                 .input          = {{
490                         .type   = CX23885_VMUX_TELEVISION,
491                         .vmux   = CX25840_VIN2_CH1 |
492                                   CX25840_VIN5_CH2 |
493                                   CX25840_NONE0_CH3,
494                 }, {
495                         .type   = CX23885_VMUX_COMPOSITE1,
496                         .vmux   = CX25840_COMPOSITE1,
497                 }, {
498                         .type   = CX23885_VMUX_SVIDEO,
499                         .vmux   = CX25840_SVIDEO_LUMA3 |
500                                   CX25840_SVIDEO_CHROMA4,
501                 }, {
502                         .type   = CX23885_VMUX_COMPONENT,
503                         .vmux   = CX25840_VIN7_CH1 |
504                                   CX25840_VIN6_CH2 |
505                                   CX25840_VIN8_CH3 |
506                                   CX25840_COMPONENT_ON,
507                 } },
508         },
509         [CX23885_BOARD_GOTVIEW_X5_3D_HYBRID] = {
510                 .name           = "GoTView X5 3D Hybrid",
511                 .tuner_type     = TUNER_XC5000,
512                 .tuner_addr     = 0x64,
513                 .tuner_bus      = 1,
514                 .porta          = CX23885_ANALOG_VIDEO,
515                 .portb          = CX23885_MPEG_DVB,
516                 .input          = {{
517                         .type   = CX23885_VMUX_TELEVISION,
518                         .vmux   = CX25840_VIN2_CH1 |
519                                   CX25840_VIN5_CH2,
520                         .gpio0  = 0x02,
521                 }, {
522                         .type   = CX23885_VMUX_COMPOSITE1,
523                         .vmux   = CX23885_VMUX_COMPOSITE1,
524                 }, {
525                         .type   = CX23885_VMUX_SVIDEO,
526                         .vmux   = CX25840_SVIDEO_LUMA3 |
527                                   CX25840_SVIDEO_CHROMA4,
528                 } },
529         },
530         [CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF] = {
531                 .ci_type        = 2,
532                 .name           = "NetUP Dual DVB-T/C-CI RF",
533                 .porta          = CX23885_ANALOG_VIDEO,
534                 .portb          = CX23885_MPEG_DVB,
535                 .portc          = CX23885_MPEG_DVB,
536                 .num_fds_portb  = 2,
537                 .num_fds_portc  = 2,
538                 .tuner_type     = TUNER_XC5000,
539                 .tuner_addr     = 0x64,
540                 .input          = { {
541                                 .type   = CX23885_VMUX_TELEVISION,
542                                 .vmux   = CX25840_COMPOSITE1,
543                 } },
544         },
545         [CX23885_BOARD_MPX885] = {
546                 .name           = "MPX-885",
547                 .porta          = CX23885_ANALOG_VIDEO,
548                 .input          = {{
549                         .type   = CX23885_VMUX_COMPOSITE1,
550                         .vmux   = CX25840_COMPOSITE1,
551                         .amux   = CX25840_AUDIO6,
552                         .gpio0  = 0,
553                 }, {
554                         .type   = CX23885_VMUX_COMPOSITE2,
555                         .vmux   = CX25840_COMPOSITE2,
556                         .amux   = CX25840_AUDIO6,
557                         .gpio0  = 0,
558                 }, {
559                         .type   = CX23885_VMUX_COMPOSITE3,
560                         .vmux   = CX25840_COMPOSITE3,
561                         .amux   = CX25840_AUDIO7,
562                         .gpio0  = 0,
563                 }, {
564                         .type   = CX23885_VMUX_COMPOSITE4,
565                         .vmux   = CX25840_COMPOSITE4,
566                         .amux   = CX25840_AUDIO7,
567                         .gpio0  = 0,
568                 } },
569         },
570         [CX23885_BOARD_MYGICA_X8507] = {
571                 .name           = "Mygica X8502/X8507 ISDB-T",
572                 .tuner_type = TUNER_XC5000,
573                 .tuner_addr = 0x61,
574                 .tuner_bus      = 1,
575                 .porta          = CX23885_ANALOG_VIDEO,
576                 .portb          = CX23885_MPEG_DVB,
577                 .input          = {
578                         {
579                                 .type   = CX23885_VMUX_TELEVISION,
580                                 .vmux   = CX25840_COMPOSITE2,
581                                 .amux   = CX25840_AUDIO8,
582                         },
583                         {
584                                 .type   = CX23885_VMUX_COMPOSITE1,
585                                 .vmux   = CX25840_COMPOSITE8,
586                                 .amux   = CX25840_AUDIO7,
587                         },
588                         {
589                                 .type   = CX23885_VMUX_SVIDEO,
590                                 .vmux   = CX25840_SVIDEO_LUMA3 |
591                                                 CX25840_SVIDEO_CHROMA4,
592                                 .amux   = CX25840_AUDIO7,
593                         },
594                         {
595                                 .type   = CX23885_VMUX_COMPONENT,
596                                 .vmux   = CX25840_COMPONENT_ON |
597                                         CX25840_VIN1_CH1 |
598                                         CX25840_VIN6_CH2 |
599                                         CX25840_VIN7_CH3,
600                                 .amux   = CX25840_AUDIO7,
601                         },
602                 },
603         },
604         [CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL] = {
605                 .name           = "TerraTec Cinergy T PCIe Dual",
606                 .portb          = CX23885_MPEG_DVB,
607                 .portc          = CX23885_MPEG_DVB,
608         },
609         [CX23885_BOARD_TEVII_S471] = {
610                 .name           = "TeVii S471",
611                 .portb          = CX23885_MPEG_DVB,
612         },
613         [CX23885_BOARD_PROF_8000] = {
614                 .name           = "Prof Revolution DVB-S2 8000",
615                 .portb          = CX23885_MPEG_DVB,
616         },
617         [CX23885_BOARD_HAUPPAUGE_HVR4400] = {
618                 .name           = "Hauppauge WinTV-HVR4400/HVR5500",
619                 .porta          = CX23885_ANALOG_VIDEO,
620                 .portb          = CX23885_MPEG_DVB,
621                 .portc          = CX23885_MPEG_DVB,
622                 .tuner_type     = TUNER_NXP_TDA18271,
623                 .tuner_addr     = 0x60, /* 0xc0 >> 1 */
624                 .tuner_bus      = 1,
625         },
626         [CX23885_BOARD_HAUPPAUGE_STARBURST] = {
627                 .name           = "Hauppauge WinTV Starburst",
628                 .portb          = CX23885_MPEG_DVB,
629         },
630         [CX23885_BOARD_AVERMEDIA_HC81R] = {
631                 .name           = "AVerTV Hybrid Express Slim HC81R",
632                 .tuner_type     = TUNER_XC2028,
633                 .tuner_addr     = 0x61, /* 0xc2 >> 1 */
634                 .tuner_bus      = 1,
635                 .porta          = CX23885_ANALOG_VIDEO,
636                 .input          = {{
637                         .type   = CX23885_VMUX_TELEVISION,
638                         .vmux   = CX25840_VIN2_CH1 |
639                                   CX25840_VIN5_CH2 |
640                                   CX25840_NONE0_CH3 |
641                                   CX25840_NONE1_CH3,
642                         .amux   = CX25840_AUDIO8,
643                 }, {
644                         .type   = CX23885_VMUX_SVIDEO,
645                         .vmux   = CX25840_VIN8_CH1 |
646                                   CX25840_NONE_CH2 |
647                                   CX25840_VIN7_CH3 |
648                                   CX25840_SVIDEO_ON,
649                         .amux   = CX25840_AUDIO6,
650                 }, {
651                         .type   = CX23885_VMUX_COMPONENT,
652                         .vmux   = CX25840_VIN1_CH1 |
653                                   CX25840_NONE_CH2 |
654                                   CX25840_NONE0_CH3 |
655                                   CX25840_NONE1_CH3,
656                         .amux   = CX25840_AUDIO6,
657                 } },
658         },
659         [CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2] = {
660                 .name           = "DViCO FusionHDTV DVB-T Dual Express2",
661                 .portb          = CX23885_MPEG_DVB,
662                 .portc          = CX23885_MPEG_DVB,
663         },
664         [CX23885_BOARD_HAUPPAUGE_IMPACTVCBE] = {
665                 .name           = "Hauppauge ImpactVCB-e",
666                 .tuner_type     = TUNER_ABSENT,
667                 .porta          = CX23885_ANALOG_VIDEO,
668                 .input          = {{
669                         .type   = CX23885_VMUX_COMPOSITE1,
670                         .vmux   = CX25840_VIN7_CH3 |
671                                   CX25840_VIN4_CH2 |
672                                   CX25840_VIN6_CH1,
673                         .amux   = CX25840_AUDIO7,
674                 }, {
675                         .type   = CX23885_VMUX_SVIDEO,
676                         .vmux   = CX25840_VIN7_CH3 |
677                                   CX25840_VIN4_CH2 |
678                                   CX25840_VIN8_CH1 |
679                                   CX25840_SVIDEO_ON,
680                         .amux   = CX25840_AUDIO7,
681                 } },
682         },
683         [CX23885_BOARD_DVBSKY_T9580] = {
684                 .name           = "DVBSky T9580",
685                 .portb          = CX23885_MPEG_DVB,
686                 .portc          = CX23885_MPEG_DVB,
687         },
688         [CX23885_BOARD_DVBSKY_T980C] = {
689                 .name           = "DVBSky T980C",
690                 .portb          = CX23885_MPEG_DVB,
691         },
692         [CX23885_BOARD_DVBSKY_S950C] = {
693                 .name           = "DVBSky S950C",
694                 .portb          = CX23885_MPEG_DVB,
695         },
696         [CX23885_BOARD_TT_CT2_4500_CI] = {
697                 .name           = "Technotrend TT-budget CT2-4500 CI",
698                 .portb          = CX23885_MPEG_DVB,
699         },
700         [CX23885_BOARD_DVBSKY_S950] = {
701                 .name           = "DVBSky S950",
702                 .portb          = CX23885_MPEG_DVB,
703         },
704         [CX23885_BOARD_DVBSKY_S952] = {
705                 .name           = "DVBSky S952",
706                 .portb          = CX23885_MPEG_DVB,
707                 .portc          = CX23885_MPEG_DVB,
708         },
709         [CX23885_BOARD_DVBSKY_T982] = {
710                 .name           = "DVBSky T982",
711                 .portb          = CX23885_MPEG_DVB,
712                 .portc          = CX23885_MPEG_DVB,
713         },
714         [CX23885_BOARD_HAUPPAUGE_HVR5525] = {
715                 .name           = "Hauppauge WinTV-HVR5525",
716                 .portb          = CX23885_MPEG_DVB,
717                 .portc          = CX23885_MPEG_DVB,
718         },
719         [CX23885_BOARD_VIEWCAST_260E] = {
720                 .name           = "ViewCast 260e",
721                 .porta          = CX23885_ANALOG_VIDEO,
722                 .force_bff      = 1,
723                 .input          = {{
724                         .type   = CX23885_VMUX_COMPOSITE1,
725                         .vmux   = CX25840_VIN6_CH1,
726                         .amux   = CX25840_AUDIO7,
727                 }, {
728                         .type   = CX23885_VMUX_SVIDEO,
729                         .vmux   = CX25840_VIN7_CH3 |
730                                         CX25840_VIN5_CH1 |
731                                         CX25840_SVIDEO_ON,
732                         .amux   = CX25840_AUDIO7,
733                 }, {
734                         .type   = CX23885_VMUX_COMPONENT,
735                         .vmux   = CX25840_VIN7_CH3 |
736                                         CX25840_VIN6_CH2 |
737                                         CX25840_VIN5_CH1 |
738                                         CX25840_COMPONENT_ON,
739                         .amux   = CX25840_AUDIO7,
740                 } },
741         },
742         [CX23885_BOARD_VIEWCAST_460E] = {
743                 .name           = "ViewCast 460e",
744                 .porta          = CX23885_ANALOG_VIDEO,
745                 .force_bff      = 1,
746                 .input          = {{
747                         .type   = CX23885_VMUX_COMPOSITE1,
748                         .vmux   = CX25840_VIN4_CH1,
749                         .amux   = CX25840_AUDIO7,
750                 }, {
751                         .type   = CX23885_VMUX_SVIDEO,
752                         .vmux   = CX25840_VIN7_CH3 |
753                                         CX25840_VIN6_CH1 |
754                                         CX25840_SVIDEO_ON,
755                         .amux   = CX25840_AUDIO7,
756                 }, {
757                         .type   = CX23885_VMUX_COMPONENT,
758                         .vmux   = CX25840_VIN7_CH3 |
759                                         CX25840_VIN6_CH1 |
760                                         CX25840_VIN5_CH2 |
761                                         CX25840_COMPONENT_ON,
762                         .amux   = CX25840_AUDIO7,
763                 }, {
764                         .type   = CX23885_VMUX_COMPOSITE2,
765                         .vmux   = CX25840_VIN6_CH1,
766                         .amux   = CX25840_AUDIO7,
767                 } },
768         },
769         [CX23885_BOARD_HAUPPAUGE_QUADHD_DVB] = {
770                 .name        = "Hauppauge WinTV-QuadHD-DVB",
771                 .portb        = CX23885_MPEG_DVB,
772                 .portc        = CX23885_MPEG_DVB,
773         },
774         [CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC] = {
775                 .name        = "Hauppauge WinTV-QuadHD-ATSC",
776                 .portb        = CX23885_MPEG_DVB,
777                 .portc        = CX23885_MPEG_DVB,
778         },
779         [CX23885_BOARD_HAUPPAUGE_HVR1265_K4] = {
780                 .name           = "Hauppauge WinTV-HVR-1265(161111)",
781                 .portc          = CX23885_MPEG_DVB,
782                 .force_bff      = 1,
783         },
784 };
785 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
786
787 /* ------------------------------------------------------------------ */
788 /* PCI subsystem IDs                                                  */
789
790 struct cx23885_subid cx23885_subids[] = {
791         {
792                 .subvendor = 0x0070,
793                 .subdevice = 0x3400,
794                 .card      = CX23885_BOARD_UNKNOWN,
795         }, {
796                 .subvendor = 0x0070,
797                 .subdevice = 0x7600,
798                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1800lp,
799         }, {
800                 .subvendor = 0x0070,
801                 .subdevice = 0x7800,
802                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1800,
803         }, {
804                 .subvendor = 0x0070,
805                 .subdevice = 0x7801,
806                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1800,
807         }, {
808                 .subvendor = 0x0070,
809                 .subdevice = 0x7809,
810                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1800,
811         }, {
812                 .subvendor = 0x0070,
813                 .subdevice = 0x7911,
814                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1250,
815         }, {
816                 .subvendor = 0x18ac,
817                 .subdevice = 0xd500,
818                 .card      = CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP,
819         }, {
820                 .subvendor = 0x0070,
821                 .subdevice = 0x7790,
822                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
823         }, {
824                 .subvendor = 0x0070,
825                 .subdevice = 0x7797,
826                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1500Q,
827         }, {
828                 .subvendor = 0x0070,
829                 .subdevice = 0x7710,
830                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1500,
831         }, {
832                 .subvendor = 0x0070,
833                 .subdevice = 0x7717,
834                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1500,
835         }, {
836                 .subvendor = 0x0070,
837                 .subdevice = 0x71d1,
838                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1200,
839         }, {
840                 .subvendor = 0x0070,
841                 .subdevice = 0x71d3,
842                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1200,
843         }, {
844                 .subvendor = 0x0070,
845                 .subdevice = 0x8101,
846                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1700,
847         }, {
848                 .subvendor = 0x0070,
849                 .subdevice = 0x8010,
850                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1400,
851         }, {
852                 .subvendor = 0x18ac,
853                 .subdevice = 0xd618,
854                 .card      = CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP,
855         }, {
856                 .subvendor = 0x18ac,
857                 .subdevice = 0xdb78,
858                 .card      = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP,
859         }, {
860                 .subvendor = 0x107d,
861                 .subdevice = 0x6681,
862                 .card      = CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H,
863         }, {
864                 .subvendor = 0x107d,
865                 .subdevice = 0x6f21,
866                 .card      = CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200,
867         }, {
868                 .subvendor = 0x107d,
869                 .subdevice = 0x6f39,
870                 .card      = CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000,
871         }, {
872                 .subvendor = 0x185b,
873                 .subdevice = 0xe800,
874                 .card      = CX23885_BOARD_COMPRO_VIDEOMATE_E650F,
875         }, {
876                 .subvendor = 0x6920,
877                 .subdevice = 0x8888,
878                 .card      = CX23885_BOARD_TBS_6920,
879         }, {
880                 .subvendor = 0x6980,
881                 .subdevice = 0x8888,
882                 .card      = CX23885_BOARD_TBS_6980,
883         }, {
884                 .subvendor = 0x6981,
885                 .subdevice = 0x8888,
886                 .card      = CX23885_BOARD_TBS_6981,
887         }, {
888                 .subvendor = 0xd470,
889                 .subdevice = 0x9022,
890                 .card      = CX23885_BOARD_TEVII_S470,
891         }, {
892                 .subvendor = 0x0001,
893                 .subdevice = 0x2005,
894                 .card      = CX23885_BOARD_DVBWORLD_2005,
895         }, {
896                 .subvendor = 0x1b55,
897                 .subdevice = 0x2a2c,
898                 .card      = CX23885_BOARD_NETUP_DUAL_DVBS2_CI,
899         }, {
900                 .subvendor = 0x0070,
901                 .subdevice = 0x2211,
902                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1270,
903         }, {
904                 .subvendor = 0x0070,
905                 .subdevice = 0x2215,
906                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1275,
907         }, {
908                 .subvendor = 0x0070,
909                 .subdevice = 0x221d,
910                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1275,
911         }, {
912                 .subvendor = 0x0070,
913                 .subdevice = 0x2251,
914                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1255,
915         }, {
916                 .subvendor = 0x0070,
917                 .subdevice = 0x2259,
918                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1255_22111,
919         }, {
920                 .subvendor = 0x0070,
921                 .subdevice = 0x2291,
922                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210,
923         }, {
924                 .subvendor = 0x0070,
925                 .subdevice = 0x2295,
926                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210,
927         }, {
928                 .subvendor = 0x0070,
929                 .subdevice = 0x2299,
930                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210,
931         }, {
932                 .subvendor = 0x0070,
933                 .subdevice = 0x229d,
934                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210, /* HVR1215 */
935         }, {
936                 .subvendor = 0x0070,
937                 .subdevice = 0x22f0,
938                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210,
939         }, {
940                 .subvendor = 0x0070,
941                 .subdevice = 0x22f1,
942                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1255,
943         }, {
944                 .subvendor = 0x0070,
945                 .subdevice = 0x22f2,
946                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1275,
947         }, {
948                 .subvendor = 0x0070,
949                 .subdevice = 0x22f3,
950                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210, /* HVR1215 */
951         }, {
952                 .subvendor = 0x0070,
953                 .subdevice = 0x22f4,
954                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210,
955         }, {
956                 .subvendor = 0x0070,
957                 .subdevice = 0x22f5,
958                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1210, /* HVR1215 */
959         }, {
960                 .subvendor = 0x14f1,
961                 .subdevice = 0x8651,
962                 .card      = CX23885_BOARD_MYGICA_X8506,
963         }, {
964                 .subvendor = 0x14f1,
965                 .subdevice = 0x8657,
966                 .card      = CX23885_BOARD_MAGICPRO_PROHDTVE2,
967         }, {
968                 .subvendor = 0x0070,
969                 .subdevice = 0x8541,
970                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1850,
971         }, {
972                 .subvendor = 0x1858,
973                 .subdevice = 0xe800,
974                 .card      = CX23885_BOARD_COMPRO_VIDEOMATE_E800,
975         }, {
976                 .subvendor = 0x0070,
977                 .subdevice = 0x8551,
978                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1290,
979         }, {
980                 .subvendor = 0x14f1,
981                 .subdevice = 0x8578,
982                 .card      = CX23885_BOARD_MYGICA_X8558PRO,
983         }, {
984                 .subvendor = 0x107d,
985                 .subdevice = 0x6f22,
986                 .card      = CX23885_BOARD_LEADTEK_WINFAST_PXTV1200,
987         }, {
988                 .subvendor = 0x5654,
989                 .subdevice = 0x2390,
990                 .card      = CX23885_BOARD_GOTVIEW_X5_3D_HYBRID,
991         }, {
992                 .subvendor = 0x1b55,
993                 .subdevice = 0xe2e4,
994                 .card      = CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF,
995         }, {
996                 .subvendor = 0x14f1,
997                 .subdevice = 0x8502,
998                 .card      = CX23885_BOARD_MYGICA_X8507,
999         }, {
1000                 .subvendor = 0x153b,
1001                 .subdevice = 0x117e,
1002                 .card      = CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL,
1003         }, {
1004                 .subvendor = 0xd471,
1005                 .subdevice = 0x9022,
1006                 .card      = CX23885_BOARD_TEVII_S471,
1007         }, {
1008                 .subvendor = 0x8000,
1009                 .subdevice = 0x3034,
1010                 .card      = CX23885_BOARD_PROF_8000,
1011         }, {
1012                 .subvendor = 0x0070,
1013                 .subdevice = 0xc108,
1014                 .card      = CX23885_BOARD_HAUPPAUGE_HVR4400, /* Hauppauge WinTV HVR-4400 (Model 121xxx, Hybrid DVB-T/S2, IR) */
1015         }, {
1016                 .subvendor = 0x0070,
1017                 .subdevice = 0xc138,
1018                 .card      = CX23885_BOARD_HAUPPAUGE_HVR4400, /* Hauppauge WinTV HVR-5500 (Model 121xxx, Hybrid DVB-T/C/S2, IR) */
1019         }, {
1020                 .subvendor = 0x0070,
1021                 .subdevice = 0xc12a,
1022                 .card      = CX23885_BOARD_HAUPPAUGE_STARBURST, /* Hauppauge WinTV Starburst (Model 121x00, DVB-S2, IR) */
1023         }, {
1024                 .subvendor = 0x0070,
1025                 .subdevice = 0xc1f8,
1026                 .card      = CX23885_BOARD_HAUPPAUGE_HVR4400, /* Hauppauge WinTV HVR-5500 (Model 121xxx, Hybrid DVB-T/C/S2, IR) */
1027         }, {
1028                 .subvendor = 0x1461,
1029                 .subdevice = 0xd939,
1030                 .card      = CX23885_BOARD_AVERMEDIA_HC81R,
1031         }, {
1032                 .subvendor = 0x0070,
1033                 .subdevice = 0x7133,
1034                 .card      = CX23885_BOARD_HAUPPAUGE_IMPACTVCBE,
1035         }, {
1036                 .subvendor = 0x0070,
1037                 .subdevice = 0x7137,
1038                 .card      = CX23885_BOARD_HAUPPAUGE_IMPACTVCBE,
1039         }, {
1040                 .subvendor = 0x18ac,
1041                 .subdevice = 0xdb98,
1042                 .card      = CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2,
1043         }, {
1044                 .subvendor = 0x4254,
1045                 .subdevice = 0x9580,
1046                 .card      = CX23885_BOARD_DVBSKY_T9580,
1047         }, {
1048                 .subvendor = 0x4254,
1049                 .subdevice = 0x980c,
1050                 .card      = CX23885_BOARD_DVBSKY_T980C,
1051         }, {
1052                 .subvendor = 0x4254,
1053                 .subdevice = 0x950c,
1054                 .card      = CX23885_BOARD_DVBSKY_S950C,
1055         }, {
1056                 .subvendor = 0x13c2,
1057                 .subdevice = 0x3013,
1058                 .card      = CX23885_BOARD_TT_CT2_4500_CI,
1059         }, {
1060                 .subvendor = 0x4254,
1061                 .subdevice = 0x0950,
1062                 .card      = CX23885_BOARD_DVBSKY_S950,
1063         }, {
1064                 .subvendor = 0x4254,
1065                 .subdevice = 0x0952,
1066                 .card      = CX23885_BOARD_DVBSKY_S952,
1067         }, {
1068                 .subvendor = 0x4254,
1069                 .subdevice = 0x0982,
1070                 .card      = CX23885_BOARD_DVBSKY_T982,
1071         }, {
1072                 .subvendor = 0x0070,
1073                 .subdevice = 0xf038,
1074                 .card      = CX23885_BOARD_HAUPPAUGE_HVR5525,
1075         }, {
1076                 .subvendor = 0x1576,
1077                 .subdevice = 0x0260,
1078                 .card      = CX23885_BOARD_VIEWCAST_260E,
1079         }, {
1080                 .subvendor = 0x1576,
1081                 .subdevice = 0x0460,
1082                 .card      = CX23885_BOARD_VIEWCAST_460E,
1083         }, {
1084                 .subvendor = 0x0070,
1085                 .subdevice = 0x6a28,
1086                 .card      = CX23885_BOARD_HAUPPAUGE_QUADHD_DVB, /* Tuner Pair 1 */
1087         }, {
1088                 .subvendor = 0x0070,
1089                 .subdevice = 0x6b28,
1090                 .card      = CX23885_BOARD_HAUPPAUGE_QUADHD_DVB, /* Tuner Pair 2 */
1091         }, {
1092                 .subvendor = 0x0070,
1093                 .subdevice = 0x6a18,
1094                 .card      = CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC, /* Tuner Pair 1 */
1095         }, {
1096                 .subvendor = 0x0070,
1097                 .subdevice = 0x6b18,
1098                 .card      = CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC, /* Tuner Pair 2 */
1099         }, {
1100                 .subvendor = 0x0070,
1101                 .subdevice = 0x2a18,
1102                 .card      = CX23885_BOARD_HAUPPAUGE_HVR1265_K4, /* Hauppauge WinTV HVR-1265 (Model 161xx1, Hybrid ATSC/QAM-B) */
1103         },
1104 };
1105 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
1106
1107 void cx23885_card_list(struct cx23885_dev *dev)
1108 {
1109         int i;
1110
1111         if (0 == dev->pci->subsystem_vendor &&
1112             0 == dev->pci->subsystem_device) {
1113                 pr_info("%s: Board has no valid PCIe Subsystem ID and can't\n"
1114                         "%s: be autodetected. Pass card=<n> insmod option\n"
1115                         "%s: to workaround that. Redirect complaints to the\n"
1116                         "%s: vendor of the TV card.  Best regards,\n"
1117                         "%s:         -- tux\n",
1118                         dev->name, dev->name, dev->name, dev->name, dev->name);
1119         } else {
1120                 pr_info("%s: Your board isn't known (yet) to the driver.\n"
1121                         "%s: Try to pick one of the existing card configs via\n"
1122                         "%s: card=<n> insmod option.  Updating to the latest\n"
1123                         "%s: version might help as well.\n",
1124                         dev->name, dev->name, dev->name, dev->name);
1125         }
1126         pr_info("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
1127                dev->name);
1128         for (i = 0; i < cx23885_bcount; i++)
1129                 pr_info("%s:    card=%d -> %s\n",
1130                         dev->name, i, cx23885_boards[i].name);
1131 }
1132
1133 static void viewcast_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
1134 {
1135         u32 sn;
1136
1137         /* The serial number record begins with tag 0x59 */
1138         if (*(eeprom_data + 0x00) != 0x59) {
1139                 pr_info("%s() eeprom records are undefined, no serial number\n",
1140                         __func__);
1141                 return;
1142         }
1143
1144         sn =    (*(eeprom_data + 0x06) << 24) |
1145                 (*(eeprom_data + 0x05) << 16) |
1146                 (*(eeprom_data + 0x04) << 8) |
1147                 (*(eeprom_data + 0x03));
1148
1149         pr_info("%s: card '%s' sn# MM%d\n",
1150                 dev->name,
1151                 cx23885_boards[dev->board].name,
1152                 sn);
1153 }
1154
1155 static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
1156 {
1157         struct tveeprom tv;
1158
1159         tveeprom_hauppauge_analog(&tv, eeprom_data);
1160
1161         /* Make sure we support the board model */
1162         switch (tv.model) {
1163         case 22001:
1164                 /* WinTV-HVR1270 (PCIe, Retail, half height)
1165                  * ATSC/QAM and basic analog, IR Blast */
1166         case 22009:
1167                 /* WinTV-HVR1210 (PCIe, Retail, half height)
1168                  * DVB-T and basic analog, IR Blast */
1169         case 22011:
1170                 /* WinTV-HVR1270 (PCIe, Retail, half height)
1171                  * ATSC/QAM and basic analog, IR Recv */
1172         case 22019:
1173                 /* WinTV-HVR1210 (PCIe, Retail, half height)
1174                  * DVB-T and basic analog, IR Recv */
1175         case 22021:
1176                 /* WinTV-HVR1275 (PCIe, Retail, half height)
1177                  * ATSC/QAM and basic analog, IR Recv */
1178         case 22029:
1179                 /* WinTV-HVR1210 (PCIe, Retail, half height)
1180                  * DVB-T and basic analog, IR Recv */
1181         case 22101:
1182                 /* WinTV-HVR1270 (PCIe, Retail, full height)
1183                  * ATSC/QAM and basic analog, IR Blast */
1184         case 22109:
1185                 /* WinTV-HVR1210 (PCIe, Retail, full height)
1186                  * DVB-T and basic analog, IR Blast */
1187         case 22111:
1188                 /* WinTV-HVR1270 (PCIe, Retail, full height)
1189                  * ATSC/QAM and basic analog, IR Recv */
1190         case 22119:
1191                 /* WinTV-HVR1210 (PCIe, Retail, full height)
1192                  * DVB-T and basic analog, IR Recv */
1193         case 22121:
1194                 /* WinTV-HVR1275 (PCIe, Retail, full height)
1195                  * ATSC/QAM and basic analog, IR Recv */
1196         case 22129:
1197                 /* WinTV-HVR1210 (PCIe, Retail, full height)
1198                  * DVB-T and basic analog, IR Recv */
1199         case 71009:
1200                 /* WinTV-HVR1200 (PCIe, Retail, full height)
1201                  * DVB-T and basic analog */
1202         case 71100:
1203                 /* WinTV-ImpactVCB-e (PCIe, Retail, half height)
1204                  * Basic analog */
1205         case 71359:
1206                 /* WinTV-HVR1200 (PCIe, OEM, half height)
1207                  * DVB-T and basic analog */
1208         case 71439:
1209                 /* WinTV-HVR1200 (PCIe, OEM, half height)
1210                  * DVB-T and basic analog */
1211         case 71449:
1212                 /* WinTV-HVR1200 (PCIe, OEM, full height)
1213                  * DVB-T and basic analog */
1214         case 71939:
1215                 /* WinTV-HVR1200 (PCIe, OEM, half height)
1216                  * DVB-T and basic analog */
1217         case 71949:
1218                 /* WinTV-HVR1200 (PCIe, OEM, full height)
1219                  * DVB-T and basic analog */
1220         case 71959:
1221                 /* WinTV-HVR1200 (PCIe, OEM, full height)
1222                  * DVB-T and basic analog */
1223         case 71979:
1224                 /* WinTV-HVR1200 (PCIe, OEM, half height)
1225                  * DVB-T and basic analog */
1226         case 71999:
1227                 /* WinTV-HVR1200 (PCIe, OEM, full height)
1228                  * DVB-T and basic analog */
1229         case 76601:
1230                 /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual
1231                         channel ATSC and MPEG2 HW Encoder */
1232         case 77001:
1233                 /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC
1234                         and Basic analog */
1235         case 77011:
1236                 /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC
1237                         and Basic analog */
1238         case 77041:
1239                 /* WinTV-HVR1500Q (Express Card, OEM, No IR, ATSC/QAM
1240                         and Basic analog */
1241         case 77051:
1242                 /* WinTV-HVR1500Q (Express Card, Retail, No IR, ATSC/QAM
1243                         and Basic analog */
1244         case 78011:
1245                 /* WinTV-HVR1800 (PCIe, Retail, 3.5mm in, IR, No FM,
1246                         Dual channel ATSC and MPEG2 HW Encoder */
1247         case 78501:
1248                 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
1249                         Dual channel ATSC and MPEG2 HW Encoder */
1250         case 78521:
1251                 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, FM,
1252                         Dual channel ATSC and MPEG2 HW Encoder */
1253         case 78531:
1254                 /* WinTV-HVR1800 (PCIe, OEM, RCA in, No IR, No FM,
1255                         Dual channel ATSC and MPEG2 HW Encoder */
1256         case 78631:
1257                 /* WinTV-HVR1800 (PCIe, OEM, No IR, No FM,
1258                         Dual channel ATSC and MPEG2 HW Encoder */
1259         case 79001:
1260                 /* WinTV-HVR1250 (PCIe, Retail, IR, full height,
1261                         ATSC and Basic analog */
1262         case 79101:
1263                 /* WinTV-HVR1250 (PCIe, Retail, IR, half height,
1264                         ATSC and Basic analog */
1265         case 79501:
1266                 /* WinTV-HVR1250 (PCIe, No IR, half height,
1267                         ATSC [at least] and Basic analog) */
1268         case 79561:
1269                 /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
1270                         ATSC and Basic analog */
1271         case 79571:
1272                 /* WinTV-HVR1250 (PCIe, OEM, No IR, full height,
1273                  ATSC and Basic analog */
1274         case 79671:
1275                 /* WinTV-HVR1250 (PCIe, OEM, No IR, half height,
1276                         ATSC and Basic analog */
1277         case 80019:
1278                 /* WinTV-HVR1400 (Express Card, Retail, IR,
1279                  * DVB-T and Basic analog */
1280         case 81509:
1281                 /* WinTV-HVR1700 (PCIe, OEM, No IR, half height)
1282                  * DVB-T and MPEG2 HW Encoder */
1283         case 81519:
1284                 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
1285                  * DVB-T and MPEG2 HW Encoder */
1286                 break;
1287         case 85021:
1288                 /* WinTV-HVR1850 (PCIe, Retail, 3.5mm in, IR, FM,
1289                         Dual channel ATSC and MPEG2 HW Encoder */
1290                 break;
1291         case 85721:
1292                 /* WinTV-HVR1290 (PCIe, OEM, RCA in, IR,
1293                         Dual channel ATSC and Basic analog */
1294         case 121019:
1295                 /* WinTV-HVR4400 (PCIe, DVB-S2, DVB-C/T) */
1296                 break;
1297         case 121029:
1298                 /* WinTV-HVR5500 (PCIe, DVB-S2, DVB-C/T) */
1299                 break;
1300         case 150329:
1301                 /* WinTV-HVR5525 (PCIe, DVB-S/S2, DVB-T/T2/C) */
1302                 break;
1303         case 161111:
1304                 /* WinTV-HVR-1265 K4 (PCIe, Analog/ATSC/QAM-B) */
1305                 break;
1306         case 166100:
1307                 /* WinTV-QuadHD (DVB) Tuner Pair 1 (PCIe, IR, half height,
1308                    DVB-T/T2/C, DVB-T/T2/C */
1309                 break;
1310         case 166101:
1311                 /* WinTV-QuadHD (DVB) Tuner Pair 2 (PCIe, IR, half height,
1312                    DVB-T/T2/C, DVB-T/T2/C */
1313                 break;
1314         case 165100:
1315                 /*
1316                  * WinTV-QuadHD (ATSC) Tuner Pair 1 (PCIe, IR, half height,
1317                  * ATSC, ATSC
1318                  */
1319                 break;
1320         case 165101:
1321                 /*
1322                  * WinTV-QuadHD (DVB) Tuner Pair 2 (PCIe, IR, half height,
1323                  * ATSC, ATSC
1324                  */
1325                 break;
1326         default:
1327                 pr_warn("%s: warning: unknown hauppauge model #%d\n",
1328                         dev->name, tv.model);
1329                 break;
1330         }
1331
1332         pr_info("%s: hauppauge eeprom: model=%d\n",
1333                 dev->name, tv.model);
1334 }
1335
1336 /* Some TBS cards require initing a chip using a bitbanged SPI attached
1337    to the cx23885 gpio's. If this chip doesn't get init'ed the demod
1338    doesn't respond to any command. */
1339 static void tbs_card_init(struct cx23885_dev *dev)
1340 {
1341         int i;
1342         static const u8 buf[] = {
1343                 0xe0, 0x06, 0x66, 0x33, 0x65,
1344                 0x01, 0x17, 0x06, 0xde};
1345
1346         switch (dev->board) {
1347         case CX23885_BOARD_TBS_6980:
1348         case CX23885_BOARD_TBS_6981:
1349                 cx_set(GP0_IO, 0x00070007);
1350                 usleep_range(1000, 10000);
1351                 cx_clear(GP0_IO, 2);
1352                 usleep_range(1000, 10000);
1353                 for (i = 0; i < 9 * 8; i++) {
1354                         cx_clear(GP0_IO, 7);
1355                         usleep_range(1000, 10000);
1356                         cx_set(GP0_IO,
1357                                 ((buf[i >> 3] >> (7 - (i & 7))) & 1) | 4);
1358                         usleep_range(1000, 10000);
1359                 }
1360                 cx_set(GP0_IO, 7);
1361                 break;
1362         }
1363 }
1364
1365 int cx23885_tuner_callback(void *priv, int component, int command, int arg)
1366 {
1367         struct cx23885_tsport *port = priv;
1368         struct cx23885_dev *dev = port->dev;
1369         u32 bitmask = 0;
1370
1371         if ((command == XC2028_RESET_CLK) || (command == XC2028_I2C_FLUSH))
1372                 return 0;
1373
1374         if (command != 0) {
1375                 pr_err("%s(): Unknown command 0x%x.\n",
1376                        __func__, command);
1377                 return -EINVAL;
1378         }
1379
1380         switch (dev->board) {
1381         case CX23885_BOARD_HAUPPAUGE_HVR1400:
1382         case CX23885_BOARD_HAUPPAUGE_HVR1500:
1383         case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1384         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
1385         case CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200:
1386         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
1387         case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
1388         case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1389         case CX23885_BOARD_LEADTEK_WINFAST_PXTV1200:
1390                 /* Tuner Reset Command */
1391                 bitmask = 0x04;
1392                 break;
1393         case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
1394         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
1395         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
1396                 /* Two identical tuners on two different i2c buses,
1397                  * we need to reset the correct gpio. */
1398                 if (port->nr == 1)
1399                         bitmask = 0x01;
1400                 else if (port->nr == 2)
1401                         bitmask = 0x04;
1402                 break;
1403         case CX23885_BOARD_GOTVIEW_X5_3D_HYBRID:
1404                 /* Tuner Reset Command */
1405                 bitmask = 0x02;
1406                 break;
1407         case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1408                 altera_ci_tuner_reset(dev, port->nr);
1409                 break;
1410         case CX23885_BOARD_AVERMEDIA_HC81R:
1411                 /* XC3028L Reset Command */
1412                 bitmask = 1 << 2;
1413                 break;
1414         }
1415
1416         if (bitmask) {
1417                 /* Drive the tuner into reset and back out */
1418                 cx_clear(GP0_IO, bitmask);
1419                 mdelay(200);
1420                 cx_set(GP0_IO, bitmask);
1421         }
1422
1423         return 0;
1424 }
1425
1426 void cx23885_gpio_setup(struct cx23885_dev *dev)
1427 {
1428         switch (dev->board) {
1429         case CX23885_BOARD_HAUPPAUGE_HVR1250:
1430                 /* GPIO-0 cx24227 demodulator reset */
1431                 cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
1432                 break;
1433         case CX23885_BOARD_HAUPPAUGE_HVR1500:
1434                 /* GPIO-0 cx24227 demodulator */
1435                 /* GPIO-2 xc3028 tuner */
1436
1437                 /* Put the parts into reset */
1438                 cx_set(GP0_IO, 0x00050000);
1439                 cx_clear(GP0_IO, 0x00000005);
1440                 msleep(5);
1441
1442                 /* Bring the parts out of reset */
1443                 cx_set(GP0_IO, 0x00050005);
1444                 break;
1445         case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1446                 /* GPIO-0 cx24227 demodulator reset */
1447                 /* GPIO-2 xc5000 tuner reset */
1448                 cx_set(GP0_IO, 0x00050005); /* Bring the part out of reset */
1449                 break;
1450         case CX23885_BOARD_HAUPPAUGE_HVR1800:
1451                 /* GPIO-0 656_CLK */
1452                 /* GPIO-1 656_D0 */
1453                 /* GPIO-2 8295A Reset */
1454                 /* GPIO-3-10 cx23417 data0-7 */
1455                 /* GPIO-11-14 cx23417 addr0-3 */
1456                 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
1457                 /* GPIO-19 IR_RX */
1458
1459                 /* CX23417 GPIO's */
1460                 /* EIO15 Zilog Reset */
1461                 /* EIO14 S5H1409/CX24227 Reset */
1462                 mc417_gpio_enable(dev, GPIO_15 | GPIO_14, 1);
1463
1464                 /* Put the demod into reset and protect the eeprom */
1465                 mc417_gpio_clear(dev, GPIO_15 | GPIO_14);
1466                 mdelay(100);
1467
1468                 /* Bring the demod and blaster out of reset */
1469                 mc417_gpio_set(dev, GPIO_15 | GPIO_14);
1470                 mdelay(100);
1471
1472                 /* Force the TDA8295A into reset and back */
1473                 cx23885_gpio_enable(dev, GPIO_2, 1);
1474                 cx23885_gpio_set(dev, GPIO_2);
1475                 mdelay(20);
1476                 cx23885_gpio_clear(dev, GPIO_2);
1477                 mdelay(20);
1478                 cx23885_gpio_set(dev, GPIO_2);
1479                 mdelay(20);
1480                 break;
1481         case CX23885_BOARD_HAUPPAUGE_HVR1200:
1482                 /* GPIO-0 tda10048 demodulator reset */
1483                 /* GPIO-2 tda18271 tuner reset */
1484
1485                 /* Put the parts into reset and back */
1486                 cx_set(GP0_IO, 0x00050000);
1487                 mdelay(20);
1488                 cx_clear(GP0_IO, 0x00000005);
1489                 mdelay(20);
1490                 cx_set(GP0_IO, 0x00050005);
1491                 break;
1492         case CX23885_BOARD_HAUPPAUGE_HVR1700:
1493                 /* GPIO-0 TDA10048 demodulator reset */
1494                 /* GPIO-2 TDA8295A Reset */
1495                 /* GPIO-3-10 cx23417 data0-7 */
1496                 /* GPIO-11-14 cx23417 addr0-3 */
1497                 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
1498
1499                 /* The following GPIO's are on the interna AVCore (cx25840) */
1500                 /* GPIO-19 IR_RX */
1501                 /* GPIO-20 IR_TX 416/DVBT Select */
1502                 /* GPIO-21 IIS DAT */
1503                 /* GPIO-22 IIS WCLK */
1504                 /* GPIO-23 IIS BCLK */
1505
1506                 /* Put the parts into reset and back */
1507                 cx_set(GP0_IO, 0x00050000);
1508                 mdelay(20);
1509                 cx_clear(GP0_IO, 0x00000005);
1510                 mdelay(20);
1511                 cx_set(GP0_IO, 0x00050005);
1512                 break;
1513         case CX23885_BOARD_HAUPPAUGE_HVR1400:
1514                 /* GPIO-0  Dibcom7000p demodulator reset */
1515                 /* GPIO-2  xc3028L tuner reset */
1516                 /* GPIO-13 LED */
1517
1518                 /* Put the parts into reset and back */
1519                 cx_set(GP0_IO, 0x00050000);
1520                 mdelay(20);
1521                 cx_clear(GP0_IO, 0x00000005);
1522                 mdelay(20);
1523                 cx_set(GP0_IO, 0x00050005);
1524                 break;
1525         case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
1526                 /* GPIO-0 xc5000 tuner reset i2c bus 0 */
1527                 /* GPIO-1 s5h1409 demod reset i2c bus 0 */
1528                 /* GPIO-2 xc5000 tuner reset i2c bus 1 */
1529                 /* GPIO-3 s5h1409 demod reset i2c bus 0 */
1530
1531                 /* Put the parts into reset and back */
1532                 cx_set(GP0_IO, 0x000f0000);
1533                 mdelay(20);
1534                 cx_clear(GP0_IO, 0x0000000f);
1535                 mdelay(20);
1536                 cx_set(GP0_IO, 0x000f000f);
1537                 break;
1538         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
1539         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
1540                 /* GPIO-0 portb xc3028 reset */
1541                 /* GPIO-1 portb zl10353 reset */
1542                 /* GPIO-2 portc xc3028 reset */
1543                 /* GPIO-3 portc zl10353 reset */
1544
1545                 /* Put the parts into reset and back */
1546                 cx_set(GP0_IO, 0x000f0000);
1547                 mdelay(20);
1548                 cx_clear(GP0_IO, 0x0000000f);
1549                 mdelay(20);
1550                 cx_set(GP0_IO, 0x000f000f);
1551                 break;
1552         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
1553         case CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200:
1554         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
1555         case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
1556         case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
1557         case CX23885_BOARD_LEADTEK_WINFAST_PXTV1200:
1558                 /* GPIO-2  xc3028 tuner reset */
1559
1560                 /* The following GPIO's are on the internal AVCore (cx25840) */
1561                 /* GPIO-?  zl10353 demod reset */
1562
1563                 /* Put the parts into reset and back */
1564                 cx_set(GP0_IO, 0x00040000);
1565                 mdelay(20);
1566                 cx_clear(GP0_IO, 0x00000004);
1567                 mdelay(20);
1568                 cx_set(GP0_IO, 0x00040004);
1569                 break;
1570         case CX23885_BOARD_TBS_6920:
1571         case CX23885_BOARD_TBS_6980:
1572         case CX23885_BOARD_TBS_6981:
1573         case CX23885_BOARD_PROF_8000:
1574                 cx_write(MC417_CTL, 0x00000036);
1575                 cx_write(MC417_OEN, 0x00001000);
1576                 cx_set(MC417_RWD, 0x00000002);
1577                 mdelay(200);
1578                 cx_clear(MC417_RWD, 0x00000800);
1579                 mdelay(200);
1580                 cx_set(MC417_RWD, 0x00000800);
1581                 mdelay(200);
1582                 break;
1583         case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1584                 /* GPIO-0 INTA from CiMax1
1585                    GPIO-1 INTB from CiMax2
1586                    GPIO-2 reset chips
1587                    GPIO-3 to GPIO-10 data/addr for CA
1588                    GPIO-11 ~CS0 to CiMax1
1589                    GPIO-12 ~CS1 to CiMax2
1590                    GPIO-13 ADL0 load LSB addr
1591                    GPIO-14 ADL1 load MSB addr
1592                    GPIO-15 ~RDY from CiMax
1593                    GPIO-17 ~RD to CiMax
1594                    GPIO-18 ~WR to CiMax
1595                  */
1596                 cx_set(GP0_IO, 0x00040000); /* GPIO as out */
1597                 /* GPIO1 and GPIO2 as INTA and INTB from CiMaxes, reset low */
1598                 cx_clear(GP0_IO, 0x00030004);
1599                 mdelay(100);/* reset delay */
1600                 cx_set(GP0_IO, 0x00040004); /* GPIO as out, reset high */
1601                 cx_write(MC417_CTL, 0x00000037);/* enable GPIO3-18 pins */
1602                 /* GPIO-15 IN as ~ACK, rest as OUT */
1603                 cx_write(MC417_OEN, 0x00001000);
1604                 /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */
1605                 cx_write(MC417_RWD, 0x0000c300);
1606                 /* enable irq */
1607                 cx_write(GPIO_ISM, 0x00000000);/* INTERRUPTS active low*/
1608                 break;
1609         case CX23885_BOARD_HAUPPAUGE_HVR1270:
1610         case CX23885_BOARD_HAUPPAUGE_HVR1275:
1611         case CX23885_BOARD_HAUPPAUGE_HVR1255:
1612         case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1613         case CX23885_BOARD_HAUPPAUGE_HVR1210:
1614                 /* GPIO-5 RF Control: 0 = RF1 Terrestrial, 1 = RF2 Cable */
1615                 /* GPIO-6 I2C Gate which can isolate the demod from the bus */
1616                 /* GPIO-9 Demod reset */
1617
1618                 /* Put the parts into reset and back */
1619                 cx23885_gpio_enable(dev, GPIO_9 | GPIO_6 | GPIO_5, 1);
1620                 cx23885_gpio_set(dev, GPIO_9 | GPIO_6 | GPIO_5);
1621                 cx23885_gpio_clear(dev, GPIO_9);
1622                 mdelay(20);
1623                 cx23885_gpio_set(dev, GPIO_9);
1624                 break;
1625         case CX23885_BOARD_MYGICA_X8506:
1626         case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1627         case CX23885_BOARD_MYGICA_X8507:
1628                 /* GPIO-0 (0)Analog / (1)Digital TV */
1629                 /* GPIO-1 reset XC5000 */
1630                 /* GPIO-2 demod reset */
1631                 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1 | GPIO_2, 1);
1632                 cx23885_gpio_clear(dev, GPIO_1 | GPIO_2);
1633                 mdelay(100);
1634                 cx23885_gpio_set(dev, GPIO_0 | GPIO_1 | GPIO_2);
1635                 mdelay(100);
1636                 break;
1637         case CX23885_BOARD_MYGICA_X8558PRO:
1638                 /* GPIO-0 reset first ATBM8830 */
1639                 /* GPIO-1 reset second ATBM8830 */
1640                 cx23885_gpio_enable(dev, GPIO_0 | GPIO_1, 1);
1641                 cx23885_gpio_clear(dev, GPIO_0 | GPIO_1);
1642                 mdelay(100);
1643                 cx23885_gpio_set(dev, GPIO_0 | GPIO_1);
1644                 mdelay(100);
1645                 break;
1646         case CX23885_BOARD_HAUPPAUGE_HVR1850:
1647         case CX23885_BOARD_HAUPPAUGE_HVR1290:
1648                 /* GPIO-0 656_CLK */
1649                 /* GPIO-1 656_D0 */
1650                 /* GPIO-2 Wake# */
1651                 /* GPIO-3-10 cx23417 data0-7 */
1652                 /* GPIO-11-14 cx23417 addr0-3 */
1653                 /* GPIO-15-18 cx23417 READY, CS, RD, WR */
1654                 /* GPIO-19 IR_RX */
1655                 /* GPIO-20 C_IR_TX */
1656                 /* GPIO-21 I2S DAT */
1657                 /* GPIO-22 I2S WCLK */
1658                 /* GPIO-23 I2S BCLK */
1659                 /* ALT GPIO: EXP GPIO LATCH */
1660
1661                 /* CX23417 GPIO's */
1662                 /* GPIO-14 S5H1411/CX24228 Reset */
1663                 /* GPIO-13 EEPROM write protect */
1664                 mc417_gpio_enable(dev, GPIO_14 | GPIO_13, 1);
1665
1666                 /* Put the demod into reset and protect the eeprom */
1667                 mc417_gpio_clear(dev, GPIO_14 | GPIO_13);
1668                 mdelay(100);
1669
1670                 /* Bring the demod out of reset */
1671                 mc417_gpio_set(dev, GPIO_14);
1672                 mdelay(100);
1673
1674                 /* CX24228 GPIO */
1675                 /* Connected to IF / Mux */
1676                 break;
1677         case CX23885_BOARD_GOTVIEW_X5_3D_HYBRID:
1678                 cx_set(GP0_IO, 0x00010001); /* Bring the part out of reset */
1679                 break;
1680         case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1681                 /* GPIO-0 ~INT in
1682                    GPIO-1 TMS out
1683                    GPIO-2 ~reset chips out
1684                    GPIO-3 to GPIO-10 data/addr for CA in/out
1685                    GPIO-11 ~CS out
1686                    GPIO-12 ADDR out
1687                    GPIO-13 ~WR out
1688                    GPIO-14 ~RD out
1689                    GPIO-15 ~RDY in
1690                    GPIO-16 TCK out
1691                    GPIO-17 TDO in
1692                    GPIO-18 TDI out
1693                  */
1694                 cx_set(GP0_IO, 0x00060000); /* GPIO-1,2 as out */
1695                 /* GPIO-0 as INT, reset & TMS low */
1696                 cx_clear(GP0_IO, 0x00010006);
1697                 mdelay(100);/* reset delay */
1698                 cx_set(GP0_IO, 0x00000004); /* reset high */
1699                 cx_write(MC417_CTL, 0x00000037);/* enable GPIO-3..18 pins */
1700                 /* GPIO-17 is TDO in, GPIO-15 is ~RDY in, rest is out */
1701                 cx_write(MC417_OEN, 0x00005000);
1702                 /* ~RD, ~WR high; ADDR low; ~CS high */
1703                 cx_write(MC417_RWD, 0x00000d00);
1704                 /* enable irq */
1705                 cx_write(GPIO_ISM, 0x00000000);/* INTERRUPTS active low*/
1706                 break;
1707         case CX23885_BOARD_HAUPPAUGE_HVR4400:
1708         case CX23885_BOARD_HAUPPAUGE_STARBURST:
1709                 /* GPIO-8 tda10071 demod reset */
1710                 /* GPIO-9 si2165 demod reset (only HVR4400/HVR5500)*/
1711
1712                 /* Put the parts into reset and back */
1713                 cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1);
1714
1715                 cx23885_gpio_clear(dev, GPIO_8 | GPIO_9);
1716                 mdelay(100);
1717                 cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
1718                 mdelay(100);
1719
1720                 break;
1721         case CX23885_BOARD_AVERMEDIA_HC81R:
1722                 cx_clear(MC417_CTL, 1);
1723                 /* GPIO-0,1,2 setup direction as output */
1724                 cx_set(GP0_IO, 0x00070000);
1725                 mdelay(10);
1726                 /* AF9013 demod reset */
1727                 cx_set(GP0_IO, 0x00010001);
1728                 mdelay(10);
1729                 cx_clear(GP0_IO, 0x00010001);
1730                 mdelay(10);
1731                 cx_set(GP0_IO, 0x00010001);
1732                 mdelay(10);
1733                 /* demod tune? */
1734                 cx_clear(GP0_IO, 0x00030003);
1735                 mdelay(10);
1736                 cx_set(GP0_IO, 0x00020002);
1737                 mdelay(10);
1738                 cx_set(GP0_IO, 0x00010001);
1739                 mdelay(10);
1740                 cx_clear(GP0_IO, 0x00020002);
1741                 /* XC3028L tuner reset */
1742                 cx_set(GP0_IO, 0x00040004);
1743                 cx_clear(GP0_IO, 0x00040004);
1744                 cx_set(GP0_IO, 0x00040004);
1745                 mdelay(60);
1746                 break;
1747         case CX23885_BOARD_DVBSKY_T9580:
1748         case CX23885_BOARD_DVBSKY_S952:
1749         case CX23885_BOARD_DVBSKY_T982:
1750                 /* enable GPIO3-18 pins */
1751                 cx_write(MC417_CTL, 0x00000037);
1752                 cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1);
1753                 cx23885_gpio_clear(dev, GPIO_2 | GPIO_11);
1754                 mdelay(100);
1755                 cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
1756                 break;
1757         case CX23885_BOARD_DVBSKY_T980C:
1758         case CX23885_BOARD_DVBSKY_S950C:
1759         case CX23885_BOARD_TT_CT2_4500_CI:
1760                 /*
1761                  * GPIO-0 INTA from CiMax, input
1762                  * GPIO-1 reset CiMax, output, high active
1763                  * GPIO-2 reset demod, output, low active
1764                  * GPIO-3 to GPIO-10 data/addr for CAM
1765                  * GPIO-11 ~CS0 to CiMax1
1766                  * GPIO-12 ~CS1 to CiMax2
1767                  * GPIO-13 ADL0 load LSB addr
1768                  * GPIO-14 ADL1 load MSB addr
1769                  * GPIO-15 ~RDY from CiMax
1770                  * GPIO-17 ~RD to CiMax
1771                  * GPIO-18 ~WR to CiMax
1772                  */
1773
1774                 cx_set(GP0_IO, 0x00060002); /* GPIO 1/2 as output */
1775                 cx_clear(GP0_IO, 0x00010004); /* GPIO 0 as input */
1776                 mdelay(100); /* reset delay */
1777                 cx_set(GP0_IO, 0x00060004); /* GPIO as out, reset high */
1778                 cx_clear(GP0_IO, 0x00010002);
1779                 cx_write(MC417_CTL, 0x00000037); /* enable GPIO3-18 pins */
1780
1781                 /* GPIO-15 IN as ~ACK, rest as OUT */
1782                 cx_write(MC417_OEN, 0x00001000);
1783
1784                 /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */
1785                 cx_write(MC417_RWD, 0x0000c300);
1786
1787                 /* enable irq */
1788                 cx_write(GPIO_ISM, 0x00000000); /* INTERRUPTS active low */
1789                 break;
1790         case CX23885_BOARD_DVBSKY_S950:
1791                 cx23885_gpio_enable(dev, GPIO_2, 1);
1792                 cx23885_gpio_clear(dev, GPIO_2);
1793                 msleep(100);
1794                 cx23885_gpio_set(dev, GPIO_2);
1795                 break;
1796         case CX23885_BOARD_HAUPPAUGE_HVR5525:
1797         case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
1798         case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC:
1799                 /*
1800                  * HVR5525 GPIO Details:
1801                  *  GPIO-00 IR_WIDE
1802                  *  GPIO-02 wake#
1803                  *  GPIO-03 VAUX Pres.
1804                  *  GPIO-07 PROG#
1805                  *  GPIO-08 SAT_RESN
1806                  *  GPIO-09 TER_RESN
1807                  *  GPIO-10 B2_SENSE
1808                  *  GPIO-11 B1_SENSE
1809                  *  GPIO-15 IR_LED_STATUS
1810                  *  GPIO-19 IR_NARROW
1811                  *  GPIO-20 Blauster1
1812                  *  ALTGPIO VAUX_SWITCH
1813                  *  AUX_PLL_CLK : Blaster2
1814                  */
1815                 /* Put the parts into reset and back */
1816                 cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1);
1817                 cx23885_gpio_clear(dev, GPIO_8 | GPIO_9);
1818                 msleep(100);
1819                 cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
1820                 msleep(100);
1821                 break;
1822         case CX23885_BOARD_VIEWCAST_260E:
1823         case CX23885_BOARD_VIEWCAST_460E:
1824                 /* For documentation purposes, it's worth noting that this
1825                  * card does not have any GPIO's connected to subcomponents.
1826                  */
1827                 break;
1828         case CX23885_BOARD_HAUPPAUGE_HVR1265_K4:
1829                 /*
1830                  * GPIO-08 TER1_RESN
1831                  * GPIO-09 TER2_RESN
1832                  */
1833                 /* Put the parts into reset and back */
1834                 cx23885_gpio_enable(dev, GPIO_8 | GPIO_9, 1);
1835                 cx23885_gpio_clear(dev, GPIO_8 | GPIO_9);
1836                 msleep(100);
1837                 cx23885_gpio_set(dev, GPIO_8 | GPIO_9);
1838                 msleep(100);
1839                 break;
1840         }
1841 }
1842
1843 int cx23885_ir_init(struct cx23885_dev *dev)
1844 {
1845         static struct v4l2_subdev_io_pin_config ir_rxtx_pin_cfg[] = {
1846                 {
1847                         .flags    = BIT(V4L2_SUBDEV_IO_PIN_INPUT),
1848                         .pin      = CX23885_PIN_IR_RX_GPIO19,
1849                         .function = CX23885_PAD_IR_RX,
1850                         .value    = 0,
1851                         .strength = CX25840_PIN_DRIVE_MEDIUM,
1852                 }, {
1853                         .flags    = BIT(V4L2_SUBDEV_IO_PIN_OUTPUT),
1854                         .pin      = CX23885_PIN_IR_TX_GPIO20,
1855                         .function = CX23885_PAD_IR_TX,
1856                         .value    = 0,
1857                         .strength = CX25840_PIN_DRIVE_MEDIUM,
1858                 }
1859         };
1860         const size_t ir_rxtx_pin_cfg_count = ARRAY_SIZE(ir_rxtx_pin_cfg);
1861
1862         static struct v4l2_subdev_io_pin_config ir_rx_pin_cfg[] = {
1863                 {
1864                         .flags    = BIT(V4L2_SUBDEV_IO_PIN_INPUT),
1865                         .pin      = CX23885_PIN_IR_RX_GPIO19,
1866                         .function = CX23885_PAD_IR_RX,
1867                         .value    = 0,
1868                         .strength = CX25840_PIN_DRIVE_MEDIUM,
1869                 }
1870         };
1871         const size_t ir_rx_pin_cfg_count = ARRAY_SIZE(ir_rx_pin_cfg);
1872
1873         struct v4l2_subdev_ir_parameters params;
1874         int ret = 0;
1875         switch (dev->board) {
1876         case CX23885_BOARD_HAUPPAUGE_HVR1500:
1877         case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1878         case CX23885_BOARD_HAUPPAUGE_HVR1800:
1879         case CX23885_BOARD_HAUPPAUGE_HVR1200:
1880         case CX23885_BOARD_HAUPPAUGE_HVR1400:
1881         case CX23885_BOARD_HAUPPAUGE_HVR1275:
1882         case CX23885_BOARD_HAUPPAUGE_HVR1255:
1883         case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
1884         case CX23885_BOARD_HAUPPAUGE_HVR1210:
1885         case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
1886         case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC:
1887                 /* FIXME: Implement me */
1888                 break;
1889         case CX23885_BOARD_HAUPPAUGE_HVR1270:
1890                 ret = cx23888_ir_probe(dev);
1891                 if (ret)
1892                         break;
1893                 dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_888_IR);
1894                 v4l2_subdev_call(dev->sd_cx25840, core, s_io_pin_config,
1895                                  ir_rx_pin_cfg_count, ir_rx_pin_cfg);
1896                 break;
1897         case CX23885_BOARD_HAUPPAUGE_HVR1850:
1898         case CX23885_BOARD_HAUPPAUGE_HVR1290:
1899                 ret = cx23888_ir_probe(dev);
1900                 if (ret)
1901                         break;
1902                 dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_888_IR);
1903                 v4l2_subdev_call(dev->sd_cx25840, core, s_io_pin_config,
1904                                  ir_rxtx_pin_cfg_count, ir_rxtx_pin_cfg);
1905                 /*
1906                  * For these boards we need to invert the Tx output via the
1907                  * IR controller to have the LED off while idle
1908                  */
1909                 v4l2_subdev_call(dev->sd_ir, ir, tx_g_parameters, &params);
1910                 params.enable = false;
1911                 params.shutdown = false;
1912                 params.invert_level = true;
1913                 v4l2_subdev_call(dev->sd_ir, ir, tx_s_parameters, &params);
1914                 params.shutdown = true;
1915                 v4l2_subdev_call(dev->sd_ir, ir, tx_s_parameters, &params);
1916                 break;
1917         case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1918         case CX23885_BOARD_TEVII_S470:
1919         case CX23885_BOARD_MYGICA_X8507:
1920         case CX23885_BOARD_TBS_6980:
1921         case CX23885_BOARD_TBS_6981:
1922         case CX23885_BOARD_DVBSKY_T9580:
1923         case CX23885_BOARD_DVBSKY_T980C:
1924         case CX23885_BOARD_DVBSKY_S950C:
1925         case CX23885_BOARD_TT_CT2_4500_CI:
1926         case CX23885_BOARD_DVBSKY_S950:
1927         case CX23885_BOARD_DVBSKY_S952:
1928         case CX23885_BOARD_DVBSKY_T982:
1929                 if (!enable_885_ir)
1930                         break;
1931                 dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
1932                 if (dev->sd_ir == NULL) {
1933                         ret = -ENODEV;
1934                         break;
1935                 }
1936                 v4l2_subdev_call(dev->sd_cx25840, core, s_io_pin_config,
1937                                  ir_rx_pin_cfg_count, ir_rx_pin_cfg);
1938                 break;
1939         case CX23885_BOARD_HAUPPAUGE_HVR1250:
1940                 if (!enable_885_ir)
1941                         break;
1942                 dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
1943                 if (dev->sd_ir == NULL) {
1944                         ret = -ENODEV;
1945                         break;
1946                 }
1947                 v4l2_subdev_call(dev->sd_cx25840, core, s_io_pin_config,
1948                                  ir_rxtx_pin_cfg_count, ir_rxtx_pin_cfg);
1949                 break;
1950         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
1951         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
1952                 request_module("ir-kbd-i2c");
1953                 break;
1954         }
1955
1956         return ret;
1957 }
1958
1959 void cx23885_ir_fini(struct cx23885_dev *dev)
1960 {
1961         switch (dev->board) {
1962         case CX23885_BOARD_HAUPPAUGE_HVR1270:
1963         case CX23885_BOARD_HAUPPAUGE_HVR1850:
1964         case CX23885_BOARD_HAUPPAUGE_HVR1290:
1965                 cx23885_irq_remove(dev, PCI_MSK_IR);
1966                 cx23888_ir_remove(dev);
1967                 dev->sd_ir = NULL;
1968                 break;
1969         case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1970         case CX23885_BOARD_TEVII_S470:
1971         case CX23885_BOARD_HAUPPAUGE_HVR1250:
1972         case CX23885_BOARD_MYGICA_X8507:
1973         case CX23885_BOARD_TBS_6980:
1974         case CX23885_BOARD_TBS_6981:
1975         case CX23885_BOARD_DVBSKY_T9580:
1976         case CX23885_BOARD_DVBSKY_T980C:
1977         case CX23885_BOARD_DVBSKY_S950C:
1978         case CX23885_BOARD_TT_CT2_4500_CI:
1979         case CX23885_BOARD_DVBSKY_S950:
1980         case CX23885_BOARD_DVBSKY_S952:
1981         case CX23885_BOARD_DVBSKY_T982:
1982                 cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
1983                 /* sd_ir is a duplicate pointer to the AV Core, just clear it */
1984                 dev->sd_ir = NULL;
1985                 break;
1986         }
1987 }
1988
1989 static int netup_jtag_io(void *device, int tms, int tdi, int read_tdo)
1990 {
1991         int data;
1992         int tdo = 0;
1993         struct cx23885_dev *dev = (struct cx23885_dev *)device;
1994         /*TMS*/
1995         data = ((cx_read(GP0_IO)) & (~0x00000002));
1996         data |= (tms ? 0x00020002 : 0x00020000);
1997         cx_write(GP0_IO, data);
1998
1999         /*TDI*/
2000         data = ((cx_read(MC417_RWD)) & (~0x0000a000));
2001         data |= (tdi ? 0x00008000 : 0);
2002         cx_write(MC417_RWD, data);
2003         if (read_tdo)
2004                 tdo = (data & 0x00004000) ? 1 : 0; /*TDO*/
2005
2006         cx_write(MC417_RWD, data | 0x00002000);
2007         udelay(1);
2008         /*TCK*/
2009         cx_write(MC417_RWD, data);
2010
2011         return tdo;
2012 }
2013
2014 void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
2015 {
2016         switch (dev->board) {
2017         case CX23885_BOARD_HAUPPAUGE_HVR1270:
2018         case CX23885_BOARD_HAUPPAUGE_HVR1850:
2019         case CX23885_BOARD_HAUPPAUGE_HVR1290:
2020                 if (dev->sd_ir)
2021                         cx23885_irq_add_enable(dev, PCI_MSK_IR);
2022                 break;
2023         case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
2024         case CX23885_BOARD_TEVII_S470:
2025         case CX23885_BOARD_HAUPPAUGE_HVR1250:
2026         case CX23885_BOARD_MYGICA_X8507:
2027         case CX23885_BOARD_TBS_6980:
2028         case CX23885_BOARD_TBS_6981:
2029         case CX23885_BOARD_DVBSKY_T9580:
2030         case CX23885_BOARD_DVBSKY_T980C:
2031         case CX23885_BOARD_DVBSKY_S950C:
2032         case CX23885_BOARD_TT_CT2_4500_CI:
2033         case CX23885_BOARD_DVBSKY_S950:
2034         case CX23885_BOARD_DVBSKY_S952:
2035         case CX23885_BOARD_DVBSKY_T982:
2036                 if (dev->sd_ir)
2037                         cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
2038                 break;
2039         }
2040 }
2041
2042 void cx23885_card_setup(struct cx23885_dev *dev)
2043 {
2044         struct cx23885_tsport *ts1 = &dev->ts1;
2045         struct cx23885_tsport *ts2 = &dev->ts2;
2046
2047         static u8 eeprom[256];
2048
2049         if (dev->i2c_bus[0].i2c_rc == 0) {
2050                 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
2051                 tveeprom_read(&dev->i2c_bus[0].i2c_client,
2052                               eeprom, sizeof(eeprom));
2053         }
2054
2055         switch (dev->board) {
2056         case CX23885_BOARD_HAUPPAUGE_HVR1250:
2057                 if (dev->i2c_bus[0].i2c_rc == 0) {
2058                         if (eeprom[0x80] != 0x84)
2059                                 hauppauge_eeprom(dev, eeprom+0xc0);
2060                         else
2061                                 hauppauge_eeprom(dev, eeprom+0x80);
2062                 }
2063                 break;
2064         case CX23885_BOARD_HAUPPAUGE_HVR1500:
2065         case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
2066         case CX23885_BOARD_HAUPPAUGE_HVR1400:
2067                 if (dev->i2c_bus[0].i2c_rc == 0)
2068                         hauppauge_eeprom(dev, eeprom+0x80);
2069                 break;
2070         case CX23885_BOARD_HAUPPAUGE_HVR1800:
2071         case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
2072         case CX23885_BOARD_HAUPPAUGE_HVR1200:
2073         case CX23885_BOARD_HAUPPAUGE_HVR1700:
2074         case CX23885_BOARD_HAUPPAUGE_HVR1270:
2075         case CX23885_BOARD_HAUPPAUGE_HVR1275:
2076         case CX23885_BOARD_HAUPPAUGE_HVR1255:
2077         case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
2078         case CX23885_BOARD_HAUPPAUGE_HVR1210:
2079         case CX23885_BOARD_HAUPPAUGE_HVR1850:
2080         case CX23885_BOARD_HAUPPAUGE_HVR1290:
2081         case CX23885_BOARD_HAUPPAUGE_HVR4400:
2082         case CX23885_BOARD_HAUPPAUGE_STARBURST:
2083         case CX23885_BOARD_HAUPPAUGE_IMPACTVCBE:
2084         case CX23885_BOARD_HAUPPAUGE_HVR5525:
2085         case CX23885_BOARD_HAUPPAUGE_HVR1265_K4:
2086         case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
2087         case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC:
2088                 if (dev->i2c_bus[0].i2c_rc == 0)
2089                         hauppauge_eeprom(dev, eeprom+0xc0);
2090                 break;
2091         case CX23885_BOARD_VIEWCAST_260E:
2092         case CX23885_BOARD_VIEWCAST_460E:
2093                 dev->i2c_bus[1].i2c_client.addr = 0xa0 >> 1;
2094                 tveeprom_read(&dev->i2c_bus[1].i2c_client,
2095                               eeprom, sizeof(eeprom));
2096                 if (dev->i2c_bus[0].i2c_rc == 0)
2097                         viewcast_eeprom(dev, eeprom);
2098                 break;
2099         }
2100
2101         switch (dev->board) {
2102         case CX23885_BOARD_AVERMEDIA_HC81R:
2103                 /* Defaults for VID B */
2104                 ts1->gen_ctrl_val  = 0x4; /* Parallel */
2105                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2106                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2107                 /* Defaults for VID C */
2108                 /* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */
2109                 ts2->gen_ctrl_val  = 0x10e;
2110                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2111                 ts2->src_sel_val     = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2112                 break;
2113         case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
2114         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
2115         case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2:
2116                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2117                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2118                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2119                 /* fall-through */
2120         case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
2121                 ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2122                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2123                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2124                 break;
2125         case CX23885_BOARD_HAUPPAUGE_HVR1850:
2126         case CX23885_BOARD_HAUPPAUGE_HVR1800:
2127                 /* Defaults for VID B - Analog encoder */
2128                 /* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */
2129                 ts1->gen_ctrl_val    = 0x10e;
2130                 ts1->ts_clk_en_val   = 0x1; /* Enable TS_CLK */
2131                 ts1->src_sel_val     = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2132
2133                 /* APB_TSVALERR_POL (active low)*/
2134                 ts1->vld_misc_val    = 0x2000;
2135                 ts1->hw_sop_ctrl_val = (0x47 << 16 | 188 << 4 | 0xc);
2136                 cx_write(0x130184, 0xc);
2137
2138                 /* Defaults for VID C */
2139                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2140                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2141                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2142                 break;
2143         case CX23885_BOARD_TBS_6920:
2144                 ts1->gen_ctrl_val  = 0x4; /* Parallel */
2145                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2146                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2147                 break;
2148         case CX23885_BOARD_TEVII_S470:
2149         case CX23885_BOARD_TEVII_S471:
2150         case CX23885_BOARD_DVBWORLD_2005:
2151         case CX23885_BOARD_PROF_8000:
2152         case CX23885_BOARD_DVBSKY_T980C:
2153         case CX23885_BOARD_DVBSKY_S950C:
2154         case CX23885_BOARD_TT_CT2_4500_CI:
2155         case CX23885_BOARD_DVBSKY_S950:
2156                 ts1->gen_ctrl_val  = 0x5; /* Parallel */
2157                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2158                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2159                 break;
2160         case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2161         case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2162         case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
2163                 ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2164                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2165                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2166                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2167                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2168                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2169                 break;
2170         case CX23885_BOARD_TBS_6980:
2171         case CX23885_BOARD_TBS_6981:
2172                 ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2173                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2174                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2175                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2176                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2177                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2178                 tbs_card_init(dev);
2179                 break;
2180         case CX23885_BOARD_MYGICA_X8506:
2181         case CX23885_BOARD_MAGICPRO_PROHDTVE2:
2182         case CX23885_BOARD_MYGICA_X8507:
2183                 ts1->gen_ctrl_val  = 0x5; /* Parallel */
2184                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2185                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2186                 break;
2187         case CX23885_BOARD_MYGICA_X8558PRO:
2188                 ts1->gen_ctrl_val  = 0x5; /* Parallel */
2189                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2190                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2191                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2192                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2193                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2194                 break;
2195         case CX23885_BOARD_HAUPPAUGE_HVR4400:
2196                 ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2197                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2198                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2199                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2200                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2201                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2202                 break;
2203         case CX23885_BOARD_HAUPPAUGE_STARBURST:
2204                 ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2205                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2206                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2207                 break;
2208         case CX23885_BOARD_DVBSKY_T9580:
2209         case CX23885_BOARD_DVBSKY_T982:
2210                 ts1->gen_ctrl_val  = 0x5; /* Parallel */
2211                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2212                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2213                 ts2->gen_ctrl_val  = 0x8; /* Serial bus */
2214                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2215                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2216                 break;
2217         case CX23885_BOARD_DVBSKY_S952:
2218                 ts1->gen_ctrl_val  = 0x5; /* Parallel */
2219                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2220                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2221                 ts2->gen_ctrl_val  = 0xe; /* Serial bus */
2222                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2223                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2224                 break;
2225         case CX23885_BOARD_HAUPPAUGE_HVR5525:
2226                 ts1->gen_ctrl_val  = 0x5; /* Parallel */
2227                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2228                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2229                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2230                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2231                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2232                 break;
2233         case CX23885_BOARD_HAUPPAUGE_HVR1265_K4:
2234         case CX23885_BOARD_HAUPPAUGE_QUADHD_DVB:
2235         case CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC:
2236                 ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2237                 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2238                 ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2239                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2240                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2241                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2242                 break;
2243         case CX23885_BOARD_HAUPPAUGE_HVR1250:
2244         case CX23885_BOARD_HAUPPAUGE_HVR1500:
2245         case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
2246         case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
2247         case CX23885_BOARD_HAUPPAUGE_HVR1200:
2248         case CX23885_BOARD_HAUPPAUGE_HVR1700:
2249         case CX23885_BOARD_HAUPPAUGE_HVR1400:
2250         case CX23885_BOARD_HAUPPAUGE_IMPACTVCBE:
2251         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
2252         case CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200:
2253         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
2254         case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
2255         case CX23885_BOARD_HAUPPAUGE_HVR1270:
2256         case CX23885_BOARD_HAUPPAUGE_HVR1275:
2257         case CX23885_BOARD_HAUPPAUGE_HVR1255:
2258         case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
2259         case CX23885_BOARD_HAUPPAUGE_HVR1210:
2260         case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
2261         case CX23885_BOARD_HAUPPAUGE_HVR1290:
2262         case CX23885_BOARD_GOTVIEW_X5_3D_HYBRID:
2263         default:
2264                 ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
2265                 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
2266                 ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
2267         }
2268
2269         /* Certain boards support analog, or require the avcore to be
2270          * loaded, ensure this happens.
2271          */
2272         switch (dev->board) {
2273         case CX23885_BOARD_TEVII_S470:
2274                 /* Currently only enabled for the integrated IR controller */
2275                 if (!enable_885_ir)
2276                         break;
2277                 /* fall-through */
2278         case CX23885_BOARD_HAUPPAUGE_HVR1250:
2279         case CX23885_BOARD_HAUPPAUGE_HVR1800:
2280         case CX23885_BOARD_HAUPPAUGE_IMPACTVCBE:
2281         case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
2282         case CX23885_BOARD_HAUPPAUGE_HVR1700:
2283         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
2284         case CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200:
2285         case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
2286         case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
2287         case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2288         case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
2289         case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
2290         case CX23885_BOARD_HAUPPAUGE_HVR1255:
2291         case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
2292         case CX23885_BOARD_HAUPPAUGE_HVR1265_K4:
2293         case CX23885_BOARD_HAUPPAUGE_HVR1270:
2294         case CX23885_BOARD_HAUPPAUGE_HVR1850:
2295         case CX23885_BOARD_MYGICA_X8506:
2296         case CX23885_BOARD_MAGICPRO_PROHDTVE2:
2297         case CX23885_BOARD_HAUPPAUGE_HVR1290:
2298         case CX23885_BOARD_LEADTEK_WINFAST_PXTV1200:
2299         case CX23885_BOARD_GOTVIEW_X5_3D_HYBRID:
2300         case CX23885_BOARD_HAUPPAUGE_HVR1500:
2301         case CX23885_BOARD_MPX885:
2302         case CX23885_BOARD_MYGICA_X8507:
2303         case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
2304         case CX23885_BOARD_AVERMEDIA_HC81R:
2305         case CX23885_BOARD_TBS_6980:
2306         case CX23885_BOARD_TBS_6981:
2307         case CX23885_BOARD_DVBSKY_T9580:
2308         case CX23885_BOARD_DVBSKY_T980C:
2309         case CX23885_BOARD_DVBSKY_S950C:
2310         case CX23885_BOARD_TT_CT2_4500_CI:
2311         case CX23885_BOARD_DVBSKY_S950:
2312         case CX23885_BOARD_DVBSKY_S952:
2313         case CX23885_BOARD_DVBSKY_T982:
2314         case CX23885_BOARD_VIEWCAST_260E:
2315         case CX23885_BOARD_VIEWCAST_460E:
2316                 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
2317                                 &dev->i2c_bus[2].i2c_adap,
2318                                 "cx25840", 0x88 >> 1, NULL);
2319                 if (dev->sd_cx25840) {
2320                         dev->sd_cx25840->grp_id = CX23885_HW_AV_CORE;
2321                         v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
2322                 }
2323                 break;
2324         }
2325
2326         switch (dev->board) {
2327         case CX23885_BOARD_VIEWCAST_260E:
2328                 v4l2_i2c_new_subdev(&dev->v4l2_dev,
2329                                 &dev->i2c_bus[0].i2c_adap,
2330                                 "cs3308", 0x82 >> 1, NULL);
2331                 break;
2332         case CX23885_BOARD_VIEWCAST_460E:
2333                 /* This cs3308 controls the audio from the breakout cable */
2334                 v4l2_i2c_new_subdev(&dev->v4l2_dev,
2335                                 &dev->i2c_bus[0].i2c_adap,
2336                                 "cs3308", 0x80 >> 1, NULL);
2337                 /* This cs3308 controls the audio from the onboard header */
2338                 v4l2_i2c_new_subdev(&dev->v4l2_dev,
2339                                 &dev->i2c_bus[0].i2c_adap,
2340                                 "cs3308", 0x82 >> 1, NULL);
2341                 break;
2342         }
2343
2344         /* AUX-PLL 27MHz CLK */
2345         switch (dev->board) {
2346         case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
2347                 netup_initialize(dev);
2348                 break;
2349         case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
2350                 int ret;
2351                 const struct firmware *fw;
2352                 const char *filename = "dvb-netup-altera-01.fw";
2353                 char *action = "configure";
2354                 static struct netup_card_info cinfo;
2355                 struct altera_config netup_config = {
2356                         .dev = dev,
2357                         .action = action,
2358                         .jtag_io = netup_jtag_io,
2359                 };
2360
2361                 netup_initialize(dev);
2362
2363                 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
2364                 if (netup_card_rev)
2365                         cinfo.rev = netup_card_rev;
2366
2367                 switch (cinfo.rev) {
2368                 case 0x4:
2369                         filename = "dvb-netup-altera-04.fw";
2370                         break;
2371                 default:
2372                         filename = "dvb-netup-altera-01.fw";
2373                         break;
2374                 }
2375                 pr_info("NetUP card rev=0x%x fw_filename=%s\n",
2376                         cinfo.rev, filename);
2377
2378                 ret = request_firmware(&fw, filename, &dev->pci->dev);
2379                 if (ret != 0)
2380                         pr_err("did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems.",
2381                                filename);
2382                 else
2383                         altera_init(&netup_config, fw);
2384
2385                 release_firmware(fw);
2386                 break;
2387         }
2388         }
2389 }