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

Commit 810daeb9 authored by Amit Shekhar's avatar Amit Shekhar
Browse files

msm: vidc: Fix setting rotation and flip controls



Move setting rotation and flip controls to encoder set property
function to align with property consolidation design.

Change-Id: I71d0b89b3ab760ebe06d00b61b9cc029552fb276
Signed-off-by: default avatarAmit Shekhar <ashekhar@codeaurora.org>
parent 00474817
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
@@ -3249,6 +3249,71 @@ int msm_venc_set_video_signal_info(struct msm_vidc_inst *inst)
	return rc;
}

int msm_venc_set_rotation(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct v4l2_ctrl *rotation = NULL;
	struct v4l2_ctrl *hflip = NULL;
	struct v4l2_ctrl *vflip = NULL;
	struct hfi_device *hdev;
	struct hfi_vpe_rotation_type vpe_rotation;
	struct hfi_frame_size frame_sz;

	hdev = inst->core->device;

	rotation = get_ctrl(inst, V4L2_CID_ROTATE);

	vpe_rotation.rotation = HFI_ROTATE_NONE;
	if (rotation->val == 90)
		vpe_rotation.rotation = HFI_ROTATE_90;
	else if (rotation->val == 180)
		vpe_rotation.rotation = HFI_ROTATE_180;
	else if (rotation->val ==  270)
		vpe_rotation.rotation = HFI_ROTATE_270;

	hflip = get_ctrl(inst, V4L2_CID_HFLIP);
	vflip = get_ctrl(inst, V4L2_CID_VFLIP);

	vpe_rotation.flip = HFI_FLIP_NONE;
	if ((hflip->val == V4L2_MPEG_MSM_VIDC_ENABLE) &&
		(vflip->val == V4L2_MPEG_MSM_VIDC_ENABLE))
		vpe_rotation.flip = HFI_FLIP_HORIZONTAL | HFI_FLIP_VERTICAL;
	else if (hflip->val == V4L2_MPEG_MSM_VIDC_ENABLE)
		vpe_rotation.flip = HFI_FLIP_HORIZONTAL;
	else if (vflip->val == V4L2_MPEG_MSM_VIDC_ENABLE)
		vpe_rotation.flip = HFI_FLIP_VERTICAL;

	dprintk(VIDC_DBG, "Set rotation = %d, flip = %d\n",
			vpe_rotation.rotation, vpe_rotation.flip);
	rc = call_hfi_op(hdev, session_set_property,
				(void *)inst->session,
				HFI_PROPERTY_PARAM_VPE_ROTATION,
				&vpe_rotation, sizeof(vpe_rotation));
	if (rc) {
		dprintk(VIDC_ERR, "Set rotation/flip failed\n");
		return rc;
	}

	/* flip the output resolution if required */
	if (vpe_rotation.rotation == HFI_ROTATE_90 ||
		vpe_rotation.rotation == HFI_ROTATE_270) {
		frame_sz.buffer_type = HFI_BUFFER_OUTPUT;
		frame_sz.width = inst->prop.height[CAPTURE_PORT];
		frame_sz.height = inst->prop.width[CAPTURE_PORT];
		dprintk(VIDC_DBG, "CAPTURE port width = %d, height = %d\n",
			frame_sz.width, frame_sz.height);
		rc = call_hfi_op(hdev, session_set_property, (void *)
			inst->session, HFI_PROPERTY_PARAM_FRAME_SIZE,
			&frame_sz, sizeof(frame_sz));
		if (rc) {
			dprintk(VIDC_ERR,
				"Failed to set framesize\n");
			return rc;
		}
	}
	return rc;
}

int msm_venc_set_video_csc(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -3837,6 +3902,10 @@ int msm_venc_set_properties(struct msm_vidc_inst *inst)
	rc = msm_venc_set_buffer_counts(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_rotation(inst);
	if (rc)
		goto exit;

exit:
	if (rc)
		dprintk(VIDC_ERR, "%s: failed with %d\n", __func__, rc);
+2 −86
Original line number Diff line number Diff line
@@ -797,83 +797,6 @@ static inline int msm_vidc_verify_buffer_counts(struct msm_vidc_inst *inst)
	return rc;
}

static int msm_vidc_set_rotation(struct msm_vidc_inst *inst)
{
	int rc = 0;
	int value = 0, hflip = 0, vflip = 0;
	struct hfi_device *hdev;
	struct hfi_vpe_rotation_type vpe_rotation;
	struct hfi_frame_size frame_sz;

	hdev = inst->core->device;

	/* Set rotation and flip first */
	value = msm_comm_g_ctrl_for_id(inst, V4L2_CID_ROTATE);
	if (value < 0) {
		dprintk(VIDC_ERR, "Get control for rotation failed\n");
		return value;
	}

	vpe_rotation.rotation = HFI_ROTATE_NONE;
	if (value == 90)
		vpe_rotation.rotation = HFI_ROTATE_90;
	else if (value == 180)
		vpe_rotation.rotation = HFI_ROTATE_180;
	else if (value ==  270)
		vpe_rotation.rotation = HFI_ROTATE_270;

	hflip = msm_comm_g_ctrl_for_id(inst, V4L2_CID_HFLIP);
	if (hflip < 0) {
		dprintk(VIDC_ERR, "Get control for hflip failed\n");
		return value;
	}

	vflip = msm_comm_g_ctrl_for_id(inst, V4L2_CID_VFLIP);
	if (vflip < 0) {
		dprintk(VIDC_ERR, "Get control for vflip failed\n");
		return value;
	}

	vpe_rotation.flip = HFI_FLIP_NONE;
	if ((hflip == V4L2_MPEG_MSM_VIDC_ENABLE) &&
		(vflip == V4L2_MPEG_MSM_VIDC_ENABLE))
		vpe_rotation.flip = HFI_FLIP_HORIZONTAL | HFI_FLIP_VERTICAL;
	else if (hflip == V4L2_MPEG_MSM_VIDC_ENABLE)
		vpe_rotation.flip = HFI_FLIP_HORIZONTAL;
	else if (vflip == V4L2_MPEG_MSM_VIDC_ENABLE)
		vpe_rotation.flip = HFI_FLIP_VERTICAL;

	dprintk(VIDC_DBG, "Set rotation = %d, flip = %d for capture port.\n",
			vpe_rotation.rotation, vpe_rotation.flip);
	rc = call_hfi_op(hdev, session_set_property,
				(void *)inst->session,
				HFI_PROPERTY_PARAM_VPE_ROTATION,
				&vpe_rotation, sizeof(vpe_rotation));
	if (rc) {
		dprintk(VIDC_ERR, "Set rotation/flip at start stream failed\n");
		return rc;
	}

	/* flip the output resolution if required */
	if (vpe_rotation.rotation == HFI_ROTATE_90 ||
		vpe_rotation.rotation == HFI_ROTATE_270) {
		frame_sz.buffer_type = HFI_BUFFER_OUTPUT;
		frame_sz.width = inst->prop.height[CAPTURE_PORT];
		frame_sz.height = inst->prop.width[CAPTURE_PORT];
		dprintk(VIDC_DBG, "CAPTURE port width = %d, height = %d\n",
			frame_sz.width, frame_sz.height);
		rc = call_hfi_op(hdev, session_set_property, (void *)
			inst->session, HFI_PROPERTY_PARAM_FRAME_SIZE,
			&frame_sz, sizeof(frame_sz));
		if (rc) {
			dprintk(VIDC_ERR,
				"Failed to set framesize for CAPTURE port\n");
			return rc;
		}
	}
	return rc;
}

static int msm_vidc_set_properties(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -904,15 +827,8 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
	}

	b.buffer_type = HFI_BUFFER_OUTPUT;
	if (inst->session_type == MSM_VIDC_ENCODER) {
		rc = msm_vidc_set_rotation(inst);
		if (rc) {
			dprintk(VIDC_ERR,
				"Set rotation for encoder failed %pK\n", inst);
			goto fail_start;
		}
	} else if ((inst->session_type == MSM_VIDC_DECODER) &&
			(is_secondary_output_mode(inst)))
	if (inst->session_type == MSM_VIDC_DECODER &&
		is_secondary_output_mode(inst))
		b.buffer_type = HFI_BUFFER_OUTPUT2;

	/* HEIC HW/FWK tiling encode is supported only for CQ RC mode */