Commit 096573e4 authored by Viswanath Boma's avatar Viswanath Boma Committed by Mauro Carvalho Chehab
Browse files

media: venus : Addition of control support - V4L2_CID_MIN_BUFFERS_FOR_OUTPUT



V4l2 encoder compliance expecting minimum buffers support for
the application to allocate buffers as per the control support values.

Signed-off-by: default avatarViswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: default avatarVikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 014a6b27
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@

#include "core.h"
#include "venc.h"
#include "helpers.h"

#define BITRATE_MIN		32000
#define BITRATE_MAX		160000000
@@ -348,8 +349,29 @@ static int venc_op_s_ctrl(struct v4l2_ctrl *ctrl)
	return 0;
}

static int venc_op_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
{
	struct venus_inst *inst = ctrl_to_inst(ctrl);
	struct hfi_buffer_requirements bufreq;
	enum hfi_version ver = inst->core->res->hfi_version;
	int ret;

	switch (ctrl->id) {
	case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
		ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
		if (!ret)
			ctrl->val = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
		break;
	default:
		return -EINVAL;
	}

	return 0;
}

static const struct v4l2_ctrl_ops venc_ctrl_ops = {
	.s_ctrl = venc_op_s_ctrl,
	.g_volatile_ctrl = venc_op_g_volatile_ctrl,
};

int venc_ctrl_init(struct venus_inst *inst)
@@ -360,7 +382,7 @@ int venc_ctrl_init(struct venus_inst *inst)
		{ 16000, 34500, 3000 }, 15635, 16450, 10000000, 500,
	};

	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 58);
	ret = v4l2_ctrl_handler_init(&inst->ctrl_handler, 59);
	if (ret)
		return ret;

@@ -440,6 +462,9 @@ int venc_ctrl_init(struct venus_inst *inst)
		V4L2_MPEG_VIDEO_VP8_PROFILE_3,
		0, V4L2_MPEG_VIDEO_VP8_PROFILE_0);

	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
			  V4L2_CID_MIN_BUFFERS_FOR_OUTPUT, 4, 11, 1, 4);

	v4l2_ctrl_new_std(&inst->ctrl_handler, &venc_ctrl_ops,
		V4L2_CID_MPEG_VIDEO_BITRATE, BITRATE_MIN, BITRATE_MAX,
		BITRATE_STEP, BITRATE_DEFAULT);