diff options
Diffstat (limited to 'drivers/media/usb/dvb-usb-v2/af9035.c')
-rw-r--r-- | drivers/media/usb/dvb-usb-v2/af9035.c | 644 |
1 files changed, 563 insertions, 81 deletions
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index c82beac0e0cb..00758c83eec7 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c | |||
@@ -193,6 +193,92 @@ static int af9035_wr_reg_mask(struct dvb_usb_device *d, u32 reg, u8 val, | |||
193 | return af9035_wr_regs(d, reg, &val, 1); | 193 | return af9035_wr_regs(d, reg, &val, 1); |
194 | } | 194 | } |
195 | 195 | ||
196 | static int af9035_add_i2c_dev(struct dvb_usb_device *d, char *type, u8 addr, | ||
197 | void *platform_data, struct i2c_adapter *adapter) | ||
198 | { | ||
199 | int ret, num; | ||
200 | struct state *state = d_to_priv(d); | ||
201 | struct i2c_client *client; | ||
202 | struct i2c_board_info board_info = { | ||
203 | .addr = addr, | ||
204 | .platform_data = platform_data, | ||
205 | }; | ||
206 | |||
207 | strlcpy(board_info.type, type, I2C_NAME_SIZE); | ||
208 | |||
209 | /* find first free client */ | ||
210 | for (num = 0; num < AF9035_I2C_CLIENT_MAX; num++) { | ||
211 | if (state->i2c_client[num] == NULL) | ||
212 | break; | ||
213 | } | ||
214 | |||
215 | dev_dbg(&d->udev->dev, "%s: num=%d\n", __func__, num); | ||
216 | |||
217 | if (num == AF9035_I2C_CLIENT_MAX) { | ||
218 | dev_err(&d->udev->dev, "%s: I2C client out of index\n", | ||
219 | KBUILD_MODNAME); | ||
220 | ret = -ENODEV; | ||
221 | goto err; | ||
222 | } | ||
223 | |||
224 | request_module(board_info.type); | ||
225 | |||
226 | /* register I2C device */ | ||
227 | client = i2c_new_device(adapter, &board_info); | ||
228 | if (client == NULL || client->dev.driver == NULL) { | ||
229 | ret = -ENODEV; | ||
230 | goto err; | ||
231 | } | ||
232 | |||
233 | /* increase I2C driver usage count */ | ||
234 | if (!try_module_get(client->dev.driver->owner)) { | ||
235 | i2c_unregister_device(client); | ||
236 | ret = -ENODEV; | ||
237 | goto err; | ||
238 | } | ||
239 | |||
240 | state->i2c_client[num] = client; | ||
241 | return 0; | ||
242 | err: | ||
243 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); | ||
244 | return ret; | ||
245 | } | ||
246 | |||
247 | static void af9035_del_i2c_dev(struct dvb_usb_device *d) | ||
248 | { | ||
249 | int num; | ||
250 | struct state *state = d_to_priv(d); | ||
251 | struct i2c_client *client; | ||
252 | |||
253 | /* find last used client */ | ||
254 | num = AF9035_I2C_CLIENT_MAX; | ||
255 | while (num--) { | ||
256 | if (state->i2c_client[num] != NULL) | ||
257 | break; | ||
258 | } | ||
259 | |||
260 | dev_dbg(&d->udev->dev, "%s: num=%d\n", __func__, num); | ||
261 | |||
262 | if (num == -1) { | ||
263 | dev_err(&d->udev->dev, "%s: I2C client out of index\n", | ||
264 | KBUILD_MODNAME); | ||
265 | goto err; | ||
266 | } | ||
267 | |||
268 | client = state->i2c_client[num]; | ||
269 | |||
270 | /* decrease I2C driver usage count */ | ||
271 | module_put(client->dev.driver->owner); | ||
272 | |||
273 | /* unregister I2C device */ | ||
274 | i2c_unregister_device(client); | ||
275 | |||
276 | state->i2c_client[num] = NULL; | ||
277 | return; | ||
278 | err: | ||
279 | dev_dbg(&d->udev->dev, "%s: failed\n", __func__); | ||
280 | } | ||
281 | |||
196 | static int af9035_i2c_master_xfer(struct i2c_adapter *adap, | 282 | static int af9035_i2c_master_xfer(struct i2c_adapter *adap, |
197 | struct i2c_msg msg[], int num) | 283 | struct i2c_msg msg[], int num) |
198 | { | 284 | { |
@@ -204,7 +290,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, | |||
204 | return -EAGAIN; | 290 | return -EAGAIN; |
205 | 291 | ||
206 | /* | 292 | /* |
207 | * I2C sub header is 5 bytes long. Meaning of those bytes are: | 293 | * AF9035 I2C sub header is 5 bytes long. Meaning of those bytes are: |
208 | * 0: data len | 294 | * 0: data len |
209 | * 1: I2C addr << 1 | 295 | * 1: I2C addr << 1 |
210 | * 2: reg addr len | 296 | * 2: reg addr len |
@@ -218,110 +304,156 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap, | |||
218 | * NOTE: As a firmware knows tuner type there is very small possibility | 304 | * NOTE: As a firmware knows tuner type there is very small possibility |
219 | * there could be some tuner I2C hacks done by firmware and this may | 305 | * there could be some tuner I2C hacks done by firmware and this may |
220 | * lead problems if firmware expects those bytes are used. | 306 | * lead problems if firmware expects those bytes are used. |
307 | * | ||
308 | * TODO: Here is few hacks. AF9035 chip integrates AF9033 demodulator. | ||
309 | * IT9135 chip integrates AF9033 demodulator and RF tuner. For dual | ||
310 | * tuner devices, there is also external AF9033 demodulator connected | ||
311 | * via external I2C bus. All AF9033 demod I2C traffic, both single and | ||
312 | * dual tuner configuration, is covered by firmware - actual USB IO | ||
313 | * looks just like a memory access. | ||
314 | * In case of IT913x chip, there is own tuner driver. It is implemented | ||
315 | * currently as a I2C driver, even tuner IP block is likely build | ||
316 | * directly into the demodulator memory space and there is no own I2C | ||
317 | * bus. I2C subsystem does not allow register multiple devices to same | ||
318 | * bus, having same slave address. Due to that we reuse demod address, | ||
319 | * shifted by one bit, on that case. | ||
320 | * | ||
321 | * For IT930x we use a different command and the sub header is | ||
322 | * different as well: | ||
323 | * 0: data len | ||
324 | * 1: I2C bus (0x03 seems to be only value used) | ||
325 | * 2: I2C addr << 1 | ||
221 | */ | 326 | */ |
222 | if (num == 2 && !(msg[0].flags & I2C_M_RD) && | 327 | #define AF9035_IS_I2C_XFER_WRITE_READ(_msg, _num) \ |
223 | (msg[1].flags & I2C_M_RD)) { | 328 | (_num == 2 && !(_msg[0].flags & I2C_M_RD) && (_msg[1].flags & I2C_M_RD)) |
329 | #define AF9035_IS_I2C_XFER_WRITE(_msg, _num) \ | ||
330 | (_num == 1 && !(_msg[0].flags & I2C_M_RD)) | ||
331 | #define AF9035_IS_I2C_XFER_READ(_msg, _num) \ | ||
332 | (_num == 1 && (_msg[0].flags & I2C_M_RD)) | ||
333 | |||
334 | if (AF9035_IS_I2C_XFER_WRITE_READ(msg, num)) { | ||
224 | if (msg[0].len > 40 || msg[1].len > 40) { | 335 | if (msg[0].len > 40 || msg[1].len > 40) { |
225 | /* TODO: correct limits > 40 */ | 336 | /* TODO: correct limits > 40 */ |
226 | ret = -EOPNOTSUPP; | 337 | ret = -EOPNOTSUPP; |
227 | } else if ((msg[0].addr == state->af9033_config[0].i2c_addr) || | 338 | } else if ((msg[0].addr == state->af9033_i2c_addr[0]) || |
228 | (msg[0].addr == state->af9033_config[1].i2c_addr)) { | 339 | (msg[0].addr == state->af9033_i2c_addr[1]) || |
340 | (state->chip_type == 0x9135)) { | ||
229 | /* demod access via firmware interface */ | 341 | /* demod access via firmware interface */ |
230 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | | 342 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | |
231 | msg[0].buf[2]; | 343 | msg[0].buf[2]; |
232 | 344 | ||
233 | if (msg[0].addr == state->af9033_config[1].i2c_addr) | 345 | if (msg[0].addr == state->af9033_i2c_addr[1] || |
346 | msg[0].addr == (state->af9033_i2c_addr[1] >> 1)) | ||
234 | reg |= 0x100000; | 347 | reg |= 0x100000; |
235 | 348 | ||
236 | ret = af9035_rd_regs(d, reg, &msg[1].buf[0], | 349 | ret = af9035_rd_regs(d, reg, &msg[1].buf[0], |
237 | msg[1].len); | 350 | msg[1].len); |
238 | } else { | 351 | } else { |
239 | /* I2C */ | 352 | /* I2C write + read */ |
240 | u8 buf[MAX_XFER_SIZE]; | 353 | u8 buf[MAX_XFER_SIZE]; |
241 | struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len, | 354 | struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len, |
242 | buf, msg[1].len, msg[1].buf }; | 355 | buf, msg[1].len, msg[1].buf }; |
243 | 356 | ||
244 | if (5 + msg[0].len > sizeof(buf)) { | 357 | if (state->chip_type == 0x9306) { |
245 | dev_warn(&d->udev->dev, | 358 | req.cmd = CMD_GENERIC_I2C_RD; |
246 | "%s: i2c xfer: len=%d is too big!\n", | 359 | req.wlen = 3 + msg[0].len; |
247 | KBUILD_MODNAME, msg[0].len); | ||
248 | ret = -EOPNOTSUPP; | ||
249 | goto unlock; | ||
250 | } | 360 | } |
251 | req.mbox |= ((msg[0].addr & 0x80) >> 3); | 361 | req.mbox |= ((msg[0].addr & 0x80) >> 3); |
362 | |||
252 | buf[0] = msg[1].len; | 363 | buf[0] = msg[1].len; |
253 | buf[1] = msg[0].addr << 1; | 364 | if (state->chip_type == 0x9306) { |
254 | buf[2] = 0x00; /* reg addr len */ | 365 | buf[1] = 0x03; /* I2C bus */ |
255 | buf[3] = 0x00; /* reg addr MSB */ | 366 | buf[2] = msg[0].addr << 1; |
256 | buf[4] = 0x00; /* reg addr LSB */ | 367 | memcpy(&buf[3], msg[0].buf, msg[0].len); |
257 | memcpy(&buf[5], msg[0].buf, msg[0].len); | 368 | } else { |
369 | buf[1] = msg[0].addr << 1; | ||
370 | buf[2] = 0x00; /* reg addr len */ | ||
371 | buf[3] = 0x00; /* reg addr MSB */ | ||
372 | buf[4] = 0x00; /* reg addr LSB */ | ||
373 | memcpy(&buf[5], msg[0].buf, msg[0].len); | ||
374 | } | ||
258 | ret = af9035_ctrl_msg(d, &req); | 375 | ret = af9035_ctrl_msg(d, &req); |
259 | } | 376 | } |
260 | } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) { | 377 | } else if (AF9035_IS_I2C_XFER_WRITE(msg, num)) { |
261 | if (msg[0].len > 40) { | 378 | if (msg[0].len > 40) { |
262 | /* TODO: correct limits > 40 */ | 379 | /* TODO: correct limits > 40 */ |
263 | ret = -EOPNOTSUPP; | 380 | ret = -EOPNOTSUPP; |
264 | } else if ((msg[0].addr == state->af9033_config[0].i2c_addr) || | 381 | } else if ((msg[0].addr == state->af9033_i2c_addr[0]) || |
265 | (msg[0].addr == state->af9033_config[1].i2c_addr)) { | 382 | (msg[0].addr == state->af9033_i2c_addr[1]) || |
383 | (state->chip_type == 0x9135)) { | ||
266 | /* demod access via firmware interface */ | 384 | /* demod access via firmware interface */ |
267 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | | 385 | u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 | |
268 | msg[0].buf[2]; | 386 | msg[0].buf[2]; |
269 | 387 | ||
270 | if (msg[0].addr == state->af9033_config[1].i2c_addr) | 388 | if (msg[0].addr == state->af9033_i2c_addr[1] || |
389 | msg[0].addr == (state->af9033_i2c_addr[1] >> 1)) | ||
271 | reg |= 0x100000; | 390 | reg |= 0x100000; |
272 | 391 | ||
273 | ret = af9035_wr_regs(d, reg, &msg[0].buf[3], | 392 | ret = af9035_wr_regs(d, reg, &msg[0].buf[3], |
274 | msg[0].len - 3); | 393 | msg[0].len - 3); |
275 | } else { | 394 | } else { |
276 | /* I2C */ | 395 | /* I2C write */ |
277 | u8 buf[MAX_XFER_SIZE]; | 396 | u8 buf[MAX_XFER_SIZE]; |
278 | struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len, | 397 | struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len, |
279 | buf, 0, NULL }; | 398 | buf, 0, NULL }; |
280 | 399 | ||
281 | if (5 + msg[0].len > sizeof(buf)) { | 400 | if (state->chip_type == 0x9306) { |
282 | dev_warn(&d->udev->dev, | 401 | req.cmd = CMD_GENERIC_I2C_WR; |
283 | "%s: i2c xfer: len=%d is too big!\n", | 402 | req.wlen = 3 + msg[0].len; |
284 | KBUILD_MODNAME, msg[0].len); | ||
285 | ret = -EOPNOTSUPP; | ||
286 | goto unlock; | ||
287 | } | 403 | } |
404 | |||
288 | req.mbox |= ((msg[0].addr & 0x80) >> 3); | 405 | req.mbox |= ((msg[0].addr & 0x80) >> 3); |
289 | buf[0] = msg[0].len; | 406 | buf[0] = msg[0].len; |
290 | buf[1] = msg[0].addr << 1; | 407 | if (state->chip_type == 0x9306) { |
291 | buf[2] = 0x00; /* reg addr len */ | 408 | buf[1] = 0x03; /* I2C bus */ |
292 | buf[3] = 0x00; /* reg addr MSB */ | 409 | buf[2] = msg[0].addr << 1; |
293 | buf[4] = 0x00; /* reg addr LSB */ | 410 | memcpy(&buf[3], msg[0].buf, msg[0].len); |
294 | memcpy(&buf[5], msg[0].buf, msg[0].len); | 411 | } else { |
412 | buf[1] = msg[0].addr << 1; | ||
413 | buf[2] = 0x00; /* reg addr len */ | ||
414 | buf[3] = 0x00; /* reg addr MSB */ | ||
415 | buf[4] = 0x00; /* reg addr LSB */ | ||
416 | memcpy(&buf[5], msg[0].buf, msg[0].len); | ||
417 | } | ||
295 | ret = af9035_ctrl_msg(d, &req); | 418 | ret = af9035_ctrl_msg(d, &req); |
296 | } | 419 | } |
297 | } else if (num == 1 && (msg[0].flags & I2C_M_RD)) { | 420 | } else if (AF9035_IS_I2C_XFER_READ(msg, num)) { |
298 | if (msg[0].len > 40) { | 421 | if (msg[0].len > 40) { |
299 | /* TODO: correct limits > 40 */ | 422 | /* TODO: correct limits > 40 */ |
300 | ret = -EOPNOTSUPP; | 423 | ret = -EOPNOTSUPP; |
301 | } else { | 424 | } else { |
302 | /* I2C */ | 425 | /* I2C read */ |
303 | u8 buf[5]; | 426 | u8 buf[5]; |
304 | struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), | 427 | struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), |
305 | buf, msg[0].len, msg[0].buf }; | 428 | buf, msg[0].len, msg[0].buf }; |
429 | |||
430 | if (state->chip_type == 0x9306) { | ||
431 | req.cmd = CMD_GENERIC_I2C_RD; | ||
432 | req.wlen = 3; | ||
433 | } | ||
306 | req.mbox |= ((msg[0].addr & 0x80) >> 3); | 434 | req.mbox |= ((msg[0].addr & 0x80) >> 3); |
307 | buf[0] = msg[0].len; | 435 | buf[0] = msg[0].len; |
308 | buf[1] = msg[0].addr << 1; | 436 | if (state->chip_type == 0x9306) { |
309 | buf[2] = 0x00; /* reg addr len */ | 437 | buf[1] = 0x03; /* I2C bus */ |
310 | buf[3] = 0x00; /* reg addr MSB */ | 438 | buf[2] = msg[0].addr << 1; |
311 | buf[4] = 0x00; /* reg addr LSB */ | 439 | } else { |
440 | buf[1] = msg[0].addr << 1; | ||
441 | buf[2] = 0x00; /* reg addr len */ | ||
442 | buf[3] = 0x00; /* reg addr MSB */ | ||
443 | buf[4] = 0x00; /* reg addr LSB */ | ||
444 | } | ||
312 | ret = af9035_ctrl_msg(d, &req); | 445 | ret = af9035_ctrl_msg(d, &req); |
313 | } | 446 | } |
314 | } else { | 447 | } else { |
315 | /* | 448 | /* |
316 | * We support only three kind of I2C transactions: | 449 | * We support only three kind of I2C transactions: |
317 | * 1) 1 x read + 1 x write (repeated start) | 450 | * 1) 1 x write + 1 x read (repeated start) |
318 | * 2) 1 x write | 451 | * 2) 1 x write |
319 | * 3) 1 x read | 452 | * 3) 1 x read |
320 | */ | 453 | */ |
321 | ret = -EOPNOTSUPP; | 454 | ret = -EOPNOTSUPP; |
322 | } | 455 | } |
323 | 456 | ||
324 | unlock: | ||
325 | mutex_unlock(&d->i2c_mutex); | 457 | mutex_unlock(&d->i2c_mutex); |
326 | 458 | ||
327 | if (ret < 0) | 459 | if (ret < 0) |
@@ -371,6 +503,9 @@ static int af9035_identify_state(struct dvb_usb_device *d, const char **name) | |||
371 | else | 503 | else |
372 | *name = AF9035_FIRMWARE_IT9135_V1; | 504 | *name = AF9035_FIRMWARE_IT9135_V1; |
373 | state->eeprom_addr = EEPROM_BASE_IT9135; | 505 | state->eeprom_addr = EEPROM_BASE_IT9135; |
506 | } else if (state->chip_type == 0x9306) { | ||
507 | *name = AF9035_FIRMWARE_IT9303; | ||
508 | state->eeprom_addr = EEPROM_BASE_IT9135; | ||
374 | } else { | 509 | } else { |
375 | *name = AF9035_FIRMWARE_AF9035; | 510 | *name = AF9035_FIRMWARE_AF9035; |
376 | state->eeprom_addr = EEPROM_BASE_AF9035; | 511 | state->eeprom_addr = EEPROM_BASE_AF9035; |
@@ -536,6 +671,7 @@ static int af9035_download_firmware(struct dvb_usb_device *d, | |||
536 | u8 tmp; | 671 | u8 tmp; |
537 | struct usb_req req = { 0, 0, 0, NULL, 0, NULL }; | 672 | struct usb_req req = { 0, 0, 0, NULL, 0, NULL }; |
538 | struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf }; | 673 | struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf }; |
674 | |||
539 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 675 | dev_dbg(&d->udev->dev, "%s:\n", __func__); |
540 | 676 | ||
541 | /* | 677 | /* |
@@ -579,7 +715,8 @@ static int af9035_download_firmware(struct dvb_usb_device *d, | |||
579 | if (!tmp) | 715 | if (!tmp) |
580 | tmp = 0x3a; | 716 | tmp = 0x3a; |
581 | 717 | ||
582 | if (state->chip_type == 0x9135) { | 718 | if ((state->chip_type == 0x9135) || |
719 | (state->chip_type == 0x9306)) { | ||
583 | ret = af9035_wr_reg(d, 0x004bfb, tmp); | 720 | ret = af9035_wr_reg(d, 0x004bfb, tmp); |
584 | if (ret < 0) | 721 | if (ret < 0) |
585 | goto err; | 722 | goto err; |
@@ -640,23 +777,26 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
640 | u16 tmp16, addr; | 777 | u16 tmp16, addr; |
641 | 778 | ||
642 | /* demod I2C "address" */ | 779 | /* demod I2C "address" */ |
643 | state->af9033_config[0].i2c_addr = 0x38; | 780 | state->af9033_i2c_addr[0] = 0x38; |
644 | state->af9033_config[1].i2c_addr = 0x3a; | 781 | state->af9033_i2c_addr[1] = 0x3a; |
645 | state->af9033_config[0].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; | 782 | state->af9033_config[0].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; |
646 | state->af9033_config[1].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; | 783 | state->af9033_config[1].adc_multiplier = AF9033_ADC_MULTIPLIER_2X; |
647 | state->af9033_config[0].ts_mode = AF9033_TS_MODE_USB; | 784 | state->af9033_config[0].ts_mode = AF9033_TS_MODE_USB; |
648 | state->af9033_config[1].ts_mode = AF9033_TS_MODE_SERIAL; | 785 | state->af9033_config[1].ts_mode = AF9033_TS_MODE_SERIAL; |
649 | 786 | ||
650 | /* eeprom memory mapped location */ | ||
651 | if (state->chip_type == 0x9135) { | 787 | if (state->chip_type == 0x9135) { |
788 | /* feed clock for integrated RF tuner */ | ||
789 | state->af9033_config[0].dyn0_clk = true; | ||
790 | state->af9033_config[1].dyn0_clk = true; | ||
791 | |||
652 | if (state->chip_version == 0x02) { | 792 | if (state->chip_version == 0x02) { |
653 | state->af9033_config[0].tuner = AF9033_TUNER_IT9135_60; | 793 | state->af9033_config[0].tuner = AF9033_TUNER_IT9135_60; |
654 | state->af9033_config[1].tuner = AF9033_TUNER_IT9135_60; | 794 | state->af9033_config[1].tuner = AF9033_TUNER_IT9135_60; |
655 | tmp16 = 0x00461d; | 795 | tmp16 = 0x00461d; /* eeprom memory mapped location */ |
656 | } else { | 796 | } else { |
657 | state->af9033_config[0].tuner = AF9033_TUNER_IT9135_38; | 797 | state->af9033_config[0].tuner = AF9033_TUNER_IT9135_38; |
658 | state->af9033_config[1].tuner = AF9033_TUNER_IT9135_38; | 798 | state->af9033_config[1].tuner = AF9033_TUNER_IT9135_38; |
659 | tmp16 = 0x00461b; | 799 | tmp16 = 0x00461b; /* eeprom memory mapped location */ |
660 | } | 800 | } |
661 | 801 | ||
662 | /* check if eeprom exists */ | 802 | /* check if eeprom exists */ |
@@ -668,8 +808,16 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
668 | dev_dbg(&d->udev->dev, "%s: no eeprom\n", __func__); | 808 | dev_dbg(&d->udev->dev, "%s: no eeprom\n", __func__); |
669 | goto skip_eeprom; | 809 | goto skip_eeprom; |
670 | } | 810 | } |
811 | } else if (state->chip_type == 0x9306) { | ||
812 | /* | ||
813 | * IT930x is an USB bridge, only single demod-single tuner | ||
814 | * configurations seen so far. | ||
815 | */ | ||
816 | return 0; | ||
671 | } | 817 | } |
672 | 818 | ||
819 | |||
820 | |||
673 | /* check if there is dual tuners */ | 821 | /* check if there is dual tuners */ |
674 | ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_TS_MODE, &tmp); | 822 | ret = af9035_rd_reg(d, state->eeprom_addr + EEPROM_TS_MODE, &tmp); |
675 | if (ret < 0) | 823 | if (ret < 0) |
@@ -690,7 +838,7 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
690 | goto err; | 838 | goto err; |
691 | 839 | ||
692 | if (tmp) | 840 | if (tmp) |
693 | state->af9033_config[1].i2c_addr = tmp; | 841 | state->af9033_i2c_addr[1] = tmp; |
694 | 842 | ||
695 | dev_dbg(&d->udev->dev, "%s: 2nd demod I2C addr=%02x\n", | 843 | dev_dbg(&d->udev->dev, "%s: 2nd demod I2C addr=%02x\n", |
696 | __func__, tmp); | 844 | __func__, tmp); |
@@ -799,25 +947,6 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
799 | addr += 0x10; /* shift for the 2nd tuner params */ | 947 | addr += 0x10; /* shift for the 2nd tuner params */ |
800 | } | 948 | } |
801 | 949 | ||
802 | /* | ||
803 | * These AVerMedia devices has a bad EEPROM content :-( | ||
804 | * Override some wrong values here. | ||
805 | */ | ||
806 | if (le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_AVERMEDIA) { | ||
807 | switch (le16_to_cpu(d->udev->descriptor.idProduct)) { | ||
808 | case USB_PID_AVERMEDIA_A835B_1835: | ||
809 | case USB_PID_AVERMEDIA_A835B_2835: | ||
810 | case USB_PID_AVERMEDIA_A835B_3835: | ||
811 | dev_info(&d->udev->dev, | ||
812 | "%s: overriding tuner from %02x to %02x\n", | ||
813 | KBUILD_MODNAME, state->af9033_config[0].tuner, | ||
814 | AF9033_TUNER_IT9135_60); | ||
815 | |||
816 | state->af9033_config[0].tuner = AF9033_TUNER_IT9135_60; | ||
817 | break; | ||
818 | } | ||
819 | } | ||
820 | |||
821 | skip_eeprom: | 950 | skip_eeprom: |
822 | /* get demod clock */ | 951 | /* get demod clock */ |
823 | ret = af9035_rd_reg(d, 0x00d800, &tmp); | 952 | ret = af9035_rd_reg(d, 0x00d800, &tmp); |
@@ -990,6 +1119,7 @@ static int af9035_frontend_callback(void *adapter_priv, int component, | |||
990 | static int af9035_get_adapter_count(struct dvb_usb_device *d) | 1119 | static int af9035_get_adapter_count(struct dvb_usb_device *d) |
991 | { | 1120 | { |
992 | struct state *state = d_to_priv(d); | 1121 | struct state *state = d_to_priv(d); |
1122 | |||
993 | return state->dual_mode + 1; | 1123 | return state->dual_mode + 1; |
994 | } | 1124 | } |
995 | 1125 | ||
@@ -998,7 +1128,8 @@ static int af9035_frontend_attach(struct dvb_usb_adapter *adap) | |||
998 | struct state *state = adap_to_priv(adap); | 1128 | struct state *state = adap_to_priv(adap); |
999 | struct dvb_usb_device *d = adap_to_d(adap); | 1129 | struct dvb_usb_device *d = adap_to_d(adap); |
1000 | int ret; | 1130 | int ret; |
1001 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 1131 | |
1132 | dev_dbg(&d->udev->dev, "%s: adap->id=%d\n", __func__, adap->id); | ||
1002 | 1133 | ||
1003 | if (!state->af9033_config[adap->id].tuner) { | 1134 | if (!state->af9033_config[adap->id].tuner) { |
1004 | /* unsupported tuner */ | 1135 | /* unsupported tuner */ |
@@ -1006,9 +1137,13 @@ static int af9035_frontend_attach(struct dvb_usb_adapter *adap) | |||
1006 | goto err; | 1137 | goto err; |
1007 | } | 1138 | } |
1008 | 1139 | ||
1009 | /* attach demodulator */ | 1140 | state->af9033_config[adap->id].fe = &adap->fe[0]; |
1010 | adap->fe[0] = dvb_attach(af9033_attach, &state->af9033_config[adap->id], | 1141 | state->af9033_config[adap->id].ops = &state->ops; |
1011 | &d->i2c_adap, &state->ops); | 1142 | ret = af9035_add_i2c_dev(d, "af9033", state->af9033_i2c_addr[adap->id], |
1143 | &state->af9033_config[adap->id], &d->i2c_adap); | ||
1144 | if (ret) | ||
1145 | goto err; | ||
1146 | |||
1012 | if (adap->fe[0] == NULL) { | 1147 | if (adap->fe[0] == NULL) { |
1013 | ret = -ENODEV; | 1148 | ret = -ENODEV; |
1014 | goto err; | 1149 | goto err; |
@@ -1026,6 +1161,78 @@ err: | |||
1026 | return ret; | 1161 | return ret; |
1027 | } | 1162 | } |
1028 | 1163 | ||
1164 | static int it930x_frontend_attach(struct dvb_usb_adapter *adap) | ||
1165 | { | ||
1166 | struct state *state = adap_to_priv(adap); | ||
1167 | struct dvb_usb_device *d = adap_to_d(adap); | ||
1168 | int ret; | ||
1169 | struct si2168_config si2168_config; | ||
1170 | struct i2c_adapter *adapter; | ||
1171 | |||
1172 | dev_dbg(&d->udev->dev, "adap->id=%d\n", adap->id); | ||
1173 | |||
1174 | si2168_config.i2c_adapter = &adapter; | ||
1175 | si2168_config.fe = &adap->fe[0]; | ||
1176 | si2168_config.ts_mode = SI2168_TS_SERIAL; | ||
1177 | |||
1178 | state->af9033_config[adap->id].fe = &adap->fe[0]; | ||
1179 | state->af9033_config[adap->id].ops = &state->ops; | ||
1180 | ret = af9035_add_i2c_dev(d, "si2168", 0x67, &si2168_config, | ||
1181 | &d->i2c_adap); | ||
1182 | if (ret) | ||
1183 | goto err; | ||
1184 | |||
1185 | if (adap->fe[0] == NULL) { | ||
1186 | ret = -ENODEV; | ||
1187 | goto err; | ||
1188 | } | ||
1189 | state->i2c_adapter_demod = adapter; | ||
1190 | |||
1191 | return 0; | ||
1192 | |||
1193 | err: | ||
1194 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); | ||
1195 | |||
1196 | return ret; | ||
1197 | } | ||
1198 | |||
1199 | static int af9035_frontend_detach(struct dvb_usb_adapter *adap) | ||
1200 | { | ||
1201 | struct state *state = adap_to_priv(adap); | ||
1202 | struct dvb_usb_device *d = adap_to_d(adap); | ||
1203 | int demod2; | ||
1204 | |||
1205 | dev_dbg(&d->udev->dev, "%s: adap->id=%d\n", __func__, adap->id); | ||
1206 | |||
1207 | /* | ||
1208 | * For dual tuner devices we have to resolve 2nd demod client, as there | ||
1209 | * is two different kind of tuner drivers; one is using I2C binding | ||
1210 | * and the other is using DVB attach/detach binding. | ||
1211 | */ | ||
1212 | switch (state->af9033_config[adap->id].tuner) { | ||
1213 | case AF9033_TUNER_IT9135_38: | ||
1214 | case AF9033_TUNER_IT9135_51: | ||
1215 | case AF9033_TUNER_IT9135_52: | ||
1216 | case AF9033_TUNER_IT9135_60: | ||
1217 | case AF9033_TUNER_IT9135_61: | ||
1218 | case AF9033_TUNER_IT9135_62: | ||
1219 | demod2 = 2; | ||
1220 | break; | ||
1221 | default: | ||
1222 | demod2 = 1; | ||
1223 | } | ||
1224 | |||
1225 | if (adap->id == 1) { | ||
1226 | if (state->i2c_client[demod2]) | ||
1227 | af9035_del_i2c_dev(d); | ||
1228 | } else if (adap->id == 0) { | ||
1229 | if (state->i2c_client[0]) | ||
1230 | af9035_del_i2c_dev(d); | ||
1231 | } | ||
1232 | |||
1233 | return 0; | ||
1234 | } | ||
1235 | |||
1029 | static struct tua9001_config af9035_tua9001_config = { | 1236 | static struct tua9001_config af9035_tua9001_config = { |
1030 | .i2c_addr = 0x60, | 1237 | .i2c_addr = 0x60, |
1031 | }; | 1238 | }; |
@@ -1084,7 +1291,8 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap) | |||
1084 | struct dvb_frontend *fe; | 1291 | struct dvb_frontend *fe; |
1085 | struct i2c_msg msg[1]; | 1292 | struct i2c_msg msg[1]; |
1086 | u8 tuner_addr; | 1293 | u8 tuner_addr; |
1087 | dev_dbg(&d->udev->dev, "%s:\n", __func__); | 1294 | |
1295 | dev_dbg(&d->udev->dev, "%s: adap->id=%d\n", __func__, adap->id); | ||
1088 | 1296 | ||
1089 | /* | 1297 | /* |
1090 | * XXX: Hack used in that function: we abuse unused I2C address bit [7] | 1298 | * XXX: Hack used in that function: we abuse unused I2C address bit [7] |
@@ -1243,14 +1451,53 @@ static int af9035_tuner_attach(struct dvb_usb_adapter *adap) | |||
1243 | case AF9033_TUNER_IT9135_38: | 1451 | case AF9033_TUNER_IT9135_38: |
1244 | case AF9033_TUNER_IT9135_51: | 1452 | case AF9033_TUNER_IT9135_51: |
1245 | case AF9033_TUNER_IT9135_52: | 1453 | case AF9033_TUNER_IT9135_52: |
1454 | { | ||
1455 | struct it913x_config it913x_config = { | ||
1456 | .fe = adap->fe[0], | ||
1457 | .chip_ver = 1, | ||
1458 | }; | ||
1459 | |||
1460 | if (state->dual_mode) { | ||
1461 | if (adap->id == 0) | ||
1462 | it913x_config.role = IT913X_ROLE_DUAL_MASTER; | ||
1463 | else | ||
1464 | it913x_config.role = IT913X_ROLE_DUAL_SLAVE; | ||
1465 | } | ||
1466 | |||
1467 | ret = af9035_add_i2c_dev(d, "it913x", | ||
1468 | state->af9033_i2c_addr[adap->id] >> 1, | ||
1469 | &it913x_config, &d->i2c_adap); | ||
1470 | if (ret) | ||
1471 | goto err; | ||
1472 | |||
1473 | fe = adap->fe[0]; | ||
1474 | break; | ||
1475 | } | ||
1246 | case AF9033_TUNER_IT9135_60: | 1476 | case AF9033_TUNER_IT9135_60: |
1247 | case AF9033_TUNER_IT9135_61: | 1477 | case AF9033_TUNER_IT9135_61: |
1248 | case AF9033_TUNER_IT9135_62: | 1478 | case AF9033_TUNER_IT9135_62: |
1249 | /* attach tuner */ | 1479 | { |
1250 | fe = dvb_attach(it913x_attach, adap->fe[0], &d->i2c_adap, | 1480 | struct it913x_config it913x_config = { |
1251 | state->af9033_config[adap->id].i2c_addr, | 1481 | .fe = adap->fe[0], |
1252 | state->af9033_config[0].tuner); | 1482 | .chip_ver = 2, |
1483 | }; | ||
1484 | |||
1485 | if (state->dual_mode) { | ||
1486 | if (adap->id == 0) | ||
1487 | it913x_config.role = IT913X_ROLE_DUAL_MASTER; | ||
1488 | else | ||
1489 | it913x_config.role = IT913X_ROLE_DUAL_SLAVE; | ||
1490 | } | ||
1491 | |||
1492 | ret = af9035_add_i2c_dev(d, "it913x", | ||
1493 | state->af9033_i2c_addr[adap->id] >> 1, | ||
1494 | &it913x_config, &d->i2c_adap); | ||
1495 | if (ret) | ||
1496 | goto err; | ||
1497 | |||
1498 | fe = adap->fe[0]; | ||
1253 | break; | 1499 | break; |
1500 | } | ||
1254 | default: | 1501 | default: |
1255 | fe = NULL; | 1502 | fe = NULL; |
1256 | } | 1503 | } |
@@ -1268,6 +1515,119 @@ err: | |||
1268 | return ret; | 1515 | return ret; |
1269 | } | 1516 | } |
1270 | 1517 | ||
1518 | static int it930x_tuner_attach(struct dvb_usb_adapter *adap) | ||
1519 | { | ||
1520 | struct state *state = adap_to_priv(adap); | ||
1521 | struct dvb_usb_device *d = adap_to_d(adap); | ||
1522 | int ret; | ||
1523 | struct si2157_config si2157_config; | ||
1524 | |||
1525 | dev_dbg(&d->udev->dev, "%s: adap->id=%d\n", __func__, adap->id); | ||
1526 | |||
1527 | /* I2C master bus 2 clock speed 300k */ | ||
1528 | ret = af9035_wr_reg(d, 0x00f6a7, 0x07); | ||
1529 | if (ret < 0) | ||
1530 | goto err; | ||
1531 | |||
1532 | /* I2C master bus 1,3 clock speed 300k */ | ||
1533 | ret = af9035_wr_reg(d, 0x00f103, 0x07); | ||
1534 | if (ret < 0) | ||
1535 | goto err; | ||
1536 | |||
1537 | /* set gpio11 low */ | ||
1538 | ret = af9035_wr_reg_mask(d, 0xd8d4, 0x01, 0x01); | ||
1539 | if (ret < 0) | ||
1540 | goto err; | ||
1541 | |||
1542 | ret = af9035_wr_reg_mask(d, 0xd8d5, 0x01, 0x01); | ||
1543 | if (ret < 0) | ||
1544 | goto err; | ||
1545 | |||
1546 | ret = af9035_wr_reg_mask(d, 0xd8d3, 0x01, 0x01); | ||
1547 | if (ret < 0) | ||
1548 | goto err; | ||
1549 | |||
1550 | /* Tuner enable using gpiot2_en, gpiot2_on and gpiot2_o (reset) */ | ||
1551 | ret = af9035_wr_reg_mask(d, 0xd8b8, 0x01, 0x01); | ||
1552 | if (ret < 0) | ||
1553 | goto err; | ||
1554 | |||
1555 | ret = af9035_wr_reg_mask(d, 0xd8b9, 0x01, 0x01); | ||
1556 | if (ret < 0) | ||
1557 | goto err; | ||
1558 | |||
1559 | ret = af9035_wr_reg_mask(d, 0xd8b7, 0x00, 0x01); | ||
1560 | if (ret < 0) | ||
1561 | goto err; | ||
1562 | |||
1563 | msleep(200); | ||
1564 | |||
1565 | ret = af9035_wr_reg_mask(d, 0xd8b7, 0x01, 0x01); | ||
1566 | if (ret < 0) | ||
1567 | goto err; | ||
1568 | |||
1569 | memset(&si2157_config, 0, sizeof(si2157_config)); | ||
1570 | si2157_config.fe = adap->fe[0]; | ||
1571 | ret = af9035_add_i2c_dev(d, "si2157", 0x63, | ||
1572 | &si2157_config, state->i2c_adapter_demod); | ||
1573 | |||
1574 | if (ret) | ||
1575 | goto err; | ||
1576 | |||
1577 | return 0; | ||
1578 | |||
1579 | err: | ||
1580 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); | ||
1581 | |||
1582 | return ret; | ||
1583 | } | ||
1584 | |||
1585 | |||
1586 | static int it930x_tuner_detach(struct dvb_usb_adapter *adap) | ||
1587 | { | ||
1588 | struct state *state = adap_to_priv(adap); | ||
1589 | struct dvb_usb_device *d = adap_to_d(adap); | ||
1590 | |||
1591 | dev_dbg(&d->udev->dev, "adap->id=%d\n", adap->id); | ||
1592 | |||
1593 | if (adap->id == 1) { | ||
1594 | if (state->i2c_client[3]) | ||
1595 | af9035_del_i2c_dev(d); | ||
1596 | } else if (adap->id == 0) { | ||
1597 | if (state->i2c_client[1]) | ||
1598 | af9035_del_i2c_dev(d); | ||
1599 | } | ||
1600 | |||
1601 | return 0; | ||
1602 | } | ||
1603 | |||
1604 | |||
1605 | static int af9035_tuner_detach(struct dvb_usb_adapter *adap) | ||
1606 | { | ||
1607 | struct state *state = adap_to_priv(adap); | ||
1608 | struct dvb_usb_device *d = adap_to_d(adap); | ||
1609 | |||
1610 | dev_dbg(&d->udev->dev, "%s: adap->id=%d\n", __func__, adap->id); | ||
1611 | |||
1612 | switch (state->af9033_config[adap->id].tuner) { | ||
1613 | case AF9033_TUNER_IT9135_38: | ||
1614 | case AF9033_TUNER_IT9135_51: | ||
1615 | case AF9033_TUNER_IT9135_52: | ||
1616 | case AF9033_TUNER_IT9135_60: | ||
1617 | case AF9033_TUNER_IT9135_61: | ||
1618 | case AF9033_TUNER_IT9135_62: | ||
1619 | if (adap->id == 1) { | ||
1620 | if (state->i2c_client[3]) | ||
1621 | af9035_del_i2c_dev(d); | ||
1622 | } else if (adap->id == 0) { | ||
1623 | if (state->i2c_client[1]) | ||
1624 | af9035_del_i2c_dev(d); | ||
1625 | } | ||
1626 | } | ||
1627 | |||
1628 | return 0; | ||
1629 | } | ||
1630 | |||
1271 | static int af9035_init(struct dvb_usb_device *d) | 1631 | static int af9035_init(struct dvb_usb_device *d) |
1272 | { | 1632 | { |
1273 | struct state *state = d_to_priv(d); | 1633 | struct state *state = d_to_priv(d); |
@@ -1315,6 +1675,89 @@ err: | |||
1315 | return ret; | 1675 | return ret; |
1316 | } | 1676 | } |
1317 | 1677 | ||
1678 | static int it930x_init(struct dvb_usb_device *d) | ||
1679 | { | ||
1680 | struct state *state = d_to_priv(d); | ||
1681 | int ret, i; | ||
1682 | u16 frame_size = (d->udev->speed == USB_SPEED_FULL ? 5 : 816) * 188 / 4; | ||
1683 | u8 packet_size = (d->udev->speed == USB_SPEED_FULL ? 64 : 512) / 4; | ||
1684 | struct reg_val_mask tab[] = { | ||
1685 | { 0x00da1a, 0x00, 0x01 }, /* ignore_sync_byte */ | ||
1686 | { 0x00f41f, 0x04, 0x04 }, /* dvbt_inten */ | ||
1687 | { 0x00da10, 0x00, 0x01 }, /* mpeg_full_speed */ | ||
1688 | { 0x00f41a, 0x01, 0x01 }, /* dvbt_en */ | ||
1689 | { 0x00da1d, 0x01, 0x01 }, /* mp2_sw_rst, reset EP4 */ | ||
1690 | { 0x00dd11, 0x00, 0x20 }, /* ep4_tx_en, disable EP4 */ | ||
1691 | { 0x00dd13, 0x00, 0x20 }, /* ep4_tx_nak, disable EP4 NAK */ | ||
1692 | { 0x00dd11, 0x20, 0x20 }, /* ep4_tx_en, enable EP4 */ | ||
1693 | { 0x00dd11, 0x00, 0x40 }, /* ep5_tx_en, disable EP5 */ | ||
1694 | { 0x00dd13, 0x00, 0x40 }, /* ep5_tx_nak, disable EP5 NAK */ | ||
1695 | { 0x00dd11, state->dual_mode << 6, 0x40 }, /* enable EP5 */ | ||
1696 | { 0x00dd88, (frame_size >> 0) & 0xff, 0xff}, | ||
1697 | { 0x00dd89, (frame_size >> 8) & 0xff, 0xff}, | ||
1698 | { 0x00dd0c, packet_size, 0xff}, | ||
1699 | { 0x00dd8a, (frame_size >> 0) & 0xff, 0xff}, | ||
1700 | { 0x00dd8b, (frame_size >> 8) & 0xff, 0xff}, | ||
1701 | { 0x00dd0d, packet_size, 0xff }, | ||
1702 | { 0x00da1d, 0x00, 0x01 }, /* mp2_sw_rst, disable */ | ||
1703 | { 0x00d833, 0x01, 0xff }, /* slew rate ctrl: slew rate boosts */ | ||
1704 | { 0x00d830, 0x00, 0xff }, /* Bit 0 of output driving control */ | ||
1705 | { 0x00d831, 0x01, 0xff }, /* Bit 1 of output driving control */ | ||
1706 | { 0x00d832, 0x00, 0xff }, /* Bit 2 of output driving control */ | ||
1707 | |||
1708 | /* suspend gpio1 for TS-C */ | ||
1709 | { 0x00d8b0, 0x01, 0xff }, /* gpio1 */ | ||
1710 | { 0x00d8b1, 0x01, 0xff }, /* gpio1 */ | ||
1711 | { 0x00d8af, 0x00, 0xff }, /* gpio1 */ | ||
1712 | |||
1713 | /* suspend gpio7 for TS-D */ | ||
1714 | { 0x00d8c4, 0x01, 0xff }, /* gpio7 */ | ||
1715 | { 0x00d8c5, 0x01, 0xff }, /* gpio7 */ | ||
1716 | { 0x00d8c3, 0x00, 0xff }, /* gpio7 */ | ||
1717 | |||
1718 | /* suspend gpio13 for TS-B */ | ||
1719 | { 0x00d8dc, 0x01, 0xff }, /* gpio13 */ | ||
1720 | { 0x00d8dd, 0x01, 0xff }, /* gpio13 */ | ||
1721 | { 0x00d8db, 0x00, 0xff }, /* gpio13 */ | ||
1722 | |||
1723 | /* suspend gpio14 for TS-E */ | ||
1724 | { 0x00d8e4, 0x01, 0xff }, /* gpio14 */ | ||
1725 | { 0x00d8e5, 0x01, 0xff }, /* gpio14 */ | ||
1726 | { 0x00d8e3, 0x00, 0xff }, /* gpio14 */ | ||
1727 | |||
1728 | /* suspend gpio15 for TS-A */ | ||
1729 | { 0x00d8e8, 0x01, 0xff }, /* gpio15 */ | ||
1730 | { 0x00d8e9, 0x01, 0xff }, /* gpio15 */ | ||
1731 | { 0x00d8e7, 0x00, 0xff }, /* gpio15 */ | ||
1732 | |||
1733 | { 0x00da58, 0x00, 0x01 }, /* ts_in_src, serial */ | ||
1734 | { 0x00da73, 0x01, 0xff }, /* ts0_aggre_mode */ | ||
1735 | { 0x00da78, 0x47, 0xff }, /* ts0_sync_byte */ | ||
1736 | { 0x00da4c, 0x01, 0xff }, /* ts0_en */ | ||
1737 | { 0x00da5a, 0x1f, 0xff }, /* ts_fail_ignore */ | ||
1738 | }; | ||
1739 | |||
1740 | dev_dbg(&d->udev->dev, | ||
1741 | "%s: USB speed=%d frame_size=%04x packet_size=%02x\n", | ||
1742 | __func__, d->udev->speed, frame_size, packet_size); | ||
1743 | |||
1744 | /* init endpoints */ | ||
1745 | for (i = 0; i < ARRAY_SIZE(tab); i++) { | ||
1746 | ret = af9035_wr_reg_mask(d, tab[i].reg, | ||
1747 | tab[i].val, tab[i].mask); | ||
1748 | |||
1749 | if (ret < 0) | ||
1750 | goto err; | ||
1751 | } | ||
1752 | |||
1753 | return 0; | ||
1754 | err: | ||
1755 | dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret); | ||
1756 | |||
1757 | return ret; | ||
1758 | } | ||
1759 | |||
1760 | |||
1318 | #if IS_ENABLED(CONFIG_RC_CORE) | 1761 | #if IS_ENABLED(CONFIG_RC_CORE) |
1319 | static int af9035_rc_query(struct dvb_usb_device *d) | 1762 | static int af9035_rc_query(struct dvb_usb_device *d) |
1320 | { | 1763 | { |
@@ -1409,6 +1852,7 @@ static int af9035_get_stream_config(struct dvb_frontend *fe, u8 *ts_type, | |||
1409 | struct usb_data_stream_properties *stream) | 1852 | struct usb_data_stream_properties *stream) |
1410 | { | 1853 | { |
1411 | struct dvb_usb_device *d = fe_to_d(fe); | 1854 | struct dvb_usb_device *d = fe_to_d(fe); |
1855 | |||
1412 | dev_dbg(&d->udev->dev, "%s: adap=%d\n", __func__, fe_to_adap(fe)->id); | 1856 | dev_dbg(&d->udev->dev, "%s: adap=%d\n", __func__, fe_to_adap(fe)->id); |
1413 | 1857 | ||
1414 | if (d->udev->speed == USB_SPEED_FULL) | 1858 | if (d->udev->speed == USB_SPEED_FULL) |
@@ -1486,7 +1930,9 @@ static const struct dvb_usb_device_properties af9035_props = { | |||
1486 | .i2c_algo = &af9035_i2c_algo, | 1930 | .i2c_algo = &af9035_i2c_algo, |
1487 | .read_config = af9035_read_config, | 1931 | .read_config = af9035_read_config, |
1488 | .frontend_attach = af9035_frontend_attach, | 1932 | .frontend_attach = af9035_frontend_attach, |
1933 | .frontend_detach = af9035_frontend_detach, | ||
1489 | .tuner_attach = af9035_tuner_attach, | 1934 | .tuner_attach = af9035_tuner_attach, |
1935 | .tuner_detach = af9035_tuner_detach, | ||
1490 | .init = af9035_init, | 1936 | .init = af9035_init, |
1491 | .get_rc_config = af9035_get_rc_config, | 1937 | .get_rc_config = af9035_get_rc_config, |
1492 | .get_stream_config = af9035_get_stream_config, | 1938 | .get_stream_config = af9035_get_stream_config, |
@@ -1515,6 +1961,37 @@ static const struct dvb_usb_device_properties af9035_props = { | |||
1515 | }, | 1961 | }, |
1516 | }; | 1962 | }; |
1517 | 1963 | ||
1964 | static const struct dvb_usb_device_properties it930x_props = { | ||
1965 | .driver_name = KBUILD_MODNAME, | ||
1966 | .owner = THIS_MODULE, | ||
1967 | .adapter_nr = adapter_nr, | ||
1968 | .size_of_priv = sizeof(struct state), | ||
1969 | |||
1970 | .generic_bulk_ctrl_endpoint = 0x02, | ||
1971 | .generic_bulk_ctrl_endpoint_response = 0x81, | ||
1972 | |||
1973 | .identify_state = af9035_identify_state, | ||
1974 | .download_firmware = af9035_download_firmware, | ||
1975 | |||
1976 | .i2c_algo = &af9035_i2c_algo, | ||
1977 | .read_config = af9035_read_config, | ||
1978 | .frontend_attach = it930x_frontend_attach, | ||
1979 | .frontend_detach = af9035_frontend_detach, | ||
1980 | .tuner_attach = it930x_tuner_attach, | ||
1981 | .tuner_detach = it930x_tuner_detach, | ||
1982 | .init = it930x_init, | ||
1983 | .get_stream_config = af9035_get_stream_config, | ||
1984 | |||
1985 | .get_adapter_count = af9035_get_adapter_count, | ||
1986 | .adapter = { | ||
1987 | { | ||
1988 | .stream = DVB_USB_STREAM_BULK(0x84, 4, 816 * 188), | ||
1989 | }, { | ||
1990 | .stream = DVB_USB_STREAM_BULK(0x85, 4, 816 * 188), | ||
1991 | }, | ||
1992 | }, | ||
1993 | }; | ||
1994 | |||
1518 | static const struct usb_device_id af9035_id_table[] = { | 1995 | static const struct usb_device_id af9035_id_table[] = { |
1519 | /* AF9035 devices */ | 1996 | /* AF9035 devices */ |
1520 | { DVB_USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9035_9035, | 1997 | { DVB_USB_DEVICE(USB_VID_AFATECH, USB_PID_AFATECH_AF9035_9035, |
@@ -1568,17 +2045,21 @@ static const struct usb_device_id af9035_id_table[] = { | |||
1568 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2, | 2045 | { DVB_USB_DEVICE(USB_VID_KWORLD_2, USB_PID_CTVDIGDUAL_V2, |
1569 | &af9035_props, "Digital Dual TV Receiver CTVDIGDUAL_V2", | 2046 | &af9035_props, "Digital Dual TV Receiver CTVDIGDUAL_V2", |
1570 | RC_MAP_IT913X_V1) }, | 2047 | RC_MAP_IT913X_V1) }, |
2048 | /* IT930x devices */ | ||
2049 | { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9303, | ||
2050 | &it930x_props, "ITE 9303 Generic", NULL) }, | ||
1571 | /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */ | 2051 | /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */ |
1572 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099, | 2052 | { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099, |
1573 | &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) }, | 2053 | &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", |
2054 | NULL) }, | ||
1574 | { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a05, | 2055 | { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a05, |
1575 | &af9035_props, "Leadtek WinFast DTV Dongle Dual", NULL) }, | 2056 | &af9035_props, "Leadtek WinFast DTV Dongle Dual", NULL) }, |
1576 | { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xf900, | 2057 | { DVB_USB_DEVICE(USB_VID_HAUPPAUGE, 0xf900, |
1577 | &af9035_props, "Hauppauge WinTV-MiniStick 2", NULL) }, | 2058 | &af9035_props, "Hauppauge WinTV-MiniStick 2", NULL) }, |
1578 | { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_78E, | 2059 | { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_78E, |
1579 | &af9035_props, "PCTV 78e", RC_MAP_IT913X_V1) }, | 2060 | &af9035_props, "PCTV AndroiDTV (78e)", RC_MAP_IT913X_V1) }, |
1580 | { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_79E, | 2061 | { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_79E, |
1581 | &af9035_props, "PCTV 79e", RC_MAP_IT913X_V2) }, | 2062 | &af9035_props, "PCTV microStick (79e)", RC_MAP_IT913X_V2) }, |
1582 | { } | 2063 | { } |
1583 | }; | 2064 | }; |
1584 | MODULE_DEVICE_TABLE(usb, af9035_id_table); | 2065 | MODULE_DEVICE_TABLE(usb, af9035_id_table); |
@@ -1603,3 +2084,4 @@ MODULE_LICENSE("GPL"); | |||
1603 | MODULE_FIRMWARE(AF9035_FIRMWARE_AF9035); | 2084 | MODULE_FIRMWARE(AF9035_FIRMWARE_AF9035); |
1604 | MODULE_FIRMWARE(AF9035_FIRMWARE_IT9135_V1); | 2085 | MODULE_FIRMWARE(AF9035_FIRMWARE_IT9135_V1); |
1605 | MODULE_FIRMWARE(AF9035_FIRMWARE_IT9135_V2); | 2086 | MODULE_FIRMWARE(AF9035_FIRMWARE_IT9135_V2); |
2087 | MODULE_FIRMWARE(AF9035_FIRMWARE_IT9303); | ||