Skip to content
Snippets Groups Projects
Commit d923ca8a authored by Jonas Karlman's avatar Jonas Karlman Committed by Nicolas Dufresne
Browse files

media: rkvdec: Add get_image_fmt ops


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: default avatarJonas Karlman <jonas@kwiboo.se>
Tested-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Co-developed-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
parent 89362f02
No related branches found
No related tags found
No related merge requests found
...@@ -72,6 +72,15 @@ static bool rkvdec_is_valid_fmt(struct rkvdec_ctx *ctx, u32 fourcc, ...@@ -72,6 +72,15 @@ static bool rkvdec_is_valid_fmt(struct rkvdec_ctx *ctx, u32 fourcc,
return false; return false;
} }
static bool rkvdec_fmt_changed(struct rkvdec_ctx *ctx,
enum rkvdec_image_fmt image_fmt)
{
if (image_fmt == RKVDEC_IMG_FMT_ANY)
return false;
return ctx->image_fmt != image_fmt;
}
static void rkvdec_fill_decoded_pixfmt(struct rkvdec_ctx *ctx, static void rkvdec_fill_decoded_pixfmt(struct rkvdec_ctx *ctx,
struct v4l2_pix_format_mplane *pix_mp) struct v4l2_pix_format_mplane *pix_mp)
{ {
...@@ -118,8 +127,34 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl) ...@@ -118,8 +127,34 @@ static int rkvdec_try_ctrl(struct v4l2_ctrl *ctrl)
return 0; 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;
enum rkvdec_image_fmt image_fmt;
struct vb2_queue *vq;
/* Check if this change requires a capture format reset */
if (!desc->ops->get_image_fmt)
return 0;
image_fmt = desc->ops->get_image_fmt(ctx, ctrl);
if (rkvdec_fmt_changed(ctx, image_fmt)) {
vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
if (vb2_is_busy(vq))
return -EBUSY;
ctx->image_fmt = image_fmt;
rkvdec_reset_decoded_fmt(ctx);
}
return 0;
}
static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = { static const struct v4l2_ctrl_ops rkvdec_ctrl_ops = {
.try_ctrl = rkvdec_try_ctrl, .try_ctrl = rkvdec_try_ctrl,
.s_ctrl = rkvdec_s_ctrl,
}; };
static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = { static const struct rkvdec_ctrl_desc rkvdec_h264_ctrl_descs[] = {
......
...@@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops { ...@@ -73,6 +73,8 @@ struct rkvdec_coded_fmt_ops {
struct vb2_v4l2_buffer *dst_buf, struct vb2_v4l2_buffer *dst_buf,
enum vb2_buffer_state result); enum vb2_buffer_state result);
int (*try_ctrl)(struct rkvdec_ctx *ctx, struct v4l2_ctrl *ctrl); 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 { enum rkvdec_image_fmt {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment