aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sunplus.c
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2009-08-31 05:15:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-12 11:20:07 -0400
commit2e1794b51b3917d09412a118711ef994ea72a403 (patch)
tree69d021b897a06e2ac177d2ca324563d021a22d34 /drivers/media/video/gspca/sunplus.c
parent1f78a976ce18bc98e8b509cee04c5b3756098614 (diff)
V4L/DVB (12692): gspca - sunplus: Optimize code.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sunplus.c')
-rw-r--r--drivers/media/video/gspca/sunplus.c372
1 files changed, 165 insertions, 207 deletions
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index e9481fa77749..ffbe3f625ddb 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -32,22 +32,22 @@ MODULE_LICENSE("GPL");
32struct sd { 32struct sd {
33 struct gspca_dev gspca_dev; /* !! must be the first item */ 33 struct gspca_dev gspca_dev; /* !! must be the first item */
34 34
35 unsigned char brightness; 35 u8 brightness;
36 unsigned char contrast; 36 u8 contrast;
37 unsigned char colors; 37 u8 colors;
38 unsigned char autogain; 38 u8 autogain;
39 u8 quality; 39 u8 quality;
40#define QUALITY_MIN 70 40#define QUALITY_MIN 70
41#define QUALITY_MAX 95 41#define QUALITY_MAX 95
42#define QUALITY_DEF 85 42#define QUALITY_DEF 85
43 43
44 char bridge; 44 u8 bridge;
45#define BRIDGE_SPCA504 0 45#define BRIDGE_SPCA504 0
46#define BRIDGE_SPCA504B 1 46#define BRIDGE_SPCA504B 1
47#define BRIDGE_SPCA504C 2 47#define BRIDGE_SPCA504C 2
48#define BRIDGE_SPCA533 3 48#define BRIDGE_SPCA533 3
49#define BRIDGE_SPCA536 4 49#define BRIDGE_SPCA536 4
50 char subtype; 50 u8 subtype;
51#define AiptekMiniPenCam13 1 51#define AiptekMiniPenCam13 1
52#define LogitechClickSmart420 2 52#define LogitechClickSmart420 2
53#define LogitechClickSmart820 3 53#define LogitechClickSmart820 3
@@ -68,7 +68,6 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val);
68static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); 68static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val);
69 69
70static struct ctrl sd_ctrls[] = { 70static struct ctrl sd_ctrls[] = {
71#define SD_BRIGHTNESS 0
72 { 71 {
73 { 72 {
74 .id = V4L2_CID_BRIGHTNESS, 73 .id = V4L2_CID_BRIGHTNESS,
@@ -77,12 +76,12 @@ static struct ctrl sd_ctrls[] = {
77 .minimum = 0, 76 .minimum = 0,
78 .maximum = 0xff, 77 .maximum = 0xff,
79 .step = 1, 78 .step = 1,
80 .default_value = 0, 79#define BRIGHTNESS_DEF 0
80 .default_value = BRIGHTNESS_DEF,
81 }, 81 },
82 .set = sd_setbrightness, 82 .set = sd_setbrightness,
83 .get = sd_getbrightness, 83 .get = sd_getbrightness,
84 }, 84 },
85#define SD_CONTRAST 1
86 { 85 {
87 { 86 {
88 .id = V4L2_CID_CONTRAST, 87 .id = V4L2_CID_CONTRAST,
@@ -91,12 +90,12 @@ static struct ctrl sd_ctrls[] = {
91 .minimum = 0, 90 .minimum = 0,
92 .maximum = 0xff, 91 .maximum = 0xff,
93 .step = 1, 92 .step = 1,
94 .default_value = 0x20, 93#define CONTRAST_DEF 0x20
94 .default_value = CONTRAST_DEF,
95 }, 95 },
96 .set = sd_setcontrast, 96 .set = sd_setcontrast,
97 .get = sd_getcontrast, 97 .get = sd_getcontrast,
98 }, 98 },
99#define SD_COLOR 2
100 { 99 {
101 { 100 {
102 .id = V4L2_CID_SATURATION, 101 .id = V4L2_CID_SATURATION,
@@ -105,12 +104,12 @@ static struct ctrl sd_ctrls[] = {
105 .minimum = 0, 104 .minimum = 0,
106 .maximum = 0xff, 105 .maximum = 0xff,
107 .step = 1, 106 .step = 1,
108 .default_value = 0x1a, 107#define COLOR_DEF 0x1a
108 .default_value = COLOR_DEF,
109 }, 109 },
110 .set = sd_setcolors, 110 .set = sd_setcolors,
111 .get = sd_getcolors, 111 .get = sd_getcolors,
112 }, 112 },
113#define SD_AUTOGAIN 3
114 { 113 {
115 { 114 {
116 .id = V4L2_CID_AUTOGAIN, 115 .id = V4L2_CID_AUTOGAIN,
@@ -119,7 +118,8 @@ static struct ctrl sd_ctrls[] = {
119 .minimum = 0, 118 .minimum = 0,
120 .maximum = 1, 119 .maximum = 1,
121 .step = 1, 120 .step = 1,
122 .default_value = 1, 121#define AUTOGAIN_DEF 1
122 .default_value = AUTOGAIN_DEF,
123 }, 123 },
124 .set = sd_setautogain, 124 .set = sd_setautogain,
125 .get = sd_getautogain, 125 .get = sd_getautogain,
@@ -181,14 +181,20 @@ static const struct v4l2_pix_format vga_mode2[] = {
181#define SPCA504_PCCAM600_OFFSET_MODE 5 181#define SPCA504_PCCAM600_OFFSET_MODE 5
182#define SPCA504_PCCAM600_OFFSET_DATA 14 182#define SPCA504_PCCAM600_OFFSET_DATA 14
183 /* Frame packet header offsets for the spca533 */ 183 /* Frame packet header offsets for the spca533 */
184#define SPCA533_OFFSET_DATA 16 184#define SPCA533_OFFSET_DATA 16
185#define SPCA533_OFFSET_FRAMSEQ 15 185#define SPCA533_OFFSET_FRAMSEQ 15
186/* Frame packet header offsets for the spca536 */ 186/* Frame packet header offsets for the spca536 */
187#define SPCA536_OFFSET_DATA 4 187#define SPCA536_OFFSET_DATA 4
188#define SPCA536_OFFSET_FRAMSEQ 1 188#define SPCA536_OFFSET_FRAMSEQ 1
189
190struct cmd {
191 u8 req;
192 u16 val;
193 u16 idx;
194};
189 195
190/* Initialisation data for the Creative PC-CAM 600 */ 196/* Initialisation data for the Creative PC-CAM 600 */
191static const __u16 spca504_pccam600_init_data[][3] = { 197static const struct cmd spca504_pccam600_init_data[] = {
192/* {0xa0, 0x0000, 0x0503}, * capture mode */ 198/* {0xa0, 0x0000, 0x0503}, * capture mode */
193 {0x00, 0x0000, 0x2000}, 199 {0x00, 0x0000, 0x2000},
194 {0x00, 0x0013, 0x2301}, 200 {0x00, 0x0013, 0x2301},
@@ -212,22 +218,20 @@ static const __u16 spca504_pccam600_init_data[][3] = {
212 {0x00, 0x0003, 0x2000}, 218 {0x00, 0x0003, 0x2000},
213 {0x00, 0x0013, 0x2301}, 219 {0x00, 0x0013, 0x2301},
214 {0x00, 0x0003, 0x2000}, 220 {0x00, 0x0003, 0x2000},
215 {}
216}; 221};
217 222
218/* Creative PC-CAM 600 specific open data, sent before using the 223/* Creative PC-CAM 600 specific open data, sent before using the
219 * generic initialisation data from spca504_open_data. 224 * generic initialisation data from spca504_open_data.
220 */ 225 */
221static const __u16 spca504_pccam600_open_data[][3] = { 226static const struct cmd spca504_pccam600_open_data[] = {
222 {0x00, 0x0001, 0x2501}, 227 {0x00, 0x0001, 0x2501},
223 {0x20, 0x0500, 0x0001}, /* snapshot mode */ 228 {0x20, 0x0500, 0x0001}, /* snapshot mode */
224 {0x00, 0x0003, 0x2880}, 229 {0x00, 0x0003, 0x2880},
225 {0x00, 0x0001, 0x2881}, 230 {0x00, 0x0001, 0x2881},
226 {}
227}; 231};
228 232
229/* Initialisation data for the logitech clicksmart 420 */ 233/* Initialisation data for the logitech clicksmart 420 */
230static const __u16 spca504A_clicksmart420_init_data[][3] = { 234static const struct cmd spca504A_clicksmart420_init_data[] = {
231/* {0xa0, 0x0000, 0x0503}, * capture mode */ 235/* {0xa0, 0x0000, 0x0503}, * capture mode */
232 {0x00, 0x0000, 0x2000}, 236 {0x00, 0x0000, 0x2000},
233 {0x00, 0x0013, 0x2301}, 237 {0x00, 0x0013, 0x2301},
@@ -244,7 +248,7 @@ static const __u16 spca504A_clicksmart420_init_data[][3] = {
244 {0xb0, 0x0001, 0x0000}, 248 {0xb0, 0x0001, 0x0000},
245 249
246 250
247 {0x0a1, 0x0080, 0x0001}, 251 {0xa1, 0x0080, 0x0001},
248 {0x30, 0x0049, 0x0000}, 252 {0x30, 0x0049, 0x0000},
249 {0x30, 0x0060, 0x0005}, 253 {0x30, 0x0060, 0x0005},
250 {0x0c, 0x0004, 0x0000}, 254 {0x0c, 0x0004, 0x0000},
@@ -254,11 +258,10 @@ static const __u16 spca504A_clicksmart420_init_data[][3] = {
254 {0x00, 0x0003, 0x2000}, 258 {0x00, 0x0003, 0x2000},
255 {0x00, 0x0000, 0x2000}, 259 {0x00, 0x0000, 0x2000},
256 260
257 {}
258}; 261};
259 262
260/* clicksmart 420 open data ? */ 263/* clicksmart 420 open data ? */
261static const __u16 spca504A_clicksmart420_open_data[][3] = { 264static const struct cmd spca504A_clicksmart420_open_data[] = {
262 {0x00, 0x0001, 0x2501}, 265 {0x00, 0x0001, 0x2501},
263 {0x20, 0x0502, 0x0000}, 266 {0x20, 0x0502, 0x0000},
264 {0x06, 0x0000, 0x0000}, 267 {0x06, 0x0000, 0x0000},
@@ -402,10 +405,9 @@ static const __u16 spca504A_clicksmart420_open_data[][3] = {
402 {0x00, 0x0028, 0x287f}, 405 {0x00, 0x0028, 0x287f},
403 406
404 {0xa0, 0x0000, 0x0503}, 407 {0xa0, 0x0000, 0x0503},
405 {}
406}; 408};
407 409
408static const __u8 qtable_creative_pccam[2][64] = { 410static const u8 qtable_creative_pccam[2][64] = {
409 { /* Q-table Y-components */ 411 { /* Q-table Y-components */
410 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, 412 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
411 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, 413 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -430,7 +432,7 @@ static const __u8 qtable_creative_pccam[2][64] = {
430 * except for one byte. Possibly a typo? 432 * except for one byte. Possibly a typo?
431 * NWG: 18/05/2003. 433 * NWG: 18/05/2003.
432 */ 434 */
433static const __u8 qtable_spca504_default[2][64] = { 435static const u8 qtable_spca504_default[2][64] = {
434 { /* Q-table Y-components */ 436 { /* Q-table Y-components */
435 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, 437 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12,
436 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, 438 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11,
@@ -454,9 +456,9 @@ static const __u8 qtable_spca504_default[2][64] = {
454 456
455/* read <len> bytes to gspca_dev->usb_buf */ 457/* read <len> bytes to gspca_dev->usb_buf */
456static void reg_r(struct gspca_dev *gspca_dev, 458static void reg_r(struct gspca_dev *gspca_dev,
457 __u16 req, 459 u8 req,
458 __u16 index, 460 u16 index,
459 __u16 len) 461 u16 len)
460{ 462{
461#ifdef GSPCA_DEBUG 463#ifdef GSPCA_DEBUG
462 if (len > USB_BUF_SZ) { 464 if (len > USB_BUF_SZ) {
@@ -474,31 +476,26 @@ static void reg_r(struct gspca_dev *gspca_dev,
474 500); 476 500);
475} 477}
476 478
477/* write <len> bytes from gspca_dev->usb_buf */ 479/* write one byte */
478static void reg_w(struct gspca_dev *gspca_dev, 480static void reg_w_1(struct gspca_dev *gspca_dev,
479 __u16 req, 481 u8 req,
480 __u16 value, 482 u16 value,
481 __u16 index, 483 u16 index,
482 __u16 len) 484 u16 byte)
483{ 485{
484#ifdef GSPCA_DEBUG 486 gspca_dev->usb_buf[0] = byte;
485 if (len > USB_BUF_SZ) {
486 err("reg_w: buffer overflow");
487 return;
488 }
489#endif
490 usb_control_msg(gspca_dev->dev, 487 usb_control_msg(gspca_dev->dev,
491 usb_sndctrlpipe(gspca_dev->dev, 0), 488 usb_sndctrlpipe(gspca_dev->dev, 0),
492 req, 489 req,
493 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 490 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
494 value, index, 491 value, index,
495 len ? gspca_dev->usb_buf : NULL, len, 492 gspca_dev->usb_buf, 1,
496 500); 493 500);
497} 494}
498 495
499/* write req / index / value */ 496/* write req / index / value */
500static int reg_w_riv(struct usb_device *dev, 497static int reg_w_riv(struct usb_device *dev,
501 __u16 req, __u16 index, __u16 value) 498 u8 req, u16 index, u16 value)
502{ 499{
503 int ret; 500 int ret;
504 501
@@ -516,7 +513,7 @@ static int reg_w_riv(struct usb_device *dev,
516 513
517/* read 1 byte */ 514/* read 1 byte */
518static int reg_r_1(struct gspca_dev *gspca_dev, 515static int reg_r_1(struct gspca_dev *gspca_dev,
519 __u16 value) /* wValue */ 516 u16 value) /* wValue */
520{ 517{
521 int ret; 518 int ret;
522 519
@@ -537,9 +534,9 @@ static int reg_r_1(struct gspca_dev *gspca_dev,
537 534
538/* read 1 or 2 bytes - returns < 0 if error */ 535/* read 1 or 2 bytes - returns < 0 if error */
539static int reg_r_12(struct gspca_dev *gspca_dev, 536static int reg_r_12(struct gspca_dev *gspca_dev,
540 __u16 req, /* bRequest */ 537 u8 req, /* bRequest */
541 __u16 index, /* wIndex */ 538 u16 index, /* wIndex */
542 __u16 length) /* wLength (1 or 2 only) */ 539 u16 length) /* wLength (1 or 2 only) */
543{ 540{
544 int ret; 541 int ret;
545 542
@@ -560,43 +557,40 @@ static int reg_r_12(struct gspca_dev *gspca_dev,
560} 557}
561 558
562static int write_vector(struct gspca_dev *gspca_dev, 559static int write_vector(struct gspca_dev *gspca_dev,
563 const __u16 data[][3]) 560 const struct cmd *data, int ncmds)
564{ 561{
565 struct usb_device *dev = gspca_dev->dev; 562 struct usb_device *dev = gspca_dev->dev;
566 int ret, i = 0; 563 int ret;
567 564
568 while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { 565 while (--ncmds >= 0) {
569 ret = reg_w_riv(dev, data[i][0], data[i][2], data[i][1]); 566 ret = reg_w_riv(dev, data->req, data->idx, data->val);
570 if (ret < 0) { 567 if (ret < 0) {
571 PDEBUG(D_ERR, 568 PDEBUG(D_ERR,
572 "Register write failed for 0x%x,0x%x,0x%x", 569 "Register write failed for 0x%02x, 0x%04x, 0x%04x",
573 data[i][0], data[i][1], data[i][2]); 570 data->req, data->val, data->idx);
574 return ret; 571 return ret;
575 } 572 }
576 i++; 573 data++;
577 } 574 }
578 return 0; 575 return 0;
579} 576}
580 577
581static int spca50x_setup_qtable(struct gspca_dev *gspca_dev, 578static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
582 unsigned int request, 579 const u8 qtable[2][64])
583 unsigned int ybase,
584 unsigned int cbase,
585 const __u8 qtable[2][64])
586{ 580{
587 struct usb_device *dev = gspca_dev->dev; 581 struct usb_device *dev = gspca_dev->dev;
588 int i, err; 582 int i, err;
589 583
590 /* loop over y components */ 584 /* loop over y components */
591 for (i = 0; i < 64; i++) { 585 for (i = 0; i < 64; i++) {
592 err = reg_w_riv(dev, request, ybase + i, qtable[0][i]); 586 err = reg_w_riv(dev, 0x00, 0x2800 + i, qtable[0][i]);
593 if (err < 0) 587 if (err < 0)
594 return err; 588 return err;
595 } 589 }
596 590
597 /* loop over c components */ 591 /* loop over c components */
598 for (i = 0; i < 64; i++) { 592 for (i = 0; i < 64; i++) {
599 err = reg_w_riv(dev, request, cbase + i, qtable[1][i]); 593 err = reg_w_riv(dev, 0x00, 0x2840 + i, qtable[1][i]);
600 if (err < 0) 594 if (err < 0)
601 return err; 595 return err;
602 } 596 }
@@ -604,34 +598,34 @@ static int spca50x_setup_qtable(struct gspca_dev *gspca_dev,
604} 598}
605 599
606static void spca504_acknowledged_command(struct gspca_dev *gspca_dev, 600static void spca504_acknowledged_command(struct gspca_dev *gspca_dev,
607 __u16 req, __u16 idx, __u16 val) 601 u8 req, u16 idx, u16 val)
608{ 602{
609 struct usb_device *dev = gspca_dev->dev; 603 struct usb_device *dev = gspca_dev->dev;
610 __u8 notdone; 604 int notdone;
611 605
612 reg_w_riv(dev, req, idx, val); 606 reg_w_riv(dev, req, idx, val);
613 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 607 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
614 reg_w_riv(dev, req, idx, val); 608 reg_w_riv(dev, req, idx, val);
615 609
616 PDEBUG(D_FRAM, "before wait 0x%x", notdone); 610 PDEBUG(D_FRAM, "before wait 0x%04x", notdone);
617 611
618 msleep(200); 612 msleep(200);
619 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 613 notdone = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
620 PDEBUG(D_FRAM, "after wait 0x%x", notdone); 614 PDEBUG(D_FRAM, "after wait 0x%04x", notdone);
621} 615}
622 616
623static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev, 617static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
624 __u16 req, 618 u8 req,
625 __u16 idx, __u16 val, __u8 stat, __u8 count) 619 u16 idx, u16 val, u8 stat, u8 count)
626{ 620{
627 struct usb_device *dev = gspca_dev->dev; 621 struct usb_device *dev = gspca_dev->dev;
628 __u8 status; 622 int status;
629 __u8 endcode; 623 u8 endcode;
630 624
631 reg_w_riv(dev, req, idx, val); 625 reg_w_riv(dev, req, idx, val);
632 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 626 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
633 endcode = stat; 627 endcode = stat;
634 PDEBUG(D_FRAM, "Status 0x%x Need 0x%x", status, stat); 628 PDEBUG(D_FRAM, "Status 0x%x Need 0x%04x", status, stat);
635 if (!count) 629 if (!count)
636 return; 630 return;
637 count = 200; 631 count = 200;
@@ -641,7 +635,7 @@ static void spca504A_acknowledged_command(struct gspca_dev *gspca_dev,
641/* reg_w_riv(dev, req, idx, val); */ 635/* reg_w_riv(dev, req, idx, val); */
642 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1); 636 status = reg_r_12(gspca_dev, 0x01, 0x0001, 1);
643 if (status == endcode) { 637 if (status == endcode) {
644 PDEBUG(D_FRAM, "status 0x%x after wait 0x%x", 638 PDEBUG(D_FRAM, "status 0x%04x after wait %d",
645 status, 200 - count); 639 status, 200 - count);
646 break; 640 break;
647 } 641 }
@@ -668,8 +662,7 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
668 while (--count > 0) { 662 while (--count > 0) {
669 reg_r(gspca_dev, 0x21, 1, 1); 663 reg_r(gspca_dev, 0x21, 1, 1);
670 if (gspca_dev->usb_buf[0] != 0) { 664 if (gspca_dev->usb_buf[0] != 0) {
671 gspca_dev->usb_buf[0] = 0; 665 reg_w_1(gspca_dev, 0x21, 0, 1, 0);
672 reg_w(gspca_dev, 0x21, 0, 1, 1);
673 reg_r(gspca_dev, 0x21, 1, 1); 666 reg_r(gspca_dev, 0x21, 1, 1);
674 spca504B_PollingDataReady(gspca_dev); 667 spca504B_PollingDataReady(gspca_dev);
675 break; 668 break;
@@ -680,7 +673,7 @@ static void spca504B_WaitCmdStatus(struct gspca_dev *gspca_dev)
680 673
681static void spca50x_GetFirmware(struct gspca_dev *gspca_dev) 674static void spca50x_GetFirmware(struct gspca_dev *gspca_dev)
682{ 675{
683 __u8 *data; 676 u8 *data;
684 677
685 data = gspca_dev->usb_buf; 678 data = gspca_dev->usb_buf;
686 reg_r(gspca_dev, 0x20, 0, 5); 679 reg_r(gspca_dev, 0x20, 0, 5);
@@ -694,41 +687,34 @@ static void spca504B_SetSizeType(struct gspca_dev *gspca_dev)
694{ 687{
695 struct sd *sd = (struct sd *) gspca_dev; 688 struct sd *sd = (struct sd *) gspca_dev;
696 struct usb_device *dev = gspca_dev->dev; 689 struct usb_device *dev = gspca_dev->dev;
697 __u8 Size; 690 u8 Size;
698 __u8 Type;
699 int rc; 691 int rc;
700 692
701 Size = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 693 Size = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv;
702 Type = 0;
703 switch (sd->bridge) { 694 switch (sd->bridge) {
704 case BRIDGE_SPCA533: 695 case BRIDGE_SPCA533:
705 reg_w(gspca_dev, 0x31, 0, 0, 0); 696 reg_w_riv(dev, 0x31, 0, 0);
706 spca504B_WaitCmdStatus(gspca_dev); 697 spca504B_WaitCmdStatus(gspca_dev);
707 rc = spca504B_PollingDataReady(gspca_dev); 698 rc = spca504B_PollingDataReady(gspca_dev);
708 spca50x_GetFirmware(gspca_dev); 699 spca50x_GetFirmware(gspca_dev);
709 gspca_dev->usb_buf[0] = 2; /* type */ 700 reg_w_1(gspca_dev, 0x24, 0, 8, 2); /* type */
710 reg_w(gspca_dev, 0x24, 0, 8, 1);
711 reg_r(gspca_dev, 0x24, 8, 1); 701 reg_r(gspca_dev, 0x24, 8, 1);
712 702
713 gspca_dev->usb_buf[0] = Size; 703 reg_w_1(gspca_dev, 0x25, 0, 4, Size);
714 reg_w(gspca_dev, 0x25, 0, 4, 1);
715 reg_r(gspca_dev, 0x25, 4, 1); /* size */ 704 reg_r(gspca_dev, 0x25, 4, 1); /* size */
716 rc = spca504B_PollingDataReady(gspca_dev); 705 rc = spca504B_PollingDataReady(gspca_dev);
717 706
718 /* Init the cam width height with some values get on init ? */ 707 /* Init the cam width height with some values get on init ? */
719 reg_w(gspca_dev, 0x31, 0, 4, 0); 708 reg_w_riv(dev, 0x31, 0, 0x04);
720 spca504B_WaitCmdStatus(gspca_dev); 709 spca504B_WaitCmdStatus(gspca_dev);
721 rc = spca504B_PollingDataReady(gspca_dev); 710 rc = spca504B_PollingDataReady(gspca_dev);
722 break; 711 break;
723 default: 712 default:
724/* case BRIDGE_SPCA504B: */ 713/* case BRIDGE_SPCA504B: */
725/* case BRIDGE_SPCA536: */ 714/* case BRIDGE_SPCA536: */
726 gspca_dev->usb_buf[0] = Size; 715 reg_w_1(gspca_dev, 0x25, 0, 4, Size);
727 reg_w(gspca_dev, 0x25, 0, 4, 1);
728 reg_r(gspca_dev, 0x25, 4, 1); /* size */ 716 reg_r(gspca_dev, 0x25, 4, 1); /* size */
729 Type = 6; 717 reg_w_1(gspca_dev, 0x27, 0, 0, 6);
730 gspca_dev->usb_buf[0] = Type;
731 reg_w(gspca_dev, 0x27, 0, 0, 1);
732 reg_r(gspca_dev, 0x27, 0, 1); /* type */ 718 reg_r(gspca_dev, 0x27, 0, 1); /* type */
733 rc = spca504B_PollingDataReady(gspca_dev); 719 rc = spca504B_PollingDataReady(gspca_dev);
734 break; 720 break;
@@ -768,17 +754,51 @@ static void spca504_wait_status(struct gspca_dev *gspca_dev)
768 754
769static void spca504B_setQtable(struct gspca_dev *gspca_dev) 755static void spca504B_setQtable(struct gspca_dev *gspca_dev)
770{ 756{
771 gspca_dev->usb_buf[0] = 3; 757 reg_w_1(gspca_dev, 0x26, 0, 0, 3);
772 reg_w(gspca_dev, 0x26, 0, 0, 1);
773 reg_r(gspca_dev, 0x26, 0, 1); 758 reg_r(gspca_dev, 0x26, 0, 1);
774 spca504B_PollingDataReady(gspca_dev); 759 spca504B_PollingDataReady(gspca_dev);
775} 760}
776 761
777static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev) 762static void setbrightness(struct gspca_dev *gspca_dev)
763{
764 struct sd *sd = (struct sd *) gspca_dev;
765 struct usb_device *dev = gspca_dev->dev;
766 u16 reg;
767
768 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f0 : 0x21a7;
769 reg_w_riv(dev, 0x00, reg, sd->brightness);
770}
771
772static void setcontrast(struct gspca_dev *gspca_dev)
778{ 773{
779 struct sd *sd = (struct sd *) gspca_dev; 774 struct sd *sd = (struct sd *) gspca_dev;
775 struct usb_device *dev = gspca_dev->dev;
776 u16 reg;
777
778 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f1 : 0x21a8;
779 reg_w_riv(dev, 0x00, reg, sd->contrast);
780}
781
782static void setcolors(struct gspca_dev *gspca_dev)
783{
784 struct sd *sd = (struct sd *) gspca_dev;
785 struct usb_device *dev = gspca_dev->dev;
786 u16 reg;
787
788 reg = sd->bridge == BRIDGE_SPCA536 ? 0x20f6 : 0x21ae;
789 reg_w_riv(dev, 0x00, reg, sd->colors);
790}
791
792static void init_ctl_reg(struct gspca_dev *gspca_dev)
793{
794 struct sd *sd = (struct sd *) gspca_dev;
795 struct usb_device *dev = gspca_dev->dev;
780 int pollreg = 1; 796 int pollreg = 1;
781 797
798 setbrightness(gspca_dev);
799 setcontrast(gspca_dev);
800 setcolors(gspca_dev);
801
782 switch (sd->bridge) { 802 switch (sd->bridge) {
783 case BRIDGE_SPCA504: 803 case BRIDGE_SPCA504:
784 case BRIDGE_SPCA504C: 804 case BRIDGE_SPCA504C:
@@ -787,20 +807,14 @@ static void sp5xx_initContBrigHueRegisters(struct gspca_dev *gspca_dev)
787 default: 807 default:
788/* case BRIDGE_SPCA533: */ 808/* case BRIDGE_SPCA533: */
789/* case BRIDGE_SPCA504B: */ 809/* case BRIDGE_SPCA504B: */
790 reg_w(gspca_dev, 0, 0, 0x21a7, 0); /* brightness */ 810 reg_w_riv(dev, 0, 0x00, 0x21ad); /* hue */
791 reg_w(gspca_dev, 0, 0x20, 0x21a8, 0); /* contrast */ 811 reg_w_riv(dev, 0, 0x01, 0x21ac); /* sat/hue */
792 reg_w(gspca_dev, 0, 0, 0x21ad, 0); /* hue */ 812 reg_w_riv(dev, 0, 0x00, 0x21a3); /* gamma */
793 reg_w(gspca_dev, 0, 1, 0x21ac, 0); /* sat/hue */
794 reg_w(gspca_dev, 0, 0x20, 0x21ae, 0); /* saturation */
795 reg_w(gspca_dev, 0, 0, 0x21a3, 0); /* gamma */
796 break; 813 break;
797 case BRIDGE_SPCA536: 814 case BRIDGE_SPCA536:
798 reg_w(gspca_dev, 0, 0, 0x20f0, 0); 815 reg_w_riv(dev, 0, 0x40, 0x20f5);
799 reg_w(gspca_dev, 0, 0x21, 0x20f1, 0); 816 reg_w_riv(dev, 0, 0x01, 0x20f4);
800 reg_w(gspca_dev, 0, 0x40, 0x20f5, 0); 817 reg_w_riv(dev, 0, 0x00, 0x2089);
801 reg_w(gspca_dev, 0, 1, 0x20f4, 0);
802 reg_w(gspca_dev, 0, 0x40, 0x20f6, 0);
803 reg_w(gspca_dev, 0, 0, 0x2089, 0);
804 break; 818 break;
805 } 819 }
806 if (pollreg) 820 if (pollreg)
@@ -855,9 +869,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
855 cam->nmodes = ARRAY_SIZE(vga_mode2); 869 cam->nmodes = ARRAY_SIZE(vga_mode2);
856 break; 870 break;
857 } 871 }
858 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; 872 sd->brightness = BRIGHTNESS_DEF;
859 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; 873 sd->contrast = CONTRAST_DEF;
860 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; 874 sd->colors = COLOR_DEF;
875 sd->autogain = AUTOGAIN_DEF;
861 sd->quality = QUALITY_DEF; 876 sd->quality = QUALITY_DEF;
862 return 0; 877 return 0;
863} 878}
@@ -867,32 +882,29 @@ static int sd_init(struct gspca_dev *gspca_dev)
867{ 882{
868 struct sd *sd = (struct sd *) gspca_dev; 883 struct sd *sd = (struct sd *) gspca_dev;
869 struct usb_device *dev = gspca_dev->dev; 884 struct usb_device *dev = gspca_dev->dev;
870 int rc; 885 int i, err_code;
871 __u8 i; 886 u8 info[6];
872 __u8 info[6];
873 int err_code;
874 887
875 switch (sd->bridge) { 888 switch (sd->bridge) {
876 case BRIDGE_SPCA504B: 889 case BRIDGE_SPCA504B:
877 reg_w(gspca_dev, 0x1d, 0, 0, 0); 890 reg_w_riv(dev, 0x1d, 0x00, 0);
878 reg_w(gspca_dev, 0, 1, 0x2306, 0); 891 reg_w_riv(dev, 0, 0x01, 0x2306);
879 reg_w(gspca_dev, 0, 0, 0x0d04, 0); 892 reg_w_riv(dev, 0, 0x00, 0x0d04);
880 reg_w(gspca_dev, 0, 0, 0x2000, 0); 893 reg_w_riv(dev, 0, 0x00, 0x2000);
881 reg_w(gspca_dev, 0, 0x13, 0x2301, 0); 894 reg_w_riv(dev, 0, 0x13, 0x2301);
882 reg_w(gspca_dev, 0, 0, 0x2306, 0); 895 reg_w_riv(dev, 0, 0x00, 0x2306);
883 /* fall thru */ 896 /* fall thru */
884 case BRIDGE_SPCA533: 897 case BRIDGE_SPCA533:
885 rc = spca504B_PollingDataReady(gspca_dev); 898 spca504B_PollingDataReady(gspca_dev);
886 spca50x_GetFirmware(gspca_dev); 899 spca50x_GetFirmware(gspca_dev);
887 break; 900 break;
888 case BRIDGE_SPCA536: 901 case BRIDGE_SPCA536:
889 spca50x_GetFirmware(gspca_dev); 902 spca50x_GetFirmware(gspca_dev);
890 reg_r(gspca_dev, 0x00, 0x5002, 1); 903 reg_r(gspca_dev, 0x00, 0x5002, 1);
891 gspca_dev->usb_buf[0] = 0; 904 reg_w_1(gspca_dev, 0x24, 0, 0, 0);
892 reg_w(gspca_dev, 0x24, 0, 0, 1);
893 reg_r(gspca_dev, 0x24, 0, 1); 905 reg_r(gspca_dev, 0x24, 0, 1);
894 rc = spca504B_PollingDataReady(gspca_dev); 906 spca504B_PollingDataReady(gspca_dev);
895 reg_w(gspca_dev, 0x34, 0, 0, 0); 907 reg_w_riv(dev, 0x34, 0, 0);
896 spca504B_WaitCmdStatus(gspca_dev); 908 spca504B_WaitCmdStatus(gspca_dev);
897 break; 909 break;
898 case BRIDGE_SPCA504C: /* pccam600 */ 910 case BRIDGE_SPCA504C: /* pccam600 */
@@ -902,12 +914,13 @@ static int sd_init(struct gspca_dev *gspca_dev)
902 spca504_wait_status(gspca_dev); 914 spca504_wait_status(gspca_dev);
903 if (sd->subtype == LogitechClickSmart420) 915 if (sd->subtype == LogitechClickSmart420)
904 write_vector(gspca_dev, 916 write_vector(gspca_dev,
905 spca504A_clicksmart420_open_data); 917 spca504A_clicksmart420_open_data,
918 ARRAY_SIZE(spca504A_clicksmart420_open_data));
906 else 919 else
907 write_vector(gspca_dev, spca504_pccam600_open_data); 920 write_vector(gspca_dev, spca504_pccam600_open_data,
921 ARRAY_SIZE(spca504_pccam600_open_data));
908 err_code = spca50x_setup_qtable(gspca_dev, 922 err_code = spca50x_setup_qtable(gspca_dev,
909 0x00, 0x2800, 923 qtable_creative_pccam);
910 0x2840, qtable_creative_pccam);
911 if (err_code < 0) { 924 if (err_code < 0) {
912 PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed"); 925 PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed");
913 return err_code; 926 return err_code;
@@ -945,8 +958,8 @@ static int sd_init(struct gspca_dev *gspca_dev)
945 6, 0, 0x86, 1); */ 958 6, 0, 0x86, 1); */
946/* spca504A_acknowledged_command (gspca_dev, 0x24, 959/* spca504A_acknowledged_command (gspca_dev, 0x24,
947 0, 0, 0x9D, 1); */ 960 0, 0, 0x9D, 1); */
948 reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */ 961 reg_w_riv(dev, 0x00, 0x270c, 0x05); /* L92 sno1t.txt */
949 reg_w_riv(dev, 0x0, 0x2310, 0x05); 962 reg_w_riv(dev, 0x00, 0x2310, 0x05);
950 spca504A_acknowledged_command(gspca_dev, 0x01, 963 spca504A_acknowledged_command(gspca_dev, 0x01,
951 0x0f, 0, 0xff, 0); 964 0x0f, 0, 0xff, 0);
952 } 965 }
@@ -954,8 +967,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
954 reg_w_riv(dev, 0, 0x2000, 0); 967 reg_w_riv(dev, 0, 0x2000, 0);
955 reg_w_riv(dev, 0, 0x2883, 1); 968 reg_w_riv(dev, 0, 0x2883, 1);
956 err_code = spca50x_setup_qtable(gspca_dev, 969 err_code = spca50x_setup_qtable(gspca_dev,
957 0x00, 0x2800,
958 0x2840,
959 qtable_spca504_default); 970 qtable_spca504_default);
960 if (err_code < 0) { 971 if (err_code < 0) {
961 PDEBUG(D_ERR, "spca50x_setup_qtable failed"); 972 PDEBUG(D_ERR, "spca50x_setup_qtable failed");
@@ -970,10 +981,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
970{ 981{
971 struct sd *sd = (struct sd *) gspca_dev; 982 struct sd *sd = (struct sd *) gspca_dev;
972 struct usb_device *dev = gspca_dev->dev; 983 struct usb_device *dev = gspca_dev->dev;
973 int rc;
974 int enable; 984 int enable;
975 __u8 i; 985 int i;
976 __u8 info[6]; 986 u8 info[6];
977 987
978 /* create the JPEG header */ 988 /* create the JPEG header */
979 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL); 989 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
@@ -991,17 +1001,20 @@ static int sd_start(struct gspca_dev *gspca_dev)
991/* case BRIDGE_SPCA504B: */ 1001/* case BRIDGE_SPCA504B: */
992/* case BRIDGE_SPCA533: */ 1002/* case BRIDGE_SPCA533: */
993/* case BRIDGE_SPCA536: */ 1003/* case BRIDGE_SPCA536: */
994 if (sd->subtype == MegapixV4 || 1004 switch (sd->subtype) {
995 sd->subtype == LogitechClickSmart820 || 1005 case MegapixV4:
996 sd->subtype == MegaImageVI) { 1006 case LogitechClickSmart820:
997 reg_w(gspca_dev, 0xf0, 0, 0, 0); 1007 case MegaImageVI:
1008 reg_w_riv(dev, 0xf0, 0, 0);
998 spca504B_WaitCmdStatus(gspca_dev); 1009 spca504B_WaitCmdStatus(gspca_dev);
999 reg_r(gspca_dev, 0xf0, 4, 0); 1010 reg_r(gspca_dev, 0xf0, 4, 0);
1000 spca504B_WaitCmdStatus(gspca_dev); 1011 spca504B_WaitCmdStatus(gspca_dev);
1001 } else { 1012 break;
1002 reg_w(gspca_dev, 0x31, 0, 4, 0); 1013 default:
1014 reg_w_riv(dev, 0x31, 0, 0x04);
1003 spca504B_WaitCmdStatus(gspca_dev); 1015 spca504B_WaitCmdStatus(gspca_dev);
1004 rc = spca504B_PollingDataReady(gspca_dev); 1016 spca504B_PollingDataReady(gspca_dev);
1017 break;
1005 } 1018 }
1006 break; 1019 break;
1007 case BRIDGE_SPCA504: 1020 case BRIDGE_SPCA504:
@@ -1035,15 +1048,17 @@ static int sd_start(struct gspca_dev *gspca_dev)
1035 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); 1048 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1036 } 1049 }
1037 spca504B_SetSizeType(gspca_dev); 1050 spca504B_SetSizeType(gspca_dev);
1038 reg_w_riv(dev, 0x0, 0x270c, 0x05); /* L92 sno1t.txt */ 1051 reg_w_riv(dev, 0x00, 0x270c, 0x05); /* L92 sno1t.txt */
1039 reg_w_riv(dev, 0x0, 0x2310, 0x05); 1052 reg_w_riv(dev, 0x00, 0x2310, 0x05);
1040 break; 1053 break;
1041 case BRIDGE_SPCA504C: 1054 case BRIDGE_SPCA504C:
1042 if (sd->subtype == LogitechClickSmart420) { 1055 if (sd->subtype == LogitechClickSmart420) {
1043 write_vector(gspca_dev, 1056 write_vector(gspca_dev,
1044 spca504A_clicksmart420_init_data); 1057 spca504A_clicksmart420_init_data,
1058 ARRAY_SIZE(spca504A_clicksmart420_init_data));
1045 } else { 1059 } else {
1046 write_vector(gspca_dev, spca504_pccam600_init_data); 1060 write_vector(gspca_dev, spca504_pccam600_init_data,
1061 ARRAY_SIZE(spca504_pccam600_init_data));
1047 } 1062 }
1048 enable = (sd->autogain ? 0x04 : 0x01); 1063 enable = (sd->autogain ? 0x04 : 0x01);
1049 reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */ 1064 reg_w_riv(dev, 0x0c, 0x0000, enable); /* auto exposure */
@@ -1055,7 +1070,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
1055 spca504B_SetSizeType(gspca_dev); 1070 spca504B_SetSizeType(gspca_dev);
1056 break; 1071 break;
1057 } 1072 }
1058 sp5xx_initContBrigHueRegisters(gspca_dev); 1073 init_ctl_reg(gspca_dev);
1059 return 0; 1074 return 0;
1060} 1075}
1061 1076
@@ -1069,7 +1084,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1069/* case BRIDGE_SPCA533: */ 1084/* case BRIDGE_SPCA533: */
1070/* case BRIDGE_SPCA536: */ 1085/* case BRIDGE_SPCA536: */
1071/* case BRIDGE_SPCA504B: */ 1086/* case BRIDGE_SPCA504B: */
1072 reg_w(gspca_dev, 0x31, 0, 0, 0); 1087 reg_w_riv(dev, 0x31, 0, 0);
1073 spca504B_WaitCmdStatus(gspca_dev); 1088 spca504B_WaitCmdStatus(gspca_dev);
1074 spca504B_PollingDataReady(gspca_dev); 1089 spca504B_PollingDataReady(gspca_dev);
1075 break; 1090 break;
@@ -1087,7 +1102,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1087 0x0f, 0x00, 0xff, 1); 1102 0x0f, 0x00, 0xff, 1);
1088 } else { 1103 } else {
1089 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0); 1104 spca504_acknowledged_command(gspca_dev, 0x24, 0, 0);
1090 reg_w_riv(dev, 0x01, 0x000f, 0x00); 1105 reg_w_riv(dev, 0x01, 0x000f, 0x0000);
1091 } 1106 }
1092 break; 1107 break;
1093 } 1108 }
@@ -1102,12 +1117,12 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
1102 1117
1103static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1118static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1104 struct gspca_frame *frame, /* target */ 1119 struct gspca_frame *frame, /* target */
1105 __u8 *data, /* isoc packet */ 1120 u8 *data, /* isoc packet */
1106 int len) /* iso packet length */ 1121 int len) /* iso packet length */
1107{ 1122{
1108 struct sd *sd = (struct sd *) gspca_dev; 1123 struct sd *sd = (struct sd *) gspca_dev;
1109 int i, sof = 0; 1124 int i, sof = 0;
1110 static unsigned char ffd9[] = {0xff, 0xd9}; 1125 static u8 ffd9[] = {0xff, 0xd9};
1111 1126
1112/* frames are jpeg 4.1.1 without 0xff escape */ 1127/* frames are jpeg 4.1.1 without 0xff escape */
1113 switch (sd->bridge) { 1128 switch (sd->bridge) {
@@ -1195,63 +1210,6 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1195 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 1210 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
1196} 1211}
1197 1212
1198static void setbrightness(struct gspca_dev *gspca_dev)
1199{
1200 struct sd *sd = (struct sd *) gspca_dev;
1201 struct usb_device *dev = gspca_dev->dev;
1202
1203 switch (sd->bridge) {
1204 default:
1205/* case BRIDGE_SPCA533: */
1206/* case BRIDGE_SPCA504B: */
1207/* case BRIDGE_SPCA504: */
1208/* case BRIDGE_SPCA504C: */
1209 reg_w_riv(dev, 0x0, 0x21a7, sd->brightness);
1210 break;
1211 case BRIDGE_SPCA536:
1212 reg_w_riv(dev, 0x0, 0x20f0, sd->brightness);
1213 break;
1214 }
1215}
1216
1217static void setcontrast(struct gspca_dev *gspca_dev)
1218{
1219 struct sd *sd = (struct sd *) gspca_dev;
1220 struct usb_device *dev = gspca_dev->dev;
1221
1222 switch (sd->bridge) {
1223 default:
1224/* case BRIDGE_SPCA533: */
1225/* case BRIDGE_SPCA504B: */
1226/* case BRIDGE_SPCA504: */
1227/* case BRIDGE_SPCA504C: */
1228 reg_w_riv(dev, 0x0, 0x21a8, sd->contrast);
1229 break;
1230 case BRIDGE_SPCA536:
1231 reg_w_riv(dev, 0x0, 0x20f1, sd->contrast);
1232 break;
1233 }
1234}
1235
1236static void setcolors(struct gspca_dev *gspca_dev)
1237{
1238 struct sd *sd = (struct sd *) gspca_dev;
1239 struct usb_device *dev = gspca_dev->dev;
1240
1241 switch (sd->bridge) {
1242 default:
1243/* case BRIDGE_SPCA533: */
1244/* case BRIDGE_SPCA504B: */
1245/* case BRIDGE_SPCA504: */
1246/* case BRIDGE_SPCA504C: */
1247 reg_w_riv(dev, 0x0, 0x21ae, sd->colors);
1248 break;
1249 case BRIDGE_SPCA536:
1250 reg_w_riv(dev, 0x0, 0x20f6, sd->colors);
1251 break;
1252 }
1253}
1254
1255static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 1213static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
1256{ 1214{
1257 struct sd *sd = (struct sd *) gspca_dev; 1215 struct sd *sd = (struct sd *) gspca_dev;