Skip to contentSkip to conversation

media: Add a driver for the og01a1b camera sensor

PATCH In review Shawnx Tu 3 participants 3 messages Feb 15, 2022 – Feb 16, 2022

Subsystems (3)
lore
Share & tools
lore

Shawnx Tu

author
#0 lore raw

PATCH 1/1 media: Add a driver for the og01a1b camera sensor

From: Shawn Tu <[email protected]>

Add a V4L2 sub-device driver for Omnivision og01a1b b&w image sensor. This is a camera sensor using the I2C bus for control and the CSI-2 bus for data.

This driver supports following features:
- manual exposure and analog/digital gain control support
- vblank/hblank control support
- test pattern support
- media controller support
- runtime PM support
- support following resolutions:
+ 1280x1024 at 120FPS

---
 MAINTAINERS                 |    6 +
 drivers/media/i2c/Kconfig   |   13 +
 drivers/media/i2c/Makefile  |    1 +
 drivers/media/i2c/og01a1b.c | 1128 +++++++++++++++++++++++++++++++++++
 4 files changed, 1148 insertions(+)
 create mode 100644 drivers/media/i2c/og01a1b.c
MAINTAINERS +6 -0
index 83d27b57016f..b3949b10dbbf 100644
@@ -14185,6 +14185,12 @@ M:	Harald Welte <[email protected]>
 S:	Maintained
 F:	drivers/char/pcmcia/cm4040_cs.*
 
+OMNIVISION OG01A1B SENSOR DRIVER
+M:	Shawn Tu <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/media/i2c/og01a1b.c
+
 OMNIVISION OV02A10 SENSOR DRIVER
 M:	Dongchun Zhu <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +13 -0
index fe66093b8849..508145b572cf 100644
@@ -912,6 +912,19 @@ config VIDEO_IMX412
 	  To compile this driver as a module, choose M here: the
 	  module will be called imx412.
 
+config VIDEO_OG01A1B
+	tristate "OmniVision OG01A1B sensor support"
+	depends on I2C && VIDEO_V4L2
+	select MEDIA_CONTROLLER
+	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_FWNODE
+	help
+	  This is a Video4Linux2 sensor driver for the OmniVision
+	  OG01A1B camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called og01a1b.
+
 config VIDEO_OV02A10
 	tristate "OmniVision OV02A10 sensor support"
 	depends on VIDEO_V4L2 && I2C
drivers/media/i2c/Makefile +1 -0
index f6b80ef6f41d..d85d7a7e9c0f 100644
@@ -64,6 +64,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_OG01A1B) += og01a1b.o
 obj-$(CONFIG_VIDEO_OV02A10) += ov02a10.o
 obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
drivers/media/i2c/og01a1b.c new file +1128 -0

1,128 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw
I love your patch! Yet something to improve:

Hi Shawnx,

I love your patch! Yet something to improve:

[auto build test ERROR on next-20220214]
[also build test ERROR on v5.17-rc4]
[cannot apply to media-tree/master linus/master v5.17-rc4 v5.17-rc3 v5.17-rc2] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Shawnx-Tu/media-Add-a-driver-for-the-og01a1b-camera-sensor/20220215-152129
base:    259cbfc98c55ba3b6ef6e61fb7cfc3751dfded1e
config: arc-allyesconfig (https://download.01.org/0day-ci/archive/20220215/202202152018.UKmjje4k-lkp(a)intel.com/config)
compiler: arceb-elf-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/25f40ab32e83055024114ae7aa3a566344f00e67
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Shawnx-Tu/media-Add-a-driver-for-the-og01a1b-camera-sensor/20220215-152129 git checkout 25f40ab32e83055024114ae7aa3a566344f00e67
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arc SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/media/i2c/og01a1b.c: In function 'og01a1b_probe':

>> drivers/media/i2c/og01a1b.c:1074:15: error: implicit declaration of function 'v4l2_async_register_subdev_sensor_common'; did you mean 'v4l2_async_register_subdev_sensor'? [-Werror=implicit-function-declaration]
    1074 |         ret = v4l2_async_register_subdev_sensor_common(&og01a1b->sd);
         |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |               v4l2_async_register_subdev_sensor

cc1: some warnings being treated as errors

vim +1074 drivers/media/i2c/og01a1b.c

1031
1032 static int og01a1b_probe(struct i2c_client *client)
1033 {
1034 struct og01a1b *og01a1b;
1035 int ret;
1036
1037 ret = og01a1b_check_hwcfg(&client->dev);
1038 if (ret) {
1039 dev_err(&client->dev, "failed to check HW configuration: %d",
1040 ret);
1041 return ret;
1042 }
1043
1044 og01a1b = devm_kzalloc(&client->dev, sizeof(*og01a1b), GFP_KERNEL);
1045 if (!og01a1b)
1046 return -ENOMEM;
1047
1048 v4l2_i2c_subdev_init(&og01a1b->sd, client, &og01a1b_subdev_ops);
1049 ret = og01a1b_identify_module(og01a1b);
1050 if (ret) {
1051 dev_err(&client->dev, "failed to find sensor: %d", ret);
1052 return ret;
1053 }
1054
1055 mutex_init(&og01a1b->mutex);
1056 og01a1b->cur_mode = &supported_modes[0];
1057 ret = og01a1b_init_controls(og01a1b);
1058 if (ret) {
1059 dev_err(&client->dev, "failed to init controls: %d", ret);
1060 goto probe_error_v4l2_ctrl_handler_free;
1061 }
1062
1063 og01a1b->sd.internal_ops = &og01a1b_internal_ops;
1064 og01a1b->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1065 og01a1b->sd.entity.ops = &og01a1b_subdev_entity_ops;
1066 og01a1b->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
1067 og01a1b->pad.flags = MEDIA_PAD_FL_SOURCE;
1068 ret = media_entity_pads_init(&og01a1b->sd.entity, 1, &og01a1b->pad);
1069 if (ret) {
1070 dev_err(&client->dev, "failed to init entity pads: %d", ret);
1071 goto probe_error_v4l2_ctrl_handler_free;
1072 }
1073

> 1074		ret = v4l2_async_register_subdev_sensor_common(&og01a1b->sd);

1075 if (ret < 0) {
1076 dev_err(&client->dev, "failed to register V4L2 subdev: %d",
1077 ret);
1078 goto probe_error_media_entity_cleanup;
1079 }
1080
1081 /*
1082 * Device is already turned on by i2c-core with ACPI domain PM.
1083 * Enable runtime PM and turn off the device.
1084 */
1085 pm_runtime_set_active(&client->dev);
1086 pm_runtime_enable(&client->dev);
1087 pm_runtime_idle(&client->dev);
1088
1089 return 0;
1090
1091 probe_error_media_entity_cleanup:
1092 media_entity_cleanup(&og01a1b->sd.entity);
1093
1094 probe_error_v4l2_ctrl_handler_free:
1095 v4l2_ctrl_handler_free(og01a1b->sd.ctrl_handler);
1096 mutex_destroy(&og01a1b->mutex);
1097
1098 return ret;
1099 }
1100

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#2 lore raw
In reply to Shawnx Tu

Hi Shawn,

Quoted 15 lines · Shawnx Tu

From: Shawn Tu <[email protected]>

Add a V4L2 sub-device driver for Omnivision og01a1b b&w image sensor. This is a camera sensor using the I2C bus for control and the CSI-2 bus for data.

This driver supports following features:
- manual exposure and analog/digital gain control support
- vblank/hblank control support
- test pattern support
- media controller support
- runtime PM support
- support following resolutions:
+ 1280x1024 at 120FPS

Quoted 1 line

Thanks for the patch. I'lve applied it with this diff:

drivers/media/i2c/og01a1b.c +1 -1
index 05538184d95a..87179fc04e00 100644
@@ -1071,7 +1071,7 @@ static int og01a1b_probe(struct i2c_client *client)
 		goto probe_error_v4l2_ctrl_handler_free;
 	}
 
-	ret = v4l2_async_register_subdev_sensor_common(&og01a1b->sd);
+	ret = v4l2_async_register_subdev_sensor(&og01a1b->sd);
 	if (ret < 0) {
 		dev_err(&client->dev, "failed to register V4L2 subdev: %d",
 			ret);
Signature · 3 lines
Kind regards,

Sakari Ailus