Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1566640imm; Mon, 3 Sep 2018 03:59:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ6TObKZjh/6/c48hBI/EQYgsLExzHytjYxFEVDppThIwQXIn7/z+9UKuyK0rWN++uZ+ktE X-Received: by 2002:a17:902:b28:: with SMTP id 37-v6mr27842554plq.337.1535972388366; Mon, 03 Sep 2018 03:59:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535972388; cv=none; d=google.com; s=arc-20160816; b=EbD9QhcEwNqDPMhxwNNl7Vc7W2SoagMZybnVYm4zygQwsPmMIDR3oqIg0vEIetdanM TYKUjDhUt8HQdSp+o5dk1mBoz5oauxKEFRm7RY9dF3Zjlyrpx2BW6n3+/7te6FQ5ovtD UhmbeNdR64RG5mM48869AXTn7JI399WXSA0Ieg8xLowguyfVSSNHlkeS1AJvUQ8ZEuBt GcY20peVpxt8Pvk4JhuWNcGpGyaZbwhC/w1fuB6p54hIZRp8bZLSbNPOaixxAjurCGIM lRxGPRjqhNziaddecpHWcTpgkabJf6H2RSDl+xgeDCFo9K0ZPU8b9MmYo5lakxvxIP5o QvXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WVVkAfKWBSaoGejboUTFiEaO4xnUt59TJqeEBjkK4pg=; b=VMfuKffV1gPhmvA/yK0QwQpzvXDkw4yA9ApHSvQ7f+BZ4WL98pQHKkC1kqIK57itmH IzNqCs7lrIQ4nT0FlQPBYaZ5izFrd/RGhYLLoo6kIFiV+KfAvNeuT1kWr95I8Z3kvo9a zNhoPPs1Hr8GgcG2TA0Rb2utsEWPpfYADQvcO2hPu+EBX3qGff1D4PQgLi9HJrstE7ES QxOz5OtxSV8Sn2swnK4uyRWYHltaerPGSSzwxeC9F0nQWjswhfXkQZh2D/b+/O9sCPln 3t9+K4OdI/WXUAK2W6rqnDKrugfsUNDRCE2iwpvxJvs90NS4pZ3bCuZOo6Afzxtmyd9K Qohg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m37-v6si17355366plg.340.2018.09.03.03.59.33; Mon, 03 Sep 2018 03:59:48 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727480AbeICPRx (ORCPT + 99 others); Mon, 3 Sep 2018 11:17:53 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40506 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725943AbeICPRi (ORCPT ); Mon, 3 Sep 2018 11:17:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7328A8011309; Mon, 3 Sep 2018 10:58:00 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-66.ams2.redhat.com [10.36.116.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 718512027EA0; Mon, 3 Sep 2018 10:57:58 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id CBBD017444; Mon, 3 Sep 2018 12:57:57 +0200 (CEST) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: Gerd Hoffmann , Gustavo Padovan , Maarten Lankhorst , Sean Paul , David Airlie , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/5] drm: fix drm_mode_addfb() on big endian machines. Date: Mon, 3 Sep 2018 12:57:54 +0200 Message-Id: <20180903105756.24912-4-kraxel@redhat.com> In-Reply-To: <20180903105756.24912-1-kraxel@redhat.com> References: <20180903105756.24912-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 03 Sep 2018 10:58:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 03 Sep 2018 10:58:00 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Userspace on big endian machhines typically expects the ADDFB ioctl returns a big endian framebuffer. drm_mode_addfb() will call drm_mode_addfb2() unconditionally with little endian DRM_FORMAT_* values though, which is wrong. This patch fixes that. Drivers (both kernel and xorg) have quirks in place to deal with the broken drm_mode_addfb() behavior. Because of this we can't just change drm_mode_addfb() behavior for everybody without breaking things. So add a new driver feature flag DRIVER_PREFER_HOST_BYTE_ORDER, so drivers can opt-in. Signed-off-by: Gerd Hoffmann --- include/drm/drm_drv.h | 1 + drivers/gpu/drm/drm_framebuffer.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 46a8009784..9cf12596cd 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -57,6 +57,7 @@ struct drm_printer; #define DRIVER_KMS_LEGACY_CONTEXT 0x20000 #define DRIVER_SYNCOBJ 0x40000 #define DRIVER_PREFER_XBGR_30BPP 0x80000 +#define DRIVER_PREFER_HOST_BYTE_ORDER 0x100000 /** * struct drm_driver - DRM driver structure diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 88758096d5..ccbda8a2e9 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -124,6 +124,17 @@ int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or, dev->driver->driver_features & DRIVER_PREFER_XBGR_30BPP) r.pixel_format = DRM_FORMAT_XBGR2101010; + if (dev->driver->driver_features & DRIVER_PREFER_HOST_BYTE_ORDER) { + if (r.pixel_format == DRM_FORMAT_XRGB8888) + r.pixel_format = DRM_FORMAT_HOST_XRGB8888; + if (r.pixel_format == DRM_FORMAT_ARGB8888) + r.pixel_format = DRM_FORMAT_HOST_ARGB8888; + if (r.pixel_format == DRM_FORMAT_RGB565) + r.pixel_format = DRM_FORMAT_HOST_RGB565; + if (r.pixel_format == DRM_FORMAT_XRGB1555) + r.pixel_format = DRM_FORMAT_HOST_XRGB1555; + } + ret = drm_mode_addfb2(dev, &r, file_priv); if (ret) return ret; -- 2.9.3