From patchwork Sun Aug 6 02:25:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 9883473 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 DF34F603F4 for ; Sun, 6 Aug 2017 02:25:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8A52874B for ; Sun, 6 Aug 2017 02:25:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEAD428760; Sun, 6 Aug 2017 02:25:58 +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 09C0A28761 for ; Sun, 6 Aug 2017 02:25:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 676EF6E25F; Sun, 6 Aug 2017 02:25:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x243.google.com (mail-qt0-x243.google.com [IPv6:2607:f8b0:400d:c0d::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 211706E1D5; Sun, 6 Aug 2017 02:25:14 +0000 (UTC) Received: by mail-qt0-x243.google.com with SMTP id d10so4985817qtb.4; Sat, 05 Aug 2017 19:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=wVippBuivFu4lpQkAlno3/OIE9er91sRdR63tRSYdqo=; b=eHYgJNKzgwqoh76+y+AnbHYOTytI7j9XTiIViy/7VU4Mpa6+PMYRXCoxUh8vcg2pes iMrcR8EDRsL3akprzbEmYVe2ehGfyegRdv4MTVX9MgJcbg2QEYJb5wuH0HWwH9mBC1Ei eSkxnFYLMB0cuXLz8j0h/sZ8LOZVYRmnInH9QgHl3vkCncX7B14UFBKAmMp33x32T1pR bIrDBs+l/16IVFhSZKUI/G9y/YMdm7/krNj3FEQSkWKMqj6Jqilq4l0mcOTBrV/oP6si EmcTb7FfT5yZghci4YOZuAq06HLEUjlt9tskEbLNUhdSVVdLp1yYPxiBwB3f+zHttq8X 2uXQ== 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 :in-reply-to:references; bh=wVippBuivFu4lpQkAlno3/OIE9er91sRdR63tRSYdqo=; b=tk/WR9Kt/yjujKgTtACLO88GML22guE2Yo3zCD+QJd2ZMiCmqcNbqqCpqVIyQ7FS2g 8j8SMeyO4aRhhXU/k3XTaYDoMJOAg3Ir9jniFnP+kR/ZG55TJpNfUD/BEw6OnTGOPxI1 5sXxMfIFFVf8xXO8q12CvGvdzF7sHef+G1d+9SHQJfNhZEv9qpKP1b/o7gvNlneaVGdh x1XmlIv3/VoQImmbCIRCUO3ELCSW1wyv2EacjpJd2+0wJR7vlsWng53XqROgCI+oU8JN 5bOsmSD+YidVBHNQ+j3z9UFFVwUgZRRQe1gyda3vPRas3uEw1alniKCkguD0D6lCft9u h6kA== X-Gm-Message-State: AHYfb5g/7Taa8/Y/XRd6sjm0P8/S3PIUzv2E8juRcrMg0iE1d/uOo5OW k5vTRfGlpW5mR1Y5 X-Received: by 10.237.54.225 with SMTP id f88mr9224381qtb.240.1501986313360; Sat, 05 Aug 2017 19:25:13 -0700 (PDT) Received: from athos.fios-router.home (pool-100-2-1-206.nycmny.fios.verizon.net. [100.2.1.206]) by smtp.gmail.com with ESMTPSA id h47sm3633391qte.67.2017.08.05.19.25.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Aug 2017 19:25:12 -0700 (PDT) From: Ilia Mirkin To: Ben Skeggs , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/nouveau/dispnv04: fix exposed format list Date: Sat, 5 Aug 2017 22:25:05 -0400 Message-Id: <20170806022505.3763-5-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170806022505.3763-1-imirkin@alum.mit.edu> References: <20170806022505.3763-1-imirkin@alum.mit.edu> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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 drm_crtc_init exposes the XRGB8888 and ARGB8888 formats. In actuality, ARGB8888's 32-bit depth messes up some formulas that weren't meant for it, and the alpha is fairly meaningless for the primary plane. The modesetting logic appears to be fully prepared for RGB565 as well as XRGB1555 however, as tested with modetest. Signed-off-by: Ilia Mirkin --- drivers/gpu/drm/nouveau/dispnv04/crtc.c | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/crtc.c b/drivers/gpu/drm/nouveau/dispnv04/crtc.c index 4b4b0b496262..c078811b4e11 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/crtc.c +++ b/drivers/gpu/drm/nouveau/dispnv04/crtc.c @@ -1099,6 +1099,38 @@ static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = { .disable = nv_crtc_disable, }; +static const uint32_t modeset_formats[] = { + DRM_FORMAT_XRGB8888, + DRM_FORMAT_RGB565, + DRM_FORMAT_XRGB1555, +}; + +static struct drm_plane * +create_primary_plane(struct drm_device *dev) +{ + struct drm_plane *primary; + int ret; + + primary = kzalloc(sizeof(*primary), GFP_KERNEL); + if (primary == NULL) { + DRM_DEBUG_KMS("Failed to allocate primary plane\n"); + return NULL; + } + + /* possible_crtc's will be filled in later by crtc_init */ + ret = drm_universal_plane_init(dev, primary, 0, + &drm_primary_helper_funcs, + modeset_formats, + ARRAY_SIZE(modeset_formats), + DRM_PLANE_TYPE_PRIMARY, NULL); + if (ret) { + kfree(primary); + primary = NULL; + } + + return primary; +} + int nv04_crtc_create(struct drm_device *dev, int crtc_num) { @@ -1122,7 +1154,9 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num) nv_crtc->save = nv_crtc_save; nv_crtc->restore = nv_crtc_restore; - drm_crtc_init(dev, &nv_crtc->base, &nv04_crtc_funcs); + drm_crtc_init_with_planes(dev, &nv_crtc->base, + create_primary_plane(dev), NULL, + &nv04_crtc_funcs, NULL); drm_crtc_helper_add(&nv_crtc->base, &nv04_crtc_helper_funcs); drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);