From patchwork Wed Sep 20 14:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 142482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp4211098vqi; Wed, 20 Sep 2023 08:10:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSw39eRaH76f9QrHBzwqjn5OZyQJIWWKQjGSs76CQmLFFuiaPyHKNz02O6XddSr3CHX51y X-Received: by 2002:a05:6a20:244f:b0:12e:4d86:c017 with SMTP id t15-20020a056a20244f00b0012e4d86c017mr3309286pzc.10.1695222639501; Wed, 20 Sep 2023 08:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695222639; cv=none; d=google.com; s=arc-20160816; b=VbgnZ/+678skysCFDpJokhXoo8hLlAmglFdDm0dA248UIJrYU2E3HI9C6KJ1cqm7nK zwZzbcJppuzc7e6FPmwNZmbrpBPbYiqUpPGg3XU7HcJTf91AxAW2PoHhcUQTLDfhODy1 oijF/NijFoqpI9e0Iy5VBgBbxA683fKbX5lzWk/VF2GFYzrNuvOxq3BwCqaY/VsDUceG nFa4gyJVamOncEXAtQp4vrNVjYBthqVmtCQ/0ndv0qNqLp0nWPYDFOXM4GVo1CPNOZli MxxiHPTVc8aZB/dKZ3KkzvFyfbJfWgbEOS2zK+mu8uKwZJq+nIFwUI8VczChh/FjSjdp nfdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=DlJlTRszKEN5H3CNJThp8HxOOzyAyip8+BJL4Xe17uE=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=Y4z2bcQBrN+IX7t87o51MMNqPM6NoKAm3Vd4uhn3sMAQd3GoDkoFy3dTxD2vvfJns3 mpM3+pr7+BT2pExGJ9/kuZH+Ux79h4OaDD6WrMH96XMIxcsX9dYC+2YFXtarmR/zzwul y/FsLZ7GopFkPvXQsU+H7yBLYm1ldiiw4uFWW/DaN1myyuzXpqDSANW0Jr/67Lk8h9DA RAt2884UfvHbkGEt7MglERO/8kLVN2Sddp3d5+0RBGZcisLgvQbDeHPJvcOylfD+GzkS VqF3se6bC3aYbp4VZbohiaqrIVkikwvqQ6v9A+8LOxoeyn2KTAQBbJ6e1BSIhEt3DOtK ve9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PyJP8jr5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id d22-20020a056a0024d600b00690f74dd2ccsi1208961pfv.69.2023.09.20.08.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 08:10:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PyJP8jr5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1EA6082D66E4; Wed, 20 Sep 2023 07:39:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236658AbjITOjC (ORCPT + 27 others); Wed, 20 Sep 2023 10:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236754AbjITOiw (ORCPT ); Wed, 20 Sep 2023 10:38:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5811ACD5; Wed, 20 Sep 2023 07:37:21 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3B97C43395; Wed, 20 Sep 2023 14:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695220638; bh=jSpZuOH1RdsM4aSPqCaZdH7lflfIrdCTw/BW9GZsfMs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PyJP8jr5cDrRwWVafU05aV5BwNrENn1CEomoZvpty2nJjKK1UJDPH2bg869WXujTF jT1BfIw6PxOZTN5/445wBTjcO3+MF35RDDrRGFne4TaAOGZU+sJKQ6zQjAavlQXUiB heT+LRjC7z67dp1HpNSLWTgedkG6iq4+Xn2j8lniuJ6Ef/voscW6lzSKpQjDqhL93P Pon+Z1FTSjzB+v1UHDeRQJe7UI7jfQb1QJTPsqSB/QeR0RnaHQjP2W9Bx7GN3UH9kP iUOGMi4WzSFIXFoFKzooIlL4/spFmA2nruLgsR6jXOE6vhSlvWDOBpHzUyXODJasBU gOvE9vpzdXVXg== From: Maxime Ripard Date: Wed, 20 Sep 2023 16:35:49 +0200 Subject: [PATCH RFC v2 34/37] drm/sun4i: hdmi: Move mode_set into enable MIME-Version: 1.0 Message-Id: <20230920-kms-hdmi-connector-state-v2-34-17932daddd7d@kernel.org> References: <20230920-kms-hdmi-connector-state-v2-0-17932daddd7d@kernel.org> In-Reply-To: <20230920-kms-hdmi-connector-state-v2-0-17932daddd7d@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=jSpZuOH1RdsM4aSPqCaZdH7lflfIrdCTw/BW9GZsfMs=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKnczFasUXoJEz407fmxc9vLEOsu07188idlJ6y5Fvpbt XTxhpfHO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRC88ZGe6YVsQpCN56Ocsx n888r3nnp5DvvXM2b/W7pPWm3bLl0C2G/94ct25yS6vrcTreMXvknM9gIfhvfazAsaKTW8uq2Cd M5gMA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 20 Sep 2023 07:39:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777569774536626337 X-GMAIL-MSGID: 1777569774536626337 We're not doing anything special in atomic_mode_set so we can simply merge it into atomic_enable. Signed-off-by: Maxime Ripard --- 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, };