All of lore.kernel.org
 help / color / mirror / Atom feed
From: Micah Fedke <micah.fedke@collabora.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 1/3] lib: update kmstest_get_pipe_from_crtc_id
Date: Fri,  4 Sep 2015 18:22:57 +0000	[thread overview]
Message-ID: <1441390979-1747-2-git-send-email-micah.fedke@collabora.co.uk> (raw)
In-Reply-To: <1441390979-1747-1-git-send-email-micah.fedke@collabora.co.uk>

This function uses an intel-specific ioctl to fetch a mapping between pipes and
crtc ids, but this technique is outdated as the crtc id is now always
equivalent to its index in the array of crtcs returned by the kernel.

---
 lib/igt_kms.c | 33 ++++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 0bb16b4..693d1cf 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -271,20 +271,35 @@ void kmstest_dump_mode(drmModeModeInfo *mode)
  * @fd: DRM fd
  * @crtc_id: DRM CRTC id
  *
- * Returns: The pipe number for the given DRM CRTC @crtc_id. This maps directly
- * to an enum pipe value used in other helper functions.
+ * Returns: The crtc index for the given DRM CRTC ID @crtc_id. The crtc index
+ * is the equivalent of the pipe id.  This value maps directly to an enum pipe
+ * value used in other helper functions.  Returns 0 if the index could not be
+ * determined.
  */
+
 int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id)
 {
-	struct drm_i915_get_pipe_from_crtc_id pfci;
-	int ret;
+	drmModeRes *res;
+	drmModeCrtc *crtc;
+	int i, cur_id;
+
+	res = drmModeGetResources(fd);
+	igt_assert(res);
+
+	for (i = 0; i < res->count_crtcs; i++) {
+		crtc = drmModeGetCrtc(fd, res->crtcs[i]);
+		igt_assert(crtc);
+		cur_id = crtc->crtc_id;
+		drmModeFreeCrtc(crtc);
+		if (cur_id == crtc_id)
+			break;
+	}
+
+	drmModeFreeResources(res);
 
-	memset(&pfci, 0, sizeof(pfci));
-	pfci.crtc_id = crtc_id;
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID, &pfci);
-	igt_assert(ret == 0);
+	igt_assert(i < res->count_crtcs);
 
-	return pfci.pipe;
+	return i;
 }
 
 /*
-- 
2.1.4

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

  reply	other threads:[~2015-09-04 18:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-04 18:22 [PATCH 0/3] remove crtc<->pipe mapping code Micah Fedke
2015-09-04 18:22 ` Micah Fedke [this message]
2015-09-04 18:22 ` [PATCH 2/3] tests/drm_read: remove manual crtc<->pipe mapping from drm_read test Micah Fedke
2015-09-04 18:22 ` [PATCH 3/3] overlay: remove crtc<->pipe mapping code from kms-overlay Micah Fedke
2015-09-08 11:07   ` Thomas Wood
2015-09-08 11:07 ` [PATCH 0/3] remove crtc<->pipe mapping code Thomas Wood

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=1441390979-1747-2-git-send-email-micah.fedke@collabora.co.uk \
    --to=micah.fedke@collabora.co.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.