blob: ed428c58b73d76098698ca123cb534ba19dd12d8 [file] [log] [blame]
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001/*
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -08002 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB video capture devices
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08003
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -08004 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
5 Markus Rechberger <mrechberger@gmail.com>
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -08006 Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -08007 Sascha Sommer <saschasommer@freenet.de>
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08008
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>
Mauro Carvalho Chehab1f6173e2005-11-08 21:37:16 -080031#include <media/audiochip.h>
32#include <media/tveeprom.h>
Mauro Carvalho Chehab9bb13a62006-01-09 15:25:37 -020033#include <media/v4l2-common.h>
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080034#include "msp3400.h"
35
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -080036#include "em28xx.h"
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080037
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080038struct em28xx_board em28xx_boards[] = {
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080039 [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,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080046 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080047 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080048 .type = EM28XX_VMUX_COMPOSITE1,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080049 .vmux = 0,
50 .amux = 1,
51 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080052 .type = EM28XX_VMUX_SVIDEO,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080053 .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,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080064 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080065 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080066 .type = EM28XX_VMUX_COMPOSITE1,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080067 .vmux = 0,
68 .amux = 1,
69 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080070 .type = EM28XX_VMUX_SVIDEO,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080071 .vmux = 9,
72 .amux = 1,
73 }},
74 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080075 [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,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080082 .decoder = EM28XX_SAA7113,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080083 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080084 .type = EM28XX_VMUX_TELEVISION,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080085 .vmux = 2,
86 .amux = 0,
87 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080088 .type = EM28XX_VMUX_COMPOSITE1,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080089 .vmux = 0,
90 .amux = 1,
91 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080092 .type = EM28XX_VMUX_SVIDEO,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080093 .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,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800104 .decoder = EM28XX_SAA7113,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800105 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800106 .type = EM28XX_VMUX_TELEVISION,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800107 .vmux = 2,
108 .amux = 0,
109 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800110 .type = EM28XX_VMUX_COMPOSITE1,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800111 .vmux = 0,
112 .amux = 1,
113 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800114 .type = EM28XX_VMUX_SVIDEO,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800115 .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,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800126 .decoder = EM28XX_TVP5150,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800127 .has_msp34xx = 1,
128 /*FIXME: S-Video not tested */
129 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800130 .type = EM28XX_VMUX_TELEVISION,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800131 .vmux = 0,
Mauro Carvalho Chehabeac94352005-11-08 21:38:43 -0800132 .amux = 6,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800133 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800134 .type = EM28XX_VMUX_SVIDEO,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800135 .vmux = 2,
136 .amux = 1,
137 }},
138 },
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200139 [EM2880_BOARD_WINTV_HVR_900] = {
140 .name = "WinTV HVR 900",
141 .vchannels = 3,
142 .norm = VIDEO_MODE_PAL,
143 .has_tuner = 0,
144 .tda9887_conf = TDA9887_PRESENT,
145 .has_tuner = 1,
146 .decoder = EM28XX_TVP5150,
147 .input = {{
148 .type = EM28XX_VMUX_COMPOSITE1,
149 .vmux = 2,
150 .amux = 0,
151 },{
152 .type = EM28XX_VMUX_TELEVISION,
153 .vmux = 0,
154 .amux = 1,
155 },{
156 .type = EM28XX_VMUX_SVIDEO,
157 .vmux = 9,
158 .amux = 1,
159 }},
160 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800161 [EM2820_BOARD_MSI_VOX_USB_2] = {
162 .name = "MSI VOX USB 2.0",
163 .vchannels = 3,
164 .norm = VIDEO_MODE_PAL,
Markus Rechberger08eca132005-11-08 21:38:05 -0800165 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800166 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
167 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800168 .decoder = EM28XX_SAA7114,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800169 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800170 .type = EM28XX_VMUX_TELEVISION,
Markus Rechberger30556b22005-11-08 21:38:05 -0800171 .vmux = 4,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800172 .amux = 0,
173 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800174 .type = EM28XX_VMUX_COMPOSITE1,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800175 .vmux = 0,
176 .amux = 1,
177 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800178 .type = EM28XX_VMUX_SVIDEO,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800179 .vmux = 9,
180 .amux = 1,
181 }},
182 },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800183 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
184 .name = "Terratec Cinergy 200 USB",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800185 .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,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800191 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800192 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800193 .type = EM28XX_VMUX_TELEVISION,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800194 .vmux = 2,
195 .amux = 0,
196 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800197 .type = EM28XX_VMUX_COMPOSITE1,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800198 .vmux = 0,
199 .amux = 1,
200 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800201 .type = EM28XX_VMUX_SVIDEO,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800202 .vmux = 9,
203 .amux = 1,
204 }},
205 },
206 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
207 .name = "Leadtek Winfast USB II",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800208 .is_em2800 = 1,
209 .vchannels = 3,
210 .norm = VIDEO_MODE_PAL,
211 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
212 .tda9887_conf = TDA9887_PRESENT,
213 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800214 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800215 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800216 .type = EM28XX_VMUX_TELEVISION,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800217 .vmux = 2,
218 .amux = 0,
219 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800220 .type = EM28XX_VMUX_COMPOSITE1,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800221 .vmux = 0,
222 .amux = 1,
223 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800224 .type = EM28XX_VMUX_SVIDEO,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800225 .vmux = 9,
226 .amux = 1,
227 }},
228 },
229 [EM2800_BOARD_KWORLD_USB2800] = {
230 .name = "Kworld USB2800",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800231 .is_em2800 = 1,
232 .vchannels = 3,
233 .norm = VIDEO_MODE_PAL,
234 .tuner_type = TUNER_PHILIPS_ATSC,
235 .tda9887_conf = TDA9887_PRESENT,
236 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800237 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800238 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800239 .type = EM28XX_VMUX_TELEVISION,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800240 .vmux = 2,
241 .amux = 0,
242 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800243 .type = EM28XX_VMUX_COMPOSITE1,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800244 .vmux = 0,
245 .amux = 1,
246 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800247 .type = EM28XX_VMUX_SVIDEO,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800248 .vmux = 9,
249 .amux = 1,
250 }},
251 },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800252 [EM2820_BOARD_PINNACLE_DVC_90] = {
253 .name = "Pinnacle Dazzle DVC 90",
254 .vchannels = 3,
255 .norm = VIDEO_MODE_PAL,
256 .has_tuner = 0,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800257 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800258 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800259 .type = EM28XX_VMUX_COMPOSITE1,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800260 .vmux = 0,
261 .amux = 1,
262 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800263 .type = EM28XX_VMUX_SVIDEO,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800264 .vmux = 9,
265 .amux = 1,
266 }},
267 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800268};
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800269const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800270
271/* table of devices that work with this driver */
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800272struct usb_device_id em28xx_id_table [] = {
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800273 { USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
Markus Rechberger08eca132005-11-08 21:38:05 -0800274 { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800275 { USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
276 { USB_DEVICE(0x2304, 0x0208), .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
277 { USB_DEVICE(0x2040, 0x4200), .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800278 { USB_DEVICE(0x2304, 0x0207), .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200279 { USB_DEVICE(0x2040, 0x6500), .driver_info = EM2880_BOARD_WINTV_HVR_900 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800280 { },
281};
282
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200283void em28xx_pre_card_setup(struct em28xx *dev)
284{
285 /* request some modules */
286 switch(dev->model){
287 case EM2880_BOARD_WINTV_HVR_900:
288 {
289 em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1); // reset through GPIO?
290 break;
291 }
292 }
293}
294
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800295void em28xx_card_setup(struct em28xx *dev)
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800296{
297 /* request some modules */
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200298 switch(dev->model){
299 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
300 {
301 struct tveeprom tv;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800302#ifdef CONFIG_MODULES
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200303 request_module("tveeprom");
304 request_module("ir-kbd-i2c");
305 request_module("msp3400");
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800306#endif
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200307 /* Call first TVeeprom */
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800308
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200309 dev->i2c_client.addr = 0xa0 >> 1;
310 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800311
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200312 dev->tuner_type= tv.tuner_type;
313 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
314 dev->i2s_speed=2048000;
315 dev->has_msp34xx=1;
316 } else
317 dev->has_msp34xx=0;
318 break;
319 }
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800320 }
321}
322
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800323EXPORT_SYMBOL(em28xx_boards);
324EXPORT_SYMBOL(em28xx_bcount);
325EXPORT_SYMBOL(em28xx_id_table);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800326
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800327MODULE_DEVICE_TABLE (usb, em28xx_id_table);