diff mbox

Support faulty USB IDs on DIBUSB_MC

Message ID 4974E4BE.2060107@free.fr (mailing list archive)
State Rejected
Headers show

Commit Message

Matthieu Castet Jan. 19, 2009, 8:38 p.m. UTC
matthieu castet wrote:
> Hi,
> 
> I got a LITE-ON USB2.0 DVB-T Tuner that loose it's cold state vid/pid 
> and got  FX2 dev kit one (0x04b4, 0x8613).
> 
> This patch introduce an option similar to the DVB_USB_DIBUSB_MB_FAULTY :
> it add the FX2 dev kit ids to the DIBUSB_MC driver if 
> DVB_USB_DIBUSB_MC_FAULTY is selected.
> 
> Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
> 

Ping

Comments

Mauro Carvalho Chehab Jan. 29, 2009, 9:47 a.m. UTC | #1
On Mon, 19 Jan 2009 21:38:22 +0100
matthieu castet <castet.matthieu@free.fr> wrote:

> matthieu castet wrote:
> > Hi,
> > 
> > I got a LITE-ON USB2.0 DVB-T Tuner that loose it's cold state vid/pid 
> > and got  FX2 dev kit one (0x04b4, 0x8613).
> > 
> > This patch introduce an option similar to the DVB_USB_DIBUSB_MB_FAULTY :
> > it add the FX2 dev kit ids to the DIBUSB_MC driver if 
> > DVB_USB_DIBUSB_MC_FAULTY is selected.
> > 
> > Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr>
> > 
> 
> diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
> index f00a0eb..a656b9b 100644
> --- a/drivers/media/dvb/dvb-usb/Kconfig
> +++ b/drivers/media/dvb/dvb-usb/Kconfig
> @@ -68,6 +68,12 @@ config DVB_USB_DIBUSB_MC
>  	  Say Y if you own such a device and want to use it. You should build it as
>  	  a module.
>  
> +config DVB_USB_DIBUSB_MC_FAULTY
> +	bool "Support faulty USB IDs"
> +	depends on DVB_USB_DIBUSB_MC
> +	help
> +	  Support for faulty USB IDs due to an invalid EEPROM on some LITE-ON devices.
> +
>  config DVB_USB_DIB0700
>  	tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
>  	depends on DVB_USB
> diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
> index 059cec9..ab5766a 100644
> --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
> +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
> @@ -42,6 +42,17 @@ static struct usb_device_id dibusb_dib3000mc_table [] = {
>  /* 11 */	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,	USB_PID_ARTEC_T14_WARM) },
>  /* 12 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_COLD) },
>  /* 13 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_WARM) },
> +/*
> + * XXX: Some LITE-ON devices seem to loose their id after some time. Bad EEPROM ???.
> + *      We don't catch these faulty IDs (namely 'Cypress FX2 USB controller') that
> + *      have been left on the device. If you don't have such a device but an LITE-ON
> + *      device that's supposed to work with this driver but is not detected by it,
> + *      free to enable CONFIG_DVB_USB_DIBUSB_MC_FAULTY via your kernel config.
> + */
> +
> +#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
> +/* 14 */	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
> +#endif

It doesn't sound a very good approach the need of recompiling the driver to
allow it to work with a broken card. The better would be to have some modprobe
option to force it to accept a certain USB ID as a valid ID for the card.

>  			{ }		/* Terminating entry */
>  };
>  MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
> @@ -88,7 +99,11 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
>  
>  	.generic_bulk_ctrl_endpoint = 0x01,
>  
> +#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
> +	.num_device_descs = 8,
> +#else
>  	.num_device_descs = 7,
> +#endif

The above is really ugly. IMO, we should replace this by
ARRAY_SIZE(dibusb_mc_properties.devices). Of course, for this to work,
num_device_descs should be bellow devices.

>  	.devices = {
>  		{   "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
>  			{ &dibusb_dib3000mc_table[0], NULL },
> @@ -119,6 +134,13 @@ static struct dvb_usb_device_properties dibusb_mc_properties = {
>  			{ &dibusb_dib3000mc_table[12], NULL },
>  			{ &dibusb_dib3000mc_table[13], NULL },
>  		},
> +#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
> +		{   "LITE-ON USB2.0 DVB-T Tuner (faulty USB IDs)",
> +		    /* Also rebranded as Intuix S800, Toshiba */
> +			{ &dibusb_dib3000mc_table[14], NULL },
> +			{ NULL },
> +		},
> +#endif
>  		{ NULL },
>  	}
>  };


Patrick,
Comments?


Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Patrick Boettcher Jan. 29, 2009, 10:19 a.m. UTC | #2
Hi,

sorry for not answering ealier, recently I became the master of 
postponing things. :(

On Thu, 29 Jan 2009, Mauro Carvalho Chehab wrote:

>> +/* 14 */	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
>> +#endif
>
> It doesn't sound a very good approach the need of recompiling the driver to
> allow it to work with a broken card. The better would be to have some modprobe
> option to force it to accept a certain USB ID as a valid ID for the card.

The most correct way would be to reprogram the eeprom, by simply writing 
to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb some 
time ago.

> The above is really ugly. IMO, we should replace this by
> ARRAY_SIZE(dibusb_mc_properties.devices). Of course, for this to work,
> num_device_descs should be bellow devices.

We could do that, still I'm not sure if ARRAY_SIZE will work in that 
situation?! Are you 
sure, Mauro?

Patrick.

--
   Mail: patrick.boettcher@desy.de
   WWW:  http://www.wi-bw.tfh-wildau.de/~pboettch/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matthieu Castet Jan. 29, 2009, 8:05 p.m. UTC | #3
Hi Patrick,

Patrick Boettcher wrote:
> Hi,
> 
> sorry for not answering ealier, recently I became the master of 
> postponing things. :(
> 
> On Thu, 29 Jan 2009, Mauro Carvalho Chehab wrote:
> 
>>> +/* 14 */    { USB_DEVICE(USB_VID_CYPRESS,        
>>> USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
>>> +#endif
>>
>> It doesn't sound a very good approach the need of recompiling the 
>> driver to
>> allow it to work with a broken card. The better would be to have some 
>> modprobe
>> option to force it to accept a certain USB ID as a valid ID for the card.
> 
> The most correct way would be to reprogram the eeprom, by simply writing 
> to 0xa0 (0x50 << 1) I2C address... There was a thread on the linux-dvb 
> some time ago.
> 
Why not, I only don't want to maintain a patch for my device.

I wonder why didn't they use WP pin of the eeprom to avoid write.

Do you know what should be written.
After a quick search, I found [1]. Is that ok ?


Matthieu

[1]
EEPROM Address            Contents
       0        0xC0
       1        Vendor ID (VID) L
       2        Vendor ID (VID) H
       3        Product ID (PID) L
       4        Product ID (PID) H
       5        Device ID (DID) L
       6        Device ID (DID) H
       7        Configuration byte

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matthieu Castet Jan. 29, 2009, 8:46 p.m. UTC | #4
matthieu castet wrote:
> Hi Patrick,
> 
> Patrick Boettcher wrote:
>> Hi,
>>
>> sorry for not answering ealier, recently I became the master of 
>> postponing things. :(
>>
>> On Thu, 29 Jan 2009, Mauro Carvalho Chehab wrote:
>>
>>>> +/* 14 */    { USB_DEVICE(USB_VID_CYPRESS,        
>>>> USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
>>>> +#endif
>>>
>>> It doesn't sound a very good approach the need of recompiling the 
>>> driver to
>>> allow it to work with a broken card. The better would be to have some 
>>> modprobe
>>> option to force it to accept a certain USB ID as a valid ID for the 
>>> card.
>>
>> The most correct way would be to reprogram the eeprom, by simply 
>> writing to 0xa0 (0x50 << 1) I2C address... There was a thread on the 
>> linux-dvb some time ago.
>>
BTW dibusb_i2c_xfer seems to do things very dangerous :
it assumes that it get only write/read request or write request.

That means that read can be understood as write. For example a program 
doing
file = open("/dev/i2c-x", O_RDWR);
ioctl(file, I2C_SLAVE, 0x50)
  read(file, data, 10)
will corrupt the eeprom as it will be understood as a write.

Now that I think of that, I run sensors-detect on this machine, may be 
this is what trash the eeprom ?


Matthieu
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index f00a0eb..a656b9b 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -68,6 +68,12 @@  config DVB_USB_DIBUSB_MC
 	  Say Y if you own such a device and want to use it. You should build it as
 	  a module.
 
+config DVB_USB_DIBUSB_MC_FAULTY
+	bool "Support faulty USB IDs"
+	depends on DVB_USB_DIBUSB_MC
+	help
+	  Support for faulty USB IDs due to an invalid EEPROM on some LITE-ON devices.
+
 config DVB_USB_DIB0700
 	tristate "DiBcom DiB0700 USB DVB devices (see help for supported devices)"
 	depends on DVB_USB
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
index 059cec9..ab5766a 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
@@ -42,6 +42,17 @@  static struct usb_device_id dibusb_dib3000mc_table [] = {
 /* 11 */	{ USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC,	USB_PID_ARTEC_T14_WARM) },
 /* 12 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_COLD) },
 /* 13 */	{ USB_DEVICE(USB_VID_LEADTEK,		USB_PID_WINFAST_DTV_DONGLE_WARM) },
+/*
+ * XXX: Some LITE-ON devices seem to loose their id after some time. Bad EEPROM ???.
+ *      We don't catch these faulty IDs (namely 'Cypress FX2 USB controller') that
+ *      have been left on the device. If you don't have such a device but an LITE-ON
+ *      device that's supposed to work with this driver but is not detected by it,
+ *      free to enable CONFIG_DVB_USB_DIBUSB_MC_FAULTY via your kernel config.
+ */
+
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+/* 14 */	{ USB_DEVICE(USB_VID_CYPRESS,		USB_PID_ULTIMA_TVBOX_USB2_FX_COLD) },
+#endif
 			{ }		/* Terminating entry */
 };
 MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
@@ -88,7 +99,11 @@  static struct dvb_usb_device_properties dibusb_mc_properties = {
 
 	.generic_bulk_ctrl_endpoint = 0x01,
 
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+	.num_device_descs = 8,
+#else
 	.num_device_descs = 7,
+#endif
 	.devices = {
 		{   "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
 			{ &dibusb_dib3000mc_table[0], NULL },
@@ -119,6 +134,13 @@  static struct dvb_usb_device_properties dibusb_mc_properties = {
 			{ &dibusb_dib3000mc_table[12], NULL },
 			{ &dibusb_dib3000mc_table[13], NULL },
 		},
+#ifdef CONFIG_DVB_USB_DIBUSB_MC_FAULTY
+		{   "LITE-ON USB2.0 DVB-T Tuner (faulty USB IDs)",
+		    /* Also rebranded as Intuix S800, Toshiba */
+			{ &dibusb_dib3000mc_table[14], NULL },
+			{ NULL },
+		},
+#endif
 		{ NULL },
 	}
 };