aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/spca506.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/spca506.c')
-rw-r--r--drivers/media/video/gspca/spca506.c121
1 files changed, 33 insertions, 88 deletions
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c
index 143203c1fd9f..6fe715c80ad2 100644
--- a/drivers/media/video/gspca/spca506.c
+++ b/drivers/media/video/gspca/spca506.c
@@ -25,9 +25,6 @@
25 25
26#include "gspca.h" 26#include "gspca.h"
27 27
28#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
29static const char version[] = "2.1.7";
30
31MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
32MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver"); 29MODULE_DESCRIPTION("GSPCA/SPCA506 USB Camera Driver");
33MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
@@ -36,10 +33,6 @@ MODULE_LICENSE("GPL");
36struct sd { 33struct sd {
37 struct gspca_dev gspca_dev; /* !! must be the first item */ 34 struct gspca_dev gspca_dev; /* !! must be the first item */
38 35
39 int buflen;
40 __u8 tmpbuf[640 * 480 * 3]; /* YYUV per line */
41 __u8 tmpbuf2[640 * 480 * 2]; /* YUYV */
42
43 unsigned char brightness; 36 unsigned char brightness;
44 unsigned char contrast; 37 unsigned char contrast;
45 unsigned char colors; 38 unsigned char colors;
@@ -118,29 +111,29 @@ static struct ctrl sd_ctrls[] = {
118}; 111};
119 112
120static struct v4l2_pix_format vga_mode[] = { 113static struct v4l2_pix_format vga_mode[] = {
121 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 114 {160, 120, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
122 .bytesperline = 160 * 2, 115 .bytesperline = 160 * 3,
123 .sizeimage = 160 * 120 * 2, 116 .sizeimage = 160 * 120 * 3 / 2,
124 .colorspace = V4L2_COLORSPACE_SRGB, 117 .colorspace = V4L2_COLORSPACE_SRGB,
125 .priv = 5}, 118 .priv = 5},
126 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 119 {176, 144, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
127 .bytesperline = 176 * 2, 120 .bytesperline = 176 * 3,
128 .sizeimage = 176 * 144 * 2, 121 .sizeimage = 176 * 144 * 3 / 2,
129 .colorspace = V4L2_COLORSPACE_SRGB, 122 .colorspace = V4L2_COLORSPACE_SRGB,
130 .priv = 4}, 123 .priv = 4},
131 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 124 {320, 240, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
132 .bytesperline = 320 * 2, 125 .bytesperline = 320 * 3,
133 .sizeimage = 320 * 240 * 2, 126 .sizeimage = 320 * 240 * 3 / 2,
134 .colorspace = V4L2_COLORSPACE_SRGB, 127 .colorspace = V4L2_COLORSPACE_SRGB,
135 .priv = 2}, 128 .priv = 2},
136 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 129 {352, 288, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
137 .bytesperline = 352 * 2, 130 .bytesperline = 352 * 3,
138 .sizeimage = 352 * 288 * 2, 131 .sizeimage = 352 * 288 * 3 / 2,
139 .colorspace = V4L2_COLORSPACE_SRGB, 132 .colorspace = V4L2_COLORSPACE_SRGB,
140 .priv = 1}, 133 .priv = 1},
141 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 134 {640, 480, V4L2_PIX_FMT_SPCA505, V4L2_FIELD_NONE,
142 .bytesperline = 640 * 2, 135 .bytesperline = 640 * 3,
143 .sizeimage = 640 * 480 * 2, 136 .sizeimage = 640 * 480 * 3 / 2,
144 .colorspace = V4L2_COLORSPACE_SRGB, 137 .colorspace = V4L2_COLORSPACE_SRGB,
145 .priv = 0}, 138 .priv = 0},
146}; 139};
@@ -310,7 +303,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
310 struct cam *cam; 303 struct cam *cam;
311 304
312 cam = &gspca_dev->cam; 305 cam = &gspca_dev->cam;
313 cam->dev_name = (char *) id->driver_info;
314 cam->epaddr = 0x01; 306 cam->epaddr = 0x01;
315 cam->cam_mode = vga_mode; 307 cam->cam_mode = vga_mode;
316 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0]; 308 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
@@ -576,77 +568,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
576{ 568{
577} 569}
578 570
579/* convert YYUV per line to YUYV (YUV 4:2:2) */
580static void yyuv_decode(unsigned char *out,
581 unsigned char *in,
582 int width,
583 int height)
584{
585 unsigned char *Ui, *Vi, *yi, *yi1;
586 unsigned char *out1;
587 int i, j;
588
589 yi = in;
590 for (i = height / 2; --i >= 0; ) {
591 out1 = out + width * 2; /* next line */
592 yi1 = yi + width;
593 Ui = yi1 + width;
594 Vi = Ui + width / 2;
595 for (j = width / 2; --j >= 0; ) {
596 *out++ = 128 + *yi++;
597 *out++ = 128 + *Ui;
598 *out++ = 128 + *yi++;
599 *out++ = 128 + *Vi;
600
601 *out1++ = 128 + *yi1++;
602 *out1++ = 128 + *Ui++;
603 *out1++ = 128 + *yi1++;
604 *out1++ = 128 + *Vi++;
605 }
606 yi += width * 2;
607 out = out1;
608 }
609}
610
611static void sd_pkt_scan(struct gspca_dev *gspca_dev, 571static void sd_pkt_scan(struct gspca_dev *gspca_dev,
612 struct gspca_frame *frame, /* target */ 572 struct gspca_frame *frame, /* target */
613 __u8 *data, /* isoc packet */ 573 __u8 *data, /* isoc packet */
614 int len) /* iso packet length */ 574 int len) /* iso packet length */
615{ 575{
616 struct sd *sd = (struct sd *) gspca_dev;
617
618 switch (data[0]) { 576 switch (data[0]) {
619 case 0: /* start of frame */ 577 case 0: /* start of frame */
620 if (gspca_dev->last_packet_type == FIRST_PACKET) { 578 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
621 yyuv_decode(sd->tmpbuf2, sd->tmpbuf, 579 data, 0);
622 gspca_dev->width,
623 gspca_dev->height);
624 frame = gspca_frame_add(gspca_dev,
625 LAST_PACKET,
626 frame,
627 sd->tmpbuf2,
628 gspca_dev->width
629 * gspca_dev->height
630 * 2);
631 }
632 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
633 data, 0);
634 data += SPCA50X_OFFSET_DATA; 580 data += SPCA50X_OFFSET_DATA;
635 len -= SPCA50X_OFFSET_DATA; 581 len -= SPCA50X_OFFSET_DATA;
636 if (len > 0) 582 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
637 memcpy(sd->tmpbuf, data, len); 583 data, len);
638 else 584 break;
639 len = 0;
640 sd->buflen = len;
641 return;
642 case 0xff: /* drop */ 585 case 0xff: /* drop */
643/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 586/* gspca_dev->last_packet_type = DISCARD_PACKET; */
644 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;
645 } 594 }
646 data += 1;
647 len -= 1;
648 memcpy(&sd->tmpbuf[sd->buflen], data, len);
649 sd->buflen += len;
650} 595}
651 596
652static void setbrightness(struct gspca_dev *gspca_dev) 597static void setbrightness(struct gspca_dev *gspca_dev)
@@ -804,12 +749,12 @@ static struct sd_desc sd_desc = {
804}; 749};
805 750
806/* -- module initialisation -- */ 751/* -- module initialisation -- */
807#define DVNM(name) .driver_info = (kernel_ulong_t) name
808static __devinitdata struct usb_device_id device_table[] = { 752static __devinitdata struct usb_device_id device_table[] = {
809 {USB_DEVICE(0x06e1, 0xa190), DVNM("ADS Instant VCD")}, 753 {USB_DEVICE(0x06e1, 0xa190)},
810/* {USB_DEVICE(0x0733, 0x0430), DVNM("UsbGrabber PV321c")}, */ 754/*fixme: may be IntelPCCameraPro BRIDGE_SPCA505
811 {USB_DEVICE(0x0734, 0x043b), DVNM("3DeMon USB Capture aka")}, 755 {USB_DEVICE(0x0733, 0x0430)}, */
812 {USB_DEVICE(0x99fa, 0x8988), DVNM("Grandtec V.cap")}, 756 {USB_DEVICE(0x0734, 0x043b)},
757 {USB_DEVICE(0x99fa, 0x8988)},
813 {} 758 {}
814}; 759};
815MODULE_DEVICE_TABLE(usb, device_table); 760MODULE_DEVICE_TABLE(usb, device_table);
@@ -834,7 +779,7 @@ static int __init sd_mod_init(void)
834{ 779{
835 if (usb_register(&sd_driver) < 0) 780 if (usb_register(&sd_driver) < 0)
836 return -1; 781 return -1;
837 PDEBUG(D_PROBE, "v%s registered", version); 782 PDEBUG(D_PROBE, "registered");
838 return 0; 783 return 0;
839} 784}
840static void __exit sd_mod_exit(void) 785static void __exit sd_mod_exit(void)