Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 0/2] Get active crtc list
@ 2026-09-21 13:07 Arun R Murthy
  2026-09-21 13:07 ` [PATCH libdrm 1/2] xf86drmMode: add drmModeGetCrtcList() to enumerate available CRTCs Arun R Murthy
  2026-09-21 13:07 ` [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage Arun R Murthy
  0 siblings, 2 replies; 6+ messages in thread
From: Arun R Murthy @ 2026-09-21 13:07 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, intel-xe, Jani Nikula, Ville Syrjälä,
	ankit.k.nautiyal, adarsh.g.m, Arun R Murthy

drmModeGetResources() tells the system capability and not runtime
availability of the hardware resource.
DRM_IOCTL_MODE_GETCRTC only tells userspace which CRTCs are enabled
through KMS, not which are active in hardware. A pipe can be actively
scanning out without being enabled through the KMS state, so relying on
GETCRTC alone would report such a CRTC as free and assignable when it is
not.
Add new function drmModeGetCrtcList that enumerates the crtc list.

Arun R Murthy (2):
  xf86drmMode: add drmModeGetCrtcList() to enumerate available CRTCs
  tests/crtclist: add utility to inspect CRTC usage

 core-symbols.txt  |   2 +
 tests/crtclist.c  | 116 +++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build |   9 ++++
 xf86drmMode.c     | 123 ++++++++++++++++++++++++++++++++++++++++++++++
 xf86drmMode.h     |  38 ++++++++++++++
 5 files changed, 288 insertions(+)
 create mode 100644 tests/crtclist.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH libdrm 1/2] xf86drmMode: add drmModeGetCrtcList() to enumerate available CRTCs
  2026-09-21 13:07 [PATCH libdrm 0/2] Get active crtc list Arun R Murthy
@ 2026-09-21 13:07 ` Arun R Murthy
  2026-09-21 13:07 ` [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage Arun R Murthy
  1 sibling, 0 replies; 6+ messages in thread
From: Arun R Murthy @ 2026-09-21 13:07 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, intel-xe, Jani Nikula, Ville Syrjälä,
	ankit.k.nautiyal, adarsh.g.m, Arun R Murthy

drmModeGetResources() tells the system capability and not runtime
availability of the hardware resource.
DRM_IOCTL_MODE_GETCRTC only tells userspace which CRTCs are enabled
through KMS, not which are active in hardware. A pipe can be actively
scanning out without being enabled through the KMS state, so relying on
GETCRTC alone would report such a CRTC as free and assignable when it is
not.

An active pipe keeps its vblank running, so reading the CRTC's vblank
sequence reveals the active pipes: an active pipe's counter keeps
advancing while an inactive pipe's does not. For every CRTC that GETCRTC
reports as free, sample the vblank via drmCrtcGetSequence() across a
single short wait and, if it advanced, flag the entry as driver_active
and exclude it from count_available.

The list is allocated by drmModeGetCrtcList() and released with the new
drmModeFreeCrtcList(). Both symbols are exported via core-symbols.txt.

The helper is a thin wrapper over the standard KMS uAPI, so it works
identically on i915, xe and any other KMS driver.

Assisted-by: Claude:claude-opus-4.7
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
 core-symbols.txt |   2 +
 xf86drmMode.c    | 123 +++++++++++++++++++++++++++++++++++++++++++++++
 xf86drmMode.h    |  38 +++++++++++++++
 3 files changed, 163 insertions(+)

diff --git a/core-symbols.txt b/core-symbols.txt
index 766c342d..a14add40 100644
--- a/core-symbols.txt
+++ b/core-symbols.txt
@@ -119,6 +119,7 @@ drmModeDirtyFB
 drmModeFormatModifierBlobIterNext
 drmModeFreeConnector
 drmModeFreeCrtc
+drmModeFreeCrtcList
 drmModeFreeEncoder
 drmModeFreeFB
 drmModeFreeFB2
@@ -133,6 +134,7 @@ drmModeGetConnector
 drmModeGetConnectorCurrent
 drmModeGetConnectorTypeName
 drmModeGetCrtc
+drmModeGetCrtcList
 drmModeGetEncoder
 drmModeGetFB
 drmModeGetFB2
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 5b5d7053..224212bb 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -35,6 +35,7 @@
 #include <dirent.h>
 #include <unistd.h>
 #include <errno.h>
+#include <time.h>
 
 #define memclear(s) memset(&s, 0, sizeof(s))
 
@@ -383,6 +384,128 @@ drm_public drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
 	return r;
 }
 
+drm_public drmModeCrtcListPtr drmModeGetCrtcList(int fd)
+{
+	drmModeResPtr res;
+	drmModeCrtcListPtr list;
+	uint64_t *seq0 = NULL;
+	char *probe = NULL;
+	int need_probe = 0;
+	int i;
+
+	res = drmModeGetResources(fd);
+	if (!res)
+		return NULL;
+
+	list = drmMalloc(sizeof(*list));
+	if (!list)
+		goto err_res;
+
+	list->count = res->count_crtcs;
+	list->count_available = 0;
+
+	if (res->count_crtcs) {
+		list->crtcs = drmMalloc(res->count_crtcs * sizeof(*list->crtcs));
+		if (!list->crtcs)
+			goto err_list;
+		seq0 = drmMalloc(res->count_crtcs * sizeof(*seq0));
+		probe = drmMalloc(res->count_crtcs * sizeof(*probe));
+		if (!seq0 || !probe)
+			goto err_probe;
+	}
+
+	for (i = 0; i < res->count_crtcs; i++) {
+		drmModeCrtcInfoPtr info = &list->crtcs[i];
+		drmModeCrtcPtr crtc = drmModeGetCrtc(fd, res->crtcs[i]);
+
+		info->crtc_id = res->crtcs[i];
+		info->index = i;
+
+		if (!crtc) {
+			/* Unreadable CRTC: report as busy so callers don't grab it. */
+			info->in_use = 1;
+			continue;
+		}
+
+		info->buffer_id = crtc->buffer_id;
+		if (crtc->mode_valid) {
+			info->in_use = 1;
+			info->width = crtc->width;
+			info->height = crtc->height;
+			info->mode = crtc->mode;
+		} else {
+			/*
+			 * GETCRTC only tells us which pipes are enabled through
+			 * KMS, not which are active in hardware. A pipe can be
+			 * active (scanning out) without being enabled here, and
+			 * an active pipe keeps its vblank counter advancing.
+			 * Snapshot the vblank sequence now and re-check it below
+			 * to find such active pipes.
+			 */
+			uint64_t ns;
+
+			if (!drmCrtcGetSequence(fd, info->crtc_id, &seq0[i], &ns)) {
+				probe[i] = 1;
+				need_probe = 1;
+			}
+		}
+
+		drmModeFreeCrtc(crtc);
+	}
+
+	/*
+	 * One shared wait covers every candidate: an active pipe keeps
+	 * advancing its vblank counter, an inactive pipe does not. 50ms
+	 * crosses at least one vblank down to ~24Hz.
+	 */
+	if (need_probe) {
+		struct timespec ts = { .tv_sec = 0, .tv_nsec = 50000000 };
+
+		nanosleep(&ts, NULL);
+
+		for (i = 0; i < res->count_crtcs; i++) {
+			uint64_t seq1, ns;
+
+			if (!probe[i])
+				continue;
+			if (drmCrtcGetSequence(fd, list->crtcs[i].crtc_id,
+					       &seq1, &ns))
+				continue;
+			if (seq1 != seq0[i])
+				list->crtcs[i].driver_active = 1;
+		}
+	}
+
+	for (i = 0; i < res->count_crtcs; i++) {
+		if (!list->crtcs[i].in_use && !list->crtcs[i].driver_active)
+			list->count_available++;
+	}
+
+	drmFree(probe);
+	drmFree(seq0);
+	drmModeFreeResources(res);
+	return list;
+
+err_probe:
+	drmFree(probe);
+	drmFree(seq0);
+	drmFree(list->crtcs);
+err_list:
+	drmFree(list);
+err_res:
+	drmModeFreeResources(res);
+	return NULL;
+}
+
+drm_public void drmModeFreeCrtcList(drmModeCrtcListPtr ptr)
+{
+	if (!ptr)
+		return;
+
+	drmFree(ptr->crtcs);
+	drmFree(ptr);
+}
+
 drm_public int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
 		   uint32_t x, uint32_t y, uint32_t *connectors, int count,
 		   drmModeModeInfoPtr mode)
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 2a7156db..c634333b 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -147,6 +147,30 @@ typedef struct _drmModeCrtc {
 
 } drmModeCrtc, *drmModeCrtcPtr;
 
+/**
+ * Per-CRTC availability information, produced by drmModeGetCrtcList().
+ */
+typedef struct _drmModeCrtcInfo {
+	uint32_t crtc_id;   /**< KMS object id of the CRTC */
+	int index;          /**< Index in drmModeRes.crtcs[]; usable for vblank high-crtc bits */
+	int in_use;         /**< Non-zero if userspace has a mode set on this CRTC */
+	int driver_active;  /**< Non-zero if the CRTC is active in hardware (its
+			     *   vblank is running) even though it is not enabled
+			     *   through KMS. GETCRTC only reports enabled pipes;
+			     *   reading the vblank counter reveals active pipes,
+			     *   which must not be treated as free. */
+	uint32_t buffer_id; /**< FB currently scanned out, 0 if none */
+	uint32_t width, height; /**< Active mode resolution, 0 when not in use */
+	drmModeModeInfo mode;   /**< Active mode; valid only when in_use is set */
+} drmModeCrtcInfo, *drmModeCrtcInfoPtr;
+
+typedef struct _drmModeCrtcList {
+	int count;                /**< Total number of CRTCs on the device */
+	int count_available;      /**< CRTCs that are free and assignable (neither
+				   *   in_use nor driver_active) */
+	drmModeCrtcInfoPtr crtcs; /**< Array of 'count' CRTC entries */
+} drmModeCrtcList, *drmModeCrtcListPtr;
+
 typedef struct _drmModeEncoder {
 	uint32_t encoder_id;
 	uint32_t encoder_type;
@@ -317,6 +341,20 @@ extern int drmModeDirtyFB(int fd, uint32_t bufferId,
  */
 extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
 
+/**
+ * Enumerate every CRTC on the device and report which ones are available.
+ *
+ * Convenience wrapper around drmModeGetResources() + drmModeGetCrtc() intended
+ * for compositors that need to discover free CRTCs. The returned list must be
+ * released with drmModeFreeCrtcList(). Returns NULL on error.
+ */
+extern drmModeCrtcListPtr drmModeGetCrtcList(int fd);
+
+/**
+ * Free a list previously returned by drmModeGetCrtcList().
+ */
+extern void drmModeFreeCrtcList(drmModeCrtcListPtr ptr);
+
 /**
  * Set the mode on a crtc crtcId with the given mode modeId.
  */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage
  2026-09-21 13:07 [PATCH libdrm 0/2] Get active crtc list Arun R Murthy
  2026-09-21 13:07 ` [PATCH libdrm 1/2] xf86drmMode: add drmModeGetCrtcList() to enumerate available CRTCs Arun R Murthy
@ 2026-09-21 13:07 ` Arun R Murthy
  2026-09-21 14:07   ` Murthy, Arun R
  1 sibling, 1 reply; 6+ messages in thread
From: Arun R Murthy @ 2026-09-21 13:07 UTC (permalink / raw)
  To: dri-devel
  Cc: intel-gfx, intel-xe, Jani Nikula, Ville Syrjälä,
	ankit.k.nautiyal, adarsh.g.m, Arun R Murthy

Add a small diagnostic utility built on the new drmModeGetCrtcList()
API. It prints the total number of CRTCs, how many are free vs in use,
and a per-CRTC line with state, scanout framebuffer and active mode.

Built like the other tests/ utilities (drmdevice, modeprint); it is a
human-facing tool and is intentionally not registered as a meson test,
since correctness is covered by the drmmode_crtc_list_ult suite.

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
 tests/crtclist.c  | 116 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build |   9 ++++
 2 files changed, 125 insertions(+)
 create mode 100644 tests/crtclist.c

diff --git a/tests/crtclist.c b/tests/crtclist.c
new file mode 100644
index 00000000..7ac16853
--- /dev/null
+++ b/tests/crtclist.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2026 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/*
+ * crtclist - inspect CRTC usage on a DRM device via drmModeGetCrtcList().
+ *
+ * Prints the total number of CRTCs, how many are free vs in use, and a
+ * per-CRTC line showing state, scanout framebuffer and active mode. Useful
+ * for compositor bring-up to see which CRTCs are available.
+ *
+ * Usage: crtclist [/dev/dri/cardN]   (defaults to the first KMS node)
+ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+
+static int open_kms_node(void)
+{
+	char path[64];
+	int i;
+
+	for (i = 0; i < 16; i++) {
+		int fd;
+
+		snprintf(path, sizeof(path), "/dev/dri/card%d", i);
+		fd = open(path, O_RDWR | O_CLOEXEC);
+		if (fd < 0)
+			continue;
+		if (drmIsKMS(fd)) {
+			printf("Using %s\n", path);
+			return fd;
+		}
+		close(fd);
+	}
+	return -1;
+}
+
+int main(int argc, char **argv)
+{
+	drmModeCrtcListPtr list;
+	int fd, i;
+
+	if (argc > 1)
+		fd = open(argv[1], O_RDWR | O_CLOEXEC);
+	else
+		fd = open_kms_node();
+
+	if (fd < 0) {
+		fprintf(stderr, "No accessible KMS DRM device (try running as root).\n");
+		return 1;
+	}
+
+	list = drmModeGetCrtcList(fd);
+	if (!list) {
+		fprintf(stderr, "drmModeGetCrtcList() failed\n");
+		close(fd);
+		return 1;
+	}
+
+	printf("Total CRTCs : %d\n", list->count);
+	printf("Available   : %d\n", list->count_available);
+	printf("In use      : %d\n\n", list->count - list->count_available);
+
+	printf("%-5s %-8s %-13s %-8s %s\n",
+	       "idx", "crtc_id", "state", "fb_id", "mode");
+	printf("-------------------------------------------------------\n");
+	for (i = 0; i < list->count; i++) {
+		drmModeCrtcInfoPtr c = &list->crtcs[i];
+		const char *state;
+
+		if (c->in_use)
+			state = "IN USE";
+		else if (c->driver_active)
+			state = "ACTIVE";
+		else
+			state = "FREE";
+
+		printf("%-5d %-8u %-13s %-8u ",
+		       c->index, c->crtc_id, state, c->buffer_id);
+		if (c->in_use)
+			printf("%ux%u @ %uHz (%s)\n",
+			       c->width, c->height, c->mode.vrefresh,
+			       c->mode.name);
+		else if (c->driver_active)
+			printf("(active in hardware, not enabled via KMS)\n");
+		else
+			printf("-\n");
+	}
+
+	drmModeFreeCrtcList(list);
+	close(fd);
+	return 0;
+}
diff --git a/tests/meson.build b/tests/meson.build
index ac9e66b0..9c98bc2b 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -69,6 +69,15 @@ drmdevice = executable(
   install : with_install_tests,
 )
 
+crtclist = executable(
+  'crtclist',
+  files('crtclist.c'),
+  include_directories : [inc_root, inc_drm],
+  link_with : libdrm,
+  c_args : libdrm_c_args,
+  install : with_install_tests,
+)
+
 test('hash', hash)
 test('drmsl', drmsl)
 test('drmdevice', drmdevice)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage
  2026-09-21 13:07 ` [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage Arun R Murthy
@ 2026-09-21 14:07   ` Murthy, Arun R
  2026-09-22 14:16     ` Michel Dänzer
  0 siblings, 1 reply; 6+ messages in thread
From: Murthy, Arun R @ 2026-09-21 14:07 UTC (permalink / raw)
  To: dri-devel@lists.freedesktop.org
  Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	Jani Nikula, Ville Syrjälä, Nautiyal, Ankit K,
	G M, Adarsh


> -----Original Message-----
> From: Murthy, Arun R <arun.r.murthy@intel.com>
> Sent: Monday, September 21, 2026 6:38 PM
> To: dri-devel@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org; intel-xe@lists.freedesktop.org; Jani Nikula
> <jani.nikula@linux.intel.com>; Ville Syrjälä <ville.syrjala@linux.intel.com>;
> Nautiyal, Ankit K <ankit.k.nautiyal@intel.com>; G M, Adarsh
> <adarsh.g.m@intel.com>; Murthy, Arun R <arun.r.murthy@intel.com>
> Subject: [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage
> 
> Add a small diagnostic utility built on the new drmModeGetCrtcList() API. It
> prints the total number of CRTCs, how many are free vs in use, and a per-CRTC
> line with state, scanout framebuffer and active mode.
> 
> Built like the other tests/ utilities (drmdevice, modeprint); it is a human-facing
> tool and is intentionally not registered as a meson test, since correctness is
> covered by the drmmode_crtc_list_ult suite.
> 
ULT is removed from this patch, as this utility itself should suffice.
This paragraph will be removed in the next version.

Thanks and Regards,
Arun R Murthy
-------------------
> Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
> ---
>  tests/crtclist.c  | 116
> ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/meson.build |   9 ++++
>  2 files changed, 125 insertions(+)
>  create mode 100644 tests/crtclist.c
> 
> diff --git a/tests/crtclist.c b/tests/crtclist.c new file mode 100644 index
> 00000000..7ac16853
> --- /dev/null
> +++ b/tests/crtclist.c
> @@ -0,0 +1,116 @@
> +/*
> + * Copyright © 2026 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person
> +obtaining a copy
> + * of this software and associated documentation files (the
> +"Software"), to deal
> + * in the Software without restriction, including without limitation
> +the rights
> + * to use, copy, modify, merge, publish, distribute, sublicense, and/or
> +sell
> + * copies of the Software, and to permit persons to whom the Software
> +is
> + * furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> +included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> +EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> +MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
> EVENT
> +SHALL THE
> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
> OR
> +OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> +ARISING FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> +DEALINGS IN THE
> + * SOFTWARE.
> + */
> +
> +/*
> + * crtclist - inspect CRTC usage on a DRM device via drmModeGetCrtcList().
> + *
> + * Prints the total number of CRTCs, how many are free vs in use, and a
> + * per-CRTC line showing state, scanout framebuffer and active mode.
> +Useful
> + * for compositor bring-up to see which CRTCs are available.
> + *
> + * Usage: crtclist [/dev/dri/cardN]   (defaults to the first KMS node)
> + */
> +
> +#include <fcntl.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +
> +#include <xf86drm.h>
> +#include <xf86drmMode.h>
> +
> +static int open_kms_node(void)
> +{
> +	char path[64];
> +	int i;
> +
> +	for (i = 0; i < 16; i++) {
> +		int fd;
> +
> +		snprintf(path, sizeof(path), "/dev/dri/card%d", i);
> +		fd = open(path, O_RDWR | O_CLOEXEC);
> +		if (fd < 0)
> +			continue;
> +		if (drmIsKMS(fd)) {
> +			printf("Using %s\n", path);
> +			return fd;
> +		}
> +		close(fd);
> +	}
> +	return -1;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	drmModeCrtcListPtr list;
> +	int fd, i;
> +
> +	if (argc > 1)
> +		fd = open(argv[1], O_RDWR | O_CLOEXEC);
> +	else
> +		fd = open_kms_node();
> +
> +	if (fd < 0) {
> +		fprintf(stderr, "No accessible KMS DRM device (try running as
> root).\n");
> +		return 1;
> +	}
> +
> +	list = drmModeGetCrtcList(fd);
> +	if (!list) {
> +		fprintf(stderr, "drmModeGetCrtcList() failed\n");
> +		close(fd);
> +		return 1;
> +	}
> +
> +	printf("Total CRTCs : %d\n", list->count);
> +	printf("Available   : %d\n", list->count_available);
> +	printf("In use      : %d\n\n", list->count - list->count_available);
> +
> +	printf("%-5s %-8s %-13s %-8s %s\n",
> +	       "idx", "crtc_id", "state", "fb_id", "mode");
> +	printf("-------------------------------------------------------\n");
> +	for (i = 0; i < list->count; i++) {
> +		drmModeCrtcInfoPtr c = &list->crtcs[i];
> +		const char *state;
> +
> +		if (c->in_use)
> +			state = "IN USE";
> +		else if (c->driver_active)
> +			state = "ACTIVE";
> +		else
> +			state = "FREE";
> +
> +		printf("%-5d %-8u %-13s %-8u ",
> +		       c->index, c->crtc_id, state, c->buffer_id);
> +		if (c->in_use)
> +			printf("%ux%u @ %uHz (%s)\n",
> +			       c->width, c->height, c->mode.vrefresh,
> +			       c->mode.name);
> +		else if (c->driver_active)
> +			printf("(active in hardware, not enabled via KMS)\n");
> +		else
> +			printf("-\n");
> +	}
> +
> +	drmModeFreeCrtcList(list);
> +	close(fd);
> +	return 0;
> +}
> diff --git a/tests/meson.build b/tests/meson.build index ac9e66b0..9c98bc2b
> 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -69,6 +69,15 @@ drmdevice = executable(
>    install : with_install_tests,
>  )
> 
> +crtclist = executable(
> +  'crtclist',
> +  files('crtclist.c'),
> +  include_directories : [inc_root, inc_drm],
> +  link_with : libdrm,
> +  c_args : libdrm_c_args,
> +  install : with_install_tests,
> +)
> +
>  test('hash', hash)
>  test('drmsl', drmsl)
>  test('drmdevice', drmdevice)
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage
  2026-09-21 14:07   ` Murthy, Arun R
@ 2026-09-22 14:16     ` Michel Dänzer
  2026-09-23  4:22       ` Murthy, Arun R
  0 siblings, 1 reply; 6+ messages in thread
From: Michel Dänzer @ 2026-09-22 14:16 UTC (permalink / raw)
  To: Murthy, Arun R
  Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	Jani Nikula, Ville Syrjälä, Nautiyal, Ankit K,
	G M, Adarsh, dri-devel@lists.freedesktop.org

On 9/21/26 16:07, Murthy, Arun R wrote:
>> From: Murthy, Arun R <arun.r.murthy@intel.com>
>>
>> Add a small diagnostic utility built on the new drmModeGetCrtcList() API. It
>> prints the total number of CRTCs, how many are free vs in use, and a per-CRTC
>> line with state, scanout framebuffer and active mode.
>>
>> Built like the other tests/ utilities (drmdevice, modeprint); it is a human-facing
>> tool and is intentionally not registered as a meson test, since correctness is
>> covered by the drmmode_crtc_list_ult suite.
>>
> ULT is removed from this patch, as this utility itself should suffice.
> This paragraph will be removed in the next version.

Note that we use gitlab MRs for libdrm: https://gitlab.freedesktop.org/mesa/libdrm/-/merge_requests


-- 
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage
  2026-09-22 14:16     ` Michel Dänzer
@ 2026-09-23  4:22       ` Murthy, Arun R
  0 siblings, 0 replies; 6+ messages in thread
From: Murthy, Arun R @ 2026-09-23  4:22 UTC (permalink / raw)
  To: Michel Dänzer
  Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
	Jani Nikula, Ville Syrjälä, Nautiyal, Ankit K,
	G M, Adarsh, dri-devel@lists.freedesktop.org

> -----Original Message-----
> From: Michel Dänzer <michel.daenzer@mailbox.org>
> Sent: Tuesday, September 22, 2026 7:47 PM
> To: Murthy, Arun R <arun.r.murthy@intel.com>
> Cc: intel-gfx@lists.freedesktop.org; intel-xe@lists.freedesktop.org; Jani Nikula
> <jani.nikula@linux.intel.com>; Ville Syrjälä <ville.syrjala@linux.intel.com>;
> Nautiyal, Ankit K <ankit.k.nautiyal@intel.com>; G M, Adarsh
> <adarsh.g.m@intel.com>; dri-devel@lists.freedesktop.org
> Subject: Re: [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage
> 
> On 9/21/26 16:07, Murthy, Arun R wrote:
> >> From: Murthy, Arun R <arun.r.murthy@intel.com>
> >>
> >> Add a small diagnostic utility built on the new drmModeGetCrtcList()
> >> API. It prints the total number of CRTCs, how many are free vs in
> >> use, and a per-CRTC line with state, scanout framebuffer and active mode.
> >>
> >> Built like the other tests/ utilities (drmdevice, modeprint); it is a
> >> human-facing tool and is intentionally not registered as a meson
> >> test, since correctness is covered by the drmmode_crtc_list_ult suite.
> >>
> > ULT is removed from this patch, as this utility itself should suffice.
> > This paragraph will be removed in the next version.
> 
> Note that we use gitlab MRs for libdrm:
> https://gitlab.freedesktop.org/mesa/libdrm/-/merge_requests
> 
> 
Noted!
Created MR - https://gitlab.freedesktop.org/mesa/libdrm/-/merge_requests/490

Thanks and Regards,
Arun R Murthy
--------------------
> --
> Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
> https://redhat.com             \               Libre software enthusiast

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-09-23  4:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-21 13:07 [PATCH libdrm 0/2] Get active crtc list Arun R Murthy
2026-09-21 13:07 ` [PATCH libdrm 1/2] xf86drmMode: add drmModeGetCrtcList() to enumerate available CRTCs Arun R Murthy
2026-09-21 13:07 ` [PATCH libdrm 2/2] tests/crtclist: add utility to inspect CRTC usage Arun R Murthy
2026-09-21 14:07   ` Murthy, Arun R
2026-09-22 14:16     ` Michel Dänzer
2026-09-23  4:22       ` Murthy, Arun R

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox