From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: Jernej Skrabec <jernej.skrabec@gmail.com>,
mripard@kernel.org, paul.kocialkowski@bootlin.com
Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org,
samuel@sholland.org, 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 v2 10/11] media: cedrus: Adjust buffer size based on control values
Date: Fri, 4 Nov 2022 16:27:29 +0100 [thread overview]
Message-ID: <76c3fc1b-e90f-748c-39ee-74be93fd6811@xs4all.nl> (raw)
In-Reply-To: <20221102180810.267252-11-jernej.skrabec@gmail.com>
Hi Jernej,
On 02/11/2022 19:08, Jernej Skrabec wrote:
> In some cases decoding engine needs extra space in capture buffers. This
> is the case for decoding 10-bit HEVC frames into 8-bit capture format.
> This commit only adds infrastructure for such cases.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> ---
> drivers/staging/media/sunxi/cedrus/cedrus.c | 14 ++++++++++++++
> drivers/staging/media/sunxi/cedrus/cedrus.h | 2 ++
> drivers/staging/media/sunxi/cedrus/cedrus_video.c | 4 ++++
> 3 files changed, 20 insertions(+)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c
> index 6a2c08928613..c36999e47591 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c
> @@ -68,8 +68,22 @@ static int cedrus_try_ctrl(struct v4l2_ctrl *ctrl)
> return 0;
> }
>
> +static int cedrus_s_ctrl(struct v4l2_ctrl *ctrl)
> +{
> + struct cedrus_ctx *ctx = container_of(ctrl->handler,
> + struct cedrus_ctx, hdl);
> + struct vb2_queue *vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
> + V4L2_BUF_TYPE_VIDEO_CAPTURE);
> +
> + if (!vb2_is_busy(vq) && !vb2_is_streaming(vq))
You can drop the !vb2_is_streaming part. If you are streaming, then
it will also be 'busy'.
> + cedrus_reset_cap_format(ctx);
This is weird. I would expect that this is only called for specific controls,
since presumably not all will change the sizeimage value. It looks like
it applies only to V4L2_CID_STATELESS_HEVC_SPS, so I see no reason why
you would call cedrus_reset_cap_format() for other controls as well.
And what happens if someone makes such a change *while streaming*?
Shouldn't cedrus_try_ctrl detect that and fail with -EBUSY in that case?
Regardless, this is unexpected behavior, so some explanatory comments
would be useful.
I'm also not sure whether it isn't better to add cedrus_s_ctrl in the next
patch, I think it would be more understandable when seen with an actual
control.
Regards,
Hans
> +
> + return 0;
> +}
> +
> static const struct v4l2_ctrl_ops cedrus_ctrl_ops = {
> .try_ctrl = cedrus_try_ctrl,
> + .s_ctrl = cedrus_s_ctrl,
> };
>
> static const struct cedrus_control cedrus_controls[] = {
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.h b/drivers/staging/media/sunxi/cedrus/cedrus.h
> index 5904294f3108..774fe8048ce3 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus.h
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus.h
> @@ -162,6 +162,8 @@ struct cedrus_dec_ops {
> int (*start)(struct cedrus_ctx *ctx);
> void (*stop)(struct cedrus_ctx *ctx);
> void (*trigger)(struct cedrus_ctx *ctx);
> + unsigned int (*extra_cap_size)(struct cedrus_ctx *ctx,
> + struct v4l2_pix_format *pix_fmt);
> };
>
> struct cedrus_variant {
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> index dec5d3ae4871..dc67940f1ade 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> @@ -250,6 +250,10 @@ static int cedrus_try_fmt_vid_cap_p(struct cedrus_ctx *ctx,
> pix_fmt->height = ctx->src_fmt.height;
> cedrus_prepare_format(pix_fmt);
>
> + if (ctx->current_codec->extra_cap_size)
> + pix_fmt->sizeimage +=
> + ctx->current_codec->extra_cap_size(ctx, pix_fmt);
> +
> return 0;
> }
>
next prev parent reply other threads:[~2022-11-04 15:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 18:07 [PATCH v2 00/11] media: cedrus: Format handling improvements and 10-bit HEVC support Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 01/11] media: cedrus: remove superfluous call Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 02/11] media: cedrus: Add format reset helpers Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 03/11] media: cedrus: use helper to set default formats Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 04/11] media: cedrus: Add helper for checking capabilities Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 05/11] media: cedrus: Filter controls based on capability Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 06/11] media: cedrus: set codec ops immediately Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 07/11] media: cedrus: Remove cedrus_codec enum Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 08/11] media: cedrus: prefer untiled capture format Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 09/11] media: cedrus: initialize controls a bit later Jernej Skrabec
2022-11-02 18:08 ` [PATCH v2 10/11] media: cedrus: Adjust buffer size based on control values Jernej Skrabec
2022-11-04 15:27 ` Hans Verkuil [this message]
2022-11-04 18:10 ` Jernej Škrabec
2022-11-02 18:08 ` [PATCH v2 11/11] media: cedrus: h265: Support decoding 10-bit frames Jernej Skrabec
2022-11-04 15:31 ` [PATCH v2 00/11] media: cedrus: Format handling improvements and 10-bit HEVC support Hans Verkuil
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=76c3fc1b-e90f-748c-39ee-74be93fd6811@xs4all.nl \
--to=hverkuil-cisco@xs4all.nl \
--cc=gregkh@linuxfoundation.org \
--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=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