media: ov8856: Add support for OV8856 sensor
PATCH v3 1/1 media: ov8856: Add support for OV8856 sensor
This patch adds driver for Omnivision's ov8856 sensor, the driver supports following features:
- manual exposure/gain(analog and digital) control support
- two link frequencies
- VBLANK/HBLANK support
- test pattern support
- media controller support
- runtime PM support
- enable Vsync signal output
- supported resolutions
+ 3280x2464 at 30FPS
+ 1640x1232 at 30FPS
---
since v2:
--Add MAINTAINERS entry for ov8856 driver.
--Modify the type of variables buf_i/var_i to "unsigned int" in
ov8856_write_reg().
--Add link_validate function.
--Remove "ifdef CONFIG_ACPI" in ov8856_i2c_driver{}. --Move ov8856_check_hwcfg() to the top of ov8856_probe(). --Remove unnecessary blank lines.
--Remove unnecessary V4L2_SUBDEV_FL_HAS_EVENTS flag. --Enable Vsync signal output.
since v3:
--Correct the year of Copyright.
--Remove unnecessary define V4L2_CID_DIGITAL_GAIN
--Set ret in switch default case of ov8856_set_ctrl(). --Modify ov8856_write_reg() / ov8856_read_reg() to be simplified.
--- MAINTAINERS | 7 + drivers/media/i2c/Kconfig | 12 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/ov8856.c | 1267 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1287 insertions(+) create mode 100644 drivers/media/i2c/ov8856.c
MAINTAINERS +7 -0
@@ -11231,6 +11231,13 @@ S: Maintained F: drivers/media/i2c/ov7740.c F: Documentation/devicetree/bindings/media/i2c/ov7740.txt +OMNIVISION OV8856 SENSOR DRIVER +M: Ben Kao <[email protected]> +L: [email protected] +T: git git://linuxtv.org/media_tree.git +S: Maintained +F: drivers/media/i2c/ov8856.c + OMNIVISION OV9650 SENSOR DRIVER M: Sakari Ailus <[email protected]> R: Akinobu Mita <[email protected]>
drivers/media/i2c/Kconfig +12 -0
@@ -820,6 +820,18 @@ config VIDEO_OV7740 This is a Video4Linux2 sensor driver for the OmniVision OV7740 VGA camera sensor. +config VIDEO_OV8856 + tristate "OmniVision OV8856 sensor support" + depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API + depends on MEDIA_CAMERA_SUPPORT + select V4L2_FWNODE + help + This is a Video4Linux2 sensor driver for the OmniVision + OV8856 camera sensor. + + To compile this driver as a module, choose M here: the + module will be called ov8856. + config VIDEO_OV9650 tristate "OmniVision OV9650/OV9652 sensor support" depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
drivers/media/i2c/Makefile +1 -0
@@ -78,6 +78,7 @@ obj-$(CONFIG_VIDEO_OV7640) += ov7640.o obj-$(CONFIG_VIDEO_OV7670) += ov7670.o obj-$(CONFIG_VIDEO_OV772X) += ov772x.o obj-$(CONFIG_VIDEO_OV7740) += ov7740.o +obj-$(CONFIG_VIDEO_OV8856) += ov8856.o obj-$(CONFIG_VIDEO_OV9650) += ov9650.o obj-$(CONFIG_VIDEO_OV13858) += ov13858.o obj-$(CONFIG_VIDEO_MT9M032) += mt9m032.o
drivers/media/i2c/ov8856.c new file +1267 -0
1,267 lines not on this page · raw message
Signature · 1 line
2.7.4
Sakari Ailus
maintainerHi Ben,
Thanks for the update! I've applied the patch, but please see the comments below.
On Tue, Jan 15, 2019 at 04:30:29PM +0800, Ben Kao wrote:
...
drivers/media/i2c/ov8856.c line 608
Quoted 5 lines
drivers/media/i2c/ov8856.c new file +5
-0+static int ov8856_read_reg (struct ov8856 *ov8856,u16 reg,u16 len,u32 *val) +{ +struct i2c_client *client =v4l2_get_subdevdata (&ov8856->sd); +struct i2c_msg msgs[2 ]; +u8 addr_buf[2 ] = {reg >>8 , reg &0xff };
You could use put_unaligned_be16() for doing this, as you do below.
drivers/media/i2c/ov8856.c line 617
Quoted 9 lines
drivers/media/i2c/ov8856.c new file +9
-0+u8 data_buf[4 ] = {0 , }; +int ret; + +if (len >4 ) +return -EINVAL ; + + msgs[0 ].addr = client->addr; + msgs[0 ].flags =0 ; + msgs[0 ].len =ARRAY_SIZE (addr_buf);
sizeof() would be better suited for the purpose: the length is in bytes.
Could you send a follow-up patch on top of this one?
Quoted 14 lines
drivers/media/i2c/ov8856.c new file +14
-0+ msgs[0 ].buf = addr_buf; + msgs[1 ].addr = client->addr; + msgs[1 ].flags =I2C_M_RD ; + msgs[1 ].len = len; + msgs[1 ].buf = &data_buf[4 - len]; + + ret =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs)); +if (ret !=ARRAY_SIZE (msgs)) +return -EIO ; + + *val =get_unaligned_be32 (data_buf); + +return 0 ; +}
Signature · 4 lines
Regards, Sakari Ailus [email protected]