V4L/DVB (7992): Add support for Pinnacle PCTV HD Pro stick (the older variant 2304...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / media / video / em28xx / em28xx-cards.c
blobc22c90301d85c27335dd96d3bc32fe78a14262e0
1 /*
2 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
3 video capture devices
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>
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.
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.
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.
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>
38 #include "em28xx.h"
40 static int tuner = -1;
41 module_param(tuner, int, 0444);
42 MODULE_PARM_DESC(tuner, "tuner type");
44 static unsigned int disable_ir;
45 module_param(disable_ir, int, 0444);
46 MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
48 struct em28xx_hash_table {
49 unsigned long hash;
50 unsigned int model;
51 unsigned int tuner;
54 struct em28xx_board em28xx_boards[] = {
55 [EM2800_BOARD_UNKNOWN] = {
56 .name = "Unknown EM2800 video grabber",
57 .is_em2800 = 1,
58 .vchannels = 2,
59 .tda9887_conf = TDA9887_PRESENT,
60 .decoder = EM28XX_SAA7113,
61 .input = { {
62 .type = EM28XX_VMUX_COMPOSITE1,
63 .vmux = SAA7115_COMPOSITE0,
64 .amux = 1,
65 }, {
66 .type = EM28XX_VMUX_SVIDEO,
67 .vmux = SAA7115_SVIDEO3,
68 .amux = 1,
69 } },
71 [EM2820_BOARD_UNKNOWN] = {
72 .name = "Unknown EM2750/28xx video grabber",
73 .is_em2800 = 0,
74 .tuner_type = TUNER_ABSENT,
76 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
77 .name = "Kworld PVR TV 2800 RF",
78 .is_em2800 = 0,
79 .vchannels = 2,
80 .tuner_type = TUNER_TEMIC_PAL,
81 .tda9887_conf = TDA9887_PRESENT,
82 .decoder = EM28XX_SAA7113,
83 .input = { {
84 .type = EM28XX_VMUX_COMPOSITE1,
85 .vmux = SAA7115_COMPOSITE0,
86 .amux = 1,
87 }, {
88 .type = EM28XX_VMUX_SVIDEO,
89 .vmux = SAA7115_SVIDEO3,
90 .amux = 1,
91 } },
93 [EM2820_BOARD_TERRATEC_CINERGY_250] = {
94 .name = "Terratec Cinergy 250 USB",
95 .vchannels = 3,
96 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
97 .tda9887_conf = TDA9887_PRESENT,
98 .decoder = EM28XX_SAA7113,
99 .input = { {
100 .type = EM28XX_VMUX_TELEVISION,
101 .vmux = SAA7115_COMPOSITE2,
102 .amux = 1,
103 }, {
104 .type = EM28XX_VMUX_COMPOSITE1,
105 .vmux = SAA7115_COMPOSITE0,
106 .amux = 1,
107 }, {
108 .type = EM28XX_VMUX_SVIDEO,
109 .vmux = SAA7115_SVIDEO3,
110 .amux = 1,
111 } },
113 [EM2820_BOARD_PINNACLE_USB_2] = {
114 .name = "Pinnacle PCTV USB 2",
115 .vchannels = 3,
116 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
117 .tda9887_conf = TDA9887_PRESENT,
118 .decoder = EM28XX_SAA7113,
119 .input = { {
120 .type = EM28XX_VMUX_TELEVISION,
121 .vmux = SAA7115_COMPOSITE2,
122 .amux = 0,
123 }, {
124 .type = EM28XX_VMUX_COMPOSITE1,
125 .vmux = SAA7115_COMPOSITE0,
126 .amux = 1,
127 }, {
128 .type = EM28XX_VMUX_SVIDEO,
129 .vmux = SAA7115_SVIDEO3,
130 .amux = 1,
131 } },
133 [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
134 .name = "Hauppauge WinTV USB 2",
135 .vchannels = 3,
136 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
137 .tda9887_conf = TDA9887_PRESENT |
138 TDA9887_PORT1_ACTIVE|
139 TDA9887_PORT2_ACTIVE,
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 } },
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 .mts_firmware = 1,
160 .has_dvb = 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 } },
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 .mts_firmware = 1,
182 .has_12mhz_i2s = 1,
183 .has_dvb = 1,
184 .decoder = EM28XX_TVP5150,
185 .input = { {
186 .type = EM28XX_VMUX_TELEVISION,
187 .vmux = TVP5150_COMPOSITE0,
188 .amux = 0,
189 }, {
190 .type = EM28XX_VMUX_COMPOSITE1,
191 .vmux = TVP5150_COMPOSITE1,
192 .amux = 1,
193 }, {
194 .type = EM28XX_VMUX_SVIDEO,
195 .vmux = TVP5150_SVIDEO,
196 .amux = 1,
197 } },
199 [EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
200 .name = "Pinnacle PCTV HD Pro Stick",
201 .vchannels = 3,
202 .tda9887_conf = TDA9887_PRESENT,
203 .tuner_type = TUNER_XC2028,
204 .mts_firmware = 1,
205 .has_12mhz_i2s = 1,
206 .has_dvb = 1,
207 .decoder = EM28XX_TVP5150,
208 .input = { {
209 .type = EM28XX_VMUX_TELEVISION,
210 .vmux = TVP5150_COMPOSITE0,
211 .amux = 0,
212 }, {
213 .type = EM28XX_VMUX_COMPOSITE1,
214 .vmux = TVP5150_COMPOSITE1,
215 .amux = 1,
216 }, {
217 .type = EM28XX_VMUX_SVIDEO,
218 .vmux = TVP5150_SVIDEO,
219 .amux = 1,
220 } },
222 [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
223 .name = "Terratec Hybrid XS",
224 .vchannels = 3,
225 .tda9887_conf = TDA9887_PRESENT,
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 } },
242 /* maybe there's a reason behind it why Terratec sells the Hybrid XS
243 as Prodigy XS with a different PID, let's keep it separated for now
244 maybe we'll need it lateron */
245 [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
246 .name = "Terratec Prodigy XS",
247 .vchannels = 3,
248 .tda9887_conf = TDA9887_PRESENT,
249 .tuner_type = TUNER_XC2028,
250 .decoder = EM28XX_TVP5150,
251 .input = { {
252 .type = EM28XX_VMUX_TELEVISION,
253 .vmux = TVP5150_COMPOSITE0,
254 .amux = 0,
255 }, {
256 .type = EM28XX_VMUX_COMPOSITE1,
257 .vmux = TVP5150_COMPOSITE1,
258 .amux = 1,
259 }, {
260 .type = EM28XX_VMUX_SVIDEO,
261 .vmux = TVP5150_SVIDEO,
262 .amux = 1,
263 } },
265 [EM2820_BOARD_MSI_VOX_USB_2] = {
266 .name = "MSI VOX USB 2.0",
267 .vchannels = 3,
268 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
269 .tda9887_conf = TDA9887_PRESENT |
270 TDA9887_PORT1_ACTIVE |
271 TDA9887_PORT2_ACTIVE,
272 .max_range_640_480 = 1,
274 .decoder = EM28XX_SAA7114,
275 .input = { {
276 .type = EM28XX_VMUX_TELEVISION,
277 .vmux = SAA7115_COMPOSITE4,
278 .amux = 0,
279 }, {
280 .type = EM28XX_VMUX_COMPOSITE1,
281 .vmux = SAA7115_COMPOSITE0,
282 .amux = 1,
283 }, {
284 .type = EM28XX_VMUX_SVIDEO,
285 .vmux = SAA7115_SVIDEO3,
286 .amux = 1,
287 } },
289 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
290 .name = "Terratec Cinergy 200 USB",
291 .is_em2800 = 1,
292 .vchannels = 3,
293 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
294 .tda9887_conf = TDA9887_PRESENT,
295 .decoder = EM28XX_SAA7113,
296 .input = { {
297 .type = EM28XX_VMUX_TELEVISION,
298 .vmux = SAA7115_COMPOSITE2,
299 .amux = 0,
300 }, {
301 .type = EM28XX_VMUX_COMPOSITE1,
302 .vmux = SAA7115_COMPOSITE0,
303 .amux = 1,
304 }, {
305 .type = EM28XX_VMUX_SVIDEO,
306 .vmux = SAA7115_SVIDEO3,
307 .amux = 1,
308 } },
310 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
311 .name = "Leadtek Winfast USB II",
312 .is_em2800 = 1,
313 .vchannels = 3,
314 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
315 .tda9887_conf = TDA9887_PRESENT,
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 } },
331 [EM2800_BOARD_KWORLD_USB2800] = {
332 .name = "Kworld USB2800",
333 .is_em2800 = 1,
334 .vchannels = 3,
335 .tuner_type = TUNER_PHILIPS_FCV1236D,
336 .tda9887_conf = TDA9887_PRESENT,
337 .decoder = EM28XX_SAA7113,
338 .input = { {
339 .type = EM28XX_VMUX_TELEVISION,
340 .vmux = SAA7115_COMPOSITE2,
341 .amux = 0,
342 }, {
343 .type = EM28XX_VMUX_COMPOSITE1,
344 .vmux = SAA7115_COMPOSITE0,
345 .amux = 1,
346 }, {
347 .type = EM28XX_VMUX_SVIDEO,
348 .vmux = SAA7115_SVIDEO3,
349 .amux = 1,
350 } },
352 [EM2820_BOARD_PINNACLE_DVC_90] = {
353 .name = "Pinnacle Dazzle DVC 90/DVC 100",
354 .vchannels = 3,
355 .tuner_type = TUNER_ABSENT,
356 .decoder = EM28XX_SAA7113,
357 .input = { {
358 .type = EM28XX_VMUX_COMPOSITE1,
359 .vmux = SAA7115_COMPOSITE0,
360 .amux = 1,
361 }, {
362 .type = EM28XX_VMUX_SVIDEO,
363 .vmux = SAA7115_SVIDEO3,
364 .amux = 1,
365 } },
367 [EM2800_BOARD_VGEAR_POCKETTV] = {
368 .name = "V-Gear PocketTV",
369 .is_em2800 = 1,
370 .vchannels = 3,
371 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
372 .tda9887_conf = TDA9887_PRESENT,
373 .decoder = EM28XX_SAA7113,
374 .input = { {
375 .type = EM28XX_VMUX_TELEVISION,
376 .vmux = SAA7115_COMPOSITE2,
377 .amux = 0,
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 } },
388 [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
389 .name = "Pixelview Prolink PlayTV USB 2.0",
390 .vchannels = 3,
391 .tda9887_conf = TDA9887_PRESENT,
392 .tuner_type = TUNER_YMEC_TVF_5533MF,
393 .decoder = EM28XX_SAA7113,
394 .input = { {
395 .type = EM28XX_VMUX_TELEVISION,
396 .vmux = SAA7115_COMPOSITE2,
397 .amux = EM28XX_AMUX_LINE_IN,
398 }, {
399 .type = EM28XX_VMUX_COMPOSITE1,
400 .vmux = SAA7115_COMPOSITE0,
401 .amux = EM28XX_AMUX_LINE_IN,
402 }, {
403 .type = EM28XX_VMUX_SVIDEO,
404 .vmux = SAA7115_SVIDEO3,
405 .amux = EM28XX_AMUX_LINE_IN,
406 } },
409 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
411 /* table of devices that work with this driver */
412 struct usb_device_id em28xx_id_table [] = {
413 { USB_DEVICE(0xeb1a, 0x2750),
414 .driver_info = EM2820_BOARD_UNKNOWN },
415 { USB_DEVICE(0xeb1a, 0x2800),
416 .driver_info = EM2800_BOARD_UNKNOWN },
417 { USB_DEVICE(0xeb1a, 0x2820),
418 .driver_info = EM2820_BOARD_UNKNOWN },
419 { USB_DEVICE(0xeb1a, 0x2821),
420 .driver_info = EM2820_BOARD_UNKNOWN },
421 { USB_DEVICE(0xeb1a, 0x2860),
422 .driver_info = EM2820_BOARD_UNKNOWN },
423 { USB_DEVICE(0xeb1a, 0x2861),
424 .driver_info = EM2820_BOARD_UNKNOWN },
425 { USB_DEVICE(0xeb1a, 0x2870),
426 .driver_info = EM2820_BOARD_UNKNOWN },
427 { USB_DEVICE(0xeb1a, 0x2881),
428 .driver_info = EM2820_BOARD_UNKNOWN },
429 { USB_DEVICE(0xeb1a, 0x2883),
430 .driver_info = EM2820_BOARD_UNKNOWN },
431 { USB_DEVICE(0x0ccd, 0x0036),
432 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
433 { USB_DEVICE(0x2304, 0x0208),
434 .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
435 { USB_DEVICE(0x2040, 0x4200),
436 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
437 { USB_DEVICE(0x2040, 0x4201),
438 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
439 { USB_DEVICE(0x2304, 0x0207),
440 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
441 { USB_DEVICE(0x2304, 0x021a),
442 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
443 { USB_DEVICE(0x2304, 0x0227),
444 .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
445 { USB_DEVICE(0x2040, 0x6500),
446 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
447 { USB_DEVICE(0x2040, 0x6502),
448 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
449 { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
450 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
451 { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */
452 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
453 { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */
454 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
455 { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
456 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
457 { USB_DEVICE(0x0ccd, 0x0042),
458 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
459 { USB_DEVICE(0x0ccd, 0x0047),
460 .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
461 { },
463 MODULE_DEVICE_TABLE(usb, em28xx_id_table);
466 * Reset sequences for analog/digital modes
469 /* Board Hauppauge WinTV HVR 900 analog */
470 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
471 {EM28XX_R08_GPIO, 0x2d, ~EM_GPIO_4, 10},
472 {0x05, 0xff, 0x10, 10},
473 { -1, -1, -1, -1},
476 /* Board Hauppauge WinTV HVR 900 digital */
477 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
478 {EM28XX_R08_GPIO, 0x2e, ~EM_GPIO_4, 10},
479 {EM2880_R04_GPO, 0x04, 0x0f, 10},
480 {EM2880_R04_GPO, 0x0c, 0x0f, 10},
481 { -1, -1, -1, -1},
484 /* Board Hauppauge WinTV HVR 900 tuner_callback */
485 static struct em28xx_reg_seq hauppauge_wintv_hvr_900_tuner_callback[] = {
486 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10},
487 {EM28XX_R08_GPIO, 0, EM_GPIO_4, 10},
488 {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10},
489 { -1, -1, -1, -1},
493 * EEPROM hash table for devices with generic USB IDs
495 static struct em28xx_hash_table em28xx_eeprom_hash [] = {
496 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
497 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
500 /* I2C devicelist hash table for devices with generic USB IDs */
501 static struct em28xx_hash_table em28xx_i2c_hash[] = {
502 {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
503 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
506 int em28xx_tuner_callback(void *ptr, int command, int arg)
508 int rc = 0;
509 struct em28xx *dev = ptr;
511 if (dev->tuner_type != TUNER_XC2028)
512 return 0;
514 if (command != XC2028_TUNER_RESET)
515 return 0;
517 if (dev->mode == EM28XX_ANALOG_MODE)
518 rc = em28xx_gpio_set(dev, dev->tun_analog_gpio);
519 else
520 rc = em28xx_gpio_set(dev, dev->tun_digital_gpio);
522 return rc;
524 EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
526 static void em28xx_set_model(struct em28xx *dev)
528 dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
529 dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
530 dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
531 dev->decoder = em28xx_boards[dev->model].decoder;
532 dev->video_inputs = em28xx_boards[dev->model].vchannels;
533 dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
534 dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
535 dev->has_dvb = em28xx_boards[dev->model].has_dvb;
538 /* Since em28xx_pre_card_setup() requires a proper dev->model,
539 * this won't work for boards with generic PCI IDs
541 void em28xx_pre_card_setup(struct em28xx *dev)
543 int rc;
545 rc = em28xx_read_reg(dev, EM2880_R04_GPO);
546 if (rc >= 0)
547 dev->reg_gpo = rc;
549 dev->wait_after_write = 5;
550 rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
551 if (rc > 0) {
552 switch (rc) {
553 case CHIP_ID_EM2860:
554 em28xx_info("chip ID is em2860\n");
555 break;
556 case CHIP_ID_EM2883:
557 em28xx_info("chip ID is em2882/em2883\n");
558 dev->wait_after_write = 0;
559 break;
560 default:
561 em28xx_info("em28xx chip ID = %d\n", rc);
564 em28xx_set_model(dev);
566 /* request some modules */
567 switch (dev->model) {
568 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
569 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
570 case EM2880_BOARD_TERRATEC_HYBRID_XS:
571 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
572 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
573 em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1);
574 em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
575 msleep(50);
577 /* Sets GPO/GPIO sequences for this device */
578 dev->analog_gpio = hauppauge_wintv_hvr_900_analog;
579 dev->digital_gpio = hauppauge_wintv_hvr_900_digital;
580 dev->tun_analog_gpio = hauppauge_wintv_hvr_900_tuner_callback;
581 dev->tun_digital_gpio = hauppauge_wintv_hvr_900_tuner_callback;
583 break;
586 em28xx_gpio_set(dev, dev->tun_analog_gpio);
587 em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
589 /* Unlock device */
590 em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED);
593 static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
595 memset(ctl, 0, sizeof(*ctl));
597 ctl->fname = XC2028_DEFAULT_FIRMWARE;
598 ctl->max_len = 64;
599 ctl->mts = em28xx_boards[dev->model].mts_firmware;
601 switch (dev->model) {
602 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
603 ctl->demod = XC3028_FE_ZARLINK456;
604 break;
605 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
606 case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
607 /* FIXME: Better to specify the needed IF */
608 ctl->demod = XC3028_FE_DEFAULT;
609 break;
610 default:
611 ctl->demod = XC3028_FE_OREN538;
615 static void em28xx_config_tuner(struct em28xx *dev)
617 struct v4l2_priv_tun_config xc2028_cfg;
618 struct tuner_setup tun_setup;
619 struct v4l2_frequency f;
621 if (dev->tuner_type == TUNER_ABSENT)
622 return;
624 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
625 tun_setup.type = dev->tuner_type;
626 tun_setup.addr = dev->tuner_addr;
627 tun_setup.tuner_callback = em28xx_tuner_callback;
629 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
631 if (dev->tuner_type == TUNER_XC2028) {
632 struct xc2028_ctrl ctl;
634 em28xx_setup_xc3028(dev, &ctl);
636 xc2028_cfg.tuner = TUNER_XC2028;
637 xc2028_cfg.priv = &ctl;
639 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
642 /* configure tuner */
643 f.tuner = 0;
644 f.type = V4L2_TUNER_ANALOG_TV;
645 f.frequency = 9076; /* just a magic number */
646 dev->ctl_freq = f.frequency;
647 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
650 static int em28xx_hint_board(struct em28xx *dev)
652 int i;
654 /* HINT method: EEPROM
656 * This method works only for boards with eeprom.
657 * Uses a hash of all eeprom bytes. The hash should be
658 * unique for a vendor/tuner pair.
659 * There are a high chance that tuners for different
660 * video standards produce different hashes.
662 for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
663 if (dev->hash == em28xx_eeprom_hash[i].hash) {
664 dev->model = em28xx_eeprom_hash[i].model;
665 dev->tuner_type = em28xx_eeprom_hash[i].tuner;
667 em28xx_errdev("Your board has no unique USB ID.\n");
668 em28xx_errdev("A hint were successfully done, "
669 "based on eeprom hash.\n");
670 em28xx_errdev("This method is not 100%% failproof.\n");
671 em28xx_errdev("If the board were missdetected, "
672 "please email this log to:\n");
673 em28xx_errdev("\tV4L Mailing List "
674 " <video4linux-list@redhat.com>\n");
675 em28xx_errdev("Board detected as %s\n",
676 em28xx_boards[dev->model].name);
678 return 0;
682 /* HINT method: I2C attached devices
684 * This method works for all boards.
685 * Uses a hash of i2c scanned devices.
686 * Devices with the same i2c attached chips will
687 * be considered equal.
688 * This method is less precise than the eeprom one.
691 /* user did not request i2c scanning => do it now */
692 if (!dev->i2c_hash)
693 em28xx_do_i2c_scan(dev);
695 for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
696 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
697 dev->model = em28xx_i2c_hash[i].model;
698 dev->tuner_type = em28xx_i2c_hash[i].tuner;
699 em28xx_errdev("Your board has no unique USB ID.\n");
700 em28xx_errdev("A hint were successfully done, "
701 "based on i2c devicelist hash.\n");
702 em28xx_errdev("This method is not 100%% failproof.\n");
703 em28xx_errdev("If the board were missdetected, "
704 "please email this log to:\n");
705 em28xx_errdev("\tV4L Mailing List "
706 " <video4linux-list@redhat.com>\n");
707 em28xx_errdev("Board detected as %s\n",
708 em28xx_boards[dev->model].name);
710 return 0;
714 em28xx_errdev("Your board has no unique USB ID and thus need a "
715 "hint to be detected.\n");
716 em28xx_errdev("You may try to use card=<n> insmod option to "
717 "workaround that.\n");
718 em28xx_errdev("Please send an email with this log to:\n");
719 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
720 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
721 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
723 em28xx_errdev("Here is a list of valid choices for the card=<n>"
724 " insmod option:\n");
725 for (i = 0; i < em28xx_bcount; i++) {
726 em28xx_errdev(" card=%d -> %s\n",
727 i, em28xx_boards[i].name);
729 return -1;
732 /* ----------------------------------------------------------------------- */
733 void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
735 if (disable_ir) {
736 ir->get_key = NULL;
737 return ;
740 /* detect & configure */
741 switch (dev->model) {
742 case (EM2800_BOARD_UNKNOWN):
743 break;
744 case (EM2820_BOARD_UNKNOWN):
745 break;
746 case (EM2800_BOARD_TERRATEC_CINERGY_200):
747 case (EM2820_BOARD_TERRATEC_CINERGY_250):
748 ir->ir_codes = ir_codes_em_terratec;
749 ir->get_key = em28xx_get_key_terratec;
750 snprintf(ir->c.name, sizeof(ir->c.name),
751 "i2c IR (EM28XX Terratec)");
752 break;
753 case (EM2820_BOARD_PINNACLE_USB_2):
754 ir->ir_codes = ir_codes_pinnacle_grey;
755 ir->get_key = em28xx_get_key_pinnacle_usb_grey;
756 snprintf(ir->c.name, sizeof(ir->c.name),
757 "i2c IR (EM28XX Pinnacle PCTV)");
758 break;
759 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
760 ir->ir_codes = ir_codes_hauppauge_new;
761 ir->get_key = em28xx_get_key_em_haup;
762 snprintf(ir->c.name, sizeof(ir->c.name),
763 "i2c IR (EM2840 Hauppauge)");
764 break;
765 case (EM2820_BOARD_MSI_VOX_USB_2):
766 break;
767 case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
768 break;
769 case (EM2800_BOARD_KWORLD_USB2800):
770 break;
774 void em28xx_card_setup(struct em28xx *dev)
776 em28xx_set_model(dev);
778 dev->tuner_type = em28xx_boards[dev->model].tuner_type;
780 /* request some modules */
781 switch (dev->model) {
782 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
783 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
784 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
786 struct tveeprom tv;
787 #ifdef CONFIG_MODULES
788 request_module("tveeprom");
789 #endif
790 /* Call first TVeeprom */
792 dev->i2c_client.addr = 0xa0 >> 1;
793 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
795 dev->tuner_type = tv.tuner_type;
797 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
798 dev->i2s_speed = 2048000;
799 dev->has_msp34xx = 1;
801 #ifdef CONFIG_MODULES
802 if (tv.has_ir)
803 request_module("ir-kbd-i2c");
804 #endif
805 break;
807 case EM2820_BOARD_KWORLD_PVRTV2800RF:
808 /* GPIO enables sound on KWORLD PVR TV 2800RF */
809 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
810 break;
811 case EM2820_BOARD_UNKNOWN:
812 case EM2800_BOARD_UNKNOWN:
813 if (!em28xx_hint_board(dev))
814 em28xx_set_model(dev);
817 /* Allow override tuner type by a module parameter */
818 if (tuner >= 0)
819 dev->tuner_type = tuner;
821 #ifdef CONFIG_MODULES
822 /* request some modules */
823 if (dev->has_msp34xx)
824 request_module("msp3400");
825 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
826 request_module("saa7115");
827 if (dev->decoder == EM28XX_TVP5150)
828 request_module("tvp5150");
829 if (dev->tuner_type != TUNER_ABSENT)
830 request_module("tuner");
831 #endif
833 em28xx_config_tuner(dev);