[COMMON] media: smfc: measure H/W delay
authorCho KyongHo <pullip.cho@samsung.com>
Tue, 2 Jun 2015 07:27:54 +0000 (16:27 +0900)
committerSeungchul Kim <sc377.kim@samsung.com>
Mon, 28 May 2018 05:31:04 +0000 (14:31 +0900)
The delay in usec. is stored to reserved2 field of v4l2_buffer of
capture queue.

Change-Id: I91165095d69003d67c48a36a147d03a386d9ed89
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/media/platform/exynos/smfc/smfc.c
drivers/media/platform/exynos/smfc/smfc.h

index c9fe8396060198903cfc890e1eb15cab36325668..9e3bebbc5931af818a5ad37ee5ede1630f6f3594 100644 (file)
@@ -292,11 +292,14 @@ static irqreturn_t exynos_smfc_irq_handler(int irq, void *priv)
 {
        struct smfc_dev *smfc = priv;
        struct smfc_ctx *ctx = v4l2_m2m_get_curr_priv(smfc->m2mdev);
+       ktime_t ktime;
        enum vb2_buffer_state state = VB2_BUF_STATE_DONE;
        u32 streamsize = smfc_get_streamsize(smfc);
        u32 thumb_streamsize = smfc_get_2nd_streamsize(smfc);
        bool suspending = false;
 
+       ktime = ktime_get();
+
        if (!(smfc->flags & SMFC_DEV_RUNNING)) {
                smfc_dump_registers(smfc);
                BUG();
@@ -333,6 +336,10 @@ static irqreturn_t exynos_smfc_irq_handler(int irq, void *priv)
                                vb2_set_plane_payload(&vb_capture->vb2_buf, 1,
                                                        thumb_streamsize);
                }
+
+               vb_capture->vb2_buf.timestamp =
+                               (__u32)ktime_us_delta(ktime, ctx->ktime_beg);
+
                v4l2_m2m_buf_done(v4l2_m2m_src_buf_remove(ctx->m2mctx), state);
                v4l2_m2m_buf_done(vb_capture, state);
                if (!suspending) {
@@ -1235,6 +1242,8 @@ static void smfc_m2m_device_run(void *priv)
        ctx->smfc->flags |= SMFC_DEV_RUNNING;
        spin_unlock_irqrestore(&ctx->smfc->flag_lock, flags);
 
+       ctx->ktime_beg = ktime_get();
+
        smfc_hwconfigure_start(ctx, restart_interval, !!enable_hwfc);
 
        return;
index a59e01b6a25c8a9f7029f4dc756eb6558e763742..9a758adaaa0ae239c2bceb47e14c7feb25e6ed91 100644 (file)
@@ -12,6 +12,8 @@
 #ifndef _MEDIA_EXYNOS_SMFC_H_
 #define _MEDIA_EXYNOS_SMFC_H_
 
+#include <linux/ktime.h>
+
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-mem2mem.h>
@@ -68,6 +70,7 @@ struct smfc_ctx {
        struct v4l2_ctrl_handler v4l2_ctrlhdlr;
        struct smfc_dev *smfc;
        struct v4l2_m2m_ctx *m2mctx;
+       ktime_t ktime_beg;
        u32 flags;
        /* uncomressed image description */
        const struct smfc_image_format *img_fmt;