diff options
Diffstat (limited to 'drivers/media/dvb/dvb-usb/af9035.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/af9035.c | 141 |
1 files changed, 140 insertions, 1 deletions
diff --git a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-usb/af9035.c index 7bb8817864af..5ae5cc167c9f 100644 --- a/drivers/media/dvb/dvb-usb/af9035.c +++ b/drivers/media/dvb/dvb-usb/af9035.c | |||
@@ -29,7 +29,7 @@ | |||
29 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 29 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
30 | static DEFINE_MUTEX(af9035_usb_mutex); | 30 | static DEFINE_MUTEX(af9035_usb_mutex); |
31 | static struct config af9035_config; | 31 | static struct config af9035_config; |
32 | static struct dvb_usb_device_properties af9035_properties[1]; | 32 | static struct dvb_usb_device_properties af9035_properties[2]; |
33 | static int af9035_properties_count = ARRAY_SIZE(af9035_properties); | 33 | static int af9035_properties_count = ARRAY_SIZE(af9035_properties); |
34 | static struct af9033_config af9035_af9033_config[] = { | 34 | static struct af9033_config af9035_af9033_config[] = { |
35 | { | 35 | { |
@@ -493,6 +493,76 @@ err: | |||
493 | return ret; | 493 | return ret; |
494 | } | 494 | } |
495 | 495 | ||
496 | static int af9035_download_firmware_it9135(struct usb_device *udev, | ||
497 | const struct firmware *fw) | ||
498 | { | ||
499 | int ret, i, i_prev; | ||
500 | u8 wbuf[1]; | ||
501 | u8 rbuf[4]; | ||
502 | struct usb_req req = { 0, 0, 0, NULL, 0, NULL }; | ||
503 | struct usb_req req_fw_dl = { CMD_FW_SCATTER_WR, 0, 0, NULL, 0, NULL }; | ||
504 | struct usb_req req_fw_ver = { CMD_FW_QUERYINFO, 0, 1, wbuf, 4, rbuf } ; | ||
505 | #define HDR_SIZE 7 | ||
506 | |||
507 | /* | ||
508 | * There seems to be following firmware header. Meaning of bytes 0-3 | ||
509 | * is unknown. | ||
510 | * | ||
511 | * 0: 3 | ||
512 | * 1: 0, 1 | ||
513 | * 2: 0 | ||
514 | * 3: 1, 2, 3 | ||
515 | * 4: addr MSB | ||
516 | * 5: addr LSB | ||
517 | * 6: count of data bytes ? | ||
518 | */ | ||
519 | |||
520 | for (i = HDR_SIZE, i_prev = 0; i <= fw->size; i++) { | ||
521 | if (i == fw->size || | ||
522 | (fw->data[i + 0] == 0x03 && | ||
523 | (fw->data[i + 1] == 0x00 || | ||
524 | fw->data[i + 1] == 0x01) && | ||
525 | fw->data[i + 2] == 0x00)) { | ||
526 | req_fw_dl.wlen = i - i_prev; | ||
527 | req_fw_dl.wbuf = (u8 *) &fw->data[i_prev]; | ||
528 | i_prev = i; | ||
529 | ret = af9035_ctrl_msg(udev, &req_fw_dl); | ||
530 | if (ret < 0) | ||
531 | goto err; | ||
532 | |||
533 | pr_debug("%s: data uploaded=%d\n", __func__, i); | ||
534 | } | ||
535 | } | ||
536 | |||
537 | /* firmware loaded, request boot */ | ||
538 | req.cmd = CMD_FW_BOOT; | ||
539 | ret = af9035_ctrl_msg(udev, &req); | ||
540 | if (ret < 0) | ||
541 | goto err; | ||
542 | |||
543 | /* ensure firmware starts */ | ||
544 | wbuf[0] = 1; | ||
545 | ret = af9035_ctrl_msg(udev, &req_fw_ver); | ||
546 | if (ret < 0) | ||
547 | goto err; | ||
548 | |||
549 | if (!(rbuf[0] || rbuf[1] || rbuf[2] || rbuf[3])) { | ||
550 | info("firmware did not run"); | ||
551 | ret = -ENODEV; | ||
552 | goto err; | ||
553 | } | ||
554 | |||
555 | info("firmware version=%d.%d.%d.%d", rbuf[0], rbuf[1], rbuf[2], | ||
556 | rbuf[3]); | ||
557 | |||
558 | return 0; | ||
559 | |||
560 | err: | ||
561 | pr_debug("%s: failed=%d\n", __func__, ret); | ||
562 | |||
563 | return ret; | ||
564 | } | ||
565 | |||
496 | /* abuse that callback as there is no better one for reading eeprom */ | 566 | /* abuse that callback as there is no better one for reading eeprom */ |
497 | static int af9035_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) | 567 | static int af9035_read_mac_address(struct dvb_usb_device *d, u8 mac[6]) |
498 | { | 568 | { |
@@ -566,6 +636,32 @@ err: | |||
566 | return ret; | 636 | return ret; |
567 | } | 637 | } |
568 | 638 | ||
639 | /* abuse that callback as there is no better one for reading eeprom */ | ||
640 | static int af9035_read_mac_address_it9135(struct dvb_usb_device *d, u8 mac[6]) | ||
641 | { | ||
642 | int ret, i; | ||
643 | u8 tmp; | ||
644 | |||
645 | af9035_config.dual_mode = 0; | ||
646 | |||
647 | /* get demod clock */ | ||
648 | ret = af9035_rd_reg(d, 0x00d800, &tmp); | ||
649 | if (ret < 0) | ||
650 | goto err; | ||
651 | |||
652 | tmp = (tmp >> 0) & 0x0f; | ||
653 | |||
654 | for (i = 0; i < af9035_properties[0].num_adapters; i++) | ||
655 | af9035_af9033_config[i].clock = clock_lut_it9135[tmp]; | ||
656 | |||
657 | return 0; | ||
658 | |||
659 | err: | ||
660 | pr_debug("%s: failed=%d\n", __func__, ret); | ||
661 | |||
662 | return ret; | ||
663 | } | ||
664 | |||
569 | static int af9035_fc0011_tuner_callback(struct dvb_usb_device *d, | 665 | static int af9035_fc0011_tuner_callback(struct dvb_usb_device *d, |
570 | int cmd, int arg) | 666 | int cmd, int arg) |
571 | { | 667 | { |
@@ -914,6 +1010,49 @@ static struct dvb_usb_device_properties af9035_properties[] = { | |||
914 | }, | 1010 | }, |
915 | } | 1011 | } |
916 | }, | 1012 | }, |
1013 | { | ||
1014 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
1015 | |||
1016 | .usb_ctrl = DEVICE_SPECIFIC, | ||
1017 | .download_firmware = af9035_download_firmware_it9135, | ||
1018 | .firmware = "dvb-usb-it9135-01.fw", | ||
1019 | .no_reconnect = 1, | ||
1020 | |||
1021 | .num_adapters = 1, | ||
1022 | .adapter = { | ||
1023 | { | ||
1024 | .num_frontends = 1, | ||
1025 | .fe = { | ||
1026 | { | ||
1027 | .frontend_attach = af9035_frontend_attach, | ||
1028 | .tuner_attach = af9035_tuner_attach, | ||
1029 | .stream = { | ||
1030 | .type = USB_BULK, | ||
1031 | .count = 6, | ||
1032 | .endpoint = 0x84, | ||
1033 | .u = { | ||
1034 | .bulk = { | ||
1035 | .buffersize = (87 * 188), | ||
1036 | } | ||
1037 | } | ||
1038 | } | ||
1039 | } | ||
1040 | } | ||
1041 | } | ||
1042 | }, | ||
1043 | |||
1044 | .identify_state = af9035_identify_state, | ||
1045 | .read_mac_address = af9035_read_mac_address_it9135, | ||
1046 | |||
1047 | .i2c_algo = &af9035_i2c_algo, | ||
1048 | |||
1049 | .num_device_descs = 0, /* disabled as no support for IT9135 */ | ||
1050 | .devices = { | ||
1051 | { | ||
1052 | .name = "ITE Tech. IT9135 reference design", | ||
1053 | }, | ||
1054 | } | ||
1055 | }, | ||
917 | }; | 1056 | }; |
918 | 1057 | ||
919 | static int af9035_usb_probe(struct usb_interface *intf, | 1058 | static int af9035_usb_probe(struct usb_interface *intf, |