Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1165496AbdDXG0N (ORCPT ); Mon, 24 Apr 2017 02:26:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60124 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165413AbdDXGZp (ORCPT ); Mon, 24 Apr 2017 02:25:45 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 409521555E Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 409521555E From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Daniel Vetter , Pekka Paalanen , Ilia Mirkin , =?UTF-8?q?Michel=20D=C3=A4nzer?= , Alex Deucher , amd-gfx@lists.freedesktop.org, Jani Nikula , Sean Paul , David Airlie , Gerd Hoffmann , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/6] drm: fourcc byteorder: add bigendian support to drm_mode_legacy_fb_format Date: Mon, 24 Apr 2017 08:25:29 +0200 Message-Id: <20170424062532.26722-4-kraxel@redhat.com> In-Reply-To: <20170424062532.26722-1-kraxel@redhat.com> References: <20170424062532.26722-1-kraxel@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 24 Apr 2017 06:25:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1412 Lines: 57 Return correct fourcc codes on bigendian. Drivers must be adapted to this change. Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/drm_fourcc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c index adb3ff59a4..28401d3745 100644 --- a/drivers/gpu/drm/drm_fourcc.c +++ b/drivers/gpu/drm/drm_fourcc.c @@ -42,11 +42,34 @@ static char printable_char(int c) * * Computes a drm fourcc pixel format code for the given @bpp/@depth values. * Useful in fbdev emulation code, since that deals in those values. + * + * DRM_FORMAT_* are little endian, we'll pick cpu endian here, therefore we + * results differ depending on byte order. */ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth) { uint32_t fmt; +#ifdef __BIG_ENDIAN + switch (bpp) { + case 8: + fmt = DRM_FORMAT_C8; + break; + case 24: + fmt = DRM_FORMAT_BGR888; + break; + case 32: + if (depth == 24) + fmt = DRM_FORMAT_BGRX8888; + else + fmt = DRM_FORMAT_BGRA8888; + break; + default: + DRM_ERROR("bad bpp, assuming b8g8r8x8 pixel format\n"); + fmt = DRM_FORMAT_BGRX8888; + break; + } +#else switch (bpp) { case 8: fmt = DRM_FORMAT_C8; @@ -73,6 +96,7 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth) fmt = DRM_FORMAT_XRGB8888; break; } +#endif return fmt; } -- 2.9.3