Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[pandora-kernel.git] / drivers / media / video / pvrusb2 / pvrusb2-devattr.c
1 /*
2  *
3  *
4  *  Copyright (C) 2007 Mike Isely <isely@pobox.com>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 /*
22
23 This source file should encompass ALL per-device type information for the
24 driver.  To define a new device, add elements to the pvr2_device_table and
25 pvr2_device_desc structures.
26
27 */
28
29 #include "pvrusb2-devattr.h"
30 #include <linux/usb.h>
31 /* This is needed in order to pull in tuner type ids... */
32 #include <linux/i2c.h>
33 #include <media/tuner.h>
34 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
35 #include "pvrusb2-hdw-internal.h"
36 #include "lgdt330x.h"
37 #include "s5h1409.h"
38 #include "s5h1411.h"
39 #include "tda10048.h"
40 #include "tda18271.h"
41 #include "tda8290.h"
42 #include "tuner-simple.h"
43 #endif
44
45
46 /*------------------------------------------------------------------------*/
47 /* Hauppauge PVR-USB2 Model 29xxx */
48
49 static const struct pvr2_device_client_desc pvr2_cli_29xxx[] = {
50         { .module_id = PVR2_CLIENT_ID_SAA7115 },
51         { .module_id = PVR2_CLIENT_ID_MSP3400 },
52         { .module_id = PVR2_CLIENT_ID_TUNER },
53         { .module_id = PVR2_CLIENT_ID_DEMOD },
54 };
55
56 static const char *pvr2_fw1_names_29xxx[] = {
57                 "v4l-pvrusb2-29xxx-01.fw",
58 };
59
60 static const struct pvr2_device_desc pvr2_device_29xxx = {
61                 .description = "WinTV PVR USB2 Model Category 29xxx",
62                 .shortname = "29xxx",
63                 .client_table.lst = pvr2_cli_29xxx,
64                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_29xxx),
65                 .fx2_firmware.lst = pvr2_fw1_names_29xxx,
66                 .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_29xxx),
67                 .flag_has_hauppauge_rom = !0,
68                 .flag_has_analogtuner = !0,
69                 .flag_has_fmradio = !0,
70                 .flag_has_composite = !0,
71                 .flag_has_svideo = !0,
72                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
73                 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
74 };
75
76
77
78 /*------------------------------------------------------------------------*/
79 /* Hauppauge PVR-USB2 Model 24xxx */
80
81 static const struct pvr2_device_client_desc pvr2_cli_24xxx[] = {
82         { .module_id = PVR2_CLIENT_ID_CX25840 },
83         { .module_id = PVR2_CLIENT_ID_TUNER },
84         { .module_id = PVR2_CLIENT_ID_WM8775 },
85         { .module_id = PVR2_CLIENT_ID_DEMOD },
86 };
87
88 static const char *pvr2_fw1_names_24xxx[] = {
89                 "v4l-pvrusb2-24xxx-01.fw",
90 };
91
92 static const struct pvr2_device_desc pvr2_device_24xxx = {
93                 .description = "WinTV PVR USB2 Model Category 24xxx",
94                 .shortname = "24xxx",
95                 .client_table.lst = pvr2_cli_24xxx,
96                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_24xxx),
97                 .fx2_firmware.lst = pvr2_fw1_names_24xxx,
98                 .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_24xxx),
99                 .flag_has_cx25840 = !0,
100                 .flag_has_wm8775 = !0,
101                 .flag_has_hauppauge_rom = !0,
102                 .flag_has_analogtuner = !0,
103                 .flag_has_fmradio = !0,
104                 .flag_has_composite = !0,
105                 .flag_has_svideo = !0,
106                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
107                 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
108                 .ir_scheme = PVR2_IR_SCHEME_24XXX,
109 };
110
111
112
113 /*------------------------------------------------------------------------*/
114 /* GOTVIEW USB2.0 DVD2 */
115
116 static const struct pvr2_device_client_desc pvr2_cli_gotview_2[] = {
117         { .module_id = PVR2_CLIENT_ID_CX25840 },
118         { .module_id = PVR2_CLIENT_ID_TUNER },
119 };
120
121 static const struct pvr2_device_desc pvr2_device_gotview_2 = {
122                 .description = "Gotview USB 2.0 DVD 2",
123                 .shortname = "gv2",
124                 .client_table.lst = pvr2_cli_gotview_2,
125                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_gotview_2),
126                 .flag_has_cx25840 = !0,
127                 .default_tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
128                 .flag_has_analogtuner = !0,
129                 .flag_has_fmradio = !0,
130                 .flag_has_composite = !0,
131                 .flag_has_svideo = !0,
132                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_GOTVIEW,
133 };
134
135
136
137 /*------------------------------------------------------------------------*/
138 /* GOTVIEW USB2.0 DVD Deluxe */
139
140 /* (same module list as gotview_2) */
141
142 static const struct pvr2_device_desc pvr2_device_gotview_2d = {
143                 .description = "Gotview USB 2.0 DVD Deluxe",
144                 .shortname = "gv2d",
145                 .client_table.lst = pvr2_cli_gotview_2,
146                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_gotview_2),
147                 .flag_has_cx25840 = !0,
148                 .default_tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
149                 .flag_has_analogtuner = !0,
150                 .flag_has_composite = !0,
151                 .flag_has_svideo = !0,
152                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_GOTVIEW,
153 };
154
155
156
157 /*------------------------------------------------------------------------*/
158 /* OnAir Creator */
159
160 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
161 static struct lgdt330x_config pvr2_lgdt3303_config = {
162         .demod_address       = 0x0e,
163         .demod_chip          = LGDT3303,
164         .clock_polarity_flip = 1,
165 };
166
167 static int pvr2_lgdt3303_attach(struct pvr2_dvb_adapter *adap)
168 {
169         adap->fe = dvb_attach(lgdt330x_attach, &pvr2_lgdt3303_config,
170                               &adap->channel.hdw->i2c_adap);
171         if (adap->fe)
172                 return 0;
173
174         return -EIO;
175 }
176
177 static int pvr2_lgh06xf_attach(struct pvr2_dvb_adapter *adap)
178 {
179         dvb_attach(simple_tuner_attach, adap->fe,
180                    &adap->channel.hdw->i2c_adap, 0x61,
181                    TUNER_LG_TDVS_H06XF);
182
183         return 0;
184 }
185
186 static const struct pvr2_dvb_props pvr2_onair_creator_fe_props = {
187         .frontend_attach = pvr2_lgdt3303_attach,
188         .tuner_attach    = pvr2_lgh06xf_attach,
189 };
190 #endif
191
192 static const struct pvr2_device_client_desc pvr2_cli_onair_creator[] = {
193         { .module_id = PVR2_CLIENT_ID_SAA7115 },
194         { .module_id = PVR2_CLIENT_ID_CS53L32A },
195         { .module_id = PVR2_CLIENT_ID_TUNER },
196 };
197
198 static const struct pvr2_device_desc pvr2_device_onair_creator = {
199                 .description = "OnAir Creator Hybrid USB tuner",
200                 .shortname = "oac",
201                 .client_table.lst = pvr2_cli_onair_creator,
202                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_onair_creator),
203                 .default_tuner_type = TUNER_LG_TDVS_H06XF,
204                 .flag_has_analogtuner = !0,
205                 .flag_has_composite = !0,
206                 .flag_has_svideo = !0,
207                 .flag_digital_requires_cx23416 = !0,
208                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_ONAIR,
209                 .digital_control_scheme = PVR2_DIGITAL_SCHEME_ONAIR,
210                 .default_std_mask = V4L2_STD_NTSC_M,
211 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
212                 .dvb_props = &pvr2_onair_creator_fe_props,
213 #endif
214 };
215
216
217
218 /*------------------------------------------------------------------------*/
219 /* OnAir USB 2.0 */
220
221 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
222 static struct lgdt330x_config pvr2_lgdt3302_config = {
223         .demod_address       = 0x0e,
224         .demod_chip          = LGDT3302,
225 };
226
227 static int pvr2_lgdt3302_attach(struct pvr2_dvb_adapter *adap)
228 {
229         adap->fe = dvb_attach(lgdt330x_attach, &pvr2_lgdt3302_config,
230                               &adap->channel.hdw->i2c_adap);
231         if (adap->fe)
232                 return 0;
233
234         return -EIO;
235 }
236
237 static int pvr2_fcv1236d_attach(struct pvr2_dvb_adapter *adap)
238 {
239         dvb_attach(simple_tuner_attach, adap->fe,
240                    &adap->channel.hdw->i2c_adap, 0x61,
241                    TUNER_PHILIPS_FCV1236D);
242
243         return 0;
244 }
245
246 static const struct pvr2_dvb_props pvr2_onair_usb2_fe_props = {
247         .frontend_attach = pvr2_lgdt3302_attach,
248         .tuner_attach    = pvr2_fcv1236d_attach,
249 };
250 #endif
251
252 static const struct pvr2_device_client_desc pvr2_cli_onair_usb2[] = {
253         { .module_id = PVR2_CLIENT_ID_SAA7115 },
254         { .module_id = PVR2_CLIENT_ID_CS53L32A },
255         { .module_id = PVR2_CLIENT_ID_TUNER },
256 };
257
258 static const struct pvr2_device_desc pvr2_device_onair_usb2 = {
259                 .description = "OnAir USB2 Hybrid USB tuner",
260                 .shortname = "oa2",
261                 .client_table.lst = pvr2_cli_onair_usb2,
262                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_onair_usb2),
263                 .default_tuner_type = TUNER_PHILIPS_FCV1236D,
264                 .flag_has_analogtuner = !0,
265                 .flag_has_composite = !0,
266                 .flag_has_svideo = !0,
267                 .flag_digital_requires_cx23416 = !0,
268                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_ONAIR,
269                 .digital_control_scheme = PVR2_DIGITAL_SCHEME_ONAIR,
270                 .default_std_mask = V4L2_STD_NTSC_M,
271 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
272                 .dvb_props = &pvr2_onair_usb2_fe_props,
273 #endif
274 };
275
276
277
278 /*------------------------------------------------------------------------*/
279 /* Hauppauge PVR-USB2 Model 73xxx */
280
281 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
282 static struct tda10048_config hauppauge_tda10048_config = {
283         .demod_address  = 0x10 >> 1,
284         .output_mode    = TDA10048_PARALLEL_OUTPUT,
285         .fwbulkwritelen = TDA10048_BULKWRITE_50,
286         .inversion      = TDA10048_INVERSION_ON,
287 };
288
289 static struct tda829x_config tda829x_no_probe = {
290         .probe_tuner = TDA829X_DONT_PROBE,
291 };
292
293 static struct tda18271_config hauppauge_tda18271_dvb_config = {
294         .gate    = TDA18271_GATE_ANALOG,
295 };
296
297 static int pvr2_tda10048_attach(struct pvr2_dvb_adapter *adap)
298 {
299         adap->fe = dvb_attach(tda10048_attach, &hauppauge_tda10048_config,
300                               &adap->channel.hdw->i2c_adap);
301         if (adap->fe)
302                 return 0;
303
304         return -EIO;
305 }
306
307 static int pvr2_73xxx_tda18271_8295_attach(struct pvr2_dvb_adapter *adap)
308 {
309         dvb_attach(tda829x_attach, adap->fe,
310                    &adap->channel.hdw->i2c_adap, 0x42,
311                    &tda829x_no_probe);
312         dvb_attach(tda18271_attach, adap->fe, 0x60,
313                    &adap->channel.hdw->i2c_adap,
314                    &hauppauge_tda18271_dvb_config);
315
316         return 0;
317 }
318
319 static const struct pvr2_dvb_props pvr2_73xxx_dvb_props = {
320         .frontend_attach = pvr2_tda10048_attach,
321         .tuner_attach    = pvr2_73xxx_tda18271_8295_attach,
322 };
323 #endif
324
325 static const struct pvr2_device_client_desc pvr2_cli_73xxx[] = {
326         { .module_id = PVR2_CLIENT_ID_CX25840 },
327         { .module_id = PVR2_CLIENT_ID_TUNER,
328           .i2c_address_list = "\x42"},
329 };
330
331 static const char *pvr2_fw1_names_73xxx[] = {
332                 "v4l-pvrusb2-73xxx-01.fw",
333 };
334
335 static const struct pvr2_device_desc pvr2_device_73xxx = {
336                 .description = "WinTV HVR-1900 Model Category 73xxx",
337                 .shortname = "73xxx",
338                 .client_table.lst = pvr2_cli_73xxx,
339                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_73xxx),
340                 .fx2_firmware.lst = pvr2_fw1_names_73xxx,
341                 .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_73xxx),
342                 .flag_has_cx25840 = !0,
343                 .flag_has_hauppauge_rom = !0,
344                 .flag_has_analogtuner = !0,
345                 .flag_has_composite = !0,
346                 .flag_has_svideo = !0,
347                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
348                 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
349                 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
350                 .ir_scheme = PVR2_IR_SCHEME_ZILOG,
351 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
352                 .dvb_props = &pvr2_73xxx_dvb_props,
353 #endif
354 };
355
356
357
358 /*------------------------------------------------------------------------*/
359 /* Hauppauge PVR-USB2 Model 75xxx */
360
361 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
362 static struct s5h1409_config pvr2_s5h1409_config = {
363         .demod_address = 0x32 >> 1,
364         .output_mode   = S5H1409_PARALLEL_OUTPUT,
365         .gpio          = S5H1409_GPIO_OFF,
366         .qam_if        = 4000,
367         .inversion     = S5H1409_INVERSION_ON,
368         .status_mode   = S5H1409_DEMODLOCKING,
369 };
370
371 static struct s5h1411_config pvr2_s5h1411_config = {
372         .output_mode   = S5H1411_PARALLEL_OUTPUT,
373         .gpio          = S5H1411_GPIO_OFF,
374         .vsb_if        = S5H1411_IF_44000,
375         .qam_if        = S5H1411_IF_4000,
376         .inversion     = S5H1411_INVERSION_ON,
377         .status_mode   = S5H1411_DEMODLOCKING,
378 };
379
380 static struct tda18271_std_map hauppauge_tda18271_std_map = {
381         .atsc_6   = { .if_freq = 5380, .agc_mode = 3, .std = 3,
382                       .if_lvl = 6, .rfagc_top = 0x37, },
383         .qam_6    = { .if_freq = 4000, .agc_mode = 3, .std = 0,
384                       .if_lvl = 6, .rfagc_top = 0x37, },
385 };
386
387 static struct tda18271_config hauppauge_tda18271_config = {
388         .std_map = &hauppauge_tda18271_std_map,
389         .gate    = TDA18271_GATE_ANALOG,
390 };
391
392 static int pvr2_s5h1409_attach(struct pvr2_dvb_adapter *adap)
393 {
394         adap->fe = dvb_attach(s5h1409_attach, &pvr2_s5h1409_config,
395                               &adap->channel.hdw->i2c_adap);
396         if (adap->fe)
397                 return 0;
398
399         return -EIO;
400 }
401
402 static int pvr2_s5h1411_attach(struct pvr2_dvb_adapter *adap)
403 {
404         adap->fe = dvb_attach(s5h1411_attach, &pvr2_s5h1411_config,
405                               &adap->channel.hdw->i2c_adap);
406         if (adap->fe)
407                 return 0;
408
409         return -EIO;
410 }
411
412 static int pvr2_tda18271_8295_attach(struct pvr2_dvb_adapter *adap)
413 {
414         dvb_attach(tda829x_attach, adap->fe,
415                    &adap->channel.hdw->i2c_adap, 0x42,
416                    &tda829x_no_probe);
417         dvb_attach(tda18271_attach, adap->fe, 0x60,
418                    &adap->channel.hdw->i2c_adap,
419                    &hauppauge_tda18271_config);
420
421         return 0;
422 }
423
424 static const struct pvr2_dvb_props pvr2_750xx_dvb_props = {
425         .frontend_attach = pvr2_s5h1409_attach,
426         .tuner_attach    = pvr2_tda18271_8295_attach,
427 };
428
429 static const struct pvr2_dvb_props pvr2_751xx_dvb_props = {
430         .frontend_attach = pvr2_s5h1411_attach,
431         .tuner_attach    = pvr2_tda18271_8295_attach,
432 };
433 #endif
434
435 static const char *pvr2_fw1_names_75xxx[] = {
436                 "v4l-pvrusb2-73xxx-01.fw",
437 };
438
439 static const struct pvr2_device_desc pvr2_device_750xx = {
440                 .description = "WinTV HVR-1950 Model Category 750xx",
441                 .shortname = "750xx",
442                 .client_table.lst = pvr2_cli_73xxx,
443                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_73xxx),
444                 .fx2_firmware.lst = pvr2_fw1_names_75xxx,
445                 .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_75xxx),
446                 .flag_has_cx25840 = !0,
447                 .flag_has_hauppauge_rom = !0,
448                 .flag_has_analogtuner = !0,
449                 .flag_has_composite = !0,
450                 .flag_has_svideo = !0,
451                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
452                 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
453                 .default_std_mask = V4L2_STD_NTSC_M,
454                 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
455                 .ir_scheme = PVR2_IR_SCHEME_ZILOG,
456 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
457                 .dvb_props = &pvr2_750xx_dvb_props,
458 #endif
459 };
460
461 static const struct pvr2_device_desc pvr2_device_751xx = {
462                 .description = "WinTV HVR-1950 Model Category 751xx",
463                 .shortname = "751xx",
464                 .client_table.lst = pvr2_cli_73xxx,
465                 .client_table.cnt = ARRAY_SIZE(pvr2_cli_73xxx),
466                 .fx2_firmware.lst = pvr2_fw1_names_75xxx,
467                 .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_75xxx),
468                 .flag_has_cx25840 = !0,
469                 .flag_has_hauppauge_rom = !0,
470                 .flag_has_analogtuner = !0,
471                 .flag_has_composite = !0,
472                 .flag_has_svideo = !0,
473                 .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
474                 .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
475                 .default_std_mask = V4L2_STD_NTSC_M,
476                 .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
477                 .ir_scheme = PVR2_IR_SCHEME_ZILOG,
478 #ifdef CONFIG_VIDEO_PVRUSB2_DVB
479                 .dvb_props = &pvr2_751xx_dvb_props,
480 #endif
481 };
482
483
484
485 /*------------------------------------------------------------------------*/
486
487 struct usb_device_id pvr2_device_table[] = {
488         { USB_DEVICE(0x2040, 0x2900),
489           .driver_info = (kernel_ulong_t)&pvr2_device_29xxx},
490         { USB_DEVICE(0x2040, 0x2950), /* Logically identical to 2900 */
491           .driver_info = (kernel_ulong_t)&pvr2_device_29xxx},
492         { USB_DEVICE(0x2040, 0x2400),
493           .driver_info = (kernel_ulong_t)&pvr2_device_24xxx},
494         { USB_DEVICE(0x1164, 0x0622),
495           .driver_info = (kernel_ulong_t)&pvr2_device_gotview_2},
496         { USB_DEVICE(0x1164, 0x0602),
497           .driver_info = (kernel_ulong_t)&pvr2_device_gotview_2d},
498         { USB_DEVICE(0x11ba, 0x1003),
499           .driver_info = (kernel_ulong_t)&pvr2_device_onair_creator},
500         { USB_DEVICE(0x11ba, 0x1001),
501           .driver_info = (kernel_ulong_t)&pvr2_device_onair_usb2},
502         { USB_DEVICE(0x2040, 0x7300),
503           .driver_info = (kernel_ulong_t)&pvr2_device_73xxx},
504         { USB_DEVICE(0x2040, 0x7500),
505           .driver_info = (kernel_ulong_t)&pvr2_device_750xx},
506         { USB_DEVICE(0x2040, 0x7501),
507           .driver_info = (kernel_ulong_t)&pvr2_device_751xx},
508         { }
509 };
510
511 MODULE_DEVICE_TABLE(usb, pvr2_device_table);
512
513
514 /*
515   Stuff for Emacs to see, in order to encourage consistent editing style:
516   *** Local Variables: ***
517   *** mode: c ***
518   *** fill-column: 75 ***
519   *** tab-width: 8 ***
520   *** c-basic-offset: 8 ***
521   *** End: ***
522   */