2 * SPCA505 chip based cameras initialization data
4 * V4L2 by Jean-Francis Moine <http://moinejf.free.fr>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #define MODULE_NAME "spca505"
26 MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
27 MODULE_DESCRIPTION("GSPCA/SPCA505 USB Camera Driver");
28 MODULE_LICENSE("GPL");
30 /* specific webcam descriptor */
32 struct gspca_dev gspca_dev; /* !! must be the first item */
35 unsigned char tmpbuf[640 * 480 * 3 / 2]; /* YYUV per line */
36 unsigned char tmpbuf2[640 * 480 * 2]; /* YUYV */
38 unsigned char brightness;
41 #define IntelPCCameraPro 0
45 /* V4L2 controls supported by the driver */
46 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val);
47 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val);
49 static struct ctrl sd_ctrls[] = {
50 #define SD_BRIGHTNESS 0
53 .id = V4L2_CID_BRIGHTNESS,
54 .type = V4L2_CTRL_TYPE_INTEGER,
61 .set = sd_setbrightness,
62 .get = sd_getbrightness,
66 static struct v4l2_pix_format vga_mode[] = {
67 {160, 120, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
68 .bytesperline = 160 * 2,
69 .sizeimage = 160 * 120 * 2,
70 .colorspace = V4L2_COLORSPACE_SRGB,
72 {176, 144, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
73 .bytesperline = 176 * 2,
74 .sizeimage = 176 * 144 * 2,
75 .colorspace = V4L2_COLORSPACE_SRGB,
77 {320, 240, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
78 .bytesperline = 320 * 2,
79 .sizeimage = 320 * 240 * 2,
80 .colorspace = V4L2_COLORSPACE_SRGB,
82 {352, 288, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
83 .bytesperline = 352 * 2,
84 .sizeimage = 352 * 288 * 2,
85 .colorspace = V4L2_COLORSPACE_SRGB,
87 {640, 480, V4L2_PIX_FMT_YUYV, V4L2_FIELD_NONE,
88 .bytesperline = 640 * 2,
89 .sizeimage = 640 * 480 * 2,
90 .colorspace = V4L2_COLORSPACE_SRGB,
94 #define SPCA50X_OFFSET_DATA 10
96 #define SPCA50X_REG_USB 0x02 /* spca505 501 */
98 #define SPCA50X_USB_CTRL 0x00 /* spca505 */
99 #define SPCA50X_CUSB_ENABLE 0x01 /* spca505 */
100 #define SPCA50X_REG_GLOBAL 0x03 /* spca505 */
101 #define SPCA50X_GMISC0_IDSEL 0x01 /* Global control device ID select spca505 */
102 #define SPCA50X_GLOBAL_MISC0 0x00 /* Global control miscellaneous 0 spca505 */
104 #define SPCA50X_GLOBAL_MISC1 0x01 /* 505 */
105 #define SPCA50X_GLOBAL_MISC3 0x03 /* 505 */
106 #define SPCA50X_GMISC3_SAA7113RST 0x20 /* Not sure about this one spca505 */
109 * Data to initialize a SPCA505. Common to the CCD and external modes
111 static const __u16 spca505_init_data[][3] = {
112 /* line bmRequest,value,index */
114 {SPCA50X_REG_GLOBAL, SPCA50X_GMISC3_SAA7113RST, SPCA50X_GLOBAL_MISC3},
116 /* 1822 */ {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC3},
117 /* 1825 */ {SPCA50X_REG_GLOBAL, 0x00, SPCA50X_GLOBAL_MISC1},
118 /* Block USB reset */
119 /* 1828 */ {SPCA50X_REG_GLOBAL, SPCA50X_GMISC0_IDSEL,
120 SPCA50X_GLOBAL_MISC0},
122 /* 1831 */ {0x5, 0x01, 0x10},
123 /* Maybe power down some stuff */
124 /* 1834 */ {0x5, 0x0f, 0x11},
126 /* Setup internal CCD ? */
127 /* 1837 */ {0x6, 0x10, 0x08},
128 /* 1840 */ {0x6, 0x00, 0x09},
129 /* 1843 */ {0x6, 0x00, 0x0a},
130 /* 1846 */ {0x6, 0x00, 0x0b},
131 /* 1849 */ {0x6, 0x10, 0x0c},
132 /* 1852 */ {0x6, 0x00, 0x0d},
133 /* 1855 */ {0x6, 0x00, 0x0e},
134 /* 1858 */ {0x6, 0x00, 0x0f},
135 /* 1861 */ {0x6, 0x10, 0x10},
136 /* 1864 */ {0x6, 0x02, 0x11},
137 /* 1867 */ {0x6, 0x00, 0x12},
138 /* 1870 */ {0x6, 0x04, 0x13},
139 /* 1873 */ {0x6, 0x02, 0x14},
140 /* 1876 */ {0x6, 0x8a, 0x51},
141 /* 1879 */ {0x6, 0x40, 0x52},
142 /* 1882 */ {0x6, 0xb6, 0x53},
143 /* 1885 */ {0x6, 0x3d, 0x54},
148 * Data to initialize the camera using the internal CCD
150 static const __u16 spca505_open_data_ccd[][3] = {
151 /* line bmRequest,value,index */
152 /* Internal CCD data set */
153 /* 1891 */ {0x3, 0x04, 0x01},
154 /* This could be a reset */
155 /* 1894 */ {0x3, 0x00, 0x01},
157 /* Setup compression and image registers. 0x6 and 0x7 seem to be
158 related to H&V hold, and are resolution mode specific */
159 /* 1897 */ {0x4, 0x10, 0x01},
160 /* DIFF(0x50), was (0x10) */
161 /* 1900 */ {0x4, 0x00, 0x04},
162 /* 1903 */ {0x4, 0x00, 0x05},
163 /* 1906 */ {0x4, 0x20, 0x06},
164 /* 1909 */ {0x4, 0x20, 0x07},
166 /* 1912 */ {0x8, 0x0a, 0x00},
167 /* DIFF (0x4a), was (0xa) */
169 /* 1915 */ {0x5, 0x00, 0x10},
170 /* 1918 */ {0x5, 0x00, 0x11},
171 /* 1921 */ {0x5, 0x00, 0x00},
172 /* DIFF not written */
173 /* 1924 */ {0x5, 0x00, 0x01},
174 /* DIFF not written */
175 /* 1927 */ {0x5, 0x00, 0x02},
176 /* DIFF not written */
177 /* 1930 */ {0x5, 0x00, 0x03},
178 /* DIFF not written */
179 /* 1933 */ {0x5, 0x00, 0x04},
180 /* DIFF not written */
181 /* 1936 */ {0x5, 0x80, 0x05},
182 /* DIFF not written */
183 /* 1939 */ {0x5, 0xe0, 0x06},
184 /* DIFF not written */
185 /* 1942 */ {0x5, 0x20, 0x07},
186 /* DIFF not written */
187 /* 1945 */ {0x5, 0xa0, 0x08},
188 /* DIFF not written */
189 /* 1948 */ {0x5, 0x0, 0x12},
190 /* DIFF not written */
191 /* 1951 */ {0x5, 0x02, 0x0f},
192 /* DIFF not written */
193 /* 1954 */ {0x5, 0x10, 0x46},
194 /* DIFF not written */
195 /* 1957 */ {0x5, 0x8, 0x4a},
196 /* DIFF not written */
198 /* 1960 */ {0x3, 0x08, 0x03},
199 /* DIFF (0x3,0x28,0x3) */
200 /* 1963 */ {0x3, 0x08, 0x01},
201 /* 1966 */ {0x3, 0x0c, 0x03},
202 /* DIFF not written */
203 /* 1969 */ {0x3, 0x21, 0x00},
206 /* Extra block copied from init to hopefully ensure CCD is in a sane state */
207 /* 1837 */ {0x6, 0x10, 0x08},
208 /* 1840 */ {0x6, 0x00, 0x09},
209 /* 1843 */ {0x6, 0x00, 0x0a},
210 /* 1846 */ {0x6, 0x00, 0x0b},
211 /* 1849 */ {0x6, 0x10, 0x0c},
212 /* 1852 */ {0x6, 0x00, 0x0d},
213 /* 1855 */ {0x6, 0x00, 0x0e},
214 /* 1858 */ {0x6, 0x00, 0x0f},
215 /* 1861 */ {0x6, 0x10, 0x10},
216 /* 1864 */ {0x6, 0x02, 0x11},
217 /* 1867 */ {0x6, 0x00, 0x12},
218 /* 1870 */ {0x6, 0x04, 0x13},
219 /* 1873 */ {0x6, 0x02, 0x14},
220 /* 1876 */ {0x6, 0x8a, 0x51},
221 /* 1879 */ {0x6, 0x40, 0x52},
222 /* 1882 */ {0x6, 0xb6, 0x53},
223 /* 1885 */ {0x6, 0x3d, 0x54},
224 /* End of extra block */
226 /* 1972 */ {0x6, 0x3f, 0x1},
228 /* 1975 */ {0x6, 0x10, 0x02},
229 /* 1978 */ {0x6, 0x64, 0x07},
230 /* 1981 */ {0x6, 0x10, 0x08},
231 /* 1984 */ {0x6, 0x00, 0x09},
232 /* 1987 */ {0x6, 0x00, 0x0a},
233 /* 1990 */ {0x6, 0x00, 0x0b},
234 /* 1993 */ {0x6, 0x10, 0x0c},
235 /* 1996 */ {0x6, 0x00, 0x0d},
236 /* 1999 */ {0x6, 0x00, 0x0e},
237 /* 2002 */ {0x6, 0x00, 0x0f},
238 /* 2005 */ {0x6, 0x10, 0x10},
239 /* 2008 */ {0x6, 0x02, 0x11},
240 /* 2011 */ {0x6, 0x00, 0x12},
241 /* 2014 */ {0x6, 0x04, 0x13},
242 /* 2017 */ {0x6, 0x02, 0x14},
243 /* 2020 */ {0x6, 0x8a, 0x51},
244 /* 2023 */ {0x6, 0x40, 0x52},
245 /* 2026 */ {0x6, 0xb6, 0x53},
246 /* 2029 */ {0x6, 0x3d, 0x54},
247 /* 2032 */ {0x6, 0x60, 0x57},
248 /* 2035 */ {0x6, 0x20, 0x58},
249 /* 2038 */ {0x6, 0x15, 0x59},
250 /* 2041 */ {0x6, 0x05, 0x5a},
252 /* 2044 */ {0x5, 0x01, 0xc0},
253 /* 2047 */ {0x5, 0x10, 0xcb},
254 /* 2050 */ {0x5, 0x80, 0xc1},
256 /* 2053 */ {0x5, 0x0, 0xc2},
258 /* 2056 */ {0x5, 0x00, 0xca},
259 /* 2059 */ {0x5, 0x80, 0xc1},
261 /* 2062 */ {0x5, 0x04, 0xc2},
262 /* 2065 */ {0x5, 0x00, 0xca},
263 /* 2068 */ {0x5, 0x0, 0xc1},
265 /* 2071 */ {0x5, 0x00, 0xc2},
266 /* 2074 */ {0x5, 0x00, 0xca},
267 /* 2077 */ {0x5, 0x40, 0xc1},
269 /* 2080 */ {0x5, 0x17, 0xc2},
270 /* 2083 */ {0x5, 0x00, 0xca},
271 /* 2086 */ {0x5, 0x80, 0xc1},
273 /* 2089 */ {0x5, 0x06, 0xc2},
274 /* 2092 */ {0x5, 0x00, 0xca},
275 /* 2095 */ {0x5, 0x80, 0xc1},
277 /* 2098 */ {0x5, 0x04, 0xc2},
278 /* 2101 */ {0x5, 0x00, 0xca},
280 /* 2104 */ {0x3, 0x4c, 0x3},
281 /* 2107 */ {0x3, 0x18, 0x1},
283 /* 2110 */ {0x6, 0x70, 0x51},
284 /* 2113 */ {0x6, 0xbe, 0x53},
285 /* 2116 */ {0x6, 0x71, 0x57},
286 /* 2119 */ {0x6, 0x20, 0x58},
287 /* 2122 */ {0x6, 0x05, 0x59},
288 /* 2125 */ {0x6, 0x15, 0x5a},
290 /* 2128 */ {0x4, 0x00, 0x08},
291 /* Compress = OFF (0x1 to turn on) */
292 /* 2131 */ {0x4, 0x12, 0x09},
293 /* 2134 */ {0x4, 0x21, 0x0a},
294 /* 2137 */ {0x4, 0x10, 0x0b},
295 /* 2140 */ {0x4, 0x21, 0x0c},
296 /* 2143 */ {0x4, 0x05, 0x00},
297 /* was 5 (Image Type ? ) */
298 /* 2146 */ {0x4, 0x00, 0x01},
300 /* 2149 */ {0x6, 0x3f, 0x01},
302 /* 2152 */ {0x4, 0x00, 0x04},
303 /* 2155 */ {0x4, 0x00, 0x05},
304 /* 2158 */ {0x4, 0x40, 0x06},
305 /* 2161 */ {0x4, 0x40, 0x07},
307 /* 2164 */ {0x6, 0x1c, 0x17},
308 /* 2167 */ {0x6, 0xe2, 0x19},
309 /* 2170 */ {0x6, 0x1c, 0x1b},
310 /* 2173 */ {0x6, 0xe2, 0x1d},
311 /* 2176 */ {0x6, 0xaa, 0x1f},
312 /* 2179 */ {0x6, 0x70, 0x20},
314 /* 2182 */ {0x5, 0x01, 0x10},
315 /* 2185 */ {0x5, 0x00, 0x11},
316 /* 2188 */ {0x5, 0x01, 0x00},
317 /* 2191 */ {0x5, 0x05, 0x01},
318 /* 2194 */ {0x5, 0x00, 0xc1},
320 /* 2197 */ {0x5, 0x00, 0xc2},
321 /* 2200 */ {0x5, 0x00, 0xca},
323 /* 2203 */ {0x6, 0x70, 0x51},
324 /* 2206 */ {0x6, 0xbe, 0x53},
329 Made by Tomasz Zablocki (skalamandra@poczta.onet.pl)
330 * SPCA505b chip based cameras initialization data
334 #define initial_brightness 0x7f /* 0x0(white)-0xff(black) */
335 /* #define initial_brightness 0x0 //0x0(white)-0xff(black) */
337 * Data to initialize a SPCA505. Common to the CCD and external modes
339 static const __u16 spca505b_init_data[][3] = {
341 {0x02, 0x00, 0x00}, /* init */
401 * Data to initialize the camera using the internal CCD
403 static const __u16 spca505b_open_data_ccd[][3] = {
405 /* {0x02,0x00,0x00}, */
406 {0x03, 0x04, 0x01}, /* rst */
432 {0x05, initial_brightness >> 6, 0x00},
433 {0x05, initial_brightness << 2, 0x01},
443 {0x05, 128, 0x14}, /* max exposure off (0=on) */
462 {0x06, 0x11, 0x10}, /* contrast */
527 {0x06, 0x4d, 0x51}, /* maybe saturation (4d) */
528 {0x06, 0x84, 0x53}, /* making green (84) */
529 {0x06, 0x00, 0x57}, /* sharpness (1) */
534 {0x06, 0x18, 0x0c}, /* maybe hue (18) */
538 {0x06, 0x18, 0x10}, /* maybe contrast (18) */
542 {0x04, 0x00, 0x08}, /* compression */
547 {0x04, 0x1d, 0x00}, /* imagetype (1d) */
548 {0x04, 0x41, 0x01}, /* hardware snapcontrol */
566 {0x05, initial_brightness >> 6, 0x00},
567 {0x05, initial_brightness << 2, 0x01},
575 static int reg_write(struct usb_device *dev,
576 __u16 reg, __u16 index, __u16 value)
580 ret = usb_control_msg(dev,
581 usb_sndctrlpipe(dev, 0),
583 USB_TYPE_VENDOR | USB_RECIP_DEVICE,
584 value, index, NULL, 0, 500);
585 PDEBUG(D_PACK, "reg write: 0x%02x,0x%02x:0x%02x, 0x%x",
586 reg, index, value, ret);
588 PDEBUG(D_ERR, "reg write: error %d", ret);
592 /* returns: negative is error, pos or zero is data */
593 static int reg_read(struct gspca_dev *gspca_dev,
594 __u16 reg, /* bRequest */
595 __u16 index, /* wIndex */
596 __u16 length) /* wLength (1 or 2 only) */
600 gspca_dev->usb_buf[1] = 0;
601 ret = usb_control_msg(gspca_dev->dev,
602 usb_rcvctrlpipe(gspca_dev->dev, 0),
604 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
605 (__u16) 0, /* value */
607 gspca_dev->usb_buf, length,
610 PDEBUG(D_ERR, "reg_read err %d", ret);
613 return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0];
616 static int write_vector(struct gspca_dev *gspca_dev,
617 const __u16 data[][3])
619 struct usb_device *dev = gspca_dev->dev;
622 while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) {
623 ret = reg_write(dev, data[i][0], data[i][2], data[i][1]);
626 "Register write failed for 0x%x,0x%x,0x%x",
627 data[i][0], data[i][1], data[i][2]);
635 /* this function is called at probe time */
636 static int sd_config(struct gspca_dev *gspca_dev,
637 const struct usb_device_id *id)
639 struct sd *sd = (struct sd *) gspca_dev;
644 vendor = id->idVendor;
645 product = id->idProduct;
647 case 0x041e: /* Creative cameras */
648 /* switch (product) { */
649 /* case 0x401d: * here505b */
650 sd->subtype = Nxultra;
654 case 0x0733: /* Rebadged ViewQuest (Intel) and ViewQuest cameras */
655 /* switch (product) { */
657 /* fixme: may be UsbGrabberPV321 BRIDGE_SPCA506 SENSOR_SAA7113 */
658 sd->subtype = IntelPCCameraPro;
664 cam = &gspca_dev->cam;
665 cam->dev_name = (char *) id->driver_info;
667 cam->cam_mode = vga_mode;
668 if (sd->subtype != IntelPCCameraPro)
669 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0];
670 else /* no 640x480 for IntelPCCameraPro */
671 cam->nmodes = sizeof vga_mode / sizeof vga_mode[0] - 1;
672 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
674 if (sd->subtype == Nxultra) {
675 if (write_vector(gspca_dev, spca505b_init_data))
678 if (write_vector(gspca_dev, spca505_init_data))
684 /* this function is called at open time */
685 static int sd_open(struct gspca_dev *gspca_dev)
687 struct sd *sd = (struct sd *) gspca_dev;
690 PDEBUG(D_STREAM, "Initializing SPCA505");
691 if (sd->subtype == Nxultra)
692 write_vector(gspca_dev, spca505b_open_data_ccd);
694 write_vector(gspca_dev, spca505_open_data_ccd);
695 ret = reg_read(gspca_dev, 6, 0x16, 2);
698 PDEBUG(D_ERR|D_STREAM,
699 "register read failed for after vector read err = %d",
704 "After vector read returns : 0x%x should be 0x0101",
707 ret = reg_write(gspca_dev->dev, 6, 0x16, 0x0a);
709 PDEBUG(D_ERR, "register write failed for (6,0xa,0x16) err=%d",
713 reg_write(gspca_dev->dev, 5, 0xc2, 18);
717 static void sd_start(struct gspca_dev *gspca_dev)
719 struct usb_device *dev = gspca_dev->dev;
722 /* necessary because without it we can see stream
723 * only once after loading module */
724 /* stopping usb registers Tomasz change */
725 reg_write(dev, 0x02, 0x0, 0x0);
726 switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {
728 reg_write(dev, 0x04, 0x00, 0x00);
729 reg_write(dev, 0x04, 0x06, 0x10);
730 reg_write(dev, 0x04, 0x07, 0x10);
733 reg_write(dev, 0x04, 0x00, 0x01);
734 reg_write(dev, 0x04, 0x06, 0x1a);
735 reg_write(dev, 0x04, 0x07, 0x1a);
738 reg_write(dev, 0x04, 0x00, 0x02);
739 reg_write(dev, 0x04, 0x06, 0x1c);
740 reg_write(dev, 0x04, 0x07, 0x1d);
743 reg_write(dev, 0x04, 0x00, 0x04);
744 reg_write(dev, 0x04, 0x06, 0x34);
745 reg_write(dev, 0x04, 0x07, 0x34);
749 reg_write(dev, 0x04, 0x00, 0x05);
750 reg_write(dev, 0x04, 0x06, 0x40);
751 reg_write(dev, 0x04, 0x07, 0x40);
754 /* Enable ISO packet machine - should we do this here or in ISOC init ? */
755 ret = reg_write(dev, SPCA50X_REG_USB,
757 SPCA50X_CUSB_ENABLE);
759 /* reg_write(dev, 0x5, 0x0, 0x0); */
760 /* reg_write(dev, 0x5, 0x0, 0x1); */
761 /* reg_write(dev, 0x5, 0x11, 0x2); */
764 static void sd_stopN(struct gspca_dev *gspca_dev)
766 /* Disable ISO packet machine */
767 reg_write(gspca_dev->dev, 0x02, 0x00, 0x00);
770 static void sd_stop0(struct gspca_dev *gspca_dev)
774 /* this function is called at close time */
775 static void sd_close(struct gspca_dev *gspca_dev)
777 /* This maybe reset or power control */
778 reg_write(gspca_dev->dev, 0x03, 0x03, 0x20);
779 reg_write(gspca_dev->dev, 0x03, 0x01, 0x0);
780 reg_write(gspca_dev->dev, 0x03, 0x00, 0x1);
781 reg_write(gspca_dev->dev, 0x05, 0x10, 0x1);
782 reg_write(gspca_dev->dev, 0x05, 0x11, 0xf);
785 /* convert YYUV per line to YUYV (YUV 4:2:2) */
786 static void yyuv_decode(unsigned char *out,
791 unsigned char *Ui, *Vi, *yi, *yi1;
796 for (i = height / 2; --i >= 0; ) {
797 out1 = out + width * 2; /* next line */
801 for (j = width / 2; --j >= 0; ) {
802 *out++ = 128 + *yi++;
804 *out++ = 128 + *yi++;
807 *out1++ = 128 + *yi1++;
808 *out1++ = 128 + *Ui++;
809 *out1++ = 128 + *yi1++;
810 *out1++ = 128 + *Vi++;
817 static void sd_pkt_scan(struct gspca_dev *gspca_dev,
818 struct gspca_frame *frame, /* target */
819 __u8 *data, /* isoc packet */
820 int len) /* iso packet length */
822 struct sd *sd = (struct sd *) gspca_dev;
825 case 0: /* start of frame */
826 if (gspca_dev->last_packet_type == FIRST_PACKET) {
827 yyuv_decode(sd->tmpbuf2, sd->tmpbuf,
830 frame = gspca_frame_add(gspca_dev,
838 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
840 data += SPCA50X_OFFSET_DATA;
841 len -= SPCA50X_OFFSET_DATA;
843 memcpy(sd->tmpbuf, data, len);
848 case 0xff: /* drop */
849 /* gspca_dev->last_packet_type = DISCARD_PACKET; */
854 memcpy(&sd->tmpbuf[sd->buflen], data, len);
858 static void setbrightness(struct gspca_dev *gspca_dev)
860 struct sd *sd = (struct sd *) gspca_dev;
862 __u8 brightness = sd->brightness;
863 reg_write(gspca_dev->dev, 5, 0x00, (255 - brightness) >> 6);
864 reg_write(gspca_dev->dev, 5, 0x01, (255 - brightness) << 2);
867 static void getbrightness(struct gspca_dev *gspca_dev)
869 struct sd *sd = (struct sd *) gspca_dev;
872 - ((reg_read(gspca_dev, 5, 0x01, 1) >> 2)
873 + (reg_read(gspca_dev, 5, 0x0, 1) << 6));
876 static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
878 struct sd *sd = (struct sd *) gspca_dev;
880 sd->brightness = val;
881 if (gspca_dev->streaming)
882 setbrightness(gspca_dev);
886 static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val)
888 struct sd *sd = (struct sd *) gspca_dev;
890 getbrightness(gspca_dev);
891 *val = sd->brightness;
895 /* sub-driver description */
896 static const struct sd_desc sd_desc = {
899 .nctrls = ARRAY_SIZE(sd_ctrls),
906 .pkt_scan = sd_pkt_scan,
909 /* -- module initialisation -- */
910 #define DVNM(name) .driver_info = (kernel_ulong_t) name
911 static const __devinitdata struct usb_device_id device_table[] = {
912 {USB_DEVICE(0x041e, 0x401d), DVNM("Creative Webcam NX ULTRA")},
913 {USB_DEVICE(0x0733, 0x0430), DVNM("Intel PC Camera Pro")},
916 MODULE_DEVICE_TABLE(usb, device_table);
918 /* -- device connect -- */
919 static int sd_probe(struct usb_interface *intf,
920 const struct usb_device_id *id)
922 return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
926 static struct usb_driver sd_driver = {
928 .id_table = device_table,
930 .disconnect = gspca_disconnect,
933 /* -- module insert / remove -- */
934 static int __init sd_mod_init(void)
936 if (usb_register(&sd_driver) < 0)
938 PDEBUG(D_PROBE, "registered");
941 static void __exit sd_mod_exit(void)
943 usb_deregister(&sd_driver);
944 PDEBUG(D_PROBE, "deregistered");
947 module_init(sd_mod_init);
948 module_exit(sd_mod_exit);