From e4d1429e49f520d08c836df7559109562f65282a Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 19 Mar 2010 13:16:28 -0300 Subject: [PATCH] --- yaml --- r: 192863 b: refs/heads/master c: 467142093de1507833a08c50740d74b3b8c8eaca h: refs/heads/master i: 192861: efcbdec40bfe310b8130e8e6b3d7c2cb8ff5a227 192859: 902bf76cc0f83b72d2b60d007f6358d0f034a796 192855: e3b870d81711bfa4d754f8639609f36d21dd1ea4 192847: 69deaf0c5420bdf38b040363045439c2ef17e24c 192831: 7a5fe2f4227da7aedd1507d281774af23314a5cc v: v3 --- [refs] | 2 +- trunk/drivers/media/video/ov7670.c | 37 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 4cad4155e4ec..20c1bd0e4895 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 364e93372fb21ef5de18d0122c78789f065ddbf5 +refs/heads/master: 467142093de1507833a08c50740d74b3b8c8eaca diff --git a/trunk/drivers/media/video/ov7670.c b/trunk/drivers/media/video/ov7670.c index 90c44598dd51..21243303755f 100644 --- a/trunk/drivers/media/video/ov7670.c +++ b/trunk/drivers/media/video/ov7670.c @@ -409,6 +409,42 @@ static struct regval_list ov7670_fmt_raw[] = { /* * Low-level register I/O. + * + * Note that there are two versions of these. On the XO 1, the + * i2c controller only does SMBUS, so that's what we use. The + * ov7670 is not really an SMBUS device, though, so the communication + * is not always entirely reliable. + */ +#ifdef CONFIG_OLPC_XO_1 +static int ov7670_read(struct v4l2_subdev *sd, unsigned char reg, + unsigned char *value) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + int ret; + + ret = i2c_smbus_read_byte_data(client, reg); + if (ret >= 0) { + *value = (unsigned char)ret; + ret = 0; + } + return ret; +} + + +static int ov7670_write(struct v4l2_subdev *sd, unsigned char reg, + unsigned char value) +{ + struct i2c_client *client = v4l2_get_subdevdata(sd); + int ret = i2c_smbus_write_byte_data(client, reg, value); + + if (reg == REG_COM7 && (value & COM7_RESET)) + msleep(5); /* Wait for reset to run */ + return ret; +} + +#else /* ! CONFIG_OLPC_XO_1 */ +/* + * On most platforms, we'd rather do straight i2c I/O. */ static int ov7670_read(struct v4l2_subdev *sd, unsigned char reg, unsigned char *value) @@ -462,6 +498,7 @@ static int ov7670_write(struct v4l2_subdev *sd, unsigned char reg, msleep(5); /* Wait for reset to run */ return ret; } +#endif /* CONFIG_OLPC_XO_1 */ /*