public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Sebastian Fricke <sebastian.fricke@collabora.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Boris Brezillon <boris.brezillon@collabora.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	linux-staging@lists.linux.dev,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Alex Bee <knaerzche@gmail.com>,
	Nicolas Dufresne <nicolas.dufresne@collabora.com>,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	Detlev Casanova <detlev.casanova@collabora.com>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Jonas Karlman <jonas@kwiboo.se>,
	Christopher Obbard <christopher.obbard@linaro.org>
Subject: Re: [PATCH v7 09/12] media: rkvdec: Add get_image_fmt ops
Date: Mon, 7 Apr 2025 13:09:07 +0200	[thread overview]
Message-ID: <e6b99109-bd35-46ff-a4e2-eb69b549dcbc@xs4all.nl> (raw)
In-Reply-To: <20250225-rkvdec_h264_high10_and_422_support-v7-9-7992a68a4910@collabora.com>

On 25/02/2025 10:40, Sebastian Fricke wrote:
> From: Jonas Karlman <jonas@kwiboo.se>
> 
> Add support for a get_image_fmt() ops that returns the required image
> format.
> 
> The CAPTURE format is reset when the required image format changes and
> the buffer queue is not busy.
> 
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Christopher Obbard <chris.obbard@collabora.com>
> ---
>  drivers/staging/media/rkvdec/rkvdec.c | 49 +++++++++++++++++++++++++++++++++--
>  drivers/staging/media/rkvdec/rkvdec.h |  2 ++
>  2 files changed, 49 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
> index 70154948b4e32e2c439f259b0f1e1bbc8b52b063..5394079509305c619f1d0c1f542bfc409317c3b7 100644
> --- a/drivers/staging/media/rkvdec/rkvdec.c
> +++ b/drivers/staging/media/rkvdec/rkvdec.c
> @@ -111,15 +111,60 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
>  {
>  	struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
>  	const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
> +	struct v4l2_pix_format_mplane *pix_mp = &ctx->decoded_fmt.fmt.pix_mp;
> +	enum rkvdec_image_fmt image_fmt;
> +	struct vb2_queue *vq;
> +	int ret;
> +
> +	if (desc->ops->try_ctrl) {
> +		ret = desc->ops->try_ctrl(ctx, ctrl);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	if (!desc->ops->get_image_fmt)
> +		return 0;
>  
> -	if (desc->ops->try_ctrl)
> -		return desc->ops->try_ctrl(ctx, ctrl);
> +	image_fmt = desc->ops->get_image_fmt(ctx, ctrl);
> +	if (ctx->image_fmt == image_fmt)
> +		return 0;
> +
> +	if (rkvdec_is_valid_fmt(ctx, pix_mp->pixelformat, image_fmt))
> +		return 0;
> +
> +	/* format change not allowed when queue is busy */
> +	vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
> +			     V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
> +	if (vb2_is_busy(vq))
> +		return -EINVAL;

This makes no sense to me. This just tries a control, and that should just
work, regardless of vb2_is_busy(). It's a 'try', so you are not actually
changing anything.

> +
> +	return 0;
> +}
> +
> +static int rkvdec_s_ctrl(struct v4l2_ctrl *ctrl)
> +{
> +	struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
> +	const struct rkvdec_coded_fmt_desc *desc = ctx->coded_fmt_desc;
> +	struct v4l2_pix_format_mplane *pix_mp = &ctx->decoded_fmt.fmt.pix_mp;
> +	enum rkvdec_image_fmt image_fmt;
> +
> +	if (!desc->ops->get_image_fmt)
> +		return 0;
> +
> +	image_fmt = desc->ops->get_image_fmt(ctx, ctrl);
> +	if (ctx->image_fmt == image_fmt)
> +		return 0;

If you really can't set a control when the queue is busy, then that should
be tested here, not in try_ctrl. And then you return -EBUSY.

Am I missing something here?

Regards,

	Hans

> +
> +	ctx->image_fmt = image_fmt;
> +	if (!rkvdec_is_valid_fmt(ctx, pix_mp->pixelformat, ctx->image_fmt))
> +		rkvdec_reset_decoded_fmt(ctx);
>  
>  	return 0;
>  }
>  
>  static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
>  	.try_ctrl = rkvdec_try_ctrl,
> +	.s_ctrl = rkvdec_s_ctrl,
>  };
>  
>  static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
> diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h
> index 6f8cf50c5d99aad2f52e321f54f3ca17166ddf98..e466a2753ccfc13738e0a672bc578e521af2c3f2 100644
> --- a/drivers/staging/media/rkvdec/rkvdec.h
> +++ b/drivers/staging/media/rkvdec/rkvdec.h
> @@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops {
>  		     struct vb2_v4l2_buffer *dst_buf,
>  		     enum vb2_buffer_state result);
>  	int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl);
> +	enum rkvdec_image_fmt (*get_image_fmt)(struct rkvdec_ctx *ctx,
> +					       struct v4l2_ctrl *ctrl);
>  };
>  
>  enum rkvdec_image_fmt {
> 


  reply	other threads:[~2025-04-07 11:09 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-25  9:40 [PATCH v7 00/12] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 01/12] media: v4l2-common: Add helpers to calculate bytesperline and sizeimage Sebastian Fricke
2025-02-25 12:51   ` Hans Verkuil
2025-02-25  9:40 ` [PATCH v7 02/12] media: v4l2: Add NV15 and NV20 pixel formats Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 03/12] media: rkvdec: h264: Use bytesperline and buffer height as virstride Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 04/12] media: rkvdec: h264: Don't hardcode SPS/PPS parameters Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 05/12] media: rkvdec: Extract rkvdec_fill_decoded_pixfmt into helper Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 06/12] media: rkvdec: Move rkvdec_reset_decoded_fmt helper Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 07/12] media: rkvdec: Extract decoded format enumeration into helper Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 08/12] media: rkvdec: Add image format concept Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 09/12] media: rkvdec: Add get_image_fmt ops Sebastian Fricke
2025-04-07 11:09   ` Hans Verkuil [this message]
2025-04-07 13:52     ` Nicolas Dufresne
2025-04-07 14:17       ` Hans Verkuil
2025-04-07 14:59         ` Nicolas Dufresne
2025-04-07 15:07           ` Jonas Karlman
2025-04-07 15:33             ` Jonas Karlman
2025-04-07 15:35             ` Nicolas Dufresne
2025-04-07 15:44               ` Jonas Karlman
2025-04-08  8:28           ` Hans Verkuil
2025-04-08 13:36             ` Nicolas Dufresne
2025-04-08 14:32               ` Hans Verkuil
2025-04-08 17:01                 ` Jonas Karlman
2025-04-08 17:13                 ` Nicolas Dufresne
2025-02-25  9:40 ` [PATCH v7 10/12] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 11/12] media: rkvdec: h264: Limit minimum profile to constrained baseline Sebastian Fricke
2025-02-25  9:40 ` [PATCH v7 12/12] media: rkvdec: Fix frame size enumeration Sebastian Fricke
2025-02-25 12:40 ` [PATCH] fixup! media: v4l2-common: Add helpers to calculate bytesperline and sizeimage Sebastian Fricke
2025-02-25 12:46   ` Sebastian Fricke
2025-02-25 12:50     ` Hans Verkuil
2025-02-25 14:05       ` Nicolas Dufresne

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=e6b99109-bd35-46ff-a4e2-eb69b549dcbc@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=benjamin.gaignard@collabora.com \
    --cc=boris.brezillon@collabora.com \
    --cc=christopher.obbard@linaro.org \
    --cc=dan.carpenter@linaro.org \
    --cc=detlev.casanova@collabora.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonas@kwiboo.se \
    --cc=knaerzche@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab+huawei@kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=sebastian.fricke@collabora.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