Skip to contentSkip to conversation

Patch: gspca-pac73xx-fixes-v2.patch

PATCH Hans de Goede 1 participant 1 message Aug 22, 2008 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hi All,

I made a little mistake with the previous patch (forgot to hg add the new pac_common.h, so it didn't make it into the patch) please use this version and don't forget to hg add pac_common.h :)

##

I'm proud to present the results of spending way too much hours (days) working on pac73xx results:

-add documentation (based on trial and error) for some registers -some preparations for adding autogain_n_exposure functionality:
-remove some old (broken, disabled in current version) autogain cruft -add working average lumination reading
-various pac7311 fixes so that a pac7311 cam will actually work
(tested with a trust wb 3400-T: 093a:260e)
-disable brightness and colors controls for 7311, brightness was actually
changing a gain register (I'll do a seperate patch adding gain and exposure controls, I already know which registers to poke for this).
-fix contrast control for 7311
-add hflip and vflip controls for 7311
-only send a very minimal jpeg header, tinyjpeg in libv4l can already handle
jpeg's without a huffman header, and I've added the special Pixart quantization table to tinyjpeg, this saves some decoding time and more important makes us more flexibles with regards to the quantization table. I have strong indications that the magic marker in the bitstream after each DCT block actually codes which quantization table to use for that block. I believe this as with my 7302 testcam, some blocks get decoded looking actually blocky, just like what happens with the 7311 when you use the wrong quantization table, and exactly these blocks have a marker of 0x48 instead of 0x44. Now if only I knew which quantization table to use for those blocks :(
-add proper SOF detection instead of relying on the JPEG EOF marker. This
code was taken from the pac207 subdriver which uses the some SOF marker, and is moved to a header file shared by both drivers. Also check the JPEG EOF from the previous frame for additional robustness.

Regards,

Hans

I made a little mistake with the previous patch (forgot to hg add the new pac_common.h, so it didn't make it into the patch) please use this version and don't forget to hg add pac_common.h :)

##

I'm proud to present the results of spending way too much hours (days) working on pac73xx results:

-add documentation (based on trial and error) for some registers -some preparations for adding autogain_n_exposure functionality:
-remove some old (broken, disabled in current version) autogain cruft -add working average lumination reading
-various pac7311 fixes so that a pac7311 cam will actually work
(tested with a trust wb 3400-T: 093a:260e)
-disable brightness and colors controls for 7311, brightness was actually
changing a gain register (I'll do a seperate patch adding gain and exposure controls, I already know which registers to poke for this).
-fix contrast control for 7311
-add hflip and vflip controls for 7311
-only send a very minimal jpeg header, tinyjpeg in libv4l can already handle
jpeg's without a huffman header, and I've added the special Pixart quantization table to tinyjpeg, this saves some decoding time and more important makes us more flexibles with regards to the quantization table. I have strong indications that the magic marker in the bitstream after each DCT block actually codes which quantization table to use for that block. I believe this as with my 7302 testcam, some blocks get decoded looking actually blocky, just like what happens with the 7311 when you use the wrong quantization table, and exactly these blocks have a marker of 0x48 instead of 0x44. Now if only I knew which quantization table to use for those blocks :(
-add proper SOF detection instead of relying on the JPEG EOF marker. This
code was taken from the pac207 subdriver which uses the some SOF marker, and is moved to a header file shared by both drivers. Also check the JPEG EOF from the previous frame for additional robustness.

p.s.

I'll commit Pixart JPEG support to libv4l to my tree real soon now:
http://linuxtv.org/hg/~hgoede/v4l-dvb

linux/drivers/media/video/gspca/pac207.c +5 -31
diff -r 62a8eab36231 linux/drivers/media/video/gspca/pac207.c
@@ -181,9 +181,6 @@
 			/* 48 reg_72 Rate Control end BalSize_4a =0x36 */
 static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 };
 
-static const unsigned char pac207_sof_marker[5] =
-		{ 0xff, 0xff, 0x00, 0xff, 0x96 };
-
 static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
 	const u8 *buffer, u16 length)
 {
@@ -367,31 +364,8 @@
 		sd->autogain_ignore_frames = PAC207_AUTOGAIN_IGNORE_FRAMES;
 }
 
-static unsigned char *pac207_find_sof(struct gspca_dev *gspca_dev,
-					unsigned char *m, int len)
-{
-	struct sd *sd = (struct sd *) gspca_dev;
-	int i;
-
-	/* Search for the SOF marker (fixed part) in the header */
-	for (i = 0; i < len; i++) {
-		if (m[i] == pac207_sof_marker[sd->sof_read]) {
-			sd->sof_read++;
-			if (sd->sof_read == sizeof(pac207_sof_marker)) {
-				PDEBUG(D_STREAM,
-					"SOF found, bytes to analyze: %u."
-					" Frame starts at byte #%u",
-					len, i + 1);
-				sd->sof_read = 0;
-				return m + i + 1;
-			}
-		} else {
-			sd->sof_read = 0;
-		}
-	}
-
-	return NULL;
-}
+/* Include pac common sof detection functions */
+#include "pac_common.h"
 
 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
 			struct gspca_frame *frame,
@@ -401,14 +375,14 @@
 	struct sd *sd = (struct sd *) gspca_dev;
 	unsigned char *sof;
 
-	sof = pac207_find_sof(gspca_dev, data, len);
+	sof = pac_find_sof(gspca_dev, data, len);
 	if (sof) {
 		int n;
 
 		/* finish decoding current frame */
 		n = sof - data;
-		if (n > sizeof pac207_sof_marker)
-			n -= sizeof pac207_sof_marker;
+		if (n > sizeof pac_sof_marker)
+			n -= sizeof pac_sof_marker;
 		else
 			n = 0;
 		frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
linux/drivers/media/video/gspca/pac7311.c +161 -136

482 lines not on this page · raw message

linux/drivers/media/video/gspca/pac_common.h new file +53 -0

53 lines not on this page · raw message

--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list