diff options
author | Antti Palosaari <crope@iki.fi> | 2008-05-17 22:05:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:06:17 -0400 |
commit | a51e34dd6080d8d5c9e95a4e0292cd4cb889a61b (patch) | |
tree | 4b876d181bc6a375b6f81a170ef0dddda3d4e47b | |
parent | 139dfeb2611ce92dec4c6b77297d209748340a21 (diff) |
V4L/DVB (7914): Anysee: driver for Anysee DVB-T/C receiver
- driver for Anysee DVB-T/C receiver
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/dvb/dvb-usb/Kconfig | 9 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/Makefile | 3 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/anysee.c | 555 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/anysee.h | 304 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-ids.h | 2 |
5 files changed, 873 insertions, 0 deletions
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index f00a0eb40420..3f7b9b6326b3 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
@@ -241,3 +241,12 @@ config DVB_USB_AF9005_REMOTE | |||
241 | Say Y here to support the default remote control decoding for the | 241 | Say Y here to support the default remote control decoding for the |
242 | Afatech AF9005 based receiver. | 242 | Afatech AF9005 based receiver. |
243 | 243 | ||
244 | config DVB_USB_ANYSEE | ||
245 | tristate "Anysee DVB-T/C USB2.0 support" | ||
246 | depends on DVB_USB | ||
247 | select DVB_MT352 if !DVB_FE_CUSTOMISE | ||
248 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE | ||
249 | select DVB_TDA10023 if !DVB_FE_CUSTOMISE | ||
250 | help | ||
251 | Say Y here to support the Anysee E30, Anysee E30 Plus or | ||
252 | Anysee E30 C Plus DVB USB2.0 receiver. | ||
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile index c6511a6c0ab8..44c11e45e564 100644 --- a/drivers/media/dvb/dvb-usb/Makefile +++ b/drivers/media/dvb/dvb-usb/Makefile | |||
@@ -61,6 +61,9 @@ obj-$(CONFIG_DVB_USB_AF9005) += dvb-usb-af9005.o | |||
61 | dvb-usb-af9005-remote-objs = af9005-remote.o | 61 | dvb-usb-af9005-remote-objs = af9005-remote.o |
62 | obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o | 62 | obj-$(CONFIG_DVB_USB_AF9005_REMOTE) += dvb-usb-af9005-remote.o |
63 | 63 | ||
64 | dvb-usb-anysee-objs = anysee.o | ||
65 | obj-$(CONFIG_DVB_USB_ANYSEE) += dvb-usb-anysee.o | ||
66 | |||
64 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | 67 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ |
65 | # due to tuner-xc3028 | 68 | # due to tuner-xc3028 |
66 | EXTRA_CFLAGS += -Idrivers/media/common/tuners | 69 | EXTRA_CFLAGS += -Idrivers/media/common/tuners |
diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c new file mode 100644 index 000000000000..dada92a14cf3 --- /dev/null +++ b/drivers/media/dvb/dvb-usb/anysee.c | |||
@@ -0,0 +1,555 @@ | |||
1 | /* | ||
2 | * DVB USB Linux driver for Anysee E30 DVB-C & DVB-T USB2.0 receiver | ||
3 | * | ||
4 | * Copyright (C) 2007 Antti Palosaari <crope@iki.fi> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | * | ||
20 | * TODO: | ||
21 | * - add smart card reader support for Conditional Access (CA) | ||
22 | * | ||
23 | * Card reader in Anysee is nothing more than ISO 7816 card reader. | ||
24 | * There is no hardware CAM in any Anysee device sold. | ||
25 | * In my understanding it should be implemented by making own module | ||
26 | * for ISO 7816 card reader, like dvb_ca_en50221 is implented. This | ||
27 | * module registers serial interface that can be used to comminicate | ||
28 | * with any ISO 7816 smart card. | ||
29 | * | ||
30 | * Any help according to implement serial smart card reader support | ||
31 | * is highly welcome! | ||
32 | */ | ||
33 | |||
34 | #include "anysee.h" | ||
35 | #include "tda1002x.h" | ||
36 | #include "mt352.h" | ||
37 | #include "mt352_priv.h" | ||
38 | #include "zl10353.h" | ||
39 | |||
40 | /* debug */ | ||
41 | static int dvb_usb_anysee_debug; | ||
42 | module_param_named(debug, dvb_usb_anysee_debug, int, 0644); | ||
43 | MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); | ||
44 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
45 | |||
46 | struct mutex anysee_usb_mutex; | ||
47 | |||
48 | static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, | ||
49 | u8 *rbuf, u8 rlen) | ||
50 | { | ||
51 | struct anysee_state *state = d->priv; | ||
52 | int act_len, ret; | ||
53 | u8 buf[64]; | ||
54 | |||
55 | if (slen > sizeof(buf)) | ||
56 | slen = sizeof(buf); | ||
57 | memcpy(&buf[0], sbuf, slen); | ||
58 | buf[60] = state->seq++; | ||
59 | |||
60 | if (mutex_lock_interruptible(&anysee_usb_mutex) < 0) | ||
61 | return -EAGAIN; | ||
62 | |||
63 | /* We need receive one message more after dvb_usb_generic_rw due | ||
64 | to weird transaction flow, which is 1 x send + 2 x receive. */ | ||
65 | ret = dvb_usb_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf), 0); | ||
66 | |||
67 | if (!ret) { | ||
68 | /* receive 2nd answer */ | ||
69 | ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, | ||
70 | d->props.generic_bulk_ctrl_endpoint), buf, sizeof(buf), | ||
71 | &act_len, 2000); | ||
72 | if (ret) | ||
73 | err("%s: recv bulk message failed: %d", __func__, ret); | ||
74 | else { | ||
75 | deb_xfer("<<< "); | ||
76 | debug_dump(buf, act_len, deb_xfer); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | /* read request, copy returned data to return buf */ | ||
81 | if (!ret && rbuf && rlen) | ||
82 | memcpy(rbuf, buf, rlen); | ||
83 | |||
84 | mutex_unlock(&anysee_usb_mutex); | ||
85 | |||
86 | return ret; | ||
87 | } | ||
88 | |||
89 | static int anysee_read_reg(struct dvb_usb_device *d, u16 reg, u8 *val) | ||
90 | { | ||
91 | u8 buf[] = {CMD_REG_READ, reg >> 8, reg & 0xff, 0x01}; | ||
92 | int ret; | ||
93 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), val, 1); | ||
94 | deb_info("%s: reg:%04x val:%02x\n", __func__, reg, *val); | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | static int anysee_write_reg(struct dvb_usb_device *d, u16 reg, u8 val) | ||
99 | { | ||
100 | u8 buf[] = {CMD_REG_WRITE, reg >> 8, reg & 0xff, 0x01, val}; | ||
101 | deb_info("%s: reg:%04x val:%02x\n", __func__, reg, val); | ||
102 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); | ||
103 | } | ||
104 | |||
105 | static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id) | ||
106 | { | ||
107 | u8 buf[] = {CMD_GET_HW_INFO}; | ||
108 | return anysee_ctrl_msg(d, buf, sizeof(buf), id, 3); | ||
109 | } | ||
110 | |||
111 | static int anysee_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | ||
112 | { | ||
113 | u8 buf[] = {CMD_STREAMING_CTRL, (u8)onoff, 0x00}; | ||
114 | deb_info("%s: onoff:%02x\n", __func__, onoff); | ||
115 | return anysee_ctrl_msg(adap->dev, buf, sizeof(buf), NULL, 0); | ||
116 | } | ||
117 | |||
118 | static int anysee_led_ctrl(struct dvb_usb_device *d, u8 mode, u8 interval) | ||
119 | { | ||
120 | u8 buf[] = {CMD_LED_AND_IR_CTRL, 0x01, mode, interval}; | ||
121 | deb_info("%s: state:%02x interval:%02x\n", __func__, mode, interval); | ||
122 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); | ||
123 | } | ||
124 | |||
125 | static int anysee_ir_ctrl(struct dvb_usb_device *d, u8 onoff) | ||
126 | { | ||
127 | u8 buf[] = {CMD_LED_AND_IR_CTRL, 0x02, onoff}; | ||
128 | deb_info("%s: onoff:%02x\n", __func__, onoff); | ||
129 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); | ||
130 | } | ||
131 | |||
132 | static int anysee_init(struct dvb_usb_device *d) | ||
133 | { | ||
134 | int ret; | ||
135 | /* LED light */ | ||
136 | ret = anysee_led_ctrl(d, 0x01, 0x03); | ||
137 | if (ret) | ||
138 | return ret; | ||
139 | |||
140 | /* enable IR */ | ||
141 | ret = anysee_ir_ctrl(d, 1); | ||
142 | if (ret) | ||
143 | return ret; | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | /* I2C */ | ||
149 | static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, | ||
150 | int num) | ||
151 | { | ||
152 | struct dvb_usb_device *d = i2c_get_adapdata(adap); | ||
153 | int ret, inc, i = 0; | ||
154 | |||
155 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) | ||
156 | return -EAGAIN; | ||
157 | |||
158 | while (i < num) { | ||
159 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { | ||
160 | u8 buf[6]; | ||
161 | buf[0] = CMD_I2C_READ; | ||
162 | buf[1] = msg[i].addr + 1; | ||
163 | buf[2] = msg[i].buf[0]; | ||
164 | buf[3] = 0x00; | ||
165 | buf[4] = 0x00; | ||
166 | buf[5] = 0x01; | ||
167 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), msg[i+1].buf, | ||
168 | msg[i+1].len); | ||
169 | inc = 2; | ||
170 | } else { | ||
171 | u8 buf[4+msg[i].len]; | ||
172 | buf[0] = CMD_I2C_WRITE; | ||
173 | buf[1] = msg[i].addr; | ||
174 | buf[2] = msg[i].len; | ||
175 | buf[3] = 0x01; | ||
176 | memcpy(&buf[4], msg[i].buf, msg[i].len); | ||
177 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); | ||
178 | inc = 1; | ||
179 | } | ||
180 | if (ret) | ||
181 | return ret; | ||
182 | |||
183 | i += inc; | ||
184 | } | ||
185 | |||
186 | mutex_unlock(&d->i2c_mutex); | ||
187 | |||
188 | return i; | ||
189 | } | ||
190 | |||
191 | static u32 anysee_i2c_func(struct i2c_adapter *adapter) | ||
192 | { | ||
193 | return I2C_FUNC_I2C; | ||
194 | } | ||
195 | |||
196 | static struct i2c_algorithm anysee_i2c_algo = { | ||
197 | .master_xfer = anysee_master_xfer, | ||
198 | .functionality = anysee_i2c_func, | ||
199 | }; | ||
200 | |||
201 | static int anysee_mt352_demod_init(struct dvb_frontend *fe) | ||
202 | { | ||
203 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 }; | ||
204 | static u8 reset [] = { RESET, 0x80 }; | ||
205 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; | ||
206 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 }; | ||
207 | static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 }; | ||
208 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; | ||
209 | |||
210 | mt352_write(fe, clock_config, sizeof(clock_config)); | ||
211 | udelay(200); | ||
212 | mt352_write(fe, reset, sizeof(reset)); | ||
213 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); | ||
214 | |||
215 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); | ||
216 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); | ||
217 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); | ||
218 | |||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | /* Callbacks for DVB USB */ | ||
223 | static struct tda10023_config anysee_tda10023_config = { | ||
224 | .demod_address = 0x1a, | ||
225 | .invert = 0, | ||
226 | .xtal = 16000000, | ||
227 | .pll_m = 11, | ||
228 | .pll_p = 3, | ||
229 | .pll_n = 1, | ||
230 | .deltaf = 0xfed6, | ||
231 | }; | ||
232 | |||
233 | static struct mt352_config anysee_mt352_config = { | ||
234 | .demod_address = 0x1e, | ||
235 | .demod_init = anysee_mt352_demod_init, | ||
236 | }; | ||
237 | |||
238 | static struct zl10353_config anysee_zl10353_config = { | ||
239 | .demod_address = 0x1e, | ||
240 | .parallel_ts = 1, | ||
241 | }; | ||
242 | |||
243 | static int anysee_frontend_attach(struct dvb_usb_adapter *adap) | ||
244 | { | ||
245 | int ret; | ||
246 | struct anysee_state *state = adap->dev->priv; | ||
247 | u8 hw_info[3]; | ||
248 | u8 io_d; /* IO port D */ | ||
249 | |||
250 | /* check which hardware we have | ||
251 | We must do this call two times to get reliable values (hw bug). */ | ||
252 | ret = anysee_get_hw_info(adap->dev, hw_info); | ||
253 | if (ret) | ||
254 | return ret; | ||
255 | ret = anysee_get_hw_info(adap->dev, hw_info); | ||
256 | if (ret) | ||
257 | return ret; | ||
258 | |||
259 | /* Meaning of these info bytes are guessed. */ | ||
260 | info("firmware version:%d.%d.%d hardware id:%d", | ||
261 | 0, hw_info[1], hw_info[2], hw_info[0]); | ||
262 | |||
263 | ret = anysee_read_reg(adap->dev, 0xb0, &io_d); /* IO port D */ | ||
264 | if (ret) | ||
265 | return ret; | ||
266 | deb_info("%s: IO port D:%02x\n", __func__, io_d); | ||
267 | |||
268 | /* Select demod using trial and error method. */ | ||
269 | |||
270 | /* Try to attach demodulator in following order: | ||
271 | model demod hw firmware | ||
272 | 1. E30 MT352 02 0.2.1 | ||
273 | 2. E30 ZL10353 02 0.2.1 | ||
274 | 3. E30 Plus ZL10353 06 0.1.0 | ||
275 | 4. E30C Plus TDA10023 0a 0.1.0 | ||
276 | E30C Plus TDA10023 0f 0.1.2 (not working) | ||
277 | */ | ||
278 | |||
279 | /* Zarlink MT352 DVB-T demod inside of Samsung DNOS404ZH102A NIM */ | ||
280 | adap->fe = dvb_attach(mt352_attach, &anysee_mt352_config, | ||
281 | &adap->dev->i2c_adap); | ||
282 | if (adap->fe != NULL) { | ||
283 | state->tuner = DVB_PLL_THOMSON_DTT7579; | ||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | /* Zarlink ZL10353 DVB-T demod inside of Samsung DNOS404ZH103A NIM */ | ||
288 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, | ||
289 | &adap->dev->i2c_adap); | ||
290 | if (adap->fe != NULL) { | ||
291 | state->tuner = DVB_PLL_THOMSON_DTT7579; | ||
292 | return 0; | ||
293 | } | ||
294 | |||
295 | /* connect demod on IO port D for TDA10023 & ZL10353 */ | ||
296 | ret = anysee_write_reg(adap->dev, 0xb0, 0x25); | ||
297 | if (ret) | ||
298 | return ret; | ||
299 | |||
300 | /* Zarlink ZL10353 DVB-T demod inside of Samsung DNOS404ZH103A NIM */ | ||
301 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, | ||
302 | &adap->dev->i2c_adap); | ||
303 | if (adap->fe != NULL) { | ||
304 | state->tuner = DVB_PLL_THOMSON_DTT7579; | ||
305 | return 0; | ||
306 | } | ||
307 | |||
308 | /* known not working (E30C Plus v0.1.2) */ | ||
309 | if (hw_info[0] == 0x0f) { | ||
310 | info("this version of Anysee is not supported yet"); | ||
311 | /* return IO port D to init value for safe */ | ||
312 | ret = anysee_write_reg(adap->dev, 0xb0, io_d); | ||
313 | return -ENODEV; | ||
314 | } | ||
315 | |||
316 | /* Philips TDA10023 DVB-C demod */ | ||
317 | adap->fe = dvb_attach(tda10023_attach, &anysee_tda10023_config, | ||
318 | &adap->dev->i2c_adap, 0x48); | ||
319 | if (adap->fe != NULL) { | ||
320 | state->tuner = DVB_PLL_SAMSUNG_DTOS403IH102A; | ||
321 | return 0; | ||
322 | } | ||
323 | |||
324 | /* return IO port D to init value for safe */ | ||
325 | ret = anysee_write_reg(adap->dev, 0xb0, io_d); | ||
326 | if (ret) | ||
327 | return ret; | ||
328 | |||
329 | err("Unkown Anysee version: %02x %02x %02x. "\ | ||
330 | "Please report the <linux-dvb@linuxtv.org>.", | ||
331 | hw_info[0], hw_info[1], hw_info[2]); | ||
332 | |||
333 | return -ENODEV; | ||
334 | } | ||
335 | |||
336 | static int anysee_tuner_attach(struct dvb_usb_adapter *adap) | ||
337 | { | ||
338 | struct anysee_state *state = adap->dev->priv; | ||
339 | deb_info("%s: \n", __func__); | ||
340 | |||
341 | switch (state->tuner) { | ||
342 | case DVB_PLL_THOMSON_DTT7579: | ||
343 | /* Thomson dtt7579 (not sure) PLL inside of: | ||
344 | Samsung DNOS404ZH102A NIM | ||
345 | Samsung DNOS404ZH103A NIM */ | ||
346 | dvb_attach(dvb_pll_attach, adap->fe, 0x61, | ||
347 | NULL, DVB_PLL_THOMSON_DTT7579); | ||
348 | break; | ||
349 | case DVB_PLL_SAMSUNG_DTOS403IH102A: | ||
350 | /* Unknown PLL inside of Samsung DTOS403IH102A tuner module */ | ||
351 | dvb_attach(dvb_pll_attach, adap->fe, 0xc0, | ||
352 | &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); | ||
353 | break; | ||
354 | } | ||
355 | |||
356 | return 0; | ||
357 | } | ||
358 | |||
359 | static int anysee_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | ||
360 | { | ||
361 | u8 buf[] = {CMD_GET_IR_CODE}; | ||
362 | struct dvb_usb_rc_key *keymap = d->props.rc_key_map; | ||
363 | u8 ircode[2]; | ||
364 | int i, ret; | ||
365 | |||
366 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), &ircode[0], 2); | ||
367 | if (ret) | ||
368 | return ret; | ||
369 | |||
370 | *event = 0; | ||
371 | *state = REMOTE_NO_KEY_PRESSED; | ||
372 | |||
373 | for (i = 0; i < d->props.rc_key_map_size; i++) { | ||
374 | if (keymap[i].custom == ircode[0] && | ||
375 | keymap[i].data == ircode[1]) { | ||
376 | *event = keymap[i].event; | ||
377 | *state = REMOTE_KEY_PRESSED; | ||
378 | return 0; | ||
379 | } | ||
380 | } | ||
381 | return 0; | ||
382 | } | ||
383 | |||
384 | static struct dvb_usb_rc_key anysee_rc_keys[] = { | ||
385 | { 0x01, 0x00, KEY_0 }, | ||
386 | { 0x01, 0x01, KEY_1 }, | ||
387 | { 0x01, 0x02, KEY_2 }, | ||
388 | { 0x01, 0x03, KEY_3 }, | ||
389 | { 0x01, 0x04, KEY_4 }, | ||
390 | { 0x01, 0x05, KEY_5 }, | ||
391 | { 0x01, 0x06, KEY_6 }, | ||
392 | { 0x01, 0x07, KEY_7 }, | ||
393 | { 0x01, 0x08, KEY_8 }, | ||
394 | { 0x01, 0x09, KEY_9 }, | ||
395 | { 0x01, 0x0a, KEY_POWER }, | ||
396 | { 0x01, 0x0b, KEY_DOCUMENTS }, /* * */ | ||
397 | { 0x01, 0x19, KEY_FAVORITES }, | ||
398 | { 0x01, 0x20, KEY_SLEEP }, | ||
399 | { 0x01, 0x21, KEY_MODE }, /* 4:3 / 16:9 select */ | ||
400 | { 0x01, 0x22, KEY_ZOOM }, | ||
401 | { 0x01, 0x47, KEY_TEXT }, | ||
402 | { 0x01, 0x16, KEY_TV }, /* TV / radio select */ | ||
403 | { 0x01, 0x1e, KEY_LANGUAGE }, /* Second Audio Program */ | ||
404 | { 0x01, 0x1a, KEY_SUBTITLE }, | ||
405 | { 0x01, 0x1b, KEY_CAMERA }, /* screenshot */ | ||
406 | { 0x01, 0x42, KEY_MUTE }, | ||
407 | { 0x01, 0x0e, KEY_MENU }, | ||
408 | { 0x01, 0x0f, KEY_EPG }, | ||
409 | { 0x01, 0x17, KEY_INFO }, | ||
410 | { 0x01, 0x10, KEY_EXIT }, | ||
411 | { 0x01, 0x13, KEY_VOLUMEUP }, | ||
412 | { 0x01, 0x12, KEY_VOLUMEDOWN }, | ||
413 | { 0x01, 0x11, KEY_CHANNELUP }, | ||
414 | { 0x01, 0x14, KEY_CHANNELDOWN }, | ||
415 | { 0x01, 0x15, KEY_OK }, | ||
416 | { 0x01, 0x1d, KEY_RED }, | ||
417 | { 0x01, 0x1f, KEY_GREEN }, | ||
418 | { 0x01, 0x1c, KEY_YELLOW }, | ||
419 | { 0x01, 0x44, KEY_BLUE }, | ||
420 | { 0x01, 0x0c, KEY_SHUFFLE }, /* snapshot */ | ||
421 | { 0x01, 0x48, KEY_STOP }, | ||
422 | { 0x01, 0x50, KEY_PLAY }, | ||
423 | { 0x01, 0x51, KEY_PAUSE }, | ||
424 | { 0x01, 0x49, KEY_RECORD }, | ||
425 | { 0x01, 0x18, KEY_PREVIOUS }, /* |<< */ | ||
426 | { 0x01, 0x0d, KEY_NEXT }, /* >>| */ | ||
427 | { 0x01, 0x24, KEY_PROG1 }, /* F1 */ | ||
428 | { 0x01, 0x25, KEY_PROG2 }, /* F2 */ | ||
429 | }; | ||
430 | |||
431 | /* DVB USB Driver stuff */ | ||
432 | static struct dvb_usb_device_properties anysee_properties; | ||
433 | |||
434 | static int anysee_probe(struct usb_interface *intf, | ||
435 | const struct usb_device_id *id) | ||
436 | { | ||
437 | struct dvb_usb_device *d; | ||
438 | struct usb_host_interface *alt; | ||
439 | int ret; | ||
440 | |||
441 | mutex_init(&anysee_usb_mutex); | ||
442 | |||
443 | /* There is one interface with two alternate settings. | ||
444 | Alternate setting 0 is for bulk transfer. | ||
445 | Alternate setting 1 is for isochronous transfer. | ||
446 | We use bulk transfer (alternate setting 0). */ | ||
447 | if (intf->num_altsetting < 1) | ||
448 | return -ENODEV; | ||
449 | |||
450 | ret = dvb_usb_device_init(intf, &anysee_properties, THIS_MODULE, &d, | ||
451 | adapter_nr); | ||
452 | if (ret) | ||
453 | return ret; | ||
454 | |||
455 | alt = usb_altnum_to_altsetting(intf, 0); | ||
456 | if (alt == NULL) { | ||
457 | deb_info("%s: no alt found!\n", __func__); | ||
458 | return -ENODEV; | ||
459 | } | ||
460 | |||
461 | ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, | ||
462 | alt->desc.bAlternateSetting); | ||
463 | if (ret) | ||
464 | return ret; | ||
465 | |||
466 | if (d) | ||
467 | ret = anysee_init(d); | ||
468 | |||
469 | return ret; | ||
470 | } | ||
471 | |||
472 | static struct usb_device_id anysee_table [] = { | ||
473 | { USB_DEVICE(USB_VID_CYPRESS, USB_PID_ANYSEE) }, | ||
474 | { USB_DEVICE(USB_VID_AMT, USB_PID_ANYSEE) }, | ||
475 | { } /* Terminating entry */ | ||
476 | }; | ||
477 | MODULE_DEVICE_TABLE(usb, anysee_table); | ||
478 | |||
479 | static struct dvb_usb_device_properties anysee_properties = { | ||
480 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
481 | |||
482 | .usb_ctrl = DEVICE_SPECIFIC, | ||
483 | |||
484 | .size_of_priv = sizeof(struct anysee_state), | ||
485 | |||
486 | .num_adapters = 1, | ||
487 | .adapter = { | ||
488 | { | ||
489 | .streaming_ctrl = anysee_streaming_ctrl, | ||
490 | .frontend_attach = anysee_frontend_attach, | ||
491 | .tuner_attach = anysee_tuner_attach, | ||
492 | .stream = { | ||
493 | .type = USB_BULK, | ||
494 | .count = 8, | ||
495 | .endpoint = 0x82, | ||
496 | .u = { | ||
497 | .bulk = { | ||
498 | .buffersize = 512, | ||
499 | } | ||
500 | } | ||
501 | }, | ||
502 | } | ||
503 | }, | ||
504 | |||
505 | .rc_key_map = anysee_rc_keys, | ||
506 | .rc_key_map_size = ARRAY_SIZE(anysee_rc_keys), | ||
507 | .rc_query = anysee_rc_query, | ||
508 | .rc_interval = 200, /* windows driver uses 500ms */ | ||
509 | |||
510 | .i2c_algo = &anysee_i2c_algo, | ||
511 | |||
512 | .generic_bulk_ctrl_endpoint = 1, | ||
513 | |||
514 | .num_device_descs = 1, | ||
515 | .devices = { | ||
516 | { | ||
517 | .name = "Anysee DVB USB2.0", | ||
518 | .cold_ids = {NULL}, | ||
519 | .warm_ids = {&anysee_table[0], | ||
520 | &anysee_table[1], NULL}, | ||
521 | }, | ||
522 | } | ||
523 | }; | ||
524 | |||
525 | static struct usb_driver anysee_driver = { | ||
526 | .name = "dvb_usb_anysee", | ||
527 | .probe = anysee_probe, | ||
528 | .disconnect = dvb_usb_device_exit, | ||
529 | .id_table = anysee_table, | ||
530 | }; | ||
531 | |||
532 | /* module stuff */ | ||
533 | static int __init anysee_module_init(void) | ||
534 | { | ||
535 | int ret; | ||
536 | |||
537 | ret = usb_register(&anysee_driver); | ||
538 | if (ret) | ||
539 | err("%s: usb_register failed. Error number %d", __func__, ret); | ||
540 | |||
541 | return ret; | ||
542 | } | ||
543 | |||
544 | static void __exit anysee_module_exit(void) | ||
545 | { | ||
546 | /* deregister this driver from the USB subsystem */ | ||
547 | usb_deregister(&anysee_driver); | ||
548 | } | ||
549 | |||
550 | module_init(anysee_module_init); | ||
551 | module_exit(anysee_module_exit); | ||
552 | |||
553 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); | ||
554 | MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0"); | ||
555 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/dvb-usb/anysee.h b/drivers/media/dvb/dvb-usb/anysee.h new file mode 100644 index 000000000000..48da3949ef0b --- /dev/null +++ b/drivers/media/dvb/dvb-usb/anysee.h | |||
@@ -0,0 +1,304 @@ | |||
1 | /* | ||
2 | * DVB USB Linux driver for Anysee E30 DVB-C & DVB-T USB2.0 receiver | ||
3 | * | ||
4 | * Copyright (C) 2007 Antti Palosaari <crope@iki.fi> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
19 | * | ||
20 | * TODO: | ||
21 | * - add smart card reader support for Conditional Access (CA) | ||
22 | * | ||
23 | * Card reader in Anysee is nothing more than ISO 7816 card reader. | ||
24 | * There is no hardware CAM in any Anysee device sold. | ||
25 | * In my understanding it should be implemented by making own module | ||
26 | * for ISO 7816 card reader, like dvb_ca_en50221 is implented. This | ||
27 | * module registers serial interface that can be used to comminicate | ||
28 | * with any ISO 7816 smart card. | ||
29 | * | ||
30 | * Any help according to implement serial smart card reader support | ||
31 | * is highly welcome! | ||
32 | */ | ||
33 | |||
34 | #ifndef _DVB_USB_ANYSEE_H_ | ||
35 | #define _DVB_USB_ANYSEE_H_ | ||
36 | |||
37 | #define DVB_USB_LOG_PREFIX "anysee" | ||
38 | #include "dvb-usb.h" | ||
39 | |||
40 | #define deb_info(args...) dprintk(dvb_usb_anysee_debug, 0x01, args) | ||
41 | #define deb_xfer(args...) dprintk(dvb_usb_anysee_debug, 0x02, args) | ||
42 | #define deb_rc(args...) dprintk(dvb_usb_anysee_debug, 0x04, args) | ||
43 | #define deb_reg(args...) dprintk(dvb_usb_anysee_debug, 0x08, args) | ||
44 | #define deb_i2c(args...) dprintk(dvb_usb_anysee_debug, 0x10, args) | ||
45 | #define deb_fw(args...) dprintk(dvb_usb_anysee_debug, 0x20, args) | ||
46 | |||
47 | enum cmd { | ||
48 | CMD_I2C_READ = 0x33, | ||
49 | CMD_I2C_WRITE = 0x31, | ||
50 | CMD_REG_READ = 0xb0, | ||
51 | CMD_REG_WRITE = 0xb1, | ||
52 | CMD_STREAMING_CTRL = 0x12, | ||
53 | CMD_LED_AND_IR_CTRL = 0x16, | ||
54 | CMD_GET_IR_CODE = 0x41, | ||
55 | CMD_GET_HW_INFO = 0x19, | ||
56 | CMD_SMARTCARD = 0x34, | ||
57 | }; | ||
58 | |||
59 | struct anysee_state { | ||
60 | u8 tuner; | ||
61 | u8 seq; | ||
62 | }; | ||
63 | |||
64 | #endif | ||
65 | |||
66 | /*************************************************************************** | ||
67 | * USB API description (reverse engineered) | ||
68 | *************************************************************************** | ||
69 | |||
70 | Transaction flow: | ||
71 | ================= | ||
72 | BULK[00001] >>> REQUEST PACKET 64 bytes | ||
73 | BULK[00081] <<< REPLY PACKET #1 64 bytes (PREVIOUS TRANSACTION REPLY) | ||
74 | BULK[00081] <<< REPLY PACKET #2 64 bytes (CURRENT TRANSACTION REPLY) | ||
75 | |||
76 | General reply packet(s) are always used if not own reply defined. | ||
77 | |||
78 | ============================================================================ | ||
79 | | 00-63 | GENERAL REPLY PACKET #1 (PREVIOUS REPLY) | ||
80 | ============================================================================ | ||
81 | | 00 | reply data (if any) from previous transaction | ||
82 | | | Just same reply packet as returned during previous transaction. | ||
83 | | | Needed only if reply is missed in previous transaction. | ||
84 | | | Just skip normally. | ||
85 | ---------------------------------------------------------------------------- | ||
86 | | 01-59 | don't care | ||
87 | ---------------------------------------------------------------------------- | ||
88 | | 60 | packet sequence number | ||
89 | ---------------------------------------------------------------------------- | ||
90 | | 61-63 | don't care | ||
91 | ---------------------------------------------------------------------------- | ||
92 | |||
93 | ============================================================================ | ||
94 | | 00-63 | GENERAL REPLY PACKET #2 (CURRENT REPLY) | ||
95 | ============================================================================ | ||
96 | | 00 | reply data (if any) | ||
97 | ---------------------------------------------------------------------------- | ||
98 | | 01-59 | don't care | ||
99 | ---------------------------------------------------------------------------- | ||
100 | | 60 | packet sequence number | ||
101 | ---------------------------------------------------------------------------- | ||
102 | | 61-63 | don't care | ||
103 | ---------------------------------------------------------------------------- | ||
104 | |||
105 | ============================================================================ | ||
106 | | 00-63 | I2C WRITE REQUEST PACKET | ||
107 | ============================================================================ | ||
108 | | 00 | 0x31 I2C write command | ||
109 | ---------------------------------------------------------------------------- | ||
110 | | 01 | i2c address | ||
111 | ---------------------------------------------------------------------------- | ||
112 | | 02 | data length | ||
113 | | | 0x02 (for typical I2C reg / val pair) | ||
114 | ---------------------------------------------------------------------------- | ||
115 | | 03 | 0x01 | ||
116 | ---------------------------------------------------------------------------- | ||
117 | | 04- | data | ||
118 | ---------------------------------------------------------------------------- | ||
119 | | -59 | don't care | ||
120 | ---------------------------------------------------------------------------- | ||
121 | | 60 | packet sequence number | ||
122 | ---------------------------------------------------------------------------- | ||
123 | | 61-63 | don't care | ||
124 | ---------------------------------------------------------------------------- | ||
125 | |||
126 | ============================================================================ | ||
127 | | 00-63 | I2C READ REQUEST PACKET | ||
128 | ============================================================================ | ||
129 | | 00 | 0x33 I2C read command | ||
130 | ---------------------------------------------------------------------------- | ||
131 | | 01 | i2c address + 1 | ||
132 | ---------------------------------------------------------------------------- | ||
133 | | 02 | register | ||
134 | ---------------------------------------------------------------------------- | ||
135 | | 03 | 0x00 | ||
136 | ---------------------------------------------------------------------------- | ||
137 | | 04 | 0x00 | ||
138 | ---------------------------------------------------------------------------- | ||
139 | | 05 | 0x01 | ||
140 | ---------------------------------------------------------------------------- | ||
141 | | 06-59 | don't care | ||
142 | ---------------------------------------------------------------------------- | ||
143 | | 60 | packet sequence number | ||
144 | ---------------------------------------------------------------------------- | ||
145 | | 61-63 | don't care | ||
146 | ---------------------------------------------------------------------------- | ||
147 | |||
148 | ============================================================================ | ||
149 | | 00-63 | USB CONTROLLER REGISTER WRITE REQUEST PACKET | ||
150 | ============================================================================ | ||
151 | | 00 | 0xb1 register write command | ||
152 | ---------------------------------------------------------------------------- | ||
153 | | 01-02 | register | ||
154 | ---------------------------------------------------------------------------- | ||
155 | | 03 | 0x01 | ||
156 | ---------------------------------------------------------------------------- | ||
157 | | 04 | value | ||
158 | ---------------------------------------------------------------------------- | ||
159 | | 05-59 | don't care | ||
160 | ---------------------------------------------------------------------------- | ||
161 | | 60 | packet sequence number | ||
162 | ---------------------------------------------------------------------------- | ||
163 | | 61-63 | don't care | ||
164 | ---------------------------------------------------------------------------- | ||
165 | |||
166 | ============================================================================ | ||
167 | | 00-63 | USB CONTROLLER REGISTER READ REQUEST PACKET | ||
168 | ============================================================================ | ||
169 | | 00 | 0xb0 register read command | ||
170 | ---------------------------------------------------------------------------- | ||
171 | | 01-02 | register | ||
172 | ---------------------------------------------------------------------------- | ||
173 | | 03 | 0x01 | ||
174 | ---------------------------------------------------------------------------- | ||
175 | | 04-59 | don't care | ||
176 | ---------------------------------------------------------------------------- | ||
177 | | 60 | packet sequence number | ||
178 | ---------------------------------------------------------------------------- | ||
179 | | 61-63 | don't care | ||
180 | ---------------------------------------------------------------------------- | ||
181 | |||
182 | ============================================================================ | ||
183 | | 00-63 | LED CONTROL REQUEST PACKET | ||
184 | ============================================================================ | ||
185 | | 00 | 0x16 LED and IR control command | ||
186 | ---------------------------------------------------------------------------- | ||
187 | | 01 | 0x01 (LED) | ||
188 | ---------------------------------------------------------------------------- | ||
189 | | 03 | 0x00 blink | ||
190 | | | 0x01 lights continuously | ||
191 | ---------------------------------------------------------------------------- | ||
192 | | 04 | blink interval | ||
193 | | | 0x00 fastest (looks like LED lights continuously) | ||
194 | | | 0xff slowest | ||
195 | ---------------------------------------------------------------------------- | ||
196 | | 05-59 | don't care | ||
197 | ---------------------------------------------------------------------------- | ||
198 | | 60 | packet sequence number | ||
199 | ---------------------------------------------------------------------------- | ||
200 | | 61-63 | don't care | ||
201 | ---------------------------------------------------------------------------- | ||
202 | |||
203 | ============================================================================ | ||
204 | | 00-63 | IR CONTROL REQUEST PACKET | ||
205 | ============================================================================ | ||
206 | | 00 | 0x16 LED and IR control command | ||
207 | ---------------------------------------------------------------------------- | ||
208 | | 01 | 0x02 (IR) | ||
209 | ---------------------------------------------------------------------------- | ||
210 | | 03 | 0x00 IR disabled | ||
211 | | | 0x01 IR enabled | ||
212 | ---------------------------------------------------------------------------- | ||
213 | | 04-59 | don't care | ||
214 | ---------------------------------------------------------------------------- | ||
215 | | 60 | packet sequence number | ||
216 | ---------------------------------------------------------------------------- | ||
217 | | 61-63 | don't care | ||
218 | ---------------------------------------------------------------------------- | ||
219 | |||
220 | ============================================================================ | ||
221 | | 00-63 | STREAMING CONTROL REQUEST PACKET | ||
222 | ============================================================================ | ||
223 | | 00 | 0x12 streaming control command | ||
224 | ---------------------------------------------------------------------------- | ||
225 | | 01 | 0x00 streaming disabled | ||
226 | | | 0x01 streaming enabled | ||
227 | ---------------------------------------------------------------------------- | ||
228 | | 02 | 0x00 | ||
229 | ---------------------------------------------------------------------------- | ||
230 | | 03-59 | don't care | ||
231 | ---------------------------------------------------------------------------- | ||
232 | | 60 | packet sequence number | ||
233 | ---------------------------------------------------------------------------- | ||
234 | | 61-63 | don't care | ||
235 | ---------------------------------------------------------------------------- | ||
236 | |||
237 | ============================================================================ | ||
238 | | 00-63 | REMOTE CONTROL REQUEST PACKET | ||
239 | ============================================================================ | ||
240 | | 00 | 0x41 remote control command | ||
241 | ---------------------------------------------------------------------------- | ||
242 | | 01-59 | don't care | ||
243 | ---------------------------------------------------------------------------- | ||
244 | | 60 | packet sequence number | ||
245 | ---------------------------------------------------------------------------- | ||
246 | | 61-63 | don't care | ||
247 | ---------------------------------------------------------------------------- | ||
248 | |||
249 | ============================================================================ | ||
250 | | 00-63 | REMOTE CONTROL REPLY PACKET | ||
251 | ============================================================================ | ||
252 | | 00 | 0x00 code not received | ||
253 | | | 0x01 code received | ||
254 | ---------------------------------------------------------------------------- | ||
255 | | 01 | remote control code | ||
256 | ---------------------------------------------------------------------------- | ||
257 | | 02-59 | don't care | ||
258 | ---------------------------------------------------------------------------- | ||
259 | | 60 | packet sequence number | ||
260 | ---------------------------------------------------------------------------- | ||
261 | | 61-63 | don't care | ||
262 | ---------------------------------------------------------------------------- | ||
263 | |||
264 | ============================================================================ | ||
265 | | 00-63 | GET HARDWARE INFO REQUEST PACKET | ||
266 | ============================================================================ | ||
267 | | 00 | 0x19 get hardware info command | ||
268 | ---------------------------------------------------------------------------- | ||
269 | | 01-59 | don't care | ||
270 | ---------------------------------------------------------------------------- | ||
271 | | 60 | packet sequence number | ||
272 | ---------------------------------------------------------------------------- | ||
273 | | 61-63 | don't care | ||
274 | ---------------------------------------------------------------------------- | ||
275 | |||
276 | ============================================================================ | ||
277 | | 00-63 | GET HARDWARE INFO REPLY PACKET | ||
278 | ============================================================================ | ||
279 | | 00 | hardware id | ||
280 | ---------------------------------------------------------------------------- | ||
281 | | 01-02 | firmware version | ||
282 | ---------------------------------------------------------------------------- | ||
283 | | 03-59 | don't care | ||
284 | ---------------------------------------------------------------------------- | ||
285 | | 60 | packet sequence number | ||
286 | ---------------------------------------------------------------------------- | ||
287 | | 61-63 | don't care | ||
288 | ---------------------------------------------------------------------------- | ||
289 | |||
290 | ============================================================================ | ||
291 | | 00-63 | SMART CARD READER PACKET | ||
292 | ============================================================================ | ||
293 | | 00 | 0x34 smart card reader command | ||
294 | ---------------------------------------------------------------------------- | ||
295 | | xx | | ||
296 | ---------------------------------------------------------------------------- | ||
297 | | xx-59 | don't care | ||
298 | ---------------------------------------------------------------------------- | ||
299 | | 60 | packet sequence number | ||
300 | ---------------------------------------------------------------------------- | ||
301 | | 61-63 | don't care | ||
302 | ---------------------------------------------------------------------------- | ||
303 | |||
304 | */ | ||
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index 34245d1b7dd9..e6b43fb3a148 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #define USB_VID_AFATECH 0x15a4 | 14 | #define USB_VID_AFATECH 0x15a4 |
15 | #define USB_VID_ALCOR_MICRO 0x058f | 15 | #define USB_VID_ALCOR_MICRO 0x058f |
16 | #define USB_VID_ALINK 0x05e3 | 16 | #define USB_VID_ALINK 0x05e3 |
17 | #define USB_VID_AMT 0x1c73 | ||
17 | #define USB_VID_ANCHOR 0x0547 | 18 | #define USB_VID_ANCHOR 0x0547 |
18 | #define USB_VID_ANSONIC 0x10b9 | 19 | #define USB_VID_ANSONIC 0x10b9 |
19 | #define USB_VID_ANUBIS_ELECTRONIC 0x10fd | 20 | #define USB_VID_ANUBIS_ELECTRONIC 0x10fd |
@@ -57,6 +58,7 @@ | |||
57 | #define USB_PID_AFATECH_AF9005 0x9020 | 58 | #define USB_PID_AFATECH_AF9005 0x9020 |
58 | #define USB_VID_ALINK_DTU 0xf170 | 59 | #define USB_VID_ALINK_DTU 0xf170 |
59 | #define USB_PID_ANSONIC_DVBT_USB 0x6000 | 60 | #define USB_PID_ANSONIC_DVBT_USB 0x6000 |
61 | #define USB_PID_ANYSEE 0x861f | ||
60 | #define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001 | 62 | #define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001 |
61 | #define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002 | 63 | #define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002 |
62 | #define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800 | 64 | #define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800 |