From patchwork Wed Feb 26 04:30:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 11405503 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 92F5914B4 for ; Wed, 26 Feb 2020 08:09: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 71D332084E for ; Wed, 26 Feb 2020 08:09:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="IWlayfR7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71D332084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=crapouillou.net 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 9BA366E23D; Wed, 26 Feb 2020 08:09:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from crapouillou.net (outils.crapouillou.net [89.234.176.41]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85DB16E0EA for ; Wed, 26 Feb 2020 04:30:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1582691453; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=EBs+WyA9SoX0izZ/2YmeENtSC3EofRpkHiHuspGvF2k=; b=IWlayfR7Bunx4LFkE4p/wAp7BSODGzofuzBCHue4eX+xxz559in2m6Opf0JBNiCgI3FL3B y6iNKebknpDSFT0C8kuXLbA+I9wNvGVD9/WYBH37JmnzN+DlrbUyVHl2AoxbIDekC17JTr rtCiqoTGTX927hJ5zMIpjEQ+yD3ph2w= From: Paul Cercueil To: Daniel Vetter , David Airlie Subject: [PATCH v2 1/3] gpu/drm: ingenic: Add trick to support 16bpp on 24-bit panels Date: Wed, 26 Feb 2020 01:30:39 -0300 Message-Id: <20200226043041.289764-1-paul@crapouillou.net> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 26 Feb 2020 08:08:26 +0000 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: Paul Cercueil , od@zcrc.me, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If the panel interface is 24-bit but our primary plane is 16bpp, configure as if the panel was 18-bit. This tricks permits the display of 16bpp data on a 24-bit panel by wiring each color component to the MSBs of the 24-bit interface. v2: Check bytes-per-pixel count instead of fourcc format Signed-off-by: Paul Cercueil --- drivers/gpu/drm/ingenic/ingenic-drm.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c b/drivers/gpu/drm/ingenic/ingenic-drm.c index 6d47ef7b148c..5493a80d7d2f 100644 --- a/drivers/gpu/drm/ingenic/ingenic-drm.c +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c @@ -400,6 +400,8 @@ static void ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode = &crtc_state->adjusted_mode; struct drm_connector *conn = conn_state->connector; struct drm_display_info *info = &conn->display_info; + struct drm_plane_state *plane_state = crtc_state->crtc->primary->state; + const struct drm_format_info *finfo = NULL; unsigned int cfg; priv->panel_is_sharp = info->bus_flags & DRM_BUS_FLAG_SHARP_SIGNALS; @@ -435,7 +437,21 @@ static void ingenic_drm_encoder_atomic_mode_set(struct drm_encoder *encoder, cfg |= JZ_LCD_CFG_MODE_GENERIC_18BIT; break; case MEDIA_BUS_FMT_RGB888_1X24: - cfg |= JZ_LCD_CFG_MODE_GENERIC_24BIT; + if (plane_state && plane_state->fb) + finfo = plane_state->fb->format; + + /* + * If the panel interface is 24-bit but our + * primary plane is 16bpp, configure as if the + * panel was 18-bit. This tricks permits the + * display of 16bpp data on a 24-bit panel by + * wiring each color component to the MSBs of + * the 24-bit interface. + */ + if (finfo && finfo->cpp[0] < 3) + cfg |= JZ_LCD_CFG_MODE_GENERIC_18BIT; + else + cfg |= JZ_LCD_CFG_MODE_GENERIC_24BIT; break; case MEDIA_BUS_FMT_RGB888_3X8: cfg |= JZ_LCD_CFG_MODE_8BIT_SERIAL;