Commit 9935eea5 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] rtl28xxu: many small tweaks

* some style issues
* remove rtl2832u device IDs
* move USB IDs to correct place
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent fba16b13
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#define USB_VID_PINNACLE 0x2304 #define USB_VID_PINNACLE 0x2304
#define USB_VID_PCTV 0x2013 #define USB_VID_PCTV 0x2013
#define USB_VID_PIXELVIEW 0x1554 #define USB_VID_PIXELVIEW 0x1554
#define USB_VID_REALTEK 0x0bda
#define USB_VID_TECHNOTREND 0x0b48 #define USB_VID_TECHNOTREND 0x0b48
#define USB_VID_TERRATEC 0x0ccd #define USB_VID_TERRATEC 0x0ccd
#define USB_VID_TELESTAR 0x10b9 #define USB_VID_TELESTAR 0x10b9
...@@ -126,6 +127,7 @@ ...@@ -126,6 +127,7 @@
#define USB_PID_E3C_EC168_3 0xfffb #define USB_PID_E3C_EC168_3 0xfffb
#define USB_PID_E3C_EC168_4 0x1001 #define USB_PID_E3C_EC168_4 0x1001
#define USB_PID_E3C_EC168_5 0x1002 #define USB_PID_E3C_EC168_5 0x1002
#define USB_PID_FREECOM_DVBT 0x0160
#define USB_PID_UNIWILL_STK7700P 0x6003 #define USB_PID_UNIWILL_STK7700P 0x6003
#define USB_PID_GENIUS_TVGO_DVB_T03 0x4012 #define USB_PID_GENIUS_TVGO_DVB_T03 0x4012
#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0 #define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
...@@ -252,6 +254,8 @@ ...@@ -252,6 +254,8 @@
#define USB_PID_PCTV_400E 0x020f #define USB_PID_PCTV_400E 0x020f
#define USB_PID_PCTV_450E 0x0222 #define USB_PID_PCTV_450E 0x0222
#define USB_PID_PCTV_452E 0x021f #define USB_PID_PCTV_452E 0x021f
#define USB_PID_REALTEK_RTL2831U 0x2831
#define USB_PID_REALTEK_RTL2832U 0x2832
#define USB_PID_TECHNOTREND_CONNECT_S2_3600 0x3007 #define USB_PID_TECHNOTREND_CONNECT_S2_3600 0x3007
#define USB_PID_TECHNOTREND_CONNECT_S2_3650_CI 0x300a #define USB_PID_TECHNOTREND_CONNECT_S2_3650_CI 0x300a
#define USB_PID_NEBULA_DIGITV 0x0201 #define USB_PID_NEBULA_DIGITV 0x0201
......
...@@ -59,24 +59,22 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req) ...@@ -59,24 +59,22 @@ static int rtl28xxu_ctrl_msg(struct dvb_usb_device *d, struct rtl28xxu_req *req)
ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value, ret = usb_control_msg(d->udev, pipe, 0, requesttype, req->value,
req->index, buf, req->size, 1000); req->index, buf, req->size, 1000);
if (ret > 0)
ret = 0;
deb_dump(0, requesttype, req->value, req->index, buf, req->size, deb_dump(0, requesttype, req->value, req->index, buf, req->size,
deb_xfer); deb_xfer);
if (ret < 0)
goto err_dealloc;
else
ret = 0;
/* read request, copy returned data to return buf */ /* read request, copy returned data to return buf */
if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN))
memcpy(req->data, buf, req->size); memcpy(req->data, buf, req->size);
kfree(buf); kfree(buf);
return ret;
err_dealloc: if (ret)
kfree(buf); goto err;
return ret;
err: err:
deb_info("%s: failed=%d\n", __func__, ret); deb_info("%s: failed=%d\n", __func__, ret);
return ret; return ret;
...@@ -167,7 +165,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -167,7 +165,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
if (msg[0].len > 24 || msg[1].len > 24) { if (msg[0].len > 24 || msg[1].len > 24) {
/* TODO: check msg[0].len max */ /* TODO: check msg[0].len max */
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto err_unlock; goto err_mutex_unlock;
} else if (msg[0].addr == 0x10) { } else if (msg[0].addr == 0x10) {
/* method 1 - integrated demod */ /* method 1 - integrated demod */
req.value = (msg[0].buf[0] << 8) | (msg[0].addr << 1); 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,7 +188,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
req.data = msg[0].buf; req.data = msg[0].buf;
ret = rtl28xxu_ctrl_msg(d, &req); ret = rtl28xxu_ctrl_msg(d, &req);
if (ret) if (ret)
goto err_unlock; goto err_mutex_unlock;
req.value = (msg[0].addr << 1); req.value = (msg[0].addr << 1);
req.index = CMD_I2C_DA_RD; req.index = CMD_I2C_DA_RD;
...@@ -202,7 +200,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -202,7 +200,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
if (msg[0].len > 22) { if (msg[0].len > 22) {
/* TODO: check msg[0].len max */ /* TODO: check msg[0].len max */
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto err_unlock; goto err_mutex_unlock;
} else if (msg[0].addr == 0x10) { } else if (msg[0].addr == 0x10) {
/* method 1 - integrated demod */ /* method 1 - integrated demod */
if (msg[0].buf[0] == 0x00) { if (msg[0].buf[0] == 0x00) {
...@@ -236,7 +234,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -236,7 +234,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
ret = -EINVAL; ret = -EINVAL;
} }
err_unlock: err_mutex_unlock:
mutex_unlock(&d->i2c_mutex); mutex_unlock(&d->i2c_mutex);
return ret ? ret : num; return ret ? ret : num;
...@@ -293,11 +291,11 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap) ...@@ -293,11 +291,11 @@ static int rtl2831u_frontend_attach(struct dvb_usb_adapter *adap)
u8 buf[1]; u8 buf[1];
struct rtl2830_config *rtl2830_config; struct rtl2830_config *rtl2830_config;
/* open RTL2831U/RTL2830 I2C gate */ /* open RTL2831U/RTL2830 I2C gate */
struct rtl28xxu_req req_gate = {0x0120, 0x0011, 0x0001, "\x08"}; struct rtl28xxu_req req_gate = { 0x0120, 0x0011, 0x0001, "\x08" };
/* for MT2060 tuner probe */ /* for MT2060 tuner probe */
struct rtl28xxu_req req_mt2060 = {0x00c0, CMD_I2C_RD, 1, buf}; struct rtl28xxu_req req_mt2060 = { 0x00c0, CMD_I2C_RD, 1, buf };
/* for QT1010 tuner probe */ /* for QT1010 tuner probe */
struct rtl28xxu_req req_qt1010 = {0x0fc4, CMD_I2C_RD, 1, buf}; struct rtl28xxu_req req_qt1010 = { 0x0fc4, CMD_I2C_RD, 1, buf };
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
...@@ -484,7 +482,7 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap) ...@@ -484,7 +482,7 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap)
int ret; int ret;
struct rtl28xxu_priv *priv = adap->dev->priv; struct rtl28xxu_priv *priv = adap->dev->priv;
struct i2c_adapter *rtl2830_tuner_i2c; struct i2c_adapter *rtl2830_tuner_i2c;
struct dvb_frontend *fe = NULL; struct dvb_frontend *fe;
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
...@@ -506,6 +504,7 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap) ...@@ -506,6 +504,7 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap)
rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config); rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config);
break; break;
default: default:
fe = NULL;
err("unknown tuner=%d", priv->tuner); err("unknown tuner=%d", priv->tuner);
} }
...@@ -524,15 +523,17 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap) ...@@ -524,15 +523,17 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
{ {
int ret; int ret;
struct rtl28xxu_priv *priv = adap->dev->priv; struct rtl28xxu_priv *priv = adap->dev->priv;
struct dvb_frontend *fe = NULL; struct dvb_frontend *fe;
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
switch (priv->tuner) { switch (priv->tuner) {
case TUNER_RTL2832_FC2580: case TUNER_RTL2832_FC2580:
/* TODO: */ /* TODO: */
fe = NULL;
break; break;
default: default:
fe = NULL;
err("unknown tuner=%d", priv->tuner); err("unknown tuner=%d", priv->tuner);
} }
...@@ -707,7 +708,6 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d) ...@@ -707,7 +708,6 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d)
return ret; return ret;
} }
static int rtl2832u_rc_query(struct dvb_usb_device *d) static int rtl2832u_rc_query(struct dvb_usb_device *d)
{ {
int ret, i; int ret, i;
...@@ -715,20 +715,20 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) ...@@ -715,20 +715,20 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d)
u8 buf[128]; u8 buf[128];
int len; int len;
struct rtl28xxu_reg_val rc_nec_tab[] = { struct rtl28xxu_reg_val rc_nec_tab[] = {
{IR_RX_CTRL, 0x20}, { IR_RX_CTRL, 0x20 },
{IR_RX_BUF_CTRL, 0x80}, { IR_RX_BUF_CTRL, 0x80 },
{IR_RX_IF, 0xff}, { IR_RX_IF, 0xff },
{IR_RX_IE, 0xff}, { IR_RX_IE, 0xff },
{IR_MAX_DURATION0, 0xd0}, { IR_MAX_DURATION0, 0xd0 },
{IR_MAX_DURATION1, 0x07}, { IR_MAX_DURATION1, 0x07 },
{IR_IDLE_LEN0, 0xc0}, { IR_IDLE_LEN0, 0xc0 },
{IR_IDLE_LEN1, 0x00}, { IR_IDLE_LEN1, 0x00 },
{IR_GLITCH_LEN, 0x03}, { IR_GLITCH_LEN, 0x03 },
{IR_RX_CLK, 0x09}, { IR_RX_CLK, 0x09 },
{IR_RX_CFG, 0x1c}, { IR_RX_CFG, 0x1c },
{IR_MAX_H_TOL_LEN, 0x1e}, { IR_MAX_H_TOL_LEN, 0x1e },
{IR_MAX_L_TOL_LEN, 0x1e}, { IR_MAX_L_TOL_LEN, 0x1e },
{IR_RX_CTRL, 0x80}, { IR_RX_CTRL, 0x80 },
}; };
/* init remote controller */ /* init remote controller */
...@@ -769,35 +769,19 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) ...@@ -769,35 +769,19 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d)
return ret; return ret;
} }
enum rtl28xxu_usb_table_entry {
/* DVB USB Driver stuff */ RTL2831U_0BDA_2831,
#define USB_VID_REALTEK 0x0bda RTL2831U_14AA_0160,
#define USB_VID_DEXATEK 0x1D19 };
#define USB_PID_RTL2831U 0x2831
#define USB_PID_RTL2832U 0x2832
#define USB_PID_FREECOM 0x0160
#define USB_PID_DEXATEK_1101 0x1101
#define RTL2831U_0BDA_2831 0
#define RTL2831U_14AA_0160 1
#define RTL2832U_1ST_ID (RTL2831U_14AA_0160 + 1)
#define RTL2832U_0BDA_2832 (0 + RTL2832U_1ST_ID)
#define RTL2832U_1D19_1101 (1 + RTL2832U_1ST_ID)
static struct usb_device_id rtl28xxu_table[] = { static struct usb_device_id rtl28xxu_table[] = {
/* RTL2831U */
[RTL2831U_0BDA_2831] = { [RTL2831U_0BDA_2831] = {
USB_DEVICE(USB_VID_REALTEK, USB_PID_RTL2831U)}, USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U)},
[RTL2831U_14AA_0160] = { [RTL2831U_14AA_0160] = {
USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM)}, USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT)},
[RTL2832U_0BDA_2832] = {
USB_DEVICE(USB_VID_REALTEK, USB_PID_RTL2832U)},
[RTL2832U_1D19_1101] = {
USB_DEVICE(USB_VID_DEXATEK, USB_PID_DEXATEK_1101)},
/* RTL2832U */
{} /* terminating entry */ {} /* terminating entry */
}; };
...@@ -827,7 +811,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { ...@@ -827,7 +811,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = {
.endpoint = 0x81, .endpoint = 0x81,
.u = { .u = {
.bulk = { .bulk = {
.buffersize = 4096, .buffersize = 8*512,
} }
} }
} }
...@@ -853,15 +837,15 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { ...@@ -853,15 +837,15 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = {
.devices = { .devices = {
{ {
.name = "Realtek RTL2831U reference design", .name = "Realtek RTL2831U reference design",
.cold_ids = {NULL},
.warm_ids = { .warm_ids = {
&rtl28xxu_table[RTL2831U_0BDA_2831], NULL}, &rtl28xxu_table[RTL2831U_0BDA_2831],
},
}, },
{ {
.name = "Freecom USB2.0 DVB-T", .name = "Freecom USB2.0 DVB-T",
.cold_ids = {NULL},
.warm_ids = { .warm_ids = {
&rtl28xxu_table[RTL2831U_14AA_0160], NULL}, &rtl28xxu_table[RTL2831U_14AA_0160],
},
}, },
} }
}, },
...@@ -888,7 +872,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { ...@@ -888,7 +872,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = {
.endpoint = 0x81, .endpoint = 0x81,
.u = { .u = {
.bulk = { .bulk = {
.buffersize = 4096, .buffersize = 8*512,
} }
} }
} }
...@@ -910,19 +894,10 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = { ...@@ -910,19 +894,10 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = {
.i2c_algo = &rtl28xxu_i2c_algo, .i2c_algo = &rtl28xxu_i2c_algo,
.num_device_descs = 2, .num_device_descs = 0, /* disabled as no support for RTL2832 */
.devices = { .devices = {
{ {
.name = "Realtek RTL2832U reference design", .name = "Realtek RTL2832U reference design",
.cold_ids = {NULL},
.warm_ids = {
&rtl28xxu_table[RTL2832U_0BDA_2832], NULL},
},
{
.name = "Dexatek dongle",
.cold_ids = {NULL},
.warm_ids = {
&rtl28xxu_table[RTL2832U_1D19_1101], NULL},
}, },
} }
}, },
...@@ -934,7 +909,7 @@ static int rtl28xxu_probe(struct usb_interface *intf, ...@@ -934,7 +909,7 @@ static int rtl28xxu_probe(struct usb_interface *intf,
{ {
int ret, i; int ret, i;
int properties_count = ARRAY_SIZE(rtl28xxu_properties); int properties_count = ARRAY_SIZE(rtl28xxu_properties);
struct dvb_usb_device *d = NULL; struct dvb_usb_device *d;
deb_info("%s: interface=%d\n", __func__, deb_info("%s: interface=%d\n", __func__,
intf->cur_altsetting->desc.bInterfaceNumber); intf->cur_altsetting->desc.bInterfaceNumber);
...@@ -982,7 +957,9 @@ static struct usb_driver rtl28xxu_driver = { ...@@ -982,7 +957,9 @@ static struct usb_driver rtl28xxu_driver = {
static int __init rtl28xxu_module_init(void) static int __init rtl28xxu_module_init(void)
{ {
int ret; int ret;
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
ret = usb_register(&rtl28xxu_driver); ret = usb_register(&rtl28xxu_driver);
if (ret) if (ret)
err("usb_register failed=%d", ret); err("usb_register failed=%d", ret);
...@@ -993,6 +970,7 @@ static int __init rtl28xxu_module_init(void) ...@@ -993,6 +970,7 @@ static int __init rtl28xxu_module_init(void)
static void __exit rtl28xxu_module_exit(void) static void __exit rtl28xxu_module_exit(void)
{ {
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
/* deregister this driver from the USB subsystem */ /* deregister this driver from the USB subsystem */
usb_deregister(&rtl28xxu_driver); usb_deregister(&rtl28xxu_driver);
} }
......
...@@ -49,25 +49,27 @@ ...@@ -49,25 +49,27 @@
* USB commands * USB commands
* (usb_control_msg() index parameter) * (usb_control_msg() index parameter)
*/ */
#define DEMOD (0x00 << 8)
#define USB (0x01 << 8)
#define SYS (0x02 << 8)
#define I2C (0x03 << 8)
#define I2C_DA (0x06 << 8)
#define CMD_WR_FLAG 0x10 #define DEMOD 0x0000
#define CMD_DEMOD_RD (DEMOD) #define USB 0x0100
#define CMD_DEMOD_WR (DEMOD | CMD_WR_FLAG) #define SYS 0x0200
#define CMD_USB_RD (USB) #define I2C 0x0300
#define CMD_USB_WR (USB | CMD_WR_FLAG) #define I2C_DA 0x0600
#define CMD_SYS_RD (SYS)
#define CMD_IR_RD (CMD_SYS_RD | 0x01) #define CMD_WR_FLAG 0x0010
#define CMD_IR_WR (CMD_SYS_WR | 0x01) #define CMD_DEMOD_RD 0x0000
#define CMD_SYS_WR (SYS | CMD_WR_FLAG) #define CMD_DEMOD_WR 0x0010
#define CMD_I2C_RD (I2C) #define CMD_USB_RD 0x0100
#define CMD_I2C_WR (I2C | CMD_WR_FLAG) #define CMD_USB_WR 0x0110
#define CMD_I2C_DA_RD (I2C_DA) #define CMD_SYS_RD 0x0200
#define CMD_I2C_DA_WR (I2C_DA | CMD_WR_FLAG) #define CMD_IR_RD 0x0201
#define CMD_IR_WR 0x0211
#define CMD_SYS_WR 0x0210
#define CMD_I2C_RD 0x0300
#define CMD_I2C_WR 0x0310
#define CMD_I2C_DA_RD 0x0600
#define CMD_I2C_DA_WR 0x0610
struct rtl28xxu_priv { struct rtl28xxu_priv {
u8 chip_id; u8 chip_id;
...@@ -77,13 +79,13 @@ struct rtl28xxu_priv { ...@@ -77,13 +79,13 @@ struct rtl28xxu_priv {
}; };
enum rtl28xxu_chip_id { enum rtl28xxu_chip_id {
CHIP_ID_NONE = 0, CHIP_ID_NONE,
CHIP_ID_RTL2831U, CHIP_ID_RTL2831U,
CHIP_ID_RTL2832U, CHIP_ID_RTL2832U,
}; };
enum rtl28xxu_tuner { enum rtl28xxu_tuner {
TUNER_NONE = 0, TUNER_NONE,
TUNER_RTL2830_QT1010, TUNER_RTL2830_QT1010,
TUNER_RTL2830_MT2060, TUNER_RTL2830_MT2060,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment