2 * DVB USB Linux driver for Anysee E30 DVB-C & DVB-T USB2.0 receiver
4 * Copyright (C) 2007 Antti Palosaari <crope@iki.fi>
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.
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.
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.
21 * - add smart card reader support for Conditional Access (CA)
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 implemented. This
27 * module registers serial interface that can be used to communicate
28 * with any ISO 7816 smart card.
30 * Any help according to implement serial smart card reader support
37 #include "mt352_priv.h"
46 static int dvb_usb_anysee_debug
;
47 module_param_named(debug
, dvb_usb_anysee_debug
, int, 0644);
48 MODULE_PARM_DESC(debug
, "set debugging level" DVB_USB_DEBUG_STATUS
);
49 static int dvb_usb_anysee_delsys
;
50 module_param_named(delsys
, dvb_usb_anysee_delsys
, int, 0644);
51 MODULE_PARM_DESC(delsys
, "select delivery mode (0=DVB-C, 1=DVB-T)");
52 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr
);
54 static DEFINE_MUTEX(anysee_usb_mutex
);
56 static int anysee_ctrl_msg(struct dvb_usb_device
*d
, u8
*sbuf
, u8 slen
,
59 struct anysee_state
*state
= d
->priv
;
63 memcpy(&buf
[0], sbuf
, slen
);
64 buf
[60] = state
->seq
++;
66 if (mutex_lock_interruptible(&anysee_usb_mutex
) < 0)
69 /* We need receive one message more after dvb_usb_generic_rw due
70 to weird transaction flow, which is 1 x send + 2 x receive. */
71 ret
= dvb_usb_generic_rw(d
, buf
, sizeof(buf
), buf
, sizeof(buf
), 0);
74 /* receive 2nd answer */
75 ret
= usb_bulk_msg(d
->udev
, usb_rcvbulkpipe(d
->udev
,
76 d
->props
.generic_bulk_ctrl_endpoint
), buf
, sizeof(buf
),
79 err("%s: recv bulk message failed: %d", __func__
, ret
);
82 debug_dump(buf
, act_len
, deb_xfer
);
86 /* read request, copy returned data to return buf */
87 if (!ret
&& rbuf
&& rlen
)
88 memcpy(rbuf
, buf
, rlen
);
90 mutex_unlock(&anysee_usb_mutex
);
95 static int anysee_read_reg(struct dvb_usb_device
*d
, u16 reg
, u8
*val
)
97 u8 buf
[] = {CMD_REG_READ
, reg
>> 8, reg
& 0xff, 0x01};
99 ret
= anysee_ctrl_msg(d
, buf
, sizeof(buf
), val
, 1);
100 deb_info("%s: reg:%04x val:%02x\n", __func__
, reg
, *val
);
104 static int anysee_write_reg(struct dvb_usb_device
*d
, u16 reg
, u8 val
)
106 u8 buf
[] = {CMD_REG_WRITE
, reg
>> 8, reg
& 0xff, 0x01, val
};
107 deb_info("%s: reg:%04x val:%02x\n", __func__
, reg
, val
);
108 return anysee_ctrl_msg(d
, buf
, sizeof(buf
), NULL
, 0);
111 /* write single register with mask */
112 static int anysee_wr_reg_mask(struct dvb_usb_device
*d
, u16 reg
, u8 val
,
118 /* no need for read if whole reg is written */
120 ret
= anysee_read_reg(d
, reg
, &tmp
);
129 return anysee_write_reg(d
, reg
, val
);
132 static int anysee_get_hw_info(struct dvb_usb_device
*d
, u8
*id
)
134 u8 buf
[] = {CMD_GET_HW_INFO
};
135 return anysee_ctrl_msg(d
, buf
, sizeof(buf
), id
, 3);
138 static int anysee_streaming_ctrl(struct dvb_usb_adapter
*adap
, int onoff
)
140 u8 buf
[] = {CMD_STREAMING_CTRL
, (u8
)onoff
, 0x00};
141 deb_info("%s: onoff:%02x\n", __func__
, onoff
);
142 return anysee_ctrl_msg(adap
->dev
, buf
, sizeof(buf
), NULL
, 0);
145 static int anysee_led_ctrl(struct dvb_usb_device
*d
, u8 mode
, u8 interval
)
147 u8 buf
[] = {CMD_LED_AND_IR_CTRL
, 0x01, mode
, interval
};
148 deb_info("%s: state:%02x interval:%02x\n", __func__
, mode
, interval
);
149 return anysee_ctrl_msg(d
, buf
, sizeof(buf
), NULL
, 0);
152 static int anysee_ir_ctrl(struct dvb_usb_device
*d
, u8 onoff
)
154 u8 buf
[] = {CMD_LED_AND_IR_CTRL
, 0x02, onoff
};
155 deb_info("%s: onoff:%02x\n", __func__
, onoff
);
156 return anysee_ctrl_msg(d
, buf
, sizeof(buf
), NULL
, 0);
159 static int anysee_init(struct dvb_usb_device
*d
)
163 ret
= anysee_led_ctrl(d
, 0x01, 0x03);
168 ret
= anysee_ir_ctrl(d
, 1);
176 static int anysee_master_xfer(struct i2c_adapter
*adap
, struct i2c_msg
*msg
,
179 struct dvb_usb_device
*d
= i2c_get_adapdata(adap
);
180 int ret
= 0, inc
, i
= 0;
181 u8 buf
[52]; /* 4 + 48 (I2C WR USB command header + I2C WR max) */
183 if (mutex_lock_interruptible(&d
->i2c_mutex
) < 0)
187 if (num
> i
+ 1 && (msg
[i
+1].flags
& I2C_M_RD
)) {
188 if (msg
[i
].len
> 2 || msg
[i
+1].len
> 60) {
192 buf
[0] = CMD_I2C_READ
;
193 buf
[1] = (msg
[i
].addr
<< 1) | 0x01;
194 buf
[2] = msg
[i
].buf
[0];
195 buf
[3] = msg
[i
].buf
[1];
196 buf
[4] = msg
[i
].len
-1;
197 buf
[5] = msg
[i
+1].len
;
198 ret
= anysee_ctrl_msg(d
, buf
, 6, msg
[i
+1].buf
,
202 if (msg
[i
].len
> 48) {
206 buf
[0] = CMD_I2C_WRITE
;
207 buf
[1] = (msg
[i
].addr
<< 1);
210 memcpy(&buf
[4], msg
[i
].buf
, msg
[i
].len
);
211 ret
= anysee_ctrl_msg(d
, buf
, 4 + msg
[i
].len
, NULL
, 0);
220 mutex_unlock(&d
->i2c_mutex
);
222 return ret
? ret
: i
;
225 static u32
anysee_i2c_func(struct i2c_adapter
*adapter
)
230 static struct i2c_algorithm anysee_i2c_algo
= {
231 .master_xfer
= anysee_master_xfer
,
232 .functionality
= anysee_i2c_func
,
235 static int anysee_mt352_demod_init(struct dvb_frontend
*fe
)
237 static u8 clock_config
[] = { CLOCK_CTL
, 0x38, 0x28 };
238 static u8 reset
[] = { RESET
, 0x80 };
239 static u8 adc_ctl_1_cfg
[] = { ADC_CTL_1
, 0x40 };
240 static u8 agc_cfg
[] = { AGC_TARGET
, 0x28, 0x20 };
241 static u8 gpp_ctl_cfg
[] = { GPP_CTL
, 0x33 };
242 static u8 capt_range_cfg
[] = { CAPT_RANGE
, 0x32 };
244 mt352_write(fe
, clock_config
, sizeof(clock_config
));
246 mt352_write(fe
, reset
, sizeof(reset
));
247 mt352_write(fe
, adc_ctl_1_cfg
, sizeof(adc_ctl_1_cfg
));
249 mt352_write(fe
, agc_cfg
, sizeof(agc_cfg
));
250 mt352_write(fe
, gpp_ctl_cfg
, sizeof(gpp_ctl_cfg
));
251 mt352_write(fe
, capt_range_cfg
, sizeof(capt_range_cfg
));
256 /* Callbacks for DVB USB */
257 static struct tda10023_config anysee_tda10023_config
= {
258 .demod_address
= (0x1a >> 1),
264 .output_mode
= TDA10023_OUTPUT_MODE_PARALLEL_C
,
268 static struct mt352_config anysee_mt352_config
= {
269 .demod_address
= (0x1e >> 1),
270 .demod_init
= anysee_mt352_demod_init
,
273 static struct zl10353_config anysee_zl10353_config
= {
274 .demod_address
= (0x1e >> 1),
278 static struct zl10353_config anysee_zl10353_tda18212_config2
= {
279 .demod_address
= (0x1e >> 1),
281 .disable_i2c_gate_ctrl
= 1,
286 static struct zl10353_config anysee_zl10353_tda18212_config
= {
287 .demod_address
= (0x18 >> 1),
289 .disable_i2c_gate_ctrl
= 1,
294 static struct tda10023_config anysee_tda10023_tda18212_config
= {
295 .demod_address
= (0x1a >> 1),
300 .output_mode
= TDA10023_OUTPUT_MODE_PARALLEL_C
,
304 static struct tda18212_config anysee_tda18212_config
= {
305 .i2c_address
= (0xc0 >> 1),
312 static struct cx24116_config anysee_cx24116_config
= {
313 .demod_address
= (0xaa >> 1),
314 .mpg_clk_pos_pol
= 0x00,
318 static struct stv0900_config anysee_stv0900_config
= {
319 .demod_address
= (0xd0 >> 1),
325 .tun1_adc
= 1, /* 1 Vpp */
329 static struct stv6110_config anysee_stv6110_config
= {
330 .i2c_address
= (0xc0 >> 1),
335 static struct isl6423_config anysee_isl6423_config
= {
336 .current_max
= SEC_CURRENT_800m
,
337 .curlim
= SEC_CURRENT_LIM_OFF
,
343 * New USB device strings: Mfr=1, Product=2, SerialNumber=0
344 * Manufacturer: AMT.CO.KR
346 * E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=????????
348 * parts: DNOS404ZH102A(MT352, DTT7579(?))
350 * E30 VID=04b4 PID=861f HW=2 FW=2.1 "anysee-T(LP)"
351 * PCB: PCB 507T (rev1.61)
352 * parts: DNOS404ZH103A(ZL10353, DTT7579(?))
353 * OEA=0a OEB=00 OEC=00 OED=ff OEE=00
354 * IOA=45 IOB=ff IOC=00 IOD=ff IOE=00
356 * E30 Plus VID=04b4 PID=861f HW=6 FW=1.0 "anysee"
357 * PCB: 507CD (rev1.1)
358 * parts: DNOS404ZH103A(ZL10353, DTT7579(?)), CST56I01
359 * OEA=80 OEB=00 OEC=00 OED=ff OEE=fe
360 * IOA=4f IOB=ff IOC=00 IOD=06 IOE=01
361 * IOD[0] ZL10353 1=enabled
362 * IOA[7] TS 0=enabled
363 * tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not)
365 * E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)"
366 * PCB: 507DC (rev0.2)
367 * parts: TDA10023, DTOS403IH102B TM, CST56I01
368 * OEA=80 OEB=00 OEC=00 OED=ff OEE=fe
369 * IOA=4f IOB=ff IOC=00 IOD=26 IOE=01
370 * IOD[0] TDA10023 1=enabled
372 * E30 S2 Plus VID=04b4 PID=861f HW=11 FW=0.1 "anysee-S2(LP)"
373 * PCB: 507SI (rev2.1)
374 * parts: BS2N10WCC01(CX24116, CX24118), ISL6423, TDA8024
375 * OEA=80 OEB=00 OEC=ff OED=ff OEE=fe
376 * IOA=4d IOB=ff IOC=00 IOD=26 IOE=01
377 * IOD[0] CX24116 1=enabled
379 * E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
380 * PCB: 507FA (rev0.4)
381 * parts: TDA10023, DTOS403IH102B TM, TDA8024
382 * OEA=80 OEB=00 OEC=ff OED=ff OEE=ff
383 * IOA=4d IOB=ff IOC=00 IOD=00 IOE=c0
384 * IOD[5] TDA10023 1=enabled
385 * IOE[0] tuner 1=enabled
387 * E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)"
388 * PCB: 507FA (rev1.1)
389 * parts: ZL10353, TDA10023, DTOS403IH102B TM, TDA8024
390 * OEA=80 OEB=00 OEC=ff OED=ff OEE=ff
391 * IOA=4d IOB=ff IOC=00 IOD=00 IOE=c0
393 * IOD[5] TDA10023 1=enabled
394 * IOE[0] tuner 1=enabled
396 * IOD[0] ZL10353 1=enabled
397 * IOE[0] tuner 0=enabled
398 * tuner is behind ZL10353 I2C-gate
400 * E7 TC VID=1c73 PID=861f HW=18 FW=0.7 AMTCI=0.5 "anysee-E7TC(LP)"
401 * PCB: 508TC (rev0.6)
402 * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212)
403 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
404 * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4
405 * IOA[7] TS 1=enabled
406 * IOE[4] TDA18212 1=enabled
408 * IOD[6] ZL10353 0=disabled
409 * IOD[5] TDA10023 1=enabled
410 * IOE[0] IF 1=enabled
412 * IOD[5] TDA10023 0=disabled
413 * IOD[6] ZL10353 1=enabled
414 * IOE[0] IF 0=enabled
416 * E7 S2 VID=1c73 PID=861f HW=19 FW=0.4 AMTCI=0.5 "anysee-E7S2(LP)"
417 * PCB: 508S2 (rev0.7)
418 * parts: DNBU10512IST(STV0903, STV6110), ISL6423
419 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
420 * IOA=4d IOB=00 IOC=c4 IOD=08 IOE=e4
421 * IOA[7] TS 1=enabled
422 * IOE[5] STV0903 1=enabled
424 * E7 PTC VID=1c73 PID=861f HW=21 FW=0.1 AMTCI=?? "anysee-E7PTC(LP)"
425 * PCB: 508PTC (rev0.5)
426 * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212)
427 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
428 * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4
429 * IOA[7] TS 1=enabled
430 * IOE[4] TDA18212 1=enabled
432 * IOD[6] ZL10353 0=disabled
433 * IOD[5] TDA10023 1=enabled
434 * IOE[0] IF 1=enabled
436 * IOD[5] TDA10023 0=disabled
437 * IOD[6] ZL10353 1=enabled
438 * IOE[0] IF 0=enabled
440 * E7 S2 VID=1c73 PID=861f HW=22 FW=0.1 AMTCI=?? "anysee-E7PS2(LP)"
441 * PCB: 508PS2 (rev0.4)
442 * parts: DNBU10512IST(STV0903, STV6110), ISL6423
443 * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff
444 * IOA=4d IOB=00 IOC=c4 IOD=08 IOE=e4
445 * IOA[7] TS 1=enabled
446 * IOE[5] STV0903 1=enabled
449 static int anysee_frontend_attach(struct dvb_usb_adapter
*adap
)
452 struct anysee_state
*state
= adap
->dev
->priv
;
455 struct i2c_msg msg
[2] = {
457 .addr
= anysee_tda18212_config
.i2c_address
,
462 .addr
= anysee_tda18212_config
.i2c_address
,
469 /* Check which hardware we have.
470 * We must do this call two times to get reliable values (hw bug).
472 ret
= anysee_get_hw_info(adap
->dev
, hw_info
);
476 ret
= anysee_get_hw_info(adap
->dev
, hw_info
);
480 /* Meaning of these info bytes are guessed. */
481 info("firmware version:%d.%d hardware id:%d",
482 hw_info
[1], hw_info
[2], hw_info
[0]);
484 state
->hw
= hw_info
[0];
487 case ANYSEE_HW_507T
: /* 2 */
491 adap
->fe
= dvb_attach(mt352_attach
, &anysee_mt352_config
,
492 &adap
->dev
->i2c_adap
);
497 adap
->fe
= dvb_attach(zl10353_attach
, &anysee_zl10353_config
,
498 &adap
->dev
->i2c_adap
);
501 case ANYSEE_HW_507CD
: /* 6 */
504 /* enable DVB-T demod on IOD[0] */
505 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (1 << 0), 0x01);
509 /* enable transport stream on IOA[7] */
510 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOA
, (0 << 7), 0x80);
515 adap
->fe
= dvb_attach(zl10353_attach
, &anysee_zl10353_config
,
516 &adap
->dev
->i2c_adap
);
519 case ANYSEE_HW_507DC
: /* 10 */
522 /* enable DVB-C demod on IOD[0] */
523 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (1 << 0), 0x01);
528 adap
->fe
= dvb_attach(tda10023_attach
, &anysee_tda10023_config
,
529 &adap
->dev
->i2c_adap
, 0x48);
532 case ANYSEE_HW_507SI
: /* 11 */
535 /* enable DVB-S/S2 demod on IOD[0] */
536 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (1 << 0), 0x01);
541 adap
->fe
= dvb_attach(cx24116_attach
, &anysee_cx24116_config
,
542 &adap
->dev
->i2c_adap
);
545 case ANYSEE_HW_507FA
: /* 15 */
549 /* enable tuner on IOE[4] */
550 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (1 << 4), 0x10);
556 ret
= i2c_transfer(&adap
->dev
->i2c_adap
, msg
, 2);
557 if (ret
== 2 && tmp
== 0xc7)
558 deb_info("%s: TDA18212 found\n", __func__
);
562 /* disable tuner on IOE[4] */
563 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (0 << 4), 0x10);
567 if (dvb_usb_anysee_delsys
) {
568 /* disable DVB-C demod on IOD[5] */
569 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (0 << 5),
574 /* enable DVB-T demod on IOD[0] */
575 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (1 << 0),
582 /* TDA18212 config */
583 adap
->fe
= dvb_attach(zl10353_attach
,
584 &anysee_zl10353_tda18212_config2
,
585 &adap
->dev
->i2c_adap
);
588 adap
->fe
= dvb_attach(zl10353_attach
,
589 &anysee_zl10353_config
,
590 &adap
->dev
->i2c_adap
);
593 /* disable DVB-T demod on IOD[0] */
594 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (0 << 0),
599 /* enable DVB-C demod on IOD[5] */
600 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (1 << 5),
607 /* TDA18212 config */
608 adap
->fe
= dvb_attach(tda10023_attach
,
609 &anysee_tda10023_tda18212_config
,
610 &adap
->dev
->i2c_adap
, 0x48);
613 adap
->fe
= dvb_attach(tda10023_attach
,
614 &anysee_tda10023_config
,
615 &adap
->dev
->i2c_adap
, 0x48);
620 case ANYSEE_HW_508TC
: /* 18 */
621 case ANYSEE_HW_508PTC
: /* 21 */
625 /* enable transport stream on IOA[7] */
626 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOA
, (1 << 7), 0x80);
630 if (dvb_usb_anysee_delsys
) {
631 /* disable DVB-C demod on IOD[5] */
632 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (0 << 5),
637 /* enable DVB-T demod on IOD[6] */
638 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (1 << 6),
643 /* enable IF route on IOE[0] */
644 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (0 << 0),
650 adap
->fe
= dvb_attach(zl10353_attach
,
651 &anysee_zl10353_tda18212_config
,
652 &adap
->dev
->i2c_adap
);
654 /* disable DVB-T demod on IOD[6] */
655 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (0 << 6),
660 /* enable DVB-C demod on IOD[5] */
661 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOD
, (1 << 5),
666 /* enable IF route on IOE[0] */
667 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (1 << 0),
673 adap
->fe
= dvb_attach(tda10023_attach
,
674 &anysee_tda10023_tda18212_config
,
675 &adap
->dev
->i2c_adap
, 0x48);
679 case ANYSEE_HW_508S2
: /* 19 */
680 case ANYSEE_HW_508PS2
: /* 22 */
684 /* enable transport stream on IOA[7] */
685 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOA
, (1 << 7), 0x80);
689 /* enable DVB-S/S2 demod on IOE[5] */
690 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (1 << 5), 0x20);
695 adap
->fe
= dvb_attach(stv0900_attach
, &anysee_stv0900_config
,
696 &adap
->dev
->i2c_adap
, 0);
702 /* we have no frontend :-( */
704 err("Unsupported Anysee version. " \
705 "Please report the <linux-media@vger.kernel.org>.");
711 static int anysee_tuner_attach(struct dvb_usb_adapter
*adap
)
713 struct anysee_state
*state
= adap
->dev
->priv
;
714 struct dvb_frontend
*fe
;
716 deb_info("%s:\n", __func__
);
719 case ANYSEE_HW_507T
: /* 2 */
723 fe
= dvb_attach(dvb_pll_attach
, adap
->fe
, (0xc2 >> 1),
724 NULL
, DVB_PLL_THOMSON_DTT7579
);
727 case ANYSEE_HW_507CD
: /* 6 */
731 fe
= dvb_attach(dvb_pll_attach
, adap
->fe
, (0xc2 >> 1),
732 &adap
->dev
->i2c_adap
, DVB_PLL_THOMSON_DTT7579
);
735 case ANYSEE_HW_507DC
: /* 10 */
739 fe
= dvb_attach(dvb_pll_attach
, adap
->fe
, (0xc0 >> 1),
740 &adap
->dev
->i2c_adap
, DVB_PLL_SAMSUNG_DTOS403IH102A
);
743 case ANYSEE_HW_507SI
: /* 11 */
746 /* attach LNB controller */
747 fe
= dvb_attach(isl6423_attach
, adap
->fe
, &adap
->dev
->i2c_adap
,
748 &anysee_isl6423_config
);
751 case ANYSEE_HW_507FA
: /* 15 */
755 if (dvb_usb_anysee_delsys
) {
756 /* enable DVB-T tuner on IOE[0] */
757 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (0 << 0),
762 /* enable DVB-C tuner on IOE[0] */
763 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (1 << 0),
769 /* Try first attach TDA18212 silicon tuner on IOE[4], if that
770 * fails attach old simple PLL. */
772 /* enable tuner on IOE[4] */
773 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (1 << 4), 0x10);
778 fe
= dvb_attach(tda18212_attach
, adap
->fe
, &adap
->dev
->i2c_adap
,
779 &anysee_tda18212_config
);
783 /* disable tuner on IOE[4] */
784 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (0 << 4), 0x10);
789 fe
= dvb_attach(dvb_pll_attach
, adap
->fe
, (0xc0 >> 1),
790 &adap
->dev
->i2c_adap
, DVB_PLL_SAMSUNG_DTOS403IH102A
);
793 case ANYSEE_HW_508TC
: /* 18 */
794 case ANYSEE_HW_508PTC
: /* 21 */
798 /* enable tuner on IOE[4] */
799 ret
= anysee_wr_reg_mask(adap
->dev
, REG_IOE
, (1 << 4), 0x10);
804 fe
= dvb_attach(tda18212_attach
, adap
->fe
, &adap
->dev
->i2c_adap
,
805 &anysee_tda18212_config
);
808 case ANYSEE_HW_508S2
: /* 19 */
809 case ANYSEE_HW_508PS2
: /* 22 */
814 fe
= dvb_attach(stv6110_attach
, adap
->fe
,
815 &anysee_stv6110_config
, &adap
->dev
->i2c_adap
);
818 /* attach LNB controller */
819 fe
= dvb_attach(isl6423_attach
, adap
->fe
,
820 &adap
->dev
->i2c_adap
, &anysee_isl6423_config
);
837 static int anysee_rc_query(struct dvb_usb_device
*d
)
839 u8 buf
[] = {CMD_GET_IR_CODE
};
843 /* Remote controller is basic NEC using address byte 0x08.
844 Anysee device RC query returns only two bytes, status and code,
845 address byte is dropped. Also it does not return any value for
846 NEC RCs having address byte other than 0x08. Due to that, we
847 cannot use that device as standard NEC receiver.
848 It could be possible make hack which reads whole code directly
849 from device memory... */
851 ret
= anysee_ctrl_msg(d
, buf
, sizeof(buf
), ircode
, sizeof(ircode
));
856 deb_rc("%s: key pressed %02x\n", __func__
, ircode
[1]);
857 rc_keydown(d
->rc_dev
, 0x08 << 8 | ircode
[1], 0);
863 /* DVB USB Driver stuff */
864 static struct dvb_usb_device_properties anysee_properties
;
866 static int anysee_probe(struct usb_interface
*intf
,
867 const struct usb_device_id
*id
)
869 struct dvb_usb_device
*d
;
870 struct usb_host_interface
*alt
;
873 /* There is one interface with two alternate settings.
874 Alternate setting 0 is for bulk transfer.
875 Alternate setting 1 is for isochronous transfer.
876 We use bulk transfer (alternate setting 0). */
877 if (intf
->num_altsetting
< 1)
881 * Anysee is always warm (its USB-bridge, Cypress FX2, uploads
882 * firmware from eeprom). If dvb_usb_device_init() succeeds that
883 * means d is a valid pointer.
885 ret
= dvb_usb_device_init(intf
, &anysee_properties
, THIS_MODULE
, &d
,
890 alt
= usb_altnum_to_altsetting(intf
, 0);
892 deb_info("%s: no alt found!\n", __func__
);
896 ret
= usb_set_interface(d
->udev
, alt
->desc
.bInterfaceNumber
,
897 alt
->desc
.bAlternateSetting
);
901 return anysee_init(d
);
904 static struct usb_device_id anysee_table
[] = {
905 { USB_DEVICE(USB_VID_CYPRESS
, USB_PID_ANYSEE
) },
906 { USB_DEVICE(USB_VID_AMT
, USB_PID_ANYSEE
) },
907 { } /* Terminating entry */
909 MODULE_DEVICE_TABLE(usb
, anysee_table
);
911 static struct dvb_usb_device_properties anysee_properties
= {
912 .caps
= DVB_USB_IS_AN_I2C_ADAPTER
,
914 .usb_ctrl
= DEVICE_SPECIFIC
,
916 .size_of_priv
= sizeof(struct anysee_state
),
921 .streaming_ctrl
= anysee_streaming_ctrl
,
922 .frontend_attach
= anysee_frontend_attach
,
923 .tuner_attach
= anysee_tuner_attach
,
930 .buffersize
= (16*512),
938 .rc_codes
= RC_MAP_ANYSEE
,
939 .protocol
= RC_TYPE_OTHER
,
940 .module_name
= "anysee",
941 .rc_query
= anysee_rc_query
,
942 .rc_interval
= 250, /* windows driver uses 500ms */
945 .i2c_algo
= &anysee_i2c_algo
,
947 .generic_bulk_ctrl_endpoint
= 1,
949 .num_device_descs
= 1,
952 .name
= "Anysee DVB USB2.0",
954 .warm_ids
= {&anysee_table
[0],
955 &anysee_table
[1], NULL
},
960 static struct usb_driver anysee_driver
= {
961 .name
= "dvb_usb_anysee",
962 .probe
= anysee_probe
,
963 .disconnect
= dvb_usb_device_exit
,
964 .id_table
= anysee_table
,
968 static int __init
anysee_module_init(void)
972 ret
= usb_register(&anysee_driver
);
974 err("%s: usb_register failed. Error number %d", __func__
, ret
);
979 static void __exit
anysee_module_exit(void)
981 /* deregister this driver from the USB subsystem */
982 usb_deregister(&anysee_driver
);
985 module_init(anysee_module_init
);
986 module_exit(anysee_module_exit
);
988 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
989 MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0");
990 MODULE_LICENSE("GPL");