f220fa2e10d83b5d0e69a8d43c85cff033e8df49
[linux-2.6.git] / drivers / media / video / cx88 / cx88-cards.c
1 /*
2  *
3  * device driver for Conexant 2388x based TV cards
4  * card-specific stuff.
5  *
6  * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include <linux/init.h>
24 #include <linux/module.h>
25 #include <linux/pci.h>
26 #include <linux/delay.h>
27 #include <linux/slab.h>
28
29 #include "cx88.h"
30 #include "tea5767.h"
31
32 static unsigned int tuner[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
33 static unsigned int radio[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
34 static unsigned int card[]  = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
35
36 module_param_array(tuner, int, NULL, 0444);
37 module_param_array(radio, int, NULL, 0444);
38 module_param_array(card,  int, NULL, 0444);
39
40 MODULE_PARM_DESC(tuner,"tuner type");
41 MODULE_PARM_DESC(radio,"radio tuner type");
42 MODULE_PARM_DESC(card,"card type");
43
44 static unsigned int latency = UNSET;
45 module_param(latency,int,0444);
46 MODULE_PARM_DESC(latency,"pci latency timer");
47
48 static int disable_ir;
49 module_param(disable_ir, int, 0444);
50 MODULE_PARM_DESC(latency, "Disable IR support");
51
52 #define info_printk(core, fmt, arg...) \
53         printk(KERN_INFO "%s: " fmt, core->name , ## arg)
54
55 #define warn_printk(core, fmt, arg...) \
56         printk(KERN_WARNING "%s: " fmt, core->name , ## arg)
57
58 #define err_printk(core, fmt, arg...) \
59         printk(KERN_ERR "%s: " fmt, core->name , ## arg)
60
61
62 /* ------------------------------------------------------------------ */
63 /* board config info                                                  */
64
65 /* If radio_type !=UNSET, radio_addr should be specified
66  */
67
68 static const struct cx88_board cx88_boards[] = {
69         [CX88_BOARD_UNKNOWN] = {
70                 .name           = "UNKNOWN/GENERIC",
71                 .tuner_type     = UNSET,
72                 .radio_type     = UNSET,
73                 .tuner_addr     = ADDR_UNSET,
74                 .radio_addr     = ADDR_UNSET,
75                 .input          = {{
76                         .type   = CX88_VMUX_COMPOSITE1,
77                         .vmux   = 0,
78                 },{
79                         .type   = CX88_VMUX_COMPOSITE2,
80                         .vmux   = 1,
81                 },{
82                         .type   = CX88_VMUX_COMPOSITE3,
83                         .vmux   = 2,
84                 },{
85                         .type   = CX88_VMUX_COMPOSITE4,
86                         .vmux   = 3,
87                 }},
88         },
89         [CX88_BOARD_HAUPPAUGE] = {
90                 .name           = "Hauppauge WinTV 34xxx models",
91                 .tuner_type     = UNSET,
92                 .radio_type     = UNSET,
93                 .tuner_addr     = ADDR_UNSET,
94                 .radio_addr     = ADDR_UNSET,
95                 .tda9887_conf   = TDA9887_PRESENT,
96                 .input          = {{
97                         .type   = CX88_VMUX_TELEVISION,
98                         .vmux   = 0,
99                         .gpio0  = 0xff00,  // internal decoder
100                 },{
101                         .type   = CX88_VMUX_DEBUG,
102                         .vmux   = 0,
103                         .gpio0  = 0xff01,  // mono from tuner chip
104                 },{
105                         .type   = CX88_VMUX_COMPOSITE1,
106                         .vmux   = 1,
107                         .gpio0  = 0xff02,
108                 },{
109                         .type   = CX88_VMUX_SVIDEO,
110                         .vmux   = 2,
111                         .gpio0  = 0xff02,
112                 }},
113                 .radio = {
114                         .type   = CX88_RADIO,
115                         .gpio0  = 0xff01,
116                 },
117         },
118         [CX88_BOARD_GDI] = {
119                 .name           = "GDI Black Gold",
120                 .tuner_type     = UNSET,
121                 .radio_type     = UNSET,
122                 .tuner_addr     = ADDR_UNSET,
123                 .radio_addr     = ADDR_UNSET,
124                 .input          = {{
125                         .type   = CX88_VMUX_TELEVISION,
126                         .vmux   = 0,
127                 },{
128                         .type   = CX88_VMUX_SVIDEO,
129                         .vmux   = 2,
130                 }},
131         },
132         [CX88_BOARD_PIXELVIEW] = {
133                 .name           = "PixelView",
134                 .tuner_type     = TUNER_PHILIPS_PAL,
135                 .radio_type     = UNSET,
136                 .tuner_addr     = ADDR_UNSET,
137                 .radio_addr     = ADDR_UNSET,
138                 .input          = {{
139                         .type   = CX88_VMUX_TELEVISION,
140                         .vmux   = 0,
141                         .gpio0  = 0xff00,  // internal decoder
142                 },{
143                         .type   = CX88_VMUX_COMPOSITE1,
144                         .vmux   = 1,
145                 },{
146                         .type   = CX88_VMUX_SVIDEO,
147                         .vmux   = 2,
148                 }},
149                 .radio = {
150                          .type  = CX88_RADIO,
151                          .gpio0 = 0xff10,
152                 },
153         },
154         [CX88_BOARD_ATI_WONDER_PRO] = {
155                 .name           = "ATI TV Wonder Pro",
156                 .tuner_type     = TUNER_PHILIPS_4IN1,
157                 .radio_type     = UNSET,
158                 .tuner_addr     = ADDR_UNSET,
159                 .radio_addr     = ADDR_UNSET,
160                 .tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER,
161                 .input          = {{
162                         .type   = CX88_VMUX_TELEVISION,
163                         .vmux   = 0,
164                         .gpio0  = 0x03ff,
165                 },{
166                         .type   = CX88_VMUX_COMPOSITE1,
167                         .vmux   = 1,
168                         .gpio0  = 0x03fe,
169                 },{
170                         .type   = CX88_VMUX_SVIDEO,
171                         .vmux   = 2,
172                         .gpio0  = 0x03fe,
173                 }},
174         },
175         [CX88_BOARD_WINFAST2000XP_EXPERT] = {
176                 .name           = "Leadtek Winfast 2000XP Expert",
177                 .tuner_type     = TUNER_PHILIPS_4IN1,
178                 .radio_type     = UNSET,
179                 .tuner_addr     = ADDR_UNSET,
180                 .radio_addr     = ADDR_UNSET,
181                 .tda9887_conf   = TDA9887_PRESENT,
182                 .input          = {{
183                         .type   = CX88_VMUX_TELEVISION,
184                         .vmux   = 0,
185                         .gpio0  = 0x00F5e700,
186                         .gpio1  = 0x00003004,
187                         .gpio2  = 0x00F5e700,
188                         .gpio3  = 0x02000000,
189                 },{
190                         .type   = CX88_VMUX_COMPOSITE1,
191                         .vmux   = 1,
192                         .gpio0  = 0x00F5c700,
193                         .gpio1  = 0x00003004,
194                         .gpio2  = 0x00F5c700,
195                         .gpio3  = 0x02000000,
196                 },{
197                         .type   = CX88_VMUX_SVIDEO,
198                         .vmux   = 2,
199                         .gpio0  = 0x00F5c700,
200                         .gpio1  = 0x00003004,
201                         .gpio2  = 0x00F5c700,
202                         .gpio3  = 0x02000000,
203                 }},
204                 .radio = {
205                         .type   = CX88_RADIO,
206                         .gpio0  = 0x00F5d700,
207                         .gpio1  = 0x00003004,
208                         .gpio2  = 0x00F5d700,
209                         .gpio3  = 0x02000000,
210                 },
211         },
212         [CX88_BOARD_AVERTV_STUDIO_303] = {
213                 .name           = "AverTV Studio 303 (M126)",
214                 .tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
215                 .radio_type     = UNSET,
216                 .tuner_addr     = ADDR_UNSET,
217                 .radio_addr     = ADDR_UNSET,
218                 .tda9887_conf   = TDA9887_PRESENT,
219                 .input          = {{
220                         .type   = CX88_VMUX_TELEVISION,
221                         .vmux   = 0,
222                         .gpio1  = 0xe09f,
223                 },{
224                         .type   = CX88_VMUX_COMPOSITE1,
225                         .vmux   = 1,
226                         .gpio1  = 0xe05f,
227                 },{
228                         .type   = CX88_VMUX_SVIDEO,
229                         .vmux   = 2,
230                         .gpio1  = 0xe05f,
231                 }},
232                 .radio = {
233                         .gpio1  = 0xe0df,
234                         .type   = CX88_RADIO,
235                 },
236         },
237         [CX88_BOARD_MSI_TVANYWHERE_MASTER] = {
238                 // added gpio values thanks to Michal
239                 // values for PAL from DScaler
240                 .name           = "MSI TV-@nywhere Master",
241                 .tuner_type     = TUNER_MT2032,
242                 .radio_type     = UNSET,
243                 .tuner_addr     = ADDR_UNSET,
244                 .radio_addr     = ADDR_UNSET,
245                 .tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER_NTSC,
246                 .input          = {{
247                         .type   = CX88_VMUX_TELEVISION,
248                         .vmux   = 0,
249                         .gpio0  = 0x000040bf,
250                         .gpio1  = 0x000080c0,
251                         .gpio2  = 0x0000ff40,
252                 },{
253                         .type   = CX88_VMUX_COMPOSITE1,
254                         .vmux   = 1,
255                         .gpio0  = 0x000040bf,
256                         .gpio1  = 0x000080c0,
257                         .gpio2  = 0x0000ff40,
258                 },{
259                         .type   = CX88_VMUX_SVIDEO,
260                         .vmux   = 2,
261                         .gpio0  = 0x000040bf,
262                         .gpio1  = 0x000080c0,
263                         .gpio2  = 0x0000ff40,
264                 }},
265                 .radio = {
266                          .type   = CX88_RADIO,
267                          .vmux   = 3,
268                          .gpio0  = 0x000040bf,
269                          .gpio1  = 0x000080c0,
270                          .gpio2  = 0x0000ff20,
271                 },
272         },
273         [CX88_BOARD_WINFAST_DV2000] = {
274                 .name           = "Leadtek Winfast DV2000",
275                 .tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
276                 .radio_type     = UNSET,
277                 .tuner_addr     = ADDR_UNSET,
278                 .radio_addr     = ADDR_UNSET,
279                 .tda9887_conf   = TDA9887_PRESENT,
280                 .input          = {{
281                         .type   = CX88_VMUX_TELEVISION,
282                         .vmux   = 0,
283                         .gpio0  = 0x0035e700,
284                         .gpio1  = 0x00003004,
285                         .gpio2  = 0x0035e700,
286                         .gpio3  = 0x02000000,
287                 },{
288
289                         .type   = CX88_VMUX_COMPOSITE1,
290                         .vmux   = 1,
291                         .gpio0  = 0x0035c700,
292                         .gpio1  = 0x00003004,
293                         .gpio2  = 0x0035c700,
294                         .gpio3  = 0x02000000,
295                 },{
296                         .type   = CX88_VMUX_SVIDEO,
297                         .vmux   = 2,
298                         .gpio0  = 0x0035c700,
299                         .gpio1  = 0x0035c700,
300                         .gpio2  = 0x02000000,
301                         .gpio3  = 0x02000000,
302                 }},
303                 .radio = {
304                         .type   = CX88_RADIO,
305                         .gpio0  = 0x0035d700,
306                         .gpio1  = 0x00007004,
307                         .gpio2  = 0x0035d700,
308                         .gpio3  = 0x02000000,
309                 },
310         },
311         [CX88_BOARD_LEADTEK_PVR2000] = {
312                 // gpio values for PAL version from regspy by DScaler
313                 .name           = "Leadtek PVR 2000",
314                 .tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
315                 .radio_type     = UNSET,
316                 .tuner_addr     = ADDR_UNSET,
317                 .radio_addr     = ADDR_UNSET,
318                 .tda9887_conf   = TDA9887_PRESENT,
319                 .input          = {{
320                         .type   = CX88_VMUX_TELEVISION,
321                         .vmux   = 0,
322                         .gpio0  = 0x0000bde2,
323                         .audioroute = 1,
324                 },{
325                         .type   = CX88_VMUX_COMPOSITE1,
326                         .vmux   = 1,
327                         .gpio0  = 0x0000bde6,
328                         .audioroute = 1,
329                 },{
330                         .type   = CX88_VMUX_SVIDEO,
331                         .vmux   = 2,
332                         .gpio0  = 0x0000bde6,
333                         .audioroute = 1,
334                 }},
335                 .radio = {
336                         .type   = CX88_RADIO,
337                         .gpio0  = 0x0000bd62,
338                         .audioroute = 1,
339                 },
340                 .mpeg           = CX88_MPEG_BLACKBIRD,
341         },
342         [CX88_BOARD_IODATA_GVVCP3PCI] = {
343                 .name           = "IODATA GV-VCP3/PCI",
344                 .tuner_type     = TUNER_ABSENT,
345                 .radio_type     = UNSET,
346                 .tuner_addr     = ADDR_UNSET,
347                 .radio_addr     = ADDR_UNSET,
348                 .input          = {{
349                         .type   = CX88_VMUX_COMPOSITE1,
350                         .vmux   = 0,
351                 },{
352                         .type   = CX88_VMUX_COMPOSITE2,
353                         .vmux   = 1,
354                 },{
355                         .type   = CX88_VMUX_SVIDEO,
356                         .vmux   = 2,
357                 }},
358         },
359         [CX88_BOARD_PROLINK_PLAYTVPVR] = {
360                 .name           = "Prolink PlayTV PVR",
361                 .tuner_type     = TUNER_PHILIPS_FM1236_MK3,
362                 .radio_type     = UNSET,
363                 .tuner_addr     = ADDR_UNSET,
364                 .radio_addr     = ADDR_UNSET,
365                 .tda9887_conf   = TDA9887_PRESENT,
366                 .input          = {{
367                         .type   = CX88_VMUX_TELEVISION,
368                         .vmux   = 0,
369                         .gpio0  = 0xbff0,
370                 },{
371                         .type   = CX88_VMUX_COMPOSITE1,
372                         .vmux   = 1,
373                         .gpio0  = 0xbff3,
374                 },{
375                         .type   = CX88_VMUX_SVIDEO,
376                         .vmux   = 2,
377                         .gpio0  = 0xbff3,
378                 }},
379                 .radio = {
380                         .type   = CX88_RADIO,
381                         .gpio0  = 0xbff0,
382                 },
383         },
384         [CX88_BOARD_ASUS_PVR_416] = {
385                 .name           = "ASUS PVR-416",
386                 .tuner_type     = TUNER_PHILIPS_FM1236_MK3,
387                 .radio_type     = UNSET,
388                 .tuner_addr     = ADDR_UNSET,
389                 .radio_addr     = ADDR_UNSET,
390                 .tda9887_conf   = TDA9887_PRESENT,
391                 .input          = {{
392                         .type   = CX88_VMUX_TELEVISION,
393                         .vmux   = 0,
394                         .gpio0  = 0x0000fde6,
395                 },{
396                         .type   = CX88_VMUX_SVIDEO,
397                         .vmux   = 2,
398                         .gpio0  = 0x0000fde6, // 0x0000fda6 L,R RCA audio in?
399                         .audioroute = 1,
400                 }},
401                 .radio = {
402                         .type   = CX88_RADIO,
403                         .gpio0  = 0x0000fde2,
404                 },
405                 .mpeg           = CX88_MPEG_BLACKBIRD,
406         },
407         [CX88_BOARD_MSI_TVANYWHERE] = {
408                 .name           = "MSI TV-@nywhere",
409                 .tuner_type     = TUNER_MT2032,
410                 .radio_type     = UNSET,
411                 .tuner_addr     = ADDR_UNSET,
412                 .radio_addr     = ADDR_UNSET,
413                 .tda9887_conf   = TDA9887_PRESENT,
414                 .input          = {{
415                         .type   = CX88_VMUX_TELEVISION,
416                         .vmux   = 0,
417                         .gpio0  = 0x00000fbf,
418                         .gpio2  = 0x0000fc08,
419                 },{
420                         .type   = CX88_VMUX_COMPOSITE1,
421                         .vmux   = 1,
422                         .gpio0  = 0x00000fbf,
423                         .gpio2  = 0x0000fc68,
424                 },{
425                         .type   = CX88_VMUX_SVIDEO,
426                         .vmux   = 2,
427                         .gpio0  = 0x00000fbf,
428                         .gpio2  = 0x0000fc68,
429                 }},
430         },
431         [CX88_BOARD_KWORLD_DVB_T] = {
432                 .name           = "KWorld/VStream XPert DVB-T",
433                 .tuner_type     = TUNER_ABSENT,
434                 .radio_type     = UNSET,
435                 .tuner_addr     = ADDR_UNSET,
436                 .radio_addr     = ADDR_UNSET,
437                 .input          = {{
438                         .type   = CX88_VMUX_COMPOSITE1,
439                         .vmux   = 1,
440                         .gpio0  = 0x0700,
441                         .gpio2  = 0x0101,
442                 },{
443                         .type   = CX88_VMUX_SVIDEO,
444                         .vmux   = 2,
445                         .gpio0  = 0x0700,
446                         .gpio2  = 0x0101,
447                 }},
448                 .mpeg           = CX88_MPEG_DVB,
449         },
450         [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = {
451                 .name           = "DViCO FusionHDTV DVB-T1",
452                 .tuner_type     = TUNER_ABSENT, /* No analog tuner */
453                 .radio_type     = UNSET,
454                 .tuner_addr     = ADDR_UNSET,
455                 .radio_addr     = ADDR_UNSET,
456                 .input          = {{
457                         .type   = CX88_VMUX_COMPOSITE1,
458                         .vmux   = 1,
459                         .gpio0  = 0x000027df,
460                 },{
461                         .type   = CX88_VMUX_SVIDEO,
462                         .vmux   = 2,
463                         .gpio0  = 0x000027df,
464                 }},
465                 .mpeg           = CX88_MPEG_DVB,
466         },
467         [CX88_BOARD_KWORLD_LTV883] = {
468                 .name           = "KWorld LTV883RF",
469                 .tuner_type     = TUNER_TNF_8831BGFF,
470                 .radio_type     = UNSET,
471                 .tuner_addr     = ADDR_UNSET,
472                 .radio_addr     = ADDR_UNSET,
473                 .input          = {{
474                         .type   = CX88_VMUX_TELEVISION,
475                         .vmux   = 0,
476                         .gpio0  = 0x07f8,
477                 },{
478                         .type   = CX88_VMUX_DEBUG,
479                         .vmux   = 0,
480                         .gpio0  = 0x07f9,  // mono from tuner chip
481                 },{
482                         .type   = CX88_VMUX_COMPOSITE1,
483                         .vmux   = 1,
484                         .gpio0  = 0x000007fa,
485                 },{
486                         .type   = CX88_VMUX_SVIDEO,
487                         .vmux   = 2,
488                         .gpio0  = 0x000007fa,
489                 }},
490                 .radio = {
491                         .type   = CX88_RADIO,
492                         .gpio0  = 0x000007f8,
493                 },
494         },
495         [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q] = {
496                 .name           = "DViCO FusionHDTV 3 Gold-Q",
497                 .tuner_type     = TUNER_MICROTUNE_4042FI5,
498                 .radio_type     = UNSET,
499                 .tuner_addr     = ADDR_UNSET,
500                 .radio_addr     = ADDR_UNSET,
501                 /*
502                    GPIO[0] resets DT3302 DTV receiver
503                     0 - reset asserted
504                     1 - normal operation
505                    GPIO[1] mutes analog audio output connector
506                     0 - enable selected source
507                     1 - mute
508                    GPIO[2] selects source for analog audio output connector
509                     0 - analog audio input connector on tab
510                     1 - analog DAC output from CX23881 chip
511                    GPIO[3] selects RF input connector on tuner module
512                     0 - RF connector labeled CABLE
513                     1 - RF connector labeled ANT
514                    GPIO[4] selects high RF for QAM256 mode
515                     0 - normal RF
516                     1 - high RF
517                 */
518                 .input          = {{
519                         .type   = CX88_VMUX_TELEVISION,
520                         .vmux   = 0,
521                         .gpio0  = 0x0f0d,
522                 },{
523                         .type   = CX88_VMUX_CABLE,
524                         .vmux   = 0,
525                         .gpio0  = 0x0f05,
526                 },{
527                         .type   = CX88_VMUX_COMPOSITE1,
528                         .vmux   = 1,
529                         .gpio0  = 0x0f00,
530                 },{
531                         .type   = CX88_VMUX_SVIDEO,
532                         .vmux   = 2,
533                         .gpio0  = 0x0f00,
534                 }},
535                 .mpeg           = CX88_MPEG_DVB,
536         },
537         [CX88_BOARD_HAUPPAUGE_DVB_T1] = {
538                 .name           = "Hauppauge Nova-T DVB-T",
539                 .tuner_type     = TUNER_ABSENT,
540                 .radio_type     = UNSET,
541                 .tuner_addr     = ADDR_UNSET,
542                 .radio_addr     = ADDR_UNSET,
543                 .input          = {{
544                         .type   = CX88_VMUX_DVB,
545                         .vmux   = 0,
546                 }},
547                 .mpeg           = CX88_MPEG_DVB,
548         },
549         [CX88_BOARD_CONEXANT_DVB_T1] = {
550                 .name           = "Conexant DVB-T reference design",
551                 .tuner_type     = TUNER_ABSENT,
552                 .radio_type     = UNSET,
553                 .tuner_addr     = ADDR_UNSET,
554                 .radio_addr     = ADDR_UNSET,
555                 .input          = {{
556                         .type   = CX88_VMUX_DVB,
557                         .vmux   = 0,
558                 }},
559                 .mpeg           = CX88_MPEG_DVB,
560         },
561         [CX88_BOARD_PROVIDEO_PV259] = {
562                 .name           = "Provideo PV259",
563                 .tuner_type     = TUNER_PHILIPS_FQ1216ME,
564                 .radio_type     = UNSET,
565                 .tuner_addr     = ADDR_UNSET,
566                 .radio_addr     = ADDR_UNSET,
567                 .input          = {{
568                         .type   = CX88_VMUX_TELEVISION,
569                         .vmux   = 0,
570                         .audioroute = 1,
571                 }},
572                 .mpeg           = CX88_MPEG_BLACKBIRD,
573         },
574         [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = {
575                 .name           = "DViCO FusionHDTV DVB-T Plus",
576                 .tuner_type     = TUNER_ABSENT, /* No analog tuner */
577                 .radio_type     = UNSET,
578                 .tuner_addr     = ADDR_UNSET,
579                 .radio_addr     = ADDR_UNSET,
580                 .input          = {{
581                         .type   = CX88_VMUX_COMPOSITE1,
582                         .vmux   = 1,
583                         .gpio0  = 0x000027df,
584                 },{
585                         .type   = CX88_VMUX_SVIDEO,
586                         .vmux   = 2,
587                         .gpio0  = 0x000027df,
588                 }},
589                 .mpeg           = CX88_MPEG_DVB,
590         },
591         [CX88_BOARD_DNTV_LIVE_DVB_T] = {
592                 .name           = "digitalnow DNTV Live! DVB-T",
593                 .tuner_type     = TUNER_ABSENT,
594                 .radio_type     = UNSET,
595                 .tuner_addr     = ADDR_UNSET,
596                 .radio_addr     = ADDR_UNSET,
597                 .input          = {{
598                         .type   = CX88_VMUX_COMPOSITE1,
599                         .vmux   = 1,
600                         .gpio0  = 0x00000700,
601                         .gpio2  = 0x00000101,
602                 },{
603                         .type   = CX88_VMUX_SVIDEO,
604                         .vmux   = 2,
605                         .gpio0  = 0x00000700,
606                         .gpio2  = 0x00000101,
607                 }},
608                 .mpeg           = CX88_MPEG_DVB,
609         },
610         [CX88_BOARD_PCHDTV_HD3000] = {
611                 .name           = "pcHDTV HD3000 HDTV",
612                 .tuner_type     = TUNER_THOMSON_DTT761X,
613                 .radio_type     = UNSET,
614                 .tuner_addr     = ADDR_UNSET,
615                 .radio_addr     = ADDR_UNSET,
616                 .tda9887_conf   = TDA9887_PRESENT,
617                 /* GPIO[2] = audio source for analog audio out connector
618                  *  0 = analog audio input connector
619                  *  1 = CX88 audio DACs
620                  *
621                  * GPIO[7] = input to CX88's audio/chroma ADC
622                  *  0 = FM 10.7 MHz IF
623                  *  1 = Sound 4.5 MHz IF
624                  *
625                  * GPIO[1,5,6] = Oren 51132 pins 27,35,28 respectively
626                  *
627                  * GPIO[16] = Remote control input
628                  */
629                 .input          = {{
630                         .type   = CX88_VMUX_TELEVISION,
631                         .vmux   = 0,
632                         .gpio0  = 0x00008484,
633                 },{
634                         .type   = CX88_VMUX_COMPOSITE1,
635                         .vmux   = 1,
636                         .gpio0  = 0x00008400,
637                 },{
638                         .type   = CX88_VMUX_SVIDEO,
639                         .vmux   = 2,
640                         .gpio0  = 0x00008400,
641                 }},
642                 .radio = {
643                         .type   = CX88_RADIO,
644                         .gpio0  = 0x00008404,
645                 },
646                 .mpeg           = CX88_MPEG_DVB,
647         },
648         [CX88_BOARD_HAUPPAUGE_ROSLYN] = {
649                 // entry added by Kaustubh D. Bhalerao <bhalerao.1@osu.edu>
650                 // GPIO values obtained from regspy, courtesy Sean Covel
651                 .name           = "Hauppauge WinTV 28xxx (Roslyn) models",
652                 .tuner_type     = UNSET,
653                 .radio_type     = UNSET,
654                 .tuner_addr     = ADDR_UNSET,
655                 .radio_addr     = ADDR_UNSET,
656                 .input          = {{
657                         .type   = CX88_VMUX_TELEVISION,
658                         .vmux   = 0,
659                         .gpio0  = 0xed1a,
660                         .gpio2  = 0x00ff,
661                 },{
662                         .type   = CX88_VMUX_DEBUG,
663                         .vmux   = 0,
664                         .gpio0  = 0xff01,
665                 },{
666                         .type   = CX88_VMUX_COMPOSITE1,
667                         .vmux   = 1,
668                         .gpio0  = 0xff02,
669                 },{
670                         .type   = CX88_VMUX_SVIDEO,
671                         .vmux   = 2,
672                         .gpio0  = 0xed92,
673                         .gpio2  = 0x00ff,
674                 }},
675                 .radio = {
676                          .type   = CX88_RADIO,
677                          .gpio0  = 0xed96,
678                          .gpio2  = 0x00ff,
679                  },
680                 .mpeg           = CX88_MPEG_BLACKBIRD,
681         },
682         [CX88_BOARD_DIGITALLOGIC_MEC] = {
683                 .name           = "Digital-Logic MICROSPACE Entertainment Center (MEC)",
684                 .tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
685                 .radio_type     = UNSET,
686                 .tuner_addr     = ADDR_UNSET,
687                 .radio_addr     = ADDR_UNSET,
688                 .tda9887_conf   = TDA9887_PRESENT,
689                 .input          = {{
690                         .type   = CX88_VMUX_TELEVISION,
691                         .vmux   = 0,
692                         .gpio0  = 0x00009d80,
693                         .audioroute = 1,
694                 },{
695                         .type   = CX88_VMUX_COMPOSITE1,
696                         .vmux   = 1,
697                         .gpio0  = 0x00009d76,
698                         .audioroute = 1,
699                 },{
700                         .type   = CX88_VMUX_SVIDEO,
701                         .vmux   = 2,
702                         .gpio0  = 0x00009d76,
703                         .audioroute = 1,
704                 }},
705                 .radio = {
706                         .type   = CX88_RADIO,
707                         .gpio0  = 0x00009d00,
708                         .audioroute = 1,
709                 },
710                 .mpeg           = CX88_MPEG_BLACKBIRD,
711         },
712         [CX88_BOARD_IODATA_GVBCTV7E] = {
713                 .name           = "IODATA GV/BCTV7E",
714                 .tuner_type     = TUNER_PHILIPS_FQ1286,
715                 .radio_type     = UNSET,
716                 .tuner_addr     = ADDR_UNSET,
717                 .radio_addr     = ADDR_UNSET,
718                 .tda9887_conf   = TDA9887_PRESENT,
719                 .input          = {{
720                         .type   = CX88_VMUX_TELEVISION,
721                         .vmux   = 1,
722                         .gpio1  = 0x0000e03f,
723                 },{
724                         .type   = CX88_VMUX_COMPOSITE1,
725                         .vmux   = 2,
726                         .gpio1  = 0x0000e07f,
727                 },{
728                         .type   = CX88_VMUX_SVIDEO,
729                         .vmux   = 3,
730                         .gpio1  = 0x0000e07f,
731                 }}
732         },
733         [CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO] = {
734                 .name           = "PixelView PlayTV Ultra Pro (Stereo)",
735                 /* May be also TUNER_YMEC_TVF_5533MF for NTSC/M or PAL/M */
736                 .tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
737                 .radio_type     = UNSET,
738                 .tuner_addr     = ADDR_UNSET,
739                 .radio_addr     = ADDR_UNSET,
740                 /* Some variants use a tda9874 and so need the tvaudio module. */
741                 .audio_chip     = V4L2_IDENT_TVAUDIO,
742                 .input          = {{
743                         .type   = CX88_VMUX_TELEVISION,
744                         .vmux   = 0,
745                         .gpio0  = 0xbf61,  /* internal decoder */
746                 },{
747                         .type   = CX88_VMUX_COMPOSITE1,
748                         .vmux   = 1,
749                         .gpio0  = 0xbf63,
750                 },{
751                         .type   = CX88_VMUX_SVIDEO,
752                         .vmux   = 2,
753                         .gpio0  = 0xbf63,
754                 }},
755                 .radio = {
756                          .type  = CX88_RADIO,
757                          .gpio0 = 0xbf60,
758                  },
759         },
760         [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T] = {
761                 .name           = "DViCO FusionHDTV 3 Gold-T",
762                 .tuner_type     = TUNER_THOMSON_DTT761X,
763                 .radio_type     = UNSET,
764                 .tuner_addr     = ADDR_UNSET,
765                 .radio_addr     = ADDR_UNSET,
766                 .tda9887_conf   = TDA9887_PRESENT,
767                 .input          = {{
768                         .type   = CX88_VMUX_TELEVISION,
769                         .vmux   = 0,
770                         .gpio0  = 0x97ed,
771                 },{
772                         .type   = CX88_VMUX_COMPOSITE1,
773                         .vmux   = 1,
774                         .gpio0  = 0x97e9,
775                 },{
776                         .type   = CX88_VMUX_SVIDEO,
777                         .vmux   = 2,
778                         .gpio0  = 0x97e9,
779                 }},
780                 .mpeg           = CX88_MPEG_DVB,
781         },
782         [CX88_BOARD_ADSTECH_DVB_T_PCI] = {
783                 .name           = "ADS Tech Instant TV DVB-T PCI",
784                 .tuner_type     = TUNER_ABSENT,
785                 .radio_type     = UNSET,
786                 .tuner_addr     = ADDR_UNSET,
787                 .radio_addr     = ADDR_UNSET,
788                 .input          = {{
789                         .type   = CX88_VMUX_COMPOSITE1,
790                         .vmux   = 1,
791                         .gpio0  = 0x0700,
792                         .gpio2  = 0x0101,
793                 },{
794                         .type   = CX88_VMUX_SVIDEO,
795                         .vmux   = 2,
796                         .gpio0  = 0x0700,
797                         .gpio2  = 0x0101,
798                 }},
799                 .mpeg           = CX88_MPEG_DVB,
800         },
801         [CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1] = {
802                 .name           = "TerraTec Cinergy 1400 DVB-T",
803                 .tuner_type     = TUNER_ABSENT,
804                 .input          = {{
805                         .type   = CX88_VMUX_DVB,
806                         .vmux   = 0,
807                 },{
808                         .type   = CX88_VMUX_COMPOSITE1,
809                         .vmux   = 2,
810                 },{
811                         .type   = CX88_VMUX_SVIDEO,
812                         .vmux   = 2,
813                 }},
814                 .mpeg           = CX88_MPEG_DVB,
815         },
816         [CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD] = {
817                 .name           = "DViCO FusionHDTV 5 Gold",
818                 .tuner_type     = TUNER_LG_TDVS_H06XF, /* TDVS-H062F */
819                 .radio_type     = UNSET,
820                 .tuner_addr     = ADDR_UNSET,
821                 .radio_addr     = ADDR_UNSET,
822                 .tda9887_conf   = TDA9887_PRESENT,
823                 .input          = {{
824                         .type   = CX88_VMUX_TELEVISION,
825                         .vmux   = 0,
826                         .gpio0  = 0x87fd,
827                 },{
828                         .type   = CX88_VMUX_COMPOSITE1,
829                         .vmux   = 1,
830                         .gpio0  = 0x87f9,
831                 },{
832                         .type   = CX88_VMUX_SVIDEO,
833                         .vmux   = 2,
834                         .gpio0  = 0x87f9,
835                 }},
836                 .mpeg           = CX88_MPEG_DVB,
837         },
838         [CX88_BOARD_AVERMEDIA_ULTRATV_MC_550] = {
839                 .name           = "AverMedia UltraTV Media Center PCI 550",
840                 .tuner_type     = TUNER_PHILIPS_FM1236_MK3,
841                 .radio_type     = UNSET,
842                 .tuner_addr     = ADDR_UNSET,
843                 .radio_addr     = ADDR_UNSET,
844                 .tda9887_conf   = TDA9887_PRESENT,
845                 .input          = {{
846                         .type   = CX88_VMUX_COMPOSITE1,
847                         .vmux   = 0,
848                         .gpio0  = 0x0000cd73,
849                         .audioroute = 1,
850                 },{
851                         .type   = CX88_VMUX_SVIDEO,
852                         .vmux   = 1,
853                         .gpio0  = 0x0000cd73,
854                         .audioroute = 1,
855                 },{
856                         .type   = CX88_VMUX_TELEVISION,
857                         .vmux   = 3,
858                         .gpio0  = 0x0000cdb3,
859                         .audioroute = 1,
860                 }},
861                 .radio = {
862                         .type   = CX88_RADIO,
863                         .vmux   = 2,
864                         .gpio0  = 0x0000cdf3,
865                         .audioroute = 1,
866                 },
867                 .mpeg           = CX88_MPEG_BLACKBIRD,
868         },
869         [CX88_BOARD_KWORLD_VSTREAM_EXPERT_DVD] = {
870                  /* Alexander Wold <awold@bigfoot.com> */
871                  .name           = "Kworld V-Stream Xpert DVD",
872                  .tuner_type     = UNSET,
873                  .input          = {{
874                          .type   = CX88_VMUX_COMPOSITE1,
875                          .vmux   = 1,
876                          .gpio0  = 0x03000000,
877                          .gpio1  = 0x01000000,
878                          .gpio2  = 0x02000000,
879                          .gpio3  = 0x00100000,
880                  },{
881                          .type   = CX88_VMUX_SVIDEO,
882                          .vmux   = 2,
883                          .gpio0  = 0x03000000,
884                          .gpio1  = 0x01000000,
885                          .gpio2  = 0x02000000,
886                          .gpio3  = 0x00100000,
887                  }},
888         },
889         [CX88_BOARD_ATI_HDTVWONDER] = {
890                 .name           = "ATI HDTV Wonder",
891                 .tuner_type     = TUNER_PHILIPS_TUV1236D,
892                 .radio_type     = UNSET,
893                 .tuner_addr     = ADDR_UNSET,
894                 .radio_addr     = ADDR_UNSET,
895                 .input          = {{
896                         .type   = CX88_VMUX_TELEVISION,
897                         .vmux   = 0,
898                         .gpio0  = 0x00000ff7,
899                         .gpio1  = 0x000000ff,
900                         .gpio2  = 0x00000001,
901                         .gpio3  = 0x00000000,
902                 },{
903                         .type   = CX88_VMUX_COMPOSITE1,
904                         .vmux   = 1,
905                         .gpio0  = 0x00000ffe,
906                         .gpio1  = 0x000000ff,
907                         .gpio2  = 0x00000001,
908                         .gpio3  = 0x00000000,
909                 },{
910                         .type   = CX88_VMUX_SVIDEO,
911                         .vmux   = 2,
912                         .gpio0  = 0x00000ffe,
913                         .gpio1  = 0x000000ff,
914                         .gpio2  = 0x00000001,
915                         .gpio3  = 0x00000000,
916                 }},
917                 .mpeg           = CX88_MPEG_DVB,
918         },
919         [CX88_BOARD_WINFAST_DTV1000] = {
920                 .name           = "WinFast DTV1000-T",
921                 .tuner_type     = TUNER_ABSENT,
922                 .radio_type     = UNSET,
923                 .tuner_addr     = ADDR_UNSET,
924                 .radio_addr     = ADDR_UNSET,
925                 .input          = {{
926                         .type   = CX88_VMUX_DVB,
927                         .vmux   = 0,
928                 },{
929                         .type   = CX88_VMUX_COMPOSITE1,
930                         .vmux   = 1,
931                 },{
932                         .type   = CX88_VMUX_SVIDEO,
933                         .vmux   = 2,
934                 }},
935                 .mpeg           = CX88_MPEG_DVB,
936         },
937         [CX88_BOARD_AVERTV_303] = {
938                 .name           = "AVerTV 303 (M126)",
939                 .tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
940                 .radio_type     = UNSET,
941                 .tuner_addr     = ADDR_UNSET,
942                 .radio_addr     = ADDR_UNSET,
943                 .tda9887_conf   = TDA9887_PRESENT,
944                 .input          = {{
945                         .type   = CX88_VMUX_TELEVISION,
946                         .vmux   = 0,
947                         .gpio0  = 0x00ff,
948                         .gpio1  = 0xe09f,
949                         .gpio2  = 0x0010,
950                         .gpio3  = 0x0000,
951                 },{
952                         .type   = CX88_VMUX_COMPOSITE1,
953                         .vmux   = 1,
954                         .gpio0  = 0x00ff,
955                         .gpio1  = 0xe05f,
956                         .gpio2  = 0x0010,
957                         .gpio3  = 0x0000,
958                 },{
959                         .type   = CX88_VMUX_SVIDEO,
960                         .vmux   = 2,
961                         .gpio0  = 0x00ff,
962                         .gpio1  = 0xe05f,
963                         .gpio2  = 0x0010,
964                         .gpio3  = 0x0000,
965                 }},
966         },
967         [CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1] = {
968                 .name           = "Hauppauge Nova-S-Plus DVB-S",
969                 .tuner_type     = TUNER_ABSENT,
970                 .radio_type     = UNSET,
971                 .tuner_addr     = ADDR_UNSET,
972                 .radio_addr     = ADDR_UNSET,
973                 .input          = {{
974                         .type   = CX88_VMUX_DVB,
975                         .vmux   = 0,
976                 },{
977                         .type   = CX88_VMUX_COMPOSITE1,
978                         .vmux   = 1,
979                 },{
980                         .type   = CX88_VMUX_SVIDEO,
981                         .vmux   = 2,
982                 }},
983                 .mpeg           = CX88_MPEG_DVB,
984         },
985         [CX88_BOARD_HAUPPAUGE_NOVASE2_S1] = {
986                 .name           = "Hauppauge Nova-SE2 DVB-S",
987                 .tuner_type     = TUNER_ABSENT,
988                 .radio_type     = UNSET,
989                 .tuner_addr     = ADDR_UNSET,
990                 .radio_addr     = ADDR_UNSET,
991                 .input          = {{
992                         .type   = CX88_VMUX_DVB,
993                         .vmux   = 0,
994                 }},
995                 .mpeg           = CX88_MPEG_DVB,
996         },
997         [CX88_BOARD_KWORLD_DVBS_100] = {
998                 .name           = "KWorld DVB-S 100",
999                 .tuner_type     = TUNER_ABSENT,
1000                 .radio_type     = UNSET,
1001                 .tuner_addr     = ADDR_UNSET,
1002                 .radio_addr     = ADDR_UNSET,
1003                 .input          = {{
1004                         .type   = CX88_VMUX_DVB,
1005                         .vmux   = 0,
1006                 },{
1007                         .type   = CX88_VMUX_COMPOSITE1,
1008                         .vmux   = 1,
1009                 },{
1010                         .type   = CX88_VMUX_SVIDEO,
1011                         .vmux   = 2,
1012                 }},
1013                 .mpeg           = CX88_MPEG_DVB,
1014         },
1015         [CX88_BOARD_HAUPPAUGE_HVR1100] = {
1016                 .name           = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid",
1017                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1018                 .radio_type     = UNSET,
1019                 .tuner_addr     = ADDR_UNSET,
1020                 .radio_addr     = ADDR_UNSET,
1021                 .tda9887_conf   = TDA9887_PRESENT,
1022                 .input          = {{
1023                         .type   = CX88_VMUX_TELEVISION,
1024                         .vmux   = 0,
1025                 },{
1026                         .type   = CX88_VMUX_COMPOSITE1,
1027                         .vmux   = 1,
1028                 },{
1029                         .type   = CX88_VMUX_SVIDEO,
1030                         .vmux   = 2,
1031                 }},
1032                 /* fixme: Add radio support */
1033                 .mpeg           = CX88_MPEG_DVB,
1034         },
1035         [CX88_BOARD_HAUPPAUGE_HVR1100LP] = {
1036                 .name           = "Hauppauge WinTV-HVR1100 DVB-T/Hybrid (Low Profile)",
1037                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1038                 .radio_type     = UNSET,
1039                 .tuner_addr     = ADDR_UNSET,
1040                 .radio_addr     = ADDR_UNSET,
1041                 .tda9887_conf   = TDA9887_PRESENT,
1042                 .input          = {{
1043                         .type   = CX88_VMUX_TELEVISION,
1044                         .vmux   = 0,
1045                 },{
1046                         .type   = CX88_VMUX_COMPOSITE1,
1047                         .vmux   = 1,
1048                 }},
1049                 /* fixme: Add radio support */
1050                 .mpeg           = CX88_MPEG_DVB,
1051         },
1052         [CX88_BOARD_DNTV_LIVE_DVB_T_PRO] = {
1053                 .name           = "digitalnow DNTV Live! DVB-T Pro",
1054                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1055                 .radio_type     = UNSET,
1056                 .tuner_addr     = ADDR_UNSET,
1057                 .radio_addr     = ADDR_UNSET,
1058                 .tda9887_conf   = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE |
1059                                   TDA9887_PORT2_ACTIVE,
1060                 .input          = {{
1061                         .type   = CX88_VMUX_TELEVISION,
1062                         .vmux   = 0,
1063                         .gpio0  = 0xf80808,
1064                 },{
1065                         .type   = CX88_VMUX_COMPOSITE1,
1066                         .vmux   = 1,
1067                         .gpio0  = 0xf80808,
1068                 },{
1069                         .type   = CX88_VMUX_SVIDEO,
1070                         .vmux   = 2,
1071                         .gpio0  = 0xf80808,
1072                 }},
1073                 .radio = {
1074                          .type  = CX88_RADIO,
1075                          .gpio0 = 0xf80808,
1076                 },
1077                 .mpeg           = CX88_MPEG_DVB,
1078         },
1079         [CX88_BOARD_KWORLD_DVB_T_CX22702] = {
1080                 /* Kworld V-stream Xpert DVB-T with Thomson tuner */
1081                 /* DTT 7579 Conexant CX22702-19 Conexant CX2388x  */
1082                 /* Manenti Marco <marco_manenti@colman.it> */
1083                 .name           = "KWorld/VStream XPert DVB-T with cx22702",
1084                 .tuner_type     = TUNER_ABSENT,
1085                 .radio_type     = UNSET,
1086                 .tuner_addr     = ADDR_UNSET,
1087                 .radio_addr     = ADDR_UNSET,
1088                 .input          = {{
1089                         .type   = CX88_VMUX_COMPOSITE1,
1090                         .vmux   = 1,
1091                         .gpio0  = 0x0700,
1092                         .gpio2  = 0x0101,
1093                 },{
1094                         .type   = CX88_VMUX_SVIDEO,
1095                         .vmux   = 2,
1096                         .gpio0  = 0x0700,
1097                         .gpio2  = 0x0101,
1098                 }},
1099                 .mpeg           = CX88_MPEG_DVB,
1100         },
1101         [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL] = {
1102                 .name           = "DViCO FusionHDTV DVB-T Dual Digital",
1103                 .tuner_type     = TUNER_ABSENT, /* No analog tuner */
1104                 .radio_type     = UNSET,
1105                 .tuner_addr     = ADDR_UNSET,
1106                 .radio_addr     = ADDR_UNSET,
1107                 .input          = {{
1108                         .type   = CX88_VMUX_COMPOSITE1,
1109                         .vmux   = 1,
1110                         .gpio0  = 0x000067df,
1111                  },{
1112                         .type   = CX88_VMUX_SVIDEO,
1113                         .vmux   = 2,
1114                         .gpio0  = 0x000067df,
1115                 }},
1116                 .mpeg           = CX88_MPEG_DVB,
1117         },
1118         [CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT] = {
1119                 .name           = "KWorld HardwareMpegTV XPert",
1120                 .tuner_type     = TUNER_PHILIPS_TDA8290,
1121                 .radio_type     = UNSET,
1122                 .tuner_addr     = ADDR_UNSET,
1123                 .radio_addr     = ADDR_UNSET,
1124                 .input          = {{
1125                         .type   = CX88_VMUX_TELEVISION,
1126                         .vmux   = 0,
1127                         .gpio0  = 0x3de2,
1128                         .gpio2  = 0x00ff,
1129                 },{
1130                         .type   = CX88_VMUX_COMPOSITE1,
1131                         .vmux   = 1,
1132                         .gpio0  = 0x3de6,
1133                         .audioroute = 1,
1134                 },{
1135                         .type   = CX88_VMUX_SVIDEO,
1136                         .vmux   = 2,
1137                         .gpio0  = 0x3de6,
1138                         .audioroute = 1,
1139                 }},
1140                 .radio = {
1141                         .type   = CX88_RADIO,
1142                         .gpio0  = 0x3de6,
1143                         .gpio2  = 0x00ff,
1144                 },
1145                 .mpeg           = CX88_MPEG_BLACKBIRD,
1146         },
1147         [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID] = {
1148                 .name           = "DViCO FusionHDTV DVB-T Hybrid",
1149                 .tuner_type     = TUNER_THOMSON_FE6600,
1150                 .radio_type     = UNSET,
1151                 .tuner_addr     = ADDR_UNSET,
1152                 .radio_addr     = ADDR_UNSET,
1153                 .input          = {{
1154                         .type   = CX88_VMUX_TELEVISION,
1155                         .vmux   = 0,
1156                         .gpio0  = 0x0000a75f,
1157                 },{
1158                         .type   = CX88_VMUX_COMPOSITE1,
1159                         .vmux   = 1,
1160                         .gpio0  = 0x0000a75b,
1161                 },{
1162                         .type   = CX88_VMUX_SVIDEO,
1163                         .vmux   = 2,
1164                         .gpio0  = 0x0000a75b,
1165                 }},
1166                 .mpeg           = CX88_MPEG_DVB,
1167         },
1168         [CX88_BOARD_PCHDTV_HD5500] = {
1169                 .name           = "pcHDTV HD5500 HDTV",
1170                 .tuner_type     = TUNER_LG_TDVS_H06XF, /* TDVS-H064F */
1171                 .radio_type     = UNSET,
1172                 .tuner_addr     = ADDR_UNSET,
1173                 .radio_addr     = ADDR_UNSET,
1174                 .tda9887_conf   = TDA9887_PRESENT,
1175                 .input          = {{
1176                         .type   = CX88_VMUX_TELEVISION,
1177                         .vmux   = 0,
1178                         .gpio0  = 0x87fd,
1179                 },{
1180                         .type   = CX88_VMUX_COMPOSITE1,
1181                         .vmux   = 1,
1182                         .gpio0  = 0x87f9,
1183                 },{
1184                         .type   = CX88_VMUX_SVIDEO,
1185                         .vmux   = 2,
1186                         .gpio0  = 0x87f9,
1187                 }},
1188                 .mpeg           = CX88_MPEG_DVB,
1189         },
1190         [CX88_BOARD_KWORLD_MCE200_DELUXE] = {
1191                 /* FIXME: tested TV input only, disabled composite,
1192                    svideo and radio until they can be tested also. */
1193                 .name           = "Kworld MCE 200 Deluxe",
1194                 .tuner_type     = TUNER_TENA_9533_DI,
1195                 .radio_type     = UNSET,
1196                 .tda9887_conf   = TDA9887_PRESENT,
1197                 .tuner_addr     = ADDR_UNSET,
1198                 .radio_addr     = ADDR_UNSET,
1199                 .input          = {{
1200                         .type   = CX88_VMUX_TELEVISION,
1201                         .vmux   = 0,
1202                         .gpio0  = 0x0000BDE6
1203                 }},
1204                 .mpeg           = CX88_MPEG_BLACKBIRD,
1205         },
1206         [CX88_BOARD_PIXELVIEW_PLAYTV_P7000] = {
1207                 /* FIXME: SVideo, Composite and FM inputs are untested */
1208                 .name           = "PixelView PlayTV P7000",
1209                 .tuner_type     = TUNER_PHILIPS_FM1216ME_MK3,
1210                 .radio_type     = UNSET,
1211                 .tuner_addr     = ADDR_UNSET,
1212                 .radio_addr     = ADDR_UNSET,
1213                 .tda9887_conf   = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE |
1214                                   TDA9887_PORT2_ACTIVE,
1215                 .input          = {{
1216                         .type   = CX88_VMUX_TELEVISION,
1217                         .vmux   = 0,
1218                         .gpio0  = 0x5da6,
1219                 }},
1220                 .mpeg           = CX88_MPEG_BLACKBIRD,
1221         },
1222         [CX88_BOARD_NPGTECH_REALTV_TOP10FM] = {
1223                 .name           = "NPG Tech Real TV FM Top 10",
1224                 .tuner_type     = TUNER_TNF_5335MF, /* Actually a TNF9535 */
1225                 .radio_type     = UNSET,
1226                 .tuner_addr     = ADDR_UNSET,
1227                 .radio_addr     = ADDR_UNSET,
1228                 .input          = {{
1229                         .type   = CX88_VMUX_TELEVISION,
1230                         .vmux   = 0,
1231                         .gpio0  = 0x0788,
1232                 },{
1233                         .type   = CX88_VMUX_COMPOSITE1,
1234                         .vmux   = 1,
1235                         .gpio0  = 0x078b,
1236                 },{
1237                         .type   = CX88_VMUX_SVIDEO,
1238                         .vmux   = 2,
1239                         .gpio0  = 0x078b,
1240                 }},
1241                 .radio = {
1242                          .type  = CX88_RADIO,
1243                          .gpio0 = 0x074a,
1244                 },
1245         },
1246         [CX88_BOARD_WINFAST_DTV2000H] = {
1247                 .name           = "WinFast DTV2000 H",
1248                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1249                 .radio_type     = UNSET,
1250                 .tuner_addr     = ADDR_UNSET,
1251                 .radio_addr     = ADDR_UNSET,
1252                 .tda9887_conf   = TDA9887_PRESENT,
1253                 .input          = {{
1254                         .type   = CX88_VMUX_TELEVISION,
1255                         .vmux   = 0,
1256                         .gpio0  = 0x00017304,
1257                         .gpio1  = 0x00008203,
1258                         .gpio2  = 0x00017304,
1259                         .gpio3  = 0x02000000,
1260                 }, {
1261                         .type   = CX88_VMUX_COMPOSITE1,
1262                         .vmux   = 1,
1263                         .gpio0  = 0x0001d701,
1264                         .gpio1  = 0x0000b207,
1265                         .gpio2  = 0x0001d701,
1266                         .gpio3  = 0x02000000,
1267                 }, {
1268                         .type   = CX88_VMUX_COMPOSITE2,
1269                         .vmux   = 2,
1270                         .gpio0  = 0x0001d503,
1271                         .gpio1  = 0x0000b207,
1272                         .gpio2  = 0x0001d503,
1273                         .gpio3  = 0x02000000,
1274                 }, {
1275                         .type   = CX88_VMUX_SVIDEO,
1276                         .vmux   = 3,
1277                         .gpio0  = 0x0001d701,
1278                         .gpio1  = 0x0000b207,
1279                         .gpio2  = 0x0001d701,
1280                         .gpio3  = 0x02000000,
1281                 }},
1282                 .radio = {
1283                          .type  = CX88_RADIO,
1284                          .gpio0 = 0x00015702,
1285                          .gpio1 = 0x0000f207,
1286                          .gpio2 = 0x00015702,
1287                          .gpio3 = 0x02000000,
1288                 },
1289                 .mpeg           = CX88_MPEG_DVB,
1290         },
1291         [CX88_BOARD_WINFAST_DTV2000H_J] = {
1292                 .name           = "WinFast DTV2000 H rev. J",
1293                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1294                 .radio_type     = UNSET,
1295                 .tuner_addr     = ADDR_UNSET,
1296                 .radio_addr     = ADDR_UNSET,
1297                 .tda9887_conf   = TDA9887_PRESENT,
1298                 .input          = {{
1299                         .type   = CX88_VMUX_TELEVISION,
1300                         .vmux   = 0,
1301                         .gpio0  = 0x00017300,
1302                         .gpio1  = 0x00008207,
1303                         .gpio2  = 0x00000000,
1304                         .gpio3  = 0x02000000,
1305                 },{
1306                         .type   = CX88_VMUX_TELEVISION,
1307                         .vmux   = 0,
1308                         .gpio0  = 0x00018300,
1309                         .gpio1  = 0x0000f207,
1310                         .gpio2  = 0x00017304,
1311                         .gpio3  = 0x02000000,
1312                 },{
1313                         .type   = CX88_VMUX_COMPOSITE1,
1314                         .vmux   = 1,
1315                         .gpio0  = 0x00018301,
1316                         .gpio1  = 0x0000f207,
1317                         .gpio2  = 0x00017304,
1318                         .gpio3  = 0x02000000,
1319                 },{
1320                         .type   = CX88_VMUX_SVIDEO,
1321                         .vmux   = 2,
1322                         .gpio0  = 0x00018301,
1323                         .gpio1  = 0x0000f207,
1324                         .gpio2  = 0x00017304,
1325                         .gpio3  = 0x02000000,
1326                 }},
1327                 .radio = {
1328                          .type  = CX88_RADIO,
1329                          .gpio0 = 0x00015702,
1330                          .gpio1 = 0x0000f207,
1331                          .gpio2 = 0x00015702,
1332                          .gpio3 = 0x02000000,
1333                 },
1334                 .mpeg           = CX88_MPEG_DVB,
1335         },
1336         [CX88_BOARD_GENIATECH_DVBS] = {
1337                 .name          = "Geniatech DVB-S",
1338                 .tuner_type    = TUNER_ABSENT,
1339                 .radio_type    = UNSET,
1340                 .tuner_addr    = ADDR_UNSET,
1341                 .radio_addr    = ADDR_UNSET,
1342                 .input  = {{
1343                         .type  = CX88_VMUX_DVB,
1344                         .vmux  = 0,
1345                 },{
1346                         .type  = CX88_VMUX_COMPOSITE1,
1347                         .vmux  = 1,
1348                 }},
1349                 .mpeg           = CX88_MPEG_DVB,
1350         },
1351         [CX88_BOARD_HAUPPAUGE_HVR3000] = {
1352                 .name           = "Hauppauge WinTV-HVR3000 TriMode Analog/DVB-S/DVB-T",
1353                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1354                 .radio_type     = UNSET,
1355                 .tuner_addr     = ADDR_UNSET,
1356                 .radio_addr     = ADDR_UNSET,
1357                 .tda9887_conf   = TDA9887_PRESENT,
1358                 .audio_chip     = V4L2_IDENT_WM8775,
1359                 .input          = {{
1360                         .type   = CX88_VMUX_TELEVISION,
1361                         .vmux   = 0,
1362                         .gpio0  = 0x84bf,
1363                         /* 1: TV Audio / FM Mono */
1364                         .audioroute = 1,
1365                 },{
1366                         .type   = CX88_VMUX_COMPOSITE1,
1367                         .vmux   = 1,
1368                         .gpio0  = 0x84bf,
1369                         /* 2: Line-In */
1370                         .audioroute = 2,
1371                 },{
1372                         .type   = CX88_VMUX_SVIDEO,
1373                         .vmux   = 2,
1374                         .gpio0  = 0x84bf,
1375                         /* 2: Line-In */
1376                         .audioroute = 2,
1377                 }},
1378                 .radio = {
1379                         .type   = CX88_RADIO,
1380                         .gpio0  = 0x84bf,
1381                         /* 4: FM Stereo (untested) */
1382                         .audioroute = 8,
1383                 },
1384                 .mpeg           = CX88_MPEG_DVB,
1385                 .num_frontends  = 2,
1386         },
1387         [CX88_BOARD_NORWOOD_MICRO] = {
1388                 .name           = "Norwood Micro TV Tuner",
1389                 .tuner_type     = TUNER_TNF_5335MF,
1390                 .radio_type     = UNSET,
1391                 .tuner_addr     = ADDR_UNSET,
1392                 .radio_addr     = ADDR_UNSET,
1393                 .input          = {{
1394                         .type   = CX88_VMUX_TELEVISION,
1395                         .vmux   = 0,
1396                         .gpio0  = 0x0709,
1397                 },{
1398                         .type   = CX88_VMUX_COMPOSITE1,
1399                         .vmux   = 1,
1400                         .gpio0  = 0x070b,
1401                 },{
1402                         .type   = CX88_VMUX_SVIDEO,
1403                         .vmux   = 2,
1404                         .gpio0  = 0x070b,
1405                 }},
1406         },
1407         [CX88_BOARD_TE_DTV_250_OEM_SWANN] = {
1408                 .name           = "Shenzhen Tungsten Ages Tech TE-DTV-250 / Swann OEM",
1409                 .tuner_type     = TUNER_LG_PAL_NEW_TAPC,
1410                 .radio_type     = UNSET,
1411                 .tuner_addr     = ADDR_UNSET,
1412                 .radio_addr     = ADDR_UNSET,
1413                 .input          = {{
1414                         .type   = CX88_VMUX_TELEVISION,
1415                         .vmux   = 0,
1416                         .gpio0  = 0x003fffff,
1417                         .gpio1  = 0x00e00000,
1418                         .gpio2  = 0x003fffff,
1419                         .gpio3  = 0x02000000,
1420                 },{
1421                         .type   = CX88_VMUX_COMPOSITE1,
1422                         .vmux   = 1,
1423                         .gpio0  = 0x003fffff,
1424                         .gpio1  = 0x00e00000,
1425                         .gpio2  = 0x003fffff,
1426                         .gpio3  = 0x02000000,
1427                 },{
1428                         .type   = CX88_VMUX_SVIDEO,
1429                         .vmux   = 2,
1430                         .gpio0  = 0x003fffff,
1431                         .gpio1  = 0x00e00000,
1432                         .gpio2  = 0x003fffff,
1433                         .gpio3  = 0x02000000,
1434                 }},
1435         },
1436         [CX88_BOARD_HAUPPAUGE_HVR1300] = {
1437                 .name           = "Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder",
1438                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1439                 .radio_type     = UNSET,
1440                 .tuner_addr     = ADDR_UNSET,
1441                 .radio_addr     = ADDR_UNSET,
1442                 .tda9887_conf   = TDA9887_PRESENT,
1443                 .audio_chip     = V4L2_IDENT_WM8775,
1444                 /*
1445                  * gpio0 as reported by Mike Crash <mike AT mikecrash.com>
1446                  */
1447                 .input          = {{
1448                         .type   = CX88_VMUX_TELEVISION,
1449                         .vmux   = 0,
1450                         .gpio0  = 0xef88,
1451                         /* 1: TV Audio / FM Mono */
1452                         .audioroute = 1,
1453                 },{
1454                         .type   = CX88_VMUX_COMPOSITE1,
1455                         .vmux   = 1,
1456                         .gpio0  = 0xef88,
1457                         /* 2: Line-In */
1458                         .audioroute = 2,
1459                 },{
1460                         .type   = CX88_VMUX_SVIDEO,
1461                         .vmux   = 2,
1462                         .gpio0  = 0xef88,
1463                         /* 2: Line-In */
1464                         .audioroute = 2,
1465                 }},
1466                 .mpeg           = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD,
1467                 .radio = {
1468                         .type   = CX88_RADIO,
1469                         .gpio0  = 0xef88,
1470                         /* 4: FM Stereo (untested) */
1471                         .audioroute = 8,
1472                 },
1473         },
1474         [CX88_BOARD_SAMSUNG_SMT_7020] = {
1475                 .name           = "Samsung SMT 7020 DVB-S",
1476                 .tuner_type     = TUNER_ABSENT,
1477                 .radio_type     = UNSET,
1478                 .tuner_addr     = ADDR_UNSET,
1479                 .radio_addr     = ADDR_UNSET,
1480                 .input          = { {
1481                         .type   = CX88_VMUX_DVB,
1482                         .vmux   = 0,
1483                 } },
1484                 .mpeg           = CX88_MPEG_DVB,
1485         },
1486         [CX88_BOARD_ADSTECH_PTV_390] = {
1487                 .name           = "ADS Tech Instant Video PCI",
1488                 .tuner_type     = TUNER_ABSENT,
1489                 .radio_type     = UNSET,
1490                 .tuner_addr     = ADDR_UNSET,
1491                 .radio_addr     = ADDR_UNSET,
1492                 .input          = {{
1493                         .type   = CX88_VMUX_DEBUG,
1494                         .vmux   = 3,
1495                         .gpio0  = 0x04ff,
1496                 },{
1497                         .type   = CX88_VMUX_COMPOSITE1,
1498                         .vmux   = 1,
1499                         .gpio0  = 0x07fa,
1500                 },{
1501                         .type   = CX88_VMUX_SVIDEO,
1502                         .vmux   = 2,
1503                         .gpio0  = 0x07fa,
1504                 }},
1505         },
1506         [CX88_BOARD_PINNACLE_PCTV_HD_800i] = {
1507                 .name           = "Pinnacle PCTV HD 800i",
1508                 .tuner_type     = TUNER_XC5000,
1509                 .radio_type     = UNSET,
1510                 .tuner_addr     = ADDR_UNSET,
1511                 .radio_addr     = ADDR_UNSET,
1512                 .input          = {{
1513                         .type   = CX88_VMUX_TELEVISION,
1514                         .vmux   = 0,
1515                         .gpio0  = 0x04fb,
1516                         .gpio1  = 0x10ff,
1517                 },{
1518                         .type   = CX88_VMUX_COMPOSITE1,
1519                         .vmux   = 1,
1520                         .gpio0  = 0x04fb,
1521                         .gpio1  = 0x10ef,
1522                         .audioroute = 1,
1523                 },{
1524                         .type   = CX88_VMUX_SVIDEO,
1525                         .vmux   = 2,
1526                         .gpio0  = 0x04fb,
1527                         .gpio1  = 0x10ef,
1528                         .audioroute = 1,
1529                 }},
1530                 .mpeg           = CX88_MPEG_DVB,
1531         },
1532         [CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO] = {
1533                 .name           = "DViCO FusionHDTV 5 PCI nano",
1534                 /* xc3008 tuner, digital only for now */
1535                 .tuner_type     = TUNER_ABSENT,
1536                 .radio_type     = UNSET,
1537                 .tuner_addr     = ADDR_UNSET,
1538                 .radio_addr     = ADDR_UNSET,
1539                 .input          = {{
1540                         .type   = CX88_VMUX_TELEVISION,
1541                         .vmux   = 0,
1542                         .gpio0  = 0x000027df, /* Unconfirmed */
1543                 }, {
1544                         .type   = CX88_VMUX_COMPOSITE1,
1545                         .vmux   = 1,
1546                         .gpio0  = 0x000027df, /* Unconfirmed */
1547                         .audioroute = 1,
1548                 }, {
1549                         .type   = CX88_VMUX_SVIDEO,
1550                         .vmux   = 2,
1551                         .gpio0  = 0x000027df, /* Unconfirmed */
1552                         .audioroute = 1,
1553                 } },
1554                 .mpeg           = CX88_MPEG_DVB,
1555         },
1556         [CX88_BOARD_PINNACLE_HYBRID_PCTV] = {
1557                 .name           = "Pinnacle Hybrid PCTV",
1558                 .tuner_type     = TUNER_XC2028,
1559                 .tuner_addr     = 0x61,
1560                 .radio_type     = TUNER_XC2028,
1561                 .radio_addr     = 0x61,
1562                 .input          = { {
1563                         .type   = CX88_VMUX_TELEVISION,
1564                         .vmux   = 0,
1565                         .gpio0  = 0x004ff,
1566                         .gpio1  = 0x010ff,
1567                         .gpio2  = 0x00001,
1568                 }, {
1569                         .type   = CX88_VMUX_COMPOSITE1,
1570                         .vmux   = 1,
1571                         .gpio0  = 0x004fb,
1572                         .gpio1  = 0x010ef,
1573                         .audioroute = 1,
1574                 }, {
1575                         .type   = CX88_VMUX_SVIDEO,
1576                         .vmux   = 2,
1577                         .gpio0  = 0x004fb,
1578                         .gpio1  = 0x010ef,
1579                         .audioroute = 1,
1580                 } },
1581                 .radio = {
1582                         .type   = CX88_RADIO,
1583                         .gpio0  = 0x004ff,
1584                         .gpio1  = 0x010ff,
1585                         .gpio2  = 0x0ff,
1586                 },
1587                 .mpeg           = CX88_MPEG_DVB,
1588         },
1589         /* Terry Wu <terrywu2009@gmail.com> */
1590         /* TV Audio :      set GPIO 2, 18, 19 value to 0, 1, 0 */
1591         /* FM Audio :      set GPIO 2, 18, 19 value to 0, 0, 0 */
1592         /* Line-in Audio : set GPIO 2, 18, 19 value to 0, 1, 1 */
1593         /* Mute Audio :    set GPIO 2 value to 1               */
1594         [CX88_BOARD_WINFAST_TV2000_XP_GLOBAL] = {
1595                 .name           = "Leadtek TV2000 XP Global",
1596                 .tuner_type     = TUNER_XC2028,
1597                 .tuner_addr     = 0x61,
1598                 .radio_type     = TUNER_XC2028,
1599                 .radio_addr     = 0x61,
1600                 .input          = { {
1601                         .type   = CX88_VMUX_TELEVISION,
1602                         .vmux   = 0,
1603                         .gpio0  = 0x0400,       /* pin 2 = 0 */
1604                         .gpio1  = 0x0000,
1605                         .gpio2  = 0x0C04,       /* pin 18 = 1, pin 19 = 0 */
1606                         .gpio3  = 0x0000,
1607                 }, {
1608                         .type   = CX88_VMUX_COMPOSITE1,
1609                         .vmux   = 1,
1610                         .gpio0  = 0x0400,       /* pin 2 = 0 */
1611                         .gpio1  = 0x0000,
1612                         .gpio2  = 0x0C0C,       /* pin 18 = 1, pin 19 = 1 */
1613                         .gpio3  = 0x0000,
1614                 }, {
1615                         .type   = CX88_VMUX_SVIDEO,
1616                         .vmux   = 2,
1617                         .gpio0  = 0x0400,       /* pin 2 = 0 */
1618                         .gpio1  = 0x0000,
1619                         .gpio2  = 0x0C0C,       /* pin 18 = 1, pin 19 = 1 */
1620                         .gpio3  = 0x0000,
1621                 } },
1622                 .radio = {
1623                         .type   = CX88_RADIO,
1624                         .gpio0  = 0x0400,        /* pin 2 = 0 */
1625                         .gpio1  = 0x0000,
1626                         .gpio2  = 0x0C00,       /* pin 18 = 0, pin 19 = 0 */
1627                         .gpio3  = 0x0000,
1628                 },
1629         },
1630         [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = {
1631                 .name           = "PowerColor RA330",   /* Long names may confuse LIRC. */
1632                 .tuner_type     = TUNER_XC2028,
1633                 .tuner_addr     = 0x61,
1634                 .input          = { {
1635                         .type   = CX88_VMUX_DEBUG,
1636                         .vmux   = 3,            /* Due to the way the cx88 driver is written,   */
1637                         .gpio0 = 0x00ff,        /* there is no way to deactivate audio pass-    */
1638                         .gpio1 = 0xf39d,        /* through without this entry. Furthermore, if  */
1639                         .gpio3 = 0x0000,        /* the TV mux entry is first, you get audio     */
1640                 }, {                            /* from the tuner on boot for a little while.   */
1641                         .type   = CX88_VMUX_TELEVISION,
1642                         .vmux   = 0,
1643                         .gpio0 = 0x00ff,
1644                         .gpio1 = 0xf35d,
1645                         .gpio3 = 0x0000,
1646                 }, {
1647                         .type   = CX88_VMUX_COMPOSITE1,
1648                         .vmux   = 1,
1649                         .gpio0 = 0x00ff,
1650                         .gpio1 = 0xf37d,
1651                         .gpio3 = 0x0000,
1652                 }, {
1653                         .type   = CX88_VMUX_SVIDEO,
1654                         .vmux   = 2,
1655                         .gpio0  = 0x000ff,
1656                         .gpio1  = 0x0f37d,
1657                         .gpio3  = 0x00000,
1658                 } },
1659                 .radio = {
1660                         .type   = CX88_RADIO,
1661                         .gpio0  = 0x000ff,
1662                         .gpio1  = 0x0f35d,
1663                         .gpio3  = 0x00000,
1664                 },
1665         },
1666         [CX88_BOARD_GENIATECH_X8000_MT] = {
1667                 /* Also PowerColor Real Angel 330 and Geniatech X800 OEM */
1668                 .name           = "Geniatech X8000-MT DVBT",
1669                 .tuner_type     = TUNER_XC2028,
1670                 .tuner_addr     = 0x61,
1671                 .input          = { {
1672                         .type   = CX88_VMUX_TELEVISION,
1673                         .vmux   = 0,
1674                         .gpio0  = 0x00000000,
1675                         .gpio1  = 0x00e3e341,
1676                         .gpio2  = 0x00000000,
1677                         .gpio3  = 0x00000000,
1678                 }, {
1679                         .type   = CX88_VMUX_COMPOSITE1,
1680                         .vmux   = 1,
1681                         .gpio0  = 0x00000000,
1682                         .gpio1  = 0x00e3e361,
1683                         .gpio2  = 0x00000000,
1684                         .gpio3  = 0x00000000,
1685                 }, {
1686                         .type   = CX88_VMUX_SVIDEO,
1687                         .vmux   = 2,
1688                         .gpio0  = 0x00000000,
1689                         .gpio1  = 0x00e3e361,
1690                         .gpio2  = 0x00000000,
1691                         .gpio3  = 0x00000000,
1692                 } },
1693                 .radio = {
1694                         .type   = CX88_RADIO,
1695                         .gpio0  = 0x00000000,
1696                         .gpio1  = 0x00e3e341,
1697                         .gpio2  = 0x00000000,
1698                         .gpio3  = 0x00000000,
1699                 },
1700                 .mpeg           = CX88_MPEG_DVB,
1701         },
1702         [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO] = {
1703                 .name           = "DViCO FusionHDTV DVB-T PRO",
1704                 .tuner_type     = TUNER_XC2028,
1705                 .tuner_addr     = 0x61,
1706                 .radio_type     = UNSET,
1707                 .radio_addr     = ADDR_UNSET,
1708                 .input          = { {
1709                         .type   = CX88_VMUX_COMPOSITE1,
1710                         .vmux   = 1,
1711                         .gpio0  = 0x000067df,
1712                 }, {
1713                         .type   = CX88_VMUX_SVIDEO,
1714                         .vmux   = 2,
1715                         .gpio0  = 0x000067df,
1716                 } },
1717                 .mpeg           = CX88_MPEG_DVB,
1718         },
1719         [CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD] = {
1720                 .name           = "DViCO FusionHDTV 7 Gold",
1721                 .tuner_type     = TUNER_XC5000,
1722                 .radio_type     = UNSET,
1723                 .tuner_addr     = ADDR_UNSET,
1724                 .radio_addr     = ADDR_UNSET,
1725                 .input          = {{
1726                         .type   = CX88_VMUX_TELEVISION,
1727                         .vmux   = 0,
1728                         .gpio0  = 0x10df,
1729                 },{
1730                         .type   = CX88_VMUX_COMPOSITE1,
1731                         .vmux   = 1,
1732                         .gpio0  = 0x16d9,
1733                 },{
1734                         .type   = CX88_VMUX_SVIDEO,
1735                         .vmux   = 2,
1736                         .gpio0  = 0x16d9,
1737                 }},
1738                 .mpeg           = CX88_MPEG_DVB,
1739         },
1740         [CX88_BOARD_PROLINK_PV_8000GT] = {
1741                 .name           = "Prolink Pixelview MPEG 8000GT",
1742                 .tuner_type     = TUNER_XC2028,
1743                 .tuner_addr     = 0x61,
1744                 .input          = { {
1745                         .type   = CX88_VMUX_TELEVISION,
1746                         .vmux   = 0,
1747                         .gpio0 = 0x0ff,
1748                         .gpio2 = 0x0cfb,
1749                 }, {
1750                         .type   = CX88_VMUX_COMPOSITE1,
1751                         .vmux   = 1,
1752                         .gpio2 = 0x0cfb,
1753                 }, {
1754                         .type   = CX88_VMUX_SVIDEO,
1755                         .vmux   = 2,
1756                         .gpio2 = 0x0cfb,
1757                 } },
1758                 .radio = {
1759                         .type   = CX88_RADIO,
1760                         .gpio2 = 0x0cfb,
1761                 },
1762         },
1763         [CX88_BOARD_PROLINK_PV_GLOBAL_XTREME] = {
1764                 .name           = "Prolink Pixelview Global Extreme",
1765                 .tuner_type     = TUNER_XC2028,
1766                 .tuner_addr     = 0x61,
1767                 .input          = { {
1768                         .type   = CX88_VMUX_TELEVISION,
1769                         .vmux   = 0,
1770                         .gpio0 = 0x04fb,
1771                         .gpio1 = 0x04080,
1772                         .gpio2 = 0x0cf7,
1773                 }, {
1774                         .type   = CX88_VMUX_COMPOSITE1,
1775                         .vmux   = 1,
1776                         .gpio0 = 0x04fb,
1777                         .gpio1 = 0x04080,
1778                         .gpio2 = 0x0cfb,
1779                 }, {
1780                         .type   = CX88_VMUX_SVIDEO,
1781                         .vmux   = 2,
1782                         .gpio0 = 0x04fb,
1783                         .gpio1 = 0x04080,
1784                         .gpio2 = 0x0cfb,
1785                 } },
1786                 .radio = {
1787                         .type   = CX88_RADIO,
1788                         .gpio0 = 0x04ff,
1789                         .gpio1 = 0x04080,
1790                         .gpio2 = 0x0cf7,
1791                 },
1792         },
1793         /* Both radio, analog and ATSC work with this board.
1794            However, for analog to work, s5h1409 gate should be open,
1795            otherwise, tuner-xc3028 won't be detected.
1796            A proper fix require using the newer i2c methods to add
1797            tuner-xc3028 without doing an i2c probe.
1798          */
1799         [CX88_BOARD_KWORLD_ATSC_120] = {
1800                 .name           = "Kworld PlusTV HD PCI 120 (ATSC 120)",
1801                 .tuner_type     = TUNER_XC2028,
1802                 .radio_type     = UNSET,
1803                 .tuner_addr     = ADDR_UNSET,
1804                 .radio_addr     = ADDR_UNSET,
1805                 .input          = { {
1806                         .type   = CX88_VMUX_TELEVISION,
1807                         .vmux   = 0,
1808                         .gpio0  = 0x000000ff,
1809                         .gpio1  = 0x0000f35d,
1810                         .gpio2  = 0x00000000,
1811                 }, {
1812                         .type   = CX88_VMUX_COMPOSITE1,
1813                         .vmux   = 1,
1814                         .gpio0  = 0x000000ff,
1815                         .gpio1  = 0x0000f37e,
1816                         .gpio2  = 0x00000000,
1817                 }, {
1818                         .type   = CX88_VMUX_SVIDEO,
1819                         .vmux   = 2,
1820                         .gpio0  = 0x000000ff,
1821                         .gpio1  = 0x0000f37e,
1822                         .gpio2  = 0x00000000,
1823                 } },
1824                 .radio = {
1825                         .type   = CX88_RADIO,
1826                         .gpio0  = 0x000000ff,
1827                         .gpio1  = 0x0000f35d,
1828                         .gpio2  = 0x00000000,
1829                 },
1830                 .mpeg           = CX88_MPEG_DVB,
1831         },
1832         [CX88_BOARD_HAUPPAUGE_HVR4000] = {
1833                 .name           = "Hauppauge WinTV-HVR4000 DVB-S/S2/T/Hybrid",
1834                 .tuner_type     = TUNER_PHILIPS_FMD1216ME_MK3,
1835                 .radio_type     = UNSET,
1836                 .tuner_addr     = ADDR_UNSET,
1837                 .radio_addr     = ADDR_UNSET,
1838                 .tda9887_conf   = TDA9887_PRESENT,
1839                 .audio_chip     = V4L2_IDENT_WM8775,
1840                 /*
1841                  * GPIO0 (WINTV2000)
1842                  *
1843                  * Analogue     SAT     DVB-T
1844                  * Antenna      0xc4bf  0xc4bb
1845                  * Composite    0xc4bf  0xc4bb
1846                  * S-Video      0xc4bf  0xc4bb
1847                  * Composite1   0xc4ff  0xc4fb
1848                  * S-Video1     0xc4ff  0xc4fb
1849                  *
1850                  * BIT  VALUE   FUNCTION GP{x}_IO
1851                  * 0    1       I:?
1852                  * 1    1       I:?
1853                  * 2    1       O:MPEG PORT 0=DVB-T 1=DVB-S
1854                  * 3    1       I:?
1855                  * 4    1       I:?
1856                  * 5    1       I:?
1857                  * 6    0       O:INPUT SELECTOR 0=INTERNAL 1=EXPANSION
1858                  * 7    1       O:DVB-T DEMOD RESET LOW
1859                  *
1860                  * BIT  VALUE   FUNCTION GP{x}_OE
1861                  * 8    0       I
1862                  * 9    0       I
1863                  * a    1       O
1864                  * b    0       I
1865                  * c    0       I
1866                  * d    0       I
1867                  * e    1       O
1868                  * f    1       O
1869                  *
1870                  * WM8775 ADC
1871                  *
1872                  * 1: TV Audio / FM Mono
1873                  * 2: Line-In
1874                  * 3: Line-In Expansion
1875                  * 4: FM Stereo
1876                  */
1877                 .input          = {{
1878                         .type   = CX88_VMUX_TELEVISION,
1879                         .vmux   = 0,
1880                         .gpio0  = 0xc4bf,
1881                         /* 1: TV Audio / FM Mono */
1882                         .audioroute = 1,
1883                 }, {
1884                         .type   = CX88_VMUX_COMPOSITE1,
1885                         .vmux   = 1,
1886                         .gpio0  = 0xc4bf,
1887                         /* 2: Line-In */
1888                         .audioroute = 2,
1889                 }, {
1890                         .type   = CX88_VMUX_SVIDEO,
1891                         .vmux   = 2,
1892                         .gpio0  = 0xc4bf,
1893                         /* 2: Line-In */
1894                         .audioroute = 2,
1895                 } },
1896                 .radio = {
1897                         .type   = CX88_RADIO,
1898                         .gpio0  = 0xc4bf,
1899                         /* 4: FM Stereo */
1900                         .audioroute = 8,
1901                 },
1902                 .mpeg           = CX88_MPEG_DVB,
1903                 .num_frontends  = 2,
1904         },
1905         [CX88_BOARD_HAUPPAUGE_HVR4000LITE] = {
1906                 .name           = "Hauppauge WinTV-HVR4000(Lite) DVB-S/S2",
1907                 .tuner_type     = UNSET,
1908                 .radio_type     = UNSET,
1909                 .tuner_addr     = ADDR_UNSET,
1910                 .radio_addr     = ADDR_UNSET,
1911                 .input          = {{
1912                         .type   = CX88_VMUX_DVB,
1913                         .vmux   = 0,
1914                 } },
1915                 .mpeg           = CX88_MPEG_DVB,
1916         },
1917         [CX88_BOARD_TEVII_S420] = {
1918                 .name           = "TeVii S420 DVB-S",
1919                 .tuner_type     = UNSET,
1920                 .radio_type     = UNSET,
1921                 .tuner_addr     = ADDR_UNSET,
1922                 .radio_addr     = ADDR_UNSET,
1923                 .input          = {{
1924                         .type   = CX88_VMUX_DVB,
1925                         .vmux   = 0,
1926                 } },
1927                 .mpeg           = CX88_MPEG_DVB,
1928         },
1929         [CX88_BOARD_TEVII_S460] = {
1930                 .name           = "TeVii S460 DVB-S/S2",
1931                 .tuner_type     = UNSET,
1932                 .radio_type     = UNSET,
1933                 .tuner_addr     = ADDR_UNSET,
1934                 .radio_addr     = ADDR_UNSET,
1935                 .input          = {{
1936                         .type   = CX88_VMUX_DVB,
1937                         .vmux   = 0,
1938                 } },
1939                 .mpeg           = CX88_MPEG_DVB,
1940         },
1941         [CX88_BOARD_OMICOM_SS4_PCI] = {
1942                 .name           = "Omicom SS4 DVB-S/S2 PCI",
1943                 .tuner_type     = UNSET,
1944                 .radio_type     = UNSET,
1945                 .tuner_addr     = ADDR_UNSET,
1946                 .radio_addr     = ADDR_UNSET,
1947                 .input          = {{
1948                         .type   = CX88_VMUX_DVB,
1949                         .vmux   = 0,
1950                 } },
1951                 .mpeg           = CX88_MPEG_DVB,
1952         },
1953         [CX88_BOARD_TBS_8910] = {
1954                 .name           = "TBS 8910 DVB-S",
1955                 .tuner_type     = UNSET,
1956                 .radio_type     = UNSET,
1957                 .tuner_addr     = ADDR_UNSET,
1958                 .radio_addr     = ADDR_UNSET,
1959                 .input          = {{
1960                         .type   = CX88_VMUX_DVB,
1961                         .vmux   = 0,
1962                 } },
1963                 .mpeg           = CX88_MPEG_DVB,
1964         },
1965         [CX88_BOARD_TBS_8920] = {
1966                 .name           = "TBS 8920 DVB-S/S2",
1967                 .tuner_type     = TUNER_ABSENT,
1968                 .radio_type     = UNSET,
1969                 .tuner_addr     = ADDR_UNSET,
1970                 .radio_addr     = ADDR_UNSET,
1971                 .input          = {{
1972                         .type   = CX88_VMUX_DVB,
1973                         .vmux   = 0,
1974                         .gpio0  = 0x8080,
1975                 } },
1976                 .mpeg           = CX88_MPEG_DVB,
1977         },
1978         [CX88_BOARD_PROF_6200] = {
1979                 .name           = "Prof 6200 DVB-S",
1980                 .tuner_type     = UNSET,
1981                 .radio_type     = UNSET,
1982                 .tuner_addr     = ADDR_UNSET,
1983                 .radio_addr     = ADDR_UNSET,
1984                 .input          = {{
1985                         .type   = CX88_VMUX_DVB,
1986                         .vmux   = 0,
1987                 } },
1988                 .mpeg           = CX88_MPEG_DVB,
1989         },
1990         [CX88_BOARD_PROF_7300] = {
1991                 .name           = "PROF 7300 DVB-S/S2",
1992                 .tuner_type     = UNSET,
1993                 .radio_type     = UNSET,
1994                 .tuner_addr     = ADDR_UNSET,
1995                 .radio_addr     = ADDR_UNSET,
1996                 .input          = {{
1997                         .type   = CX88_VMUX_DVB,
1998                         .vmux   = 0,
1999                 } },
2000                 .mpeg           = CX88_MPEG_DVB,
2001         },
2002         [CX88_BOARD_SATTRADE_ST4200] = {
2003                 .name           = "SATTRADE ST4200 DVB-S/S2",
2004                 .tuner_type     = UNSET,
2005                 .radio_type     = UNSET,
2006                 .tuner_addr     = ADDR_UNSET,
2007                 .radio_addr     = ADDR_UNSET,
2008                 .input          = {{
2009                         .type   = CX88_VMUX_DVB,
2010                         .vmux   = 0,
2011                 } },
2012                 .mpeg           = CX88_MPEG_DVB,
2013         },
2014         [CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII] = {
2015                 .name           = "Terratec Cinergy HT PCI MKII",
2016                 .tuner_type     = TUNER_XC2028,
2017                 .tuner_addr     = 0x61,
2018                 .radio_type     = TUNER_XC2028,
2019                 .radio_addr     = 0x61,
2020                 .input          = { {
2021                         .type   = CX88_VMUX_TELEVISION,
2022                         .vmux   = 0,
2023                         .gpio0  = 0x004ff,
2024                         .gpio1  = 0x010ff,
2025                         .gpio2  = 0x00001,
2026                 }, {
2027                         .type   = CX88_VMUX_COMPOSITE1,
2028                         .vmux   = 1,
2029                         .gpio0  = 0x004fb,
2030                         .gpio1  = 0x010ef,
2031                         .audioroute = 1,
2032                 }, {
2033                         .type   = CX88_VMUX_SVIDEO,
2034                         .vmux   = 2,
2035                         .gpio0  = 0x004fb,
2036                         .gpio1  = 0x010ef,
2037                         .audioroute = 1,
2038                 } },
2039                 .radio = {
2040                         .type   = CX88_RADIO,
2041                         .gpio0  = 0x004ff,
2042                         .gpio1  = 0x010ff,
2043                         .gpio2  = 0x0ff,
2044                 },
2045                 .mpeg           = CX88_MPEG_DVB,
2046         },
2047         [CX88_BOARD_HAUPPAUGE_IRONLY] = {
2048                 .name           = "Hauppauge WinTV-IR Only",
2049                 .tuner_type     = UNSET,
2050                 .radio_type     = UNSET,
2051                 .tuner_addr     = ADDR_UNSET,
2052                 .radio_addr     = ADDR_UNSET,
2053         },
2054         [CX88_BOARD_WINFAST_DTV1800H] = {
2055                 .name           = "Leadtek WinFast DTV1800 Hybrid",
2056                 .tuner_type     = TUNER_XC2028,
2057                 .radio_type     = TUNER_XC2028,
2058                 .tuner_addr     = 0x61,
2059                 .radio_addr     = 0x61,
2060                 /*
2061                  * GPIO setting
2062                  *
2063                  *  2: mute (0=off,1=on)
2064                  * 12: tuner reset pin
2065                  * 13: audio source (0=tuner audio,1=line in)
2066                  * 14: FM (0=on,1=off ???)
2067                  */
2068                 .input          = {{
2069                         .type   = CX88_VMUX_TELEVISION,
2070                         .vmux   = 0,
2071                         .gpio0  = 0x0400,       /* pin 2 = 0 */
2072                         .gpio1  = 0x6040,       /* pin 13 = 0, pin 14 = 1 */
2073                         .gpio2  = 0x0000,
2074                 }, {
2075                         .type   = CX88_VMUX_COMPOSITE1,
2076                         .vmux   = 1,
2077                         .gpio0  = 0x0400,       /* pin 2 = 0 */
2078                         .gpio1  = 0x6060,       /* pin 13 = 1, pin 14 = 1 */
2079                         .gpio2  = 0x0000,
2080                 }, {
2081                         .type   = CX88_VMUX_SVIDEO,
2082                         .vmux   = 2,
2083                         .gpio0  = 0x0400,       /* pin 2 = 0 */
2084                         .gpio1  = 0x6060,       /* pin 13 = 1, pin 14 = 1 */
2085                         .gpio2  = 0x0000,
2086                 } },
2087                 .radio = {
2088                         .type   = CX88_RADIO,
2089                         .gpio0  = 0x0400,       /* pin 2 = 0 */
2090                         .gpio1  = 0x6000,       /* pin 13 = 0, pin 14 = 0 */
2091                         .gpio2  = 0x0000,
2092                 },
2093                 .mpeg           = CX88_MPEG_DVB,
2094         },
2095         [CX88_BOARD_PROF_7301] = {
2096                 .name           = "Prof 7301 DVB-S/S2",
2097                 .tuner_type     = UNSET,
2098                 .radio_type     = UNSET,
2099                 .tuner_addr     = ADDR_UNSET,
2100                 .radio_addr     = ADDR_UNSET,
2101                 .input          = { {
2102                         .type   = CX88_VMUX_DVB,
2103                         .vmux   = 0,
2104                 } },
2105                 .mpeg           = CX88_MPEG_DVB,
2106         },
2107         [CX88_BOARD_TWINHAN_VP1027_DVBS] = {
2108                 .name           = "Twinhan VP-1027 DVB-S",
2109                 .tuner_type     = TUNER_ABSENT,
2110                 .radio_type     = UNSET,
2111                 .tuner_addr     = ADDR_UNSET,
2112                 .radio_addr     = ADDR_UNSET,
2113                 .input          = {{
2114                        .type   = CX88_VMUX_DVB,
2115                        .vmux   = 0,
2116                 } },
2117                 .mpeg           = CX88_MPEG_DVB,
2118         },
2119 };
2120
2121 /* ------------------------------------------------------------------ */
2122 /* PCI subsystem IDs                                                  */
2123
2124 static const struct cx88_subid cx88_subids[] = {
2125         {
2126                 .subvendor = 0x0070,
2127                 .subdevice = 0x3400,
2128                 .card      = CX88_BOARD_HAUPPAUGE,
2129         },{
2130                 .subvendor = 0x0070,
2131                 .subdevice = 0x3401,
2132                 .card      = CX88_BOARD_HAUPPAUGE,
2133         },{
2134                 .subvendor = 0x14c7,
2135                 .subdevice = 0x0106,
2136                 .card      = CX88_BOARD_GDI,
2137         },{
2138                 .subvendor = 0x14c7,
2139                 .subdevice = 0x0107, /* with mpeg encoder */
2140                 .card      = CX88_BOARD_GDI,
2141         },{
2142                 .subvendor = PCI_VENDOR_ID_ATI,
2143                 .subdevice = 0x00f8,
2144                 .card      = CX88_BOARD_ATI_WONDER_PRO,
2145         }, {
2146                 .subvendor = PCI_VENDOR_ID_ATI,
2147                 .subdevice = 0x00f9,
2148                 .card      = CX88_BOARD_ATI_WONDER_PRO,
2149         }, {
2150                 .subvendor = 0x107d,
2151                 .subdevice = 0x6611,
2152                 .card      = CX88_BOARD_WINFAST2000XP_EXPERT,
2153         },{
2154                 .subvendor = 0x107d,
2155                 .subdevice = 0x6613,    /* NTSC */
2156                 .card      = CX88_BOARD_WINFAST2000XP_EXPERT,
2157         },{
2158                 .subvendor = 0x107d,
2159                 .subdevice = 0x6620,
2160                 .card      = CX88_BOARD_WINFAST_DV2000,
2161         },{
2162                 .subvendor = 0x107d,
2163                 .subdevice = 0x663b,
2164                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2165         },{
2166                 .subvendor = 0x107d,
2167                 .subdevice = 0x663c,
2168                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2169         },{
2170                 .subvendor = 0x1461,
2171                 .subdevice = 0x000b,
2172                 .card      = CX88_BOARD_AVERTV_STUDIO_303,
2173         },{
2174                 .subvendor = 0x1462,
2175                 .subdevice = 0x8606,
2176                 .card      = CX88_BOARD_MSI_TVANYWHERE_MASTER,
2177         },{
2178                 .subvendor = 0x10fc,
2179                 .subdevice = 0xd003,
2180                 .card      = CX88_BOARD_IODATA_GVVCP3PCI,
2181         },{
2182                 .subvendor = 0x1043,
2183                 .subdevice = 0x4823,  /* with mpeg encoder */
2184                 .card      = CX88_BOARD_ASUS_PVR_416,
2185         },{
2186                 .subvendor = 0x17de,
2187                 .subdevice = 0x08a6,
2188                 .card      = CX88_BOARD_KWORLD_DVB_T,
2189         },{
2190                 .subvendor = 0x18ac,
2191                 .subdevice = 0xd810,
2192                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
2193         },{
2194                 .subvendor = 0x18ac,
2195                 .subdevice = 0xd820,
2196                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T,
2197         },{
2198                 .subvendor = 0x18ac,
2199                 .subdevice = 0xdb00,
2200                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1,
2201         },{
2202                 .subvendor = 0x0070,
2203                 .subdevice = 0x9002,
2204                 .card      = CX88_BOARD_HAUPPAUGE_DVB_T1,
2205         },{
2206                 .subvendor = 0x14f1,
2207                 .subdevice = 0x0187,
2208                 .card      = CX88_BOARD_CONEXANT_DVB_T1,
2209         },{
2210                 .subvendor = 0x1540,
2211                 .subdevice = 0x2580,
2212                 .card      = CX88_BOARD_PROVIDEO_PV259,
2213         },{
2214                 .subvendor = 0x18ac,
2215                 .subdevice = 0xdb10,
2216                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
2217         },{
2218                 .subvendor = 0x1554,
2219                 .subdevice = 0x4811,
2220                 .card      = CX88_BOARD_PIXELVIEW,
2221         },{
2222                 .subvendor = 0x7063,
2223                 .subdevice = 0x3000, /* HD-3000 card */
2224                 .card      = CX88_BOARD_PCHDTV_HD3000,
2225         },{
2226                 .subvendor = 0x17de,
2227                 .subdevice = 0xa8a6,
2228                 .card      = CX88_BOARD_DNTV_LIVE_DVB_T,
2229         },{
2230                 .subvendor = 0x0070,
2231                 .subdevice = 0x2801,
2232                 .card      = CX88_BOARD_HAUPPAUGE_ROSLYN,
2233         },{
2234                 .subvendor = 0x14f1,
2235                 .subdevice = 0x0342,
2236                 .card      = CX88_BOARD_DIGITALLOGIC_MEC,
2237         },{
2238                 .subvendor = 0x10fc,
2239                 .subdevice = 0xd035,
2240                 .card      = CX88_BOARD_IODATA_GVBCTV7E,
2241         },{
2242                 .subvendor = 0x1421,
2243                 .subdevice = 0x0334,
2244                 .card      = CX88_BOARD_ADSTECH_DVB_T_PCI,
2245         },{
2246                 .subvendor = 0x153b,
2247                 .subdevice = 0x1166,
2248                 .card      = CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1,
2249         },{
2250                 .subvendor = 0x18ac,
2251                 .subdevice = 0xd500,
2252                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD,
2253         },{
2254                 .subvendor = 0x1461,
2255                 .subdevice = 0x8011,
2256                 .card      = CX88_BOARD_AVERMEDIA_ULTRATV_MC_550,
2257         },{
2258                 .subvendor = PCI_VENDOR_ID_ATI,
2259                 .subdevice = 0xa101,
2260                 .card      = CX88_BOARD_ATI_HDTVWONDER,
2261         },{
2262                 .subvendor = 0x107d,
2263                 .subdevice = 0x665f,
2264                 .card      = CX88_BOARD_WINFAST_DTV1000,
2265         },{
2266                 .subvendor = 0x1461,
2267                 .subdevice = 0x000a,
2268                 .card      = CX88_BOARD_AVERTV_303,
2269         },{
2270                 .subvendor = 0x0070,
2271                 .subdevice = 0x9200,
2272                 .card      = CX88_BOARD_HAUPPAUGE_NOVASE2_S1,
2273         },{
2274                 .subvendor = 0x0070,
2275                 .subdevice = 0x9201,
2276                 .card      = CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1,
2277         },{
2278                 .subvendor = 0x0070,
2279                 .subdevice = 0x9202,
2280                 .card      = CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1,
2281         },{
2282                 .subvendor = 0x17de,
2283                 .subdevice = 0x08b2,
2284                 .card      = CX88_BOARD_KWORLD_DVBS_100,
2285         },{
2286                 .subvendor = 0x0070,
2287                 .subdevice = 0x9400,
2288                 .card      = CX88_BOARD_HAUPPAUGE_HVR1100,
2289         },{
2290                 .subvendor = 0x0070,
2291                 .subdevice = 0x9402,
2292                 .card      = CX88_BOARD_HAUPPAUGE_HVR1100,
2293         },{
2294                 .subvendor = 0x0070,
2295                 .subdevice = 0x9800,
2296                 .card      = CX88_BOARD_HAUPPAUGE_HVR1100LP,
2297         },{
2298                 .subvendor = 0x0070,
2299                 .subdevice = 0x9802,
2300                 .card      = CX88_BOARD_HAUPPAUGE_HVR1100LP,
2301         },{
2302                 .subvendor = 0x0070,
2303                 .subdevice = 0x9001,
2304                 .card      = CX88_BOARD_HAUPPAUGE_DVB_T1,
2305         },{
2306                 .subvendor = 0x1822,
2307                 .subdevice = 0x0025,
2308                 .card      = CX88_BOARD_DNTV_LIVE_DVB_T_PRO,
2309         },{
2310                 .subvendor = 0x17de,
2311                 .subdevice = 0x08a1,
2312                 .card      = CX88_BOARD_KWORLD_DVB_T_CX22702,
2313         },{
2314                 .subvendor = 0x18ac,
2315                 .subdevice = 0xdb50,
2316                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL,
2317         },{
2318                 .subvendor = 0x18ac,
2319                 .subdevice = 0xdb54,
2320                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL,
2321                 /* Re-branded DViCO: DigitalNow DVB-T Dual */
2322         },{
2323                 .subvendor = 0x18ac,
2324                 .subdevice = 0xdb11,
2325                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
2326                 /* Re-branded DViCO: UltraView DVB-T Plus */
2327         }, {
2328                 .subvendor = 0x18ac,
2329                 .subdevice = 0xdb30,
2330                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO,
2331         }, {
2332                 .subvendor = 0x17de,
2333                 .subdevice = 0x0840,
2334                 .card      = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT,
2335         },{
2336                 .subvendor = 0x1421,
2337                 .subdevice = 0x0305,
2338                 .card      = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT,
2339         },{
2340                 .subvendor = 0x18ac,
2341                 .subdevice = 0xdb40,
2342                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID,
2343         },{
2344                 .subvendor = 0x18ac,
2345                 .subdevice = 0xdb44,
2346                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID,
2347         },{
2348                 .subvendor = 0x7063,
2349                 .subdevice = 0x5500,
2350                 .card      = CX88_BOARD_PCHDTV_HD5500,
2351         },{
2352                 .subvendor = 0x17de,
2353                 .subdevice = 0x0841,
2354                 .card      = CX88_BOARD_KWORLD_MCE200_DELUXE,
2355         },{
2356                 .subvendor = 0x1822,
2357                 .subdevice = 0x0019,
2358                 .card      = CX88_BOARD_DNTV_LIVE_DVB_T_PRO,
2359         },{
2360                 .subvendor = 0x1554,
2361                 .subdevice = 0x4813,
2362                 .card      = CX88_BOARD_PIXELVIEW_PLAYTV_P7000,
2363         },{
2364                 .subvendor = 0x14f1,
2365                 .subdevice = 0x0842,
2366                 .card      = CX88_BOARD_NPGTECH_REALTV_TOP10FM,
2367         },{
2368                 .subvendor = 0x107d,
2369                 .subdevice = 0x665e,
2370                 .card      = CX88_BOARD_WINFAST_DTV2000H,
2371         },{
2372                 .subvendor = 0x107d,
2373                 .subdevice = 0x6f2b,
2374                 .card      = CX88_BOARD_WINFAST_DTV2000H_J,
2375         },{
2376                 .subvendor = 0x18ac,
2377                 .subdevice = 0xd800, /* FusionHDTV 3 Gold (original revision) */
2378                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
2379         },{
2380                 .subvendor = 0x14f1,
2381                 .subdevice = 0x0084,
2382                 .card      = CX88_BOARD_GENIATECH_DVBS,
2383         },{
2384                 .subvendor = 0x0070,
2385                 .subdevice = 0x1404,
2386                 .card      = CX88_BOARD_HAUPPAUGE_HVR3000,
2387         }, {
2388                 .subvendor = 0x18ac,
2389                 .subdevice = 0xdc00,
2390                 .card      = CX88_BOARD_SAMSUNG_SMT_7020,
2391         }, {
2392                 .subvendor = 0x18ac,
2393                 .subdevice = 0xdccd,
2394                 .card      = CX88_BOARD_SAMSUNG_SMT_7020,
2395         },{
2396                 .subvendor = 0x1461,
2397                 .subdevice = 0xc111, /* AverMedia M150-D */
2398                 /* This board is known to work with the ASUS PVR416 config */
2399                 .card      = CX88_BOARD_ASUS_PVR_416,
2400         },{
2401                 .subvendor = 0xc180,
2402                 .subdevice = 0xc980,
2403                 .card      = CX88_BOARD_TE_DTV_250_OEM_SWANN,
2404         },{
2405                 .subvendor = 0x0070,
2406                 .subdevice = 0x9600,
2407                 .card      = CX88_BOARD_HAUPPAUGE_HVR1300,
2408         },{
2409                 .subvendor = 0x0070,
2410                 .subdevice = 0x9601,
2411                 .card      = CX88_BOARD_HAUPPAUGE_HVR1300,
2412         },{
2413                 .subvendor = 0x0070,
2414                 .subdevice = 0x9602,
2415                 .card      = CX88_BOARD_HAUPPAUGE_HVR1300,
2416         },{
2417                 .subvendor = 0x107d,
2418                 .subdevice = 0x6632,
2419                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2420         },{
2421                 .subvendor = 0x12ab,
2422                 .subdevice = 0x2300, /* Club3D Zap TV2100 */
2423                 .card      = CX88_BOARD_KWORLD_DVB_T_CX22702,
2424         },{
2425                 .subvendor = 0x0070,
2426                 .subdevice = 0x9000,
2427                 .card      = CX88_BOARD_HAUPPAUGE_DVB_T1,
2428         },{
2429                 .subvendor = 0x0070,
2430                 .subdevice = 0x1400,
2431                 .card      = CX88_BOARD_HAUPPAUGE_HVR3000,
2432         },{
2433                 .subvendor = 0x0070,
2434                 .subdevice = 0x1401,
2435                 .card      = CX88_BOARD_HAUPPAUGE_HVR3000,
2436         },{
2437                 .subvendor = 0x0070,
2438                 .subdevice = 0x1402,
2439                 .card      = CX88_BOARD_HAUPPAUGE_HVR3000,
2440         },{
2441                 .subvendor = 0x1421,
2442                 .subdevice = 0x0341, /* ADS Tech InstantTV DVB-S */
2443                 .card      = CX88_BOARD_KWORLD_DVBS_100,
2444         },{
2445                 .subvendor = 0x1421,
2446                 .subdevice = 0x0390,
2447                 .card      = CX88_BOARD_ADSTECH_PTV_390,
2448         },{
2449                 .subvendor = 0x11bd,
2450                 .subdevice = 0x0051,
2451                 .card      = CX88_BOARD_PINNACLE_PCTV_HD_800i,
2452         }, {
2453                 .subvendor = 0x18ac,
2454                 .subdevice = 0xd530,
2455                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO,
2456         }, {
2457                 .subvendor = 0x12ab,
2458                 .subdevice = 0x1788,
2459                 .card      = CX88_BOARD_PINNACLE_HYBRID_PCTV,
2460         }, {
2461                 .subvendor = 0x14f1,
2462                 .subdevice = 0xea3d,
2463                 .card      = CX88_BOARD_POWERCOLOR_REAL_ANGEL,
2464         }, {
2465                 .subvendor = 0x107d,
2466                 .subdevice = 0x6f18,
2467                 .card      = CX88_BOARD_WINFAST_TV2000_XP_GLOBAL,
2468         }, {
2469                 .subvendor = 0x14f1,
2470                 .subdevice = 0x8852,
2471                 .card      = CX88_BOARD_GENIATECH_X8000_MT,
2472         }, {
2473                 .subvendor = 0x18ac,
2474                 .subdevice = 0xd610,
2475                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD,
2476         }, {
2477                 .subvendor = 0x1554,
2478                 .subdevice = 0x4935,
2479                 .card      = CX88_BOARD_PROLINK_PV_8000GT,
2480         }, {
2481                 .subvendor = 0x1554,
2482                 .subdevice = 0x4976,
2483                 .card      = CX88_BOARD_PROLINK_PV_GLOBAL_XTREME,
2484         }, {
2485                 .subvendor = 0x17de,
2486                 .subdevice = 0x08c1,
2487                 .card      = CX88_BOARD_KWORLD_ATSC_120,
2488         }, {
2489                 .subvendor = 0x0070,
2490                 .subdevice = 0x6900,
2491                 .card      = CX88_BOARD_HAUPPAUGE_HVR4000,
2492         }, {
2493                 .subvendor = 0x0070,
2494                 .subdevice = 0x6904,
2495                 .card      = CX88_BOARD_HAUPPAUGE_HVR4000,
2496         }, {
2497                 .subvendor = 0x0070,
2498                 .subdevice = 0x6902,
2499                 .card      = CX88_BOARD_HAUPPAUGE_HVR4000,
2500         }, {
2501                 .subvendor = 0x0070,
2502                 .subdevice = 0x6905,
2503                 .card      = CX88_BOARD_HAUPPAUGE_HVR4000LITE,
2504         }, {
2505                 .subvendor = 0x0070,
2506                 .subdevice = 0x6906,
2507                 .card      = CX88_BOARD_HAUPPAUGE_HVR4000LITE,
2508         }, {
2509                 .subvendor = 0xd420,
2510                 .subdevice = 0x9022,
2511                 .card      = CX88_BOARD_TEVII_S420,
2512         }, {
2513                 .subvendor = 0xd460,
2514                 .subdevice = 0x9022,
2515                 .card      = CX88_BOARD_TEVII_S460,
2516         }, {
2517                 .subvendor = 0xA044,
2518                 .subdevice = 0x2011,
2519                 .card      = CX88_BOARD_OMICOM_SS4_PCI,
2520         }, {
2521                 .subvendor = 0x8910,
2522                 .subdevice = 0x8888,
2523                 .card      = CX88_BOARD_TBS_8910,
2524         }, {
2525                 .subvendor = 0x8920,
2526                 .subdevice = 0x8888,
2527                 .card      = CX88_BOARD_TBS_8920,
2528         }, {
2529                 .subvendor = 0xb022,
2530                 .subdevice = 0x3022,
2531                 .card      = CX88_BOARD_PROF_6200,
2532         }, {
2533                 .subvendor = 0xB033,
2534                 .subdevice = 0x3033,
2535                 .card      = CX88_BOARD_PROF_7300,
2536         }, {
2537                 .subvendor = 0xb200,
2538                 .subdevice = 0x4200,
2539                 .card      = CX88_BOARD_SATTRADE_ST4200,
2540         }, {
2541                 .subvendor = 0x153b,
2542                 .subdevice = 0x1177,
2543                 .card      = CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII,
2544         }, {
2545                 .subvendor = 0x0070,
2546                 .subdevice = 0x9290,
2547                 .card      = CX88_BOARD_HAUPPAUGE_IRONLY,
2548         }, {
2549                 .subvendor = 0x107d,
2550                 .subdevice = 0x6654,
2551                 .card      = CX88_BOARD_WINFAST_DTV1800H,
2552         }, {
2553                 /* PVR2000 PAL Model [107d:6630] */
2554                 .subvendor = 0x107d,
2555                 .subdevice = 0x6630,
2556                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2557         }, {
2558                 /* PVR2000 PAL Model [107d:6638] */
2559                 .subvendor = 0x107d,
2560                 .subdevice = 0x6638,
2561                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2562         }, {
2563                 /* PVR2000 NTSC Model [107d:6631] */
2564                 .subvendor = 0x107d,
2565                 .subdevice = 0x6631,
2566                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2567         }, {
2568                 /* PVR2000 NTSC Model [107d:6637] */
2569                 .subvendor = 0x107d,
2570                 .subdevice = 0x6637,
2571                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2572         }, {
2573                 /* PVR2000 NTSC Model [107d:663d] */
2574                 .subvendor = 0x107d,
2575                 .subdevice = 0x663d,
2576                 .card      = CX88_BOARD_LEADTEK_PVR2000,
2577         }, {
2578                 /* DV2000 NTSC Model [107d:6621] */
2579                 .subvendor = 0x107d,
2580                 .subdevice = 0x6621,
2581                 .card      = CX88_BOARD_WINFAST_DV2000,
2582         }, {
2583                 /* TV2000 XP Global [107d:6618]  */
2584                 .subvendor = 0x107d,
2585                 .subdevice = 0x6618,
2586                 .card      = CX88_BOARD_WINFAST_TV2000_XP_GLOBAL,
2587         }, {
2588                 .subvendor = 0xb034,
2589                 .subdevice = 0x3034,
2590                 .card      = CX88_BOARD_PROF_7301,
2591         }, {
2592                 .subvendor = 0x1822,
2593                 .subdevice = 0x0023,
2594                 .card      = CX88_BOARD_TWINHAN_VP1027_DVBS,
2595         },
2596 };
2597
2598 /* ----------------------------------------------------------------------- */
2599 /* some leadtek specific stuff                                             */
2600
2601 static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
2602 {
2603         if (eeprom_data[4] != 0x7d ||
2604             eeprom_data[5] != 0x10 ||
2605             eeprom_data[7] != 0x66) {
2606                 warn_printk(core, "Leadtek eeprom invalid.\n");
2607                 return;
2608         }
2609
2610         /* Terry Wu <terrywu2009@gmail.com> */
2611         switch (eeprom_data[6]) {
2612         case 0x13: /* SSID 6613 for TV2000 XP Expert NTSC Model */
2613         case 0x21: /* SSID 6621 for DV2000 NTSC Model */
2614         case 0x31: /* SSID 6631 for PVR2000 NTSC Model */
2615         case 0x37: /* SSID 6637 for PVR2000 NTSC Model */
2616         case 0x3d: /* SSID 6637 for PVR2000 NTSC Model */
2617                 core->board.tuner_type = TUNER_PHILIPS_FM1236_MK3;
2618                 break;
2619         default:
2620                 core->board.tuner_type = TUNER_PHILIPS_FM1216ME_MK3;
2621                 break;
2622         }
2623
2624         info_printk(core, "Leadtek Winfast 2000XP Expert config: "
2625                     "tuner=%d, eeprom[0]=0x%02x\n",
2626                     core->board.tuner_type, eeprom_data[0]);
2627 }
2628
2629 static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
2630 {
2631         struct tveeprom tv;
2632
2633         tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data);
2634         core->board.tuner_type = tv.tuner_type;
2635         core->tuner_formats = tv.tuner_formats;
2636         core->board.radio.type = tv.has_radio ? CX88_RADIO : 0;
2637
2638         /* Make sure we support the board model */
2639         switch (tv.model)
2640         {
2641         case 14009: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in) */
2642         case 14019: /* WinTV-HVR3000 (Retail, IR Blaster, b/panel video, 3.5mm audio in) */
2643         case 14029: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge) */
2644         case 14109: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - low profile) */
2645         case 14129: /* WinTV-HVR3000 (Retail, IR, b/panel video, 3.5mm audio in - 880 bridge - LP) */
2646         case 14559: /* WinTV-HVR3000 (OEM, no IR, b/panel video, 3.5mm audio in) */
2647         case 14569: /* WinTV-HVR3000 (OEM, no IR, no back panel video) */
2648         case 14659: /* WinTV-HVR3000 (OEM, no IR, b/panel video, RCA audio in - Low profile) */
2649         case 14669: /* WinTV-HVR3000 (OEM, no IR, no b/panel video - Low profile) */
2650         case 28552: /* WinTV-PVR 'Roslyn' (No IR) */
2651         case 34519: /* WinTV-PCI-FM */
2652         case 69009:
2653                 /* WinTV-HVR4000 (DVBS/S2/T, Video and IR, back panel inputs) */
2654         case 69100: /* WinTV-HVR4000LITE (DVBS/S2, IR) */
2655         case 69500: /* WinTV-HVR4000LITE (DVBS/S2, No IR) */
2656         case 69559:
2657                 /* WinTV-HVR4000 (DVBS/S2/T, Video no IR, back panel inputs) */
2658         case 69569: /* WinTV-HVR4000 (DVBS/S2/T, Video no IR) */
2659         case 90002: /* Nova-T-PCI (9002) */
2660         case 92001: /* Nova-S-Plus (Video and IR) */
2661         case 92002: /* Nova-S-Plus (Video and IR) */
2662         case 90003: /* Nova-T-PCI (9002 No RF out) */
2663         case 90500: /* Nova-T-PCI (oem) */
2664         case 90501: /* Nova-T-PCI (oem/IR) */
2665         case 92000: /* Nova-SE2 (OEM, No Video or IR) */
2666         case 92900: /* WinTV-IROnly (No analog or digital Video inputs) */
2667         case 94009: /* WinTV-HVR1100 (Video and IR Retail) */
2668         case 94501: /* WinTV-HVR1100 (Video and IR OEM) */
2669         case 96009: /* WinTV-HVR1300 (PAL Video, MPEG Video and IR RX) */
2670         case 96019: /* WinTV-HVR1300 (PAL Video, MPEG Video and IR RX/TX) */
2671         case 96559: /* WinTV-HVR1300 (PAL Video, MPEG Video no IR) */
2672         case 96569: /* WinTV-HVR1300 () */
2673         case 96659: /* WinTV-HVR1300 () */
2674         case 98559: /* WinTV-HVR1100LP (Video no IR, Retail - Low Profile) */
2675                 /* known */
2676                 break;
2677         case CX88_BOARD_SAMSUNG_SMT_7020:
2678                 cx_set(MO_GP0_IO, 0x008989FF);
2679                 break;
2680         default:
2681                 warn_printk(core, "warning: unknown hauppauge model #%d\n",
2682                             tv.model);
2683                 break;
2684         }
2685
2686         info_printk(core, "hauppauge eeprom: model=%d\n", tv.model);
2687 }
2688
2689 /* ----------------------------------------------------------------------- */
2690 /* some GDI (was: Modular Technology) specific stuff                       */
2691
2692 static const struct {
2693         int  id;
2694         int  fm;
2695         const char *name;
2696 } gdi_tuner[] = {
2697         [ 0x01 ] = { .id   = TUNER_ABSENT,
2698                      .name = "NTSC_M" },
2699         [ 0x02 ] = { .id   = TUNER_ABSENT,
2700                      .name = "PAL_B" },
2701         [ 0x03 ] = { .id   = TUNER_ABSENT,
2702                      .name = "PAL_I" },
2703         [ 0x04 ] = { .id   = TUNER_ABSENT,
2704                      .name = "PAL_D" },
2705         [ 0x05 ] = { .id   = TUNER_ABSENT,
2706                      .name = "SECAM" },
2707
2708         [ 0x10 ] = { .id   = TUNER_ABSENT,
2709                      .fm   = 1,
2710                      .name = "TEMIC_4049" },
2711         [ 0x11 ] = { .id   = TUNER_TEMIC_4136FY5,
2712                      .name = "TEMIC_4136" },
2713         [ 0x12 ] = { .id   = TUNER_ABSENT,
2714                      .name = "TEMIC_4146" },
2715
2716         [ 0x20 ] = { .id   = TUNER_PHILIPS_FQ1216ME,
2717                      .fm   = 1,
2718                      .name = "PHILIPS_FQ1216_MK3" },
2719         [ 0x21 ] = { .id   = TUNER_ABSENT, .fm = 1,
2720                      .name = "PHILIPS_FQ1236_MK3" },
2721         [ 0x22 ] = { .id   = TUNER_ABSENT,
2722                      .name = "PHILIPS_FI1236_MK3" },
2723         [ 0x23 ] = { .id   = TUNER_ABSENT,
2724                      .name = "PHILIPS_FI1216_MK3" },
2725 };
2726
2727 static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
2728 {
2729         const char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
2730                 ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
2731
2732         info_printk(core, "GDI: tuner=%s\n", name ? name : "unknown");
2733         if (NULL == name)
2734                 return;
2735         core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
2736         core->board.radio.type = gdi_tuner[eeprom_data[0x0d]].fm ?
2737                 CX88_RADIO : 0;
2738 }
2739
2740 /* ------------------------------------------------------------------- */
2741 /* some Divco specific stuff                                           */
2742 static int cx88_dvico_xc2028_callback(struct cx88_core *core,
2743                                       int command, int arg)
2744 {
2745         switch (command) {
2746         case XC2028_TUNER_RESET:
2747                 switch (core->boardnr) {
2748                 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
2749                         /* GPIO-4 xc3028 tuner */
2750
2751                         cx_set(MO_GP0_IO, 0x00001000);
2752                         cx_clear(MO_GP0_IO, 0x00000010);
2753                         msleep(100);
2754                         cx_set(MO_GP0_IO, 0x00000010);
2755                         msleep(100);
2756                         break;
2757                 default:
2758                         cx_write(MO_GP0_IO, 0x101000);
2759                         mdelay(5);
2760                         cx_set(MO_GP0_IO, 0x101010);
2761                 }
2762                 break;
2763         default:
2764                 return -EINVAL;
2765         }
2766
2767         return 0;
2768 }
2769
2770
2771 /* ----------------------------------------------------------------------- */
2772 /* some Geniatech specific stuff                                           */
2773
2774 static int cx88_xc3028_geniatech_tuner_callback(struct cx88_core *core,
2775                                                 int command, int mode)
2776 {
2777         switch (command) {
2778         case XC2028_TUNER_RESET:
2779                 switch (INPUT(core->input).type) {
2780                 case CX88_RADIO:
2781                         break;
2782                 case CX88_VMUX_DVB:
2783                         cx_write(MO_GP1_IO, 0x030302);
2784                         mdelay(50);
2785                         break;
2786                 default:
2787                         cx_write(MO_GP1_IO, 0x030301);
2788                         mdelay(50);
2789                 }
2790                 cx_write(MO_GP1_IO, 0x101010);
2791                 mdelay(50);
2792                 cx_write(MO_GP1_IO, 0x101000);
2793                 mdelay(50);
2794                 cx_write(MO_GP1_IO, 0x101010);
2795                 mdelay(50);
2796                 return 0;
2797         }
2798         return -EINVAL;
2799 }
2800
2801 static int cx88_xc3028_winfast1800h_callback(struct cx88_core *core,
2802                                              int command, int arg)
2803 {
2804         switch (command) {
2805         case XC2028_TUNER_RESET:
2806                 /* GPIO 12 (xc3028 tuner reset) */
2807                 cx_set(MO_GP1_IO, 0x1010);
2808                 mdelay(50);
2809                 cx_clear(MO_GP1_IO, 0x10);
2810                 mdelay(50);
2811                 cx_set(MO_GP1_IO, 0x10);
2812                 mdelay(50);
2813                 return 0;
2814         }
2815         return -EINVAL;
2816 }
2817
2818 /* ------------------------------------------------------------------- */
2819 /* some Divco specific stuff                                           */
2820 static int cx88_pv_8000gt_callback(struct cx88_core *core,
2821                                    int command, int arg)
2822 {
2823         switch (command) {
2824         case XC2028_TUNER_RESET:
2825                 cx_write(MO_GP2_IO, 0xcf7);
2826                 mdelay(50);
2827                 cx_write(MO_GP2_IO, 0xef5);
2828                 mdelay(50);
2829                 cx_write(MO_GP2_IO, 0xcf7);
2830                 break;
2831         default:
2832                 return -EINVAL;
2833         }
2834
2835         return 0;
2836 }
2837
2838 /* ----------------------------------------------------------------------- */
2839 /* some DViCO specific stuff                                               */
2840
2841 static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core)
2842 {
2843         struct i2c_msg msg = { .addr = 0x45, .flags = 0 };
2844         int i, err;
2845         static u8 init_bufs[13][5] = {
2846                 { 0x10, 0x00, 0x20, 0x01, 0x03 },
2847                 { 0x10, 0x10, 0x01, 0x00, 0x21 },
2848                 { 0x10, 0x10, 0x10, 0x00, 0xCA },
2849                 { 0x10, 0x10, 0x12, 0x00, 0x08 },
2850                 { 0x10, 0x10, 0x13, 0x00, 0x0A },
2851                 { 0x10, 0x10, 0x16, 0x01, 0xC0 },
2852                 { 0x10, 0x10, 0x22, 0x01, 0x3D },
2853                 { 0x10, 0x10, 0x73, 0x01, 0x2E },
2854                 { 0x10, 0x10, 0x72, 0x00, 0xC5 },
2855                 { 0x10, 0x10, 0x71, 0x01, 0x97 },
2856                 { 0x10, 0x10, 0x70, 0x00, 0x0F },
2857                 { 0x10, 0x10, 0xB0, 0x00, 0x01 },
2858                 { 0x03, 0x0C },
2859         };
2860
2861         for (i = 0; i < ARRAY_SIZE(init_bufs); i++) {
2862                 msg.buf = init_bufs[i];
2863                 msg.len = (i != 12 ? 5 : 2);
2864                 err = i2c_transfer(&core->i2c_adap, &msg, 1);
2865                 if (err != 1) {
2866                         warn_printk(core, "dvico_fusionhdtv_hybrid_init buf %d "
2867                                           "failed (err = %d)!\n", i, err);
2868                         return;
2869                 }
2870         }
2871 }
2872
2873 static int cx88_xc2028_tuner_callback(struct cx88_core *core,
2874                                       int command, int arg)
2875 {
2876         /* Board-specific callbacks */
2877         switch (core->boardnr) {
2878         case CX88_BOARD_POWERCOLOR_REAL_ANGEL:
2879         case CX88_BOARD_GENIATECH_X8000_MT:
2880         case CX88_BOARD_KWORLD_ATSC_120:
2881                 return cx88_xc3028_geniatech_tuner_callback(core,
2882                                                         command, arg);
2883         case CX88_BOARD_PROLINK_PV_8000GT:
2884         case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME:
2885                 return cx88_pv_8000gt_callback(core, command, arg);
2886         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
2887         case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
2888                 return cx88_dvico_xc2028_callback(core, command, arg);
2889         case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
2890         case CX88_BOARD_WINFAST_DTV1800H:
2891                 return cx88_xc3028_winfast1800h_callback(core, command, arg);
2892         }
2893
2894         switch (command) {
2895         case XC2028_TUNER_RESET:
2896                 switch (INPUT(core->input).type) {
2897                 case CX88_RADIO:
2898                         info_printk(core, "setting GPIO to radio!\n");
2899                         cx_write(MO_GP0_IO, 0x4ff);
2900                         mdelay(250);
2901                         cx_write(MO_GP2_IO, 0xff);
2902                         mdelay(250);
2903                         break;
2904                 case CX88_VMUX_DVB:     /* Digital TV*/
2905                 default:                /* Analog TV */
2906                         info_printk(core, "setting GPIO to TV!\n");
2907                         break;
2908                 }
2909                 cx_write(MO_GP1_IO, 0x101010);
2910                 mdelay(250);
2911                 cx_write(MO_GP1_IO, 0x101000);
2912                 mdelay(250);
2913                 cx_write(MO_GP1_IO, 0x101010);
2914                 mdelay(250);
2915                 return 0;
2916         }
2917         return -EINVAL;
2918 }
2919
2920 /* ----------------------------------------------------------------------- */
2921 /* Tuner callback function. Currently only needed for the Pinnacle         *
2922  * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both       *
2923  * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c)    */
2924
2925 static int cx88_xc5000_tuner_callback(struct cx88_core *core,
2926                                       int command, int arg)
2927 {
2928         switch (core->boardnr) {
2929         case CX88_BOARD_PINNACLE_PCTV_HD_800i:
2930                 if (command == 0) { /* This is the reset command from xc5000 */
2931
2932                         /* djh - According to the engineer at PCTV Systems,
2933                            the xc5000 reset pin is supposed to be on GPIO12.
2934                            However, despite three nights of effort, pulling
2935                            that GPIO low didn't reset the xc5000.  While
2936                            pulling MO_SRST_IO low does reset the xc5000, this
2937                            also resets in the s5h1409 being reset as well.
2938                            This causes tuning to always fail since the internal
2939                            state of the s5h1409 does not match the driver's
2940                            state.  Given that the only two conditions in which
2941                            the driver performs a reset is during firmware load
2942                            and powering down the chip, I am taking out the
2943                            reset.  We know that the chip is being reset
2944                            when the cx88 comes online, and not being able to
2945                            do power management for this board is worse than
2946                            not having any tuning at all. */
2947                         return 0;
2948                 } else {
2949                         err_printk(core, "xc5000: unknown tuner "
2950                                    "callback command.\n");
2951                         return -EINVAL;
2952                 }
2953                 break;
2954         case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
2955                 if (command == 0) { /* This is the reset command from xc5000 */
2956                         cx_clear(MO_GP0_IO, 0x00000010);
2957                         msleep(10);
2958                         cx_set(MO_GP0_IO, 0x00000010);
2959                         return 0;
2960                 } else {
2961                         printk(KERN_ERR
2962                                 "xc5000: unknown tuner callback command.\n");
2963                         return -EINVAL;
2964                 }
2965                 break;
2966         }
2967         return 0; /* Should never be here */
2968 }
2969
2970 int cx88_tuner_callback(void *priv, int component, int command, int arg)
2971 {
2972         struct i2c_algo_bit_data *i2c_algo = priv;
2973         struct cx88_core *core;
2974
2975         if (!i2c_algo) {
2976                 printk(KERN_ERR "cx88: Error - i2c private data undefined.\n");
2977                 return -EINVAL;
2978         }
2979
2980         core = i2c_algo->data;
2981
2982         if (!core) {
2983                 printk(KERN_ERR "cx88: Error - device struct undefined.\n");
2984                 return -EINVAL;
2985         }
2986
2987         if (component != DVB_FRONTEND_COMPONENT_TUNER)
2988                 return -EINVAL;
2989
2990         switch (core->board.tuner_type) {
2991                 case TUNER_XC2028:
2992                         info_printk(core, "Calling XC2028/3028 callback\n");
2993                         return cx88_xc2028_tuner_callback(core, command, arg);
2994                 case TUNER_XC5000:
2995                         info_printk(core, "Calling XC5000 callback\n");
2996                         return cx88_xc5000_tuner_callback(core, command, arg);
2997         }
2998         err_printk(core, "Error: Calling callback for tuner %d\n",
2999                    core->board.tuner_type);
3000         return -EINVAL;
3001 }
3002 EXPORT_SYMBOL(cx88_tuner_callback);
3003
3004 /* ----------------------------------------------------------------------- */
3005
3006 static void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
3007 {
3008         int i;
3009
3010         if (0 == pci->subsystem_vendor &&
3011             0 == pci->subsystem_device) {
3012                 printk(KERN_ERR
3013                        "%s: Your board has no valid PCI Subsystem ID and thus can't\n"
3014                        "%s: be autodetected.  Please pass card=<n> insmod option to\n"
3015                        "%s: workaround that.  Redirect complaints to the vendor of\n"
3016                        "%s: the TV card.  Best regards,\n"
3017                        "%s:         -- tux\n",
3018                        core->name,core->name,core->name,core->name,core->name);
3019         } else {
3020                 printk(KERN_ERR
3021                        "%s: Your board isn't known (yet) to the driver.  You can\n"
3022                        "%s: try to pick one of the existing card configs via\n"
3023                        "%s: card=<n> insmod option.  Updating to the latest\n"
3024                        "%s: version might help as well.\n",
3025                        core->name,core->name,core->name,core->name);
3026         }
3027         err_printk(core, "Here is a list of valid choices for the card=<n> "
3028                    "insmod option:\n");
3029         for (i = 0; i < ARRAY_SIZE(cx88_boards); i++)
3030                 printk(KERN_ERR "%s:    card=%d -> %s\n",
3031                        core->name, i, cx88_boards[i].name);
3032 }
3033
3034 static void cx88_card_setup_pre_i2c(struct cx88_core *core)
3035 {
3036         switch (core->boardnr) {
3037         case CX88_BOARD_HAUPPAUGE_HVR1300:
3038                 /*
3039                  * Bring the 702 demod up before i2c scanning/attach or devices are hidden
3040                  * We leave here with the 702 on the bus
3041                  *
3042                  * "reset the IR receiver on GPIO[3]"
3043                  * Reported by Mike Crash <mike AT mikecrash.com>
3044                  */
3045                 cx_write(MO_GP0_IO, 0x0000ef88);
3046                 udelay(1000);
3047                 cx_clear(MO_GP0_IO, 0x00000088);
3048                 udelay(50);
3049                 cx_set(MO_GP0_IO, 0x00000088); /* 702 out of reset */
3050                 udelay(1000);
3051                 break;
3052
3053         case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME:
3054         case CX88_BOARD_PROLINK_PV_8000GT:
3055                 cx_write(MO_GP2_IO, 0xcf7);
3056                 mdelay(50);
3057                 cx_write(MO_GP2_IO, 0xef5);
3058                 mdelay(50);
3059                 cx_write(MO_GP2_IO, 0xcf7);
3060                 msleep(10);
3061                 break;
3062
3063         case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
3064                 /* Enable the xc5000 tuner */
3065                 cx_set(MO_GP0_IO, 0x00001010);
3066                 break;
3067
3068         case CX88_BOARD_HAUPPAUGE_HVR3000:
3069         case CX88_BOARD_HAUPPAUGE_HVR4000:
3070                 /* Init GPIO */
3071                 cx_write(MO_GP0_IO, core->board.input[0].gpio0);
3072                 udelay(1000);
3073                 cx_clear(MO_GP0_IO, 0x00000080);
3074                 udelay(50);
3075                 cx_set(MO_GP0_IO, 0x00000080); /* 702 out of reset */
3076                 udelay(1000);
3077                 break;
3078
3079         case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
3080         case CX88_BOARD_WINFAST_DTV1800H:
3081                 /* GPIO 12 (xc3028 tuner reset) */
3082                 cx_set(MO_GP1_IO, 0x1010);
3083                 mdelay(50);
3084                 cx_clear(MO_GP1_IO, 0x10);
3085                 mdelay(50);
3086                 cx_set(MO_GP1_IO, 0x10);
3087                 mdelay(50);
3088                 break;
3089
3090         case CX88_BOARD_TWINHAN_VP1027_DVBS:
3091                 cx_write(MO_GP0_IO, 0x00003230);
3092                 cx_write(MO_GP0_IO, 0x00003210);
3093                 msleep(1);
3094                 cx_write(MO_GP0_IO, 0x00001230);
3095                 break;
3096         }
3097 }
3098
3099 /*
3100  * Sets board-dependent xc3028 configuration
3101  */
3102 void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl)
3103 {
3104         memset(ctl, 0, sizeof(*ctl));
3105
3106         ctl->fname   = XC2028_DEFAULT_FIRMWARE;
3107         ctl->max_len = 64;
3108
3109         switch (core->boardnr) {
3110         case CX88_BOARD_POWERCOLOR_REAL_ANGEL:
3111                 /* Now works with firmware version 2.7 */
3112                 if (core->i2c_algo.udelay < 16)
3113                         core->i2c_algo.udelay = 16;
3114                 break;
3115         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
3116         case CX88_BOARD_WINFAST_DTV1800H:
3117                 ctl->demod = XC3028_FE_ZARLINK456;
3118                 break;
3119         case CX88_BOARD_KWORLD_ATSC_120:
3120         case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
3121                 ctl->demod = XC3028_FE_OREN538;
3122                 break;
3123         case CX88_BOARD_GENIATECH_X8000_MT:
3124                 /* FIXME: For this board, the xc3028 never recovers after being
3125                    powered down (the reset GPIO probably is not set properly).
3126                    We don't have access to the hardware so we cannot determine
3127                    which GPIO is used for xc3028, so just disable power xc3028
3128                    power management for now */
3129                 ctl->disable_power_mgmt = 1;
3130                 break;
3131         case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
3132         case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME:
3133         case CX88_BOARD_PROLINK_PV_8000GT:
3134                 /*
3135                  * Those boards uses non-MTS firmware
3136                  */
3137                 break;
3138         case CX88_BOARD_PINNACLE_HYBRID_PCTV:
3139         case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
3140                 ctl->demod = XC3028_FE_ZARLINK456;
3141                 ctl->mts = 1;
3142                 break;
3143         default:
3144                 ctl->demod = XC3028_FE_OREN538;
3145                 ctl->mts = 1;
3146         }
3147 }
3148 EXPORT_SYMBOL_GPL(cx88_setup_xc3028);
3149
3150 static void cx88_card_setup(struct cx88_core *core)
3151 {
3152         static u8 eeprom[256];
3153         struct tuner_setup tun_setup;
3154         unsigned int mode_mask = T_RADIO     |
3155                                  T_ANALOG_TV |
3156                                  T_DIGITAL_TV;
3157
3158         memset(&tun_setup, 0, sizeof(tun_setup));
3159
3160         if (0 == core->i2c_rc) {
3161                 core->i2c_client.addr = 0xa0 >> 1;
3162                 tveeprom_read(&core->i2c_client, eeprom, sizeof(eeprom));
3163         }
3164
3165         switch (core->boardnr) {
3166         case CX88_BOARD_HAUPPAUGE:
3167         case CX88_BOARD_HAUPPAUGE_ROSLYN:
3168                 if (0 == core->i2c_rc)
3169                         hauppauge_eeprom(core, eeprom+8);
3170                 break;
3171         case CX88_BOARD_GDI:
3172                 if (0 == core->i2c_rc)
3173                         gdi_eeprom(core, eeprom);
3174                 break;
3175         case CX88_BOARD_LEADTEK_PVR2000:
3176         case CX88_BOARD_WINFAST_DV2000:
3177         case CX88_BOARD_WINFAST2000XP_EXPERT:
3178                 if (0 == core->i2c_rc)
3179                         leadtek_eeprom(core, eeprom);
3180                 break;
3181         case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
3182         case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
3183         case CX88_BOARD_HAUPPAUGE_DVB_T1:
3184         case CX88_BOARD_HAUPPAUGE_HVR1100:
3185         case CX88_BOARD_HAUPPAUGE_HVR1100LP:
3186         case CX88_BOARD_HAUPPAUGE_HVR3000:
3187         case CX88_BOARD_HAUPPAUGE_HVR1300:
3188         case CX88_BOARD_HAUPPAUGE_HVR4000:
3189         case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
3190         case CX88_BOARD_HAUPPAUGE_IRONLY:
3191                 if (0 == core->i2c_rc)
3192                         hauppauge_eeprom(core, eeprom);
3193                 break;
3194         case CX88_BOARD_KWORLD_DVBS_100:
3195                 cx_write(MO_GP0_IO, 0x000007f8);
3196                 cx_write(MO_GP1_IO, 0x00000001);
3197                 break;
3198         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
3199                 /* GPIO0:0 is hooked to demod reset */
3200                 /* GPIO0:4 is hooked to xc3028 reset */
3201                 cx_write(MO_GP0_IO, 0x00111100);
3202                 msleep(1);
3203                 cx_write(MO_GP0_IO, 0x00111111);
3204                 break;
3205         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
3206                 /* GPIO0:6 is hooked to FX2 reset pin */
3207                 cx_set(MO_GP0_IO, 0x00004040);
3208                 cx_clear(MO_GP0_IO, 0x00000040);
3209                 msleep(1000);
3210                 cx_set(MO_GP0_IO, 0x00004040);
3211                 /* FALLTHROUGH */
3212         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
3213         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
3214         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
3215                 /* GPIO0:0 is hooked to mt352 reset pin */
3216                 cx_set(MO_GP0_IO, 0x00000101);
3217                 cx_clear(MO_GP0_IO, 0x00000001);
3218                 msleep(1);
3219                 cx_set(MO_GP0_IO, 0x00000101);
3220                 if (0 == core->i2c_rc &&
3221                     core->boardnr == CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID)
3222                         dvico_fusionhdtv_hybrid_init(core);
3223                 break;
3224         case CX88_BOARD_KWORLD_DVB_T:
3225         case CX88_BOARD_DNTV_LIVE_DVB_T:
3226                 cx_set(MO_GP0_IO, 0x00000707);
3227                 cx_set(MO_GP2_IO, 0x00000101);
3228                 cx_clear(MO_GP2_IO, 0x00000001);
3229                 msleep(1);
3230                 cx_clear(MO_GP0_IO, 0x00000007);
3231                 cx_set(MO_GP2_IO, 0x00000101);
3232                 break;
3233         case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
3234                 cx_write(MO_GP0_IO, 0x00080808);
3235                 break;
3236         case CX88_BOARD_ATI_HDTVWONDER:
3237                 if (0 == core->i2c_rc) {
3238                         /* enable tuner */
3239                         int i;
3240                         static const u8 buffer [][2] = {
3241                                 {0x10,0x12},
3242                                 {0x13,0x04},
3243                                 {0x16,0x00},
3244                                 {0x14,0x04},
3245                                 {0x17,0x00}
3246                         };
3247                         core->i2c_client.addr = 0x0a;
3248
3249                         for (i = 0; i < ARRAY_SIZE(buffer); i++)
3250                                 if (2 != i2c_master_send(&core->i2c_client,
3251                                                         buffer[i],2))
3252                                         warn_printk(core, "Unable to enable "
3253                                                     "tuner(%i).\n", i);
3254                 }
3255                 break;
3256         case CX88_BOARD_MSI_TVANYWHERE_MASTER:
3257         {
3258                 struct v4l2_priv_tun_config tea5767_cfg;
3259                 struct tea5767_ctrl ctl;
3260
3261                 memset(&ctl, 0, sizeof(ctl));
3262
3263                 ctl.high_cut  = 1;
3264                 ctl.st_noise  = 1;
3265                 ctl.deemph_75 = 1;
3266                 ctl.xtal_freq = TEA5767_HIGH_LO_13MHz;
3267
3268                 tea5767_cfg.tuner = TUNER_TEA5767;
3269                 tea5767_cfg.priv  = &ctl;
3270
3271                 call_all(core, tuner, s_config, &tea5767_cfg);
3272                 break;
3273         }
3274         case  CX88_BOARD_TEVII_S420:
3275         case  CX88_BOARD_TEVII_S460:
3276         case  CX88_BOARD_OMICOM_SS4_PCI:
3277         case  CX88_BOARD_TBS_8910:
3278         case  CX88_BOARD_TBS_8920:
3279         case  CX88_BOARD_PROF_6200:
3280         case  CX88_BOARD_PROF_7300:
3281         case  CX88_BOARD_PROF_7301:
3282         case  CX88_BOARD_SATTRADE_ST4200:
3283                 cx_write(MO_GP0_IO, 0x8000);
3284                 msleep(100);
3285                 cx_write(MO_SRST_IO, 0);
3286                 msleep(10);
3287                 cx_write(MO_GP0_IO, 0x8080);
3288                 msleep(100);
3289                 cx_write(MO_SRST_IO, 1);
3290                 msleep(100);
3291                 break;
3292         } /*end switch() */
3293
3294
3295         /* Setup tuners */
3296         if ((core->board.radio_type != UNSET)) {
3297                 tun_setup.mode_mask      = T_RADIO;
3298                 tun_setup.type           = core->board.radio_type;
3299                 tun_setup.addr           = core->board.radio_addr;
3300                 tun_setup.tuner_callback = cx88_tuner_callback;
3301                 call_all(core, tuner, s_type_addr, &tun_setup);
3302                 mode_mask &= ~T_RADIO;
3303         }
3304
3305         if (core->board.tuner_type != TUNER_ABSENT) {
3306                 tun_setup.mode_mask      = mode_mask;
3307                 tun_setup.type           = core->board.tuner_type;
3308                 tun_setup.addr           = core->board.tuner_addr;
3309                 tun_setup.tuner_callback = cx88_tuner_callback;
3310
3311                 call_all(core, tuner, s_type_addr, &tun_setup);
3312         }
3313
3314         if (core->board.tda9887_conf) {
3315                 struct v4l2_priv_tun_config tda9887_cfg;
3316
3317                 tda9887_cfg.tuner = TUNER_TDA9887;
3318                 tda9887_cfg.priv  = &core->board.tda9887_conf;
3319
3320                 call_all(core, tuner, s_config, &tda9887_cfg);
3321         }
3322
3323         if (core->board.tuner_type == TUNER_XC2028) {
3324                 struct v4l2_priv_tun_config  xc2028_cfg;
3325                 struct xc2028_ctrl           ctl;
3326
3327                 /* Fills device-dependent initialization parameters */
3328                 cx88_setup_xc3028(core, &ctl);
3329
3330                 /* Sends parameters to xc2028/3028 tuner */
3331                 memset(&xc2028_cfg, 0, sizeof(xc2028_cfg));
3332                 xc2028_cfg.tuner = TUNER_XC2028;
3333                 xc2028_cfg.priv  = &ctl;
3334                 info_printk(core, "Asking xc2028/3028 to load firmware %s\n",
3335                             ctl.fname);
3336                 call_all(core, tuner, s_config, &xc2028_cfg);
3337         }
3338         call_all(core, core, s_power, 0);
3339 }
3340
3341 /* ------------------------------------------------------------------ */
3342
3343 static int cx88_pci_quirks(const char *name, struct pci_dev *pci)
3344 {
3345         unsigned int lat = UNSET;
3346         u8 ctrl = 0;
3347         u8 value;
3348
3349         /* check pci quirks */
3350         if (pci_pci_problems & PCIPCI_TRITON) {
3351                 printk(KERN_INFO "%s: quirk: PCIPCI_TRITON -- set TBFX\n",
3352                        name);
3353                 ctrl |= CX88X_EN_TBFX;
3354         }
3355         if (pci_pci_problems & PCIPCI_NATOMA) {
3356                 printk(KERN_INFO "%s: quirk: PCIPCI_NATOMA -- set TBFX\n",
3357                        name);
3358                 ctrl |= CX88X_EN_TBFX;
3359         }
3360         if (pci_pci_problems & PCIPCI_VIAETBF) {
3361                 printk(KERN_INFO "%s: quirk: PCIPCI_VIAETBF -- set TBFX\n",
3362                        name);
3363                 ctrl |= CX88X_EN_TBFX;
3364         }
3365         if (pci_pci_problems & PCIPCI_VSFX) {
3366                 printk(KERN_INFO "%s: quirk: PCIPCI_VSFX -- set VSFX\n",
3367                        name);
3368                 ctrl |= CX88X_EN_VSFX;
3369         }
3370 #ifdef PCIPCI_ALIMAGIK
3371         if (pci_pci_problems & PCIPCI_ALIMAGIK) {
3372                 printk(KERN_INFO "%s: quirk: PCIPCI_ALIMAGIK -- latency fixup\n",
3373                        name);
3374                 lat = 0x0A;
3375         }
3376 #endif
3377
3378         /* check insmod options */
3379         if (UNSET != latency)
3380                 lat = latency;
3381
3382         /* apply stuff */
3383         if (ctrl) {
3384                 pci_read_config_byte(pci, CX88X_DEVCTRL, &value);
3385                 value |= ctrl;
3386                 pci_write_config_byte(pci, CX88X_DEVCTRL, value);
3387         }
3388         if (UNSET != lat) {
3389                 printk(KERN_INFO "%s: setting pci latency timer to %d\n",
3390                        name, latency);
3391                 pci_write_config_byte(pci, PCI_LATENCY_TIMER, latency);
3392         }
3393         return 0;
3394 }
3395
3396 int cx88_get_resources(const struct cx88_core *core, struct pci_dev *pci)
3397 {
3398         if (request_mem_region(pci_resource_start(pci,0),
3399                                pci_resource_len(pci,0),
3400                                core->name))
3401                 return 0;
3402         printk(KERN_ERR
3403                "%s/%d: Can't get MMIO memory @ 0x%llx, subsystem: %04x:%04x\n",
3404                core->name, PCI_FUNC(pci->devfn),
3405                (unsigned long long)pci_resource_start(pci, 0),
3406                pci->subsystem_vendor, pci->subsystem_device);
3407         return -EBUSY;
3408 }
3409
3410 /* Allocate and initialize the cx88 core struct.  One should hold the
3411  * devlist mutex before calling this.  */
3412 struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
3413 {
3414         struct cx88_core *core;
3415         int i;
3416
3417         core = kzalloc(sizeof(*core), GFP_KERNEL);
3418         if (core == NULL)
3419                 return NULL;
3420
3421         atomic_inc(&core->refcount);
3422         core->pci_bus  = pci->bus->number;
3423         core->pci_slot = PCI_SLOT(pci->devfn);
3424         core->pci_irqmask = PCI_INT_RISC_RD_BERRINT | PCI_INT_RISC_WR_BERRINT |
3425                             PCI_INT_BRDG_BERRINT | PCI_INT_SRC_DMA_BERRINT |
3426                             PCI_INT_DST_DMA_BERRINT | PCI_INT_IPB_DMA_BERRINT;
3427         mutex_init(&core->lock);
3428
3429         core->nr = nr;
3430         sprintf(core->name, "cx88[%d]", core->nr);
3431
3432         strcpy(core->v4l2_dev.name, core->name);
3433         if (v4l2_device_register(NULL, &core->v4l2_dev)) {
3434                 kfree(core);
3435                 return NULL;
3436         }
3437
3438         if (0 != cx88_get_resources(core, pci)) {
3439                 v4l2_device_unregister(&core->v4l2_dev);
3440                 kfree(core);
3441                 return NULL;
3442         }
3443
3444         /* PCI stuff */
3445         cx88_pci_quirks(core->name, pci);
3446         core->lmmio = ioremap(pci_resource_start(pci, 0),
3447                               pci_resource_len(pci, 0));
3448         core->bmmio = (u8 __iomem *)core->lmmio;
3449
3450         if (core->lmmio == NULL) {
3451                 kfree(core);
3452                 return NULL;
3453         }
3454
3455         /* board config */
3456         core->boardnr = UNSET;
3457         if (card[core->nr] < ARRAY_SIZE(cx88_boards))
3458                 core->boardnr = card[core->nr];
3459         for (i = 0; UNSET == core->boardnr && i < ARRAY_SIZE(cx88_subids); i++)
3460                 if (pci->subsystem_vendor == cx88_subids[i].subvendor &&
3461                     pci->subsystem_device == cx88_subids[i].subdevice)
3462                         core->boardnr = cx88_subids[i].card;
3463         if (UNSET == core->boardnr) {
3464                 core->boardnr = CX88_BOARD_UNKNOWN;
3465                 cx88_card_list(core, pci);
3466         }
3467
3468         memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board));
3469
3470         if (!core->board.num_frontends && (core->board.mpeg & CX88_MPEG_DVB))
3471                 core->board.num_frontends = 1;
3472
3473         info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s], frontend(s): %d\n",
3474                 pci->subsystem_vendor, pci->subsystem_device, core->board.name,
3475                 core->boardnr, card[core->nr] == core->boardnr ?
3476                 "insmod option" : "autodetected",
3477                 core->board.num_frontends);
3478
3479         if (tuner[core->nr] != UNSET)
3480                 core->board.tuner_type = tuner[core->nr];
3481         if (radio[core->nr] != UNSET)
3482                 core->board.radio_type = radio[core->nr];
3483
3484         info_printk(core, "TV tuner type %d, Radio tuner type %d\n",
3485                     core->board.tuner_type, core->board.radio_type);
3486
3487         /* init hardware */
3488         cx88_reset(core);
3489         cx88_card_setup_pre_i2c(core);
3490         cx88_i2c_init(core, pci);
3491
3492         /* load tuner module, if needed */
3493         if (TUNER_ABSENT != core->board.tuner_type) {
3494                 /* Ignore 0x6b and 0x6f on cx88 boards.
3495                  * FusionHDTV5 RT Gold has an ir receiver at 0x6b
3496                  * and an RTC at 0x6f which can get corrupted if probed. */
3497                 static const unsigned short tv_addrs[] = {
3498                         0x42, 0x43, 0x4a, 0x4b,         /* tda8290 */
3499                         0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
3500                         0x68, 0x69, 0x6a, 0x6c, 0x6d, 0x6e,
3501                         I2C_CLIENT_END
3502                 };
3503                 int has_demod = (core->board.tda9887_conf & TDA9887_PRESENT);
3504
3505                 /* I don't trust the radio_type as is stored in the card
3506                    definitions, so we just probe for it.
3507                    The radio_type is sometimes missing, or set to UNSET but
3508                    later code configures a tea5767.
3509                  */
3510                 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
3511                                 "tuner", "tuner",
3512                                 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO));
3513                 if (has_demod)
3514                         v4l2_i2c_new_subdev(&core->v4l2_dev,
3515                                 &core->i2c_adap, "tuner", "tuner",
3516                                 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
3517                 if (core->board.tuner_addr == ADDR_UNSET) {
3518                         v4l2_i2c_new_subdev(&core->v4l2_dev,
3519                                 &core->i2c_adap, "tuner", "tuner",
3520                                 0, has_demod ? tv_addrs + 4 : tv_addrs);
3521                 } else {
3522                         v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
3523                                 "tuner", "tuner", core->board.tuner_addr, NULL);
3524                 }
3525         }
3526
3527         cx88_card_setup(core);
3528         if (!disable_ir) {
3529                 cx88_i2c_init_ir(core);
3530                 cx88_ir_init(core, pci);
3531         }
3532
3533         return core;
3534 }