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: 175240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4875990vqy; Thu, 7 Dec 2023 07:53:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IH2bDCRvGsflkVdk3F+Kdspeua2dRmGbxXS7mISk8DA+suvbhh3o0Az0+7X4YLb0yZ6MzwI X-Received: by 2002:a17:902:f545:b0:1d0:8c63:cfe4 with SMTP id h5-20020a170902f54500b001d08c63cfe4mr3428787plf.77.1701964379787; Thu, 07 Dec 2023 07:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701964379; cv=none; d=google.com; s=arc-20160816; b=fnhwfAlN5M4XI2YPZa1hjAmuOugQZkI2xXNgGplQUBJHjuTUzRoB224/ZIOTioxiTI uny2GWJJqaEmUHedThPU/QMPG57nIUFX94/joyw92xnWISehm5OpYeexihlJMgAY6yxx /hdSJi02QoeIXPu76Lrfp7JRe3srpUw2ax+hi1fa4SvAx8fTqEyu3VuIFSHtU6bvGfWP bxhsNAQX07QWbInxwZ8OEZrAvgq8oH3uHaKM6+pRtl2rfwFRpWjIrZLlJCfzoa8qxanw mjCRI3oQvITaXzxcTMxu7hRoIhzSDR9WTenpTpn2q+UU+iIlnuvqxJZD/pewARbqidD6 rThw== 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=4wLRL4chBHbOLb2Pu6mH7ri0N6Xsl83H+q/B+nH0fy8=; fh=e6/uyeFf2k7v8JUtB6fPyaAS5iN3eSA1hjtg35V2Rzw=; b=le1M856QcSushZT7x5RYO76f55CQwtI6DA/OtnkDGm5q/sj2wTdAYNAYH2oLWnllNY ZQ277gB2FeLFSXmGnMjaxNCppsVCZ2rzaA+aJtpDYNBilSGgTc8VSuORD1m+yDmHB6R9 udXFUw8242g/Z677ny9i9cj9I4nmBuJkbO4qI0FdC271hb3lTDY99b4dUBPWiMjMG2ch t5f/dv6qpbsjAMMiPmmHuonrTWnhM2TpcpWqUedZlBgIR18uKkJVpxiitMWP+GwbluIe DyL5rx/C4oWtDusvXRtjF3gj7LIHzI4zv0IFegWMK8IqQLv2J5axJVHZKt88WC1QKP92 Wbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rO9HpGf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o14-20020a63e34e000000b005c6cc76fd44si1386631pgj.101.2023.12.07.07.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 07:52:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rO9HpGf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 83A7E807D92C; Thu, 7 Dec 2023 07:52:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443839AbjLGPwi (ORCPT + 99 others); Thu, 7 Dec 2023 10:52:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443698AbjLGPwH (ORCPT ); Thu, 7 Dec 2023 10:52:07 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658C62D77 for ; Thu, 7 Dec 2023 07:51:28 -0800 (PST) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 07 Dec 2023 07:52:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784639001611149204 X-GMAIL-MSGID: 1784639001611149204 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, };