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

Commit 9aff11cf authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: Fix setting frame rate control"

parents 46239a01 80f2b9ef
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -192,20 +192,6 @@ static int msm_v4l2_encoder_cmd(struct file *file, void *fh,
	return msm_vidc_comm_cmd((void *)vidc_inst, (union msm_v4l2_cmd *)enc);
}

static int msm_v4l2_s_parm(struct file *file, void *fh,
			struct v4l2_streamparm *a)
{
	struct msm_vidc_inst *vidc_inst = get_vidc_inst(file, fh);

	return msm_vidc_s_parm(vidc_inst, a);
}

static int msm_v4l2_g_parm(struct file *file, void *fh,
		struct v4l2_streamparm *a)
{
	return 0;
}

static int msm_v4l2_enum_framesizes(struct file *file, void *fh,
				struct v4l2_frmsizeenum *fsize)
{
@@ -251,8 +237,6 @@ const struct v4l2_ioctl_ops msm_v4l2_ioctl_ops = {
	.vidioc_unsubscribe_event = msm_v4l2_unsubscribe_event,
	.vidioc_decoder_cmd = msm_v4l2_decoder_cmd,
	.vidioc_encoder_cmd = msm_v4l2_encoder_cmd,
	.vidioc_s_parm = msm_v4l2_s_parm,
	.vidioc_g_parm = msm_v4l2_g_parm,
	.vidioc_enum_framesizes = msm_v4l2_enum_framesizes,
	.vidioc_default = msm_v4l2_default,
};
+20 −11
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@
/* Y=16(0-9bits), Cb(10-19bits)=Cr(20-29bits)=128, black by default */
#define DEFAULT_VIDEO_CONCEAL_COLOR_BLACK 0x8020010
#define MB_SIZE_IN_PIXEL (16 * 16)
#define DEFAULT_OPERATING_RATE 30
#define OPERATING_FRAME_RATE_STEP (1 << 16)
#define MAX_VP9D_INST_COUNT 6
#define MAX_4K_MBPF 38736 /* (4096 * 2304 / 256) */

@@ -444,6 +442,17 @@ static struct msm_vidc_ctrl msm_vdec_ctrls[] = {
		.qmenu = mpeg_vidc_video_entropy_mode,
		.flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE,
		.name = "Frame Rate",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = (MINIMUM_FPS << 16),
		.maximum = (MAXIMUM_FPS << 16),
		.default_value = (DEFAULT_FPS << 16),
		.step = 1,
		.menu_skip_mask = 0,
		.qmenu = NULL,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_PRIORITY,
		.name = "Session Priority",
@@ -457,10 +466,12 @@ static struct msm_vidc_ctrl msm_vdec_ctrls[] = {
		.id = V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE,
		.name = "Set Decoder Operating rate",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 0,
		.minimum = (MINIMUM_FPS << 16),
		.maximum = INT_MAX,
		.default_value =  (DEFAULT_OPERATING_RATE << 16),
		.default_value =  (DEFAULT_FPS << 16),
		.step = 1,
		.menu_skip_mask = 0,
		.qmenu = NULL,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_LOWLATENCY_MODE,
@@ -865,8 +876,8 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
		VENUS_EXTRADATA_SIZE(
			inst->prop.height[CAPTURE_PORT],
			inst->prop.width[CAPTURE_PORT]);
	inst->prop.fps = DEFAULT_FPS;
	inst->clk_data.operating_rate = 0;
	inst->clk_data.frame_rate = (DEFAULT_FPS << 16);
	inst->clk_data.operating_rate = (DEFAULT_FPS << 16);
	if (core->resources.decode_batching)
		inst->batch.size = MAX_DEC_BATCH_SIZE;

@@ -1003,6 +1014,9 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
		if (ctrl->val)
			inst->flags |= VIDC_SECURE;
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE:
		inst->clk_data.frame_rate = ctrl->val;
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA:
		inst->bufq[CAPTURE_PORT].num_planes = 1;
		inst->bufq[CAPTURE_PORT].plane_sizes[1] = 0;
@@ -1729,11 +1743,6 @@ int msm_vdec_set_properties(struct msm_vidc_inst *inst)
	return rc;
}

int msm_vdec_s_parm(struct msm_vidc_inst *inst, struct v4l2_streamparm *a)
{
	return msm_vidc_comm_s_parm(inst, a);
}

int msm_vdec_ctrl_init(struct msm_vidc_inst *inst,
	const struct v4l2_ctrl_ops *ctrl_ops)
{
+1 −3
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */
#ifndef _MSM_VDEC_H_
#define _MSM_VDEC_H_
@@ -20,7 +20,5 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst,
		struct v4l2_ctrl *ctrl);
int msm_vdec_g_ctrl(struct msm_vidc_inst *inst,
		struct v4l2_ctrl *ctrl);
int msm_vdec_s_parm(struct msm_vidc_inst *inst,
		struct v4l2_streamparm *a);
int msm_vdec_set_properties(struct msm_vidc_inst *inst);
#endif
+57 −44
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@
#define MAX_BIT_RATE 1200000000
#define DEFAULT_BIT_RATE 64000
#define BIT_RATE_STEP 1
#define DEFAULT_FRAME_RATE 15
#define DEFAULT_OPERATING_RATE DEFAULT_FRAME_RATE
#define OPERATING_FRAME_RATE_STEP (1 << 16)
#define MAX_SLICE_BYTE_SIZE ((MAX_BIT_RATE)>>3)
#define MIN_SLICE_BYTE_SIZE 512
#define NUM_MBS_720P (((1280 + 15) >> 4) * ((720 + 15) >> 4))
@@ -101,7 +98,7 @@ static struct msm_vidc_ctrl msm_venc_ctrls[] = {
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 0,
		.maximum = INT_MAX,
		.default_value = 2*DEFAULT_FRAME_RATE-1,
		.default_value = 2*DEFAULT_FPS-1,
		.step = 1,
		.menu_skip_mask = 0,
		.qmenu = NULL,
@@ -248,6 +245,17 @@ static struct msm_vidc_ctrl msm_venc_ctrls[] = {
		.menu_skip_mask = 0,
		.qmenu = NULL,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE,
		.name = "Frame Rate",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = (MINIMUM_FPS << 16),
		.maximum = (MAXIMUM_FPS << 16),
		.default_value = (DEFAULT_FPS << 16),
		.step = 1,
		.menu_skip_mask = 0,
		.qmenu = NULL,
	},
	{
		.id = V4L2_CID_MPEG_VIDEO_BITRATE,
		.name = "Bit Rate",
@@ -783,10 +791,12 @@ static struct msm_vidc_ctrl msm_venc_ctrls[] = {
		.id = V4L2_CID_MPEG_VIDC_VIDEO_OPERATING_RATE,
		.name = "Set Encoder Operating rate",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 0,
		.minimum = (MINIMUM_FPS << 16),
		.maximum = INT_MAX,
		.default_value = (DEFAULT_OPERATING_RATE << 16),
		.default_value = (DEFAULT_FPS << 16),
		.step = 1,
		.menu_skip_mask = 0,
		.qmenu = NULL,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_VPE_CSC,
@@ -1143,12 +1153,12 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
	inst->capability.secure_output2_threshold.max = 0;
	inst->buffer_mode_set[OUTPUT_PORT] = HAL_BUFFER_MODE_DYNAMIC;
	inst->buffer_mode_set[CAPTURE_PORT] = HAL_BUFFER_MODE_STATIC;
	inst->prop.fps = DEFAULT_FPS;
	inst->clk_data.frame_rate = (DEFAULT_FPS << 16);
	inst->capability.pixelprocess_capabilities = 0;
	/* To start with, both ports are 1 plane each */
	inst->bufq[OUTPUT_PORT].num_planes = 1;
	inst->bufq[CAPTURE_PORT].num_planes = 1;
	inst->clk_data.operating_rate = 0;
	inst->clk_data.operating_rate = (DEFAULT_FPS << 16);

	inst->buff_req.buffer[1].buffer_type = HAL_BUFFER_INPUT;
	inst->buff_req.buffer[1].buffer_count_min_host =
@@ -1521,6 +1531,16 @@ int msm_venc_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
					"%s: set bitrate failed\n", __func__);
		}
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_FRAME_RATE:
		inst->clk_data.frame_rate = ctrl->val;
		if (inst->state == MSM_VIDC_START_DONE) {
			rc = msm_venc_set_frame_rate(inst);
			if (rc)
				dprintk(VIDC_ERR,
					"%s: set frame rate failed\n",
					__func__);
		}
		break;
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES:
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE:
	case V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB:
@@ -1807,6 +1827,32 @@ int msm_venc_set_frame_size(struct msm_vidc_inst *inst)
	return rc;
}

int msm_venc_set_frame_rate(struct msm_vidc_inst *inst)
{
	int rc = 0;
	struct hfi_device *hdev;
	struct hfi_frame_rate frame_rate;

	if (!inst || !inst->core) {
		dprintk(VIDC_ERR, "%s: invalid params\n", __func__);
		return -EINVAL;
	}
	hdev = inst->core->device;

	frame_rate.buffer_type = HFI_BUFFER_OUTPUT;
	frame_rate.frame_rate = inst->clk_data.frame_rate;

	dprintk(VIDC_DBG, "%s: %#x\n", __func__, frame_rate.frame_rate);

	rc = call_hfi_op(hdev, session_set_property,
		inst->session, HFI_PROPERTY_CONFIG_FRAME_RATE,
		&frame_rate, sizeof(frame_rate));
	if (rc)
		dprintk(VIDC_ERR, "%s: set property failed\n", __func__);

	return rc;
}

int msm_venc_set_color_format(struct msm_vidc_inst *inst)
{
	int rc = 0;
@@ -3405,6 +3451,9 @@ int msm_venc_set_properties(struct msm_vidc_inst *inst)
	int rc = 0;

	rc = msm_venc_set_frame_size(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_frame_rate(inst);
	if (rc)
		goto exit;
	rc = msm_venc_set_color_format(inst);
@@ -3527,39 +3576,3 @@ int msm_venc_set_properties(struct msm_vidc_inst *inst)

	return rc;
}

int msm_venc_s_parm(struct msm_vidc_inst *inst, struct v4l2_streamparm *a)
{
	int fps = 0;
	u64 us_per_frame = 0;

	if (!inst || !a) {
		dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
		return -EINVAL;
	}

	if (a->parm.output.timeperframe.denominator) {
		switch (a->type) {
		case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
		case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
			us_per_frame = a->parm.output.timeperframe.numerator *
				(u64)USEC_PER_SEC;
			do_div(us_per_frame,
				a->parm.output.timeperframe.denominator);
			break;
		default:
			dprintk(VIDC_ERR, "%s: unknown parm type %d\n",
					__func__, a->type);
			break;
		}
	}
	if (!us_per_frame) {
		dprintk(VIDC_ERR, "%s: time between frames is 0\n", __func__);
		return -EINVAL;
	}
	fps = us_per_frame > USEC_PER_SEC ?
		0 : USEC_PER_SEC / (u32)us_per_frame;

	inst->prop.fps = fps;
	return 0;
}
+1 −3
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */
#ifndef _MSM_VENC_H_
#define _MSM_VENC_H_
@@ -18,8 +18,6 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst,
		struct v4l2_format *f);
int msm_venc_s_ctrl(struct msm_vidc_inst *inst,
		struct v4l2_ctrl *ctrl);
int msm_venc_s_parm(struct msm_vidc_inst *inst,
		struct v4l2_streamparm *a);
int msm_venc_set_properties(struct msm_vidc_inst *inst);
int msm_venc_set_extradata(struct msm_vidc_inst *inst);
int msm_venc_set_frame_rate(struct msm_vidc_inst *inst);
Loading