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

Commit 2763dd1a authored by Chinmay Sawarkar's avatar Chinmay Sawarkar Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: Handle rotation during capability check



When rotation is 90 or 270, width and height must be swapped,
before checking against the capability, to prevent rejection
of valid session.

CRs-Fixed: 2085881
Change-Id: I0495db10ff652e2a2b3c338a7aa9223de2ea2384
Signed-off-by: default avatarChinmay Sawarkar <chinmays@codeaurora.org>
parent 8e0e97e8
Loading
Loading
Loading
Loading
+27 −12
Original line number Original line Diff line number Diff line
@@ -5158,6 +5158,8 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
	int rc = 0;
	int rc = 0;
	struct hfi_device *hdev;
	struct hfi_device *hdev;
	struct msm_vidc_core *core;
	struct msm_vidc_core *core;
	u32 output_height, output_width;
	u32 rotation;


	if (!inst || !inst->core || !inst->core->device) {
	if (!inst || !inst->core || !inst->core->device) {
		dprintk(VIDC_WARN, "%s: Invalid parameter\n", __func__);
		dprintk(VIDC_WARN, "%s: Invalid parameter\n", __func__);
@@ -5179,34 +5181,47 @@ int msm_vidc_check_session_supported(struct msm_vidc_inst *inst)
		return -ENOTSUPP;
		return -ENOTSUPP;
	}
	}


	rotation =  msm_comm_g_ctrl_for_id(inst,
					V4L2_CID_MPEG_VIDC_VIDEO_ROTATION);

	output_height = inst->prop.height[CAPTURE_PORT];
	output_width = inst->prop.width[CAPTURE_PORT];

	if ((output_width != output_height) &&
		(rotation == V4L2_CID_MPEG_VIDC_VIDEO_ROTATION_90 ||
		rotation == V4L2_CID_MPEG_VIDC_VIDEO_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 capability",
			rotation, output_width, output_height);
	}

	if (!rc) {
	if (!rc) {
		if (inst->prop.width[CAPTURE_PORT] < capability->width.min ||
		if (output_width < capability->width.min ||
			inst->prop.height[CAPTURE_PORT] <
			output_height < capability->height.min) {
			capability->height.min) {
			dprintk(VIDC_ERR,
			dprintk(VIDC_ERR,
				"Unsupported WxH = (%u)x(%u), min supported is - (%u)x(%u)\n",
				"Unsupported WxH = (%u)x(%u), min supported is - (%u)x(%u)\n",
				inst->prop.width[CAPTURE_PORT],
				output_width,
				inst->prop.height[CAPTURE_PORT],
				output_height,
				capability->width.min,
				capability->width.min,
				capability->height.min);
				capability->height.min);
			rc = -ENOTSUPP;
			rc = -ENOTSUPP;
		}
		}
		if (!rc && inst->prop.width[CAPTURE_PORT] >
		if (!rc && output_width > capability->width.max) {
			capability->width.max) {
			dprintk(VIDC_ERR,
			dprintk(VIDC_ERR,
				"Unsupported width = %u supported max width = %u\n",
				"Unsupported width = %u supported max width = %u\n",
				inst->prop.width[CAPTURE_PORT],
				output_width,
				capability->width.max);
				capability->width.max);
				rc = -ENOTSUPP;
				rc = -ENOTSUPP;
		}
		}


		if (!rc && inst->prop.height[CAPTURE_PORT]
		if (!rc && output_height * output_width >
			* inst->prop.width[CAPTURE_PORT] >
			capability->width.max * capability->height.max) {
			capability->width.max * capability->height.max) {
			dprintk(VIDC_ERR,
			dprintk(VIDC_ERR,
			"Unsupported WxH = (%u)x(%u), max supported is - (%u)x(%u)\n",
			"Unsupported WxH = (%u)x(%u), max supported is - (%u)x(%u)\n",
			inst->prop.width[CAPTURE_PORT],
			output_width, output_height,
			inst->prop.height[CAPTURE_PORT],
			capability->width.max, capability->height.max);
			capability->width.max, capability->height.max);
			rc = -ENOTSUPP;
			rc = -ENOTSUPP;
		}
		}