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

Commit 13c90969 authored by Praneeth Paladugu's avatar Praneeth Paladugu
Browse files

msm: vidc: Enhance the buffer count exchange model



Use extended controls to exchange the buffer counts between
clients and driver. This will give more flexibility for clients
to set the buffer counts.

CRs-Fixed: 2022735
Change-Id: I2e056aa3e83bd47f9b0444775f579f2b7e1d396c
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
parent 24806ed6
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -135,6 +135,14 @@ int msm_v4l2_s_ext_ctrl(struct file *file, void *fh,
	return msm_vidc_s_ext_ctrl((void *)vidc_inst, a);
}

int msm_v4l2_g_ext_ctrl(struct file *file, void *fh,
					struct v4l2_ext_controls *a)
{
	struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);

	return msm_vidc_g_ext_ctrl((void *)vidc_inst, a);
}

int msm_v4l2_reqbufs(struct file *file, void *fh,
				struct v4l2_requestbuffers *b)
{
@@ -250,6 +258,7 @@ static const struct v4l2_ioctl_ops msm_v4l2_ioctl_ops = {
	.vidioc_g_ctrl = msm_v4l2_g_ctrl,
	.vidioc_queryctrl = msm_v4l2_queryctrl,
	.vidioc_s_ext_ctrls = msm_v4l2_s_ext_ctrl,
	.vidioc_g_ext_ctrls = msm_v4l2_g_ext_ctrl,
	.vidioc_subscribe_event = msm_v4l2_subscribe_event,
	.vidioc_unsubscribe_event = msm_v4l2_unsubscribe_event,
	.vidioc_decoder_cmd = msm_v4l2_decoder_cmd,
+69 −11
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@

static int try_get_ctrl(struct msm_vidc_inst *inst,
	struct v4l2_ctrl *ctrl);
static int msm_vidc_get_count(struct msm_vidc_inst *inst,
	struct v4l2_ctrl *ctrl);

static int get_poll_flags(void *instance)
{
@@ -274,6 +276,40 @@ int msm_vidc_g_ctrl(void *instance, struct v4l2_control *control)
}
EXPORT_SYMBOL(msm_vidc_g_ctrl);

int msm_vidc_g_ext_ctrl(void *instance, struct v4l2_ext_controls *control)
{
	struct msm_vidc_inst *inst = instance;
	struct v4l2_ext_control *ext_control;
	struct v4l2_ctrl ctrl;
	int i = 0, rc = 0;

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

	ext_control = control->controls;

	for (i = 0; i < control->count; i++) {
		switch (ext_control[i].id) {
		case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
		case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
			ctrl.id = ext_control[i].id;
			ctrl.val = ext_control[i].value;

			msm_vidc_get_count(inst, &ctrl);
			ext_control->value = ctrl.val;
			break;
		default:
			dprintk(VIDC_ERR,
				"This control %x is not supported yet\n",
					ext_control[i].id);
			rc = -EINVAL;
			break;
		}
	}
	return rc;
}
EXPORT_SYMBOL(msm_vidc_g_ext_ctrl);

int msm_vidc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *control)
{
	struct msm_vidc_inst *inst = instance;
@@ -1187,6 +1223,8 @@ static int set_buffer_count(struct msm_vidc_inst *inst,
	buf_count.buffer_type = type;
	buf_count.buffer_count_actual = act_count;
	buf_count.buffer_count_min_host = host_count;
	dprintk(VIDC_DBG, "%s : Act count = %d Host count = %d\n",
		__func__, act_count, host_count);
	rc = call_hfi_op(hdev, session_set_property,
		inst->session, HAL_PARAM_BUFFER_COUNT_ACTUAL, &buf_count);
	if (rc)
@@ -1839,23 +1877,21 @@ static int msm_vidc_get_count(struct msm_vidc_inst *inst,
static int try_get_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
{
	int rc = 0;

	/*
	 * HACK: unlock the control prior to querying the hardware.  Otherwise
	 * lower level code that attempts to do g_ctrl() will end up deadlocking
	 * us.
	 */
	struct hal_buffer_requirements *bufreq = NULL;
	enum hal_buffer buffer_type;

	switch (ctrl->id) {

	case V4L2_CID_MPEG_VIDEO_H264_PROFILE:
	case V4L2_CID_MPEG_VIDC_VIDEO_VP8_PROFILE_LEVEL:
	case V4L2_CID_MPEG_VIDC_VIDEO_MPEG2_PROFILE:
	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_PROFILE:
		ctrl->val = inst->profile;
		break;

	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
	case V4L2_CID_MPEG_VIDC_VIDEO_MPEG2_LEVEL:
	case V4L2_CID_MPEG_VIDC_VIDEO_HEVC_TIER_LEVEL:
		ctrl->val = inst->level;
		break;

@@ -1864,8 +1900,29 @@ static int try_get_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
		break;

	case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
		if (inst->in_reconfig)
			msm_comm_try_get_bufreqs(inst);

		buffer_type = msm_comm_get_hal_output_buffer(inst);
		bufreq = get_buff_req_buffer(inst,
			buffer_type);
		if (!bufreq) {
			dprintk(VIDC_ERR,
				"Failed to find bufreqs for buffer type = %d\n",
					buffer_type);
			return -EINVAL;
		}
		ctrl->val = bufreq->buffer_count_min_host;
		break;
	case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
		rc = msm_vidc_get_count(inst, ctrl);
		bufreq = get_buff_req_buffer(inst, HAL_BUFFER_INPUT);
		if (!bufreq) {
			dprintk(VIDC_ERR,
				"Failed to find bufreqs for buffer type = %d\n",
					HAL_BUFFER_INPUT);
			return -EINVAL;
		}
		ctrl->val = bufreq->buffer_count_min_host;
		break;
	default:
		/*
@@ -2031,6 +2088,7 @@ void *msm_vidc_open(int core_id, int session_type)
		goto fail_init;
	}

	msm_dcvs_try_enable(inst);
	if (msm_vidc_check_for_inst_overload(core)) {
		dprintk(VIDC_ERR,
			"Instance count reached Max limit, rejecting session");
+1 −2
Original line number Diff line number Diff line
@@ -4094,9 +4094,8 @@ int msm_comm_try_get_bufreqs(struct msm_vidc_inst *inst)
	dprintk(VIDC_DBG, "%15s %8s %8s %8s %8s\n",
		"buffer type", "count", "mincount_host", "mincount_fw", "size");
	for (i = 0; i < HAL_BUFFER_MAX; i++) {
		struct hal_buffer_requirements req = hprop.buf_req.buffer[i];
		struct hal_buffer_requirements req = inst->buff_req.buffer[i];

		inst->buff_req.buffer[i] = req;
		if (req.buffer_type != HAL_BUFFER_NONE) {
			dprintk(VIDC_DBG, "%15s %8d %8d %8d %8d\n",
				get_buffer_name(req.buffer_type),
+1 −0
Original line number Diff line number Diff line
@@ -103,6 +103,7 @@ int msm_vidc_s_fmt(void *instance, struct v4l2_format *f);
int msm_vidc_g_fmt(void *instance, struct v4l2_format *f);
int msm_vidc_s_ctrl(void *instance, struct v4l2_control *a);
int msm_vidc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
int msm_vidc_g_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
int msm_vidc_g_ctrl(void *instance, struct v4l2_control *a);
int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
int msm_vidc_release_buffer(void *instance, int buffer_type,