V4L/DVB (6422): Add the pending entries for xc2028/3028 based boards
[linux-2.6] / drivers / media / video / em28xx / em28xx-cards.c
1 /*
2    em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB video capture devices
3
4    Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
5                       Markus Rechberger <mrechberger@gmail.com>
6                       Mauro Carvalho Chehab <mchehab@infradead.org>
7                       Sascha Sommer <saschasommer@freenet.de>
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/delay.h>
27 #include <linux/i2c.h>
28 #include <linux/usb.h>
29 #include <media/tuner.h>
30 #include <media/msp3400.h>
31 #include <media/saa7115.h>
32 #include <media/tvp5150.h>
33 #include <media/tveeprom.h>
34 #include <media/audiochip.h>
35 #include <media/v4l2-common.h>
36
37 #include "em28xx.h"
38
39 struct em28xx_board em28xx_boards[] = {
40         [EM2800_BOARD_UNKNOWN] = {
41                 .name         = "Unknown EM2800 video grabber",
42                 .is_em2800    = 1,
43                 .vchannels    = 2,
44                 .norm         = VIDEO_MODE_PAL,
45                 .tda9887_conf = TDA9887_PRESENT,
46                 .has_tuner    = 1,
47                 .decoder      = EM28XX_SAA7113,
48                 .input           = {{
49                         .type     = EM28XX_VMUX_COMPOSITE1,
50                         .vmux     = SAA7115_COMPOSITE0,
51                         .amux     = 1,
52                 },{
53                         .type     = EM28XX_VMUX_SVIDEO,
54                         .vmux     = SAA7115_SVIDEO3,
55                         .amux     = 1,
56                 }},
57         },
58         [EM2820_BOARD_UNKNOWN] = {
59                 .name         = "Unknown EM2820/2840 video grabber",
60                 .is_em2800    = 0,
61                 .vchannels    = 2,
62                 .norm         = VIDEO_MODE_PAL,
63                 .tda9887_conf = TDA9887_PRESENT,
64                 .has_tuner    = 1,
65                 .decoder      = EM28XX_SAA7113,
66                 .input           = {{
67                         .type     = EM28XX_VMUX_COMPOSITE1,
68                         .vmux     = SAA7115_COMPOSITE0,
69                         .amux     = 1,
70                 },{
71                         .type     = EM28XX_VMUX_SVIDEO,
72                         .vmux     = SAA7115_SVIDEO3,
73                         .amux     = 1,
74                 }},
75         },
76         [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
77                 .name         = "Kworld PVR TV 2800 RF",
78                 .is_em2800    = 0,
79                 .vchannels    = 2,
80                 .norm         = VIDEO_MODE_PAL,
81                 .tda9887_conf = TDA9887_PRESENT,
82                 .has_tuner    = 1,
83                 .decoder      = EM28XX_SAA7113,
84                 .input           = {{
85                         .type     = EM28XX_VMUX_COMPOSITE1,
86                         .vmux     = SAA7115_COMPOSITE0,
87                         .amux     = 1,
88                 },{
89                         .type     = EM28XX_VMUX_SVIDEO,
90                         .vmux     = SAA7115_SVIDEO3,
91                         .amux     = 1,
92                 }},
93         },
94         [EM2820_BOARD_TERRATEC_CINERGY_250] = {
95                 .name         = "Terratec Cinergy 250 USB",
96                 .vchannels    = 3,
97                 .norm         = VIDEO_MODE_PAL,
98                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
99                 .tda9887_conf = TDA9887_PRESENT,
100                 .has_tuner    = 1,
101                 .decoder      = EM28XX_SAA7113,
102                 .input          = {{
103                         .type     = EM28XX_VMUX_TELEVISION,
104                         .vmux     = SAA7115_COMPOSITE2,
105                         .amux     = 1,
106                 },{
107                         .type     = EM28XX_VMUX_COMPOSITE1,
108                         .vmux     = SAA7115_COMPOSITE0,
109                         .amux     = 1,
110                 },{
111                         .type     = EM28XX_VMUX_SVIDEO,
112                         .vmux     = SAA7115_SVIDEO3,
113                         .amux     = 1,
114                 }},
115         },
116         [EM2820_BOARD_PINNACLE_USB_2] = {
117                 .name         = "Pinnacle PCTV USB 2",
118                 .vchannels    = 3,
119                 .norm         = VIDEO_MODE_PAL,
120                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
121                 .tda9887_conf = TDA9887_PRESENT,
122                 .has_tuner    = 1,
123                 .decoder      = EM28XX_SAA7113,
124                 .input          = {{
125                         .type     = EM28XX_VMUX_TELEVISION,
126                         .vmux     = SAA7115_COMPOSITE2,
127                         .amux     = 0,
128                 },{
129                         .type     = EM28XX_VMUX_COMPOSITE1,
130                         .vmux     = SAA7115_COMPOSITE0,
131                         .amux     = 1,
132                 },{
133                         .type     = EM28XX_VMUX_SVIDEO,
134                         .vmux     = SAA7115_SVIDEO3,
135                         .amux     = 1,
136                 }},
137         },
138         [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
139                 .name         = "Hauppauge WinTV USB 2",
140                 .vchannels    = 3,
141                 .norm         = VIDEO_MODE_NTSC,
142                 .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
143                 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
144                 .has_tuner    = 1,
145                 .decoder      = EM28XX_TVP5150,
146                 .has_msp34xx  = 1,
147                 /*FIXME: S-Video not tested */
148                 .input          = {{
149                         .type     = EM28XX_VMUX_TELEVISION,
150                         .vmux     = TVP5150_COMPOSITE0,
151                         .amux     = MSP_INPUT_DEFAULT,
152                 },{
153                         .type     = EM28XX_VMUX_SVIDEO,
154                         .vmux     = TVP5150_SVIDEO,
155                         .amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
156                                         MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
157                 }},
158         },
159         [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
160                 .name         = "Hauppauge WinTV HVR 900",
161                 .vchannels    = 3,
162                 .norm         = VIDEO_MODE_PAL,
163                 .tda9887_conf = TDA9887_PRESENT,
164                 .tuner_type   = TUNER_XC2028,
165                 .has_tuner    = 1,
166                 .decoder      = EM28XX_TVP5150,
167                 .input          = {{
168                         .type     = EM28XX_VMUX_COMPOSITE1,
169                         .vmux     = TVP5150_COMPOSITE1,
170                         .amux     = 1,
171                 },{
172                         .type     = EM28XX_VMUX_TELEVISION,
173                         .vmux     = TVP5150_COMPOSITE0,
174                         .amux     = 0,
175                 },{
176                         .type     = EM28XX_VMUX_SVIDEO,
177                         .vmux     = TVP5150_SVIDEO,
178                         .amux     = 1,
179                 }},
180         },
181         [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
182                 .name         = "Terratec Hybrid XS",
183                 .vchannels    = 3,
184                 .norm         = VIDEO_MODE_PAL,
185                 .tda9887_conf = TDA9887_PRESENT,
186                 .has_tuner    = 1,
187                 .tuner_type   = TUNER_XC2028,
188                 .decoder      = EM28XX_TVP5150,
189                 .input          = {{
190                         .type     = EM28XX_VMUX_TELEVISION,
191                         .vmux     = TVP5150_COMPOSITE0,
192                         .amux     = 0,
193                 },{
194                         .type     = EM28XX_VMUX_COMPOSITE1,
195                         .vmux     = TVP5150_COMPOSITE1,
196                         .amux     = 1,
197                 },{
198                         .type     = EM28XX_VMUX_SVIDEO,
199                         .vmux     = TVP5150_SVIDEO,
200                         .amux     = 1,
201                 }},
202         },
203         /* maybe there's a reason behind it why Terratec sells the Hybrid XS as Prodigy XS with a
204          * different PID, let's keep it separated for now maybe we'll need it lateron */
205         [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
206                 .name         = "Terratec Prodigy XS",
207                 .vchannels    = 3,
208                 .norm         = VIDEO_MODE_PAL,
209                 .tda9887_conf = TDA9887_PRESENT,
210                 .has_tuner    = 1,
211                 .tuner_type   = TUNER_XC2028,
212                 .decoder      = EM28XX_TVP5150,
213                 .input          = {{
214                         .type     = EM28XX_VMUX_TELEVISION,
215                         .vmux     = TVP5150_COMPOSITE0,
216                         .amux     = 0,
217                 },{
218                         .type     = EM28XX_VMUX_COMPOSITE1,
219                         .vmux     = TVP5150_COMPOSITE1,
220                         .amux     = 1,
221                 },{
222                         .type     = EM28XX_VMUX_SVIDEO,
223                         .vmux     = TVP5150_SVIDEO,
224                         .amux     = 1,
225                 }},
226         },
227         [EM2820_BOARD_MSI_VOX_USB_2] = {
228                 .name           = "MSI VOX USB 2.0",
229                 .vchannels      = 3,
230                 .norm           = VIDEO_MODE_PAL,
231                 .tuner_type     = TUNER_LG_PAL_NEW_TAPC,
232                 .tda9887_conf   = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
233                 .has_tuner      = 1,
234                 .decoder        = EM28XX_SAA7114,
235                 .input          = {{
236                         .type     = EM28XX_VMUX_TELEVISION,
237                         .vmux     = SAA7115_COMPOSITE4,
238                         .amux     = 0,
239                 },{
240                         .type     = EM28XX_VMUX_COMPOSITE1,
241                         .vmux     = SAA7115_COMPOSITE0,
242                         .amux     = 1,
243                 },{
244                         .type     = EM28XX_VMUX_SVIDEO,
245                         .vmux     = SAA7115_SVIDEO3,
246                         .amux     = 1,
247                 }},
248         },
249         [EM2800_BOARD_TERRATEC_CINERGY_200] = {
250                 .name         = "Terratec Cinergy 200 USB",
251                 .is_em2800    = 1,
252                 .vchannels    = 3,
253                 .norm         = VIDEO_MODE_PAL,
254                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
255                 .tda9887_conf = TDA9887_PRESENT,
256                 .has_tuner    = 1,
257                 .decoder      = EM28XX_SAA7113,
258                 .input          = {{
259                         .type     = EM28XX_VMUX_TELEVISION,
260                         .vmux     = SAA7115_COMPOSITE2,
261                         .amux     = 0,
262                 },{
263                         .type     = EM28XX_VMUX_COMPOSITE1,
264                         .vmux     = SAA7115_COMPOSITE0,
265                         .amux     = 1,
266                 },{
267                         .type     = EM28XX_VMUX_SVIDEO,
268                         .vmux     = SAA7115_SVIDEO3,
269                         .amux     = 1,
270                 }},
271         },
272         [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
273                 .name         = "Leadtek Winfast USB II",
274                 .is_em2800    = 1,
275                 .vchannels    = 3,
276                 .norm         = VIDEO_MODE_PAL,
277                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
278                 .tda9887_conf = TDA9887_PRESENT,
279                 .has_tuner    = 1,
280                 .decoder      = EM28XX_SAA7113,
281                 .input          = {{
282                         .type     = EM28XX_VMUX_TELEVISION,
283                         .vmux     = SAA7115_COMPOSITE2,
284                         .amux     = 0,
285                 },{
286                         .type     = EM28XX_VMUX_COMPOSITE1,
287                         .vmux     = SAA7115_COMPOSITE0,
288                         .amux     = 1,
289                 },{
290                         .type     = EM28XX_VMUX_SVIDEO,
291                         .vmux     = SAA7115_SVIDEO3,
292                         .amux     = 1,
293                 }},
294         },
295         [EM2800_BOARD_KWORLD_USB2800] = {
296                 .name         = "Kworld USB2800",
297                 .is_em2800    = 1,
298                 .vchannels    = 3,
299                 .norm         = VIDEO_MODE_PAL,
300                 .tuner_type   = TUNER_PHILIPS_ATSC,
301                 .tda9887_conf = TDA9887_PRESENT,
302                 .has_tuner    = 1,
303                 .decoder      = EM28XX_SAA7113,
304                 .input          = {{
305                         .type     = EM28XX_VMUX_TELEVISION,
306                         .vmux     = SAA7115_COMPOSITE2,
307                         .amux     = 0,
308                 },{
309                         .type     = EM28XX_VMUX_COMPOSITE1,
310                         .vmux     = SAA7115_COMPOSITE0,
311                         .amux     = 1,
312                 },{
313                         .type     = EM28XX_VMUX_SVIDEO,
314                         .vmux     = SAA7115_SVIDEO3,
315                         .amux     = 1,
316                 }},
317         },
318         [EM2820_BOARD_PINNACLE_DVC_90] = {
319                 .name         = "Pinnacle Dazzle DVC 90",
320                 .vchannels    = 3,
321                 .norm         = VIDEO_MODE_PAL,
322                 .has_tuner    = 0,
323                 .decoder      = EM28XX_SAA7113,
324                 .input          = {{
325                         .type     = EM28XX_VMUX_COMPOSITE1,
326                         .vmux     = SAA7115_COMPOSITE0,
327                         .amux     = 1,
328                 },{
329                         .type     = EM28XX_VMUX_SVIDEO,
330                         .vmux     = SAA7115_SVIDEO3,
331                         .amux     = 1,
332                 }},
333         },
334 };
335 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
336
337 /* table of devices that work with this driver */
338 struct usb_device_id em28xx_id_table [] = {
339         { USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
340         { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
341         { USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
342         { USB_DEVICE(0x2304, 0x0208), .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
343         { USB_DEVICE(0x2040, 0x4200), .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
344         { USB_DEVICE(0x2304, 0x0207), .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
345         { USB_DEVICE(0x2040, 0x6500), .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
346         { USB_DEVICE(0x0ccd, 0x0042), .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
347         { USB_DEVICE(0x0ccd, 0x0047), .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
348         { },
349 };
350
351 void em28xx_pre_card_setup(struct em28xx *dev)
352 {
353         /* request some modules */
354         switch(dev->model){
355                 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
356                 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
357                 case EM2880_BOARD_TERRATEC_HYBRID_XS:
358                         {
359                                 em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1); // reset through GPIO?
360                                 break;
361                         }
362         }
363 }
364
365 void em28xx_card_setup(struct em28xx *dev)
366 {
367         /* request some modules */
368         switch(dev->model){
369                 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
370                         {
371                                 struct tveeprom tv;
372 #ifdef CONFIG_MODULES
373                                 request_module("tveeprom");
374                                 request_module("ir-kbd-i2c");
375                                 request_module("msp3400");
376 #endif
377                                 /* Call first TVeeprom */
378
379                                 dev->i2c_client.addr = 0xa0 >> 1;
380                                 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
381
382                                 dev->tuner_type= tv.tuner_type;
383                                 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
384                                         dev->i2s_speed=2048000;
385                                         dev->has_msp34xx=1;
386                                 } else
387                                         dev->has_msp34xx=0;
388                                 break;
389                         }
390                 case EM2820_BOARD_KWORLD_PVRTV2800RF:
391                         {
392                                 em28xx_write_regs_req(dev,0x00,0x08, "\xf9", 1); // GPIO enables sound on KWORLD PVR TV 2800RF
393                                 break;
394                         }
395
396         }
397 }
398
399 MODULE_DEVICE_TABLE (usb, em28xx_id_table);