blob: fb3829a73d2df0fa5ad8a70cb3161f387b448e9c [file] [log] [blame]
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001/*
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
Antti Palosaari9fdd9ca2008-06-11 11:43:19 -030026 * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This
27 * module registers serial interface that can be used to communicate
Antti Palosaaria51e34d2008-05-17 23:05:48 -030028 * 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"
Antti Palosaaria4e7c512012-06-14 04:56:09 -030035#include "dvb-pll.h"
Antti Palosaaria51e34d2008-05-17 23:05:48 -030036#include "tda1002x.h"
37#include "mt352.h"
38#include "mt352_priv.h"
39#include "zl10353.h"
Antti Palosaari72ffd2b2011-04-10 20:14:50 -030040#include "tda18212.h"
Antti Palosaarif0a53102011-04-27 21:11:59 -030041#include "cx24116.h"
Antti Palosaaribedbf3d2011-04-29 13:55:02 -030042#include "stv0900.h"
43#include "stv6110.h"
Antti Palosaarif0a53102011-04-27 21:11:59 -030044#include "isl6423.h"
Antti Palosaari608add82011-08-12 18:29:46 -030045#include "cxd2820r.h"
Antti Palosaaria51e34d2008-05-17 23:05:48 -030046
47/* debug */
48static int dvb_usb_anysee_debug;
49module_param_named(debug, dvb_usb_anysee_debug, int, 0644);
50MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS);
51DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
52
Akinobu Mitadec0c462008-10-29 21:16:04 -030053static DEFINE_MUTEX(anysee_usb_mutex);
Antti Palosaaria51e34d2008-05-17 23:05:48 -030054
55static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen,
56 u8 *rbuf, u8 rlen)
57{
Antti Palosaari05cd62e2012-06-18 19:39:02 -030058 struct anysee_state *state = d_to_priv(d);
Antti Palosaaricf427952012-01-21 11:19:29 -030059 int act_len, ret, i;
Antti Palosaaria51e34d2008-05-17 23:05:48 -030060 u8 buf[64];
61
Antti Palosaaria51e34d2008-05-17 23:05:48 -030062 memcpy(&buf[0], sbuf, slen);
63 buf[60] = state->seq++;
64
Antti Palosaaria4e7c512012-06-14 04:56:09 -030065 mutex_lock(&anysee_usb_mutex);
Antti Palosaaria51e34d2008-05-17 23:05:48 -030066
Antti Palosaari4048da22011-09-29 20:28:53 -030067 deb_xfer(">>> ");
68 debug_dump(buf, slen, deb_xfer);
69
Antti Palosaaria51e34d2008-05-17 23:05:48 -030070 /* We need receive one message more after dvb_usb_generic_rw due
71 to weird transaction flow, which is 1 x send + 2 x receive. */
Antti Palosaari1162c7b2012-06-20 20:27:42 -030072 ret = dvb_usbv2_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf));
Antti Palosaaricf427952012-01-21 11:19:29 -030073 if (ret)
74 goto error_unlock;
75
76 /* TODO FIXME: dvb_usb_generic_rw() fails rarely with error code -32
77 * (EPIPE, Broken pipe). Function supports currently msleep() as a
78 * parameter but I would not like to use it, since according to
79 * Documentation/timers/timers-howto.txt it should not be used such
80 * short, under < 20ms, sleeps. Repeating failed message would be
81 * better choice as not to add unwanted delays...
82 * Fixing that correctly is one of those or both;
83 * 1) use repeat if possible
84 * 2) add suitable delay
85 */
86
87 /* get answer, retry few times if error returned */
88 for (i = 0; i < 3; i++) {
Antti Palosaaria51e34d2008-05-17 23:05:48 -030089 /* receive 2nd answer */
90 ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev,
Antti Palosaaria4e7c512012-06-14 04:56:09 -030091 d->props->generic_bulk_ctrl_endpoint), buf, sizeof(buf),
Antti Palosaaria51e34d2008-05-17 23:05:48 -030092 &act_len, 2000);
Antti Palosaaricf427952012-01-21 11:19:29 -030093
94 if (ret) {
95 deb_info("%s: recv bulk message failed: %d",
96 __func__, ret);
97 } else {
Antti Palosaaria51e34d2008-05-17 23:05:48 -030098 deb_xfer("<<< ");
Antti Palosaari4048da22011-09-29 20:28:53 -030099 debug_dump(buf, rlen, deb_xfer);
100
101 if (buf[63] != 0x4f)
102 deb_info("%s: cmd failed\n", __func__);
Antti Palosaaricf427952012-01-21 11:19:29 -0300103
104 break;
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300105 }
106 }
107
Antti Palosaaricf427952012-01-21 11:19:29 -0300108 if (ret) {
109 /* all retries failed, it is fatal */
110 err("%s: recv bulk message failed: %d", __func__, ret);
111 goto error_unlock;
112 }
113
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300114 /* read request, copy returned data to return buf */
Antti Palosaaricf427952012-01-21 11:19:29 -0300115 if (rbuf && rlen)
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300116 memcpy(rbuf, buf, rlen);
117
Antti Palosaaricf427952012-01-21 11:19:29 -0300118error_unlock:
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300119 mutex_unlock(&anysee_usb_mutex);
120
121 return ret;
122}
123
124static int anysee_read_reg(struct dvb_usb_device *d, u16 reg, u8 *val)
125{
126 u8 buf[] = {CMD_REG_READ, reg >> 8, reg & 0xff, 0x01};
127 int ret;
128 ret = anysee_ctrl_msg(d, buf, sizeof(buf), val, 1);
129 deb_info("%s: reg:%04x val:%02x\n", __func__, reg, *val);
130 return ret;
131}
132
133static int anysee_write_reg(struct dvb_usb_device *d, u16 reg, u8 val)
134{
135 u8 buf[] = {CMD_REG_WRITE, reg >> 8, reg & 0xff, 0x01, val};
136 deb_info("%s: reg:%04x val:%02x\n", __func__, reg, val);
137 return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
138}
139
Antti Palosaari41f81f62011-04-10 17:53:52 -0300140/* write single register with mask */
141static int anysee_wr_reg_mask(struct dvb_usb_device *d, u16 reg, u8 val,
142 u8 mask)
143{
144 int ret;
145 u8 tmp;
146
147 /* no need for read if whole reg is written */
148 if (mask != 0xff) {
149 ret = anysee_read_reg(d, reg, &tmp);
150 if (ret)
151 return ret;
152
153 val &= mask;
154 tmp &= ~mask;
155 val |= tmp;
156 }
157
158 return anysee_write_reg(d, reg, val);
159}
160
Antti Palosaari05cd37d2011-09-05 23:33:04 -0300161/* read single register with mask */
162static int anysee_rd_reg_mask(struct dvb_usb_device *d, u16 reg, u8 *val,
163 u8 mask)
164{
165 int ret, i;
166 u8 tmp;
167
168 ret = anysee_read_reg(d, reg, &tmp);
169 if (ret)
170 return ret;
171
172 tmp &= mask;
173
174 /* find position of the first bit */
175 for (i = 0; i < 8; i++) {
176 if ((mask >> i) & 0x01)
177 break;
178 }
179 *val = tmp >> i;
180
181 return 0;
182}
183
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300184static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id)
185{
186 u8 buf[] = {CMD_GET_HW_INFO};
187 return anysee_ctrl_msg(d, buf, sizeof(buf), id, 3);
188}
189
Antti Palosaaria13a6e12012-06-26 00:04:33 -0300190static int anysee_streaming_ctrl(struct dvb_frontend *fe, int onoff)
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300191{
192 u8 buf[] = {CMD_STREAMING_CTRL, (u8)onoff, 0x00};
193 deb_info("%s: onoff:%02x\n", __func__, onoff);
Antti Palosaaria13a6e12012-06-26 00:04:33 -0300194 return anysee_ctrl_msg(fe_to_d(fe), buf, sizeof(buf), NULL, 0);
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300195}
196
197static int anysee_led_ctrl(struct dvb_usb_device *d, u8 mode, u8 interval)
198{
199 u8 buf[] = {CMD_LED_AND_IR_CTRL, 0x01, mode, interval};
200 deb_info("%s: state:%02x interval:%02x\n", __func__, mode, interval);
201 return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
202}
203
204static int anysee_ir_ctrl(struct dvb_usb_device *d, u8 onoff)
205{
206 u8 buf[] = {CMD_LED_AND_IR_CTRL, 0x02, onoff};
207 deb_info("%s: onoff:%02x\n", __func__, onoff);
208 return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
209}
210
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300211/* I2C */
212static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
213 int num)
214{
215 struct dvb_usb_device *d = i2c_get_adapdata(adap);
Mauro Carvalho Chehab902571a2008-12-29 19:02:24 -0300216 int ret = 0, inc, i = 0;
Antti Palosaari21d2e932011-05-24 06:04:08 -0300217 u8 buf[52]; /* 4 + 48 (I2C WR USB command header + I2C WR max) */
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300218
219 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
220 return -EAGAIN;
221
222 while (i < num) {
223 if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) {
Antti Palosaari21d2e932011-05-24 06:04:08 -0300224 if (msg[i].len > 2 || msg[i+1].len > 60) {
225 ret = -EOPNOTSUPP;
226 break;
227 }
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300228 buf[0] = CMD_I2C_READ;
Antti Palosaari7ea03d22011-04-09 20:50:07 -0300229 buf[1] = (msg[i].addr << 1) | 0x01;
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300230 buf[2] = msg[i].buf[0];
Antti Palosaari882b82c2011-04-12 19:49:25 -0300231 buf[3] = msg[i].buf[1];
232 buf[4] = msg[i].len-1;
Antti Palosaarib3e6a5a2011-04-09 21:00:51 -0300233 buf[5] = msg[i+1].len;
Antti Palosaari21d2e932011-05-24 06:04:08 -0300234 ret = anysee_ctrl_msg(d, buf, 6, msg[i+1].buf,
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300235 msg[i+1].len);
236 inc = 2;
237 } else {
Antti Palosaari21d2e932011-05-24 06:04:08 -0300238 if (msg[i].len > 48) {
239 ret = -EOPNOTSUPP;
240 break;
241 }
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300242 buf[0] = CMD_I2C_WRITE;
Antti Palosaari7ea03d22011-04-09 20:50:07 -0300243 buf[1] = (msg[i].addr << 1);
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300244 buf[2] = msg[i].len;
245 buf[3] = 0x01;
246 memcpy(&buf[4], msg[i].buf, msg[i].len);
Antti Palosaari21d2e932011-05-24 06:04:08 -0300247 ret = anysee_ctrl_msg(d, buf, 4 + msg[i].len, NULL, 0);
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300248 inc = 1;
249 }
250 if (ret)
Antti Palosaarie613f8f2008-08-11 10:36:43 -0300251 break;
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300252
253 i += inc;
254 }
255
256 mutex_unlock(&d->i2c_mutex);
257
Antti Palosaarie613f8f2008-08-11 10:36:43 -0300258 return ret ? ret : i;
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300259}
260
261static u32 anysee_i2c_func(struct i2c_adapter *adapter)
262{
263 return I2C_FUNC_I2C;
264}
265
266static struct i2c_algorithm anysee_i2c_algo = {
267 .master_xfer = anysee_master_xfer,
268 .functionality = anysee_i2c_func,
269};
270
271static int anysee_mt352_demod_init(struct dvb_frontend *fe)
272{
Antti Palosaariae3745f2009-09-16 19:50:25 -0300273 static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x28 };
274 static u8 reset[] = { RESET, 0x80 };
275 static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 };
276 static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0x20 };
277 static u8 gpp_ctl_cfg[] = { GPP_CTL, 0x33 };
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300278 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
279
280 mt352_write(fe, clock_config, sizeof(clock_config));
281 udelay(200);
282 mt352_write(fe, reset, sizeof(reset));
283 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
284
285 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
286 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
287 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
288
289 return 0;
290}
291
292/* Callbacks for DVB USB */
293static struct tda10023_config anysee_tda10023_config = {
Antti Palosaari7ea03d22011-04-09 20:50:07 -0300294 .demod_address = (0x1a >> 1),
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300295 .invert = 0,
296 .xtal = 16000000,
297 .pll_m = 11,
298 .pll_p = 3,
299 .pll_n = 1,
Antti Palosaari5ae2fca2008-06-09 22:58:22 -0300300 .output_mode = TDA10023_OUTPUT_MODE_PARALLEL_C,
301 .deltaf = 0xfeeb,
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300302};
303
304static struct mt352_config anysee_mt352_config = {
Antti Palosaari7ea03d22011-04-09 20:50:07 -0300305 .demod_address = (0x1e >> 1),
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300306 .demod_init = anysee_mt352_demod_init,
307};
308
309static struct zl10353_config anysee_zl10353_config = {
Antti Palosaari7ea03d22011-04-09 20:50:07 -0300310 .demod_address = (0x1e >> 1),
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300311 .parallel_ts = 1,
312};
313
Antti Palosaari1fd80702011-04-12 17:34:08 -0300314static struct zl10353_config anysee_zl10353_tda18212_config2 = {
315 .demod_address = (0x1e >> 1),
316 .parallel_ts = 1,
317 .disable_i2c_gate_ctrl = 1,
318 .no_tuner = 1,
319 .if2 = 41500,
320};
321
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300322static struct zl10353_config anysee_zl10353_tda18212_config = {
323 .demod_address = (0x18 >> 1),
324 .parallel_ts = 1,
325 .disable_i2c_gate_ctrl = 1,
326 .no_tuner = 1,
327 .if2 = 41500,
328};
329
330static struct tda10023_config anysee_tda10023_tda18212_config = {
331 .demod_address = (0x1a >> 1),
332 .xtal = 16000000,
333 .pll_m = 12,
334 .pll_p = 3,
335 .pll_n = 1,
Antti Palosaari05cd37d2011-09-05 23:33:04 -0300336 .output_mode = TDA10023_OUTPUT_MODE_PARALLEL_B,
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300337 .deltaf = 0xba02,
338};
339
340static struct tda18212_config anysee_tda18212_config = {
341 .i2c_address = (0xc0 >> 1),
342 .if_dvbt_6 = 4150,
343 .if_dvbt_7 = 4150,
344 .if_dvbt_8 = 4150,
345 .if_dvbc = 5000,
346};
347
Antti Palosaari608add82011-08-12 18:29:46 -0300348static struct tda18212_config anysee_tda18212_config2 = {
349 .i2c_address = 0x60 /* (0xc0 >> 1) */,
350 .if_dvbt_6 = 3550,
351 .if_dvbt_7 = 3700,
352 .if_dvbt_8 = 4150,
353 .if_dvbt2_6 = 3250,
354 .if_dvbt2_7 = 4000,
355 .if_dvbt2_8 = 4000,
356 .if_dvbc = 5000,
357};
358
Antti Palosaarif0a53102011-04-27 21:11:59 -0300359static struct cx24116_config anysee_cx24116_config = {
360 .demod_address = (0xaa >> 1),
361 .mpg_clk_pos_pol = 0x00,
362 .i2c_wr_max = 48,
363};
364
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300365static struct stv0900_config anysee_stv0900_config = {
366 .demod_address = (0xd0 >> 1),
367 .demod_mode = 0,
368 .xtal = 8000000,
369 .clkmode = 3,
370 .diseqc_mode = 2,
371 .tun1_maddress = 0,
372 .tun1_adc = 1, /* 1 Vpp */
373 .path1_mode = 3,
374};
375
376static struct stv6110_config anysee_stv6110_config = {
377 .i2c_address = (0xc0 >> 1),
378 .mclk = 16000000,
379 .clk_div = 1,
380};
381
Antti Palosaarif0a53102011-04-27 21:11:59 -0300382static struct isl6423_config anysee_isl6423_config = {
383 .current_max = SEC_CURRENT_800m,
384 .curlim = SEC_CURRENT_LIM_OFF,
385 .mod_extern = 1,
386 .addr = (0x10 >> 1),
387};
388
Antti Palosaari608add82011-08-12 18:29:46 -0300389static struct cxd2820r_config anysee_cxd2820r_config = {
390 .i2c_address = 0x6d, /* (0xda >> 1) */
391 .ts_mode = 0x38,
Antti Palosaari608add82011-08-12 18:29:46 -0300392};
393
Antti Palosaari41f81f62011-04-10 17:53:52 -0300394/*
395 * New USB device strings: Mfr=1, Product=2, SerialNumber=0
396 * Manufacturer: AMT.CO.KR
397 *
398 * E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=????????
399 * PCB: ?
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300400 * parts: DNOS404ZH102A(MT352, DTT7579(?))
Antti Palosaari41f81f62011-04-10 17:53:52 -0300401 *
Antti Palosaari05c46c02011-05-25 18:30:09 -0300402 * E30 VID=04b4 PID=861f HW=2 FW=2.1 "anysee-T(LP)"
403 * PCB: PCB 507T (rev1.61)
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300404 * parts: DNOS404ZH103A(ZL10353, DTT7579(?))
Antti Palosaari05c46c02011-05-25 18:30:09 -0300405 * OEA=0a OEB=00 OEC=00 OED=ff OEE=00
406 * IOA=45 IOB=ff IOC=00 IOD=ff IOE=00
Antti Palosaari41f81f62011-04-10 17:53:52 -0300407 *
408 * E30 Plus VID=04b4 PID=861f HW=6 FW=1.0 "anysee"
409 * PCB: 507CD (rev1.1)
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300410 * parts: DNOS404ZH103A(ZL10353, DTT7579(?)), CST56I01
Antti Palosaari05c46c02011-05-25 18:30:09 -0300411 * OEA=80 OEB=00 OEC=00 OED=ff OEE=fe
412 * IOA=4f IOB=ff IOC=00 IOD=06 IOE=01
Antti Palosaari41f81f62011-04-10 17:53:52 -0300413 * IOD[0] ZL10353 1=enabled
414 * IOA[7] TS 0=enabled
415 * tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not)
416 *
417 * E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)"
418 * PCB: 507DC (rev0.2)
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300419 * parts: TDA10023, DTOS403IH102B TM, CST56I01
Antti Palosaari05c46c02011-05-25 18:30:09 -0300420 * OEA=80 OEB=00 OEC=00 OED=ff OEE=fe
421 * IOA=4f IOB=ff IOC=00 IOD=26 IOE=01
Antti Palosaari41f81f62011-04-10 17:53:52 -0300422 * IOD[0] TDA10023 1=enabled
423 *
Antti Palosaarif0a53102011-04-27 21:11:59 -0300424 * E30 S2 Plus VID=04b4 PID=861f HW=11 FW=0.1 "anysee-S2(LP)"
425 * PCB: 507SI (rev2.1)
426 * parts: BS2N10WCC01(CX24116, CX24118), ISL6423, TDA8024
Antti Palosaari05c46c02011-05-25 18:30:09 -0300427 * OEA=80 OEB=00 OEC=ff OED=ff OEE=fe
428 * IOA=4d IOB=ff IOC=00 IOD=26 IOE=01
Antti Palosaarif0a53102011-04-27 21:11:59 -0300429 * IOD[0] CX24116 1=enabled
430 *
Antti Palosaari41f81f62011-04-10 17:53:52 -0300431 * E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
432 * PCB: 507FA (rev0.4)
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300433 * parts: TDA10023, DTOS403IH102B TM, TDA8024
Antti Palosaari05c46c02011-05-25 18:30:09 -0300434 * OEA=80 OEB=00 OEC=ff OED=ff OEE=ff
435 * IOA=4d IOB=ff IOC=00 IOD=00 IOE=c0
Antti Palosaari41f81f62011-04-10 17:53:52 -0300436 * IOD[5] TDA10023 1=enabled
437 * IOE[0] tuner 1=enabled
438 *
439 * E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
440 * PCB: 507FA (rev1.1)
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300441 * parts: ZL10353, TDA10023, DTOS403IH102B TM, TDA8024
Antti Palosaari05c46c02011-05-25 18:30:09 -0300442 * OEA=80 OEB=00 OEC=ff OED=ff OEE=ff
443 * IOA=4d IOB=ff IOC=00 IOD=00 IOE=c0
Antti Palosaari41f81f62011-04-10 17:53:52 -0300444 * DVB-C:
445 * IOD[5] TDA10023 1=enabled
446 * IOE[0] tuner 1=enabled
447 * DVB-T:
448 * IOD[0] ZL10353 1=enabled
449 * IOE[0] tuner 0=enabled
450 * tuner is behind ZL10353 I2C-gate
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300451 *
452 * E7 TC VID=1c73 PID=861f HW=18 FW=0.7 AMTCI=0.5 "anysee-E7TC(LP)"
453 * PCB: 508TC (rev0.6)
454 * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212)
Antti Palosaari05c46c02011-05-25 18:30:09 -0300455 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
456 * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4
Antti Palosaari70fc26f2011-04-12 20:17:11 -0300457 * IOA[7] TS 1=enabled
458 * IOE[4] TDA18212 1=enabled
459 * DVB-C:
460 * IOD[6] ZL10353 0=disabled
461 * IOD[5] TDA10023 1=enabled
462 * IOE[0] IF 1=enabled
463 * DVB-T:
464 * IOD[5] TDA10023 0=disabled
465 * IOD[6] ZL10353 1=enabled
466 * IOE[0] IF 0=enabled
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300467 *
468 * E7 S2 VID=1c73 PID=861f HW=19 FW=0.4 AMTCI=0.5 "anysee-E7S2(LP)"
469 * PCB: 508S2 (rev0.7)
470 * parts: DNBU10512IST(STV0903, STV6110), ISL6423
Antti Palosaari05c46c02011-05-25 18:30:09 -0300471 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
472 * IOA=4d IOB=00 IOC=c4 IOD=08 IOE=e4
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300473 * IOA[7] TS 1=enabled
474 * IOE[5] STV0903 1=enabled
475 *
Antti Palosaari608add82011-08-12 18:29:46 -0300476 * E7 T2C VID=1c73 PID=861f HW=20 FW=0.1 AMTCI=0.5 "anysee-E7T2C(LP)"
477 * PCB: 508T2C (rev0.3)
478 * parts: DNOQ44QCH106A(CXD2820R, TDA18212), TDA8024
479 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
480 * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4
481 * IOA[7] TS 1=enabled
482 * IOE[5] CXD2820R 1=enabled
483 *
Antti Palosaari8439e0d2011-05-24 07:57:34 -0300484 * E7 PTC VID=1c73 PID=861f HW=21 FW=0.1 AMTCI=?? "anysee-E7PTC(LP)"
485 * PCB: 508PTC (rev0.5)
486 * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212)
487 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
488 * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4
489 * IOA[7] TS 1=enabled
490 * IOE[4] TDA18212 1=enabled
491 * DVB-C:
492 * IOD[6] ZL10353 0=disabled
493 * IOD[5] TDA10023 1=enabled
494 * IOE[0] IF 1=enabled
495 * DVB-T:
496 * IOD[5] TDA10023 0=disabled
497 * IOD[6] ZL10353 1=enabled
498 * IOE[0] IF 0=enabled
Antti Palosaarifea3c392011-05-25 18:21:43 -0300499 *
Antti Palosaari608add82011-08-12 18:29:46 -0300500 * E7 PS2 VID=1c73 PID=861f HW=22 FW=0.1 AMTCI=?? "anysee-E7PS2(LP)"
Antti Palosaarifea3c392011-05-25 18:21:43 -0300501 * PCB: 508PS2 (rev0.4)
502 * parts: DNBU10512IST(STV0903, STV6110), ISL6423
503 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
504 * IOA=4d IOB=00 IOC=c4 IOD=08 IOE=e4
505 * IOA[7] TS 1=enabled
506 * IOE[5] STV0903 1=enabled
Antti Palosaari41f81f62011-04-10 17:53:52 -0300507 */
508
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300509static int anysee_read_config(struct dvb_usb_device *d)
510{
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300511 struct anysee_state *state = d_to_priv(d);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300512 int ret;
513 u8 hw_info[3];
514
515 /*
516 * Check which hardware we have.
517 * We must do this call two times to get reliable values (hw/fw bug).
518 */
519 ret = anysee_get_hw_info(d, hw_info);
520 if (ret)
521 goto error;
522
523 ret = anysee_get_hw_info(d, hw_info);
524 if (ret)
525 goto error;
526
527 /* Meaning of these info bytes are guessed. */
528 info("firmware version:%d.%d hardware id:%d",
529 hw_info[1], hw_info[2], hw_info[0]);
530
531 state->hw = hw_info[0];
532error:
533 return ret;
534}
Antti Palosaaribe943512011-09-05 22:10:05 -0300535
536/* external I2C gate used for DNOD44CDH086A(TDA18212) tuner module */
537static int anysee_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
538{
Antti Palosaaribe943512011-09-05 22:10:05 -0300539 /* enable / disable tuner access on IOE[4] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300540 return anysee_wr_reg_mask(fe_to_d(fe), REG_IOE, (enable << 4), 0x10);
Antti Palosaaribe943512011-09-05 22:10:05 -0300541}
542
Antti Palosaari449d1a02011-07-25 20:25:21 -0300543static int anysee_frontend_ctrl(struct dvb_frontend *fe, int onoff)
544{
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300545 struct anysee_state *state = fe_to_priv(fe);
546 struct dvb_usb_device *d = fe_to_d(fe);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300547 int ret;
548
549 deb_info("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff);
550
551 /* no frontend sleep control */
552 if (onoff == 0)
553 return 0;
554
555 switch (state->hw) {
556 case ANYSEE_HW_507FA: /* 15 */
557 /* E30 Combo Plus */
558 /* E30 C Plus */
559
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300560 if (fe->id == 0) {
Antti Palosaari449d1a02011-07-25 20:25:21 -0300561 /* disable DVB-T demod on IOD[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300562 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 0), 0x01);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300563 if (ret)
564 goto error;
565
566 /* enable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300567 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 5), 0x20);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300568 if (ret)
569 goto error;
570
571 /* enable DVB-C tuner on IOE[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300572 ret = anysee_wr_reg_mask(d, REG_IOE, (1 << 0), 0x01);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300573 if (ret)
574 goto error;
575 } else {
576 /* disable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300577 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 5), 0x20);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300578 if (ret)
579 goto error;
580
581 /* enable DVB-T demod on IOD[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300582 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 0), 0x01);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300583 if (ret)
584 goto error;
585
586 /* enable DVB-T tuner on IOE[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300587 ret = anysee_wr_reg_mask(d, REG_IOE, (0 << 0), 0x01);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300588 if (ret)
589 goto error;
590 }
591
592 break;
593 case ANYSEE_HW_508TC: /* 18 */
594 case ANYSEE_HW_508PTC: /* 21 */
595 /* E7 TC */
596 /* E7 PTC */
597
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300598 if (fe->id == 0) {
Antti Palosaari449d1a02011-07-25 20:25:21 -0300599 /* disable DVB-T demod on IOD[6] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300600 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 6), 0x40);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300601 if (ret)
602 goto error;
603
604 /* enable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300605 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 5), 0x20);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300606 if (ret)
607 goto error;
608
609 /* enable IF route on IOE[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300610 ret = anysee_wr_reg_mask(d, REG_IOE, (1 << 0), 0x01);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300611 if (ret)
612 goto error;
613 } else {
614 /* disable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300615 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 5), 0x20);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300616 if (ret)
617 goto error;
618
619 /* enable DVB-T demod on IOD[6] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300620 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 6), 0x40);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300621 if (ret)
622 goto error;
623
624 /* enable IF route on IOE[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300625 ret = anysee_wr_reg_mask(d, REG_IOE, (0 << 0), 0x01);
Antti Palosaari449d1a02011-07-25 20:25:21 -0300626 if (ret)
627 goto error;
628 }
629
630 break;
631 default:
632 ret = 0;
633 }
634
635error:
636 return ret;
637}
638
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300639static int anysee_frontend_attach(struct dvb_usb_adapter *adap)
640{
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300641 struct anysee_state *state = adap_to_priv(adap);
642 struct dvb_usb_device *d = adap_to_d(adap);
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300643 int ret;
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300644 u8 tmp;
645 struct i2c_msg msg[2] = {
646 {
647 .addr = anysee_tda18212_config.i2c_address,
648 .flags = 0,
649 .len = 1,
650 .buf = "\x00",
651 }, {
652 .addr = anysee_tda18212_config.i2c_address,
653 .flags = I2C_M_RD,
654 .len = 1,
655 .buf = &tmp,
656 }
657 };
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300658
Antti Palosaari41f81f62011-04-10 17:53:52 -0300659 switch (state->hw) {
Antti Palosaari05c46c02011-05-25 18:30:09 -0300660 case ANYSEE_HW_507T: /* 2 */
Antti Palosaari41f81f62011-04-10 17:53:52 -0300661 /* E30 */
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300662
Antti Palosaari41f81f62011-04-10 17:53:52 -0300663 /* attach demod */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300664 adap->fe[0] = dvb_attach(mt352_attach, &anysee_mt352_config,
665 &d->i2c_adap);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300666 if (adap->fe[0])
Antti Palosaari41f81f62011-04-10 17:53:52 -0300667 break;
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300668
Antti Palosaari41f81f62011-04-10 17:53:52 -0300669 /* attach demod */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300670 adap->fe[0] = dvb_attach(zl10353_attach, &anysee_zl10353_config,
671 &d->i2c_adap);
Antti Palosaari41f81f62011-04-10 17:53:52 -0300672
673 break;
674 case ANYSEE_HW_507CD: /* 6 */
675 /* E30 Plus */
676
677 /* enable DVB-T demod on IOD[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300678 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 0), 0x01);
Antti Palosaari41f81f62011-04-10 17:53:52 -0300679 if (ret)
680 goto error;
681
682 /* enable transport stream on IOA[7] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300683 ret = anysee_wr_reg_mask(d, REG_IOA, (0 << 7), 0x80);
Antti Palosaari41f81f62011-04-10 17:53:52 -0300684 if (ret)
685 goto error;
686
687 /* attach demod */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300688 adap->fe[0] = dvb_attach(zl10353_attach, &anysee_zl10353_config,
689 &d->i2c_adap);
Antti Palosaari41f81f62011-04-10 17:53:52 -0300690
691 break;
692 case ANYSEE_HW_507DC: /* 10 */
693 /* E30 C Plus */
694
695 /* enable DVB-C demod on IOD[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300696 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 0), 0x01);
Antti Palosaari41f81f62011-04-10 17:53:52 -0300697 if (ret)
698 goto error;
699
700 /* attach demod */
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300701 adap->fe[0] = dvb_attach(tda10023_attach,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300702 &anysee_tda10023_config, &d->i2c_adap, 0x48);
Antti Palosaari41f81f62011-04-10 17:53:52 -0300703
704 break;
Antti Palosaarif0a53102011-04-27 21:11:59 -0300705 case ANYSEE_HW_507SI: /* 11 */
706 /* E30 S2 Plus */
707
708 /* enable DVB-S/S2 demod on IOD[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300709 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 0), 0x01);
Antti Palosaarif0a53102011-04-27 21:11:59 -0300710 if (ret)
711 goto error;
712
713 /* attach demod */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300714 adap->fe[0] = dvb_attach(cx24116_attach, &anysee_cx24116_config,
715 &d->i2c_adap);
Antti Palosaarif0a53102011-04-27 21:11:59 -0300716
717 break;
Antti Palosaari41f81f62011-04-10 17:53:52 -0300718 case ANYSEE_HW_507FA: /* 15 */
719 /* E30 Combo Plus */
720 /* E30 C Plus */
721
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300722 /* enable tuner on IOE[4] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300723 ret = anysee_wr_reg_mask(d, REG_IOE, (1 << 4), 0x10);
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300724 if (ret)
725 goto error;
726
727 /* probe TDA18212 */
728 tmp = 0;
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300729 ret = i2c_transfer(&d->i2c_adap, msg, 2);
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300730 if (ret == 2 && tmp == 0xc7)
731 deb_info("%s: TDA18212 found\n", __func__);
732 else
733 tmp = 0;
734
735 /* disable tuner on IOE[4] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300736 ret = anysee_wr_reg_mask(d, REG_IOE, (0 << 4), 0x10);
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300737 if (ret)
738 goto error;
739
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300740 /* disable DVB-T demod on IOD[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300741 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 0), 0x01);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300742 if (ret)
743 goto error;
Antti Palosaari41f81f62011-04-10 17:53:52 -0300744
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300745 /* enable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300746 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 5), 0x20);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300747 if (ret)
748 goto error;
Antti Palosaari41f81f62011-04-10 17:53:52 -0300749
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300750 /* attach demod */
751 if (tmp == 0xc7) {
752 /* TDA18212 config */
753 adap->fe[0] = dvb_attach(tda10023_attach,
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300754 &anysee_tda10023_tda18212_config,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300755 &d->i2c_adap, 0x48);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300756
757 /* I2C gate for DNOD44CDH086A(TDA18212) tuner module */
758 if (adap->fe[0])
759 adap->fe[0]->ops.i2c_gate_ctrl =
760 anysee_i2c_gate_ctrl;
761 } else {
762 /* PLL config */
763 adap->fe[0] = dvb_attach(tda10023_attach,
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300764 &anysee_tda10023_config,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300765 &d->i2c_adap, 0x48);
Antti Palosaari0f77c3a2008-08-11 10:54:16 -0300766 }
Antti Palosaarie82eea72011-04-12 19:43:30 -0300767
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300768 /* break out if first frontend attaching fails */
769 if (!adap->fe[0])
770 break;
771
772 /* disable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300773 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 5), 0x20);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300774 if (ret)
775 goto error;
776
777 /* enable DVB-T demod on IOD[0] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300778 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 0), 0x01);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300779 if (ret)
780 goto error;
781
782 /* attach demod */
Antti Palosaaribe943512011-09-05 22:10:05 -0300783 if (tmp == 0xc7) {
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300784 /* TDA18212 config */
785 adap->fe[1] = dvb_attach(zl10353_attach,
786 &anysee_zl10353_tda18212_config2,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300787 &d->i2c_adap);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300788
789 /* I2C gate for DNOD44CDH086A(TDA18212) tuner module */
790 if (adap->fe[1])
791 adap->fe[1]->ops.i2c_gate_ctrl =
792 anysee_i2c_gate_ctrl;
793 } else {
794 /* PLL config */
795 adap->fe[1] = dvb_attach(zl10353_attach,
796 &anysee_zl10353_config,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300797 &d->i2c_adap);
Antti Palosaaribe943512011-09-05 22:10:05 -0300798 }
799
Antti Palosaari41f81f62011-04-10 17:53:52 -0300800 break;
Antti Palosaaria43be982011-04-10 20:23:02 -0300801 case ANYSEE_HW_508TC: /* 18 */
Antti Palosaari8439e0d2011-05-24 07:57:34 -0300802 case ANYSEE_HW_508PTC: /* 21 */
Antti Palosaaria43be982011-04-10 20:23:02 -0300803 /* E7 TC */
Antti Palosaari8439e0d2011-05-24 07:57:34 -0300804 /* E7 PTC */
Antti Palosaaria43be982011-04-10 20:23:02 -0300805
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300806 /* disable DVB-T demod on IOD[6] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300807 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 6), 0x40);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300808 if (ret)
809 goto error;
Antti Palosaaria43be982011-04-10 20:23:02 -0300810
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300811 /* enable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300812 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 5), 0x20);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300813 if (ret)
814 goto error;
Antti Palosaaria43be982011-04-10 20:23:02 -0300815
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300816 /* attach demod */
817 adap->fe[0] = dvb_attach(tda10023_attach,
Antti Palosaari449d1a02011-07-25 20:25:21 -0300818 &anysee_tda10023_tda18212_config,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300819 &d->i2c_adap, 0x48);
Antti Palosaarie82eea72011-04-12 19:43:30 -0300820
Antti Palosaaribe943512011-09-05 22:10:05 -0300821 /* I2C gate for DNOD44CDH086A(TDA18212) tuner module */
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300822 if (adap->fe[0])
823 adap->fe[0]->ops.i2c_gate_ctrl = anysee_i2c_gate_ctrl;
824
825 /* break out if first frontend attaching fails */
826 if (!adap->fe[0])
827 break;
828
829 /* disable DVB-C demod on IOD[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300830 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 5), 0x20);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300831 if (ret)
832 goto error;
833
834 /* enable DVB-T demod on IOD[6] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300835 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 6), 0x40);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300836 if (ret)
837 goto error;
838
839 /* attach demod */
840 adap->fe[1] = dvb_attach(zl10353_attach,
841 &anysee_zl10353_tda18212_config,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300842 &d->i2c_adap);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300843
844 /* I2C gate for DNOD44CDH086A(TDA18212) tuner module */
845 if (adap->fe[1])
846 adap->fe[1]->ops.i2c_gate_ctrl = anysee_i2c_gate_ctrl;
Antti Palosaaribe943512011-09-05 22:10:05 -0300847
Antti Palosaari05cd37d2011-09-05 23:33:04 -0300848 state->has_ci = true;
849
Antti Palosaaria43be982011-04-10 20:23:02 -0300850 break;
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300851 case ANYSEE_HW_508S2: /* 19 */
Antti Palosaarifea3c392011-05-25 18:21:43 -0300852 case ANYSEE_HW_508PS2: /* 22 */
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300853 /* E7 S2 */
Antti Palosaarifea3c392011-05-25 18:21:43 -0300854 /* E7 PS2 */
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300855
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300856 /* enable DVB-S/S2 demod on IOE[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300857 ret = anysee_wr_reg_mask(d, REG_IOE, (1 << 5), 0x20);
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300858 if (ret)
859 goto error;
860
861 /* attach demod */
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300862 adap->fe[0] = dvb_attach(stv0900_attach,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300863 &anysee_stv0900_config, &d->i2c_adap, 0);
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300864
Antti Palosaari05cd37d2011-09-05 23:33:04 -0300865 state->has_ci = true;
866
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300867 break;
Antti Palosaari608add82011-08-12 18:29:46 -0300868 case ANYSEE_HW_508T2C: /* 20 */
869 /* E7 T2C */
870
Antti Palosaari608add82011-08-12 18:29:46 -0300871 /* enable DVB-T/T2/C demod on IOE[5] */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300872 ret = anysee_wr_reg_mask(d, REG_IOE, (1 << 5), 0x20);
Antti Palosaari608add82011-08-12 18:29:46 -0300873 if (ret)
874 goto error;
875
Antti Palosaarifaf27972012-01-15 14:20:50 -0300876 /* attach demod */
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300877 adap->fe[0] = dvb_attach(cxd2820r_attach,
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300878 &anysee_cxd2820r_config, &d->i2c_adap);
Antti Palosaari608add82011-08-12 18:29:46 -0300879
Antti Palosaari05cd37d2011-09-05 23:33:04 -0300880 state->has_ci = true;
Antti Palosaari0f77c3a2008-08-11 10:54:16 -0300881
882 break;
883 }
884
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300885 if (!adap->fe[0]) {
Antti Palosaari41f81f62011-04-10 17:53:52 -0300886 /* we have no frontend :-( */
887 ret = -ENODEV;
Antti Palosaarie82eea72011-04-12 19:43:30 -0300888 err("Unsupported Anysee version. " \
889 "Please report the <linux-media@vger.kernel.org>.");
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300890 }
Antti Palosaari41f81f62011-04-10 17:53:52 -0300891error:
892 return ret;
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300893}
894
895static int anysee_tuner_attach(struct dvb_usb_adapter *adap)
896{
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300897 struct anysee_state *state = adap_to_priv(adap);
898 struct dvb_usb_device *d = adap_to_d(adap);
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300899 struct dvb_frontend *fe;
Antti Palosaarie82eea72011-04-12 19:43:30 -0300900 int ret;
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300901 deb_info("%s: adap=%d\n", __func__, adap->id);
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300902
Antti Palosaari41f81f62011-04-10 17:53:52 -0300903 switch (state->hw) {
Antti Palosaari05c46c02011-05-25 18:30:09 -0300904 case ANYSEE_HW_507T: /* 2 */
Antti Palosaari41f81f62011-04-10 17:53:52 -0300905 /* E30 */
906
907 /* attach tuner */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300908 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc2 >> 1), NULL,
909 DVB_PLL_THOMSON_DTT7579);
Antti Palosaarie82eea72011-04-12 19:43:30 -0300910
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300911 break;
Antti Palosaari41f81f62011-04-10 17:53:52 -0300912 case ANYSEE_HW_507CD: /* 6 */
913 /* E30 Plus */
914
915 /* attach tuner */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300916 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc2 >> 1),
917 &d->i2c_adap, DVB_PLL_THOMSON_DTT7579);
Antti Palosaari41f81f62011-04-10 17:53:52 -0300918
919 break;
920 case ANYSEE_HW_507DC: /* 10 */
921 /* E30 C Plus */
922
923 /* attach tuner */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300924 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc0 >> 1),
925 &d->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A);
Antti Palosaarie82eea72011-04-12 19:43:30 -0300926
Antti Palosaaria51e34d2008-05-17 23:05:48 -0300927 break;
Antti Palosaarif0a53102011-04-27 21:11:59 -0300928 case ANYSEE_HW_507SI: /* 11 */
929 /* E30 S2 Plus */
930
931 /* attach LNB controller */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300932 fe = dvb_attach(isl6423_attach, adap->fe[0], &d->i2c_adap,
933 &anysee_isl6423_config);
Antti Palosaarif0a53102011-04-27 21:11:59 -0300934
935 break;
Antti Palosaari41f81f62011-04-10 17:53:52 -0300936 case ANYSEE_HW_507FA: /* 15 */
937 /* E30 Combo Plus */
938 /* E30 C Plus */
939
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300940 /* Try first attach TDA18212 silicon tuner on IOE[4], if that
941 * fails attach old simple PLL. */
942
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300943 /* attach tuner */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300944 fe = dvb_attach(tda18212_attach, adap->fe[0], &d->i2c_adap,
945 &anysee_tda18212_config);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300946
947 if (fe && adap->fe[1]) {
948 /* attach tuner for 2nd FE */
949 fe = dvb_attach(tda18212_attach, adap->fe[1],
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300950 &d->i2c_adap, &anysee_tda18212_config);
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300951 break;
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300952 } else if (fe) {
953 break;
954 }
Antti Palosaari72ffd2b2011-04-10 20:14:50 -0300955
Antti Palosaari41f81f62011-04-10 17:53:52 -0300956 /* attach tuner */
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300957 fe = dvb_attach(dvb_pll_attach, adap->fe[0], (0xc0 >> 1),
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300958 &d->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300959
960 if (fe && adap->fe[1]) {
961 /* attach tuner for 2nd FE */
962 fe = dvb_attach(dvb_pll_attach, adap->fe[0],
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300963 (0xc0 >> 1), &d->i2c_adap,
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300964 DVB_PLL_SAMSUNG_DTOS403IH102A);
965 }
Antti Palosaari41f81f62011-04-10 17:53:52 -0300966
967 break;
Antti Palosaaria43be982011-04-10 20:23:02 -0300968 case ANYSEE_HW_508TC: /* 18 */
Antti Palosaari8439e0d2011-05-24 07:57:34 -0300969 case ANYSEE_HW_508PTC: /* 21 */
Antti Palosaaria43be982011-04-10 20:23:02 -0300970 /* E7 TC */
Antti Palosaari8439e0d2011-05-24 07:57:34 -0300971 /* E7 PTC */
Antti Palosaaria43be982011-04-10 20:23:02 -0300972
Antti Palosaaria43be982011-04-10 20:23:02 -0300973 /* attach tuner */
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300974 fe = dvb_attach(tda18212_attach, adap->fe[0], &d->i2c_adap,
975 &anysee_tda18212_config);
Antti Palosaaria43be982011-04-10 20:23:02 -0300976
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300977 if (fe) {
978 /* attach tuner for 2nd FE */
979 fe = dvb_attach(tda18212_attach, adap->fe[1],
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300980 &d->i2c_adap, &anysee_tda18212_config);
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300981 }
982
Antti Palosaaria43be982011-04-10 20:23:02 -0300983 break;
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300984 case ANYSEE_HW_508S2: /* 19 */
Antti Palosaarifea3c392011-05-25 18:21:43 -0300985 case ANYSEE_HW_508PS2: /* 22 */
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300986 /* E7 S2 */
Antti Palosaarifea3c392011-05-25 18:21:43 -0300987 /* E7 PS2 */
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300988
989 /* attach tuner */
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300990 fe = dvb_attach(stv6110_attach, adap->fe[0],
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300991 &anysee_stv6110_config, &d->i2c_adap);
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300992
993 if (fe) {
994 /* attach LNB controller */
Antti Palosaaria4e7c512012-06-14 04:56:09 -0300995 fe = dvb_attach(isl6423_attach, adap->fe[0],
Antti Palosaari05cd62e2012-06-18 19:39:02 -0300996 &d->i2c_adap, &anysee_isl6423_config);
Antti Palosaaribedbf3d2011-04-29 13:55:02 -0300997 }
998
999 break;
Antti Palosaari608add82011-08-12 18:29:46 -03001000
1001 case ANYSEE_HW_508T2C: /* 20 */
1002 /* E7 T2C */
1003
1004 /* attach tuner */
Antti Palosaari05cd62e2012-06-18 19:39:02 -03001005 fe = dvb_attach(tda18212_attach, adap->fe[0], &d->i2c_adap,
1006 &anysee_tda18212_config2);
Antti Palosaari608add82011-08-12 18:29:46 -03001007
1008 break;
Antti Palosaari41f81f62011-04-10 17:53:52 -03001009 default:
Antti Palosaarie82eea72011-04-12 19:43:30 -03001010 fe = NULL;
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001011 }
1012
Antti Palosaarie82eea72011-04-12 19:43:30 -03001013 if (fe)
1014 ret = 0;
1015 else
1016 ret = -ENODEV;
1017
Antti Palosaari41f81f62011-04-10 17:53:52 -03001018 return ret;
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001019}
1020
Antti Palosaaria8494682010-10-17 18:25:10 -03001021static int anysee_rc_query(struct dvb_usb_device *d)
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001022{
1023 u8 buf[] = {CMD_GET_IR_CODE};
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001024 u8 ircode[2];
Antti Palosaaria8494682010-10-17 18:25:10 -03001025 int ret;
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001026
Antti Palosaaria8494682010-10-17 18:25:10 -03001027 /* Remote controller is basic NEC using address byte 0x08.
1028 Anysee device RC query returns only two bytes, status and code,
1029 address byte is dropped. Also it does not return any value for
1030 NEC RCs having address byte other than 0x08. Due to that, we
1031 cannot use that device as standard NEC receiver.
1032 It could be possible make hack which reads whole code directly
1033 from device memory... */
1034
1035 ret = anysee_ctrl_msg(d, buf, sizeof(buf), ircode, sizeof(ircode));
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001036 if (ret)
1037 return ret;
1038
Antti Palosaaria8494682010-10-17 18:25:10 -03001039 if (ircode[0]) {
1040 deb_rc("%s: key pressed %02x\n", __func__, ircode[1]);
Mauro Carvalho Chehabca866742010-11-17 13:53:11 -03001041 rc_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0);
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001042 }
Antti Palosaaria8494682010-10-17 18:25:10 -03001043
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001044 return 0;
1045}
1046
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001047static int anysee_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
1048{
1049 rc->allowed_protos = RC_TYPE_NEC;
1050 rc->query = anysee_rc_query;
1051 rc->interval = 250; /* windows driver uses 500ms */
1052
1053 return 0;
1054}
1055
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001056static int anysee_ci_read_attribute_mem(struct dvb_ca_en50221 *ci, int slot,
1057 int addr)
1058{
1059 struct dvb_usb_device *d = ci->data;
1060 int ret;
1061 u8 buf[] = {CMD_CI, 0x02, 0x40 | addr >> 8, addr & 0xff, 0x00, 1};
1062 u8 val;
1063
1064 ret = anysee_ctrl_msg(d, buf, sizeof(buf), &val, 1);
1065 if (ret)
1066 return ret;
1067
1068 return val;
1069}
1070
1071static int anysee_ci_write_attribute_mem(struct dvb_ca_en50221 *ci, int slot,
1072 int addr, u8 val)
1073{
1074 struct dvb_usb_device *d = ci->data;
1075 int ret;
1076 u8 buf[] = {CMD_CI, 0x03, 0x40 | addr >> 8, addr & 0xff, 0x00, 1, val};
1077
1078 ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
1079 if (ret)
1080 return ret;
1081
1082 return 0;
1083}
1084
1085static int anysee_ci_read_cam_control(struct dvb_ca_en50221 *ci, int slot,
1086 u8 addr)
1087{
1088 struct dvb_usb_device *d = ci->data;
1089 int ret;
1090 u8 buf[] = {CMD_CI, 0x04, 0x40, addr, 0x00, 1};
1091 u8 val;
1092
1093 ret = anysee_ctrl_msg(d, buf, sizeof(buf), &val, 1);
1094 if (ret)
1095 return ret;
1096
1097 return val;
1098}
1099
1100static int anysee_ci_write_cam_control(struct dvb_ca_en50221 *ci, int slot,
1101 u8 addr, u8 val)
1102{
1103 struct dvb_usb_device *d = ci->data;
1104 int ret;
1105 u8 buf[] = {CMD_CI, 0x05, 0x40, addr, 0x00, 1, val};
1106
1107 ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0);
1108 if (ret)
1109 return ret;
1110
1111 return 0;
1112}
1113
1114static int anysee_ci_slot_reset(struct dvb_ca_en50221 *ci, int slot)
1115{
1116 struct dvb_usb_device *d = ci->data;
1117 int ret;
Antti Palosaari05cd62e2012-06-18 19:39:02 -03001118 struct anysee_state *state = d_to_priv(d);
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001119
1120 state->ci_cam_ready = jiffies + msecs_to_jiffies(1000);
1121
1122 ret = anysee_wr_reg_mask(d, REG_IOA, (0 << 7), 0x80);
1123 if (ret)
1124 return ret;
1125
1126 msleep(300);
1127
1128 ret = anysee_wr_reg_mask(d, REG_IOA, (1 << 7), 0x80);
1129 if (ret)
1130 return ret;
1131
1132 return 0;
1133}
1134
1135static int anysee_ci_slot_shutdown(struct dvb_ca_en50221 *ci, int slot)
1136{
1137 struct dvb_usb_device *d = ci->data;
1138 int ret;
1139
1140 ret = anysee_wr_reg_mask(d, REG_IOA, (0 << 7), 0x80);
1141 if (ret)
1142 return ret;
1143
1144 msleep(30);
1145
1146 ret = anysee_wr_reg_mask(d, REG_IOA, (1 << 7), 0x80);
1147 if (ret)
1148 return ret;
1149
1150 return 0;
1151}
1152
1153static int anysee_ci_slot_ts_enable(struct dvb_ca_en50221 *ci, int slot)
1154{
1155 struct dvb_usb_device *d = ci->data;
1156 int ret;
1157
1158 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 1), 0x02);
1159 if (ret)
1160 return ret;
1161
1162 return 0;
1163}
1164
1165static int anysee_ci_poll_slot_status(struct dvb_ca_en50221 *ci, int slot,
1166 int open)
1167{
1168 struct dvb_usb_device *d = ci->data;
Antti Palosaari05cd62e2012-06-18 19:39:02 -03001169 struct anysee_state *state = d_to_priv(d);
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001170 int ret;
1171 u8 tmp;
1172
1173 ret = anysee_rd_reg_mask(d, REG_IOC, &tmp, 0x40);
1174 if (ret)
1175 return ret;
1176
1177 if (tmp == 0) {
1178 ret = DVB_CA_EN50221_POLL_CAM_PRESENT;
1179 if (time_after(jiffies, state->ci_cam_ready))
1180 ret |= DVB_CA_EN50221_POLL_CAM_READY;
1181 }
1182
1183 return ret;
1184}
1185
1186static int anysee_ci_init(struct dvb_usb_device *d)
1187{
Antti Palosaari05cd62e2012-06-18 19:39:02 -03001188 struct anysee_state *state = d_to_priv(d);
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001189 int ret;
1190
1191 state->ci.owner = THIS_MODULE;
1192 state->ci.read_attribute_mem = anysee_ci_read_attribute_mem;
1193 state->ci.write_attribute_mem = anysee_ci_write_attribute_mem;
1194 state->ci.read_cam_control = anysee_ci_read_cam_control;
1195 state->ci.write_cam_control = anysee_ci_write_cam_control;
1196 state->ci.slot_reset = anysee_ci_slot_reset;
1197 state->ci.slot_shutdown = anysee_ci_slot_shutdown;
1198 state->ci.slot_ts_enable = anysee_ci_slot_ts_enable;
1199 state->ci.poll_slot_status = anysee_ci_poll_slot_status;
1200 state->ci.data = d;
1201
1202 ret = anysee_wr_reg_mask(d, REG_IOA, (1 << 7), 0x80);
1203 if (ret)
1204 return ret;
1205
Antti Palosaari46de20a2012-01-20 17:39:17 -03001206 ret = anysee_wr_reg_mask(d, REG_IOD, (0 << 2)|(0 << 1)|(0 << 0), 0x07);
1207 if (ret)
1208 return ret;
1209
1210 ret = anysee_wr_reg_mask(d, REG_IOD, (1 << 2)|(1 << 1)|(1 << 0), 0x07);
1211 if (ret)
1212 return ret;
1213
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001214 ret = dvb_ca_en50221_init(&d->adapter[0].dvb_adap, &state->ci, 0, 1);
1215 if (ret)
1216 return ret;
1217
1218 return 0;
1219}
1220
1221static void anysee_ci_release(struct dvb_usb_device *d)
1222{
Antti Palosaari05cd62e2012-06-18 19:39:02 -03001223 struct anysee_state *state = d_to_priv(d);
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001224
1225 /* detach CI */
1226 if (state->has_ci)
1227 dvb_ca_en50221_release(&state->ci);
1228
1229 return;
1230}
1231
1232static int anysee_init(struct dvb_usb_device *d)
1233{
Antti Palosaari05cd62e2012-06-18 19:39:02 -03001234 struct anysee_state *state = d_to_priv(d);
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001235 int ret;
1236
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001237 /* There is one interface with two alternate settings.
1238 Alternate setting 0 is for bulk transfer.
1239 Alternate setting 1 is for isochronous transfer.
1240 We use bulk transfer (alternate setting 0). */
1241 ret = usb_set_interface(d->udev, 0, 0);
1242 if (ret)
1243 return ret;
1244
Antti Palosaari05cd37d2011-09-05 23:33:04 -03001245 /* LED light */
1246 ret = anysee_led_ctrl(d, 0x01, 0x03);
1247 if (ret)
1248 return ret;
1249
1250 /* enable IR */
1251 ret = anysee_ir_ctrl(d, 1);
1252 if (ret)
1253 return ret;
1254
1255 /* attach CI */
1256 if (state->has_ci) {
1257 ret = anysee_ci_init(d);
1258 if (ret) {
1259 state->has_ci = false;
1260 return ret;
1261 }
1262 }
1263
1264 return 0;
1265}
1266
Antti Palosaari831511b2012-06-20 00:32:53 -03001267static void anysee_exit(struct dvb_usb_device *d)
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001268{
1269 return anysee_ci_release(d);
1270}
1271
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001272/* DVB USB Driver stuff */
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001273static struct dvb_usb_device_properties anysee_props = {
1274 .driver_name = KBUILD_MODNAME,
1275 .owner = THIS_MODULE,
1276 .adapter_nr = adapter_nr,
1277 .size_of_priv = sizeof(struct anysee_state),
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001278
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001279 .generic_bulk_ctrl_endpoint = 0x01,
1280 .generic_bulk_ctrl_endpoint_response = 0x81,
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001281
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001282 .i2c_algo = &anysee_i2c_algo,
1283 .read_config = anysee_read_config,
1284 .frontend_attach = anysee_frontend_attach,
1285 .tuner_attach = anysee_tuner_attach,
1286 .init = anysee_init,
1287 .get_rc_config = anysee_get_rc_config,
1288 .frontend_ctrl = anysee_frontend_ctrl,
1289 .streaming_ctrl = anysee_streaming_ctrl,
Antti Palosaari831511b2012-06-20 00:32:53 -03001290 .exit = anysee_exit,
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001291
1292 .num_adapters = 1,
1293 .adapter = {
1294 {
Antti Palosaari05cd62e2012-06-18 19:39:02 -03001295 .stream = DVB_USB_STREAM_BULK(0x82, 8, 16 * 512),
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001296 }
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001297 }
1298};
1299
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001300static const struct usb_device_id anysee_id_table[] = {
1301 { DVB_USB_DEVICE(USB_VID_CYPRESS, USB_PID_ANYSEE,
1302 &anysee_props, "Anysee", RC_MAP_ANYSEE) },
1303 { DVB_USB_DEVICE(USB_VID_AMT, USB_PID_ANYSEE,
1304 &anysee_props, "Anysee", RC_MAP_ANYSEE) },
1305 { }
1306};
1307MODULE_DEVICE_TABLE(usb, anysee_id_table);
1308
1309static struct usb_driver anysee_usb_driver = {
1310 .name = KBUILD_MODNAME,
1311 .id_table = anysee_id_table,
1312 .probe = dvb_usbv2_probe,
1313 .disconnect = dvb_usbv2_disconnect,
1314 .suspend = dvb_usbv2_suspend,
1315 .resume = dvb_usbv2_resume,
1316 .no_dynamic_id = 1,
1317 .soft_unbind = 1,
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001318};
1319
Antti Palosaaria4e7c512012-06-14 04:56:09 -03001320module_usb_driver(anysee_usb_driver);
Antti Palosaaria51e34d2008-05-17 23:05:48 -03001321
1322MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
1323MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0");
1324MODULE_LICENSE("GPL");