Re: dvb_usb_vp7045 "usb control message "out" went wrong". Solution!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
Hi,
 
Back in May in this mailing list there were few messages describing a problem with Twinhan Alpha USB2 DVB-T (the old device, not the new one with the same brand name which doesn't work at all in Linux, yet) device. Couple people reported (including me) that this device had problems in Linux VDR application.
 
DVB-T TV picture works great with the device, for a while. Every now and then the device starts to throw "usb in went wrong" and/or "usb out went wrong" error messages in dmesg log. After the the whole system started to crawl and didn't recover until the device was disconnected and re-connected in USB port (well, that breaks VDR app so it had to be restarted also).
 
The problem could be related to VIA EPIA mini-itx boards (I have Epia M10000 board) because on www.vdr-portal.de (in LinVDR forum section) some other people were reporting the same problem and at least one of them had EPIA board also.
 
Finally I have found a solution in my hardware setup. It required small modification in drivers/media/dvb/dvb-usb/vp7045.c Kernel module (Twinhan alpha2 uses dvb-usb-vp7045 module). If some of you have the same problem then maybe attached diff patch works for you too.
 
I don't know too much about Linux DVB API and dvb arhitechture there so the diff is just a hack. There could be easier or better solution available also. The attached diff is probably useful only for in those scenarios where this issue is giving "show stopper" problems.
 
Here is copy-paste of the post I did in http://www.vdr-portal.de/board/thread.php?threadid=61812&page=2 forum post.
 
- Mike N
 
----------
 
Hello,

This is an old topic but just wanted to share experiences and findings. I had this same issue "usb out went wrong" with Epia M10000 board and Twinhan Alpha USB2 DVB-T tuner.

Mozard seems to have Epia board also and having the same kind of errors, so could be that something is non-standard in Epia USB ports.

"Mr. Google" didn't have an answer to this problem, only few hits to pages describing the same problem. I have built Epia based VDR and eventually I got frustrated enough to look more closely into this problem.

The good news is that at least in my hardware combination I have found a solution. Maybe it helps in your situation also.

I tracked down the problem into Kernel dvb-usb-vp7045 module and "hack fix" modification in the corresponding vp7045.c source file did the trick in my system (requires kernel module re-compilation).

The problem was the "usb-in" error came always first and after that it started to throw "usb out went wrong" errors. I hardly ever recovered from that error until Twinhan device was disconnected and re-connected in USB port. The exact error code from failed usb command was always ETIMEDOUT (110), so the command didn't complete properly in USB device.

I have Linux 2.6.21.1 kernel but I think the module I modifed is pretty much the same in more recent kernels too (and few steps older also).

I modified "linux-2.6.21.1/drivers/media/dvb/dvb-usb/vp7045.c" source file in a following way:

- From line 22 begins "int vp7045_usb_op" function
- Few lines below in this function there are two usb_control_msg function calls (the first one is out and second one in usb command).
- I added simple FOR loop to re-try the USB-IN command few times if the error code was timeout error (and increasing timeout value each time just in case until command succeeds).

This "re-send the command" fix does the magic in my Epia. Jihuuu! I still get "usb in went wrong" every now and then but the driver automatically recovers from it within few secs so I don't even notice it if I don't look at dmesg log outputs.

If you have problems with "usb OUT went wrong" situations in a way where IN command never failed at first then maybe similar "re-try" and timeout increase fixes that too. But, in my case I noticed that the first error message was always "usb in went wrong" and only after that it started to throw "usb out went wrong".

Please see the attached diff path file for a more detailed code lines. This is "hack fix" so defintely backup the original vp7045.c file before appyling the patch.

Hopefully this hack fix works for you also. For me it works great.

- Mike



Connect to the next generation of MSN Messenger  Get it now!
diff -Naur old/vp7045.c new/vp7045.c
--- old/vp7045.c	2007-11-04 22:19:39.000000000 +0200
+++ new/vp7045.c	2007-11-04 22:20:40.000000000 +0200
@@ -21,6 +21,7 @@
 
 int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec)
 {
+	int usbResult, idx; /* Hack fix to usb went wrong */
 	int ret = 0;
 	u8 inbuf[12] = { 0 }, outbuf[20] = { 0 };
 
@@ -52,10 +53,28 @@
 
 	msleep(msec);
 
+/* Hack fix: Removed code below and replaced with re-try looping	
 	if (usb_control_msg(d->udev,
 			usb_rcvctrlpipe(d->udev,0),
 			TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
 			inbuf, 12, 2000) != 12) {
+*/
+
+	/* Hack fix: If usb-in fails in timeout error then try to recover from it */
+	/* by re-sending the command. This seem to fix the problem with some hardware */
+ 	for (idx = 0; idx < 3; idx++) {
+		usbResult  = usb_control_msg(d->udev,
+			usb_rcvctrlpipe(d->udev,0),
+			TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
+			inbuf, 12, 2000 + (idx * 1000));
+
+		/* If usb-in succeeded (12 bytes) or not timed out error then do not re-try */
+		if(usbResult == 12 || usbResult != -ETIMEDOUT) break; 
+
+		err("USB control message 'in' went wrong. Trying to recover (retry idx=%d).", idx);
+	}
+
+	if (usbResult != 12) {
 		err("USB control message 'in' went wrong.");
 		ret = -EIO;
 		goto unlock;
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux