aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/ov519.c
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-07-04 10:16:16 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:16:53 -0400
commita5ae2062252e697d38e53dbbeb91460252208914 (patch)
tree38706e9f36e2d93cd3dee8eea639bb74a17b3efa /drivers/media/video/gspca/ov519.c
parent54ab92ca05550550bcec2462de2605f35d079b66 (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/ov519.c')
-rw-r--r--drivers/media/video/gspca/ov519.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index 7d6237f18ba0..d92729ac41f0 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -24,8 +24,8 @@
24 24
25#include "gspca.h" 25#include "gspca.h"
26 26
27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 0) 27#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 4)
28static const char version[] = "2.1.0"; 28static const char version[] = "2.1.4";
29 29
30MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); 30MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
31MODULE_DESCRIPTION("OV519 USB Camera Driver"); 31MODULE_DESCRIPTION("OV519 USB Camera Driver");
@@ -266,15 +266,15 @@ static unsigned char ov7670_abs_to_sm(unsigned char v)
266static int reg_w(struct sd *sd, __u16 index, __u8 value) 266static int reg_w(struct sd *sd, __u16 index, __u8 value)
267{ 267{
268 int ret; 268 int ret;
269 __u8 buf[4]; 269 __u8 data;
270 270
271 buf[0] = value; 271 data = value;
272 ret = usb_control_msg(sd->gspca_dev.dev, 272 ret = usb_control_msg(sd->gspca_dev.dev,
273 usb_sndctrlpipe(sd->gspca_dev.dev, 0), 273 usb_sndctrlpipe(sd->gspca_dev.dev, 0),
274 1, /* REQ_IO (ov518/519) */ 274 1, /* REQ_IO (ov518/519) */
275 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 275 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
276 0, index, 276 0, index,
277 &buf[0], 1, 500); 277 &data, 1, 500);
278 if (ret < 0) 278 if (ret < 0)
279 PDEBUG(D_ERR, "Write reg [%02x] %02x failed", index, value); 279 PDEBUG(D_ERR, "Write reg [%02x] %02x failed", index, value);
280 return ret; 280 return ret;
@@ -285,16 +285,16 @@ static int reg_w(struct sd *sd, __u16 index, __u8 value)
285static int reg_r(struct sd *sd, __u16 index) 285static int reg_r(struct sd *sd, __u16 index)
286{ 286{
287 int ret; 287 int ret;
288 __u8 buf[4]; 288 __u8 data;
289 289
290 ret = usb_control_msg(sd->gspca_dev.dev, 290 ret = usb_control_msg(sd->gspca_dev.dev,
291 usb_rcvctrlpipe(sd->gspca_dev.dev, 0), 291 usb_rcvctrlpipe(sd->gspca_dev.dev, 0),
292 1, /* REQ_IO */ 292 1, /* REQ_IO */
293 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 293 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
294 0, index, &buf[0], 1, 500); 294 0, index, &data, 1, 500);
295 295
296 if (ret >= 0) 296 if (ret >= 0)
297 ret = buf[0]; 297 ret = data;
298 else 298 else
299 PDEBUG(D_ERR, "Read reg [0x%02x] failed", index); 299 PDEBUG(D_ERR, "Read reg [0x%02x] failed", index);
300 return ret; 300 return ret;
@@ -302,7 +302,7 @@ static int reg_r(struct sd *sd, __u16 index)
302 302
303/* Read 8 values from a OV519 register */ 303/* Read 8 values from a OV519 register */
304static int reg_r8(struct sd *sd, 304static int reg_r8(struct sd *sd,
305 __u16 index) 305 __u16 index)
306{ 306{
307 int ret; 307 int ret;
308 __u8 buf[8]; 308 __u8 buf[8];
@@ -528,7 +528,7 @@ struct ov_i2c_regvals {
528}; 528};
529 529
530static int write_regvals(struct sd *sd, 530static int write_regvals(struct sd *sd,
531 struct ov_regvals *regvals, 531 const struct ov_regvals *regvals,
532 int n) 532 int n)
533{ 533{
534 int rc; 534 int rc;
@@ -543,7 +543,7 @@ static int write_regvals(struct sd *sd,
543} 543}
544 544
545static int write_i2c_regvals(struct sd *sd, 545static int write_i2c_regvals(struct sd *sd,
546 struct ov_i2c_regvals *regvals, 546 const struct ov_i2c_regvals *regvals,
547 int n) 547 int n)
548{ 548{
549 int rc; 549 int rc;
@@ -569,7 +569,7 @@ static int write_i2c_regvals(struct sd *sd,
569static int ov8xx0_configure(struct sd *sd) 569static int ov8xx0_configure(struct sd *sd)
570{ 570{
571 int rc; 571 int rc;
572 static struct ov_i2c_regvals norm_8610[] = { 572 static const struct ov_i2c_regvals norm_8610[] = {
573 { 0x12, 0x80 }, 573 { 0x12, 0x80 },
574 { 0x00, 0x00 }, 574 { 0x00, 0x00 },
575 { 0x01, 0x80 }, 575 { 0x01, 0x80 },
@@ -707,7 +707,7 @@ static int ov7xx0_configure(struct sd *sd)
707 * 0x05 (old driver setting): very overexposed, too much 707 * 0x05 (old driver setting): very overexposed, too much
708 * contrast 708 * contrast
709 */ 709 */
710 static struct ov_i2c_regvals norm_7610[] = { 710 static const struct ov_i2c_regvals norm_7610[] = {
711 { 0x10, 0xff }, 711 { 0x10, 0xff },
712 { 0x16, 0x06 }, 712 { 0x16, 0x06 },
713 { 0x28, 0x24 }, 713 { 0x28, 0x24 },
@@ -737,7 +737,7 @@ static int ov7xx0_configure(struct sd *sd)
737 { 0x0d, 0x24 }, 737 { 0x0d, 0x24 },
738 }; 738 };
739 739
740 static struct ov_i2c_regvals norm_7620[] = { 740 static const struct ov_i2c_regvals norm_7620[] = {
741 { 0x00, 0x00 }, /* gain */ 741 { 0x00, 0x00 }, /* gain */
742 { 0x01, 0x80 }, /* blue gain */ 742 { 0x01, 0x80 }, /* blue gain */
743 { 0x02, 0x80 }, /* red gain */ 743 { 0x02, 0x80 }, /* red gain */
@@ -804,14 +804,14 @@ static int ov7xx0_configure(struct sd *sd)
804 }; 804 };
805 805
806 /* 7640 and 7648. The defaults should be OK for most registers. */ 806 /* 7640 and 7648. The defaults should be OK for most registers. */
807 static struct ov_i2c_regvals norm_7640[] = { 807 static const struct ov_i2c_regvals norm_7640[] = {
808 { 0x12, 0x80 }, 808 { 0x12, 0x80 },
809 { 0x12, 0x14 }, 809 { 0x12, 0x14 },
810 }; 810 };
811 811
812 /* 7670. Defaults taken from OmniVision provided data, 812 /* 7670. Defaults taken from OmniVision provided data,
813 * as provided by Jonathan Corbet of OLPC */ 813 * as provided by Jonathan Corbet of OLPC */
814 static struct ov_i2c_regvals norm_7670[] = { 814 static const struct ov_i2c_regvals norm_7670[] = {
815 { OV7670_REG_COM7, OV7670_COM7_RESET }, 815 { OV7670_REG_COM7, OV7670_COM7_RESET },
816 { OV7670_REG_TSLB, 0x04 }, /* OV */ 816 { OV7670_REG_TSLB, 0x04 }, /* OV */
817 { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */ 817 { OV7670_REG_COM7, OV7670_COM7_FMT_VGA }, /* VGA */
@@ -1075,7 +1075,7 @@ static int ov7xx0_configure(struct sd *sd)
1075static int ov6xx0_configure(struct sd *sd) 1075static int ov6xx0_configure(struct sd *sd)
1076{ 1076{
1077 int rc; 1077 int rc;
1078 static struct ov_i2c_regvals norm_6x20[] = { 1078 static const struct ov_i2c_regvals norm_6x20[] = {
1079 { 0x12, 0x80 }, /* reset */ 1079 { 0x12, 0x80 }, /* reset */
1080 { 0x11, 0x01 }, 1080 { 0x11, 0x01 },
1081 { 0x03, 0x60 }, 1081 { 0x03, 0x60 },
@@ -1118,7 +1118,7 @@ static int ov6xx0_configure(struct sd *sd)
1118/* Toggle 0x12[2] off and on here? */ 1118/* Toggle 0x12[2] off and on here? */
1119 }; 1119 };
1120 1120
1121 static struct ov_i2c_regvals norm_6x30[] = { 1121 static const struct ov_i2c_regvals norm_6x30[] = {
1122 { 0x12, 0x80 }, /* Reset */ 1122 { 0x12, 0x80 }, /* Reset */
1123 { 0x00, 0x1f }, /* Gain */ 1123 { 0x00, 0x1f }, /* Gain */
1124 { 0x01, 0x99 }, /* Blue gain */ 1124 { 0x01, 0x99 }, /* Blue gain */
@@ -1284,7 +1284,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
1284 struct cam *cam; 1284 struct cam *cam;
1285 1285
1286/* (from ov519_configure) */ 1286/* (from ov519_configure) */
1287 static struct ov_regvals init_519[] = { 1287 static const struct ov_regvals init_519[] = {
1288 { 0x5a, 0x6d }, /* EnableSystem */ 1288 { 0x5a, 0x6d }, /* EnableSystem */
1289/* jfm trace usbsnoop3-1.txt */ 1289/* jfm trace usbsnoop3-1.txt */
1290/* jfm 53 = fb */ 1290/* jfm 53 = fb */
@@ -1302,8 +1302,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
1302 /* windows reads 0x55 at this point*/ 1302 /* windows reads 0x55 at this point*/
1303 }; 1303 };
1304 1304
1305 if (write_regvals(sd, init_519, 1305 if (write_regvals(sd, init_519, ARRAY_SIZE(init_519)))
1306 sizeof init_519 / sizeof init_519[0]))
1307 goto error; 1306 goto error;
1308/* jfm: not seen in windows trace */ 1307/* jfm: not seen in windows trace */
1309 if (ov519_init_compression(sd)) 1308 if (ov519_init_compression(sd))
@@ -1389,7 +1388,7 @@ static int sd_open(struct gspca_dev *gspca_dev)
1389static int ov519_mode_init_regs(struct sd *sd, 1388static int ov519_mode_init_regs(struct sd *sd,
1390 int width, int height) 1389 int width, int height)
1391{ 1390{
1392 static struct ov_regvals mode_init_519_ov7670[] = { 1391 static const struct ov_regvals mode_init_519_ov7670[] = {
1393 { 0x5d, 0x03 }, /* Turn off suspend mode */ 1392 { 0x5d, 0x03 }, /* Turn off suspend mode */
1394 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ 1393 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
1395 { 0x54, 0x0f }, /* bit2 (jpeg enable) */ 1394 { 0x54, 0x0f }, /* bit2 (jpeg enable) */
@@ -1412,7 +1411,7 @@ static int ov519_mode_init_regs(struct sd *sd,
1412 /* windows reads 0x55 at this point, why? */ 1411 /* windows reads 0x55 at this point, why? */
1413 }; 1412 };
1414 1413
1415 static struct ov_regvals mode_init_519[] = { 1414 static const struct ov_regvals mode_init_519[] = {
1416 { 0x5d, 0x03 }, /* Turn off suspend mode */ 1415 { 0x5d, 0x03 }, /* Turn off suspend mode */
1417 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */ 1416 { 0x53, 0x9f }, /* was 9b in 1.65-1.08 */
1418 { 0x54, 0x0f }, /* bit2 (jpeg enable) */ 1417 { 0x54, 0x0f }, /* bit2 (jpeg enable) */
@@ -1448,12 +1447,11 @@ static int ov519_mode_init_regs(struct sd *sd,
1448 /******** Set the mode ********/ 1447 /******** Set the mode ********/
1449 if (sd->sensor != SEN_OV7670) { 1448 if (sd->sensor != SEN_OV7670) {
1450 if (write_regvals(sd, mode_init_519, 1449 if (write_regvals(sd, mode_init_519,
1451 sizeof mode_init_519 / sizeof mode_init_519[0])) 1450 ARRAY_SIZE(mode_init_519)))
1452 return -EIO; 1451 return -EIO;
1453 } else { 1452 } else {
1454 if (write_regvals(sd, mode_init_519_ov7670, 1453 if (write_regvals(sd, mode_init_519_ov7670,
1455 sizeof mode_init_519_ov7670 1454 ARRAY_SIZE(mode_init_519_ov7670)))
1456 / sizeof mode_init_519_ov7670[0]))
1457 return -EIO; 1455 return -EIO;
1458 } 1456 }
1459 1457
@@ -1883,7 +1881,7 @@ static void sd_close(struct gspca_dev *gspca_dev)
1883 1881
1884static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1882static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1885 struct gspca_frame *frame, /* target */ 1883 struct gspca_frame *frame, /* target */
1886 unsigned char *data, /* isoc packet */ 1884 __u8 *data, /* isoc packet */
1887 int len) /* iso packet length */ 1885 int len) /* iso packet length */
1888{ 1886{
1889 /* Header of ov519 is 16 bytes: 1887 /* Header of ov519 is 16 bytes:
@@ -1982,7 +1980,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
1982 case SEN_OV6630: 1980 case SEN_OV6630:
1983 i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f); 1981 i2c_w_mask(sd, OV7610_REG_CNT, val >> 4, 0x0f);
1984 case SEN_OV8610: { 1982 case SEN_OV8610: {
1985 static __u8 ctab[] = { 1983 static const __u8 ctab[] = {
1986 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f 1984 0x03, 0x09, 0x0b, 0x0f, 0x53, 0x6f, 0x35, 0x7f
1987 }; 1985 };
1988 1986
@@ -1991,7 +1989,7 @@ static void setcontrast(struct gspca_dev *gspca_dev)
1991 break; 1989 break;
1992 } 1990 }
1993 case SEN_OV7620: { 1991 case SEN_OV7620: {
1994 static __u8 ctab[] = { 1992 static const __u8 ctab[] = {
1995 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57, 1993 0x01, 0x05, 0x09, 0x11, 0x15, 0x35, 0x37, 0x57,
1996 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff 1994 0x5b, 0xa5, 0xa7, 0xc7, 0xc9, 0xcf, 0xef, 0xff
1997 }; 1995 };
@@ -2104,7 +2102,7 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val)
2104} 2102}
2105 2103
2106/* sub-driver description */ 2104/* sub-driver description */
2107static struct sd_desc sd_desc = { 2105static const struct sd_desc sd_desc = {
2108 .name = MODULE_NAME, 2106 .name = MODULE_NAME,
2109 .ctrls = sd_ctrls, 2107 .ctrls = sd_ctrls,
2110 .nctrls = ARRAY_SIZE(sd_ctrls), 2108 .nctrls = ARRAY_SIZE(sd_ctrls),
@@ -2119,7 +2117,7 @@ static struct sd_desc sd_desc = {
2119 2117
2120/* -- module initialisation -- */ 2118/* -- module initialisation -- */
2121#define DVNM(name) .driver_info = (kernel_ulong_t) name 2119#define DVNM(name) .driver_info = (kernel_ulong_t) name
2122static __devinitdata struct usb_device_id device_table[] = { 2120static const __devinitdata struct usb_device_id device_table[] = {
2123 {USB_DEVICE(0x041e, 0x4052), DVNM("Creative Live! VISTA IM")}, 2121 {USB_DEVICE(0x041e, 0x4052), DVNM("Creative Live! VISTA IM")},
2124 {USB_DEVICE(0x041e, 0x405f), DVNM("Creative Live! VISTA VF0330")}, 2122 {USB_DEVICE(0x041e, 0x405f), DVNM("Creative Live! VISTA VF0330")},
2125 {USB_DEVICE(0x041e, 0x4060), DVNM("Creative Live! VISTA VF0350")}, 2123 {USB_DEVICE(0x041e, 0x4060), DVNM("Creative Live! VISTA VF0350")},