v4l: add output dump feature [1/1]
authorSong Zhao <song.zhao@amlogic.com>
Fri, 26 Jun 2020 21:30:17 +0000 (14:30 -0700)
committerSong Zhao <song.zhao@amlogic.com>
Thu, 17 Dec 2020 05:34:17 +0000 (21:34 -0800)
PD#SWPL-28515

Problem:
Some App like Cobalt has random garbage, need stream dump to analyze

Solution:
Add dump feature

Verify:
U212

Change-Id: Ifa00f582f4add2ae43f5636dde4bda6a97bfccf6
Signed-off-by: Song Zhao <song.zhao@amlogic.com>
drivers/amvdec_ports/aml_vcodec_adapt.c
drivers/amvdec_ports/aml_vcodec_dec_drv.c

index 521526ceae7c177d1e24ba13a615d0addcde2463..34e9c8febf7de4be755c2ce083e72ccc3eff7436 100644 (file)
@@ -55,6 +55,7 @@
 
 //#define DATA_DEBUG
 
+extern int dump_output_frame;
 extern void aml_recycle_dma_buffers(struct aml_vcodec_ctx *ctx, u32 handle);
 static int def_4k_vstreambuf_sizeM =
        (DEFAULT_VIDEO_BUFFER_SIZE_4K >> 20);
@@ -608,6 +609,18 @@ out:
        return ret;
 }
 
+void dump(const char* path, const char *data, unsigned int size)
+{
+       struct file *fp;
+
+       fp = filp_open(path,
+                       O_CREAT | O_RDWR | O_LARGEFILE | O_APPEND, 0600);
+       if (!IS_ERR(fp)) {
+               kernel_write(fp, data, size, 0);
+               filp_close(fp, NULL);
+       }
+
+}
 int vdec_vbuf_write(struct aml_vdec_adapt *ada_ctx,
        const char *buf, unsigned int count)
 {
@@ -678,10 +691,11 @@ int vdec_vframe_write(struct aml_vdec_adapt *ada_ctx,
                msleep(30);
        }
 
-#ifdef DATA_DEBUG
-       /* dump to file */
-       dump_write(buf, count);
-#endif
+       if (dump_output_frame > 0) {
+               dump("/data/es.data", buf, count);
+               dump_output_frame--;
+       }
+
        v4l_dbg(ada_ctx->ctx, V4L_DEBUG_CODEC_INPUT,
                "write frames, vbuf: %p, size: %u, ret: %d, crc: %x, ts: %llu\n",
                buf, count, ret, crc32_le(0, buf, count), timestamp);
index 1a975c2b555e1c47d2fb989f5c4df7f7bd8be1ce..1ed0b9766f2591ffdf4497d312f671bb5de69e71 100644 (file)
@@ -620,6 +620,10 @@ bool dump_capture_frame;
 EXPORT_SYMBOL(dump_capture_frame);
 module_param(dump_capture_frame, bool, 0644);
 
+int dump_output_frame;
+EXPORT_SYMBOL(dump_output_frame);
+module_param(dump_output_frame, int, 0644);
+
 EXPORT_SYMBOL(param_sets_from_ucode);
 module_param(param_sets_from_ucode, bool, 0644);