initial commit with v2.6.9
[linux-2.6.9-moxart.git] / drivers / media / video / cx88 / cx88-cards.c
blob1e183aae05e7fd13046e631558181888ac22b7e9
1 /*
2 * device driver for Conexant 2388x based TV cards
3 * card-specific stuff.
5 * (c) 2003 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <linux/init.h>
23 #include <linux/module.h>
24 #include <linux/pci.h>
26 #include "cx88.h"
28 /* ------------------------------------------------------------------ */
29 /* board config info */
31 struct cx88_board cx88_boards[] = {
32 [CX88_BOARD_UNKNOWN] = {
33 .name = "UNKNOWN/GENERIC",
34 .tuner_type = UNSET,
35 .input = {{
36 .type = CX88_VMUX_COMPOSITE1,
37 .vmux = 0,
38 },{
39 .type = CX88_VMUX_COMPOSITE2,
40 .vmux = 1,
41 },{
42 .type = CX88_VMUX_COMPOSITE3,
43 .vmux = 2,
44 },{
45 .type = CX88_VMUX_COMPOSITE4,
46 .vmux = 3,
47 }},
49 [CX88_BOARD_HAUPPAUGE] = {
50 .name = "Hauppauge WinTV 34xxx models",
51 .tuner_type = UNSET,
52 .input = {{
53 .type = CX88_VMUX_TELEVISION,
54 .vmux = 0,
55 .gpio0 = 0xff00, // internal decoder
56 },{
57 .type = CX88_VMUX_DEBUG,
58 .vmux = 0,
59 .gpio0 = 0xff01, // mono from tuner chip
60 },{
61 .type = CX88_VMUX_COMPOSITE1,
62 .vmux = 1,
63 .gpio0 = 0xff02,
64 },{
65 .type = CX88_VMUX_SVIDEO,
66 .vmux = 2,
67 .gpio0 = 0xff02,
68 }},
69 .radio = {
70 .type = CX88_RADIO,
71 .gpio0 = 0xff01,
74 [CX88_BOARD_GDI] = {
75 .name = "GDI Black Gold",
76 .tuner_type = UNSET,
77 .input = {{
78 .type = CX88_VMUX_TELEVISION,
79 .vmux = 0,
80 }},
82 [CX88_BOARD_PIXELVIEW] = {
83 .name = "PixelView",
84 .tuner_type = UNSET,
85 .input = {{
86 .type = CX88_VMUX_TELEVISION,
87 .vmux = 0,
88 },{
89 .type = CX88_VMUX_COMPOSITE1,
90 .vmux = 1,
91 },{
92 .type = CX88_VMUX_SVIDEO,
93 .vmux = 2,
94 }},
96 [CX88_BOARD_ATI_WONDER_PRO] = {
97 .name = "ATI TV Wonder Pro",
98 .tuner_type = 44,
99 .input = {{
100 .type = CX88_VMUX_TELEVISION,
101 .vmux = 0,
102 .gpio0 = 0x000003ff,
103 .gpio1 = 0x000000ff,
104 .gpio2 = 0x000000ff,
105 .gpio3 = 0x00000000,
107 .type = CX88_VMUX_COMPOSITE1,
108 .vmux = 1,
110 .type = CX88_VMUX_SVIDEO,
111 .vmux = 2,
115 [CX88_BOARD_WINFAST2000XP] = {
116 .name = "Leadtek Winfast 2000XP Expert",
117 .tuner_type = 44,
118 .needs_tda9887 = 1,
119 .input = {{
120 .type = CX88_VMUX_TELEVISION,
121 .vmux = 0,
122 .gpio0 = 0x00F5e700,
123 .gpio1 = 0x00003004,
124 .gpio2 = 0x00F5e700,
125 .gpio3 = 0x02000000,
127 .type = CX88_VMUX_COMPOSITE1,
128 .vmux = 1,
129 .gpio0 = 0x00F5c700,
130 .gpio1 = 0x00003004,
131 .gpio2 = 0x00F5c700,
132 .gpio3 = 0x02000000,
134 .type = CX88_VMUX_SVIDEO,
135 .vmux = 2,
136 .gpio0 = 0x00F5c700,
137 .gpio1 = 0x00003004,
138 .gpio2 = 0x00F5c700,
139 .gpio3 = 0x02000000,
141 .radio = {
142 .type = CX88_RADIO,
143 .gpio0 = 0x00F5d700,
144 .gpio1 = 0x00003004,
145 .gpio2 = 0x00F5d700,
146 .gpio3 = 0x02000000,
149 [CX88_BOARD_AVERTV_303] = {
150 .name = "AverTV Studio 303 (M126)",
151 .tuner_type = TUNER_PHILIPS_PAL_DK,
152 .input = {{
153 .type = CX88_VMUX_TELEVISION,
154 .vmux = 0,
157 [CX88_BOARD_MSI_TVANYWHERE_MASTER] = {
158 //added gpio values thanks to Torsten Seeboth
159 //values for PAL from DScaler
160 .name = "MSI TV-@nywhere Master",
161 .tuner_type = 33,
162 .needs_tda9887 = 1,
163 .input = {{
164 .type = CX88_VMUX_TELEVISION,
165 .vmux = 0,
166 .gpio0 = 0x000040bf,
167 .gpio1 = 0x000080c0,
168 .gpio2 = 0x0000ff40,
169 .gpio3 = 0x00000000,
171 .type = CX88_VMUX_COMPOSITE1,
172 .vmux = 1,
173 .gpio0 = 0x000040bf,
174 .gpio1 = 0x000080c0,
175 .gpio2 = 0x0000ff40,
176 .gpio3 = 0x00000000,
178 .type = CX88_VMUX_SVIDEO,
179 .vmux = 2,
180 .gpio0 = 0x000040bf,
181 .gpio1 = 0x000080c0,
182 .gpio2 = 0x0000ff40,
183 .gpio3 = 0x00000000,
185 .radio = {
186 .type = CX88_RADIO,
189 [CX88_BOARD_WINFAST_DV2000] = {
190 .name = "Leadtek Winfast DV2000",
191 .tuner_type = 38,
192 .needs_tda9887 = 1,
193 .input = {{
194 .type = CX88_VMUX_TELEVISION,
195 .vmux = 0,
197 .radio = {
198 .type = CX88_RADIO,
201 [CX88_BOARD_LEADTEK_PVR2000] = {
202 .name = "Leadtek PVR 2000",
203 .tuner_type = 38,
204 .input = {{
205 .type = CX88_VMUX_TELEVISION,
206 .vmux = 0,
208 .type = CX88_VMUX_COMPOSITE1,
209 .vmux = 1,
211 .type = CX88_VMUX_SVIDEO,
212 .vmux = 2,
214 .radio = {
215 .type = CX88_RADIO,
218 [CX88_BOARD_IODATA_GVVCP3PCI] = {
219 .name = "IODATA GV-VCP3/PCI",
220 .tuner_type = TUNER_ABSENT,
221 .needs_tda9887 = 0,
222 .input = {{
223 .type = CX88_VMUX_COMPOSITE1,
224 .vmux = 0,
226 .type = CX88_VMUX_COMPOSITE2,
227 .vmux = 1,
229 .type = CX88_VMUX_SVIDEO,
230 .vmux = 2,
233 [CX88_BOARD_PROLINK_PLAYTVPVR] = {
234 .name = "Prolink PlayTV PVR",
235 .tuner_type = 43,
236 .needs_tda9887 = 1,
237 .input = {{
238 .type = CX88_VMUX_TELEVISION,
239 .vmux = 0,
240 .gpio0 = 0xff00,
242 .type = CX88_VMUX_COMPOSITE1,
243 .vmux = 1,
244 .gpio0 = 0xff03,
246 .type = CX88_VMUX_SVIDEO,
247 .vmux = 2,
248 .gpio0 = 0xff03,
250 .radio = {
251 .type = CX88_RADIO,
252 .gpio0 = 0xff00,
255 [CX88_BOARD_ASUS_PVR_416] = {
256 .name = "ASUS PVR-416",
257 .tuner_type = 43,
258 .needs_tda9887 = 1,
259 .input = {{
260 .type = CX88_VMUX_TELEVISION,
261 .vmux = 0,
262 .gpio0 = 0x0000fde6,
263 .gpio1 = 0x00000000, // possibly for mpeg data
264 .gpio2 = 0x000000e9,
265 .gpio3 = 0x00000000,
267 .type = CX88_VMUX_SVIDEO,
268 .vmux = 2,
269 .gpio0 = 0x0000fde6, // 0x0000fda6 L,R RCA audio in?
270 .gpio1 = 0x00000000, // possibly for mpeg data
271 .gpio2 = 0x000000e9,
272 .gpio3 = 0x00000000,
274 .radio = {
275 .type = CX88_RADIO,
276 .gpio0 = 0x0000fde2,
277 .gpio1 = 0x00000000,
278 .gpio2 = 0x000000e9,
279 .gpio3 = 0x00000000,
282 [CX88_BOARD_MSI_TVANYWHERE] = {
283 .name = "MSI TV-@nywhere",
284 .tuner_type = 33,
285 .needs_tda9887 = 1,
286 .input = {{
287 .type = CX88_VMUX_TELEVISION,
288 .vmux = 0,
289 .gpio0 = 0x00000fbf,
290 .gpio1 = 0x000000c0,
291 .gpio2 = 0x0000fc08,
292 .gpio3 = 0x00000000,
294 .type = CX88_VMUX_COMPOSITE1,
295 .vmux = 1,
296 .gpio0 = 0x00000fbf,
297 .gpio1 = 0x000000c0,
298 .gpio2 = 0x0000fc68,
299 .gpio3 = 0x00000000,
301 .type = CX88_VMUX_SVIDEO,
302 .vmux = 2,
303 .gpio0 = 0x00000fbf,
304 .gpio1 = 0x000000c0,
305 .gpio2 = 0x0000fc68,
306 .gpio3 = 0x00000000,
310 const unsigned int cx88_bcount = ARRAY_SIZE(cx88_boards);
312 /* ------------------------------------------------------------------ */
313 /* PCI subsystem IDs */
315 struct cx88_subid cx88_subids[] = {
317 .subvendor = 0x0070,
318 .subdevice = 0x3400,
319 .card = CX88_BOARD_HAUPPAUGE,
321 .subvendor = 0x0070,
322 .subdevice = 0x3401,
323 .card = CX88_BOARD_HAUPPAUGE,
325 .subvendor = 0x14c7,
326 .subdevice = 0x0106,
327 .card = CX88_BOARD_GDI,
329 .subvendor = 0x14c7,
330 .subdevice = 0x0107, /* with mpeg encoder */
331 .card = CX88_BOARD_GDI,
333 .subvendor = PCI_VENDOR_ID_ATI,
334 .subdevice = 0x00f8,
335 .card = CX88_BOARD_ATI_WONDER_PRO,
337 .subvendor = 0x107d,
338 .subdevice = 0x6611,
339 .card = CX88_BOARD_WINFAST2000XP,
341 .subvendor = 0x107d,
342 .subdevice = 0x6613, /* NTSC */
343 .card = CX88_BOARD_WINFAST2000XP,
345 .subvendor = 0x107d,
346 .subdevice = 0x6620,
347 .card = CX88_BOARD_WINFAST_DV2000,
349 .subvendor = 0x107d,
350 .subdevice = 0x663b,
351 .card = CX88_BOARD_LEADTEK_PVR2000,
353 .subvendor = 0x107d,
354 .subdevice = 0x663C,
355 .card = CX88_BOARD_LEADTEK_PVR2000,
357 .subvendor = 0x1461,
358 .subdevice = 0x000b,
359 .card = CX88_BOARD_AVERTV_303,
361 .subvendor = 0x1462,
362 .subdevice = 0x8606,
363 .card = CX88_BOARD_MSI_TVANYWHERE_MASTER,
365 .subvendor = 0x10fc,
366 .subdevice = 0xd003,
367 .card = CX88_BOARD_IODATA_GVVCP3PCI,
369 .subvendor = 0x1043,
370 .subdevice = 0x4823, /* with mpeg encoder */
371 .card = CX88_BOARD_ASUS_PVR_416,
374 const unsigned int cx88_idcount = ARRAY_SIZE(cx88_subids);
376 /* ----------------------------------------------------------------------- */
377 /* some leadtek specific stuff */
379 static void __devinit leadtek_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
381 /* This is just for the Winfast 2000 XP board ATM; I don't have data on
382 * any others.
384 * Byte 0 is 1 on the NTSC board.
387 if (eeprom_data[4] != 0x7d ||
388 eeprom_data[5] != 0x10 ||
389 eeprom_data[7] != 0x66) {
390 printk(KERN_WARNING "%s Leadtek eeprom invalid.\n", dev->name);
391 return;
394 dev->has_radio = 1;
395 dev->tuner_type = (eeprom_data[6] == 0x13) ? 43 : 38;
397 printk(KERN_INFO "%s: Leadtek Winfast 2000 XP config: "
398 "tuner=%d, eeprom[0]=0x%02x\n",
399 dev->name, dev->tuner_type, eeprom_data[0]);
403 /* ----------------------------------------------------------------------- */
404 /* some hauppauge specific stuff */
406 static struct {
407 int id;
408 char *name;
409 } hauppauge_tuner[] __devinitdata = {
410 { TUNER_ABSENT, "" },
411 { TUNER_ABSENT, "External" },
412 { TUNER_ABSENT, "Unspecified" },
413 { TUNER_PHILIPS_PAL, "Philips FI1216" },
414 { TUNER_PHILIPS_SECAM, "Philips FI1216MF" },
415 { TUNER_PHILIPS_NTSC, "Philips FI1236" },
416 { TUNER_PHILIPS_PAL_I, "Philips FI1246" },
417 { TUNER_PHILIPS_PAL_DK,"Philips FI1256" },
418 { TUNER_PHILIPS_PAL, "Philips FI1216 MK2" },
419 { TUNER_PHILIPS_SECAM, "Philips FI1216MF MK2" },
420 { TUNER_PHILIPS_NTSC, "Philips FI1236 MK2" },
421 { TUNER_PHILIPS_PAL_I, "Philips FI1246 MK2" },
422 { TUNER_PHILIPS_PAL_DK,"Philips FI1256 MK2" },
423 { TUNER_TEMIC_NTSC, "Temic 4032FY5" },
424 { TUNER_TEMIC_PAL, "Temic 4002FH5" },
425 { TUNER_TEMIC_PAL_I, "Temic 4062FY5" },
426 { TUNER_PHILIPS_PAL, "Philips FR1216 MK2" },
427 { TUNER_PHILIPS_SECAM, "Philips FR1216MF MK2" },
428 { TUNER_PHILIPS_NTSC, "Philips FR1236 MK2" },
429 { TUNER_PHILIPS_PAL_I, "Philips FR1246 MK2" },
430 { TUNER_PHILIPS_PAL_DK,"Philips FR1256 MK2" },
431 { TUNER_PHILIPS_PAL, "Philips FM1216" },
432 { TUNER_PHILIPS_SECAM, "Philips FM1216MF" },
433 { TUNER_PHILIPS_NTSC, "Philips FM1236" },
434 { TUNER_PHILIPS_PAL_I, "Philips FM1246" },
435 { TUNER_PHILIPS_PAL_DK,"Philips FM1256" },
436 { TUNER_TEMIC_4036FY5_NTSC, "Temic 4036FY5" },
437 { TUNER_ABSENT, "Samsung TCPN9082D" },
438 { TUNER_ABSENT, "Samsung TCPM9092P" },
439 { TUNER_TEMIC_4006FH5_PAL, "Temic 4006FH5" },
440 { TUNER_ABSENT, "Samsung TCPN9085D" },
441 { TUNER_ABSENT, "Samsung TCPB9085P" },
442 { TUNER_ABSENT, "Samsung TCPL9091P" },
443 { TUNER_TEMIC_4039FR5_NTSC, "Temic 4039FR5" },
444 { TUNER_PHILIPS_FQ1216ME, "Philips FQ1216 ME" },
445 { TUNER_TEMIC_4066FY5_PAL_I, "Temic 4066FY5" },
446 { TUNER_PHILIPS_NTSC, "Philips TD1536" },
447 { TUNER_PHILIPS_NTSC, "Philips TD1536D" },
448 { TUNER_PHILIPS_NTSC, "Philips FMR1236" }, /* mono radio */
449 { TUNER_ABSENT, "Philips FI1256MP" },
450 { TUNER_ABSENT, "Samsung TCPQ9091P" },
451 { TUNER_TEMIC_4006FN5_MULTI_PAL, "Temic 4006FN5" },
452 { TUNER_TEMIC_4009FR5_PAL, "Temic 4009FR5" },
453 { TUNER_TEMIC_4046FM5, "Temic 4046FM5" },
454 { TUNER_TEMIC_4009FN5_MULTI_PAL_FM, "Temic 4009FN5" },
455 { TUNER_ABSENT, "Philips TD1536D_FH_44"},
456 { TUNER_LG_NTSC_FM, "LG TPI8NSR01F"},
457 { TUNER_LG_PAL_FM, "LG TPI8PSB01D"},
458 { TUNER_LG_PAL, "LG TPI8PSB11D"},
459 { TUNER_LG_PAL_I_FM, "LG TAPC-I001D"},
460 { TUNER_LG_PAL_I, "LG TAPC-I701D"}
463 static void __devinit hauppauge_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
465 unsigned int blk2,tuner,radio,model;
467 if (eeprom_data[0] != 0x84 || eeprom_data[2] != 0) {
468 printk(KERN_WARNING "%s: Hauppauge eeprom: invalid\n",
469 dev->name);
470 return;
473 /* Block 2 starts after len+3 bytes header */
474 blk2 = eeprom_data[1] + 3;
476 /* decode + use some config infos */
477 model = eeprom_data[12] << 8 | eeprom_data[11];
478 tuner = eeprom_data[9];
479 radio = eeprom_data[blk2-1] & 0x01;
481 if (tuner < ARRAY_SIZE(hauppauge_tuner))
482 dev->tuner_type = hauppauge_tuner[tuner].id;
483 if (radio)
484 dev->has_radio = 1;
486 printk(KERN_INFO "%s: hauppauge eeprom: model=%d, "
487 "tuner=%s (%d), radio=%s\n",
488 dev->name, model, hauppauge_tuner[tuner].name,
489 dev->tuner_type, radio ? "yes" : "no");
492 /* ----------------------------------------------------------------------- */
493 /* some GDI (was: Modular Technology) specific stuff */
495 static struct {
496 int id;
497 int fm;
498 char *name;
499 } gdi_tuner[] = {
500 [ 0x01 ] = { .id = TUNER_ABSENT,
501 .name = "NTSC_M" },
502 [ 0x02 ] = { .id = TUNER_ABSENT,
503 .name = "PAL_B" },
504 [ 0x03 ] = { .id = TUNER_ABSENT,
505 .name = "PAL_I" },
506 [ 0x04 ] = { .id = TUNER_ABSENT,
507 .name = "PAL_D" },
508 [ 0x05 ] = { .id = TUNER_ABSENT,
509 .name = "SECAM" },
511 [ 0x10 ] = { .id = TUNER_ABSENT,
512 .fm = 1,
513 .name = "TEMIC_4049" },
514 [ 0x11 ] = { .id = TUNER_TEMIC_4136FY5,
515 .name = "TEMIC_4136" },
516 [ 0x12 ] = { .id = TUNER_ABSENT,
517 .name = "TEMIC_4146" },
519 [ 0x20 ] = { .id = TUNER_PHILIPS_FQ1216ME,
520 .fm = 1,
521 .name = "PHILIPS_FQ1216_MK3" },
522 [ 0x21 ] = { .id = TUNER_ABSENT, .fm = 1,
523 .name = "PHILIPS_FQ1236_MK3" },
524 [ 0x22 ] = { .id = TUNER_ABSENT,
525 .name = "PHILIPS_FI1236_MK3" },
526 [ 0x23 ] = { .id = TUNER_ABSENT,
527 .name = "PHILIPS_FI1216_MK3" },
530 static void __devinit gdi_eeprom(struct cx8800_dev *dev, u8 *eeprom_data)
532 char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner))
533 ? gdi_tuner[eeprom_data[0x0d]].name : NULL;
535 printk(KERN_INFO "%s: GDI: tuner=%s\n", dev->name,
536 name ? name : "unknown");
537 if (NULL == name)
538 return;
539 dev->tuner_type = gdi_tuner[eeprom_data[0x0d]].id;
540 dev->has_radio = gdi_tuner[eeprom_data[0x0d]].fm;
543 /* ----------------------------------------------------------------------- */
545 static int
546 i2c_eeprom(struct i2c_client *c, unsigned char *eedata, int len)
548 unsigned char buf;
549 int err;
551 c->addr = 0xa0 >> 1;
552 buf = 0;
553 if (1 != (err = i2c_master_send(c,&buf,1))) {
554 printk(KERN_INFO "cx88: Huh, no eeprom present (err=%d)?\n",
555 err);
556 return -1;
558 if (len != (err = i2c_master_recv(c,eedata,len))) {
559 printk(KERN_WARNING "cx88: i2c eeprom read error (err=%d)\n",
560 err);
561 return -1;
563 #if 0
564 for (i = 0; i < len; i++) {
565 if (0 == (i % 16))
566 printk(KERN_INFO "cx88 ee: %02x:",i);
567 printk(" %02x",eedata[i]);
568 if (15 == (i % 16))
569 printk("\n");
571 #endif
572 return 0;
575 void cx88_card_list(struct cx8800_dev *dev)
577 int i;
579 if (0 == dev->pci->subsystem_vendor &&
580 0 == dev->pci->subsystem_device) {
581 printk("%s: Your board has no valid PCI Subsystem ID and thus can't\n"
582 "%s: be autodetected. Please pass card=<n> insmod option to\n"
583 "%s: workaround that. Redirect complaints to the vendor of\n"
584 "%s: the TV card. Best regards,\n"
585 "%s: -- tux\n",
586 dev->name,dev->name,dev->name,dev->name,dev->name);
587 } else {
588 printk("%s: Your board isn't known (yet) to the driver. You can\n"
589 "%s: try to pick one of the existing card configs via\n"
590 "%s: card=<n> insmod option. Updating to the latest\n"
591 "%s: version might help as well.\n",
592 dev->name,dev->name,dev->name,dev->name);
594 printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
595 dev->name);
596 for (i = 0; i < cx88_bcount; i++)
597 printk("%s: card=%d -> %s\n",
598 dev->name, i, cx88_boards[i].name);
601 void cx88_card_setup(struct cx8800_dev *dev)
603 static u8 eeprom[128];
605 switch (dev->board) {
606 case CX88_BOARD_HAUPPAUGE:
607 if (0 == dev->i2c_rc)
608 i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
609 hauppauge_eeprom(dev,eeprom+8);
610 break;
611 case CX88_BOARD_GDI:
612 if (0 == dev->i2c_rc)
613 i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
614 gdi_eeprom(dev,eeprom);
615 break;
616 case CX88_BOARD_WINFAST2000XP:
617 if (0 == dev->i2c_rc)
618 i2c_eeprom(&dev->i2c_client,eeprom,sizeof(eeprom));
619 leadtek_eeprom(dev,eeprom);
620 break;
621 case CX88_BOARD_ASUS_PVR_416:
622 dev->has_radio = 1;
623 break;
627 /* ------------------------------------------------------------------ */
629 EXPORT_SYMBOL(cx88_boards);
630 EXPORT_SYMBOL(cx88_bcount);
631 EXPORT_SYMBOL(cx88_subids);
632 EXPORT_SYMBOL(cx88_idcount);
633 EXPORT_SYMBOL(cx88_card_list);
634 EXPORT_SYMBOL(cx88_card_setup);
637 * Local variables:
638 * c-basic-offset: 8
639 * End: