1c036cc36fe15c9a779fc3678d49df8f1bd853ee
[linux-2.6.git] / drivers / media / video / cx88 / cx88-cards.c
1 /*
2  * $Id: cx88-cards.c,v 1.66 2005/03/04 09:12:23 kraxel Exp $
3  *
4  * device driver for Conexant 2388x based TV cards
5  * card-specific stuff.
6  *
7  * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23
24 #include <linux/init.h>
25 #include <linux/module.h>
26 #include <linux/pci.h>
27 #include <linux/delay.h>
28
29 #include "cx88.h"
30
31 /* ------------------------------------------------------------------ */
32 /* board config info                                                  */
33
34 struct cx88_board cx88_boards[] = {
35         [CX88_BOARD_UNKNOWN] = {
36                 .name           = "UNKNOWN/GENERIC",
37                 .tuner_type     = UNSET,
38                 .input          = {{
39                         .type   = CX88_VMUX_COMPOSITE1,
40                         .vmux   = 0,
41                 },{
42                         .type   = CX88_VMUX_COMPOSITE2,
43                         .vmux   = 1,
44                 },{
45                         .type   = CX88_VMUX_COMPOSITE3,
46                         .vmux   = 2,
47                 },{
48                         .type   = CX88_VMUX_COMPOSITE4,
49                         .vmux   = 3,
50                 }},
51         },
52         [CX88_BOARD_HAUPPAUGE] = {
53                 .name           = "Hauppauge WinTV 34xxx models",
54                 .tuner_type     = UNSET,
55                 .tda9887_conf   = TDA9887_PRESENT,
56                 .input          = {{
57                         .type   = CX88_VMUX_TELEVISION,
58                         .vmux   = 0,
59                         .gpio0  = 0xff00,  // internal decoder
60                 },{
61                         .type   = CX88_VMUX_DEBUG,
62                         .vmux   = 0,
63                         .gpio0  = 0xff01,  // mono from tuner chip
64                 },{
65                         .type   = CX88_VMUX_COMPOSITE1,
66                         .vmux   = 1,
67                         .gpio0  = 0xff02,
68                 },{
69                         .type   = CX88_VMUX_SVIDEO,
70                         .vmux   = 2,
71                         .gpio0  = 0xff02,
72                 }},
73                 .radio = {
74                         .type   = CX88_RADIO,
75                         .gpio0  = 0xff01,
76                 },
77         },
78         [CX88_BOARD_GDI] = {
79                 .name           = "GDI Black Gold",
80                 .tuner_type     = UNSET,
81                 .input          = {{
82                         .type   = CX88_VMUX_TELEVISION,
83                         .vmux   = 0,
84                 }},
85         },
86         [CX88_BOARD_PIXELVIEW] = {
87                 .name           = "PixelView",
88                 .tuner_type     = 5,
89                 .input          = {{
90                         .type   = CX88_VMUX_TELEVISION,
91                         .vmux   = 0,
92                         .gpio0  = 0xff00,  // internal decoder
93                 },{
94                         .type   = CX88_VMUX_COMPOSITE1,
95                         .vmux   = 1,
96                 },{
97                         .type   = CX88_VMUX_SVIDEO,
98                         .vmux   = 2,
99                 }},
100                 .radio = {
101                          .type  = CX88_RADIO,
102                          .gpio0 = 0xff10,
103                  },
104         },
105         [CX88_BOARD_ATI_WONDER_PRO] = {
106                 .name           = "ATI TV Wonder Pro",
107                 .tuner_type     = 44,
108                 .tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER,
109                 .input          = {{
110                         .type   = CX88_VMUX_TELEVISION,
111                         .vmux   = 0,
112                         .gpio0  = 0x03ff,
113                 },{
114                         .type   = CX88_VMUX_COMPOSITE1,
115                         .vmux   = 1,
116                         .gpio0  = 0x03fe,
117                 },{
118                         .type   = CX88_VMUX_SVIDEO,
119                         .vmux   = 2,
120                         .gpio0  = 0x03fe,
121                 }},
122         },
123         [CX88_BOARD_WINFAST2000XP_EXPERT] = {
124                 .name           = "Leadtek Winfast 2000XP Expert",
125                 .tuner_type     = 44,
126                 .tda9887_conf   = TDA9887_PRESENT,
127                 .input          = {{
128                         .type   = CX88_VMUX_TELEVISION,
129                         .vmux   = 0,
130                         .gpio0  = 0x00F5e700,
131                         .gpio1  = 0x00003004,
132                         .gpio2  = 0x00F5e700,
133                         .gpio3  = 0x02000000,
134                 },{
135                         .type   = CX88_VMUX_COMPOSITE1,
136                         .vmux   = 1,
137                         .gpio0  = 0x00F5c700,
138                         .gpio1  = 0x00003004,
139                         .gpio2  = 0x00F5c700,
140                         .gpio3  = 0x02000000,
141                 },{
142                         .type   = CX88_VMUX_SVIDEO,
143                         .vmux   = 2,
144                         .gpio0  = 0x00F5c700,
145                         .gpio1  = 0x00003004,
146                         .gpio2  = 0x00F5c700,
147                         .gpio3  = 0x02000000,
148                 }},
149                 .radio = {
150                         .type   = CX88_RADIO,
151                         .gpio0  = 0x00F5d700,
152                         .gpio1  = 0x00003004,
153                         .gpio2  = 0x00F5d700,
154                         .gpio3  = 0x02000000,
155                 },
156         },
157         [CX88_BOARD_AVERTV_303] = {
158                 .name           = "AverTV Studio 303 (M126)",
159                 .tuner_type     = 38,
160                 .tda9887_conf   = TDA9887_PRESENT,
161                 .input          = {{
162                         .type   = CX88_VMUX_TELEVISION,
163                         .vmux   = 0,
164                         .gpio1  = 0x309f,
165                 },{
166                         .type   = CX88_VMUX_COMPOSITE1,
167                         .vmux   = 1,
168                         .gpio1  = 0x305f,
169                 },{
170                         .type   = CX88_VMUX_SVIDEO,
171                         .vmux   = 2,
172                         .gpio1  = 0x305f,
173                 }},
174                 .radio = {
175                         .type   = CX88_RADIO,
176                 },
177         },
178         [CX88_BOARD_MSI_TVANYWHERE_MASTER] = {
179                 // added gpio values thanks to Michal
180                 // values for PAL from DScaler
181                 .name           = "MSI TV-@nywhere Master",
182                 .tuner_type     = 33,
183                 .tda9887_conf   = TDA9887_PRESENT,
184                 .input          = {{
185                         .type   = CX88_VMUX_TELEVISION,
186                         .vmux   = 0,
187                         .gpio0  = 0x000040bf,
188                         .gpio1  = 0x000080c0,
189                         .gpio2  = 0x0000ff40,
190                 },{
191                         .type   = CX88_VMUX_COMPOSITE1,
192                         .vmux   = 1,
193                         .gpio0  = 0x000040bf,
194                         .gpio1  = 0x000080c0,
195                         .gpio2  = 0x0000ff40,
196                 },{
197                         .type   = CX88_VMUX_SVIDEO,
198                         .vmux   = 2,
199                         .gpio0  = 0x000040bf,
200                         .gpio1  = 0x000080c0,
201                         .gpio2  = 0x0000ff40,
202                 }},
203                 .radio = {
204                          .type   = CX88_RADIO,
205                 },
206         },
207         [CX88_BOARD_WINFAST_DV2000] = {
208                 .name           = "Leadtek Winfast DV2000",
209                 .tuner_type     = 38,
210                 .tda9887_conf   = TDA9887_PRESENT,
211                 .input          = {{
212                         .type   = CX88_VMUX_TELEVISION,
213                         .vmux   = 0,
214                         .gpio0  = 0x0035e700,
215                         .gpio1  = 0x00003004,
216                         .gpio2  = 0x0035e700,
217                         .gpio3  = 0x02000000,
218                 },{
219
220                         .type   = CX88_VMUX_COMPOSITE1,
221                         .vmux   = 1,
222                         .gpio0  = 0x0035c700,
223                         .gpio1  = 0x00003004,
224                         .gpio2  = 0x0035c700,
225                         .gpio3  = 0x02000000,
226                 },{
227                         .type   = CX88_VMUX_SVIDEO,
228                         .vmux   = 2,
229                         .gpio0  = 0x0035c700,
230                         .gpio1  = 0x0035c700,
231                         .gpio2  = 0x02000000,
232                         .gpio3  = 0x02000000,
233                 }},
234                 .radio = {
235                         .type   = CX88_RADIO,
236                         .gpio0  = 0x0035d700,
237                         .gpio1  = 0x00007004,
238                         .gpio2  = 0x0035d700,
239                         .gpio3  = 0x02000000,
240                  },
241         },
242         [CX88_BOARD_LEADTEK_PVR2000] = {
243                 // gpio values for PAL version from regspy by DScaler
244                 .name           = "Leadtek PVR 2000",
245                 .tuner_type     = 38,
246                 .tda9887_conf   = TDA9887_PRESENT,
247                 .input          = {{
248                         .type   = CX88_VMUX_TELEVISION,
249                         .vmux   = 0,
250                         .gpio0  = 0x0000bde6,
251                 },{
252                         .type   = CX88_VMUX_COMPOSITE1,
253                         .vmux   = 1,
254                         .gpio0  = 0x0000bde6,
255                 },{
256                         .type   = CX88_VMUX_SVIDEO,
257                         .vmux   = 2,
258                         .gpio0  = 0x0000bde6,
259                 }},
260                 .radio = {
261                         .type   = CX88_RADIO,
262                         .gpio0  = 0x0000bd62,
263                 },
264                 .blackbird = 1,
265         },
266         [CX88_BOARD_IODATA_GVVCP3PCI] = {
267                 .name           = "IODATA GV-VCP3/PCI",
268                 .tuner_type     = TUNER_ABSENT,
269                 .input          = {{
270                         .type   = CX88_VMUX_COMPOSITE1,
271                         .vmux   = 0,
272                 },{
273                         .type   = CX88_VMUX_COMPOSITE2,
274                         .vmux   = 1,
275                 },{
276                         .type   = CX88_VMUX_SVIDEO,
277                         .vmux   = 2,
278                 }},
279         },
280         [CX88_BOARD_PROLINK_PLAYTVPVR] = {
281                 .name           = "Prolink PlayTV PVR",
282                 .tuner_type     = 43,
283                 .tda9887_conf   = TDA9887_PRESENT,
284                 .input          = {{
285                         .type   = CX88_VMUX_TELEVISION,
286                         .vmux   = 0,
287                         .gpio0  = 0xff00,
288                 },{
289                         .type   = CX88_VMUX_COMPOSITE1,
290                         .vmux   = 1,
291                         .gpio0  = 0xff03,
292                 },{
293                         .type   = CX88_VMUX_SVIDEO,
294                         .vmux   = 2,
295                         .gpio0  = 0xff03,
296                 }},
297                 .radio = {
298                         .type   = CX88_RADIO,
299                         .gpio0  = 0xff00,
300                 },
301         },
302         [CX88_BOARD_ASUS_PVR_416] = {
303                 .name           = "ASUS PVR-416",
304                 .tuner_type     = 43,
305                 .tda9887_conf   = TDA9887_PRESENT,
306                 .input          = {{
307                         .type   = CX88_VMUX_TELEVISION,
308                         .vmux   = 0,
309                         .gpio0  = 0x0000fde6,
310                 },{
311                         .type   = CX88_VMUX_SVIDEO,
312                         .vmux   = 2,
313                         .gpio0  = 0x0000fde6, // 0x0000fda6 L,R RCA audio in?
314                 }},
315                 .radio = {
316                         .type   = CX88_RADIO,
317                         .gpio0  = 0x0000fde2,
318                 },
319                 .blackbird = 1,
320         },
321         [CX88_BOARD_MSI_TVANYWHERE] = {
322                 .name           = "MSI TV-@nywhere",
323                 .tuner_type     = 33,
324                 .tda9887_conf   = TDA9887_PRESENT,
325                 .input          = {{
326                         .type   = CX88_VMUX_TELEVISION,
327                         .vmux   = 0,
328                         .gpio0  = 0x00000fbf,
329                         .gpio2  = 0x0000fc08,
330                 },{
331                         .type   = CX88_VMUX_COMPOSITE1,
332                         .vmux   = 1,
333                         .gpio0  = 0x00000fbf,
334                         .gpio2  = 0x0000fc68,
335                 },{
336                         .type   = CX88_VMUX_SVIDEO,
337                         .vmux   = 2,
338                         .gpio0  = 0x00000fbf,
339                         .gpio2  = 0x0000fc68,
340                 }},
341         },
342         [CX88_BOARD_KWORLD_DVB_T] = {
343                 .name           = "KWorld/VStream XPert DVB-T",
344                 .tuner_type     = TUNER_ABSENT,
345                 .input          = {{
346                         .type   = CX88_VMUX_COMPOSITE1,
347                         .vmux   = 1,
348                         .gpio0  = 0x0700,
349                         .gpio2  = 0x0101,
350                 },{
351                         .type   = CX88_VMUX_SVIDEO,
352                         .vmux   = 2,
353                         .gpio0  = 0x0700,
354                         .gpio2  = 0x0101,
355                 }},
356                 .dvb            = 1,
357         },
358         [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1] = {
359                 .name           = "DVICO FusionHDTV DVB-T1",
360                 .tuner_type     = TUNER_ABSENT, /* No analog tuner */
361                 .input          = {{
362                         .type   = CX88_VMUX_COMPOSITE1,
363                         .vmux   = 1,
364                         .gpio0  = 0x000027df,
365                  },{
366                         .type   = CX88_VMUX_SVIDEO,
367                         .vmux   = 2,
368                         .gpio0  = 0x000027df,
369                 }},
370                 .dvb            = 1,
371         },
372         [CX88_BOARD_KWORLD_LTV883] = {
373                 .name           = "KWorld LTV883RF",
374                 .tuner_type     = 48,
375                 .input          = {{
376                         .type   = CX88_VMUX_TELEVISION,
377                         .vmux   = 0,
378                         .gpio0  = 0x07f8,
379                 },{
380                         .type   = CX88_VMUX_DEBUG,
381                         .vmux   = 0,
382                         .gpio0  = 0x07f9,  // mono from tuner chip
383                 },{
384                         .type   = CX88_VMUX_COMPOSITE1,
385                         .vmux   = 1,
386                         .gpio0  = 0x000007fa,
387                 },{
388                         .type   = CX88_VMUX_SVIDEO,
389                         .vmux   = 2,
390                         .gpio0  = 0x000007fa,
391                 }},
392                 .radio = {
393                         .type   = CX88_RADIO,
394                         .gpio0  = 0x000007f8,
395                 },
396         },
397         [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD] = {
398                 .name           = "DViCO - FusionHDTV 3 Gold",
399                 .tuner_type     = TUNER_MICROTUNE_4042FI5,
400                 /*
401                    GPIO[0] resets DT3302 DTV receiver
402                     0 - reset asserted
403                     1 - normal operation
404                    GPIO[1] mutes analog audio output connector
405                     0 - enable selected source
406                     1 - mute
407                    GPIO[2] selects source for analog audio output connector
408                     0 - analog audio input connector on tab
409                     1 - analog DAC output from CX23881 chip
410                    GPIO[3] selects RF input connector on tuner module
411                     0 - RF connector labeled CABLE
412                     1 - RF connector labeled ANT
413                 */
414                 .input          = {{
415                         .type   = CX88_VMUX_TELEVISION,
416                         .vmux   = 0,
417                         .gpio0  = 0x0f0d,
418                 },{
419                         .type   = CX88_VMUX_CABLE,
420                         .vmux   = 0,
421                         .gpio0  = 0x0f05,
422                 },{
423                         .type   = CX88_VMUX_COMPOSITE1,
424                         .vmux   = 1,
425                         .gpio0  = 0x0f00,
426                 },{
427                         .type   = CX88_VMUX_SVIDEO,
428                         .vmux   = 2,
429                         .gpio0  = 0x0f00,
430                 }},
431 #if 0
432                 .ts             = {
433                          .type   = CX88_TS,
434                          .gpio0  = 0x00000f01,   /* Hooked to tuner reset bit */
435                  }
436 #endif
437         },
438         [CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q] = {
439                 .name           = "DViCO - FusionHDTV 3 Gold-Q",
440                 .tuner_type     = 52, /* Thomson DDT 7610 ATSC/NTSC - Its actually a 7611 chip, but this works */
441                 .input          = {{
442                         .type   = CX88_VMUX_TELEVISION,
443                         .vmux   = 0,
444                         .gpio0  = 0x0f0d,
445                 },{
446                         .type   = CX88_VMUX_CABLE,
447                         .vmux   = 0,
448                         .gpio0  = 0x0f05,
449                 },{
450                         .type   = CX88_VMUX_COMPOSITE1,
451                         .vmux   = 1,
452                         .gpio0  = 0x0f00,
453                 },{
454                         .type   = CX88_VMUX_SVIDEO,
455                         .vmux   = 2,
456                         .gpio0  = 0x0f00,
457                 }},
458 #if 0
459                 .ts             = {
460                          .type   = CX88_TS,
461                          .gpio0  = 0x00000f01,   /* Hooked to tuner reset bit */
462                  }
463 #endif
464         },
465         [CX88_BOARD_HAUPPAUGE_DVB_T1] = {
466                 .name           = "Hauppauge Nova-T DVB-T",
467                 .tuner_type     = TUNER_ABSENT,
468                 .input          = {{
469                         .type   = CX88_VMUX_DVB,
470                         .vmux   = 0,
471                 }},
472                 .dvb            = 1,
473         },
474         [CX88_BOARD_CONEXANT_DVB_T1] = {
475                 .name           = "Conexant DVB-T reference design",
476                 .tuner_type     = TUNER_ABSENT,
477                 .input          = {{
478                         .type   = CX88_VMUX_DVB,
479                         .vmux   = 0,
480                 }},
481                 .dvb            = 1,
482         },
483         [CX88_BOARD_PROVIDEO_PV259] = {
484                 .name           = "Provideo PV259",
485                 .tuner_type     = TUNER_PHILIPS_FQ1216ME,
486                 .input          = {{
487                         .type   = CX88_VMUX_TELEVISION,
488                         .vmux   = 0,
489                 }},
490                 .blackbird = 1,
491         },
492         [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS] = {
493                 .name           = "DVICO FusionHDTV DVB-T Plus",
494                 .tuner_type     = TUNER_ABSENT, /* No analog tuner */
495                 .input          = {{
496                         .type   = CX88_VMUX_COMPOSITE1,
497                         .vmux   = 1,
498                         .gpio0  = 0x000027df,
499                  },{
500                         .type   = CX88_VMUX_SVIDEO,
501                         .vmux   = 2,
502                         .gpio0  = 0x000027df,
503                 }},
504                 .dvb            = 1,
505         },
506         [CX88_BOARD_DNTV_LIVE_DVB_T] = {
507                 .name           = "digitalnow DNTV Live! DVB-T",
508                 .tuner_type     = TUNER_ABSENT,
509                 .input          = {{
510                         .type   = CX88_VMUX_COMPOSITE1,
511                         .vmux   = 1,
512                         .gpio0  = 0x00000700,
513                         .gpio2  = 0x00000101,
514                 },{
515                         .type   = CX88_VMUX_SVIDEO,
516                         .vmux   = 2,
517                         .gpio0  = 0x00000700,
518                         .gpio2  = 0x00000101,
519                 }},
520                 .dvb            = 1,
521         },
522         [CX88_BOARD_PCHDTV_HD3000] = {
523                 .name           = "pcHDTV HD3000 HDTV",
524                 .tuner_type     = TUNER_THOMSON_DTT7610,
525                 .input          = {{
526                         .type   = CX88_VMUX_TELEVISION,
527                         .vmux   = 0,
528                         .gpio0  = 0x00008484,
529                         .gpio1  = 0x00000000,
530                         .gpio2  = 0x00000000,
531                         .gpio3  = 0x00000000,
532                 },{
533                         .type   = CX88_VMUX_COMPOSITE1,
534                         .vmux   = 1,
535                         .gpio0  = 0x00008400,
536                         .gpio1  = 0x00000000,
537                         .gpio2  = 0x00000000,
538                         .gpio3  = 0x00000000,
539                 },{
540                         .type   = CX88_VMUX_SVIDEO,
541                         .vmux   = 2,
542                         .gpio0  = 0x00008400,
543                         .gpio1  = 0x00000000,
544                         .gpio2  = 0x00000000,
545                         .gpio3  = 0x00000000,
546                 }},
547                 .radio = {
548                         .type   = CX88_RADIO,
549                         .vmux   = 2,
550                         .gpio0  = 0x00008400,
551                         .gpio1  = 0x00000000,
552                         .gpio2  = 0x00000000,
553                         .gpio3  = 0x00000000,
554                 },
555                 .dvb            = 1,
556         },
557         [CX88_BOARD_HAUPPAUGE_ROSLYN] = {
558                 // entry added by Kaustubh D. Bhalerao <bhalerao.1@osu.edu>
559                 // GPIO values obtained from regspy, courtesy Sean Covel
560                 .name        = "Hauppauge WinTV 28xxx (Roslyn) models",
561                 .tuner_type  = UNSET,
562                 .input          = {{
563                         .type   = CX88_VMUX_TELEVISION,
564                         .vmux   = 0,
565                         .gpio0  = 0xed12,  // internal decoder
566                         .gpio2  = 0x00ff,
567                 },{
568                         .type   = CX88_VMUX_DEBUG,
569                         .vmux   = 0,
570                         .gpio0  = 0xff01,  // mono from tuner chip
571                 },{
572                         .type   = CX88_VMUX_COMPOSITE1,
573                         .vmux   = 1,
574                         .gpio0  = 0xff02,
575                 },{
576                         .type   = CX88_VMUX_SVIDEO,
577                         .vmux   = 2,
578                         .gpio0  = 0xed92,
579                         .gpio2  = 0x00ff,
580                 }},
581                 .radio = {
582                          .type   = CX88_RADIO,
583                          .gpio0  = 0xed96,
584                          .gpio2  = 0x00ff,
585                  },
586                 .blackbird = 1,
587         },
588         [CX88_BOARD_DIGITALLOGIC_MEC] = {
589                 /* params copied over from Leadtek PVR 2000 */
590                 .name           = "Digital-Logic MICROSPACE Entertainment Center (MEC)",
591                 /* not sure yet about the tuner type */
592                 .tuner_type     = 38,
593                 .tda9887_conf   = TDA9887_PRESENT,
594                 .input          = {{
595                         .type   = CX88_VMUX_TELEVISION,
596                         .vmux   = 0,
597                         .gpio0  = 0x0000bde6,
598                 },{
599                         .type   = CX88_VMUX_COMPOSITE1,
600                         .vmux   = 1,
601                         .gpio0  = 0x0000bde6,
602                 },{
603                         .type   = CX88_VMUX_SVIDEO,
604                         .vmux   = 2,
605                         .gpio0  = 0x0000bde6,
606                 }},
607                 .radio = {
608                         .type   = CX88_RADIO,
609                         .gpio0  = 0x0000bd62,
610                 },
611                 .blackbird = 1,
612         },
613         [CX88_BOARD_IODATA_GVBCTV7E] = {
614                 .name           = "IODATA GV/BCTV7E",
615                 .tuner_type     = TUNER_PHILIPS_FQ1286,
616                 .tda9887_conf   = TDA9887_PRESENT,
617                 .input          = {{
618                         .type   = CX88_VMUX_TELEVISION,
619                         .vmux   = 1,
620                         .gpio1  = 0x0000e03f,
621                 },{
622                         .type   = CX88_VMUX_COMPOSITE1,
623                         .vmux   = 2,
624                         .gpio1  = 0x0000e07f,
625                 },{
626                         .type   = CX88_VMUX_SVIDEO,
627                         .vmux   = 3,
628                         .gpio1  = 0x0000e07f,
629                 }}
630         },
631         [CX88_BOARD_PIXELVIEW_PLAYTV_ULTRA_PRO] = {
632                 .name           = "PixelView PlayTV Ultra Pro (Stereo)",
633                 .tuner_type     = 38,
634                 .input          = {{
635                         .type   = CX88_VMUX_TELEVISION,
636                         .vmux   = 0,
637                         .gpio0  = 0xbf61,  // internal decoder
638                 },{
639                         .type   = CX88_VMUX_COMPOSITE1,
640                         .vmux   = 1,
641                         .gpio0  = 0xbf63,
642                 },{
643                         .type   = CX88_VMUX_SVIDEO,
644                         .vmux   = 2,
645                         .gpio0  = 0xbf63,
646                 }},
647                 .radio = {
648                         .type  = CX88_RADIO,
649                         .gpio0 = 0xbf60,
650                 },
651         },
652 };
653 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
654
655 /* ------------------------------------------------------------------ */
656 /* PCI subsystem IDs                                                  */
657
658 struct cx88_subid cx88_subids[] = {
659         {
660                 .subvendor = 0x0070,
661                 .subdevice = 0x3400,
662                 .card      = CX88_BOARD_HAUPPAUGE,
663         },{
664                 .subvendor = 0x0070,
665                 .subdevice = 0x3401,
666                 .card      = CX88_BOARD_HAUPPAUGE,
667         },{
668                 .subvendor = 0x14c7,
669                 .subdevice = 0x0106,
670                 .card      = CX88_BOARD_GDI,
671         },{
672                 .subvendor = 0x14c7,
673                 .subdevice = 0x0107, /* with mpeg encoder */
674                 .card      = CX88_BOARD_GDI,
675         },{
676                 .subvendor = PCI_VENDOR_ID_ATI,
677                 .subdevice = 0x00f8,
678                 .card      = CX88_BOARD_ATI_WONDER_PRO,
679         },{
680                 .subvendor = 0x107d,
681                 .subdevice = 0x6611,
682                 .card      = CX88_BOARD_WINFAST2000XP_EXPERT,
683         },{
684                 .subvendor = 0x107d,
685                 .subdevice = 0x6613,    /* NTSC */
686                 .card      = CX88_BOARD_WINFAST2000XP_EXPERT,
687         },{
688                 .subvendor = 0x107d,
689                 .subdevice = 0x6620,
690                 .card      = CX88_BOARD_WINFAST_DV2000,
691         },{
692                 .subvendor = 0x107d,
693                 .subdevice = 0x663b,
694                 .card      = CX88_BOARD_LEADTEK_PVR2000,
695         },{
696                 .subvendor = 0x107d,
697                 .subdevice = 0x663C,
698                 .card      = CX88_BOARD_LEADTEK_PVR2000,
699         },{
700                 .subvendor = 0x1461,
701                 .subdevice = 0x000b,
702                 .card      = CX88_BOARD_AVERTV_303,
703         },{
704                 .subvendor = 0x1462,
705                 .subdevice = 0x8606,
706                 .card      = CX88_BOARD_MSI_TVANYWHERE_MASTER,
707         },{
708                 .subvendor = 0x10fc,
709                 .subdevice = 0xd003,
710                 .card      = CX88_BOARD_IODATA_GVVCP3PCI,
711         },{
712                 .subvendor = 0x1043,
713                 .subdevice = 0x4823,  /* with mpeg encoder */
714                 .card      = CX88_BOARD_ASUS_PVR_416,
715         },{
716                 .subvendor = 0x17de,
717                 .subdevice = 0x08a6,
718                 .card      = CX88_BOARD_KWORLD_DVB_T,
719         },{
720                 .subvendor = 0x18ac,
721                 .subdevice = 0xd810,
722                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD,
723         },{
724                 .subvendor = 0x18ac,
725                 .subdevice = 0xd820,
726                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q,
727         },{
728                 .subvendor = 0x18AC,
729                 .subdevice = 0xDB00,
730                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1,
731         },{
732                 .subvendor = 0x0070,
733                 .subdevice = 0x9002,
734                 .card      = CX88_BOARD_HAUPPAUGE_DVB_T1,
735         },{
736                 .subvendor = 0x14f1,
737                 .subdevice = 0x0187,
738                 .card      = CX88_BOARD_CONEXANT_DVB_T1,
739         },{
740                 .subvendor = 0x1540,
741                 .subdevice = 0x2580,
742                 .card      = CX88_BOARD_PROVIDEO_PV259,
743         },{
744                 .subvendor = 0x18AC,
745                 .subdevice = 0xDB10,
746                 .card      = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS,
747         },{
748                 .subvendor = 0x1554,
749                 .subdevice = 0x4811,
750                 .card      = CX88_BOARD_PIXELVIEW,
751         },{
752                 .subvendor = 0x7063,
753                 .subdevice = 0x3000, /* HD-3000 card */
754                 .card      = CX88_BOARD_PCHDTV_HD3000,
755         },{
756                 .subvendor = 0x17DE,
757                 .subdevice = 0xA8A6,
758                 .card      = CX88_BOARD_DNTV_LIVE_DVB_T,
759         },{
760                 .subvendor = 0x0070,
761                 .subdevice = 0x2801,
762                 .card      = CX88_BOARD_HAUPPAUGE_ROSLYN,
763         },{
764                 .subvendor = 0x14F1,
765                 .subdevice = 0x0342,
766                 .card      = CX88_BOARD_DIGITALLOGIC_MEC,
767         },{
768                 .subvendor = 0x10fc,
769                 .subdevice = 0xd035,
770                 .card      = CX88_BOARD_IODATA_GVBCTV7E,
771         }
772 };
773 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
774
775 /* ----------------------------------------------------------------------- */
776 /* some leadtek specific stuff                                             */
777
778 static void __devinit leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
779 {
780         /* This is just for the "Winfast 2000XP Expert" board ATM; I don't have data on
781          * any others.
782          *
783          * Byte 0 is 1 on the NTSC board.
784          */
785
786         if (eeprom_data[4] != 0x7d ||
787             eeprom_data[5] != 0x10 ||
788             eeprom_data[7] != 0x66) {
789                 printk(KERN_WARNING "%s: Leadtek eeprom invalid.\n",
790                        core->name);
791                 return;
792         }
793
794         core->has_radio  = 1;
795         core->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
796
797         printk(KERN_INFO "%s: Leadtek Winfast 2000XP Expert config: "
798                "tuner=%d, eeprom[0]=0x%02x\n",
799                core->name, core->tuner_type, eeprom_data[0]);
800 }
801
802
803 /* ----------------------------------------------------------------------- */
804
805 static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
806 {
807         struct tveeprom tv;
808
809         tveeprom_hauppauge_analog(&tv, eeprom_data);
810         core->tuner_type = tv.tuner_type;
811         core->has_radio  = tv.has_radio;
812 }
813
814 static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
815 {
816         int model;
817         int tuner;
818
819         /* Make sure we support the board model */
820         model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c];
821         switch(model) {
822         case 90002:
823         case 90500:
824         case 90501:
825                 /* known */
826                 break;
827         default:
828                 printk("%s: warning: unknown hauppauge model #%d\n",
829                        core->name, model);
830                 break;
831         }
832
833         /* Make sure we support the tuner */
834         tuner = ee[0x2d];
835         switch(tuner) {
836         case 0x4B: /* dtt 7595 */
837         case 0x4C: /* dtt 7592 */
838                 break;
839         default:
840                 printk("%s: error: unknown hauppauge tuner 0x%02x\n",
841                        core->name, tuner);
842                 return -ENODEV;
843         }
844         printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d\n",
845                core->name, model, tuner);
846         return 0;
847 }
848
849 /* ----------------------------------------------------------------------- */
850 /* some GDI (was: Modular Technology) specific stuff                       */
851
852 static struct {
853         int  id;
854         int  fm;
855         char *name;
856 } gdi_tuner[] = {
857         [ 0x01 ] = { .id   = TUNER_ABSENT,
858                      .name = "NTSC_M" },
859         [ 0x02 ] = { .id   = TUNER_ABSENT,
860                      .name = "PAL_B" },
861         [ 0x03 ] = { .id   = TUNER_ABSENT,
862                      .name = "PAL_I" },
863         [ 0x04 ] = { .id   = TUNER_ABSENT,
864                      .name = "PAL_D" },
865         [ 0x05 ] = { .id   = TUNER_ABSENT,
866                      .name = "SECAM" },
867
868         [ 0x10 ] = { .id   = TUNER_ABSENT,
869                      .fm   = 1,
870                      .name = "TEMIC_4049" },
871         [ 0x11 ] = { .id   = TUNER_TEMIC_4136FY5,
872                      .name = "TEMIC_4136" },
873         [ 0x12 ] = { .id   = TUNER_ABSENT,
874                      .name = "TEMIC_4146" },
875
876         [ 0x20 ] = { .id   = TUNER_PHILIPS_FQ1216ME,
877                      .fm   = 1,
878                      .name = "PHILIPS_FQ1216_MK3" },
879         [ 0x21 ] = { .id   = TUNER_ABSENT, .fm = 1,
880                      .name = "PHILIPS_FQ1236_MK3" },
881         [ 0x22 ] = { .id   = TUNER_ABSENT,
882                      .name = "PHILIPS_FI1236_MK3" },
883         [ 0x23 ] = { .id   = TUNER_ABSENT,
884                      .name = "PHILIPS_FI1216_MK3" },
885 };
886
887 static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data)
888 {
889         char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
890                 ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
891
892         printk(KERN_INFO "%s: GDI: tuner=%s\n", core->name,
893                name ? name : "unknown");
894         if (NULL == name)
895                 return;
896         core->tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
897         core->has_radio  = gdi_tuner[eeprom_data[0x0d]].fm;
898 }
899
900 /* ----------------------------------------------------------------------- */
901
902 void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
903 {
904         int i;
905
906         if (0 == pci->subsystem_vendor &&
907             0 == pci->subsystem_device) {
908                 printk("%s: Your board has no valid PCI Subsystem ID and thus can't\n"
909                        "%s: be autodetected.  Please pass card=<n> insmod option to\n"
910                        "%s: workaround that.  Redirect complaints to the vendor of\n"
911                        "%s: the TV card.  Best regards,\n"
912                        "%s:         -- tux\n",
913                        core->name,core->name,core->name,core->name,core->name);
914         } else {
915                 printk("%s: Your board isn't known (yet) to the driver.  You can\n"
916                        "%s: try to pick one of the existing card configs via\n"
917                        "%s: card=<n> insmod option.  Updating to the latest\n"
918                        "%s: version might help as well.\n",
919                        core->name,core->name,core->name,core->name);
920         }
921         printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
922                core->name);
923         for (i = 0; i < cx88_bcount; i++)
924                 printk("%s:    card=%d -> %s\n",
925                        core->name, i, cx88_boards[i].name);
926 }
927
928 void cx88_card_setup(struct cx88_core *core)
929 {
930         static u8 eeprom[128];
931
932         if (0 == core->i2c_rc) {
933                 core->i2c_client.addr = 0xa0 >> 1;
934                 tveeprom_read(&core->i2c_client,eeprom,sizeof(eeprom));
935         }
936
937         switch (core->board) {
938         case CX88_BOARD_HAUPPAUGE:
939         case CX88_BOARD_HAUPPAUGE_ROSLYN:
940                 if (0 == core->i2c_rc)
941                         hauppauge_eeprom(core,eeprom+8);
942                 break;
943         case CX88_BOARD_GDI:
944                 if (0 == core->i2c_rc)
945                         gdi_eeprom(core,eeprom);
946                 break;
947         case CX88_BOARD_WINFAST2000XP_EXPERT:
948                 if (0 == core->i2c_rc)
949                         leadtek_eeprom(core,eeprom);
950                 break;
951         case CX88_BOARD_HAUPPAUGE_DVB_T1:
952                 if (0 == core->i2c_rc)
953                         hauppauge_eeprom_dvb(core,eeprom);
954                 break;
955         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
956         case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
957                 /* GPIO0:0 is hooked to mt352 reset pin */
958                 cx_set(MO_GP0_IO, 0x00000101);
959                 cx_clear(MO_GP0_IO, 0x00000001);
960                 msleep(1);
961                 cx_set(MO_GP0_IO, 0x00000101);
962                 break;
963         case CX88_BOARD_KWORLD_DVB_T:
964         case CX88_BOARD_DNTV_LIVE_DVB_T:
965                 cx_set(MO_GP0_IO, 0x00000707);
966                 cx_set(MO_GP2_IO, 0x00000101);
967                 cx_clear(MO_GP2_IO, 0x00000001);
968                 msleep(1);
969                 cx_clear(MO_GP0_IO, 0x00000007);
970                 cx_set(MO_GP2_IO, 0x00000101);
971                 break;
972         }
973         if (cx88_boards[core->board].radio.type == CX88_RADIO)
974                 core->has_radio = 1;
975 }
976
977 /* ------------------------------------------------------------------ */
978
979 EXPORT_SYMBOL(cx88_boards);
980 EXPORT_SYMBOL(cx88_bcount);
981 EXPORT_SYMBOL(cx88_subids);
982 EXPORT_SYMBOL(cx88_idcount);
983 EXPORT_SYMBOL(cx88_card_list);
984 EXPORT_SYMBOL(cx88_card_setup);
985
986 /*
987  * Local variables:
988  * c-basic-offset: 8
989  * End:
990  */