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

Commit 0c93b5f9 authored by Zhongbo Shi's avatar Zhongbo Shi
Browse files

msm: vidc: defer set rotation/flip and swapped output resolution



Defer set rotation/flip and swapped output resolution to HAL
during start of streaming.

Change-Id: Id0f088ee9ad38dacb1b8219d6b44d3075fd8c8c9
Signed-off-by: default avatarZhongbo Shi <zhongbos@codeaurora.org>
parent da0130a5
Loading
Loading
Loading
Loading
+2 −17
Original line number Diff line number Diff line
@@ -1296,7 +1296,6 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	enum hal_h264_entropy h264_entropy;
	struct hal_intra_period intra_period;
	struct hal_idr_period idr_period;
	struct hal_vpe_rotation vpe_rotation;
	struct hal_intra_refresh intra_refresh;
	struct hal_multi_slice_control multi_slice_control;
	struct hal_h264_db_control h264_db_control;
@@ -1594,31 +1593,17 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
		break;
	case V4L2_CID_ROTATE:
	{
		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDC_VIDEO_FLIP);
		property_id = HAL_PARAM_VPE_ROTATION;

		if (ctrl->val != 0 && ctrl->val != 90
			&& ctrl->val != 180 && ctrl->val != 270) {
			dprintk(VIDC_ERR, "Invalid rotation angle");
			rc = -ENOTSUPP;
		}

		vpe_rotation.rotate = ctrl->val;
		vpe_rotation.flip = msm_comm_v4l2_to_hal(
				V4L2_CID_MPEG_VIDC_VIDEO_FLIP,
				temp_ctrl->val);
		pdata = &vpe_rotation;
		dprintk(VIDC_DBG, "Rotation %d\n", ctrl->val);
		break;
	}
	case V4L2_CID_MPEG_VIDC_VIDEO_FLIP:
	{
		temp_ctrl = TRY_GET_CTRL(V4L2_CID_ROTATE);
		property_id = HAL_PARAM_VPE_ROTATION;
		vpe_rotation.rotate = temp_ctrl->val;
		vpe_rotation.flip = msm_comm_v4l2_to_hal(
				V4L2_CID_MPEG_VIDC_VIDEO_FLIP,
				ctrl->val);
		pdata = &vpe_rotation;
		dprintk(VIDC_DBG, "Flip %d\n", ctrl->val);
		break;
	}
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE: {
+60 −0
Original line number Diff line number Diff line
@@ -994,6 +994,57 @@ int msm_vidc_set_internal_config(struct msm_vidc_inst *inst)
	return rc;
}

static int msm_vidc_set_rotation(struct msm_vidc_inst *inst)
{
	int rc = 0;
	int value = 0;
	struct hfi_device *hdev;
	struct hal_vpe_rotation vpe_rotation;
	struct hal_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.rotate = value;
	value = msm_comm_g_ctrl_for_id(inst, V4L2_CID_MPEG_VIDC_VIDEO_FLIP);
	if (value < 0) {
		dprintk(VIDC_ERR, "Get control for flip failed\n");
		return value;
	}
	vpe_rotation.flip = value;
	dprintk(VIDC_DBG, "Set rotation = %d, flip = %d for capture port.\n",
			vpe_rotation.rotate, vpe_rotation.flip);
	rc = call_hfi_op(hdev, session_set_property,
				(void *)inst->session,
				HAL_PARAM_VPE_ROTATION, &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.rotate == 90 || vpe_rotation.rotate == 270) {
		frame_sz.buffer_type = HAL_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, HAL_PARAM_FRAME_SIZE, &frame_sz);
		if (rc) {
			dprintk(VIDC_ERR,
				"Failed to set framesize for CAPTURE port\n");
			return rc;
		}
	}
	return rc;
}

static inline int start_streaming(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -1005,6 +1056,15 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
		hash32_ptr(inst->session), inst);
	hdev = inst->core->device;

	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");
			goto fail_start;
		}
	}

	rc_mode =  msm_comm_g_ctrl_for_id(inst,
		V4L2_CID_MPEG_VIDEO_BITRATE_MODE);
	/* HEIC HW/FWK tiling encode is supported only for CQ RC mode */
+0 −30
Original line number Diff line number Diff line
@@ -5437,7 +5437,6 @@ int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
{
	u32 x_min, x_max, y_min, y_max;
	u32 input_height, input_width, output_height, output_width;
	u32 rotation;

	if (inst->grid_enable > 0) {
		dprintk(VIDC_DBG, "Skip scaling check for HEIC\n");
@@ -5478,20 +5477,6 @@ int msm_vidc_check_scaling_supported(struct msm_vidc_inst *inst)
		return 0;
	}

	rotation =  msm_comm_g_ctrl_for_id(inst,
					V4L2_CID_ROTATE);

	if ((output_width != output_height) &&
		(rotation == 90 ||
		rotation == 270)) {

		output_width = inst->prop.height[CAPTURE_PORT];
		output_height = inst->prop.width[CAPTURE_PORT];
		dprintk(VIDC_DBG,
			"Rotation=%u Swapped Output W=%u H=%u to check scaling",
			rotation, output_width, output_height);
	}

	x_min = (1<<16)/inst->capability.scale_x.min;
	y_min = (1<<16)/inst->capability.scale_y.min;
	x_max = inst->capability.scale_x.max >> 16;
@@ -5537,7 +5522,6 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
	struct hfi_device *hdev;
	struct msm_vidc_core *core;
	u32 output_height, output_width, input_height, input_width;
	u32 rotation;

	if (!inst || !inst->core || !inst->core->device) {
		dprintk(VIDC_WARN, "%s: Invalid parameter\n", __func__);
@@ -5576,23 +5560,9 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
		rc = -ENOTSUPP;
	}

	rotation =  msm_comm_g_ctrl_for_id(inst,
					V4L2_CID_ROTATE);

	output_height = ALIGN(inst->prop.height[CAPTURE_PORT], 16);
	output_width = ALIGN(inst->prop.width[CAPTURE_PORT], 16);

	if ((output_width != output_height) &&
		(rotation == 90 ||
		rotation == 270)) {

		output_width = ALIGN(inst->prop.height[CAPTURE_PORT], 16);
		output_height = ALIGN(inst->prop.width[CAPTURE_PORT], 16);
		dprintk(VIDC_DBG,
			"Rotation=%u Swapped Output W=%u H=%u to check capability",
			rotation, output_width, output_height);
	}

	if (!rc) {
		if (output_width < capability->width.min ||
			output_height < capability->height.min) {