diff mbox series

[V2,2/2] Add suport for Avermedia TD310

Message ID 97905686-6FE3-4EFE-9B1B-B137631FBAD3@telefonica.net (mailing list archive)
State New, archived
Headers show
Series Add suport for Avermedia TD310 | expand

Commit Message

Jose Alberto Reguero Feb. 20, 2019, 9:36 p.m. UTC
This patch add support for Avermedia TD310 usb stik. 

Signed-off-by: Jose Alberto Reguero <jose.alberto.reguero@gmail.com>

Comments

Sean Young Feb. 21, 2019, 9:35 a.m. UTC | #1
s/suport/support in title.

On Wed, Feb 20, 2019 at 10:36:16PM +0100, Jose Alberto Reguero wrote:
> This patch add support for Avermedia TD310 usb stik. 

stick

> 
> Signed-off-by: Jose Alberto Reguero <jose.alberto.reguero@gmail.com> 
> 
> diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.c linux.new/drivers/media/usb/dvb-usb-v2/af9035.c
> --- linux/drivers/media/usb/dvb-usb-v2/af9035.c	2019-02-20 16:54:24.121847069 +0100
> +++ linux.new/drivers/media/usb/dvb-usb-v2/af9035.c	2019-02-20 16:53:50.148848459 +0100
> @@ -1215,6 +1215,7 @@ static int it930x_frontend_attach(struct
>  	int ret;
>  	struct si2168_config si2168_config;
>  	struct i2c_adapter *adapter;
> +	u8 i2c_addr;
>  
>  	dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
>  
> @@ -1267,7 +1268,11 @@ static int it930x_frontend_attach(struct
>  
>  	state->af9033_config[adap->id].fe = &adap->fe[0];
>  	state->af9033_config[adap->id].ops = &state->ops;
> -	ret = af9035_add_i2c_dev(d, "si2168", 0x67, &si2168_config,
> +	i2c_addr = 0x67;
> +	if ((le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_AVERMEDIA) &&
> +			(le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_AVERMEDIA_TD310))

Bad alignment. Please check with checkpatch.pl --strict

Also I'm not a fan of the comparing usb ids in the frontend attach. It would
be nicer to have this in some constant struct which stores per-device i2c
addresses (and other bits which vary per-device). 


Sean

> +		i2c_addr = 0x64;
> +	ret = af9035_add_i2c_dev(d, "si2168", i2c_addr, &si2168_config,
>  				&d->i2c_adap);
>  	if (ret)
>  		goto err;
> @@ -1614,13 +1619,20 @@ static int it930x_tuner_attach(struct dv
>  	struct usb_interface *intf = d->intf;
>  	int ret;
>  	struct si2157_config si2157_config;
> +	u8 i2c_addr;
>  
>  	dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
>  
>  	memset(&si2157_config, 0, sizeof(si2157_config));
>  	si2157_config.fe = adap->fe[0];
>  	si2157_config.if_port = 1;
> -	ret = af9035_add_i2c_dev(d, "si2157", 0x63,
> +	i2c_addr = 0x63;
> +	if ((le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_AVERMEDIA) &&
> +			(le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_AVERMEDIA_TD310)) {
> +		i2c_addr = 0x60;
> +		si2157_config.if_port = 0;
> +	}
> +	ret = af9035_add_i2c_dev(d, "si2157", i2c_addr,
>  			&si2157_config, state->i2c_adapter_demod);
>  
>  	if (ret)
> @@ -2128,6 +2140,8 @@ static const struct usb_device_id af9035
>  	/* IT930x devices */
>  	{ DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9303,
>  		&it930x_props, "ITE 9303 Generic", NULL) },
> +	{ DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD310,
> +		&it930x_props, "AVerMedia TD310 DVB-T2", NULL) },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(usb, af9035_id_table);
> diff -upr linux/include/media/dvb-usb-ids.h linux.new/include/media/dvb-usb-ids.h
> --- linux/include/media/dvb-usb-ids.h	2018-05-05 07:40:18.000000000 +0200
> +++ linux.new/include/media/dvb-usb-ids.h	2019-02-20 16:53:50.149848459 +0100
> @@ -258,6 +258,7 @@
>  #define USB_PID_AVERMEDIA_A867				0xa867
>  #define USB_PID_AVERMEDIA_H335				0x0335
>  #define USB_PID_AVERMEDIA_TD110				0xa110
> +#define USB_PID_AVERMEDIA_TD310				0x1871
>  #define USB_PID_AVERMEDIA_TWINSTAR			0x0825
>  #define USB_PID_TECHNOTREND_CONNECT_S2400               0x3006
>  #define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM	0x3009
> 
> -- 
> Enviado desde mi dispositivo Android con K-9 Mail. Por favor, disculpa mi brevedad.
diff mbox series

Patch

diff -upr linux/drivers/media/usb/dvb-usb-v2/af9035.c linux.new/drivers/media/usb/dvb-usb-v2/af9035.c
--- linux/drivers/media/usb/dvb-usb-v2/af9035.c	2019-02-20 16:54:24.121847069 +0100
+++ linux.new/drivers/media/usb/dvb-usb-v2/af9035.c	2019-02-20 16:53:50.148848459 +0100
@@ -1215,6 +1215,7 @@  static int it930x_frontend_attach(struct
 	int ret;
 	struct si2168_config si2168_config;
 	struct i2c_adapter *adapter;
+	u8 i2c_addr;
 
 	dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
 
@@ -1267,7 +1268,11 @@  static int it930x_frontend_attach(struct
 
 	state->af9033_config[adap->id].fe = &adap->fe[0];
 	state->af9033_config[adap->id].ops = &state->ops;
-	ret = af9035_add_i2c_dev(d, "si2168", 0x67, &si2168_config,
+	i2c_addr = 0x67;
+	if ((le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_AVERMEDIA) &&
+			(le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_AVERMEDIA_TD310))
+		i2c_addr = 0x64;
+	ret = af9035_add_i2c_dev(d, "si2168", i2c_addr, &si2168_config,
 				&d->i2c_adap);
 	if (ret)
 		goto err;
@@ -1614,13 +1619,20 @@  static int it930x_tuner_attach(struct dv
 	struct usb_interface *intf = d->intf;
 	int ret;
 	struct si2157_config si2157_config;
+	u8 i2c_addr;
 
 	dev_dbg(&intf->dev, "adap->id=%d\n", adap->id);
 
 	memset(&si2157_config, 0, sizeof(si2157_config));
 	si2157_config.fe = adap->fe[0];
 	si2157_config.if_port = 1;
-	ret = af9035_add_i2c_dev(d, "si2157", 0x63,
+	i2c_addr = 0x63;
+	if ((le16_to_cpu(d->udev->descriptor.idVendor) == USB_VID_AVERMEDIA) &&
+			(le16_to_cpu(d->udev->descriptor.idProduct) == USB_PID_AVERMEDIA_TD310)) {
+		i2c_addr = 0x60;
+		si2157_config.if_port = 0;
+	}
+	ret = af9035_add_i2c_dev(d, "si2157", i2c_addr,
 			&si2157_config, state->i2c_adapter_demod);
 
 	if (ret)
@@ -2128,6 +2140,8 @@  static const struct usb_device_id af9035
 	/* IT930x devices */
 	{ DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9303,
 		&it930x_props, "ITE 9303 Generic", NULL) },
+	{ DVB_USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_TD310,
+		&it930x_props, "AVerMedia TD310 DVB-T2", NULL) },
 	{ }
 };
 MODULE_DEVICE_TABLE(usb, af9035_id_table);
diff -upr linux/include/media/dvb-usb-ids.h linux.new/include/media/dvb-usb-ids.h
--- linux/include/media/dvb-usb-ids.h	2018-05-05 07:40:18.000000000 +0200
+++ linux.new/include/media/dvb-usb-ids.h	2019-02-20 16:53:50.149848459 +0100
@@ -258,6 +258,7 @@ 
 #define USB_PID_AVERMEDIA_A867				0xa867
 #define USB_PID_AVERMEDIA_H335				0x0335
 #define USB_PID_AVERMEDIA_TD110				0xa110
+#define USB_PID_AVERMEDIA_TD310				0x1871
 #define USB_PID_AVERMEDIA_TWINSTAR			0x0825
 #define USB_PID_TECHNOTREND_CONNECT_S2400               0x3006
 #define USB_PID_TECHNOTREND_CONNECT_S2400_8KEEPROM	0x3009