From patchwork Thu Dec 7 15:50:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13483598 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 29DABC4167B for ; Thu, 7 Dec 2023 15:53:06 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LT5oC/4eFsinr/sA1AtO7SN1LM2ujqCtVaDo5wuw3hU=; b=UGJrn5EejCPB7y ANc/wtFooOTRczF9gcJYaaoLBGQL35cYTrQGERC5sijWy/xKcKevCBHcNhdfY2JynXwDrNVw3mW/3 8OjuFFLCvEfNZRgSo8zcWcpmBVe9QgvMcan36So175TVTvF0fJcj5a5UdaaGT9/oN25A9IAo/iYOH thz5aTE5kBk/SGhpRi5+EYkMPxdQk1E0hBv0BhLfibjyPhW8zv3mD41JAiqgKVNru2lvf67fJGsY2 nJGDvY5MMAYroTZ6ofkBQI6oI/bgqObRS6203CoGxTS/tIYmtDigSnfa9h+a2kr3748u+UuuchrrE 1DZCUXSjXpFR8x81RCFg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBGfz-00DJGR-2N; Thu, 07 Dec 2023 15:52:35 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBGez-00DI6h-2t; Thu, 07 Dec 2023 15:51:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=4wLRL4chBHbOLb2Pu6mH7ri0N6Xsl83H+q/B+nH0fy8=; b=N4LXDaEBG8HlINa+tnMEOdPhmJ LUtXSThqbI33FHTVE7iVxDGspspcfzcD/ssXBGMbJC1AHeYMc0PaPIhtz60fxzABedcsRE/xden+p g8Q4YdLGy/N7WLYcuadQo5+IJgaiFY+3FwAuTYlVvNfsafQ0WQe8nu8kIIZ9ag65GFCvpMKgyqJfh MN/pO5mcVgCOYDxRLRSVF8Lhh+/mmRi8Mbt1Q7pLaC+vEVT393paP1R9cmLpLrdUEYEQo05Fqtm6t 1nMVsQd3qfOfjJ3ZqwcvNP5Des1kWrCdOkcc77y0F1BhDOZ3xfgPYOE6X0H8TmRTwMjYpMs6JSqai leraCNSw==; Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBGew-0062jd-0g; Thu, 07 Dec 2023 15:51:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 931E261E91; Thu, 7 Dec 2023 15:51:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 945A0C433CD; Thu, 7 Dec 2023 15:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701964287; bh=QM5QQucjX6Wkg6pjREcm1sHKZtnbYmRMBHy4SASqXu8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rO9HpGf/roKnHOljhlRTWw8UYg3IEM33g32NsbShWiMESGLR6cMW1c+u9huJYs5q0 Cpso7Po38xtlSesWDMCoq1Orfw97RP2iQIbvEEQPsE2mJWyHdQhyO5X1yqkdNcrps1 ztKUhsohbNOGqBpOmR6opct19RJVt0J+swW96Mfjwe+gI5hFODYg5+J750mpKLtWjM HuzQjVnEF0dhdBJFuJjlTxi3yl7TEVU2wnjqPAmBYB5j4QOy4iCnQoKzxjqnU5ZWce 099N7iiHGEJI4vG5ZIqksndEpeVjRQo9PpN51tWbtNjIN8TYPtz+wPbGSGG9UzUAO/ 5JTaiYkJc3uhA== From: Maxime Ripard Date: Thu, 07 Dec 2023 16:50:04 +0100 Subject: [PATCH v5 41/44] drm/sun4i: hdmi: Move mode_set into enable MIME-Version: 1.0 Message-Id: <20231207-kms-hdmi-connector-state-v5-41-6538e19d634d@kernel.org> References: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> In-Reply-To: <20231207-kms-hdmi-connector-state-v5-0-6538e19d634d@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Hans Verkuil , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2808; i=mripard@kernel.org; h=from:subject:message-id; bh=QM5QQucjX6Wkg6pjREcm1sHKZtnbYmRMBHy4SASqXu8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmFL9uXeV+euLRK6MOrvI5rCVlzrL1N682W2oYnZJz/K 3P+DtO9jlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAExEmImRYbeUqbrjh4Ui7h1X GSYcUJZd4PxiQdDMstYDr7RVY4WluxkZbgUp939p66k04OP0m99yJTfgqOOB7ul5FTuPtd0SCHV iBQA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231207_155130_797868_3AD07886 X-CRM114-Status: GOOD ( 10.91 ) 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 We're not doing anything special in atomic_mode_set so we can simply merge it into atomic_enable. Signed-off-by: Maxime Ripard Acked-by: Sui Jingfeng --- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 38 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index 799a26215cc2..bae69d696765 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -103,33 +103,11 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder, struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder); struct drm_display_info *display = &hdmi->connector.display_info; + unsigned int x, y; u32 val = 0; DRM_DEBUG_DRIVER("Enabling the HDMI Output\n"); - clk_prepare_enable(hdmi->tmds_clk); - - sun4i_hdmi_setup_avi_infoframes(hdmi, mode); - val |= SUN4I_HDMI_PKT_CTRL_TYPE(0, SUN4I_HDMI_PKT_AVI); - val |= SUN4I_HDMI_PKT_CTRL_TYPE(1, SUN4I_HDMI_PKT_END); - writel(val, hdmi->base + SUN4I_HDMI_PKT_CTRL_REG(0)); - - val = SUN4I_HDMI_VID_CTRL_ENABLE; - if (display->is_hdmi) - val |= SUN4I_HDMI_VID_CTRL_HDMI_MODE; - - writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG); -} - -static void sun4i_hdmi_mode_set(struct drm_encoder *encoder, - struct drm_crtc_state *crtc_state, - struct drm_connector_state *conn_state) -{ - const struct drm_display_mode *mode = &crtc_state->mode; - struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder); - unsigned int x, y; - u32 val; - clk_set_rate(hdmi->mod_clk, mode->crtc_clock * 1000); clk_set_rate(hdmi->tmds_clk, mode->crtc_clock * 1000); @@ -181,6 +159,19 @@ static void sun4i_hdmi_mode_set(struct drm_encoder *encoder, val |= SUN4I_HDMI_VID_TIMING_POL_VSYNC; writel(val, hdmi->base + SUN4I_HDMI_VID_TIMING_POL_REG); + + clk_prepare_enable(hdmi->tmds_clk); + + sun4i_hdmi_setup_avi_infoframes(hdmi, mode); + val |= SUN4I_HDMI_PKT_CTRL_TYPE(0, SUN4I_HDMI_PKT_AVI); + val |= SUN4I_HDMI_PKT_CTRL_TYPE(1, SUN4I_HDMI_PKT_END); + writel(val, hdmi->base + SUN4I_HDMI_PKT_CTRL_REG(0)); + + val = SUN4I_HDMI_VID_CTRL_ENABLE; + if (display->is_hdmi) + val |= SUN4I_HDMI_VID_CTRL_HDMI_MODE; + + writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG); } static enum drm_mode_status sun4i_hdmi_mode_valid(struct drm_encoder *encoder, @@ -206,7 +197,6 @@ static const struct drm_encoder_helper_funcs sun4i_hdmi_helper_funcs = { .atomic_check = sun4i_hdmi_atomic_check, .atomic_disable = sun4i_hdmi_disable, .atomic_enable = sun4i_hdmi_enable, - .atomic_mode_set = sun4i_hdmi_mode_set, .mode_valid = sun4i_hdmi_mode_valid, };