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

Commit 94848f82 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: add new control for limiting i/p buffer size"

parents 1d400639 f8ca77a5
Loading
Loading
Loading
Loading
+54 −14
Original line number Diff line number Diff line
@@ -487,6 +487,17 @@ static struct msm_vidc_ctrl msm_vdec_ctrls[] = {
		.default_value = DEFAULT_VIDEO_CONCEAL_COLOR_BLACK,
		.step = 1,
	},
	{
		.id = V4L2_CID_MPEG_VIDC_VIDEO_BUFFER_SIZE_LIMIT,
		.name = "Buffer size limit",
		.type = V4L2_CTRL_TYPE_INTEGER,
		.minimum = 0,
		.maximum = 0x7fffffff,
		.default_value = 0,
		.step = 1,
		.menu_skip_mask = 0,
		.qmenu = NULL,
	},
};

#define NUM_CTRLS ARRAY_SIZE(msm_vdec_ctrls)
@@ -503,6 +514,36 @@ static u32 get_frame_size_compressed(int plane,
	return (max_mbs_per_frame * size_per_mb * 3/2)/2;
}

static u32 get_frame_size(struct msm_vidc_inst *inst,
					const struct msm_vidc_format *fmt,
					int fmt_type, int plane)
{
	u32 frame_size = 0;
	if (fmt_type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
		frame_size = fmt->get_frame_size(plane,
					inst->capability.mbs_per_frame.max,
					MB_SIZE_IN_PIXEL);
		if (inst->capability.buffer_size_limit &&
			(inst->capability.buffer_size_limit < frame_size)) {
			frame_size = inst->capability.buffer_size_limit;
			dprintk(VIDC_DBG, "input buffer size limited to %d\n",
				frame_size);
		} else {
			dprintk(VIDC_DBG, "set input buffer size to %d\n",
				frame_size);
		}
	} else if (fmt_type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
		frame_size = fmt->get_frame_size(plane,
					inst->capability.height.max,
					inst->capability.width.max);
		dprintk(VIDC_DBG, "set output buffer size to %d\n",
			frame_size);
	} else {
		dprintk(VIDC_WARN, "Wrong format type\n");
	}
	return frame_size;
}

static int is_ctrl_valid_for_codec(struct msm_vidc_inst *inst,
					struct v4l2_ctrl *ctrl)
{
@@ -959,10 +1000,8 @@ int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
			for (i = 0; i < fmt->num_planes; ++i) {
				if (plane_sizes[i] == 0) {
					f->fmt.pix_mp.plane_fmt[i].sizeimage =
						fmt->get_frame_size(i,
						inst->capability.
						mbs_per_frame.max,
						MB_SIZE_IN_PIXEL);
						get_frame_size(inst, fmt,
								f->type, i);
					plane_sizes[i] =
						f->fmt.pix_mp.plane_fmt[i].
							sizeimage;
@@ -1147,9 +1186,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
		if (ret) {
			for (i = 0; i < fmt->num_planes; ++i) {
				f->fmt.pix_mp.plane_fmt[i].sizeimage =
					fmt->get_frame_size(i,
						inst->capability.height.max,
						inst->capability.width.max);
					get_frame_size(inst, fmt, f->type, i);
			}
		} else {
			buff_req_buffer =
@@ -1231,10 +1268,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
			frame_sz.buffer_type, frame_sz.width,
			frame_sz.height);
		msm_comm_try_set_prop(inst, HAL_PARAM_FRAME_SIZE, &frame_sz);

		max_input_size = fmt->get_frame_size(0,
			inst->capability.mbs_per_frame.max, MB_SIZE_IN_PIXEL);

		max_input_size = get_frame_size(inst, fmt, f->type, 0);
		if (f->fmt.pix_mp.plane_fmt[0].sizeimage > max_input_size ||
			f->fmt.pix_mp.plane_fmt[0].sizeimage == 0) {
			f->fmt.pix_mp.plane_fmt[0].sizeimage = max_input_size;
@@ -1333,9 +1367,8 @@ static int msm_vdec_queue_setup(struct vb2_queue *q,
				*num_buffers > MAX_NUM_OUTPUT_BUFFERS)
			*num_buffers = MIN_NUM_OUTPUT_BUFFERS;
		for (i = 0; i < *num_planes; i++) {
			sizes[i] = inst->fmts[OUTPUT_PORT]->get_frame_size(
					i, inst->capability.mbs_per_frame.max,
					MB_SIZE_IN_PIXEL);
			sizes[i] = get_frame_size(inst,
					inst->fmts[OUTPUT_PORT], q->type, i);
		}
		property_id = HAL_PARAM_BUFFER_COUNT_ACTUAL;
		new_buf_count.buffer_type = HAL_BUFFER_INPUT;
@@ -2121,6 +2154,13 @@ static int try_set_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
				temp_ctrl->val);
		pdata = &profile_level;
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_BUFFER_SIZE_LIMIT:
	{
		inst->capability.buffer_size_limit = ctrl->val;
		dprintk(VIDC_DBG,
			"Limiting input buffer size to :%u\n", ctrl->val);
		break;
	}
	default:
		break;
	}
+1 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ struct msm_vidc_core_capability {
	struct hal_capability_supported mbs_per_frame;
	u32 capability_set;
	enum buffer_mode_type buffer_mode[MAX_PORT_NUM];
	u32 buffer_size_limit;
};

struct msm_vidc_idle_stats {
+3 −0
Original line number Diff line number Diff line
@@ -917,6 +917,9 @@ enum vl42_mpeg_vidc_video_enable_initial_qp {
#define V4L2_CID_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE \
	(V4L2_CID_MPEG_MSM_VIDC_BASE + 63)

#define V4L2_CID_MPEG_VIDC_VIDEO_BUFFER_SIZE_LIMIT \
		(V4L2_CID_MPEG_MSM_VIDC_BASE + 64)

enum vl42_mpeg_vidc_video_vpx_error_resilience {
	V4L2_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE_DISABLED = 0,
	V4L2_MPEG_VIDC_VIDEO_VPX_ERROR_RESILIENCE_ENABLED = 1,