media: coda: add decoder MPEG-2 profile and level controls
The MPEG-2 decoder firmware reports profile and level indication that can be used to set V4L2 MPEG-2 profile and level controls Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
5902bca94a
commit
8a8621ba01
|
@ -1,6 +1,6 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
coda-objs := coda-common.o coda-bit.o coda-gdi.o coda-h264.o coda-mpeg4.o coda-jpeg.o
|
coda-objs := coda-common.o coda-bit.o coda-gdi.o coda-h264.o coda-mpeg2.o coda-mpeg4.o coda-jpeg.o
|
||||||
|
|
||||||
obj-$(CONFIG_VIDEO_CODA) += coda.o
|
obj-$(CONFIG_VIDEO_CODA) += coda.o
|
||||||
obj-$(CONFIG_VIDEO_IMX_VDOA) += imx-vdoa.o
|
obj-$(CONFIG_VIDEO_IMX_VDOA) += imx-vdoa.o
|
||||||
|
|
|
@ -1590,6 +1590,15 @@ void coda_update_profile_level_ctrls(struct coda_ctx *ctx, u8 profile_idc,
|
||||||
profile = coda_h264_profile(profile_idc);
|
profile = coda_h264_profile(profile_idc);
|
||||||
level = coda_h264_level(level_idc);
|
level = coda_h264_level(level_idc);
|
||||||
break;
|
break;
|
||||||
|
case V4L2_PIX_FMT_MPEG2:
|
||||||
|
codec_name = "MPEG-2";
|
||||||
|
profile_cid = V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE;
|
||||||
|
level_cid = V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL;
|
||||||
|
profile_ctrl = ctx->mpeg2_profile_ctrl;
|
||||||
|
level_ctrl = ctx->mpeg2_level_ctrl;
|
||||||
|
profile = coda_mpeg2_profile(profile_idc);
|
||||||
|
level = coda_mpeg2_level(level_idc);
|
||||||
|
break;
|
||||||
case V4L2_PIX_FMT_MPEG4:
|
case V4L2_PIX_FMT_MPEG4:
|
||||||
codec_name = "MPEG-4";
|
codec_name = "MPEG-4";
|
||||||
profile_cid = V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE;
|
profile_cid = V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE;
|
||||||
|
@ -1949,6 +1958,8 @@ static int coda_s_ctrl(struct v4l2_ctrl *ctrl)
|
||||||
case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP:
|
case V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP:
|
||||||
ctx->params.mpeg4_inter_qp = ctrl->val;
|
ctx->params.mpeg4_inter_qp = ctrl->val;
|
||||||
break;
|
break;
|
||||||
|
case V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE:
|
||||||
|
case V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL:
|
||||||
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
|
case V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE:
|
||||||
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
|
case V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL:
|
||||||
/* nothing to do, these are fixed */
|
/* nothing to do, these are fixed */
|
||||||
|
@ -2129,6 +2140,20 @@ static void coda_decode_ctrls(struct coda_ctx *ctx)
|
||||||
if (ctx->h264_level_ctrl)
|
if (ctx->h264_level_ctrl)
|
||||||
ctx->h264_level_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
ctx->h264_level_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
||||||
|
|
||||||
|
ctx->mpeg2_profile_ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrls,
|
||||||
|
&coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE,
|
||||||
|
V4L2_MPEG_VIDEO_MPEG2_PROFILE_HIGH, 0,
|
||||||
|
V4L2_MPEG_VIDEO_MPEG2_PROFILE_HIGH);
|
||||||
|
if (ctx->mpeg2_profile_ctrl)
|
||||||
|
ctx->mpeg2_profile_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
||||||
|
|
||||||
|
ctx->mpeg2_level_ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrls,
|
||||||
|
&coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL,
|
||||||
|
V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH, 0,
|
||||||
|
V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH);
|
||||||
|
if (ctx->mpeg2_level_ctrl)
|
||||||
|
ctx->mpeg2_level_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
||||||
|
|
||||||
ctx->mpeg4_profile_ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrls,
|
ctx->mpeg4_profile_ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrls,
|
||||||
&coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE,
|
&coda_ctrl_ops, V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE,
|
||||||
V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY, 0,
|
V4L2_MPEG_VIDEO_MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY, 0,
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
/*
|
||||||
|
* Coda multi-standard codec IP - MPEG-2 helper functions
|
||||||
|
*
|
||||||
|
* Copyright (C) 2019 Pengutronix, Philipp Zabel
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/videodev2.h>
|
||||||
|
#include "coda.h"
|
||||||
|
|
||||||
|
int coda_mpeg2_profile(int profile_idc)
|
||||||
|
{
|
||||||
|
switch (profile_idc) {
|
||||||
|
case 5:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_PROFILE_SIMPLE;
|
||||||
|
case 4:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_PROFILE_MAIN;
|
||||||
|
case 3:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_PROFILE_SNR_SCALABLE;
|
||||||
|
case 2:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_PROFILE_SPATIALLY_SCALABLE;
|
||||||
|
case 1:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_PROFILE_HIGH;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int coda_mpeg2_level(int level_idc)
|
||||||
|
{
|
||||||
|
switch (level_idc) {
|
||||||
|
case 10:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_LEVEL_LOW;
|
||||||
|
case 8:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_LEVEL_MAIN;
|
||||||
|
case 6:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH_1440;
|
||||||
|
case 4:
|
||||||
|
return V4L2_MPEG_VIDEO_MPEG2_LEVEL_HIGH;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
|
@ -122,6 +122,8 @@ struct coda_params {
|
||||||
s8 h264_chroma_qp_index_offset;
|
s8 h264_chroma_qp_index_offset;
|
||||||
u8 h264_profile_idc;
|
u8 h264_profile_idc;
|
||||||
u8 h264_level_idc;
|
u8 h264_level_idc;
|
||||||
|
u8 mpeg2_profile_idc;
|
||||||
|
u8 mpeg2_level_idc;
|
||||||
u8 mpeg4_intra_qp;
|
u8 mpeg4_intra_qp;
|
||||||
u8 mpeg4_inter_qp;
|
u8 mpeg4_inter_qp;
|
||||||
u8 gop_size;
|
u8 gop_size;
|
||||||
|
@ -217,6 +219,8 @@ struct coda_ctx {
|
||||||
struct v4l2_ctrl_handler ctrls;
|
struct v4l2_ctrl_handler ctrls;
|
||||||
struct v4l2_ctrl *h264_profile_ctrl;
|
struct v4l2_ctrl *h264_profile_ctrl;
|
||||||
struct v4l2_ctrl *h264_level_ctrl;
|
struct v4l2_ctrl *h264_level_ctrl;
|
||||||
|
struct v4l2_ctrl *mpeg2_profile_ctrl;
|
||||||
|
struct v4l2_ctrl *mpeg2_level_ctrl;
|
||||||
struct v4l2_ctrl *mpeg4_profile_ctrl;
|
struct v4l2_ctrl *mpeg4_profile_ctrl;
|
||||||
struct v4l2_ctrl *mpeg4_level_ctrl;
|
struct v4l2_ctrl *mpeg4_level_ctrl;
|
||||||
struct v4l2_fh fh;
|
struct v4l2_fh fh;
|
||||||
|
@ -330,6 +334,8 @@ int coda_sps_parse_profile(struct coda_ctx *ctx, struct vb2_buffer *vb);
|
||||||
int coda_h264_sps_fixup(struct coda_ctx *ctx, int width, int height, char *buf,
|
int coda_h264_sps_fixup(struct coda_ctx *ctx, int width, int height, char *buf,
|
||||||
int *size, int max_size);
|
int *size, int max_size);
|
||||||
|
|
||||||
|
int coda_mpeg2_profile(int profile_idc);
|
||||||
|
int coda_mpeg2_level(int level_idc);
|
||||||
int coda_mpeg4_profile(int profile_idc);
|
int coda_mpeg4_profile(int profile_idc);
|
||||||
int coda_mpeg4_level(int level_idc);
|
int coda_mpeg4_level(int level_idc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue