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" |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 41 | #include "stv0900.h" |
| 42 | #include "stv6110.h" |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 43 | #include "isl6423.h" |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame^] | 44 | #include "cxd2820r.h" |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 45 | |
| 46 | /* debug */ |
| 47 | static int dvb_usb_anysee_debug; |
| 48 | module_param_named(debug, dvb_usb_anysee_debug, int, 0644); |
| 49 | MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); |
Mauro Carvalho Chehab | ffbc5f8 | 2009-01-05 01:34:20 -0300 | [diff] [blame] | 50 | static int dvb_usb_anysee_delsys; |
Antti Palosaari | 0f77c3a | 2008-08-11 10:54:16 -0300 | [diff] [blame] | 51 | module_param_named(delsys, dvb_usb_anysee_delsys, int, 0644); |
| 52 | 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] | 53 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
| 54 | |
Akinobu Mita | dec0c46 | 2008-10-29 21:16:04 -0300 | [diff] [blame] | 55 | static DEFINE_MUTEX(anysee_usb_mutex); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 56 | |
| 57 | static int anysee_ctrl_msg(struct dvb_usb_device *d, u8 *sbuf, u8 slen, |
| 58 | u8 *rbuf, u8 rlen) |
| 59 | { |
| 60 | struct anysee_state *state = d->priv; |
| 61 | int act_len, ret; |
| 62 | u8 buf[64]; |
| 63 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 64 | memcpy(&buf[0], sbuf, slen); |
| 65 | buf[60] = state->seq++; |
| 66 | |
| 67 | if (mutex_lock_interruptible(&anysee_usb_mutex) < 0) |
| 68 | return -EAGAIN; |
| 69 | |
| 70 | /* 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. */ |
| 72 | ret = dvb_usb_generic_rw(d, buf, sizeof(buf), buf, sizeof(buf), 0); |
| 73 | |
| 74 | if (!ret) { |
| 75 | /* receive 2nd answer */ |
| 76 | ret = usb_bulk_msg(d->udev, usb_rcvbulkpipe(d->udev, |
| 77 | d->props.generic_bulk_ctrl_endpoint), buf, sizeof(buf), |
| 78 | &act_len, 2000); |
| 79 | if (ret) |
| 80 | err("%s: recv bulk message failed: %d", __func__, ret); |
| 81 | else { |
| 82 | deb_xfer("<<< "); |
| 83 | debug_dump(buf, act_len, deb_xfer); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /* read request, copy returned data to return buf */ |
| 88 | if (!ret && rbuf && rlen) |
| 89 | memcpy(rbuf, buf, rlen); |
| 90 | |
| 91 | mutex_unlock(&anysee_usb_mutex); |
| 92 | |
| 93 | return ret; |
| 94 | } |
| 95 | |
| 96 | static int anysee_read_reg(struct dvb_usb_device *d, u16 reg, u8 *val) |
| 97 | { |
| 98 | u8 buf[] = {CMD_REG_READ, reg >> 8, reg & 0xff, 0x01}; |
| 99 | int ret; |
| 100 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), val, 1); |
| 101 | deb_info("%s: reg:%04x val:%02x\n", __func__, reg, *val); |
| 102 | return ret; |
| 103 | } |
| 104 | |
| 105 | static int anysee_write_reg(struct dvb_usb_device *d, u16 reg, u8 val) |
| 106 | { |
| 107 | u8 buf[] = {CMD_REG_WRITE, reg >> 8, reg & 0xff, 0x01, val}; |
| 108 | deb_info("%s: reg:%04x val:%02x\n", __func__, reg, val); |
| 109 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); |
| 110 | } |
| 111 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 112 | /* write single register with mask */ |
| 113 | static int anysee_wr_reg_mask(struct dvb_usb_device *d, u16 reg, u8 val, |
| 114 | u8 mask) |
| 115 | { |
| 116 | int ret; |
| 117 | u8 tmp; |
| 118 | |
| 119 | /* no need for read if whole reg is written */ |
| 120 | if (mask != 0xff) { |
| 121 | ret = anysee_read_reg(d, reg, &tmp); |
| 122 | if (ret) |
| 123 | return ret; |
| 124 | |
| 125 | val &= mask; |
| 126 | tmp &= ~mask; |
| 127 | val |= tmp; |
| 128 | } |
| 129 | |
| 130 | return anysee_write_reg(d, reg, val); |
| 131 | } |
| 132 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 133 | static int anysee_get_hw_info(struct dvb_usb_device *d, u8 *id) |
| 134 | { |
| 135 | u8 buf[] = {CMD_GET_HW_INFO}; |
| 136 | return anysee_ctrl_msg(d, buf, sizeof(buf), id, 3); |
| 137 | } |
| 138 | |
| 139 | static int anysee_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) |
| 140 | { |
| 141 | u8 buf[] = {CMD_STREAMING_CTRL, (u8)onoff, 0x00}; |
| 142 | deb_info("%s: onoff:%02x\n", __func__, onoff); |
| 143 | return anysee_ctrl_msg(adap->dev, buf, sizeof(buf), NULL, 0); |
| 144 | } |
| 145 | |
| 146 | static int anysee_led_ctrl(struct dvb_usb_device *d, u8 mode, u8 interval) |
| 147 | { |
| 148 | u8 buf[] = {CMD_LED_AND_IR_CTRL, 0x01, mode, interval}; |
| 149 | deb_info("%s: state:%02x interval:%02x\n", __func__, mode, interval); |
| 150 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); |
| 151 | } |
| 152 | |
| 153 | static int anysee_ir_ctrl(struct dvb_usb_device *d, u8 onoff) |
| 154 | { |
| 155 | u8 buf[] = {CMD_LED_AND_IR_CTRL, 0x02, onoff}; |
| 156 | deb_info("%s: onoff:%02x\n", __func__, onoff); |
| 157 | return anysee_ctrl_msg(d, buf, sizeof(buf), NULL, 0); |
| 158 | } |
| 159 | |
| 160 | static int anysee_init(struct dvb_usb_device *d) |
| 161 | { |
| 162 | int ret; |
| 163 | /* LED light */ |
| 164 | ret = anysee_led_ctrl(d, 0x01, 0x03); |
| 165 | if (ret) |
| 166 | return ret; |
| 167 | |
| 168 | /* enable IR */ |
| 169 | ret = anysee_ir_ctrl(d, 1); |
| 170 | if (ret) |
| 171 | return ret; |
| 172 | |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | /* I2C */ |
| 177 | static int anysee_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, |
| 178 | int num) |
| 179 | { |
| 180 | struct dvb_usb_device *d = i2c_get_adapdata(adap); |
Mauro Carvalho Chehab | 902571a | 2008-12-29 19:02:24 -0300 | [diff] [blame] | 181 | int ret = 0, inc, i = 0; |
Antti Palosaari | 21d2e93 | 2011-05-24 06:04:08 -0300 | [diff] [blame] | 182 | u8 buf[52]; /* 4 + 48 (I2C WR USB command header + I2C WR max) */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 183 | |
| 184 | if (mutex_lock_interruptible(&d->i2c_mutex) < 0) |
| 185 | return -EAGAIN; |
| 186 | |
| 187 | while (i < num) { |
| 188 | if (num > i + 1 && (msg[i+1].flags & I2C_M_RD)) { |
Antti Palosaari | 21d2e93 | 2011-05-24 06:04:08 -0300 | [diff] [blame] | 189 | if (msg[i].len > 2 || msg[i+1].len > 60) { |
| 190 | ret = -EOPNOTSUPP; |
| 191 | break; |
| 192 | } |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 193 | buf[0] = CMD_I2C_READ; |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 194 | buf[1] = (msg[i].addr << 1) | 0x01; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 195 | buf[2] = msg[i].buf[0]; |
Antti Palosaari | 882b82c | 2011-04-12 19:49:25 -0300 | [diff] [blame] | 196 | buf[3] = msg[i].buf[1]; |
| 197 | buf[4] = msg[i].len-1; |
Antti Palosaari | b3e6a5a | 2011-04-09 21:00:51 -0300 | [diff] [blame] | 198 | buf[5] = msg[i+1].len; |
Antti Palosaari | 21d2e93 | 2011-05-24 06:04:08 -0300 | [diff] [blame] | 199 | ret = anysee_ctrl_msg(d, buf, 6, msg[i+1].buf, |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 200 | msg[i+1].len); |
| 201 | inc = 2; |
| 202 | } else { |
Antti Palosaari | 21d2e93 | 2011-05-24 06:04:08 -0300 | [diff] [blame] | 203 | if (msg[i].len > 48) { |
| 204 | ret = -EOPNOTSUPP; |
| 205 | break; |
| 206 | } |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 207 | buf[0] = CMD_I2C_WRITE; |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 208 | buf[1] = (msg[i].addr << 1); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 209 | buf[2] = msg[i].len; |
| 210 | buf[3] = 0x01; |
| 211 | memcpy(&buf[4], msg[i].buf, msg[i].len); |
Antti Palosaari | 21d2e93 | 2011-05-24 06:04:08 -0300 | [diff] [blame] | 212 | ret = anysee_ctrl_msg(d, buf, 4 + msg[i].len, NULL, 0); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 213 | inc = 1; |
| 214 | } |
| 215 | if (ret) |
Antti Palosaari | e613f8f | 2008-08-11 10:36:43 -0300 | [diff] [blame] | 216 | break; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 217 | |
| 218 | i += inc; |
| 219 | } |
| 220 | |
| 221 | mutex_unlock(&d->i2c_mutex); |
| 222 | |
Antti Palosaari | e613f8f | 2008-08-11 10:36:43 -0300 | [diff] [blame] | 223 | return ret ? ret : i; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | static u32 anysee_i2c_func(struct i2c_adapter *adapter) |
| 227 | { |
| 228 | return I2C_FUNC_I2C; |
| 229 | } |
| 230 | |
| 231 | static struct i2c_algorithm anysee_i2c_algo = { |
| 232 | .master_xfer = anysee_master_xfer, |
| 233 | .functionality = anysee_i2c_func, |
| 234 | }; |
| 235 | |
| 236 | static int anysee_mt352_demod_init(struct dvb_frontend *fe) |
| 237 | { |
Antti Palosaari | ae3745f | 2009-09-16 19:50:25 -0300 | [diff] [blame] | 238 | static u8 clock_config[] = { CLOCK_CTL, 0x38, 0x28 }; |
| 239 | static u8 reset[] = { RESET, 0x80 }; |
| 240 | static u8 adc_ctl_1_cfg[] = { ADC_CTL_1, 0x40 }; |
| 241 | static u8 agc_cfg[] = { AGC_TARGET, 0x28, 0x20 }; |
| 242 | static u8 gpp_ctl_cfg[] = { GPP_CTL, 0x33 }; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 243 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 }; |
| 244 | |
| 245 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 246 | udelay(200); |
| 247 | mt352_write(fe, reset, sizeof(reset)); |
| 248 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); |
| 249 | |
| 250 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); |
| 251 | mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg)); |
| 252 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); |
| 253 | |
| 254 | return 0; |
| 255 | } |
| 256 | |
| 257 | /* Callbacks for DVB USB */ |
| 258 | static struct tda10023_config anysee_tda10023_config = { |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 259 | .demod_address = (0x1a >> 1), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 260 | .invert = 0, |
| 261 | .xtal = 16000000, |
| 262 | .pll_m = 11, |
| 263 | .pll_p = 3, |
| 264 | .pll_n = 1, |
Antti Palosaari | 5ae2fca | 2008-06-09 22:58:22 -0300 | [diff] [blame] | 265 | .output_mode = TDA10023_OUTPUT_MODE_PARALLEL_C, |
| 266 | .deltaf = 0xfeeb, |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | static struct mt352_config anysee_mt352_config = { |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 270 | .demod_address = (0x1e >> 1), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 271 | .demod_init = anysee_mt352_demod_init, |
| 272 | }; |
| 273 | |
| 274 | static struct zl10353_config anysee_zl10353_config = { |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 275 | .demod_address = (0x1e >> 1), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 276 | .parallel_ts = 1, |
| 277 | }; |
| 278 | |
Antti Palosaari | 1fd8070 | 2011-04-12 17:34:08 -0300 | [diff] [blame] | 279 | static struct zl10353_config anysee_zl10353_tda18212_config2 = { |
| 280 | .demod_address = (0x1e >> 1), |
| 281 | .parallel_ts = 1, |
| 282 | .disable_i2c_gate_ctrl = 1, |
| 283 | .no_tuner = 1, |
| 284 | .if2 = 41500, |
| 285 | }; |
| 286 | |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 287 | static struct zl10353_config anysee_zl10353_tda18212_config = { |
| 288 | .demod_address = (0x18 >> 1), |
| 289 | .parallel_ts = 1, |
| 290 | .disable_i2c_gate_ctrl = 1, |
| 291 | .no_tuner = 1, |
| 292 | .if2 = 41500, |
| 293 | }; |
| 294 | |
| 295 | static struct tda10023_config anysee_tda10023_tda18212_config = { |
| 296 | .demod_address = (0x1a >> 1), |
| 297 | .xtal = 16000000, |
| 298 | .pll_m = 12, |
| 299 | .pll_p = 3, |
| 300 | .pll_n = 1, |
| 301 | .output_mode = TDA10023_OUTPUT_MODE_PARALLEL_C, |
| 302 | .deltaf = 0xba02, |
| 303 | }; |
| 304 | |
| 305 | static struct tda18212_config anysee_tda18212_config = { |
| 306 | .i2c_address = (0xc0 >> 1), |
| 307 | .if_dvbt_6 = 4150, |
| 308 | .if_dvbt_7 = 4150, |
| 309 | .if_dvbt_8 = 4150, |
| 310 | .if_dvbc = 5000, |
| 311 | }; |
| 312 | |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame^] | 313 | static struct tda18212_config anysee_tda18212_config2 = { |
| 314 | .i2c_address = 0x60 /* (0xc0 >> 1) */, |
| 315 | .if_dvbt_6 = 3550, |
| 316 | .if_dvbt_7 = 3700, |
| 317 | .if_dvbt_8 = 4150, |
| 318 | .if_dvbt2_6 = 3250, |
| 319 | .if_dvbt2_7 = 4000, |
| 320 | .if_dvbt2_8 = 4000, |
| 321 | .if_dvbc = 5000, |
| 322 | }; |
| 323 | |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 324 | static struct cx24116_config anysee_cx24116_config = { |
| 325 | .demod_address = (0xaa >> 1), |
| 326 | .mpg_clk_pos_pol = 0x00, |
| 327 | .i2c_wr_max = 48, |
| 328 | }; |
| 329 | |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 330 | static struct stv0900_config anysee_stv0900_config = { |
| 331 | .demod_address = (0xd0 >> 1), |
| 332 | .demod_mode = 0, |
| 333 | .xtal = 8000000, |
| 334 | .clkmode = 3, |
| 335 | .diseqc_mode = 2, |
| 336 | .tun1_maddress = 0, |
| 337 | .tun1_adc = 1, /* 1 Vpp */ |
| 338 | .path1_mode = 3, |
| 339 | }; |
| 340 | |
| 341 | static struct stv6110_config anysee_stv6110_config = { |
| 342 | .i2c_address = (0xc0 >> 1), |
| 343 | .mclk = 16000000, |
| 344 | .clk_div = 1, |
| 345 | }; |
| 346 | |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 347 | static struct isl6423_config anysee_isl6423_config = { |
| 348 | .current_max = SEC_CURRENT_800m, |
| 349 | .curlim = SEC_CURRENT_LIM_OFF, |
| 350 | .mod_extern = 1, |
| 351 | .addr = (0x10 >> 1), |
| 352 | }; |
| 353 | |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame^] | 354 | static struct cxd2820r_config anysee_cxd2820r_config = { |
| 355 | .i2c_address = 0x6d, /* (0xda >> 1) */ |
| 356 | .ts_mode = 0x38, |
| 357 | .if_dvbt_6 = 3550, |
| 358 | .if_dvbt_7 = 3700, |
| 359 | .if_dvbt_8 = 4150, |
| 360 | .if_dvbt2_6 = 3250, |
| 361 | .if_dvbt2_7 = 4000, |
| 362 | .if_dvbt2_8 = 4000, |
| 363 | .if_dvbc = 5000, |
| 364 | }; |
| 365 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 366 | /* |
| 367 | * New USB device strings: Mfr=1, Product=2, SerialNumber=0 |
| 368 | * Manufacturer: AMT.CO.KR |
| 369 | * |
| 370 | * E30 VID=04b4 PID=861f HW=2 FW=2.1 Product=???????? |
| 371 | * PCB: ? |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 372 | * parts: DNOS404ZH102A(MT352, DTT7579(?)) |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 373 | * |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 374 | * E30 VID=04b4 PID=861f HW=2 FW=2.1 "anysee-T(LP)" |
| 375 | * PCB: PCB 507T (rev1.61) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 376 | * parts: DNOS404ZH103A(ZL10353, DTT7579(?)) |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 377 | * OEA=0a OEB=00 OEC=00 OED=ff OEE=00 |
| 378 | * IOA=45 IOB=ff IOC=00 IOD=ff IOE=00 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 379 | * |
| 380 | * E30 Plus VID=04b4 PID=861f HW=6 FW=1.0 "anysee" |
| 381 | * PCB: 507CD (rev1.1) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 382 | * parts: DNOS404ZH103A(ZL10353, DTT7579(?)), CST56I01 |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 383 | * OEA=80 OEB=00 OEC=00 OED=ff OEE=fe |
| 384 | * IOA=4f IOB=ff IOC=00 IOD=06 IOE=01 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 385 | * IOD[0] ZL10353 1=enabled |
| 386 | * IOA[7] TS 0=enabled |
| 387 | * tuner is not behind ZL10353 I2C-gate (no care if gate disabled or not) |
| 388 | * |
| 389 | * E30 C Plus VID=04b4 PID=861f HW=10 FW=1.0 "anysee-DC(LP)" |
| 390 | * PCB: 507DC (rev0.2) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 391 | * parts: TDA10023, DTOS403IH102B TM, CST56I01 |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 392 | * OEA=80 OEB=00 OEC=00 OED=ff OEE=fe |
| 393 | * IOA=4f IOB=ff IOC=00 IOD=26 IOE=01 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 394 | * IOD[0] TDA10023 1=enabled |
| 395 | * |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 396 | * E30 S2 Plus VID=04b4 PID=861f HW=11 FW=0.1 "anysee-S2(LP)" |
| 397 | * PCB: 507SI (rev2.1) |
| 398 | * parts: BS2N10WCC01(CX24116, CX24118), ISL6423, TDA8024 |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 399 | * OEA=80 OEB=00 OEC=ff OED=ff OEE=fe |
| 400 | * IOA=4d IOB=ff IOC=00 IOD=26 IOE=01 |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 401 | * IOD[0] CX24116 1=enabled |
| 402 | * |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 403 | * E30 C Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)" |
| 404 | * PCB: 507FA (rev0.4) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 405 | * parts: TDA10023, DTOS403IH102B TM, TDA8024 |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 406 | * OEA=80 OEB=00 OEC=ff OED=ff OEE=ff |
| 407 | * IOA=4d IOB=ff IOC=00 IOD=00 IOE=c0 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 408 | * IOD[5] TDA10023 1=enabled |
| 409 | * IOE[0] tuner 1=enabled |
| 410 | * |
| 411 | * E30 Combo Plus VID=1c73 PID=861f HW=15 FW=1.2 "anysee-FA(LP)" |
| 412 | * PCB: 507FA (rev1.1) |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 413 | * parts: ZL10353, TDA10023, DTOS403IH102B TM, TDA8024 |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 414 | * OEA=80 OEB=00 OEC=ff OED=ff OEE=ff |
| 415 | * IOA=4d IOB=ff IOC=00 IOD=00 IOE=c0 |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 416 | * DVB-C: |
| 417 | * IOD[5] TDA10023 1=enabled |
| 418 | * IOE[0] tuner 1=enabled |
| 419 | * DVB-T: |
| 420 | * IOD[0] ZL10353 1=enabled |
| 421 | * IOE[0] tuner 0=enabled |
| 422 | * tuner is behind ZL10353 I2C-gate |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 423 | * |
| 424 | * E7 TC VID=1c73 PID=861f HW=18 FW=0.7 AMTCI=0.5 "anysee-E7TC(LP)" |
| 425 | * PCB: 508TC (rev0.6) |
| 426 | * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212) |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 427 | * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff |
| 428 | * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4 |
Antti Palosaari | 70fc26f | 2011-04-12 20:17:11 -0300 | [diff] [blame] | 429 | * IOA[7] TS 1=enabled |
| 430 | * IOE[4] TDA18212 1=enabled |
| 431 | * DVB-C: |
| 432 | * IOD[6] ZL10353 0=disabled |
| 433 | * IOD[5] TDA10023 1=enabled |
| 434 | * IOE[0] IF 1=enabled |
| 435 | * DVB-T: |
| 436 | * IOD[5] TDA10023 0=disabled |
| 437 | * IOD[6] ZL10353 1=enabled |
| 438 | * IOE[0] IF 0=enabled |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 439 | * |
| 440 | * E7 S2 VID=1c73 PID=861f HW=19 FW=0.4 AMTCI=0.5 "anysee-E7S2(LP)" |
| 441 | * PCB: 508S2 (rev0.7) |
| 442 | * parts: DNBU10512IST(STV0903, STV6110), ISL6423 |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 443 | * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff |
| 444 | * IOA=4d IOB=00 IOC=c4 IOD=08 IOE=e4 |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 445 | * IOA[7] TS 1=enabled |
| 446 | * IOE[5] STV0903 1=enabled |
| 447 | * |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame^] | 448 | * E7 T2C VID=1c73 PID=861f HW=20 FW=0.1 AMTCI=0.5 "anysee-E7T2C(LP)" |
| 449 | * PCB: 508T2C (rev0.3) |
| 450 | * parts: DNOQ44QCH106A(CXD2820R, TDA18212), TDA8024 |
| 451 | * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff |
| 452 | * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4 |
| 453 | * IOA[7] TS 1=enabled |
| 454 | * IOE[5] CXD2820R 1=enabled |
| 455 | * |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame] | 456 | * E7 PTC VID=1c73 PID=861f HW=21 FW=0.1 AMTCI=?? "anysee-E7PTC(LP)" |
| 457 | * PCB: 508PTC (rev0.5) |
| 458 | * parts: ZL10353, TDA10023, DNOD44CDH086A(TDA18212) |
| 459 | * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff |
| 460 | * IOA=4d IOB=00 IOC=cc IOD=48 IOE=e4 |
| 461 | * IOA[7] TS 1=enabled |
| 462 | * IOE[4] TDA18212 1=enabled |
| 463 | * DVB-C: |
| 464 | * IOD[6] ZL10353 0=disabled |
| 465 | * IOD[5] TDA10023 1=enabled |
| 466 | * IOE[0] IF 1=enabled |
| 467 | * DVB-T: |
| 468 | * IOD[5] TDA10023 0=disabled |
| 469 | * IOD[6] ZL10353 1=enabled |
| 470 | * IOE[0] IF 0=enabled |
Antti Palosaari | fea3c39 | 2011-05-25 18:21:43 -0300 | [diff] [blame] | 471 | * |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame^] | 472 | * E7 PS2 VID=1c73 PID=861f HW=22 FW=0.1 AMTCI=?? "anysee-E7PS2(LP)" |
Antti Palosaari | fea3c39 | 2011-05-25 18:21:43 -0300 | [diff] [blame] | 473 | * PCB: 508PS2 (rev0.4) |
| 474 | * parts: DNBU10512IST(STV0903, STV6110), ISL6423 |
| 475 | * OEA=80 OEB=00 OEC=03 OED=f7 OEE=ff |
| 476 | * IOA=4d IOB=00 IOC=c4 IOD=08 IOE=e4 |
| 477 | * IOA[7] TS 1=enabled |
| 478 | * IOE[5] STV0903 1=enabled |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 479 | */ |
| 480 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 481 | static int anysee_frontend_ctrl(struct dvb_frontend *fe, int onoff) |
| 482 | { |
| 483 | struct dvb_usb_adapter *adap = fe->dvb->priv; |
| 484 | struct anysee_state *state = adap->dev->priv; |
| 485 | int ret; |
| 486 | |
| 487 | deb_info("%s: fe=%d onoff=%d\n", __func__, fe->id, onoff); |
| 488 | |
| 489 | /* no frontend sleep control */ |
| 490 | if (onoff == 0) |
| 491 | return 0; |
| 492 | |
| 493 | switch (state->hw) { |
| 494 | case ANYSEE_HW_507FA: /* 15 */ |
| 495 | /* E30 Combo Plus */ |
| 496 | /* E30 C Plus */ |
| 497 | |
| 498 | if ((fe->id ^ dvb_usb_anysee_delsys) == 0) { |
| 499 | /* disable DVB-T demod on IOD[0] */ |
| 500 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0), |
| 501 | 0x01); |
| 502 | if (ret) |
| 503 | goto error; |
| 504 | |
| 505 | /* enable DVB-C demod on IOD[5] */ |
| 506 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), |
| 507 | 0x20); |
| 508 | if (ret) |
| 509 | goto error; |
| 510 | |
| 511 | /* enable DVB-C tuner on IOE[0] */ |
| 512 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0), |
| 513 | 0x01); |
| 514 | if (ret) |
| 515 | goto error; |
| 516 | } else { |
| 517 | /* disable DVB-C demod on IOD[5] */ |
| 518 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), |
| 519 | 0x20); |
| 520 | if (ret) |
| 521 | goto error; |
| 522 | |
| 523 | /* enable DVB-T demod on IOD[0] */ |
| 524 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), |
| 525 | 0x01); |
| 526 | if (ret) |
| 527 | goto error; |
| 528 | |
| 529 | /* enable DVB-T tuner on IOE[0] */ |
| 530 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0), |
| 531 | 0x01); |
| 532 | if (ret) |
| 533 | goto error; |
| 534 | } |
| 535 | |
| 536 | break; |
| 537 | case ANYSEE_HW_508TC: /* 18 */ |
| 538 | case ANYSEE_HW_508PTC: /* 21 */ |
| 539 | /* E7 TC */ |
| 540 | /* E7 PTC */ |
| 541 | |
| 542 | if ((fe->id ^ dvb_usb_anysee_delsys) == 0) { |
| 543 | /* disable DVB-T demod on IOD[6] */ |
| 544 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 6), |
| 545 | 0x40); |
| 546 | if (ret) |
| 547 | goto error; |
| 548 | |
| 549 | /* enable DVB-C demod on IOD[5] */ |
| 550 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), |
| 551 | 0x20); |
| 552 | if (ret) |
| 553 | goto error; |
| 554 | |
| 555 | /* enable IF route on IOE[0] */ |
| 556 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 0), |
| 557 | 0x01); |
| 558 | if (ret) |
| 559 | goto error; |
| 560 | } else { |
| 561 | /* disable DVB-C demod on IOD[5] */ |
| 562 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), |
| 563 | 0x20); |
| 564 | if (ret) |
| 565 | goto error; |
| 566 | |
| 567 | /* enable DVB-T demod on IOD[6] */ |
| 568 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 6), |
| 569 | 0x40); |
| 570 | if (ret) |
| 571 | goto error; |
| 572 | |
| 573 | /* enable IF route on IOE[0] */ |
| 574 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 0), |
| 575 | 0x01); |
| 576 | if (ret) |
| 577 | goto error; |
| 578 | } |
| 579 | |
| 580 | break; |
| 581 | default: |
| 582 | ret = 0; |
| 583 | } |
| 584 | |
| 585 | error: |
| 586 | return ret; |
| 587 | } |
| 588 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 589 | static int anysee_frontend_attach(struct dvb_usb_adapter *adap) |
| 590 | { |
| 591 | int ret; |
| 592 | struct anysee_state *state = adap->dev->priv; |
| 593 | u8 hw_info[3]; |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 594 | u8 tmp; |
| 595 | struct i2c_msg msg[2] = { |
| 596 | { |
| 597 | .addr = anysee_tda18212_config.i2c_address, |
| 598 | .flags = 0, |
| 599 | .len = 1, |
| 600 | .buf = "\x00", |
| 601 | }, { |
| 602 | .addr = anysee_tda18212_config.i2c_address, |
| 603 | .flags = I2C_M_RD, |
| 604 | .len = 1, |
| 605 | .buf = &tmp, |
| 606 | } |
| 607 | }; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 608 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 609 | /* detect hardware only once */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 610 | if (adap->fe_adap[0].fe == NULL) { |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 611 | /* Check which hardware we have. |
| 612 | * We must do this call two times to get reliable values (hw bug). |
| 613 | */ |
| 614 | ret = anysee_get_hw_info(adap->dev, hw_info); |
| 615 | if (ret) |
| 616 | goto error; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 617 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 618 | ret = anysee_get_hw_info(adap->dev, hw_info); |
| 619 | if (ret) |
| 620 | goto error; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 621 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 622 | /* Meaning of these info bytes are guessed. */ |
| 623 | info("firmware version:%d.%d hardware id:%d", |
| 624 | hw_info[1], hw_info[2], hw_info[0]); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 625 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 626 | state->hw = hw_info[0]; |
| 627 | } |
| 628 | |
| 629 | /* set current frondend ID for devices having two frondends */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 630 | if (adap->fe_adap[0].fe) |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 631 | state->fe_id++; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 632 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 633 | switch (state->hw) { |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 634 | case ANYSEE_HW_507T: /* 2 */ |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 635 | /* E30 */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 636 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 637 | if (state->fe_id) |
| 638 | break; |
| 639 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 640 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 641 | adap->fe_adap[0].fe = dvb_attach(mt352_attach, &anysee_mt352_config, |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 642 | &adap->dev->i2c_adap); |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 643 | if (adap->fe_adap[0].fe) |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 644 | break; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 645 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 646 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 647 | adap->fe_adap[0].fe = dvb_attach(zl10353_attach, &anysee_zl10353_config, |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 648 | &adap->dev->i2c_adap); |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 649 | |
| 650 | break; |
| 651 | case ANYSEE_HW_507CD: /* 6 */ |
| 652 | /* E30 Plus */ |
| 653 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 654 | if (state->fe_id) |
| 655 | break; |
| 656 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 657 | /* enable DVB-T demod on IOD[0] */ |
| 658 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); |
| 659 | if (ret) |
| 660 | goto error; |
| 661 | |
| 662 | /* enable transport stream on IOA[7] */ |
| 663 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (0 << 7), 0x80); |
| 664 | if (ret) |
| 665 | goto error; |
| 666 | |
| 667 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 668 | adap->fe_adap[0].fe = dvb_attach(zl10353_attach, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 669 | &anysee_zl10353_config, &adap->dev->i2c_adap); |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 670 | |
| 671 | break; |
| 672 | case ANYSEE_HW_507DC: /* 10 */ |
| 673 | /* E30 C Plus */ |
| 674 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 675 | if (state->fe_id) |
| 676 | break; |
| 677 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 678 | /* enable DVB-C demod on IOD[0] */ |
| 679 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); |
| 680 | if (ret) |
| 681 | goto error; |
| 682 | |
| 683 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 684 | adap->fe_adap[0].fe = dvb_attach(tda10023_attach, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 685 | &anysee_tda10023_config, &adap->dev->i2c_adap, 0x48); |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 686 | |
| 687 | break; |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 688 | case ANYSEE_HW_507SI: /* 11 */ |
| 689 | /* E30 S2 Plus */ |
| 690 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 691 | if (state->fe_id) |
| 692 | break; |
| 693 | |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 694 | /* enable DVB-S/S2 demod on IOD[0] */ |
| 695 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), 0x01); |
| 696 | if (ret) |
| 697 | goto error; |
| 698 | |
| 699 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 700 | adap->fe_adap[0].fe = dvb_attach(cx24116_attach, &anysee_cx24116_config, |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 701 | &adap->dev->i2c_adap); |
| 702 | |
| 703 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 704 | case ANYSEE_HW_507FA: /* 15 */ |
| 705 | /* E30 Combo Plus */ |
| 706 | /* E30 C Plus */ |
| 707 | |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 708 | /* enable tuner on IOE[4] */ |
| 709 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); |
| 710 | if (ret) |
| 711 | goto error; |
| 712 | |
| 713 | /* probe TDA18212 */ |
| 714 | tmp = 0; |
| 715 | ret = i2c_transfer(&adap->dev->i2c_adap, msg, 2); |
| 716 | if (ret == 2 && tmp == 0xc7) |
| 717 | deb_info("%s: TDA18212 found\n", __func__); |
| 718 | else |
| 719 | tmp = 0; |
| 720 | |
| 721 | /* disable tuner on IOE[4] */ |
| 722 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 4), 0x10); |
| 723 | if (ret) |
| 724 | goto error; |
| 725 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 726 | if ((state->fe_id ^ dvb_usb_anysee_delsys) == 0) { |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 727 | /* disable DVB-T demod on IOD[0] */ |
| 728 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 0), |
| 729 | 0x01); |
| 730 | if (ret) |
| 731 | goto error; |
| 732 | |
| 733 | /* enable DVB-C demod on IOD[5] */ |
| 734 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), |
| 735 | 0x20); |
| 736 | if (ret) |
| 737 | goto error; |
| 738 | |
| 739 | /* attach demod */ |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 740 | if (tmp == 0xc7) { |
| 741 | /* TDA18212 config */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 742 | adap->fe_adap[state->fe_id].fe = dvb_attach( |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 743 | tda10023_attach, |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 744 | &anysee_tda10023_tda18212_config, |
| 745 | &adap->dev->i2c_adap, 0x48); |
| 746 | } else { |
| 747 | /* PLL config */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 748 | adap->fe_adap[state->fe_id].fe = dvb_attach( |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 749 | tda10023_attach, |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 750 | &anysee_tda10023_config, |
| 751 | &adap->dev->i2c_adap, 0x48); |
| 752 | } |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 753 | } else { |
| 754 | /* disable DVB-C demod on IOD[5] */ |
| 755 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), |
| 756 | 0x20); |
| 757 | if (ret) |
| 758 | goto error; |
| 759 | |
| 760 | /* enable DVB-T demod on IOD[0] */ |
| 761 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 0), |
| 762 | 0x01); |
| 763 | if (ret) |
| 764 | goto error; |
| 765 | |
| 766 | /* attach demod */ |
| 767 | if (tmp == 0xc7) { |
| 768 | /* TDA18212 config */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 769 | adap->fe_adap[state->fe_id].fe = dvb_attach( |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 770 | zl10353_attach, |
| 771 | &anysee_zl10353_tda18212_config2, |
| 772 | &adap->dev->i2c_adap); |
| 773 | } else { |
| 774 | /* PLL config */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 775 | adap->fe_adap[state->fe_id].fe = dvb_attach( |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 776 | zl10353_attach, |
| 777 | &anysee_zl10353_config, |
| 778 | &adap->dev->i2c_adap); |
| 779 | } |
Antti Palosaari | 0f77c3a | 2008-08-11 10:54:16 -0300 | [diff] [blame] | 780 | } |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 781 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 782 | break; |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 783 | case ANYSEE_HW_508TC: /* 18 */ |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame] | 784 | case ANYSEE_HW_508PTC: /* 21 */ |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 785 | /* E7 TC */ |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame] | 786 | /* E7 PTC */ |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 787 | |
| 788 | /* enable transport stream on IOA[7] */ |
| 789 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80); |
| 790 | if (ret) |
| 791 | goto error; |
| 792 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 793 | if ((state->fe_id ^ dvb_usb_anysee_delsys) == 0) { |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 794 | /* disable DVB-T demod on IOD[6] */ |
| 795 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 6), |
| 796 | 0x40); |
| 797 | if (ret) |
| 798 | goto error; |
| 799 | |
| 800 | /* enable DVB-C demod on IOD[5] */ |
| 801 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 5), |
| 802 | 0x20); |
| 803 | if (ret) |
| 804 | goto error; |
| 805 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 806 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 807 | adap->fe_adap[state->fe_id].fe = dvb_attach(tda10023_attach, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 808 | &anysee_tda10023_tda18212_config, |
| 809 | &adap->dev->i2c_adap, 0x48); |
| 810 | } else { |
| 811 | /* disable DVB-C demod on IOD[5] */ |
| 812 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (0 << 5), |
| 813 | 0x20); |
| 814 | if (ret) |
| 815 | goto error; |
| 816 | |
| 817 | /* enable DVB-T demod on IOD[6] */ |
| 818 | ret = anysee_wr_reg_mask(adap->dev, REG_IOD, (1 << 6), |
| 819 | 0x40); |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 820 | if (ret) |
| 821 | goto error; |
| 822 | |
| 823 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 824 | adap->fe_adap[state->fe_id].fe = dvb_attach(zl10353_attach, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 825 | &anysee_zl10353_tda18212_config, |
| 826 | &adap->dev->i2c_adap); |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 827 | } |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 828 | |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 829 | break; |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 830 | case ANYSEE_HW_508S2: /* 19 */ |
Antti Palosaari | fea3c39 | 2011-05-25 18:21:43 -0300 | [diff] [blame] | 831 | case ANYSEE_HW_508PS2: /* 22 */ |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 832 | /* E7 S2 */ |
Antti Palosaari | fea3c39 | 2011-05-25 18:21:43 -0300 | [diff] [blame] | 833 | /* E7 PS2 */ |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 834 | |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 835 | if (state->fe_id) |
| 836 | break; |
| 837 | |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 838 | /* enable transport stream on IOA[7] */ |
| 839 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80); |
| 840 | if (ret) |
| 841 | goto error; |
| 842 | |
| 843 | /* enable DVB-S/S2 demod on IOE[5] */ |
| 844 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 5), 0x20); |
| 845 | if (ret) |
| 846 | goto error; |
| 847 | |
| 848 | /* attach demod */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 849 | adap->fe_adap[0].fe = dvb_attach(stv0900_attach, &anysee_stv0900_config, |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 850 | &adap->dev->i2c_adap, 0); |
| 851 | |
| 852 | break; |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame^] | 853 | case ANYSEE_HW_508T2C: /* 20 */ |
| 854 | /* E7 T2C */ |
| 855 | |
| 856 | /* enable transport stream on IOA[7] */ |
| 857 | ret = anysee_wr_reg_mask(adap->dev, REG_IOA, (1 << 7), 0x80); |
| 858 | if (ret) |
| 859 | goto error; |
| 860 | |
| 861 | /* enable DVB-T/T2/C demod on IOE[5] */ |
| 862 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 5), 0x20); |
| 863 | if (ret) |
| 864 | goto error; |
| 865 | |
| 866 | if (state->fe_id == 0) { |
| 867 | /* DVB-T/T2 */ |
| 868 | adap->fe[0] = dvb_attach(cxd2820r_attach, |
| 869 | &anysee_cxd2820r_config, |
| 870 | &adap->dev->i2c_adap, NULL); |
| 871 | } else { |
| 872 | /* DVB-C */ |
| 873 | adap->fe[1] = dvb_attach(cxd2820r_attach, |
| 874 | &anysee_cxd2820r_config, |
| 875 | &adap->dev->i2c_adap, adap->fe[0]); |
| 876 | } |
| 877 | |
| 878 | break; |
Antti Palosaari | 0f77c3a | 2008-08-11 10:54:16 -0300 | [diff] [blame] | 879 | } |
| 880 | |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 881 | if (!adap->fe_adap[0].fe) { |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 882 | /* we have no frontend :-( */ |
| 883 | ret = -ENODEV; |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 884 | err("Unsupported Anysee version. " \ |
| 885 | "Please report the <linux-media@vger.kernel.org>."); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 886 | } |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 887 | error: |
| 888 | return ret; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 889 | } |
| 890 | |
| 891 | static int anysee_tuner_attach(struct dvb_usb_adapter *adap) |
| 892 | { |
| 893 | struct anysee_state *state = adap->dev->priv; |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 894 | struct dvb_frontend *fe; |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 895 | int ret; |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 896 | deb_info("%s: fe=%d\n", __func__, state->fe_id); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 897 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 898 | switch (state->hw) { |
Antti Palosaari | 05c46c0 | 2011-05-25 18:30:09 -0300 | [diff] [blame] | 899 | case ANYSEE_HW_507T: /* 2 */ |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 900 | /* E30 */ |
| 901 | |
| 902 | /* attach tuner */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 903 | fe = dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, (0xc2 >> 1), |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 904 | NULL, DVB_PLL_THOMSON_DTT7579); |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 905 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 906 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 907 | case ANYSEE_HW_507CD: /* 6 */ |
| 908 | /* E30 Plus */ |
| 909 | |
| 910 | /* attach tuner */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 911 | fe = dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, (0xc2 >> 1), |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 912 | &adap->dev->i2c_adap, DVB_PLL_THOMSON_DTT7579); |
| 913 | |
| 914 | break; |
| 915 | case ANYSEE_HW_507DC: /* 10 */ |
| 916 | /* E30 C Plus */ |
| 917 | |
| 918 | /* attach tuner */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 919 | fe = dvb_attach(dvb_pll_attach, adap->fe_adap[0].fe, (0xc0 >> 1), |
Antti Palosaari | 7ea03d2 | 2011-04-09 20:50:07 -0300 | [diff] [blame] | 920 | &adap->dev->i2c_adap, DVB_PLL_SAMSUNG_DTOS403IH102A); |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 921 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 922 | break; |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 923 | case ANYSEE_HW_507SI: /* 11 */ |
| 924 | /* E30 S2 Plus */ |
| 925 | |
| 926 | /* attach LNB controller */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 927 | fe = dvb_attach(isl6423_attach, adap->fe_adap[0].fe, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 928 | &adap->dev->i2c_adap, &anysee_isl6423_config); |
Antti Palosaari | f0a5310 | 2011-04-27 21:11:59 -0300 | [diff] [blame] | 929 | |
| 930 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 931 | case ANYSEE_HW_507FA: /* 15 */ |
| 932 | /* E30 Combo Plus */ |
| 933 | /* E30 C Plus */ |
| 934 | |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 935 | /* Try first attach TDA18212 silicon tuner on IOE[4], if that |
| 936 | * fails attach old simple PLL. */ |
| 937 | |
| 938 | /* enable tuner on IOE[4] */ |
| 939 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); |
| 940 | if (ret) |
| 941 | goto error; |
| 942 | |
| 943 | /* attach tuner */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 944 | fe = dvb_attach(tda18212_attach, adap->fe_adap[state->fe_id].fe, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 945 | &adap->dev->i2c_adap, &anysee_tda18212_config); |
Antti Palosaari | 72ffd2b | 2011-04-10 20:14:50 -0300 | [diff] [blame] | 946 | if (fe) |
| 947 | break; |
| 948 | |
| 949 | /* disable tuner on IOE[4] */ |
| 950 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (0 << 4), 0x10); |
| 951 | if (ret) |
| 952 | goto error; |
| 953 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 954 | /* attach tuner */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 955 | fe = dvb_attach(dvb_pll_attach, adap->fe_adap[state->fe_id].fe, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 956 | (0xc0 >> 1), &adap->dev->i2c_adap, |
| 957 | DVB_PLL_SAMSUNG_DTOS403IH102A); |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 958 | |
| 959 | break; |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 960 | case ANYSEE_HW_508TC: /* 18 */ |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame] | 961 | case ANYSEE_HW_508PTC: /* 21 */ |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 962 | /* E7 TC */ |
Antti Palosaari | 8439e0d | 2011-05-24 07:57:34 -0300 | [diff] [blame] | 963 | /* E7 PTC */ |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 964 | |
| 965 | /* enable tuner on IOE[4] */ |
| 966 | ret = anysee_wr_reg_mask(adap->dev, REG_IOE, (1 << 4), 0x10); |
| 967 | if (ret) |
| 968 | goto error; |
| 969 | |
| 970 | /* attach tuner */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 971 | fe = dvb_attach(tda18212_attach, adap->fe_adap[state->fe_id].fe, |
Antti Palosaari | 449d1a0 | 2011-07-25 20:25:21 -0300 | [diff] [blame] | 972 | &adap->dev->i2c_adap, &anysee_tda18212_config); |
Antti Palosaari | a43be98 | 2011-04-10 20:23:02 -0300 | [diff] [blame] | 973 | |
| 974 | break; |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 975 | case ANYSEE_HW_508S2: /* 19 */ |
Antti Palosaari | fea3c39 | 2011-05-25 18:21:43 -0300 | [diff] [blame] | 976 | case ANYSEE_HW_508PS2: /* 22 */ |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 977 | /* E7 S2 */ |
Antti Palosaari | fea3c39 | 2011-05-25 18:21:43 -0300 | [diff] [blame] | 978 | /* E7 PS2 */ |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 979 | |
| 980 | /* attach tuner */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 981 | fe = dvb_attach(stv6110_attach, adap->fe_adap[0].fe, |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 982 | &anysee_stv6110_config, &adap->dev->i2c_adap); |
| 983 | |
| 984 | if (fe) { |
| 985 | /* attach LNB controller */ |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 986 | fe = dvb_attach(isl6423_attach, adap->fe_adap[0].fe, |
Antti Palosaari | bedbf3d | 2011-04-29 13:55:02 -0300 | [diff] [blame] | 987 | &adap->dev->i2c_adap, &anysee_isl6423_config); |
| 988 | } |
| 989 | |
| 990 | break; |
Antti Palosaari | 608add8 | 2011-08-12 18:29:46 -0300 | [diff] [blame^] | 991 | |
| 992 | case ANYSEE_HW_508T2C: /* 20 */ |
| 993 | /* E7 T2C */ |
| 994 | |
| 995 | /* attach tuner */ |
| 996 | fe = dvb_attach(tda18212_attach, adap->fe[state->fe_id], |
| 997 | &adap->dev->i2c_adap, &anysee_tda18212_config2); |
| 998 | |
| 999 | break; |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 1000 | default: |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 1001 | fe = NULL; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1002 | } |
| 1003 | |
Antti Palosaari | e82eea7 | 2011-04-12 19:43:30 -0300 | [diff] [blame] | 1004 | if (fe) |
| 1005 | ret = 0; |
| 1006 | else |
| 1007 | ret = -ENODEV; |
| 1008 | |
Antti Palosaari | 41f81f6 | 2011-04-10 17:53:52 -0300 | [diff] [blame] | 1009 | error: |
| 1010 | return ret; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1011 | } |
| 1012 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1013 | static int anysee_rc_query(struct dvb_usb_device *d) |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1014 | { |
| 1015 | u8 buf[] = {CMD_GET_IR_CODE}; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1016 | u8 ircode[2]; |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1017 | int ret; |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1018 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1019 | /* Remote controller is basic NEC using address byte 0x08. |
| 1020 | Anysee device RC query returns only two bytes, status and code, |
| 1021 | address byte is dropped. Also it does not return any value for |
| 1022 | NEC RCs having address byte other than 0x08. Due to that, we |
| 1023 | cannot use that device as standard NEC receiver. |
| 1024 | It could be possible make hack which reads whole code directly |
| 1025 | from device memory... */ |
| 1026 | |
| 1027 | ret = anysee_ctrl_msg(d, buf, sizeof(buf), ircode, sizeof(ircode)); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1028 | if (ret) |
| 1029 | return ret; |
| 1030 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1031 | if (ircode[0]) { |
| 1032 | deb_rc("%s: key pressed %02x\n", __func__, ircode[1]); |
Mauro Carvalho Chehab | ca86674 | 2010-11-17 13:53:11 -0300 | [diff] [blame] | 1033 | rc_keydown(d->rc_dev, 0x08 << 8 | ircode[1], 0); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1034 | } |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1035 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1036 | return 0; |
| 1037 | } |
| 1038 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1039 | /* DVB USB Driver stuff */ |
| 1040 | static struct dvb_usb_device_properties anysee_properties; |
| 1041 | |
| 1042 | static int anysee_probe(struct usb_interface *intf, |
| 1043 | const struct usb_device_id *id) |
| 1044 | { |
| 1045 | struct dvb_usb_device *d; |
| 1046 | struct usb_host_interface *alt; |
| 1047 | int ret; |
| 1048 | |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1049 | /* There is one interface with two alternate settings. |
| 1050 | Alternate setting 0 is for bulk transfer. |
| 1051 | Alternate setting 1 is for isochronous transfer. |
| 1052 | We use bulk transfer (alternate setting 0). */ |
| 1053 | if (intf->num_altsetting < 1) |
| 1054 | return -ENODEV; |
| 1055 | |
Dan Carpenter | 8b0d704 | 2010-05-31 16:27:39 -0300 | [diff] [blame] | 1056 | /* |
| 1057 | * Anysee is always warm (its USB-bridge, Cypress FX2, uploads |
| 1058 | * firmware from eeprom). If dvb_usb_device_init() succeeds that |
| 1059 | * means d is a valid pointer. |
| 1060 | */ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1061 | ret = dvb_usb_device_init(intf, &anysee_properties, THIS_MODULE, &d, |
| 1062 | adapter_nr); |
| 1063 | if (ret) |
| 1064 | return ret; |
| 1065 | |
| 1066 | alt = usb_altnum_to_altsetting(intf, 0); |
| 1067 | if (alt == NULL) { |
| 1068 | deb_info("%s: no alt found!\n", __func__); |
| 1069 | return -ENODEV; |
| 1070 | } |
| 1071 | |
| 1072 | ret = usb_set_interface(d->udev, alt->desc.bInterfaceNumber, |
| 1073 | alt->desc.bAlternateSetting); |
| 1074 | if (ret) |
| 1075 | return ret; |
| 1076 | |
Dan Carpenter | 8b0d704 | 2010-05-31 16:27:39 -0300 | [diff] [blame] | 1077 | return anysee_init(d); |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1078 | } |
| 1079 | |
Antti Palosaari | ae3745f | 2009-09-16 19:50:25 -0300 | [diff] [blame] | 1080 | static struct usb_device_id anysee_table[] = { |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1081 | { USB_DEVICE(USB_VID_CYPRESS, USB_PID_ANYSEE) }, |
| 1082 | { USB_DEVICE(USB_VID_AMT, USB_PID_ANYSEE) }, |
| 1083 | { } /* Terminating entry */ |
| 1084 | }; |
| 1085 | MODULE_DEVICE_TABLE(usb, anysee_table); |
| 1086 | |
| 1087 | static struct dvb_usb_device_properties anysee_properties = { |
| 1088 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, |
| 1089 | |
| 1090 | .usb_ctrl = DEVICE_SPECIFIC, |
| 1091 | |
| 1092 | .size_of_priv = sizeof(struct anysee_state), |
| 1093 | |
| 1094 | .num_adapters = 1, |
| 1095 | .adapter = { |
| 1096 | { |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1097 | .num_frontends = 2, |
| 1098 | .frontend_ctrl = anysee_frontend_ctrl, |
| 1099 | .fe = {{ |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1100 | .streaming_ctrl = anysee_streaming_ctrl, |
| 1101 | .frontend_attach = anysee_frontend_attach, |
| 1102 | .tuner_attach = anysee_tuner_attach, |
| 1103 | .stream = { |
| 1104 | .type = USB_BULK, |
| 1105 | .count = 8, |
| 1106 | .endpoint = 0x82, |
| 1107 | .u = { |
| 1108 | .bulk = { |
Antti Palosaari | ab69333 | 2009-09-16 19:47:01 -0300 | [diff] [blame] | 1109 | .buffersize = (16*512), |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1110 | } |
| 1111 | } |
| 1112 | }, |
Michael Krufky | 77eed21 | 2011-09-06 09:31:57 -0300 | [diff] [blame] | 1113 | }, { |
| 1114 | .streaming_ctrl = anysee_streaming_ctrl, |
| 1115 | .frontend_attach = anysee_frontend_attach, |
| 1116 | .tuner_attach = anysee_tuner_attach, |
| 1117 | .stream = { |
| 1118 | .type = USB_BULK, |
| 1119 | .count = 8, |
| 1120 | .endpoint = 0x82, |
| 1121 | .u = { |
| 1122 | .bulk = { |
| 1123 | .buffersize = (16*512), |
| 1124 | } |
| 1125 | } |
| 1126 | }, |
| 1127 | }}, |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1128 | } |
| 1129 | }, |
| 1130 | |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1131 | .rc.core = { |
| 1132 | .rc_codes = RC_MAP_ANYSEE, |
Mauro Carvalho Chehab | 52b6614 | 2010-11-17 14:20:52 -0300 | [diff] [blame] | 1133 | .protocol = RC_TYPE_OTHER, |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1134 | .module_name = "anysee", |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1135 | .rc_query = anysee_rc_query, |
Antti Palosaari | a849468 | 2010-10-17 18:25:10 -0300 | [diff] [blame] | 1136 | .rc_interval = 250, /* windows driver uses 500ms */ |
Mauro Carvalho Chehab | f72a27b | 2010-07-31 18:04:09 -0300 | [diff] [blame] | 1137 | }, |
Antti Palosaari | a51e34d | 2008-05-17 23:05:48 -0300 | [diff] [blame] | 1138 | |
| 1139 | .i2c_algo = &anysee_i2c_algo, |
| 1140 | |
| 1141 | .generic_bulk_ctrl_endpoint = 1, |
| 1142 | |
| 1143 | .num_device_descs = 1, |
| 1144 | .devices = { |
| 1145 | { |
| 1146 | .name = "Anysee DVB USB2.0", |
| 1147 | .cold_ids = {NULL}, |
| 1148 | .warm_ids = {&anysee_table[0], |
| 1149 | &anysee_table[1], NULL}, |
| 1150 | }, |
| 1151 | } |
| 1152 | }; |
| 1153 | |
| 1154 | static struct usb_driver anysee_driver = { |
| 1155 | .name = "dvb_usb_anysee", |
| 1156 | .probe = anysee_probe, |
| 1157 | .disconnect = dvb_usb_device_exit, |
| 1158 | .id_table = anysee_table, |
| 1159 | }; |
| 1160 | |
| 1161 | /* module stuff */ |
| 1162 | static int __init anysee_module_init(void) |
| 1163 | { |
| 1164 | int ret; |
| 1165 | |
| 1166 | ret = usb_register(&anysee_driver); |
| 1167 | if (ret) |
| 1168 | err("%s: usb_register failed. Error number %d", __func__, ret); |
| 1169 | |
| 1170 | return ret; |
| 1171 | } |
| 1172 | |
| 1173 | static void __exit anysee_module_exit(void) |
| 1174 | { |
| 1175 | /* deregister this driver from the USB subsystem */ |
| 1176 | usb_deregister(&anysee_driver); |
| 1177 | } |
| 1178 | |
| 1179 | module_init(anysee_module_init); |
| 1180 | module_exit(anysee_module_exit); |
| 1181 | |
| 1182 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
| 1183 | MODULE_DESCRIPTION("Driver Anysee E30 DVB-C & DVB-T USB2.0"); |
| 1184 | MODULE_LICENSE("GPL"); |