aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorErik Andrén <erik.andren@gmail.com>2008-11-27 11:42:45 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-12-30 06:39:53 -0500
commit905aabafc4051a8313168b1dd20949b8108fbbb2 (patch)
treebd0d7abeb79f65cc088069e4e304f97cc82102de /drivers/media
parentedbfbdb3bdcf9ae90ce06b92636a07c05224fe45 (diff)
V4L/DVB (10019): m5602: Let the ov9650 use the common read sensor function
Signed-off-by: Erik Andrén <erik.andren@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/gspca/m5602/m5602_ov9650.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/media/video/gspca/m5602/m5602_ov9650.c b/drivers/media/video/gspca/m5602/m5602_ov9650.c
index 197a2026ec5d..e58c84645b45 100644
--- a/drivers/media/video/gspca/m5602/m5602_ov9650.c
+++ b/drivers/media/video/gspca/m5602/m5602_ov9650.c
@@ -128,10 +128,10 @@ int ov9650_probe(struct sd *sd)
128 m5602_write_bridge(sd, preinit_ov9650[i][1], data); 128 m5602_write_bridge(sd, preinit_ov9650[i][1], data);
129 } 129 }
130 130
131 if (ov9650_read_sensor(sd, OV9650_PID, &prod_id, 1)) 131 if (m5602_read_sensor(sd, OV9650_PID, &prod_id, 1))
132 return -ENODEV; 132 return -ENODEV;
133 133
134 if (ov9650_read_sensor(sd, OV9650_VER, &ver_id, 1)) 134 if (m5602_read_sensor(sd, OV9650_VER, &ver_id, 1))
135 return -ENODEV; 135 return -ENODEV;
136 136
137 if ((prod_id == 0x96) && (ver_id == 0x52)) { 137 if ((prod_id == 0x96) && (ver_id == 0x52)) {
@@ -197,17 +197,17 @@ int ov9650_get_exposure(struct gspca_dev *gspca_dev, __s32 *val)
197 u8 i2c_data; 197 u8 i2c_data;
198 int err; 198 int err;
199 199
200 err = ov9650_read_sensor(sd, OV9650_COM1, &i2c_data, 1); 200 err = m5602_read_sensor(sd, OV9650_COM1, &i2c_data, 1);
201 if (err < 0) 201 if (err < 0)
202 goto out; 202 goto out;
203 *val = i2c_data & 0x03; 203 *val = i2c_data & 0x03;
204 204
205 err = ov9650_read_sensor(sd, OV9650_AECH, &i2c_data, 1); 205 err = m5602_read_sensor(sd, OV9650_AECH, &i2c_data, 1);
206 if (err < 0) 206 if (err < 0)
207 goto out; 207 goto out;
208 *val |= (i2c_data << 2); 208 *val |= (i2c_data << 2);
209 209
210 err = ov9650_read_sensor(sd, OV9650_AECHM, &i2c_data, 1); 210 err = m5602_read_sensor(sd, OV9650_AECHM, &i2c_data, 1);
211 if (err < 0) 211 if (err < 0)
212 goto out; 212 goto out;
213 *val |= (i2c_data & 0x3f) << 10; 213 *val |= (i2c_data & 0x3f) << 10;
@@ -254,10 +254,10 @@ int ov9650_get_gain(struct gspca_dev *gspca_dev, __s32 *val)
254 u8 i2c_data; 254 u8 i2c_data;
255 struct sd *sd = (struct sd *) gspca_dev; 255 struct sd *sd = (struct sd *) gspca_dev;
256 256
257 ov9650_read_sensor(sd, OV9650_VREF, &i2c_data, 1); 257 m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1);
258 *val = (i2c_data & 0x03) << 8; 258 *val = (i2c_data & 0x03) << 8;
259 259
260 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 260 err = m5602_read_sensor(sd, OV9650_GAIN, &i2c_data, 1);
261 *val |= i2c_data; 261 *val |= i2c_data;
262 PDEBUG(D_V4L2, "Read gain %d", *val); 262 PDEBUG(D_V4L2, "Read gain %d", *val);
263 return err; 263 return err;
@@ -272,7 +272,7 @@ int ov9650_set_gain(struct gspca_dev *gspca_dev, __s32 val)
272 /* The 2 MSB */ 272 /* The 2 MSB */
273 /* Read the OV9650_VREF register first to avoid 273 /* Read the OV9650_VREF register first to avoid
274 corrupting the VREF high and low bits */ 274 corrupting the VREF high and low bits */
275 ov9650_read_sensor(sd, OV9650_VREF, &i2c_data, 1); 275 m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1);
276 /* Mask away all uninteresting bits */ 276 /* Mask away all uninteresting bits */
277 i2c_data = ((val & 0x0300) >> 2) | 277 i2c_data = ((val & 0x0300) >> 2) |
278 (i2c_data & 0x3F); 278 (i2c_data & 0x3F);
@@ -290,7 +290,7 @@ int ov9650_get_red_balance(struct gspca_dev *gspca_dev, __s32 *val)
290 u8 i2c_data; 290 u8 i2c_data;
291 struct sd *sd = (struct sd *) gspca_dev; 291 struct sd *sd = (struct sd *) gspca_dev;
292 292
293 err = ov9650_read_sensor(sd, OV9650_RED, &i2c_data, 1); 293 err = m5602_read_sensor(sd, OV9650_RED, &i2c_data, 1);
294 *val = i2c_data; 294 *val = i2c_data;
295 295
296 PDEBUG(D_V4L2, "Read red gain %d", *val); 296 PDEBUG(D_V4L2, "Read red gain %d", *val);
@@ -319,7 +319,7 @@ int ov9650_get_blue_balance(struct gspca_dev *gspca_dev, __s32 *val)
319 u8 i2c_data; 319 u8 i2c_data;
320 struct sd *sd = (struct sd *) gspca_dev; 320 struct sd *sd = (struct sd *) gspca_dev;
321 321
322 err = ov9650_read_sensor(sd, OV9650_BLUE, &i2c_data, 1); 322 err = m5602_read_sensor(sd, OV9650_BLUE, &i2c_data, 1);
323 *val = i2c_data; 323 *val = i2c_data;
324 324
325 PDEBUG(D_V4L2, "Read blue gain %d", *val); 325 PDEBUG(D_V4L2, "Read blue gain %d", *val);
@@ -348,7 +348,7 @@ int ov9650_get_hflip(struct gspca_dev *gspca_dev, __s32 *val)
348 u8 i2c_data; 348 u8 i2c_data;
349 struct sd *sd = (struct sd *) gspca_dev; 349 struct sd *sd = (struct sd *) gspca_dev;
350 350
351 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 351 err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1);
352 if (dmi_check_system(ov9650_flip_dmi_table)) 352 if (dmi_check_system(ov9650_flip_dmi_table))
353 *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1; 353 *val = ((i2c_data & OV9650_HFLIP) >> 5) ? 0 : 1;
354 else 354 else
@@ -365,7 +365,7 @@ int ov9650_set_hflip(struct gspca_dev *gspca_dev, __s32 val)
365 struct sd *sd = (struct sd *) gspca_dev; 365 struct sd *sd = (struct sd *) gspca_dev;
366 366
367 PDEBUG(D_V4L2, "Set horizontal flip to %d", val); 367 PDEBUG(D_V4L2, "Set horizontal flip to %d", val);
368 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 368 err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1);
369 if (err < 0) 369 if (err < 0)
370 goto out; 370 goto out;
371 371
@@ -387,7 +387,7 @@ int ov9650_get_vflip(struct gspca_dev *gspca_dev, __s32 *val)
387 u8 i2c_data; 387 u8 i2c_data;
388 struct sd *sd = (struct sd *) gspca_dev; 388 struct sd *sd = (struct sd *) gspca_dev;
389 389
390 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 390 err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1);
391 if (dmi_check_system(ov9650_flip_dmi_table)) 391 if (dmi_check_system(ov9650_flip_dmi_table))
392 *val = ((i2c_data & 0x10) >> 4) ? 0 : 1; 392 *val = ((i2c_data & 0x10) >> 4) ? 0 : 1;
393 else 393 else
@@ -404,7 +404,7 @@ int ov9650_set_vflip(struct gspca_dev *gspca_dev, __s32 val)
404 struct sd *sd = (struct sd *) gspca_dev; 404 struct sd *sd = (struct sd *) gspca_dev;
405 405
406 PDEBUG(D_V4L2, "Set vertical flip to %d", val); 406 PDEBUG(D_V4L2, "Set vertical flip to %d", val);
407 err = ov9650_read_sensor(sd, OV9650_MVFP, &i2c_data, 1); 407 err = m5602_read_sensor(sd, OV9650_MVFP, &i2c_data, 1);
408 if (err < 0) 408 if (err < 0)
409 goto out; 409 goto out;
410 410
@@ -426,12 +426,12 @@ int ov9650_get_brightness(struct gspca_dev *gspca_dev, __s32 *val)
426 u8 i2c_data; 426 u8 i2c_data;
427 struct sd *sd = (struct sd *) gspca_dev; 427 struct sd *sd = (struct sd *) gspca_dev;
428 428
429 err = ov9650_read_sensor(sd, OV9650_VREF, &i2c_data, 1); 429 err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1);
430 if (err < 0) 430 if (err < 0)
431 goto out; 431 goto out;
432 *val = (i2c_data & 0x03) << 8; 432 *val = (i2c_data & 0x03) << 8;
433 433
434 err = ov9650_read_sensor(sd, OV9650_GAIN, &i2c_data, 1); 434 err = m5602_read_sensor(sd, OV9650_GAIN, &i2c_data, 1);
435 *val |= i2c_data; 435 *val |= i2c_data;
436 PDEBUG(D_V4L2, "Read gain %d", *val); 436 PDEBUG(D_V4L2, "Read gain %d", *val);
437out: 437out:
@@ -448,7 +448,7 @@ int ov9650_set_brightness(struct gspca_dev *gspca_dev, __s32 val)
448 448
449 /* Read the OV9650_VREF register first to avoid 449 /* Read the OV9650_VREF register first to avoid
450 corrupting the VREF high and low bits */ 450 corrupting the VREF high and low bits */
451 err = ov9650_read_sensor(sd, OV9650_VREF, &i2c_data, 1); 451 err = m5602_read_sensor(sd, OV9650_VREF, &i2c_data, 1);
452 if (err < 0) 452 if (err < 0)
453 goto out; 453 goto out;
454 454
@@ -472,7 +472,7 @@ int ov9650_get_auto_white_balance(struct gspca_dev *gspca_dev, __s32 *val)
472 u8 i2c_data; 472 u8 i2c_data;
473 struct sd *sd = (struct sd *) gspca_dev; 473 struct sd *sd = (struct sd *) gspca_dev;
474 474
475 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 475 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
476 *val = (i2c_data & OV9650_AWB_EN) >> 1; 476 *val = (i2c_data & OV9650_AWB_EN) >> 1;
477 PDEBUG(D_V4L2, "Read auto white balance %d", *val); 477 PDEBUG(D_V4L2, "Read auto white balance %d", *val);
478 478
@@ -486,7 +486,7 @@ int ov9650_set_auto_white_balance(struct gspca_dev *gspca_dev, __s32 val)
486 struct sd *sd = (struct sd *) gspca_dev; 486 struct sd *sd = (struct sd *) gspca_dev;
487 487
488 PDEBUG(D_V4L2, "Set auto white balance to %d", val); 488 PDEBUG(D_V4L2, "Set auto white balance to %d", val);
489 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 489 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
490 if (err < 0) 490 if (err < 0)
491 goto out; 491 goto out;
492 492
@@ -502,7 +502,7 @@ int ov9650_get_auto_gain(struct gspca_dev *gspca_dev, __s32 *val)
502 u8 i2c_data; 502 u8 i2c_data;
503 struct sd *sd = (struct sd *) gspca_dev; 503 struct sd *sd = (struct sd *) gspca_dev;
504 504
505 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 505 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
506 *val = (i2c_data & OV9650_AGC_EN) >> 2; 506 *val = (i2c_data & OV9650_AGC_EN) >> 2;
507 PDEBUG(D_V4L2, "Read auto gain control %d", *val); 507 PDEBUG(D_V4L2, "Read auto gain control %d", *val);
508 508
@@ -516,7 +516,7 @@ int ov9650_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
516 struct sd *sd = (struct sd *) gspca_dev; 516 struct sd *sd = (struct sd *) gspca_dev;
517 517
518 PDEBUG(D_V4L2, "Set auto gain control to %d", val); 518 PDEBUG(D_V4L2, "Set auto gain control to %d", val);
519 err = ov9650_read_sensor(sd, OV9650_COM8, &i2c_data, 1); 519 err = m5602_read_sensor(sd, OV9650_COM8, &i2c_data, 1);
520 if (err < 0) 520 if (err < 0)
521 goto out; 521 goto out;
522 522
@@ -532,7 +532,7 @@ static void ov9650_dump_registers(struct sd *sd)
532 info("Dumping the ov9650 register state"); 532 info("Dumping the ov9650 register state");
533 for (address = 0; address < 0xa9; address++) { 533 for (address = 0; address < 0xa9; address++) {
534 u8 value; 534 u8 value;
535 ov9650_read_sensor(sd, address, &value, 1); 535 m5602_read_sensor(sd, address, &value, 1);
536 info("register 0x%x contains 0x%x", 536 info("register 0x%x contains 0x%x",
537 address, value); 537 address, value);
538 } 538 }
@@ -544,9 +544,9 @@ static void ov9650_dump_registers(struct sd *sd)
544 u8 old_value, ctrl_value; 544 u8 old_value, ctrl_value;
545 u8 test_value[2] = {0xff, 0xff}; 545 u8 test_value[2] = {0xff, 0xff};
546 546
547 ov9650_read_sensor(sd, address, &old_value, 1); 547 m5602_read_sensor(sd, address, &old_value, 1);
548 m5602_write_sensor(sd, address, test_value, 1); 548 m5602_write_sensor(sd, address, test_value, 1);
549 ov9650_read_sensor(sd, address, &ctrl_value, 1); 549 m5602_read_sensor(sd, address, &ctrl_value, 1);
550 550
551 if (ctrl_value == test_value[0]) 551 if (ctrl_value == test_value[0])
552 info("register 0x%x is writeable", address); 552 info("register 0x%x is writeable", address);