ov2640: fix vflip control
authorFrank Schaefer <fschaefer.oss@googlemail.com>
Sun, 16 Apr 2017 17:35:45 +0000 (14:35 -0300)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 26 Aug 2017 01:14:02 +0000 (02:14 +0100)
commit1791088dcec466dce8fb2be6f18739a4f2e7d938
tree1d5bb4c25b5ec7f06bafbc4e843db5e68a67b0d0
parent716e324b700b885a6692b38d113329b61788d2d5
ov2640: fix vflip control

commit 7f140fc2064bcd23e0490d8210650e2ef21c1c89 upstream.

Enabling vflip currently causes wrong colors.
It seems that (at least with the current sensor setup) REG04_VFLIP_IMG only
changes the vertical readout direction.
Because pixels are arranged RGRG... in odd lines and GBGB... in even lines,
either a one line shift or even/odd line swap is required, too, but
apparently this doesn't happen.

I finally figured out that this can be done manually by setting
REG04_VREF_EN.
Looking at hflip, it turns out that bit REG04_HREF_EN is set there
permanetly, but according to my tests has no effect on the pixel readout
order.
So my conclusion is that the current documentation of sensor register 0x04
is wrong (has changed after preliminary datasheet version 2.2).

I'm pretty sure that automatic vertical line shift/switch can be enabled,
too, but until anyone finds ot how this works, we have to stick with manual
switching.

Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
[bwh: Backported to 3.2: adjust filename]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/media/video/ov2640.c