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

Commit 68251b15 authored by Praneeth Paladugu's avatar Praneeth Paladugu Committed by Vikash Garodia
Browse files

msm: vidc: Add support for querying controls



Add support in driver to query for control information.
This helps clients to findout limits for various controls
and sets the values accordingly.

Also update the control limits based on Venus HW capabilities.
This helps to prevent rogue clients not to set invalid values
to HW.

CRs-Fixed: 2003998
Change-Id: Ib444aba2203c898f778f4d7c0bc086ecc07461af
Signed-off-by: default avatarVikash Garodia <vgarodia@codeaurora.org>
parent 5a092dc8
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -222,6 +222,14 @@ static int msm_v4l2_enum_framesizes(struct file *file, void *fh,
	return msm_vidc_enum_framesizes((void *)vidc_inst, fsize);
}

static int msm_v4l2_queryctrl(struct file *file, void *fh,
	struct v4l2_queryctrl *ctrl)
{
	struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);

	return msm_vidc_query_ctrl((void *)vidc_inst, ctrl);
}

static const struct v4l2_ioctl_ops msm_v4l2_ioctl_ops = {
	.vidioc_querycap = msm_v4l2_querycap,
	.vidioc_enum_fmt_vid_cap_mplane = msm_v4l2_enum_fmt,
@@ -238,6 +246,7 @@ static const struct v4l2_ioctl_ops msm_v4l2_ioctl_ops = {
	.vidioc_streamoff = msm_v4l2_streamoff,
	.vidioc_s_ctrl = msm_v4l2_s_ctrl,
	.vidioc_g_ctrl = msm_v4l2_g_ctrl,
	.vidioc_queryctrl = msm_v4l2_queryctrl,
	.vidioc_s_ext_ctrls = msm_v4l2_s_ext_ctrl,
	.vidioc_subscribe_event = msm_v4l2_subscribe_event,
	.vidioc_unsubscribe_event = msm_v4l2_unsubscribe_event,
+28 −0
Original line number Diff line number Diff line
@@ -110,6 +110,34 @@ int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f)
}
EXPORT_SYMBOL(msm_vidc_enum_fmt);

int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl)
{
	struct msm_vidc_inst *inst = instance;
	int rc = 0;

	if (!inst || !ctrl)
		return -EINVAL;

	switch (ctrl->id) {
	case V4L2_CID_MPEG_VIDC_VIDEO_HYBRID_HIERP_MODE:
		ctrl->maximum = inst->capability.hier_p_hybrid.max;
		ctrl->minimum = inst->capability.hier_p_hybrid.min;
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_HIER_B_NUM_LAYERS:
		ctrl->maximum = inst->capability.hier_b.max;
		ctrl->minimum = inst->capability.hier_b.min;
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_HIER_P_NUM_LAYERS:
		ctrl->maximum = inst->capability.hier_p.max;
		ctrl->minimum = inst->capability.hier_p.min;
		break;
	default:
		rc = -EINVAL;
	}
	return rc;
}
EXPORT_SYMBOL(msm_vidc_query_ctrl);

int msm_vidc_s_fmt(void *instance, struct v4l2_format *f)
{
	struct msm_vidc_inst *inst = instance;
+50 −0
Original line number Diff line number Diff line
@@ -959,6 +959,48 @@ static void print_cap(const char *type,
		type, cap->min, cap->max, cap->step_size);
}


static void msm_vidc_comm_update_ctrl_limits(struct msm_vidc_inst *inst)
{
	struct v4l2_ctrl *ctrl = NULL;

	ctrl = v4l2_ctrl_find(&inst->ctrl_handler,
		V4L2_CID_MPEG_VIDC_VIDEO_HYBRID_HIERP_MODE);
	if (ctrl) {
		v4l2_ctrl_modify_range(ctrl, inst->capability.hier_p_hybrid.min,
			inst->capability.hier_p_hybrid.max, ctrl->step,
			inst->capability.hier_p_hybrid.min);
		dprintk(VIDC_DBG,
			"%s: Updated Range = %lld --> %lld Def value = %lld\n",
			ctrl->name, ctrl->minimum, ctrl->maximum,
			ctrl->default_value);
	}

	ctrl = v4l2_ctrl_find(&inst->ctrl_handler,
		V4L2_CID_MPEG_VIDC_VIDEO_HIER_B_NUM_LAYERS);
	if (ctrl) {
		v4l2_ctrl_modify_range(ctrl, inst->capability.hier_b.min,
			inst->capability.hier_b.max, ctrl->step,
			inst->capability.hier_b.min);
		dprintk(VIDC_DBG,
			"%s: Updated Range = %lld --> %lld Def value = %lld\n",
			ctrl->name, ctrl->minimum, ctrl->maximum,
			ctrl->default_value);
	}

	ctrl = v4l2_ctrl_find(&inst->ctrl_handler,
		V4L2_CID_MPEG_VIDC_VIDEO_HIER_P_NUM_LAYERS);
	if (ctrl) {
		v4l2_ctrl_modify_range(ctrl, inst->capability.hier_p.min,
			inst->capability.hier_p.max, ctrl->step,
			inst->capability.hier_p.min);
		dprintk(VIDC_DBG,
			"%s: Updated Range = %lld --> %lld Def value = %lld\n",
			ctrl->name, ctrl->minimum, ctrl->maximum,
			ctrl->default_value);
	}
}

static void handle_session_init_done(enum hal_command_response cmd, void *data)
{
	struct msm_vidc_cb_cmd_done *response = data;
@@ -1052,8 +1094,16 @@ static void handle_session_init_done(enum hal_command_response cmd, void *data)
	print_cap("ltr_count", &inst->capability.ltr_count);
	print_cap("mbs_per_sec_low_power",
		&inst->capability.mbs_per_sec_power_save);
	print_cap("hybrid-hp", &inst->capability.hier_p_hybrid);

	signal_session_msg_receipt(cmd, inst);

	/*
	 * Update controls after informing session_init_done to avoid
	 * timeouts.
	 */

	msm_vidc_comm_update_ctrl_limits(inst);
	put_inst(inst);
}

+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -110,6 +110,7 @@ int msm_vidc_release_buffers(void *instance, int buffer_type);
int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b);
int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b);
int msm_vidc_streamon(void *instance, enum v4l2_buf_type i);
int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl);
int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i);
int msm_vidc_comm_cmd(void *instance, union msm_v4l2_cmd *cmd);
int msm_vidc_poll(void *instance, struct file *filp,