aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/spca508.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/gspca/spca508.c')
-rw-r--r--drivers/media/video/gspca/spca508.c164
1 files changed, 30 insertions, 134 deletions
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index d8cd93866a4a..b608a27ad115 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -22,9 +22,6 @@
22 22
23#include "gspca.h" 23#include "gspca.h"
24 24
25#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
26static const char version[] = "2.1.7";
27
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 25MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
29MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver"); 26MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver");
30MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
@@ -33,10 +30,6 @@ MODULE_LICENSE("GPL");
33struct sd { 30struct sd {
34 struct gspca_dev gspca_dev; /* !! must be the first item */ 31 struct gspca_dev gspca_dev; /* !! must be the first item */
35 32
36 int buflen;
37 unsigned char tmpbuf[352 * 288 * 3 / 2]; /* YUVY per line */
38 unsigned char tmpbuf2[352 * 288 * 2]; /* YUYV */
39
40 unsigned char brightness; 33 unsigned char brightness;
41 34
42 char subtype; 35 char subtype;
@@ -71,23 +64,23 @@ static struct ctrl sd_ctrls[] = {
71 64
72static struct v4l2_pix_format sif_mode[] = { 65static struct v4l2_pix_format sif_mode[] = {
73 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 66 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
74 .bytesperline = 160 * 2, 67 .bytesperline = 160 * 3,
75 .sizeimage = 160 * 120 * 2, 68 .sizeimage = 160 * 120 * 3 / 2,
76 .colorspace = V4L2_COLORSPACE_SRGB, 69 .colorspace = V4L2_COLORSPACE_SRGB,
77 .priv = 3}, 70 .priv = 3},
78 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 71 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
79 .bytesperline = 176 * 2, 72 .bytesperline = 176 * 3,
80 .sizeimage = 176 * 144 * 2, 73 .sizeimage = 176 * 144 * 3 / 2,
81 .colorspace = V4L2_COLORSPACE_SRGB, 74 .colorspace = V4L2_COLORSPACE_SRGB,
82 .priv = 2}, 75 .priv = 2},
83 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 76 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
84 .bytesperline = 320 * 2, 77 .bytesperline = 320 * 3,
85 .sizeimage = 320 * 240 * 2, 78 .sizeimage = 320 * 240 * 3 / 2,
86 .colorspace = V4L2_COLORSPACE_SRGB, 79 .colorspace = V4L2_COLORSPACE_SRGB,
87 .priv = 1}, 80 .priv = 1},
88 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE, 81 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
89 .bytesperline = 352 * 2, 82 .bytesperline = 352 * 3,
90 .sizeimage = 352 * 288 * 2, 83 .sizeimage = 352 * 288 * 3 / 2,
91 .colorspace = V4L2_COLORSPACE_SRGB, 84 .colorspace = V4L2_COLORSPACE_SRGB,
92 .priv = 0}, 85 .priv = 0},
93}; 86};
@@ -1476,58 +1469,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
1476{ 1469{
1477 struct sd *sd = (struct sd *) gspca_dev; 1470 struct sd *sd = (struct sd *) gspca_dev;
1478 struct cam *cam; 1471 struct cam *cam;
1479 __u16 product;
1480 int data1, data2; 1472 int data1, data2;
1481 1473
1482 product = id->idProduct;
1483 switch (id->idVendor) {
1484 case 0x0130: /* Clone webcam */
1485/* switch (product) { */
1486/* case 0x0130: */
1487 sd->subtype = HamaUSBSightcam; /* same as Hama 0010 */
1488/* break; */
1489/* } */
1490 break;
1491 case 0x041e: /* Creative cameras */
1492/* switch (product) { */
1493/* case 0x4018: */
1494 sd->subtype = CreativeVista;
1495/* break; */
1496/* } */
1497 break;
1498 case 0x0461: /* MicroInnovation */
1499/* switch (product) { */
1500/* case 0x0815: */
1501 sd->subtype = MicroInnovationIC200;
1502/* break; */
1503/* } */
1504 break;
1505 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
1506/* switch (product) { */
1507/* case 0x110: */
1508 sd->subtype = ViewQuestVQ110;
1509/* break; */
1510/* } */
1511 break;
1512 case 0x0af9: /* Hama cameras */
1513 switch (product) {
1514 case 0x0010:
1515 sd->subtype = HamaUSBSightcam;
1516 break;
1517 case 0x0011:
1518 sd->subtype = HamaUSBSightcam2;
1519 break;
1520 }
1521 break;
1522 case 0x8086: /* Intel */
1523/* switch (product) { */
1524/* case 0x0110: */
1525 sd->subtype = IntelEasyPCCamera;
1526/* break; */
1527/* } */
1528 break;
1529 }
1530
1531 /* Read from global register the USB product and vendor IDs, just to 1474 /* Read from global register the USB product and vendor IDs, just to
1532 * prove that we can communicate with the device. This works, which 1475 * prove that we can communicate with the device. This works, which
1533 * confirms at we are communicating properly and that the device 1476 * confirms at we are communicating properly and that the device
@@ -1544,10 +1487,11 @@ static int sd_config(struct gspca_dev *gspca_dev,
1544 PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); 1487 PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1);
1545 1488
1546 cam = &gspca_dev->cam; 1489 cam = &gspca_dev->cam;
1547 cam->dev_name = (char *) id->driver_info;
1548 cam->epaddr = 0x01; 1490 cam->epaddr = 0x01;
1549 cam->cam_mode = sif_mode; 1491 cam->cam_mode = sif_mode;
1550 cam->nmodes = ARRAY_SIZE(sif_mode); 1492 cam->nmodes = ARRAY_SIZE(sif_mode);
1493
1494 sd->subtype = id->driver_info;
1551 sd->brightness = BRIGHTNESS_DEF; 1495 sd->brightness = BRIGHTNESS_DEF;
1552 1496
1553 switch (sd->subtype) { 1497 switch (sd->subtype) {
@@ -1619,77 +1563,30 @@ static void sd_close(struct gspca_dev *gspca_dev)
1619{ 1563{
1620} 1564}
1621 1565
1622/* convert YUVY per line to YUYV (YUV 4:2:2) */
1623static void yuvy_decode(unsigned char *out,
1624 unsigned char *in,
1625 int width,
1626 int height)
1627{
1628 unsigned char *Ui, *Vi, *yi, *yi1;
1629 unsigned char *out1;
1630 int i, j;
1631
1632 yi = in;
1633 for (i = height / 2; --i >= 0; ) {
1634 out1 = out + width * 2; /* next line */
1635 Ui = yi + width;
1636 Vi = Ui + width / 2;
1637 yi1 = Vi + width / 2;
1638 for (j = width / 2; --j >= 0; ) {
1639 *out++ = 128 + *yi++;
1640 *out++ = 128 + *Ui;
1641 *out++ = 128 + *yi++;
1642 *out++ = 128 + *Vi;
1643
1644 *out1++ = 128 + *yi1++;
1645 *out1++ = 128 + *Ui++;
1646 *out1++ = 128 + *yi1++;
1647 *out1++ = 128 + *Vi++;
1648 }
1649 yi += width * 2;
1650 out = out1;
1651 }
1652}
1653
1654static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1566static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1655 struct gspca_frame *frame, /* target */ 1567 struct gspca_frame *frame, /* target */
1656 __u8 *data, /* isoc packet */ 1568 __u8 *data, /* isoc packet */
1657 int len) /* iso packet length */ 1569 int len) /* iso packet length */
1658{ 1570{
1659 struct sd *sd = (struct sd *) gspca_dev;
1660
1661 switch (data[0]) { 1571 switch (data[0]) {
1662 case 0: /* start of frame */ 1572 case 0: /* start of frame */
1663 if (gspca_dev->last_packet_type == FIRST_PACKET) { 1573 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
1664 yuvy_decode(sd->tmpbuf2, sd->tmpbuf, 1574 data, 0);
1665 gspca_dev->width,
1666 gspca_dev->height);
1667 frame = gspca_frame_add(gspca_dev,
1668 LAST_PACKET,
1669 frame,
1670 sd->tmpbuf2,
1671 gspca_dev->width
1672 * gspca_dev->height
1673 * 2);
1674 }
1675 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1676 data, 0);
1677 data += SPCA508_OFFSET_DATA; 1575 data += SPCA508_OFFSET_DATA;
1678 len -= SPCA508_OFFSET_DATA; 1576 len -= SPCA508_OFFSET_DATA;
1679 if (len > 0) 1577 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1680 memcpy(sd->tmpbuf, data, len); 1578 data, len);
1681 else 1579 break;
1682 len = 0;
1683 sd->buflen = len;
1684 return;
1685 case 0xff: /* drop */ 1580 case 0xff: /* drop */
1686/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 1581/* gspca_dev->last_packet_type = DISCARD_PACKET; */
1687 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;
1688 } 1589 }
1689 data += 1;
1690 len -= 1;
1691 memcpy(&sd->tmpbuf[sd->buflen], data, len);
1692 sd->buflen += len;
1693} 1590}
1694 1591
1695static void setbrightness(struct gspca_dev *gspca_dev) 1592static void setbrightness(struct gspca_dev *gspca_dev)
@@ -1745,15 +1642,14 @@ static const struct sd_desc sd_desc = {
1745}; 1642};
1746 1643
1747/* -- module initialisation -- */ 1644/* -- module initialisation -- */
1748#define DVNM(name) .driver_info = (kernel_ulong_t) name
1749static const __devinitdata struct usb_device_id device_table[] = { 1645static const __devinitdata struct usb_device_id device_table[] = {
1750 {USB_DEVICE(0x0130, 0x0130), DVNM("Clone Digital Webcam 11043")}, 1646 {USB_DEVICE(0x0130, 0x0130), .driver_info = HamaUSBSightcam},
1751 {USB_DEVICE(0x041e, 0x4018), DVNM("Creative Webcam Vista (PD1100)")}, 1647 {USB_DEVICE(0x041e, 0x4018), .driver_info = CreativeVista},
1752 {USB_DEVICE(0x0461, 0x0815), DVNM("Micro Innovation IC200")}, 1648 {USB_DEVICE(0x0461, 0x0815), .driver_info = MicroInnovationIC200},
1753 {USB_DEVICE(0x0733, 0x0110), DVNM("ViewQuest VQ110")}, 1649 {USB_DEVICE(0x0733, 0x0110), .driver_info = ViewQuestVQ110},
1754 {USB_DEVICE(0x0af9, 0x0010), DVNM("Hama USB Sightcam 100")}, 1650 {USB_DEVICE(0x0af9, 0x0010), .driver_info = HamaUSBSightcam},
1755 {USB_DEVICE(0x0af9, 0x0011), DVNM("Hama USB Sightcam 100")}, 1651 {USB_DEVICE(0x0af9, 0x0011), .driver_info = HamaUSBSightcam2},
1756 {USB_DEVICE(0x8086, 0x0110), DVNM("Intel Easy PC Camera")}, 1652 {USB_DEVICE(0x8086, 0x0110), .driver_info = IntelEasyPCCamera},
1757 {} 1653 {}
1758}; 1654};
1759MODULE_DEVICE_TABLE(usb, device_table); 1655MODULE_DEVICE_TABLE(usb, device_table);
@@ -1778,7 +1674,7 @@ static int __init sd_mod_init(void)
1778{ 1674{
1779 if (usb_register(&sd_driver) < 0) 1675 if (usb_register(&sd_driver) < 0)
1780 return -1; 1676 return -1;
1781 PDEBUG(D_PROBE, "v%s registered", version); 1677 PDEBUG(D_PROBE, "registered");
1782 return 0; 1678 return 0;
1783} 1679}
1784static void __exit sd_mod_exit(void) 1680static void __exit sd_mod_exit(void)