summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/ov2640.c
Commit message (Collapse)AuthorAgeFilesLines
* media: ov2640: don't clear V4L2_SUBDEV_FL_IS_I2CAkinobu Mita2017-10-311-1/+1
| | | | | | | | | | | | | | | | | | The v4l2_i2c_subdev_init() sets V4L2_SUBDEV_FL_IS_I2C flag in the subdev->flags. But this driver overwrites subdev->flags immediately after calling v4l2_i2c_subdev_init(). So V4L2_SUBDEV_FL_IS_I2C is not set after all. This stops breaking subdev->flags and preserves V4L2_SUBDEV_FL_IS_I2C. Side note: According to the comment in v4l2_device_unregister(), this is problematic only if the device is platform bus device. Device tree or ACPI based devices are not affected. Cc: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: make array reset_seq static, reduces object code sizeColin Ian King2017-10-041-1/+1
| | | | | | | | | | | | | | | | | Don't populate the array reset_seq on the stack, instead make it static. Makes the object code smaller by over 50 bytes: Before: text data bss dec hex filename 11737 6000 64 17801 4589 drivers/media/i2c/ov2640.o After: text data bss dec hex filename 11582 6096 64 17742 454e drivers/media/i2c/ov2640.o Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] i2c: Improve a size determinationMarkus Elfring2017-10-041-1/+1
| | | | | | | | | | | | | Replace the specification of a data structure by pointer dereferences as the parameter for the operator "sizeof" to make size determination a bit safer according to the Linux coding style convention. This issue was detected by using the Coccinelle software. [mchehab@s-opensource.com: merged similar patches] Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] i2c: Delete an error messages for failed memory allocationMarkus Elfring2017-10-041-4/+1Star
| | | | | | | | | | | Omit extra messages for memory allocation failures. This issue was detected by using the Coccinelle software. [mchehab@s-opensource.com: merged similar patches] Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] ov2640: Check the return value from clk_prepare_enable()Fabio Estevam2017-10-041-1/+3
| | | | | | | | | clk_prepare_enable() may fail, so we should better check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] ov2640: Propagate the real error on devm_clk_get() failureFabio Estevam2017-10-041-1/+1
| | | | | | | | | devm_clk_get() may return different error codes other than -EPROBE_DEFER, so it is better to return the real error code instead. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] ov2640: print error if devm_*_optional*() failsMauro Carvalho Chehab2017-04-251-6/+20
| | | | | | | | | | devm_gpiod_get_optional() can return -ENOSYS if GPIOLIB is disabled, causing probe to fail. Warn the user if this happens. Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: add support for MEDIA_BUS_FMT_YVYU8_2X8 and ↵Frank Schaefer2017-04-191-0/+18
| | | | | | | MEDIA_BUS_FMT_VYUY8_2X8 Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: fix vflip controlFrank Schaefer2017-04-191-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | 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> Cc: stable <stable@vger.kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: fix duplicate width+height returning from ov2640_select_win()Frank Schaefer2017-04-191-11/+7Star
| | | | | | | | | ov2640_select_win() returns height and width values as part of struct ov2640_win_size, so there is no point in modifying the passed height and width parameters, too. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: add missing write to size change preambleFrank Schaefer2017-04-191-0/+3
| | | | | | | | HSIZE and VSIZE bits 0 to 2 and HSIZE bit 11 are encoded in DSP register SIZEL. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: add information about DSP register 0xc7Frank Schaefer2017-04-191-1/+5
| | | | | | | | | | | | | | | | | According to ov2640 software application notes, there are two Automatic White Balance (AWB) modes, which are selected by DSP register 0xc7: 1) Simple AWB: assumes the average color is gray + independent from lens - doesn't work well if captured area contains unbalanced colors (e.g. large blue background) 2) Advanced AWB: uses color temperature information + more accurate, works with all image contents - lens specific, requires calibration Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: improve banding filter register definitions/documentationFrank Schaefer2017-04-191-3/+17
| | | | | | | | | | | - add missing initialisation of sensor register COM25 (2 MSBs of banding filter AEC values) - add macros for setting the banding filter AEC values - add definitions for sensor register 0x5a, which is documented in Omnivisions software application notes Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: fix init sequence alignmentFrank Schaefer2017-04-191-12/+12
| | | | | | | While we are at it, remove a misleading comment (copy/paste mistake) Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: make GPIOLIB an optional dependencyMauro Carvalho Chehab2017-04-191-1/+4
| | | | | | | | | | | | | | As warned by kbuild test robot: warning: (VIDEO_EM28XX_V4L2) selects VIDEO_OV2640 which has unmet direct dependencies (MEDIA_SUPPORT && VIDEO_V4L2 && I2C && GPIOLIB && MEDIA_CAMERA_SUPPORT) The em28xx driver can use ov2640, but it doesn't depend (or use) the GPIOLIB in order to power off/on the sensor. So, as we want to allow both usages with and without GPIOLIB, make its dependency optional. Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: avoid calling ov2640_select_win() twiceHans Verkuil2017-04-151-11/+7Star
| | | | | | | | Simplify ov2640_set_params and ov2640_set_fmt. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: add MC supportHans Verkuil2017-04-101-2/+20
| | | | | | | | The MC support is needed by the em28xx driver. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: use standard clk and enable itHans Verkuil2017-04-101-17/+14Star
| | | | | | | | | Convert v4l2_clk to normal clk and enable the clock. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hugues Fruchet <hugues.fruchet@st.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ov2640: convert from soc-camera to a standard subdev sensor driverHans Verkuil2017-04-101-0/+1136
Convert ov2640 to a standard subdev driver. The soc-camera driver no longer uses this driver, so it can safely be converted. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Hugues Fruchet <hugues.fruchet@st.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>