[PATCH v3 1/3] media: i2c: Add the ov7740 image sensor driver
The ov7740 (color) image sensor is a high performance VGA CMOS image snesor, which supports for output formats: RAW RGB and YUV and image sizes: VGA, and QVGA, CIF and any size smaller. Signed-off-by: Songjun WuSigned-off-by: Wenyou Yang --- Changes in v3: None Changes in v2: None drivers/media/i2c/Kconfig |8 + drivers/media/i2c/Makefile |1 + drivers/media/i2c/ov7740.c | 1220 3 files changed, 1229 insertions(+) create mode 100644 drivers/media/i2c/ov7740.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 3c6d6428f525..ac484bb82fae 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -665,6 +665,14 @@ config VIDEO_OV7670 OV7670 VGA camera. It currently only works with the M88ALP01 controller. +config VIDEO_OV7740 + tristate "OmniVision OV7740 sensor support" + depends on I2C && VIDEO_V4L2 + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the OmniVision + OV7740 VGA camera sensor. + config VIDEO_OV9650 tristate "OmniVision OV9650/OV9652 sensor support" depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index f8d57e453936..be800c674e8d 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -67,6 +67,7 @@ obj-$(CONFIG_VIDEO_OV5670) += ov5670.o obj-$(CONFIG_VIDEO_OV6650) += ov6650.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.o obj-$(CONFIG_VIDEO_OV7670) += ov7670.o +obj-$(CONFIG_VIDEO_OV7740) += ov7740.o obj-$(CONFIG_VIDEO_OV9650) += ov9650.o obj-$(CONFIG_VIDEO_OV13858) += ov13858.o obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c new file mode 100644 index ..d68add05b46e --- /dev/null +++ b/drivers/media/i2c/ov7740.c @@ -0,0 +1,1220 @@ +/* + * Copyright (c) 2017 Microchip Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * 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 General Public License for more details. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define REG_OUTSIZE_LSB 0x34 + +/* OV7740 register tables */ +#define REG_GAIN 0x00/* Gain lower 8 bits (rest in vref) */ +#define REG_BGAIN 0x01/* blue gain */ +#define REG_RGAIN 0x02/* red gain */ +#define REG_GGAIN 0x03/* green gain */ +#define REG_REG04 0x04/* analog setting, dont change*/ +#define REG_BAVG 0x05/* b channel average */ +#define REG_GAVG 0x06/* g channel average */ +#define REG_RAVG 0x07/* r channel average */ + +#define REG_REG0C 0x0C/* filp enable */ +#define REG0C_IMG_FLIP 0x80 +#define REG0C_IMG_MIRROR 0x40 + +#define REG_REG0E 0x0E/* blc line */ +#define REG_HAEC 0x0F/* auto exposure cntrl */ +#define REG_AEC0x10/* auto exposure cntrl */ + +#define REG_CLK0x11/* Clock control */ +#define REG_REG55 0x55/* Clock PLL DIV/PreDiv */ + +#define REG_REG12 0x12 + +#define REG_REG13 0x13/* auto/manual AGC, AEC, Write Balance*/ +#define REG13_AEC_EN 0x01 +#define REG13_AGC_EN 0x04 + +#define REG_REG14 0x14 +#define REG_REG15 0x15 +#define REG15_GAIN_MSB 0x03 + +#define REG_REG16 0x16 + +#define REG_MIDH 0x1C/* manufacture id byte */ +#define REG_MIDL 0x1D/* manufacture id byre */ +#define REG_PIDH 0x0A/* Product ID MSB */ +#define REG_PIDL 0x0B/* Product ID LSB */ + +#define REG_84 0x84/* lots of stuff */ +#define REG_REG38 0x38/* sub-addr */ + +#define REG_AHSTART0x17/* Horiz start high bits */ +#define REG_AHSIZE 0x18 +#define REG_AVSTART0x19/* Vert start high bits */ +#define REG_AVSIZE 0x1A +#define REG_PSHFT 0x1b/* Pixel delay after HREF */ + +#define REG_HOUTSIZE 0x31 +#define REG_VOUTSIZE 0x32 +#define REG_HVSIZEOFF 0x33 +#define REG_REG34 0x34/* DSP output size H/V LSB*/ + +#define REG_ISP_CTRL00 0x80 +#define ISPCTRL00_AWB_EN 0x10 +#define ISPCTRL00_AWB_GAIN_EN 0x04 + +#defineREG_YGAIN 0xE2/* ygain for contrast control */ + +#defineREG_YBRIGHT 0xE3 +#defineREG_SGNSET0xE4 +#defineSGNSET_YBRIGHT_MASK 0x08 + +#define REG_USAT 0xDD +#define REG_VSAT 0xDE + + +struct ov7740 { + struct v4l2_subdev
[PATCH v3 1/3] media: i2c: Add the ov7740 image sensor driver
The ov7740 (color) image sensor is a high performance VGA CMOS image snesor, which supports for output formats: RAW RGB and YUV and image sizes: VGA, and QVGA, CIF and any size smaller. Signed-off-by: Songjun Wu Signed-off-by: Wenyou Yang --- Changes in v3: None Changes in v2: None drivers/media/i2c/Kconfig |8 + drivers/media/i2c/Makefile |1 + drivers/media/i2c/ov7740.c | 1220 3 files changed, 1229 insertions(+) create mode 100644 drivers/media/i2c/ov7740.c diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 3c6d6428f525..ac484bb82fae 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig @@ -665,6 +665,14 @@ config VIDEO_OV7670 OV7670 VGA camera. It currently only works with the M88ALP01 controller. +config VIDEO_OV7740 + tristate "OmniVision OV7740 sensor support" + depends on I2C && VIDEO_V4L2 + depends on MEDIA_CAMERA_SUPPORT + ---help--- + This is a Video4Linux2 sensor-level driver for the OmniVision + OV7740 VGA camera sensor. + config VIDEO_OV9650 tristate "OmniVision OV9650/OV9652 sensor support" depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index f8d57e453936..be800c674e8d 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile @@ -67,6 +67,7 @@ obj-$(CONFIG_VIDEO_OV5670) += ov5670.o obj-$(CONFIG_VIDEO_OV6650) += ov6650.o obj-$(CONFIG_VIDEO_OV7640) += ov7640.o obj-$(CONFIG_VIDEO_OV7670) += ov7670.o +obj-$(CONFIG_VIDEO_OV7740) += ov7740.o obj-$(CONFIG_VIDEO_OV9650) += ov9650.o obj-$(CONFIG_VIDEO_OV13858) += ov13858.o obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c new file mode 100644 index ..d68add05b46e --- /dev/null +++ b/drivers/media/i2c/ov7740.c @@ -0,0 +1,1220 @@ +/* + * Copyright (c) 2017 Microchip Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * 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 General Public License for more details. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define REG_OUTSIZE_LSB 0x34 + +/* OV7740 register tables */ +#define REG_GAIN 0x00/* Gain lower 8 bits (rest in vref) */ +#define REG_BGAIN 0x01/* blue gain */ +#define REG_RGAIN 0x02/* red gain */ +#define REG_GGAIN 0x03/* green gain */ +#define REG_REG04 0x04/* analog setting, dont change*/ +#define REG_BAVG 0x05/* b channel average */ +#define REG_GAVG 0x06/* g channel average */ +#define REG_RAVG 0x07/* r channel average */ + +#define REG_REG0C 0x0C/* filp enable */ +#define REG0C_IMG_FLIP 0x80 +#define REG0C_IMG_MIRROR 0x40 + +#define REG_REG0E 0x0E/* blc line */ +#define REG_HAEC 0x0F/* auto exposure cntrl */ +#define REG_AEC0x10/* auto exposure cntrl */ + +#define REG_CLK0x11/* Clock control */ +#define REG_REG55 0x55/* Clock PLL DIV/PreDiv */ + +#define REG_REG12 0x12 + +#define REG_REG13 0x13/* auto/manual AGC, AEC, Write Balance*/ +#define REG13_AEC_EN 0x01 +#define REG13_AGC_EN 0x04 + +#define REG_REG14 0x14 +#define REG_REG15 0x15 +#define REG15_GAIN_MSB 0x03 + +#define REG_REG16 0x16 + +#define REG_MIDH 0x1C/* manufacture id byte */ +#define REG_MIDL 0x1D/* manufacture id byre */ +#define REG_PIDH 0x0A/* Product ID MSB */ +#define REG_PIDL 0x0B/* Product ID LSB */ + +#define REG_84 0x84/* lots of stuff */ +#define REG_REG38 0x38/* sub-addr */ + +#define REG_AHSTART0x17/* Horiz start high bits */ +#define REG_AHSIZE 0x18 +#define REG_AVSTART0x19/* Vert start high bits */ +#define REG_AVSIZE 0x1A +#define REG_PSHFT 0x1b/* Pixel delay after HREF */ + +#define REG_HOUTSIZE 0x31 +#define REG_VOUTSIZE 0x32 +#define REG_HVSIZEOFF 0x33 +#define REG_REG34 0x34/* DSP output size H/V LSB*/ + +#define REG_ISP_CTRL00 0x80 +#define ISPCTRL00_AWB_EN 0x10 +#define ISPCTRL00_AWB_GAIN_EN 0x04 + +#defineREG_YGAIN 0xE2/* ygain for contrast control */ + +#defineREG_YBRIGHT 0xE3 +#defineREG_SGNSET0xE4 +#defineSGNSET_YBRIGHT_MASK 0x08 + +#define REG_USAT 0xDD +#define REG_VSAT 0xDE + + +struct ov7740 { + struct v4l2_subdev subdev; +#if defined(CONFIG_MEDIA_CONTROLLER) +