浏览代码

video: driver: move DPB_LIST to input port

1. Move DPB_LIST subscription on input
port instead of output port.

2. Move decoder port PSC and properties
to platform data.

Change-Id: I5711e0ba915ebe4136f64d1440ae331b787f4d61
Signed-off-by: Zhongbo Shi <[email protected]>
Zhongbo Shi 2 年之前
父节点
当前提交
133bfb56ea

+ 12 - 0
driver/platform/common/inc/msm_vidc_platform.h

@@ -240,6 +240,18 @@ struct msm_vidc_platform_data {
 	unsigned int efuse_data_size;
 	unsigned int sku_version;
 	struct msm_vidc_format_capability *format_data;
+	const u32 *psc_avc_tbl;
+	unsigned int psc_avc_tbl_size;
+	const u32 *psc_hevc_tbl;
+	unsigned int psc_hevc_tbl_size;
+	const u32 *psc_vp9_tbl;
+	unsigned int psc_vp9_tbl_size;
+	const u32 *psc_av1_tbl;
+	unsigned int psc_av1_tbl_size;
+	const u32 *dec_input_prop;
+	unsigned int dec_input_prop_size;
+	const u32 *dec_output_prop;
+	unsigned int dec_output_prop_size;
 };
 
 struct msm_vidc_platform {

+ 73 - 0
driver/platform/kalama/src/msm_vidc_kalama.c

@@ -2561,6 +2561,65 @@ static const struct reg_preset_table kalama_reg_preset_table[] = {
 	{ 0xB0088, 0x0, 0x11 },
 };
 
+/* decoder properties */
+static const u32 kalama_vdec_psc_avc[] = {
+	HFI_PROP_BITSTREAM_RESOLUTION,
+	HFI_PROP_CROP_OFFSETS,
+	HFI_PROP_CODED_FRAMES,
+	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
+	HFI_PROP_PIC_ORDER_CNT_TYPE,
+	HFI_PROP_PROFILE,
+	HFI_PROP_LEVEL,
+	HFI_PROP_SIGNAL_COLOR_INFO,
+};
+
+static const u32 kalama_vdec_psc_hevc[] = {
+	HFI_PROP_BITSTREAM_RESOLUTION,
+	HFI_PROP_CROP_OFFSETS,
+	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
+	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
+	HFI_PROP_PROFILE,
+	HFI_PROP_LEVEL,
+	HFI_PROP_TIER,
+	HFI_PROP_SIGNAL_COLOR_INFO,
+};
+
+static const u32 kalama_vdec_psc_vp9[] = {
+	HFI_PROP_BITSTREAM_RESOLUTION,
+	HFI_PROP_CROP_OFFSETS,
+	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
+	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
+	HFI_PROP_PROFILE,
+	HFI_PROP_LEVEL,
+};
+
+static const u32 kalama_vdec_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,
+	HFI_PROP_SIGNAL_COLOR_INFO,
+};
+
+static const u32 kalama_vdec_input_properties[] = {
+	HFI_PROP_NO_OUTPUT,
+	HFI_PROP_SUBFRAME_INPUT,
+};
+
+static const u32 kalama_vdec_output_properties[] = {
+	HFI_PROP_WORST_COMPRESSION_RATIO,
+	HFI_PROP_WORST_COMPLEXITY_FACTOR,
+	HFI_PROP_PICTURE_TYPE,
+	HFI_PROP_DPB_LIST,
+	HFI_PROP_CABAC_SESSION,
+	HFI_PROP_FENCE,
+};
+
 static const struct msm_vidc_platform_data kalama_data = {
 	/* resources dependent on other module */
 	.bw_tbl = kalama_bw_table,
@@ -2599,6 +2658,20 @@ static const struct msm_vidc_platform_data kalama_data = {
 	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
 	.ubwc_config = ubwc_config_kalama,
 	.format_data = &format_data_kalama,
+
+	/* decoder properties related*/
+	.psc_avc_tbl = kalama_vdec_psc_avc,
+	.psc_avc_tbl_size = ARRAY_SIZE(kalama_vdec_psc_avc),
+	.psc_hevc_tbl = kalama_vdec_psc_hevc,
+	.psc_hevc_tbl_size = ARRAY_SIZE(kalama_vdec_psc_hevc),
+	.psc_vp9_tbl = kalama_vdec_psc_vp9,
+	.psc_vp9_tbl_size = ARRAY_SIZE(kalama_vdec_psc_vp9),
+	.psc_av1_tbl = kalama_vdec_psc_av1,
+	.psc_av1_tbl_size = ARRAY_SIZE(kalama_vdec_psc_av1),
+	.dec_input_prop = kalama_vdec_input_properties,
+	.dec_input_prop_size = ARRAY_SIZE(kalama_vdec_input_properties),
+	.dec_output_prop = kalama_vdec_output_properties,
+	.dec_output_prop_size = ARRAY_SIZE(kalama_vdec_output_properties),
 };
 
 static const struct msm_vidc_platform_data kalama_data_v2 = {

+ 74 - 1
driver/platform/pineapple/src/msm_vidc_pineapple.c

@@ -1635,7 +1635,7 @@ static struct msm_platform_inst_capability instance_cap_data_pineapple[] = {
 		0, 1, 1, 0,
 		0,
 		HFI_PROP_DPB_LIST,
-		CAP_FLAG_OUTPUT_PORT},
+		CAP_FLAG_INPUT_PORT},
 
 	{FILM_GRAIN, DEC, AV1,
 		0, 1, 1, 0,
@@ -2607,6 +2607,65 @@ static const struct device_region_table pineapple_device_region_table[] = {
 	{ "aon-registers", 0x0AAE0000, 0x1000, 0xFFAE0000, MSM_VIDC_AON_REGISTERS },
 };
 
+/* decoder properties */
+static const u32 pineapple_vdec_psc_avc[] = {
+	HFI_PROP_BITSTREAM_RESOLUTION,
+	HFI_PROP_CROP_OFFSETS,
+	HFI_PROP_CODED_FRAMES,
+	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
+	HFI_PROP_PIC_ORDER_CNT_TYPE,
+	HFI_PROP_PROFILE,
+	HFI_PROP_LEVEL,
+	HFI_PROP_SIGNAL_COLOR_INFO,
+};
+
+static const u32 pineapple_vdec_psc_hevc[] = {
+	HFI_PROP_BITSTREAM_RESOLUTION,
+	HFI_PROP_CROP_OFFSETS,
+	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
+	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
+	HFI_PROP_PROFILE,
+	HFI_PROP_LEVEL,
+	HFI_PROP_TIER,
+	HFI_PROP_SIGNAL_COLOR_INFO,
+};
+
+static const u32 pineapple_vdec_psc_vp9[] = {
+	HFI_PROP_BITSTREAM_RESOLUTION,
+	HFI_PROP_CROP_OFFSETS,
+	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
+	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
+	HFI_PROP_PROFILE,
+	HFI_PROP_LEVEL,
+};
+
+static const u32 pineapple_vdec_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,
+	HFI_PROP_SIGNAL_COLOR_INFO,
+};
+
+static const u32 pineapple_vdec_input_properties[] = {
+	HFI_PROP_NO_OUTPUT,
+	HFI_PROP_SUBFRAME_INPUT,
+	HFI_PROP_DPB_LIST,
+};
+
+static const u32 pineapple_vdec_output_properties[] = {
+	HFI_PROP_WORST_COMPRESSION_RATIO,
+	HFI_PROP_WORST_COMPLEXITY_FACTOR,
+	HFI_PROP_PICTURE_TYPE,
+	HFI_PROP_CABAC_SESSION,
+	HFI_PROP_FENCE,
+};
+
 static const struct msm_vidc_platform_data pineapple_data = {
 	/* resources dependent on other module */
 	.bw_tbl = pineapple_bw_table,
@@ -2647,6 +2706,20 @@ static const struct msm_vidc_platform_data pineapple_data = {
 	.csc_data.vpe_csc_custom_limit_coeff = vpe_csc_custom_limit_coeff,
 	.ubwc_config = ubwc_config_pineapple,
 	.format_data = &format_data_pineapple,
+
+	/* decoder properties related*/
+	.psc_avc_tbl = pineapple_vdec_psc_avc,
+	.psc_avc_tbl_size = ARRAY_SIZE(pineapple_vdec_psc_avc),
+	.psc_hevc_tbl = pineapple_vdec_psc_hevc,
+	.psc_hevc_tbl_size = ARRAY_SIZE(pineapple_vdec_psc_hevc),
+	.psc_vp9_tbl = pineapple_vdec_psc_vp9,
+	.psc_vp9_tbl_size = ARRAY_SIZE(pineapple_vdec_psc_vp9),
+	.psc_av1_tbl = pineapple_vdec_psc_av1,
+	.psc_av1_tbl_size = ARRAY_SIZE(pineapple_vdec_psc_av1),
+	.dec_input_prop = pineapple_vdec_input_properties,
+	.dec_input_prop_size = ARRAY_SIZE(pineapple_vdec_input_properties),
+	.dec_output_prop = pineapple_vdec_output_properties,
+	.dec_output_prop_size = ARRAY_SIZE(pineapple_vdec_output_properties),
 };
 
 int msm_vidc_pineapple_check_ddr_type(void)

+ 1 - 0
driver/vidc/inc/msm_vidc_internal.h

@@ -772,6 +772,7 @@ struct msm_vidc_subscription_params {
 	u32                    tier;
 	u32                    av1_film_grain_present;
 	u32                    av1_super_block_enabled;
+	u32                    dpb_list_enabled;
 };
 
 struct msm_vidc_hfi_frame_info {

+ 79 - 84
driver/vidc/src/msm_vdec.c

@@ -24,64 +24,6 @@
 #define MAX_DEC_BATCH_SIZE 6
 #define SKIP_BATCH_WINDOW 100
 
-static const u32 msm_vdec_subscribe_for_psc_avc[] = {
-	HFI_PROP_BITSTREAM_RESOLUTION,
-	HFI_PROP_CROP_OFFSETS,
-	HFI_PROP_CODED_FRAMES,
-	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
-	HFI_PROP_PIC_ORDER_CNT_TYPE,
-	HFI_PROP_PROFILE,
-	HFI_PROP_LEVEL,
-	HFI_PROP_SIGNAL_COLOR_INFO,
-};
-
-static const u32 msm_vdec_subscribe_for_psc_hevc[] = {
-	HFI_PROP_BITSTREAM_RESOLUTION,
-	HFI_PROP_CROP_OFFSETS,
-	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
-	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
-	HFI_PROP_PROFILE,
-	HFI_PROP_LEVEL,
-	HFI_PROP_TIER,
-	HFI_PROP_SIGNAL_COLOR_INFO,
-};
-
-static const u32 msm_vdec_subscribe_for_psc_vp9[] = {
-	HFI_PROP_BITSTREAM_RESOLUTION,
-	HFI_PROP_CROP_OFFSETS,
-	HFI_PROP_LUMA_CHROMA_BIT_DEPTH,
-	HFI_PROP_BUFFER_FW_MIN_OUTPUT_COUNT,
-	HFI_PROP_PROFILE,
-	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,
-	HFI_PROP_SIGNAL_COLOR_INFO,
-};
-
-static const u32 msm_vdec_input_subscribe_for_properties[] = {
-	HFI_PROP_NO_OUTPUT,
-	HFI_PROP_SUBFRAME_INPUT,
-};
-
-static const u32 msm_vdec_output_subscribe_for_properties[] = {
-	HFI_PROP_WORST_COMPRESSION_RATIO,
-	HFI_PROP_WORST_COMPLEXITY_FACTOR,
-	HFI_PROP_PICTURE_TYPE,
-	HFI_PROP_DPB_LIST,
-	HFI_PROP_CABAC_SESSION,
-	HFI_PROP_FENCE,
-};
-
 static const u32 msm_vdec_internal_buffer_type[] = {
 	MSM_VIDC_BUF_BIN,
 	MSM_VIDC_BUF_COMV,
@@ -884,22 +826,27 @@ static int msm_vdec_subscribe_input_port_settings_change(struct msm_vidc_inst *i
 		d_vpr_e("%s: invalid params\n", __func__);
 		return -EINVAL;
 	}
-	core = inst->core;
 	i_vpr_h(inst, "%s()\n", __func__);
 
+	core = inst->core;
+	if (!core->platform) {
+		d_vpr_e("%s: invalid platform data\n", __func__);
+		return -EINVAL;
+	}
+
 	payload[0] = HFI_MODE_PORT_SETTINGS_CHANGE;
 	if (inst->codec == MSM_VIDC_H264) {
-		subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_avc);
-		psc = msm_vdec_subscribe_for_psc_avc;
+		subscribe_psc_size = core->platform->data.psc_avc_tbl_size;
+		psc = core->platform->data.psc_avc_tbl;
 	} else if (inst->codec == MSM_VIDC_HEVC || inst->codec == MSM_VIDC_HEIC) {
-		subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_hevc);
-		psc = msm_vdec_subscribe_for_psc_hevc;
+		subscribe_psc_size = core->platform->data.psc_hevc_tbl_size;
+		psc = core->platform->data.psc_hevc_tbl;
 	} 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;
+		subscribe_psc_size = core->platform->data.psc_vp9_tbl_size;
+		psc = core->platform->data.psc_vp9_tbl;
 	} 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;
+		subscribe_psc_size = core->platform->data.psc_av1_tbl_size;
+		psc = core->platform->data.psc_av1_tbl;
 	} else {
 		i_vpr_e(inst, "%s: unsupported codec: %d\n", __func__, inst->codec);
 		psc = NULL;
@@ -949,30 +896,61 @@ static int msm_vdec_subscribe_property(struct msm_vidc_inst *inst,
 	u32 payload[32] = {0};
 	u32 i, count = 0;
 	bool allow = false;
+	struct msm_vidc_core *core;
+	u32 subscribe_prop_size;
+	const u32 *subcribe_prop;
 
-	if (!inst) {
+	if (!inst || !inst->core) {
 		d_vpr_e("%s: invalid params\n", __func__);
 		return -EINVAL;
 	}
+	core = inst->core;
 	i_vpr_h(inst, "%s()\n", __func__);
 
+	if (!core->platform) {
+		d_vpr_e("%s: invalid platform data\n", __func__);
+		return -EINVAL;
+	}
+
 	payload[0] = HFI_MODE_PROPERTY;
 
 	if (port == INPUT_PORT) {
-		for (i = 0; i < ARRAY_SIZE(msm_vdec_input_subscribe_for_properties); i++) {
-			payload[count + 1] = msm_vdec_input_subscribe_for_properties[i];
-			count++;
+		subscribe_prop_size = core->platform->data.dec_input_prop_size;
+		subcribe_prop = core->platform->data.dec_input_prop;
+		for (i = 0; i < subscribe_prop_size; i++) {
+			allow = msm_vidc_allow_property(inst,
+				subcribe_prop[i]);
+			if (allow) {
+				payload[count + 1] = subcribe_prop[i];
+				count++;
+			}
+
+			if (subcribe_prop[i] == HFI_PROP_DPB_LIST) {
+				inst->subcr_params[port].dpb_list_enabled = true;
+				i_vpr_h(inst, "%s: DPB_LIST suscribed on input port", __func__);
+			}
+
+			msm_vidc_update_property_cap(inst,
+				subcribe_prop[i], allow);
 		}
 	} else if (port == OUTPUT_PORT) {
-		for (i = 0; i < ARRAY_SIZE(msm_vdec_output_subscribe_for_properties); i++) {
+		subscribe_prop_size = core->platform->data.dec_output_prop_size;
+		subcribe_prop = core->platform->data.dec_output_prop;
+		for (i = 0; i < subscribe_prop_size; i++) {
 			allow = msm_vidc_allow_property(inst,
-				msm_vdec_output_subscribe_for_properties[i]);
+				subcribe_prop[i]);
 			if (allow) {
-				payload[count + 1] = msm_vdec_output_subscribe_for_properties[i];
+				payload[count + 1] = subcribe_prop[i];
 				count++;
 			}
+
+			if (subcribe_prop[i] == HFI_PROP_DPB_LIST) {
+				inst->subcr_params[port].dpb_list_enabled = true;
+				i_vpr_h(inst, "%s: DPB_LIST suscribed on output port", __func__);
+			}
+
 			msm_vidc_update_property_cap(inst,
-				msm_vdec_output_subscribe_for_properties[i], allow);
+				subcribe_prop[i], allow);
 		}
 	} else {
 		i_vpr_e(inst, "%s: invalid port: %d\n", __func__, port);
@@ -1592,6 +1570,7 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
 	enum msm_vidc_port_type port)
 {
 	int rc = 0;
+	struct msm_vidc_core *core;
 	u32 payload[32] = {0};
 	u32 prop_type, payload_size, payload_type;
 	u32 i;
@@ -1599,25 +1578,31 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
 	u32 subscribe_psc_size = 0;
 	const u32 *psc = NULL;
 
-	if (!inst) {
+	if (!inst || !inst->core) {
 		d_vpr_e("%s: invalid params\n", __func__);
 		return -EINVAL;
 	}
 	i_vpr_h(inst, "%s()\n", __func__);
 
+	core = inst->core;
+	if (!core->platform) {
+		d_vpr_e("%s: invalid platform data\n", __func__);
+		return -EINVAL;
+	}
+
 	payload[0] = HFI_MODE_PORT_SETTINGS_CHANGE;
 	if (inst->codec == MSM_VIDC_H264) {
-		subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_avc);
-		psc = msm_vdec_subscribe_for_psc_avc;
+		subscribe_psc_size = core->platform->data.psc_avc_tbl_size;
+		psc = core->platform->data.psc_avc_tbl;
 	} else if (inst->codec == MSM_VIDC_HEVC || inst->codec == MSM_VIDC_HEIC) {
-		subscribe_psc_size = ARRAY_SIZE(msm_vdec_subscribe_for_psc_hevc);
-		psc = msm_vdec_subscribe_for_psc_hevc;
+		subscribe_psc_size = core->platform->data.psc_hevc_tbl_size;
+		psc = core->platform->data.psc_hevc_tbl;
 	} 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;
+		subscribe_psc_size = core->platform->data.psc_vp9_tbl_size;
+		psc = core->platform->data.psc_vp9_tbl;
 	} 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;
+		subscribe_psc_size = core->platform->data.psc_av1_tbl_size;
+		psc = core->platform->data.psc_av1_tbl;
 	} else {
 		i_vpr_e(inst, "%s: unsupported codec: %d\n", __func__, inst->codec);
 		psc = NULL;
@@ -1935,6 +1920,13 @@ static int msm_vdec_release_nonref_buffers(struct msm_vidc_inst *inst)
 		return -EINVAL;
 	}
 
+	/*
+	 * if DPB_LIST subscribed on output port then driver need to
+	 * hold MAX_BPB_COUNT of read only buffer at least.
+	 */
+	if (!inst->subcr_params[OUTPUT_PORT].dpb_list_enabled)
+		goto release_buffers;
+
 	/* count read_only buffers which are not pending release in read_only list */
 	list_for_each_entry(ro_buf, &inst->buffers.read_only.list, list) {
 		if (!(ro_buf->attr & MSM_VIDC_ATTR_READ_ONLY))
@@ -1980,6 +1972,7 @@ static int msm_vdec_release_nonref_buffers(struct msm_vidc_inst *inst)
 	i_vpr_l(inst, "%s: fw ro buf count %d, non-ref ro count %d\n",
 		__func__, fw_ro_count, nonref_ro_count);
 
+release_buffers:
 	/* release the eligible buffers as per above condition */
 	list_for_each_entry(ro_buf, &inst->buffers.read_only.list, list) {
 		found = false;
@@ -2706,6 +2699,8 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
 	inst->buffers.output_meta.extra_count = 0;
 	inst->buffers.output_meta.actual_count = 0;
 	inst->buffers.output_meta.size = 0;
+	inst->subcr_params[INPUT_PORT].dpb_list_enabled = 0;
+	inst->subcr_params[OUTPUT_PORT].dpb_list_enabled = 0;
 
 	rc = msm_vdec_codec_change(inst,
 			inst->fmts[INPUT_PORT].fmt.pix_mp.pixelformat);

+ 1 - 1
driver/vidc/src/venus_hfi_response.c

@@ -1694,7 +1694,7 @@ static int handle_property_with_payload(struct msm_vidc_inst *inst,
 				__func__);
 		break;
 	case HFI_PROP_DPB_LIST:
-		if (is_decode_session(inst) && port == OUTPUT_PORT &&
+		if (is_decode_session(inst) &&
 			inst->capabilities->cap[DPB_LIST].value) {
 			rc = handle_dpb_list_property(inst, pkt);
 			if (rc)