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

Commit 23fdc179 authored by Akshay Chandrashekhar Kalghatgi's avatar Akshay Chandrashekhar Kalghatgi
Browse files

msm: vidc: Support ioctl VIDIOC_ENUM_FRAMESIZES



Changed ioctl VIDIOC_ENUM_FRAMESIZES behavior in conformance with
V4L2 specification to be able to query based on pixel format.

Change-Id: Ia5803341070d14335cbb939108575f835471a857
Signed-off-by: default avatarAkshay Chandrashekhar Kalghatgi <akalghat@codeaurora.org>
parent 8480d22d
Loading
Loading
Loading
Loading
+31 −8
Original line number Diff line number Diff line
@@ -1198,6 +1198,8 @@ int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize)
{
	struct msm_vidc_inst *inst = instance;
	struct msm_vidc_capability *capability = NULL;
	enum hal_video_codec codec;
	int i;

	if (!inst || !fsize) {
		dprintk(VIDC_ERR, "%s: invalid parameter: %pK %pK\n",
@@ -1206,15 +1208,36 @@ int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize)
	}
	if (!inst->core)
		return -EINVAL;
	if (fsize->index != 0)
		return -EINVAL;

	codec = get_hal_codec(fsize->pixel_format);
	if (codec == HAL_UNUSED_CODEC)
		return -EINVAL;

	capability = &inst->capability;
	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
	for (i = 0; i < VIDC_MAX_SESSIONS; i++) {
		if (inst->core->capabilities[i].codec == codec) {
			capability = &inst->core->capabilities[i];
			break;
		}
	}

	if (capability) {
		fsize->type = capability->width.step_size == 1 &&
				capability->height.step_size == 1 ?
				V4L2_FRMSIZE_TYPE_CONTINUOUS :
				V4L2_FRMSIZE_TYPE_STEPWISE;
		fsize->stepwise.min_width = capability->width.min;
		fsize->stepwise.max_width = capability->width.max;
		fsize->stepwise.step_width = capability->width.step_size;
		fsize->stepwise.min_height = capability->height.min;
		fsize->stepwise.max_height = capability->height.max;
		fsize->stepwise.step_height = capability->height.step_size;
	} else {
		dprintk(VIDC_ERR, "%s: Invalid Pixel Fmt %#x\n",
				__func__, fsize->pixel_format);
		return -EINVAL;
	}
	return 0;
}
EXPORT_SYMBOL(msm_vidc_enum_framesizes);