aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-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: