V4L/DVB (em28xx): Add support for Pinnacle Dazzle DVC 100
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / media / video / em28xx / em28xx-cards.c
1 /*
2 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
3 video capture devices
4
5 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
6 Markus Rechberger <mrechberger@gmail.com>
7 Mauro Carvalho Chehab <mchehab@infradead.org>
8 Sascha Sommer <saschasommer@freenet.de>
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 #include <linux/init.h>
26 #include <linux/module.h>
27 #include <linux/delay.h>
28 #include <linux/i2c.h>
29 #include <linux/usb.h>
30 #include <media/tuner.h>
31 #include <media/msp3400.h>
32 #include <media/saa7115.h>
33 #include <media/tvp5150.h>
34 #include <media/tveeprom.h>
35 #include <media/audiochip.h>
36 #include <media/v4l2-common.h>
37
38 #include "em28xx.h"
39 #include "tuner-xc2028.h"
40
41 static int tuner = -1;
42 module_param(tuner, int, 0444);
43 MODULE_PARM_DESC(tuner, "tuner type");
44
45 struct em28xx_hash_table {
46 unsigned long hash;
47 unsigned int model;
48 unsigned int tuner;
49 };
50
51 struct em28xx_board em28xx_boards[] = {
52 [EM2800_BOARD_UNKNOWN] = {
53 .name = "Unknown EM2800 video grabber",
54 .is_em2800 = 1,
55 .vchannels = 2,
56 .tda9887_conf = TDA9887_PRESENT,
57 .has_tuner = 1,
58 .decoder = EM28XX_SAA7113,
59 .input = { {
60 .type = EM28XX_VMUX_COMPOSITE1,
61 .vmux = SAA7115_COMPOSITE0,
62 .amux = 1,
63 }, {
64 .type = EM28XX_VMUX_SVIDEO,
65 .vmux = SAA7115_SVIDEO3,
66 .amux = 1,
67 } },
68 },
69 [EM2820_BOARD_UNKNOWN] = {
70 .name = "Unknown EM2750/28xx video grabber",
71 .is_em2800 = 0,
72 },
73 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
74 .name = "Kworld PVR TV 2800 RF",
75 .is_em2800 = 0,
76 .vchannels = 2,
77 .tda9887_conf = TDA9887_PRESENT,
78 .has_tuner = 1,
79 .decoder = EM28XX_SAA7113,
80 .input = { {
81 .type = EM28XX_VMUX_COMPOSITE1,
82 .vmux = SAA7115_COMPOSITE0,
83 .amux = 1,
84 }, {
85 .type = EM28XX_VMUX_SVIDEO,
86 .vmux = SAA7115_SVIDEO3,
87 .amux = 1,
88 } },
89 },
90 [EM2820_BOARD_TERRATEC_CINERGY_250] = {
91 .name = "Terratec Cinergy 250 USB",
92 .vchannels = 3,
93 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
94 .tda9887_conf = TDA9887_PRESENT,
95 .has_tuner = 1,
96 .decoder = EM28XX_SAA7113,
97 .input = { {
98 .type = EM28XX_VMUX_TELEVISION,
99 .vmux = SAA7115_COMPOSITE2,
100 .amux = 1,
101 }, {
102 .type = EM28XX_VMUX_COMPOSITE1,
103 .vmux = SAA7115_COMPOSITE0,
104 .amux = 1,
105 }, {
106 .type = EM28XX_VMUX_SVIDEO,
107 .vmux = SAA7115_SVIDEO3,
108 .amux = 1,
109 } },
110 },
111 [EM2820_BOARD_PINNACLE_USB_2] = {
112 .name = "Pinnacle PCTV USB 2",
113 .vchannels = 3,
114 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
115 .tda9887_conf = TDA9887_PRESENT,
116 .has_tuner = 1,
117 .decoder = EM28XX_SAA7113,
118 .input = { {
119 .type = EM28XX_VMUX_TELEVISION,
120 .vmux = SAA7115_COMPOSITE2,
121 .amux = 0,
122 }, {
123 .type = EM28XX_VMUX_COMPOSITE1,
124 .vmux = SAA7115_COMPOSITE0,
125 .amux = 1,
126 }, {
127 .type = EM28XX_VMUX_SVIDEO,
128 .vmux = SAA7115_SVIDEO3,
129 .amux = 1,
130 } },
131 },
132 [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
133 .name = "Hauppauge WinTV USB 2",
134 .vchannels = 3,
135 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
136 .tda9887_conf = TDA9887_PRESENT |
137 TDA9887_PORT1_ACTIVE|
138 TDA9887_PORT2_ACTIVE,
139 .has_tuner = 1,
140 .decoder = EM28XX_TVP5150,
141 .has_msp34xx = 1,
142 /*FIXME: S-Video not tested */
143 .input = { {
144 .type = EM28XX_VMUX_TELEVISION,
145 .vmux = TVP5150_COMPOSITE0,
146 .amux = MSP_INPUT_DEFAULT,
147 }, {
148 .type = EM28XX_VMUX_SVIDEO,
149 .vmux = TVP5150_SVIDEO,
150 .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
151 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
152 } },
153 },
154 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
155 .name = "Hauppauge WinTV HVR 900",
156 .vchannels = 3,
157 .tda9887_conf = TDA9887_PRESENT,
158 .tuner_type = TUNER_XC2028,
159 .has_tuner = 1,
160 .mts_firmware = 1,
161 .decoder = EM28XX_TVP5150,
162 .input = { {
163 .type = EM28XX_VMUX_TELEVISION,
164 .vmux = TVP5150_COMPOSITE0,
165 .amux = 0,
166 }, {
167 .type = EM28XX_VMUX_COMPOSITE1,
168 .vmux = TVP5150_COMPOSITE1,
169 .amux = 1,
170 }, {
171 .type = EM28XX_VMUX_SVIDEO,
172 .vmux = TVP5150_SVIDEO,
173 .amux = 1,
174 } },
175 },
176 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
177 .name = "Hauppauge WinTV HVR 950",
178 .vchannels = 3,
179 .tda9887_conf = TDA9887_PRESENT,
180 .tuner_type = TUNER_XC2028,
181 .has_tuner = 1,
182 .decoder = EM28XX_TVP5150,
183 .input = { {
184 .type = EM28XX_VMUX_TELEVISION,
185 .vmux = TVP5150_COMPOSITE0,
186 .amux = 0,
187 }, {
188 .type = EM28XX_VMUX_COMPOSITE1,
189 .vmux = TVP5150_COMPOSITE1,
190 .amux = 1,
191 }, {
192 .type = EM28XX_VMUX_SVIDEO,
193 .vmux = TVP5150_SVIDEO,
194 .amux = 1,
195 } },
196 },
197 [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
198 .name = "Terratec Hybrid XS",
199 .vchannels = 3,
200 .tda9887_conf = TDA9887_PRESENT,
201 .has_tuner = 1,
202 .tuner_type = TUNER_XC2028,
203 .decoder = EM28XX_TVP5150,
204 .input = { {
205 .type = EM28XX_VMUX_TELEVISION,
206 .vmux = TVP5150_COMPOSITE0,
207 .amux = 0,
208 }, {
209 .type = EM28XX_VMUX_COMPOSITE1,
210 .vmux = TVP5150_COMPOSITE1,
211 .amux = 1,
212 }, {
213 .type = EM28XX_VMUX_SVIDEO,
214 .vmux = TVP5150_SVIDEO,
215 .amux = 1,
216 } },
217 },
218 /* maybe there's a reason behind it why Terratec sells the Hybrid XS
219 as Prodigy XS with a different PID, let's keep it separated for now
220 maybe we'll need it lateron */
221 [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
222 .name = "Terratec Prodigy XS",
223 .vchannels = 3,
224 .tda9887_conf = TDA9887_PRESENT,
225 .has_tuner = 1,
226 .tuner_type = TUNER_XC2028,
227 .decoder = EM28XX_TVP5150,
228 .input = { {
229 .type = EM28XX_VMUX_TELEVISION,
230 .vmux = TVP5150_COMPOSITE0,
231 .amux = 0,
232 }, {
233 .type = EM28XX_VMUX_COMPOSITE1,
234 .vmux = TVP5150_COMPOSITE1,
235 .amux = 1,
236 }, {
237 .type = EM28XX_VMUX_SVIDEO,
238 .vmux = TVP5150_SVIDEO,
239 .amux = 1,
240 } },
241 },
242 [EM2820_BOARD_MSI_VOX_USB_2] = {
243 .name = "MSI VOX USB 2.0",
244 .vchannels = 3,
245 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
246 .tda9887_conf = TDA9887_PRESENT |
247 TDA9887_PORT1_ACTIVE |
248 TDA9887_PORT2_ACTIVE,
249 .has_tuner = 1,
250 .decoder = EM28XX_SAA7114,
251 .input = { {
252 .type = EM28XX_VMUX_TELEVISION,
253 .vmux = SAA7115_COMPOSITE4,
254 .amux = 0,
255 }, {
256 .type = EM28XX_VMUX_COMPOSITE1,
257 .vmux = SAA7115_COMPOSITE0,
258 .amux = 1,
259 }, {
260 .type = EM28XX_VMUX_SVIDEO,
261 .vmux = SAA7115_SVIDEO3,
262 .amux = 1,
263 } },
264 },
265 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
266 .name = "Terratec Cinergy 200 USB",
267 .is_em2800 = 1,
268 .vchannels = 3,
269 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
270 .tda9887_conf = TDA9887_PRESENT,
271 .has_tuner = 1,
272 .decoder = EM28XX_SAA7113,
273 .input = { {
274 .type = EM28XX_VMUX_TELEVISION,
275 .vmux = SAA7115_COMPOSITE2,
276 .amux = 0,
277 }, {
278 .type = EM28XX_VMUX_COMPOSITE1,
279 .vmux = SAA7115_COMPOSITE0,
280 .amux = 1,
281 }, {
282 .type = EM28XX_VMUX_SVIDEO,
283 .vmux = SAA7115_SVIDEO3,
284 .amux = 1,
285 } },
286 },
287 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
288 .name = "Leadtek Winfast USB II",
289 .is_em2800 = 1,
290 .vchannels = 3,
291 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
292 .tda9887_conf = TDA9887_PRESENT,
293 .has_tuner = 1,
294 .decoder = EM28XX_SAA7113,
295 .input = { {
296 .type = EM28XX_VMUX_TELEVISION,
297 .vmux = SAA7115_COMPOSITE2,
298 .amux = 0,
299 }, {
300 .type = EM28XX_VMUX_COMPOSITE1,
301 .vmux = SAA7115_COMPOSITE0,
302 .amux = 1,
303 }, {
304 .type = EM28XX_VMUX_SVIDEO,
305 .vmux = SAA7115_SVIDEO3,
306 .amux = 1,
307 } },
308 },
309 [EM2800_BOARD_KWORLD_USB2800] = {
310 .name = "Kworld USB2800",
311 .is_em2800 = 1,
312 .vchannels = 3,
313 .tuner_type = TUNER_PHILIPS_ATSC,
314 .tda9887_conf = TDA9887_PRESENT,
315 .has_tuner = 1,
316 .decoder = EM28XX_SAA7113,
317 .input = { {
318 .type = EM28XX_VMUX_TELEVISION,
319 .vmux = SAA7115_COMPOSITE2,
320 .amux = 0,
321 }, {
322 .type = EM28XX_VMUX_COMPOSITE1,
323 .vmux = SAA7115_COMPOSITE0,
324 .amux = 1,
325 }, {
326 .type = EM28XX_VMUX_SVIDEO,
327 .vmux = SAA7115_SVIDEO3,
328 .amux = 1,
329 } },
330 },
331 [EM2820_BOARD_PINNACLE_DVC_90] = {
332 .name = "Pinnacle Dazzle DVC 90/DVC 100",
333 .vchannels = 3,
334 .has_tuner = 0,
335 .decoder = EM28XX_SAA7113,
336 .input = { {
337 .type = EM28XX_VMUX_COMPOSITE1,
338 .vmux = SAA7115_COMPOSITE0,
339 .amux = 1,
340 }, {
341 .type = EM28XX_VMUX_SVIDEO,
342 .vmux = SAA7115_SVIDEO3,
343 .amux = 1,
344 } },
345 },
346 [EM2800_BOARD_VGEAR_POCKETTV] = {
347 .name = "V-Gear PocketTV",
348 .is_em2800 = 1,
349 .vchannels = 3,
350 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
351 .tda9887_conf = TDA9887_PRESENT,
352 .has_tuner = 1,
353 .decoder = EM28XX_SAA7113,
354 .input = { {
355 .type = EM28XX_VMUX_TELEVISION,
356 .vmux = SAA7115_COMPOSITE2,
357 .amux = 0,
358 }, {
359 .type = EM28XX_VMUX_COMPOSITE1,
360 .vmux = SAA7115_COMPOSITE0,
361 .amux = 1,
362 }, {
363 .type = EM28XX_VMUX_SVIDEO,
364 .vmux = SAA7115_SVIDEO3,
365 .amux = 1,
366 } },
367 },
368 [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
369 .name = "Pixelview Prolink PlayTV USB 2.0",
370 .vchannels = 3,
371 .tda9887_conf = TDA9887_PRESENT,
372 .has_tuner = 1,
373 .decoder = EM28XX_SAA7113,
374 .input = { {
375 .type = EM28XX_VMUX_TELEVISION,
376 .vmux = SAA7115_COMPOSITE2,
377 .amux = 1,
378 }, {
379 .type = EM28XX_VMUX_COMPOSITE1,
380 .vmux = SAA7115_COMPOSITE0,
381 .amux = 1,
382 }, {
383 .type = EM28XX_VMUX_SVIDEO,
384 .vmux = SAA7115_SVIDEO3,
385 .amux = 1,
386 } },
387 },
388 };
389 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
390
391 /* table of devices that work with this driver */
392 struct usb_device_id em28xx_id_table [] = {
393 { USB_DEVICE(0xeb1a, 0x2750),
394 .driver_info = EM2820_BOARD_UNKNOWN },
395 { USB_DEVICE(0xeb1a, 0x2800),
396 .driver_info = EM2800_BOARD_UNKNOWN },
397 { USB_DEVICE(0xeb1a, 0x2820),
398 .driver_info = EM2820_BOARD_UNKNOWN },
399 { USB_DEVICE(0xeb1a, 0x2821),
400 .driver_info = EM2820_BOARD_UNKNOWN },
401 { USB_DEVICE(0xeb1a, 0x2860),
402 .driver_info = EM2820_BOARD_UNKNOWN },
403 { USB_DEVICE(0xeb1a, 0x2861),
404 .driver_info = EM2820_BOARD_UNKNOWN },
405 { USB_DEVICE(0xeb1a, 0x2870),
406 .driver_info = EM2820_BOARD_UNKNOWN },
407 { USB_DEVICE(0xeb1a, 0x2881),
408 .driver_info = EM2820_BOARD_UNKNOWN },
409 { USB_DEVICE(0xeb1a, 0x2883),
410 .driver_info = EM2820_BOARD_UNKNOWN },
411 { USB_DEVICE(0x0ccd, 0x0036),
412 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
413 { USB_DEVICE(0x2304, 0x0208),
414 .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
415 { USB_DEVICE(0x2040, 0x4200),
416 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
417 { USB_DEVICE(0x2304, 0x0207),
418 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
419 { USB_DEVICE(0x2304, 0x021a),
420 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
421 { USB_DEVICE(0x2040, 0x6500),
422 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
423 { USB_DEVICE(0x2040, 0x6513),
424 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
425 { USB_DEVICE(0x0ccd, 0x0042),
426 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
427 { USB_DEVICE(0x0ccd, 0x0047),
428 .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
429 { },
430 };
431 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
432
433 /* EEPROM hash table for devices with generic USB IDs */
434 static struct em28xx_hash_table em28xx_eeprom_hash [] = {
435 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
436 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
437 };
438
439 /* I2C devicelist hash table for devices with generic USB IDs */
440 static struct em28xx_hash_table em28xx_i2c_hash[] = {
441 {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
442 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
443 };
444
445 /* Since em28xx_pre_card_setup() requires a proper dev->model,
446 * this won't work for boards with generic PCI IDs
447 */
448 void em28xx_pre_card_setup(struct em28xx *dev)
449 {
450 /* request some modules */
451 switch (dev->model) {
452 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
453 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
454 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
455 case EM2880_BOARD_TERRATEC_HYBRID_XS:
456 /* reset through GPIO? */
457 em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1);
458 break;
459 }
460 }
461
462 static int em28xx_tuner_callback(void *ptr, int command, int arg)
463 {
464 int rc = 0;
465 struct em28xx *dev = ptr;
466
467 if (dev->tuner_type != TUNER_XC2028)
468 return 0;
469
470 switch (command) {
471 case XC2028_TUNER_RESET:
472 /* FIXME: This is device-dependent */
473 dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
474 dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
475
476 msleep(140);
477 break;
478 }
479 return rc;
480 }
481
482 static void em28xx_config_tuner(struct em28xx *dev)
483 {
484 struct v4l2_priv_tun_config xc2028_cfg;
485 struct xc2028_ctrl ctl;
486 struct tuner_setup tun_setup;
487 struct v4l2_frequency f;
488
489 if (!dev->has_tuner)
490 return;
491
492 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
493 tun_setup.type = dev->tuner_type;
494 tun_setup.addr = dev->tuner_addr;
495 tun_setup.tuner_callback = em28xx_tuner_callback;
496
497 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
498
499 if (dev->tuner_type == TUNER_XC2028) {
500 memset(&ctl, 0, sizeof(ctl));
501
502 ctl.fname = XC2028_DEFAULT_FIRMWARE;
503 ctl.max_len = 64;
504 ctl.mts = em28xx_boards[dev->model].mts_firmware;
505
506 xc2028_cfg.tuner = TUNER_XC2028;
507 xc2028_cfg.priv = &ctl;
508
509 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
510 }
511
512 /* configure tuner */
513 f.tuner = 0;
514 f.type = V4L2_TUNER_ANALOG_TV;
515 f.frequency = 9076; /* just a magic number */
516 dev->ctl_freq = f.frequency;
517 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
518 }
519
520 static int em28xx_hint_board(struct em28xx *dev)
521 {
522 int i;
523
524 /* HINT method: EEPROM
525 *
526 * This method works only for boards with eeprom.
527 * Uses a hash of all eeprom bytes. The hash should be
528 * unique for a vendor/tuner pair.
529 * There are a high chance that tuners for different
530 * video standards produce different hashes.
531 */
532 for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
533 if (dev->hash == em28xx_eeprom_hash[i].hash) {
534 dev->model = em28xx_eeprom_hash[i].model;
535 dev->tuner_type = em28xx_eeprom_hash[i].tuner;
536
537 em28xx_errdev("Your board has no unique USB ID.\n");
538 em28xx_errdev("A hint were successfully done, "
539 "based on eeprom hash.\n");
540 em28xx_errdev("This method is not 100%% failproof.\n");
541 em28xx_errdev("If the board were missdetected, "
542 "please email this log to:\n");
543 em28xx_errdev("\tV4L Mailing List "
544 " <video4linux-list@redhat.com>\n");
545 em28xx_errdev("Board detected as %s\n",
546 em28xx_boards[dev->model].name);
547
548 return 0;
549 }
550 }
551
552 /* HINT method: I2C attached devices
553 *
554 * This method works for all boards.
555 * Uses a hash of i2c scanned devices.
556 * Devices with the same i2c attached chips will
557 * be considered equal.
558 * This method is less precise than the eeprom one.
559 */
560
561 /* user did not request i2c scanning => do it now */
562 if (!dev->i2c_hash)
563 em28xx_do_i2c_scan(dev);
564
565 for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
566 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
567 dev->model = em28xx_i2c_hash[i].model;
568 dev->tuner_type = em28xx_i2c_hash[i].tuner;
569 em28xx_errdev("Your board has no unique USB ID.\n");
570 em28xx_errdev("A hint were successfully done, "
571 "based on i2c devicelist hash.\n");
572 em28xx_errdev("This method is not 100%% failproof.\n");
573 em28xx_errdev("If the board were missdetected, "
574 "please email this log to:\n");
575 em28xx_errdev("\tV4L Mailing List "
576 " <video4linux-list@redhat.com>\n");
577 em28xx_errdev("Board detected as %s\n",
578 em28xx_boards[dev->model].name);
579
580 return 0;
581 }
582 }
583
584 em28xx_errdev("Your board has no unique USB ID and thus need a "
585 "hint to be detected.\n");
586 em28xx_errdev("You may try to use card=<n> insmod option to "
587 "workaround that.\n");
588 em28xx_errdev("Please send an email with this log to:\n");
589 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
590 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
591 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
592
593 em28xx_errdev("Here is a list of valid choices for the card=<n>"
594 " insmod option:\n");
595 for (i = 0; i < em28xx_bcount; i++) {
596 em28xx_errdev(" card=%d -> %s\n",
597 i, em28xx_boards[i].name);
598 }
599 return -1;
600 }
601
602
603 static void em28xx_set_model(struct em28xx *dev)
604 {
605 dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
606 dev->has_tuner = em28xx_boards[dev->model].has_tuner;
607 dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
608 dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
609 dev->decoder = em28xx_boards[dev->model].decoder;
610 dev->video_inputs = em28xx_boards[dev->model].vchannels;
611
612 if (!em28xx_boards[dev->model].has_tuner)
613 dev->tuner_type = UNSET;
614 }
615
616 void em28xx_card_setup(struct em28xx *dev)
617 {
618 em28xx_set_model(dev);
619
620 dev->tuner_type = em28xx_boards[dev->model].tuner_type;
621
622 /* request some modules */
623 switch (dev->model) {
624 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
625 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
626 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
627 {
628 struct tveeprom tv;
629 #ifdef CONFIG_MODULES
630 request_module("tveeprom");
631 #endif
632 /* Call first TVeeprom */
633
634 dev->i2c_client.addr = 0xa0 >> 1;
635 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
636
637 dev->tuner_type = tv.tuner_type;
638 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
639 dev->i2s_speed = 2048000;
640 dev->has_msp34xx = 1;
641 }
642 #ifdef CONFIG_MODULES
643 if (tv.has_ir)
644 request_module("ir-kbd-i2c");
645 #endif
646 /* FIXME: Should also retrieve decoder processor type */
647
648 break;
649 }
650 case EM2820_BOARD_KWORLD_PVRTV2800RF:
651 /* GPIO enables sound on KWORLD PVR TV 2800RF */
652 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
653 break;
654 case EM2820_BOARD_UNKNOWN:
655 case EM2800_BOARD_UNKNOWN:
656 if (!em28xx_hint_board(dev))
657 em28xx_set_model(dev);
658 }
659
660 /* Allow override tuner type by a module parameter */
661 if (tuner >= 0)
662 dev->tuner_type = tuner;
663
664 #ifdef CONFIG_MODULES
665 /* request some modules */
666 if (dev->has_msp34xx)
667 request_module("msp3400");
668 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
669 request_module("saa7115");
670 if (dev->decoder == EM28XX_TVP5150)
671 request_module("tvp5150");
672 if (dev->has_tuner)
673 request_module("tuner");
674 #endif
675
676 em28xx_config_tuner(dev);
677 }