aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/ov7670.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index 90c44598dd51..21243303755f 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -409,6 +409,42 @@ static struct regval_list ov7670_fmt_raw[] = {
409 409
410/* 410/*
411 * Low-level register I/O. 411 * Low-level register I/O.
412 *
413 * Note that there are two versions of these. On the XO 1, the
414 * i2c controller only does SMBUS, so that's what we use. The
415 * ov7670 is not really an SMBUS device, though, so the communication
416 * is not always entirely reliable.
417 */
418#ifdef CONFIG_OLPC_XO_1
419static int ov7670_read(struct v4l2_subdev *sd, unsigned char reg,
420 unsigned char *value)
421{
422 struct i2c_client *client = v4l2_get_subdevdata(sd);
423 int ret;
424
425 ret = i2c_smbus_read_byte_data(client, reg);
426 if (ret >= 0) {
427 *value = (unsigned char)ret;
428 ret = 0;
429 }
430 return ret;
431}
432
433
434static int ov7670_write(struct v4l2_subdev *sd, unsigned char reg,
435 unsigned char value)
436{
437 struct i2c_client *client = v4l2_get_subdevdata(sd);
438 int ret = i2c_smbus_write_byte_data(client, reg, value);
439
440 if (reg == REG_COM7 && (value & COM7_RESET))
441 msleep(5); /* Wait for reset to run */
442 return ret;
443}
444
445#else /* ! CONFIG_OLPC_XO_1 */
446/*
447 * On most platforms, we'd rather do straight i2c I/O.
412 */ 448 */
413static int ov7670_read(struct v4l2_subdev *sd, unsigned char reg, 449static int ov7670_read(struct v4l2_subdev *sd, unsigned char reg,
414 unsigned char *value) 450 unsigned char *value)
@@ -462,6 +498,7 @@ static int ov7670_write(struct v4l2_subdev *sd, unsigned char reg,
462 msleep(5); /* Wait for reset to run */ 498 msleep(5); /* Wait for reset to run */
463 return ret; 499 return ret;
464} 500}
501#endif /* CONFIG_OLPC_XO_1 */
465 502
466 503
467/* 504/*