Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 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 |
Antti Palosaari | 9fdd9ca | 2008-06-11 11:43:19 -0300 | [diff] [blame] | 26 | * for ISO 7816 card reader, like dvb_ca_en50221 is implemented. This |
| 27 | * module registers serial interface that can be used to communicate |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 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" |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 39 | #include "tda18212.h" |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame^] | 40 | #include "cx24116.h" |
| 41 | #include "isl6423.h" |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 42 | |
| 43 | /* debug */ |
| 44 | static int dvb_usb_anysee_debug; |
| 45 | module_param_named(debug, dvb_usb_anysee_debug, int, 0644); |
| 46 | MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); |
Mauro Carvalho Chehab | ffbc5f8 | 2009-01-05 01:34:20 -0300 | [diff] [blame] | 47 | static int dvb_usb_anysee_delsys; |
Antti Palosaari | 0f77c3a | 2008-08-11 10:54:16 -0300 | [diff] [blame] | 48 | module_param_named(delsys, dvb_usb_anysee_delsys, int, 0644); |
| 49 | MODULE_PARM_DESC(delsys, "select delivery mode (0=DVB-C, 1=DVB-T)"); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 50 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 51 | |
Akinobu Mita | dec0c46 | 2008-10-29 21:16:04 -0300 | [diff] [blame] | 52 | static DEFINE_MUTEX(anysee_usb_mutex); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 53 | |
| 54 | static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, |
| 55 | u8 *rbuf, u8 rlen) |
| 56 | { |
| 57 | struct anysee_state *state = d->priv; |
| 58 | int act_len, ret; |
| 59 | u8 buf[64]; |
| 60 | |
| 61 | if (slen > sizeof(buf)) |
| 62 | slen = sizeof(buf); |
| 63 | memcpy(&buf[0], sbuf, slen); |
| 64 | buf[60] = state->seq++; |
| 65 | |
| 66 | if (mutex_lock_interruptible(&anysee_usb_mutex) < 0) |
| 67 | return -EAGAIN; |
| 68 | |
| 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); |
| 72 | |
| 73 | if (!ret) { |
| 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), |
| 77 | &act_len, 2000); |
| 78 | if (ret) |
| 79 | err("%s: recv bulk message failed: %d", __func__, ret); |
| 80 | else { |
| 81 | deb_xfer("<<< "); |
| 82 | debug_dump(buf, act_len, deb_xfer); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /* read request, copy returned data to return buf */ |
| 87 | if (!ret && rbuf && rlen) |
| 88 | memcpy(rbuf, buf, rlen); |
| 89 | |
| 90 | mutex_unlock(&anysee_usb_mutex); |
| 91 | |
| 92 | return ret; |
| 93 | } |
| 94 | |
| 95 | static int anysee_read_reg(struct dvb_usb_device *d, u16 reg, u8 *val) |
| 96 | { |
| 97 | u8 buf[] = {CMD_REG_READ, reg >> 8, reg & 0xff, 0x01}; |
| 98 | int ret; |
| 99 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), val, 1); |
| 100 | deb_info("%s: reg:%04x val:%02x\n", __func__, reg, *val); |
| 101 | return ret; |
| 102 | } |
| 103 | |
| 104 | static int anysee_write_reg(struct dvb_usb_device *d, u16 reg, u8 val) |
| 105 | { |
| 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); |
| 109 | } |
| 110 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 111 | /* write single register with mask */ |
| 112 | static int anysee_wr_reg_mask(struct dvb_usb_device *d, u16 reg, u8 val, |
| 113 | u8 mask) |
| 114 | { |
| 115 | int ret; |
| 116 | u8 tmp; |
| 117 | |
| 118 | /* no need for read if whole reg is written */ |
| 119 | if (mask != 0xff) { |
| 120 | ret = anysee_read_reg(d, reg, &tmp); |
| 121 | if (ret) |
| 122 | return ret; |
| 123 | |
| 124 | val &= mask; |
| 125 | tmp &= ~mask; |
| 126 | val |= tmp; |
| 127 | } |
| 128 | |
| 129 | return anysee_write_reg(d, reg, val); |
| 130 | } |
| 131 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 132 | static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id) |
| 133 | { |
| 134 | u8 buf[] = {CMD_GET_HW_INFO}; |
| 135 | return anysee_ctrl_msg(d, buf, sizeof(buf), id, 3); |
| 136 | } |
| 137 | |
| 138 | static int anysee_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) |
| 139 | { |
| 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); |
| 143 | } |
| 144 | |
| 145 | static int anysee_led_ctrl(struct dvb_usb_device *d, u8 mode, u8 interval) |
| 146 | { |
| 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); |
| 150 | } |
| 151 | |
| 152 | static int anysee_ir_ctrl(struct dvb_usb_device *d, u8 onoff) |
| 153 | { |
| 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); |
| 157 | } |
| 158 | |
| 159 | static int anysee_init(struct dvb_usb_device *d) |
| 160 | { |
| 161 | int ret; |
| 162 | /* LED light */ |
| 163 | ret = anysee_led_ctrl(d, 0x01, 0x03); |
| 164 | if (ret) |
| 165 | return ret; |
| 166 | |
| 167 | /* enable IR */ |
| 168 | ret = anysee_ir_ctrl(d, 1); |
| 169 | if (ret) |
| 170 | return ret; |
| 171 | |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | /* I2C */ |
| 176 | static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, |
| 177 | int num) |
| 178 | { |
| 179 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Mauro Carvalho Chehab | 902571a | 2008-12-29 19:02:24 -0300 | [diff] [blame] | 180 | int ret = 0, inc, i = 0; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 181 | |
| 182 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 183 | return -EAGAIN; |
| 184 | |
| 185 | while (i < num) { |
| 186 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { |
| 187 | u8 buf[6]; |
| 188 | buf[0] = CMD_I2C_READ; |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 189 | buf[1] = (msg[i].addr << 1) | 0x01; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 190 | buf[2] = msg[i].buf[0]; |
Antti Palosaari | 882b82c | 2011-04-12 19:49:25 -0300 | [diff] [blame] | 191 | buf[3] = msg[i].buf[1]; |
| 192 | buf[4] = msg[i].len-1; |
Antti Palosaari | b3e6a5a | 2011-04-09 21:00:51 -0300 | [diff] [blame] | 193 | buf[5] = msg[i+1].len; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 194 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), msg[i+1].buf, |
| 195 | msg[i+1].len); |
| 196 | inc = 2; |
| 197 | } else { |
| 198 | u8 buf[4+msg[i].len]; |
| 199 | buf[0] = CMD_I2C_WRITE; |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 200 | buf[1] = (msg[i].addr << 1); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 201 | buf[2] = msg[i].len; |
| 202 | buf[3] = 0x01; |
| 203 | memcpy(&buf[4], msg[i].buf, msg[i].len); |
| 204 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); |
| 205 | inc = 1; |
| 206 | } |
| 207 | if (ret) |
Antti Palosaari | e613f8f | 2008-08-11 10:36:43 -0300 | [diff] [blame] | 208 | break; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 209 | |
| 210 | i += inc; |
| 211 | } |
| 212 | |
| 213 | mutex_unlock(&d->i2c_mutex); |
| 214 | |
Antti Palosaari | e613f8f | 2008-08-11 10:36:43 -0300 | [diff] [blame] | 215 | return ret ? ret : i; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | static u32 anysee_i2c_func(struct i2c_adapter *adapter) |
| 219 | { |
| 220 | return I2C_FUNC_I2C; |
| 221 | } |
| 222 | |
| 223 | static struct i2c_algorithm anysee_i2c_algo = { |
| 224 | .master_xfer = anysee_master_xfer, |
| 225 | .functionality = anysee_i2c_func, |
| 226 | }; |
| 227 | |
| 228 | static int anysee_mt352_demod_init(struct dvb_frontend *fe) |
| 229 | { |
Antti Palosaari | ae3745f | 2009-09-16 19:50:25 -0300 | [diff] [blame] | 230 | static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x28 }; |
| 231 | static u8 reset[] = { RESET, 0x80 }; |
| 232 | static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 }; |
| 233 | static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0x20 }; |
| 234 | static u8 gpp_ctl_cfg[] = { GPP_CTL, 0x33 }; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 235 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 236 | |
| 237 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 238 | udelay(200); |
| 239 | mt352_write(fe, reset, sizeof(reset)); |
| 240 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 241 | |
| 242 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 243 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); |
| 244 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | /* Callbacks for DVB USB */ |
| 250 | static struct tda10023_config anysee_tda10023_config = { |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 251 | .demod_address = (0x1a >> 1), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 252 | .invert = 0, |
| 253 | .xtal = 16000000, |
| 254 | .pll_m = 11, |
| 255 | .pll_p = 3, |
| 256 | .pll_n = 1, |
Antti Palosaari | 5ae2fca | 2008-06-09 22:58:22 -0300 | [diff] [blame] | 257 | .output_mode = TDA10023_OUTPUT_MODE_PARALLEL_C, |
| 258 | .deltaf = 0xfeeb, |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 259 | }; |
| 260 | |
| 261 | static struct mt352_config anysee_mt352_config = { |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 262 | .demod_address = (0x1e >> 1), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 263 | .demod_init = anysee_mt352_demod_init, |
| 264 | }; |
| 265 | |
| 266 | static struct zl10353_config anysee_zl10353_config = { |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 267 | .demod_address = (0x1e >> 1), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 268 | .parallel_ts = 1, |
| 269 | }; |
| 270 | |
Antti Palosaari | 1fd8070 | 2011-04-12 17:34:08 -0300 | [diff] [blame] | 271 | static struct zl10353_config anysee_zl10353_tda18212_config2 = { |
| 272 | .demod_address = (0x1e >> 1), |
| 273 | .parallel_ts = 1, |
| 274 | .disable_i2c_gate_ctrl = 1, |
| 275 | .no_tuner = 1, |
| 276 | .if2 = 41500, |
| 277 | }; |
| 278 | |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 279 | static struct zl10353_config anysee_zl10353_tda18212_config = { |
| 280 | .demod_address = (0x18 >> 1), |
| 281 | .parallel_ts = 1, |
| 282 | .disable_i2c_gate_ctrl = 1, |
| 283 | .no_tuner = 1, |
| 284 | .if2 = 41500, |
| 285 | }; |
| 286 | |
| 287 | static struct tda10023_config anysee_tda10023_tda18212_config = { |
| 288 | .demod_address = (0x1a >> 1), |
| 289 | .xtal = 16000000, |
| 290 | .pll_m = 12, |
| 291 | .pll_p = 3, |
| 292 | .pll_n = 1, |
| 293 | .output_mode = TDA10023_OUTPUT_MODE_PARALLEL_C, |
| 294 | .deltaf = 0xba02, |
| 295 | }; |
| 296 | |
| 297 | static struct tda18212_config anysee_tda18212_config = { |
| 298 | .i2c_address = (0xc0 >> 1), |
| 299 | .if_dvbt_6 = 4150, |
| 300 | .if_dvbt_7 = 4150, |
| 301 | .if_dvbt_8 = 4150, |
| 302 | .if_dvbc = 5000, |
| 303 | }; |
| 304 | |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame^] | 305 | static struct cx24116_config anysee_cx24116_config = { |
| 306 | .demod_address = (0xaa >> 1), |
| 307 | .mpg_clk_pos_pol = 0x00, |
| 308 | .i2c_wr_max = 48, |
| 309 | }; |
| 310 | |
| 311 | static struct isl6423_config anysee_isl6423_config = { |
| 312 | .current_max = SEC_CURRENT_800m, |
| 313 | .curlim = SEC_CURRENT_LIM_OFF, |
| 314 | .mod_extern = 1, |
| 315 | .addr = (0x10 >> 1), |
| 316 | }; |
| 317 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 318 | /* |
| 319 | * New USB device strings: Mfr=1, Product=2, SerialNumber=0 |
| 320 | * Manufacturer: AMT.CO.KR |
| 321 | * |
| 322 | * E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=???????? |
| 323 | * PCB: ? |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 324 | * parts: DNOS404ZH102A(MT352, DTT7579(?)) |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 325 | * |
| 326 | * E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=???????? |
| 327 | * PCB: ? |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 328 | * parts: DNOS404ZH103A(ZL10353, DTT7579(?)) |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 329 | * |
| 330 | * E30 Plus VID=04b4 PID=861f HW=6 FW=1.0 "anysee" |
| 331 | * PCB: 507CD (rev1.1) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 332 | * parts: DNOS404ZH103A(ZL10353, DTT7579(?)), CST56I01 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 333 | * OEA=80 OEB=00 OEC=00 OED=ff OEF=fe |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 334 | * IOA=4f IOB=ff IOC=00 IOD=06 IOF=01 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 335 | * IOD[0] ZL10353 1=enabled |
| 336 | * IOA[7] TS 0=enabled |
| 337 | * tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not) |
| 338 | * |
| 339 | * E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)" |
| 340 | * PCB: 507DC (rev0.2) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 341 | * parts: TDA10023, DTOS403IH102B TM, CST56I01 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 342 | * OEA=80 OEB=00 OEC=00 OED=ff OEF=fe |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 343 | * IOA=4f IOB=ff IOC=00 IOD=26 IOF=01 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 344 | * IOD[0] TDA10023 1=enabled |
| 345 | * |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame^] | 346 | * E30 S2 Plus VID=04b4 PID=861f HW=11 FW=0.1 "anysee-S2(LP)" |
| 347 | * PCB: 507SI (rev2.1) |
| 348 | * parts: BS2N10WCC01(CX24116, CX24118), ISL6423, TDA8024 |
| 349 | * OEA=80 OEB=00 OEC=ff OED=ff OEF=fe |
| 350 | * IOA=4d IOB=ff IOC=00 IOD=26 IOF=01 |
| 351 | * IOD[0] CX24116 1=enabled |
| 352 | * |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 353 | * E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)" |
| 354 | * PCB: 507FA (rev0.4) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 355 | * parts: TDA10023, DTOS403IH102B TM, TDA8024 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 356 | * OEA=80 OEB=00 OEC=ff OED=ff OEF=ff |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 357 | * IOA=4d IOB=ff IOC=00 IOD=00 IOF=c0 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 358 | * IOD[5] TDA10023 1=enabled |
| 359 | * IOE[0] tuner 1=enabled |
| 360 | * |
| 361 | * E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)" |
| 362 | * PCB: 507FA (rev1.1) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 363 | * parts: ZL10353, TDA10023, DTOS403IH102B TM, TDA8024 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 364 | * OEA=80 OEB=00 OEC=ff OED=ff OEF=ff |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 365 | * IOA=4d IOB=ff IOC=00 IOD=00 IOF=c0 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 366 | * DVB-C: |
| 367 | * IOD[5] TDA10023 1=enabled |
| 368 | * IOE[0] tuner 1=enabled |
| 369 | * DVB-T: |
| 370 | * IOD[0] ZL10353 1=enabled |
| 371 | * IOE[0] tuner 0=enabled |
| 372 | * tuner is behind ZL10353 I2C-gate |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 373 | * |
| 374 | * E7 TC VID=1c73 PID=861f HW=18 FW=0.7 AMTCI=0.5 "anysee-E7TC(LP)" |
| 375 | * PCB: 508TC (rev0.6) |
| 376 | * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212) |
| 377 | * OEA=80 OEB=00 OEC=03 OED=f7 OEF=ff |
| 378 | * IOA=4d IOB=00 IOC=cc IOD=48 IOF=e4 |
| 379 | * IOA[7] TS 1=enabled |
| 380 | * IOE[4] TDA18212 1=enabled |
| 381 | * DVB-C: |
| 382 | * IOD[6] ZL10353 0=disabled |
| 383 | * IOD[5] TDA10023 1=enabled |
| 384 | * IOE[0] IF 1=enabled |
| 385 | * DVB-T: |
| 386 | * IOD[5] TDA10023 0=disabled |
| 387 | * IOD[6] ZL10353 1=enabled |
| 388 | * IOE[0] IF 0=enabled |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 389 | */ |
| 390 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 391 | static int anysee_frontend_attach(struct dvb_usb_adapter *adap) |
| 392 | { |
| 393 | int ret; |
| 394 | struct anysee_state *state = adap->dev->priv; |
| 395 | u8 hw_info[3]; |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 396 | u8 tmp; |
| 397 | struct i2c_msg msg[2] = { |
| 398 | { |
| 399 | .addr = anysee_tda18212_config.i2c_address, |
| 400 | .flags = 0, |
| 401 | .len = 1, |
| 402 | .buf = "\x00", |
| 403 | }, { |
| 404 | .addr = anysee_tda18212_config.i2c_address, |
| 405 | .flags = I2C_M_RD, |
| 406 | .len = 1, |
| 407 | .buf = &tmp, |
| 408 | } |
| 409 | }; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 410 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 411 | /* Check which hardware we have. |
| 412 | * We must do this call two times to get reliable values (hw bug). |
| 413 | */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 414 | ret = anysee_get_hw_info(adap->dev, hw_info); |
| 415 | if (ret) |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 416 | goto error; |
| 417 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 418 | ret = anysee_get_hw_info(adap->dev, hw_info); |
| 419 | if (ret) |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 420 | goto error; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 421 | |
| 422 | /* Meaning of these info bytes are guessed. */ |
Antti Palosaari | 592d9e2 | 2011-04-09 21:13:33 -0300 | [diff] [blame] | 423 | info("firmware version:%d.%d hardware id:%d", |
| 424 | hw_info[1], hw_info[2], hw_info[0]); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 425 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 426 | state->hw = hw_info[0]; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 427 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 428 | switch (state->hw) { |
| 429 | case ANYSEE_HW_02: /* 2 */ |
| 430 | /* E30 */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 431 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 432 | /* attach demod */ |
| 433 | adap->fe = dvb_attach(mt352_attach, &anysee_mt352_config, |
| 434 | &adap->dev->i2c_adap); |
| 435 | if (adap->fe) |
| 436 | break; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 437 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 438 | /* attach demod */ |
Antti Palosaari | 0f77c3a | 2008-08-11 10:54:16 -0300 | [diff] [blame] | 439 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 440 | &adap->dev->i2c_adap); |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 441 | |
| 442 | break; |
| 443 | case ANYSEE_HW_507CD: /* 6 */ |
| 444 | /* E30 Plus */ |
| 445 | |
| 446 | /* enable DVB-T demod on IOD[0] */ |
| 447 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); |
| 448 | if (ret) |
| 449 | goto error; |
| 450 | |
| 451 | /* enable transport stream on IOA[7] */ |
| 452 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (0 << 7), 0x80); |
| 453 | if (ret) |
| 454 | goto error; |
| 455 | |
| 456 | /* attach demod */ |
| 457 | adap->fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, |
| 458 | &adap->dev->i2c_adap); |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 459 | |
| 460 | break; |
| 461 | case ANYSEE_HW_507DC: /* 10 */ |
| 462 | /* E30 C Plus */ |
| 463 | |
| 464 | /* enable DVB-C demod on IOD[0] */ |
| 465 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); |
| 466 | if (ret) |
| 467 | goto error; |
| 468 | |
| 469 | /* attach demod */ |
| 470 | adap->fe = dvb_attach(tda10023_attach, &anysee_tda10023_config, |
| 471 | &adap->dev->i2c_adap, 0x48); |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 472 | |
| 473 | break; |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame^] | 474 | case ANYSEE_HW_507SI: /* 11 */ |
| 475 | /* E30 S2 Plus */ |
| 476 | |
| 477 | /* enable DVB-S/S2 demod on IOD[0] */ |
| 478 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); |
| 479 | if (ret) |
| 480 | goto error; |
| 481 | |
| 482 | /* attach demod */ |
| 483 | adap->fe = dvb_attach(cx24116_attach, &anysee_cx24116_config, |
| 484 | &adap->dev->i2c_adap); |
| 485 | |
| 486 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 487 | case ANYSEE_HW_507FA: /* 15 */ |
| 488 | /* E30 Combo Plus */ |
| 489 | /* E30 C Plus */ |
| 490 | |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 491 | /* enable tuner on IOE[4] */ |
| 492 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); |
| 493 | if (ret) |
| 494 | goto error; |
| 495 | |
| 496 | /* probe TDA18212 */ |
| 497 | tmp = 0; |
| 498 | ret = i2c_transfer(&adap->dev->i2c_adap, msg, 2); |
| 499 | if (ret == 2 && tmp == 0xc7) |
| 500 | deb_info("%s: TDA18212 found\n", __func__); |
| 501 | else |
| 502 | tmp = 0; |
| 503 | |
| 504 | /* disable tuner on IOE[4] */ |
| 505 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 4), 0x10); |
| 506 | if (ret) |
| 507 | goto error; |
| 508 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 509 | if (dvb_usb_anysee_delsys) { |
| 510 | /* disable DVB-C demod on IOD[5] */ |
| 511 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), |
| 512 | 0x20); |
| 513 | if (ret) |
| 514 | goto error; |
| 515 | |
| 516 | /* enable DVB-T demod on IOD[0] */ |
| 517 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), |
| 518 | 0x01); |
| 519 | if (ret) |
| 520 | goto error; |
| 521 | |
| 522 | /* attach demod */ |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 523 | if (tmp == 0xc7) { |
| 524 | /* TDA18212 config */ |
| 525 | adap->fe = dvb_attach(zl10353_attach, |
Antti Palosaari | 1fd8070 | 2011-04-12 17:34:08 -0300 | [diff] [blame] | 526 | &anysee_zl10353_tda18212_config2, |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 527 | &adap->dev->i2c_adap); |
| 528 | } else { |
| 529 | /* PLL config */ |
| 530 | adap->fe = dvb_attach(zl10353_attach, |
| 531 | &anysee_zl10353_config, |
| 532 | &adap->dev->i2c_adap); |
| 533 | } |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 534 | } else { |
| 535 | /* disable DVB-T demod on IOD[0] */ |
| 536 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0), |
| 537 | 0x01); |
| 538 | if (ret) |
| 539 | goto error; |
| 540 | |
| 541 | /* enable DVB-C demod on IOD[5] */ |
| 542 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), |
| 543 | 0x20); |
| 544 | if (ret) |
| 545 | goto error; |
| 546 | |
| 547 | /* attach demod */ |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 548 | if (tmp == 0xc7) { |
| 549 | /* TDA18212 config */ |
| 550 | adap->fe = dvb_attach(tda10023_attach, |
| 551 | &anysee_tda10023_tda18212_config, |
| 552 | &adap->dev->i2c_adap, 0x48); |
| 553 | } else { |
| 554 | /* PLL config */ |
| 555 | adap->fe = dvb_attach(tda10023_attach, |
| 556 | &anysee_tda10023_config, |
| 557 | &adap->dev->i2c_adap, 0x48); |
| 558 | } |
Antti Palosaari | 0f77c3a | 2008-08-11 10:54:16 -0300 | [diff] [blame] | 559 | } |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 560 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 561 | break; |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 562 | case ANYSEE_HW_508TC: /* 18 */ |
| 563 | /* E7 TC */ |
| 564 | |
| 565 | /* enable transport stream on IOA[7] */ |
| 566 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80); |
| 567 | if (ret) |
| 568 | goto error; |
| 569 | |
| 570 | if (dvb_usb_anysee_delsys) { |
| 571 | /* disable DVB-C demod on IOD[5] */ |
| 572 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), |
| 573 | 0x20); |
| 574 | if (ret) |
| 575 | goto error; |
| 576 | |
| 577 | /* enable DVB-T demod on IOD[6] */ |
| 578 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 6), |
| 579 | 0x40); |
| 580 | if (ret) |
| 581 | goto error; |
| 582 | |
| 583 | /* enable IF route on IOE[0] */ |
| 584 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0), |
| 585 | 0x01); |
| 586 | if (ret) |
| 587 | goto error; |
| 588 | |
| 589 | /* attach demod */ |
| 590 | adap->fe = dvb_attach(zl10353_attach, |
| 591 | &anysee_zl10353_tda18212_config, |
| 592 | &adap->dev->i2c_adap); |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 593 | } else { |
| 594 | /* disable DVB-T demod on IOD[6] */ |
| 595 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 6), |
| 596 | 0x40); |
| 597 | if (ret) |
| 598 | goto error; |
| 599 | |
| 600 | /* enable DVB-C demod on IOD[5] */ |
| 601 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), |
| 602 | 0x20); |
| 603 | if (ret) |
| 604 | goto error; |
| 605 | |
| 606 | /* enable IF route on IOE[0] */ |
| 607 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0), |
| 608 | 0x01); |
| 609 | if (ret) |
| 610 | goto error; |
| 611 | |
| 612 | /* attach demod */ |
| 613 | adap->fe = dvb_attach(tda10023_attach, |
| 614 | &anysee_tda10023_tda18212_config, |
| 615 | &adap->dev->i2c_adap, 0x48); |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 616 | } |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 617 | |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 618 | break; |
Antti Palosaari | 0f77c3a | 2008-08-11 10:54:16 -0300 | [diff] [blame] | 619 | } |
| 620 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 621 | if (!adap->fe) { |
| 622 | /* we have no frontend :-( */ |
| 623 | ret = -ENODEV; |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 624 | err("Unsupported Anysee version. " \ |
| 625 | "Please report the <linux-media@vger.kernel.org>."); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 626 | } |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 627 | error: |
| 628 | return ret; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | static int anysee_tuner_attach(struct dvb_usb_adapter *adap) |
| 632 | { |
| 633 | struct anysee_state *state = adap->dev->priv; |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 634 | struct dvb_frontend *fe; |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 635 | int ret; |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 636 | deb_info("%s:\n", __func__); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 637 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 638 | switch (state->hw) { |
| 639 | case ANYSEE_HW_02: /* 2 */ |
| 640 | /* E30 */ |
| 641 | |
| 642 | /* attach tuner */ |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 643 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc2 >> 1), |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 644 | NULL, DVB_PLL_THOMSON_DTT7579); |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 645 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 646 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 647 | case ANYSEE_HW_507CD: /* 6 */ |
| 648 | /* E30 Plus */ |
| 649 | |
| 650 | /* attach tuner */ |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 651 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc2 >> 1), |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 652 | &adap->dev->i2c_adap, DVB_PLL_THOMSON_DTT7579); |
| 653 | |
| 654 | break; |
| 655 | case ANYSEE_HW_507DC: /* 10 */ |
| 656 | /* E30 C Plus */ |
| 657 | |
| 658 | /* attach tuner */ |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 659 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc0 >> 1), |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 660 | &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 661 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 662 | break; |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame^] | 663 | case ANYSEE_HW_507SI: /* 11 */ |
| 664 | /* E30 S2 Plus */ |
| 665 | |
| 666 | /* attach LNB controller */ |
| 667 | fe = dvb_attach(isl6423_attach, adap->fe, &adap->dev->i2c_adap, |
| 668 | &anysee_isl6423_config); |
| 669 | |
| 670 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 671 | case ANYSEE_HW_507FA: /* 15 */ |
| 672 | /* E30 Combo Plus */ |
| 673 | /* E30 C Plus */ |
| 674 | |
Antti Palosaari | 59fb414 | 2011-04-12 10:22:47 -0300 | [diff] [blame] | 675 | if (dvb_usb_anysee_delsys) { |
| 676 | /* enable DVB-T tuner on IOE[0] */ |
| 677 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0), |
| 678 | 0x01); |
| 679 | if (ret) |
| 680 | goto error; |
| 681 | } else { |
| 682 | /* enable DVB-C tuner on IOE[0] */ |
| 683 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0), |
| 684 | 0x01); |
| 685 | if (ret) |
| 686 | goto error; |
| 687 | } |
| 688 | |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 689 | /* Try first attach TDA18212 silicon tuner on IOE[4], if that |
| 690 | * fails attach old simple PLL. */ |
| 691 | |
| 692 | /* enable tuner on IOE[4] */ |
| 693 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); |
| 694 | if (ret) |
| 695 | goto error; |
| 696 | |
| 697 | /* attach tuner */ |
| 698 | fe = dvb_attach(tda18212_attach, adap->fe, &adap->dev->i2c_adap, |
| 699 | &anysee_tda18212_config); |
| 700 | if (fe) |
| 701 | break; |
| 702 | |
| 703 | /* disable tuner on IOE[4] */ |
| 704 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 4), 0x10); |
| 705 | if (ret) |
| 706 | goto error; |
| 707 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 708 | /* attach tuner */ |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 709 | fe = dvb_attach(dvb_pll_attach, adap->fe, (0xc0 >> 1), |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 710 | &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); |
| 711 | |
| 712 | break; |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 713 | case ANYSEE_HW_508TC: /* 18 */ |
| 714 | /* E7 TC */ |
| 715 | |
| 716 | /* enable tuner on IOE[4] */ |
| 717 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); |
| 718 | if (ret) |
| 719 | goto error; |
| 720 | |
| 721 | /* attach tuner */ |
| 722 | fe = dvb_attach(tda18212_attach, adap->fe, &adap->dev->i2c_adap, |
| 723 | &anysee_tda18212_config); |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 724 | |
| 725 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 726 | default: |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 727 | fe = NULL; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 728 | } |
| 729 | |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 730 | if (fe) |
| 731 | ret = 0; |
| 732 | else |
| 733 | ret = -ENODEV; |
| 734 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 735 | error: |
| 736 | return ret; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 737 | } |
| 738 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 739 | static int anysee_rc_query(struct dvb_usb_device *d) |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 740 | { |
| 741 | u8 buf[] = {CMD_GET_IR_CODE}; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 742 | u8 ircode[2]; |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 743 | int ret; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 744 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 745 | /* Remote controller is basic NEC using address byte 0x08. |
| 746 | Anysee device RC query returns only two bytes, status and code, |
| 747 | address byte is dropped. Also it does not return any value for |
| 748 | NEC RCs having address byte other than 0x08. Due to that, we |
| 749 | cannot use that device as standard NEC receiver. |
| 750 | It could be possible make hack which reads whole code directly |
| 751 | from device memory... */ |
| 752 | |
| 753 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), ircode, sizeof(ircode)); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 754 | if (ret) |
| 755 | return ret; |
| 756 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 757 | if (ircode[0]) { |
| 758 | deb_rc("%s: key pressed %02x\n", __func__, ircode[1]); |
Mauro Carvalho Chehab | ca86674 | 2010-11-17 13:53:11 -0300 | [diff] [blame] | 759 | rc_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 760 | } |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 761 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 762 | return 0; |
| 763 | } |
| 764 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 765 | /* DVB USB Driver stuff */ |
| 766 | static struct dvb_usb_device_properties anysee_properties; |
| 767 | |
| 768 | static int anysee_probe(struct usb_interface *intf, |
| 769 | const struct usb_device_id *id) |
| 770 | { |
| 771 | struct dvb_usb_device *d; |
| 772 | struct usb_host_interface *alt; |
| 773 | int ret; |
| 774 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 775 | /* There is one interface with two alternate settings. |
| 776 | Alternate setting 0 is for bulk transfer. |
| 777 | Alternate setting 1 is for isochronous transfer. |
| 778 | We use bulk transfer (alternate setting 0). */ |
| 779 | if (intf->num_altsetting < 1) |
| 780 | return -ENODEV; |
| 781 | |
Dan Carpenter | 8b0d704 | 2010-05-31 16:27:39 -0300 | [diff] [blame] | 782 | /* |
| 783 | * Anysee is always warm (its USB-bridge, Cypress FX2, uploads |
| 784 | * firmware from eeprom). If dvb_usb_device_init() succeeds that |
| 785 | * means d is a valid pointer. |
| 786 | */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 787 | ret = dvb_usb_device_init(intf, &anysee_properties, THIS_MODULE, &d, |
| 788 | adapter_nr); |
| 789 | if (ret) |
| 790 | return ret; |
| 791 | |
| 792 | alt = usb_altnum_to_altsetting(intf, 0); |
| 793 | if (alt == NULL) { |
| 794 | deb_info("%s: no alt found!\n", __func__); |
| 795 | return -ENODEV; |
| 796 | } |
| 797 | |
| 798 | ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, |
| 799 | alt->desc.bAlternateSetting); |
| 800 | if (ret) |
| 801 | return ret; |
| 802 | |
Dan Carpenter | 8b0d704 | 2010-05-31 16:27:39 -0300 | [diff] [blame] | 803 | return anysee_init(d); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 804 | } |
| 805 | |
Antti Palosaari | ae3745f | 2009-09-16 19:50:25 -0300 | [diff] [blame] | 806 | static struct usb_device_id anysee_table[] = { |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 807 | { USB_DEVICE(USB_VID_CYPRESS, USB_PID_ANYSEE) }, |
| 808 | { USB_DEVICE(USB_VID_AMT, USB_PID_ANYSEE) }, |
| 809 | { } /* Terminating entry */ |
| 810 | }; |
| 811 | MODULE_DEVICE_TABLE(usb, anysee_table); |
| 812 | |
| 813 | static struct dvb_usb_device_properties anysee_properties = { |
| 814 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 815 | |
| 816 | .usb_ctrl = DEVICE_SPECIFIC, |
| 817 | |
| 818 | .size_of_priv = sizeof(struct anysee_state), |
| 819 | |
| 820 | .num_adapters = 1, |
| 821 | .adapter = { |
| 822 | { |
| 823 | .streaming_ctrl = anysee_streaming_ctrl, |
| 824 | .frontend_attach = anysee_frontend_attach, |
| 825 | .tuner_attach = anysee_tuner_attach, |
| 826 | .stream = { |
| 827 | .type = USB_BULK, |
| 828 | .count = 8, |
| 829 | .endpoint = 0x82, |
| 830 | .u = { |
| 831 | .bulk = { |
Antti Palosaari | ab69333 | 2009-09-16 19:47:01 -0300 | [diff] [blame] | 832 | .buffersize = (16*512), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 833 | } |
| 834 | } |
| 835 | }, |
| 836 | } |
| 837 | }, |
| 838 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 839 | .rc.core = { |
| 840 | .rc_codes = RC_MAP_ANYSEE, |
Mauro Carvalho Chehab | 52b6614 | 2010-11-17 14:20:52 -0300 | [diff] [blame] | 841 | .protocol = RC_TYPE_OTHER, |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 842 | .module_name = "anysee", |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 843 | .rc_query = anysee_rc_query, |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 844 | .rc_interval = 250, /* windows driver uses 500ms */ |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 845 | }, |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 846 | |
| 847 | .i2c_algo = &anysee_i2c_algo, |
| 848 | |
| 849 | .generic_bulk_ctrl_endpoint = 1, |
| 850 | |
| 851 | .num_device_descs = 1, |
| 852 | .devices = { |
| 853 | { |
| 854 | .name = "Anysee DVB USB2.0", |
| 855 | .cold_ids = {NULL}, |
| 856 | .warm_ids = {&anysee_table[0], |
| 857 | &anysee_table[1], NULL}, |
| 858 | }, |
| 859 | } |
| 860 | }; |
| 861 | |
| 862 | static struct usb_driver anysee_driver = { |
| 863 | .name = "dvb_usb_anysee", |
| 864 | .probe = anysee_probe, |
| 865 | .disconnect = dvb_usb_device_exit, |
| 866 | .id_table = anysee_table, |
| 867 | }; |
| 868 | |
| 869 | /* module stuff */ |
| 870 | static int __init anysee_module_init(void) |
| 871 | { |
| 872 | int ret; |
| 873 | |
| 874 | ret = usb_register(&anysee_driver); |
| 875 | if (ret) |
| 876 | err("%s: usb_register failed. Error number %d", __func__, ret); |
| 877 | |
| 878 | return ret; |
| 879 | } |
| 880 | |
| 881 | static void __exit anysee_module_exit(void) |
| 882 | { |
| 883 | /* deregister this driver from the USB subsystem */ |
| 884 | usb_deregister(&anysee_driver); |
| 885 | } |
| 886 | |
| 887 | module_init(anysee_module_init); |
| 888 | module_exit(anysee_module_exit); |
| 889 | |
| 890 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
| 891 | MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0"); |
| 892 | MODULE_LICENSE("GPL"); |