[PATCH v2 07/12] staging: media: rkvdec: Add a routine to fetch SPS attributes as a callback
Sebastian Fricke
sebastian.fricke at collabora.com
Thu Jan 12 04:56:22 PST 2023
Add a callback for each codec variant, that fetches basic information
like resolution, bit-depth and sub-sampling from a SPS structure. This
data is used to verify whether a new SPS structure is valid.
Signed-off-by: Sebastian Fricke <sebastian.fricke at collabora.com>
---
drivers/staging/media/rkvdec/rkvdec.c | 10 ++++++++++
drivers/staging/media/rkvdec/rkvdec.h | 10 ++++++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c
index a46f918926a2..e8c750a7343a 100644
--- a/drivers/staging/media/rkvdec/rkvdec.c
+++ b/drivers/staging/media/rkvdec/rkvdec.c
@@ -52,6 +52,16 @@ static int rkvdec_get_valid_fmt(struct rkvdec_ctx *ctx)
return ctx->coded_fmt_desc->decoded_fmts[0];
}
+static int rkvdec_get_sps_attributes(struct rkvdec_ctx *ctx, void *sps,
+ struct sps_attributes *attributes)
+{
+ const struct rkvdec_coded_fmt_desc *coded_desc = ctx->coded_fmt_desc;
+
+ if (coded_desc->ops->get_sps_attributes)
+ return coded_desc->ops->get_sps_attributes(ctx, sps, attributes);
+ return 0;
+}
+
static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
{
struct rkvdec_ctx *ctx = container_of(ctrl->handler, struct rkvdec_ctx, ctrl_hdl);
diff --git a/drivers/staging/media/rkvdec/rkvdec.h b/drivers/staging/media/rkvdec/rkvdec.h
index e353a4403e5b..7b6702c360fd 100644
--- a/drivers/staging/media/rkvdec/rkvdec.h
+++ b/drivers/staging/media/rkvdec/rkvdec.h
@@ -63,10 +63,20 @@ vb2_to_rkvdec_decoded_buf(struct vb2_buffer *buf)
base.vb.vb2_buf);
}
+struct sps_attributes {
+ unsigned int width;
+ unsigned int height;
+ unsigned int luma_bitdepth;
+ unsigned int chroma_bitdepth;
+ unsigned int subsampling;
+};
+
struct rkvdec_coded_fmt_ops {
int (*adjust_fmt)(struct rkvdec_ctx *ctx,
struct v4l2_format *f);
u32 (*valid_fmt)(struct rkvdec_ctx *ctx);
+ int (*get_sps_attributes)(struct rkvdec_ctx *ctx, void *sps,
+ struct sps_attributes *attributes);
int (*start)(struct rkvdec_ctx *ctx);
void (*stop)(struct rkvdec_ctx *ctx);
int (*run)(struct rkvdec_ctx *ctx);
--
2.25.1
More information about the Linux-rockchip
mailing list