From cccadf391f6031370fd29c28b1573ab03832eb07 Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Tue, 2 Jun 2015 16:27:54 +0900 Subject: [PATCH] [COMMON] media: smfc: measure H/W delay The delay in usec. is stored to reserved2 field of v4l2_buffer of capture queue. Change-Id: I91165095d69003d67c48a36a147d03a386d9ed89 Signed-off-by: Cho KyongHo --- drivers/media/platform/exynos/smfc/smfc.c | 9 +++++++++ drivers/media/platform/exynos/smfc/smfc.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/drivers/media/platform/exynos/smfc/smfc.c b/drivers/media/platform/exynos/smfc/smfc.c index c9fe83960601..9e3bebbc5931 100644 --- a/drivers/media/platform/exynos/smfc/smfc.c +++ b/drivers/media/platform/exynos/smfc/smfc.c @@ -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; diff --git a/drivers/media/platform/exynos/smfc/smfc.h b/drivers/media/platform/exynos/smfc/smfc.h index a59e01b6a25c..9a758adaaa0a 100644 --- a/drivers/media/platform/exynos/smfc/smfc.h +++ b/drivers/media/platform/exynos/smfc/smfc.h @@ -12,6 +12,8 @@ #ifndef _MEDIA_EXYNOS_SMFC_H_ #define _MEDIA_EXYNOS_SMFC_H_ +#include + #include #include #include @@ -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; -- 2.20.1