aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ov7670.c
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2010-03-19 12:16:28 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-17 23:51:23 -0400
commit467142093de1507833a08c50740d74b3b8c8eaca (patch)
tree4a71be39df69b783205668d5b70f2f672936c7b2 /drivers/media/video/ov7670.c
parent364e93372fb21ef5de18d0122c78789f065ddbf5 (diff)
V4L/DVB: ov7670: Restore SMBUS I/O for the XO 1.0
The Cafe controller doesn't do non-SMBUS I/O, so we have to use it there. Signed-off-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/ov7670.c')
-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/*