blob: fe0ee4518479f9f678f792d4cb9ba3bb4af1c9f5 [file] [log] [blame]
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08001/*
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -03002 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
3 video capture devices
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08004
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -08005 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
6 Markus Rechberger <mrechberger@gmail.com>
Mauro Carvalho Chehab2e7c6dc2006-04-03 07:53:40 -03007 Mauro Carvalho Chehab <mchehab@infradead.org>
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -08008 Sascha Sommer <saschasommer@freenet.de>
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -08009
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#include <linux/init.h>
26#include <linux/module.h>
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080027#include <linux/delay.h>
28#include <linux/i2c.h>
29#include <linux/usb.h>
30#include <media/tuner.h>
Hans Verkuil2474ed42006-03-19 12:35:57 -030031#include <media/msp3400.h>
Hans Verkuilc7c0b342006-04-02 13:35:00 -030032#include <media/saa7115.h>
33#include <media/tvp5150.h>
Mauro Carvalho Chehab1f6173e2005-11-08 21:37:16 -080034#include <media/tveeprom.h>
Hans Verkuil2474ed42006-03-19 12:35:57 -030035#include <media/audiochip.h>
Mauro Carvalho Chehab9bb13a62006-01-09 15:25:37 -020036#include <media/v4l2-common.h>
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080037
Mauro Carvalho Chehabf7abcd32005-11-08 21:38:25 -080038#include "em28xx.h"
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -030039#include "tuner-xc2028.h"
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080040
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -030041static int tuner = -1;
42module_param(tuner, int, 0444);
43MODULE_PARM_DESC(tuner, "tuner type");
44
45struct em28xx_hash_table {
46 unsigned long hash;
47 unsigned int model;
48 unsigned int tuner;
49};
50
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080051struct em28xx_board em28xx_boards[] = {
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080052 [EM2800_BOARD_UNKNOWN] = {
53 .name = "Unknown EM2800 video grabber",
54 .is_em2800 = 1,
55 .vchannels = 2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080056 .tda9887_conf = TDA9887_PRESENT,
57 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080058 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030059 .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,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030063 }, {
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,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030067 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080068 },
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,
Markus Rechberger4d17d082006-02-07 06:25:39 -020077 .tda9887_conf = TDA9887_PRESENT,
78 .has_tuner = 1,
79 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030080 .input = { {
Markus Rechberger4d17d082006-02-07 06:25:39 -020081 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030082 .vmux = SAA7115_COMPOSITE0,
Markus Rechberger4d17d082006-02-07 06:25:39 -020083 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030084 }, {
Markus Rechberger4d17d082006-02-07 06:25:39 -020085 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030086 .vmux = SAA7115_SVIDEO3,
Markus Rechberger4d17d082006-02-07 06:25:39 -020087 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030088 } },
Markus Rechberger4d17d082006-02-07 06:25:39 -020089 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080090 [EM2820_BOARD_TERRATEC_CINERGY_250] = {
91 .name = "Terratec Cinergy 250 USB",
92 .vchannels = 3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -080093 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
94 .tda9887_conf = TDA9887_PRESENT,
95 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080096 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030097 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080098 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030099 .vmux = SAA7115_COMPOSITE2,
Markus Rechberger9475fb12006-02-27 00:07:34 -0300100 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300101 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800102 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300103 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800104 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300105 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800106 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300107 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800108 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300109 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800110 },
111 [EM2820_BOARD_PINNACLE_USB_2] = {
112 .name = "Pinnacle PCTV USB 2",
113 .vchannels = 3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800114 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
115 .tda9887_conf = TDA9887_PRESENT,
116 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800117 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300118 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800119 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300120 .vmux = SAA7115_COMPOSITE2,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800121 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300122 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800123 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300124 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800125 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300126 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800127 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300128 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800129 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300130 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800131 },
132 [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
133 .name = "Hauppauge WinTV USB 2",
134 .vchannels = 3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800135 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300136 .tda9887_conf = TDA9887_PRESENT |
137 TDA9887_PORT1_ACTIVE|
138 TDA9887_PORT2_ACTIVE,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800139 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800140 .decoder = EM28XX_TVP5150,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800141 .has_msp34xx = 1,
142 /*FIXME: S-Video not tested */
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300143 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800144 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300145 .vmux = TVP5150_COMPOSITE0,
Hans Verkuil2474ed42006-03-19 12:35:57 -0300146 .amux = MSP_INPUT_DEFAULT,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300147 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800148 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300149 .vmux = TVP5150_SVIDEO,
Hans Verkuil07151722006-04-01 18:03:23 -0300150 .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
151 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300152 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800153 },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300154 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
Aidan Thornton122d1582007-11-20 15:25:08 -0300155 .name = "Hauppauge WinTV HVR 900",
156 .vchannels = 3,
157 .tda9887_conf = TDA9887_PRESENT,
158 .tuner_type = TUNER_XC2028,
159 .has_tuner = 1,
Mauro Carvalho Chehab5add9a62007-11-22 12:08:53 -0300160 .mts_firmware = 1,
Aidan Thornton122d1582007-11-20 15:25:08 -0300161 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300162 .input = { {
Aidan Thornton122d1582007-11-20 15:25:08 -0300163 .type = EM28XX_VMUX_TELEVISION,
164 .vmux = TVP5150_COMPOSITE0,
165 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300166 }, {
Aidan Thornton122d1582007-11-20 15:25:08 -0300167 .type = EM28XX_VMUX_COMPOSITE1,
168 .vmux = TVP5150_COMPOSITE1,
169 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300170 }, {
Aidan Thornton122d1582007-11-20 15:25:08 -0300171 .type = EM28XX_VMUX_SVIDEO,
172 .vmux = TVP5150_SVIDEO,
173 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300174 } },
Aidan Thornton122d1582007-11-20 15:25:08 -0300175 },
176 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
Mauro Carvalho Chehab3abee532008-01-05 17:01:41 -0300177 .name = "Hauppauge WinTV HVR 950",
178 .vchannels = 3,
179 .tda9887_conf = TDA9887_PRESENT,
180 .tuner_type = TUNER_XC2028,
181 .has_tuner = 1,
182 .mts_firmware = 1,
183 .has_12mhz_i2s = 1,
184 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300185 .input = { {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300186 .type = EM28XX_VMUX_TELEVISION,
187 .vmux = TVP5150_COMPOSITE0,
188 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300189 }, {
Mauro Carvalho Chehab7d070e22007-11-01 21:52:58 -0300190 .type = EM28XX_VMUX_COMPOSITE1,
191 .vmux = TVP5150_COMPOSITE1,
192 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300193 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300194 .type = EM28XX_VMUX_SVIDEO,
195 .vmux = TVP5150_SVIDEO,
196 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300197 } },
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300198
199 /* gpio's 4, 1, 0 */
200 .analog_gpio = 0x003d2d,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300201 },
202 [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
203 .name = "Terratec Hybrid XS",
204 .vchannels = 3,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300205 .tda9887_conf = TDA9887_PRESENT,
206 .has_tuner = 1,
207 .tuner_type = TUNER_XC2028,
208 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300209 .input = { {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300210 .type = EM28XX_VMUX_TELEVISION,
211 .vmux = TVP5150_COMPOSITE0,
212 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300213 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300214 .type = EM28XX_VMUX_COMPOSITE1,
215 .vmux = TVP5150_COMPOSITE1,
216 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300217 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300218 .type = EM28XX_VMUX_SVIDEO,
219 .vmux = TVP5150_SVIDEO,
220 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300221 } },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300222 },
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300223 /* maybe there's a reason behind it why Terratec sells the Hybrid XS
224 as Prodigy XS with a different PID, let's keep it separated for now
225 maybe we'll need it lateron */
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300226 [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
227 .name = "Terratec Prodigy XS",
228 .vchannels = 3,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300229 .tda9887_conf = TDA9887_PRESENT,
230 .has_tuner = 1,
231 .tuner_type = TUNER_XC2028,
232 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300233 .input = { {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300234 .type = EM28XX_VMUX_TELEVISION,
235 .vmux = TVP5150_COMPOSITE0,
236 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300237 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300238 .type = EM28XX_VMUX_COMPOSITE1,
239 .vmux = TVP5150_COMPOSITE1,
240 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300241 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300242 .type = EM28XX_VMUX_SVIDEO,
243 .vmux = TVP5150_SVIDEO,
244 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300245 } },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300246 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800247 [EM2820_BOARD_MSI_VOX_USB_2] = {
248 .name = "MSI VOX USB 2.0",
249 .vchannels = 3,
Markus Rechberger08eca132005-11-08 21:38:05 -0800250 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300251 .tda9887_conf = TDA9887_PRESENT |
252 TDA9887_PORT1_ACTIVE |
253 TDA9887_PORT2_ACTIVE,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800254 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800255 .decoder = EM28XX_SAA7114,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300256 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800257 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300258 .vmux = SAA7115_COMPOSITE4,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800259 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300260 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800261 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300262 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800263 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300264 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800265 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300266 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800267 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300268 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800269 },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800270 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
271 .name = "Terratec Cinergy 200 USB",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800272 .is_em2800 = 1,
273 .vchannels = 3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800274 .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 Chehabc23f5942007-11-23 14:22:14 -0300278 .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,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300282 }, {
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,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300286 }, {
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,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300290 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800291 },
292 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
293 .name = "Leadtek Winfast USB II",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800294 .is_em2800 = 1,
295 .vchannels = 3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800296 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
297 .tda9887_conf = TDA9887_PRESENT,
298 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800299 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300300 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800301 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300302 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800303 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300304 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800305 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300306 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800307 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300308 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800309 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300310 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800311 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300312 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800313 },
314 [EM2800_BOARD_KWORLD_USB2800] = {
315 .name = "Kworld USB2800",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800316 .is_em2800 = 1,
317 .vchannels = 3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800318 .tuner_type = TUNER_PHILIPS_ATSC,
319 .tda9887_conf = TDA9887_PRESENT,
320 .has_tuner = 1,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800321 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300322 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800323 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300324 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800325 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300326 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800327 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300328 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800329 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300330 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800331 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300332 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800333 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300334 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800335 },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800336 [EM2820_BOARD_PINNACLE_DVC_90] = {
Aurelien Jarnoaec2aef2007-12-17 13:49:17 -0300337 .name = "Pinnacle Dazzle DVC 90/DVC 100",
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800338 .vchannels = 3,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800339 .has_tuner = 0,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800340 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300341 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800342 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300343 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800344 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300345 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800346 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300347 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800348 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300349 } },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800350 },
Sascha Sommer43625592007-11-03 15:05:07 -0300351 [EM2800_BOARD_VGEAR_POCKETTV] = {
352 .name = "V-Gear PocketTV",
353 .is_em2800 = 1,
354 .vchannels = 3,
Sascha Sommer43625592007-11-03 15:05:07 -0300355 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
356 .tda9887_conf = TDA9887_PRESENT,
357 .has_tuner = 1,
358 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300359 .input = { {
Sascha Sommer43625592007-11-03 15:05:07 -0300360 .type = EM28XX_VMUX_TELEVISION,
361 .vmux = SAA7115_COMPOSITE2,
362 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300363 }, {
Sascha Sommer43625592007-11-03 15:05:07 -0300364 .type = EM28XX_VMUX_COMPOSITE1,
365 .vmux = SAA7115_COMPOSITE0,
366 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300367 }, {
Sascha Sommer43625592007-11-03 15:05:07 -0300368 .type = EM28XX_VMUX_SVIDEO,
369 .vmux = SAA7115_SVIDEO3,
370 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300371 } },
Sascha Sommer43625592007-11-03 15:05:07 -0300372 },
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300373 [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
374 .name = "Pixelview Prolink PlayTV USB 2.0",
375 .vchannels = 3,
376 .tda9887_conf = TDA9887_PRESENT,
377 .has_tuner = 1,
378 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300379 .input = { {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300380 .type = EM28XX_VMUX_TELEVISION,
381 .vmux = SAA7115_COMPOSITE2,
382 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300383 }, {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300384 .type = EM28XX_VMUX_COMPOSITE1,
385 .vmux = SAA7115_COMPOSITE0,
386 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300387 }, {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300388 .type = EM28XX_VMUX_SVIDEO,
389 .vmux = SAA7115_SVIDEO3,
390 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300391 } },
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300392 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800393};
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800394const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800395
396/* table of devices that work with this driver */
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800397struct usb_device_id em28xx_id_table [] = {
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300398 { USB_DEVICE(0xeb1a, 0x2750),
399 .driver_info = EM2820_BOARD_UNKNOWN },
400 { USB_DEVICE(0xeb1a, 0x2800),
401 .driver_info = EM2800_BOARD_UNKNOWN },
402 { USB_DEVICE(0xeb1a, 0x2820),
403 .driver_info = EM2820_BOARD_UNKNOWN },
404 { USB_DEVICE(0xeb1a, 0x2821),
405 .driver_info = EM2820_BOARD_UNKNOWN },
406 { USB_DEVICE(0xeb1a, 0x2860),
407 .driver_info = EM2820_BOARD_UNKNOWN },
408 { USB_DEVICE(0xeb1a, 0x2861),
409 .driver_info = EM2820_BOARD_UNKNOWN },
410 { USB_DEVICE(0xeb1a, 0x2870),
411 .driver_info = EM2820_BOARD_UNKNOWN },
412 { USB_DEVICE(0xeb1a, 0x2881),
413 .driver_info = EM2820_BOARD_UNKNOWN },
414 { USB_DEVICE(0xeb1a, 0x2883),
415 .driver_info = EM2820_BOARD_UNKNOWN },
416 { USB_DEVICE(0x0ccd, 0x0036),
417 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
418 { USB_DEVICE(0x2304, 0x0208),
419 .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
420 { USB_DEVICE(0x2040, 0x4200),
421 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
Mauro Carvalho Chehab15b9bec2008-01-13 12:02:20 -0300422 { USB_DEVICE(0x2040, 0x4201),
423 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300424 { USB_DEVICE(0x2304, 0x0207),
425 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
Aurelien Jarnoaec2aef2007-12-17 13:49:17 -0300426 { USB_DEVICE(0x2304, 0x021a),
427 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300428 { USB_DEVICE(0x2040, 0x6500),
429 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
430 { USB_DEVICE(0x2040, 0x6513),
431 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
432 { USB_DEVICE(0x0ccd, 0x0042),
433 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
434 { USB_DEVICE(0x0ccd, 0x0047),
435 .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800436 { },
437};
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300438MODULE_DEVICE_TABLE(usb, em28xx_id_table);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800439
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300440/* EEPROM hash table for devices with generic USB IDs */
441static struct em28xx_hash_table em28xx_eeprom_hash [] = {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300442 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300443 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300444};
445
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300446/* I2C devicelist hash table for devices with generic USB IDs */
Sascha Sommerfad7b952007-11-04 08:06:48 -0300447static struct em28xx_hash_table em28xx_i2c_hash[] = {
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300448 {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
449 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
Sascha Sommerfad7b952007-11-04 08:06:48 -0300450};
451
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300452/* Since em28xx_pre_card_setup() requires a proper dev->model,
453 * this won't work for boards with generic PCI IDs
454 */
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200455void em28xx_pre_card_setup(struct em28xx *dev)
456{
457 /* request some modules */
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300458 switch (dev->model) {
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300459 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
460 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
Aidan Thornton122d1582007-11-20 15:25:08 -0300461 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300462 case EM2880_BOARD_TERRATEC_HYBRID_XS:
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300463 em28xx_write_regs(dev, XCLK_REG, "\x27", 1);
464 em28xx_write_regs(dev, I2C_CLK_REG, "\x40", 1);
465 em28xx_write_regs(dev, 0x08, "\xff", 1);
466 em28xx_write_regs(dev, 0x04, "\x00", 1);
467 msleep(100);
468 em28xx_write_regs(dev, 0x04, "\x08", 1);
469 msleep(100);
470 em28xx_write_regs(dev, 0x08, "\xff", 1);
471 msleep(50);
472 em28xx_write_regs(dev, 0x08, "\x2d", 1);
473 msleep(50);
474 em28xx_write_regs(dev, 0x08, "\x3d", 1);
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300475 break;
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200476 }
477}
478
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300479static int em28xx_tuner_callback(void *ptr, int command, int arg)
480{
481 int rc = 0;
482 struct em28xx *dev = ptr;
483
484 if (dev->tuner_type != TUNER_XC2028)
485 return 0;
486
487 switch (command) {
488 case XC2028_TUNER_RESET:
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300489 {
Mauro Carvalho Chehaba4950132008-01-06 09:45:44 -0300490 /* GPIO and initialization codes for analog TV and radio
491 This code should be complemented for DTV, since reset
492 codes are different.
493 */
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300494
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300495 dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
496 dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
497
Mauro Carvalho Chehaba4950132008-01-06 09:45:44 -0300498 if (dev->analog_gpio) {
499 char gpio0 = dev->analog_gpio & 0xff;
500 char gpio1 = (dev->analog_gpio >> 8) & 0xff;
501 char gpio4 = dev->analog_gpio >> 24;
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300502
Mauro Carvalho Chehaba4950132008-01-06 09:45:44 -0300503 if (gpio4) {
504 dev->em28xx_write_regs(dev, 0x04, &gpio4, 1);
505 msleep(140);
506 }
507
508 msleep(6);
509 dev->em28xx_write_regs(dev, 0x08, &gpio0, 1);
510 msleep(10);
511 dev->em28xx_write_regs(dev, 0x08, &gpio1, 1);
512 msleep(5);
513 }
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300514
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300515 break;
516 }
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300517 }
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300518 return rc;
519}
520
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300521static void em28xx_config_tuner(struct em28xx *dev)
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300522{
523 struct v4l2_priv_tun_config xc2028_cfg;
524 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300525 struct tuner_setup tun_setup;
526 struct v4l2_frequency f;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300527
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300528 if (!dev->has_tuner)
529 return;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300530
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300531 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
532 tun_setup.type = dev->tuner_type;
533 tun_setup.addr = dev->tuner_addr;
534 tun_setup.tuner_callback = em28xx_tuner_callback;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300535
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300536 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300537
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300538 if (dev->tuner_type == TUNER_XC2028) {
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300539 memset(&ctl, 0, sizeof(ctl));
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300540
541 ctl.fname = XC2028_DEFAULT_FIRMWARE;
542 ctl.max_len = 64;
Mauro Carvalho Chehab5add9a62007-11-22 12:08:53 -0300543 ctl.mts = em28xx_boards[dev->model].mts_firmware;
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300544
545 xc2028_cfg.tuner = TUNER_XC2028;
546 xc2028_cfg.priv = &ctl;
547
548 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
549 }
550
551 /* configure tuner */
552 f.tuner = 0;
553 f.type = V4L2_TUNER_ANALOG_TV;
554 f.frequency = 9076; /* just a magic number */
555 dev->ctl_freq = f.frequency;
556 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
557}
558
559static int em28xx_hint_board(struct em28xx *dev)
560{
561 int i;
562
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300563 /* HINT method: EEPROM
564 *
565 * This method works only for boards with eeprom.
566 * Uses a hash of all eeprom bytes. The hash should be
567 * unique for a vendor/tuner pair.
568 * There are a high chance that tuners for different
569 * video standards produce different hashes.
570 */
571 for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
572 if (dev->hash == em28xx_eeprom_hash[i].hash) {
573 dev->model = em28xx_eeprom_hash[i].model;
574 dev->tuner_type = em28xx_eeprom_hash[i].tuner;
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300575
576 em28xx_errdev("Your board has no unique USB ID.\n");
577 em28xx_errdev("A hint were successfully done, "
578 "based on eeprom hash.\n");
579 em28xx_errdev("This method is not 100%% failproof.\n");
580 em28xx_errdev("If the board were missdetected, "
581 "please email this log to:\n");
582 em28xx_errdev("\tV4L Mailing List "
583 " <video4linux-list@redhat.com>\n");
584 em28xx_errdev("Board detected as %s\n",
585 em28xx_boards[dev->model].name);
586
587 return 0;
588 }
589 }
Sascha Sommerfad7b952007-11-04 08:06:48 -0300590
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300591 /* HINT method: I2C attached devices
592 *
593 * This method works for all boards.
594 * Uses a hash of i2c scanned devices.
595 * Devices with the same i2c attached chips will
596 * be considered equal.
597 * This method is less precise than the eeprom one.
598 */
599
Sascha Sommerfad7b952007-11-04 08:06:48 -0300600 /* user did not request i2c scanning => do it now */
601 if (!dev->i2c_hash)
602 em28xx_do_i2c_scan(dev);
603
604 for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
605 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
606 dev->model = em28xx_i2c_hash[i].model;
607 dev->tuner_type = em28xx_i2c_hash[i].tuner;
608 em28xx_errdev("Your board has no unique USB ID.\n");
609 em28xx_errdev("A hint were successfully done, "
610 "based on i2c devicelist hash.\n");
611 em28xx_errdev("This method is not 100%% failproof.\n");
612 em28xx_errdev("If the board were missdetected, "
613 "please email this log to:\n");
614 em28xx_errdev("\tV4L Mailing List "
615 " <video4linux-list@redhat.com>\n");
616 em28xx_errdev("Board detected as %s\n",
617 em28xx_boards[dev->model].name);
618
619 return 0;
620 }
621 }
622
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300623 em28xx_errdev("Your board has no unique USB ID and thus need a "
624 "hint to be detected.\n");
625 em28xx_errdev("You may try to use card=<n> insmod option to "
626 "workaround that.\n");
627 em28xx_errdev("Please send an email with this log to:\n");
628 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
629 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
Sascha Sommerfad7b952007-11-04 08:06:48 -0300630 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300631
632 em28xx_errdev("Here is a list of valid choices for the card=<n>"
633 " insmod option:\n");
634 for (i = 0; i < em28xx_bcount; i++) {
635 em28xx_errdev(" card=%d -> %s\n",
636 i, em28xx_boards[i].name);
637 }
638 return -1;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300639}
640
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300641
642static void em28xx_set_model(struct em28xx *dev)
643{
644 dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
645 dev->has_tuner = em28xx_boards[dev->model].has_tuner;
646 dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
647 dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
648 dev->decoder = em28xx_boards[dev->model].decoder;
649 dev->video_inputs = em28xx_boards[dev->model].vchannels;
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300650 dev->analog_gpio = em28xx_boards[dev->model].analog_gpio;
Mauro Carvalho Chehab3abee532008-01-05 17:01:41 -0300651 dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300652
653 if (!em28xx_boards[dev->model].has_tuner)
654 dev->tuner_type = UNSET;
655}
656
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800657void em28xx_card_setup(struct em28xx *dev)
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800658{
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300659 em28xx_set_model(dev);
660
661 dev->tuner_type = em28xx_boards[dev->model].tuner_type;
662
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800663 /* request some modules */
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300664 switch (dev->model) {
665 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
Mauro Carvalho Chehab98ae1272007-11-05 09:30:39 -0300666 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
Aidan Thornton122d1582007-11-20 15:25:08 -0300667 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300668 {
669 struct tveeprom tv;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800670#ifdef CONFIG_MODULES
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300671 request_module("tveeprom");
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800672#endif
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300673 /* Call first TVeeprom */
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800674
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300675 dev->i2c_client.addr = 0xa0 >> 1;
676 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800677
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300678 dev->tuner_type = tv.tuner_type;
679 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
680 dev->i2s_speed = 2048000;
681 dev->has_msp34xx = 1;
682 }
Mauro Carvalho Chehab98ae1272007-11-05 09:30:39 -0300683#ifdef CONFIG_MODULES
684 if (tv.has_ir)
685 request_module("ir-kbd-i2c");
686#endif
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300687 break;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800688 }
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300689 case EM2820_BOARD_KWORLD_PVRTV2800RF:
690 /* GPIO enables sound on KWORLD PVR TV 2800RF */
691 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
692 break;
693 case EM2820_BOARD_UNKNOWN:
694 case EM2800_BOARD_UNKNOWN:
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300695 if (!em28xx_hint_board(dev))
696 em28xx_set_model(dev);
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300697 }
698
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300699 /* Allow override tuner type by a module parameter */
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300700 if (tuner >= 0)
701 dev->tuner_type = tuner;
702
703#ifdef CONFIG_MODULES
704 /* request some modules */
705 if (dev->has_msp34xx)
706 request_module("msp3400");
707 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
708 request_module("saa7115");
709 if (dev->decoder == EM28XX_TVP5150)
710 request_module("tvp5150");
711 if (dev->has_tuner)
712 request_module("tuner");
713#endif
714
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300715 em28xx_config_tuner(dev);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800716}