All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: linux-renesas-soc@vger.kernel.org,
	"Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Hyun Kwon" <hyunk@xilinx.com>,
	"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>
Subject: Re: [PATCH v8 10/13] squash! max9286: Implement Pixelrate control
Date: Fri, 10 Apr 2020 08:51:21 +0100	[thread overview]
Message-ID: <bdb73234-7ef1-dd66-0393-5317688b7c63@ideasonboard.com> (raw)
In-Reply-To: <20200409162956.xz3ykjl5sgwkwbnx@uno.localdomain>

On 09/04/2020 17:29, Jacopo Mondi wrote:
> Hi Kieran,
> 
> On Thu, Apr 09, 2020 at 01:11:59PM +0100, Kieran Bingham wrote:
>> Determine the (CSI2) pixel rate control by providing a control to read,
>> and checking the rate from the upstream camera sensors, and their
>> appropriate formats.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
>> ---
>>  drivers/media/i2c/max9286.c | 44 ++++++++++++++++++++++++++++++++-----
>>  1 file changed, 38 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
>> index 17830c362a50..008a93910300 100644
>> --- a/drivers/media/i2c/max9286.c
>> +++ b/drivers/media/i2c/max9286.c
>> @@ -155,6 +155,7 @@ struct max9286_priv {
>>  	bool mux_open;
>>
>>  	struct v4l2_ctrl_handler ctrls;
>> +	struct v4l2_ctrl *pixelrate;
>>
>>  	struct v4l2_mbus_framefmt fmt[MAX9286_N_SINKS];
>>
>> @@ -631,6 +632,16 @@ static int max9286_s_stream(struct v4l2_subdev *sd, int enable)
>>  	return 0;
>>  }
>>
>> +static int max9286_set_pixelrate(struct max9286_priv *priv, s64 rate)
>> +{
>> +	if (!priv->pixelrate)
>> +		return -EINVAL;
> 
> Can this happen ?

Hrm ... no because the control is registered when we register the V4L2
device, - so there can't be an occasion where we don't have it :-)

Removing and simplifying.

> 
>> +
>> +	dev_err(&priv->client->dev, "Setting pixel rate to %lld\n", rate);
> 
> Is this an error ?


Oops - debug print failure :-)

I can just drop this line.


>> +
>> +	return v4l2_ctrl_s_ctrl_int64(priv->pixelrate, rate);
>> +}
>> +
>>  static int max9286_enum_mbus_code(struct v4l2_subdev *sd,
>>  				  struct v4l2_subdev_pad_config *cfg,
>>  				  struct v4l2_subdev_mbus_code_enum *code)
>> @@ -664,6 +675,7 @@ static int max9286_set_fmt(struct v4l2_subdev *sd,
>>  {
>>  	struct max9286_priv *priv = sd_to_max9286(sd);
>>  	struct v4l2_mbus_framefmt *cfg_fmt;
>> +	s64 pixelrate;
>>
>>  	if (format->pad >= MAX9286_SRC_PAD)
>>  		return -EINVAL;
>> @@ -688,6 +700,12 @@ static int max9286_set_fmt(struct v4l2_subdev *sd,
>>  	*cfg_fmt = format->format;
>>  	mutex_unlock(&priv->mutex);
>>
>> +	/* Update pixel rate for the CSI2 receiver */
>> +	pixelrate = cfg_fmt->width * cfg_fmt->height
>> +		  * priv->nsources * 30 /*FPS*/;
>> +
>> +	max9286_set_pixelrate(priv, pixelrate);
>> +
>>  	return 0;
>>  }
>>
>> @@ -756,6 +774,20 @@ static const struct v4l2_subdev_internal_ops max9286_subdev_internal_ops = {
>>  	.open = max9286_open,
>>  };
>>
>> +static int max9286_s_ctrl(struct v4l2_ctrl *ctrl)
>> +{
>> +	switch (ctrl->id) {
>> +	case V4L2_CID_PIXEL_RATE:
>> +		return 0;
>> +	default:
>> +		return -EINVAL;
>> +	}
>> +}
>> +
>> +static const struct v4l2_ctrl_ops max9286_ctrl_ops = {
>> +	.s_ctrl	= max9286_s_ctrl,
>> +};
>> +
> 
> After -years- I still don't get controls fully... Where is get? that's
> the whole point of calculating the pixel rate to report it to the
> receiver... I would not allow setting this from the extern but just
> retrieve it after it has been updated by a set_format().
> 
> Am I getting controls wrong again ?

The control framework handles get. The value is stored in the
priv->pixelrate control structure or managed by the core.

The CSI2 receiver calls the get operation on this subdev to know what
the rate is for the CSI2 link, see:

https://git.kernel.org/pub/scm/linux/kernel/git/kbingham/rcar.git/tree/drivers/media/platform/rcar-vin/rcar-csi2.c?h=gmsl/dev#n449

> 
>>  static int max9286_v4l2_register(struct max9286_priv *priv)
>>  {
>>  	struct device *dev = &priv->client->dev;
>> @@ -777,12 +809,12 @@ static int max9286_v4l2_register(struct max9286_priv *priv)
>>  	priv->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
>>
>>  	v4l2_ctrl_handler_init(&priv->ctrls, 1);
>> -	/*
>> -	 * FIXME: Compute the real pixel rate. The 50 MP/s value comes from the
>> -	 * hardcoded frequency in the BSP CSI-2 receiver driver.
>> -	 */
>> -	v4l2_ctrl_new_std(&priv->ctrls, NULL, V4L2_CID_PIXEL_RATE,
>> -			  50000000, 50000000, 1, 50000000);
>> +
>> +	priv->pixelrate = v4l2_ctrl_new_std(&priv->ctrls,
>> +					    &max9286_ctrl_ops,
>> +					    V4L2_CID_PIXEL_RATE,
>> +					    1, INT_MAX, 1, 50000000);
>> +
>>  	priv->sd.ctrl_handler = &priv->ctrls;
>>  	ret = priv->ctrls.error;
>>  	if (ret)
>> --
>> 2.20.1
>>


  reply	other threads:[~2020-04-10  7:51 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 12:11 [PATCH v8 00/13] max9286 v8 - modifications Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 01/13] squash! max9286: Update the bound_sources mask on unbind Kieran Bingham
2020-04-09 15:20   ` Jacopo Mondi
2020-04-09 12:11 ` [PATCH v8 02/13] squash! max9286: convert probe kzalloc Kieran Bingham
2020-04-09 16:33   ` Laurent Pinchart
2020-04-10  8:20     ` Kieran Bingham
2020-04-10 11:15       ` Laurent Pinchart
2020-04-23  7:38         ` Sakari Ailus
2020-04-23  9:32           ` Laurent Pinchart
2020-04-23 10:55           ` Kieran Bingham
2020-04-23 23:25             ` Sakari Ailus
2020-04-09 17:08   ` [PATCH] squash! i2c: max9286: Put of node on error Jacopo Mondi
2020-04-09 20:20     ` Jacopo Mondi
2020-04-10  7:20       ` Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 03/13] squash! max9286: Fix cleanup path from GPIO powerdown Kieran Bingham
2020-04-09 16:22   ` Jacopo Mondi
2020-04-10  7:34     ` Geert Uytterhoeven
2020-04-10  7:41       ` Kieran Bingham
2020-04-10  7:52       ` Jacopo Mondi
2020-04-10  7:38     ` Kieran Bingham
2020-04-10  7:42       ` Kieran Bingham
2020-04-11 12:33     ` Jacopo Mondi
2020-04-09 12:11 ` [PATCH v8 04/13] squash! max9286: cleanup GPIO device registration fail path Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 05/13] squash! max9286: Convert to use devm_regulator_get() Kieran Bingham
2020-04-09 12:15   ` Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 06/13] squash! max9286: Fit max9286_parse_dt print on one line Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 07/13] squash! max9286: Move multi-device workarounds out of upstream Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 08/13] squash! max9286: Remove I2C mod-table Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 09/13] sqaush! max9286: Lock format changes Kieran Bingham
2020-04-09 12:11 ` [PATCH v8 10/13] squash! max9286: Implement Pixelrate control Kieran Bingham
2020-04-09 16:29   ` Jacopo Mondi
2020-04-10  7:51     ` Kieran Bingham [this message]
2020-04-10 12:35       ` Jacopo Mondi
2020-04-14 10:50   ` Jacopo Mondi
2020-04-14 21:10     ` Laurent Pinchart
2020-04-15  9:13       ` Jacopo Mondi
2020-04-15 15:28         ` Laurent Pinchart
2020-04-09 12:12 ` [PATCH v8 11/13] squash! max9286: Disable overlap window Kieran Bingham
2020-04-09 16:32   ` Jacopo Mondi
2020-04-10  7:14     ` Kieran Bingham
2020-04-10  7:48       ` Jacopo Mondi
2020-04-09 12:12 ` [PATCH v8 12/13] sqaush! max9286: Describe pad index usage Kieran Bingham
2020-04-09 12:12 ` [PATCH v8 13/13] sqaush! max9286: Remove poc_enabled workaround Kieran Bingham
2020-04-09 16:33   ` Jacopo Mondi

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=bdb73234-7ef1-dd66-0393-5317688b7c63@ideasonboard.com \
    --to=kieran.bingham+renesas@ideasonboard.com \
    --cc=hyunk@xilinx.com \
    --cc=jacopo@jmondi.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=niklas.soderlund@ragnatech.se \
    /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.