Skip to content

Commit

Permalink
V4L/DVB (8518): gspca: Remove the remaining frame decoding functions …
Browse files Browse the repository at this point in the history
…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 <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Jean-Francois Moine authored and Mauro Carvalho Chehab committed Jul 27, 2008
1 parent 496cd7e commit 1250ac6
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 227 deletions.
105 changes: 27 additions & 78 deletions drivers/media/video/gspca/spca505.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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},
};
Expand Down Expand Up @@ -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)
Expand Down
105 changes: 27 additions & 78 deletions drivers/media/video/gspca/spca506.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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},
};
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit 1250ac6

Please sign in to comment.