Re: Problem with gspca and zc3xx

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

 



Hi All,

On 01/11/2010 10:55 AM, Jean-Francois Moine wrote:
On Mon, 11 Jan 2010 09:37:29 +0100
Hans de Goede<hdegoede@xxxxxxxxxx>  wrote:

This is the infamous zc3xx bottom of the image is missing in 320x240
problem, with several sensors the register settings we took from the
windows driver will only give you 320x232 (iirc), we tried changing
them to get 320x240, but then the camera would not stream. Most
likely some timing issue between bridge and sensor.

I once had a patch fixing this by actually reporting the broken modes
as 320x232, but that never got applied as it breaks app which are
hardcoded to ask for 320x240. libv4l has had the ability to extend
the 320x232 image to 320x240 for a while now (by adding a few black
lines at the top + bottom), fixing the hardcoded apps problem.

So I think such a patch can and should be applied now. This will get
rid of the jpeg decompression errors reported by libv4l and in case
if yuv mode the ugly green bar with some random noise in it at the
bottom.

I'm afraid my patch is most likely lost, but I can create a new one
if you want, I have access to quite a few zc3xx camera's, and more
over what resolution they are actually streaming at can be deducted
from the register settings in the driver.

Hi Hans,

As you may see in Jose Alberto's message, the problem occurs with
640x480 and, yes, the image bottom is lacking, but also the right side.


Hmm, the right side missing would indicate some timing issue between sensor
and bridge, but it seems this is an intermittent problem, as in Jose's
last message only the last 8 lines are missing.

As for this happening also at 640x480, I re-checked things and that is the
same problem, here is a table of the resolutions per sensor, derived
from the register settings in zc3xx.c, iow this are the resolutions we
are telling the bridge to send us!

adcm2700        640x472         320x232
cs2102          640x480         320x240
cs2102k         640x480         320x240
gc0305          640x480         320x240
hdcs2020xb      640x480         320x240
hv7131bxx       640x480         320x240
hv7131cxx       640x480         320x240
icm105axx       640x480         320x240
MC501CB         640x472         320x232
OV7620          640x472         320x232
ov7630c         640x480         320x240
pas202b         640x480         320x232
mi0360soc       640x480         320x240
pb0330          640x480         320x240
PO2030          640x480         320x240
tas5130CK       640x480         320x240
tas5130cxx      640x480         320x240
tas5130c_vf0250 640x480         320x240

I did not lose your patch, but I did not apply it because most of the
time, the webcams work in the best resolution (VGA) and the associated
problem has not found yet a good resolution...

It turns out I was wrong, and the problem happens for 3 of the 4 affected
sensors at both VGA and QVGA. What we are currently doing is telling the
bridge to send us these resolutions, and then telling userspace it is
getting something different. This is just plain wrong, no but ..., it
is just *wrong*.

This makes for users getting an image out of the cam like Jose is getting
with the last 8 lines garbled. And when they start their webcam application
from a terminal the terminal fills with:
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffec
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffd9
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff
libv4lconvert: Error decompressing JPEG: unknown huffman code: 0000ffff

Which is because libv4l expects there to be more data then it actually
is getting, as we are *lying* to it.

I know ideally we would change the register settings to actually get
640x480 and 320x240, but that won't work when you do that the camera's
with the affected sensors won't stream at all, that is I've tried
fiddling with the register settings for a pas202b equipped cam
for hours to fix 320x240 and I got no where at all.

I've done a new version of my patch, which also fixes the affected cams
at 640x480, please apply this, as said I know this isn't ideal, but it
is better then what we currently have. If we ever find register settings
to make these cams work at normal resolutions, we can always revert this.

I've tested the attached patch with the following cams:
Philips SPC 200NC               0471:0325       zc3xx   PAS106
Logitech QuickCam IM/Connect    046d:08d9       zc3xx   HV7131R
Logitech QuickCam E2500         046d:089d       zc3xx   MC501CB
Creative WebCam NX Pro          041e:401e       zc3xx   HV7131B
No brand                        0ac8:307b       zc3xx   ADCM2700
Labtec notebook cam             046d:08aa       zc3xx   PAS202B
Creative WebCam Notebook        041e:401f       zc3xx   TAS5130C
Creative Live! Cam Video IM     041e:4053       zc3xx   TAS5130-VF250

And for the 3 affected models it fixes the garbled bottom of the
image and the libv4lconvert error messages (which people keep
submitting bugs about).

Jose,

Can you please test the attached patch, do:
install mercurial (on Fedora yum install mercurial)
hg clone http://linuxtv.org/hg/~jfrancois/gspca/
cd gscpa
patch -p1 < [path-to]/gspca_zc3xx-8lines-missing.patch
make menuconfig
[choose exit]
make
sudo make install
[reboot]

Thanks & Regards,

Hans
diff -r 70b1d636a39a linux/drivers/media/video/gspca/zc3xx.c
--- a/linux/drivers/media/video/gspca/zc3xx.c	Sun Jan 10 23:34:57 2010 +0100
+++ b/linux/drivers/media/video/gspca/zc3xx.c	Mon Jan 11 22:44:45 2010 +0100
@@ -194,6 +194,34 @@
 		.priv = 0},
 };
 
+/* VGA with last 8 lines missing */
+static const struct v4l2_pix_format broken_vga_mode[] = {
+	{320, 232, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+		.bytesperline = 320,
+		.sizeimage = 320 * 232 * 3 / 8 + 590,
+		.colorspace = V4L2_COLORSPACE_JPEG,
+		.priv = 1},
+	{640, 472, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+		.bytesperline = 640,
+		.sizeimage = 640 * 472 * 3 / 8 + 590,
+		.colorspace = V4L2_COLORSPACE_JPEG,
+		.priv = 0},
+};
+
+/* VGA with last 8 lines missing in 320x240 mode */
+static const struct v4l2_pix_format pas202b_vga_mode[] = {
+	{320, 232, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+		.bytesperline = 320,
+		.sizeimage = 320 * 232 * 3 / 8 + 590,
+		.colorspace = V4L2_COLORSPACE_JPEG,
+		.priv = 1},
+	{640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
+		.bytesperline = 640,
+		.sizeimage = 640 * 480 * 3 / 8 + 590,
+		.colorspace = V4L2_COLORSPACE_JPEG,
+		.priv = 0},
+};
+
 static const struct v4l2_pix_format sif_mode[] = {
 	{176, 144, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE,
 		.bytesperline = 176,
@@ -6651,7 +6679,8 @@
 	struct sd *sd = (struct sd *) gspca_dev;
 	struct cam *cam;
 	int sensor;
-	int vga = 1;		/* 1: vga, 0: sif */
+	/* 0: sif, 1: vga, 2: 640x472, 320x232, 3: 640x480, 320x232 */
+	int vga = 1;
 	static const __u8 gamma[SENSOR_MAX] = {
 		4,	/* SENSOR_ADCM2700 0 */
 		4,	/* SENSOR_CS2102 1 */
@@ -6689,6 +6718,7 @@
 			switch (sd->sensor) {
 			case SENSOR_MC501CB:
 				PDEBUG(D_PROBE, "Sensor MC501CB");
+				vga = 2; /* last 8 lines missing */
 				break;
 			case SENSOR_TAS5130C_VF0250:
 				PDEBUG(D_PROBE, "Sensor Tas5130 (VF0250)");
@@ -6729,6 +6759,7 @@
 			PDEBUG(D_PROBE, "Find Sensor PAS202B");
 			sd->sensor = SENSOR_PAS202B;
 			sd->sharpness = 1;
+			vga = 3; /* broken 320x240 (can only do 320x232) */
 			break;
 		case 0x0f:
 			PDEBUG(D_PROBE, "Find Sensor PAS106");
@@ -6765,6 +6796,7 @@
 		case 0x16:
 			PDEBUG(D_PROBE, "Find Sensor ADCM2700");
 			sd->sensor = SENSOR_ADCM2700;
+			vga = 2; /* last 8 lines missing */
 			break;
 		case 0x29:
 			PDEBUG(D_PROBE, "Find Sensor GC0305");
@@ -6782,6 +6814,7 @@
 		case 0x7620:
 			PDEBUG(D_PROBE, "Find Sensor OV7620");
 			sd->sensor = SENSOR_OV7620;
+			vga = 2; /* last 8 lines missing */
 			break;
 		case 0x7631:
 			PDEBUG(D_PROBE, "Find Sensor OV7630C");
@@ -6790,6 +6823,7 @@
 		case 0x7648:
 			PDEBUG(D_PROBE, "Find Sensor OV7648");
 			sd->sensor = SENSOR_OV7620;	/* same sensor (?) */
+			vga = 2; /* last 8 lines missing */
 			break;
 		default:
 			PDEBUG(D_ERR|D_PROBE, "Unknown sensor %04x", sensor);
@@ -6807,12 +6841,23 @@
 	cam = &gspca_dev->cam;
 /*fixme:test*/
 	gspca_dev->nbalt--;
-	if (vga) {
+	switch (vga) {
+	case 0:
+		cam->cam_mode = sif_mode;
+		cam->nmodes = ARRAY_SIZE(sif_mode);
+		break;
+	case 1:
 		cam->cam_mode = vga_mode;
 		cam->nmodes = ARRAY_SIZE(vga_mode);
-	} else {
-		cam->cam_mode = sif_mode;
-		cam->nmodes = ARRAY_SIZE(sif_mode);
+		break;
+	case 2:
+		cam->cam_mode = broken_vga_mode;
+		cam->nmodes = ARRAY_SIZE(broken_vga_mode);
+		break;
+	case 3:
+		cam->cam_mode = pas202b_vga_mode;
+		cam->nmodes = ARRAY_SIZE(pas202b_vga_mode);
+		break;
 	}
 	sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
 	sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;

[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux