All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>,
	jeanmichel.hautbois@ideasonboard.com,
	paul.kocialkowski@bootlin.com, sakari.ailus@iki.fi,
	paul.elder@ideasonboard.com,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	"open list:OMNIVISION OV5670 SENSOR DRIVER" 
	<linux-media@vger.kernel.org>
Subject: Re: [PATCH 6/6] media: i2c: ov5670: Add .get_selection() support
Date: Sun, 13 Mar 2022 16:44:48 +0200	[thread overview]
Message-ID: <Yi4DYNpdEGkfEUR4@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220310130829.96001-7-jacopo@jmondi.org>

Hi Jacopo,

Thank you for the patch.

On Thu, Mar 10, 2022 at 02:08:29PM +0100, Jacopo Mondi wrote:
> From: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> 
> The ov5670 driver's v4l2_subdev_pad_ops currently does not include
> .get_selection() - add support for that callback.
> 
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  drivers/media/i2c/ov5670.c | 64 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
> index c9f69ffef210..1fa0d632c536 100644
> --- a/drivers/media/i2c/ov5670.c
> +++ b/drivers/media/i2c/ov5670.c
> @@ -70,6 +70,15 @@
>  #define OV5670_REG_VALUE_16BIT		2
>  #define OV5670_REG_VALUE_24BIT		3
>  
> +/* Pixel Array */
> +
> +#define OV5670_NATIVE_WIDTH		2624
> +#define OV5670_NATIVE_HEIGHT		1980
> +#define OV5670_ACTIVE_START_TOP		8
> +#define OV5670_ACTIVE_START_LEFT	16
> +#define OV5670_ACTIVE_WIDTH		2592
> +#define OV5670_ACTIVE_HEIGHT		1944
> +
>  /* Initial number of frames to skip to avoid possible garbage */
>  #define OV5670_NUM_OF_SKIP_FRAMES	2
>  
> @@ -2491,6 +2500,59 @@ static const struct v4l2_subdev_core_ops ov5670_core_ops = {
>  	.unsubscribe_event = v4l2_event_subdev_unsubscribe,
>  };
>  
> +static void
> +__ov5670_get_pad_crop(struct ov5670 *sensor,
> +		      struct v4l2_subdev_state *state, unsigned int pad,
> +		      enum v4l2_subdev_format_whence which, struct v4l2_rect *r)
> +{
> +	const struct ov5670_mode *mode = sensor->cur_mode;
> +
> +	switch (which) {
> +	case V4L2_SUBDEV_FORMAT_TRY:
> +		*r = *v4l2_subdev_get_try_crop(&sensor->sd, state, pad);

Where is the try crop rectangle initialized ?

> +		break;
> +	case V4L2_SUBDEV_FORMAT_ACTIVE:
> +		r->height = mode->height;
> +		r->width = mode->width;
> +		r->top = (OV5670_NATIVE_HEIGHT - mode->height) / 2;
> +		r->left = (OV5670_NATIVE_WIDTH - mode->width) / 2;

There's a comment above stating

/*
 * OV5670 sensor supports following resolutions with full FOV:
 * 4:3  ==> {2592x1944, 1296x972, 648x486}
 * 16:9 ==> {2560x1440, 1280x720, 640x360}
 */

so this doesn't look right.

> +		break;
> +	}
> +}
> +
> +static int ov5670_get_selection(struct v4l2_subdev *subdev,
> +				struct v4l2_subdev_state *state,
> +				struct v4l2_subdev_selection *sel)
> +{
> +	struct ov5670 *sensor = to_ov5670(subdev);
> +
> +	switch (sel->target) {
> +	case V4L2_SEL_TGT_CROP:
> +		mutex_lock(&sensor->mutex);
> +			__ov5670_get_pad_crop(sensor, state, sel->pad,
> +					      sel->which, &sel->r);

Wrong indentation.

> +		mutex_unlock(&sensor->mutex);
> +		break;
> +	case V4L2_SEL_TGT_NATIVE_SIZE:
> +	case V4L2_SEL_TGT_CROP_BOUNDS:
> +		sel->r.top = 0;
> +		sel->r.left = 0;
> +		sel->r.width = OV5670_NATIVE_WIDTH;
> +		sel->r.height = OV5670_NATIVE_HEIGHT;
> +		break;
> +	case V4L2_SEL_TGT_CROP_DEFAULT:
> +		sel->r.top = OV5670_ACTIVE_START_TOP;
> +		sel->r.left = OV5670_ACTIVE_START_LEFT;
> +		sel->r.width = OV5670_ACTIVE_WIDTH;
> +		sel->r.height = OV5670_ACTIVE_HEIGHT;
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}
> +
>  static const struct v4l2_subdev_video_ops ov5670_video_ops = {
>  	.s_stream = ov5670_set_stream,
>  };
> @@ -2500,6 +2562,8 @@ static const struct v4l2_subdev_pad_ops ov5670_pad_ops = {
>  	.get_fmt = ov5670_get_pad_format,
>  	.set_fmt = ov5670_set_pad_format,
>  	.enum_frame_size = ov5670_enum_frame_size,
> +	.get_selection = ov5670_get_selection,
> +	.set_selection = ov5670_get_selection,
>  };
>  
>  static const struct v4l2_subdev_sensor_ops ov5670_sensor_ops = {

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2022-03-13 14:45 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 13:08 [PATCH 0/6] media: i2c: ov5670: OF support, runtime_pm, regulators Jacopo Mondi
2022-03-10 13:08 ` [PATCH 1/6] media: dt-bindings: i2c: Document ov5670 Jacopo Mondi
2022-03-10 14:29   ` Krzysztof Kozlowski
2022-03-10 17:16     ` Jacopo Mondi
2022-03-10 17:26       ` Krzysztof Kozlowski
2022-03-10 23:30         ` Rob Herring
2022-03-11 16:05         ` Jacopo Mondi
2022-03-11 16:11           ` Krzysztof Kozlowski
2022-03-11 18:00             ` Jacopo Mondi
2022-03-12 10:30               ` Krzysztof Kozlowski
2022-03-13 14:30                 ` Laurent Pinchart
2022-03-10 13:08 ` [PATCH 2/6] media: i2c: ov5670: Allow probing with OF Jacopo Mondi
2022-03-10 18:16   ` kernel test robot
2022-03-10 20:29   ` kernel test robot
2022-03-10 20:39   ` kernel test robot
2022-03-13 14:33   ` Laurent Pinchart
2022-03-14  8:42     ` Jacopo Mondi
2022-03-14  8:50       ` Laurent Pinchart
2022-03-14  8:51         ` Laurent Pinchart
2022-03-10 13:08 ` [PATCH 3/6] media: i2c: ov5670: Probe regulators Jacopo Mondi
2022-03-13 14:35   ` Laurent Pinchart
2022-03-10 13:08 ` [PATCH 4/6] media: i2c: ov5670: Probe GPIOs Jacopo Mondi
2022-03-13 14:36   ` Laurent Pinchart
2022-03-10 13:08 ` [PATCH 5/6] media: i2c: ov5670: Add runtime_pm operations Jacopo Mondi
2022-03-13 14:42   ` Laurent Pinchart
2022-03-10 13:08 ` [PATCH 6/6] media: i2c: ov5670: Add .get_selection() support Jacopo Mondi
2022-03-13 14:44   ` Laurent Pinchart [this message]
2022-03-14 13:30     ` Jacopo Mondi
2022-03-14 13:40       ` 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=Yi4DYNpdEGkfEUR4@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=chiranjeevi.rapolu@intel.com \
    --cc=jacopo@jmondi.org \
    --cc=jeanmichel.hautbois@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=paul.elder@ideasonboard.com \
    --cc=paul.kocialkowski@bootlin.com \
    --cc=sakari.ailus@iki.fi \
    /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.