diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-07-04 10:16:16 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:16:53 -0400 |
commit | a5ae2062252e697d38e53dbbeb91460252208914 (patch) | |
tree | 38706e9f36e2d93cd3dee8eea639bb74a17b3efa /drivers/media/video/gspca/spca500.c | |
parent | 54ab92ca05550550bcec2462de2605f35d079b66 (diff) |
V4L/DVB (8195): gspca: Input buffer overwritten in spca561 + cleanup code.
spca561: Input buffer may be changed on reg write.
(all sd): Cleanup code, 'const' added.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/gspca/spca500.c')
-rw-r--r-- | drivers/media/video/gspca/spca500.c | 301 |
1 files changed, 153 insertions, 148 deletions
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c index 1db5b33ad85e..3a42506830f8 100644 --- a/drivers/media/video/gspca/spca500.c +++ b/drivers/media/video/gspca/spca500.c | |||
@@ -24,8 +24,8 @@ | |||
24 | #include "gspca.h" | 24 | #include "gspca.h" |
25 | #include "jpeg.h" | 25 | #include "jpeg.h" |
26 | 26 | ||
27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) | 27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 4) |
28 | static const char version[] = "2.1.0"; | 28 | static const char version[] = "2.1.4"; |
29 | 29 | ||
30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); | 30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
31 | MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver"); | 31 | MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver"); |
@@ -35,7 +35,7 @@ MODULE_LICENSE("GPL"); | |||
35 | struct sd { | 35 | struct sd { |
36 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 36 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
37 | 37 | ||
38 | unsigned char packet[ISO_MAX_SIZE + 128]; | 38 | __u8 packet[ISO_MAX_SIZE + 128]; |
39 | /* !! no more than 128 ff in an ISO packet */ | 39 | /* !! no more than 128 ff in an ISO packet */ |
40 | 40 | ||
41 | unsigned char brightness; | 41 | unsigned char brightness; |
@@ -70,44 +70,44 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val); | |||
70 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); | 70 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val); |
71 | 71 | ||
72 | static struct ctrl sd_ctrls[] = { | 72 | static struct ctrl sd_ctrls[] = { |
73 | #define SD_BRIGHTNESS 0 | ||
74 | { | 73 | { |
75 | { | 74 | { |
76 | .id = V4L2_CID_BRIGHTNESS, | 75 | .id = V4L2_CID_BRIGHTNESS, |
77 | .type = V4L2_CTRL_TYPE_INTEGER, | 76 | .type = V4L2_CTRL_TYPE_INTEGER, |
78 | .name = "Brightness", | 77 | .name = "Brightness", |
79 | .minimum = 0, | 78 | .minimum = 0, |
80 | .maximum = 0xff, | 79 | .maximum = 255, |
81 | .step = 1, | 80 | .step = 1, |
82 | .default_value = 0x7f, | 81 | #define BRIGHTNESS_DEF 127 |
82 | .default_value = BRIGHTNESS_DEF, | ||
83 | }, | 83 | }, |
84 | .set = sd_setbrightness, | 84 | .set = sd_setbrightness, |
85 | .get = sd_getbrightness, | 85 | .get = sd_getbrightness, |
86 | }, | 86 | }, |
87 | #define SD_CONTRAST 1 | ||
88 | { | 87 | { |
89 | { | 88 | { |
90 | .id = V4L2_CID_CONTRAST, | 89 | .id = V4L2_CID_CONTRAST, |
91 | .type = V4L2_CTRL_TYPE_INTEGER, | 90 | .type = V4L2_CTRL_TYPE_INTEGER, |
92 | .name = "Contrast", | 91 | .name = "Contrast", |
93 | .minimum = 0, | 92 | .minimum = 0, |
94 | .maximum = 255, | 93 | .maximum = 63, |
95 | .step = 1, | 94 | .step = 1, |
96 | .default_value = 127, | 95 | #define CONTRAST_DEF 31 |
96 | .default_value = CONTRAST_DEF, | ||
97 | }, | 97 | }, |
98 | .set = sd_setcontrast, | 98 | .set = sd_setcontrast, |
99 | .get = sd_getcontrast, | 99 | .get = sd_getcontrast, |
100 | }, | 100 | }, |
101 | #define SD_COLOR 2 | ||
102 | { | 101 | { |
103 | { | 102 | { |
104 | .id = V4L2_CID_SATURATION, | 103 | .id = V4L2_CID_SATURATION, |
105 | .type = V4L2_CTRL_TYPE_INTEGER, | 104 | .type = V4L2_CTRL_TYPE_INTEGER, |
106 | .name = "Color", | 105 | .name = "Color", |
107 | .minimum = 0, | 106 | .minimum = 0, |
108 | .maximum = 255, | 107 | .maximum = 63, |
109 | .step = 1, | 108 | .step = 1, |
110 | .default_value = 127, | 109 | #define COLOR_DEF 31 |
110 | .default_value = COLOR_DEF, | ||
111 | }, | 111 | }, |
112 | .set = sd_setcolors, | 112 | .set = sd_setcolors, |
113 | .get = sd_getcolors, | 113 | .get = sd_getcolors, |
@@ -139,7 +139,7 @@ static struct cam_mode sif_mode[] = { | |||
139 | #define SPCA500_OFFSET_DATA 16 | 139 | #define SPCA500_OFFSET_DATA 16 |
140 | 140 | ||
141 | 141 | ||
142 | static __u16 spca500_visual_defaults[][3] = { | 142 | static const __u16 spca500_visual_defaults[][3] = { |
143 | {0x00, 0x0003, 0x816b}, /* SSI not active sync with vsync, | 143 | {0x00, 0x0003, 0x816b}, /* SSI not active sync with vsync, |
144 | * hue (H byte) = 0, | 144 | * hue (H byte) = 0, |
145 | * saturation/hue enable, | 145 | * saturation/hue enable, |
@@ -161,10 +161,9 @@ static __u16 spca500_visual_defaults[][3] = { | |||
161 | {0x00, 0x0001, 0x8202}, /* clock rate compensation = 1/25 sec/frame */ | 161 | {0x00, 0x0001, 0x8202}, /* clock rate compensation = 1/25 sec/frame */ |
162 | {0x0c, 0x0004, 0x0000}, | 162 | {0x0c, 0x0004, 0x0000}, |
163 | /* set interface */ | 163 | /* set interface */ |
164 | 164 | {} | |
165 | {0, 0, 0} | ||
166 | }; | 165 | }; |
167 | static __u16 Clicksmart510_defaults[][3] = { | 166 | static const __u16 Clicksmart510_defaults[][3] = { |
168 | {0x00, 0x00, 0x8211}, | 167 | {0x00, 0x00, 0x8211}, |
169 | {0x00, 0x01, 0x82c0}, | 168 | {0x00, 0x01, 0x82c0}, |
170 | {0x00, 0x10, 0x82cb}, | 169 | {0x00, 0x10, 0x82cb}, |
@@ -293,7 +292,7 @@ static __u16 Clicksmart510_defaults[][3] = { | |||
293 | {} | 292 | {} |
294 | }; | 293 | }; |
295 | 294 | ||
296 | static unsigned char qtable_creative_pccam[2][64] = { | 295 | static const __u8 qtable_creative_pccam[2][64] = { |
297 | { /* Q-table Y-components */ | 296 | { /* Q-table Y-components */ |
298 | 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, | 297 | 0x05, 0x03, 0x03, 0x05, 0x07, 0x0c, 0x0f, 0x12, |
299 | 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, | 298 | 0x04, 0x04, 0x04, 0x06, 0x08, 0x11, 0x12, 0x11, |
@@ -314,7 +313,7 @@ static unsigned char qtable_creative_pccam[2][64] = { | |||
314 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e} | 313 | 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e} |
315 | }; | 314 | }; |
316 | 315 | ||
317 | static unsigned char qtable_kodak_ez200[2][64] = { | 316 | static const __u8 qtable_kodak_ez200[2][64] = { |
318 | { /* Q-table Y-components */ | 317 | { /* Q-table Y-components */ |
319 | 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x05, 0x06, | 318 | 0x02, 0x01, 0x01, 0x02, 0x02, 0x04, 0x05, 0x06, |
320 | 0x01, 0x01, 0x01, 0x02, 0x03, 0x06, 0x06, 0x06, | 319 | 0x01, 0x01, 0x01, 0x02, 0x03, 0x06, 0x06, 0x06, |
@@ -335,7 +334,7 @@ static unsigned char qtable_kodak_ez200[2][64] = { | |||
335 | 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a} | 334 | 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a} |
336 | }; | 335 | }; |
337 | 336 | ||
338 | static unsigned char qtable_pocketdv[2][64] = { | 337 | static const __u8 qtable_pocketdv[2][64] = { |
339 | { /* Q-table Y-components start registers 0x8800 */ | 338 | { /* Q-table Y-components start registers 0x8800 */ |
340 | 0x06, 0x04, 0x04, 0x06, 0x0a, 0x10, 0x14, 0x18, | 339 | 0x06, 0x04, 0x04, 0x06, 0x0a, 0x10, 0x14, 0x18, |
341 | 0x05, 0x05, 0x06, 0x08, 0x0a, 0x17, 0x18, 0x16, | 340 | 0x05, 0x05, 0x06, 0x08, 0x0a, 0x17, 0x18, 0x16, |
@@ -357,7 +356,7 @@ static unsigned char qtable_pocketdv[2][64] = { | |||
357 | 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28} | 356 | 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28} |
358 | }; | 357 | }; |
359 | 358 | ||
360 | static void spca5xxRegRead(struct usb_device *dev, | 359 | static void reg_r(struct usb_device *dev, |
361 | __u16 index, | 360 | __u16 index, |
362 | __u8 *buffer, __u16 length) | 361 | __u8 *buffer, __u16 length) |
363 | { | 362 | { |
@@ -369,25 +368,24 @@ static void spca5xxRegRead(struct usb_device *dev, | |||
369 | index, buffer, length, 500); | 368 | index, buffer, length, 500); |
370 | } | 369 | } |
371 | 370 | ||
372 | static int reg_write(struct usb_device *dev, | 371 | static int reg_w(struct usb_device *dev, |
373 | __u16 req, __u16 index, __u16 value) | 372 | __u16 req, __u16 index, __u16 value) |
374 | { | 373 | { |
375 | int ret; | 374 | int ret; |
376 | 375 | ||
376 | PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x", index, value); | ||
377 | ret = usb_control_msg(dev, | 377 | ret = usb_control_msg(dev, |
378 | usb_sndctrlpipe(dev, 0), | 378 | usb_sndctrlpipe(dev, 0), |
379 | req, | 379 | req, |
380 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 380 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
381 | value, index, NULL, 0, 500); | 381 | value, index, NULL, 0, 500); |
382 | PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x, 0x%x", | ||
383 | index, value, ret); | ||
384 | if (ret < 0) | 382 | if (ret < 0) |
385 | PDEBUG(D_ERR, "reg write: error %d", ret); | 383 | PDEBUG(D_ERR, "reg write: error %d", ret); |
386 | return ret; | 384 | return ret; |
387 | } | 385 | } |
388 | 386 | ||
389 | /* returns: negative is error, pos or zero is data */ | 387 | /* returns: negative is error, pos or zero is data */ |
390 | static int reg_read(struct usb_device *dev, | 388 | static int reg_r_12(struct usb_device *dev, |
391 | __u16 req, /* bRequest */ | 389 | __u16 req, /* bRequest */ |
392 | __u16 index, /* wIndex */ | 390 | __u16 index, /* wIndex */ |
393 | __u16 length) /* wLength (1 or 2 only) */ | 391 | __u16 length) /* wLength (1 or 2 only) */ |
@@ -405,7 +403,7 @@ static int reg_read(struct usb_device *dev, | |||
405 | buf, length, | 403 | buf, length, |
406 | 500); /* timeout */ | 404 | 500); /* timeout */ |
407 | if (ret < 0) { | 405 | if (ret < 0) { |
408 | PDEBUG(D_ERR, "reg_read err %d", ret); | 406 | PDEBUG(D_ERR, "reg_r_12 err %d", ret); |
409 | return -1; | 407 | return -1; |
410 | } | 408 | } |
411 | return (buf[1] << 8) + buf[0]; | 409 | return (buf[1] << 8) + buf[0]; |
@@ -416,13 +414,13 @@ static int reg_read(struct usb_device *dev, | |||
416 | * a reg_read call. | 414 | * a reg_read call. |
417 | * Returns: negative is error or timeout, zero is success. | 415 | * Returns: negative is error or timeout, zero is success. |
418 | */ | 416 | */ |
419 | static int reg_readwait(struct usb_device *dev, | 417 | static int reg_r_wait(struct usb_device *dev, |
420 | __u16 reg, __u16 index, __u16 value) | 418 | __u16 reg, __u16 index, __u16 value) |
421 | { | 419 | { |
422 | int ret, cnt = 20; | 420 | int ret, cnt = 20; |
423 | 421 | ||
424 | while (--cnt > 0) { | 422 | while (--cnt > 0) { |
425 | ret = reg_read(dev, reg, index, 1); | 423 | ret = reg_r_12(dev, reg, index, 1); |
426 | if (ret == value) | 424 | if (ret == value) |
427 | return 0; | 425 | return 0; |
428 | msleep(50); | 426 | msleep(50); |
@@ -431,13 +429,13 @@ static int reg_readwait(struct usb_device *dev, | |||
431 | } | 429 | } |
432 | 430 | ||
433 | static int write_vector(struct gspca_dev *gspca_dev, | 431 | static int write_vector(struct gspca_dev *gspca_dev, |
434 | __u16 data[][3]) | 432 | const __u16 data[][3]) |
435 | { | 433 | { |
436 | struct usb_device *dev = gspca_dev->dev; | 434 | struct usb_device *dev = gspca_dev->dev; |
437 | int ret, i = 0; | 435 | int ret, i = 0; |
438 | 436 | ||
439 | while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { | 437 | while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { |
440 | ret = reg_write(dev, data[i][0], data[i][2], data[i][1]); | 438 | ret = reg_w(dev, data[i][0], data[i][2], data[i][1]); |
441 | if (ret < 0) | 439 | if (ret < 0) |
442 | return ret; | 440 | return ret; |
443 | i++; | 441 | i++; |
@@ -449,21 +447,21 @@ static int spca50x_setup_qtable(struct gspca_dev *gspca_dev, | |||
449 | unsigned int request, | 447 | unsigned int request, |
450 | unsigned int ybase, | 448 | unsigned int ybase, |
451 | unsigned int cbase, | 449 | unsigned int cbase, |
452 | unsigned char qtable[2][64]) | 450 | const __u8 qtable[2][64]) |
453 | { | 451 | { |
454 | struct usb_device *dev = gspca_dev->dev; | 452 | struct usb_device *dev = gspca_dev->dev; |
455 | int i, err; | 453 | int i, err; |
456 | 454 | ||
457 | /* loop over y components */ | 455 | /* loop over y components */ |
458 | for (i = 0; i < 64; i++) { | 456 | for (i = 0; i < 64; i++) { |
459 | err = reg_write(dev, request, ybase + i, qtable[0][i]); | 457 | err = reg_w(dev, request, ybase + i, qtable[0][i]); |
460 | if (err < 0) | 458 | if (err < 0) |
461 | return err; | 459 | return err; |
462 | } | 460 | } |
463 | 461 | ||
464 | /* loop over c components */ | 462 | /* loop over c components */ |
465 | for (i = 0; i < 64; i++) { | 463 | for (i = 0; i < 64; i++) { |
466 | err = reg_write(dev, request, cbase + i, qtable[1][i]); | 464 | err = reg_w(dev, request, cbase + i, qtable[1][i]); |
467 | if (err < 0) | 465 | if (err < 0) |
468 | return err; | 466 | return err; |
469 | } | 467 | } |
@@ -474,8 +472,8 @@ static void spca500_ping310(struct gspca_dev *gspca_dev) | |||
474 | { | 472 | { |
475 | __u8 Data[2]; | 473 | __u8 Data[2]; |
476 | 474 | ||
477 | spca5xxRegRead(gspca_dev->dev, 0x0d04, Data, 2); | 475 | reg_r(gspca_dev->dev, 0x0d04, Data, 2); |
478 | PDEBUG(D_PACK, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x", | 476 | PDEBUG(D_STREAM, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x", |
479 | Data[0], Data[1]); | 477 | Data[0], Data[1]); |
480 | } | 478 | } |
481 | 479 | ||
@@ -483,26 +481,26 @@ static void spca500_clksmart310_init(struct gspca_dev *gspca_dev) | |||
483 | { | 481 | { |
484 | __u8 Data[2]; | 482 | __u8 Data[2]; |
485 | 483 | ||
486 | spca5xxRegRead(gspca_dev->dev, 0x0d05, Data, 2); | 484 | reg_r(gspca_dev->dev, 0x0d05, Data, 2); |
487 | PDEBUG(D_PACK, "ClickSmart310 init 0x0d05 0x%02x 0x%02x", Data[0], | 485 | PDEBUG(D_STREAM, "ClickSmart310 init 0x0d05 0x%02x 0x%02x", |
488 | Data[1]); | 486 | Data[0], Data[1]); |
489 | reg_write(gspca_dev->dev, 0x00, 0x8167, 0x5a); | 487 | reg_w(gspca_dev->dev, 0x00, 0x8167, 0x5a); |
490 | spca500_ping310(gspca_dev); | 488 | spca500_ping310(gspca_dev); |
491 | 489 | ||
492 | reg_write(gspca_dev->dev, 0x00, 0x8168, 0x22); | 490 | reg_w(gspca_dev->dev, 0x00, 0x8168, 0x22); |
493 | reg_write(gspca_dev->dev, 0x00, 0x816a, 0xc0); | 491 | reg_w(gspca_dev->dev, 0x00, 0x816a, 0xc0); |
494 | reg_write(gspca_dev->dev, 0x00, 0x816b, 0x0b); | 492 | reg_w(gspca_dev->dev, 0x00, 0x816b, 0x0b); |
495 | reg_write(gspca_dev->dev, 0x00, 0x8169, 0x25); | 493 | reg_w(gspca_dev->dev, 0x00, 0x8169, 0x25); |
496 | reg_write(gspca_dev->dev, 0x00, 0x8157, 0x5b); | 494 | reg_w(gspca_dev->dev, 0x00, 0x8157, 0x5b); |
497 | reg_write(gspca_dev->dev, 0x00, 0x8158, 0x5b); | 495 | reg_w(gspca_dev->dev, 0x00, 0x8158, 0x5b); |
498 | reg_write(gspca_dev->dev, 0x00, 0x813f, 0x03); | 496 | reg_w(gspca_dev->dev, 0x00, 0x813f, 0x03); |
499 | reg_write(gspca_dev->dev, 0x00, 0x8151, 0x4a); | 497 | reg_w(gspca_dev->dev, 0x00, 0x8151, 0x4a); |
500 | reg_write(gspca_dev->dev, 0x00, 0x8153, 0x78); | 498 | reg_w(gspca_dev->dev, 0x00, 0x8153, 0x78); |
501 | reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x04); | 499 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x04); |
502 | /* 00 for adjust shutter */ | 500 | /* 00 for adjust shutter */ |
503 | reg_write(gspca_dev->dev, 0x00, 0x0d02, 0x01); | 501 | reg_w(gspca_dev->dev, 0x00, 0x0d02, 0x01); |
504 | reg_write(gspca_dev->dev, 0x00, 0x8169, 0x25); | 502 | reg_w(gspca_dev->dev, 0x00, 0x8169, 0x25); |
505 | reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x02); | 503 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x02); |
506 | } | 504 | } |
507 | 505 | ||
508 | static void spca500_setmode(struct gspca_dev *gspca_dev, | 506 | static void spca500_setmode(struct gspca_dev *gspca_dev, |
@@ -511,14 +509,14 @@ static void spca500_setmode(struct gspca_dev *gspca_dev, | |||
511 | int mode; | 509 | int mode; |
512 | 510 | ||
513 | /* set x multiplier */ | 511 | /* set x multiplier */ |
514 | reg_write(gspca_dev->dev, 0, 0x8001, xmult); | 512 | reg_w(gspca_dev->dev, 0, 0x8001, xmult); |
515 | 513 | ||
516 | /* set y multiplier */ | 514 | /* set y multiplier */ |
517 | reg_write(gspca_dev->dev, 0, 0x8002, ymult); | 515 | reg_w(gspca_dev->dev, 0, 0x8002, ymult); |
518 | 516 | ||
519 | /* use compressed mode, VGA, with mode specific subsample */ | 517 | /* use compressed mode, VGA, with mode specific subsample */ |
520 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode; | 518 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].mode; |
521 | reg_write(gspca_dev->dev, 0, 0x8003, mode << 4); | 519 | reg_w(gspca_dev->dev, 0, 0x8003, mode << 4); |
522 | } | 520 | } |
523 | 521 | ||
524 | static int spca500_full_reset(struct gspca_dev *gspca_dev) | 522 | static int spca500_full_reset(struct gspca_dev *gspca_dev) |
@@ -526,20 +524,20 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev) | |||
526 | int err; | 524 | int err; |
527 | 525 | ||
528 | /* send the reset command */ | 526 | /* send the reset command */ |
529 | err = reg_write(gspca_dev->dev, 0xe0, 0x0001, 0x0000); | 527 | err = reg_w(gspca_dev->dev, 0xe0, 0x0001, 0x0000); |
530 | if (err < 0) | 528 | if (err < 0) |
531 | return err; | 529 | return err; |
532 | 530 | ||
533 | /* wait for the reset to complete */ | 531 | /* wait for the reset to complete */ |
534 | err = reg_readwait(gspca_dev->dev, 0x06, 0x0000, 0x0000); | 532 | err = reg_r_wait(gspca_dev->dev, 0x06, 0x0000, 0x0000); |
535 | if (err < 0) | 533 | if (err < 0) |
536 | return err; | 534 | return err; |
537 | err = reg_write(gspca_dev->dev, 0xe0, 0x0000, 0x0000); | 535 | err = reg_w(gspca_dev->dev, 0xe0, 0x0000, 0x0000); |
538 | if (err < 0) | 536 | if (err < 0) |
539 | return err; | 537 | return err; |
540 | err = reg_readwait(gspca_dev->dev, 0x06, 0, 0); | 538 | err = reg_r_wait(gspca_dev->dev, 0x06, 0, 0); |
541 | if (err < 0) { | 539 | if (err < 0) { |
542 | PDEBUG(D_ERR, "reg_readwait() failed"); | 540 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
543 | return err; | 541 | return err; |
544 | } | 542 | } |
545 | /* all ok */ | 543 | /* all ok */ |
@@ -562,7 +560,7 @@ static int spca500_synch310(struct gspca_dev *gspca_dev) | |||
562 | } | 560 | } |
563 | spca500_ping310(gspca_dev); | 561 | spca500_ping310(gspca_dev); |
564 | 562 | ||
565 | spca5xxRegRead(gspca_dev->dev, 0x0d00, &Data, 1); | 563 | reg_r(gspca_dev->dev, 0x0d00, &Data, 1); |
566 | 564 | ||
567 | /* need alt setting here */ | 565 | /* need alt setting here */ |
568 | PDEBUG(D_PACK, "ClickSmart310 sync alt: %d", gspca_dev->alt); | 566 | PDEBUG(D_PACK, "ClickSmart310 sync alt: %d", gspca_dev->alt); |
@@ -586,12 +584,12 @@ static void spca500_reinit(struct gspca_dev *gspca_dev) | |||
586 | 584 | ||
587 | /* some unknow command from Aiptek pocket dv and family300 */ | 585 | /* some unknow command from Aiptek pocket dv and family300 */ |
588 | 586 | ||
589 | reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x01); | 587 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x01); |
590 | reg_write(gspca_dev->dev, 0x00, 0x0d03, 0x00); | 588 | reg_w(gspca_dev->dev, 0x00, 0x0d03, 0x00); |
591 | reg_write(gspca_dev->dev, 0x00, 0x0d02, 0x01); | 589 | reg_w(gspca_dev->dev, 0x00, 0x0d02, 0x01); |
592 | 590 | ||
593 | /* enable drop packet */ | 591 | /* enable drop packet */ |
594 | reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 592 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); |
595 | 593 | ||
596 | err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, | 594 | err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, |
597 | qtable_pocketdv); | 595 | qtable_pocketdv); |
@@ -599,22 +597,22 @@ static void spca500_reinit(struct gspca_dev *gspca_dev) | |||
599 | PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init"); | 597 | PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init"); |
600 | 598 | ||
601 | /* set qtable index */ | 599 | /* set qtable index */ |
602 | reg_write(gspca_dev->dev, 0x00, 0x8880, 2); | 600 | reg_w(gspca_dev->dev, 0x00, 0x8880, 2); |
603 | /* family cam Quicksmart stuff */ | 601 | /* family cam Quicksmart stuff */ |
604 | reg_write(gspca_dev->dev, 0x00, 0x800a, 0x00); | 602 | reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00); |
605 | /* Set agc transfer: synced inbetween frames */ | 603 | /* Set agc transfer: synced inbetween frames */ |
606 | reg_write(gspca_dev->dev, 0x00, 0x820f, 0x01); | 604 | reg_w(gspca_dev->dev, 0x00, 0x820f, 0x01); |
607 | /* Init SDRAM - needed for SDRAM access */ | 605 | /* Init SDRAM - needed for SDRAM access */ |
608 | reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04); | 606 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); |
609 | /*Start init sequence or stream */ | 607 | /*Start init sequence or stream */ |
610 | 608 | ||
611 | reg_write(gspca_dev->dev, 0, 0x8003, 0x00); | 609 | reg_w(gspca_dev->dev, 0, 0x8003, 0x00); |
612 | /* switch to video camera mode */ | 610 | /* switch to video camera mode */ |
613 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 611 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
614 | msleep(2000); | 612 | msleep(2000); |
615 | if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 613 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) |
616 | spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1); | 614 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); |
617 | reg_write(gspca_dev->dev, 0x00, 0x816b, Data); | 615 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); |
618 | } | 616 | } |
619 | 617 | ||
620 | /* this function is called at probe time */ | 618 | /* this function is called at probe time */ |
@@ -734,9 +732,9 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
734 | cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; | 732 | cam->nmodes = sizeof sif_mode / sizeof sif_mode[0]; |
735 | } | 733 | } |
736 | sd->qindex = 5; | 734 | sd->qindex = 5; |
737 | sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; | 735 | sd->brightness = BRIGHTNESS_DEF; |
738 | sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; | 736 | sd->contrast = CONTRAST_DEF; |
739 | sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; | 737 | sd->colors = COLOR_DEF; |
740 | return 0; | 738 | return 0; |
741 | } | 739 | } |
742 | 740 | ||
@@ -771,7 +769,7 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
771 | } | 769 | } |
772 | 770 | ||
773 | /* is there a sensor here ? */ | 771 | /* is there a sensor here ? */ |
774 | spca5xxRegRead(gspca_dev->dev, 0x8a04, &Data, 1); | 772 | reg_r(gspca_dev->dev, 0x8a04, &Data, 1); |
775 | PDEBUG(D_STREAM, "Spca500 Sensor Address 0x%02X", Data); | 773 | PDEBUG(D_STREAM, "Spca500 Sensor Address 0x%02X", Data); |
776 | PDEBUG(D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02X, Ymult: 0x%02X", | 774 | PDEBUG(D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02X, Ymult: 0x%02X", |
777 | gspca_dev->curr_mode, xmult, ymult); | 775 | gspca_dev->curr_mode, xmult, ymult); |
@@ -782,33 +780,33 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
782 | spca500_setmode(gspca_dev, xmult, ymult); | 780 | spca500_setmode(gspca_dev, xmult, ymult); |
783 | 781 | ||
784 | /* enable drop packet */ | 782 | /* enable drop packet */ |
785 | reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 783 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); |
786 | reg_write(gspca_dev->dev, 0x00, 0x8880, 3); | 784 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); |
787 | err = spca50x_setup_qtable(gspca_dev, | 785 | err = spca50x_setup_qtable(gspca_dev, |
788 | 0x00, 0x8800, 0x8840, | 786 | 0x00, 0x8800, 0x8840, |
789 | qtable_creative_pccam); | 787 | qtable_creative_pccam); |
790 | if (err < 0) | 788 | if (err < 0) |
791 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 789 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
792 | /* Init SDRAM - needed for SDRAM access */ | 790 | /* Init SDRAM - needed for SDRAM access */ |
793 | reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04); | 791 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); |
794 | 792 | ||
795 | /* switch to video camera mode */ | 793 | /* switch to video camera mode */ |
796 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 794 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
797 | msleep(500); | 795 | msleep(500); |
798 | if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 796 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) |
799 | PDEBUG(D_ERR, "reg_readwait() failed"); | 797 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
800 | 798 | ||
801 | spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1); | 799 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); |
802 | reg_write(gspca_dev->dev, 0x00, 0x816b, Data); | 800 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); |
803 | 801 | ||
804 | spca500_synch310(gspca_dev); | 802 | spca500_synch310(gspca_dev); |
805 | 803 | ||
806 | write_vector(gspca_dev, spca500_visual_defaults); | 804 | write_vector(gspca_dev, spca500_visual_defaults); |
807 | spca500_setmode(gspca_dev, xmult, ymult); | 805 | spca500_setmode(gspca_dev, xmult, ymult); |
808 | /* enable drop packet */ | 806 | /* enable drop packet */ |
809 | reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 807 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); |
810 | PDEBUG(D_ERR, "failed to enable drop packet"); | 808 | PDEBUG(D_ERR, "failed to enable drop packet"); |
811 | reg_write(gspca_dev->dev, 0x00, 0x8880, 3); | 809 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); |
812 | err = spca50x_setup_qtable(gspca_dev, | 810 | err = spca50x_setup_qtable(gspca_dev, |
813 | 0x00, 0x8800, 0x8840, | 811 | 0x00, 0x8800, 0x8840, |
814 | qtable_creative_pccam); | 812 | qtable_creative_pccam); |
@@ -816,16 +814,16 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
816 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 814 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
817 | 815 | ||
818 | /* Init SDRAM - needed for SDRAM access */ | 816 | /* Init SDRAM - needed for SDRAM access */ |
819 | reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04); | 817 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); |
820 | 818 | ||
821 | /* switch to video camera mode */ | 819 | /* switch to video camera mode */ |
822 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 820 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
823 | 821 | ||
824 | if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 822 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) |
825 | PDEBUG(D_ERR, "reg_readwait() failed"); | 823 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
826 | 824 | ||
827 | spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1); | 825 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); |
828 | reg_write(gspca_dev->dev, 0x00, 0x816b, Data); | 826 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); |
829 | break; | 827 | break; |
830 | case CreativePCCam300: /* Creative PC-CAM 300 640x480 CCD */ | 828 | case CreativePCCam300: /* Creative PC-CAM 300 640x480 CCD */ |
831 | case IntelPocketPCCamera: /* FIXME: Temporary fix for | 829 | case IntelPocketPCCamera: /* FIXME: Temporary fix for |
@@ -838,10 +836,10 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
838 | PDEBUG(D_ERR, "spca500_full_reset failed"); | 836 | PDEBUG(D_ERR, "spca500_full_reset failed"); |
839 | 837 | ||
840 | /* enable drop packet */ | 838 | /* enable drop packet */ |
841 | err = reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 839 | err = reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); |
842 | if (err < 0) | 840 | if (err < 0) |
843 | PDEBUG(D_ERR, "failed to enable drop packet"); | 841 | PDEBUG(D_ERR, "failed to enable drop packet"); |
844 | reg_write(gspca_dev->dev, 0x00, 0x8880, 3); | 842 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); |
845 | err = spca50x_setup_qtable(gspca_dev, | 843 | err = spca50x_setup_qtable(gspca_dev, |
846 | 0x00, 0x8800, 0x8840, | 844 | 0x00, 0x8800, 0x8840, |
847 | qtable_creative_pccam); | 845 | qtable_creative_pccam); |
@@ -849,18 +847,18 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
849 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 847 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
850 | 848 | ||
851 | spca500_setmode(gspca_dev, xmult, ymult); | 849 | spca500_setmode(gspca_dev, xmult, ymult); |
852 | reg_write(gspca_dev->dev, 0x20, 0x0001, 0x0004); | 850 | reg_w(gspca_dev->dev, 0x20, 0x0001, 0x0004); |
853 | 851 | ||
854 | /* switch to video camera mode */ | 852 | /* switch to video camera mode */ |
855 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 853 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
856 | 854 | ||
857 | if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 855 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) |
858 | PDEBUG(D_ERR, "reg_readwait() failed"); | 856 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
859 | 857 | ||
860 | spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1); | 858 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); |
861 | reg_write(gspca_dev->dev, 0x00, 0x816b, Data); | 859 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); |
862 | 860 | ||
863 | /* write_vector(gspca_dev, spca500_visual_defaults); */ | 861 | /* write_vector(gspca_dev, spca500_visual_defaults); */ |
864 | break; | 862 | break; |
865 | case KodakEZ200: /* Kodak EZ200 */ | 863 | case KodakEZ200: /* Kodak EZ200 */ |
866 | 864 | ||
@@ -869,8 +867,8 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
869 | if (err < 0) | 867 | if (err < 0) |
870 | PDEBUG(D_ERR, "spca500_full_reset failed"); | 868 | PDEBUG(D_ERR, "spca500_full_reset failed"); |
871 | /* enable drop packet */ | 869 | /* enable drop packet */ |
872 | reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 870 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); |
873 | reg_write(gspca_dev->dev, 0x00, 0x8880, 0); | 871 | reg_w(gspca_dev->dev, 0x00, 0x8880, 0); |
874 | err = spca50x_setup_qtable(gspca_dev, | 872 | err = spca50x_setup_qtable(gspca_dev, |
875 | 0x00, 0x8800, 0x8840, | 873 | 0x00, 0x8800, 0x8840, |
876 | qtable_kodak_ez200); | 874 | qtable_kodak_ez200); |
@@ -878,18 +876,18 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
878 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 876 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
879 | spca500_setmode(gspca_dev, xmult, ymult); | 877 | spca500_setmode(gspca_dev, xmult, ymult); |
880 | 878 | ||
881 | reg_write(gspca_dev->dev, 0x20, 0x0001, 0x0004); | 879 | reg_w(gspca_dev->dev, 0x20, 0x0001, 0x0004); |
882 | 880 | ||
883 | /* switch to video camera mode */ | 881 | /* switch to video camera mode */ |
884 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 882 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
885 | 883 | ||
886 | if (reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 884 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) |
887 | PDEBUG(D_ERR, "reg_readwait() failed"); | 885 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
888 | 886 | ||
889 | spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1); | 887 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); |
890 | reg_write(gspca_dev->dev, 0x00, 0x816b, Data); | 888 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); |
891 | 889 | ||
892 | /* write_vector(gspca_dev, spca500_visual_defaults); */ | 890 | /* write_vector(gspca_dev, spca500_visual_defaults); */ |
893 | break; | 891 | break; |
894 | 892 | ||
895 | case BenqDC1016: | 893 | case BenqDC1016: |
@@ -902,56 +900,56 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
902 | case ToptroIndus: | 900 | case ToptroIndus: |
903 | case AgfaCl20: | 901 | case AgfaCl20: |
904 | spca500_reinit(gspca_dev); | 902 | spca500_reinit(gspca_dev); |
905 | reg_write(gspca_dev->dev, 0x00, 0x0d01, 0x01); | 903 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x01); |
906 | /* enable drop packet */ | 904 | /* enable drop packet */ |
907 | reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 905 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); |
908 | 906 | ||
909 | err = spca50x_setup_qtable(gspca_dev, | 907 | err = spca50x_setup_qtable(gspca_dev, |
910 | 0x00, 0x8800, 0x8840, qtable_pocketdv); | 908 | 0x00, 0x8800, 0x8840, qtable_pocketdv); |
911 | if (err < 0) | 909 | if (err < 0) |
912 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 910 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
913 | reg_write(gspca_dev->dev, 0x00, 0x8880, 2); | 911 | reg_w(gspca_dev->dev, 0x00, 0x8880, 2); |
914 | 912 | ||
915 | /* familycam Quicksmart pocketDV stuff */ | 913 | /* familycam Quicksmart pocketDV stuff */ |
916 | reg_write(gspca_dev->dev, 0x00, 0x800a, 0x00); | 914 | reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00); |
917 | /* Set agc transfer: synced inbetween frames */ | 915 | /* Set agc transfer: synced inbetween frames */ |
918 | reg_write(gspca_dev->dev, 0x00, 0x820f, 0x01); | 916 | reg_w(gspca_dev->dev, 0x00, 0x820f, 0x01); |
919 | /* Init SDRAM - needed for SDRAM access */ | 917 | /* Init SDRAM - needed for SDRAM access */ |
920 | reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04); | 918 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); |
921 | 919 | ||
922 | spca500_setmode(gspca_dev, xmult, ymult); | 920 | spca500_setmode(gspca_dev, xmult, ymult); |
923 | /* switch to video camera mode */ | 921 | /* switch to video camera mode */ |
924 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 922 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
925 | 923 | ||
926 | reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44); | 924 | reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44); |
927 | 925 | ||
928 | spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1); | 926 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); |
929 | reg_write(gspca_dev->dev, 0x00, 0x816b, Data); | 927 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); |
930 | break; | 928 | break; |
931 | case LogitechTraveler: | 929 | case LogitechTraveler: |
932 | case LogitechClickSmart510: | 930 | case LogitechClickSmart510: |
933 | reg_write(gspca_dev->dev, 0x02, 0x00, 0x00); | 931 | reg_w(gspca_dev->dev, 0x02, 0x00, 0x00); |
934 | /* enable drop packet */ | 932 | /* enable drop packet */ |
935 | reg_write(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 933 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); |
936 | 934 | ||
937 | err = spca50x_setup_qtable(gspca_dev, | 935 | err = spca50x_setup_qtable(gspca_dev, |
938 | 0x00, 0x8800, | 936 | 0x00, 0x8800, |
939 | 0x8840, qtable_creative_pccam); | 937 | 0x8840, qtable_creative_pccam); |
940 | if (err < 0) | 938 | if (err < 0) |
941 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 939 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
942 | reg_write(gspca_dev->dev, 0x00, 0x8880, 3); | 940 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); |
943 | reg_write(gspca_dev->dev, 0x00, 0x800a, 0x00); | 941 | reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00); |
944 | /* Init SDRAM - needed for SDRAM access */ | 942 | /* Init SDRAM - needed for SDRAM access */ |
945 | reg_write(gspca_dev->dev, 0x00, 0x870a, 0x04); | 943 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); |
946 | 944 | ||
947 | spca500_setmode(gspca_dev, xmult, ymult); | 945 | spca500_setmode(gspca_dev, xmult, ymult); |
948 | 946 | ||
949 | /* switch to video camera mode */ | 947 | /* switch to video camera mode */ |
950 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 948 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
951 | reg_readwait(gspca_dev->dev, 0, 0x8000, 0x44); | 949 | reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44); |
952 | 950 | ||
953 | spca5xxRegRead(gspca_dev->dev, 0x816b, &Data, 1); | 951 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); |
954 | reg_write(gspca_dev->dev, 0x00, 0x816b, Data); | 952 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); |
955 | write_vector(gspca_dev, Clicksmart510_defaults); | 953 | write_vector(gspca_dev, Clicksmart510_defaults); |
956 | break; | 954 | break; |
957 | } | 955 | } |
@@ -959,13 +957,13 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
959 | 957 | ||
960 | static void sd_stopN(struct gspca_dev *gspca_dev) | 958 | static void sd_stopN(struct gspca_dev *gspca_dev) |
961 | { | 959 | { |
962 | __u8 data = 0; | 960 | __u8 data; |
963 | 961 | ||
964 | reg_write(gspca_dev->dev, 0, 0x8003, 0x00); | 962 | reg_w(gspca_dev->dev, 0, 0x8003, 0x00); |
965 | 963 | ||
966 | /* switch to video camera mode */ | 964 | /* switch to video camera mode */ |
967 | reg_write(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 965 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); |
968 | spca5xxRegRead(gspca_dev->dev, 0x8000, &data, 1); | 966 | reg_r(gspca_dev->dev, 0x8000, &data, 1); |
969 | PDEBUG(D_STREAM, "stop SPCA500 done reg8000: 0x%2x", data); | 967 | PDEBUG(D_STREAM, "stop SPCA500 done reg8000: 0x%2x", data); |
970 | } | 968 | } |
971 | 969 | ||
@@ -979,13 +977,13 @@ static void sd_close(struct gspca_dev *gspca_dev) | |||
979 | 977 | ||
980 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 978 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
981 | struct gspca_frame *frame, /* target */ | 979 | struct gspca_frame *frame, /* target */ |
982 | unsigned char *data, /* isoc packet */ | 980 | __u8 *data, /* isoc packet */ |
983 | int len) /* iso packet length */ | 981 | int len) /* iso packet length */ |
984 | { | 982 | { |
985 | struct sd *sd = (struct sd *) gspca_dev; | 983 | struct sd *sd = (struct sd *) gspca_dev; |
986 | int i; | 984 | int i; |
987 | unsigned char *s, *d; | 985 | __u8 *s, *d; |
988 | static unsigned char ffd9[] = {0xff, 0xd9}; | 986 | static __u8 ffd9[] = {0xff, 0xd9}; |
989 | 987 | ||
990 | /* frames are jpeg 4.1.1 without 0xff escape */ | 988 | /* frames are jpeg 4.1.1 without 0xff escape */ |
991 | if (data[0] == 0xff) { | 989 | if (data[0] == 0xff) { |
@@ -997,9 +995,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
997 | ffd9, 2); | 995 | ffd9, 2); |
998 | 996 | ||
999 | /* put the JPEG header in the new frame */ | 997 | /* put the JPEG header in the new frame */ |
1000 | jpeg_put_header(gspca_dev, frame, | 998 | jpeg_put_header(gspca_dev, frame, sd->qindex, 0x22); |
1001 | ((struct sd *) gspca_dev)->qindex, | ||
1002 | 0x22); | ||
1003 | 999 | ||
1004 | data += SPCA500_OFFSET_DATA; | 1000 | data += SPCA500_OFFSET_DATA; |
1005 | len -= SPCA500_OFFSET_DATA; | 1001 | len -= SPCA500_OFFSET_DATA; |
@@ -1031,43 +1027,52 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
1031 | { | 1027 | { |
1032 | struct sd *sd = (struct sd *) gspca_dev; | 1028 | struct sd *sd = (struct sd *) gspca_dev; |
1033 | 1029 | ||
1034 | reg_write(gspca_dev->dev, 0x00, 0x8167, | 1030 | reg_w(gspca_dev->dev, 0x00, 0x8167, |
1035 | (__u8) (sd->brightness - 128)); | 1031 | (__u8) (sd->brightness - 128)); |
1036 | } | 1032 | } |
1037 | 1033 | ||
1038 | static void getbrightness(struct gspca_dev *gspca_dev) | 1034 | static void getbrightness(struct gspca_dev *gspca_dev) |
1039 | { | 1035 | { |
1040 | struct sd *sd = (struct sd *) gspca_dev; | 1036 | struct sd *sd = (struct sd *) gspca_dev; |
1037 | int ret; | ||
1041 | 1038 | ||
1042 | sd->brightness = reg_read(gspca_dev->dev, 0x00, 0x8167, 1) + 128; | 1039 | ret = reg_r_12(gspca_dev->dev, 0x00, 0x8167, 1); |
1040 | if (ret >= 0) | ||
1041 | sd->brightness = ret + 128; | ||
1043 | } | 1042 | } |
1044 | 1043 | ||
1045 | static void setcontrast(struct gspca_dev *gspca_dev) | 1044 | static void setcontrast(struct gspca_dev *gspca_dev) |
1046 | { | 1045 | { |
1047 | struct sd *sd = (struct sd *) gspca_dev; | 1046 | struct sd *sd = (struct sd *) gspca_dev; |
1048 | 1047 | ||
1049 | reg_write(gspca_dev->dev, 0x00, 0x8168, sd->contrast >> 2); | 1048 | reg_w(gspca_dev->dev, 0x00, 0x8168, sd->contrast); |
1050 | } | 1049 | } |
1051 | 1050 | ||
1052 | static void getcontrast(struct gspca_dev *gspca_dev) | 1051 | static void getcontrast(struct gspca_dev *gspca_dev) |
1053 | { | 1052 | { |
1054 | struct sd *sd = (struct sd *) gspca_dev; | 1053 | struct sd *sd = (struct sd *) gspca_dev; |
1054 | int ret; | ||
1055 | 1055 | ||
1056 | sd->contrast = reg_read(gspca_dev->dev, 0x0, 0x8168, 1) << 2; | 1056 | ret = reg_r_12(gspca_dev->dev, 0x0, 0x8168, 1); |
1057 | if (ret >= 0) | ||
1058 | sd->contrast = ret; | ||
1057 | } | 1059 | } |
1058 | 1060 | ||
1059 | static void setcolors(struct gspca_dev *gspca_dev) | 1061 | static void setcolors(struct gspca_dev *gspca_dev) |
1060 | { | 1062 | { |
1061 | struct sd *sd = (struct sd *) gspca_dev; | 1063 | struct sd *sd = (struct sd *) gspca_dev; |
1062 | 1064 | ||
1063 | reg_write(gspca_dev->dev, 0x00, 0x8169, sd->colors >> 2); | 1065 | reg_w(gspca_dev->dev, 0x00, 0x8169, sd->colors); |
1064 | } | 1066 | } |
1065 | 1067 | ||
1066 | static void getcolors(struct gspca_dev *gspca_dev) | 1068 | static void getcolors(struct gspca_dev *gspca_dev) |
1067 | { | 1069 | { |
1068 | struct sd *sd = (struct sd *) gspca_dev; | 1070 | struct sd *sd = (struct sd *) gspca_dev; |
1071 | int ret; | ||
1069 | 1072 | ||
1070 | sd->colors = reg_read(gspca_dev->dev, 0x0, 0x8169, 1) << 2; | 1073 | ret = reg_r_12(gspca_dev->dev, 0x0, 0x8169, 1); |
1074 | if (ret >= 0) | ||
1075 | sd->colors = ret; | ||
1071 | } | 1076 | } |
1072 | 1077 | ||
1073 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 1078 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
@@ -1131,7 +1136,7 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | |||
1131 | static struct sd_desc sd_desc = { | 1136 | static struct sd_desc sd_desc = { |
1132 | .name = MODULE_NAME, | 1137 | .name = MODULE_NAME, |
1133 | .ctrls = sd_ctrls, | 1138 | .ctrls = sd_ctrls, |
1134 | .nctrls = sizeof sd_ctrls / sizeof sd_ctrls[0], | 1139 | .nctrls = ARRAY_SIZE(sd_ctrls), |
1135 | .config = sd_config, | 1140 | .config = sd_config, |
1136 | .open = sd_open, | 1141 | .open = sd_open, |
1137 | .start = sd_start, | 1142 | .start = sd_start, |
@@ -1143,7 +1148,7 @@ static struct sd_desc sd_desc = { | |||
1143 | 1148 | ||
1144 | /* -- module initialisation -- */ | 1149 | /* -- module initialisation -- */ |
1145 | #define DVNM(name) .driver_info = (kernel_ulong_t) name | 1150 | #define DVNM(name) .driver_info = (kernel_ulong_t) name |
1146 | static __devinitdata struct usb_device_id device_table[] = { | 1151 | static const __devinitdata struct usb_device_id device_table[] = { |
1147 | {USB_DEVICE(0x040a, 0x0300), DVNM("Kodak EZ200")}, | 1152 | {USB_DEVICE(0x040a, 0x0300), DVNM("Kodak EZ200")}, |
1148 | {USB_DEVICE(0x041e, 0x400a), DVNM("Creative PC-CAM 300")}, | 1153 | {USB_DEVICE(0x041e, 0x400a), DVNM("Creative PC-CAM 300")}, |
1149 | {USB_DEVICE(0x046d, 0x0890), DVNM("Logitech QuickCam traveler")}, | 1154 | {USB_DEVICE(0x046d, 0x0890), DVNM("Logitech QuickCam traveler")}, |