blob: ae6634156e7672db8c2804b9c757e599196919e1 [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 Chehab2e7c6dc2006-04-03 07:53:40 -03006 Mauro Carvalho Chehab <mchehab@infradead.org>
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>
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080026#include <linux/delay.h>
27#include <linux/i2c.h>
28#include <linux/usb.h>
29#include <media/tuner.h>
Hans Verkuil2474ed42006-03-19 12:35:57 -030030#include <media/msp3400.h>
Hans Verkuilc7c0b342006-04-02 13:35:00 -030031#include <media/saa7115.h>
32#include <media/tvp5150.h>
Mauro Carvalho Chehab1f6173e2005-11-08 21:37:16 -080033#include <media/tveeprom.h>
Hans Verkuil2474ed42006-03-19 12:35:57 -030034#include <media/audiochip.h>
Mauro Carvalho Chehab9bb13a62006-01-09 15:25:37 -020035#include <media/v4l2-common.h>
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080036
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -080037#include "em28xx.h"
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -030038#include "tuner-xc2028.h"
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080039
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -030040static int tuner = -1;
41module_param(tuner, int, 0444);
42MODULE_PARM_DESC(tuner, "tuner type");
43
44struct em28xx_hash_table {
45 unsigned long hash;
46 unsigned int model;
47 unsigned int tuner;
48};
49
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080050struct em28xx_board em28xx_boards[] = {
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080051 [EM2800_BOARD_UNKNOWN] = {
52 .name = "Unknown EM2800 video grabber",
53 .is_em2800 = 1,
54 .vchannels = 2,
55 .norm = VIDEO_MODE_PAL,
56 .tda9887_conf = TDA9887_PRESENT,
57 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080058 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080059 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080060 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030061 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080062 .amux = 1,
63 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080064 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030065 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080066 .amux = 1,
67 }},
68 },
69 [EM2820_BOARD_UNKNOWN] = {
Mauro Carvalho Chehab3dbd85b2007-11-03 08:07:07 -030070 .name = "Unknown EM2750/28xx video grabber",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080071 .is_em2800 = 0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080072 },
Markus Rechberger4d17d082006-02-07 06:25:39 -020073 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
Markus Rechberger33ccaa32006-02-07 06:25:41 -020074 .name = "Kworld PVR TV 2800 RF",
Markus Rechberger4d17d082006-02-07 06:25:39 -020075 .is_em2800 = 0,
76 .vchannels = 2,
77 .norm = VIDEO_MODE_PAL,
78 .tda9887_conf = TDA9887_PRESENT,
79 .has_tuner = 1,
80 .decoder = EM28XX_SAA7113,
81 .input = {{
82 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030083 .vmux = SAA7115_COMPOSITE0,
Markus Rechberger4d17d082006-02-07 06:25:39 -020084 .amux = 1,
85 },{
86 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030087 .vmux = SAA7115_SVIDEO3,
Markus Rechberger4d17d082006-02-07 06:25:39 -020088 .amux = 1,
89 }},
90 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080091 [EM2820_BOARD_TERRATEC_CINERGY_250] = {
92 .name = "Terratec Cinergy 250 USB",
93 .vchannels = 3,
94 .norm = VIDEO_MODE_PAL,
95 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
96 .tda9887_conf = TDA9887_PRESENT,
97 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080098 .decoder = EM28XX_SAA7113,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080099 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800100 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300101 .vmux = SAA7115_COMPOSITE2,
Markus Rechberger9475fb12006-02-27 00:07:34 -0300102 .amux = 1,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800103 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800104 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300105 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800106 .amux = 1,
107 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800108 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300109 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800110 .amux = 1,
111 }},
112 },
113 [EM2820_BOARD_PINNACLE_USB_2] = {
114 .name = "Pinnacle PCTV USB 2",
115 .vchannels = 3,
116 .norm = VIDEO_MODE_PAL,
117 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
118 .tda9887_conf = TDA9887_PRESENT,
119 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800120 .decoder = EM28XX_SAA7113,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800121 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800122 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300123 .vmux = SAA7115_COMPOSITE2,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800124 .amux = 0,
125 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800126 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300127 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800128 .amux = 1,
129 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800130 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300131 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800132 .amux = 1,
133 }},
134 },
135 [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
136 .name = "Hauppauge WinTV USB 2",
137 .vchannels = 3,
138 .norm = VIDEO_MODE_NTSC,
139 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
140 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
141 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800142 .decoder = EM28XX_TVP5150,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800143 .has_msp34xx = 1,
144 /*FIXME: S-Video not tested */
145 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800146 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300147 .vmux = TVP5150_COMPOSITE0,
Hans Verkuil2474ed42006-03-19 12:35:57 -0300148 .amux = MSP_INPUT_DEFAULT,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800149 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800150 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300151 .vmux = TVP5150_SVIDEO,
Hans Verkuil07151722006-04-01 18:03:23 -0300152 .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
153 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800154 }},
155 },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300156 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
Mauro Carvalho Chehab7d070e22007-11-01 21:52:58 -0300157 .name = "Hauppauge WinTV HVR 900/950",
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300158 .vchannels = 3,
159 .norm = VIDEO_MODE_PAL,
160 .tda9887_conf = TDA9887_PRESENT,
161 .tuner_type = TUNER_XC2028,
162 .has_tuner = 1,
163 .decoder = EM28XX_TVP5150,
164 .input = {{
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300165 .type = EM28XX_VMUX_TELEVISION,
166 .vmux = TVP5150_COMPOSITE0,
167 .amux = 0,
168 },{
Mauro Carvalho Chehab7d070e22007-11-01 21:52:58 -0300169 .type = EM28XX_VMUX_COMPOSITE1,
170 .vmux = TVP5150_COMPOSITE1,
171 .amux = 1,
172 },{
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300173 .type = EM28XX_VMUX_SVIDEO,
174 .vmux = TVP5150_SVIDEO,
175 .amux = 1,
176 }},
177 },
178 [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
179 .name = "Terratec Hybrid XS",
180 .vchannels = 3,
181 .norm = VIDEO_MODE_PAL,
182 .tda9887_conf = TDA9887_PRESENT,
183 .has_tuner = 1,
184 .tuner_type = TUNER_XC2028,
185 .decoder = EM28XX_TVP5150,
186 .input = {{
187 .type = EM28XX_VMUX_TELEVISION,
188 .vmux = TVP5150_COMPOSITE0,
189 .amux = 0,
190 },{
191 .type = EM28XX_VMUX_COMPOSITE1,
192 .vmux = TVP5150_COMPOSITE1,
193 .amux = 1,
194 },{
195 .type = EM28XX_VMUX_SVIDEO,
196 .vmux = TVP5150_SVIDEO,
197 .amux = 1,
198 }},
199 },
200 /* maybe there's a reason behind it why Terratec sells the Hybrid XS as Prodigy XS with a
201 * different PID, let's keep it separated for now maybe we'll need it lateron */
202 [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
203 .name = "Terratec Prodigy XS",
204 .vchannels = 3,
205 .norm = VIDEO_MODE_PAL,
206 .tda9887_conf = TDA9887_PRESENT,
207 .has_tuner = 1,
208 .tuner_type = TUNER_XC2028,
209 .decoder = EM28XX_TVP5150,
210 .input = {{
211 .type = EM28XX_VMUX_TELEVISION,
212 .vmux = TVP5150_COMPOSITE0,
213 .amux = 0,
214 },{
215 .type = EM28XX_VMUX_COMPOSITE1,
216 .vmux = TVP5150_COMPOSITE1,
217 .amux = 1,
218 },{
219 .type = EM28XX_VMUX_SVIDEO,
220 .vmux = TVP5150_SVIDEO,
221 .amux = 1,
222 }},
223 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800224 [EM2820_BOARD_MSI_VOX_USB_2] = {
225 .name = "MSI VOX USB 2.0",
226 .vchannels = 3,
227 .norm = VIDEO_MODE_PAL,
Markus Rechberger08eca132005-11-08 21:38:05 -0800228 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800229 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
230 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800231 .decoder = EM28XX_SAA7114,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800232 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800233 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300234 .vmux = SAA7115_COMPOSITE4,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800235 .amux = 0,
236 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800237 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300238 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800239 .amux = 1,
240 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800241 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300242 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800243 .amux = 1,
244 }},
245 },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800246 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
247 .name = "Terratec Cinergy 200 USB",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800248 .is_em2800 = 1,
249 .vchannels = 3,
250 .norm = VIDEO_MODE_PAL,
251 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
252 .tda9887_conf = TDA9887_PRESENT,
253 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800254 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800255 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800256 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300257 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800258 .amux = 0,
259 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800260 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300261 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800262 .amux = 1,
263 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800264 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300265 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800266 .amux = 1,
267 }},
268 },
269 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
270 .name = "Leadtek Winfast USB II",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800271 .is_em2800 = 1,
272 .vchannels = 3,
273 .norm = VIDEO_MODE_PAL,
274 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
275 .tda9887_conf = TDA9887_PRESENT,
276 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800277 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800278 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800279 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300280 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800281 .amux = 0,
282 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800283 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300284 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800285 .amux = 1,
286 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800287 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300288 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800289 .amux = 1,
290 }},
291 },
292 [EM2800_BOARD_KWORLD_USB2800] = {
293 .name = "Kworld USB2800",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800294 .is_em2800 = 1,
295 .vchannels = 3,
296 .norm = VIDEO_MODE_PAL,
297 .tuner_type = TUNER_PHILIPS_ATSC,
298 .tda9887_conf = TDA9887_PRESENT,
299 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800300 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800301 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800302 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300303 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800304 .amux = 0,
305 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800306 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300307 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800308 .amux = 1,
309 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800310 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300311 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800312 .amux = 1,
313 }},
314 },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800315 [EM2820_BOARD_PINNACLE_DVC_90] = {
316 .name = "Pinnacle Dazzle DVC 90",
317 .vchannels = 3,
318 .norm = VIDEO_MODE_PAL,
319 .has_tuner = 0,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800320 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800321 .input = {{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800322 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300323 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800324 .amux = 1,
325 },{
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800326 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300327 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800328 .amux = 1,
329 }},
330 },
Sascha Sommer43625592007-11-03 15:05:07 -0300331 [EM2800_BOARD_VGEAR_POCKETTV] = {
332 .name = "V-Gear PocketTV",
333 .is_em2800 = 1,
334 .vchannels = 3,
335 .norm = VIDEO_MODE_PAL,
336 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
337 .tda9887_conf = TDA9887_PRESENT,
338 .has_tuner = 1,
339 .decoder = EM28XX_SAA7113,
340 .input = {{
341 .type = EM28XX_VMUX_TELEVISION,
342 .vmux = SAA7115_COMPOSITE2,
343 .amux = 0,
344 },{
345 .type = EM28XX_VMUX_COMPOSITE1,
346 .vmux = SAA7115_COMPOSITE0,
347 .amux = 1,
348 },{
349 .type = EM28XX_VMUX_SVIDEO,
350 .vmux = SAA7115_SVIDEO3,
351 .amux = 1,
352 }},
353 },
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300354 [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
355 .name = "Pixelview Prolink PlayTV USB 2.0",
356 .vchannels = 3,
357 .tda9887_conf = TDA9887_PRESENT,
358 .has_tuner = 1,
359 .decoder = EM28XX_SAA7113,
360 .input = {{
361 .type = EM28XX_VMUX_TELEVISION,
362 .vmux = SAA7115_COMPOSITE2,
363 .amux = 1,
364 },{
365 .type = EM28XX_VMUX_COMPOSITE1,
366 .vmux = SAA7115_COMPOSITE0,
367 .amux = 1,
368 },{
369 .type = EM28XX_VMUX_SVIDEO,
370 .vmux = SAA7115_SVIDEO3,
371 .amux = 1,
372 }},
373 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800374};
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800375const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800376
377/* table of devices that work with this driver */
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800378struct usb_device_id em28xx_id_table [] = {
Mauro Carvalho Chehab3dbd85b2007-11-03 08:07:07 -0300379 { USB_DEVICE(0xeb1a, 0x2750), .driver_info = EM2820_BOARD_UNKNOWN },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800380 { USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
Mauro Carvalho Chehab3dbd85b2007-11-03 08:07:07 -0300381 { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_UNKNOWN },
382 { USB_DEVICE(0xeb1a, 0x2821), .driver_info = EM2820_BOARD_UNKNOWN },
383 { USB_DEVICE(0xeb1a, 0x2860), .driver_info = EM2820_BOARD_UNKNOWN },
384 { USB_DEVICE(0xeb1a, 0x2861), .driver_info = EM2820_BOARD_UNKNOWN },
385 { USB_DEVICE(0xeb1a, 0x2870), .driver_info = EM2820_BOARD_UNKNOWN },
386 { USB_DEVICE(0xeb1a, 0x2881), .driver_info = EM2820_BOARD_UNKNOWN },
387 { USB_DEVICE(0xeb1a, 0x2883), .driver_info = EM2820_BOARD_UNKNOWN },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800388 { USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
389 { USB_DEVICE(0x2304, 0x0208), .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
390 { USB_DEVICE(0x2040, 0x4200), .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800391 { USB_DEVICE(0x2304, 0x0207), .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300392 { USB_DEVICE(0x2040, 0x6500), .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
Mauro Carvalho Chehab6c362c82007-10-29 23:36:12 -0300393 { USB_DEVICE(0x2040, 0x6513), .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300394 { USB_DEVICE(0x0ccd, 0x0042), .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
395 { USB_DEVICE(0x0ccd, 0x0047), .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800396 { },
397};
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300398MODULE_DEVICE_TABLE (usb, em28xx_id_table);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800399
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300400static struct em28xx_hash_table em28xx_hash [] = {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300401 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
402 { 0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF },
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300403};
404
405/* Since em28xx_pre_card_setup() requires a proper dev->model,
406 * this won't work for boards with generic PCI IDs
407 */
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200408void em28xx_pre_card_setup(struct em28xx *dev)
409{
410 /* request some modules */
411 switch(dev->model){
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300412 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
413 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
414 case EM2880_BOARD_TERRATEC_HYBRID_XS:
415 /* reset through GPIO? */
416 em28xx_write_regs_req(dev, 0x00, 0x08, "\x7d", 1);
417 break;
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200418 }
419}
420
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300421static int em28xx_tuner_callback(void *ptr, int command, int arg)
422{
423 int rc = 0;
424 struct em28xx *dev = ptr;
425
426 if (dev->tuner_type != TUNER_XC2028)
427 return 0;
428
429 switch (command) {
430 case XC2028_TUNER_RESET:
431 /* FIXME: This is device-dependent */
432 dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
433 dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
434
435 msleep(140);
436 break;
437 }
438 return rc;
439}
440
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300441static void em28xx_config_tuner (struct em28xx *dev)
442{
443 struct v4l2_priv_tun_config xc2028_cfg;
444 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300445 struct tuner_setup tun_setup;
446 struct v4l2_frequency f;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300447
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300448 if (!dev->has_tuner)
449 return;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300450
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300451 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
452 tun_setup.type = dev->tuner_type;
453 tun_setup.addr = dev->tuner_addr;
454 tun_setup.tuner_callback = em28xx_tuner_callback;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300455
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300456 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300457
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300458 if (dev->tuner_type == TUNER_XC2028) {
459 memset (&ctl, 0, sizeof(ctl));
460
461 ctl.fname = XC2028_DEFAULT_FIRMWARE;
462 ctl.max_len = 64;
463
464 xc2028_cfg.tuner = TUNER_XC2028;
465 xc2028_cfg.priv = &ctl;
466
467 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
468 }
469
470 /* configure tuner */
471 f.tuner = 0;
472 f.type = V4L2_TUNER_ANALOG_TV;
473 f.frequency = 9076; /* just a magic number */
474 dev->ctl_freq = f.frequency;
475 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
476}
477
478static int em28xx_hint_board(struct em28xx *dev)
479{
480 int i;
481
482 for (i = 0; i < ARRAY_SIZE(em28xx_hash); i++) {
483 if (dev->hash == em28xx_hash[i].hash) {
484 dev->model = em28xx_hash[i].model;
485 dev->tuner_type = em28xx_hash[i].tuner;
486
487 em28xx_errdev("Your board has no unique USB ID.\n");
488 em28xx_errdev("A hint were successfully done, "
489 "based on eeprom hash.\n");
490 em28xx_errdev("This method is not 100%% failproof.\n");
491 em28xx_errdev("If the board were missdetected, "
492 "please email this log to:\n");
493 em28xx_errdev("\tV4L Mailing List "
494 " <video4linux-list@redhat.com>\n");
495 em28xx_errdev("Board detected as %s\n",
496 em28xx_boards[dev->model].name);
497
498 return 0;
499 }
500 }
501 em28xx_errdev("Your board has no unique USB ID and thus need a "
502 "hint to be detected.\n");
503 em28xx_errdev("You may try to use card=<n> insmod option to "
504 "workaround that.\n");
505 em28xx_errdev("Please send an email with this log to:\n");
506 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
507 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
508
509 em28xx_errdev("Here is a list of valid choices for the card=<n>"
510 " insmod option:\n");
511 for (i = 0; i < em28xx_bcount; i++) {
512 em28xx_errdev(" card=%d -> %s\n",
513 i, em28xx_boards[i].name);
514 }
515 return -1;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300516}
517
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800518void em28xx_card_setup(struct em28xx *dev)
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800519{
520 /* request some modules */
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300521 switch (dev->model) {
522 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
523 {
524 struct tveeprom tv;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800525#ifdef CONFIG_MODULES
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300526 request_module("tveeprom");
527 request_module("ir-kbd-i2c");
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800528#endif
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300529 /* Call first TVeeprom */
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800530
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300531 dev->i2c_client.addr = 0xa0 >> 1;
532 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800533
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300534 dev->tuner_type = tv.tuner_type;
535 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
536 dev->i2s_speed = 2048000;
537 dev->has_msp34xx = 1;
538 }
539 break;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800540 }
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300541 case EM2820_BOARD_KWORLD_PVRTV2800RF:
542 /* GPIO enables sound on KWORLD PVR TV 2800RF */
543 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
544 break;
545 case EM2820_BOARD_UNKNOWN:
546 case EM2800_BOARD_UNKNOWN:
547 em28xx_hint_board(dev);
548 }
549
550 dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
551 dev->has_tuner = em28xx_boards[dev->model].has_tuner;
552 dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
553 dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
554 dev->decoder = em28xx_boards[dev->model].decoder;
555 dev->video_inputs = em28xx_boards[dev->model].vchannels;
556
557 if (tuner >= 0)
558 dev->tuner_type = tuner;
559
560#ifdef CONFIG_MODULES
561 /* request some modules */
562 if (dev->has_msp34xx)
563 request_module("msp3400");
564 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
565 request_module("saa7115");
566 if (dev->decoder == EM28XX_TVP5150)
567 request_module("tvp5150");
568 if (dev->has_tuner)
569 request_module("tuner");
570#endif
571
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300572 em28xx_config_tuner (dev);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800573}