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