On Fri, Jul 04, 2008 at 09:42:54PM +0200, Jan Prunk wrote:
> I untared and patched the files in gspca-source.
> And loaded the module with parameter:
> "modprobe gspca vflip=1"

> in dmesg i get :

> [snip]

> and xawtv still shows the image flipped wrongly..

Well, as I said, my patch is for Pixart based cameras, that's what I
have (Genius e-Messenger 112). I made it to fix the same problem as you
have.

So, it is obvious that you have a camera of a different class and it
encodes frames using JPEG. I am not familiar with JPEG compression nor
I have a camera that uses it, so I can't make an accurate fix.

Anyway I've made a dirty hack. Please, try the attached patch instead of
the previous one. I do not like it, but it should work, I hope.

-- 
Sergey Lungu
diff -ur gspcav1-20071224.orig/decoder/gspcadecoder.c gspcav1-20071224/decoder/gspcadecoder.c
--- gspcav1-20071224.orig/decoder/gspcadecoder.c	2007-12-24 16:35:27.000000000 +0300
+++ gspcav1-20071224/decoder/gspcadecoder.c	2008-07-05 02:29:50.000000000 +0400
@@ -2725,6 +2725,31 @@
 	done = -1;
 	break;
     }
+
+    if (done >= 0 && myframe->spca50x_dev->vflip != 0 &&
+	    myframe->format != VIDEO_PALETTE_JPEG &&
+	    myframe->format != VIDEO_PALETTE_RAW_JPEG)
+    {
+	int w = myframe->width;
+	int h = myframe->height;
+	char *top, *center, *bottom;
+
+	w *= myframe->scanlength / (w * h);
+	top = myframe->data;
+	center = top + (h >> 1) * w;
+	bottom = top + (h - 1) * w;
+	while (top < center) {
+	    char *t, *b; 
+	    for (t = top, b = bottom; (int) (t - top) < w; t++, b++) {
+		*t = *t ^ *b;
+		*b = *t ^ *b;
+		*t = *t ^ *b;
+	    }       
+	    top += w;
+	    bottom -= w;
+	}
+    }
+
     return done;
 }
 
diff -ur gspcav1-20071224.orig/gspca_core.c gspcav1-20071224/gspca_core.c
--- gspcav1-20071224.orig/gspca_core.c	2007-12-24 19:56:47.000000000 +0300
+++ gspcav1-20071224/gspca_core.c	2008-07-05 02:31:24.000000000 +0400
@@ -105,6 +105,8 @@
 /* force sensor id*/
 static int force_sensor_id=-1;
 static int force_gamma_id=-1;
+static int vflip = 0;
+
 module_param(autoexpo, int, 0644);
 module_param(debug, int, 0644);
 module_param(force_rgb, int, 0644);
@@ -127,6 +129,7 @@
 #endif
 module_param(force_sensor_id, int, 0644);
 module_param(force_gamma_id, int, 0644);
+module_param(vflip, int, 0644);
 
 MODULE_PARM_DESC(autoexpo,
 		 "Enable/Disable auto exposure (default=1: enabled) (PC-CAM 600/Zc03xx/spca561a/Etoms Only !!!)");
@@ -154,6 +157,7 @@
 #endif				/* SPCA5XX_ENABLE_REGISTERPLAY */
 MODULE_PARM_DESC(force_gamma_id, "Forced assigning ID of contrast settings (0=default,1,2,3) Zc03xx only");
 MODULE_PARM_DESC(force_sensor_id, "Forced assigning ID sensor (Zc03xx only). Dangerous, only for experts !!!");
+MODULE_PARM_DESC(vflip, "Flip image vertically");
 
 /****************/
 MODULE_AUTHOR
@@ -4281,6 +4285,7 @@
 		spca50x->last_times = 0;
 		spca50x->dtimes = 0;
 		spca50x->autoexpo = autoexpo;
+		spca50x->vflip = vflip;
 		init_MUTEX(&spca50x->lock);	/* to 1 == available */
 		init_MUTEX(&spca50x->buf_lock);
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
diff -ur gspcav1-20071224.orig/gspca.h gspcav1-20071224/gspca.h
--- gspcav1-20071224.orig/gspca.h	2007-12-24 19:56:47.000000000 +0300
+++ gspcav1-20071224/gspca.h	2008-07-05 02:04:41.000000000 +0400
@@ -417,6 +417,7 @@
 	int whiteness;
 	int exposure;		// used by spca561 
 	int autoexpo;
+	int vflip;
 	int qindex;
 	int width;		/* use here for the init of each frame */
 	int height;

Reply via email to