Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
[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@brturbo.com.br>
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/pci.h>
27 #include <linux/delay.h>
28 #include <linux/i2c.h>
29 #include <linux/usb.h>
30 #include <media/tuner.h>
31 #include <media/audiochip.h>
32 #include <media/tveeprom.h>
33 #include <media/v4l2-common.h>
34 #include "msp3400.h"
35
36 #include "em28xx.h"
37
38 struct em28xx_board em28xx_boards[] = {
39         [EM2800_BOARD_UNKNOWN] = {
40                 .name         = "Unknown EM2800 video grabber",
41                 .is_em2800    = 1,
42                 .vchannels    = 2,
43                 .norm         = VIDEO_MODE_PAL,
44                 .tda9887_conf = TDA9887_PRESENT,
45                 .has_tuner    = 1,
46                 .decoder      = EM28XX_SAA7113,
47                 .input           = {{
48                         .type     = EM28XX_VMUX_COMPOSITE1,
49                         .vmux     = 0,
50                         .amux     = 1,
51                 },{
52                         .type     = EM28XX_VMUX_SVIDEO,
53                         .vmux     = 9,
54                         .amux     = 1,
55                 }},
56         },
57         [EM2820_BOARD_UNKNOWN] = {
58                 .name         = "Unknown EM2820/2840 video grabber",
59                 .is_em2800    = 0,
60                 .vchannels    = 2,
61                 .norm         = VIDEO_MODE_PAL,
62                 .tda9887_conf = TDA9887_PRESENT,
63                 .has_tuner    = 1,
64                 .decoder      = EM28XX_SAA7113,
65                 .input           = {{
66                         .type     = EM28XX_VMUX_COMPOSITE1,
67                         .vmux     = 0,
68                         .amux     = 1,
69                 },{
70                         .type     = EM28XX_VMUX_SVIDEO,
71                         .vmux     = 9,
72                         .amux     = 1,
73                 }},
74         },
75         [EM2820_BOARD_TERRATEC_CINERGY_250] = {
76                 .name         = "Terratec Cinergy 250 USB",
77                 .vchannels    = 3,
78                 .norm         = VIDEO_MODE_PAL,
79                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
80                 .tda9887_conf = TDA9887_PRESENT,
81                 .has_tuner    = 1,
82                 .decoder      = EM28XX_SAA7113,
83                 .input          = {{
84                         .type     = EM28XX_VMUX_TELEVISION,
85                         .vmux     = 2,
86                         .amux     = 0,
87                 },{
88                         .type     = EM28XX_VMUX_COMPOSITE1,
89                         .vmux     = 0,
90                         .amux     = 1,
91                 },{
92                         .type     = EM28XX_VMUX_SVIDEO,
93                         .vmux     = 9,
94                         .amux     = 1,
95                 }},
96         },
97         [EM2820_BOARD_PINNACLE_USB_2] = {
98                 .name         = "Pinnacle PCTV USB 2",
99                 .vchannels    = 3,
100                 .norm         = VIDEO_MODE_PAL,
101                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
102                 .tda9887_conf = TDA9887_PRESENT,
103                 .has_tuner    = 1,
104                 .decoder      = EM28XX_SAA7113,
105                 .input          = {{
106                         .type     = EM28XX_VMUX_TELEVISION,
107                         .vmux     = 2,
108                         .amux     = 0,
109                 },{
110                         .type     = EM28XX_VMUX_COMPOSITE1,
111                         .vmux     = 0,
112                         .amux     = 1,
113                 },{
114                         .type     = EM28XX_VMUX_SVIDEO,
115                         .vmux     = 9,
116                         .amux     = 1,
117                 }},
118         },
119         [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
120                 .name         = "Hauppauge WinTV USB 2",
121                 .vchannels    = 3,
122                 .norm         = VIDEO_MODE_NTSC,
123                 .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
124                 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
125                 .has_tuner    = 1,
126                 .decoder      = EM28XX_TVP5150,
127                 .has_msp34xx  = 1,
128                 /*FIXME: S-Video not tested */
129                 .input          = {{
130                         .type     = EM28XX_VMUX_TELEVISION,
131                         .vmux     = 0,
132                         .amux     = 6,
133                 },{
134                         .type     = EM28XX_VMUX_SVIDEO,
135                         .vmux     = 2,
136                         .amux     = 1,
137                 }},
138         },
139         [EM2820_BOARD_MSI_VOX_USB_2] = {
140                 .name           = "MSI VOX USB 2.0",
141                 .vchannels      = 3,
142                 .norm           = VIDEO_MODE_PAL,
143                 .tuner_type     = TUNER_LG_PAL_NEW_TAPC,
144                 .tda9887_conf   = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
145                 .has_tuner      = 1,
146                 .decoder        = EM28XX_SAA7114,
147                 .input          = {{
148                         .type     = EM28XX_VMUX_TELEVISION,
149                         .vmux     = 4,
150                         .amux     = 0,
151                 },{
152                         .type     = EM28XX_VMUX_COMPOSITE1,
153                         .vmux     = 0,
154                         .amux     = 1,
155                 },{
156                         .type     = EM28XX_VMUX_SVIDEO,
157                         .vmux     = 9,
158                         .amux     = 1,
159                 }},
160         },
161         [EM2800_BOARD_TERRATEC_CINERGY_200] = {
162                 .name         = "Terratec Cinergy 200 USB",
163                 .is_em2800    = 1,
164                 .vchannels    = 3,
165                 .norm         = VIDEO_MODE_PAL,
166                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
167                 .tda9887_conf = TDA9887_PRESENT,
168                 .has_tuner    = 1,
169                 .decoder      = EM28XX_SAA7113,
170                 .input          = {{
171                         .type     = EM28XX_VMUX_TELEVISION,
172                         .vmux     = 2,
173                         .amux     = 0,
174                 },{
175                         .type     = EM28XX_VMUX_COMPOSITE1,
176                         .vmux     = 0,
177                         .amux     = 1,
178                 },{
179                         .type     = EM28XX_VMUX_SVIDEO,
180                         .vmux     = 9,
181                         .amux     = 1,
182                 }},
183         },
184         [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
185                 .name         = "Leadtek Winfast USB II",
186                 .is_em2800    = 1,
187                 .vchannels    = 3,
188                 .norm         = VIDEO_MODE_PAL,
189                 .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
190                 .tda9887_conf = TDA9887_PRESENT,
191                 .has_tuner    = 1,
192                 .decoder      = EM28XX_SAA7113,
193                 .input          = {{
194                         .type     = EM28XX_VMUX_TELEVISION,
195                         .vmux     = 2,
196                         .amux     = 0,
197                 },{
198                         .type     = EM28XX_VMUX_COMPOSITE1,
199                         .vmux     = 0,
200                         .amux     = 1,
201                 },{
202                         .type     = EM28XX_VMUX_SVIDEO,
203                         .vmux     = 9,
204                         .amux     = 1,
205                 }},
206         },
207         [EM2800_BOARD_KWORLD_USB2800] = {
208                 .name         = "Kworld USB2800",
209                 .is_em2800    = 1,
210                 .vchannels    = 3,
211                 .norm         = VIDEO_MODE_PAL,
212                 .tuner_type   = TUNER_PHILIPS_ATSC,
213                 .tda9887_conf = TDA9887_PRESENT,
214                 .has_tuner    = 1,
215                 .decoder      = EM28XX_SAA7113,
216                 .input          = {{
217                         .type     = EM28XX_VMUX_TELEVISION,
218                         .vmux     = 2,
219                         .amux     = 0,
220                 },{
221                         .type     = EM28XX_VMUX_COMPOSITE1,
222                         .vmux     = 0,
223                         .amux     = 1,
224                 },{
225                         .type     = EM28XX_VMUX_SVIDEO,
226                         .vmux     = 9,
227                         .amux     = 1,
228                 }},
229         },
230         [EM2820_BOARD_PINNACLE_DVC_90] = {
231                 .name         = "Pinnacle Dazzle DVC 90",
232                 .vchannels    = 3,
233                 .norm         = VIDEO_MODE_PAL,
234                 .has_tuner    = 0,
235                 .decoder      = EM28XX_SAA7113,
236                 .input          = {{
237                         .type     = EM28XX_VMUX_COMPOSITE1,
238                         .vmux     = 0,
239                         .amux     = 1,
240                 },{
241                         .type     = EM28XX_VMUX_SVIDEO,
242                         .vmux     = 9,
243                         .amux     = 1,
244                 }},
245         },
246 };
247 const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
248
249 /* table of devices that work with this driver */
250 struct usb_device_id em28xx_id_table [] = {
251         { USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
252         { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
253         { USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
254         { USB_DEVICE(0x2304, 0x0208), .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
255         { USB_DEVICE(0x2040, 0x4200), .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
256         { USB_DEVICE(0x2304, 0x0207), .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
257         { },
258 };
259
260 void em28xx_card_setup(struct em28xx *dev)
261 {
262         /* request some modules */
263         if (dev->model == EM2820_BOARD_HAUPPAUGE_WINTV_USB_2) {
264                 struct tveeprom tv;
265 #ifdef CONFIG_MODULES
266                 request_module("tveeprom");
267                 request_module("ir-kbd-i2c");
268                 request_module("msp3400");
269 #endif
270                 /* Call first TVeeprom */
271
272                 dev->i2c_client.addr = 0xa0 >> 1;
273                 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
274
275                 dev->tuner_type= tv.tuner_type;
276                 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
277                         dev->i2s_speed=2048000;
278                         dev->has_msp34xx=1;
279                 } else
280                         dev->has_msp34xx=0;
281         }
282 }
283
284 EXPORT_SYMBOL(em28xx_boards);
285 EXPORT_SYMBOL(em28xx_bcount);
286 EXPORT_SYMBOL(em28xx_id_table);
287
288 MODULE_DEVICE_TABLE (usb, em28xx_id_table);