From patchwork Mon Oct 12 23:28:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11834477 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2E2F139F for ; Mon, 12 Oct 2020 23:29:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A3F1216C4 for ; Mon, 12 Oct 2020 23:29:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ija4UAaE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A3F1216C4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66D8F6E84E; Mon, 12 Oct 2020 23:29:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by gabe.freedesktop.org (Postfix) with ESMTPS id 367046E839 for ; Mon, 12 Oct 2020 23:29:32 +0000 (UTC) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E61E1A3F; Tue, 13 Oct 2020 01:29:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1602545370; bh=8Kkm9+JHDsiHPyq+HeEXq8sWzn1gla75u2KB0a/+prY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ija4UAaEUKxBT4qQ6ZEoNC905YXN1jsklrebJsrSJ7+IQ+uaSj9MFhdOO+chwWfdh flDr4rGpZb9i9MKee+GQwuuoDw/mJ+qkeHTZA9L9SaNFRnwGieEwdbLkT6JDtTdK1x bwCBojqfRDrrbgISedCL11cit2aUeHoU4usDkPtQ= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm: mxsfb: Fix format changes for primary plane Date: Tue, 13 Oct 2020 02:28:39 +0300 Message-Id: <20201012232840.15680-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201012232840.15680-1-laurent.pinchart@ideasonboard.com> References: <20201012232840.15680-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , kernel@pengutronix.de, linux-imx@nxp.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The primary plane's format is configured in registers that have no shadow support for live updates. They require the display to be fully reconfigured in order to be updated. Force a mode set when the primary plane format changes to ensure this. Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/mxsfb/mxsfb_kms.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 6d512f346918..7a69d9f3a875 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -407,14 +407,28 @@ static int mxsfb_plane_atomic_check(struct drm_plane *plane, { struct mxsfb_drm_private *mxsfb = to_mxsfb_drm_private(plane->dev); struct drm_crtc_state *crtc_state; + int ret; crtc_state = drm_atomic_get_new_crtc_state(plane_state->state, &mxsfb->crtc); - return drm_atomic_helper_check_plane_state(plane_state, crtc_state, - DRM_PLANE_HELPER_NO_SCALING, - DRM_PLANE_HELPER_NO_SCALING, - false, true); + ret = drm_atomic_helper_check_plane_state(plane_state, crtc_state, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING, + false, true); + if (ret < 0) + return ret; + + /* + * Changing the primary plane format requires stopping the display + * controller first. Force a full mode set to do so. + */ + if (plane == mxsfb->crtc.primary && + plane_state->visible && plane->state->visible && + plane_state->fb->format != plane->state->fb->format) + crtc_state->mode_changed = true; + + return 0; } static void mxsfb_plane_primary_atomic_update(struct drm_plane *plane, From patchwork Mon Oct 12 23:28:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11834475 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 883F21580 for ; Mon, 12 Oct 2020 23:29:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5429D20878 for ; Mon, 12 Oct 2020 23:29:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EYMaWT8c" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5429D20878 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 03C0E6E84D; Mon, 12 Oct 2020 23:29:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1B7B36E84E for ; Mon, 12 Oct 2020 23:29:34 +0000 (UTC) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D52061A51; Tue, 13 Oct 2020 01:29:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1602545371; bh=1gYOsQgLI1kXGsp6YcA9DssdcpvUUYgyQjbTxGHA7sM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EYMaWT8cgyOpfSB6ih5PqG24mFuzuO8FjltL6VY2TcUoQSc+dkI+KlrW3KE+stcKw BsaUanXuhe6u8vBSii+26Psjtlg6jpaHKXlF/aG3mvf4SmzAV+Ax4d8S2i3/TIT1Bp CrKI9V8bwv0jOPQSxb6U0LMzfma4wv/m2V7o7fSw= From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm: mxsfb: Add RGB888 support on the primary plane Date: Tue, 13 Oct 2020 02:28:40 +0300 Message-Id: <20201012232840.15680-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201012232840.15680-1-laurent.pinchart@ideasonboard.com> References: <20201012232840.15680-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , kernel@pengutronix.de, linux-imx@nxp.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The primary plane can support the packed 24-bit RGB888 format. Enable it. Signed-off-by: Laurent Pinchart --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 5 +++++ drivers/gpu/drm/mxsfb/mxsfb_kms.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index d52cf8a506a5..5ec10f0f6508 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -97,6 +97,11 @@ mxsfb_fb_create(struct drm_device *dev, struct drm_file *file_priv, return ERR_PTR(-EINVAL); } + if (info->cpp[0] == 3 && mode_cmd->width % 4) { + dev_dbg(dev->dev, "24-bit RGB format requires a width aligned to 4\n"); + return ERR_PTR(-EINVAL); + } + return drm_gem_fb_create(dev, file_priv, mode_cmd); } diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 7a69d9f3a875..7a0d6bc58be0 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -75,6 +75,12 @@ static void mxsfb_set_formats(struct mxsfb_drm_private *mxsfb) ctrl |= CTRL_WORD_LENGTH_16; ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0xf); break; + case DRM_FORMAT_RGB888: + dev_dbg(drm->dev, "Setting up RGB888 mode\n"); + ctrl |= CTRL_WORD_LENGTH_24; + /* Enable pixel packing, 4 pixels in 3 bytes. */ + ctrl1 |= CTRL1_SET_BYTE_PACKAGING(0xf); + break; case DRM_FORMAT_XRGB8888: dev_dbg(drm->dev, "Setting up XRGB8888 mode\n"); ctrl |= CTRL_WORD_LENGTH_24; @@ -523,6 +529,7 @@ static const struct drm_plane_funcs mxsfb_plane_funcs = { static const uint32_t mxsfb_primary_plane_formats[] = { DRM_FORMAT_RGB565, + DRM_FORMAT_RGB888, DRM_FORMAT_XRGB8888, };