From: Damien Lespiau Subject: [PATCH i-g-t 01/43] igt_kms: Factor out a generic get_property() out of get_drm_plane_type() Date: Thu, 10 Jul 2014 19:00:02 +0100 Message-ID: <1405015244-11370-2-git-send-email-damien.lespiau@intel.com> References: <1405015244-11370-1-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 27ABA6E025 for ; Thu, 10 Jul 2014 11:01:00 -0700 (PDT) In-Reply-To: <1405015244-11370-1-git-send-email-damien.lespiau@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org Signed-off-by: Damien Lespiau --- lib/igt_kms.c | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 4a8c394..666b0d0 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -495,37 +495,56 @@ static void igt_output_refresh(igt_output_t *output) display->pipes_in_use |= 1 << output->config.pipe; } -/* - * Walk a plane's property list to determine its type. If we don't - * find a type property, then the kernel doesn't support universal - * planes and we know the plane is an overlay/sprite. - */ -static int get_drm_plane_type(igt_display_t *display, uint32_t plane_id) +static bool +get_property(igt_display_t *display, + uint32_t object_id, uint32_t object_type, const char *name, + uint32_t *prop_id /* out */, uint64_t *value /* out */) { drmModeObjectPropertiesPtr proplist; drmModePropertyPtr prop = NULL; - int type = DRM_PLANE_TYPE_OVERLAY; + bool found = false; int i; proplist = drmModeObjectGetProperties(display->drm_fd, - plane_id, - DRM_MODE_OBJECT_PLANE); + object_id, object_type); for (i = 0; i < proplist->count_props; i++) { drmModeFreeProperty(prop); prop = drmModeGetProperty(display->drm_fd, proplist->props[i]); if (!prop) continue; - if (strcmp(prop->name, "type") == 0) { - type = proplist->prop_values[i]; - break; + 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; } } +out: drmModeFreeProperty(prop); drmModeFreeObjectProperties(proplist); + return found; +} + +/* + * Walk a plane's property list to determine its type. If we don't + * find a type property, then the kernel doesn't support universal + * planes and we know the plane is an overlay/sprite. + */ +static int get_drm_plane_type(igt_display_t *display, uint32_t plane_id) +{ + uint64_t value; + bool has_prop; + + has_prop = get_property(display, plane_id, DRM_MODE_OBJECT_PLANE, + "type", NULL /* prop_id */, &value); + if (has_prop) + return (int)value; - return type; + return DRM_PLANE_TYPE_OVERLAY; } void igt_display_init(igt_display_t *display, int drm_fd) -- 1.8.3.1