Bug 13074

Summary: gspca_stv06xx doesn't work with Logitech QuickCam Express (046d:0840)
Product: v4l-dvb Reporter: Paulo Matias (matias)
Component: webcamAssignee: Erik Andr (erik.andren)
Status: RESOLVED CODE_FIX    
Severity: normal CC: bjorn.lie, der.osterhase, erik.andren, jteste1970, moinejf, rfeany, rjw, sinanhaliyo
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.29.1 Subsystem:
Regression: Yes Bisected commit-id:
Bug Depends on:    
Bug Blocks: 12398    
Attachments: Image produced in gst-launch.
Kernel logs (using 2.6.29.1 + gspca hg 1a7449833166)
vlc - V4L2 working screenshot
kernel log
syslog last 20 lines
messages extract, quickcam debug output
tail -n5000 /var/log/syslog > syslog-5000.txt
Make errors during Item (4) following instructions from comment#28
console log after comands make unload and make load
dmesg after make unload and make load
syslog gspca_stv06xx with 046d:0870 debug=0x84 (gspca-m5602)

Description Paulo Matias 2009-04-12 14:10:57 UTC
Created attachment 20944 [details]
Image produced in gst-launch.

ID 046d:0840 Logitech, Inc. QuickCam Express

I used to use this webcam with the qc-usb driver, which was working correctly (with some compile fixing patches) in 2.6.28.

Now in 2.6.29.1 this webcam is recognized by the gspca_stv06xx driver, but it doesn't work at all.

When the webcam is plugged, dmesg shows:

usb 2-2: new full speed USB device using uhci_hcd and address 2
usb 2-2: configuration #1 chosen from 1 choice
Linux video capture interface: v2.00
gspca: main v2.4.0 registered
STV06xx: Probing for a stv06xx device
gspca: probing 046d:0840
STV06xx: Configuring camera
STV06xx: HDCS-1000/1100 sensor detected
STV06xx: Initializing camera
gspca: probe ok

Then, hexdumping /dev/video0 produces:

$ hexdump /dev/video0
0000000 0203 0202 0201 0100 0001 0000 0000 0000
0000010 0000 0000 0000 0000 0000 0000 0001 0000
0000020 0000 0001 0000 0000 0000 0000 0000 0000
0000030 0000 0000 0000 0000 0000 0000 0000 0000
*
00005c0 0000 0000 0000 0001 0000 0000 0000 0000
00005d0 0000 0000 0000 0000 0000 0000 0000 0000
*
00005f0 0000 0000 0000 0000 0001 0000 0000 0000
0000600 0000 0000 0000 0000 0000 0000 0000 0000
*

Then a output like these two last groups (mostly zeros) repeats until I finish hexdump.

Running hexdump by a second time produces:

$ hexdump /dev/video0
hexdump: /dev/video0: Input/output error
$

And dmesg shows nothing new. Then I get Input/output errors until I unplug the webcam from the USB port and plug it again.

I tried video also with xawtv, cheese and gst-launch. Just after plugging the webcam, xawtv and cheese shows nothing, and "gst-launch-0.10 v4l2src ! autovideosink" shows a black screen with some strips that looks like TV interference (see attached file).

After closing these programs and opening them for a second time, again I get Input/output errors. For gst-launch, for example:

libv4l2: error dequeuing buf: Input/output error

Blacklisting gspca_stv06xx and using qc-usb doesn't help also. The qc-usb drivers builds successfully using the same patches used for 2.6.28, but in 2.6.29.1 it causes a kernel panic when I try to plug the webcam.
Comment 1 Jean-Francois Moine 2009-04-14 07:59:30 UTC
May you get the last gspca at LinuxTv.org from my test repository:
      http://linuxtv.org/hg/~jfrancois/gspca
and try it?
Comment 2 Paulo Matias 2009-04-14 17:16:40 UTC
Hi,

I just tried changeset 1a7449833166 from your hg repository, and the same issue unfortunately persists.
Comment 3 Erik Andr 2009-04-14 18:05:15 UTC
Hi Paulo. 
Do you have libv4l installed?
Comment 4 Paulo Matias 2009-04-14 18:12:30 UTC
Hi Erik. Yes, I have.
Comment 5 Erik Andr 2009-04-15 16:07:43 UTC
The situation is as follows: the gspca_stv06xx is a port of the qc-usb driver.
I don't have the same hardware as you have but we should be able to get it working providing we can trace what goes wrong. I need you to insert the gspca_main module with the debug=0xffff and attach the kernel log output to this bug report when you attach the camera.
Comment 6 Paulo Matias 2009-04-15 16:21:41 UTC
Created attachment 20993 [details]
Kernel logs (using 2.6.29.1 + gspca hg 1a7449833166)
Comment 7 Erik Andr 2009-04-18 21:03:16 UTC
Thanks for your thorough logs.
From what I can make out of them, your not receiving the correct amount of packets from the webcam before the start and end of frame markers. Would it be possible for you to revert to an earlier kernel where the qc-usb camera works, insert it with the qcdebug parameter added and attach the produced logs here?

This allows me to compare what registers that are written and what we're missing in the new driver.
Comment 8 Erik Andr 2009-04-22 08:43:51 UTC
Ping!

Please let me know if there's an issue with my current suggestion.
Thanks!
Comment 9 Bjørn Lie 2009-05-03 10:27:38 UTC
Created attachment 21197 [details]
vlc - V4L2 working screenshot
Comment 10 Bjørn Lie 2009-05-03 10:30:06 UTC
I have almost the same cam

Bus 003 Device 002: ID 046d:0850 Logitech, Inc. QuickCam Web

and I see the same behaviour, (does not work in gst + ekiga and whatnot)

But it does work in vlc however. (when using v4l2)

Maybe the bug is in the other apps and not in the "new" driver after all
Comment 11 Bjørn Lie 2009-05-03 11:28:03 UTC
Sorry for the noise, but I also tried to download the svv program form the driver author page http://moinejf.free.fr/ (and compiled it)

And the webcam worked perfectly with his testprogram
Comment 12 Erik Andr 2009-05-03 16:25:44 UTC
Björn,
the ekiga/gst is a separate issue and lies in the gstreamer stack.

I've filed a bug [1] but haven't gotten any help sofar.

[1] http://bugzilla.gnome.org/show_bug.cgi?id=577963
Comment 13 Erik Andr 2009-05-30 20:43:01 UTC
Paulo,
Please add the data I need. Otherwise I'm not going to be able to fix this bug. :(
Comment 14 Matthias 2009-06-03 02:13:53 UTC
Created attachment 21720 [details]
kernel log

kernel debug log
Comment 15 Matthias 2009-06-03 02:15:13 UTC
Hi,

I have an ID 046d:0870 Logitech, Inc. QuickCam Express. Trying to run it with gspca_stv06xx I get the same behavior as written in bug description.

uname -a
Linux host-13c4 2.6.29-gentoo-r5 #3 SMP PREEMPT Wed Jun 3 03:12:06 CEST 2009 i686 Unknow CPU Type AuthenticAMD GNU/Linux

Kernel log at #14.

If I can help with further information, please let me now.
Comment 16 Erik Andr 2009-06-03 19:36:41 UTC
Matthias, 
If you could follow the suggestion i posted in comment #7 it would help tremendously.
Comment 17 Ricardo 2009-06-05 14:51:19 UTC
Erik, 
I have the same problem described by Paulo Matias.
I was running:
Kernel version = 2.6.29.3-desktop586-1mnb
Distribution=Mandriva Linux release 2009.1 (Official) for i586
CPU=AMD Athlon(tm) 64 X2 Dual Core Processor 4200+

I am now running from the CDROM an old linux version where the camera works.
It is:
Mandriva Linux release 2007.1 (Official) for x86_64
Linux version 2.6.17-13mdv (rtp@octopus.mandriva.com) (gcc version 4.1.2 20070302 (prerelease) (4.1.2-1mdv2007.1)) #1 SMP Fri Mar 23 15:18:36 EDT 2007

See that this is an x86_64 version, and the previous was i586.
However I do not know how to follow your request: "Would it be
possible for you to revert to an earlier kernel where the qc-usb camera works,
insert it with the qcdebug parameter added and attach the produced logs here?"
Can you provide detailed steps?
Thanks,
Ricardo
Comment 18 Ricardo 2009-06-20 23:19:25 UTC
Erik, 
I am now running a LIVE CDROM from an old Mandriva Version ( 2007.1) x86_64
Linux version 2.6.17-13mdv (rtp@octopus.mandriva.com) (gcc version 4.1.2 20070302 (prerelease) (4.1.2-1mdv2007.1)) #1 SMP Fri Mar 23 15:18:36 EDT 2007

First I removed quickcam module: 
      [root@localhost guest]# rmmod -v quickcam
      rmmod quickcam, wait=no
Then I downloaded qc-usb from:
http://sourceforge.net/project/downloading.php?group_id=12924&filename=qc-usb-0.6.6.tar.gz&a=52628338

Then I could install quickcam module with debub option:
      [root@localhost qc-usb-0.6.6]# insmod ./quickcam.ko qcdebug=8

However I could not find any interesting debug text.
I am attaching the file generated by "tail -n20 syslog > syslog-tail-20.log"
regards,
Ricardo
Comment 19 Ricardo 2009-06-20 23:20:20 UTC
Created attachment 22032 [details]
syslog last 20 lines
Comment 20 Erik Andr 2009-06-21 15:04:07 UTC
In the official release, line 114 is outcommented in quickcam.h
Activate the statement i.e remove the // in and rebuild the driver in order for debug to be activated.

Best regards,
Erik
Comment 21 Matthias 2009-06-21 16:57:10 UTC
For me, I had to comment out qc-driver.c:728.
Comment 22 Matthias 2009-06-21 17:25:57 UTC
Created attachment 22034 [details]
messages extract, quickcam debug output
Comment 23 Matthias 2009-06-21 17:27:40 UTC
I hope, the information is complete and helps. If I can support your work with some more tests, please let me know.
Comment 24 Erik Andr 2009-06-22 10:53:58 UTC
Matthias,
the gspca log you previously attached lacked the correct debug parameter and thus didn't generate any logs of the register writes.
Could you reproduce the logs with debug=0x80 supplied as a parameter to gspca_main.ko and attach it this bug?

TIA,
Erik
Comment 25 Erik Andr 2009-06-22 17:05:45 UTC
Sorry, I meant debug=0x84
Comment 26 Ricardo 2009-06-27 12:11:45 UTC
Erik, 
Now I could produce some logs that I believe will help you.
Here are the detailed steps:
I am now running a LIVE CDROM from an old Mandriva Version ( 2007.1) x86_64
Linux version 2.6.17-13mdv (rtp@octopus.mandriva.com) (gcc version 4.1.2
20070302 (prerelease) (4.1.2-1mdv2007.1)) #1 SMP Fri Mar 23 15:18:36 EDT 2007
Installed the kernel sources
Installed camorama
I removed quickcam module: 
      [root@localhost guest]# rmmod -v quickcam
      rmmod quickcam, wait=no
Then I downloaded qc-usb from:
http://sourceforge.net/project/downloading.php?group_id=12924&filename=qc-usb-0.6.6.tar.gz&a=52628338

edited quickcam.h and removed // from line 114
compiled the code using: make all 

Then I could install quickcam module with debub option:
      [root@localhost qc-usb-0.6.6]# insmod ./quickcam.ko qcdebug=8

Now /var/log/syslog seems interesting.
I am attaching the file generated by "tail -n2000 syslog > syslog-2000.log"
regards,
Ricardo
Comment 27 Ricardo 2009-06-27 12:16:41 UTC
Created attachment 22123 [details]
tail -n5000 /var/log/syslog > syslog-5000.txt

Now it seems more interesting
Comment 28 Erik Andr 2009-06-29 18:51:25 UTC
All, 
I've found and fixed a couple of bugs in the hdcs code.
Please try the testing repository below and report if it works any better.


1. Ensure you have mercurial (hg) source control installed.
2. Clone the gspca tree by navigating to a suitable directory on your harddrive and type

hg clone http://linuxtv.org/hg/~eandren/gspca/

3. Enter the directory

cd gspca

4. Type

make

to build the repository. If this fails, please ensure you have the source headers for your current linux version installed.

5. Unload all relevant modules by typing

make unload

you need to be a superuser to perform this

6. Load all relevant modules by typing

make load
Comment 29 Ricardo 2009-06-30 01:57:52 UTC
Created attachment 22146 [details]
Make errors during Item (4) following instructions from comment#28

Erik,
I could not compile the code.
I have kernel-source (kernel-linus-source-2.6.29.4-1mdv-1-1mdv2009.1)
I am running "Linux version 2.6.29.4-1mdv (mandrake@n1.mandriva.com) (gcc version 4.3.2 (GCC) ) #1 SMP Wed May 20 04:07:49 EDT 2009" - Mandriva linux realease 2009.1 for i586. This is a AMD Athlon(tm) 64 X2 Dual Core Processor 4200+.

I followed the steps you wrote, however at step (4) I had some errors that I am attaching. Errors started when it was compiling "firedtv-1394"

I will try to upgrade kernel version to "kernel-linus-source-2.6.30-2" during weekend.
Regards,
Ricardo
Comment 30 Erik Andr 2009-06-30 06:33:02 UTC
If you issue a `make menuconfig` in the hg tree root, you can disable all drivers that doesn't compile as we're only after the gspca drivers.
Comment 31 Ricardo 2009-07-01 01:21:06 UTC
Created attachment 22156 [details]
console log after comands make unload and make load

Erik,
I still could not make the camera work.
I could compile the code.

As root run: make menuconfig, disabled FireDTV

As root run: 
make
make unload
make load

See logs attached. A few errors, however gspca_main.ko and gspca_stv06xx.ko loaded

Could not make the camera work on camorama or camstream
I will also attach dmesg
Ricardo
Comment 32 Ricardo 2009-07-01 01:22:06 UTC
Created attachment 22157 [details]
dmesg after make unload and make load
Comment 33 Erik Andr 2009-07-01 04:49:15 UTC
Ricardo, what if you try a v4l2 application like cheese?
Comment 34 Ricardo 2009-07-02 01:11:41 UTC
Erik,
I still could not make the camera work, even using cheese.
Comment 35 Erik Andr 2009-07-02 07:46:28 UTC
Ricardo, 
That's strange. You have a Dexxa cam right?
I have a separate report from another user with the 046d:0840 which claims that it works for him using the latest hg.

Any difference if you clone this repository instead:
http://linuxtv.org/hg/~eandren/gspca-m5602/
Comment 36 Ricardo 2009-07-02 22:12:46 UTC
Erik,
the camera worked with: http://linuxtv.org/hg/~eandren/gspca-m5602/
using "cheese", however it did not worked with:
a) camstream ( The device expireenced an error -22 ( invalid argument))
b) camorama ( this time camera captures part of the image however in black& white and stops and does not show the entire image)

The image using "cheese" seems saturated. Image seems worse than using old linux version.
Do you need aditional information (logs)?
Ricardo
Comment 37 Ricardo 2009-07-04 17:43:21 UTC
Erik,
the camera (Logitech QuickCam) worked also with 
 http://linuxtv.org/hg/~eandren/gspca/

I guess the problem before was that I "make unload" and "make load" inside KDE. Now I stopped KDE and the display manager ( "service dm stop") and entered the commands:
"make unload" and "make load"
service dm start
started KDE, and it worked.

However the image using "cheese" seems saturated. I guess "cheese" does not have the same software options as camorama.

Does the drivers will receive enhancements to run programs like:
-camorama, ekiga, camstream
or these softwares will have to change?
I guess also skype does no works.
Ricardo
Comment 38 Erik Andr 2009-07-04 18:14:07 UTC
You should be able to get v4l1 applications working by following this suggestion.
(From the libv4l documentation)


wrappers
--------

The functionality provided by libv4l1 for v4l1 apps and libv4l2 for v4l2 apps
can also be used by existing apps without modifying them. For this purpose
2 wrapper libraries are provided which can be preloaded before starting the
application using the LD_PRELOAD environment variable. These wrappers will
then intercept calls to open/close/ioctl/etc. and if these calls directed
towards a video device the wrapper will redirect the call to the libv4lX
counterparts.

The preloadable libv4l1 wrapper which adds v4l2 device compatibility to v4l1
applications is called v4l1compat.so. The preloadable libv4l1 wrapper which
adds v4l2 device compatibility to v4l1 applications is called v4l2convert.so

Example usage:
$ export LD_LIBRARY_PATH=`pwd`/lib
$ export LD_PRELOAD=`pwd`/lib/v4l1compat.so
$ camorama
Comment 39 Erik Andr 2009-07-17 14:24:04 UTC
Sensors now work. Closing.
Comment 40 Sinan 2009-08-03 12:58:28 UTC
Created attachment 22587 [details]
syslog gspca_stv06xx with 046d:0870 debug=0x84 (gspca-m5602)
Comment 41 Sinan 2009-08-03 13:02:23 UTC
Just tested your latest hg gspca ans gspca-m5602 with 046d:0870 Logitech, Inc. QuickCam Express. All I get is a white image. :-( (cheese, camorama)

# uname -a
Linux 2.6.29.5-191.fc11.i686.PAE #1 SMP Tue Jun 16 23:19:53 EDT 2009 i686 i686 i386 GNU/Linux

attached the syslog with gspace_main debug=0x84

Hope that helps.
Comment 42 Sinan 2009-08-03 13:04:10 UTC
sorry, s/camorama/camstream/