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

Commit ad512472 authored by Arun Menon's avatar Arun Menon
Browse files

msm: vidc: add debugfs support for dynamic buffer mode



video driver debugfs will provide the following info
(a) buffer mode for each buffer type
(b) list of pending output dynamic buffers with
firmware and driver along with their ref count, fd
and address.

Change-Id: Idc3816c825dfb0c174e6d01b72e741d14f9299e3
Signed-off-by: default avatarArun Menon <avmenon@codeaurora.org>
parent 07f1e3d0
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@ static struct debug_buffer dbg_buf;
	__buf.filled_size = 0; \
})

#define DYNAMIC_BUF_OWNER(__binfo) ({ \
	atomic_read(&__binfo->ref_count) == 2 ? "video driver" : "firmware";\
})

static int core_info_open(struct inode *inode, struct file *file)
{
	file->private_data = inode->i_private;
@@ -193,6 +197,37 @@ static int inst_info_open(struct inode *inode, struct file *file)
	return 0;
}

static int publish_unreleased_reference(struct msm_vidc_inst *inst)
{
	struct buffer_info *temp = NULL;
	struct buffer_info *dummy = NULL;
	struct list_head *list = NULL;

	if (!inst) {
		dprintk(VIDC_ERR, "%s: invalid param\n", __func__);
		return -EINVAL;
	}

	list = &inst->registered_bufs;
	mutex_lock(&inst->lock);
	if (inst->buffer_mode_set[CAPTURE_PORT] == HAL_BUFFER_MODE_DYNAMIC) {
		list_for_each_entry_safe(temp, dummy, list, list) {
			if (temp && temp->type ==
			V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
			!temp->inactive && atomic_read(&temp->ref_count)) {
				write_str(&dbg_buf,
				"\tpending buffer: 0x%x fd[0] = %d ref_count = %d held by: %s\n",
				temp->device_addr[0],
				temp->fd[0],
				atomic_read(&temp->ref_count),
				DYNAMIC_BUF_OWNER(temp));
			}
		}
	}
	mutex_unlock(&inst->lock);
	return 0;
}

static ssize_t inst_info_read(struct file *file, char __user *buf,
		size_t count, loff_t *ppos)
{
@@ -221,6 +256,19 @@ static ssize_t inst_info_read(struct file *file, char __user *buf,
		write_str(
		&dbg_buf, "type: %s\n", inst->fmts[i]->type == OUTPUT_PORT ?
		"Output" : "Capture");
		switch (inst->buffer_mode_set[i]) {
		case HAL_BUFFER_MODE_STATIC:
			write_str(&dbg_buf, "buffer mode : %s\n", "static");
			break;
		case HAL_BUFFER_MODE_RING:
			write_str(&dbg_buf, "buffer mode : %s\n", "ring");
			break;
		case HAL_BUFFER_MODE_DYNAMIC:
			write_str(&dbg_buf, "buffer mode : %s\n", "dynamic");
			break;
		default:
			write_str(&dbg_buf, "buffer mode : unsupported\n");
		}
		for (j = 0; j < inst->fmts[i]->num_planes; j++)
			write_str(&dbg_buf, "size for plane %d: %u\n", j,
			inst->bufq[i].vb2_bufq.plane_sizes[j]);
@@ -235,6 +283,8 @@ static ssize_t inst_info_read(struct file *file, char __user *buf,
	write_str(&dbg_buf, "EBD Count: %d\n", inst->count.ebd);
	write_str(&dbg_buf, "FTB Count: %d\n", inst->count.ftb);
	write_str(&dbg_buf, "FBD Count: %d\n", inst->count.fbd);
	publish_unreleased_reference(inst);

	return simple_read_from_buffer(buf, count, ppos,
		dbg_buf.ptr, dbg_buf.filled_size);
}