From: Paulo Zanoni <przanoni@gmail.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 5/6] tests/pm_rpm: use igt_get_property()
Date: Thu, 7 Aug 2014 10:09:06 -0300 [thread overview]
Message-ID: <1407416947-2282-5-git-send-email-przanoni@gmail.com> (raw)
In-Reply-To: <1407416947-2282-1-git-send-email-przanoni@gmail.com>
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
So we can reduce the code size.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
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;
}
--
2.0.1
next prev parent reply other threads:[~2014-08-07 13:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-07 13:09 [PATCH 1/6] igt_kms: don't get drmModeRes just to free it later Paulo Zanoni
2014-08-07 13:09 ` [PATCH 2/6] igt_kms: pass drm_fd instead of igt_display_t on some functions Paulo Zanoni
2014-08-07 13:09 ` [PATCH 3/6] igt_kms: optionally return the property from get_property Paulo Zanoni
2014-08-07 13:09 ` [PATCH 4/6] igt_kms: document and export igt_get_property() Paulo Zanoni
2014-08-07 14:43 ` Daniel Vetter
2014-08-07 13:09 ` Paulo Zanoni [this message]
2014-08-07 13:09 ` [PATCH 6/6] igt_kms: add igt_unset_all_crtcs() Paulo Zanoni
2014-08-07 14:45 ` Daniel Vetter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1407416947-2282-5-git-send-email-przanoni@gmail.com \
--to=przanoni@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox