public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 09/12] lib/igt_kms: Add igt_$obj_get_prop functions
Date: Wed, 11 Oct 2017 12:11:16 +0200	[thread overview]
Message-ID: <20171011101119.32130-10-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20171011101119.32130-1-maarten.lankhorst@linux.intel.com>

Some tests need to get the current kernel value for properties
as part of the test. Add get_prop functions that will retrieve
the current kernel value.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 lib/igt_kms.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h | 24 ++++++++++++++++++
 2 files changed, 105 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 339c11843154..176e6825a492 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2407,6 +2407,51 @@ static int igt_output_commit(igt_output_t *output,
 	return 0;
 }
 
+static uint64_t igt_mode_object_get_prop(igt_display_t *display,
+					 uint32_t object_type,
+					 uint32_t object_id,
+					 uint32_t prop)
+{
+	drmModeObjectPropertiesPtr proplist;
+	bool found = false;
+	int i;
+	uint64_t ret;
+
+	proplist = drmModeObjectGetProperties(display->drm_fd, object_id, object_type);
+	for (i = 0; i < proplist->count_props; i++) {
+		if (proplist->props[i] != prop)
+			continue;
+
+		found = true;
+		break;
+	}
+
+	igt_assert(found);
+
+	ret = proplist->prop_values[i];
+
+	drmModeFreeObjectProperties(proplist);
+	return ret;
+}
+
+/**
+ * igt_plane_get_prop - Return current value on a plane for a given property.
+ *
+ * @plane: Target plane.
+ * @prop: Property to check.
+ *
+ * Returns: The value the property is set to, if this
+ * is a blob, the blob id is returned. This can be passed
+ * to drmModeGetPropertyBlob() to get the contents of the blob.
+ */
+uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop)
+{
+	igt_assert(igt_plane_has_prop(plane, prop));
+
+	return igt_mode_object_get_prop(plane->pipe->display, DRM_MODE_OBJECT_PLANE,
+					plane->drm_plane->plane_id, plane->props[prop]);
+}
+
 /**
  * igt_plane_replace_prop_blob:
  * @plane: plane to set property on.
@@ -2439,6 +2484,24 @@ igt_plane_replace_prop_blob(igt_plane_t *plane, enum igt_atomic_plane_properties
 	igt_plane_set_prop_changed(plane, prop);
 }
 
+/**
+ * igt_output_get_prop - Return current value on an output for a given property.
+ *
+ * @output: Target output.
+ * @prop: Property to return.
+ *
+ * Returns: The value the property is set to, if this
+ * is a blob, the blob id is returned. This can be passed
+ * to drmModeGetPropertyBlob() to get the contents of the blob.
+ */
+uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_properties prop)
+{
+	igt_assert(igt_output_has_prop(output, prop));
+
+	return igt_mode_object_get_prop(output->display, DRM_MODE_OBJECT_CONNECTOR,
+					output->id, output->props[prop]);
+}
+
 /**
  * igt_output_replace_prop_blob:
  * @output: output to set property on.
@@ -2471,6 +2534,24 @@ igt_output_replace_prop_blob(igt_output_t *output, enum igt_atomic_connector_pro
 	igt_output_set_prop_changed(output, prop);
 }
 
+/**
+ * igt_pipe_obj_get_prop - Return current value on a pipe for a given property.
+ *
+ * @pipe: Target pipe.
+ * @prop: Property to return.
+ *
+ * Returns: The value the property is set to, if this
+ * is a blob, the blob id is returned. This can be passed
+ * to drmModeGetPropertyBlob() to get the contents of the blob.
+ */
+uint64_t igt_pipe_obj_get_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop)
+{
+	igt_assert(igt_pipe_obj_has_prop(pipe, prop));
+
+	return igt_mode_object_get_prop(pipe->display, DRM_MODE_OBJECT_CRTC,
+					pipe->crtc_id, pipe->props[prop]);
+}
+
 /**
  * igt_pipe_obj_replace_prop_blob:
  * @pipe: pipe to set property on.
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 916cd359519a..fda94cb640de 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -503,6 +503,8 @@ igt_plane_has_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop)
 	return plane->props[prop];
 }
 
+uint64_t igt_plane_get_prop(igt_plane_t *plane, enum igt_atomic_plane_properties prop);
+
 #define igt_plane_is_prop_changed(plane, prop) \
 	(!!((plane)->changed & (1 << (prop))))
 
@@ -536,6 +538,8 @@ igt_output_has_prop(igt_output_t *output, enum igt_atomic_connector_properties p
 	return output->props[prop];
 }
 
+uint64_t igt_output_get_prop(igt_output_t *output, enum igt_atomic_connector_properties prop);
+
 #define igt_output_is_prop_changed(output, prop) \
 	(!!((output)->changed & (1 << (prop))))
 #define igt_output_set_prop_changed(output, prop) \
@@ -568,6 +572,26 @@ igt_pipe_obj_has_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop)
 	return pipe->props[prop];
 }
 
+uint64_t igt_pipe_obj_get_prop(igt_pipe_t *pipe, enum igt_atomic_crtc_properties prop);
+
+/**
+ * igt_pipe_get_prop - Return current value on a pipe for a given property.
+ *
+ * @display: Pointer to display.
+ * @pipe: Target pipe.
+ * @prop: Property to return.
+ *
+ * Returns: The value the property is set to, if this
+ * is a blob, the blob id is returned. This can be passed
+ * to drmModeGetPropertyBlob() to get the contents of the blob.
+ */
+static inline uint64_t
+igt_pipe_get_prop(igt_display_t *display, enum pipe pipe,
+		  enum igt_atomic_crtc_properties prop)
+{
+	return igt_pipe_obj_get_prop(&display->pipes[pipe], prop);
+}
+
 /**
  * igt_pipe_has_prop - Check whether pipe supports a given property.
  *
-- 
2.14.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2017-10-11 10:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 10:11 [PATCH i-g-t 00/12] lib/igt_kms: Rewrite property handling to better match atomic Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 01/12] lib/igt_kms: Rework connector properties to be more atomic, v2 Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 02/12] lib/igt_kms: Rework plane properties to be more atomic, v5 Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 03/12] lib/igt_kms: Rework pipe properties to be more atomic, v7 Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 04/12] lib/igt_kms: Allow setting any plane property through the universal path Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 05/12] lib/igt_kms: Allow setting any output property through the !atomic paths Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 06/12] lib/igt_kms: Export property blob functions for output/pipe/plane Maarten Lankhorst
2017-10-12 11:41   ` [PATCH i-g-t 1/2] lib/igt_kms: Export property blob functions for output/pipe/plane, v2 Maarten Lankhorst
2017-10-12 11:41     ` [PATCH i-g-t 2/2] tests/chamelium: Remove reliance on output->config.pipe Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 07/12] lib/igt_kms: Unexport broadcast rgb API Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 08/12] lib/igt_kms: Add igt_$obj_has_prop functions Maarten Lankhorst
2017-10-11 10:11 ` Maarten Lankhorst [this message]
2017-10-11 10:11 ` [PATCH i-g-t 10/12] tests/kms_color: Rework tests slightly to work better with new atomic api Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 11/12] lib/igt_kms: Remove igt_pipe_get_property Maarten Lankhorst
2017-10-11 10:11 ` [PATCH i-g-t 12/12] tests/kms_atomic: Convert/rewrite tests to use igt_kms framework Maarten Lankhorst
2017-10-11 13:49 ` ✗ Fi.CI.BAT: failure for lib/igt_kms: Rewrite property handling to better match atomic Patchwork
2017-10-12 12:08 ` ✓ Fi.CI.BAT: success for lib/igt_kms: Rewrite property handling to better match atomic. (rev3) Patchwork
2017-10-12 13:52 ` ✓ Fi.CI.IGT: " Patchwork

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=20171011101119.32130-10-maarten.lankhorst@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /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