blob: aae7753fef117d1c7b12f0bcc30a83a1f018c19e [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
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -030045static unsigned int disable_ir;
46module_param(disable_ir, int, 0444);
47MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
48
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -030049struct em28xx_hash_table {
50 unsigned long hash;
51 unsigned int model;
52 unsigned int tuner;
53};
54
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -030055/* Boards supported by driver */
56
57#define EM2800_BOARD_UNKNOWN 0
58#define EM2820_BOARD_UNKNOWN 1
59#define EM2820_BOARD_TERRATEC_CINERGY_250 2
60#define EM2820_BOARD_PINNACLE_USB_2 3
61#define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4
62#define EM2820_BOARD_MSI_VOX_USB_2 5
63#define EM2800_BOARD_TERRATEC_CINERGY_200 6
64#define EM2800_BOARD_LEADTEK_WINFAST_USBII 7
65#define EM2800_BOARD_KWORLD_USB2800 8
66#define EM2820_BOARD_PINNACLE_DVC_90 9
67#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10
68#define EM2880_BOARD_TERRATEC_HYBRID_XS 11
69#define EM2820_BOARD_KWORLD_PVRTV2800RF 12
70#define EM2880_BOARD_TERRATEC_PRODIGY_XS 13
71#define EM2820_BOARD_PROLINK_PLAYTV_USB2 14
72#define EM2800_BOARD_VGEAR_POCKETTV 15
73#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16
74
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080075struct em28xx_board em28xx_boards[] = {
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080076 [EM2800_BOARD_UNKNOWN] = {
77 .name = "Unknown EM2800 video grabber",
78 .is_em2800 = 1,
79 .vchannels = 2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080080 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080081 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030082 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080083 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030084 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080085 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030086 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -080087 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -030088 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080089 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -030090 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080091 },
92 [EM2820_BOARD_UNKNOWN] = {
Mauro Carvalho Chehab3dbd85b2007-11-03 08:07:07 -030093 .name = "Unknown EM2750/28xx video grabber",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080094 .is_em2800 = 0,
Mauro Carvalho Chehabed086312008-01-24 06:59:20 -030095 .tuner_type = TUNER_ABSENT,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -080096 },
Markus Rechberger4d17d082006-02-07 06:25:39 -020097 [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
Markus Rechberger33ccaa32006-02-07 06:25:41 -020098 .name = "Kworld PVR TV 2800 RF",
Markus Rechberger4d17d082006-02-07 06:25:39 -020099 .is_em2800 = 0,
100 .vchannels = 2,
Mauro Carvalho Chehabed086312008-01-24 06:59:20 -0300101 .tuner_type = TUNER_TEMIC_PAL,
Markus Rechberger4d17d082006-02-07 06:25:39 -0200102 .tda9887_conf = TDA9887_PRESENT,
Markus Rechberger4d17d082006-02-07 06:25:39 -0200103 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300104 .input = { {
Markus Rechberger4d17d082006-02-07 06:25:39 -0200105 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300106 .vmux = SAA7115_COMPOSITE0,
Markus Rechberger4d17d082006-02-07 06:25:39 -0200107 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300108 }, {
Markus Rechberger4d17d082006-02-07 06:25:39 -0200109 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300110 .vmux = SAA7115_SVIDEO3,
Markus Rechberger4d17d082006-02-07 06:25:39 -0200111 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300112 } },
Markus Rechberger4d17d082006-02-07 06:25:39 -0200113 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800114 [EM2820_BOARD_TERRATEC_CINERGY_250] = {
115 .name = "Terratec Cinergy 250 USB",
116 .vchannels = 3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800117 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
118 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800119 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300120 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800121 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300122 .vmux = SAA7115_COMPOSITE2,
Markus Rechberger9475fb12006-02-27 00:07:34 -0300123 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300124 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800125 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300126 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800127 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300128 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800129 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300130 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800131 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300132 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800133 },
134 [EM2820_BOARD_PINNACLE_USB_2] = {
135 .name = "Pinnacle PCTV USB 2",
136 .vchannels = 3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800137 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
138 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800139 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300140 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800141 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300142 .vmux = SAA7115_COMPOSITE2,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800143 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300144 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800145 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300146 .vmux = SAA7115_COMPOSITE0,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800147 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300148 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800149 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300150 .vmux = SAA7115_SVIDEO3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800151 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300152 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800153 },
154 [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
155 .name = "Hauppauge WinTV USB 2",
156 .vchannels = 3,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800157 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300158 .tda9887_conf = TDA9887_PRESENT |
159 TDA9887_PORT1_ACTIVE|
160 TDA9887_PORT2_ACTIVE,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800161 .decoder = EM28XX_TVP5150,
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800162 .has_msp34xx = 1,
163 /*FIXME: S-Video not tested */
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300164 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800165 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300166 .vmux = TVP5150_COMPOSITE0,
Hans Verkuil2474ed42006-03-19 12:35:57 -0300167 .amux = MSP_INPUT_DEFAULT,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300168 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800169 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300170 .vmux = TVP5150_SVIDEO,
Hans Verkuil07151722006-04-01 18:03:23 -0300171 .amux = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
172 MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300173 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800174 },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300175 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
Aidan Thornton122d1582007-11-20 15:25:08 -0300176 .name = "Hauppauge WinTV HVR 900",
177 .vchannels = 3,
178 .tda9887_conf = TDA9887_PRESENT,
179 .tuner_type = TUNER_XC2028,
Mauro Carvalho Chehab5add9a62007-11-22 12:08:53 -0300180 .mts_firmware = 1,
Aidan Thornton122d1582007-11-20 15:25:08 -0300181 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300182 .input = { {
Aidan Thornton122d1582007-11-20 15:25:08 -0300183 .type = EM28XX_VMUX_TELEVISION,
184 .vmux = TVP5150_COMPOSITE0,
185 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300186 }, {
Aidan Thornton122d1582007-11-20 15:25:08 -0300187 .type = EM28XX_VMUX_COMPOSITE1,
188 .vmux = TVP5150_COMPOSITE1,
189 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300190 }, {
Aidan Thornton122d1582007-11-20 15:25:08 -0300191 .type = EM28XX_VMUX_SVIDEO,
192 .vmux = TVP5150_SVIDEO,
193 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300194 } },
Aidan Thornton122d1582007-11-20 15:25:08 -0300195 },
196 [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
Mauro Carvalho Chehab3abee532008-01-05 17:01:41 -0300197 .name = "Hauppauge WinTV HVR 950",
198 .vchannels = 3,
199 .tda9887_conf = TDA9887_PRESENT,
200 .tuner_type = TUNER_XC2028,
Mauro Carvalho Chehab3abee532008-01-05 17:01:41 -0300201 .mts_firmware = 1,
202 .has_12mhz_i2s = 1,
203 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300204 .input = { {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300205 .type = EM28XX_VMUX_TELEVISION,
206 .vmux = TVP5150_COMPOSITE0,
207 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300208 }, {
Mauro Carvalho Chehab7d070e22007-11-01 21:52:58 -0300209 .type = EM28XX_VMUX_COMPOSITE1,
210 .vmux = TVP5150_COMPOSITE1,
211 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300212 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300213 .type = EM28XX_VMUX_SVIDEO,
214 .vmux = TVP5150_SVIDEO,
215 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300216 } },
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300217
218 /* gpio's 4, 1, 0 */
219 .analog_gpio = 0x003d2d,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300220 },
221 [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
222 .name = "Terratec Hybrid XS",
223 .vchannels = 3,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300224 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300225 .tuner_type = TUNER_XC2028,
226 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300227 .input = { {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300228 .type = EM28XX_VMUX_TELEVISION,
229 .vmux = TVP5150_COMPOSITE0,
230 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300231 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300232 .type = EM28XX_VMUX_COMPOSITE1,
233 .vmux = TVP5150_COMPOSITE1,
234 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300235 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300236 .type = EM28XX_VMUX_SVIDEO,
237 .vmux = TVP5150_SVIDEO,
238 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300239 } },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300240 },
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300241 /* maybe there's a reason behind it why Terratec sells the Hybrid XS
242 as Prodigy XS with a different PID, let's keep it separated for now
243 maybe we'll need it lateron */
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300244 [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
245 .name = "Terratec Prodigy XS",
246 .vchannels = 3,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300247 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300248 .tuner_type = TUNER_XC2028,
249 .decoder = EM28XX_TVP5150,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300250 .input = { {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300251 .type = EM28XX_VMUX_TELEVISION,
252 .vmux = TVP5150_COMPOSITE0,
253 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300254 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300255 .type = EM28XX_VMUX_COMPOSITE1,
256 .vmux = TVP5150_COMPOSITE1,
257 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300258 }, {
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300259 .type = EM28XX_VMUX_SVIDEO,
260 .vmux = TVP5150_SVIDEO,
261 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300262 } },
Mauro Carvalho Chehab12466572007-10-24 11:08:20 -0300263 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800264 [EM2820_BOARD_MSI_VOX_USB_2] = {
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -0300265 .name = "MSI VOX USB 2.0",
266 .vchannels = 3,
267 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
268 .tda9887_conf = TDA9887_PRESENT |
269 TDA9887_PORT1_ACTIVE |
270 TDA9887_PORT2_ACTIVE,
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -0300271 .max_range_640_480 = 1,
272
273 .decoder = EM28XX_SAA7114,
274 .input = { {
275 .type = EM28XX_VMUX_TELEVISION,
276 .vmux = SAA7115_COMPOSITE4,
277 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300278 }, {
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -0300279 .type = EM28XX_VMUX_COMPOSITE1,
280 .vmux = SAA7115_COMPOSITE0,
281 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300282 }, {
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -0300283 .type = EM28XX_VMUX_SVIDEO,
284 .vmux = SAA7115_SVIDEO3,
285 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300286 } },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800287 },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800288 [EM2800_BOARD_TERRATEC_CINERGY_200] = {
289 .name = "Terratec Cinergy 200 USB",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800290 .is_em2800 = 1,
291 .vchannels = 3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800292 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
293 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800294 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300295 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800296 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300297 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800298 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300299 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800300 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300301 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800302 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300303 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800304 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300305 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800306 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300307 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800308 },
309 [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
310 .name = "Leadtek Winfast USB II",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800311 .is_em2800 = 1,
312 .vchannels = 3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800313 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
314 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800315 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300316 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800317 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300318 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800319 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300320 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800321 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300322 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800323 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300324 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800325 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300326 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800327 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300328 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800329 },
330 [EM2800_BOARD_KWORLD_USB2800] = {
331 .name = "Kworld USB2800",
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800332 .is_em2800 = 1,
333 .vchannels = 3,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800334 .tuner_type = TUNER_PHILIPS_ATSC,
335 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800336 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300337 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800338 .type = EM28XX_VMUX_TELEVISION,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300339 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800340 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300341 }, {
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 Chehab596d92d2005-11-08 21:37:24 -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 Chehab596d92d2005-11-08 21:37:24 -0800348 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300349 } },
Mauro Carvalho Chehab596d92d2005-11-08 21:37:24 -0800350 },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800351 [EM2820_BOARD_PINNACLE_DVC_90] = {
Aurelien Jarnoaec2aef2007-12-17 13:49:17 -0300352 .name = "Pinnacle Dazzle DVC 90/DVC 100",
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800353 .vchannels = 3,
Mauro Carvalho Chehabed086312008-01-24 06:59:20 -0300354 .tuner_type = TUNER_ABSENT,
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800355 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300356 .input = { {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800357 .type = EM28XX_VMUX_COMPOSITE1,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300358 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800359 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300360 }, {
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800361 .type = EM28XX_VMUX_SVIDEO,
Hans Verkuilc7c0b342006-04-02 13:35:00 -0300362 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800363 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300364 } },
Mauro Carvalho Chehab45632c42005-11-08 21:38:15 -0800365 },
Sascha Sommer43625592007-11-03 15:05:07 -0300366 [EM2800_BOARD_VGEAR_POCKETTV] = {
367 .name = "V-Gear PocketTV",
368 .is_em2800 = 1,
369 .vchannels = 3,
Sascha Sommer43625592007-11-03 15:05:07 -0300370 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
371 .tda9887_conf = TDA9887_PRESENT,
Sascha Sommer43625592007-11-03 15:05:07 -0300372 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300373 .input = { {
Sascha Sommer43625592007-11-03 15:05:07 -0300374 .type = EM28XX_VMUX_TELEVISION,
375 .vmux = SAA7115_COMPOSITE2,
376 .amux = 0,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300377 }, {
Sascha Sommer43625592007-11-03 15:05:07 -0300378 .type = EM28XX_VMUX_COMPOSITE1,
379 .vmux = SAA7115_COMPOSITE0,
380 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300381 }, {
Sascha Sommer43625592007-11-03 15:05:07 -0300382 .type = EM28XX_VMUX_SVIDEO,
383 .vmux = SAA7115_SVIDEO3,
384 .amux = 1,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300385 } },
Sascha Sommer43625592007-11-03 15:05:07 -0300386 },
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300387 [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
388 .name = "Pixelview Prolink PlayTV USB 2.0",
389 .vchannels = 3,
390 .tda9887_conf = TDA9887_PRESENT,
Mauro Carvalho Chehabed086312008-01-24 06:59:20 -0300391 .tuner_type = TUNER_YMEC_TVF_5533MF,
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300392 .decoder = EM28XX_SAA7113,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300393 .input = { {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300394 .type = EM28XX_VMUX_TELEVISION,
395 .vmux = SAA7115_COMPOSITE2,
Mauro Carvalho Chehab7463dda2008-02-05 22:29:26 -0300396 .amux = EM28XX_AMUX_LINE_IN,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300397 }, {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300398 .type = EM28XX_VMUX_COMPOSITE1,
399 .vmux = SAA7115_COMPOSITE0,
Mauro Carvalho Chehab7463dda2008-02-05 22:29:26 -0300400 .amux = EM28XX_AMUX_LINE_IN,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300401 }, {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300402 .type = EM28XX_VMUX_SVIDEO,
403 .vmux = SAA7115_SVIDEO3,
Mauro Carvalho Chehab7463dda2008-02-05 22:29:26 -0300404 .amux = EM28XX_AMUX_LINE_IN,
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300405 } },
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300406 },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800407};
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800408const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800409
410/* table of devices that work with this driver */
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800411struct usb_device_id em28xx_id_table [] = {
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300412 { USB_DEVICE(0xeb1a, 0x2750),
413 .driver_info = EM2820_BOARD_UNKNOWN },
414 { USB_DEVICE(0xeb1a, 0x2800),
415 .driver_info = EM2800_BOARD_UNKNOWN },
416 { USB_DEVICE(0xeb1a, 0x2820),
417 .driver_info = EM2820_BOARD_UNKNOWN },
418 { USB_DEVICE(0xeb1a, 0x2821),
419 .driver_info = EM2820_BOARD_UNKNOWN },
420 { USB_DEVICE(0xeb1a, 0x2860),
421 .driver_info = EM2820_BOARD_UNKNOWN },
422 { USB_DEVICE(0xeb1a, 0x2861),
423 .driver_info = EM2820_BOARD_UNKNOWN },
424 { USB_DEVICE(0xeb1a, 0x2870),
425 .driver_info = EM2820_BOARD_UNKNOWN },
426 { USB_DEVICE(0xeb1a, 0x2881),
427 .driver_info = EM2820_BOARD_UNKNOWN },
428 { USB_DEVICE(0xeb1a, 0x2883),
429 .driver_info = EM2820_BOARD_UNKNOWN },
430 { USB_DEVICE(0x0ccd, 0x0036),
431 .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
432 { USB_DEVICE(0x2304, 0x0208),
433 .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
434 { USB_DEVICE(0x2040, 0x4200),
435 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
Mauro Carvalho Chehab15b9bec2008-01-13 12:02:20 -0300436 { USB_DEVICE(0x2040, 0x4201),
437 .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300438 { USB_DEVICE(0x2304, 0x0207),
439 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
Aurelien Jarnoaec2aef2007-12-17 13:49:17 -0300440 { USB_DEVICE(0x2304, 0x021a),
441 .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300442 { USB_DEVICE(0x2040, 0x6500),
443 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
Luc Saillard427d20c2008-01-30 17:23:00 -0300444 { USB_DEVICE(0x2040, 0x6502),
445 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300446 { USB_DEVICE(0x2040, 0x6513),
447 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
448 { USB_DEVICE(0x0ccd, 0x0042),
449 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
450 { USB_DEVICE(0x0ccd, 0x0047),
451 .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800452 { },
453};
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300454MODULE_DEVICE_TABLE(usb, em28xx_id_table);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800455
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300456/* EEPROM hash table for devices with generic USB IDs */
457static struct em28xx_hash_table em28xx_eeprom_hash [] = {
Mauro Carvalho Chehabea4fd562007-11-03 21:21:57 -0300458 /* P/N: SA 60002070465 Tuner: TVF7533-MF */
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300459 {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300460};
461
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300462/* I2C devicelist hash table for devices with generic USB IDs */
Sascha Sommerfad7b952007-11-04 08:06:48 -0300463static struct em28xx_hash_table em28xx_i2c_hash[] = {
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300464 {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
465 {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
Sascha Sommerfad7b952007-11-04 08:06:48 -0300466};
467
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300468/* Since em28xx_pre_card_setup() requires a proper dev->model,
469 * this won't work for boards with generic PCI IDs
470 */
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200471void em28xx_pre_card_setup(struct em28xx *dev)
472{
473 /* request some modules */
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300474 switch (dev->model) {
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300475 case EM2880_BOARD_TERRATEC_PRODIGY_XS:
476 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
Aidan Thornton122d1582007-11-20 15:25:08 -0300477 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300478 case EM2880_BOARD_TERRATEC_HYBRID_XS:
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300479 em28xx_write_regs(dev, XCLK_REG, "\x27", 1);
480 em28xx_write_regs(dev, I2C_CLK_REG, "\x40", 1);
481 em28xx_write_regs(dev, 0x08, "\xff", 1);
482 em28xx_write_regs(dev, 0x04, "\x00", 1);
483 msleep(100);
484 em28xx_write_regs(dev, 0x04, "\x08", 1);
485 msleep(100);
486 em28xx_write_regs(dev, 0x08, "\xff", 1);
487 msleep(50);
488 em28xx_write_regs(dev, 0x08, "\x2d", 1);
489 msleep(50);
490 em28xx_write_regs(dev, 0x08, "\x3d", 1);
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300491 break;
Markus Rechbergera94e95b2006-01-23 17:11:10 -0200492 }
493}
494
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300495static int em28xx_tuner_callback(void *ptr, int command, int arg)
496{
497 int rc = 0;
498 struct em28xx *dev = ptr;
499
500 if (dev->tuner_type != TUNER_XC2028)
501 return 0;
502
503 switch (command) {
504 case XC2028_TUNER_RESET:
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300505 {
Mauro Carvalho Chehaba4950132008-01-06 09:45:44 -0300506 /* GPIO and initialization codes for analog TV and radio
507 This code should be complemented for DTV, since reset
508 codes are different.
509 */
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300510
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300511 dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
512 dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1);
513
Mauro Carvalho Chehaba4950132008-01-06 09:45:44 -0300514 if (dev->analog_gpio) {
515 char gpio0 = dev->analog_gpio & 0xff;
516 char gpio1 = (dev->analog_gpio >> 8) & 0xff;
517 char gpio4 = dev->analog_gpio >> 24;
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300518
Mauro Carvalho Chehaba4950132008-01-06 09:45:44 -0300519 if (gpio4) {
520 dev->em28xx_write_regs(dev, 0x04, &gpio4, 1);
521 msleep(140);
522 }
523
524 msleep(6);
525 dev->em28xx_write_regs(dev, 0x08, &gpio0, 1);
526 msleep(10);
527 dev->em28xx_write_regs(dev, 0x08, &gpio1, 1);
528 msleep(5);
529 }
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300530
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300531 break;
532 }
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300533 }
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300534 return rc;
535}
536
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300537static void em28xx_config_tuner(struct em28xx *dev)
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300538{
539 struct v4l2_priv_tun_config xc2028_cfg;
540 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300541 struct tuner_setup tun_setup;
542 struct v4l2_frequency f;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300543
Mauro Carvalho Chehabed086312008-01-24 06:59:20 -0300544 if (dev->tuner_type == TUNER_ABSENT)
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300545 return;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300546
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300547 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
548 tun_setup.type = dev->tuner_type;
549 tun_setup.addr = dev->tuner_addr;
550 tun_setup.tuner_callback = em28xx_tuner_callback;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300551
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300552 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300553
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300554 if (dev->tuner_type == TUNER_XC2028) {
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300555 memset(&ctl, 0, sizeof(ctl));
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300556
557 ctl.fname = XC2028_DEFAULT_FIRMWARE;
558 ctl.max_len = 64;
Mauro Carvalho Chehab5add9a62007-11-22 12:08:53 -0300559 ctl.mts = em28xx_boards[dev->model].mts_firmware;
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300560
561 xc2028_cfg.tuner = TUNER_XC2028;
562 xc2028_cfg.priv = &ctl;
563
564 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg);
565 }
566
567 /* configure tuner */
568 f.tuner = 0;
569 f.type = V4L2_TUNER_ANALOG_TV;
570 f.frequency = 9076; /* just a magic number */
571 dev->ctl_freq = f.frequency;
572 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
573}
574
575static int em28xx_hint_board(struct em28xx *dev)
576{
577 int i;
578
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300579 /* HINT method: EEPROM
580 *
581 * This method works only for boards with eeprom.
582 * Uses a hash of all eeprom bytes. The hash should be
583 * unique for a vendor/tuner pair.
584 * There are a high chance that tuners for different
585 * video standards produce different hashes.
586 */
587 for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
588 if (dev->hash == em28xx_eeprom_hash[i].hash) {
589 dev->model = em28xx_eeprom_hash[i].model;
590 dev->tuner_type = em28xx_eeprom_hash[i].tuner;
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300591
592 em28xx_errdev("Your board has no unique USB ID.\n");
593 em28xx_errdev("A hint were successfully done, "
594 "based on eeprom hash.\n");
595 em28xx_errdev("This method is not 100%% failproof.\n");
596 em28xx_errdev("If the board were missdetected, "
597 "please email this log to:\n");
598 em28xx_errdev("\tV4L Mailing List "
599 " <video4linux-list@redhat.com>\n");
600 em28xx_errdev("Board detected as %s\n",
601 em28xx_boards[dev->model].name);
602
603 return 0;
604 }
605 }
Sascha Sommerfad7b952007-11-04 08:06:48 -0300606
Mauro Carvalho Chehabd2ba0552007-11-04 08:32:42 -0300607 /* HINT method: I2C attached devices
608 *
609 * This method works for all boards.
610 * Uses a hash of i2c scanned devices.
611 * Devices with the same i2c attached chips will
612 * be considered equal.
613 * This method is less precise than the eeprom one.
614 */
615
Sascha Sommerfad7b952007-11-04 08:06:48 -0300616 /* user did not request i2c scanning => do it now */
617 if (!dev->i2c_hash)
618 em28xx_do_i2c_scan(dev);
619
620 for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
621 if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
622 dev->model = em28xx_i2c_hash[i].model;
623 dev->tuner_type = em28xx_i2c_hash[i].tuner;
624 em28xx_errdev("Your board has no unique USB ID.\n");
625 em28xx_errdev("A hint were successfully done, "
626 "based on i2c devicelist hash.\n");
627 em28xx_errdev("This method is not 100%% failproof.\n");
628 em28xx_errdev("If the board were missdetected, "
629 "please email this log to:\n");
630 em28xx_errdev("\tV4L Mailing List "
631 " <video4linux-list@redhat.com>\n");
632 em28xx_errdev("Board detected as %s\n",
633 em28xx_boards[dev->model].name);
634
635 return 0;
636 }
637 }
638
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300639 em28xx_errdev("Your board has no unique USB ID and thus need a "
640 "hint to be detected.\n");
641 em28xx_errdev("You may try to use card=<n> insmod option to "
642 "workaround that.\n");
643 em28xx_errdev("Please send an email with this log to:\n");
644 em28xx_errdev("\tV4L Mailing List <video4linux-list@redhat.com>\n");
645 em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
Sascha Sommerfad7b952007-11-04 08:06:48 -0300646 em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300647
648 em28xx_errdev("Here is a list of valid choices for the card=<n>"
649 " insmod option:\n");
650 for (i = 0; i < em28xx_bcount; i++) {
651 em28xx_errdev(" card=%d -> %s\n",
652 i, em28xx_boards[i].name);
653 }
654 return -1;
Mauro Carvalho Chehab882876b2007-10-29 11:33:18 -0300655}
656
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300657
658static void em28xx_set_model(struct em28xx *dev)
659{
660 dev->is_em2800 = em28xx_boards[dev->model].is_em2800;
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300661 dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx;
662 dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
663 dev->decoder = em28xx_boards[dev->model].decoder;
664 dev->video_inputs = em28xx_boards[dev->model].vchannels;
Mauro Carvalho Chehab74f38a82008-01-05 09:54:58 -0300665 dev->analog_gpio = em28xx_boards[dev->model].analog_gpio;
Mauro Carvalho Chehab3abee532008-01-05 17:01:41 -0300666 dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s;
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -0300667 dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480;
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300668}
669
Mauro Carvalho Chehabc8793b02008-01-13 15:42:17 -0300670/* ----------------------------------------------------------------------- */
671void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir)
672{
673 if (disable_ir) {
674 ir->get_key = NULL;
675 return ;
676 }
677
678 /* detect & configure */
679 switch (dev->model) {
680 case (EM2800_BOARD_UNKNOWN):
681 break;
682 case (EM2820_BOARD_UNKNOWN):
683 break;
684 case (EM2800_BOARD_TERRATEC_CINERGY_200):
685 case (EM2820_BOARD_TERRATEC_CINERGY_250):
686 ir->ir_codes = ir_codes_em_terratec;
687 ir->get_key = em28xx_get_key_terratec;
688 snprintf(ir->c.name, sizeof(ir->c.name),
689 "i2c IR (EM28XX Terratec)");
690 break;
691 case (EM2820_BOARD_PINNACLE_USB_2):
692 ir->ir_codes = ir_codes_pinnacle_grey;
693 ir->get_key = em28xx_get_key_pinnacle_usb_grey;
694 snprintf(ir->c.name, sizeof(ir->c.name),
695 "i2c IR (EM28XX Pinnacle PCTV)");
696 break;
697 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
698 ir->ir_codes = ir_codes_hauppauge_new;
699 ir->get_key = em28xx_get_key_em_haup;
700 snprintf(ir->c.name, sizeof(ir->c.name),
701 "i2c IR (EM2840 Hauppauge)");
702 break;
703 case (EM2820_BOARD_MSI_VOX_USB_2):
704 break;
705 case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
706 break;
707 case (EM2800_BOARD_KWORLD_USB2800):
708 break;
709 }
710}
711
Mauro Carvalho Chehab3acf2802005-11-08 21:38:27 -0800712void em28xx_card_setup(struct em28xx *dev)
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800713{
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300714 em28xx_set_model(dev);
715
716 dev->tuner_type = em28xx_boards[dev->model].tuner_type;
717
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800718 /* request some modules */
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300719 switch (dev->model) {
720 case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
Mauro Carvalho Chehab98ae1272007-11-05 09:30:39 -0300721 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
Aidan Thornton122d1582007-11-20 15:25:08 -0300722 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950:
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300723 {
724 struct tveeprom tv;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800725#ifdef CONFIG_MODULES
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300726 request_module("tveeprom");
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800727#endif
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300728 /* Call first TVeeprom */
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800729
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300730 dev->i2c_client.addr = 0xa0 >> 1;
731 tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800732
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300733 dev->tuner_type = tv.tuner_type;
Mauro Carvalho Chehabed086312008-01-24 06:59:20 -0300734
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300735 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
736 dev->i2s_speed = 2048000;
737 dev->has_msp34xx = 1;
738 }
Mauro Carvalho Chehab98ae1272007-11-05 09:30:39 -0300739#ifdef CONFIG_MODULES
740 if (tv.has_ir)
741 request_module("ir-kbd-i2c");
742#endif
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300743 break;
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800744 }
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300745 case EM2820_BOARD_KWORLD_PVRTV2800RF:
746 /* GPIO enables sound on KWORLD PVR TV 2800RF */
747 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf9", 1);
748 break;
749 case EM2820_BOARD_UNKNOWN:
750 case EM2800_BOARD_UNKNOWN:
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300751 if (!em28xx_hint_board(dev))
752 em28xx_set_model(dev);
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300753 }
754
Mauro Carvalho Chehabf8b60302007-11-05 08:42:55 -0300755 /* Allow override tuner type by a module parameter */
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300756 if (tuner >= 0)
757 dev->tuner_type = tuner;
758
759#ifdef CONFIG_MODULES
760 /* request some modules */
761 if (dev->has_msp34xx)
762 request_module("msp3400");
763 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
764 request_module("saa7115");
765 if (dev->decoder == EM28XX_TVP5150)
766 request_module("tvp5150");
Mauro Carvalho Chehabed086312008-01-24 06:59:20 -0300767 if (dev->tuner_type != TUNER_ABSENT)
Mauro Carvalho Chehab03910cc2007-11-03 21:20:59 -0300768 request_module("tuner");
769#endif
770
Mauro Carvalho Chehabc23f5942007-11-23 14:22:14 -0300771 em28xx_config_tuner(dev);
akpm@osdl.orga6c2ba22005-11-08 21:37:07 -0800772}