From patchwork Wed Nov 23 13:04:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 9443205 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 DC47F6075F for ; Wed, 23 Nov 2016 13:10:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0F86201A4 for ; Wed, 23 Nov 2016 13:10:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C502725F3E; Wed, 23 Nov 2016 13:10:29 +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 5867E201A4 for ; Wed, 23 Nov 2016 13:10:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C2A266E8AE; Wed, 23 Nov 2016 13:10:28 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wj0-x243.google.com (mail-wj0-x243.google.com [IPv6:2a00:1450:400c:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB8386E8A2 for ; Wed, 23 Nov 2016 13:10:14 +0000 (UTC) Received: by mail-wj0-x243.google.com with SMTP id f8so1022534wje.2 for ; Wed, 23 Nov 2016 05:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=kK6Q4l5Ci/M/pswb/LAgC1IJGZsso3y+ykt1L6jFgO0=; b=uFmrMEkypOBDyDAlDYidHynqiKIHqCObxTZGIaEoIK/hpzzRphoAIOZotRkqgoFEU7 mpBKA+1WMXH748JpAC16TuVHpx+LrTmDCo+XvasTSe7gpt0IB3ValyRvvIDAdJOWLYzv 9MY6pFeGzAK9eUcF1n7ou7oLWlzx5XjwwdBWxCV8bIqR6b6GN38FeuAiK97LGlvF/ijo h7DGQi9nWQcfXPtyCehpHgzsbjHISm+c7YFadwG4Zu7AWIl331SDR85o8pFttVmVGtZ9 XIE2AzkAWNeOaAlVrN+8Hfg5rcLPa2bPJUAoUwgbDAZNrHxmvgxAc2v+bBxOklXZ7rbL ny1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=kK6Q4l5Ci/M/pswb/LAgC1IJGZsso3y+ykt1L6jFgO0=; b=PjKMLOvooYPSIGsuLl3CSnoVRczSXXta5fskqRVVzPAeV9Hd55n3lSzigWP2klrErm /aMhhizG5Yt2/AQgRlSxXRNZrP5EX+lUy5ljEtCuMxLlWpItSuvHra6W135zkOUp2UTP U90/rohqO9P6IarhE8pl0SiPkrPilXz8c/yv30V7iLZrgFajRiZc6uri0tMZKmz96D47 1R3dNEUzAxCs/cAYBoEoeekhZ7dLxDOuiOI7CzFn7FmIybpD+MtHRLqiFBZhZUOt38Th cKGGL2j7uRJaoI/V8maBvtcgCuSGRr2vhEDzebCh1ZXrW8z5QRu8fMoIbLs3oHsvaFrY SpFA== X-Gm-Message-State: AKaTC01v+RUCBIZfzb6uoXjVyHTd8uSQFM7koHqy1nqoHUdNuUDv9hAR0+47hlPe7dvndA== X-Received: by 10.194.205.34 with SMTP id ld2mr3095929wjc.211.1479906613040; Wed, 23 Nov 2016 05:10:13 -0800 (PST) Received: from cizrna.lan ([109.72.12.130]) by smtp.gmail.com with ESMTPSA id 6sm36304120wjt.5.2016.11.23.05.10.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2016 05:10:12 -0800 (PST) From: Tomeu Vizoso To: Intel GFX discussion Date: Wed, 23 Nov 2016 14:04:45 +0100 Message-Id: <1479906286-6223-2-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479906286-6223-1-git-send-email-tomeu.vizoso@collabora.com> References: <1479906286-6223-1-git-send-email-tomeu.vizoso@collabora.com> Cc: Tomeu Vizoso Subject: [Intel-gfx] [PATCH i-g-t 1/2] lib: Check format of framebuffer before SetPlane X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Avoid setting a framebuffer in a format that the plane doesn't support, so we have better debug output in IGT and we don't have to dig into dmesg files to find out what's going on. I found this issue when kms_plane_scaling tried to use a cursor plane as a regular one in a Skylake machine with just one overlay. Signed-off-by: Tomeu Vizoso --- lib/igt_kms.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 989704e14803..3234fa1bbdc4 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1670,6 +1670,14 @@ static uint32_t igt_plane_get_fb_id(igt_plane_t *plane) return 0; } +static uint32_t igt_plane_get_fb_format(igt_plane_t *plane) +{ + if (plane->fb) + return plane->fb->drm_format; + else + return 0; +} + static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane) { if (plane->fb) @@ -1678,6 +1686,28 @@ static uint32_t igt_plane_get_fb_gem_handle(igt_plane_t *plane) return 0; } +static bool igt_plane_supports_format(igt_plane_t *plane, uint32_t format) +{ + int i; + + for (i = 0; i < plane->drm_plane->count_formats; i++) { + if (format == plane->drm_plane->formats[i]) + return true; + } + + igt_debug("Plane %d in pipe %s doesn't support format %s.\n", + plane->index, + kmstest_pipe_name(plane->pipe->pipe), + igt_format_str(format)); + + igt_debug("Formats supported are:"); + for (i = 0; i < plane->drm_plane->count_formats; i++) + igt_debug(" %s", igt_format_str(plane->drm_plane->formats[i])); + igt_debug(".\n"); + + return false; +} + #define CHECK_RETURN(r, fail) { \ if (r && !fail) \ return r; \ @@ -1772,6 +1802,7 @@ static int igt_drm_plane_commit(igt_plane_t *plane, int32_t crtc_y; uint32_t crtc_w; uint32_t crtc_h; + uint32_t format; igt_assert(plane->drm_plane); @@ -1821,6 +1852,10 @@ static int igt_drm_plane_commit(igt_plane_t *plane, src_x >> 16, src_y >> 16, src_w >> 16, src_h >> 16, crtc_x, crtc_y, crtc_w, crtc_h); + /* it's an error to try an unsupported format */ + format = igt_plane_get_fb_format(plane); + igt_assert(igt_plane_supports_format(plane, format)); + ret = drmModeSetPlane(display->drm_fd, plane->drm_plane->plane_id, crtc_id,