From patchwork Mon Oct 5 21:21:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 7331841 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 16322BEEA4 for ; Mon, 5 Oct 2015 21:21:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF08B2060B for ; Mon, 5 Oct 2015 21:21:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9B9BD20609 for ; Mon, 5 Oct 2015 21:21:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A8C516E8CF; Mon, 5 Oct 2015 14:21:44 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 841766E8CE for ; Mon, 5 Oct 2015 14:21:43 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 05 Oct 2015 14:21:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,640,1437462000"; d="scan'208";a="804263022" Received: from khauck-mobl.amr.corp.intel.com (HELO panetone.amr.corp.intel.com) ([10.254.102.83]) by fmsmga001.fm.intel.com with ESMTP; 05 Oct 2015 14:21:24 -0700 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Mon, 5 Oct 2015 18:21:08 -0300 Message-Id: <1444080071-29070-3-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: <1444080071-29070-1-git-send-email-paulo.r.zanoni@intel.com> References: <1444080071-29070-1-git-send-email-paulo.r.zanoni@intel.com> Subject: [Intel-gfx] [PATCH igt 3/6] kms_frontbuffer_tracking: set the universal planes cap in the setup 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ... instead of just setting it for the fullscreen_plane subtest and then unsetting it. We want to use it more, so just make sure all the code knows how to deal with multiple planes per CRTC. This also allows us to do some upfront caching of the plane information, so the code for the tests gets simpler. There's a new test that's going to use all these changes. Signed-off-by: Paulo Zanoni --- tests/kms_frontbuffer_tracking.c | 133 ++++++++++++++------------------------- 1 file changed, 46 insertions(+), 87 deletions(-) diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c index 88a7384..6692dd8 100644 --- a/tests/kms_frontbuffer_tracking.c +++ b/tests/kms_frontbuffer_tracking.c @@ -144,11 +144,14 @@ struct rect { }; #define MAX_CONNECTORS 32 +#define MAX_PLANES 32 struct { int fd; drmModeResPtr res; drmModeConnectorPtr connectors[MAX_CONNECTORS]; - drmModePlaneResPtr planes; + drmModePlaneResPtr plane_res; + drmModePlanePtr planes[MAX_PLANES]; + uint64_t plane_types[MAX_PLANES]; drm_intel_bufmgr *bufmgr; } drm; @@ -367,17 +370,11 @@ static void init_mode_params(struct modeset_params *params, uint32_t crtc_id, uint32_t plane_id = 0; int i; - for (i = 0; i < drm.planes->count_planes && plane_id == 0; i++) { - drmModePlanePtr plane; + for (i = 0; i < drm.plane_res->count_planes && plane_id == 0; i++) + if ((drm.planes[i]->possible_crtcs & (1 << crtc_index)) && + drm.plane_types[i] == DRM_PLANE_TYPE_OVERLAY) + plane_id = drm.planes[i]->plane_id; - plane = drmModeGetPlane(drm.fd, drm.planes->planes[i]); - igt_assert(plane); - - if (plane->possible_crtcs & (1 << crtc_index)) - plane_id = plane->plane_id; - - drmModeFreePlane(plane); - } igt_assert(plane_id); params->crtc_id = crtc_id; @@ -1069,9 +1066,9 @@ static void unset_all_crtcs(void) igt_assert(rc == 0); } - for (i = 0; i < drm.planes->count_planes; i++) { - rc = drmModeSetPlane(drm.fd, drm.planes->planes[i], 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0); + for (i = 0; i < drm.plane_res->count_planes; i++) { + rc = drmModeSetPlane(drm.fd, drm.plane_res->planes[i], 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0); igt_assert(rc == 0); } } @@ -1240,9 +1237,25 @@ static void init_crcs(enum pixel_format format, pattern->initialized[format] = true; } +static uint64_t get_plane_type(uint32_t plane_id) +{ + bool found; + uint64_t prop_value; + drmModePropertyPtr prop; + + found = kmstest_get_property(drm.fd, plane_id, DRM_MODE_OBJECT_PLANE, + "type", NULL, &prop_value, &prop); + igt_assert(found); + igt_assert(prop->flags & DRM_MODE_PROP_ENUM); + igt_assert(prop_value < prop->count_enums); + + drmModeFreeProperty(prop); + return prop_value; +} + static void setup_drm(void) { - int i; + int i, rc; drm.fd = drm_open_driver_master(DRIVER_INTEL); @@ -1253,7 +1266,16 @@ static void setup_drm(void) drm.connectors[i] = drmModeGetConnector(drm.fd, drm.res->connectors[i]); - drm.planes = drmModeGetPlaneResources(drm.fd); + rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); + igt_require(rc == 0); + + drm.plane_res = drmModeGetPlaneResources(drm.fd); + igt_assert(drm.plane_res->count_planes <= MAX_PLANES); + + for (i = 0; i < drm.plane_res->count_planes; i++) { + drm.planes[i] = drmModeGetPlane(drm.fd, drm.plane_res->planes[i]); + drm.plane_types[i] = get_plane_type(drm.plane_res->planes[i]); + } drm.bufmgr = drm_intel_bufmgr_gem_init(drm.fd, 4096); igt_assert(drm.bufmgr); @@ -1266,7 +1288,9 @@ static void teardown_drm(void) drm_intel_bufmgr_destroy(drm.bufmgr); - drmModeFreePlaneResources(drm.planes); + for (i = 0; i < drm.plane_res->count_planes; i++) + drmModeFreePlane(drm.planes[i]); + drmModeFreePlaneResources(drm.plane_res); for (i = 0; i < drm.res->count_connectors; i++) drmModeFreeConnector(drm.connectors[i]); @@ -2383,91 +2407,26 @@ static void onoff_subtest(const struct test_mode *t) } } -static bool plane_is_primary(uint32_t plane_id) -{ - int i; - bool found, is_primary; - uint64_t prop_value; - drmModePropertyPtr prop; - const char *enum_name = NULL; - - found = kmstest_get_property(drm.fd, plane_id, DRM_MODE_OBJECT_PLANE, - "type", NULL, &prop_value, &prop); - if (!found) { - igt_debug("Property not found\n"); - return false; - } - if (!(prop->flags & DRM_MODE_PROP_ENUM)) { - igt_debug("Property is not an enum\n"); - return false; - } - if (prop_value >= prop->count_enums) { - igt_debug("Bad property value\n"); - return false; - } - - for (i = 0; i < prop->count_enums; i++) { - if (prop->enums[i].value == prop_value) { - enum_name = prop->enums[i].name; - break; - } - } - if (!enum_name) { - igt_debug("Enum name not found\n"); - return false; - } - - is_primary = (strcmp(enum_name, "Primary") == 0); - drmModeFreeProperty(prop); - return is_primary; -} - static bool prim_plane_disabled(void) { int i, rc; bool disabled, found = false; - drmModePlaneResPtr planes; - - rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); - igt_assert(rc == 0); - - planes = drmModeGetPlaneResources(drm.fd); - for (i = 0; i < planes->count_planes; i++) { - drmModePlanePtr plane; - - plane = drmModeGetPlane(drm.fd, planes->planes[i]); - if (!plane) { - igt_debug("Failed to get plane\n"); - goto fail; - } + for (i = 0; i < drm.plane_res->count_planes; i++) { /* We just pick the first CRTC for the primary plane. */ - if ((plane->possible_crtcs & 0x1) && - plane_is_primary(plane->plane_id)) { + if ((drm.planes[i]->possible_crtcs & 0x1) && + drm.plane_types[i] == DRM_PLANE_TYPE_PRIMARY) { found = true; - disabled = (plane->crtc_id == 0); + disabled = (drm.planes[i]->crtc_id == 0); } - drmModeFreePlane(plane); } - drmModeFreePlaneResources(planes); - if (!found) { - igt_debug("Primary plane not found\n"); - goto fail; - } + igt_assert(found); rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0); igt_assert(rc == 0); return disabled; - -fail: - /* Make sure we do this before failing any assertions so we don't mess - * the other subtests. */ - rc = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0); - igt_assert(rc == 0); - igt_assert(false); - return false; } /*