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

Commit 5c69e1a3 authored by Darshana Patil's avatar Darshana Patil
Browse files

msm: vidc: Fixed multi slice encode issue



Fixed multi slice mode capabilities and rate control checks
to enable multi slice encoding.

Change-Id: I521b392bd00964692ad575e350512c5396081054
CRs-Fixed: 2384822
Signed-off-by: default avatarDarshana Patil <darshana@codeaurora.org>
parent cde1ce93
Loading
Loading
Loading
Loading
+22 −23
Original line number Diff line number Diff line
@@ -1389,16 +1389,13 @@ static int msm_venc_resolve_rc_enable(struct msm_vidc_inst *inst,
static int msm_venc_resolve_rate_control(struct msm_vidc_inst *inst,
		struct v4l2_ctrl *ctrl)
{
	struct v4l2_ctrl *rc_enable;

	if (inst->rc_type == RATE_CONTROL_LOSSLESS) {
		dprintk(VIDC_DBG,
			"Skip RC mode when enabling lossless encoding\n");
		return 0;
	}

	rc_enable = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE);
	if (!rc_enable->val) {
	if (inst->rc_type == RATE_CONTROL_OFF) {
		dprintk(VIDC_ERR,
			"RC is not enabled.\n");
		return -EINVAL;
@@ -2615,7 +2612,6 @@ int msm_venc_set_frame_qp(struct msm_vidc_inst *inst)
	struct v4l2_ctrl *i_qp = NULL;
	struct v4l2_ctrl *p_qp = NULL;
	struct v4l2_ctrl *b_qp = NULL;
	struct v4l2_ctrl *rc_enable = NULL;
	struct hfi_quantization qp;

	if (!inst || !inst->core) {
@@ -2631,7 +2627,6 @@ int msm_venc_set_frame_qp(struct msm_vidc_inst *inst)
	i_qp = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP);
	p_qp = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP);
	b_qp = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP);
	rc_enable = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE);

	/*
	 * When RC is ON:
@@ -2640,7 +2635,7 @@ int msm_venc_set_frame_qp(struct msm_vidc_inst *inst)
	 *   I_QP value must be set by client.
	 *   If other QP value is invalid, then, assign I_QP value to it.
	 */
	if (rc_enable->val) {
	if (inst->rc_type != RATE_CONTROL_OFF) {
		if (!(inst->client_set_ctrls & CLIENT_SET_I_QP))
			qp.enable &= ~QP_ENABLE_I;
		if (!(inst->client_set_ctrls & CLIENT_SET_P_QP))
@@ -2827,7 +2822,6 @@ int msm_venc_set_slice_control_mode(struct msm_vidc_inst *inst)
	u32 mb_per_frame, fps, mbps, bitrate, max_slices;
	u32 slice_val, slice_mode, max_avg_slicesize;
	u32 rc_mode, output_width, output_height;
	struct v4l2_ctrl *rc_enable;
	u32 codec;

	if (!inst || !inst->core) {
@@ -2843,13 +2837,11 @@ int msm_venc_set_slice_control_mode(struct msm_vidc_inst *inst)
	slice_val = 0;

	bitrate = inst->clk_data.bitrate;
	fps = inst->clk_data.frame_rate;
	fps = inst->clk_data.frame_rate >> 16;
	rc_mode = inst->rc_type;
	rc_enable = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE);
	if (fps > 60 ||
		(rc_enable->val &&
		 rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR &&
		 rc_mode != V4L2_MPEG_VIDEO_BITRATE_MODE_CBR)) {
	if (fps > 60 || (!(rc_mode == RATE_CONTROL_OFF ||
		 rc_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR ||
		 rc_mode == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR))) {
		goto set_and_exit;
	}

@@ -2894,10 +2886,13 @@ int msm_venc_set_slice_control_mode(struct msm_vidc_inst *inst)
			mbps <= NUM_MBS_PER_SEC(1088, 1920, 60)) {
			max_slices = inst->capability.cap[CAP_SLICE_BYTE].max ?
				inst->capability.cap[CAP_SLICE_BYTE].max : 1;
			max_avg_slicesize = ((bitrate / fps) / 8) / max_slices;
			if (rc_mode != RATE_CONTROL_OFF) {
				max_avg_slicesize =
					((bitrate / fps) / 8) / max_slices;
				slice_val = max(slice_val, max_avg_slicesize);
			}
		}
	}

	if (slice_mode == HFI_MULTI_SLICE_OFF) {
		ctrl->val = V4L2_MPEG_VIDEO_MULTI_SLICE_MODE_SINGLE;
@@ -2926,7 +2921,6 @@ int msm_venc_set_intra_refresh_mode(struct msm_vidc_inst *inst)
	int rc = 0;
	struct hfi_device *hdev;
	struct v4l2_ctrl *ctrl = NULL;
	struct v4l2_ctrl *rc_mode = NULL;
	struct hfi_intra_refresh intra_refresh;
	struct v4l2_format *f;

@@ -2936,9 +2930,8 @@ int msm_venc_set_intra_refresh_mode(struct msm_vidc_inst *inst)
	}
	hdev = inst->core->device;

	rc_mode = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_BITRATE_MODE);
	if (!(rc_mode->val == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR ||
		rc_mode->val == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR))
	if (!(inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR ||
		inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR))
		return 0;

	/* Firmware supports only random mode */
@@ -3614,6 +3607,11 @@ int msm_venc_set_ltr_mode(struct msm_vidc_inst *inst)
	if (!(codec == V4L2_PIX_FMT_HEVC || codec == V4L2_PIX_FMT_H264))
		return 0;

	if (!(inst->rc_type == RATE_CONTROL_OFF ||
		inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR ||
		inst->rc_type == V4L2_MPEG_VIDEO_BITRATE_MODE_CBR_VFR))
		return 0;

	ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VIDEO_LTRCOUNT);
	if (!ctrl->val)
		return 0;
@@ -3704,7 +3702,6 @@ int msm_venc_set_dyn_qp(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	int rc = 0;
	struct hfi_device *hdev;
	struct hfi_quantization qp;
	struct v4l2_ctrl *rc_enable;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
@@ -3712,8 +3709,7 @@ int msm_venc_set_dyn_qp(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	}
	hdev = inst->core->device;

	rc_enable = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE);
	if (rc_enable->val) {
	if (inst->rc_type != RATE_CONTROL_OFF) {
		dprintk(VIDC_ERR, "%s: Dyn qp is set only when RC is OFF\n",
			__func__);
		return -EINVAL;
@@ -3956,6 +3952,9 @@ int msm_venc_set_properties(struct msm_vidc_inst *inst)
	if (rc)
		goto exit;
	rc = msm_venc_set_rate_control(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_vbv_delay(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_bitrate_savings_mode(inst);
+0 −6
Original line number Diff line number Diff line
@@ -1432,12 +1432,6 @@ static void msm_vidc_comm_update_ctrl_limits(struct msm_vidc_inst *inst)
			return;
		msm_vidc_comm_update_ctrl(inst, V4L2_CID_MPEG_VIDEO_BITRATE,
				&inst->capability.cap[CAP_BITRATE]);
		msm_vidc_comm_update_ctrl(inst,
				V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES,
				&inst->capability.cap[CAP_SLICE_BYTE]);
		msm_vidc_comm_update_ctrl(inst,
				V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB,
				&inst->capability.cap[CAP_SLICE_MB]);
		msm_vidc_comm_update_ctrl(inst,
				V4L2_CID_MPEG_VIDC_VIDEO_LTRCOUNT,
				&inst->capability.cap[CAP_LTR_COUNT]);