From patchwork Wed Sep 20 10:31:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13392510 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 923A5CE79C4 for ; Wed, 20 Sep 2023 10:32:03 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7mNkW188+VzhAdZ0oP19Hb+PdY91vf7lAzt6ykxi4Vo=; b=OKUZ4EYpkTiKTv LZf72+yHOjIBniM1lDkV1eqCqGMvuIz4fxY6KRlrtGBEWz+kt1Gt1OJV0SEvxyV6o/g7kZAn//aMf FZNrT5tUGbzMCtLZAbhWXgkyq6VC9o6BR5tsjsfQxQ9QwbHJcBp2dzwuzlmP0RhrAPEkkVZQkNolP suutsHFXbIFMc2K+npX+ynAB0gCyZJa83+kd2OnTMdrYljzlELY6xTkFfop1nSomow6Oly8rxXh3c FVUseQsaDknDFBoi7xI+lhw/9DXLA2k/cOeeH5M6HNu7Q0CRc9YNPt+KV6aKPBbQzfAMYDVJv8bf8 iBH8gjR7UTSOzjilPlBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qiuUc-002cDY-11; Wed, 20 Sep 2023 10:31:38 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qiuUY-002c8Y-0m for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2023 10:31:36 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qiuUR-0003mU-TI; Wed, 20 Sep 2023 12:31:27 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qiuUR-007fJ0-F1; Wed, 20 Sep 2023 12:31:27 +0200 From: Lucas Stach To: Marek Vasut , Liu Ying Cc: Pengutronix Kernel Team , NXP Linux Team , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, patchwork-lst@pengutronix.de Subject: [PATCH 5/5] drm: lcdif: force modeset when FB format changes Date: Wed, 20 Sep 2023 12:31:26 +0200 Message-Id: <20230920103126.2759601-6-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230920103126.2759601-1-l.stach@pengutronix.de> References: <20230920103126.2759601-1-l.stach@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230920_033134_280806_88B26604 X-CRM114-Status: GOOD ( 17.32 ) 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 Force a modeset if the new FB has a different format than the currently active one. While it might be possible to change between compatible formats without a full modeset as the format control is also supposed to be double buffered, the colorspace conversion is not, so when the CSC changes we need a modeset. For now just always force a modeset when the FB format changes to properly reconfigure all parts of the device for the new format. Signed-off-by: Lucas Stach Reviewed-by: Marek Vasut --- drivers/gpu/drm/mxsfb/lcdif_drv.c | 18 +++++++++++++++++- drivers/gpu/drm/mxsfb/lcdif_kms.c | 26 ++++++++++++++++++++------ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c index 18de2f17e249..b74f0cf1e240 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c @@ -30,9 +30,25 @@ #include "lcdif_drv.h" #include "lcdif_regs.h" +static int lcdif_atomic_check(struct drm_device *dev, + struct drm_atomic_state *state) +{ + int ret; + + ret = drm_atomic_helper_check(dev, state); + if (ret) + return ret; + + /* + * Check modeset again in case crtc_state->mode_changed is + * updated in plane's ->atomic_check callback. + */ + return drm_atomic_helper_check_modeset(dev, state); +} + static const struct drm_mode_config_funcs lcdif_mode_config_funcs = { .fb_create = drm_gem_fb_create, - .atomic_check = drm_atomic_helper_check, + .atomic_check = lcdif_atomic_check, .atomic_commit = drm_atomic_helper_commit, }; diff --git a/drivers/gpu/drm/mxsfb/lcdif_kms.c b/drivers/gpu/drm/mxsfb/lcdif_kms.c index 3ebf55d06027..8167604bd3f8 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_kms.c +++ b/drivers/gpu/drm/mxsfb/lcdif_kms.c @@ -647,18 +647,32 @@ static const struct drm_crtc_funcs lcdif_crtc_funcs = { static int lcdif_plane_atomic_check(struct drm_plane *plane, struct drm_atomic_state *state) { - struct drm_plane_state *plane_state = drm_atomic_get_new_plane_state(state, - plane); + struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, + plane); + struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, + plane); struct lcdif_drm_private *lcdif = to_lcdif_drm_private(plane->dev); struct drm_crtc_state *crtc_state; + int ret; + + /* always okay to disable the plane */ + if (!new_state->fb) + return 0; crtc_state = drm_atomic_get_new_crtc_state(state, &lcdif->crtc); - return drm_atomic_helper_check_plane_state(plane_state, crtc_state, - DRM_PLANE_NO_SCALING, - DRM_PLANE_NO_SCALING, - false, true); + ret = drm_atomic_helper_check_plane_state(new_state, crtc_state, + DRM_PLANE_NO_SCALING, + DRM_PLANE_NO_SCALING, + false, true); + if (ret) + return ret; + + if (old_state->fb && new_state->fb->format != old_state->fb->format) + crtc_state->mode_changed = true; + + return 0; } static void lcdif_plane_primary_atomic_update(struct drm_plane *plane,