From patchwork Fri Sep 6 15:34:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 13794378 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 5151FE6FE2B for ; Fri, 6 Sep 2024 15:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QYkcPbOi8vGLB2UjSU9jZhaW09AfmpXM0qHr4AyqR+8=; b=l5HeeDmJBdoFjoHaxs4ejp6WFp 0NHuA1ACJG/CDuPNOpTswOmw/syD/CWroB8KgVFvfAOsHf9MPBSixaJ/zDOFy+iZK7ea6sFYFyIrh hZTdLRQqIxAWdbt8GwbnuvzklCdP6fqREcs7kDoJwMwhpTIIi1O7b3HlNcpGBGOeIfiSywP+BnFs1 XjM9GPwAMA4UfTD+JnhTwyWdsSbY0Rf0FoBnXz/VyWpFsSqI5gB6H3jqPyOKU3PCO3FlmR8VJMVBC ZldiqCOX/xSE2fCzxd7R6r0JG6dOldw+jzuv88Q628qR2e8mNQktnRNWpROypUs3hGoLbY2w1Gd5l nrdkuKAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smb9N-0000000CpAD-1Tzu; Fri, 06 Sep 2024 15:45:29 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smayj-0000000Cmzk-24hb for linux-arm-kernel@lists.infradead.org; Fri, 06 Sep 2024 15:34:35 +0000 Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 45F368A9; Fri, 6 Sep 2024 17:33:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1725636794; bh=fdBL6+UH4YwcgUMre57P76rVe6EtTBlV1eAamcn7QnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmYtq/Ci4XMwnKqD4v2VbQ11d2XDispxgUnWsRzxJvtcWNAqjmM0aUprWkuB53irS rJ0QeS6H/0F5rQxTdNt8ziK5bEdvhSMuPNjqs4chR6lg24FIcVglKrk/vHPMYW1iOv RxYU/9lLGANyxUsNkLvG1BswO2MY3OwTKbugjzF0= From: Daniel Scally To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: jacopo.mondi@ideasonboard.com, nayden.kanchev@arm.com, robh+dt@kernel.org, mchehab@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jerome.forissier@linaro.org, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi, Daniel Scally Subject: [PATCH v7 12/17] media: platform: Fill stats buffer on ISP_START Date: Fri, 6 Sep 2024 16:34:01 +0100 Message-Id: <20240906153406.650105-13-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240906153406.650105-1-dan.scally@ideasonboard.com> References: <20240906153406.650105-1-dan.scally@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240906_083429_777592_DC36D79D X-CRM114-Status: GOOD ( 14.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On ISP_START, fill the stats buffer by reading out the metering space in the ISP's memory. This is done for the non-active config just as the dma transfer of the registers is. To acheive that, move the checking of the current config outside of mali_c55_swap_next_config() so we can use it for both functions. Acked-by: Nayden Kanchev Co-developed-by: Jacopo Mondi Signed-off-by: Jacopo Mondi Signed-off-by: Daniel Scally --- Changes in v7: - Reworked how the config is swapped on ISP start Changes in v6: - None Changes in v5: - New patch .../platform/arm/mali-c55/mali-c55-core.c | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-core.c b/drivers/media/platform/arm/mali-c55/mali-c55-core.c index f1dd9c8960cd..f5cce6e24df5 100644 --- a/drivers/media/platform/arm/mali-c55/mali-c55-core.c +++ b/drivers/media/platform/arm/mali-c55/mali-c55-core.c @@ -617,12 +617,6 @@ static int mali_c55_check_hwcfg(struct mali_c55 *mali_c55) static void mali_c55_swap_next_config(struct mali_c55 *mali_c55) { struct mali_c55_context *ctx = mali_c55_get_active_context(mali_c55); - u32 curr_config; - - curr_config = mali_c55_read(mali_c55, MALI_C55_REG_PING_PONG_READ); - curr_config = (curr_config & MALI_C55_REG_PING_PONG_READ_MASK) - >> (ffs(MALI_C55_REG_PING_PONG_READ_MASK) - 1); - mali_c55->next_config = curr_config ^ 1; mali_c55_config_write(ctx, mali_c55->next_config ? MALI_C55_CONFIG_PING : MALI_C55_CONFIG_PONG, @@ -644,6 +638,7 @@ static irqreturn_t mali_c55_isr(int irq, void *context) struct mali_c55 *mali_c55 = dev_get_drvdata(dev); u32 interrupt_status; unsigned int i, j; + u32 curr_config; interrupt_status = mali_c55_read(mali_c55, MALI_C55_REG_INTERRUPT_STATUS_VECTOR); @@ -666,6 +661,22 @@ static irqreturn_t mali_c55_isr(int irq, void *context) for (j = i; j < MALI_C55_NUM_CAP_DEVS; j++) mali_c55_set_next_buffer(&mali_c55->cap_devs[j]); + /* + * When the ISP starts a frame we have some work to do: + * + * 1. Copy over the config for the **next** frame + * 2. Read out the metering stats for the **last** frame + */ + + curr_config = mali_c55_read(mali_c55, + MALI_C55_REG_PING_PONG_READ); + curr_config &= MALI_C55_REG_PING_PONG_READ_MASK; + curr_config >>= ffs(MALI_C55_REG_PING_PONG_READ_MASK) - 1; + mali_c55->next_config = curr_config ^ 1; + + mali_c55_stats_fill_buffer(mali_c55, + mali_c55->next_config ? MALI_C55_CONFIG_PING : + MALI_C55_CONFIG_PONG); mali_c55_swap_next_config(mali_c55); break;