From: Paulo Zanoni <przanoni@gmail.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 3/6] igt_kms: optionally return the property from get_property
Date: Thu, 7 Aug 2014 10:09:04 -0300 [thread overview]
Message-ID: <1407416947-2282-3-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 use this function on places that also need the property
pointer, without having to call drmModeGetProperty() again with the
returned id.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
lib/igt_kms.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 5dd67fe..664b9e8 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -595,42 +595,46 @@ static void igt_output_refresh(igt_output_t *output)
static bool
get_property(int drm_fd, uint32_t object_id, uint32_t object_type,
const char *name, uint32_t *prop_id /* out */,
- uint64_t *value /* out */)
+ uint64_t *value /* out */, drmModePropertyPtr *prop /* out */)
{
drmModeObjectPropertiesPtr proplist;
- drmModePropertyPtr prop = NULL;
+ drmModePropertyPtr _prop;
bool found = false;
int i;
proplist = drmModeObjectGetProperties(drm_fd, object_id, object_type);
for (i = 0; i < proplist->count_props; i++) {
- drmModeFreeProperty(prop);
- prop = drmModeGetProperty(drm_fd, proplist->props[i]);
- if (!prop)
+ _prop = drmModeGetProperty(drm_fd, proplist->props[i]);
+ if (!_prop)
continue;
- if (strcmp(prop->name, name) == 0) {
+ if (strcmp(_prop->name, name) == 0) {
found = true;
if (prop_id)
*prop_id = proplist->props[i];
if (value)
*value = proplist->prop_values[i];
- goto out;
+ if (prop)
+ *prop = _prop;
+ else
+ drmModeFreeProperty(_prop);
+
+ break;
}
+ drmModeFreeProperty(_prop);
}
-out:
- drmModeFreeProperty(prop);
drmModeFreeObjectProperties(proplist);
return found;
}
static bool
get_plane_property(int drm_fd, uint32_t plane_id, const char *name,
- uint32_t *prop_id /* out */, uint64_t *value /* out */)
+ uint32_t *prop_id /* out */, uint64_t *value /* out */,
+ drmModePropertyPtr *prop /* out */)
{
return get_property(drm_fd, plane_id, DRM_MODE_OBJECT_PLANE,
- name, prop_id, value);
+ name, prop_id, value, prop);
}
static void
@@ -654,7 +658,7 @@ static int get_drm_plane_type(int drm_fd, uint32_t plane_id)
bool has_prop;
has_prop = get_plane_property(drm_fd, plane_id, "type",
- NULL /* prop_id */, &value);
+ NULL /* prop_id */, &value, NULL);
if (has_prop)
return (int)value;
@@ -743,7 +747,8 @@ void igt_display_init(igt_display_t *display, int drm_fd)
get_plane_property(display->drm_fd, drm_plane->plane_id,
"rotation",
&plane->rotation_property,
- &prop_value);
+ &prop_value,
+ NULL);
plane->rotation = (igt_rotation_t)prop_value;
}
--
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 ` Paulo Zanoni [this message]
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 ` [PATCH 5/6] tests/pm_rpm: use igt_get_property() Paulo Zanoni
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-3-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