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

Commit 79c7d49a 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: Misc bug fixes" into msm-4.9

parents d521d7f6 1f9d1d93
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -522,7 +522,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
			inst->prop.width[CAPTURE_PORT] == f->fmt.pix_mp.width &&
			inst->prop.height[CAPTURE_PORT] ==
				f->fmt.pix_mp.height) {
			dprintk(VIDC_DBG, "Thank you : Nothing changed\n");
			dprintk(VIDC_DBG, "No change in CAPTURE port params\n");
			return 0;
		}
		memcpy(&inst->fmts[fmt->type], fmt,
@@ -590,7 +590,7 @@ int msm_vdec_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
			inst->prop.width[OUTPUT_PORT] == f->fmt.pix_mp.width &&
			inst->prop.height[OUTPUT_PORT] ==
				f->fmt.pix_mp.height) {
			dprintk(VIDC_DBG, "Thank you : Nothing changed\n");
			dprintk(VIDC_DBG, "No change in OUTPUT port params\n");
			return 0;
		}
		inst->prop.width[OUTPUT_PORT] = f->fmt.pix_mp.width;
+15 −1
Original line number Diff line number Diff line
@@ -2229,6 +2229,7 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
	struct hfi_device *hdev;
	int extra_idx = 0, i = 0;
	struct hal_buffer_requirements *buff_req_buffer;
	struct hal_frame_size frame_sz;

	if (!inst || !f) {
		dprintk(VIDC_ERR,
@@ -2267,6 +2268,19 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
		inst->prop.width[CAPTURE_PORT] = f->fmt.pix_mp.width;
		inst->prop.height[CAPTURE_PORT] = f->fmt.pix_mp.height;

		frame_sz.buffer_type = HAL_BUFFER_OUTPUT;
		frame_sz.width = inst->prop.width[CAPTURE_PORT];
		frame_sz.height = inst->prop.height[CAPTURE_PORT];
		dprintk(VIDC_DBG, "CAPTURE port width = %d, height = %d\n",
			frame_sz.width, frame_sz.height);
		rc = call_hfi_op(hdev, session_set_property, (void *)
			inst->session, HAL_PARAM_FRAME_SIZE, &frame_sz);
		if (rc) {
			dprintk(VIDC_ERR,
				"Failed to set framesize for CAPTURE port\n");
			goto exit;
		}

		rc = msm_comm_try_get_bufreqs(inst);
		if (rc) {
			dprintk(VIDC_ERR,
@@ -2315,7 +2329,7 @@ int msm_venc_s_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
		frame_sz.buffer_type = HAL_BUFFER_INPUT;
		frame_sz.width = inst->prop.width[OUTPUT_PORT];
		frame_sz.height = inst->prop.height[OUTPUT_PORT];
		dprintk(VIDC_DBG, "width = %d, height = %d\n",
		dprintk(VIDC_DBG, "OUTPUT port width = %d, height = %d\n",
				frame_sz.width, frame_sz.height);
		rc = call_hfi_op(hdev, session_set_property, (void *)
			inst->session, HAL_PARAM_FRAME_SIZE, &frame_sz);
+90 −47
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@

#define MAX_EVENTS 30

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

static int get_poll_flags(void *instance)
{
	struct msm_vidc_inst *inst = instance;
@@ -254,11 +257,20 @@ EXPORT_SYMBOL(msm_vidc_s_ctrl);
int msm_vidc_g_ctrl(void *instance, struct v4l2_control *control)
{
	struct msm_vidc_inst *inst = instance;
	struct v4l2_ctrl *ctrl = NULL;
	int rc = 0;

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

	return msm_comm_g_ctrl(instance, control);
	ctrl = v4l2_ctrl_find(&inst->ctrl_handler, control->id);
	if (ctrl) {
		rc = try_get_ctrl(inst, ctrl);
		if (!rc)
			control->value = ctrl->val;
	}

	return rc;
}
EXPORT_SYMBOL(msm_vidc_g_ctrl);

@@ -1222,21 +1234,22 @@ static int msm_vidc_queue_setup(struct vb2_queue *q,
				HAL_BUFFER_INPUT);
			return -EINVAL;
		}
		if (*num_buffers < bufreq->buffer_count_actual) {
		if (*num_buffers < bufreq->buffer_count_min_host) {
			dprintk(VIDC_ERR,
				"Invalid parameters : Req = %d Act = %d\n",
				*num_buffers, bufreq->buffer_count_actual);
				*num_buffers, bufreq->buffer_count_min_host);
			return -EINVAL;
		}
		*num_planes = inst->bufq[OUTPUT_PORT].num_planes;
		if (*num_buffers < MIN_NUM_OUTPUT_BUFFERS ||
			*num_buffers > MAX_NUM_OUTPUT_BUFFERS)
			*num_buffers = MIN_NUM_OUTPUT_BUFFERS;
			bufreq->buffer_count_actual = *num_buffers =
				MIN_NUM_OUTPUT_BUFFERS;
		for (i = 0; i < *num_planes; i++)
			sizes[i] = inst->bufq[OUTPUT_PORT].plane_sizes[i];

		bufreq->buffer_count_actual = *num_buffers;
		rc = set_buffer_count(inst, bufreq->buffer_count_min_host,
		rc = set_buffer_count(inst, bufreq->buffer_count_actual,
			*num_buffers, HAL_BUFFER_INPUT);
		}

@@ -1251,22 +1264,27 @@ static int msm_vidc_queue_setup(struct vb2_queue *q,
				buffer_type);
			return -EINVAL;
		}
		if (*num_buffers < bufreq->buffer_count_actual) {
		if (inst->session_type != MSM_VIDC_DECODER &&
			inst->state > MSM_VIDC_LOAD_RESOURCES_DONE) {
			if (*num_buffers < bufreq->buffer_count_min_host) {
				dprintk(VIDC_ERR,
					"Invalid parameters : Req = %d Act = %d\n",
				*num_buffers, bufreq->buffer_count_actual);
						*num_buffers,
						bufreq->buffer_count_min_host);
				return -EINVAL;
			}
		}
		*num_planes = inst->bufq[CAPTURE_PORT].num_planes;
		if (*num_buffers < MIN_NUM_CAPTURE_BUFFERS ||
			*num_buffers > MAX_NUM_CAPTURE_BUFFERS)
			*num_buffers = MIN_NUM_CAPTURE_BUFFERS;
			bufreq->buffer_count_actual = *num_buffers =
				MIN_NUM_CAPTURE_BUFFERS;

		for (i = 0; i < *num_planes; i++)
			sizes[i] = inst->bufq[CAPTURE_PORT].plane_sizes[i];

		bufreq->buffer_count_actual = *num_buffers;
		rc = set_buffer_count(inst, bufreq->buffer_count_min_host,
		rc = set_buffer_count(inst, bufreq->buffer_count_actual,
			*num_buffers, buffer_type);
		}
		break;
@@ -1290,16 +1308,31 @@ static inline int msm_vidc_verify_buffer_counts(struct msm_vidc_inst *inst)
{
	int rc = 0, i = 0;

	/* For decoder No need to sanity till LOAD_RESOURCES */
	if (inst->session_type == MSM_VIDC_DECODER &&
			inst->state < MSM_VIDC_LOAD_RESOURCES_DONE) {
		dprintk(VIDC_DBG,
			"No need to verify buffer counts : %pK\n", inst);
		return 0;
	}

	for (i = 0; i < HAL_BUFFER_MAX; i++) {
		struct hal_buffer_requirements *req = &inst->buff_req.buffer[i];

		dprintk(VIDC_DBG, "Verifying Buffer : %d\n", req->buffer_type);
		if (!req ||
			req->buffer_count_actual < req->buffer_count_min_host ||
			req->buffer_count_min_host < req->buffer_count_min) {
			dprintk(VIDC_ERR, "Invalid data : Counts mismatch\n");
		if (req && (msm_comm_get_hal_output_buffer(inst) ==
				req->buffer_type)) {
			dprintk(VIDC_DBG, "Verifying Buffer : %d\n",
				req->buffer_type);
			if (req->buffer_count_actual <
					req->buffer_count_min_host ||
				req->buffer_count_min_host <
					req->buffer_count_min) {

				dprintk(VIDC_ERR,
					"Invalid data : Counts mismatch\n");
				dprintk(VIDC_ERR,
				"Min Count = %d ", req->buffer_count_min);
					"Min Count = %d ",
						req->buffer_count_min);
				dprintk(VIDC_ERR,
					"Min Host Count = %d ",
						req->buffer_count_min_host);
@@ -1310,6 +1343,7 @@ static inline int msm_vidc_verify_buffer_counts(struct msm_vidc_inst *inst)
				break;
			}
		}
	}
	return rc;
}

@@ -1729,7 +1763,7 @@ static int set_actual_buffer_count(struct msm_vidc_inst *inst,
}


static int msm_vdec_get_count(struct msm_vidc_inst *inst,
static int msm_vidc_get_count(struct msm_vidc_inst *inst,
	struct v4l2_ctrl *ctrl)
{
	int rc = 0;
@@ -1750,15 +1784,19 @@ static int msm_vdec_get_count(struct msm_vidc_inst *inst,
		}
		if (ctrl->val > bufreq->buffer_count_min_host) {
			dprintk(VIDC_DBG,
				"Interesting : Usually shouldn't happen\n");
				"Buffer count Host changed from %d to %d\n",
					bufreq->buffer_count_min_host,
					ctrl->val);
			bufreq->buffer_count_min_host = ctrl->val;
		} else {
			ctrl->val = bufreq->buffer_count_min_host;
		}
		rc = set_actual_buffer_count(inst, ctrl->val,
		rc = set_actual_buffer_count(inst,
				bufreq->buffer_count_min_host,
			HAL_BUFFER_INPUT);
		return rc;

	} else if (ctrl->id == V4L2_CID_MIN_BUFFERS_FOR_CAPTURE) {
		int count = 0;

		buffer_type = msm_comm_get_hal_output_buffer(inst);
		bufreq = get_buff_req_buffer(inst,
@@ -1775,7 +1813,7 @@ static int msm_vdec_get_count(struct msm_vidc_inst *inst,
			else
				return 0;
		}
		count = bufreq->buffer_count_min_host;


		if (inst->in_reconfig) {
			rc = msm_comm_try_get_bufreqs(inst);
@@ -1787,21 +1825,28 @@ static int msm_vdec_get_count(struct msm_vidc_inst *inst,
					buffer_type);
				return 0;
			}
			newreq->buffer_count_min_host = count =
				newreq->buffer_count_min +
				msm_dcvs_get_extra_buff_count(inst);
			ctrl->val = newreq->buffer_count_min;
		}
		if (!inst->in_reconfig &&
		if (inst->session_type == MSM_VIDC_DECODER &&
				!inst->in_reconfig &&
			inst->state < MSM_VIDC_LOAD_RESOURCES_DONE) {
			dprintk(VIDC_DBG, "Clients will correct this\n");
			rc = set_actual_buffer_count(inst, ctrl->val,
				buffer_type);
			dprintk(VIDC_DBG,
				"Clients updates Buffer count from %d to %d\n",
				bufreq->buffer_count_min_host, ctrl->val);
			bufreq->buffer_count_min_host = ctrl->val;
			return 0;
		}
		bufreq->buffer_count_min_host = ctrl->val = count;
		rc = set_actual_buffer_count(inst, ctrl->val,
			buffer_type);
		if (ctrl->val > bufreq->buffer_count_min_host) {
			dprintk(VIDC_DBG,
				"Buffer count Host changed from %d to %d\n",
				bufreq->buffer_count_min_host,
				ctrl->val);
			bufreq->buffer_count_min_host = ctrl->val;
		} else {
			ctrl->val = bufreq->buffer_count_min_host;
		}
		rc = set_actual_buffer_count(inst,
				bufreq->buffer_count_min_host,
			HAL_BUFFER_OUTPUT);

		return rc;
	}
@@ -1817,7 +1862,6 @@ static int try_get_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
	 * lower level code that attempts to do g_ctrl() will end up deadlocking
	 * us.
	 */
	v4l2_ctrl_unlock(ctrl);

	switch (ctrl->id) {

@@ -1838,7 +1882,7 @@ static int try_get_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)

	case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
	case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
		rc = msm_vdec_get_count(inst, ctrl);
		rc = msm_vidc_get_count(inst, ctrl);
		break;
	default:
		/*
@@ -1847,7 +1891,6 @@ static int try_get_ctrl(struct msm_vidc_inst *inst, struct v4l2_ctrl *ctrl)
		 */
		break;
}
	v4l2_ctrl_lock(ctrl);

	return rc;
}
+17 −4
Original line number Diff line number Diff line
@@ -422,19 +422,29 @@ int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst)

int msm_dcvs_try_enable(struct msm_vidc_inst *inst)
{
	bool force_disable = false;

	if (!inst) {
		dprintk(VIDC_ERR, "%s: Invalid args: %p\n", __func__, inst);
		return -EINVAL;
	}
	if (inst->flags & VIDC_THUMBNAIL) {

	force_disable = inst->session_type == MSM_VIDC_ENCODER ?
		!msm_vidc_enc_dcvs_mode :
		!msm_vidc_dec_dcvs_mode;

	if (force_disable || inst->flags & VIDC_THUMBNAIL) {
		dprintk(VIDC_PROF, "Thumbnail sessions don't need DCVS : %pK\n",
			inst);
		inst->dcvs.extra_capture_buffer_count = 0;
		inst->dcvs.extra_output_buffer_count = 0;
		return false;
	}
	inst->dcvs_mode = true;

	// TODO : Update with proper number based on on-target tuning.
	inst->dcvs.extra_buffer_count = DCVS_DEC_EXTRA_OUTPUT_BUFFERS;
	inst->dcvs.extra_capture_buffer_count = DCVS_DEC_EXTRA_OUTPUT_BUFFERS;
	inst->dcvs.extra_output_buffer_count = DCVS_DEC_EXTRA_OUTPUT_BUFFERS;
	return true;
}

@@ -566,14 +576,17 @@ void msm_dcvs_init(struct msm_vidc_inst *inst)
	msm_dcvs_print_dcvs_stats(dcvs);
}

int msm_dcvs_get_extra_buff_count(struct msm_vidc_inst *inst)
int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst,
	enum hal_buffer buffer_type)
{
	if (!inst) {
		dprintk(VIDC_ERR, "%s Invalid args\n", __func__);
		return 0;
	}

	return inst->dcvs.extra_buffer_count;
	return buffer_type == HAL_BUFFER_INPUT ?
		inst->dcvs.extra_output_buffer_count :
		inst->dcvs.extra_capture_buffer_count;
}

+2 −1
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@
#define DCVS_BUFFER_SAFEGUARD (DCVS_DEC_EXTRA_OUTPUT_BUFFERS - 1)

void msm_dcvs_init(struct msm_vidc_inst *inst);
int  msm_dcvs_get_extra_buff_count(struct msm_vidc_inst *inst);
int msm_vidc_get_extra_buff_count(struct msm_vidc_inst *inst,
	enum hal_buffer buffer_type);
int msm_dcvs_try_enable(struct msm_vidc_inst *inst);
int msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst);
int msm_comm_init_clocks_and_bus_data(struct msm_vidc_inst *inst);
Loading