Received: by 10.223.176.5 with SMTP id f5csp2580728wra; Thu, 1 Feb 2018 02:44:05 -0800 (PST) X-Google-Smtp-Source: AH8x226FoSjiJzsLls1vm34+Vgl+OlLW7j9ZXtVltZxn5pLx9AjZmuJVECVg1iFso7Zbf3V71Kjx X-Received: by 2002:a17:902:9346:: with SMTP id g6-v6mr31871488plp.379.1517481845334; Thu, 01 Feb 2018 02:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517481845; cv=none; d=google.com; s=arc-20160816; b=gTjkd74A7oICmHYHSuZ8ooGsclevGUV6kxGJ2un4bLhoP5kXUkDjQCZklSZBmPlXXt NcC0Ypm/FYpZNz/p9I8nmu2UMUsL9oTvtDe5JMvzgtpTl1+ezTvrMsnfQ+ZMH8V/So30 BfAUWaPgifzBCSvfRs7TbmkSMD2tYyDtknQmampuZfm681mVNYRa5n1PZZW/CcFxpuOK cxsfO/gPFwsGmx2xXrl74KNujZyq3Un9U3UIQGfswX1JMVv/YmHYmzCytFTPv6xupkxC hWHfX4TlgIXmgAQ/vny9O2fYX4iFf2QErBbTZLSCJRAhAOPoUjj24i4sVepEOFLQ3smj UxCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=hXma/1X9lL3hEjeyjntTANwVSbXM5o4QI4cbfeyBRgw=; b=gTZAQ1hUhVOZ/ojarPtwWqhdwLrbp/Yxk9OpNoOE8JIeLPNh44w8xsKb03iKcj6RYi DEQ9qjeOzm4yLMf3hfW8CxNc6MCkmwt8wwaLpabl1YdgM/DwV2QFiGhD2+YNkwRfSQaf G6m7x/FpzUencCeFIh1BE7WFYDM/5tkdx+kSaW5qxWNeCR4iwGoN5K/B9sCOXoUjh1fy VtZao3dOAOLMJMtr+4lzSomtnDEA8bcAT1fCvsWWDc5Ps1YHFadgZnmCprISNp9hI/Lw JOs/aHzcUCjj8hgn1D7dfkyA9cX8mdU874VdVaBfmg+eefn+i/nkT0MtNYHWdqX4gyHE 62ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18si1477957pge.254.2018.02.01.02.43.50; Thu, 01 Feb 2018 02:44:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752177AbeBAKnN (ORCPT + 99 others); Thu, 1 Feb 2018 05:43:13 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:37287 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751761AbeBAKnH (ORCPT ); Thu, 1 Feb 2018 05:43:07 -0500 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w11Ad5nu025456; Thu, 1 Feb 2018 11:43:00 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2fubnyy701-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 01 Feb 2018 11:43:00 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BEA0C3A; Thu, 1 Feb 2018 10:42:59 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A3D1211B8; Thu, 1 Feb 2018 10:42:59 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 1 Feb 2018 11:42:59 +0100 Received: from localhost (10.201.23.32) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.352.0; Thu, 1 Feb 2018 11:42:58 +0100 From: Philippe Cornu To: Yannick Fertre , Philippe Cornu , Benjamin Gaignard , Vincent Abriou , David Airlie , , CC: Fabien Dessenne , Mickael Reulier , Alexandre Torgue Subject: [PATCH v1 1/2] drm/stm: ltdc: add non-alpha color formats Date: Thu, 1 Feb 2018 11:42:42 +0100 Message-ID: <20180201104243.20726-2-philippe.cornu@st.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180201104243.20726-1-philippe.cornu@st.com> References: <20180201104243.20726-1-philippe.cornu@st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.23.32] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-01_03:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ltdc supports natively some color formats with alpha (like ARGB8888, ARGB1555, ARGB4444...). Related non-alpha formats are supported too (ARGB8888->XRGB8888, ARGB4444->XRGB4444...) by adjusting ltdc blending factors. Note: Wayland/Weston requests by default the non-alpha XRGB8888 color format. Signed-off-by: Philippe Cornu --- drivers/gpu/drm/stm/ltdc.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c index 90b3de516c91..f6f26fc0ae9e 100644 --- a/drivers/gpu/drm/stm/ltdc.c +++ b/drivers/gpu/drm/stm/ltdc.c @@ -328,6 +328,26 @@ static inline u32 to_drm_pixelformat(enum ltdc_pix_fmt pf) } } +static inline u32 get_pixelformat_without_alpha(u32 drm) +{ + switch (drm) { + case DRM_FORMAT_ARGB4444: + return DRM_FORMAT_XRGB4444; + case DRM_FORMAT_RGBA4444: + return DRM_FORMAT_RGBX4444; + case DRM_FORMAT_ARGB1555: + return DRM_FORMAT_XRGB1555; + case DRM_FORMAT_RGBA5551: + return DRM_FORMAT_RGBX5551; + case DRM_FORMAT_ARGB8888: + return DRM_FORMAT_XRGB8888; + case DRM_FORMAT_RGBA8888: + return DRM_FORMAT_RGBX8888; + default: + return 0; + } +} + static irqreturn_t ltdc_irq_thread(int irq, void *arg) { struct drm_device *ddev = arg; @@ -680,6 +700,9 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane, /* Specifies the blending factors */ val = BF1_PAXCA | BF2_1PAXCA; + if (!fb->format->has_alpha) + val = BF1_CA | BF2_1CA; + reg_update_bits(ldev->regs, LTDC_L1BFCR + lofs, LXBFCR_BF2 | LXBFCR_BF1, val); @@ -747,8 +770,8 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev, struct device *dev = ddev->dev; struct drm_plane *plane; unsigned int i, nb_fmt = 0; - u32 formats[NB_PF]; - u32 drm_fmt; + u32 formats[NB_PF * 2]; + u32 drm_fmt, drm_fmt_no_alpha; int ret; /* Get supported pixel formats */ @@ -757,6 +780,12 @@ static struct drm_plane *ltdc_plane_create(struct drm_device *ddev, if (!drm_fmt) continue; formats[nb_fmt++] = drm_fmt; + + /* Add the no-alpha related format if any & supported */ + drm_fmt_no_alpha = get_pixelformat_without_alpha(drm_fmt); + if (!drm_fmt_no_alpha) + continue; + formats[nb_fmt++] = drm_fmt_no_alpha; } plane = devm_kzalloc(dev, sizeof(*plane), GFP_KERNEL); -- 2.15.1