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

Commit 108f2f9d authored by Chinmay Sawarkar's avatar Chinmay Sawarkar Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: Update work mode and route for kona



Default work mode=2, route=4. Under specific conditions
limit to mode=1 and route=1.

CRs-Fixed: 2384822
Change-Id: I9749f43862d39e426cce165d15ead276a981c2ad
Signed-off-by: default avatarChinmay Sawarkar <chinmays@codeaurora.org>
parent 5dd137bb
Loading
Loading
Loading
Loading
+54 −43
Original line number Original line Diff line number Diff line
@@ -1272,6 +1272,7 @@ int msm_vidc_decide_work_route_iris2(struct msm_vidc_inst *inst)
	int rc = 0;
	int rc = 0;
	struct hfi_device *hdev;
	struct hfi_device *hdev;
	struct hfi_video_work_route pdata;
	struct hfi_video_work_route pdata;
	bool cbr_plus;


	if (!inst || !inst->core || !inst->core->device) {
	if (!inst || !inst->core || !inst->core->device) {
		dprintk(VIDC_ERR,
		dprintk(VIDC_ERR,
@@ -1281,45 +1282,39 @@ int msm_vidc_decide_work_route_iris2(struct msm_vidc_inst *inst)
	}
	}


	hdev = inst->core->device;
	hdev = inst->core->device;

	cbr_plus = inst->clk_data.is_cbr_plus;
	pdata.video_work_route = 4;
	pdata.video_work_route = 4;

	if (inst->session_type == MSM_VIDC_DECODER) {
	if (inst->session_type == MSM_VIDC_DECODER) {
		if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_MPEG2 ||
		if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_MPEG2 ||
			inst->pic_struct != MSM_VIDC_PIC_STRUCT_PROGRESSIVE)
			inst->pic_struct != MSM_VIDC_PIC_STRUCT_PROGRESSIVE)
			pdata.video_work_route = 1;
			pdata.video_work_route = 1;
	} else if (inst->session_type == MSM_VIDC_ENCODER) {
	} else if (inst->session_type == MSM_VIDC_ENCODER) {
		u32 slice_mode, rc_mode;
		u32 slice_mode, output_width, output_height, num_mbs;
		u32 output_width, output_height, fps, mbps;
		bool is_1080p_above;
		bool cbr_plus;


		if (inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_VP8) {
			pdata.video_work_route = 1;
			goto decision_done;
		}

		rc_mode = msm_comm_g_ctrl_for_id(inst,
			V4L2_CID_MPEG_VIDEO_BITRATE_MODE);
		slice_mode =  msm_comm_g_ctrl_for_id(inst,
		slice_mode =  msm_comm_g_ctrl_for_id(inst,
				V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE);
				V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE);
		output_height = inst->prop.height[CAPTURE_PORT];
		output_height = inst->prop.height[OUTPUT_PORT];
		output_width = inst->prop.width[CAPTURE_PORT];
		output_width = inst->prop.width[OUTPUT_PORT];
		fps = inst->clk_data.frame_rate >> 16;
		num_mbs = NUM_MBS_PER_FRAME(output_height, output_width);
		mbps = NUM_MBS_PER_SEC(output_height, output_width, fps);

		cbr_plus = ((rc_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR &&
		is_1080p_above =
			mbps > CBR_MB_LIMIT) ||
			((output_height > 1088 && output_width > 1920) ||
			(rc_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR &&
			 (output_height > 1920 && output_width > 1088) ||
			mbps > CBR_VFR_MB_LIMIT));
			 num_mbs > NUM_MBS_PER_FRAME(1088, 1920));

		if (slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES ||
		if (slice_mode == V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES ||
			((mbps <= NUM_MBS_PER_SEC(1920, 1088, 60)) && !cbr_plus)
			inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_VP8 ||
			) {
			(!is_1080p_above && !cbr_plus)) {
			pdata.video_work_route = 1;
			pdata.video_work_route = 1;
			dprintk(VIDC_DBG, "Configured work route = 1");
		}
		}
	} else {
	} else {
		return -EINVAL;
		return -EINVAL;
	}
	}


decision_done:
	dprintk(VIDC_DBG, "Configurng work route = %u",
			pdata.video_work_route);


	inst->clk_data.work_route = pdata.video_work_route;
	inst->clk_data.work_route = pdata.video_work_route;
	rc = call_hfi_op(hdev, session_set_property,
	rc = call_hfi_op(hdev, session_set_property,
@@ -1486,6 +1481,7 @@ int msm_vidc_decide_work_mode_iris2(struct msm_vidc_inst *inst)
	struct hfi_video_work_mode pdata;
	struct hfi_video_work_mode pdata;
	struct hfi_enable latency;
	struct hfi_enable latency;
	u32 num_mbs = 0;
	u32 num_mbs = 0;
	u32 width, height;


	if (!inst || !inst->core || !inst->core->device) {
	if (!inst || !inst->core || !inst->core->device) {
		dprintk(VIDC_ERR,
		dprintk(VIDC_ERR,
@@ -1496,28 +1492,52 @@ int msm_vidc_decide_work_mode_iris2(struct msm_vidc_inst *inst)


	hdev = inst->core->device;
	hdev = inst->core->device;
	pdata.video_work_mode = HFI_WORKMODE_2;
	pdata.video_work_mode = HFI_WORKMODE_2;
	latency.enable = inst->clk_data.low_latency_mode;


	if (inst->clk_data.low_latency_mode) {
	if (inst->session_type == MSM_VIDC_DECODER) {
		pdata.video_work_mode = HFI_WORKMODE_1;
		height = inst->prop.height[CAPTURE_PORT];
		dprintk(VIDC_DBG, "Configured work mode = 1");
		width = inst->prop.width[CAPTURE_PORT];
	} else if (inst->session_type == MSM_VIDC_DECODER) {
		num_mbs = NUM_MBS_PER_FRAME(height, width);
		num_mbs = NUM_MBS_PER_FRAME(
					inst->prop.height[OUTPUT_PORT],
					inst->prop.width[OUTPUT_PORT]);
		if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_MPEG2 ||
		if (inst->fmts[OUTPUT_PORT].fourcc == V4L2_PIX_FMT_MPEG2 ||
			(inst->pic_struct != MSM_VIDC_PIC_STRUCT_PROGRESSIVE) ||
			inst->pic_struct != MSM_VIDC_PIC_STRUCT_PROGRESSIVE ||
			(num_mbs < NUM_MBS_PER_FRAME(720, 1280)))
			inst->clk_data.low_latency_mode ||
			(width < 1280 && height < 720) ||
			(width < 720 && height < 1280) ||
			num_mbs < NUM_MBS_PER_FRAME(720, 1280)) {
			pdata.video_work_mode = HFI_WORKMODE_1;
			pdata.video_work_mode = HFI_WORKMODE_1;
		}
	} else if (inst->session_type == MSM_VIDC_ENCODER) {
	} else if (inst->session_type == MSM_VIDC_ENCODER) {
		if (inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_VP8) {
		height = inst->prop.height[OUTPUT_PORT];
		width = inst->prop.width[OUTPUT_PORT];
		num_mbs = NUM_MBS_PER_FRAME(height, width);
		if ((num_mbs >= NUM_MBS_PER_FRAME(2160, 4096) ||
			(width < 4096 && height < 2160) ||
			(width < 2160 && height < 4096)) &&
			(inst->fmts[CAPTURE_PORT].fourcc == V4L2_PIX_FMT_VP8 ||
			 inst->clk_data.low_latency_mode)) {
			pdata.video_work_mode = HFI_WORKMODE_1;
			pdata.video_work_mode = HFI_WORKMODE_1;
			/* For WORK_MODE_1, set Low Latency mode by default */
			/* For WORK_MODE_1, set Low Latency mode by default */
			inst->clk_data.low_latency_mode = true;
			latency.enable = true;
		}
		}
	} else {
	} else {
		return -EINVAL;
		return -EINVAL;
	}
	}


	dprintk(VIDC_DBG, "Configuring work mode = %u low latency = %u",
			inst->clk_data.work_mode,
			latency.enable);

	rc = call_hfi_op(hdev, session_set_property,
		(void *)inst->session,
		HFI_PROPERTY_PARAM_VENC_LOW_LATENCY_MODE,
		(void *)&latency, sizeof(latency));
	if (rc)
		dprintk(VIDC_WARN,
			" Failed to configure low latency %pK\n", inst);
	else
		inst->clk_data.low_latency_mode = latency.enable;


	inst->clk_data.work_mode = pdata.video_work_mode;
	inst->clk_data.work_mode = pdata.video_work_mode;
	rc = call_hfi_op(hdev, session_set_property,
	rc = call_hfi_op(hdev, session_set_property,
			(void *)inst->session, HFI_PROPERTY_PARAM_WORK_MODE,
			(void *)inst->session, HFI_PROPERTY_PARAM_WORK_MODE,
@@ -1526,15 +1546,6 @@ int msm_vidc_decide_work_mode_iris2(struct msm_vidc_inst *inst)
		dprintk(VIDC_WARN,
		dprintk(VIDC_WARN,
			" Failed to configure Work Mode %pK\n", inst);
			" Failed to configure Work Mode %pK\n", inst);


	if (inst->clk_data.low_latency_mode &&
		inst->session_type == MSM_VIDC_ENCODER){
		latency.enable = true;
		rc = call_hfi_op(hdev, session_set_property,
			(void *)inst->session,
			HFI_PROPERTY_PARAM_VENC_LOW_LATENCY_MODE,
			(void *)&latency, sizeof(latency));
	}

	return rc;
	return rc;
}
}