Need to change kernel driver to open decode and encode debug log at current period,
it's very unreasonable. Adding debugfs common interface to support decode and encode,
using echo command to control debug log level and getting useful information for each
instance.
patch 1 add dbgfs common interface.
patch 2~5 support decode.
patch 6~7 support encode
---
changed with v1:
- add new patch 4 and 5.
- using cmd 'cat vdec' to show debug information instead of pr_info directly.
---
Yunfei Dong (7):
media: mediatek: vcodec: Add debugfs interface to get debug
information
media: mediatek: vcodec: Add debug params to control different log
level
media: mediatek: vcodec: Add a debugfs file to get different useful
information
media: mediatek: vcodec: Get each context resolution information
media: mediatek: vcodec: Get get each instance format type
media: mediatek: vcodec: Change dbgfs interface to support encode
media: mediatek: vcodec: Add encode to support dbgfs
.../media/platform/mediatek/vcodec/Makefile | 6 +
.../mediatek/vcodec/mtk_vcodec_dbgfs.c | 196 ++++++++++++++++++
.../mediatek/vcodec/mtk_vcodec_dbgfs.h | 73 +++++++
.../mediatek/vcodec/mtk_vcodec_dec_drv.c | 4 +
.../platform/mediatek/vcodec/mtk_vcodec_drv.h | 4 +
.../mediatek/vcodec/mtk_vcodec_enc_drv.c | 2 +
.../mediatek/vcodec/mtk_vcodec_util.c | 8 +
.../mediatek/vcodec/mtk_vcodec_util.h | 25 ++-
8 files changed, 315 insertions(+), 3 deletions(-)
create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
create mode 100644 drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
--
2.18.0
Add encode to support dbgfs.
Signed-off-by: Yunfei Dong <[email protected]>
---
drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
index 9095186d5495..6961f66b5693 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_enc_drv.c
@@ -353,6 +353,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_enc_reg;
}
+ mtk_vcodec_dbgfs_init(dev, true);
mtk_v4l2_debug(0, "encoder %d registered as /dev/video%d",
dev->venc_pdata->core_id, vfd_enc->num);
@@ -463,6 +464,7 @@ static int mtk_vcodec_enc_remove(struct platform_device *pdev)
if (dev->vfd_enc)
video_unregister_device(dev->vfd_enc);
+ mtk_vcodec_dbgfs_deinit(dev);
v4l2_device_unregister(&dev->v4l2_dev);
pm_runtime_disable(dev->pm.dev);
mtk_vcodec_fw_release(dev->fw_handler);
--
2.18.0
Adding echo command to get capture and output queue format
type:'echo -format > vdec'
Signed-off-by: Yunfei Dong <[email protected]>
---
.../mediatek/vcodec/mtk_vcodec_dbgfs.c | 48 +++++++++++++++++++
.../mediatek/vcodec/mtk_vcodec_dbgfs.h | 1 +
2 files changed, 49 insertions(+)
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
index 19a1dc068efd..1b1b4301a83d 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
@@ -10,6 +10,48 @@
#include "mtk_vcodec_drv.h"
#include "mtk_vcodec_util.h"
+static void mtk_vdec_dbgfs_get_format_type(struct mtk_vcodec_ctx *ctx, char *buf,
+ int *used, int total)
+{
+ int curr_len;
+
+ switch (ctx->current_codec) {
+ case V4L2_PIX_FMT_H264_SLICE:
+ curr_len = snprintf(buf + *used, total - *used,
+ "\toutput format: h264 slice\n");
+ break;
+ case V4L2_PIX_FMT_VP8_FRAME:
+ curr_len = snprintf(buf + *used, total - *used,
+ "\toutput format: vp8 slice\n");
+ break;
+ case V4L2_PIX_FMT_VP9_FRAME:
+ curr_len = snprintf(buf + *used, total - *used,
+ "\toutput format: vp9 slice\n");
+ break;
+ default:
+ curr_len = snprintf(buf + *used, total - *used,
+ "\tunsupported output format: 0x%x\n",
+ ctx->current_codec);
+ }
+ *used += curr_len;
+
+ switch (ctx->capture_fourcc) {
+ case V4L2_PIX_FMT_MM21:
+ curr_len = snprintf(buf + *used, total - *used,
+ "\tcapture format MM21\n");
+ break;
+ case V4L2_PIX_FMT_MT21C:
+ curr_len = snprintf(buf + *used, total - *used,
+ "\tcapture format MT21C\n");
+ break;
+ default:
+ curr_len = snprintf(buf + *used, total - *used,
+ "\tunsupported capture format: 0x%x\n",
+ ctx->capture_fourcc);
+ }
+ *used += curr_len;
+}
+
static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
size_t count, loff_t *ppos)
{
@@ -45,6 +87,9 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf,
if (strstr(dbgfs->dbgfs_buf, "-picinfo"))
dbgfs_index[MTK_VDEC_DBGFS_PICINFO] = true;
+ if (strstr(dbgfs->dbgfs_buf, "-format"))
+ dbgfs_index[MTK_VDEC_DBGFS_FORMAT] = true;
+
mutex_lock(&dbgfs->dbgfs_lock);
list_for_each_entry(dbgfs_inst, &dbgfs->dbgfs_head, node) {
ctx = dbgfs_inst->vcodec_ctx;
@@ -60,6 +105,9 @@ static ssize_t mtk_vdec_dbgfs_read(struct file *filp, char __user *ubuf,
ctx->picinfo.buf_w, ctx->picinfo.buf_h);
used_len += curr_len;
}
+
+ if (dbgfs_index[MTK_VDEC_DBGFS_FORMAT])
+ mtk_vdec_dbgfs_get_format_type(ctx, buf, &used_len, total_len);
}
mutex_unlock(&dbgfs->dbgfs_lock);
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
index de886d79ad01..9e586889717b 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
@@ -15,6 +15,7 @@ struct mtk_vcodec_ctx;
*/
enum mtk_vdec_dbgfs_log_index {
MTK_VDEC_DBGFS_PICINFO,
+ MTK_VDEC_DBGFS_FORMAT,
MTK_VDEC_DBGFS_MAX,
};
--
2.18.0
Extend dbgfs init interface to support encode and create encode
dbgfs file.
Signed-off-by: Yunfei Dong <[email protected]>
---
.../media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c | 9 +++++++--
.../media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h | 4 ++--
.../media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c | 2 +-
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
index 1b1b4301a83d..4f6d0a4af651 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
@@ -160,11 +160,14 @@ void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id)
}
EXPORT_SYMBOL_GPL(mtk_vcodec_dbgfs_remove);
-void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev)
+void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode)
{
struct dentry *vcodec_root;
- vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL);
+ if (is_encode)
+ vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-enc", NULL);
+ else
+ vcodec_dev->dbgfs.vcodec_root = debugfs_create_dir("vcodec-dec", NULL);
if (IS_ERR(vcodec_dev->dbgfs.vcodec_root))
dev_err(&vcodec_dev->plat_dev->dev, "create vcodec dir err:%d\n",
IS_ERR(vcodec_dev->dbgfs.vcodec_root));
@@ -174,6 +177,8 @@ void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev)
debugfs_create_x32("mtk_vcodec_dbg", 0644, vcodec_root, &mtk_vcodec_dbg);
vcodec_dev->dbgfs.inst_count = 0;
+ if (is_encode)
+ return;
INIT_LIST_HEAD(&vcodec_dev->dbgfs.dbgfs_head);
debugfs_create_file("vdec", 0200, vcodec_root, vcodec_dev, &vdec_fops);
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
index 9e586889717b..f4d6afff64f3 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.h
@@ -51,7 +51,7 @@ struct mtk_vcodec_dbgfs {
#if defined(CONFIG_DEBUG_FS)
void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx);
void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, int ctx_id);
-void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev);
+void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode);
void mtk_vcodec_dbgfs_deinit(struct mtk_vcodec_dev *vcodec_dev);
#else
static inline void mtk_vcodec_dbgfs_create(struct mtk_vcodec_ctx *ctx)
@@ -62,7 +62,7 @@ static inline void mtk_vcodec_dbgfs_remove(struct mtk_vcodec_dev *vcodec_dev, in
{
}
-static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev)
+static inline void mtk_vcodec_dbgfs_init(struct mtk_vcodec_dev *vcodec_dev, bool is_encode)
{
}
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
index 8c2443a18f5e..bba7b932f4fa 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
@@ -433,7 +433,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
mtk_v4l2_debug(0, "media registered as /dev/media%d", vfd_dec->minor);
}
- mtk_vcodec_dbgfs_init(dev);
+ mtk_vcodec_dbgfs_init(dev, false);
mtk_v4l2_debug(0, "decoder registered as /dev/video%d", vfd_dec->minor);
return 0;
--
2.18.0
Il 22/03/23 10:46, Yunfei Dong ha scritto:
> Adding echo command to get capture and output queue format
> type:'echo -format > vdec'
>
> Signed-off-by: Yunfei Dong <[email protected]>
> ---
> .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 48 +++++++++++++++++++
> .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 1 +
> 2 files changed, 49 insertions(+)
>
> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> index 19a1dc068efd..1b1b4301a83d 100644
> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> @@ -10,6 +10,48 @@
> #include "mtk_vcodec_drv.h"
> #include "mtk_vcodec_util.h"
>
> +static void mtk_vdec_dbgfs_get_format_type(struct mtk_vcodec_ctx *ctx, char *buf,
> + int *used, int total)
> +{
> + int curr_len;
> +
> + switch (ctx->current_codec) {
> + case V4L2_PIX_FMT_H264_SLICE:
> + curr_len = snprintf(buf + *used, total - *used,
> + "\toutput format: h264 slice\n");
Isn't this the same information that's also given by the VIDIOC_ENUM_FMT ioctl?
Check functions v4l_enum_fmt(), v4l_fill_fmtdesc().
Regards,
Angelo
Hi AngeloGioacchino
Thanks for your suggestion.
On Wed, 2023-03-22 at 13:12 +0100, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> Il 22/03/23 10:46, Yunfei Dong ha scritto:
> > Adding echo command to get capture and output queue format
> > type:'echo -format > vdec'
> >
> > Signed-off-by: Yunfei Dong <[email protected]>
> > ---
> > .../mediatek/vcodec/mtk_vcodec_dbgfs.c | 48
> > +++++++++++++++++++
> > .../mediatek/vcodec/mtk_vcodec_dbgfs.h | 1 +
> > 2 files changed, 49 insertions(+)
> >
> > diff --git
> > a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> > b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> > index 19a1dc068efd..1b1b4301a83d 100644
> > --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> > +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
> > @@ -10,6 +10,48 @@
> > #include "mtk_vcodec_drv.h"
> > #include "mtk_vcodec_util.h"
> >
> > +static void mtk_vdec_dbgfs_get_format_type(struct mtk_vcodec_ctx
> > *ctx, char *buf,
> > + int *used, int total)
> > +{
> > + int curr_len;
> > +
> > + switch (ctx->current_codec) {
> > + case V4L2_PIX_FMT_H264_SLICE:
> > + curr_len = snprintf(buf + *used, total - *used,
> > + "\toutput format: h264 slice\n");
>
> Isn't this the same information that's also given by the
> VIDIOC_ENUM_FMT ioctl?
>
> Check functions v4l_enum_fmt(), v4l_fill_fmtdesc().
>
This patch used to get output and capture format for each instance.
Maybe 2 ~ 49 instance to paly video at the same time.
Need to know the format type for each instance.
> Regards,
> Angelo
>
Best Regards,
Yunfei Dong
>