Commit 1250ac6d authored by Jean-Francois Moine's avatar Jean-Francois Moine Committed by Mauro Carvalho Chehab

V4L/DVB (8518): 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: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 496cd7e9
......@@ -31,10 +31,6 @@ MODULE_LICENSE("GPL");
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},
};
......@@ -760,77 +756,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
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)
......
......@@ -33,10 +33,6 @@ MODULE_LICENSE("GPL");
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;
unsigned char colors;
......@@ -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 *gspca_dev)
{
}
/* 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)
......
......@@ -30,10 +30,6 @@ MODULE_LICENSE("GPL");
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},
};
......@@ -1567,77 +1563,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
{
}
/* 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)
......
......@@ -324,6 +324,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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment