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