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

Commit d168b1da authored by Vikash Garodia's avatar Vikash Garodia
Browse files

msm: vidc: Invalidate encoder output buffer cache



For encode usecase, video driver operates cache always on
the encoded data length rather than the buffer length.
This is an optimization and saves cache operation on unused
memory region.
VB index is used to identify a buffer given to client and fed
again to encoder. Based on that, the filled length of that
buffer is then operated for cache operations.
For certain usecases, it is difficult to identify the buffer
based on VB index. Hence keep a counter to track the max filled
length during the usecase and operate cache on that length

Change-Id: I62cfe876077786ec9d14f541a0080cd2fc124b01
Signed-off-by: default avatarVikash Garodia <vgarodia@codeaurora.org>
parent 185da22f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1597,6 +1597,7 @@ void *msm_vidc_open(int core_id, int session_type)
	inst->rc_type = V4L2_MPEG_VIDEO_BITRATE_MODE_VBR;
	inst->dpb_extra_binfo = NULL;
	inst->all_intra = false;
	inst->max_filled_len = 0;

	for (i = SESSION_MSG_INDEX(SESSION_MSG_START);
		i <= SESSION_MSG_INDEX(SESSION_MSG_END); i++) {
+5 −65
Original line number Diff line number Diff line
@@ -2626,8 +2626,8 @@ static void handle_fbd(enum hal_command_response cmd, void *data)
		fill_buf_done->input_tag, fill_buf_done->input_tag2);

	if (inst->session_type == MSM_VIDC_ENCODER) {
		msm_comm_store_filled_length(&inst->fbd_data, vb->index,
			fill_buf_done->filled_len1);
		if (inst->max_filled_len < fill_buf_done->filled_len1)
			inst->max_filled_len = fill_buf_done->filled_len1;
	}

	f = &inst->fmts[OUTPUT_PORT].v4l2_fmt;
@@ -6482,14 +6482,11 @@ int msm_comm_qbuf_cache_operations(struct msm_vidc_inst *inst,
				}
			} else if (vb->type == OUTPUT_MPLANE) {
				if (!i) { /* bitstream */
					u32 size_u32;
					skip = false;
					offset = 0;
					size_u32 = vb->planes[i].length;
					msm_comm_fetch_filled_length(
						&inst->fbd_data, vb->index,
						&size_u32);
					size = size_u32;
					size = vb->planes[i].length;
					if (inst->max_filled_len)
						size = inst->max_filled_len;
					cache_op = SMEM_CACHE_INVALIDATE;
				}
			}
@@ -7055,63 +7052,6 @@ void msm_comm_release_client_data(struct msm_vidc_inst *inst, bool remove)
	mutex_unlock(&inst->client_data.lock);
}

void msm_comm_store_filled_length(struct msm_vidc_list *data_list,
		u32 index, u32 filled_length)
{
	struct msm_vidc_buf_data *pdata = NULL;
	bool found = false;

	if (!data_list) {
		dprintk(VIDC_ERR, "%s: invalid params %pK\n",
			__func__, data_list);
		return;
	}

	mutex_lock(&data_list->lock);
	list_for_each_entry(pdata, &data_list->list, list) {
		if (pdata->index == index) {
			pdata->filled_length = filled_length;
			found = true;
			break;
		}
	}

	if (!found) {
		pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
		if (!pdata)  {
			dprintk(VIDC_ERR, "%s: malloc failure.\n", __func__);
			goto exit;
		}
		pdata->index = index;
		pdata->filled_length = filled_length;
		list_add_tail(&pdata->list, &data_list->list);
	}

exit:
	mutex_unlock(&data_list->lock);
}

void msm_comm_fetch_filled_length(struct msm_vidc_list *data_list,
		u32 index, u32 *filled_length)
{
	struct msm_vidc_buf_data *pdata = NULL;

	if (!data_list || !filled_length) {
		dprintk(VIDC_ERR, "%s: invalid params %pK %pK\n",
			__func__, data_list, filled_length);
		return;
	}

	mutex_lock(&data_list->lock);
	list_for_each_entry(pdata, &data_list->list, list) {
		if (pdata->index == index) {
			*filled_length = pdata->filled_length;
			break;
		}
	}
	mutex_unlock(&data_list->lock);
}

void msm_comm_store_input_tag(struct msm_vidc_list *data_list,
		u32 index, u32 itag, u32 itag2)
{
+0 −4
Original line number Diff line number Diff line
@@ -302,10 +302,6 @@ void print_v4l2_buffer(u32 tag, const char *str, struct msm_vidc_inst *inst,
		struct v4l2_buffer *v4l2);
void kref_put_mbuf(struct msm_vidc_buffer *mbuf);
bool kref_get_mbuf(struct msm_vidc_inst *inst, struct msm_vidc_buffer *mbuf);
void msm_comm_store_filled_length(struct msm_vidc_list *data_list,
		u32 index, u32 filled_length);
void msm_comm_fetch_filled_length(struct msm_vidc_list *data_list,
		u32 index, u32 *filled_length);
void msm_comm_store_input_tag(struct msm_vidc_list *data_list,
		u32 index, u32 itag, u32 itag2);
int msm_comm_fetch_input_tag(struct msm_vidc_list *data_list,
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,6 @@ struct msm_vidc_buf_data {
	u32 index;
	u32 input_tag;
	u32 input_tag2;
	u32 filled_length;
};

struct msm_vidc_window_data {
@@ -577,6 +576,7 @@ struct msm_vidc_inst {
	int (*buffer_size_calculators)(struct msm_vidc_inst *inst);
	bool all_intra;
	bool is_perf_eligible_session;
	u32 max_filled_len;
};

extern struct msm_vidc_drv *vidc_driver;