Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp324980rdb; Thu, 15 Feb 2024 00:54:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVk34O1kFIdyAi0gk3lQo1DcwbXKfrJPImC/G5oxccWXwsjF+GtWauKWa1khewn1m2+3sgkSTeqFU7lAVxfRCqeY/AcoApZd6VSBHC+Jg== X-Google-Smtp-Source: AGHT+IFvjOA3URImm5p95WbNyWwXr0Fz+85Jpjjh5a59qcuk3PEDBC8JuORnuGzdWC0Yl+si5WH0 X-Received: by 2002:a05:622a:1714:b0:42c:6eb2:b1c1 with SMTP id h20-20020a05622a171400b0042c6eb2b1c1mr1765208qtk.16.1707987249406; Thu, 15 Feb 2024 00:54:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707987249; cv=pass; d=google.com; s=arc-20160816; b=Qa88C3Ww2Asfr7DKCPSat+JjRyjlk4EHgw+EMXQoLPXyGNmnnqGGA4m7MaPVCZ2bvQ pCkOfih3iD4TyaearMJVxtec4g1l8wHZu1pNifvyJaGaPPfn564G5VWj57KvV4HiSa8Y R/YE6kIcuOImYSLFM3au6ZSoC6EWZlsXGyy8XZv5uQWcMk43CQZHqrX6F1dIOa7h8Haa 0xEzk4nEsR2EFBtbsaY0NMxgcBSsOQB83rqGR8MzU2D+gBIPul/zIJM9mhh0RG4bQ9Ux AO733UMTd5+gaRVq0CVAF+pxdxqp/+vmOXjabg5aWi7sjp8D/fZ7NMtW3oGC1nQORAYz nwVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2dZ5EunJwAuX9w7HTOCTRzeuO3OmdqPTzwWpnOmJm9M=; fh=1mTP9a8EwjstuScCIXzFhy8YNI0WvYbCV0wPaHCSGlk=; b=P+pjCg9bNOlnn/o1M1jT5cLVux3uTGRE1PSXfr0lqS31kolNF9JR9kCVhmUFHwIAmr nCWahvVdeyE9KeIYcf6VCfW23mEgbFYemyb1wGZc6s2wowGkR+liLutzf8j0ncPAZ+5R MtX7Zc3m5DOvFaINPSuL4qSoBVshQLdwMeh8OkoFpZD0q7XwpLNeLkpYhoIDHQZGnBFX QCWHJK2Qlu9+5V5wMVJiilWS6I/wycaA+ArelAt0Czvlj9PGJ5HQAAqsCwlEj9jTpXah dT/bC36wRLz0i+82b3dGpH3AAYCRU4tRHLBvqCIEX8j8QOxM4B8fgpflE2PXRMHmTMBA GucQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dBWcYT6T; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-66447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r4-20020ac85c84000000b0042c5d1612a1si990404qta.152.2024.02.15.00.54.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 00:54:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dBWcYT6T; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-66447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1F03F1C21B53 for ; Thu, 15 Feb 2024 08:54:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9548E17BC4; Thu, 15 Feb 2024 08:53:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="dBWcYT6T" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DBFC171D4 for ; Thu, 15 Feb 2024 08:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987206; cv=none; b=R86VRTz8z6LuUN6uh0pkaT5RhzmKmR/WTFcsjhvBmeMOA59+srLhYhoImgrEC+8fPI2sHu+9v0pPSEdRaevJ5PB189A4QMDhjZibzf/no9hnnwM0MyhOUju8A+qXbFX3Ju9aPllRFz+u9LhYSgedjvJzXPiuCdEPwOAYgnqe6PY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707987206; c=relaxed/simple; bh=exVehpvotFoH0Sv6VRJr2uGzlD2qhHspJg3kh+fUvws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YzFNDOdH+DgpQ3/YWJ/EsjoikfLzMPc7FflaMYONFYA3neLTdopnopPsZi2Kvih3J0pIp9KNuk9poOBe+75ZKOrwqHwM8eiWdt6YComoOQ3dSufhC4bwY2hSozR2vKZrkW+IOu/yABH2DlNtWyQF9dZHtXhmBCWKRztW/5vll1M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=dBWcYT6T; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707987203; bh=exVehpvotFoH0Sv6VRJr2uGzlD2qhHspJg3kh+fUvws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dBWcYT6THrHx5aRBgvzLstEQFhXNcwqP8cUGmxwXSCl23pCUIsrtrATe5+8UMTf6y oRym6vqxeeZhMoj1VJ4QjfFn476JICiDo2IvggLXXHucrZxgzmGDbcivz7H1iUkvH2 hfTIxy/7zgwu24wM/AKediWm5t9W3RSJC196aPemrNAD0SdR4+t+oPwRfKvm2q1Vh2 cKZvRAgt+u1kRZzvpwE4ZKKODOPwA3IMlDl35clGG1ss7EL9AevCaK1v9PmmjWcA8X mbb9WMXFlq4U2v2VsLoGvlLR1ErIQRZH/02IhiYNq2hvxP2Bcx0sUlad/O4leg3H+6 dOn7I8EnA2SEg== Received: from IcarusMOD.eternityproject.eu (cola.collaboradmins.com [195.201.22.229]) (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 madrid.collaboradmins.com (Postfix) with ESMTPSA id 963F837820B2; Thu, 15 Feb 2024 08:53:22 +0000 (UTC) From: AngeloGioacchino Del Regno To: chunkuang.hu@kernel.org Cc: fshao@chromium.org, 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, kernel@collabora.com, Alexandre Mergnat , CK Hu Subject: [PATCH v6 3/9] drm/mediatek: dsi: Cleanup functions mtk_dsi_ps_control{_vact}() Date: Thu, 15 Feb 2024 09:53:10 +0100 Message-ID: <20240215085316.56835-4-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240215085316.56835-1-angelogioacchino.delregno@collabora.com> References: <20240215085316.56835-1-angelogioacchino.delregno@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Function mtk_dsi_ps_control() is a subset of mtk_dsi_ps_control_vact(): merge the two in one mtk_dsi_ps_control() function by adding one function parameter `config_vact` which, when true, writes the VACT related registers. Reviewed-by: Fei Shao Reviewed-by: Alexandre Mergnat Reviewed-by: CK Hu Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/mediatek/mtk_dsi.c | 78 ++++++++++-------------------- 1 file changed, 25 insertions(+), 53 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c index 8af0afbe9e3d..0a83875ec1ba 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -351,40 +351,6 @@ static void mtk_dsi_set_vm_cmd(struct mtk_dsi *dsi) mtk_dsi_mask(dsi, DSI_VM_CMD_CON, TS_VFP_EN, TS_VFP_EN); } -static void mtk_dsi_ps_control_vact(struct mtk_dsi *dsi) -{ - struct videomode *vm = &dsi->vm; - u32 dsi_buf_bpp, ps_wc; - u32 ps_bpp_mode; - - if (dsi->format == MIPI_DSI_FMT_RGB565) - dsi_buf_bpp = 2; - else - dsi_buf_bpp = 3; - - ps_wc = vm->hactive * dsi_buf_bpp; - ps_bpp_mode = ps_wc; - - switch (dsi->format) { - case MIPI_DSI_FMT_RGB888: - ps_bpp_mode |= PACKED_PS_24BIT_RGB888; - break; - case MIPI_DSI_FMT_RGB666: - ps_bpp_mode |= LOOSELY_PS_24BIT_RGB666; - break; - case MIPI_DSI_FMT_RGB666_PACKED: - ps_bpp_mode |= PACKED_PS_18BIT_RGB666; - break; - case MIPI_DSI_FMT_RGB565: - ps_bpp_mode |= PACKED_PS_16BIT_RGB565; - break; - } - - writel(vm->vactive, dsi->regs + DSI_VACT_NL); - writel(ps_bpp_mode, dsi->regs + DSI_PSCTRL); - writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC); -} - static void mtk_dsi_rxtx_control(struct mtk_dsi *dsi) { u32 tmp_reg; @@ -416,36 +382,42 @@ static void mtk_dsi_rxtx_control(struct mtk_dsi *dsi) writel(tmp_reg, dsi->regs + DSI_TXRX_CTRL); } -static void mtk_dsi_ps_control(struct mtk_dsi *dsi) +static void mtk_dsi_ps_control(struct mtk_dsi *dsi, bool config_vact) { - u32 dsi_tmp_buf_bpp; - u32 tmp_reg; + struct videomode *vm = &dsi->vm; + u32 dsi_buf_bpp, ps_wc; + u32 ps_bpp_mode; + + if (dsi->format == MIPI_DSI_FMT_RGB565) + dsi_buf_bpp = 2; + else + dsi_buf_bpp = 3; + + ps_wc = vm->hactive * dsi_buf_bpp; + ps_bpp_mode = ps_wc; switch (dsi->format) { + default: + fallthrough; case MIPI_DSI_FMT_RGB888: - tmp_reg = PACKED_PS_24BIT_RGB888; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= PACKED_PS_24BIT_RGB888; break; case MIPI_DSI_FMT_RGB666: - tmp_reg = LOOSELY_PS_24BIT_RGB666; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= LOOSELY_PS_24BIT_RGB666; break; case MIPI_DSI_FMT_RGB666_PACKED: - tmp_reg = PACKED_PS_18BIT_RGB666; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= PACKED_PS_18BIT_RGB666; break; case MIPI_DSI_FMT_RGB565: - tmp_reg = PACKED_PS_16BIT_RGB565; - dsi_tmp_buf_bpp = 2; - break; - default: - tmp_reg = PACKED_PS_24BIT_RGB888; - dsi_tmp_buf_bpp = 3; + ps_bpp_mode |= PACKED_PS_16BIT_RGB565; break; } - tmp_reg += dsi->vm.hactive * dsi_tmp_buf_bpp & DSI_PS_WC; - writel(tmp_reg, dsi->regs + DSI_PSCTRL); + if (config_vact) { + writel(vm->vactive, dsi->regs + DSI_VACT_NL); + writel(ps_wc, dsi->regs + DSI_HSTX_CKL_WC); + } + writel(ps_bpp_mode, dsi->regs + DSI_PSCTRL); } static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) @@ -521,7 +493,7 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi) writel(horizontal_backporch_byte, dsi->regs + DSI_HBP_WC); writel(horizontal_frontporch_byte, dsi->regs + DSI_HFP_WC); - mtk_dsi_ps_control(dsi); + mtk_dsi_ps_control(dsi, false); } static void mtk_dsi_start(struct mtk_dsi *dsi) @@ -666,7 +638,7 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi) mtk_dsi_reset_engine(dsi); mtk_dsi_phy_timconfig(dsi); - mtk_dsi_ps_control_vact(dsi); + mtk_dsi_ps_control(dsi, true); mtk_dsi_set_vm_cmd(dsi); mtk_dsi_config_vdo_timing(dsi); mtk_dsi_set_interrupt_enable(dsi); -- 2.43.0