aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2007-05-21 23:39:00 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-05-22 15:16:29 -0400
commitedd75ede2d40eadb98e07d87e88fa970f86ffe9e (patch)
treeded1750d0bf6345d348573c8486e874b86dfd12e /drivers/media
parent7acf90c70c6ee063f7465b2f10e2083bc49f355b (diff)
V4L/DVB (5691): Ov7670: reset clkrc in rgb565 mode
A bug in the ov7670 sensor causes it to introduce noise unless the CLKRC register is rewritten *after* setting the image mode. Naturally, resetting CLKRC in this way will cause other modes to fail. So carefully poke the register only when indicated. Signed-off-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/ov7670.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c
index 03bc369a9e49..3ceb8a6249dd 100644
--- a/drivers/media/video/ov7670.c
+++ b/drivers/media/video/ov7670.c
@@ -720,12 +720,22 @@ static int ov7670_s_fmt(struct i2c_client *c, struct v4l2_format *fmt)
720 struct ov7670_format_struct *ovfmt; 720 struct ov7670_format_struct *ovfmt;
721 struct ov7670_win_size *wsize; 721 struct ov7670_win_size *wsize;
722 struct ov7670_info *info = i2c_get_clientdata(c); 722 struct ov7670_info *info = i2c_get_clientdata(c);
723 unsigned char com7; 723 unsigned char com7, clkrc;
724 724
725 ret = ov7670_try_fmt(c, fmt, &ovfmt, &wsize); 725 ret = ov7670_try_fmt(c, fmt, &ovfmt, &wsize);
726 if (ret) 726 if (ret)
727 return ret; 727 return ret;
728 /* 728 /*
729 * HACK: if we're running rgb565 we need to grab then rewrite
730 * CLKRC. If we're *not*, however, then rewriting clkrc hoses
731 * the colors.
732 */
733 if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_RGB565) {
734 ret = ov7670_read(c, REG_CLKRC, &clkrc);
735 if (ret)
736 return ret;
737 }
738 /*
729 * COM7 is a pain in the ass, it doesn't like to be read then 739 * COM7 is a pain in the ass, it doesn't like to be read then
730 * quickly written afterward. But we have everything we need 740 * quickly written afterward. But we have everything we need
731 * to set it absolutely here, as long as the format-specific 741 * to set it absolutely here, as long as the format-specific
@@ -744,7 +754,10 @@ static int ov7670_s_fmt(struct i2c_client *c, struct v4l2_format *fmt)
744 if (wsize->regs) 754 if (wsize->regs)
745 ret = ov7670_write_array(c, wsize->regs); 755 ret = ov7670_write_array(c, wsize->regs);
746 info->fmt = ovfmt; 756 info->fmt = ovfmt;
747 return 0; 757
758 if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_RGB565 && ret == 0)
759 ret = ov7670_write(c, REG_CLKRC, clkrc);
760 return ret;
748} 761}
749 762
750/* 763/*
@@ -1267,7 +1280,9 @@ static int ov7670_attach(struct i2c_adapter *adapter)
1267 ret = ov7670_detect(client); 1280 ret = ov7670_detect(client);
1268 if (ret) 1281 if (ret)
1269 goto out_free_info; 1282 goto out_free_info;
1270 i2c_attach_client(client); 1283 ret = i2c_attach_client(client);
1284 if (ret)
1285 goto out_free_info;
1271 return 0; 1286 return 0;
1272 1287
1273 out_free_info: 1288 out_free_info: