Re: [PATCH v2] media: Add a driver for the ov5640 sensor.

2015-10-03 Thread Mauro Carvalho Chehab
Em Wed, 30 Sep 2015 10:57:54 +0200
Javier Martin  escreveu:

> The ov5640 sensor from Omnivision supports up to 2592x1944
> and both CSI and MIPI interfaces.
> 
> The following driver adds support for the CSI interface only
> and VGA, 720p resolutions at 30fps.

Please, always test your patches with checkpatch.pl.

Thanks!
Mauro

WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per 
line)
#6: 
# Cc: antoniope...@by.com.es, man...@by.com.es, ger...@by.com.es, 
g.liakhovet...@gmx.de, Javier Martin 

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#29: 
new file mode 100644

ERROR: Do not include the paragraph about writing to the Free Software 
Foundation's mailing address from the sample GPL notice. The FSF has changed 
addresses in the past, and may do so again. Linux already includes a copy of 
the GPL.
#145: FILE: drivers/media/i2c/ov5640.c:25:
+ * with this program; if not, write to the Free Software Foundation, Inc.,$

ERROR: Do not include the paragraph about writing to the Free Software 
Foundation's mailing address from the sample GPL notice. The FSF has changed 
addresses in the past, and may do so again. Linux already includes a copy of 
the GPL.
#146: FILE: drivers/media/i2c/ov5640.c:26:
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.$

WARNING: line over 80 characters
#227: FILE: drivers/media/i2c/ov5640.c:107:
+#define OV5640_BRIGHT_Y_SET_SIGN(x)(((x) & 
OV5640_BRIGHT_Y_SIGN_MASK) << 3)

WARNING: Comparisons should place the constant on the right side of the test
#571: FILE: drivers/media/i2c/ov5640.c:451:
+   if (2 != i2c_master_send(ov5640->i2c_client, regbuf, 2)) {

WARNING: Comparisons should place the constant on the right side of the test
#577: FILE: drivers/media/i2c/ov5640.c:457:
+   if (1 != i2c_master_recv(ov5640->i2c_client, , 1)) {

WARNING: msleep < 20ms can sleep for up to 20ms; see 
Documentation/timers/timers-howto.txt
#814: FILE: drivers/media/i2c/ov5640.c:694:
+   msleep(10);

WARNING: msleep < 20ms can sleep for up to 20ms; see 
Documentation/timers/timers-howto.txt
#817: FILE: drivers/media/i2c/ov5640.c:697:
+   msleep(1);

WARNING: line over 80 characters
#1218: FILE: drivers/media/i2c/ov5640.c:1098:
+   ov5640_write_reg(ov5640, OV5640_PAD_OUTPUT_ENABLE_01, 
OV5640_PAD_DISABLE_ALL);

WARNING: line over 80 characters
#1219: FILE: drivers/media/i2c/ov5640.c:1099:
+   ov5640_write_reg(ov5640, OV5640_PAD_OUTPUT_ENABLE_02, 
OV5640_PAD_DISABLE_ALL);

WARNING: line over 80 characters
#1275: FILE: drivers/media/i2c/ov5640.c:1155:
+   dev_err(ov5640->dev, "could not set mode %d\n", 
ov5640->current_mode);

WARNING: line over 80 characters
#1288: FILE: drivers/media/i2c/ov5640.c:1168:
+   ov5640_write_reg(ov5640, OV5640_PAD_OUTPUT_ENABLE_01, 
OV5640_PAD_ENABLE_ALL);

WARNING: line over 80 characters
#1289: FILE: drivers/media/i2c/ov5640.c:1169:
+   ov5640_write_reg(ov5640, OV5640_PAD_OUTPUT_ENABLE_02, 
OV5640_PAD_ENABLE_ALL);

WARNING: line over 80 characters
#1291: FILE: drivers/media/i2c/ov5640.c:1171:
+   ov5640_write_reg(ov5640, OV5640_PAD_OUTPUT_ENABLE_01, 
OV5640_PAD_DISABLE_ALL);

WARNING: line over 80 characters
#1292: FILE: drivers/media/i2c/ov5640.c:1172:
+   ov5640_write_reg(ov5640, OV5640_PAD_OUTPUT_ENABLE_02, 
OV5640_PAD_DISABLE_ALL);

WARNING: line over 80 characters
#1432: FILE: drivers/media/i2c/ov5640.c:1312:
+   ov5640->autoexposure = v4l2_ctrl_new_std_menu(>ctrls, 
_ctrl_ops,

WARNING: line over 80 characters
#1439: FILE: drivers/media/i2c/ov5640.c:1319:
+   ov5640->pattern = v4l2_ctrl_new_std_menu_items(>ctrls, 
_ctrl_ops,

WARNING: DT compatible string "ovti,ov5640" appears un-documented -- check 
./Documentation/devicetree/bindings/
#1503: FILE: drivers/media/i2c/ov5640.c:1383:
+   { .compatible = "ovti,ov5640" },

total: 2 errors, 17 warnings, 1474 lines checked



> 
> Signed-off-by: Javier Martin 
> ---
>  .../devicetree/bindings/media/i2c/ov5640.txt   |   47 +
>  drivers/media/i2c/Kconfig  |   11 +
>  drivers/media/i2c/Makefile |1 +
>  drivers/media/i2c/ov5640.c | 1403 
> 
>  4 files changed, 1462 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5640.txt
>  create mode 100644 drivers/media/i2c/ov5640.c
> 
> diff --git a/Documentation/devicetree/bindings/media/i2c/ov5640.txt 
> b/Documentation/devicetree/bindings/media/i2c/ov5640.txt
> new file mode 100644
> index 000..2e93e97
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/i2c/ov5640.txt
> @@ -0,0 +1,47 @@
> +* Omnivision 1/4-Inch 5Mp CMOS Digital Image Sensor
> +
> +The Omnivision OV5640 is a 1/4-Inch CMOS active pixel digital image sensor 
> with
> +an active array size of 2592H x 1932V. 

[PATCH v2] media: Add a driver for the ov5640 sensor.

2015-09-30 Thread Javier Martin
The ov5640 sensor from Omnivision supports up to 2592x1944
and both CSI and MIPI interfaces.

The following driver adds support for the CSI interface only
and VGA, 720p resolutions at 30fps.

Signed-off-by: Javier Martin 
---
 .../devicetree/bindings/media/i2c/ov5640.txt   |   47 +
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5640.c | 1403 
 4 files changed, 1462 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5640.txt
 create mode 100644 drivers/media/i2c/ov5640.c

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5640.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5640.txt
new file mode 100644
index 000..2e93e97
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5640.txt
@@ -0,0 +1,47 @@
+* Omnivision 1/4-Inch 5Mp CMOS Digital Image Sensor
+
+The Omnivision OV5640 is a 1/4-Inch CMOS active pixel digital image sensor with
+an active array size of 2592H x 1932V. It is programmable through a simple
+two-wire serial interface.
+
+Required Properties:
+- compatible: value should be "ovti,ov5640"
+- clocks: reference to the xclk clock
+- clock-names: should be "xclk"
+- clock-rates: the xclk clock frequency
+
+Optional Properties:
+- reset-gpio: Chip reset GPIO
+- pwdn-gpio: Chip power down GPIO
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+
+{
+   ...
+
+   ov5640: ov5640@3c {
+   compatible = "ovti,ov5640";
+   pinctrl-names = "default";
+   pinctrl-0 = <_ov5640 _csi0>;
+   reg = <0x3c>;
+
+   clocks = < 200>;
+   clock-names = "xclk";
+   clock-rates = <2400>;
+
+   reset-gpio = < 20 GPIO_ACTIVE_LOW>;
+   pwdn-gpio = < 6 GPIO_ACTIVE_HIGH>;
+
+   port {
+   ov5640_to_csi0: endpoint {
+   remote-endpoint = <_from_ov5640>;
+   hsync-active = <1>;
+   vsync-active = <1>;
+   };
+   };
+   };
+   };
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 6f30ea7..8c6689b 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -488,6 +488,17 @@ config VIDEO_OV7640
  To compile this driver as a module, choose M here: the
  module will be called ov7640.
 
+config VIDEO_OV5640
+   tristate "OmniVision OV5640 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5640 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5640.
+
 config VIDEO_OV7670
tristate "OmniVision OV7670 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 34e7da2..65b224f 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
 obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
+obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
 obj-$(CONFIG_VIDEO_OV9650) += ov9650.o
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
new file mode 100644
index 000..e06b812
--- /dev/null
+++ b/drivers/media/i2c/ov5640.c
@@ -0,0 +1,1403 @@
+/*
+ * Driver for the OV5640 sensor from Omnivision CSI interface only.
+ *
+ * Copyright (C) 2015 By Tech Design S.L. All Rights Reserved.
+ * Copyright (C) 2012-2013 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * Based on the MT9P031 driver and an out of tree ov5640 driver by Freescale:
+ * https://github.com/varigit/linux-2.6-imx/blob/imx_3.14.38_6qp_beta-var02/
+ * drivers/media/platform/mxc/capture/ov5640.c
+ *
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU