From patchwork Sun Feb 27 16:01:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12761911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2644C433F5 for ; Sun, 27 Feb 2022 16:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3xkMfXl7dZIOIKoeVaipKtlvure1laMlZKbnC8WfJMk=; b=UtU0Wf+axGGtMB 0TZJW4OS/ApIFcUPdR/jXw7n7flH5Jb831fxx9jqdT+3GkyU6/4V28AfjbLLjxp/g0y5bCqbAk1T3 frjggU7UOcyGtR85DvEUCo00GRd4raZ1LNJwY6lY3FufIHy03dxIIurmsnQPXIqK/luzfl9yl0x2c a+HtbRLdSWT2aBXANnlSwNJKzDYMbf6x4jaojEOJtKlrjr07gcfvdBLUyBUBzsFn431dg5HoE4L5m 2oGpctSiC/dgIzWo5GK0JBQ5JWmBXQvG1A61+tzsXx3eOedFtEeJ7uLTaKgIAckTes0og24Rgx2st cD4ymE5PIudZ/b88LiyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOLzi-009dTN-52; Sun, 27 Feb 2022 16:01:58 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOLzS-009dBN-45 for linux-rockchip@lists.infradead.org; Sun, 27 Feb 2022 16:01:46 +0000 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A06A114D5; Sun, 27 Feb 2022 17:01:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1645977700; bh=NfhcRaOKnhJs2ckz7D7y6MXIixwJUREYQUk8lB1BpY8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JRzvSkNtiTain/tUCQ9NJcOI2RaFWe7j6uF2JsOtR8GIGBX8bFbyQlGFiiPF4MLwe MELqD7S10lVLo0sCAmMiEtP4O6lMByN71itpW4G98EXOUJqmWrHdYtB0c1GiAo2+By aQNHNATo4DK9tH3lG0esb9/1Zl7MN2Tj0V+LC0oI= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Dafna Hirschfeld , Heiko Stuebner , Paul Elder , Tomasz Figa , linux-rockchip@lists.infradead.org Subject: [PATCH 13/16] media: rkisp1: debug: Collect input status by sampling ISP_FLAGS_SHD Date: Sun, 27 Feb 2022 18:01:13 +0200 Message-Id: <20220227160116.18556-14-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220227160116.18556-1-laurent.pinchart@ideasonboard.com> References: <20220227160116.18556-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220227_080142_396714_1E57DD1E X-CRM114-Status: GOOD ( 13.65 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org The ISP_FLAGS_SHD register exposes the ISP parallel input signals (data and synchronization) in real time. This can help debugging when the device doesn't output any image. Sample the register 10000 times with a 1µs delay and expose the result through debugfs. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-debug.c | 46 +++++++++++++++++++ .../platform/rockchip/rkisp1/rkisp1-regs.h | 9 ++++ 2 files changed, 55 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c index 64b33774cbdf..8be4ac134cc9 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c @@ -9,9 +9,53 @@ */ #include +#include #include +#include #include "rkisp1-common.h" +#include "rkisp1-regs.h" + +#define RKISP1_DEBUG_DATA_COUNT_BINS 32 +#define RKISP1_DEBUG_DATA_COUNT_STEP (4096 / RKISP1_DEBUG_DATA_COUNT_BINS) + +static int rkisp1_debug_input_status_show(struct seq_file *m, void *p) +{ + struct rkisp1_device *rkisp1 = m->private; + u16 data_count[RKISP1_DEBUG_DATA_COUNT_BINS] = { }; + unsigned int hsync_count = 0; + unsigned int vsync_count = 0; + unsigned int i; + u32 data; + u32 val; + + /* Sample the ISP input port status 10000 times with a 1µs interval. */ + for (i = 0; i < 10000; ++i) { + val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_FLAGS_SHD); + + data = (val & RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_MASK) + >> RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_SHIFT; + data_count[data / RKISP1_DEBUG_DATA_COUNT_STEP]++; + + if (val & RKISP1_CIF_ISP_FLAGS_SHD_S_HSYNC) + hsync_count++; + if (val & RKISP1_CIF_ISP_FLAGS_SHD_S_VSYNC) + vsync_count++; + + udelay(1); + } + + seq_printf(m, "vsync: %u, hsync: %u\n", vsync_count, hsync_count); + seq_puts(m, "data:\n"); + for (i = 0; i < ARRAY_SIZE(data_count); ++i) + seq_printf(m, "- [%04u:%04u]: %u\n", + i * RKISP1_DEBUG_DATA_COUNT_STEP, + (i + 1) * RKISP1_DEBUG_DATA_COUNT_STEP - 1, + data_count[i]); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(rkisp1_debug_input_status); void rkisp1_debug_init(struct rkisp1_device *rkisp1) { @@ -42,6 +86,8 @@ void rkisp1_debug_init(struct rkisp1_device *rkisp1) &debug->frame_drop[RKISP1_MAINPATH]); debugfs_create_ulong("sp_frame_drop", 0444, debug->debugfs_dir, &debug->frame_drop[RKISP1_SELFPATH]); + debugfs_create_file("input_status", 0444, debug->debugfs_dir, rkisp1, + &rkisp1_debug_input_status_fops); } void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h index 083d92ada73f..447c5f241d69 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h @@ -454,6 +454,15 @@ #define RKISP1_CIF_ISP_DEMOSAIC_BYPASS BIT(10) #define RKISP1_CIF_ISP_DEMOSAIC_TH(x) ((x) & 0xFF) +/* ISP_FLAGS_SHD */ +#define RKISP1_CIF_ISP_FLAGS_SHD_ISP_ENABLE_SHD BIT(0) +#define RKISP1_CIF_ISP_FLAGS_SHD_ISP_ENABLE_INFORM_SHD BIT(1) +#define RKISP1_CIF_ISP_FLAGS_SHD_INFORM_FIELD BIT(2) +#define RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_MASK GENMASK(27, 16) +#define RKISP1_CIF_ISP_FLAGS_SHD_S_DATA_SHIFT 16 +#define RKISP1_CIF_ISP_FLAGS_SHD_S_VSYNC BIT(30) +#define RKISP1_CIF_ISP_FLAGS_SHD_S_HSYNC BIT(31) + /* AWB */ /* ISP_AWB_PROP */ #define RKISP1_CIF_ISP_AWB_YMAX_CMP_EN BIT(2)