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

Commit 00fadf1d authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: Modify multislice config before start"

parents d971e9f4 7984ef2e
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -1514,15 +1514,16 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	}
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: {
		int temp = 0;

		enable.enable = false;
		if (inst->fmts[CAPTURE_PORT].fourcc != V4L2_PIX_FMT_HEVC &&
			inst->fmts[CAPTURE_PORT].fourcc != V4L2_PIX_FMT_H264) {
			return rc;
		}
		switch (ctrl->val) {
		case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB:
			temp = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
			break;
		case V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_BYTES:
			temp = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
			enable.enable = true;
			break;
		case V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE:
		default:
@@ -1530,19 +1531,6 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
			break;
		}

		temp_ctrl =
			TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE);
		if (!temp_ctrl->val) {
			rc = msm_comm_try_set_prop(inst,
				   HAL_PARAM_VENC_LOW_LATENCY, &enable.enable);
			if (rc)
				dprintk(VIDC_ERR,
					"SliceMode Low Latency enable fail\n");
			else
				inst->clk_data.low_latency_mode =
							(bool) enable.enable;
		}

		if (temp)
			temp_ctrl = TRY_GET_CTRL(temp);

@@ -1555,6 +1543,10 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	}
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES:
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB:
		if (inst->fmts[CAPTURE_PORT].fourcc != V4L2_PIX_FMT_HEVC &&
			inst->fmts[CAPTURE_PORT].fourcc != V4L2_PIX_FMT_H264) {
			return rc;
		}
		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE);

		property_id = HAL_PARAM_VENC_MULTI_SLICE_CONTROL;
+59 −0
Original line number Diff line number Diff line
@@ -880,7 +880,11 @@ int msm_vidc_set_internal_config(struct msm_vidc_inst *inst)
	struct hal_vbv_hdr_buf_size hrd_buf_size;
	struct hal_enable latency;
	struct hfi_device *hdev;
	struct hal_multi_slice_control multi_slice_control;
	u32 codec;
	u32 mbps, mb_per_frame, fps, bitrate;
	u32 slice_val, slice_mode, max_avg_slicesize;
	u32 output_width, output_height;

	if (!inst || !inst->core || !inst->core->device) {
		dprintk(VIDC_WARN, "%s: Invalid parameter\n", __func__);
@@ -932,6 +936,61 @@ int msm_vidc_set_internal_config(struct msm_vidc_inst *inst)
		inst->clk_data.low_latency_mode = latency.enable;
	}

	/* Update Slice Config */
	slice_mode =  msm_comm_g_ctrl_for_id(inst,
		 V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE);

	if ((codec == V4L2_PIX_FMT_H264 || codec == V4L2_PIX_FMT_HEVC) &&
		slice_mode != V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE) {

		output_height = inst->prop.height[CAPTURE_PORT];
		output_width = inst->prop.width[CAPTURE_PORT];
		fps = inst->prop.fps;
		bitrate = inst->clk_data.bitrate;
		mb_per_frame = NUM_MBS_PER_FRAME(output_height, output_width);
		mbps = NUM_MBS_PER_SEC(output_height, output_width, fps);

		if (rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_RC_OFF &&
			rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR &&
			rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR) {
			slice_mode = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
			slice_val = 0;
		} else if (slice_mode ==
				    V4L2_MPEG_VIDEO_MULTI_SICE_MODE_MAX_MB) {
			if (output_width > 3840 || output_height > 3840 ||
				mb_per_frame > NUM_MBS_PER_FRAME(3840, 2160) ||
				fps > 60) {
				slice_mode =
					V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
				slice_val = 0;
			} else {
				slice_val = msm_comm_g_ctrl_for_id(inst,
				   V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB);
				slice_val = max(slice_val, mb_per_frame / 10);
			}
		} else {
			if (output_width > 1920 || output_height > 1920 ||
				mb_per_frame > NUM_MBS_PER_FRAME(1920, 1088) ||
				 fps > 30) {
				slice_mode =
					V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
				slice_val = 0;
			} else {
				slice_val = msm_comm_g_ctrl_for_id(inst,
				   V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES);
				max_avg_slicesize = ((bitrate / fps) / 8) / 10;
				slice_val =
					max(slice_val, max_avg_slicesize);
			}
		}

		multi_slice_control.multi_slice = slice_mode;
		multi_slice_control.slice_size = slice_val;

		rc = call_hfi_op(hdev, session_set_property,
		 (void *)inst->session, HAL_PARAM_VENC_MULTI_SLICE_CONTROL,
		 (void *)&multi_slice_control);
	}
	return rc;
}