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