From patchwork Thu Aug 7 13:09:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 4691181 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CE148C033A for ; Thu, 7 Aug 2014 13:09:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E14E201ED for ; Thu, 7 Aug 2014 13:09:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 19F97201EF for ; Thu, 7 Aug 2014 13:09:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 98EBD89FCA; Thu, 7 Aug 2014 06:09:32 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f49.google.com (mail-yh0-f49.google.com [209.85.213.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B9D289FD9 for ; Thu, 7 Aug 2014 06:09:31 -0700 (PDT) Received: by mail-yh0-f49.google.com with SMTP id b6so2866140yha.36 for ; Thu, 07 Aug 2014 06:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mPgEEYvifRD3x+pqLPO9mnlyrK44QkoYi6JyjRh67+o=; b=L7ZVbhqa5n0MQS9iuG0wnxbQRo3qdPoBmNojH8ptnNlzQGqK0+CYB22aao4IAoWC7r bKAKU8QD3dNxG2i+zF20rQbz6CyuhP8ufi5BOx5zGTrJ9gm9BCka3gcT8qCAB8Nv/C5T 5CeEGmwb4SVe8j+Zezq+J2xayArHpFPTyHNLY93U7YxgJ9M8GC/6gcjMyJ2+PNMKeYId 1SqvthvM/Aw9R8LnW9+fI8rraM++r+0/gReoXh9oawy8vPJuI+V6/uClhiyOyY5Mb66h cfEsdMa5d21c2hSlln9EAsljtrmTbnZQXgaP24Veu9JAtsY3aN8FTzr+QfnECNQCFKjo 1nUA== X-Received: by 10.236.125.72 with SMTP id y48mr4578808yhh.111.1407416971123; Thu, 07 Aug 2014 06:09:31 -0700 (PDT) Received: from localhost.localdomain ([177.156.106.184]) by mx.google.com with ESMTPSA id u23sm7515674yhg.28.2014.08.07.06.09.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Aug 2014 06:09:30 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Aug 2014 10:09:06 -0300 Message-Id: <1407416947-2282-5-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1407416947-2282-1-git-send-email-przanoni@gmail.com> References: <1407416947-2282-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 5/6] tests/pm_rpm: use igt_get_property() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 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.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Paulo Zanoni So we can reduce the code size. Signed-off-by: Paulo Zanoni --- tests/pm_rpm.c | 97 ++++++++++++++++++++++++---------------------------------- 1 file changed, 40 insertions(+), 57 deletions(-) diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c index 0633476..800ab4b 100644 --- a/tests/pm_rpm.c +++ b/tests/pm_rpm.c @@ -348,29 +348,25 @@ static void enable_one_screen(struct mode_set_data *data) static drmModePropertyBlobPtr get_connector_edid(drmModeConnectorPtr connector, int index) { - unsigned int i; - drmModeObjectPropertiesPtr props; - drmModePropertyBlobPtr ret = NULL; + bool found; + uint64_t prop_value; + drmModePropertyPtr prop; + drmModePropertyBlobPtr blob = NULL; - props = drmModeObjectGetProperties(drm_fd, connector->connector_id, - DRM_MODE_OBJECT_CONNECTOR); + found = igt_get_property(drm_fd, connector->connector_id, + DRM_MODE_OBJECT_CONNECTOR, "EDID", + NULL, &prop_value, &prop); - for (i = 0; i < props->count_props; i++) { - drmModePropertyPtr prop = drmModeGetProperty(drm_fd, - props->props[i]); + if (found) { + igt_assert(prop->flags & DRM_MODE_PROP_BLOB); + igt_assert(prop->count_blobs == 0); - if (strcmp(prop->name, "EDID") == 0) { - igt_assert(prop->flags & DRM_MODE_PROP_BLOB); - igt_assert(prop->count_blobs == 0); - ret = drmModeGetPropertyBlob(drm_fd, - props->prop_values[i]); - } + blob = drmModeGetPropertyBlob(drm_fd, prop_value); drmModeFreeProperty(prop); } - drmModeFreeObjectProperties(props); - return ret; + return blob; } static void init_mode_set_data(struct mode_set_data *data) @@ -1529,52 +1525,39 @@ static void cursor_subtest(bool dpms) static enum plane_type get_plane_type(uint32_t plane_id) { - drmModeObjectPropertiesPtr props; - int i, j; + int i; + bool found; + uint64_t prop_value; + drmModePropertyPtr prop; + const char *enum_name = NULL; enum plane_type type; - bool found = false; - - props = drmModeObjectGetProperties(drm_fd, plane_id, - DRM_MODE_OBJECT_PLANE); - igt_assert(props); - - for (i = 0; i < props->count_props && !found; i++) { - drmModePropertyPtr prop; - const char *enum_name = NULL; - - prop = drmModeGetProperty(drm_fd, props->props[i]); - igt_assert(prop); - - if (strcmp(prop->name, "type") == 0) { - igt_assert(prop->flags & DRM_MODE_PROP_ENUM); - igt_assert(props->prop_values[i] < prop->count_enums); - - for (j = 0; j < prop->count_enums; j++) { - if (prop->enums[j].value == - props->prop_values[i]) { - enum_name = prop->enums[j].name; - break; - } - } - igt_assert(enum_name); - - if (strcmp(enum_name, "Overlay") == 0) - type = PLANE_OVERLAY; - else if (strcmp(enum_name, "Primary") == 0) - type = PLANE_PRIMARY; - else if (strcmp(enum_name, "Cursor") == 0) - type = PLANE_CURSOR; - else - igt_assert(0); - found = true; - } + found = igt_get_property(drm_fd, plane_id, DRM_MODE_OBJECT_PLANE, + "type", NULL, &prop_value, &prop); + igt_assert(found); - drmModeFreeProperty(prop); + igt_assert(prop->flags & DRM_MODE_PROP_ENUM); + igt_assert(prop_value < prop->count_enums); + + for (i = 0; i < prop->count_enums; i++) { + if (prop->enums[i].value == prop_value) { + enum_name = prop->enums[i].name; + break; + } } - igt_assert(found); + igt_assert(enum_name); + + if (strcmp(enum_name, "Overlay") == 0) + type = PLANE_OVERLAY; + else if (strcmp(enum_name, "Primary") == 0) + type = PLANE_PRIMARY; + else if (strcmp(enum_name, "Cursor") == 0) + type = PLANE_CURSOR; + else + igt_assert(0); + + drmModeFreeProperty(prop); - drmModeFreeObjectProperties(props); return type; }