From: Jernej Skrabec <jernej.skrabec@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>
Cc: Maxime Ripard <mripard@kernel.org>,
Paul Kocialkowski <paulk@sys-base.io>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Chen-Yu Tsai <wens@kernel.org>,
Samuel Holland <samuel@sholland.org>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
Jernej Skrabec <jernej.skrabec@gmail.com>
Subject: [PATCH 2/3] staging: media: cedrus: factor out the format check
Date: Fri, 27 Nov 2026 07:55:22 +0100 [thread overview]
Message-ID: <20261127065523.3685726-3-jernej.skrabec@gmail.com> (raw)
In-Reply-To: <20261127065523.3685726-1-jernej.skrabec@gmail.com>
cedrus_find_format() and cedrus_enum_fmt() check the capabilities and
the direction of a format in the same way. Move the check into a
helper, so that the VP9 decoder, added later, can exclude formats in
one place.
No functional change.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
.../staging/media/sunxi/cedrus/cedrus_video.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
index 2521315abdb7..a46820a90d87 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
@@ -78,6 +78,17 @@ static struct cedrus_format cedrus_formats[] = {
#define CEDRUS_FORMATS_COUNT ARRAY_SIZE(cedrus_formats)
+static bool cedrus_check_format(struct cedrus_ctx *ctx,
+ const struct cedrus_format *fmt,
+ u32 directions)
+{
+ if (!cedrus_is_capable(ctx, fmt->capabilities) ||
+ !(fmt->directions & directions))
+ return false;
+
+ return true;
+}
+
static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx,
u32 pixelformat, u32 directions)
{
@@ -88,8 +99,7 @@ static struct cedrus_format *cedrus_find_format(struct cedrus_ctx *ctx,
for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) {
fmt = &cedrus_formats[i];
- if (!cedrus_is_capable(ctx, fmt->capabilities) ||
- !(fmt->directions & directions))
+ if (!cedrus_check_format(ctx, fmt, directions))
continue;
if (fmt->pixelformat == pixelformat)
@@ -191,10 +201,7 @@ static int cedrus_enum_fmt(struct file *file, struct v4l2_fmtdesc *f,
index = 0;
for (i = 0; i < CEDRUS_FORMATS_COUNT; i++) {
- if (!cedrus_is_capable(ctx, cedrus_formats[i].capabilities))
- continue;
-
- if (!(cedrus_formats[i].directions & direction))
+ if (!cedrus_check_format(ctx, &cedrus_formats[i], direction))
continue;
if (index == f->index)
--
2.43.0
next prev parent reply other threads:[~2026-11-27 6:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 6:55 [PATCH 0/3] staging: media: cedrus: add VP9 decoding for H616 Jernej Skrabec
2026-11-27 6:55 ` [PATCH 1/3] staging: media: cedrus: take the output line stride from the capture format Jernej Skrabec
2026-11-27 6:55 ` Jernej Skrabec [this message]
2026-11-27 6:55 ` [PATCH 3/3] staging: media: cedrus: add VP9 decoding support Jernej Skrabec
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=20261127065523.3685726-3-jernej.skrabec@gmail.com \
--to=jernej.skrabec@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil@kernel.org \
--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=mripard@kernel.org \
--cc=nicolas.dufresne@collabora.com \
--cc=paulk@sys-base.io \
--cc=samuel@sholland.org \
--cc=wens@kernel.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