Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2734023 authored by Akshata Sahukar's avatar Akshata Sahukar
Browse files

msm: vidc: Update cvp extradata control settings



If kernel to kernel CVP is enabled, initially driver disables
CVP extradata to firmware and then later, re-enables it.
Introduced a new flag to usage of CVP kernel to kernel metadata
to save the usage. As part of start streaming, driver will send
out CVP extradata enabled once based on overall usage.

Also, disabled kernel to kernel CVP usage for superframe.

Change-Id: I5590bd2274e27243da99f207d61fb00fc6fc82e0
Signed-off-by: default avatarAkshata Sahukar <asahukar@codeaurora.org>
parent b098e7cf
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -4020,7 +4020,6 @@ int msm_venc_set_hdr_info(struct msm_vidc_inst *inst)
int msm_venc_set_extradata(struct msm_vidc_inst *inst)
{
	int rc = 0;
	u32 value = 0x0;
	u32 codec;

	codec = get_v4l2_codec(inst);
@@ -4056,13 +4055,8 @@ int msm_venc_set_extradata(struct msm_vidc_inst *inst)
		}
	}

	if (inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP)
		value = 0x1;
	dprintk(VIDC_HIGH, "%s: CVP extradata %d\n", __func__, value);
	rc = msm_comm_set_extradata(inst,
		HFI_PROPERTY_PARAM_VENC_CVP_METADATA_EXTRADATA, value);
	if (rc)
		dprintk(VIDC_ERR, "%s: set CVP extradata failed\n", __func__);
	/* CVP extradata is common between user space and external CVP kernel to kernel.
	   Hence, skipping here and will be set after msm_vidc_prepare_preprocess in start_streaming*/

	return rc;
}
+34 −10
Original line number Diff line number Diff line
@@ -711,6 +711,7 @@ bool is_vidc_cvp_allowed(struct msm_vidc_inst *inst)
	bool allowed = false;
	struct msm_vidc_core *core;
	struct v4l2_ctrl *cvp_disable;
	struct v4l2_ctrl *superframe_enable;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -730,15 +731,18 @@ bool is_vidc_cvp_allowed(struct msm_vidc_inst *inst)
	 *      - V4L2_MPEG_VIDEO_BITRATE_MODE_CQ
	 *      - V4L2_MPEG_VIDEO_BITRATE_MODE_CBR
	 * - not secure session
	 * - not superframe enabled
	 */
	cvp_disable = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VENC_CVP_DISABLE);
	superframe_enable = get_ctrl(inst, V4L2_CID_MPEG_VIDC_SUPERFRAME);

	if (core->resources.cvp_external && !cvp_disable->val &&
		!(inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP) &&
		inst->rc_type != RATE_CONTROL_OFF &&
		inst->rc_type != V4L2_MPEG_VIDEO_BITRATE_MODE_CQ &&
		!inst->clk_data.is_legacy_cbr &&
		!is_secure_session(inst)) {
		!is_secure_session(inst) &&
		!superframe_enable->val) {
		dprintk(VIDC_HIGH, "%s: cvp allowed\n", __func__);
		allowed = true;
	} else {
@@ -778,15 +782,8 @@ static int msm_vidc_prepare_preprocess(struct msm_vidc_inst *inst)
		dprintk(VIDC_ERR, "%s: no cvp preprocessing\n", __func__);
		goto exit;
	}
	dprintk(VIDC_HIGH, "%s: cvp enabled\n", __func__);

	dprintk(VIDC_HIGH, "%s: set CVP extradata\n", __func__);
	rc = msm_comm_set_extradata(inst,
		HFI_PROPERTY_PARAM_VENC_CVP_METADATA_EXTRADATA, 1);
	if (rc) {
		dprintk(VIDC_ERR, "%s: set CVP extradata failed\n", __func__);
		goto exit;
	}
	dprintk(VIDC_HIGH, "%s: kernel to kernel cvp enabled\n", __func__);
	inst->prop.extradata_ctrls |= EXTRADATA_ENC_INPUT_KK_CVP;

exit:
	if (rc)
@@ -794,6 +791,31 @@ static int msm_vidc_prepare_preprocess(struct msm_vidc_inst *inst)
	return rc;
}

static bool msm_vidc_set_cvp_metadata(struct msm_vidc_inst *inst) {

	int rc = 0;
	u32 value = 0x0;

	if (!inst) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
		return false;
	}

	if ((inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_CVP) ||
	    (inst->prop.extradata_ctrls & EXTRADATA_ENC_INPUT_KK_CVP))
	    value = 0x1;

	dprintk(VIDC_HIGH, "%s: CVP extradata %d\n", __func__, value);
	rc = msm_comm_set_extradata(inst,
		HFI_PROPERTY_PARAM_VENC_CVP_METADATA_EXTRADATA, value);
	if (rc) {
		dprintk(VIDC_ERR,
			"%s: set CVP extradata failed\n", __func__);
		return false;
	}
	return true;
}

static inline int start_streaming(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -819,6 +841,8 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
			/* ignore error */
			rc = 0;
		}
		if (!(msm_vidc_set_cvp_metadata(inst)))
			goto fail_start;
	}

	b.buffer_type = HFI_BUFFER_OUTPUT;
+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@
#define INPUT_MPLANE V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
#define OUTPUT_MPLANE V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE

/* EXTRADATA_ENC_INPUT_KK_CVP is an extension of
   v4l2_mpeg_vidc_extradata for internal usage.
   This is needed to indicate internal kernel to kernel CVP usage. */
#define EXTRADATA_ENC_INPUT_KK_CVP (1UL << 31)
#define RATE_CONTROL_OFF (V4L2_MPEG_VIDEO_BITRATE_MODE_CQ + 1)
#define RATE_CONTROL_LOSSLESS (V4L2_MPEG_VIDEO_BITRATE_MODE_CQ + 2)
#define SYS_MSG_START HAL_SYS_INIT_DONE