From ed1180c0e67fb78a9c870fe80f5aa659801302c3 Mon Sep 17 00:00:00 2001 From: Janghyuck Kim Date: Tue, 30 May 2017 15:33:36 +0900 Subject: [PATCH] [COMMON] media: scaler: add context dump for debugging This patch added information of context that can be useful for unexpected error case. Change-Id: I826634b4220ae9a12d9be9fdbbab26908f2333a2 Signed-off-by: Janghyuck Kim --- drivers/media/platform/exynos/scaler/Makefile | 2 +- .../platform/exynos/scaler/scaler-core.c | 10 ++++ .../platform/exynos/scaler/scaler-debug.c | 58 +++++++++++++++++++ .../platform/exynos/scaler/scaler-regs.c | 2 + drivers/media/platform/exynos/scaler/scaler.h | 1 + 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 drivers/media/platform/exynos/scaler/scaler-debug.c diff --git a/drivers/media/platform/exynos/scaler/Makefile b/drivers/media/platform/exynos/scaler/Makefile index 433daaf13d38..3afb18741891 100644 --- a/drivers/media/platform/exynos/scaler/Makefile +++ b/drivers/media/platform/exynos/scaler/Makefile @@ -5,5 +5,5 @@ # Licensed under GPLv2 # -scaler-objs := scaler-core.o scaler-regs.o +scaler-objs := scaler-core.o scaler-regs.o scaler-debug.o obj-$(CONFIG_VIDEO_EXYNOS_SCALER) += scaler.o diff --git a/drivers/media/platform/exynos/scaler/scaler-core.c b/drivers/media/platform/exynos/scaler/scaler-core.c index 5615daf74447..8d61e4078caf 100644 --- a/drivers/media/platform/exynos/scaler/scaler-core.c +++ b/drivers/media/platform/exynos/scaler/scaler-core.c @@ -42,6 +42,9 @@ module_param_named(sc_log_level, sc_log_level, uint, 0644); int sc_set_blur; module_param_named(sc_set_blur, sc_set_blur, uint, 0644); +int sc_show_stat; +module_param_named(sc_show_stat, sc_show_stat, uint, 0644); + #define BUF_EXT_SIZE 512 #define BUF_WIDTH_ALIGN 128 @@ -2388,6 +2391,8 @@ static void sc_watchdog(unsigned long arg) if (test_bit(DEV_RUN, &sc->state)) { sc_hwregs_dump(sc); + if (sc->current_ctx) + sc_ctx_dump(sc->current_ctx); exynos_sysmmu_show_status(sc->dev); atomic_inc(&sc->wdt.cnt); dev_err(sc->dev, "scaler is still running\n"); @@ -2690,6 +2695,11 @@ static int sc_run_next_job(struct sc_dev *sc) sc_hwset_int_en(sc); + if (sc_show_stat & 0x1) + sc_hwregs_dump(sc); + if (sc_show_stat & 0x2) + sc_ctx_dump(ctx); + mod_timer(&sc->wdt.timer, jiffies + SC_TIMEOUT); if (__measure_hw_latency) { diff --git a/drivers/media/platform/exynos/scaler/scaler-debug.c b/drivers/media/platform/exynos/scaler/scaler-debug.c new file mode 100644 index 000000000000..a3412186b4c8 --- /dev/null +++ b/drivers/media/platform/exynos/scaler/scaler-debug.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Core file for Samsung EXYNOS Scaler driver + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. +*/ + +#include "scaler.h" + +static void show_crop(struct v4l2_rect *rect) +{ + pr_info(" - crop: L,T,W,H: %d, %d, %d, %d\n", + rect->left, rect->top, rect->width, rect->height); +} + +static void show_addr(struct sc_addr *addr) +{ + int i; + + for (i = 0; i < SC_MAX_PLANES; i++) + pr_info(" * plane%d. addr: %#lx, size: %#x\n", + i, (unsigned long)addr->ioaddr[i], addr->size[i]); +} + +static void show_frame(char *name, struct sc_frame *frame) +{ + pr_info(" * %s) WxH : %d x %d\n", name, frame->width, frame->height); + show_crop(&frame->crop); + show_addr(&frame->addr); + if (frame->sc_fmt) + pr_info(" * Name : %s\n", frame->sc_fmt->name); + +} + +static void show_int_frame(struct sc_int_frame *i_frame) +{ + show_addr(&i_frame->src_addr); + show_addr(&i_frame->dst_addr); +} + +void sc_ctx_dump(struct sc_ctx *ctx) +{ + pr_info("> scaler context info <\n"); + show_frame("source", &ctx->s_frame); + show_frame("dest", &ctx->d_frame); + pr_info(" - h_ratio: %#x, v_ratio: %#x\n", ctx->h_ratio, ctx->v_ratio); + pr_info(" - flip_rot_cfg: %#x\n", ctx->flip_rot_cfg); + pr_info(" - flags: %#lx\n", ctx->flags); + + if (test_bit(CTX_INT_FRAME, &ctx->flags)) { + show_frame("Internal", &ctx->i_frame->frame); + show_int_frame(ctx->i_frame); + } +} diff --git a/drivers/media/platform/exynos/scaler/scaler-regs.c b/drivers/media/platform/exynos/scaler/scaler-regs.c index 0ef48558e754..261bea573b40 100644 --- a/drivers/media/platform/exynos/scaler/scaler-regs.c +++ b/drivers/media/platform/exynos/scaler/scaler-regs.c @@ -1037,6 +1037,8 @@ static void sc_print_irq_err_status(struct sc_dev *sc, u32 status) status >>= 1; /* ignore the INT_STATUS_FRAME_END */ if (status) { sc_hwregs_dump(sc); + if (sc->current_ctx) + sc_ctx_dump(sc->current_ctx); while (status) { if (status & 1) diff --git a/drivers/media/platform/exynos/scaler/scaler.h b/drivers/media/platform/exynos/scaler/scaler.h index 531948387493..63b9aaebbe70 100644 --- a/drivers/media/platform/exynos/scaler/scaler.h +++ b/drivers/media/platform/exynos/scaler/scaler.h @@ -541,5 +541,6 @@ void sc_hwset_hcoef(struct sc_dev *sc, unsigned int coef); void sc_hwset_vcoef(struct sc_dev *sc, unsigned int coef); void sc_hwregs_dump(struct sc_dev *sc); +void sc_ctx_dump(struct sc_ctx *ctx); #endif /* SCALER__H_ */ -- 2.20.1