From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: mripard@kernel.org, paul.kocialkowski@bootlin.com
Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org,
samuel@sholland.org, hverkuil-cisco@xs4all.nl,
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
Subject: Re: [PATCH 05/11] media: cedrus: Filter controls based on capability
Date: Tue, 01 Nov 2022 23:56:49 +0100 [thread overview]
Message-ID: <5872247.lOV4Wx5bFT@kista> (raw)
In-Reply-To: <20221024201515.34129-6-jernej.skrabec@gmail.com>
Dne ponedeljek, 24. oktober 2022 ob 22:15:09 CET je Jernej Skrabec napisal(a):
> Because not all Cedrus variants supports all codecs, controls should be
> registered only if codec related to individual control is supported by
> Cedrus.
>
> Replace codec enum, which is not used at all, with capabilities flags
> and register control only if capabilities are met.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> ---
> drivers/staging/media/sunxi/cedrus/cedrus.c | 45 +++++++++++----------
> drivers/staging/media/sunxi/cedrus/cedrus.h | 2 +-
> 2 files changed, 25 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c
> b/drivers/staging/media/sunxi/cedrus/cedrus.c index
> 2f284a58d787..023566b02dc5 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
> @@ -77,56 +77,56 @@ static const struct cedrus_control cedrus_controls[] = {
> .cfg = {
> .id =
V4L2_CID_STATELESS_MPEG2_SEQUENCE,
> },
> - .codec = CEDRUS_CODEC_MPEG2,
> + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC,
> },
> {
> .cfg = {
> .id =
V4L2_CID_STATELESS_MPEG2_PICTURE,
> },
> - .codec = CEDRUS_CODEC_MPEG2,
> + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC,
> },
> {
> .cfg = {
> .id =
V4L2_CID_STATELESS_MPEG2_QUANTISATION,
> },
> - .codec = CEDRUS_CODEC_MPEG2,
> + .capabilities = CEDRUS_CAPABILITY_MPEG2_DEC,
> },
> {
> .cfg = {
> .id =
V4L2_CID_STATELESS_H264_DECODE_PARAMS,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> .id =
V4L2_CID_STATELESS_H264_SLICE_PARAMS,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> .id = V4L2_CID_STATELESS_H264_SPS,
> .ops = &cedrus_ctrl_ops,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> .id = V4L2_CID_STATELESS_H264_PPS,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> .id =
V4L2_CID_STATELESS_H264_SCALING_MATRIX,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> .id =
V4L2_CID_STATELESS_H264_PRED_WEIGHTS,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> @@ -134,7 +134,7 @@ static const struct cedrus_control cedrus_controls[] = {
> .max = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED,
> .def =
V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> @@ -142,7 +142,7 @@ static const struct cedrus_control cedrus_controls[] = {
> .max = V4L2_STATELESS_H264_START_CODE_NONE,
> .def =
V4L2_STATELESS_H264_START_CODE_NONE,
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> /*
> * We only expose supported profiles information,
> @@ -160,20 +160,20 @@ static const struct cedrus_control cedrus_controls[] =
> { .menu_skip_mask =
>
BIT(V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED),
> },
> - .codec = CEDRUS_CODEC_H264,
> + .capabilities = CEDRUS_CAPABILITY_H264_DEC,
> },
> {
> .cfg = {
> .id = V4L2_CID_STATELESS_HEVC_SPS,
> .ops = &cedrus_ctrl_ops,
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> {
> .cfg = {
> .id = V4L2_CID_STATELESS_HEVC_PPS,
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> {
> .cfg = {
> @@ -181,13 +181,13 @@ static const struct cedrus_control cedrus_controls[] =
> { /* The driver can only handle 1 entry per slice for now */
> .dims = { 1 },
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> {
> .cfg = {
> .id =
V4L2_CID_STATELESS_HEVC_SCALING_MATRIX,
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> {
> .cfg = {
> @@ -197,7 +197,7 @@ static const struct cedrus_control cedrus_controls[] = {
> .max = 0xffffffff,
> .step = 1,
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> {
> .cfg = {
> @@ -205,7 +205,7 @@ static const struct cedrus_control cedrus_controls[] = {
> .max = V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED,
> .def =
V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED,
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> {
> .cfg = {
> @@ -213,19 +213,19 @@ static const struct cedrus_control cedrus_controls[] =
> { .max = V4L2_STATELESS_HEVC_START_CODE_NONE,
> .def =
V4L2_STATELESS_HEVC_START_CODE_NONE,
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> {
> .cfg = {
> .id = V4L2_CID_STATELESS_VP8_FRAME,
> },
> - .codec = CEDRUS_CODEC_VP8,
> + .capabilities = CEDRUS_CAPABILITY_VP8_DEC,
> },
> {
> .cfg = {
> .id = V4L2_CID_STATELESS_HEVC_DECODE_PARAMS,
> },
> - .codec = CEDRUS_CODEC_H265,
> + .capabilities = CEDRUS_CAPABILITY_H265_DEC,
> },
> };
>
> @@ -275,6 +275,9 @@ static int cedrus_init_ctrls(struct cedrus_dev *dev,
> struct cedrus_ctx *ctx) return -ENOMEM;
>
> for (i = 0; i < CEDRUS_CONTROLS_COUNT; i++) {
> + if (!cedrus_is_capable(ctx,
cedrus_controls[i].capabilities))
> + continue;
While it's not visible from this commit, above filtering causes issues when
searching for controls in ctx->ctrls[]. Now are not packed together and search
functions (cedrus_find_control_data, cedrus_get_num_of_controls) rely on
controls not being null. null control marks end of the array.
I'll fix that in next revision.
Best regards,
Jernej
> +
> ctrl = v4l2_ctrl_new_custom(hdl,
&cedrus_controls[i].cfg,
> NULL);
> if (hdl->error) {
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h
> b/drivers/staging/media/sunxi/cedrus/cedrus.h index
> 1a98790a99af..7a1619967513 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus.h
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h
> @@ -57,7 +57,7 @@ enum cedrus_h264_pic_type {
>
> struct cedrus_control {
> struct v4l2_ctrl_config cfg;
> - enum cedrus_codec codec;
> + unsigned int capabilities;
> };
>
> struct cedrus_h264_run {
> --
> 2.38.1
next prev parent reply other threads:[~2022-11-01 22:56 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 20:15 [PATCH 00/11] media: cedrus: Format handling improvements and 10-bit HEVC support Jernej Skrabec
2022-10-24 20:15 ` [PATCH 01/11] media: cedrus: remove superfluous call Jernej Skrabec
2022-10-25 15:08 ` Paul Kocialkowski
2022-10-24 20:15 ` [PATCH 02/11] media: cedrus: Add format reset helpers Jernej Skrabec
2022-10-24 20:15 ` [PATCH 03/11] media: cedrus: use helper to set default formats Jernej Skrabec
2022-10-24 20:15 ` [PATCH 04/11] media: cedrus: Add helper for checking capabilities Jernej Skrabec
2022-10-25 6:30 ` Dan Carpenter
2022-10-25 15:17 ` Jernej Škrabec
2022-10-25 15:22 ` Paul Kocialkowski
2022-10-25 15:28 ` Jernej Škrabec
2022-10-25 15:35 ` Paul Kocialkowski
2022-10-24 20:15 ` [PATCH 05/11] media: cedrus: Filter controls based on capability Jernej Skrabec
2022-10-25 15:16 ` Paul Kocialkowski
2022-11-01 22:56 ` Jernej Škrabec [this message]
2022-10-24 20:15 ` [PATCH 06/11] media: cedrus: set codec ops immediately Jernej Skrabec
2022-10-25 14:59 ` Paul Kocialkowski
2022-10-24 20:15 ` [PATCH 07/11] media: cedrus: Remove cedrus_codec enum Jernej Skrabec
2022-10-25 15:03 ` Paul Kocialkowski
2022-10-24 20:15 ` [PATCH 08/11] media: cedrus: prefer untiled capture format Jernej Skrabec
2022-10-25 15:05 ` Paul Kocialkowski
2022-10-25 15:15 ` Jernej Škrabec
2022-10-24 20:15 ` [PATCH 09/11] media: cedrus: initialize controls a bit later Jernej Skrabec
2022-10-24 20:15 ` [PATCH 10/11] media: cedrus: Adjust buffer size based on control values Jernej Skrabec
2022-10-24 20:15 ` [PATCH 11/11] media: cedrus: h265: Support decoding 10-bit frames Jernej Skrabec
2022-10-25 6:55 ` [PATCH 00/11] media: cedrus: Format handling improvements and 10-bit HEVC support Dan Carpenter
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=5872247.lOV4Wx5bFT@kista \
--to=jernej.skrabec@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil-cisco@xs4all.nl \
--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=paul.kocialkowski@bootlin.com \
--cc=samuel@sholland.org \
--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