All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo@jmondi.org>
To: Dave Stevenson <dave.stevenson@raspberrypi.com>
Cc: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com,
	linux-media@vger.kernel.org
Subject: Re: [PATCH 13/16] media: i2c: ov9282: Add selection API calls for cropping info
Date: Thu, 6 Oct 2022 13:54:27 +0200	[thread overview]
Message-ID: <20221006115427.unrzqizgdtvysxoc@uno.localdomain> (raw)
In-Reply-To: <CAPY8ntAY=361=jYCn-pvBJpzWOypg4HejL1yZuC6kDO9QfzGow@mail.gmail.com>

Hi David

On Thu, Oct 06, 2022 at 12:39:35PM +0100, Dave Stevenson wrote:
> Hi Jacopo
>
> Thanks for the review.
>
> On Thu, 6 Oct 2022 at 10:43, Jacopo Mondi <jacopo@jmondi.org> wrote:
> >
> > Hi Dave
> >
> > On Wed, Oct 05, 2022 at 04:28:06PM +0100, Dave Stevenson wrote:
> > > As required by libcamera, add the relevant cropping targets
> > > to report which portion of the sensor is being read out in
> > > any mode.
> > >
> > > Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
> > > ---
> > >  drivers/media/i2c/ov9282.c | 75 ++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 75 insertions(+)
> > >
> > > diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
> > > index 8e86aa7e4b2a..d892f53fb1ea 100644
> > > --- a/drivers/media/i2c/ov9282.c
> > > +++ b/drivers/media/i2c/ov9282.c
> > > @@ -67,6 +67,17 @@
> > >  #define OV9282_PIXEL_RATE    (OV9282_LINK_FREQ * 2 * \
> > >                                OV9282_NUM_DATA_LANES / 10)
> > >
> > > +/*
> > > + * OV9282 native and active pixel array size.
> > > + * 8 dummy rows/columns on each edge of a 1280x800 active array
> > > + */
> > > +#define OV9282_NATIVE_WIDTH          1296U
> > > +#define OV9282_NATIVE_HEIGHT         816U
> > > +#define OV9282_PIXEL_ARRAY_LEFT              8U
> > > +#define OV9282_PIXEL_ARRAY_TOP               8U
> > > +#define OV9282_PIXEL_ARRAY_WIDTH     1280U
> > > +#define OV9282_PIXEL_ARRAY_HEIGHT    800U
> > > +
> > >  #define OV9282_REG_MIN               0x00
> > >  #define OV9282_REG_MAX               0xfffff
> > >
> > > @@ -118,6 +129,7 @@ struct ov9282_mode {
> > >       u32 vblank_min;
> > >       u32 vblank_max;
> > >       u32 link_freq_idx;
> > > +     struct v4l2_rect crop;
> > >       struct ov9282_reg_list reg_list;
> > >  };
> > >
> > > @@ -280,6 +292,16 @@ static const struct ov9282_mode supported_modes[] = {
> > >               .vblank_min = 41,
> > >               .vblank_max = 51540,
> > >               .link_freq_idx = 0,
> > > +             .crop = {
> > > +                     /*
> > > +                      * Note that this mode takes the top 720 lines from the
> > > +                      * 800 of the sensor. It does not take a middle crop.
> > > +                      */
> > > +                     .left = OV9282_PIXEL_ARRAY_LEFT,
> > > +                     .top = OV9282_PIXEL_ARRAY_TOP,
> > > +                     .width = 1280,
> > > +                     .height = 720
> > > +             },
> > >               .reg_list = {
> > >                       .num_of_regs = ARRAY_SIZE(mode_1280x720_regs),
> > >                       .regs = mode_1280x720_regs,
> > > @@ -719,6 +741,58 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd,
> > >       return ov9282_set_pad_format(sd, sd_state, &fmt);
> > >  }
> > >
> > > +static const struct v4l2_rect *
> > > +__ov9282_get_pad_crop(struct ov9282 *ov9282,
> > > +                   struct v4l2_subdev_state *sd_state,
> > > +                   unsigned int pad, enum v4l2_subdev_format_whence which)
> > > +{
> > > +     switch (which) {
> > > +     case V4L2_SUBDEV_FORMAT_TRY:
> > > +             return v4l2_subdev_get_try_crop(&ov9282->sd, sd_state, pad);
> > > +     case V4L2_SUBDEV_FORMAT_ACTIVE:
> > > +             return &ov9282->cur_mode->crop;
> > > +     }
> > > +
> > > +     return NULL;
> > > +}
> > > +
> > > +static int ov9282_get_selection(struct v4l2_subdev *sd,
> > > +                             struct v4l2_subdev_state *sd_state,
> > > +                             struct v4l2_subdev_selection *sel)
> > > +{
> > > +     switch (sel->target) {
> > > +     case V4L2_SEL_TGT_CROP: {
> > > +             struct ov9282 *ov9282 = to_ov9282(sd);
> > > +
> > > +             mutex_lock(&ov9282->mutex);
> >
> > As there's no set_selection, do we need the mutex here ?
>
> __ov9282_get_pad_crop is looking at the current mode, so the mutex is
> against ov9282_set_pad_format changing the mode.

Ah right

Please add my tag to v2
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

>
> You'll find the same pattern in imx214, imx219, ov5640, ov5647,
> ov8865, and hopefully all other sensor drivers implementing
> get_selection for V4L2_SEL_TGT_CROP.
>
>   Dave
>
> > > +             sel->r = *__ov9282_get_pad_crop(ov9282, sd_state, sel->pad,
> > > +                                             sel->which);
> > > +             mutex_unlock(&ov9282->mutex);
> > > +
> > > +             return 0;
> > > +     }
> > > +
> > > +     case V4L2_SEL_TGT_NATIVE_SIZE:
> > > +             sel->r.top = 0;
> > > +             sel->r.left = 0;
> > > +             sel->r.width = OV9282_NATIVE_WIDTH;
> > > +             sel->r.height = OV9282_NATIVE_HEIGHT;
> > > +
> > > +             return 0;
> > > +
> > > +     case V4L2_SEL_TGT_CROP_DEFAULT:
> > > +     case V4L2_SEL_TGT_CROP_BOUNDS:
> > > +             sel->r.top = OV9282_PIXEL_ARRAY_TOP;
> > > +             sel->r.left = OV9282_PIXEL_ARRAY_LEFT;
> > > +             sel->r.width = OV9282_PIXEL_ARRAY_WIDTH;
> > > +             sel->r.height = OV9282_PIXEL_ARRAY_HEIGHT;
> > > +
> > > +             return 0;
> > > +     }
> > > +
> > > +     return -EINVAL;
> > > +}
> > > +
> > >  /**
> > >   * ov9282_start_streaming() - Start sensor stream
> > >   * @ov9282: pointer to ov9282 device
> > > @@ -963,6 +1037,7 @@ static const struct v4l2_subdev_pad_ops ov9282_pad_ops = {
> > >       .enum_frame_size = ov9282_enum_frame_size,
> > >       .get_fmt = ov9282_get_pad_format,
> > >       .set_fmt = ov9282_set_pad_format,
> > > +     .get_selection = ov9282_get_selection,
> > >  };
> > >
> > >  static const struct v4l2_subdev_ops ov9282_subdev_ops = {
> > > --
> > > 2.34.1
> > >

  reply	other threads:[~2022-10-06 11:54 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 15:27 [PATCH 00/16] Updates to ov9282 sensor driver Dave Stevenson
2022-10-05 15:27 ` [PATCH 01/16] media: i2c: ov9282: Remove duplication of registers Dave Stevenson
2022-10-06  9:14   ` Jacopo Mondi
2022-10-05 15:27 ` [PATCH 02/16] media: i2c: ov9282: Split registers into common and mode specific Dave Stevenson
2022-10-06  9:15   ` Jacopo Mondi
2022-10-05 15:27 ` [PATCH 03/16] media: i2c: ov9282: Remove format code from the mode Dave Stevenson
2022-10-06  9:15   ` Jacopo Mondi
2022-10-05 15:27 ` [PATCH 04/16] media: i2c: ov9282: Remove pixel rate from mode definition Dave Stevenson
2022-10-06  9:17   ` Jacopo Mondi
2022-10-06 11:51     ` Dave Stevenson
2022-10-05 15:27 ` [PATCH 05/16] media: i2c: ov9281: Support more than 1 mode Dave Stevenson
2022-10-06  9:18   ` Jacopo Mondi
2022-10-26  7:22   ` Sakari Ailus
2022-10-05 15:27 ` [PATCH 06/16] media: i2c: ov9282: Correct HTS register for configured pixel rate Dave Stevenson
2022-10-06  9:23   ` Jacopo Mondi
2022-10-06 13:01     ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 07/16] media: i2c: ov9282: Reduce vblank_min values based on testing Dave Stevenson
2022-10-06 11:56   ` Jacopo Mondi
2022-10-06 13:02     ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 08/16] media: i2c: ov9282: Add selection for CSI2 clock mode Dave Stevenson
2022-10-06  9:24   ` Jacopo Mondi
2022-10-26  7:21   ` Sakari Ailus
2022-10-28 12:57     ` Dave Stevenson
2022-10-28 14:30       ` Sakari Ailus
2022-10-28 15:03         ` Dave Stevenson
2022-10-31 13:06           ` Sakari Ailus
2022-10-05 15:28 ` [PATCH 09/16] media: i2c: ov9282: Add the properties from fwnode Dave Stevenson
2022-10-06 11:57   ` Jacopo Mondi
2022-10-05 15:28 ` [PATCH 10/16] media: i2c: ov9282: Action CID_VBLANK when set Dave Stevenson
2022-10-06  9:29   ` Jacopo Mondi
2022-10-06 13:21     ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 11/16] media: i2c: ov9282: Add HFLIP and VFLIP support Dave Stevenson
2022-10-06  9:38   ` Jacopo Mondi
2022-10-06 14:21     ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 12/16] media: i2c: ov9282: Make V4L2_CID_HBLANK r/w Dave Stevenson
2022-10-06  9:41   ` Jacopo Mondi
2022-10-06 11:33     ` Dave Stevenson
2022-10-06 11:53       ` Jacopo Mondi
2022-10-05 15:28 ` [PATCH 13/16] media: i2c: ov9282: Add selection API calls for cropping info Dave Stevenson
2022-10-06  9:43   ` Jacopo Mondi
2022-10-06 11:39     ` Dave Stevenson
2022-10-06 11:54       ` Jacopo Mondi [this message]
2022-10-05 15:28 ` [PATCH 14/16] media: i2c: ov9282: Add support for 1280x800 and 640x400 modes Dave Stevenson
2022-10-06  9:48   ` Jacopo Mondi
2022-10-06 11:46     ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 15/16] media: i2c: ov9282: Add support for 8bit readout Dave Stevenson
2022-10-06  9:57   ` Jacopo Mondi
2022-10-06 12:20     ` Dave Stevenson
2022-10-05 15:28 ` [PATCH 16/16] media: i2c: ov9282: Support event handlers Dave Stevenson
2022-10-06  9:59   ` Jacopo Mondi
2022-10-07 10:22     ` Dave Stevenson
2022-10-07 12:57       ` 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=20221006115427.unrzqizgdtvysxoc@uno.localdomain \
    --to=jacopo@jmondi.org \
    --cc=daniele.alessandrelli@intel.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=linux-media@vger.kernel.org \
    --cc=paul.j.murphy@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 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.