aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-07-26 07:02:47 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-27 10:06:42 -0400
commit1250ac6d4ab716dafe0ac245fd31cd3a7cbc0a98 (patch)
tree7fa259d8d414566ddc80bc5cba6627d7e946cd28 /drivers/media
parent496cd7e977c73df2c287eaf6d612fc49d6f83dd7 (diff)
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: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/gspca/spca505.c105
-rw-r--r--drivers/media/video/gspca/spca506.c105
-rw-r--r--drivers/media/video/gspca/spca508.c91
3 files changed, 74 insertions, 227 deletions
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index 284d549e4d3..32ffe555606 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -31,10 +31,6 @@ MODULE_LICENSE("GPL");
31struct sd { 31struct sd {
32 struct gspca_dev gspca_dev; /* !! must be the first item */ 32 struct gspca_dev gspca_dev; /* !! must be the first item */
33 33
34 int buflen;
35 unsigned char tmpbuf[640 * 480 * 3 / 2]; /* YYUV per line */
36 unsigned char tmpbuf2[640 * 480 * 2]; /* YUYV */
37
38 unsigned char brightness; 34 unsigned char brightness;
39 35
40 char subtype; 36 char subtype;
@@ -64,29 +60,29 @@ static struct ctrl sd_ctrls[] = {
64}; 60};
65 61
66static struct v4l2_pix_format vga_mode[] = { 62static struct v4l2_pix_format vga_mode[] = {
67 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 63 {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
68 .bytesperline = 160 * 2, 64 .bytesperline = 160 * 3,
69 .sizeimage = 160 * 120 * 2, 65 .sizeimage = 160 * 120 * 3 / 2,
70 .colorspace = V4L2_COLORSPACE_SRGB, 66 .colorspace = V4L2_COLORSPACE_SRGB,
71 .priv = 5}, 67 .priv = 5},
72 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 68 {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
73 .bytesperline = 176 * 2, 69 .bytesperline = 176 * 3,
74 .sizeimage = 176 * 144 * 2, 70 .sizeimage = 176 * 144 * 3 / 2,
75 .colorspace = V4L2_COLORSPACE_SRGB, 71 .colorspace = V4L2_COLORSPACE_SRGB,
76 .priv = 4}, 72 .priv = 4},
77 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 73 {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
78 .bytesperline = 320 * 2, 74 .bytesperline = 320 * 3,
79 .sizeimage = 320 * 240 * 2, 75 .sizeimage = 320 * 240 * 3 / 2,
80 .colorspace = V4L2_COLORSPACE_SRGB, 76 .colorspace = V4L2_COLORSPACE_SRGB,
81 .priv = 2}, 77 .priv = 2},
82 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 78 {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
83 .bytesperline = 352 * 2, 79 .bytesperline = 352 * 3,
84 .sizeimage = 352 * 288 * 2, 80 .sizeimage = 352 * 288 * 3 / 2,
85 .colorspace = V4L2_COLORSPACE_SRGB, 81 .colorspace = V4L2_COLORSPACE_SRGB,
86 .priv = 1}, 82 .priv = 1},
87 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 83 {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
88 .bytesperline = 640 * 2, 84 .bytesperline = 640 * 3,
89 .sizeimage = 640 * 480 * 2, 85 .sizeimage = 640 * 480 * 3 / 2,
90 .colorspace = V4L2_COLORSPACE_SRGB, 86 .colorspace = V4L2_COLORSPACE_SRGB,
91 .priv = 0}, 87 .priv = 0},
92}; 88};
@@ -760,77 +756,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
760 reg_write(gspca_dev->dev, 0x05, 0x11, 0xf); 756 reg_write(gspca_dev->dev, 0x05, 0x11, 0xf);
761} 757}
762 758
763/* convert YYUV per line to YUYV (YUV 4:2:2) */
764static void yyuv_decode(unsigned char *out,
765 unsigned char *in,
766 int width,
767 int height)
768{
769 unsigned char *Ui, *Vi, *yi, *yi1;
770 unsigned char *out1;
771 int i, j;
772
773 yi = in;
774 for (i = height / 2; --i >= 0; ) {
775 out1 = out + width * 2; /* next line */
776 yi1 = yi + width;
777 Ui = yi1 + width;
778 Vi = Ui + width / 2;
779 for (j = width / 2; --j >= 0; ) {
780 *out++ = 128 + *yi++;
781 *out++ = 128 + *Ui;
782 *out++ = 128 + *yi++;
783 *out++ = 128 + *Vi;
784
785 *out1++ = 128 + *yi1++;
786 *out1++ = 128 + *Ui++;
787 *out1++ = 128 + *yi1++;
788 *out1++ = 128 + *Vi++;
789 }
790 yi += width * 2;
791 out = out1;
792 }
793}
794
795static void sd_pkt_scan(struct gspca_dev *gspca_dev, 759static void sd_pkt_scan(struct gspca_dev *gspca_dev,
796 struct gspca_frame *frame, /* target */ 760 struct gspca_frame *frame, /* target */
797 __u8 *data, /* isoc packet */ 761 __u8 *data, /* isoc packet */
798 int len) /* iso packet length */ 762 int len) /* iso packet length */
799{ 763{
800 struct sd *sd = (struct sd *) gspca_dev;
801
802 switch (data[0]) { 764 switch (data[0]) {
803 case 0: /* start of frame */ 765 case 0: /* start of frame */
804 if (gspca_dev->last_packet_type == FIRST_PACKET) { 766 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
805 yyuv_decode(sd->tmpbuf2, sd->tmpbuf, 767 data, 0);
806 gspca_dev->width,
807 gspca_dev->height);
808 frame = gspca_frame_add(gspca_dev,
809 LAST_PACKET,
810 frame,
811 sd->tmpbuf2,
812 gspca_dev->width
813 * gspca_dev->height
814 * 2);
815 }
816 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
817 data, 0);
818 data += SPCA50X_OFFSET_DATA; 768 data += SPCA50X_OFFSET_DATA;
819 len -= SPCA50X_OFFSET_DATA; 769 len -= SPCA50X_OFFSET_DATA;
820 if (len > 0) 770 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
821 memcpy(sd->tmpbuf, data, len); 771 data, len);
822 else 772 break;
823 len = 0;
824 sd->buflen = len;
825 return;
826 case 0xff: /* drop */ 773 case 0xff: /* drop */
827/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 774/* gspca_dev->last_packet_type = DISCARD_PACKET; */
828 return; 775 break;
776 default:
777 data += 1;
778 len -= 1;
779 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
780 data, len);
781 break;
829 } 782 }
830 data += 1;
831 len -= 1;
832 memcpy(&sd->tmpbuf[sd->buflen], data, len);
833 sd->buflen += len;
834} 783}
835 784
836static void setbrightness(struct gspca_dev *gspca_dev) 785static void setbrightness(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c
index 2c281a0563e..6fe715c80ad 100644
--- a/drivers/media/video/gspca/spca506.c
+++ b/drivers/media/video/gspca/spca506.c
@@ -33,10 +33,6 @@ MODULE_LICENSE("GPL");
33struct sd { 33struct 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
117static struct v4l2_pix_format vga_mode[] = { 113static 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) */
576static 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
607static void sd_pkt_scan(struct gspca_dev *gspca_dev, 571static 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
648static void setbrightness(struct gspca_dev *gspca_dev) 597static void setbrightness(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index af531d62856..4378e966edc 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -30,10 +30,6 @@ MODULE_LICENSE("GPL");
30struct sd { 30struct sd {
31 struct gspca_dev gspca_dev; /* !! must be the first item */ 31 struct gspca_dev gspca_dev; /* !! must be the first item */
32 32
33 int buflen;
34 unsigned char tmpbuf[352 * 288 * 3 / 2]; /* YUVY per line */
35 unsigned char tmpbuf2[352 * 288 * 2]; /* YUYV */
36
37 unsigned char brightness; 33 unsigned char brightness;
38 34
39 char subtype; 35 char subtype;
@@ -68,23 +64,23 @@ static struct ctrl sd_ctrls[] = {
68 64
69static struct v4l2_pix_format sif_mode[] = { 65static struct v4l2_pix_format sif_mode[] = {
70 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 66 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
71 .bytesperline = 160 * 2, 67 .bytesperline = 160 * 3,
72 .sizeimage = 160 * 120 * 2, 68 .sizeimage = 160 * 120 * 3 / 2,
73 .colorspace = V4L2_COLORSPACE_SRGB, 69 .colorspace = V4L2_COLORSPACE_SRGB,
74 .priv = 3}, 70 .priv = 3},
75 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 71 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
76 .bytesperline = 176 * 2, 72 .bytesperline = 176 * 3,
77 .sizeimage = 176 * 144 * 2, 73 .sizeimage = 176 * 144 * 3 / 2,
78 .colorspace = V4L2_COLORSPACE_SRGB, 74 .colorspace = V4L2_COLORSPACE_SRGB,
79 .priv = 2}, 75 .priv = 2},
80 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 76 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
81 .bytesperline = 320 * 2, 77 .bytesperline = 320 * 3,
82 .sizeimage = 320 * 240 * 2, 78 .sizeimage = 320 * 240 * 3 / 2,
83 .colorspace = V4L2_COLORSPACE_SRGB, 79 .colorspace = V4L2_COLORSPACE_SRGB,
84 .priv = 1}, 80 .priv = 1},
85 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 81 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
86 .bytesperline = 352 * 2, 82 .bytesperline = 352 * 3,
87 .sizeimage = 352 * 288 * 2, 83 .sizeimage = 352 * 288 * 3 / 2,
88 .colorspace = V4L2_COLORSPACE_SRGB, 84 .colorspace = V4L2_COLORSPACE_SRGB,
89 .priv = 0}, 85 .priv = 0},
90}; 86};
@@ -1567,77 +1563,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
1567{ 1563{
1568} 1564}
1569 1565
1570/* convert YUVY per line to YUYV (YUV 4:2:2) */
1571static void yuvy_decode(unsigned char *out,
1572 unsigned char *in,
1573 int width,
1574 int height)
1575{
1576 unsigned char *Ui, *Vi, *yi, *yi1;
1577 unsigned char *out1;
1578 int i, j;
1579
1580 yi = in;
1581 for (i = height / 2; --i >= 0; ) {
1582 out1 = out + width * 2; /* next line */
1583 Ui = yi + width;
1584 Vi = Ui + width / 2;
1585 yi1 = Vi + width / 2;
1586 for (j = width / 2; --j >= 0; ) {
1587 *out++ = 128 + *yi++;
1588 *out++ = 128 + *Ui;
1589 *out++ = 128 + *yi++;
1590 *out++ = 128 + *Vi;
1591
1592 *out1++ = 128 + *yi1++;
1593 *out1++ = 128 + *Ui++;
1594 *out1++ = 128 + *yi1++;
1595 *out1++ = 128 + *Vi++;
1596 }
1597 yi += width * 2;
1598 out = out1;
1599 }
1600}
1601
1602static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1566static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1603 struct gspca_frame *frame, /* target */ 1567 struct gspca_frame *frame, /* target */
1604 __u8 *data, /* isoc packet */ 1568 __u8 *data, /* isoc packet */
1605 int len) /* iso packet length */ 1569 int len) /* iso packet length */
1606{ 1570{
1607 struct sd *sd = (struct sd *) gspca_dev;
1608
1609 switch (data[0]) { 1571 switch (data[0]) {
1610 case 0: /* start of frame */ 1572 case 0: /* start of frame */
1611 if (gspca_dev->last_packet_type == FIRST_PACKET) { 1573 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
1612 yuvy_decode(sd->tmpbuf2, sd->tmpbuf, 1574 data, 0);
1613 gspca_dev->width,
1614 gspca_dev->height);
1615 frame = gspca_frame_add(gspca_dev,
1616 LAST_PACKET,
1617 frame,
1618 sd->tmpbuf2,
1619 gspca_dev->width
1620 * gspca_dev->height
1621 * 2);
1622 }
1623 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1624 data, 0);
1625 data += SPCA508_OFFSET_DATA; 1575 data += SPCA508_OFFSET_DATA;
1626 len -= SPCA508_OFFSET_DATA; 1576 len -= SPCA508_OFFSET_DATA;
1627 if (len > 0) 1577 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1628 memcpy(sd->tmpbuf, data, len); 1578 data, len);
1629 else 1579 break;
1630 len = 0;
1631 sd->buflen = len;
1632 return;
1633 case 0xff: /* drop */ 1580 case 0xff: /* drop */
1634/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 1581/* gspca_dev->last_packet_type = DISCARD_PACKET; */
1635 return; 1582 break;
1583 default:
1584 data += 1;
1585 len -= 1;
1586 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1587 data, len);
1588 break;
1636 } 1589 }
1637 data += 1;
1638 len -= 1;
1639 memcpy(&sd->tmpbuf[sd->buflen], data, len);
1640 sd->buflen += len;
1641} 1590}
1642 1591
1643static void setbrightness(struct gspca_dev *gspca_dev) 1592static void setbrightness(struct gspca_dev *gspca_dev)