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

Commit 0b564a62 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: Optimize buffer requirements call to HW"

parents 3b28cd20 6e63747e
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -1074,15 +1074,6 @@ static void hfi_process_sess_get_prop_buf_req(
	}

	while (req_bytes) {
		if (hfi_buf_req->buffer_size &&
			hfi_buf_req->buffer_count_min > hfi_buf_req->
			buffer_count_actual)
			dprintk(VIDC_WARN,
				"Bad buffer requirements for %#x: min %d, actual %d\n",
				hfi_buf_req->buffer_type,
				hfi_buf_req->buffer_count_min,
				hfi_buf_req->buffer_count_actual);

		dprintk(VIDC_DBG, "got buffer requirements for: %d\n",
					hfi_buf_req->buffer_type);
		switch (hfi_buf_req->buffer_type) {
+70 −11
Original line number Diff line number Diff line
@@ -20,7 +20,10 @@
#include "msm_vidc_clocks.h"

#define MSM_VDEC_DVC_NAME "msm_vdec_8974"
#define MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS MIN_NUM_OUTPUT_BUFFERS
#define MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS MIN_NUM_CAPTURE_BUFFERS
#define MIN_NUM_DEC_OUTPUT_BUFFERS 4
#define MIN_NUM_DEC_CAPTURE_BUFFERS 4
#define DEFAULT_VIDEO_CONCEAL_COLOR_BLACK 0x8010
#define MB_SIZE_IN_PIXEL (16 * 16)
#define OPERATING_FRAME_RATE_STEP (1 << 16)
@@ -545,7 +548,6 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
				f->fmt.pix_mp.plane_fmt[i].sizeimage;
		}

		rc = msm_comm_try_get_bufreqs(inst);
	} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {

		fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats,
@@ -599,8 +601,6 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
			inst->bufq[OUTPUT_PORT].plane_sizes[i] =
				f->fmt.pix_mp.plane_fmt[i].sizeimage;
		}

		rc = msm_comm_try_get_bufreqs(inst);
	}
err_invalid_fmt:
	return rc;
@@ -676,6 +676,19 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
	memcpy(&inst->fmts[fmt->type], fmt,
			sizeof(struct msm_vidc_format));

	inst->buff_req.buffer[1].buffer_type = HAL_BUFFER_INPUT;
	inst->buff_req.buffer[1].buffer_count_min_host =
	inst->buff_req.buffer[1].buffer_count_actual =
		MIN_NUM_DEC_OUTPUT_BUFFERS;
	inst->buff_req.buffer[2].buffer_type = HAL_BUFFER_OUTPUT;
	inst->buff_req.buffer[2].buffer_count_min_host =
	inst->buff_req.buffer[2].buffer_count_actual =
		MIN_NUM_DEC_CAPTURE_BUFFERS;
	inst->buff_req.buffer[3].buffer_type = HAL_BUFFER_OUTPUT2;
	inst->buff_req.buffer[3].buffer_count_min_host =
	inst->buff_req.buffer[3].buffer_count_actual =
		MIN_NUM_DEC_CAPTURE_BUFFERS;

	/* By default, initialize OUTPUT port to H264 decoder */
	fmt = msm_comm_get_pixel_fmt_fourcc(vdec_formats,
		ARRAY_SIZE(vdec_formats), V4L2_PIX_FMT_H264,
@@ -717,6 +730,7 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	struct v4l2_ctrl *temp_ctrl = NULL;
	struct hal_profile_level profile_level;
	struct hal_frame_size frame_sz;
	struct hal_buffer_requirements *bufreq;

	if (!inst || !inst->core || !inst->core->device) {
		dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
@@ -778,6 +792,59 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
		hal_property.enable = ctrl->val;
		pdata = &hal_property;
		msm_dcvs_try_enable(inst);

		bufreq = get_buff_req_buffer(inst,
				HAL_BUFFER_INPUT);
		if (!bufreq) {
			dprintk(VIDC_ERR,
					"Failed : No buffer requirements : %x\n",
					HAL_BUFFER_OUTPUT);
			return -EINVAL;
		}
		bufreq->buffer_count_min =
			MIN_NUM_THUMBNAIL_MODE_OUTPUT_BUFFERS;

		if (msm_comm_get_stream_output_mode(inst) ==
				HAL_VIDEO_DECODER_SECONDARY) {

			bufreq = get_buff_req_buffer(inst,
					HAL_BUFFER_OUTPUT);
			if (!bufreq) {
				dprintk(VIDC_ERR,
					"Failed : No buffer requirements: %x\n",
						HAL_BUFFER_OUTPUT);
				return -EINVAL;
			}

			bufreq->buffer_count_min =
				MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS;

			bufreq = get_buff_req_buffer(inst,
					HAL_BUFFER_OUTPUT2);
			if (!bufreq) {
				dprintk(VIDC_ERR,
					"Failed : No buffer requirements: %x\n",
						HAL_BUFFER_OUTPUT2);
				return -EINVAL;
			}

			bufreq->buffer_count_min =
				MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS;
		} else {

			bufreq = get_buff_req_buffer(inst,
					HAL_BUFFER_OUTPUT);
			if (!bufreq) {
				dprintk(VIDC_ERR,
					"Failed : No buffer requirements: %x\n",
						HAL_BUFFER_OUTPUT);
				return -EINVAL;
			}
			bufreq->buffer_count_min =
				MIN_NUM_THUMBNAIL_MODE_CAPTURE_BUFFERS;

		}

		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_SECURE:
		property_id = HAL_PARAM_SECURE;
@@ -897,7 +964,6 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
					"Failed setting OUTPUT2 size : %d\n",
					rc);

			rc = msm_comm_try_get_bufreqs(inst);
			break;
		default:
			dprintk(VIDC_ERR,
@@ -921,7 +987,6 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
				V4L2_CID_MPEG_VIDEO_H264_LEVEL,
				temp_ctrl->val);
		pdata = &profile_level;
		rc = msm_comm_try_get_bufreqs(inst);
		break;
	case V4L2_CID_MPEG_VIDEO_H264_LEVEL:
		temp_ctrl = TRY_GET_CTRL(V4L2_CID_MPEG_VIDEO_H264_PROFILE);
@@ -933,7 +998,6 @@ int msm_vdec_s_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
				V4L2_CID_MPEG_VIDEO_H264_PROFILE,
				temp_ctrl->val);
		pdata = &profile_level;
		rc = msm_comm_try_get_bufreqs(inst);
		break;
	case V4L2_CID_MPEG_VIDC_VIDEO_BUFFER_SIZE_LIMIT:
		dprintk(VIDC_DBG,
@@ -1051,11 +1115,6 @@ int msm_vdec_s_ext_ctrl(struct msm_vidc_inst *inst,
							__func__, rc);
						break;
					}
					rc = msm_comm_try_get_bufreqs(inst);
					if (rc)
						dprintk(VIDC_ERR,
							"%s Failed to get buffer requirements : %d\n",
							__func__, rc);
				}
				inst->clk_data.dpb_fourcc = fourcc;
				break;
+11 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
#define MIN_TIME_RESOLUTION 1
#define MAX_TIME_RESOLUTION 0xFFFFFF
#define DEFAULT_TIME_RESOLUTION 0x7530
#define MIN_NUM_ENC_OUTPUT_BUFFERS 4
#define MIN_NUM_ENC_CAPTURE_BUFFERS 5

/*
 * Default 601 to 709 conversion coefficients for resolution: 176x144 negative
@@ -2124,6 +2126,15 @@ int msm_venc_inst_init(struct msm_vidc_inst *inst)
	inst->bufq[CAPTURE_PORT].num_planes = 1;
	inst->clk_data.operating_rate = 0;

	inst->buff_req.buffer[1].buffer_type = HAL_BUFFER_INPUT;
	inst->buff_req.buffer[1].buffer_count_min_host =
	inst->buff_req.buffer[1].buffer_count_actual =
		MIN_NUM_ENC_OUTPUT_BUFFERS;
	inst->buff_req.buffer[2].buffer_type = HAL_BUFFER_OUTPUT;
	inst->buff_req.buffer[2].buffer_count_min_host =
	inst->buff_req.buffer[2].buffer_count_actual =
		MIN_NUM_ENC_CAPTURE_BUFFERS;

	/* By default, initialize OUTPUT port to UBWC YUV format */
	fmt = msm_comm_get_pixel_fmt_fourcc(venc_formats,
		ARRAY_SIZE(venc_formats), V4L2_PIX_FMT_NV12_UBWC,
+2 −15
Original line number Diff line number Diff line
@@ -1843,7 +1843,7 @@ static int msm_vidc_get_count(struct msm_vidc_inst *inst,
	struct v4l2_ctrl *ctrl)
{
	int rc = 0;
	struct hal_buffer_requirements *bufreq, *newreq;
	struct hal_buffer_requirements *bufreq;
	enum hal_buffer buffer_type;

	if (ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_OUTPUT) {
@@ -1892,16 +1892,7 @@ static int msm_vidc_get_count(struct msm_vidc_inst *inst,


		if (inst->in_reconfig) {
			rc = msm_comm_try_get_bufreqs(inst);
			newreq = get_buff_req_buffer(inst,
				buffer_type);
			if (!newreq) {
				dprintk(VIDC_ERR,
					"Failed to find new bufreqs = %d\n",
					buffer_type);
				return 0;
			}
			ctrl->val = newreq->buffer_count_min;
			ctrl->val = bufreq->buffer_count_min;
		}
		if (inst->session_type == MSM_VIDC_DECODER &&
				!inst->in_reconfig &&
@@ -1969,9 +1960,6 @@ 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);
@@ -1984,7 +1972,6 @@ static int try_get_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
		ctrl->val = bufreq->buffer_count_min_host;
		break;
	case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
		msm_comm_try_get_bufreqs(inst);
		bufreq = get_buff_req_buffer(inst, HAL_BUFFER_INPUT);
		if (!bufreq) {
			dprintk(VIDC_ERR,
+45 −3
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@
#define L_MODE V4L2_MPEG_VIDEO_H264_LOOP_FILTER_MODE_DISABLED_AT_SLICE_BOUNDARY

#define MAX_SUPPORTED_INSTANCES 16
static int msm_vidc_update_host_buff_counts(struct msm_vidc_inst *inst);

const char *const mpeg_video_vidc_extradata[] = {
	"Extradata none",
@@ -1456,6 +1457,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
	int rc = 0;
	struct hfi_device *hdev;
	u32 *ptr = NULL;
	struct hal_buffer_requirements *bufreq;

	if (!event_notify) {
		dprintk(VIDC_WARN, "Got an empty event from hfi\n");
@@ -1600,6 +1602,46 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
	inst->in_reconfig = true;
	inst->reconfig_height = event_notify->height;
	inst->reconfig_width = event_notify->width;

	if (msm_comm_get_stream_output_mode(inst) ==
			HAL_VIDEO_DECODER_SECONDARY) {

		bufreq = get_buff_req_buffer(inst,
				HAL_BUFFER_OUTPUT);
		if (!bufreq) {
			dprintk(VIDC_ERR,
				"Failed : No buffer requirements : %x\n",
					HAL_BUFFER_OUTPUT);
			return;
		}

		bufreq->buffer_count_min = event_notify->capture_buf_count;

		bufreq = get_buff_req_buffer(inst,
				HAL_BUFFER_OUTPUT2);
		if (!bufreq) {
			dprintk(VIDC_ERR,
				"Failed : No buffer requirements : %x\n",
					HAL_BUFFER_OUTPUT2);
			return;
		}

		bufreq->buffer_count_min = event_notify->capture_buf_count;
	} else {

		bufreq = get_buff_req_buffer(inst,
				HAL_BUFFER_OUTPUT);
		if (!bufreq) {
			dprintk(VIDC_ERR,
				"Failed : No buffer requirements : %x\n",
					HAL_BUFFER_OUTPUT);
			return;
		}
		bufreq->buffer_count_min = event_notify->capture_buf_count;

	}

	msm_vidc_update_host_buff_counts(inst);
	mutex_unlock(&inst->lock);

	if (event == V4L2_EVENT_SEQ_CHANGED_INSUFFICIENT) {
@@ -4130,7 +4172,7 @@ static int msm_vidc_update_host_buff_counts(struct msm_vidc_inst *inst)

		/* For DPB buffers, no need to add Extra buffers */

		bufreq->buffer_count_actual = bufreq->buffer_count_min_host =
		bufreq->buffer_count_min_host =	bufreq->buffer_count_actual =
			bufreq->buffer_count_min;

		bufreq = get_buff_req_buffer(inst,
@@ -4145,7 +4187,7 @@ static int msm_vidc_update_host_buff_counts(struct msm_vidc_inst *inst)
		extra_buffers = msm_vidc_get_extra_buff_count(inst,
			HAL_BUFFER_OUTPUT);

		bufreq->buffer_count_min_host =
		bufreq->buffer_count_min_host =	bufreq->buffer_count_actual =
			bufreq->buffer_count_min + extra_buffers;
	} else {

@@ -4161,7 +4203,7 @@ static int msm_vidc_update_host_buff_counts(struct msm_vidc_inst *inst)
		extra_buffers = msm_vidc_get_extra_buff_count(inst,
			HAL_BUFFER_OUTPUT);

		bufreq->buffer_count_actual = bufreq->buffer_count_min_host =
		bufreq->buffer_count_min_host =	bufreq->buffer_count_actual =
			bufreq->buffer_count_min + extra_buffers;
	}