Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3240725rwo; Fri, 4 Aug 2023 01:26:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVkhJUM8hWURjdBcoCxcbwZ+gJ4BEBjHfi71noBAisXu+xBvOVN9kZERBkAvPcGf5o9ZLu X-Received: by 2002:a17:902:d4c3:b0:1bb:f1d9:432e with SMTP id o3-20020a170902d4c300b001bbf1d9432emr959003plg.37.1691137562197; Fri, 04 Aug 2023 01:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691137562; cv=none; d=google.com; s=arc-20160816; b=ic0P/EKG6QVAmFCdkfYlA0J7OYeKni8ch0EFmh/EgtUOdtF1gyuywiXfLhd87+7OWm qAS6LJQ78v6HIGMRxMYIinpZrrkNv8LeqqPCCpGH+hoEsQzlRDn8UbEixoavRbcGL8nI IjR/hGH9tx9yxXc5KMfcBSSVGY8Nsuh5hn0C9N0cTeasHu7zG2kE81H0ali5FVLO/K3Z KfN7+wX3qwZlkCgiqRUHjB+Zd4Kb+4MYd9UqyoBLb/WmktaBSXD9VOBaP7Pou7qY6uoF MPfFnolsQ+A1CidRD47QOFYmjEPshhaswDIRtwjwwyUkh8BF8T9DrHclhrjxfcGRWf70 HPxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QxtRWSpYyOj5LmE/Q+Bsip++G5zdnJCcTZ/on+0LwCA=; fh=wVZEQimxp/UyE4Mf0Sn+nsZcfrBLHvkvU7kacOC/59o=; b=F+ZYku1pf1ughBzPzh7hURPiuzL8QmPPzPRdOF/lMl1xMmTS0Z4ekKbaOu0yjK2T1K qLV3lAQ1FPt08QXCi1+pRehVDAYAMZCBqDbNOEBCeIJEp58SuhV2j3zCjqhXVEWV560P xovcXlmtLzaxSSAT7eCVxmq/qU8s1KItpYmf6lcP96wbzP8hFuxWKyaKEp5W/blFOKlF ynuShfs7QdkCBXFEx0FTLC8246qe+YaVAB8HfH0cKvaw8QdWjo4p7xPhXJMK8w46GvMB KkH7FoxA5dwjhJH6sAA3d2R5gkFYdNJv3xIGHWeK2GqrrmyYApQhtFV/xhcaLQEq7ulb mHRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i0LpyPW+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kg3-20020a170903060300b001b80434583bsi1362651plb.227.2023.08.04.01.25.49; Fri, 04 Aug 2023 01:26:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i0LpyPW+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234157AbjHDH3F (ORCPT + 99 others); Fri, 4 Aug 2023 03:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229829AbjHDH3E (ORCPT ); Fri, 4 Aug 2023 03:29:04 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 855963AB1 for ; Fri, 4 Aug 2023 00:29:00 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4A71466071BB; Fri, 4 Aug 2023 08:28:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691134139; bh=kYeyT6HbEedO1YRPTVJsJxzagOYrnms3xwsfF+B40oU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0LpyPW+Sxg9cItk8Kr1AbXAqDwHPWyaDiLjhPEyHlouqXt8k0ErWyWVrPhwuFoWe MMIJwRKSPKbjTc/FNLoCTWX3C0le2khchlawI0johj5cctTOPQkW4TlBJU97itgE8H hS+pR5LVT8SSl3n0AuSLz1PXGvoCbM6af7xqO3Xa43SdcMlJn7eA7VURGXQ7SLjiiA w3905uCbCNtKOOhzs+/Q/f6lWG2c+zl7Zg8h9NqVzJ045/tnI7jNBkbQe4n8BhL8Pv N/UmpBE7kCboSZOFAxXQA7ra4nZbV0RuD/SC+jRf0hSeDUFvcGPceqZeh89rH9P0KY OihOZWPXv+E7g== From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wenst@chromium.org, kernel@collabora.com, ehristev@collabora.com, "Jason-JH . Lin" , Alexandre Mergnat Subject: [PATCH v10 02/16] drm/mediatek: gamma: Reduce indentation in mtk_gamma_set_common() Date: Fri, 4 Aug 2023 09:28:36 +0200 Message-ID: <20230804072850.89365-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230804072850.89365-1-angelogioacchino.delregno@collabora.com> References: <20230804072850.89365-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Invert the check for state->gamma_lut and move it at the beginning of the function to reduce indentation: this prepares the code for keeping readability on later additions. This commit brings no functional changes. Signed-off-by: AngeloGioacchino Del Regno Reviewed-by: Jason-JH.Lin Reviewed-by: Alexandre Mergnat --- drivers/gpu/drm/mediatek/mtk_disp_gamma.c | 45 ++++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c index d42cc0698d83..47751864bd5c 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_gamma.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_gamma.c @@ -64,6 +64,10 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt u32 word; u32 diff[3] = {0}; + /* If there's no gamma lut there's nothing to do here. */ + if (!state->gamma_lut) + return; + /* If we're called from AAL, dev is NULL */ gamma = dev ? dev_get_drvdata(dev) : NULL; @@ -72,29 +76,26 @@ void mtk_gamma_set_common(struct device *dev, void __iomem *regs, struct drm_crt else lut_diff = false; - if (state->gamma_lut) { - reg = readl(regs + DISP_GAMMA_CFG); - reg = reg | GAMMA_LUT_EN; - writel(reg, regs + DISP_GAMMA_CFG); - lut_base = regs + DISP_GAMMA_LUT; - lut = (struct drm_color_lut *)state->gamma_lut->data; - for (i = 0; i < MTK_LUT_SIZE; i++) { - - if (!lut_diff || (i % 2 == 0)) { - word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) + - (((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) + - ((lut[i].blue >> 6) & LUT_10BIT_MASK); - } else { - diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6); - diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6); - diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6); - - word = ((diff[0] & LUT_10BIT_MASK) << 20) + - ((diff[1] & LUT_10BIT_MASK) << 10) + - (diff[2] & LUT_10BIT_MASK); - } - writel(word, (lut_base + i * 4)); + reg = readl(regs + DISP_GAMMA_CFG); + reg = reg | GAMMA_LUT_EN; + writel(reg, regs + DISP_GAMMA_CFG); + lut_base = regs + DISP_GAMMA_LUT; + lut = (struct drm_color_lut *)state->gamma_lut->data; + for (i = 0; i < MTK_LUT_SIZE; i++) { + if (!lut_diff || (i % 2 == 0)) { + word = (((lut[i].red >> 6) & LUT_10BIT_MASK) << 20) + + (((lut[i].green >> 6) & LUT_10BIT_MASK) << 10) + + ((lut[i].blue >> 6) & LUT_10BIT_MASK); + } else { + diff[0] = (lut[i].red >> 6) - (lut[i - 1].red >> 6); + diff[1] = (lut[i].green >> 6) - (lut[i - 1].green >> 6); + diff[2] = (lut[i].blue >> 6) - (lut[i - 1].blue >> 6); + + word = ((diff[0] & LUT_10BIT_MASK) << 20) + + ((diff[1] & LUT_10BIT_MASK) << 10) + + (diff[2] & LUT_10BIT_MASK); } + writel(word, (lut_base + i * 4)); } } -- 2.41.0