Skip to contentSkip to conversation

media: i2c: Add OV05C10 camera sensor driver

PATCH In review Pratap Nirujogi 5 participants 6 messages Jul 14, 2025 – Jul 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 media: i2c: Add OV05C10 camera sensor driver

Add driver for OmniVision 5.2M OV05C10 sensor. This driver supports only the full size normal 2888x1808@30fps 2-lane sensor profile.

---
Changes v3 -> v4:

* Use link frequency@900MHz and remove redundant ov05c10_link_frequencies[] definition
* Remove ov05c10_switch_page(), include page switch logic in ov05c10_reg_read() and ov05c10_reg_write()
* Fix VTS and HTS related config issues
* Add CCI helper macros to embed page number in the CCI private bits 28-31
* Remove ov05c10_switch_page(), include page switch logic in ov05c10_reg_read() and ov05c10_reg_write()
* Inline single-use functions - ov05c10_update_pad_format(), ov05c10_start_streaming(), ov05c10_stop_streaming()
* Move ov05c10_test_pattern_menu just above ov05c10_init_controls()
* Move ov05c10_init_state() to the other subdev ops
* Move v4l2_i2c_subdev_init() just before ov05c10_init_controls() to keep all subdev initialization grouped
* Use cached cur_mode instead of accessing global const array ov05c10_supported_modes in ov05c10_update_vblank(), ov05c10_init_controls() and ov05c10_set_ctrl()
* Rename macro OV05C10_REG_TEST_PATTERN_XXX to OV05C10_REG_TEST_PATTERN_CTL
* Change val type from u64 to u32 in ov05c10_update_vblank() and ov05c10_update_digital_gain()
* Call OV05C10_REG_TRIGGER once in ov05c10_set_ctrl() instead of calling in every update control function
* Store a struct device *dev in struct ov05c10, and access it instead of client->dev all the time
* Remove unnecessary if conditions and just do the action unconditionally
* Add .colorspace = V4L2_COLORSPACE_RAW to define the colorspace used by the format
* Remove ov05c10_start_streaming() and ov05c10_stop_streaming(), and include the respective code in ov05c10_enable_streams() and ov05c10_disable_streams()
* Drop the supported_mode.lanes field and use OV05C10_DATA_LANES
* Use ov05c10->link_freq_bitmap to select which link frequencies to expose to userspace
* Use devm_v4l2_sensor_clk_get() to get clock-frequency
* In ov05c10_probe, modify runtime PM implementation to make sensor work normally in both CONFIG_PM enabled and disabled cases
* Grouped macro definitions with other related macros at top of file
* Couldn't update hardcoded register offset values with valid register names due to lack of info from sensor vendor
* Fix typo, naming, indentations and other cosmetic errors

Dependencies:

 MAINTAINERS                 |    8 +
 drivers/media/i2c/Kconfig   |   10 +
 drivers/media/i2c/Makefile  |    1 +
 drivers/media/i2c/ov05c10.c | 1105 +++++++++++++++++++++++++++++++++++
 4 files changed, 1124 insertions(+)
 create mode 100644 drivers/media/i2c/ov05c10.c
MAINTAINERS +8 -0
index 60bba48f5479..6aa6dcc78c07 100644
@@ -18344,6 +18344,14 @@ T:	git git://linuxtv.org/media.git
 F:	Documentation/devicetree/bindings/media/i2c/ovti,ov02e10.yaml
 F:	drivers/media/i2c/ov02e10.c
 
+OMNIVISION OV05C10 SENSOR DRIVER
+M:	Nirujogi Pratap <[email protected]>
+M:	Bin Du <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media.git
+F:	drivers/media/i2c/ov05c10.c
+
 OMNIVISION OV08D10 SENSOR DRIVER
 M:	Jimmy Su <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +10 -0
index e68202954a8f..1662fb29d75c 100644
@@ -377,6 +377,16 @@ config VIDEO_OV02C10
 	  To compile this driver as a module, choose M here: the
 	  module will be called ov02c10.
 
+config VIDEO_OV05C10
+	tristate "OmniVision OV05C10 sensor support"
+	select V4L2_CCI_I2C
+	help
+	  This is a Video4Linux2 sensor driver for the OmniVision
+	  OV05C10 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called OV05C10.
+
 config VIDEO_OV08D10
         tristate "OmniVision OV08D10 sensor support"
         help
drivers/media/i2c/Makefile +1 -0
index 5873d29433ee..b4a1d721a7f2 100644
@@ -85,6 +85,7 @@ obj-$(CONFIG_VIDEO_OV01A10) += ov01a10.o
 obj-$(CONFIG_VIDEO_OV02A10) += ov02a10.o
 obj-$(CONFIG_VIDEO_OV02C10) += ov02c10.o
 obj-$(CONFIG_VIDEO_OV02E10) += ov02e10.o
+obj-$(CONFIG_VIDEO_OV05C10) += ov05c10.o
 obj-$(CONFIG_VIDEO_OV08D10) += ov08d10.o
 obj-$(CONFIG_VIDEO_OV08X40) += ov08x40.o
 obj-$(CONFIG_VIDEO_OV13858) += ov13858.o
drivers/media/i2c/ov05c10.c new file +1105 -0

1,105 lines not on this page · raw message

Signature · 1 line
2.43.0
#1 lore raw

drivers/media/i2c/ov05c10.c line 1024

Quoted 5 lines · Pratap Nirujogi
drivers/media/i2c/ov05c10.c new file +5 -0
+	ret = ov05c10_init_controls(ov05c10);
+	if (ret) {
+		dev_err(ov05c10->dev, "fail to init ov05c10 ctl %d\n", ret);
+		goto err_pm;
+	}

I would expect to see an "identify_module()" function here, something similar to ov02c10.

ret = ov02c10_power_on(&client->dev);

if (ret) {
        dev_err_probe(&client->dev, ret, "failed to power on\n");
        return ret;
}

ret = ov02c10_identify_module(ov02c10);

if (ret) {
       dev_err(&client->dev, "failed to find sensor: %d", ret);
        goto probe_error_power_off;
}

ret = ov02c10_init_controls(ov02c10);

if (ret) {
       dev_err(&client->dev, "failed to init controls: %d", ret);
        goto probe_error_v4l2_ctrl_handler_free;
}

Standard practice is to try to talk to the sensor in probe() and bug out if you can't.

With your current logic, the first time you'd realise no sensor was present or is in reset etc is the first time you try to stream I think..

Definitely a good idea to probe for your sensor in probe failing the probe if you can't find the hardware.

---
bod

#2 lore raw
Quoted 23 lines · Bryan O'Donoghue

drivers/media/i2c/ov05c10.c line 1024

Quoted 5 lines · Pratap Nirujogi
drivers/media/i2c/ov05c10.c new file +5 -0
+	ret = ov05c10_init_controls(ov05c10);
+	if (ret) {
+		dev_err(ov05c10->dev, "fail to init ov05c10 ctl %d\n", ret);
+		goto err_pm;
+	}

I would expect to see an "identify_module()" function here, something similar to ov02c10.

ret = ov02c10_power_on(&client->dev);

if (ret) {
         dev_err_probe(&client->dev, ret, "failed to power on\n");
         return ret;
}

ret = ov02c10_identify_module(ov02c10);

if (ret) {
        dev_err(&client->dev, "failed to find sensor: %d", ret);
         goto probe_error_power_off;
}
Quoted 8 lines

ret = ov02c10_init_controls(ov02c10);

if (ret) {
        dev_err(&client->dev, "failed to init controls: %d", ret);
         goto probe_error_v4l2_ctrl_handler_free;
}

Standard practice is to try to talk to the sensor in probe() and bug out if you can't.

It's actually not that standard, and is a frowned upon behaviour when the sensor has a privacy LED GPIO connected to the power rail instead of a hardware streaming signal. It would cause the privacy GPIO to flash at boot time, which is considered a worrying behaviour for users. That's why a few sensor drivers make runtime identification optional. We should try to handle that in a standard way across all drivers, likely based on a device property..

Quoted 5 lines

With your current logic, the first time you'd realise no sensor was present or is in reset etc is the first time you try to stream I think..

Definitely a good idea to probe for your sensor in probe failing the probe if you can't find the hardware.

Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Hi Laurent, Hi Bryan,

Quoted 36 lines · Laurent Pinchart

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 23 lines · Bryan O'Donoghue

drivers/media/i2c/ov05c10.c line 1024

Quoted 5 lines · Pratap Nirujogi
drivers/media/i2c/ov05c10.c new file +5 -0
+   ret = ov05c10_init_controls(ov05c10);
+   if (ret) {
+           dev_err(ov05c10->dev, "fail to init ov05c10 ctl %d\n", ret);
+           goto err_pm;
+   }

I would expect to see an "identify_module()" function here, something similar to ov02c10.

ret = ov02c10_power_on(&client->dev);

if (ret) {
          dev_err_probe(&client->dev, ret, "failed to power on\n");
          return ret;
}

ret = ov02c10_identify_module(ov02c10);

if (ret) {
         dev_err(&client->dev, "failed to find sensor: %d", ret);
          goto probe_error_power_off;
}
Quoted 8 lines

ret = ov02c10_init_controls(ov02c10);

if (ret) {
         dev_err(&client->dev, "failed to init controls: %d", ret);
          goto probe_error_v4l2_ctrl_handler_free;
}

Standard practice is to try to talk to the sensor in probe() and bug out if you can't.

Quoted 8 lines

It's actually not that standard, and is a frowned upon behaviour when the sensor has a privacy LED GPIO connected to the power rail instead of a hardware streaming signal. It would cause the privacy GPIO to flash at boot time, which is considered a worrying behaviour for users. That's why a few sensor drivers make runtime identification optional. We should try to handle that in a standard way across all drivers, likely based on a device property..

Shall I add chip_id as the device property variable in the x86/platform driver to address this comment? If this is okay, I will add a chip_id check reading the property variable in sensor probe(). Please share your thoughts.

Thanks,
Pratap

Quoted 10 lines
Quoted 5 lines

With your current logic, the first time you'd realise no sensor was present or is in reset etc is the first time you try to stream I think..

Definitely a good idea to probe for your sensor in probe failing the probe if you can't find the hardware.

--
Regards,

Laurent Pinchart

#4 lore raw
In reply to Pratap Nirujogi
kernel test robot noticed the following build errors:

Hi Pratap,

kernel test robot noticed the following build errors:

[auto build test ERROR on linuxtv-media-pending/master]
[also build test ERROR on sailus-media-tree/master linus/master v6.16-rc6 next-20250715] [cannot apply to sailus-media-tree/streams media-tree/master]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pratap-Nirujogi/media-i2c-Add-OV05C10-camera-sensor-driver/20250715-050130
base:   https://git.linuxtv.org/media-ci/media-pending.git master
patch link:    https://lore.kernel.org/r/20250714205805.1329403-1-pratap.nirujogi%40amd.com
patch subject: [PATCH v4] media: i2c: Add OV05C10 camera sensor driver
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20250715/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 15.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250715/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

drivers/media/i2c/ov05c10.c: In function 'ov05c10_init_controls':

>> drivers/media/i2c/ov05c10.c:790:13: warning: variable 'max_items' set but not used [-Wunused-but-set-variable]
     790 |         u32 max_items;
         |             ^~~~~~~~~
   drivers/media/i2c/ov05c10.c: In function 'ov05c10_probe':
>> drivers/media/i2c/ov05c10.c:964:24: error: implicit declaration of function 'devm_v4l2_sensor_clk_get' [-Wimplicit-function-declaration]
     964 |         ov05c10->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/media/i2c/ov05c10.c:964:22: error: assignment to 'struct clk *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     964 |         ov05c10->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
         |                      ^

vim +/devm_v4l2_sensor_clk_get +964 drivers/media/i2c/ov05c10.c

780
781 static int ov05c10_init_controls(struct ov05c10 *ov05c10)
782 {
783 struct v4l2_ctrl_handler *ctrl_hdlr = &ov05c10->ctrl_handler;
784 const struct ov05c10_mode *mode = ov05c10->cur_mode;
785 struct v4l2_fwnode_device_properties props;
786 s64 pixel_rate_max;
787 s64 exposure_max;
788 s64 vblank_def;
789 s64 vblank_min;

 > 790		u32 max_items;
   791		s64 hblank;
   792		int ret;
   793	
   794		ret = v4l2_fwnode_device_parse(ov05c10->dev, &props);
   795		if (ret)
   796			goto err_hdl_free;
   797	
   798		ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
   799		if (ret)
   800			return ret;
   801	
   802		max_items = ARRAY_SIZE(ov05c10_link_freq_menu_items) - 1;
   803		ov05c10->link_freq =
   804			v4l2_ctrl_new_int_menu(ctrl_hdlr,
   805					       NULL,
   806					       V4L2_CID_LINK_FREQ,
   807					       __fls(ov05c10->link_freq_bitmap),
   808					       __ffs(ov05c10->link_freq_bitmap),
   809					       ov05c10_link_freq_menu_items);
   810		if (ov05c10->link_freq)
   811			ov05c10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
   812	
   813		pixel_rate_max =
   814			link_freq_to_pixel_rate(ov05c10_link_freq_menu_items[0],
   815						mode->lanes);
   816		ov05c10->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, NULL,
   817							V4L2_CID_PIXEL_RATE,
   818							0, pixel_rate_max,
   819							1, pixel_rate_max);
   820	
   821		vblank_def = mode->vts_def - mode->height;
   822		vblank_min = mode->vts_min - mode->height;
   823		ov05c10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops,
   824						    V4L2_CID_VBLANK,
   825						    vblank_min,
   826						    OV05C10_VTS_MAX - mode->height,
   827						    1, vblank_def);
   828	
   829		hblank = mode->hts - mode->width;
   830		ov05c10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, NULL,
   831						    V4L2_CID_HBLANK,
   832						    hblank, hblank, 1, hblank);
   833		if (ov05c10->hblank)
   834			ov05c10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
   835	
   836		exposure_max = mode->vts_def - OV05C10_EXPOSURE_MAX_MARGIN;
   837		ov05c10->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops,
   838						      V4L2_CID_EXPOSURE,
   839						      OV05C10_EXPOSURE_MIN,
   840						      exposure_max,
   841						      OV05C10_EXPOSURE_STEP,
   842						      exposure_max);
   843	
   844		v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
   845				  OV05C10_ANA_GAIN_MIN, OV05C10_ANA_GAIN_MAX,
   846				  OV05C10_ANA_GAIN_STEP, OV05C10_ANA_GAIN_DEFAULT);
   847	
   848		v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
   849				  OV05C10_DGTL_GAIN_MIN, OV05C10_DGTL_GAIN_MAX,
   850				  OV05C10_DGTL_GAIN_STEP, OV05C10_DGTL_GAIN_DEFAULT);
   851	
   852		v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov05c10_ctrl_ops,
   853					     V4L2_CID_TEST_PATTERN,
   854					     ARRAY_SIZE(ov05c10_test_pattern_menu) - 1,
   855					     0, 0, ov05c10_test_pattern_menu);
   856	
   857		ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov05c10_ctrl_ops,
   858						      &props);
   859		if (ret)
   860			goto err_hdl_free;
   861	
   862		if (ctrl_hdlr->error) {
   863			ret = ctrl_hdlr->error;
   864			dev_err(ov05c10->dev, "V4L2 control init failed (%d)\n", ret);
   865			goto err_hdl_free;
   866		}
   867	
   868		ov05c10->sd.ctrl_handler = ctrl_hdlr;
   869	
   870		return 0;
   871	
   872	err_hdl_free:
   873		v4l2_ctrl_handler_free(ctrl_hdlr);
   874	
   875		return ret;
   876	}
   877	
   878	static int ov05c10_parse_endpoint(struct ov05c10 *ov05c10,
   879					  struct fwnode_handle *fwnode)
   880	{
   881		struct v4l2_fwnode_endpoint bus_cfg = {
   882			.bus_type = V4L2_MBUS_CSI2_DPHY
   883		};
   884		struct device *dev = ov05c10->dev;
   885		struct fwnode_handle *ep;
   886		int ret;
   887	
   888		ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
   889		if (!ep) {
   890			dev_err(dev, "Failed to get next endpoint\n");
   891			return -ENXIO;
   892		}
   893	
   894		ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
   895		fwnode_handle_put(ep);
   896		if (ret)
   897			return ret;
   898	
   899		if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV05C10_DATA_LANES) {
   900			dev_err(dev,
   901				"number of CSI2 data lanes %d is not supported\n",
   902				bus_cfg.bus.mipi_csi2.num_data_lanes);
   903			ret = -EINVAL;
   904			goto err_endpoint_free;
   905		}
   906	
   907		ret = v4l2_link_freq_to_bitmap(dev, bus_cfg.link_frequencies,
   908					       bus_cfg.nr_of_link_frequencies,
   909					       ov05c10_link_freq_menu_items,
   910					       ARRAY_SIZE(ov05c10_link_freq_menu_items),
   911					       &ov05c10->link_freq_bitmap);
   912		if (ret)
   913			dev_err(dev, "v4l2_link_freq_to_bitmap fail with %d\n", ret);
   914	err_endpoint_free:
   915		v4l2_fwnode_endpoint_free(&bus_cfg);
   916	
   917		return ret;
   918	}
   919	
   920	static int ov05c10_runtime_resume(struct device *dev)
   921	{
   922		struct v4l2_subdev *sd = dev_get_drvdata(dev);
   923		struct ov05c10 *ov05c10 = to_ov05c10(sd);
   924		int ret;
   925	
   926		ret = clk_prepare_enable(ov05c10->clk);
   927		if (ret) {
   928			dev_err(dev, "failed to enable clock %d\n", ret);
   929			goto error;
   930		}
   931	
   932		ov05c10_sensor_power_set(ov05c10, true);
   933	
   934	error:
   935		return ret;
   936	}
   937	
   938	static int ov05c10_runtime_suspend(struct device *dev)
   939	{
   940		struct v4l2_subdev *sd = dev_get_drvdata(dev);
   941		struct ov05c10 *ov05c10 = to_ov05c10(sd);
   942	
   943		ov05c10_sensor_power_set(ov05c10, false);
   944		clk_disable_unprepare(ov05c10->clk);
   945	
   946		return 0;
   947	}
   948	
   949	static int ov05c10_probe(struct i2c_client *client)
   950	{
   951		struct ov05c10 *ov05c10;
   952		u32 clkfreq;
   953		int ret;
   954	
   955		ov05c10 = devm_kzalloc(&client->dev, sizeof(*ov05c10), GFP_KERNEL);
   956		if (!ov05c10)
   957			return -ENOMEM;
   958	
   959		ov05c10->dev = &client->dev;
   960		ov05c10->cur_mode = &ov05c10_supported_modes[0];
   961	
   962		struct fwnode_handle *fwnode = dev_fwnode(ov05c10->dev);
   963	
 > 964		ov05c10->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);

965 if (IS_ERR(ov05c10->clk))
966 return dev_err_probe(&client->dev, PTR_ERR(ov05c10->clk),
967 "failed to get clk\n");
968
969 clkfreq = clk_get_rate(ov05c10->clk);
970 if (clkfreq != OV05C10_REF_CLK)
971 return dev_err_probe(ov05c10->dev, -EINVAL,
972 "fail invalid clock freq %u, %lu expected\n",
973 clkfreq, OV05C10_REF_CLK);
974
975 ret = ov05c10_parse_endpoint(ov05c10, fwnode);
976 if (ret)
977 return dev_err_probe(ov05c10->dev, -EINVAL,
978 "fail to parse endpoint\n");
979
980 ov05c10->enable_gpio = devm_gpiod_get(ov05c10->dev, "enable",
981 GPIOD_OUT_LOW);
982 if (IS_ERR(ov05c10->enable_gpio))
983 return dev_err_probe(ov05c10->dev,
984 PTR_ERR(ov05c10->enable_gpio),
985 "fail to get enable gpio\n");
986
987 ov05c10->regmap = devm_cci_regmap_init_i2c(client, 8);
988 if (IS_ERR(ov05c10->regmap))
989 return dev_err_probe(ov05c10->dev, PTR_ERR(ov05c10->regmap),
990 "fail to init cci\n");
991
992 ov05c10->cur_page = -1;
993 ov05c10->page_ctrl_reg = OV05C10_REG_PAGE_CTL;
994
995 /*
996 * Enable power management. The driver supports runtime PM, but needs to
997 * work when runtime PM is disabled in the kernel. To that end, power
998 * the sensor on manually here.
999 */
1000 ov05c10_sensor_power_set(ov05c10, true);
1001
1002 /*
1003 * Enable runtime PM with autosuspend. As the device has been powered
1004 * manually, mark it as active, and increase the usage count without
1005 * resuming the device.
1006 */
1007 pm_runtime_set_active(ov05c10->dev);
1008 pm_runtime_get_noresume(ov05c10->dev);
1009 pm_runtime_enable(ov05c10->dev);
1010 pm_runtime_set_autosuspend_delay(ov05c10->dev, 1000);
1011 pm_runtime_use_autosuspend(ov05c10->dev);
1012
1013 v4l2_i2c_subdev_init(&ov05c10->sd, client, &ov05c10_subdev_ops);
1014
1015 ret = ov05c10_runtime_resume(&client->dev);
1016 if (ret)
1017 return dev_err_probe(&client->dev, ret,
1018 "failed to power-on the sensor");
1019
1020 ret = ov05c10_init_controls(ov05c10);
1021 if (ret) {
1022 dev_err(ov05c10->dev, "fail to init ov05c10 ctl %d\n", ret);
1023 goto err_pm;
1024 }
1025
1026 ov05c10->sd.internal_ops = &ov05c10_internal_ops;
1027 ov05c10->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1028 ov05c10->sd.entity.ops = &ov05c10_subdev_entity_ops;
1029 ov05c10->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
1030
1031 ov05c10->pad.flags = MEDIA_PAD_FL_SOURCE;
1032
1033 ret = media_entity_pads_init(&ov05c10->sd.entity, OV05C10_NUM_OF_PADS,
1034 &ov05c10->pad);
1035 if (ret) {
1036 dev_err(ov05c10->dev, "fail to init ov05c10 pads %d\n", ret);
1037 goto err_hdl_free;
1038 }
1039
1040 ret = v4l2_subdev_init_finalize(&ov05c10->sd);
1041 if (ret < 0) {
1042 dev_err(ov05c10->dev, "fail to finalize ov05c10 subdev init %d\n", ret);
1043 goto err_media_entity_cleanup;
1044 }
1045
1046 ret = v4l2_async_register_subdev_sensor(&ov05c10->sd);
1047 if (ret) {
1048 dev_err(ov05c10->dev, "fail to register ov05c10 subdev %d\n", ret);
1049 goto err_media_entity_cleanup;
1050 }
1051
1052 return 0;
1053
1054 err_media_entity_cleanup:
1055 media_entity_cleanup(&ov05c10->sd.entity);
1056 err_hdl_free:
1057 v4l2_ctrl_handler_free(ov05c10->sd.ctrl_handler);
1058 err_pm:
1059 pm_runtime_disable(ov05c10->dev);
1060 pm_runtime_put_noidle(ov05c10->dev);
1061 ov05c10_sensor_power_set(ov05c10, false);
1062 return ret;
1063 }
1064

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#5 lore raw
In reply to Pratap Nirujogi
kernel test robot noticed the following build warnings:

Hi Pratap,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linuxtv-media-pending/master]
[also build test WARNING on sailus-media-tree/master linus/master v6.16-rc6 next-20250715] [cannot apply to sailus-media-tree/streams media-tree/master]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pratap-Nirujogi/media-i2c-Add-OV05C10-camera-sensor-driver/20250715-050130
base:   https://git.linuxtv.org/media-ci/media-pending.git master
patch link:    https://lore.kernel.org/r/20250714205805.1329403-1-pratap.nirujogi%40amd.com
patch subject: [PATCH v4] media: i2c: Add OV05C10 camera sensor driver
config: um-allyesconfig (https://download.01.org/0day-ci/archive/20250716/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250716/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/media/i2c/ov05c10.c: In function 'ov05c10_init_controls':
drivers/media/i2c/ov05c10.c:790:13: warning: variable 'max_items' set but not used [-Wunused-but-set-variable]

     790 |         u32 max_items;
         |             ^~~~~~~~~
   drivers/media/i2c/ov05c10.c: In function 'ov05c10_probe':
   drivers/media/i2c/ov05c10.c:964:24: error: implicit declaration of function 'devm_v4l2_sensor_clk_get' [-Werror=implicit-function-declaration]
     964 |         ov05c10->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/media/i2c/ov05c10.c:964:22: warning: assignment to 'struct clk *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     964 |         ov05c10->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
         |                      ^

cc1: some warnings being treated as errors

vim +964 drivers/media/i2c/ov05c10.c

780
781 static int ov05c10_init_controls(struct ov05c10 *ov05c10)
782 {
783 struct v4l2_ctrl_handler *ctrl_hdlr = &ov05c10->ctrl_handler;
784 const struct ov05c10_mode *mode = ov05c10->cur_mode;
785 struct v4l2_fwnode_device_properties props;
786 s64 pixel_rate_max;
787 s64 exposure_max;
788 s64 vblank_def;
789 s64 vblank_min;

 > 790		u32 max_items;
   791		s64 hblank;
   792		int ret;
   793	
   794		ret = v4l2_fwnode_device_parse(ov05c10->dev, &props);
   795		if (ret)
   796			goto err_hdl_free;
   797	
   798		ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
   799		if (ret)
   800			return ret;
   801	
   802		max_items = ARRAY_SIZE(ov05c10_link_freq_menu_items) - 1;
   803		ov05c10->link_freq =
   804			v4l2_ctrl_new_int_menu(ctrl_hdlr,
   805					       NULL,
   806					       V4L2_CID_LINK_FREQ,
   807					       __fls(ov05c10->link_freq_bitmap),
   808					       __ffs(ov05c10->link_freq_bitmap),
   809					       ov05c10_link_freq_menu_items);
   810		if (ov05c10->link_freq)
   811			ov05c10->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
   812	
   813		pixel_rate_max =
   814			link_freq_to_pixel_rate(ov05c10_link_freq_menu_items[0],
   815						mode->lanes);
   816		ov05c10->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, NULL,
   817							V4L2_CID_PIXEL_RATE,
   818							0, pixel_rate_max,
   819							1, pixel_rate_max);
   820	
   821		vblank_def = mode->vts_def - mode->height;
   822		vblank_min = mode->vts_min - mode->height;
   823		ov05c10->vblank = v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops,
   824						    V4L2_CID_VBLANK,
   825						    vblank_min,
   826						    OV05C10_VTS_MAX - mode->height,
   827						    1, vblank_def);
   828	
   829		hblank = mode->hts - mode->width;
   830		ov05c10->hblank = v4l2_ctrl_new_std(ctrl_hdlr, NULL,
   831						    V4L2_CID_HBLANK,
   832						    hblank, hblank, 1, hblank);
   833		if (ov05c10->hblank)
   834			ov05c10->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
   835	
   836		exposure_max = mode->vts_def - OV05C10_EXPOSURE_MAX_MARGIN;
   837		ov05c10->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops,
   838						      V4L2_CID_EXPOSURE,
   839						      OV05C10_EXPOSURE_MIN,
   840						      exposure_max,
   841						      OV05C10_EXPOSURE_STEP,
   842						      exposure_max);
   843	
   844		v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
   845				  OV05C10_ANA_GAIN_MIN, OV05C10_ANA_GAIN_MAX,
   846				  OV05C10_ANA_GAIN_STEP, OV05C10_ANA_GAIN_DEFAULT);
   847	
   848		v4l2_ctrl_new_std(ctrl_hdlr, &ov05c10_ctrl_ops, V4L2_CID_DIGITAL_GAIN,
   849				  OV05C10_DGTL_GAIN_MIN, OV05C10_DGTL_GAIN_MAX,
   850				  OV05C10_DGTL_GAIN_STEP, OV05C10_DGTL_GAIN_DEFAULT);
   851	
   852		v4l2_ctrl_new_std_menu_items(ctrl_hdlr, &ov05c10_ctrl_ops,
   853					     V4L2_CID_TEST_PATTERN,
   854					     ARRAY_SIZE(ov05c10_test_pattern_menu) - 1,
   855					     0, 0, ov05c10_test_pattern_menu);
   856	
   857		ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov05c10_ctrl_ops,
   858						      &props);
   859		if (ret)
   860			goto err_hdl_free;
   861	
   862		if (ctrl_hdlr->error) {
   863			ret = ctrl_hdlr->error;
   864			dev_err(ov05c10->dev, "V4L2 control init failed (%d)\n", ret);
   865			goto err_hdl_free;
   866		}
   867	
   868		ov05c10->sd.ctrl_handler = ctrl_hdlr;
   869	
   870		return 0;
   871	
   872	err_hdl_free:
   873		v4l2_ctrl_handler_free(ctrl_hdlr);
   874	
   875		return ret;
   876	}
   877	
   878	static int ov05c10_parse_endpoint(struct ov05c10 *ov05c10,
   879					  struct fwnode_handle *fwnode)
   880	{
   881		struct v4l2_fwnode_endpoint bus_cfg = {
   882			.bus_type = V4L2_MBUS_CSI2_DPHY
   883		};
   884		struct device *dev = ov05c10->dev;
   885		struct fwnode_handle *ep;
   886		int ret;
   887	
   888		ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
   889		if (!ep) {
   890			dev_err(dev, "Failed to get next endpoint\n");
   891			return -ENXIO;
   892		}
   893	
   894		ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
   895		fwnode_handle_put(ep);
   896		if (ret)
   897			return ret;
   898	
   899		if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV05C10_DATA_LANES) {
   900			dev_err(dev,
   901				"number of CSI2 data lanes %d is not supported\n",
   902				bus_cfg.bus.mipi_csi2.num_data_lanes);
   903			ret = -EINVAL;
   904			goto err_endpoint_free;
   905		}
   906	
   907		ret = v4l2_link_freq_to_bitmap(dev, bus_cfg.link_frequencies,
   908					       bus_cfg.nr_of_link_frequencies,
   909					       ov05c10_link_freq_menu_items,
   910					       ARRAY_SIZE(ov05c10_link_freq_menu_items),
   911					       &ov05c10->link_freq_bitmap);
   912		if (ret)
   913			dev_err(dev, "v4l2_link_freq_to_bitmap fail with %d\n", ret);
   914	err_endpoint_free:
   915		v4l2_fwnode_endpoint_free(&bus_cfg);
   916	
   917		return ret;
   918	}
   919	
   920	static int ov05c10_runtime_resume(struct device *dev)
   921	{
   922		struct v4l2_subdev *sd = dev_get_drvdata(dev);
   923		struct ov05c10 *ov05c10 = to_ov05c10(sd);
   924		int ret;
   925	
   926		ret = clk_prepare_enable(ov05c10->clk);
   927		if (ret) {
   928			dev_err(dev, "failed to enable clock %d\n", ret);
   929			goto error;
   930		}
   931	
   932		ov05c10_sensor_power_set(ov05c10, true);
   933	
   934	error:
   935		return ret;
   936	}
   937	
   938	static int ov05c10_runtime_suspend(struct device *dev)
   939	{
   940		struct v4l2_subdev *sd = dev_get_drvdata(dev);
   941		struct ov05c10 *ov05c10 = to_ov05c10(sd);
   942	
   943		ov05c10_sensor_power_set(ov05c10, false);
   944		clk_disable_unprepare(ov05c10->clk);
   945	
   946		return 0;
   947	}
   948	
   949	static int ov05c10_probe(struct i2c_client *client)
   950	{
   951		struct ov05c10 *ov05c10;
   952		u32 clkfreq;
   953		int ret;
   954	
   955		ov05c10 = devm_kzalloc(&client->dev, sizeof(*ov05c10), GFP_KERNEL);
   956		if (!ov05c10)
   957			return -ENOMEM;
   958	
   959		ov05c10->dev = &client->dev;
   960		ov05c10->cur_mode = &ov05c10_supported_modes[0];
   961	
   962		struct fwnode_handle *fwnode = dev_fwnode(ov05c10->dev);
   963	
 > 964		ov05c10->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);

965 if (IS_ERR(ov05c10->clk))
966 return dev_err_probe(&client->dev, PTR_ERR(ov05c10->clk),
967 "failed to get clk\n");
968
969 clkfreq = clk_get_rate(ov05c10->clk);
970 if (clkfreq != OV05C10_REF_CLK)
971 return dev_err_probe(ov05c10->dev, -EINVAL,
972 "fail invalid clock freq %u, %lu expected\n",
973 clkfreq, OV05C10_REF_CLK);
974
975 ret = ov05c10_parse_endpoint(ov05c10, fwnode);
976 if (ret)
977 return dev_err_probe(ov05c10->dev, -EINVAL,
978 "fail to parse endpoint\n");
979
980 ov05c10->enable_gpio = devm_gpiod_get(ov05c10->dev, "enable",
981 GPIOD_OUT_LOW);
982 if (IS_ERR(ov05c10->enable_gpio))
983 return dev_err_probe(ov05c10->dev,
984 PTR_ERR(ov05c10->enable_gpio),
985 "fail to get enable gpio\n");
986
987 ov05c10->regmap = devm_cci_regmap_init_i2c(client, 8);
988 if (IS_ERR(ov05c10->regmap))
989 return dev_err_probe(ov05c10->dev, PTR_ERR(ov05c10->regmap),
990 "fail to init cci\n");
991
992 ov05c10->cur_page = -1;
993 ov05c10->page_ctrl_reg = OV05C10_REG_PAGE_CTL;
994
995 /*
996 * Enable power management. The driver supports runtime PM, but needs to
997 * work when runtime PM is disabled in the kernel. To that end, power
998 * the sensor on manually here.
999 */
1000 ov05c10_sensor_power_set(ov05c10, true);
1001
1002 /*
1003 * Enable runtime PM with autosuspend. As the device has been powered
1004 * manually, mark it as active, and increase the usage count without
1005 * resuming the device.
1006 */
1007 pm_runtime_set_active(ov05c10->dev);
1008 pm_runtime_get_noresume(ov05c10->dev);
1009 pm_runtime_enable(ov05c10->dev);
1010 pm_runtime_set_autosuspend_delay(ov05c10->dev, 1000);
1011 pm_runtime_use_autosuspend(ov05c10->dev);
1012
1013 v4l2_i2c_subdev_init(&ov05c10->sd, client, &ov05c10_subdev_ops);
1014
1015 ret = ov05c10_runtime_resume(&client->dev);
1016 if (ret)
1017 return dev_err_probe(&client->dev, ret,
1018 "failed to power-on the sensor");
1019
1020 ret = ov05c10_init_controls(ov05c10);
1021 if (ret) {
1022 dev_err(ov05c10->dev, "fail to init ov05c10 ctl %d\n", ret);
1023 goto err_pm;
1024 }
1025
1026 ov05c10->sd.internal_ops = &ov05c10_internal_ops;
1027 ov05c10->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
1028 ov05c10->sd.entity.ops = &ov05c10_subdev_entity_ops;
1029 ov05c10->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
1030
1031 ov05c10->pad.flags = MEDIA_PAD_FL_SOURCE;
1032
1033 ret = media_entity_pads_init(&ov05c10->sd.entity, OV05C10_NUM_OF_PADS,
1034 &ov05c10->pad);
1035 if (ret) {
1036 dev_err(ov05c10->dev, "fail to init ov05c10 pads %d\n", ret);
1037 goto err_hdl_free;
1038 }
1039
1040 ret = v4l2_subdev_init_finalize(&ov05c10->sd);
1041 if (ret < 0) {
1042 dev_err(ov05c10->dev, "fail to finalize ov05c10 subdev init %d\n", ret);
1043 goto err_media_entity_cleanup;
1044 }
1045
1046 ret = v4l2_async_register_subdev_sensor(&ov05c10->sd);
1047 if (ret) {
1048 dev_err(ov05c10->dev, "fail to register ov05c10 subdev %d\n", ret);
1049 goto err_media_entity_cleanup;
1050 }
1051
1052 return 0;
1053
1054 err_media_entity_cleanup:
1055 media_entity_cleanup(&ov05c10->sd.entity);
1056 err_hdl_free:
1057 v4l2_ctrl_handler_free(ov05c10->sd.ctrl_handler);
1058 err_pm:
1059 pm_runtime_disable(ov05c10->dev);
1060 pm_runtime_put_noidle(ov05c10->dev);
1061 ov05c10_sensor_power_set(ov05c10, false);
1062 return ret;
1063 }
1064

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki