From: Jonas Karlman <jonas@kwiboo.se>
To: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: Alex Bee <knaerzche@gmail.com>,
Nicolas Dufresne <nicolas.dufresne@collabora.com>,
Benjamin Gaignard <benjamin.gaignard@collabora.com>,
Sebastian Fricke <sebastian.fricke@collabora.com>,
Christopher Obbard <chris.obbard@collabora.com>,
linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Jonas Karlman <jonas@kwiboo.se>
Subject: [PATCH v4 10/11] media: rkvdec: Add get_image_fmt ops
Date: Sun, 5 Nov 2023 16:55:09 +0000 [thread overview]
Message-ID: <20231105165521.3592037-11-jonas@kwiboo.se> (raw)
In-Reply-To: <20231105165521.3592037-1-jonas@kwiboo.se>
Add support for a get_image_fmt() ops that return the required image
format.
The CAPTURE format is reset when required image format changes and the
buffer queue is not busy.
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
v4:
- Change fmt_opaque into an image format
- Split patch into two
v3:
- New patch
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 5949d59d4cf9..225aa1f0ac48 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -108,15 +108,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;
+
+ 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;
+
+ 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 6f8cf50c5d99..e466a2753ccf 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 {
--
2.42.0
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2023-11-05 16:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-05 16:54 [PATCH v4 00/11] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Jonas Karlman
2023-11-05 16:55 ` [PATCH v4 01/11] media: v4l2-common: Add helpers to calculate bytesperline and sizeimage Jonas Karlman
2023-11-08 2:45 ` Nicolas Dufresne
2023-11-09 22:42 ` Jonas Karlman
2023-11-05 16:55 ` [PATCH v4 02/11] media: v4l2: Add NV15 and NV20 pixel formats Jonas Karlman
2023-11-08 2:52 ` Nicolas Dufresne
2023-11-09 22:47 ` Jonas Karlman
2023-11-05 16:55 ` [PATCH v4 03/11] media: rkvdec: h264: Use bytesperline and buffer height as virstride Jonas Karlman
2023-11-07 21:45 ` Nicolas Dufresne
2023-11-05 16:55 ` [PATCH v4 04/11] media: rkvdec: h264: Don't hardcode SPS/PPS parameters Jonas Karlman
2023-11-07 21:47 ` Nicolas Dufresne
2023-11-05 16:55 ` [PATCH v4 05/11] media: rkvdec: h264: Remove SPS validation at streaming start Jonas Karlman
2023-11-07 22:01 ` Nicolas Dufresne
2023-11-07 22:56 ` Jonas Karlman
2023-11-08 2:39 ` Nicolas Dufresne
2023-11-09 18:07 ` Jonas Karlman
2023-11-05 16:55 ` [PATCH v4 06/11] media: rkvdec: Extract rkvdec_fill_decoded_pixfmt into helper Jonas Karlman
2023-11-07 22:04 ` Nicolas Dufresne
2023-11-05 16:55 ` [PATCH v4 07/11] media: rkvdec: Move rkvdec_reset_decoded_fmt helper Jonas Karlman
2023-11-08 1:42 ` Nicolas Dufresne
2023-11-05 16:55 ` [PATCH v4 08/11] media: rkvdec: Extract decoded format enumeration into helper Jonas Karlman
2023-11-08 1:50 ` Nicolas Dufresne
2023-11-05 16:55 ` [PATCH v4 09/11] media: rkvdec: Add image format concept Jonas Karlman
2023-11-05 16:55 ` Jonas Karlman [this message]
2023-11-05 16:55 ` [PATCH v4 11/11] media: rkvdec: h264: Support High 10 and 4:2:2 profiles Jonas Karlman
2023-11-08 2:20 ` Nicolas Dufresne
2023-11-09 18:25 ` Jonas Karlman
2023-11-07 21:43 ` [PATCH v4 00/11] media: rkvdec: Add H.264 High 10 and 4:2:2 profile support Nicolas Dufresne
2023-11-09 17:51 ` Jonas Karlman
2024-01-08 9:54 ` Christopher Obbard
2024-06-16 9:47 ` Diederik de Haas
2024-06-17 13:43 ` 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=20231105165521.3592037-11-jonas@kwiboo.se \
--to=jonas@kwiboo.se \
--cc=benjamin.gaignard@collabora.com \
--cc=chris.obbard@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=gregkh@linuxfoundation.org \
--cc=hverkuil-cisco@xs4all.nl \
--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@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