The patch number 8835 was added via Jean-Francois Moine <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Hans de Goede  <[EMAIL PROTECTED]>
gspca: Same pixfmt as the sn9c102 driver and raw Bayer added in sonixb.


1) Lower the hstart setting for all sensor by 1 so that we generate
   (compressed) BGGR data just like sn9c102 does (instead of GBRG data)
2) Add support for raw bayer output in the lowest resolutions (not enough
   bandwidth for higher resolutions), this should work with all sensors but
   to be sure only enable it for sensors where it has been tested.

Priority: high

Signed-off-by: Hans de Goede <[EMAIL PROTECTED]>
Signed-off-by: Jean-Francois Moine <[EMAIL PROTECTED]>


---

 linux/drivers/media/video/gspca/sonixb.c |   61 +++++++++++++++++------
 1 file changed, 46 insertions(+), 15 deletions(-)

diff -r 5f0339b26441 -r 0c8090b11061 linux/drivers/media/video/gspca/sonixb.c
--- a/linux/drivers/media/video/gspca/sonixb.c  Fri Aug 29 09:41:23 2008 +0200
+++ b/linux/drivers/media/video/gspca/sonixb.c  Fri Aug 29 19:09:52 2008 +0200
@@ -74,6 +74,10 @@ struct sensor_data {
 /* sensor_data flags */
 #define F_GAIN 0x01            /* has gain */
 #define F_SIF  0x02            /* sif or vga */
+#define F_RAW  0x04            /* sensor tested ok with raw bayer mode */
+
+/* priv field of struct v4l2_pix_format flags (do not use low nibble!) */
+#define MODE_RAW 0x10          /* raw bayer mode */
 
 /* ctrl_dis helper macros */
 #define NO_EXPO ((1 << EXPOSURE_IDX) | (1 << AUTOGAIN_IDX))
@@ -205,6 +209,11 @@ static struct ctrl sd_ctrls[] = {
 };
 
 static struct v4l2_pix_format vga_mode[] = {
+       {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+               .bytesperline = 160,
+               .sizeimage = 160 * 120,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 2 | MODE_RAW},
        {160, 120, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
                .bytesperline = 160,
                .sizeimage = 160 * 120 * 5 / 4,
@@ -222,6 +231,11 @@ static struct v4l2_pix_format vga_mode[]
                .priv = 0},
 };
 static struct v4l2_pix_format sif_mode[] = {
+       {176, 144, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+               .bytesperline = 176,
+               .sizeimage = 176 * 144,
+               .colorspace = V4L2_COLORSPACE_SRGB,
+               .priv = 1 | MODE_RAW},
        {176, 144, V4L2_PIX_FMT_SN9C10X, V4L2_FIELD_NONE,
                .bytesperline = 176,
                .sizeimage = 176 * 144 * 5 / 4,
@@ -237,7 +251,7 @@ static const __u8 initHv7131[] = {
 static const __u8 initHv7131[] = {
        0x46, 0x77, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x11, 0x00, 0x00, 0x00,
        0x00, 0x00,
-       0x00, 0x00, 0x00, 0x03, 0x01, 0x00,     /* shift from 0x02 0x01 0x00 */
+       0x00, 0x00, 0x00, 0x02, 0x01, 0x00,
        0x28, 0x1e, 0x60, 0x8a, 0x20,
        0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c
 };
@@ -252,13 +266,13 @@ static const __u8 initOv6650[] = {
 #if 1
        0x44, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
        0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x02, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b,
+       0x00, 0x01, 0x01, 0x0a, 0x16, 0x12, 0x68, 0x8b,
        0x10, 0x1d, 0x10, 0x00, 0x06, 0x1f, 0x00
 #else
 /* old version? */
        0x64, 0x44, 0x28, 0x00, 0x00, 0x00, 0x00, 0x10,
        0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x02, 0x01, 0x0a, 0x14, 0x0f, 0x68, 0x8b,
+       0x00, 0x01, 0x01, 0x0a, 0x14, 0x0f, 0x68, 0x8b,
        0x10, 0x1d, 0x10, 0x01, 0x01, 0x07, 0x06
 #endif
 };
@@ -316,15 +330,12 @@ static const __u8 initOv7630[] = {
 static const __u8 initOv7630[] = {
        0x04, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, /* r01 .. r08 */
        0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* r09 .. r10 */
-#if 1
-       0x00, 0x02, 0x01, 0x0a,                         /* r11 .. r14 */
+       0x00, 0x01, 0x01, 0x0a,                         /* r11 .. r14 */
        0x28, 0x1e,                     /* H & V sizes     r15 .. r16 */
        0x68, COMP2, MCK_INIT1,                         /* r17 .. r19 */
+#if 1
        0x1d, 0x10, 0x02, 0x03, 0x0f, 0x0c              /* r1a .. r1f */
 #else /* jfm from win */
-       0x00, 0x01, 0x01, 0x0a,                         /* r11 .. r14 */
-       0x16, 0x12,                     /* H & V sizes     r15 .. r16 */
-       0x68, COMP2, MCK_INIT1,                         /* r17 .. r19 */
        0x1d, 0x10, 0x06, 0x01, 0x00, 0x03              /* r1a .. r1f */
 #endif
 };
@@ -367,7 +378,7 @@ static const __u8 initPas106[] = {
 static const __u8 initPas106[] = {
        0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x00, 0x00,
        0x00, 0x00,
-       0x00, 0x00, 0x00, 0x05, 0x01, 0x00,
+       0x00, 0x00, 0x00, 0x04, 0x01, 0x00,
        0x16, 0x12, 0x24, COMP1, MCK_INIT1,
        0x18, 0x10, 0x04, 0x03, 0x11, 0x0c
 };
@@ -417,7 +428,7 @@ static const __u8 initPas202[] = {
 static const __u8 initPas202[] = {
        0x44, 0x44, 0x21, 0x30, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00,
        0x00, 0x00,
-       0x00, 0x00, 0x00, 0x07, 0x03, 0x0a,     /* 6 */
+       0x00, 0x00, 0x00, 0x06, 0x03, 0x0a,
        0x28, 0x1e, 0x28, 0x89, 0x20,
        0x00, 0x00, 0x02, 0x03, 0x0f, 0x0c
 };
@@ -448,7 +459,7 @@ static const __u8 initTas5110[] = {
 static const __u8 initTas5110[] = {
        0x44, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00,
        0x00, 0x00,
-       0x00, 0x01, 0x00, 0x46, 0x09, 0x0a,     /* shift from 0x45 0x09 0x0a */
+       0x00, 0x01, 0x00, 0x45, 0x09, 0x0a,
        0x16, 0x12, 0x60, 0x86, 0x2b,
        0x14, 0x0a, 0x02, 0x02, 0x09, 0x07
 };
@@ -461,7 +472,7 @@ static const __u8 initTas5130[] = {
 static const __u8 initTas5130[] = {
        0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x00, 0x00, 0x00,
        0x00, 0x00,
-       0x00, 0x01, 0x00, 0x69, 0x0c, 0x0a,
+       0x00, 0x01, 0x00, 0x68, 0x0c, 0x0a,
        0x28, 0x1e, 0x60, COMP, MCK_INIT,
        0x18, 0x10, 0x04, 0x03, 0x11, 0x0c
 };
@@ -475,14 +486,15 @@ static const __u8 tas5130_sensor_init[][
 
 struct sensor_data sensor_data[] = {
 SENS(initHv7131, NULL, hv7131_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ, 0),
-SENS(initOv6650, NULL, ov6650_sensor_init, NULL, NULL, F_GAIN|F_SIF, 0, 0x60),
+SENS(initOv6650, NULL, ov6650_sensor_init, NULL, NULL, F_GAIN|F_SIF|F_RAW, 0,
+       0x60),
 SENS(initOv7630, initOv7630_3, ov7630_sensor_init, NULL, ov7630_sensor_init_3,
        F_GAIN, 0, 0x21),
 SENS(initPas106, NULL, pas106_sensor_init, NULL, NULL, F_SIF, NO_EXPO|NO_FREQ,
        0),
-SENS(initPas202, initPas202, pas202_sensor_init, NULL, NULL, 0,
+SENS(initPas202, initPas202, pas202_sensor_init, NULL, NULL, F_RAW,
        NO_EXPO|NO_FREQ, 0),
-SENS(initTas5110, NULL, tas5110_sensor_init, NULL, NULL, F_GAIN|F_SIF,
+SENS(initTas5110, NULL, tas5110_sensor_init, NULL, NULL, F_GAIN|F_SIF|F_RAW,
        NO_BRIGHTNESS|NO_FREQ, 0),
 SENS(initTas5130, NULL, tas5130_sensor_init, NULL, NULL, 0, NO_EXPO|NO_FREQ,
        0),
@@ -852,6 +864,10 @@ static int sd_config(struct gspca_dev *g
                cam->cam_mode = sif_mode;
                cam->nmodes = ARRAY_SIZE(sif_mode);
        }
+       if (!(sensor_data[sd->sensor].flags & F_RAW)) {
+               cam->cam_mode++;
+               cam->nmodes--;
+       }
        sd->brightness = BRIGHTNESS_DEF;
        sd->gain = GAIN_DEF;
        sd->exposure = EXPOSURE_DEF;
@@ -900,6 +916,9 @@ static void sd_start(struct gspca_dev *g
                reg17_19[2] = mode ? 0x23 : 0x43;
                break;
        }
+       /* Disable compression when the raw bayer format has been selected */
+       if (gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv & MODE_RAW)
+               reg17_19[1] &= ~0x80;
 
        /* reg 0x01 bit 2 video transfert on */
        reg_w(gspca_dev, 0x01, &sn9c10x[0x01 - 1], 1);
@@ -962,6 +981,7 @@ static void sd_pkt_scan(struct gspca_dev
 {
        int i;
        struct sd *sd = (struct sd *) gspca_dev;
+       struct cam *cam = &gspca_dev->cam;
 
        /* frames start with:
         *      ff ff 00 c4 c4 96       synchro
@@ -1015,6 +1035,17 @@ static void sd_pkt_scan(struct gspca_dev
                        }
                }
        }
+
+       if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) {
+               /* In raw mode we sometimes get some garbage after the frame
+                  ignore this */
+               int used = frame->data_end - frame->data;
+               int size = cam->cam_mode[gspca_dev->curr_mode].sizeimage;
+
+               if (used + len > size)
+                       len = size - used;
+       }
+
        gspca_frame_add(gspca_dev, INTER_PACKET,
                        frame, data, len);
 }


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/0c8090b1106122a78cdff68be4c8362555fc7592

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to