Skip to content

Commit 07b7e50

Browse files
yunfei-mtkmchehab
authored andcommitted
media: mediatek: vcodec: Get each context resolution information
Will store the string to temp buffer like "echo -picinfo > vdec" when user want to get needed information. Then getting debug information using command 'cat vdec' calling mtk_vdec_dbgfs_read to analysis the temp buffer. Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 5e488a4 commit 07b7e50

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,51 @@ static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
2626
return dbgfs->buf_size;
2727
}
2828

29+
static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf,
30+
size_t count, loff_t *ppos)
31+
{
32+
struct mtk_vcodec_dev *vcodec_dev = filp->private_data;
33+
struct mtk_vcodec_dbgfs *dbgfs = &vcodec_dev->dbgfs;
34+
struct mtk_vcodec_dbgfs_inst *dbgfs_inst;
35+
struct mtk_vcodec_ctx *ctx;
36+
int total_len = 200 * (dbgfs->inst_count == 0 ? 1 : dbgfs->inst_count);
37+
int used_len = 0, curr_len, ret;
38+
bool dbgfs_index[MTK_VDEC_DBGFS_MAX] = {0};
39+
char *buf = kmalloc(total_len, GFP_KERNEL);
40+
41+
if (!buf)
42+
return -ENOMEM;
43+
44+
if (strstr(dbgfs->dbgfs_buf, "-picinfo"))
45+
dbgfs_index[MTK_VDEC_DBGFS_PICINFO] = true;
46+
47+
mutex_lock(&dbgfs->dbgfs_lock);
48+
list_for_each_entry(dbgfs_inst, &dbgfs->dbgfs_head, node) {
49+
ctx = dbgfs_inst->vcodec_ctx;
50+
51+
curr_len = snprintf(buf + used_len, total_len - used_len,
52+
"inst[%d]:\n ", ctx->id);
53+
used_len += curr_len;
54+
55+
if (dbgfs_index[MTK_VDEC_DBGFS_PICINFO]) {
56+
curr_len = snprintf(buf + used_len, total_len - used_len,
57+
"\treal(%dx%d)=>align(%dx%d)\n",
58+
ctx->picinfo.pic_w, ctx->picinfo.pic_h,
59+
ctx->picinfo.buf_w, ctx->picinfo.buf_h);
60+
used_len += curr_len;
61+
}
62+
}
63+
mutex_unlock(&dbgfs->dbgfs_lock);
64+
65+
ret = simple_read_from_buffer(ubuf, count, ppos, buf, used_len);
66+
kfree(buf);
67+
return ret;
68+
}
69+
2970
static const struct file_operations vdec_fops = {
3071
.open = simple_open,
3172
.write = mtk_vdec_dbgfs_write,
73+
.read = mtk_vdec_dbgfs_read,
3274
};
3375

3476
void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx)

drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
struct mtk_vcodec_dev;
1111
struct mtk_vcodec_ctx;
1212

13+
/*
14+
* enum mtk_vdec_dbgfs_log_index - used to get different debug information
15+
*/
16+
enum mtk_vdec_dbgfs_log_index {
17+
MTK_VDEC_DBGFS_PICINFO,
18+
MTK_VDEC_DBGFS_MAX,
19+
};
20+
1321
/**
1422
* struct mtk_vcodec_dbgfs_inst - debugfs information for each inst
1523
* @node: list node for each inst

0 commit comments

Comments
 (0)