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

Commit 1681bd42 authored by Praneeth Paladugu's avatar Praneeth Paladugu
Browse files

msm: vidc: Handle encoder input in true dynamic mode



Earlier video driver maintains list of fds and compare
each ETB fd with these values. If the fd is found then
mapping is retained. But in some usecases, buffer address
and fd association may not be unique. This resuts in
usage of stale buffers. This is also not the true dynamic
buffer mode. With this change, driver treats every buffer
as new buffer and map and unmap each time.

CRs-Fixed: 989007
Change-Id: Ice90c745d4920b64c48c3f4dafca789f2551b327
Signed-off-by: default avatarPraneeth Paladugu <ppaladug@codeaurora.org>
parent 8007444c
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -385,6 +385,13 @@ static inline bool is_dynamic_output_buffer_mode(struct v4l2_buffer *b,
}


static inline bool is_encoder_input_buffer(struct v4l2_buffer *b,
				struct msm_vidc_inst *inst)
{
	return b->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&
			inst->session_type == MSM_VIDC_ENCODER;
}

static inline void save_v4l2_buffer(struct v4l2_buffer *b,
						struct buffer_info *binfo)
{
@@ -935,8 +942,8 @@ int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b)
	if (rc)
		return rc;


	if (is_dynamic_output_buffer_mode(b, inst)) {
	if (is_dynamic_output_buffer_mode(b, inst) ||
		is_encoder_input_buffer(b, inst)) {
		buffer_info->dequeued = true;

		dprintk(VIDC_DBG, "[DEQUEUED]: fd[0] = %d\n",
+32 −0
Original line number Diff line number Diff line
@@ -1650,6 +1650,36 @@ static struct vb2_buffer *get_vb_from_device_addr(struct buf_queue *bufq,
	return vb;
}


static void handle_dynamic_input_buffer(struct msm_vidc_inst *inst,
		ion_phys_addr_t device_addr)
{
	struct buffer_info *binfo = NULL, *temp = NULL;

	if (inst->session_type == MSM_VIDC_ENCODER) {
		binfo = device_to_uvaddr(&inst->registeredbufs, device_addr);
		if (!binfo) {
			dprintk(VIDC_ERR,
				"%s buffer not found in registered list\n",
				__func__);
			return;
		}
		dprintk(VIDC_DBG,
			"EBD fd[0] = %d -> EBD_ref_released, addr: %pa\n",
			binfo->fd[0], &device_addr);

		mutex_lock(&inst->registeredbufs.lock);
		list_for_each_entry(temp, &inst->registeredbufs.list,
				list) {
			if (temp == binfo) {
				binfo->pending_deletion = true;
				break;
			}
		}
		mutex_unlock(&inst->registeredbufs.lock);
	}
}

static void handle_ebd(enum hal_command_response cmd, void *data)
{
	struct msm_vidc_cb_data_done *response = data;
@@ -1669,6 +1699,8 @@ static void handle_ebd(enum hal_command_response cmd, void *data)
		return;
	}

	handle_dynamic_input_buffer(inst, response->input_done.packet_buffer);

	vb = get_vb_from_device_addr(&inst->bufq[OUTPUT_PORT],
			response->input_done.packet_buffer);
	if (vb) {