Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3218457rwo; Fri, 4 Aug 2023 00:59:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFo+io/mvLNCWKSDRaNtTs0FKYRecnuYK4JGRwPhNF67L0OgvNe3u94SvXjt4xxobBnwsvD X-Received: by 2002:a17:906:305b:b0:97c:64bd:50a5 with SMTP id d27-20020a170906305b00b0097c64bd50a5mr843329ejd.53.1691135952510; Fri, 04 Aug 2023 00:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691135952; cv=none; d=google.com; s=arc-20160816; b=qLqSQqUo71hkDePnDJrPhxYUyoXEZJGrGZyMlLK7lT/D+fjB+VRfK1alQLt7D1yh0N KQMtc3dAkf/XZSjTmya/tZb4QVf7Z3lXdRbvTgLaMHK+szUknGlwNAWdify9kdTjD1UY ESs5xnOLcmRQeWOpRCwJCr/FCRZJZigLiAj0xPYBqV9dtWngLC1tFcDktv43Pu16ciMe m414Ky13EQQsn5Ymes5IKJgpIYK3vtWc2i6r6cUiXjoE29vrUA50sPynovK1LMRw6YSY 4SlfN68sYg5JrWyJgQHFJbDe+1auyzTRjud/pXl7LNpux3xY6DYQi8pF3Wwh1JplutuT F9Bg== 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=KAvsrRnPMbPNsRQigklTtE1PGcnW0d4sIngzqLt9k1M=; fh=9Aon3jQEVE1p+dS8p5fghxMOlPjmNOu/O0E5mCMmCJg=; b=IC8tBT098/mfSMoa8rjx1Wxt8zmHBDOtxyXc+LMo4bXriaiZ1jVpC3CVEDVYx5vO5F tjieSSGwacS+VfBAXbaJqNRsdNleI/RRbsiy8UHBA7iGX3VfM3iMk8ZsLQDq9TIaEki8 0qK3Pv/gDbMINMG4aEFcLrb7sHAhSpgVH7B40AsKnR/+xtn44fe1ZZTNroll79UY5aBG KvFurzSevRAY1OscdWXATC3yjRibACy/lf9WXPwzhrsjjLTp2qseNTPrb2+EaOhrhAxA hqj8YOfNjT/ziIJ9F1V/fAqWgppzmaIY+cjIpltTavSdQz1cORavgeA/uEo/REwSEheX fJ0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=iqZfSylJ; 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 qp28-20020a170907207c00b00993b3881ecbsi1281552ejb.682.2023.08.04.00.58.48; Fri, 04 Aug 2023 00:59:12 -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=iqZfSylJ; 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 S234228AbjHDH3c (ORCPT + 99 others); Fri, 4 Aug 2023 03:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234146AbjHDH3F (ORCPT ); Fri, 4 Aug 2023 03:29:05 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6945B3ABE for ; Fri, 4 Aug 2023 00:29:04 -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 AAA4066071BB; Fri, 4 Aug 2023 08:29:02 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691134143; bh=sMSXWGMzRY15n7GP2+/uJ71airFfgmnnXjt646sPTj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqZfSylJV4GtvmL7oED7wG4r4kBsy/pRa+iYrHa6/pEsBw0l0YB8eZiZDtn4gIj3x S03ZZNNdyyEXbrnMoV0pNmF7YjJagOpp0lFu43fU9rZSk+caIX1aBnH/gjypHaRV/8 ygjQG7CW1W9laxBW3hEXCe7EhI3Gbe5a3lIypjcj330VSB1+uecL8s1jd4Z1LwWO5i VDeTVW+uwwQQuJGdOgIXbQQiKASWf4SGSBF26Qz5o/LvyUgvB3GJx7VvsaV95SH+c4 Mrs1qVWrw5rwNKSRKXFqRnVoPOd+GRkQdaaByKgV+n1Rh1iFYX01sGr0nY5xy4LiIq 487nvC+X3Db8Q== 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 Subject: [PATCH v10 07/16] drm/mediatek: aal: Use bitfield macros Date: Fri, 4 Aug 2023 09:28:41 +0200 Message-ID: <20230804072850.89365-8-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 Make the code more robust and improve readability by using bitfield macros instead of open coding bit operations. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_disp_aal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_disp_aal.c b/drivers/gpu/drm/mediatek/mtk_disp_aal.c index e2e4155faf01..bec035780db0 100644 --- a/drivers/gpu/drm/mediatek/mtk_disp_aal.c +++ b/drivers/gpu/drm/mediatek/mtk_disp_aal.c @@ -18,6 +18,8 @@ #define DISP_AAL_EN 0x0000 #define AAL_EN BIT(0) #define DISP_AAL_SIZE 0x0030 +#define DISP_AAL_SIZE_HSIZE GENMASK(28, 16) +#define DISP_AAL_SIZE_VSIZE GENMASK(12, 0) #define DISP_AAL_OUTPUT_SIZE 0x04d8 #define DISP_AAL_LUT_SIZE 512 @@ -56,9 +58,13 @@ void mtk_aal_config(struct device *dev, unsigned int w, unsigned int bpc, struct cmdq_pkt *cmdq_pkt) { struct mtk_disp_aal *aal = dev_get_drvdata(dev); + u32 sz; - mtk_ddp_write(cmdq_pkt, w << 16 | h, &aal->cmdq_reg, aal->regs, DISP_AAL_SIZE); - mtk_ddp_write(cmdq_pkt, w << 16 | h, &aal->cmdq_reg, aal->regs, DISP_AAL_OUTPUT_SIZE); + sz = FIELD_PREP(DISP_AAL_SIZE_HSIZE, w); + sz |= FIELD_PREP(DISP_AAL_SIZE_VSIZE, h); + + mtk_ddp_write(cmdq_pkt, sz, &aal->cmdq_reg, aal->regs, DISP_AAL_SIZE); + mtk_ddp_write(cmdq_pkt, sz, &aal->cmdq_reg, aal->regs, DISP_AAL_OUTPUT_SIZE); } /** -- 2.41.0