media: i2c: add support for omnivision's ov2659 sensor
Subsystems (4)
Lad Prabhakar
maintainerPATCH v6 1/1 media: i2c: add support for omnivision's ov2659 sensor
From: Benoit Parrot <[email protected]>
this patch adds support for omnivision's ov2659
sensor, the driver supports following features:
1: Asynchronous probing
2: DT support
3: Media controller support
---
Changes for v6:
a: fixed V4L2_CID_PIXEL_RATE control to use link_frequency
instead of xvclk_frequency.
b: Included Ack from Sakari
v5: https://patchwork.kernel.org/patch/6000161/
v4: https://patchwork.kernel.org/patch/5961661/
v3: https://patchwork.kernel.org/patch/5959401/
v2: https://patchwork.kernel.org/patch/5859801/
v1: https://patchwork.linuxtv.org/patch/27919/
.../devicetree/bindings/media/i2c/ov2659.txt | 38 + MAINTAINERS | 10 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov2659.c | 1510 ++++++++++++++++++++ include/media/ov2659.h | 33 + 6 files changed, 1603 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2659.txt create mode 100644 drivers/media/i2c/ov2659.c create mode 100644 include/media/ov2659.h
Documentation/devicetree/bindings/media/i2c/ov2659.txt new file +38 -0
@@ -0,0 +1,38 @@ +* OV2659 1/5-Inch 2Mp SOC Camera + +The Omnivision OV2659 is a 1/5-inch SOC camera, with an active array size of +1632H x 1212V. It is programmable through a SCCB. The OV2659 sensor supports +multiple resolutions output, such as UXGA, SVGA, 720p. It also can support +YUV422, RGB565/555 or raw RGB output formats. + +Required Properties: +- compatible: Must be "ovti,ov2659" +- reg: I2C slave address +- clocks: reference to the xvclk input clock. +- clock-names: should be "xvclk". +- link-frequencies: target pixel clock frequency. + +For further reading on port node refer to +Documentation/devicetree/bindings/media/video-interfaces.txt. + +Example: + + i2c0@1c22000 { + ... + ... + ov2659@30 { + compatible = "ovti,ov2659"; + reg = <0x30>; + + clocks = <&clk_ov2659 0>; + clock-names = "xvclk"; + + port { + ov2659_0: endpoint { + remote-endpoint = <&vpfe_ep>; + link-frequencies = /bits/ 64 <70000000>; + }; + }; + }; + ... + };
MAINTAINERS +10 -0
@@ -8910,6 +8910,16 @@ T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git S: Maintained F: drivers/media/platform/am437x/ +OV2659 OMNIVISION SENSOR DRIVER +M: Lad, Prabhakar <[email protected]> +L: [email protected] +W: http://linuxtv.org/ +Q: http://patchwork.linuxtv.org/project/linux-media/list/ +T: git git://linuxtv.org/mhadli/v4l-dvb-davinci_devices.git +S: Maintained +F: drivers/media/i2c/ov2659.c +F: include/media/ov2659.h + SIS 190 ETHERNET DRIVER M: Francois Romieu <[email protected]> L: [email protected]
drivers/media/i2c/Kconfig +11 -0
@@ -466,6 +466,17 @@ config VIDEO_APTINA_PLL config VIDEO_SMIAPP_PLL tristate +config VIDEO_OV2659 + tristate "OmniVision OV2659 sensor support" + depends on VIDEO_V4L2 && I2C + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the OmniVision + OV2659 camera. + + To compile this driver as a module, choose M here: the + module will be called ov2659. + config VIDEO_OV7640 tristate "OmniVision OV7640 sensor support" depends on I2C && VIDEO_V4L2
drivers/media/i2c/Makefile +1 -0
@@ -77,3 +77,4 @@ obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o obj-$(CONFIG_VIDEO_AK881X) += ak881x.o obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o +obj-$(CONFIG_VIDEO_OV2659) += ov2659.o
drivers/media/i2c/ov2659.c new file +1510 -0
1,510 lines not on this page · raw message
include/media/ov2659.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Omnivision OV2659 CMOS Image Sensor driver +* +* Copyright (C) 2015 Texas Instruments, Inc. +* +* Benoit Parrot <[email protected]> +* Lad, Prabhakar <[email protected]> +* +* This program is free software; you may redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 2 of the License. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#ifndef OV2659_H +#define OV2659_H + +/** +* struct ov2659_platform_data - ov2659 driver platform data +* @link_frequency: target pixel clock frequency +*/ +struct ov2659_platform_data { +s64 link_frequency; +}; +#endif /* OV2659_H */
Signature · 1 line
2.1.0
Sakari Ailus
maintainerHi Prabhakar,
Lad Prabhakar wrote:
...
Quoted 22 lines
drivers/media/i2c/ov2659.c new file +22
-0+static const struct ov2659_pixfmt ov2659_formats[] = { + { + .code =MEDIA_BUS_FMT_YUYV8_2X8 , + .colorspace =V4L2_COLORSPACE_JPEG , + .format_ctrl_regs = ov2659_format_yuyv, + }, + { + .code =MEDIA_BUS_FMT_UYVY8_2X8 , + .colorspace =V4L2_COLORSPACE_JPEG , + .format_ctrl_regs = ov2659_format_uyvy, + }, + { + .code =MEDIA_BUS_FMT_RGB565_2X8_BE , + .colorspace =V4L2_COLORSPACE_JPEG , + .format_ctrl_regs = ov2659_format_rgb565, + }, + { + .code =MEDIA_BUS_FMT_SBGGR8_1X8 , + .colorspace =V4L2_COLORSPACE_SMPTE170M , + .format_ctrl_regs = ov2659_format_bggr, + }, +};
...
Quoted 24 lines
drivers/media/i2c/ov2659.c new file +24
-0+static int ov2659_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +const struct ov2659_platform_data *pdata =ov2659_get_pdata (client); +struct v4l2_subdev *sd; +struct ov2659 *ov2659; +struct clk *clk; +int ret; + +if (!pdata) { +dev_err (&client->dev,"platform data not specified\n" ); +return -EINVAL ; + } + + ov2659 =devm_kzalloc (&client->dev,sizeof (*ov2659),GFP_KERNEL ); +if (!ov2659) +return -ENOMEM ; + + ov2659->pdata = pdata; + ov2659->client = client; + + clk =devm_clk_get (&client->dev,"xvclk" ); +if (IS_ERR (clk)) +return PTR_ERR (clk);
drivers/media/i2c/ov2659.c line 1406
Quoted 10 lines
drivers/media/i2c/ov2659.c new file +10
-0+ + ov2659->xvclk_frequency =clk_get_rate (clk); +if (ov2659->xvclk_frequency <6000000 || + ov2659->xvclk_frequency >27000000 ) +return -EINVAL ; + +v4l2_ctrl_handler_init (&ov2659->ctrls,2 ); +v4l2_ctrl_new_std (&ov2659->ctrls, &ov2659_ctrl_ops, +V4L2_CID_PIXEL_RATE , pdata->link_frequency, + pdata->link_frequency,1 , pdata->link_frequency);
Are the formats that you advertise correct? If so, you should divide the link frequency by two to get pixel rate on formats that have two samples per clock cycle, i.e. use v4l2_ctrl_s_ctrl_int64() / __v4l2_ctrl_s_ctrl_int64().
Signature · 4 lines
Regards, Sakari Ailus [email protected]
Hi Prabhakar,
Quoted 39 lines · Lad Prabhakar
From: Benoit Parrot <[email protected]>
this patch adds support for omnivision's ov2659
sensor, the driver supports following features:
1: Asynchronous probing
2: DT support
3: Media controller supportSigned-off-by Benoit Parrot <[email protected]>Signed-off-by Lad, Prabhakar <[email protected]>Acked-by Sakari Ailus <[email protected]>---
Changes for v6:
a: fixedV4L2_CID_PIXEL_RATEcontrol to uselink_frequency
instead ofxvclk_frequency.
b: Included Ack from Sakariv5: https://patchwork.kernel.org/patch/6000161/
v4: https://patchwork.kernel.org/patch/5961661/
v3: https://patchwork.kernel.org/patch/5959401/
v2: https://patchwork.kernel.org/patch/5859801/
v1: https://patchwork.linuxtv.org/patch/27919/.../devicetree/bindings/media/i2c/ov2659.txt | 38 + MAINTAINERS | 10 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov2659.c | 1510 ++++++++++++++++++++ include/media/ov2659.h | 33 + 6 files changed, 1603 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2659.txt create mode 100644 drivers/media/i2c/ov2659.c create mode 100644 include/media/ov2659.hdrivers/media/i2c/ov2659.c new file +0
-0
<snip>
Quoted 12 lines
drivers/media/i2c/ov2659.c new file +12
-0+static const struct ov2659_pixfmt ov2659_formats[] = { + { + .code =MEDIA_BUS_FMT_YUYV8_2X8 , + .colorspace =V4L2_COLORSPACE_JPEG , + .format_ctrl_regs = ov2659_format_yuyv, + }, + { + .code =MEDIA_BUS_FMT_UYVY8_2X8 , + .colorspace =V4L2_COLORSPACE_JPEG , + .format_ctrl_regs = ov2659_format_uyvy, + }, + {
drivers/media/i2c/ov2659.c line 837
Quoted 10 lines
drivers/media/i2c/ov2659.c new file +10
-0+ .code = MEDIA_BUS_FMT_RGB565_2X8_BE, + .colorspace = V4L2_COLORSPACE_JPEG, + .format_ctrl_regs = ov2659_format_rgb565, + }, + { + .code = MEDIA_BUS_FMT_SBGGR8_1X8, + .colorspace = V4L2_COLORSPACE_SMPTE170M, + .format_ctrl_regs = ov2659_format_bggr, + }, +};
The colorspaces defined here make no sense. Sensors should give you V4L2_COLORSPACE_SRGB. Certainly not COLORSPACE_JPEG (unless they encode to a JPEG for you) and SMPTE170M (SDTV) is unlikely as well, unless the documentation explicitly states that it uses that colorspace.
Unfortunately, the product brief of this sensor does not mention the colorimetry information at all, nor does it give any information about the transfer function (aka gamma) used by the sensor. Since this sensor is advertised as an HDTV sensor I would guess the colorspace should either be SRGB or REC709, depending on the transfer function used.
I see a lot of sensor drivers that wrongly use the JPEG colorspace. I'm planning to fix them, since that is really wrong.
Regards,
Hans
Lad, Prabhakar
maintainerHi Hans,
Thanks for the review.
Quoted 73 lines · Hans Verkuil
Hi Prabhakar,
Quoted 39 lines · Lad Prabhakar
From: Benoit Parrot <[email protected]>
this patch adds support for omnivision's ov2659
sensor, the driver supports following features:
1: Asynchronous probing
2: DT support
3: Media controller supportSigned-off-by Benoit Parrot <[email protected]>Signed-off-by Lad, Prabhakar <[email protected]>Acked-by Sakari Ailus <[email protected]>---
Changes for v6:
a: fixedV4L2_CID_PIXEL_RATEcontrol to uselink_frequency
instead ofxvclk_frequency.
b: Included Ack from Sakariv5: https://patchwork.kernel.org/patch/6000161/
v4: https://patchwork.kernel.org/patch/5961661/
v3: https://patchwork.kernel.org/patch/5959401/
v2: https://patchwork.kernel.org/patch/5859801/
v1: https://patchwork.linuxtv.org/patch/27919/.../devicetree/bindings/media/i2c/ov2659.txt | 38 + MAINTAINERS | 10 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov2659.c | 1510 ++++++++++++++++++++ include/media/ov2659.h | 33 + 6 files changed, 1603 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2659.txt create mode 100644 drivers/media/i2c/ov2659.c create mode 100644 include/media/ov2659.hdrivers/media/i2c/ov2659.c new file +0
-0<snip>
Quoted 12 lines
drivers/media/i2c/ov2659.c new file +12
-0+static const struct ov2659_pixfmt ov2659_formats[] = { + { + .code =MEDIA_BUS_FMT_YUYV8_2X8 , + .colorspace =V4L2_COLORSPACE_JPEG , + .format_ctrl_regs = ov2659_format_yuyv, + }, + { + .code =MEDIA_BUS_FMT_UYVY8_2X8 , + .colorspace =V4L2_COLORSPACE_JPEG , + .format_ctrl_regs = ov2659_format_uyvy, + }, + {drivers/media/i2c/ov2659.c line 837
Quoted 10 lines
drivers/media/i2c/ov2659.c new file +10
-0+ .code = MEDIA_BUS_FMT_RGB565_2X8_BE, + .colorspace = V4L2_COLORSPACE_JPEG, + .format_ctrl_regs = ov2659_format_rgb565, + }, + { + .code = MEDIA_BUS_FMT_SBGGR8_1X8, + .colorspace = V4L2_COLORSPACE_SMPTE170M, + .format_ctrl_regs = ov2659_format_bggr, + }, +};The colorspaces defined here make no sense. Sensors should give you
V4L2_COLORSPACE_SRGB. Certainly notCOLORSPACE_JPEG(unless they encode to a JPEG for you) and SMPTE170M (SDTV) is unlikely as well, unless the documentation explicitly states that it uses that colorspace.
Quoted 6 lines
Unfortunately, the product brief of this sensor does not mention the colorimetry information at all, nor does it give any information about the transfer function (aka gamma) used by the sensor. Since this sensor is advertised as an HDTV sensor I would guess the colorspace should either be SRGB or REC709, depending on the transfer function used.
Yes it needs to be V4L2_COLORSPACE_SRGB, Ill respin fixing this.
Cheers,
--Prabhakar Lad
Quoted 6 lines
I see a lot of sensor drivers that wrongly use the JPEG colorspace. I'm planning to fix them, since that is really wrong.
Regards,
Hans