Message ID | 20230529103741.11904-6-hdegoede@redhat.com |
---|---|
State | Accepted |
Commit | b1b2d3992623290833f7f4ddea1986c7f123f3ad |
Headers | show |
Series | media: atomisp: Use selection API info to determine sensor padding | expand |
Hi, On 5/30/23 13:51, Andy Shevchenko wrote: > On Mon, May 29, 2023 at 9:13 PM Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: >> On Mon, May 29, 2023 at 1:38 PM Hans de Goede <hdegoede@redhat.com> wrote: > > ... > >>> +static int ov2680_init_cfg(struct v4l2_subdev *sd, >>> + struct v4l2_subdev_state *sd_state) >>> +{ >>> + struct v4l2_subdev_format fmt = { >>> + .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY >>> + : V4L2_SUBDEV_FORMAT_ACTIVE, >>> + .format = { >>> + .width = 800, >>> + .height = 600, >> >>> + } >> >> I would keep a trailing comma here. >> >>> + }; >>> + >>> + return ov2680_set_fmt(sd, sd_state, &fmt); >>> +} > > This is not addressed in your branch. Oops, sorry I've fixed this in my branch now and I've also changed 6/21 to make __ov2680_get_pad_crop() look like this: static struct v4l2_rect * __ov2680_get_pad_crop(struct ov2680_dev *sensor, struct v4l2_subdev_state *state, unsigned int pad, enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) return v4l2_subdev_get_try_crop(&sensor->sd, state, pad); return &sensor->mode.crop; } Regards, Hans
diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c index 6cbc470bce91..17fb773540e5 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c @@ -357,6 +357,21 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd, return 0; } +static int ov2680_init_cfg(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) +{ + struct v4l2_subdev_format fmt = { + .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY + : V4L2_SUBDEV_FORMAT_ACTIVE, + .format = { + .width = 800, + .height = 600, + } + }; + + return ov2680_set_fmt(sd, sd_state, &fmt); +} + static int ov2680_detect(struct i2c_client *client) { struct i2c_adapter *adapter = client->adapter; @@ -537,6 +552,7 @@ static const struct v4l2_subdev_sensor_ops ov2680_sensor_ops = { }; static const struct v4l2_subdev_pad_ops ov2680_pad_ops = { + .init_cfg = ov2680_init_cfg, .enum_mbus_code = ov2680_enum_mbus_code, .enum_frame_size = ov2680_enum_frame_size, .enum_frame_interval = ov2680_enum_frame_interval,
Having an init_cfg to initialize the passed in subdev-state is important to make which == V4L2_SUBDEV_FORMAT_TRY ops work when userspace is talking to a /dev/v4l2-subdev# node. Copy the ov2680_init_cfg() from the standard drivers/media/i2c/ov2680.c driver. This is esp. relevant once support for cropping is added where the v4l2_subdev_state.pads[pad].try_crop rectangle needs to be set correctly for set_fmt which == V4L2_SUBDEV_FORMAT_TRY calls to work. Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- .../staging/media/atomisp/i2c/atomisp-ov2680.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)