Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

[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
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@
#define USB_VID_PINNACLE			0x2304
#define USB_VID_PCTV				0x2013
#define USB_VID_PIXELVIEW			0x1554
#define USB_VID_REALTEK				0x0bda
#define USB_VID_TECHNOTREND			0x0b48
#define USB_VID_TERRATEC			0x0ccd
#define USB_VID_TELESTAR			0x10b9
@@ -126,6 +127,7 @@
#define USB_PID_E3C_EC168_3				0xfffb
#define USB_PID_E3C_EC168_4				0x1001
#define USB_PID_E3C_EC168_5				0x1002
#define USB_PID_FREECOM_DVBT				0x0160
#define USB_PID_UNIWILL_STK7700P			0x6003
#define USB_PID_GENIUS_TVGO_DVB_T03			0x4012
#define USB_PID_GRANDTEC_DVBT_USB_COLD			0x0fa0
@@ -252,6 +254,8 @@
#define USB_PID_PCTV_400E				0x020f
#define USB_PID_PCTV_450E				0x0222
#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_3650_CI		0x300a
#define USB_PID_NEBULA_DIGITV				0x0201
+59 −81
Original line number Diff line number Diff line
@@ -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,
			req->index, buf, req->size, 1000);
	if (ret > 0)
		ret = 0;

	deb_dump(0, requesttype, req->value, req->index, buf, req->size,
			deb_xfer);

	if (ret < 0)
		goto err_dealloc;
	else
		ret = 0;

	/* read request, copy returned data to return buf */
	if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN))
		memcpy(req->data, buf, req->size);

	kfree(buf);
	return ret;

err_dealloc:
	kfree(buf);
	if (ret)
		goto err;

	return ret;
err:
	deb_info("%s: failed=%d\n", __func__, ret);
	return ret;
@@ -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) {
			/* TODO: check msg[0].len max */
			ret = -EOPNOTSUPP;
			goto err_unlock;
			goto err_mutex_unlock;
		} else if (msg[0].addr == 0x10) {
			/* method 1 - integrated demod */
			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[],
			req.data = msg[0].buf;
			ret = rtl28xxu_ctrl_msg(d, &req);
			if (ret)
				goto err_unlock;
				goto err_mutex_unlock;

			req.value = (msg[0].addr << 1);
			req.index = CMD_I2C_DA_RD;
@@ -202,7 +200,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
		if (msg[0].len > 22) {
			/* TODO: check msg[0].len max */
			ret = -EOPNOTSUPP;
			goto err_unlock;
			goto err_mutex_unlock;
		} else if (msg[0].addr == 0x10) {
			/* method 1 - integrated demod */
			if (msg[0].buf[0] == 0x00) {
@@ -236,7 +234,7 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
		ret = -EINVAL;
	}

err_unlock:
err_mutex_unlock:
	mutex_unlock(&d->i2c_mutex);

	return ret ? ret : num;
@@ -484,7 +482,7 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap)
	int ret;
	struct rtl28xxu_priv *priv = adap->dev->priv;
	struct i2c_adapter *rtl2830_tuner_i2c;
	struct dvb_frontend *fe = NULL;
	struct dvb_frontend *fe;

	deb_info("%s:\n", __func__);

@@ -506,6 +504,7 @@ static int rtl2831u_tuner_attach(struct dvb_usb_adapter *adap)
				rtl2830_tuner_i2c, &rtl28xxu_mxl5005s_config);
		break;
	default:
		fe = NULL;
		err("unknown tuner=%d", priv->tuner);
	}

@@ -524,15 +523,17 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)
{
	int ret;
	struct rtl28xxu_priv *priv = adap->dev->priv;
	struct dvb_frontend *fe = NULL;
	struct dvb_frontend *fe;

	deb_info("%s:\n", __func__);

	switch (priv->tuner) {
	case TUNER_RTL2832_FC2580:
		/* TODO: */
		fe = NULL;
		break;
	default:
		fe = NULL;
		err("unknown tuner=%d", priv->tuner);
	}

@@ -707,7 +708,6 @@ static int rtl2831u_rc_query(struct dvb_usb_device *d)
	return ret;
}


static int rtl2832u_rc_query(struct dvb_usb_device *d)
{
	int ret, i;
@@ -769,35 +769,19 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d)
	return ret;
}


/* DVB USB Driver stuff */
#define	USB_VID_REALTEK                                 0x0bda
#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)

enum rtl28xxu_usb_table_entry {
	RTL2831U_0BDA_2831,
	RTL2831U_14AA_0160,
};

static struct usb_device_id rtl28xxu_table[] = {
	/* RTL2831U */
	[RTL2831U_0BDA_2831] = {
		USB_DEVICE(USB_VID_REALTEK, USB_PID_RTL2831U)},
		USB_DEVICE(USB_VID_REALTEK, USB_PID_REALTEK_RTL2831U)},
	[RTL2831U_14AA_0160] = {
		USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM)},

	[RTL2832U_0BDA_2832] = {
		USB_DEVICE(USB_VID_REALTEK, USB_PID_RTL2832U)},
	[RTL2832U_1D19_1101] = {
		USB_DEVICE(USB_VID_DEXATEK, USB_PID_DEXATEK_1101)},
		USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_FREECOM_DVBT)},

	/* RTL2832U */
	{} /* terminating entry */
};

@@ -827,7 +811,7 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = {
							.endpoint = 0x81,
							.u = {
								.bulk = {
									.buffersize = 4096,
									.buffersize = 8*512,
								}
							}
						}
@@ -853,15 +837,15 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = {
		.devices = {
			{
				.name = "Realtek RTL2831U reference design",
				.cold_ids = {NULL},
				.warm_ids = {
				&rtl28xxu_table[RTL2831U_0BDA_2831], NULL},
					&rtl28xxu_table[RTL2831U_0BDA_2831],
				},
			},
			{
				.name = "Freecom USB2.0 DVB-T",
				.cold_ids = {NULL},
				.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[] = {
							.endpoint = 0x81,
							.u = {
								.bulk = {
									.buffersize = 4096,
									.buffersize = 8*512,
								}
							}
						}
@@ -910,19 +894,10 @@ static struct dvb_usb_device_properties rtl28xxu_properties[] = {

		.i2c_algo = &rtl28xxu_i2c_algo,

		.num_device_descs = 2,
		.num_device_descs = 0, /* disabled as no support for RTL2832 */
		.devices = {
			{
				.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,
{
	int ret, i;
	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__,
		intf->cur_altsetting->desc.bInterfaceNumber);
@@ -982,7 +957,9 @@ static struct usb_driver rtl28xxu_driver = {
static int __init rtl28xxu_module_init(void)
{
	int ret;

	deb_info("%s:\n", __func__);

	ret = usb_register(&rtl28xxu_driver);
	if (ret)
		err("usb_register failed=%d", ret);
@@ -993,6 +970,7 @@ static int __init rtl28xxu_module_init(void)
static void __exit rtl28xxu_module_exit(void)
{
	deb_info("%s:\n", __func__);

	/* deregister this driver from the USB subsystem */
	usb_deregister(&rtl28xxu_driver);
}
+22 −20
Original line number Diff line number Diff line
@@ -49,25 +49,27 @@
 * USB commands
 * (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 CMD_DEMOD_RD  (DEMOD)
#define CMD_DEMOD_WR  (DEMOD | CMD_WR_FLAG)
#define CMD_USB_RD    (USB)
#define CMD_USB_WR    (USB | CMD_WR_FLAG)
#define CMD_SYS_RD    (SYS)
#define CMD_IR_RD     (CMD_SYS_RD | 0x01)
#define CMD_IR_WR     (CMD_SYS_WR | 0x01)
#define CMD_SYS_WR    (SYS | CMD_WR_FLAG)
#define CMD_I2C_RD    (I2C)
#define CMD_I2C_WR    (I2C | CMD_WR_FLAG)
#define CMD_I2C_DA_RD (I2C_DA)
#define CMD_I2C_DA_WR (I2C_DA | CMD_WR_FLAG)
#define DEMOD            0x0000
#define USB              0x0100
#define SYS              0x0200
#define I2C              0x0300
#define I2C_DA           0x0600

#define CMD_WR_FLAG      0x0010
#define CMD_DEMOD_RD     0x0000
#define CMD_DEMOD_WR     0x0010
#define CMD_USB_RD       0x0100
#define CMD_USB_WR       0x0110
#define CMD_SYS_RD       0x0200
#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 {
	u8 chip_id;
@@ -77,13 +79,13 @@ struct rtl28xxu_priv {
};

enum rtl28xxu_chip_id {
	CHIP_ID_NONE = 0,
	CHIP_ID_NONE,
	CHIP_ID_RTL2831U,
	CHIP_ID_RTL2832U,
};

enum rtl28xxu_tuner {
	TUNER_NONE = 0,
	TUNER_NONE,

	TUNER_RTL2830_QT1010,
	TUNER_RTL2830_MT2060,