video: driver: Add changes to enable AV1 Decoder

Add definitions, controls and codec-specific handling
to enable AV1 Decoder.

Change-Id: Ica2f4e298e43aa713188d3374f8705688d0ed912
Signed-off-by: Mihir Ganu <quic_mganu@quicinc.com>
This commit is contained in:
Mihir Ganu
2021-12-03 13:27:39 -08:00
父節點 1068661f6d
當前提交 04304a466f
共有 9 個文件被更改,包括 227 次插入20 次删除

查看文件

@@ -154,6 +154,7 @@ enum msm_vidc_codec_type {
MSM_VIDC_HEVC = BIT(1),
MSM_VIDC_VP9 = BIT(2),
MSM_VIDC_HEIC = BIT(3),
MSM_VIDC_AV1 = BIT(4),
};
enum priority_level {
@@ -439,6 +440,7 @@ enum msm_vidc_inst_capability_type {
PROFILE,
LEVEL,
HEVC_TIER,
AV1_TIER,
LF_MODE,
LF_ALPHA,
LF_BETA,
@@ -467,6 +469,8 @@ enum msm_vidc_inst_capability_type {
PRIORITY,
ENC_IP_CR,
DPB_LIST,
FILM_GRAIN,
SUPER_BLOCK,
ALL_INTRA,
META_LTR_MARK_USE,
META_DPB_MISR,
@@ -711,6 +715,8 @@ struct msm_vidc_subscription_params {
u32 profile;
u32 level;
u32 tier;
u32 av1_film_grain_present;
u32 av1_super_block_enabled;
};
struct msm_vidc_hfi_frame_info {

查看文件

@@ -232,6 +232,8 @@ u32 get_hfi_codec(struct msm_vidc_inst *inst)
return HFI_CODEC_DECODE_HEVC;
case MSM_VIDC_VP9:
return HFI_CODEC_DECODE_VP9;
case MSM_VIDC_AV1:
return HFI_CODEC_DECODE_AV1;
default:
i_vpr_e(inst, "invalid codec %d, domain %d\n",
inst->codec, inst->domain);

查看文件

@@ -55,6 +55,18 @@ static const u32 msm_vdec_subscribe_for_psc_vp9[] = {
HFI_PROP_LEVEL,
};
static const u32 msm_vdec_subscribe_for_psc_av1[] = {
HFI_PROP_BITSTREAM_RESOLUTION,
HFI_PROP_CROP_OFFSETS,
HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
HFI_PROP_AV1_FILM_GRAIN_PRESENT,
HFI_PROP_AV1_SUPER_BLOCK_ENABLED,
HFI_PROP_PROFILE,
HFI_PROP_LEVEL,
HFI_PROP_TIER,
};
static const u32 msm_vdec_input_subscribe_for_properties[] = {
HFI_PROP_NO_OUTPUT,
};
@@ -526,6 +538,66 @@ static int msm_vdec_set_tier(struct msm_vidc_inst *inst,
return rc;
}
static int msm_vdec_set_av1_film_grain_present(struct msm_vidc_inst *inst,
enum msm_vidc_port_type port)
{
int rc = 0;
u32 fg_present;
if (port != INPUT_PORT && port != OUTPUT_PORT) {
i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
return -EINVAL;
}
inst->subcr_params[port].av1_film_grain_present =
inst->capabilities->cap[FILM_GRAIN].value;
fg_present = inst->subcr_params[port].av1_film_grain_present;
i_vpr_h(inst, "%s: film grain present: %d", __func__, fg_present);
rc = venus_hfi_session_property(inst,
HFI_PROP_AV1_FILM_GRAIN_PRESENT,
HFI_HOST_FLAGS_NONE,
get_hfi_port(inst, port),
HFI_PAYLOAD_U32_ENUM,
&fg_present,
sizeof(u32));
if (rc) {
i_vpr_e(inst, "%s: set property failed\n", __func__);
return rc;
}
return rc;
}
static int msm_vdec_set_av1_superblock_enabled(struct msm_vidc_inst *inst,
enum msm_vidc_port_type port)
{
int rc = 0;
u32 sb_enabled;
if (port != INPUT_PORT && port != OUTPUT_PORT) {
i_vpr_e(inst, "%s: invalid port %d\n", __func__, port);
return -EINVAL;
}
inst->subcr_params[port].av1_super_block_enabled =
inst->capabilities->cap[SUPER_BLOCK].value;
sb_enabled = inst->subcr_params[port].av1_super_block_enabled;
i_vpr_h(inst, "%s: super block enabled: %d", __func__, sb_enabled);
rc = venus_hfi_session_property(inst,
HFI_PROP_AV1_SUPER_BLOCK_ENABLED,
HFI_HOST_FLAGS_NONE,
get_hfi_port(inst, port),
HFI_PAYLOAD_U32_ENUM,
&sb_enabled,
sizeof(u32));
if (rc) {
i_vpr_e(inst, "%s: set property failed\n", __func__);
return rc;
}
return rc;
}
static int msm_vdec_set_colorformat(struct msm_vidc_inst *inst)
{
int rc = 0;
@@ -921,6 +993,8 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
{HFI_PROP_PROFILE, msm_vdec_set_profile },
{HFI_PROP_LEVEL, msm_vdec_set_level },
{HFI_PROP_TIER, msm_vdec_set_tier },
{HFI_PROP_AV1_FILM_GRAIN_PRESENT, msm_vdec_set_av1_film_grain_present },
{HFI_PROP_AV1_SUPER_BLOCK_ENABLED, msm_vdec_set_av1_superblock_enabled },
};
if (!inst || !inst->core) {
@@ -940,6 +1014,9 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
} else if (inst->codec == MSM_VIDC_VP9) {
subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_vp9);
psc = msm_vdec_subscribe_for_psc_vp9;
} else if (inst->codec == MSM_VIDC_AV1) {
subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_av1);
psc = msm_vdec_subscribe_for_psc_av1;
} else {
i_vpr_e(inst, "%s: unsupported codec: %d\n", __func__, inst->codec);
psc = NULL;
@@ -1324,6 +1401,12 @@ static int msm_vdec_read_input_subcr_params(struct msm_vidc_inst *inst)
msm_vidc_update_cap_value(inst, CODED_FRAMES, CODED_FRAMES_PROGRESSIVE, __func__);
else
msm_vidc_update_cap_value(inst, CODED_FRAMES, CODED_FRAMES_INTERLACE, __func__);
if (inst->codec == MSM_VIDC_AV1) {
msm_vidc_update_cap_value(inst, FILM_GRAIN,
subsc_params.av1_film_grain_present, __func__);
msm_vidc_update_cap_value(inst, SUPER_BLOCK,
subsc_params.av1_super_block_enabled, __func__);
}
return 0;
}
@@ -1547,6 +1630,9 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
} else if (inst->codec == MSM_VIDC_VP9) {
subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_vp9);
psc = msm_vdec_subscribe_for_psc_vp9;
} else if (inst->codec == MSM_VIDC_AV1) {
subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_av1);
psc = msm_vdec_subscribe_for_psc_av1;
} else {
i_vpr_e(inst, "%s: unsupported codec: %d\n", __func__, inst->codec);
psc = NULL;
@@ -1629,6 +1715,16 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
payload_size = sizeof(u32);
payload_type = HFI_PAYLOAD_U32;
break;
case HFI_PROP_AV1_FILM_GRAIN_PRESENT:
payload[0] = subsc_params.av1_film_grain_present;
payload_size = sizeof(u32);
payload_type = HFI_PAYLOAD_U32;
break;
case HFI_PROP_AV1_SUPER_BLOCK_ENABLED:
payload[0] = subsc_params.av1_super_block_enabled;
payload_size = sizeof(u32);
payload_type = HFI_PAYLOAD_U32;
break;
default:
i_vpr_e(inst, "%s: unknown property %#x\n", __func__,
prop_type);

查看文件

@@ -72,6 +72,10 @@ u32 msm_vidc_output_min_count(struct msm_vidc_inst *inst)
case MSM_VIDC_VP9:
output_min_count = 9;
break;
case MSM_VIDC_AV1:
// TODO: needs review
output_min_count = 11;
break;
case MSM_VIDC_HEIC:
output_min_count = 3;
break;
@@ -252,6 +256,7 @@ u32 msm_vidc_decoder_input_size(struct msm_vidc_inst *inst)
/* multiply by 10/8 (1.25) to get size for 10 bit case */
if (f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_VP9 ||
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_AV1 ||
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEVC ||
f->fmt.pix_mp.pixelformat == V4L2_PIX_FMT_HEIC)
frame_size = frame_size + (frame_size >> 2);

查看文件

@@ -3684,9 +3684,12 @@ int msm_vidc_v4l2_to_hfi_enum(struct msm_vidc_inst *inst,
case V4L2_CID_MPEG_VIDEO_HEVC_PROFILE:
case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
case V4L2_CID_MPEG_VIDEO_VP9_PROFILE:
case V4L2_CID_MPEG_VIDEO_AV1_PROFILE:
case V4L2_CID_MPEG_VIDEO_HEVC_LEVEL:
case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
case V4L2_CID_MPEG_VIDEO_AV1_LEVEL:
case V4L2_CID_MPEG_VIDEO_HEVC_TIER:
case V4L2_CID_MPEG_VIDEO_AV1_TIER:
case V4L2_CID_MPEG_VIDC_VIDEO_BLUR_TYPES:
*value = capability->cap[cap_id].value;
return 0;

查看文件

@@ -136,6 +136,7 @@ static const struct msm_vidc_cap_name cap_name_arr[] = {
{PROFILE, "PROFILE" },
{LEVEL, "LEVEL" },
{HEVC_TIER, "HEVC_TIER" },
{AV1_TIER, "AV1_TIER" },
{LF_MODE, "LF_MODE" },
{LF_ALPHA, "LF_ALPHA" },
{LF_BETA, "LF_BETA" },
@@ -362,6 +363,7 @@ const char *v4l2_pixelfmt_name(u32 pixfmt)
case V4L2_PIX_FMT_HEVC: return "HEVC";
case V4L2_PIX_FMT_HEIC: return "HEIC";
case V4L2_PIX_FMT_VP9: return "VP9";
case V4L2_PIX_FMT_AV1: return "AV1";
/* meta port */
case V4L2_META_FMT_VIDC: return "META";
}
@@ -507,6 +509,9 @@ enum msm_vidc_codec_type v4l2_codec_to_driver(u32 v4l2_codec, const char *func)
case V4L2_PIX_FMT_VP9:
codec = MSM_VIDC_VP9;
break;
case V4L2_PIX_FMT_AV1:
codec = MSM_VIDC_AV1;
break;
case V4L2_PIX_FMT_HEIC:
codec = MSM_VIDC_HEIC;
break;
@@ -531,6 +536,9 @@ u32 v4l2_codec_from_driver(enum msm_vidc_codec_type codec, const char *func)
case MSM_VIDC_VP9:
v4l2_codec = V4L2_PIX_FMT_VP9;
break;
case MSM_VIDC_AV1:
v4l2_codec = V4L2_PIX_FMT_AV1;
break;
case MSM_VIDC_HEIC:
v4l2_codec = V4L2_PIX_FMT_HEIC;
break;
@@ -5158,6 +5166,7 @@ static const char *get_codec_str(enum msm_vidc_codec_type type)
case MSM_VIDC_H264: return "h264";
case MSM_VIDC_HEVC: return "h265";
case MSM_VIDC_VP9: return " vp9";
case MSM_VIDC_AV1: return " av1";
case MSM_VIDC_HEIC: return "heic";
}

查看文件

@@ -47,14 +47,15 @@ void print_psc_properties(const char *str, struct msm_vidc_inst *inst,
i_vpr_h(inst,
"%s: width %d, height %d, crop offsets[0] %#x, crop offsets[1] %#x, bit depth %#x, coded frames %d "
"fw min count %d, poc %d, color info %d, profile %d, level %d, tier %d\n",
"fw min count %d, poc %d, color info %d, profile %d, level %d, tier %d, fg present %d, sb enabled %d\n",
str, (subsc_params.bitstream_resolution & HFI_BITMASK_BITSTREAM_WIDTH) >> 16,
(subsc_params.bitstream_resolution & HFI_BITMASK_BITSTREAM_HEIGHT),
subsc_params.crop_offsets[0], subsc_params.crop_offsets[1],
subsc_params.bit_depth, subsc_params.coded_frames,
subsc_params.fw_min_count, subsc_params.pic_order_cnt,
subsc_params.color_info, subsc_params.profile, subsc_params.level,
subsc_params.tier);
subsc_params.tier, subsc_params.av1_film_grain_present,
subsc_params.av1_super_block_enabled);
}
static void print_sfr_message(struct msm_vidc_core *core)
@@ -574,7 +575,7 @@ static int get_driver_buffer_flags(struct msm_vidc_inst *inst, u32 hfi_flags)
} else if (inst->hfi_frame_info.picture_type & HFI_PICTURE_B) {
driver_flags |= MSM_VIDC_BUF_FLAG_BFRAME;
} else if (inst->hfi_frame_info.picture_type & HFI_PICTURE_I) {
if (inst->codec == MSM_VIDC_VP9)
if (inst->codec == MSM_VIDC_VP9 || inst->codec == MSM_VIDC_AV1)
driver_flags |= MSM_VIDC_BUF_FLAG_KEYFRAME;
} else if (inst->hfi_frame_info.picture_type & HFI_PICTURE_CRA) {
driver_flags |= MSM_VIDC_BUF_FLAG_KEYFRAME;
@@ -1387,6 +1388,12 @@ static int handle_session_property(struct msm_vidc_inst *inst,
case HFI_PROP_TIER:
inst->subcr_params[port].tier = payload_ptr[0];
break;
case HFI_PROP_AV1_FILM_GRAIN_PRESENT:
inst->subcr_params[port].av1_film_grain_present = payload_ptr[0];
break;
case HFI_PROP_AV1_SUPER_BLOCK_ENABLED:
inst->subcr_params[port].av1_super_block_enabled = payload_ptr[0];
break;
case HFI_PROP_PICTURE_TYPE:
inst->hfi_frame_info.picture_type = payload_ptr[0];
if (inst->hfi_frame_info.picture_type & HFI_PICTURE_B)