From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cc: linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-staging@lists.linux.dev,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Adam Pigg <adam@piggz.co.uk>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH 5/9] media: sun6i-csi: capture: Rework and separate format validation
Date: Sat, 25 Mar 2023 23:24:12 +0200 [thread overview]
Message-ID: <20230325212412.GC22214@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230324151228.2778112-6-paul.kocialkowski@bootlin.com>
Hi Paul,
Thank you for the patch.
On Fri, Mar 24, 2023 at 04:12:24PM +0100, Paul Kocialkowski wrote:
> Introduce a new sun6i_csi_capture_format_check helper to indicate
> whether a set of pixel format and mbus code are compatible.
> Most of the logic is taken from sun6i_csi_capture_link_validate,
> with extra checks added along the way.
>
> Note that v4l2_format_info is now used for all pixel formats
> since they should all be listed in the helper at this point.
>
> The motivation behind this change is to pave the way for supporting
> the mc-style enum_fmt.
>
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
> .../sunxi/sun6i-csi/sun6i_csi_capture.c | 95 ++++++++++---------
> 1 file changed, 49 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> index cf6aadbc130b..6ce7f1d3ed57 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c
> @@ -327,6 +327,52 @@ static bool sun6i_csi_capture_format_match(u32 pixelformat, u32 mbus_code)
> return false;
> }
>
> +static bool sun6i_csi_capture_format_check(u32 pixelformat, u32 mbus_code)
> +{
> + const struct sun6i_csi_capture_format *capture_format;
> + const struct sun6i_csi_bridge_format *bridge_format;
I think I would have named those output_format and input_format
respectively, as "capture" and "bridge" take a bit more mental
processing when reading the code. That may be because I'm not familiar
with the driver though, so feel free to ignore this.
> + const struct v4l2_format_info *format_info;
> +
> + format_info = v4l2_format_info(pixelformat);
> + if (WARN_ON(!format_info))
> + return false;
> +
> + capture_format = sun6i_csi_capture_format_find(pixelformat);
> + if (WARN_ON(!capture_format))
> + return false;
> +
> + bridge_format = sun6i_csi_bridge_format_find(mbus_code);
> + if (WARN_ON(!bridge_format))
> + return false;
> +
> + /* Raw input is required for non-YUV formats. */
> + if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW &&
> + (format_info->pixel_enc == V4L2_PIXEL_ENC_BAYER ||
> + format_info->pixel_enc == V4L2_PIXEL_ENC_RGB ||
> + format_info->pixel_enc == V4L2_PIXEL_ENC_COMPRESSED))
Unless I'm mistaken, the compressed format check is new. You could split
it to a separate patch, or at least mention it in the commit message.
> + return false;
> +
> + if (format_info->pixel_enc == V4L2_PIXEL_ENC_YUV) {
> + /* YUV input is required for YUV pixels. */
> + if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV420 &&
> + bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV422)
> + return false;
> +
> + /* YUV420 input can't produce (upsampled) YUV422 output. */
> + if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_YUV420 &&
> + format_info->vdiv == 1)
> + return false;
> + }
> +
> + /* Raw input requires a 1:1 match between input and output. */
> + if ((bridge_format->input_format == SUN6I_CSI_INPUT_FMT_RAW ||
> + capture_format->input_format_raw) &&
> + !sun6i_csi_capture_format_match(pixelformat, mbus_code))
> + return false;
Wrong indentation.
With this fixed,
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> +
> + return true;
> +}
> +
> /* Capture */
>
> static void
> @@ -890,28 +936,16 @@ static int sun6i_csi_capture_link_validate(struct media_link *link)
> media_entity_to_video_device(link->sink->entity);
> struct sun6i_csi_device *csi_dev = video_get_drvdata(video_dev);
> struct v4l2_device *v4l2_dev = csi_dev->v4l2_dev;
> - const struct sun6i_csi_capture_format *capture_format;
> - const struct sun6i_csi_bridge_format *bridge_format;
> unsigned int capture_width, capture_height;
> unsigned int bridge_width, bridge_height;
> - const struct v4l2_format_info *format_info;
> u32 pixelformat, capture_field;
> u32 mbus_code, bridge_field;
> - bool match;
>
> sun6i_csi_capture_dimensions(csi_dev, &capture_width, &capture_height);
> -
> sun6i_csi_capture_format(csi_dev, &pixelformat, &capture_field);
> - capture_format = sun6i_csi_capture_format_find(pixelformat);
> - if (WARN_ON(!capture_format))
> - return -EINVAL;
>
> sun6i_csi_bridge_dimensions(csi_dev, &bridge_width, &bridge_height);
> -
> sun6i_csi_bridge_format(csi_dev, &mbus_code, &bridge_field);
> - bridge_format = sun6i_csi_bridge_format_find(mbus_code);
> - if (WARN_ON(!bridge_format))
> - return -EINVAL;
>
> /* No cropping/scaling is supported. */
> if (capture_width != bridge_width || capture_height != bridge_height) {
> @@ -922,43 +956,12 @@ static int sun6i_csi_capture_link_validate(struct media_link *link)
> return -EINVAL;
> }
>
> - format_info = v4l2_format_info(pixelformat);
> - /* Some formats are not listed. */
> - if (!format_info)
> - return 0;
> -
> - if (format_info->pixel_enc == V4L2_PIXEL_ENC_BAYER &&
> - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW)
> - goto invalid;
> -
> - if (format_info->pixel_enc == V4L2_PIXEL_ENC_RGB &&
> - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW)
> - goto invalid;
> -
> - if (format_info->pixel_enc == V4L2_PIXEL_ENC_YUV) {
> - if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV420 &&
> - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV422)
> - goto invalid;
> -
> - /* YUV420 input can't produce YUV422 output. */
> - if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_YUV420 &&
> - format_info->vdiv == 1)
> - goto invalid;
> - }
> -
> - /* With raw input mode, we need a 1:1 match between input and output. */
> - if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_RAW ||
> - capture_format->input_format_raw) {
> - match = sun6i_csi_capture_format_match(pixelformat, mbus_code);
> - if (!match)
> - goto invalid;
> + if (!sun6i_csi_capture_format_check(pixelformat, mbus_code)) {
> + v4l2_err(v4l2_dev, "invalid input/output format combination\n");
> + return -EINVAL;
> }
>
> return 0;
> -
> -invalid:
> - v4l2_err(v4l2_dev, "invalid input/output format combination\n");
> - return -EINVAL;
> }
>
> static const struct media_entity_operations sun6i_csi_capture_media_ops = {
--
Regards,
Laurent Pinchart
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-03-25 21:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 15:12 [PATCH 0/9] media: sun6i-csi/isp: Implement MC I/O support Paul Kocialkowski
2023-03-24 15:12 ` [PATCH 1/9] media: v4l2: Add RGB565X pixel format to v4l2 format info Paul Kocialkowski
2023-03-25 7:06 ` Jernej Škrabec
2023-03-25 20:59 ` Laurent Pinchart
2023-03-24 15:12 ` [PATCH 2/9] media: v4l2: Add NV12_16L16 " Paul Kocialkowski
2023-03-25 7:06 ` Jernej Škrabec
2023-03-25 21:01 ` Laurent Pinchart
2023-03-31 18:54 ` Nicolas Dufresne
2023-04-05 4:21 ` Laurent Pinchart
2023-04-11 13:03 ` Nicolas Dufresne
2023-04-11 15:30 ` Nicolas Dufresne
2023-03-24 15:12 ` [PATCH 3/9] media: v4l2: Introduce compressed pixel encoding definition and helper Paul Kocialkowski
2023-03-25 7:07 ` Jernej Škrabec
2023-03-24 15:12 ` [PATCH 4/9] media: v4l2: Add JPEG pixel format to v4l2 format info Paul Kocialkowski
2023-03-25 7:08 ` Jernej Škrabec
2023-03-31 19:07 ` Nicolas Dufresne
2023-03-24 15:12 ` [PATCH 5/9] media: sun6i-csi: capture: Rework and separate format validation Paul Kocialkowski
2023-03-25 7:09 ` Jernej Škrabec
2023-03-25 21:24 ` Laurent Pinchart [this message]
2023-03-24 15:12 ` [PATCH 6/9] media: sun6i-csi: capture: Implement MC I/O with extended enum_fmt Paul Kocialkowski
2023-03-25 7:13 ` Jernej Škrabec
2023-03-25 21:29 ` Laurent Pinchart
2023-03-24 15:12 ` [PATCH 7/9] media: sun6i-csi: capture: Implement enum_framesizes Paul Kocialkowski
2023-03-25 7:13 ` Jernej Škrabec
2023-03-25 21:33 ` Laurent Pinchart
2023-03-24 15:12 ` [PATCH 8/9] media: sun6i-isp: capture: Implement MC I/O with extended enum_fmt Paul Kocialkowski
2023-03-25 7:14 ` Jernej Škrabec
2023-03-25 21:42 ` Laurent Pinchart
2023-03-24 15:12 ` [PATCH 9/9] media: sun6i-isp: capture: Implement enum_framesizes Paul Kocialkowski
2023-03-25 7:14 ` Jernej Škrabec
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=20230325212412.GC22214@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=adam@piggz.co.uk \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=linux-sunxi@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=paul.kocialkowski@bootlin.com \
--cc=samuel@sholland.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wens@csie.org \
/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).