From: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: mchehab@kernel.org, sakari.ailus@linux.intel.com,
hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com,
roman.kovalivskyi@globallogic.com,
dave.stevenson@raspberrypi.org, naush@raspberrypi.com,
andrew_gabbasov@mentor.com, mrodin@de.adit-jv.com,
mripard@kernel.org, libcamera-devel@lists.libcamera.org,
sudipi@jp.adit-jv.com, hugues.fruchet@st.com,
erosca@de.adit-jv.com, aford173@gmail.com,
linux-media@vger.kernel.org
Subject: Re: [libcamera-devel] [PATCH 19/25] media: ov5647: Implement set_fmt pad operation
Date: Tue, 30 Jun 2020 13:09:57 +0200 [thread overview]
Message-ID: <86ac2fa1-32c1-8f85-1a92-6a69ea1e5735@collabora.com> (raw)
In-Reply-To: <20200630101338.dz7toga2mhah7rsq@uno.localdomain>
On 30.06.20 12:13, Jacopo Mondi wrote:
> Hi Dafna,
>
> On Mon, Jun 29, 2020 at 06:54:43PM +0200, Dafna Hirschfeld wrote:
>>
>>
>> On 23.06.20 18:49, Jacopo Mondi wrote:
>>> Now that the driver supports more than a single mode, implement the
>>> .set_fmt pad operation and adjust the existing .get_fmt one to report
>>> the currently applied format.
>>>
>>> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
>>> ---
>>> drivers/media/i2c/ov5647.c | 67 +++++++++++++++++++++++++++++++++++---
>>> 1 file changed, 62 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
>>> index af9e6d43967d8..39e320f321bd8 100644
>>> --- a/drivers/media/i2c/ov5647.c
>>> +++ b/drivers/media/i2c/ov5647.c
>>> @@ -1016,15 +1016,72 @@ static int ov5647_enum_frame_size(struct v4l2_subdev *sd,
>>> return 0;
>>> }
>>> -static int ov5647_set_get_fmt(struct v4l2_subdev *sd,
>>> +static int ov5647_get_pad_fmt(struct v4l2_subdev *sd,
>>> struct v4l2_subdev_pad_config *cfg,
>>> struct v4l2_subdev_format *format)
>>> {
>>> struct v4l2_mbus_framefmt *fmt = &format->format;
>>> + struct v4l2_mbus_framefmt *sensor_format;
>>> + struct ov5647 *sensor = to_sensor(sd);
>>> - /* Only one format is supported, so return that. */
>>> + mutex_lock(&sensor->lock);
>>> memset(fmt, 0, sizeof(*fmt));
>>> - *fmt = OV5647_DEFAULT_FORMAT;
>>> +
>>> + switch (format->which) {
>>> + case V4L2_SUBDEV_FORMAT_TRY:
>>> + sensor_format = v4l2_subdev_get_try_format(sd, cfg, format->pad);
>>> + break;
>>> + default:
>>> + sensor_format = &sensor->mode->format;
>>> + break;
>>> + }
>>> +
>>> + *fmt = *sensor_format;
>>> + mutex_unlock(&sensor->lock);
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,
>>> + struct v4l2_subdev_pad_config *cfg,
>>> + struct v4l2_subdev_format *format)
>>> +{
>>> + struct v4l2_mbus_framefmt *fmt = &format->format;
>>> + struct ov5647 *sensor = to_sensor(sd);
>>> + struct ov5647_mode *ov5647_mode_list;
>>> + struct ov5647_mode *mode;
>>> + unsigned int num_modes;
>>> +
>>> + /*
>>> + * Default mbus code MEDIA_BUS_FMT_SBGGR10_1X10 if the requested one
>>> + * is not supported.
>>
>> In previous patch you added macros OV5647_DEFAULT_MODE, OV5647_DEFAULT_FORMAT
>> which comes from first format in the array 'ov5647_formats' which is MEDIA_BUS_FMT_SBGGR8_1X8.
>
> Oh well, that's just an arbitrary selection of the format the sensor
> is initialized with.
>
>> But here you set the default format to MEDIA_BUS_FMT_SBGGR10_1X10
>>
>
> I chose the _1x10 version as it supports more resolution than the _1X8
> one. The v4l2-spec says if the requested format is not supported the
> closed possible match should be reported. It is easy to identify what
> a closes possible match is when considering the image size, but for image
> formats the "closes possible match" might be tricky to define.
>
> I can change the sensor initial default state if you think that's the
> case, but I don't think the initial configuration and the adjusted format
> returned from s_stream() should be considered related. Do you agree or
> is there any part of the specs I'm overlooking ?
I also don't see it in the spec, but I think it is nicer that
s_fmt default to the initial value. This is also the first value
returned in the enumeration.
Thanks,
d
>
> Thanks
> j
>
>
>>> + */
>>> + if (fmt->code == MEDIA_BUS_FMT_SBGGR8_1X8) {
>>> + ov5647_mode_list = ov5647_sbggr8_modes;
>>> + num_modes = ARRAY_SIZE(ov5647_sbggr8_modes);
>>> + } else {
>>> + ov5647_mode_list = ov5647_sbggr10_modes;
>>> + num_modes = ARRAY_SIZE(ov5647_sbggr10_modes);
>>> + }
>>> +
>>> + mode = v4l2_find_nearest_size(ov5647_mode_list, num_modes,
>>> + format.width, format.height,
>>> + fmt->width, fmt->height);
>>> +
>>> + if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
>>> + mutex_lock(&sensor->lock);
>>> + *v4l2_subdev_get_try_format(sd, cfg, format->pad) = mode->format;
>>> + *fmt = mode->format;
>>> + mutex_unlock(&sensor->lock);
>>> +
>>> + return 0;
>>> + }
>>> +
>>> + /* Update the sensor mode and apply at it at streamon time. */
>>> + mutex_lock(&sensor->lock);
>>> + sensor->mode = mode;
>>> + *fmt = mode->format;
>>> + mutex_unlock(&sensor->lock);
>>> return 0;
>>> }
>>> @@ -1068,8 +1125,8 @@ static int ov5647_get_selection(struct v4l2_subdev *sd,
>>> static const struct v4l2_subdev_pad_ops ov5647_subdev_pad_ops = {
>>> .enum_mbus_code = ov5647_enum_mbus_code,
>>> .enum_frame_size = ov5647_enum_frame_size,
>>> - .set_fmt = ov5647_set_get_fmt,
>>> - .get_fmt = ov5647_set_get_fmt,
>>> + .set_fmt = ov5647_set_pad_fmt,
>>> + .get_fmt = ov5647_get_pad_fmt,
>>> .get_selection = ov5647_get_selection,
>>> };
>>>
next prev parent reply other threads:[~2020-06-30 11:10 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 10:07 [PATCH 00/25] media: ov5647: Support RaspberryPi Camera Module v1 Jacopo Mondi
2020-06-23 10:07 ` [PATCH 01/25] dt-bindings: media: ov5647: Document pwdn-gpios Jacopo Mondi
2020-06-23 10:07 ` [PATCH 02/25] dt-bindings: media: ov5647: Document clock-noncontinuous Jacopo Mondi
2020-06-23 10:07 ` [PATCH 03/25] media: ov5647: Add support for PWDN GPIO Jacopo Mondi
2020-07-09 20:04 ` [libcamera-devel] " Dafna Hirschfeld
2020-07-14 12:45 ` Jacopo Mondi
2020-06-23 10:07 ` [PATCH 04/25] media: ov5647: Add support for non-continuous clock mode Jacopo Mondi
2020-06-23 10:07 ` [PATCH 05/25] media: ov5647: Add set_fmt and get_fmt calls Jacopo Mondi
2020-06-23 10:07 ` [PATCH 06/25] media: ov5647: Fix format initialization Jacopo Mondi
2020-06-23 10:07 ` [PATCH 07/25] media: ov5647: Fix style issues Jacopo Mondi
2020-06-23 10:07 ` [PATCH 08/25] media: ov5647: Replace license with SPDX identifier Jacopo Mondi
2020-06-23 10:07 ` [PATCH 09/25] media: ov5647: Fix return value from read/write Jacopo Mondi
2020-06-23 10:08 ` [PATCH 10/25] media: ov5647: Program mode at s_stream(1) time Jacopo Mondi
2020-06-23 16:42 ` [PATCH 11/25] media: ov5647: Implement enum_frame_size() Jacopo Mondi
2020-08-18 7:33 ` Sakari Ailus
2020-08-18 7:38 ` Sakari Ailus
2020-06-23 16:42 ` [PATCH 12/25] media: ov5647: Protect s_stream() with mutex Jacopo Mondi
2020-06-23 16:42 ` [PATCH 13/25] media: ov5647: Support gain, exposure and AWB controls Jacopo Mondi
2020-06-23 16:42 ` [PATCH 14/25] media: ov5647: Rationalize driver structure name Jacopo Mondi
2020-06-23 16:42 ` [PATCH 15/25] media: ov5647: Break out format handling Jacopo Mondi
2020-07-31 11:44 ` Sakari Ailus
2020-06-23 16:49 ` [PATCH 16/25] media: ov5647: Add support for get_selection() Jacopo Mondi
2020-07-09 19:56 ` [libcamera-devel] " Dafna Hirschfeld
2020-06-23 16:49 ` [PATCH 17/25] media: ov5647: Rename SBGGR8 VGA mode Jacopo Mondi
2020-06-23 16:49 ` [PATCH 18/25] media: ov5647: Add SGGBR10_1X10 modes Jacopo Mondi
2020-06-23 16:49 ` [PATCH 19/25] media: ov5647: Implement set_fmt pad operation Jacopo Mondi
2020-06-29 16:54 ` [libcamera-devel] " Dafna Hirschfeld
2020-06-30 10:13 ` Jacopo Mondi
2020-06-30 11:09 ` Dafna Hirschfeld [this message]
2020-06-23 16:55 ` [PATCH 20/25] media: ov5647: Program mode only if it has changed Jacopo Mondi
2020-06-29 17:48 ` Dafna Hirschfeld
2020-06-30 7:43 ` Jacopo Mondi
2020-06-30 9:32 ` Dafna Hirschfeld
2020-06-30 10:06 ` Jacopo Mondi
2020-06-30 10:56 ` Dafna Hirschfeld
2020-06-30 12:05 ` Jacopo Mondi
2020-06-30 13:01 ` Dafna Hirschfeld
2020-06-30 14:53 ` [libcamera-devel] " Dave Stevenson
2020-06-30 15:11 ` Dafna Hirschfeld
2020-07-01 7:25 ` Laurent Pinchart
2020-07-03 12:21 ` Jacopo Mondi
2020-07-03 16:33 ` Laurent Pinchart
2020-06-23 16:55 ` [PATCH 21/25] media: ov5647: Set V4L2_SUBDEV_FL_HAS_EVENTS flag Jacopo Mondi
2020-06-23 16:55 ` [PATCH 22/25] media: ov5647: Support V4L2_CID_PIXEL_RATE Jacopo Mondi
2020-06-29 17:01 ` [libcamera-devel] " Dafna Hirschfeld
2020-06-29 21:25 ` Dave Stevenson
2020-06-30 15:13 ` Dave Stevenson
2020-07-01 7:21 ` Laurent Pinchart
2020-06-23 16:55 ` [PATCH 23/25] media: ov5647: Support V4L2_CID_HBLANK control Jacopo Mondi
2020-06-23 16:55 ` [PATCH 24/25] media: ov5647: Support V4L2_CID_VBLANK control Jacopo Mondi
2020-06-23 16:55 ` [PATCH 25/25] media: ov5647: Advertise the correct exposure range Jacopo Mondi
2020-06-29 17:33 ` [PATCH 00/25] media: ov5647: Support RaspberryPi Camera Module v1 Dafna Hirschfeld
2020-06-29 18:08 ` Dafna Hirschfeld
2020-07-10 15:59 ` Dafna Hirschfeld
2020-07-14 12:48 ` 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=86ac2fa1-32c1-8f85-1a92-6a69ea1e5735@collabora.com \
--to=dafna.hirschfeld@collabora.com \
--cc=aford173@gmail.com \
--cc=andrew_gabbasov@mentor.com \
--cc=dave.stevenson@raspberrypi.org \
--cc=erosca@de.adit-jv.com \
--cc=hugues.fruchet@st.com \
--cc=hverkuil@xs4all.nl \
--cc=jacopo@jmondi.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=libcamera-devel@lists.libcamera.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mripard@kernel.org \
--cc=mrodin@de.adit-jv.com \
--cc=naush@raspberrypi.com \
--cc=roman.kovalivskyi@globallogic.com \
--cc=sakari.ailus@linux.intel.com \
--cc=sudipi@jp.adit-jv.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).