The patch number 8518 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: Jean-Francois Moine  <[EMAIL PROTECTED]>
gspca: Remove the remaining frame decoding functions from the subdrivers.


SPCA505 and SPCA508 added in the pixel formats.
Decode functions and associated resources removed in spca505, 506 and 508.
The decode routines are now found in the V4L library.

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


---

 linux/drivers/media/video/gspca/spca505.c |  105 +++++-----------------
 linux/drivers/media/video/gspca/spca506.c |  105 +++++-----------------
 linux/drivers/media/video/gspca/spca508.c |   91 ++++---------------
 linux/include/linux/videodev2.h           |    2 
 4 files changed, 76 insertions(+), 227 deletions(-)

diff -r 12531455ca63 -r 6de914aaad86 linux/drivers/media/video/gspca/spca505.c
--- a/linux/drivers/media/video/gspca/spca505.c Sat Jul 26 12:49:55 2008 +0200
+++ b/linux/drivers/media/video/gspca/spca505.c Sat Jul 26 13:02:47 2008 +0200
@@ -31,10 +31,6 @@ struct sd {
 struct sd {
        struct gspca_dev gspca_dev;             /* !! must be the first item */
 
-       int buflen;
-       unsigned char tmpbuf[640 * 480 * 3 / 2]; /* YYUV per line */
-       unsigned char tmpbuf2[640 * 480 * 2];   /* YUYV */
-
        unsigned char brightness;
 
        char subtype;
@@ -64,29 +60,29 @@ static struct ctrl sd_ctrls[] = {
 };
 
 static struct v4l2_pix_format vga_mode[] = {
-       {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 160 * 2,
-               .sizeimage = 160 * 120 * 2,
+       {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 160 * 3,
+               .sizeimage = 160 * 120 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 5},
-       {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 176 * 2,
-               .sizeimage = 176 * 144 * 2,
+       {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 176 * 3,
+               .sizeimage = 176 * 144 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 4},
-       {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 320 * 2,
-               .sizeimage = 320 * 240 * 2,
+       {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 320 * 3,
+               .sizeimage = 320 * 240 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 2},
-       {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 352 * 2,
-               .sizeimage = 352 * 288 * 2,
+       {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 352 * 3,
+               .sizeimage = 352 * 288 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 1},
-       {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 640 * 2,
-               .sizeimage = 640 * 480 * 2,
+       {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 640 * 3,
+               .sizeimage = 640 * 480 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 0},
 };
@@ -829,77 +825,30 @@ static void sd_close(struct gspca_dev *g
        reg_write(gspca_dev->dev, 0x05, 0x11, 0xf);
 }
 
-/* convert YYUV per line to YUYV (YUV 4:2:2) */
-static void yyuv_decode(unsigned char *out,
-                       unsigned char *in,
-                       int width,
-                       int height)
-{
-       unsigned char *Ui, *Vi, *yi, *yi1;
-       unsigned char *out1;
-       int i, j;
-
-       yi = in;
-       for (i = height / 2; --i >= 0; ) {
-               out1 = out + width * 2;         /* next line */
-               yi1 = yi + width;
-               Ui = yi1 + width;
-               Vi = Ui + width / 2;
-               for (j = width / 2; --j >= 0; ) {
-                       *out++ = 128 + *yi++;
-                       *out++ = 128 + *Ui;
-                       *out++ = 128 + *yi++;
-                       *out++ = 128 + *Vi;
-
-                       *out1++ = 128 + *yi1++;
-                       *out1++ = 128 + *Ui++;
-                       *out1++ = 128 + *yi1++;
-                       *out1++ = 128 + *Vi++;
-               }
-               yi += width * 2;
-               out = out1;
-       }
-}
-
 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
                        struct gspca_frame *frame,      /* target */
                        __u8 *data,                     /* isoc packet */
                        int len)                        /* iso packet length */
 {
-       struct sd *sd = (struct sd *) gspca_dev;
-
        switch (data[0]) {
        case 0:                         /* start of frame */
-               if (gspca_dev->last_packet_type == FIRST_PACKET) {
-                       yyuv_decode(sd->tmpbuf2, sd->tmpbuf,
-                                       gspca_dev->width,
-                                       gspca_dev->height);
-                       frame = gspca_frame_add(gspca_dev,
-                                               LAST_PACKET,
-                                               frame,
-                                               sd->tmpbuf2,
-                                               gspca_dev->width
-                                                       * gspca_dev->height
-                                                       * 2);
-               }
-               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
-                               data, 0);
+               frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
+                                       data, 0);
                data += SPCA50X_OFFSET_DATA;
                len -= SPCA50X_OFFSET_DATA;
-               if (len > 0)
-                       memcpy(sd->tmpbuf, data, len);
-               else
-                       len = 0;
-               sd->buflen = len;
-               return;
+               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
+                               data, len);
+               break;
        case 0xff:                      /* drop */
 /*             gspca_dev->last_packet_type = DISCARD_PACKET; */
-               return;
+               break;
+       default:
+               data += 1;
+               len -= 1;
+               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
+                               data, len);
+               break;
        }
-       data += 1;
-       len -= 1;
-       memcpy(&sd->tmpbuf[sd->buflen], data, len);
-       sd->buflen += len;
 }
 
 static void setbrightness(struct gspca_dev *gspca_dev)
diff -r 12531455ca63 -r 6de914aaad86 linux/drivers/media/video/gspca/spca506.c
--- a/linux/drivers/media/video/gspca/spca506.c Sat Jul 26 12:49:55 2008 +0200
+++ b/linux/drivers/media/video/gspca/spca506.c Sat Jul 26 13:02:47 2008 +0200
@@ -32,10 +32,6 @@ MODULE_LICENSE("GPL");
 /* specific webcam descriptor */
 struct sd {
        struct gspca_dev gspca_dev;     /* !! must be the first item */
-
-       int buflen;
-       __u8 tmpbuf[640 * 480 * 3];     /* YYUV per line */
-       __u8 tmpbuf2[640 * 480 * 2];    /* YUYV */
 
        unsigned char brightness;
        unsigned char contrast;
@@ -115,29 +111,29 @@ static struct ctrl sd_ctrls[] = {
 };
 
 static struct v4l2_pix_format vga_mode[] = {
-       {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 160 * 2,
-               .sizeimage = 160 * 120 * 2,
+       {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 160 * 3,
+               .sizeimage = 160 * 120 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 5},
-       {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 176 * 2,
-               .sizeimage = 176 * 144 * 2,
+       {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 176 * 3,
+               .sizeimage = 176 * 144 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 4},
-       {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 320 * 2,
-               .sizeimage = 320 * 240 * 2,
+       {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 320 * 3,
+               .sizeimage = 320 * 240 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 2},
-       {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 352 * 2,
-               .sizeimage = 352 * 288 * 2,
+       {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 352 * 3,
+               .sizeimage = 352 * 288 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 1},
-       {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 640 * 2,
-               .sizeimage = 640 * 480 * 2,
+       {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
+               .bytesperline = 640 * 3,
+               .sizeimage = 640 * 480 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 0},
 };
@@ -572,77 +568,30 @@ static void sd_close(struct gspca_dev *g
 {
 }
 
-/* convert YYUV per line to YUYV (YUV 4:2:2) */
-static void yyuv_decode(unsigned char *out,
-                       unsigned char *in,
-                       int width,
-                       int height)
-{
-       unsigned char *Ui, *Vi, *yi, *yi1;
-       unsigned char *out1;
-       int i, j;
-
-       yi = in;
-       for (i = height / 2; --i >= 0; ) {
-               out1 = out + width * 2;         /* next line */
-               yi1 = yi + width;
-               Ui = yi1 + width;
-               Vi = Ui + width / 2;
-               for (j = width / 2; --j >= 0; ) {
-                       *out++ = 128 + *yi++;
-                       *out++ = 128 + *Ui;
-                       *out++ = 128 + *yi++;
-                       *out++ = 128 + *Vi;
-
-                       *out1++ = 128 + *yi1++;
-                       *out1++ = 128 + *Ui++;
-                       *out1++ = 128 + *yi1++;
-                       *out1++ = 128 + *Vi++;
-               }
-               yi += width * 2;
-               out = out1;
-       }
-}
-
 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
                        struct gspca_frame *frame,      /* target */
                        __u8 *data,                     /* isoc packet */
                        int len)                        /* iso packet length */
 {
-       struct sd *sd = (struct sd *) gspca_dev;
-
        switch (data[0]) {
        case 0:                         /* start of frame */
-               if (gspca_dev->last_packet_type == FIRST_PACKET) {
-                       yyuv_decode(sd->tmpbuf2, sd->tmpbuf,
-                                       gspca_dev->width,
-                                       gspca_dev->height);
-                       frame = gspca_frame_add(gspca_dev,
-                                               LAST_PACKET,
-                                               frame,
-                                               sd->tmpbuf2,
-                                               gspca_dev->width
-                                                       * gspca_dev->height
-                                                       * 2);
-               }
-               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
-                               data, 0);
+               frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
+                                       data, 0);
                data += SPCA50X_OFFSET_DATA;
                len -= SPCA50X_OFFSET_DATA;
-               if (len > 0)
-                       memcpy(sd->tmpbuf, data, len);
-               else
-                       len = 0;
-               sd->buflen = len;
-               return;
+               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
+                               data, len);
+               break;
        case 0xff:                      /* drop */
 /*             gspca_dev->last_packet_type = DISCARD_PACKET; */
-               return;
+               break;
+       default:
+               data += 1;
+               len -= 1;
+               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
+                               data, len);
+               break;
        }
-       data += 1;
-       len -= 1;
-       memcpy(&sd->tmpbuf[sd->buflen], data, len);
-       sd->buflen += len;
 }
 
 static void setbrightness(struct gspca_dev *gspca_dev)
diff -r 12531455ca63 -r 6de914aaad86 linux/drivers/media/video/gspca/spca508.c
--- a/linux/drivers/media/video/gspca/spca508.c Sat Jul 26 12:49:55 2008 +0200
+++ b/linux/drivers/media/video/gspca/spca508.c Sat Jul 26 13:02:47 2008 +0200
@@ -30,10 +30,6 @@ struct sd {
 struct sd {
        struct gspca_dev gspca_dev;             /* !! must be the first item */
 
-       int buflen;
-       unsigned char tmpbuf[352 * 288 * 3 / 2]; /* YUVY per line */
-       unsigned char tmpbuf2[352 * 288 * 2];   /* YUYV */
-
        unsigned char brightness;
 
        char subtype;
@@ -68,23 +64,23 @@ static struct ctrl sd_ctrls[] = {
 
 static struct v4l2_pix_format sif_mode[] = {
        {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 160 * 2,
-               .sizeimage = 160 * 120 * 2,
+               .bytesperline = 160 * 3,
+               .sizeimage = 160 * 120 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 3},
        {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 176 * 2,
-               .sizeimage = 176 * 144 * 2,
+               .bytesperline = 176 * 3,
+               .sizeimage = 176 * 144 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 2},
        {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 320 * 2,
-               .sizeimage = 320 * 240 * 2,
+               .bytesperline = 320 * 3,
+               .sizeimage = 320 * 240 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 1},
        {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
-               .bytesperline = 352 * 2,
-               .sizeimage = 352 * 288 * 2,
+               .bytesperline = 352 * 3,
+               .sizeimage = 352 * 288 * 3 / 2,
                .colorspace = V4L2_COLORSPACE_SRGB,
                .priv = 0},
 };
@@ -1605,77 +1601,30 @@ static void sd_close(struct gspca_dev *g
 {
 }
 
-/* convert YUVY per line to YUYV (YUV 4:2:2) */
-static void yuvy_decode(unsigned char *out,
-                       unsigned char *in,
-                       int width,
-                       int height)
-{
-       unsigned char *Ui, *Vi, *yi, *yi1;
-       unsigned char *out1;
-       int i, j;
-
-       yi = in;
-       for (i = height / 2; --i >= 0; ) {
-               out1 = out + width * 2;         /* next line */
-               Ui = yi + width;
-               Vi = Ui + width / 2;
-               yi1 = Vi + width / 2;
-               for (j = width / 2; --j >= 0; ) {
-                       *out++ = 128 + *yi++;
-                       *out++ = 128 + *Ui;
-                       *out++ = 128 + *yi++;
-                       *out++ = 128 + *Vi;
-
-                       *out1++ = 128 + *yi1++;
-                       *out1++ = 128 + *Ui++;
-                       *out1++ = 128 + *yi1++;
-                       *out1++ = 128 + *Vi++;
-               }
-               yi += width * 2;
-               out = out1;
-       }
-}
-
 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
                        struct gspca_frame *frame,      /* target */
                        __u8 *data,                     /* isoc packet */
                        int len)                        /* iso packet length */
 {
-       struct sd *sd = (struct sd *) gspca_dev;
-
        switch (data[0]) {
        case 0:                         /* start of frame */
-               if (gspca_dev->last_packet_type == FIRST_PACKET) {
-                       yuvy_decode(sd->tmpbuf2, sd->tmpbuf,
-                                       gspca_dev->width,
-                                       gspca_dev->height);
-                       frame = gspca_frame_add(gspca_dev,
-                                               LAST_PACKET,
-                                               frame,
-                                               sd->tmpbuf2,
-                                               gspca_dev->width
-                                                       * gspca_dev->height
-                                                       * 2);
-               }
-               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
-                               data, 0);
+               frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
+                                       data, 0);
                data += SPCA508_OFFSET_DATA;
                len -= SPCA508_OFFSET_DATA;
-               if (len > 0)
-                       memcpy(sd->tmpbuf, data, len);
-               else
-                       len = 0;
-               sd->buflen = len;
-               return;
+               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
+                               data, len);
+               break;
        case 0xff:                      /* drop */
 /*             gspca_dev->last_packet_type = DISCARD_PACKET; */
-               return;
+               break;
+       default:
+               data += 1;
+               len -= 1;
+               gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
+                               data, len);
+               break;
        }
-       data += 1;
-       len -= 1;
-       memcpy(&sd->tmpbuf[sd->buflen], data, len);
-       sd->buflen += len;
 }
 
 static void setbrightness(struct gspca_dev *gspca_dev)
diff -r 12531455ca63 -r 6de914aaad86 linux/include/linux/videodev2.h
--- a/linux/include/linux/videodev2.h   Sat Jul 26 12:49:55 2008 +0200
+++ b/linux/include/linux/videodev2.h   Sat Jul 26 13:02:47 2008 +0200
@@ -326,6 +326,8 @@ struct v4l2_pix_format
 #define V4L2_PIX_FMT_PWC2     v4l2_fourcc('P','W','C','2') /* pwc newer webcam 
*/
 #define V4L2_PIX_FMT_ET61X251 v4l2_fourcc('E','6','2','5') /* ET61X251 
compression */
 #define V4L2_PIX_FMT_SPCA501  v4l2_fourcc('S','5','0','1') /* YUYV per line */
+#define V4L2_PIX_FMT_SPCA505  v4l2_fourcc('S','5','0','5') /* YYUV per line */
+#define V4L2_PIX_FMT_SPCA508  v4l2_fourcc('S','5','0','8') /* YUVY per line */
 #define V4L2_PIX_FMT_SPCA561  v4l2_fourcc('S','5','6','1') /* compressed GBRG 
bayer */
 #define V4L2_PIX_FMT_PAC207   v4l2_fourcc('P','2','0','7') /* compressed BGGR 
bayer */
 


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/6de914aaad8673c3bbfe0cae82f66a137b7bba88

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

Reply via email to