linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Sakari Ailus <sakari.ailus@iki.fi>,
	Marco Felsch <m.felsch@pengutronix.de>
Cc: mchehab@kernel.org, sakari.ailus@linux.intel.com,
	robh+dt@kernel.org, mark.rutland@arm.com,
	enrico.scholz@sigma-chemnitz.de, akinobu.mita@gmail.com,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org,
	Michael Grzeschik <m.grzeschik@pengutronix.de>,
	graphics@pengutronix.de
Subject: Re: [PATCH v2 3/6] media: mt9m111: add support to select formats and fps for {Q,SXGA}
Date: Fri, 16 Nov 2018 14:31:01 +0100	[thread overview]
Message-ID: <e28d74c2-d2de-6450-d572-6d691b7416c7@xs4all.nl> (raw)
In-Reply-To: <20181116132610.54elo2dqsrrlydlh@valkosipuli.retiisi.org.uk>

On 11/16/2018 02:26 PM, Sakari Ailus wrote:
> Hi Marco, Michael,
> 
> On Mon, Oct 29, 2018 at 07:24:07PM +0100, Marco Felsch wrote:
>> From: Michael Grzeschik <m.grzeschik@pengutronix.de>
>>
>> This patch implements the framerate selection using the skipping and
>> readout power-modi features. The power-modi cut the framerate by half
>> and each context has an independent selection bit. The same applies to
>> the 2x skipping feature.
>>
>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
>>
>> ---
>> Changelog
>>
>> v2:
>> - fix updating read mode register, use mt9m111_reg_mask() to update the
>>   relevant bits only. For this purpose add reg_mask field to
>>   struct mt9m111_mode_info.
>>
>>  drivers/media/i2c/mt9m111.c | 163 ++++++++++++++++++++++++++++++++++++
>>  1 file changed, 163 insertions(+)
>>
>> diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c

<snip>

>> +static const struct mt9m111_mode_info *
>> +mt9m111_find_mode(struct mt9m111 *mt9m111, unsigned int req_fps,
>> +		  unsigned int width, unsigned int height)
>> +{
>> +	const struct mt9m111_mode_info *mode;
>> +	struct v4l2_rect *sensor_rect = &mt9m111->rect;
>> +	unsigned int gap, gap_best = (unsigned int) -1;
>> +	int i, best_gap_idx = 1;
>> +
>> +	/* find best matched fps */
>> +	for (i = 0; i < MT9M111_NUM_MODES; i++) {
>> +		unsigned int fps = mt9m111_mode_data[i].max_fps;
>> +
>> +		gap = abs(fps - req_fps);
>> +		if (gap < gap_best) {
>> +			best_gap_idx = i;
>> +			gap_best = gap;
>> +		}
> 
> Could you use v4l2_find_nearest_size() instead?
> 
> Also see below...
> 
>> +	}
>> +
>> +	/*
>> +	 * Use context a/b default timing values instead of calculate blanking
>> +	 * timing values.
>> +	 */
>> +	mode = &mt9m111_mode_data[best_gap_idx];
>> +	mt9m111->ctx = (best_gap_idx == MT9M111_MODE_QSXGA_30FPS) ? &context_a :
>> +								    &context_b;
>> +
>> +	/*
>> +	 * Check if current settings support the fps because fps selection is
>> +	 * based on the row/col skipping mechanism which has some restriction.
>> +	 */
>> +	if (sensor_rect->width != mode->sensor_w ||
>> +	    sensor_rect->height != mode->sensor_h ||
>> +	    width > mode->max_image_w ||
>> +	    height > mode->max_image_h) {
>> +		/* reset sensor window size */
>> +		mt9m111->rect.left = MT9M111_MIN_DARK_COLS;
>> +		mt9m111->rect.top = MT9M111_MIN_DARK_ROWS;
>> +		mt9m111->rect.width = mode->sensor_w;
>> +		mt9m111->rect.height = mode->sensor_h;
>> +
>> +		/* reset image size */
>> +		mt9m111->width = mode->max_image_w;
>> +		mt9m111->height = mode->max_image_h;
>> +
>> +		dev_warn(mt9m111->subdev.dev,
>> +			 "Warning: update image size %dx%d[%dx%d] -> %dx%d[%dx%d]\n",
>> +			 sensor_rect->width, sensor_rect->height, width, height,
>> +			 mode->sensor_w, mode->sensor_h, mode->max_image_w,
>> +			 mode->max_image_h);
> 
> I wouldn't expect requesting a particular frame rate to change the sensor
> format. The other way around is definitely fine though.
> 
> Cc Hans.

I agree with Sakari. Changing the framerate should never change the format.
When you enumerate framerates those framerates are the allowed framerates
for the mediabus format and the resolution. So changing the framerate should
never modify the format or resolution. Instead, the framerate should be
mapped to a framerate that is valid for the format/resolution combo.

Regards,

	Hans

  reply	other threads:[~2018-11-16 23:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 18:24 [PATCH v2 0/6] media: mt9m111 features Marco Felsch
2018-10-29 18:24 ` [PATCH v2 1/6] media: mt9m111: add s_stream callback Marco Felsch
2018-10-29 18:24 ` [PATCH v2 2/6] media: mt9m111: add streaming check to set_fmt Marco Felsch
2018-10-29 18:24 ` [PATCH v2 3/6] media: mt9m111: add support to select formats and fps for {Q,SXGA} Marco Felsch
2018-11-16 13:26   ` Sakari Ailus
2018-11-16 13:31     ` Hans Verkuil [this message]
2018-11-16 13:33       ` Sakari Ailus
2018-11-26 16:01         ` Marco Felsch
2018-10-29 18:24 ` [PATCH v2 4/6] media: mt9m111: allow to setup pixclk polarity Marco Felsch
2018-11-16 13:32   ` Sakari Ailus
2018-11-26 14:16     ` Marco Felsch
2018-10-29 18:24 ` [PATCH v2 5/6] dt-bindings: media: mt9m111: adapt documentation to be more clear Marco Felsch
2018-10-30 22:30   ` Rob Herring
2018-10-29 18:24 ` [PATCH v2 6/6] dt-bindings: media: mt9m111: add pclk-sample property Marco Felsch
2018-10-30 22:31   ` Rob Herring

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=e28d74c2-d2de-6450-d572-6d691b7416c7@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=akinobu.mita@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=enrico.scholz@sigma-chemnitz.de \
    --cc=graphics@pengutronix.de \
    --cc=linux-media@vger.kernel.org \
    --cc=m.felsch@pengutronix.de \
    --cc=m.grzeschik@pengutronix.de \
    --cc=mark.rutland@arm.com \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=sakari.ailus@linux.intel.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).