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

Commit de517812 authored by Praveen Chavan's avatar Praveen Chavan Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: Remove forced-setting of layer-wise bitrate for HP



Layerwise bitrate with predefined distribution table is applied
if HP is enabled. This is wrong (since client may configure
custom distribution) and unnecessary (client may not configure
layerwise distribution and use cumulative).

CRs-Fixed: 1023504
Change-Id: I053587ae85b36ce0b08fdb5918c0f6b9d678dd24
Signed-off-by: default avatarPraveen Chavan <pchavan@codeaurora.org>
parent 20b1a290
Loading
Loading
Loading
Loading
+5 −67
Original line number Diff line number Diff line
@@ -1572,52 +1572,6 @@ static int msm_venc_toggle_hier_p(struct msm_vidc_inst *inst, int layers)
	return rc;
}

static int set_bitrate_for_each_layer(struct msm_vidc_inst *inst,
				u32 num_enh_layers, u32 total_bitrate)
{
	u32 property_id = 0;
	int i = 0, rc = 0;
	struct hfi_device *hdev = NULL;
	struct hal_bitrate bitrate;
	struct hal_enable enable;
	int bitrate_table[3][4] = {
		{50, 50, 0, 0},
		{34, 33, 33, 0},
		{25, 25, 25, 25}
	};

	if (!inst || !inst->core || !inst->core->device) {
		dprintk(VIDC_ERR, "%s - invalid input\n", __func__);
		return -EINVAL;
	}

	if (!num_enh_layers || num_enh_layers > ARRAY_SIZE(bitrate_table)) {
		dprintk(VIDC_ERR, "%s - invalid number of enh layers: %d\n",
				__func__, num_enh_layers);
		return -EINVAL;
	}
	hdev = inst->core->device;

	property_id = HAL_PARAM_VENC_BITRATE_TYPE;
	enable.enable = V4L2_CID_MPEG_VIDC_VIDEO_VENC_BITRATE_ENABLE;
	rc = call_hfi_op(hdev, session_set_property,
			(void *)inst->session, property_id, &enable);
	if (rc) {
		dprintk(VIDC_ERR, "Failed to set layerwise bitrate\n");
		return false;
	}

	for (i = 0; !rc && i <= num_enh_layers; i++) {
		property_id = HAL_CONFIG_VENC_TARGET_BITRATE;
		bitrate.bit_rate = (u32)((total_bitrate *
			bitrate_table[num_enh_layers - 1][i]) / 100);
		bitrate.layer_id = i;
		rc = call_hfi_op(hdev, session_set_property,
				(void *)inst->session, property_id, &bitrate);
	}
	return rc;
}

static inline int msm_venc_power_save_mode_enable(struct msm_vidc_inst *inst)
{
	u32 rc = 0;
@@ -2319,26 +2273,10 @@ static int try_set_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	}
	case V4L2_CID_MPEG_VIDEO_BITRATE:
	{
		struct v4l2_ctrl *hier_p = TRY_GET_CTRL(
		   V4L2_CID_MPEG_VIDC_VIDEO_HIER_P_NUM_LAYERS);

		bitrate.layer_id = 0;
		if (hier_p->val &&
			inst->fmts[CAPTURE_PORT]->fourcc ==
			V4L2_PIX_FMT_H264) {
			rc = set_bitrate_for_each_layer(inst,
						hier_p->val, ctrl->val);
			if (rc) {
				dprintk(VIDC_ERR,
					"failed to set bitrate for multiple layers\n");
				rc = -EINVAL;
			}
		} else {
		property_id = HAL_CONFIG_VENC_TARGET_BITRATE;
		bitrate.bit_rate = ctrl->val;
		bitrate.layer_id = 0;
		pdata = &bitrate;
		}
		break;
	}
	case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK:
@@ -3306,8 +3244,8 @@ static int try_set_ext_ctrl(struct msm_vidc_inst *inst,
				bitrate.bit_rate = control[i].value;
				property_id = HAL_CONFIG_VENC_TARGET_BITRATE;
				pdata = &bitrate;
				dprintk(VIDC_DBG, "layerwise bitrate for %d\n",
					i);
				dprintk(VIDC_DBG, "bitrate for layer(%d)=%d\n",
					i, bitrate.bit_rate);
				rc = call_hfi_op(hdev, session_set_property,
					(void *)inst->session, property_id,
					 pdata);