From patchwork Mon Jan 30 14:11:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Foss X-Patchwork-Id: 9545383 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 8E32060417 for ; Mon, 30 Jan 2017 14:12:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D77B27F07 for ; Mon, 30 Jan 2017 14:12:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 623472811E; Mon, 30 Jan 2017 14:12:40 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY 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 19AC427F07 for ; Mon, 30 Jan 2017 14:12:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72FF76E1A9; Mon, 30 Jan 2017 14:12:39 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id 921626E1A9 for ; Mon, 30 Jan 2017 14:12:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: robertfoss) with ESMTPSA id 8E22D26A0AE From: Robert Foss To: intel-gfx@lists.freedesktop.org, Tomeu Vizoso , Maarten Lankhorst , Gustavo Padovan , Daniel Stone , Mika Kahola , Petri Latvala Date: Mon, 30 Jan 2017 09:11:53 -0500 Message-Id: <20170130141224.25063-3-robert.foss@collabora.com> X-Mailer: git-send-email 2.11.0.453.g787f75f05 In-Reply-To: <20170130141224.25063-1-robert.foss@collabora.com> References: <20170130141224.25063-1-robert.foss@collabora.com> Subject: [Intel-gfx] [PATCH i-g-t v3 02/33] lib/igt_kms: Avoid depencency on static plane count 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 Rework kmstest_crtc and kmstest_plane structs and their usage to not depend on a static plane count. Signed-off-by: Robert Foss Reviewed-by: Mika Kahola --- lib/igt_kms.c | 47 ++++++++++++++++++++++++++++++----------------- lib/igt_kms.h | 4 ++-- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 188b0ceb..382b0864 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1265,7 +1265,7 @@ static void get_plane(char *str, int type, struct kmstest_plane *plane) int ret; char buf[256]; - plane->plane = type; + plane->type = type; ret = sscanf(str + 12, "%d%*c %*s %[^n]s", &plane->id, buf); @@ -1278,31 +1278,36 @@ static void get_plane(char *str, int type, struct kmstest_plane *plane) igt_assert_eq(ret, 2); } -static int parse_planes(FILE *fid, struct kmstest_plane *plane) +static int parse_planes(FILE *fid, struct kmstest_plane *planes) { char tmp[256]; - int nplanes; + int n_planes; - nplanes = 0; + n_planes = 0; while (fgets(tmp, 256, fid) != NULL) { - igt_assert_neq(nplanes, IGT_MAX_PLANES); if (strstr(tmp, "type=PRI") != NULL) { - get_plane(tmp, DRM_PLANE_TYPE_PRIMARY, &plane[nplanes]); - plane[nplanes].index = nplanes; - nplanes++; + if (planes) { + get_plane(tmp, DRM_PLANE_TYPE_PRIMARY, &planes[n_planes]); + planes[n_planes].index = n_planes; + } + n_planes++; } else if (strstr(tmp, "type=OVL") != NULL) { - get_plane(tmp, DRM_PLANE_TYPE_OVERLAY, &plane[nplanes]); - plane[nplanes].index = nplanes; - nplanes++; + if (planes) { + get_plane(tmp, DRM_PLANE_TYPE_OVERLAY, &planes[n_planes]); + planes[n_planes].index = n_planes; + } + n_planes++; } else if (strstr(tmp, "type=CUR") != NULL) { - get_plane(tmp, DRM_PLANE_TYPE_CURSOR, &plane[nplanes]); - plane[nplanes].index = nplanes; - nplanes++; + if (planes) { + get_plane(tmp, DRM_PLANE_TYPE_CURSOR, &planes[n_planes]); + planes[n_planes].index = n_planes; + } + n_planes++; break; } } - return nplanes; + return n_planes; } static void parse_crtc(char *info, struct kmstest_crtc *crtc) @@ -1342,7 +1347,12 @@ void kmstest_get_crtc(enum pipe pipe, struct kmstest_crtc *crtc) if (strstr(tmp, "active=yes") != NULL) { crtc->active = true; parse_crtc(tmp, crtc); - crtc->nplanes = parse_planes(fid, crtc->plane); + + crtc->nplanes = parse_planes(fid, NULL); + crtc->plane = calloc(crtc->nplanes, sizeof(*crtc->plane)); + fseek(fid, 0, SEEK_END); + fseek(fid, 0, SEEK_SET); + parse_planes(fid, crtc->plane); if (crtc->pipe != pipe) crtc = NULL; @@ -1368,7 +1378,10 @@ void igt_assert_plane_visible(enum pipe pipe, bool visibility) kmstest_get_crtc(pipe, &crtc); visible = true; - for (i = IGT_PLANE_2; i < crtc.nplanes; i++) { + for (i = 0; i < crtc.nplanes; i++) { + if (crtc.plane[i].type == DRM_PLANE_TYPE_PRIMARY) + continue; + if (crtc.plane[i].pos_x > crtc.width) { visible = false; break; diff --git a/lib/igt_kms.h b/lib/igt_kms.h index a6a0d0c4..635702b6 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -135,8 +135,8 @@ struct kmstest_connector_config { struct kmstest_plane { int id; - int plane; int index; + int type; int pos_x; int pos_y; int width; @@ -150,7 +150,7 @@ struct kmstest_crtc { int width; int height; int nplanes; - struct kmstest_plane plane[IGT_MAX_PLANES]; + struct kmstest_plane *plane; }; /**