linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, tomi.valkeinen@ideasonboard.com,
	bingbu.cao@intel.com, hongju.wang@intel.com, hverkuil@xs4all.nl,
	Andrey Konovalov <andrey.konovalov@linaro.org>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	Dmitry Perchanov <dmitry.perchanov@intel.com>,
	"Ng, Khai Wen" <khai.wen.ng@intel.com>,
	Alain Volmat <alain.volmat@foss.st.com>
Subject: Re: [PATCH v8 27/38] media: ccs: Compute binning configuration from sub-device state
Date: Tue, 16 Apr 2024 08:01:07 +0000	[thread overview]
Message-ID: <Zh4wQ25i7dRQeVEJ@kekkonen.localdomain> (raw)
In-Reply-To: <20240321175707.GT9582@pendragon.ideasonboard.com>

Hi Laurent,

On Thu, Mar 21, 2024 at 07:57:07PM +0200, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Wed, Mar 13, 2024 at 09:25:05AM +0200, Sakari Ailus wrote:
> > Calculate binning configuration from sub-device state so the state related
> > configuration can be removed from the driver's device context struct.
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  drivers/media/i2c/ccs/ccs-core.c | 72 ++++++++++++++++++++++----------
> >  drivers/media/i2c/ccs/ccs.h      |  3 --
> >  2 files changed, 49 insertions(+), 26 deletions(-)
> > 
> > diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
> > index a8c48abd2e30..3b80c54453cc 100644
> > --- a/drivers/media/i2c/ccs/ccs-core.c
> > +++ b/drivers/media/i2c/ccs/ccs-core.c
> > @@ -511,13 +511,52 @@ static int ccs_pll_try(struct ccs_sensor *sensor, struct ccs_pll *pll)
> >  	return ccs_pll_calculate(&client->dev, &lim, pll);
> >  }
> >  
> > +static void
> > +ccs_get_binning(struct ccs_sensor *sensor, u8 *binning_mode, u8 *binh, u8 *binv)
> > +{
> > +	struct v4l2_subdev_state *binner_state =
> > +		v4l2_subdev_get_locked_active_state(&sensor->binner->sd);
> > +	struct v4l2_rect *binner_sink_crop =
> > +		v4l2_subdev_state_get_crop(binner_state, CCS_PAD_SINK,
> > +					   CCS_STREAM_PIXEL);
> > +	struct v4l2_rect *binner_sink_comp =
> > +		v4l2_subdev_state_get_compose(binner_state, CCS_PAD_SINK,
> > +					      CCS_STREAM_PIXEL);
> 
> I like this patch very much :-) The comments I made to 28/28 apply there
> too.

I agree.

> 
> > +
> > +	if (binner_sink_crop->width == binner_sink_comp->width &&
> > +	    binner_sink_crop->height == binner_sink_comp->height) {
> > +		if (binning_mode)
> > +			*binning_mode = 0;
> > +
> > +		if (binh)
> > +			*binh = 1;
> > +
> > +		if (binv)
> > +			*binv = 1;
> > +
> > +		return;
> > +	}
> > +
> > +	if (binning_mode)
> > +		*binning_mode = 1;
> > +
> > +	if (binh)
> > +		*binh = binner_sink_crop->width / binner_sink_comp->width;
> > +
> > +	if (binv)
> > +		*binv = binner_sink_crop->height / binner_sink_comp->height;
> 
> binh and binv are never NULL. How about the following ?
> 
> 	if (binning_mode)
> 		*binning_mode = sink_crop->width != sink_comp->width ||
> 				sink_crop->height != sink_comp->height;

The binning mode should use CCS register macros which for some reason
appear to be absent on the binning registers. The others have them.

> 
> 	*binh = sink_crop->width / sink_comp->width;
> 	*binv = sink_crop->height / sink_comp->height;

Yes.

> 
> > +}
> > +
> >  static int ccs_pll_update(struct ccs_sensor *sensor)
> >  {
> >  	struct ccs_pll *pll = &sensor->pll;
> > +	u8 binh, binv;
> >  	int rval;
> >  
> > -	pll->binning_horizontal = sensor->binning_horizontal;
> > -	pll->binning_vertical = sensor->binning_vertical;
> > +	ccs_get_binning(sensor, NULL, &binh, &binv);
> > +
> > +	pll->binning_horizontal = binh;
> > +	pll->binning_vertical = binv;
> >  	pll->link_freq =
> >  		sensor->link_freq->qmenu_int[sensor->link_freq->val];
> >  	pll->scale_m = sensor->scale_m;
> > @@ -1241,8 +1280,11 @@ static void ccs_update_blanking(struct ccs_sensor *sensor,
> >  	struct v4l2_ctrl *hblank = sensor->hblank;
> >  	u16 min_fll, max_fll, min_llp, max_llp, min_lbp;
> >  	int min, max;
> > +	u8 binh, binv;
> > +
> > +	ccs_get_binning(sensor, NULL, &binh, &binv);
> >  
> > -	if (sensor->binning_vertical > 1 || sensor->binning_horizontal > 1) {
> > +	if (binv > 1 || binh > 1) {
> >  		min_fll = CCS_LIM(sensor, MIN_FRAME_LENGTH_LINES_BIN);
> >  		max_fll = CCS_LIM(sensor, MAX_FRAME_LENGTH_LINES_BIN);
> >  		min_llp = CCS_LIM(sensor, MIN_LINE_LENGTH_PCK_BIN);
> > @@ -1813,7 +1855,7 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev,
> >  		v4l2_subdev_state_get_crop(src_state, CCS_PAD_SRC,
> >  					   CCS_STREAM_PIXEL);
> >  	struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
> > -	unsigned int binning_mode;
> > +	u8 binning_mode, binh, binv;
> >  	int rval;
> >  
> >  	if (pad != CCS_PAD_SRC)
> > @@ -1835,19 +1877,12 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev,
> >  		goto err_pm_put;
> >  
> >  	/* Binning configuration */
> > -	if (sensor->binning_horizontal == 1 &&
> > -	    sensor->binning_vertical == 1) {
> > -		binning_mode = 0;
> > -	} else {
> > -		u8 binning_type =
> > -			(sensor->binning_horizontal << 4)
> > -			| sensor->binning_vertical;
> > +	ccs_get_binning(sensor,	&binning_mode, &binh, &binv);
> >  
> > -		rval = ccs_write(sensor, BINNING_TYPE, binning_type);
> > +	if (binning_mode) {
> > +		rval = ccs_write(sensor, BINNING_TYPE, (binh << 4) | binv);
> >  		if (rval < 0)
> >  			goto err_pm_put;
> > -
> > -		binning_mode = 1;
> >  	}
> >  	rval = ccs_write(sensor, BINNING_MODE, binning_mode);
> >  	if (rval < 0)
> > @@ -2253,9 +2288,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev,
> >  				sensor->scale_m = CCS_LIM(sensor, SCALER_N_MIN);
> >  				sensor->scaling_mode =
> >  					CCS_SCALING_MODE_NO_SCALING;
> > -			} else if (ssd == sensor->binner) {
> > -				sensor->binning_horizontal = 1;
> > -				sensor->binning_vertical = 1;
> >  			}
> >  		}
> >  		fallthrough;
> > @@ -2529,10 +2561,6 @@ static void ccs_set_compose_binner(struct v4l2_subdev *subdev,
> >  			best = this;
> >  		}
> >  	}
> > -	if (sel->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
> > -		sensor->binning_vertical = binv;
> > -		sensor->binning_horizontal = binh;
> > -	}
> >  
> >  	sel->r.width = (sink_crop->width / binh) & ~1;
> >  	sel->r.height = (sink_crop->height / binv) & ~1;
> > @@ -3721,8 +3749,6 @@ static int ccs_probe(struct i2c_client *client)
> >  				sensor->binning_subtypes[i].vertical);
> >  		}
> >  	}
> > -	sensor->binning_horizontal = 1;
> > -	sensor->binning_vertical = 1;
> >  
> >  	if (device_create_file(&client->dev, &dev_attr_ident) != 0) {
> >  		dev_err(&client->dev, "sysfs ident entry creation failed\n");
> > diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h
> > index a2a461cda338..e6fc00a9fa11 100644
> > --- a/drivers/media/i2c/ccs/ccs.h
> > +++ b/drivers/media/i2c/ccs/ccs.h
> > @@ -237,9 +237,6 @@ struct ccs_sensor {
> >  	u32 embedded_mbus_code;
> >  	u8 emb_data_ctrl;
> >  
> > -	u8 binning_horizontal;
> > -	u8 binning_vertical;
> > -
> >  	u8 scale_m;
> >  	u8 scaling_mode;
> >  
> 

-- 
Regards,

Sakari Ailus

  reply	other threads:[~2024-04-16  8:01 UTC|newest]

Thread overview: 149+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  7:24 [PATCH v8 00/38] Generic line based metadata support, internal pads Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 01/38] media: mc: Add INTERNAL pad flag Sakari Ailus
2024-03-14  7:17   ` Tomi Valkeinen
2024-03-19 13:21     ` Sakari Ailus
2024-03-19 22:17     ` Laurent Pinchart
2024-03-20  7:49       ` Sakari Ailus
2024-03-21 17:20         ` Laurent Pinchart
2024-03-28  9:47           ` Sakari Ailus
2024-03-28 10:05             ` Sakari Ailus
2024-03-28 15:25             ` Laurent Pinchart
2024-04-11  7:25               ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 02/38] media: Documentation: Add "stream" into glossary Sakari Ailus
2024-03-14  7:18   ` Tomi Valkeinen
2024-03-19 22:20   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 03/38] media: uapi: Add generic serial metadata mbus formats Sakari Ailus
2024-03-14  7:30   ` Tomi Valkeinen
2024-03-19 13:27     ` Sakari Ailus
2024-03-19 14:20       ` Tomi Valkeinen
2024-03-19 22:33         ` Laurent Pinchart
2024-03-19 23:00           ` Laurent Pinchart
2024-03-20  8:48             ` Sakari Ailus
2024-03-21 17:30               ` Laurent Pinchart
2024-03-22  6:50           ` Tomi Valkeinen
2024-03-25 14:02             ` Sakari Ailus
2024-03-20  8:36         ` Sakari Ailus
2024-03-19 22:59   ` Laurent Pinchart
2024-03-20 16:23     ` Sakari Ailus
2024-03-21 17:38       ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 04/38] media: uapi: Document which mbus format fields are valid for metadata Sakari Ailus
2024-03-14 15:23   ` Tomi Valkeinen
2024-03-19 23:14   ` Laurent Pinchart
2024-03-20 16:49     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 05/38] media: uapi: Add generic 8-bit metadata format definitions Sakari Ailus
2024-03-19 23:37   ` Laurent Pinchart
2024-04-15 14:05     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 06/38] media: v4l: Support line-based metadata capture Sakari Ailus
2024-03-19 23:40   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 07/38] media: Documentation: Additional streams generally don't harm capture Sakari Ailus
2024-03-19 23:48   ` Laurent Pinchart
2024-04-15 14:27     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 08/38] media: Documentation: Document embedded data guidelines for camera sensors Sakari Ailus
2024-03-15 14:49   ` Julien Massot
2024-03-20  0:03   ` Laurent Pinchart
2024-04-09 11:12     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 09/38] media: Documentation: v4l: Document internal source pads Sakari Ailus
2024-03-15 15:32   ` Julien Massot
2024-03-19 13:47     ` Sakari Ailus
2024-03-19 14:38       ` Julien Massot
2024-03-20  0:26       ` Laurent Pinchart
2024-04-09 12:14         ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 10/38] media: Documentation: Document S_ROUTING behaviour Sakari Ailus
2024-03-15 15:38   ` Julien Massot
2024-03-20  0:33   ` Laurent Pinchart
2024-04-11  8:02     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 11/38] media: v4l: subdev: Add a function to lock two sub-device states, use it Sakari Ailus
2024-03-15 15:42   ` Julien Massot
2024-03-20  0:36   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 12/38] media: v4l: subdev: Move G_ROUTING handling below S_ROUTING Sakari Ailus
2024-03-15 15:43   ` Julien Massot
2024-03-20  0:37   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 13/38] media: v4l: subdev: Copy argument back to user also for S_ROUTING Sakari Ailus
2024-03-15 15:50   ` Julien Massot
2024-03-20  0:39   ` Laurent Pinchart
2024-04-11  8:06     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 14/38] media: v4l: subdev: Add len_routes field to struct v4l2_subdev_routing Sakari Ailus
2024-03-20  1:36   ` Laurent Pinchart
2024-04-16  7:09     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 15/38] media: v4l: subdev: Return routes set using S_ROUTING Sakari Ailus
2024-03-20  1:45   ` Laurent Pinchart
2024-04-16  7:12     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 16/38] media: v4l: subdev: Allow a larger number of routes than there's room for Sakari Ailus
2024-03-20  1:53   ` Laurent Pinchart
2024-04-16  8:08     ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 17/38] media: v4l: subdev: Add trivial set_routing support Sakari Ailus
2024-03-15 15:51   ` Julien Massot
2024-03-20  1:55   ` Laurent Pinchart
2024-04-01 23:41     ` Laurent Pinchart
2024-04-11  8:13       ` Sakari Ailus
2024-04-12 19:14         ` Laurent Pinchart
2024-04-15  8:10           ` Sakari Ailus
2024-03-13  7:24 ` [PATCH v8 18/38] media: ccs: No need to set streaming to false in power off Sakari Ailus
2024-03-13  9:31   ` Kieran Bingham
2024-03-21 16:35   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 19/38] media: ccs: Use {enable,disable}_streams operations Sakari Ailus
2024-03-21 16:21   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 20/38] media: ccs: Track streaming state Sakari Ailus
2024-03-15 15:56   ` Julien Massot
2024-03-21 16:36   ` Laurent Pinchart
2024-03-13  7:24 ` [PATCH v8 21/38] media: ccs: Move ccs_validate_csi_data_format up Sakari Ailus
2024-03-15 15:57   ` Julien Massot
2024-03-21 16:37   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 22/38] media: ccs: Support frame descriptors Sakari Ailus
2024-03-15 16:02   ` Julien Massot
2024-03-21 16:44   ` Laurent Pinchart
2024-04-11  8:33     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 23/38] media: uapi: ccs: Add media bus code for MIPI CCS embedded data Sakari Ailus
2024-03-15 16:03   ` Julien Massot
2024-03-21 16:49   ` Laurent Pinchart
2024-04-11  9:04     ` Sakari Ailus
2024-04-12 19:07       ` Laurent Pinchart
2024-04-14 10:48         ` Sakari Ailus
2024-04-20  8:07           ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 24/38] media: ccs: Add support for embedded data stream Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 25/38] media: ccs: Remove ccs_get_crop_compose helper Sakari Ailus
2024-03-21 18:05   ` Laurent Pinchart
2024-04-16  7:30     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 26/38] media: ccs: Rely on sub-device state locking Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 27/38] media: ccs: Compute binning configuration from sub-device state Sakari Ailus
2024-03-21 17:57   ` Laurent Pinchart
2024-04-16  8:01     ` Sakari Ailus [this message]
2024-03-13  7:25 ` [PATCH v8 28/38] media: ccs: Compute scaling " Sakari Ailus
2024-03-21 17:50   ` Laurent Pinchart
2024-04-16  7:59     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 29/38] media: ccs: Remove which parameter from ccs_propagate Sakari Ailus
2024-03-21 17:39   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 30/38] media: Documentation: ccs: Document routing Sakari Ailus
2024-03-21 17:43   ` Laurent Pinchart
2024-04-16  7:37     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 31/38] media: uapi: v4l: subdev: Enable streams API Sakari Ailus
2024-03-21 16:51   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 32/38] media: uapi: Add media bus code for ov2740 embedded data Sakari Ailus
2024-03-15 16:10   ` Julien Massot
2024-03-21 16:54   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 33/38] media: ov2740: Switch to {enable,disable}_streams Sakari Ailus
2024-03-15 16:13   ` Julien Massot
2024-03-21 16:56   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 34/38] media: ov2740: Track streaming state Sakari Ailus
2024-03-15 16:13   ` Julien Massot
2024-03-21 16:57   ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 35/38] media: ov2740: Add support for embedded data Sakari Ailus
2024-03-14  7:00   ` Bingbu Cao
2024-03-19 13:13     ` Sakari Ailus
2024-03-14  8:24   ` Julien Massot
2024-03-19 13:18     ` Sakari Ailus
2024-03-21 17:16   ` Laurent Pinchart
2024-04-10 13:18     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 36/38] media: v4l: Add V4L2_SUBDEV_ROUTE_FL_IMMUTABLE sub-device routing flag Sakari Ailus
2024-03-13  7:34   ` Tomi Valkeinen
2024-03-13  7:39     ` Sakari Ailus
2024-03-21 17:03       ` Laurent Pinchart
2024-04-09 13:21         ` Sakari Ailus
2024-04-09 15:21           ` Laurent Pinchart
2024-03-13  7:25 ` [PATCH v8 37/38] media: ccs: Add IMMUTABLE route flag Sakari Ailus
2024-03-15 16:08   ` Julien Massot
2024-03-21 16:59   ` Laurent Pinchart
2024-04-11  9:06     ` Sakari Ailus
2024-03-13  7:25 ` [PATCH v8 38/38] media: ov2740: " Sakari Ailus
2024-03-15 16:14   ` Julien Massot
2024-03-21 17:00   ` Laurent Pinchart

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=Zh4wQ25i7dRQeVEJ@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=alain.volmat@foss.st.com \
    --cc=andrey.konovalov@linaro.org \
    --cc=bingbu.cao@intel.com \
    --cc=dmitry.perchanov@intel.com \
    --cc=hongju.wang@intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=khai.wen.ng@intel.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=tomi.valkeinen@ideasonboard.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).