diff options
author | Antti Palosaari <crope@iki.fi> | 2012-01-21 20:26:52 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-02-28 16:43:39 -0500 |
commit | 9935eea5ac300b84036192af1bd98940a64650de (patch) | |
tree | aa0e86295932d6c8c9d795d8b8e630534e0f1ac9 /drivers/media/dvb/dvb-usb/rtl28xxu.c | |
parent | fba16b133e6b8dd3dd3f6f34beca1889c9ac731f (diff) |
[media] rtl28xxu: many small tweaks
* some style issues
* remove rtl2832u device IDs
* move USB IDs to correct place
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/rtl28xxu.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/rtl28xxu.c | 140 |
1 files changed, 59 insertions, 81 deletions
diff --git a/drivers/media/dvb/dvb-usb/rtl28xxu.c b/drivers/media/dvb/dvb-usb/rtl28xxu.c index 101d98e5dcdb..b5785fa36220 100644 --- a/drivers/media/dvb/dvb-usb/rtl28xxu.c +++ b/drivers/media/dvb/dvb-usb/rtl28xxu.c | |||
@@ -58,25 +58,23 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) | |||
58 | } | 58 | } |
59 | 59 | ||
60 | ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value, | 60 | ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value, |
61 | req->index, buf, req->size, 1000); | 61 | req->index, buf, req->size, 1000); |
62 | if (ret > 0) | ||
63 | ret = 0; | ||
62 | 64 | ||
63 | deb_dump(0, requesttype, req->value, req->index, buf, req->size, | 65 | deb_dump(0, requesttype, req->value, req->index, buf, req->size, |
64 | deb_xfer); | 66 | deb_xfer); |
65 | |||
66 | if (ret < 0) | ||
67 | goto err_dealloc; | ||
68 | else | ||
69 | ret = 0; | ||
70 | 67 | ||
71 | /* read request, copy returned data to return buf */ | 68 | /* read request, copy returned data to return buf */ |
72 | if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) | 69 | if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) |
73 | memcpy(req->data, buf, req->size); | 70 | memcpy(req->data, buf, req->size); |
74 | 71 | ||
75 | kfree(buf); | 72 | kfree(buf); |
76 | return ret; | ||
77 | 73 | ||
78 | err_dealloc: | 74 | if (ret) |
79 | kfree(buf); | 75 | goto err; |
76 | |||
77 | return ret; | ||
80 | err: | 78 | err: |
81 | deb_info("%s: failed=%d\n", __func__, ret); | 79 | deb_info("%s: failed=%d\n", __func__, ret); |
82 | return ret; | 80 | return ret; |
@@ -167,7 +165,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
167 | if (msg[0].len > 24 || msg[1].len > 24) { | 165 | if (msg[0].len > 24 || msg[1].len > 24) { |
168 | /* TODO: check msg[0].len max */ | 166 | /* TODO: check msg[0].len max */ |
169 | ret = -EOPNOTSUPP; | 167 | ret = -EOPNOTSUPP; |
170 | goto err_unlock; | 168 | goto err_mutex_unlock; |
171 | } else if (msg[0].addr == 0x10) { | 169 | } else if (msg[0].addr == 0x10) { |
172 | /* method 1 - integrated demod */ | 170 | /* method 1 - integrated demod */ |
173 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); | 171 | req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); |
@@ -190,7 +188,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
190 | req.data = msg[0].buf; | 188 | req.data = msg[0].buf; |
191 | ret = rtl28xxu_ctrl_msg(d, &req); | 189 | ret = rtl28xxu_ctrl_msg(d, &req); |
192 | if (ret) | 190 | if (ret) |
193 | goto err_unlock; | 191 | goto err_mutex_unlock; |
194 | 192 | ||
195 | req.value = (msg[0].addr << 1); | 193 | req.value = (msg[0].addr << 1); |
196 | req.index = CMD_I2C_DA_RD; | 194 | req.index = CMD_I2C_DA_RD; |
@@ -202,7 +200,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
202 | if (msg[0].len > 22) { | 200 | if (msg[0].len > 22) { |
203 | /* TODO: check msg[0].len max */ | 201 | /* TODO: check msg[0].len max */ |
204 | ret = -EOPNOTSUPP; | 202 | ret = -EOPNOTSUPP; |
205 | goto err_unlock; | 203 | goto err_mutex_unlock; |
206 | } else if (msg[0].addr == 0x10) { | 204 | } else if (msg[0].addr == 0x10) { |
207 | /* method 1 - integrated demod */ | 205 | /* method 1 - integrated demod */ |
208 | if (msg[0].buf[0] == 0x00) { | 206 | if (msg[0].buf[0] == 0x00) { |
@@ -236,7 +234,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], | |||
236 | ret = -EINVAL; | 234 | ret = -EINVAL; |
237 | } | 235 | } |
238 | 236 | ||
239 | err_unlock: | 237 | err_mutex_unlock: |
240 | mutex_unlock(&d->i2c_mutex); | 238 | mutex_unlock(&d->i2c_mutex); |
241 | 239 | ||
242 | return ret ? ret : num; | 240 | return ret ? ret : num; |
@@ -293,11 +291,11 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) | |||
293 | u8 buf[1]; | 291 | u8 buf[1]; |
294 | struct rtl2830_config *rtl2830_config; | 292 | struct rtl2830_config *rtl2830_config; |
295 | /* open RTL2831U/RTL2830 I2C gate */ | 293 | /* open RTL2831U/RTL2830 I2C gate */ |
296 | struct rtl28xxu_req req_gate = {0x0120, 0x0011, 0x0001, "\x08"}; | 294 | struct rtl28xxu_req req_gate = { 0x0120, 0x0011, 0x0001, "\x08" }; |
297 | /* for MT2060 tuner probe */ | 295 | /* for MT2060 tuner probe */ |
298 | struct rtl28xxu_req req_mt2060 = {0x00c0, CMD_I2C_RD, 1, buf}; | 296 | struct rtl28xxu_req req_mt2060 = { 0x00c0, CMD_I2C_RD, 1, buf }; |
299 | /* for QT1010 tuner probe */ | 297 | /* for QT1010 tuner probe */ |
300 | struct rtl28xxu_req req_qt1010 = {0x0fc4, CMD_I2C_RD, 1, buf}; | 298 | struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf }; |
301 | 299 | ||
302 | deb_info("%s:\n", __func__); | 300 | deb_info("%s:\n", __func__); |
303 | 301 | ||
@@ -484,7 +482,7 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap) | |||
484 | int ret; | 482 | int ret; |
485 | struct rtl28xxu_priv *priv = adap->dev->priv; | 483 | struct rtl28xxu_priv *priv = adap->dev->priv; |
486 | struct i2c_adapter *rtl2830_tuner_i2c; | 484 | struct i2c_adapter *rtl2830_tuner_i2c; |
487 | struct dvb_frontend *fe = NULL; | 485 | struct dvb_frontend *fe; |
488 | 486 | ||
489 | deb_info("%s:\n", __func__); | 487 | deb_info("%s:\n", __func__); |
490 | 488 | ||
@@ -503,9 +501,10 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap) | |||
503 | break; | 501 | break; |
504 | case TUNER_RTL2830_MXL5005S: | 502 | case TUNER_RTL2830_MXL5005S: |
505 | fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, | 503 | fe = dvb_attach(mxl5005s_attach, adap->fe_adap[0].fe, |
506 | rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config); | 504 | rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config); |
507 | break; | 505 | break; |
508 | default: | 506 | default: |
507 | fe = NULL; | ||
509 | err("unknown tuner=%d", priv->tuner); | 508 | err("unknown tuner=%d", priv->tuner); |
510 | } | 509 | } |
511 | 510 | ||
@@ -524,15 +523,17 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) | |||
524 | { | 523 | { |
525 | int ret; | 524 | int ret; |
526 | struct rtl28xxu_priv *priv = adap->dev->priv; | 525 | struct rtl28xxu_priv *priv = adap->dev->priv; |
527 | struct dvb_frontend *fe = NULL; | 526 | struct dvb_frontend *fe; |
528 | 527 | ||
529 | deb_info("%s:\n", __func__); | 528 | deb_info("%s:\n", __func__); |
530 | 529 | ||
531 | switch (priv->tuner) { | 530 | switch (priv->tuner) { |
532 | case TUNER_RTL2832_FC2580: | 531 | case TUNER_RTL2832_FC2580: |
533 | /* TODO: */ | 532 | /* TODO: */ |
533 | fe = NULL; | ||
534 | break; | 534 | break; |
535 | default: | 535 | default: |
536 | fe = NULL; | ||
536 | err("unknown tuner=%d", priv->tuner); | 537 | err("unknown tuner=%d", priv->tuner); |
537 | } | 538 | } |
538 | 539 | ||
@@ -662,7 +663,7 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) | |||
662 | if (!priv->rc_active) { | 663 | if (!priv->rc_active) { |
663 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { | 664 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
664 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, | 665 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, |
665 | rc_nec_tab[i].val); | 666 | rc_nec_tab[i].val); |
666 | if (ret) | 667 | if (ret) |
667 | goto err; | 668 | goto err; |
668 | } | 669 | } |
@@ -681,7 +682,7 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) | |||
681 | } else { | 682 | } else { |
682 | /* NEC extended (24 bit) */ | 683 | /* NEC extended (24 bit) */ |
683 | rc_code = buf[0] << 16 | | 684 | rc_code = buf[0] << 16 | |
684 | buf[1] << 8 | buf[2]; | 685 | buf[1] << 8 | buf[2]; |
685 | } | 686 | } |
686 | } else { | 687 | } else { |
687 | /* NEC full (32 bit) */ | 688 | /* NEC full (32 bit) */ |
@@ -707,7 +708,6 @@ err: | |||
707 | return ret; | 708 | return ret; |
708 | } | 709 | } |
709 | 710 | ||
710 | |||
711 | static int rtl2832u_rc_query(struct dvb_usb_device *d) | 711 | static int rtl2832u_rc_query(struct dvb_usb_device *d) |
712 | { | 712 | { |
713 | int ret, i; | 713 | int ret, i; |
@@ -715,27 +715,27 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) | |||
715 | u8 buf[128]; | 715 | u8 buf[128]; |
716 | int len; | 716 | int len; |
717 | struct rtl28xxu_reg_val rc_nec_tab[] = { | 717 | struct rtl28xxu_reg_val rc_nec_tab[] = { |
718 | {IR_RX_CTRL, 0x20}, | 718 | { IR_RX_CTRL, 0x20 }, |
719 | {IR_RX_BUF_CTRL, 0x80}, | 719 | { IR_RX_BUF_CTRL, 0x80 }, |
720 | {IR_RX_IF, 0xff}, | 720 | { IR_RX_IF, 0xff }, |
721 | {IR_RX_IE, 0xff}, | 721 | { IR_RX_IE, 0xff }, |
722 | {IR_MAX_DURATION0, 0xd0}, | 722 | { IR_MAX_DURATION0, 0xd0 }, |
723 | {IR_MAX_DURATION1, 0x07}, | 723 | { IR_MAX_DURATION1, 0x07 }, |
724 | {IR_IDLE_LEN0, 0xc0}, | 724 | { IR_IDLE_LEN0, 0xc0 }, |
725 | {IR_IDLE_LEN1, 0x00}, | 725 | { IR_IDLE_LEN1, 0x00 }, |
726 | {IR_GLITCH_LEN, 0x03}, | 726 | { IR_GLITCH_LEN, 0x03 }, |
727 | {IR_RX_CLK, 0x09}, | 727 | { IR_RX_CLK, 0x09 }, |
728 | {IR_RX_CFG, 0x1c}, | 728 | { IR_RX_CFG, 0x1c }, |
729 | {IR_MAX_H_TOL_LEN, 0x1e}, | 729 | { IR_MAX_H_TOL_LEN, 0x1e }, |
730 | {IR_MAX_L_TOL_LEN, 0x1e}, | 730 | { IR_MAX_L_TOL_LEN, 0x1e }, |
731 | {IR_RX_CTRL, 0x80}, | 731 | { IR_RX_CTRL, 0x80 }, |
732 | }; | 732 | }; |
733 | 733 | ||
734 | /* init remote controller */ | 734 | /* init remote controller */ |
735 | if (!priv->rc_active) { | 735 | if (!priv->rc_active) { |
736 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { | 736 | for (i = 0; i < ARRAY_SIZE(rc_nec_tab); i++) { |
737 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, | 737 | ret = rtl2831_wr_reg(d, rc_nec_tab[i].reg, |
738 | rc_nec_tab[i].val); | 738 | rc_nec_tab[i].val); |
739 | if (ret) | 739 | if (ret) |
740 | goto err; | 740 | goto err; |
741 | } | 741 | } |
@@ -769,35 +769,19 @@ err: | |||
769 | return ret; | 769 | return ret; |
770 | } | 770 | } |
771 | 771 | ||
772 | 772 | enum rtl28xxu_usb_table_entry { | |
773 | /* DVB USB Driver stuff */ | 773 | RTL2831U_0BDA_2831, |
774 | #define USB_VID_REALTEK 0x0bda | 774 | RTL2831U_14AA_0160, |
775 | #define USB_VID_DEXATEK 0x1D19 | 775 | }; |
776 | #define USB_PID_RTL2831U 0x2831 | ||
777 | #define USB_PID_RTL2832U 0x2832 | ||
778 | #define USB_PID_FREECOM 0x0160 | ||
779 | #define USB_PID_DEXATEK_1101 0x1101 | ||
780 | |||
781 | #define RTL2831U_0BDA_2831 0 | ||
782 | #define RTL2831U_14AA_0160 1 | ||
783 | |||
784 | #define RTL2832U_1ST_ID (RTL2831U_14AA_0160 + 1) | ||
785 | |||
786 | #define RTL2832U_0BDA_2832 (0 + RTL2832U_1ST_ID) | ||
787 | #define RTL2832U_1D19_1101 (1 + RTL2832U_1ST_ID) | ||
788 | |||
789 | 776 | ||
790 | static struct usb_device_id rtl28xxu_table[] = { | 777 | static struct usb_device_id rtl28xxu_table[] = { |
778 | /* RTL2831U */ | ||
791 | [RTL2831U_0BDA_2831] = { | 779 | [RTL2831U_0BDA_2831] = { |
792 | USB_DEVICE(USB_VID_REALTEK, USB_PID_RTL2831U)}, | 780 | USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U)}, |
793 | [RTL2831U_14AA_0160] = { | 781 | [RTL2831U_14AA_0160] = { |
794 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM)}, | 782 | USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT)}, |
795 | |||
796 | [RTL2832U_0BDA_2832] = { | ||
797 | USB_DEVICE(USB_VID_REALTEK, USB_PID_RTL2832U)}, | ||
798 | [RTL2832U_1D19_1101] = { | ||
799 | USB_DEVICE(USB_VID_DEXATEK, USB_PID_DEXATEK_1101)}, | ||
800 | 783 | ||
784 | /* RTL2832U */ | ||
801 | {} /* terminating entry */ | 785 | {} /* terminating entry */ |
802 | }; | 786 | }; |
803 | 787 | ||
@@ -827,7 +811,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
827 | .endpoint = 0x81, | 811 | .endpoint = 0x81, |
828 | .u = { | 812 | .u = { |
829 | .bulk = { | 813 | .bulk = { |
830 | .buffersize = 4096, | 814 | .buffersize = 8*512, |
831 | } | 815 | } |
832 | } | 816 | } |
833 | } | 817 | } |
@@ -853,15 +837,15 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
853 | .devices = { | 837 | .devices = { |
854 | { | 838 | { |
855 | .name = "Realtek RTL2831U reference design", | 839 | .name = "Realtek RTL2831U reference design", |
856 | .cold_ids = {NULL}, | ||
857 | .warm_ids = { | 840 | .warm_ids = { |
858 | &rtl28xxu_table[RTL2831U_0BDA_2831], NULL}, | 841 | &rtl28xxu_table[RTL2831U_0BDA_2831], |
842 | }, | ||
859 | }, | 843 | }, |
860 | { | 844 | { |
861 | .name = "Freecom USB2.0 DVB-T", | 845 | .name = "Freecom USB2.0 DVB-T", |
862 | .cold_ids = {NULL}, | ||
863 | .warm_ids = { | 846 | .warm_ids = { |
864 | &rtl28xxu_table[RTL2831U_14AA_0160], NULL}, | 847 | &rtl28xxu_table[RTL2831U_14AA_0160], |
848 | }, | ||
865 | }, | 849 | }, |
866 | } | 850 | } |
867 | }, | 851 | }, |
@@ -888,7 +872,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
888 | .endpoint = 0x81, | 872 | .endpoint = 0x81, |
889 | .u = { | 873 | .u = { |
890 | .bulk = { | 874 | .bulk = { |
891 | .buffersize = 4096, | 875 | .buffersize = 8*512, |
892 | } | 876 | } |
893 | } | 877 | } |
894 | } | 878 | } |
@@ -910,19 +894,10 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
910 | 894 | ||
911 | .i2c_algo = &rtl28xxu_i2c_algo, | 895 | .i2c_algo = &rtl28xxu_i2c_algo, |
912 | 896 | ||
913 | .num_device_descs = 2, | 897 | .num_device_descs = 0, /* disabled as no support for RTL2832 */ |
914 | .devices = { | 898 | .devices = { |
915 | { | 899 | { |
916 | .name = "Realtek RTL2832U reference design", | 900 | .name = "Realtek RTL2832U reference design", |
917 | .cold_ids = {NULL}, | ||
918 | .warm_ids = { | ||
919 | &rtl28xxu_table[RTL2832U_0BDA_2832], NULL}, | ||
920 | }, | ||
921 | { | ||
922 | .name = "Dexatek dongle", | ||
923 | .cold_ids = {NULL}, | ||
924 | .warm_ids = { | ||
925 | &rtl28xxu_table[RTL2832U_1D19_1101], NULL}, | ||
926 | }, | 901 | }, |
927 | } | 902 | } |
928 | }, | 903 | }, |
@@ -930,11 +905,11 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { | |||
930 | }; | 905 | }; |
931 | 906 | ||
932 | static int rtl28xxu_probe(struct usb_interface *intf, | 907 | static int rtl28xxu_probe(struct usb_interface *intf, |
933 | const struct usb_device_id *id) | 908 | const struct usb_device_id *id) |
934 | { | 909 | { |
935 | int ret, i; | 910 | int ret, i; |
936 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); | 911 | int properties_count = ARRAY_SIZE(rtl28xxu_properties); |
937 | struct dvb_usb_device *d = NULL; | 912 | struct dvb_usb_device *d; |
938 | 913 | ||
939 | deb_info("%s: interface=%d\n", __func__, | 914 | deb_info("%s: interface=%d\n", __func__, |
940 | intf->cur_altsetting->desc.bInterfaceNumber); | 915 | intf->cur_altsetting->desc.bInterfaceNumber); |
@@ -944,7 +919,7 @@ static int rtl28xxu_probe(struct usb_interface *intf, | |||
944 | 919 | ||
945 | for (i = 0; i < properties_count; i++) { | 920 | for (i = 0; i < properties_count; i++) { |
946 | ret = dvb_usb_device_init(intf, &rtl28xxu_properties[i], | 921 | ret = dvb_usb_device_init(intf, &rtl28xxu_properties[i], |
947 | THIS_MODULE, &d, adapter_nr); | 922 | THIS_MODULE, &d, adapter_nr); |
948 | if (ret == 0 || ret != -ENODEV) | 923 | if (ret == 0 || ret != -ENODEV) |
949 | break; | 924 | break; |
950 | } | 925 | } |
@@ -982,7 +957,9 @@ static struct usb_driver rtl28xxu_driver = { | |||
982 | static int __init rtl28xxu_module_init(void) | 957 | static int __init rtl28xxu_module_init(void) |
983 | { | 958 | { |
984 | int ret; | 959 | int ret; |
960 | |||
985 | deb_info("%s:\n", __func__); | 961 | deb_info("%s:\n", __func__); |
962 | |||
986 | ret = usb_register(&rtl28xxu_driver); | 963 | ret = usb_register(&rtl28xxu_driver); |
987 | if (ret) | 964 | if (ret) |
988 | err("usb_register failed=%d", ret); | 965 | err("usb_register failed=%d", ret); |
@@ -993,6 +970,7 @@ static int __init rtl28xxu_module_init(void) | |||
993 | static void __exit rtl28xxu_module_exit(void) | 970 | static void __exit rtl28xxu_module_exit(void) |
994 | { | 971 | { |
995 | deb_info("%s:\n", __func__); | 972 | deb_info("%s:\n", __func__); |
973 | |||
996 | /* deregister this driver from the USB subsystem */ | 974 | /* deregister this driver from the USB subsystem */ |
997 | usb_deregister(&rtl28xxu_driver); | 975 | usb_deregister(&rtl28xxu_driver); |
998 | } | 976 | } |