All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Himanshu Bhavani <himanshu.bhavani@siliconsignals.io>
Cc: robh@kernel.org, krzk+dt@kernel.org,
	"Elgin Perumbilly" <elgin.perumbilly@siliconsignals.io>,
	"Vladimir Zapolskiy" <vladimir.zapolskiy@linaro.org>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Hans Verkuil" <hverkuil@kernel.org>,
	"Hans de Goede" <hansg@kernel.org>,
	"Mehdi Djait" <mehdi.djait@linux.intel.com>,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"André Apitzsch" <git@apitzsch.eu>,
	"Benjamin Mugnier" <benjamin.mugnier@foss.st.com>,
	"Sylvain Petinot" <sylvain.petinot@foss.st.com>,
	"Dongcheng Yan" <dongcheng.yan@intel.com>,
	"Svyatoslav Ryhel" <clamor95@gmail.com>,
	"Jingjing Xiong" <jingjing.xiong@intel.com>,
	"Heimir Thor Sverrisson" <heimir.sverrisson@gmail.com>,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/2] media: i2c: add os05b10 image sensor driver
Date: Tue, 30 Dec 2025 14:24:50 +0200	[thread overview]
Message-ID: <aVPEkhP2587xcF78@kekkonen.localdomain> (raw)
In-Reply-To: <20251219084526.22841-3-himanshu.bhavani@siliconsignals.io>

Hi Himanshu,

Thanks for the set. A few comments below...

On Fri, Dec 19, 2025 at 02:15:19PM +0530, Himanshu Bhavani wrote:
> +static int os05b10_disable_streams(struct v4l2_subdev *sd,
> +				   struct v4l2_subdev_state *state,
> +				   u32 pad, u64 streams_mask)
> +{
> +	struct os05b10 *os05b10 = to_os05b10(sd);
> +	int ret;
> +
> +	ret = cci_write(os05b10->cci, OS05B10_REG_CTRL_MODE,
> +			OS05B10_MODE_STANDBY, NULL);
> +	if (ret)
> +		dev_err(os05b10->dev, "%s failed to set stream off\n", __func__);

I'd drop the function name here, it's obvious where this comes from. Same
elsewhere.

> +
> +	pm_runtime_put(os05b10->dev);
> +
> +	return ret;
> +}
> +
> +static int os05b10_init_state(struct v4l2_subdev *sd,
> +			      struct v4l2_subdev_state *state)
> +{
> +	struct v4l2_mbus_framefmt *format;
> +	const struct os05b10_mode *mode;
> +
> +	/* Initialize try_fmt */
> +	format = v4l2_subdev_state_get_format(state, 0);
> +
> +	mode = &supported_modes_10bit[0];
> +	format->code = MEDIA_BUS_FMT_SBGGR10_1X10;
> +
> +	/* Update image pad formate */
> +	format->width = mode->width;
> +	format->height = mode->height;
> +	format->field = V4L2_FIELD_NONE;
> +	format->colorspace = V4L2_COLORSPACE_RAW;
> +	format->quantization = V4L2_QUANTIZATION_FULL_RANGE;
> +	format->xfer_func = V4L2_XFER_FUNC_NONE;
> +
> +	return 0;
> +}
> +
> +static const struct v4l2_subdev_video_ops os05b10_video_ops = {
> +	.s_stream = v4l2_subdev_s_stream_helper,
> +};
> +
> +static const struct v4l2_subdev_pad_ops os05b10_pad_ops = {
> +	.enum_mbus_code = os05b10_enum_mbus_code,
> +	.get_fmt = v4l2_subdev_get_fmt,
> +	.set_fmt = os05b10_set_pad_format,
> +	.get_selection = os05b10_get_selection,
> +	.enum_frame_size = os05b10_enum_frame_size,
> +	.enable_streams = os05b10_enable_streams,
> +	.disable_streams = os05b10_disable_streams,
> +};
> +
> +static const struct v4l2_subdev_internal_ops os05b10_internal_ops = {
> +	.init_state = os05b10_init_state,
> +};
> +
> +static const struct v4l2_subdev_ops os05b10_subdev_ops = {
> +	.video = &os05b10_video_ops,
> +	.pad = &os05b10_pad_ops,
> +};
> +
> +static const struct v4l2_ctrl_ops os05b10_ctrl_ops = {
> +	.s_ctrl = os05b10_set_ctrl,
> +};
> +
> +static int os05b10_identify_module(struct os05b10 *os05b10)
> +{
> +	int ret;
> +	u64 val;
> +
> +	ret = cci_read(os05b10->cci, OS05B10_REG_CHIP_ID, &val, NULL);
> +	if (ret)
> +		return dev_err_probe(os05b10->dev, ret,
> +				     "failed to read chip id %x\n",
> +				     OS05B10_CHIP_ID);
> +
> +	if (val != OS05B10_CHIP_ID)
> +		return dev_err_probe(os05b10->dev, -ENODEV,
> +				     "chip id mismatch: %x!=%llx\n",
> +				     OS05B10_CHIP_ID, val);
> +
> +	return 0;
> +}
> +
> +static int os05b10_power_on(struct device *dev)
> +{
> +	struct v4l2_subdev *sd = dev_get_drvdata(dev);
> +	struct os05b10 *os05b10 = to_os05b10(sd);
> +	unsigned long delay_us;
> +	int ret;
> +
> +	/* Enable power rails */
> +	ret = regulator_bulk_enable(ARRAY_SIZE(os05b10_supply_name),
> +				    os05b10->supplies);
> +	if (ret) {
> +		dev_err(os05b10->dev, "failed to enable regulators\n");
> +		return ret;
> +	}
> +
> +	/* Enable xclk */
> +	ret = clk_prepare_enable(os05b10->xclk);
> +	if (ret) {
> +		dev_err(os05b10->dev, "failed to enable clock\n");
> +		goto err_regulator_off;
> +	}
> +
> +	gpiod_set_value_cansleep(os05b10->reset_gpio, 0);
> +
> +	/* Delay T1 */
> +	fsleep(5 * USEC_PER_MSEC);
> +
> +	/* Delay T2 (8192 cycles before SCCB/I2C access) */
> +	delay_us = DIV_ROUND_UP(8192, OS05B10_XCLK_FREQ / 1000 / 1000);
> +	usleep_range(delay_us, delay_us * 2);
> +
> +	return 0;
> +
> +err_regulator_off:
> +	regulator_bulk_disable(ARRAY_SIZE(os05b10_supply_name),
> +			       os05b10->supplies);
> +
> +	return ret;
> +}
> +
> +static int os05b10_power_off(struct device *dev)
> +{
> +	struct v4l2_subdev *sd = dev_get_drvdata(dev);
> +	struct os05b10 *os05b10 = to_os05b10(sd);
> +
> +	gpiod_set_value_cansleep(os05b10->reset_gpio, 1);
> +
> +	regulator_bulk_disable(ARRAY_SIZE(os05b10_supply_name), os05b10->supplies);

Can you run

	$ ./scripts/checkpatch.pl --strict --max-line-length=80

on the set, please?

> +	clk_disable_unprepare(os05b10->xclk);
> +
> +	return 0;
> +}
> +
> +static int os05b10_parse_endpoint(struct os05b10 *os05b10)
> +{
> +	struct v4l2_fwnode_endpoint bus_cfg = {
> +		.bus_type = V4L2_MBUS_CSI2_DPHY
> +	};
> +	unsigned long link_freq_bitmap;
> +	struct fwnode_handle *ep;
> +	int ret;
> +
> +	ep = fwnode_graph_get_next_endpoint(dev_fwnode(os05b10->dev), NULL);

Please use fwnode-graph_get_endpoint_by_id() instead.

> +	if (!ep) {
> +		dev_err(os05b10->dev, "Failed to get next endpoint\n");
> +		return -ENXIO;
> +	}
> +
> +	ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
> +	fwnode_handle_put(ep);
> +	if (ret)
> +		return ret;
> +
> +	if (bus_cfg.bus.mipi_csi2.num_data_lanes != 4) {
> +		ret = dev_err_probe(os05b10->dev, -EINVAL,
> +				    "only 4 data lanes are supported\n");
> +		goto error_out;
> +	}
> +
> +	ret = v4l2_link_freq_to_bitmap(os05b10->dev, bus_cfg.link_frequencies,
> +				       bus_cfg.nr_of_link_frequencies,
> +				       link_frequencies,
> +				       ARRAY_SIZE(link_frequencies),
> +				       &link_freq_bitmap);
> +
> +	if (ret)
> +		dev_err(os05b10->dev, "only 600MHz frequency is available\n");
> +
> +error_out:
> +	v4l2_fwnode_endpoint_free(&bus_cfg);
> +
> +	return ret;
> +}

-- 
Kind regards,

Sakari Ailus

      parent reply	other threads:[~2025-12-30 12:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-19  8:45 [PATCH v6 0/2] media: i2c: Add os05b10 camera sensor driver Himanshu Bhavani
2025-12-19  8:45 ` [PATCH v6 1/2] dt-bindings: media: i2c: Add os05b10 sensor Himanshu Bhavani
2025-12-19 14:43   ` Krzysztof Kozlowski
2025-12-20  6:37     ` Himanshu Bhavani
2025-12-20  8:21       ` Krzysztof Kozlowski
2025-12-20  8:59         ` Himanshu Bhavani
2025-12-20  8:21   ` Krzysztof Kozlowski
2025-12-19  8:45 ` [PATCH v6 2/2] media: i2c: add os05b10 image sensor driver Himanshu Bhavani
2025-12-19 14:07   ` Mehdi Djait
2025-12-20  6:01     ` Tarang Raval
2025-12-22 16:08       ` Mehdi Djait
2025-12-30 12:24   ` Sakari Ailus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aVPEkhP2587xcF78@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=benjamin.mugnier@foss.st.com \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dongcheng.yan@intel.com \
    --cc=elgin.perumbilly@siliconsignals.io \
    --cc=git@apitzsch.eu \
    --cc=hansg@kernel.org \
    --cc=heimir.sverrisson@gmail.com \
    --cc=himanshu.bhavani@siliconsignals.io \
    --cc=hverkuil@kernel.org \
    --cc=jingjing.xiong@intel.com \
    --cc=krzk+dt@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mehdi.djait@linux.intel.com \
    --cc=robh@kernel.org \
    --cc=sylvain.petinot@foss.st.com \
    --cc=vladimir.zapolskiy@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.