From patchwork Sat Feb 3 19:11:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10199107 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EEA6A603ED for ; Sat, 3 Feb 2018 19:11:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCFDA28FDE for ; Sat, 3 Feb 2018 19:11:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1A5728FE8; Sat, 3 Feb 2018 19:11:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F29628FDE for ; Sat, 3 Feb 2018 19:11:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A94D8958E; Sat, 3 Feb 2018 19:11:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x244.google.com (mail-qk0-x244.google.com [IPv6:2607:f8b0:400d:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id D45F28958E for ; Sat, 3 Feb 2018 19:11:30 +0000 (UTC) Received: by mail-qk0-x244.google.com with SMTP id d125so7553086qkg.13 for ; Sat, 03 Feb 2018 11:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=zNPHbv7bkE2MZLn/Qg+TuqWfl0qArhYH/fDlG74VBjg=; b=cUDx6vblU4h8CTW5aTnqjraPmgVzY/e8wC5ujKosyndhft3meMtMRNL5ds6x015WwR phL0tZYq9yYwj4JC3O+hih1owCFEJE0Ocr3STFBoiLe5Xxn7bY9jxKviZ08KVFY3tFUA THpq1+KJWmu8t1I8EcwM21qKBvs+1tgNX4vWpa6Zc1fxYbW2Okpu0o9AsuJnjXMJasLO foir8do0q0PnSGI3tp8DvCPQiPplg6yuLAZXytuPwgqSE0q1IqLiNBIPWvZoX8HIx40p mBTTLmbS4FYQMu6CgVPBlz4RhGTNQWZhvGcr1fGlDi6P/PwkznfOMjk0esj6t1wBcTFf HleQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=zNPHbv7bkE2MZLn/Qg+TuqWfl0qArhYH/fDlG74VBjg=; b=KqMmMcHixrUdYXeSrQ23SCzNvvFSmQQxBrrjEP4WjWXSD0DRC7mq49haVbE/bIiZZm i+nMJe14+/NS2dls9g0jgOpCkQOzuDi4JCEp2BN1knFS7zIK6nW5M9sC2CWkgHuMC0Hn WANNjZHN6FkJ+EMJbdFb5gVRxV6rUty4KG+B3H4/Tw3+jTxV2flQpbRxFQE8w8exh9Fg n+GNU23l6uIaGLyN4/zhEPOKZw8OY7/VfR1F4oFSqotxni9FImZhxntec8dXx3bkY0ZB l1I/ToVAN9F/hlNIcrqv0GnSpFhJ4bgbFz5Jt8xw6vDH+Y7pYxg76S9VSoJjdz05C5I9 +qjw== X-Gm-Message-State: APf1xPCN2INwar/ta22/OaLPUGmyF2fk9wDfJTeBpu6KqDy12BbYJW/X /xyqeFRn+w8uaEWxNAkwolCqiKL0 X-Google-Smtp-Source: AH8x225lFvC0e81+Afw4c8jj41TCaRwXBwuspw0cj9qP3adOpz4gv3WAOP/4ZaN1cpw+jTXkZtY5Kg== X-Received: by 10.55.33.8 with SMTP id h8mr15070017qkh.9.1517685089922; Sat, 03 Feb 2018 11:11:29 -0800 (PST) Received: from athos.fios-router.home (pool-173-68-28-184.nycmny.fios.verizon.net. [173.68.28.184]) by smtp.gmail.com with ESMTPSA id l6sm147677qki.17.2018.02.03.11.11.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Feb 2018 11:11:29 -0800 (PST) From: Ilia Mirkin To: Dave Airlie , Ben Skeggs , dri-devel@lists.freedesktop.org Subject: [PATCH] drm/nouveau: prefer XBGR2101010 for addfb ioctl Date: Sat, 3 Feb 2018 14:11:23 -0500 Message-Id: <20180203191123.31507-1-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.13.6 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Nouveau only exposes support for XBGR2101010. Prior to the atomic conversion, drm would pass in the wrong format in the framebuffer, but it was always ignored -- both userspace (xf86-video-nouveau) and the kernel driver agreed on the layout, so the fact that the format was wrong didn't matter. With the atomic conversion, nouveau all of a sudden started caring about the exact format, and so the previously-working code in xf86-video-nouveau no longer functioned since the (internally-assigned) format from the addfb ioctl was wrong. This change adds infrastructure to allow a drm driver to specify that it prefers the XBGR format variant for the addfb ioctl, and makes nouveau's nv50 display driver set it. (Prior gens had no support for 30bpp at all.) Signed-off-by: Ilia Mirkin Cc: stable@vger.kernel.org # v4.10+ Reviewed-by: Daniel Vetter --- Wasn't sure if the nouveau line needs to be split out into a separate change or not. drivers/gpu/drm/drm_framebuffer.c | 4 ++++ drivers/gpu/drm/nouveau/nv50_display.c | 1 + include/drm/drm_drv.h | 1 + 3 files changed, 6 insertions(+) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 5a13ff29f4f0..c0530a1af5e3 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -121,6 +121,10 @@ int drm_mode_addfb(struct drm_device *dev, r.pixel_format = drm_mode_legacy_fb_format(or->bpp, or->depth); r.handles[0] = or->handle; + if (r.pixel_format == DRM_FORMAT_XRGB2101010 && + dev->driver->driver_features & DRIVER_PREFER_XBGR_30BPP) + r.pixel_format = DRM_FORMAT_XBGR2101010; + ret = drm_mode_addfb2(dev, &r, file_priv); if (ret) return ret; diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index dd8d4352ed99..caddce88d2d8 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c @@ -4477,6 +4477,7 @@ nv50_display_create(struct drm_device *dev) nouveau_display(dev)->fini = nv50_display_fini; disp->disp = &nouveau_display(dev)->disp; dev->mode_config.funcs = &nv50_disp_func; + dev->driver->driver_features |= DRIVER_PREFER_XBGR_30BPP; if (nouveau_atomic) dev->driver->driver_features |= DRIVER_ATOMIC; diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index d32b688eb346..d23dcdd1bd95 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -56,6 +56,7 @@ struct drm_printer; #define DRIVER_ATOMIC 0x10000 #define DRIVER_KMS_LEGACY_CONTEXT 0x20000 #define DRIVER_SYNCOBJ 0x40000 +#define DRIVER_PREFER_XBGR_30BPP 0x80000 /** * struct drm_driver - DRM driver structure