All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: mchehab@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, kishon@ti.com,
	vkoul@kernel.org, laurent.pinchart@ideasonboard.com,
	jacopo@jmondi.org, hverkuil@xs4all.nl,
	linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-media@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH v3 4/4] media: tc358746: add Toshiba TC358746 Parallel to CSI-2 bridge driver
Date: Fri, 23 Sep 2022 16:38:11 +0200	[thread overview]
Message-ID: <20220923143811.d5gk52vh2koczyhk@pengutronix.de> (raw)
In-Reply-To: <Yy2rNit+rRGkcFdL@paasikivi.fi.intel.com>

Hi Sakari,

On 22-09-23, Sakari Ailus wrote:
> Hi Marco,
> 
> Thanks for the update. A few small things below.
> 
> On Thu, Sep 22, 2022 at 03:48:43PM +0200, Marco Felsch wrote:
> ...
> > +static int tc358746_apply_misc_config(struct tc358746 *tc358746)
> > +{
> > +	const struct v4l2_mbus_framefmt *mbusfmt;
> > +	struct v4l2_subdev *sd = &tc358746->sd;
> > +	struct v4l2_subdev_state *sink_state;
> > +	const struct tc358746_format *fmt;
> > +	struct device *dev = sd->dev;
> > +	u32 val;
> > +	int err;
> > +
> > +	sink_state = v4l2_subdev_lock_and_get_active_state(sd);
> > +	mbusfmt = v4l2_subdev_get_pad_format(sd, sink_state, TC358746_SINK);
> > +	v4l2_subdev_unlock_state(sink_state);
> > +
> > +	fmt = tc358746_get_format_by_code(TC358746_SINK, mbusfmt->code);
> 
> You can no longer access mbusfmt here as you've already unlocked subdev
> state.

You're right, Laurent also mentioned this but this function gets called
during .s_stream(on) so the format shouldn't be changed that late.
However since you're the 2nd with the thought, I will fix it in the v4.

> > +
> > +	/* Self defined CSI user data type id's are not supported yet */
> > +	val = PDFMT(fmt->pdformat);
> > +	dev_dbg(dev, "DATAFMT: 0x%x\n", val);
> > +	err = tc358746_write(tc358746, DATAFMT_REG, val);
> > +	if (err)
> > +		return err;
> > +
> > +	val = PDATAF(fmt->pdataf);
> > +	dev_dbg(dev, "CONFCTL[PDATAF]: 0x%x\n", fmt->pdataf);
> > +	err = tc358746_update_bits(tc358746, CONFCTL_REG, PDATAF_MASK, val);
> > +	if (err)
> > +		return err;
> > +
> > +	val = tc358746->vb_size / 32;
> > +	dev_dbg(dev, "FIFOCTL: %u (0x%x)\n", val, val);
> > +	err = tc358746_write(tc358746, FIFOCTL_REG, val);
> > +	if (err)
> > +		return err;
> > +
> > +	/* Total number of bytes for each line/width */
> > +	val = mbusfmt->width * fmt->bpp / 8;
> > +	dev_dbg(dev, "WORDCNT: %u (0x%x)\n", val, val);
> > +	return tc358746_write(tc358746, WORDCNT_REG, val);
> > +}
> 
> ...
> 
> > +static int tc358746_s_stream(struct v4l2_subdev *sd, int enable)
> > +{
> > +	struct tc358746 *tc358746 = to_tc358746(sd);
> > +	struct v4l2_subdev *src;
> > +	int err;
> > +
> > +	dev_dbg(sd->dev, "%sable\n", enable ? "en" : "dis");
> > +
> > +	src = tc358746_get_remote_sd(&tc358746->pads[TC358746_SINK]);
> > +	if (!src)
> > +		return -EPIPE;
> > +
> > +	if (enable) {
> > +		err = pm_runtime_resume_and_get(sd->dev);
> > +		if (err)
> > +			return err;
> > +
> > +		err = tc358746_apply_dphy_config(tc358746);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_apply_misc_config(tc358746);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_enable_csi_lanes(tc358746, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_enable_csi_module(tc358746, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_enable_parallel_port(tc358746, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = v4l2_subdev_call(src, video, s_stream, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		return err;
> 
> This can be return 0.

Sure.

Regards,
  Marco

> 
> > +
> > +err_out:
> > +		pm_runtime_mark_last_busy(sd->dev);
> > +		pm_runtime_put_sync_autosuspend(sd->dev);
> > +
> > +		return err;
> > +	}
> 
> -- 
> Kind regards,
> 
> Sakari Ailus
> 

WARNING: multiple messages have this Message-ID (diff)
From: Marco Felsch <m.felsch@pengutronix.de>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: mchehab@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, kishon@ti.com,
	vkoul@kernel.org, laurent.pinchart@ideasonboard.com,
	jacopo@jmondi.org, hverkuil@xs4all.nl,
	linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org, linux-media@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH v3 4/4] media: tc358746: add Toshiba TC358746 Parallel to CSI-2 bridge driver
Date: Fri, 23 Sep 2022 16:38:11 +0200	[thread overview]
Message-ID: <20220923143811.d5gk52vh2koczyhk@pengutronix.de> (raw)
In-Reply-To: <Yy2rNit+rRGkcFdL@paasikivi.fi.intel.com>

Hi Sakari,

On 22-09-23, Sakari Ailus wrote:
> Hi Marco,
> 
> Thanks for the update. A few small things below.
> 
> On Thu, Sep 22, 2022 at 03:48:43PM +0200, Marco Felsch wrote:
> ...
> > +static int tc358746_apply_misc_config(struct tc358746 *tc358746)
> > +{
> > +	const struct v4l2_mbus_framefmt *mbusfmt;
> > +	struct v4l2_subdev *sd = &tc358746->sd;
> > +	struct v4l2_subdev_state *sink_state;
> > +	const struct tc358746_format *fmt;
> > +	struct device *dev = sd->dev;
> > +	u32 val;
> > +	int err;
> > +
> > +	sink_state = v4l2_subdev_lock_and_get_active_state(sd);
> > +	mbusfmt = v4l2_subdev_get_pad_format(sd, sink_state, TC358746_SINK);
> > +	v4l2_subdev_unlock_state(sink_state);
> > +
> > +	fmt = tc358746_get_format_by_code(TC358746_SINK, mbusfmt->code);
> 
> You can no longer access mbusfmt here as you've already unlocked subdev
> state.

You're right, Laurent also mentioned this but this function gets called
during .s_stream(on) so the format shouldn't be changed that late.
However since you're the 2nd with the thought, I will fix it in the v4.

> > +
> > +	/* Self defined CSI user data type id's are not supported yet */
> > +	val = PDFMT(fmt->pdformat);
> > +	dev_dbg(dev, "DATAFMT: 0x%x\n", val);
> > +	err = tc358746_write(tc358746, DATAFMT_REG, val);
> > +	if (err)
> > +		return err;
> > +
> > +	val = PDATAF(fmt->pdataf);
> > +	dev_dbg(dev, "CONFCTL[PDATAF]: 0x%x\n", fmt->pdataf);
> > +	err = tc358746_update_bits(tc358746, CONFCTL_REG, PDATAF_MASK, val);
> > +	if (err)
> > +		return err;
> > +
> > +	val = tc358746->vb_size / 32;
> > +	dev_dbg(dev, "FIFOCTL: %u (0x%x)\n", val, val);
> > +	err = tc358746_write(tc358746, FIFOCTL_REG, val);
> > +	if (err)
> > +		return err;
> > +
> > +	/* Total number of bytes for each line/width */
> > +	val = mbusfmt->width * fmt->bpp / 8;
> > +	dev_dbg(dev, "WORDCNT: %u (0x%x)\n", val, val);
> > +	return tc358746_write(tc358746, WORDCNT_REG, val);
> > +}
> 
> ...
> 
> > +static int tc358746_s_stream(struct v4l2_subdev *sd, int enable)
> > +{
> > +	struct tc358746 *tc358746 = to_tc358746(sd);
> > +	struct v4l2_subdev *src;
> > +	int err;
> > +
> > +	dev_dbg(sd->dev, "%sable\n", enable ? "en" : "dis");
> > +
> > +	src = tc358746_get_remote_sd(&tc358746->pads[TC358746_SINK]);
> > +	if (!src)
> > +		return -EPIPE;
> > +
> > +	if (enable) {
> > +		err = pm_runtime_resume_and_get(sd->dev);
> > +		if (err)
> > +			return err;
> > +
> > +		err = tc358746_apply_dphy_config(tc358746);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_apply_misc_config(tc358746);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_enable_csi_lanes(tc358746, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_enable_csi_module(tc358746, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = tc358746_enable_parallel_port(tc358746, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		err = v4l2_subdev_call(src, video, s_stream, 1);
> > +		if (err)
> > +			goto err_out;
> > +
> > +		return err;
> 
> This can be return 0.

Sure.

Regards,
  Marco

> 
> > +
> > +err_out:
> > +		pm_runtime_mark_last_busy(sd->dev);
> > +		pm_runtime_put_sync_autosuspend(sd->dev);
> > +
> > +		return err;
> > +	}
> 
> -- 
> Kind regards,
> 
> Sakari Ailus
> 

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2022-09-23 14:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 13:48 [PATCH v3 0/4] Add support for Toshiba TC358746 Marco Felsch
2022-09-22 13:48 ` Marco Felsch
2022-09-22 13:48 ` [PATCH v3 1/4] phy: dphy: refactor get_default_config Marco Felsch
2022-09-22 13:48   ` Marco Felsch
2022-09-22 13:48 ` [PATCH v3 2/4] phy: dphy: add support to calculate the timing based on hs_clk_rate Marco Felsch
2022-09-22 13:48   ` Marco Felsch
2022-09-22 13:48 ` [PATCH v3 3/4] media: dt-bindings: add bindings for Toshiba TC358746 Marco Felsch
2022-09-22 13:48   ` Marco Felsch
2022-09-22 13:48 ` [PATCH v3 4/4] media: tc358746: add Toshiba TC358746 Parallel to CSI-2 bridge driver Marco Felsch
2022-09-22 13:48   ` Marco Felsch
2022-09-22 18:35   ` Laurent Pinchart
2022-09-22 18:35     ` Laurent Pinchart
2022-09-23  9:27     ` Marco Felsch
2022-09-23  9:27       ` Marco Felsch
2022-09-23 13:45       ` Laurent Pinchart
2022-09-23 13:45         ` Laurent Pinchart
2022-09-23 14:30         ` Marco Felsch
2022-09-23 14:30           ` Marco Felsch
2022-09-23 12:48   ` Sakari Ailus
2022-09-23 12:48     ` Sakari Ailus
2022-09-23 14:38     ` Marco Felsch [this message]
2022-09-23 14:38       ` Marco Felsch

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=20220923143811.d5gk52vh2koczyhk@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=devicetree@vger.kernel.org \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo@jmondi.org \
    --cc=kernel@pengutronix.de \
    --cc=kishon@ti.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=vkoul@kernel.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.