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

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

Merge "msm: vidc: update menu_skip_mask for menu type controls"

parents 3f55f38d f30d360a
Loading
Loading
Loading
Loading
+28 −8
Original line number Diff line number Diff line
@@ -938,10 +938,10 @@ static struct msm_vidc_ctrl msm_venc_ctrls[] = {
	{
		.id = V4L2_CID_MPEG_VIDC_VENC_BITRATE_SAVINGS,
		.name = "Enable/Disable bitrate savings",
		.type = V4L2_CTRL_TYPE_BOOLEAN,
		.minimum = V4L2_MPEG_MSM_VIDC_DISABLE,
		.maximum = V4L2_MPEG_MSM_VIDC_ENABLE,
		.default_value = V4L2_MPEG_MSM_VIDC_ENABLE,
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 0,
		.maximum = 3,
		.default_value = 3,
		.step = 1,
	},
	{
@@ -3315,8 +3315,10 @@ int msm_venc_set_bitrate_savings_mode(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct hfi_device *hdev;
	struct v4l2_ctrl *ctrl = NULL;
	struct v4l2_ctrl *cac;
	struct v4l2_ctrl *profile;
	struct hfi_enable enable;
	u32 codec;

	if (!inst || !inst->core) {
		d_vpr_e("%s: invalid params %pK\n", __func__, inst);
@@ -3324,12 +3326,30 @@ int msm_venc_set_bitrate_savings_mode(struct msm_vidc_inst *inst)
	}
	hdev = inst->core->device;

	ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VENC_BITRATE_SAVINGS);
	enable.enable = !!ctrl->val;
	if (!ctrl->val && inst->rc_type != V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) {
	cac = get_ctrl(inst, V4L2_CID_MPEG_VIDC_VENC_BITRATE_SAVINGS);
	codec = get_v4l2_codec(inst);
	profile = get_ctrl(inst, V4L2_CID_MPEG_VIDEO_HEVC_PROFILE);

	/**
	 * Enable CAC control:
	 * 0x0 -> disabled,
	 * 0x1 -> enabled for 8 bit
	 * 0x2 -> enabled for 10 bit
	 * 0x3 -> enabled for 8 and 10 bits both
	 */
	enable.enable = !!cac->val;
	if (cac->val == 0x1 && codec == V4L2_PIX_FMT_HEVC &&
		profile->val == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10)
		enable.enable = 0;
	else if (cac->val == 0x2 && !(codec == V4L2_PIX_FMT_HEVC &&
		profile->val == V4L2_MPEG_VIDEO_HEVC_PROFILE_MAIN_10))
		enable.enable = 0;

	if (!cac->val && inst->rc_type != V4L2_MPEG_VIDEO_BITRATE_MODE_VBR) {
		s_vpr_h(inst->sid,
			"Can't disable bitrate savings for non-VBR_CFR\n");
		enable.enable = 1;
		update_ctrl(cac, 3, inst->sid);
	}

	s_vpr_h(inst->sid, "%s: %d\n", __func__, enable.enable);
+19 −15
Original line number Diff line number Diff line
@@ -1400,6 +1400,7 @@ static int msm_vidc_comm_update_ctrl(struct msm_vidc_inst *inst,
{
	struct v4l2_ctrl *ctrl = NULL;
	int rc = 0;
	bool is_menu = false;

	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, id);
	if (!ctrl) {
@@ -1408,29 +1409,32 @@ static int msm_vidc_comm_update_ctrl(struct msm_vidc_inst *inst,
		return -EINVAL;
	}

	if (ctrl->type == V4L2_CTRL_TYPE_MENU)
		is_menu = true;

	/**
	 * For menu controls the step value is interpreted
	 * as a menu_skip_mask.
	 */
	rc = v4l2_ctrl_modify_range(ctrl, cap->min, cap->max,
			cap->step_size, cap->default_value);
			is_menu ? ctrl->menu_skip_mask : cap->step_size,
			cap->default_value);
	if (rc) {
		s_vpr_e(inst->sid,
			"%s: failed: control name %s, min %d, max %d, step %d, default_value %d\n",
			"%s: failed: control name %s, min %d, max %d, %s %x, default_value %d\n",
			__func__, ctrl->name, cap->min, cap->max,
			cap->step_size, cap->default_value);
		goto error;
	}
	/*
	 * v4l2_ctrl_modify_range() is not updating default_value,
	 * so use v4l2_ctrl_s_ctrl() to update it.
	 */
	rc = v4l2_ctrl_s_ctrl(ctrl, cap->default_value);
	if (rc) {
		s_vpr_e(inst->sid, "%s: failed s_ctrl: %s with value %d\n",
			__func__, ctrl->name, cap->default_value);
			is_menu ? "menu_skip_mask" : "step",
			is_menu ? ctrl->menu_skip_mask : cap->step_size,
			cap->default_value);
		goto error;
	}

	s_vpr_h(inst->sid,
		"Updated control: %s: min %lld, max %lld, step %lld, default value = %lld\n",
		"Updated control: %s: min %lld, max %lld, %s %x, default value = %lld\n",
		ctrl->name, ctrl->minimum, ctrl->maximum,
		ctrl->step, ctrl->default_value);
		is_menu ? "menu_skip_mask" : "step",
		is_menu ? ctrl->menu_skip_mask : ctrl->step,
		ctrl->default_value);

error:
	return rc;