Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp625822pxv; Thu, 15 Jul 2021 11:52:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzMy0j1Ybxsjrv8J6IVb3jTGXNWgd8sh1+Cs2oFLnnYYasTBbghMzvrNf6T2EF09uqRyoJ X-Received: by 2002:a92:c150:: with SMTP id b16mr3536920ilh.54.1626375149994; Thu, 15 Jul 2021 11:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375149; cv=none; d=google.com; s=arc-20160816; b=aOJIgGZpqopRwhEHmjJ7shzYGLPQFLigUOwozkuVrXooKlbnYIFnaxKl1zLQ2S0OD2 Kf8HGJ/gkjFm4PXvvytZ3Lj4FmK15UU1zSocTflszSP1YekYRzG1BSsfLvPJEcVuiBq6 vSDdVX99a2HY29v2a9HyVSYgX0CanhdejXKjpnIFoVFmfCI6NWkW3B3KYETsTmFTLHj0 eGhDUQqYhz0xA4qaOMztNxtgEKrKQ7uA6DMI3b90RmF4JXzHsIT+/vyLSIDJKdmFcRI5 G/hbnFNCML6KyCAZVlr4fCp0H73ZYAxwOKdTtXM47BKLI2XlIUCpkpmJcLQp4GdAYVNd kZHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=D6EnY8Xfoi0yFoXRti0WzAwjMu6XQJJFOgjVchUgv9E=; b=xojwFDS7e190SzrQVcJ53MueFDYS/GRkUCEYzW1IfhgByXsv/3OBvqRPF6VbMQJOM4 TnBuZw9QK263Q7DQSD8lxxzkIqTjyyLs+jLDILtkn9MPPOIulQpPN6DlC+wcGksmkx1t lCJtN5T0oWr6XkphK234bJbr3dj16zTP0guX5sku2mdukU5PDL1TUPf25n80W2r8nEga YQAcEvF0pet3OELpBmYHIs4KbI5CW/KI5TzSsddCEU9MPihLp8GimaoWIFwCKeMr6r90 AYE6wz+BN0X6RsXsl0LHUndFHYMyzTRH2VZuSxyNkbbpgbA2bXqsmuYTUn3S4TKuK5St GZ6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TxvbRkfb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x29si7663924jap.52.2021.07.15.11.52.17; Thu, 15 Jul 2021 11:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TxvbRkfb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240071AbhGOSw5 (ORCPT + 99 others); Thu, 15 Jul 2021 14:52:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:51692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240104AbhGOStM (ORCPT ); Thu, 15 Jul 2021 14:49:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 08CF2613DD; Thu, 15 Jul 2021 18:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374777; bh=y5INbB7BhKNTobXp8zKDbun0s0xvNKCmJ4x0sSzC/yY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxvbRkfbSq+V+FzOogAF3MLmbsxVAkyogoHaon4AxxUeUVEfU1aMoBmvrqZIZUksb zEpsCnt199VZJonXpk60OXY08q9GnihGLNkkutQGYDLlmPCa2c2nYK10XWOicObx/5 DwA+sOOV/VeMz+3yMh2Bzyr8HXwfM3WDNj4iMYI4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , =?UTF-8?q?Guido=20G=C3=BCnther?= , Robert Chiras , NXP Linux Team , Liu Ying , Sasha Levin Subject: [PATCH 5.10 007/215] drm/bridge: nwl-dsi: Force a full modeset when crtc_state->active is changed to be true Date: Thu, 15 Jul 2021 20:36:19 +0200 Message-Id: <20210715182559.808900592@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Liu Ying [ Upstream commit 3afb2a28fa2404d11cce1956a003f2aaca4da421 ] This patch replaces ->mode_fixup() with ->atomic_check() so that a full modeset can be requested from there when crtc_state->active is changed to be true(which implies only connector's DPMS is brought out of "Off" status, though not necessarily). Bridge functions are added or changed to accommodate the ->atomic_check() callback. That full modeset is needed by the up-coming patch which gets MIPI DSI controller and PHY ready in ->mode_set(), because it makes sure ->mode_set() and ->atomic_disable() are called in pairs. Cc: Andrzej Hajda Cc: Neil Armstrong Cc: Robert Foss Cc: Laurent Pinchart Cc: Jonas Karlman Cc: Jernej Skrabec Cc: David Airlie Cc: Daniel Vetter Cc: Guido Günther Cc: Robert Chiras Cc: NXP Linux Team Signed-off-by: Liu Ying Reviewed-by: Neil Armstrong Signed-off-by: Neil Armstrong Link: https://patchwork.freedesktop.org/patch/msgid/1619170003-4817-2-git-send-email-victor.liu@nxp.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/bridge/nwl-dsi.c | 61 ++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c index 66b67402f1ac..c65ca860712d 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -742,7 +743,9 @@ static int nwl_dsi_disable(struct nwl_dsi *dsi) return 0; } -static void nwl_dsi_bridge_disable(struct drm_bridge *bridge) +static void +nwl_dsi_bridge_atomic_disable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct nwl_dsi *dsi = bridge_to_dsi(bridge); int ret; @@ -803,17 +806,6 @@ static int nwl_dsi_get_dphy_params(struct nwl_dsi *dsi, return 0; } -static bool nwl_dsi_bridge_mode_fixup(struct drm_bridge *bridge, - const struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) -{ - /* At least LCDIF + NWL needs active high sync */ - adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC); - adjusted_mode->flags &= ~(DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC); - - return true; -} - static enum drm_mode_status nwl_dsi_bridge_mode_valid(struct drm_bridge *bridge, const struct drm_display_info *info, @@ -831,6 +823,24 @@ nwl_dsi_bridge_mode_valid(struct drm_bridge *bridge, return MODE_OK; } +static int nwl_dsi_bridge_atomic_check(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) +{ + struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode; + + /* At least LCDIF + NWL needs active high sync */ + adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC); + adjusted_mode->flags &= ~(DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC); + + /* Do a full modeset if crtc_state->active is changed to be true. */ + if (crtc_state->active_changed && crtc_state->active) + crtc_state->mode_changed = true; + + return 0; +} + static void nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, const struct drm_display_mode *mode, @@ -862,7 +872,9 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, drm_mode_debug_printmodeline(adjusted_mode); } -static void nwl_dsi_bridge_pre_enable(struct drm_bridge *bridge) +static void +nwl_dsi_bridge_atomic_pre_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct nwl_dsi *dsi = bridge_to_dsi(bridge); int ret; @@ -897,7 +909,9 @@ static void nwl_dsi_bridge_pre_enable(struct drm_bridge *bridge) } } -static void nwl_dsi_bridge_enable(struct drm_bridge *bridge) +static void +nwl_dsi_bridge_atomic_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_bridge_state) { struct nwl_dsi *dsi = bridge_to_dsi(bridge); int ret; @@ -942,14 +956,17 @@ static void nwl_dsi_bridge_detach(struct drm_bridge *bridge) } static const struct drm_bridge_funcs nwl_dsi_bridge_funcs = { - .pre_enable = nwl_dsi_bridge_pre_enable, - .enable = nwl_dsi_bridge_enable, - .disable = nwl_dsi_bridge_disable, - .mode_fixup = nwl_dsi_bridge_mode_fixup, - .mode_set = nwl_dsi_bridge_mode_set, - .mode_valid = nwl_dsi_bridge_mode_valid, - .attach = nwl_dsi_bridge_attach, - .detach = nwl_dsi_bridge_detach, + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, + .atomic_check = nwl_dsi_bridge_atomic_check, + .atomic_pre_enable = nwl_dsi_bridge_atomic_pre_enable, + .atomic_enable = nwl_dsi_bridge_atomic_enable, + .atomic_disable = nwl_dsi_bridge_atomic_disable, + .mode_set = nwl_dsi_bridge_mode_set, + .mode_valid = nwl_dsi_bridge_mode_valid, + .attach = nwl_dsi_bridge_attach, + .detach = nwl_dsi_bridge_detach, }; static int nwl_dsi_parse_dt(struct nwl_dsi *dsi) -- 2.30.2