diff mbox series

[4/6,RESEND] media: mediatek: vcodec: Get get each instance format type

Message ID 20230320102838.8313-5-yunfei.dong@mediatek.com
State New
Headers show
Series media: mediatek: vcodec: Add debugfs file for decode and encode | expand

Commit Message

Yunfei Dong March 20, 2023, 10:28 a.m. UTC
Adding echo command to get capture and output queue format type:
'echo -format > vdec'

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 .../mediatek/vcodec/mtk_vcodec_dbgfs.c        | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
diff mbox series

Patch

diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
index 9e7d57d21cea..8a03f986a857 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dbgfs.c
@@ -10,6 +10,34 @@ 
 #include "mtk_vcodec_drv.h"
 #include "mtk_vcodec_util.h"
 
+static void mtk_vdec_dbgfs_get_format_type(int output, int capture)
+{
+	switch (output) {
+	case V4L2_PIX_FMT_H264_SLICE:
+		pr_info("output format: h264 slice\n");
+		break;
+	case V4L2_PIX_FMT_VP8_FRAME:
+		pr_info("output format: vp8 slice\n");
+		break;
+	case V4L2_PIX_FMT_VP9_FRAME:
+		pr_info("output format: vp9 slice\n");
+		break;
+	default:
+		pr_info("unsupported output format: 0x%x\n", output);
+	}
+
+	switch (capture) {
+	case V4L2_PIX_FMT_MM21:
+		pr_info("capture format MM21\n");
+		break;
+	case V4L2_PIX_FMT_MT21C:
+		pr_info("capture format MT21C\n");
+		break;
+	default:
+		pr_info("unsupported capture format: 0x%x\n", capture);
+	}
+}
+
 static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
 				    size_t count, loff_t *ppos)
 {
@@ -33,11 +61,17 @@  static ssize_t mtk_vdec_dbgfs_write(struct file *filp, const char __user *ubuf,
 				ctx->picinfo.pic_w, ctx->picinfo.pic_h,
 				ctx->picinfo.buf_w, ctx->picinfo.buf_h);
 		}
+
+		if (strstr(buf, "-format")) {
+			str_count++;
+			mtk_vdec_dbgfs_get_format_type(ctx->current_codec, ctx->capture_fourcc);
+		}
 	}
 
 	if (!str_count) {
 		pr_info("\t can not found useful cmd: %s\n", buf);
 		pr_info("\t -picinfo	     ex. echo -picinfo\n");
+		pr_info("\t -format	     ex. echo -format\n");
 	}
 
 	return count;