diff options
Diffstat (limited to 'drivers/media/video/gspca/spca506.c')
-rw-r--r-- | drivers/media/video/gspca/spca506.c | 105 |
1 files changed, 27 insertions, 78 deletions
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c index 2c281a0563e5..6fe715c80ad2 100644 --- a/drivers/media/video/gspca/spca506.c +++ b/drivers/media/video/gspca/spca506.c | |||
@@ -33,10 +33,6 @@ MODULE_LICENSE("GPL"); | |||
33 | struct sd { | 33 | struct sd { |
34 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 34 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
35 | 35 | ||
36 | int buflen; | ||
37 | __u8 tmpbuf[640 * 480 * 3]; /* YYUV per line */ | ||
38 | __u8 tmpbuf2[640 * 480 * 2]; /* YUYV */ | ||
39 | |||
40 | unsigned char brightness; | 36 | unsigned char brightness; |
41 | unsigned char contrast; | 37 | unsigned char contrast; |
42 | unsigned char colors; | 38 | unsigned char colors; |
@@ -115,29 +111,29 @@ static struct ctrl sd_ctrls[] = { | |||
115 | }; | 111 | }; |
116 | 112 | ||
117 | static struct v4l2_pix_format vga_mode[] = { | 113 | static struct v4l2_pix_format vga_mode[] = { |
118 | {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, | 114 | {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
119 | .bytesperline = 160 * 2, | 115 | .bytesperline = 160 * 3, |
120 | .sizeimage = 160 * 120 * 2, | 116 | .sizeimage = 160 * 120 * 3 / 2, |
121 | .colorspace = V4L2_COLORSPACE_SRGB, | 117 | .colorspace = V4L2_COLORSPACE_SRGB, |
122 | .priv = 5}, | 118 | .priv = 5}, |
123 | {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, | 119 | {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
124 | .bytesperline = 176 * 2, | 120 | .bytesperline = 176 * 3, |
125 | .sizeimage = 176 * 144 * 2, | 121 | .sizeimage = 176 * 144 * 3 / 2, |
126 | .colorspace = V4L2_COLORSPACE_SRGB, | 122 | .colorspace = V4L2_COLORSPACE_SRGB, |
127 | .priv = 4}, | 123 | .priv = 4}, |
128 | {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, | 124 | {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
129 | .bytesperline = 320 * 2, | 125 | .bytesperline = 320 * 3, |
130 | .sizeimage = 320 * 240 * 2, | 126 | .sizeimage = 320 * 240 * 3 / 2, |
131 | .colorspace = V4L2_COLORSPACE_SRGB, | 127 | .colorspace = V4L2_COLORSPACE_SRGB, |
132 | .priv = 2}, | 128 | .priv = 2}, |
133 | {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, | 129 | {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
134 | .bytesperline = 352 * 2, | 130 | .bytesperline = 352 * 3, |
135 | .sizeimage = 352 * 288 * 2, | 131 | .sizeimage = 352 * 288 * 3 / 2, |
136 | .colorspace = V4L2_COLORSPACE_SRGB, | 132 | .colorspace = V4L2_COLORSPACE_SRGB, |
137 | .priv = 1}, | 133 | .priv = 1}, |
138 | {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, | 134 | {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE, |
139 | .bytesperline = 640 * 2, | 135 | .bytesperline = 640 * 3, |
140 | .sizeimage = 640 * 480 * 2, | 136 | .sizeimage = 640 * 480 * 3 / 2, |
141 | .colorspace = V4L2_COLORSPACE_SRGB, | 137 | .colorspace = V4L2_COLORSPACE_SRGB, |
142 | .priv = 0}, | 138 | .priv = 0}, |
143 | }; | 139 | }; |
@@ -572,77 +568,30 @@ static void sd_close(struct gspca_dev *gspca_dev) | |||
572 | { | 568 | { |
573 | } | 569 | } |
574 | 570 | ||
575 | /* convert YYUV per line to YUYV (YUV 4:2:2) */ | ||
576 | static void yyuv_decode(unsigned char *out, | ||
577 | unsigned char *in, | ||
578 | int width, | ||
579 | int height) | ||
580 | { | ||
581 | unsigned char *Ui, *Vi, *yi, *yi1; | ||
582 | unsigned char *out1; | ||
583 | int i, j; | ||
584 | |||
585 | yi = in; | ||
586 | for (i = height / 2; --i >= 0; ) { | ||
587 | out1 = out + width * 2; /* next line */ | ||
588 | yi1 = yi + width; | ||
589 | Ui = yi1 + width; | ||
590 | Vi = Ui + width / 2; | ||
591 | for (j = width / 2; --j >= 0; ) { | ||
592 | *out++ = 128 + *yi++; | ||
593 | *out++ = 128 + *Ui; | ||
594 | *out++ = 128 + *yi++; | ||
595 | *out++ = 128 + *Vi; | ||
596 | |||
597 | *out1++ = 128 + *yi1++; | ||
598 | *out1++ = 128 + *Ui++; | ||
599 | *out1++ = 128 + *yi1++; | ||
600 | *out1++ = 128 + *Vi++; | ||
601 | } | ||
602 | yi += width * 2; | ||
603 | out = out1; | ||
604 | } | ||
605 | } | ||
606 | |||
607 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 571 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
608 | struct gspca_frame *frame, /* target */ | 572 | struct gspca_frame *frame, /* target */ |
609 | __u8 *data, /* isoc packet */ | 573 | __u8 *data, /* isoc packet */ |
610 | int len) /* iso packet length */ | 574 | int len) /* iso packet length */ |
611 | { | 575 | { |
612 | struct sd *sd = (struct sd *) gspca_dev; | ||
613 | |||
614 | switch (data[0]) { | 576 | switch (data[0]) { |
615 | case 0: /* start of frame */ | 577 | case 0: /* start of frame */ |
616 | if (gspca_dev->last_packet_type == FIRST_PACKET) { | 578 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, |
617 | yyuv_decode(sd->tmpbuf2, sd->tmpbuf, | 579 | data, 0); |
618 | gspca_dev->width, | ||
619 | gspca_dev->height); | ||
620 | frame = gspca_frame_add(gspca_dev, | ||
621 | LAST_PACKET, | ||
622 | frame, | ||
623 | sd->tmpbuf2, | ||
624 | gspca_dev->width | ||
625 | * gspca_dev->height | ||
626 | * 2); | ||
627 | } | ||
628 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, | ||
629 | data, 0); | ||
630 | data += SPCA50X_OFFSET_DATA; | 580 | data += SPCA50X_OFFSET_DATA; |
631 | len -= SPCA50X_OFFSET_DATA; | 581 | len -= SPCA50X_OFFSET_DATA; |
632 | if (len > 0) | 582 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, |
633 | memcpy(sd->tmpbuf, data, len); | 583 | data, len); |
634 | else | 584 | break; |
635 | len = 0; | ||
636 | sd->buflen = len; | ||
637 | return; | ||
638 | case 0xff: /* drop */ | 585 | case 0xff: /* drop */ |
639 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ | 586 | /* gspca_dev->last_packet_type = DISCARD_PACKET; */ |
640 | return; | 587 | break; |
588 | default: | ||
589 | data += 1; | ||
590 | len -= 1; | ||
591 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, | ||
592 | data, len); | ||
593 | break; | ||
641 | } | 594 | } |
642 | data += 1; | ||
643 | len -= 1; | ||
644 | memcpy(&sd->tmpbuf[sd->buflen], data, len); | ||
645 | sd->buflen += len; | ||
646 | } | 595 | } |
647 | 596 | ||
648 | static void setbrightness(struct gspca_dev *gspca_dev) | 597 | static void setbrightness(struct gspca_dev *gspca_dev) |