Skip to contentSkip to conversation

Random assortment of fixes and enhancements

PATCH In review Thierry Reding 3 participants 29 messages Jan 23, 2015 – Jan 29, 2015

lore
Share & tools
lore
#0 lore raw

cover Random assortment of fixes and enhancements

From: Thierry Reding <[email protected]>

This is a stash of commits that I've been carrying for a couple months. Laurent really wanted to have the connector name patch for modetest so I thought I'd send them all out for review.

Thierry

Thierry Reding (11):
libdrm: valgrind-clear a few more IOCTL arguments
libdrm: Remove gratuitous blank lines
libdrm: Make indentation consistent
tests: Split helpers into library
tests: Move name tables to libutil xf86drmMode.h: Use consistent padding xf86drmMode.h: Add DisplayPort MST encoder type
tests: modetest: Accept connector names
tests: Add libkms-test library
tests: kms: Implement CRTC stealing test
tests: kms: Implement universal planes test

 configure.ac                        |   2 +
 tests/Makefile.am                   |   2 +-
 tests/kms/Makefile.am               |  35 ++
 tests/kms/kms-steal-crtc.c          | 161 ++++++
 tests/kms/kms-universal-planes.c    | 358 ++++++++++++++
 tests/kms/libkms-test-crtc.c        |  47 ++
 tests/kms/libkms-test-device.c      | 218 ++++++++
 tests/kms/libkms-test-framebuffer.c | 157 ++++++
 tests/kms/libkms-test-plane.c       | 139 ++++++
 tests/kms/libkms-test-screen.c      |  92 ++++
 tests/kms/libkms-test.h             | 120 +++++
 tests/modeprint/Makefile.am         |   1 +
 tests/modeprint/modeprint.c         |   2 +-
 tests/modetest/Makefile.am          |   2 +
 tests/modetest/buffers.c            | 956 +-----------------------------------
 tests/modetest/buffers.h            |  12 +-
 tests/modetest/cursor.c             |   4 +-
 tests/modetest/modetest.c           | 207 +++++---
 tests/proptest/Makefile.am          |   4 +-
 tests/proptest/proptest.c           |  43 +-
 tests/util/Makefile.am              |  21 +
 tests/util/common.h                 |  33 ++
 tests/util/format.c                 | 119 +++++
 tests/util/format.h                 |  65 +++
 tests/util/kms.c                    | 122 +++++
 tests/util/kms.h                    |  33 ++
 tests/util/pattern.c                | 870 ++++++++++++++++++++++++++++++++
 tests/util/pattern.h                |  39 ++
 tests/vbltest/Makefile.am           |   1 +
 tests/vbltest/vbltest.c             |   2 +-
 xf86drmMode.c                       |  17 +-
 xf86drmMode.h                       |  17 +-
 32 files changed, 2805 insertions(+), 1096 deletions(-)
 create mode 100644 tests/kms/Makefile.am
 create mode 100644 tests/kms/kms-steal-crtc.c
 create mode 100644 tests/kms/kms-universal-planes.c
 create mode 100644 tests/kms/libkms-test-crtc.c
 create mode 100644 tests/kms/libkms-test-device.c
 create mode 100644 tests/kms/libkms-test-framebuffer.c
 create mode 100644 tests/kms/libkms-test-plane.c
 create mode 100644 tests/kms/libkms-test-screen.c
 create mode 100644 tests/kms/libkms-test.h
 create mode 100644 tests/util/Makefile.am
 create mode 100644 tests/util/common.h
 create mode 100644 tests/util/format.c
 create mode 100644 tests/util/format.h
 create mode 100644 tests/util/kms.c
 create mode 100644 tests/util/kms.h
 create mode 100644 tests/util/pattern.c
 create mode 100644 tests/util/pattern.h
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 1/11 libdrm: valgrind-clear a few more IOCTL arguments

From: Thierry Reding <[email protected]>

Fixes a few complaints raised by valgrind when running the Tegra tests.

---
 xf86drmMode.c | 2 ++
 1 file changed, 2 insertions(+)
xf86drmMode.c +2 -0
index 60ce3699f3e3..f6e4416b88b5 100644
@@ -282,6 +282,7 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
 	struct drm_mode_fb_cmd2 f;
 	int ret;
 
+	VG_CLEAR(f);
 	f.width  = width;
 	f.height = height;
 	f.pixel_format = pixel_format;
@@ -309,6 +310,7 @@ drmModeFBPtr drmModeGetFB(int fd, uint32_t buf)
 	struct drm_mode_fb_cmd info;
 	drmModeFBPtr r;
 
+	VG_CLEAR(info);
 	info.fb_id = buf;
 
 	if (drmIoctl(fd, DRM_IOCTL_MODE_GETFB, &info))
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 2/11 libdrm: Remove gratuitous blank lines

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Usage of blank lines can be a matter of taste, of course, but for these we can surely all agree that they're not needed and inconsistent.

---
 xf86drmMode.c | 11 -----------
 1 file changed, 11 deletions(-)
xf86drmMode.c +0 -11
index f6e4416b88b5..7e228b3e7aa3 100644
@@ -115,7 +115,6 @@ void drmModeFreeResources(drmModeResPtr ptr)
 	drmFree(ptr->connectors);
 	drmFree(ptr->encoders);
 	drmFree(ptr);
-
 }
 
 void drmModeFreeFB(drmModeFBPtr ptr)
@@ -133,7 +132,6 @@ void drmModeFreeCrtc(drmModeCrtcPtr ptr)
 		return;
 
 	drmFree(ptr);
-
 }
 
 void drmModeFreeConnector(drmModeConnectorPtr ptr)
@@ -146,7 +144,6 @@ void drmModeFreeConnector(drmModeConnectorPtr ptr)
 	drmFree(ptr->props);
 	drmFree(ptr->modes);
 	drmFree(ptr);
-
 }
 
 void drmModeFreeEncoder(drmModeEncoderPtr ptr)
@@ -301,8 +298,6 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t height,
 int drmModeRmFB(int fd, uint32_t bufferId)
 {
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
-
-
 }
 
 drmModeFBPtr drmModeGetFB(int fd, uint32_t buf)
@@ -342,7 +337,6 @@ int drmModeDirtyFB(int fd, uint32_t bufferId,
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty);
 }
 
-
 /*
  * Crtc functions
  */
@@ -379,7 +373,6 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
 	return r;
 }
 
-
 int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
                    uint32_t x, uint32_t y, uint32_t *connectors, int count,
 		   drmModeModeInfoPtr mode)
@@ -594,7 +587,6 @@ int drmModeDetachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_inf
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_DETACHMODE, &res);
 }
 
-
 drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
 {
 	struct drm_mode_get_property prop;
@@ -812,7 +804,6 @@ int drmCheckModesettingSupported(const char *busid)
 	return 0;
 #endif
 	return -ENOSYS;
-
 }
 
 int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
@@ -914,7 +905,6 @@ int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
 		    uint32_t crtc_w, uint32_t crtc_h,
 		    uint32_t src_x, uint32_t src_y,
 		    uint32_t src_w, uint32_t src_h)
-
 {
 	struct drm_mode_set_plane s;
 
@@ -934,7 +924,6 @@ int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETPLANE, &s);
 }
 
-
 drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id)
 {
 	struct drm_mode_get_plane ovr, counts;
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

PATCH 3/11 libdrm: Make indentation consistent

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

---
 xf86drmMode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xf86drmMode.c +2 -2
index 7e228b3e7aa3..3d6b9cc307d1 100644
@@ -250,7 +250,7 @@ err_allocs:
 }
 
 int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
-                 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
+		 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
 		 uint32_t *buf_id)
 {
 	struct drm_mode_fb_cmd f;
@@ -374,7 +374,7 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
 }
 
 int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
-                   uint32_t x, uint32_t y, uint32_t *connectors, int count,
+		   uint32_t x, uint32_t y, uint32_t *connectors, int count,
 		   drmModeModeInfoPtr mode)
 {
 	struct drm_mode_crtc crtc;
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

PATCH 4/11 tests: Split helpers into library

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Some of the helpers, such as the pattern drawing helpers or the format lookup helpers, have potential to be reused. Move them into a separate library to make it easier to share them.

---
 configure.ac                |   1 +
 tests/Makefile.am           |   2 +-
 tests/modeprint/Makefile.am |   1 +
 tests/modeprint/modeprint.c |   2 +-
 tests/modetest/Makefile.am  |   2 +
 tests/modetest/buffers.c    | 956 +-------------------------------------------
 tests/modetest/buffers.h    |  12 +-
 tests/modetest/cursor.c     |   4 +-
 tests/modetest/modetest.c   |  25 +-
 tests/proptest/proptest.c   |   3 +-
 tests/util/Makefile.am      |  19 +
 tests/util/common.h         |  33 ++
 tests/util/format.c         | 119 ++++++
 tests/util/format.h         |  65 +++
 tests/util/pattern.c        | 870 ++++++++++++++++++++++++++++++++++++++++
 tests/util/pattern.h        |  39 ++
 tests/vbltest/Makefile.am   |   1 +
 tests/vbltest/vbltest.c     |   2 +-
 18 files changed, 1177 insertions(+), 979 deletions(-)
 create mode 100644 tests/util/Makefile.am
 create mode 100644 tests/util/common.h
 create mode 100644 tests/util/format.c
 create mode 100644 tests/util/format.h
 create mode 100644 tests/util/pattern.c
 create mode 100644 tests/util/pattern.h
configure.ac +1 -0
index 8afee834508d..58411b79b682 100644
@@ -441,6 +441,7 @@ AC_CONFIG_FILES([
 	tests/vbltest/Makefile
 	tests/exynos/Makefile
 	tests/tegra/Makefile
+	tests/util/Makefile
 	man/Makefile
 	libdrm.pc])
 AC_OUTPUT
tests/Makefile.am +1 -1
index e7ec4fa5ecff..310032732f6e 100644
@@ -10,7 +10,7 @@ check_PROGRAMS = \
 	dristat \
 	drmstat
 
-SUBDIRS = modeprint proptest
+SUBDIRS = util modeprint proptest
 
 if HAVE_LIBKMS
 SUBDIRS += kmstest modetest
tests/modeprint/Makefile.am +1 -0
index 6420ef336705..32a702ab0bdc 100644
@@ -1,5 +1,6 @@
 AM_CFLAGS = \
 	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)/tests \
 	-I$(top_srcdir)
 
 if HAVE_INSTALL_TESTS
tests/modeprint/modeprint.c +1 -1
index 6f0d03905a46..8f9471023b52 100644
@@ -41,7 +41,7 @@
 #include "xf86drm.h"
 #include "xf86drmMode.h"
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+#include "util/common.h"
 
 int connectors;
 int full_props;
tests/modetest/Makefile.am +2 -0
index 93820fac7395..88fde2eb8345 100644
@@ -4,6 +4,7 @@ AM_CFLAGS = $(filter-out -Wpointer-arith, $(WARN_CFLAGS))
 
 AM_CFLAGS += \
 	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)/tests \
 	-I$(top_srcdir)
 
 if HAVE_INSTALL_TESTS
@@ -18,6 +19,7 @@ modetest_SOURCES = $(MODETEST_FILES)
 
 modetest_LDADD = \
 	$(top_builddir)/libdrm.la \
+	$(top_builddir)/tests/util/libutil.la \
 	-lpthread
 
 if HAVE_CAIRO
tests/modetest/buffers.c +2 -954

980 lines not on this page · raw message

tests/modetest/buffers.h +3 -9
index ad73d0e4ba73..7f95396b4403 100644
@@ -27,20 +27,14 @@
 #ifndef __BUFFERS_H__
 #define __BUFFERS_H__
 
-struct bo;
+#include "util/pattern.h"
 
-enum fill_pattern {
-	PATTERN_TILES = 0,
-	PATTERN_PLAIN = 1,
-	PATTERN_SMPTE = 2,
-};
+struct bo;
 
 struct bo *bo_create(int fd, unsigned int format,
 		   unsigned int width, unsigned int height,
 		   unsigned int handles[4], unsigned int pitches[4],
-		   unsigned int offsets[4], enum fill_pattern pattern);
+		   unsigned int offsets[4], enum util_fill_pattern pattern);
 void bo_destroy(struct bo *bo);
 
-unsigned int format_fourcc(const char *name);
-
 #endif
tests/modetest/cursor.c +2 -2
index 62a50efb36e6..187054fe9556 100644
@@ -40,11 +40,11 @@
 #include "xf86drm.h"
 #include "xf86drmMode.h"
 
+#include "util/common.h"
+
 #include "buffers.h"
 #include "cursor.h"
 
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
 struct cursor {
 	int fd;
 	uint32_t bo_handle;
tests/modetest/modetest.c +15 -10
index 4b9cf2f5b439..b610956adfcb 100644
@@ -37,6 +37,7 @@
  * TODO: use cairo to write the mode info on the selected output once
  *       the mode has been programmed, along with possible test patterns.
  */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -58,6 +59,10 @@
 #include "xf86drmMode.h"
 #include "drm_fourcc.h"
 
+#include "util/common.h"
+#include "util/format.h"
+#include "util/pattern.h"
+
 #include "buffers.h"
 #include "cursor.h"
 
@@ -113,7 +118,6 @@ struct device {
 	} mode;
 };
 
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 static inline int64_t U642I64(uint64_t val)
 {
 	return (int64_t)*((int64_t *)&val);
@@ -1008,7 +1012,7 @@ static int set_plane(struct device *dev, struct plane_arg *p)
 		p->w, p->h, p->format_str, plane_id);
 
 	plane_bo = bo_create(dev->fd, p->fourcc, p->w, p->h, handles,
-			     pitches, offsets, PATTERN_TILES);
+			     pitches, offsets, UTIL_PATTERN_TILES);
 	if (plane_bo == NULL)
 		return -1;
 
@@ -1068,8 +1072,9 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
 			dev->mode.height = pipe->mode->vdisplay;
 	}
 
-	bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width, dev->mode.height,
-		       handles, pitches, offsets, PATTERN_SMPTE);
+	bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width,
+		       dev->mode.height, handles, pitches, offsets,
+		       UTIL_PATTERN_SMPTE);
 	if (bo == NULL)
 		return;
 
@@ -1138,7 +1143,7 @@ static void set_cursors(struct device *dev, struct pipe_arg *pipes, unsigned int
 	 * translucent alpha
 	 */
 	bo = bo_create(dev->fd, DRM_FORMAT_ARGB8888, cw, ch, handles, pitches,
-		       offsets, PATTERN_PLAIN);
+		       offsets, UTIL_PATTERN_PLAIN);
 	if (bo == NULL)
 		return;
 
@@ -1172,9 +1177,9 @@ static void test_page_flip(struct device *dev, struct pipe_arg *pipes, unsigned
 	unsigned int i;
 	int ret;
 
-	other_bo = bo_create(dev->fd, pipes[0].fourcc,
-			     dev->mode.width, dev->mode.height,
-			     handles, pitches, offsets, PATTERN_PLAIN);
+	other_bo = bo_create(dev->fd, pipes[0].fourcc, dev->mode.width,
+			     dev->mode.height, handles, pitches, offsets,
+			     UTIL_PATTERN_PLAIN);
 	if (other_bo == NULL)
 		return;
 
@@ -1314,7 +1319,7 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg)
 		pipe->format_str[4] = '\0';
 	}
 
-	pipe->fourcc = format_fourcc(pipe->format_str);
+	pipe->fourcc = util_format_fourcc(pipe->format_str);
 	if (pipe->fourcc == 0)  {
 		fprintf(stderr, "unknown format %s\n", pipe->format_str);
 		return -1;
@@ -1369,7 +1374,7 @@ static int parse_plane(struct plane_arg *plane, const char *p)
 		strcpy(plane->format_str, "XR24");
 	}
 
-	plane->fourcc = format_fourcc(plane->format_str);
+	plane->fourcc = util_format_fourcc(plane->format_str);
 	if (plane->fourcc == 0) {
 		fprintf(stderr, "unknown format %s\n", plane->format_str);
 		return -EINVAL;
tests/proptest/proptest.c +2 -1
index 7618f63d2018..ee3fa408a310 100644
@@ -35,7 +35,8 @@
 #include "xf86drm.h"
 #include "xf86drmMode.h"
 
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#include "util/common.h"
+
 static inline int64_t U642I64(uint64_t val)
 {
 	return (int64_t)*((int64_t *)&val);
tests/util/Makefile.am new file +19 -0
new file mode 100644
index 000000000000..1a2519fbea89
@@ -0,0 +1,19 @@
+noinst_LTLIBRARIES = \
+	libutil.la
+
+libutil_la_CPPFLAGS = \
+	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)
+
+libutil_la_CFLAGS = \
+	$(CAIRO_CFLAGS)
+
+libutil_la_SOURCES = \
+	common.h \
+	format.c \
+	format.h \
+	pattern.c \
+	pattern.h
+
+libutil_la_LIBADD = \
+	$(CAIRO_LIBS)
tests/util/common.h new file +33 -0
new file mode 100644
index 000000000000..5d572c2dd003
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Tungsten Graphics
+ *   Jakob Bornecrantz <[email protected]>
+ * Copyright 2008 Intel Corporation
+ *   Jesse Barnes <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef UTIL_COMMON_H
+#define UTIL_COMMON_H
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
+#endif /* UTIL_COMMON_H */
tests/util/format.c new file +119 -0

119 lines not on this page · raw message

tests/util/format.h new file +65 -0

65 lines not on this page · raw message

tests/util/pattern.c new file +870 -0

870 lines not on this page · raw message

tests/util/pattern.h new file +39 -0
new file mode 100644
index 000000000000..d5c4260cc6ed
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 Tungsten Graphics
+ *   Jakob Bornecrantz <[email protected]>
+ * Copyright 2008 Intel Corporation
+ *   Jesse Barnes <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef UTIL_PATTERN_H
+#define UTIL_PATTERN_H
+
+enum util_fill_pattern {
+	UTIL_PATTERN_TILES,
+	UTIL_PATTERN_PLAIN,
+	UTIL_PATTERN_SMPTE,
+};
+
+void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern,
+		       void *planes[3], unsigned int width,
+		       unsigned int height, unsigned int stride);
+
+#endif /* UTIL_PATTERN_H */
tests/vbltest/Makefile.am +1 -0
index 34a35e7d17dc..c014ea8c7253 100644
@@ -1,5 +1,6 @@
 AM_CFLAGS = \
 	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)/tests \
 	-I$(top_srcdir)
 if HAVE_INSTALL_TESTS
 bin_PROGRAMS = \
tests/vbltest/vbltest.c +1 -1
index cdc1ef6b3364..7e5e0962deaf 100644
@@ -54,7 +54,7 @@
 #include "xf86drm.h"
 #include "xf86drmMode.h"
 
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#include "util/common.h"
 
 extern char *optarg;
 extern int optind, opterr, optopt;
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH 5/11 tests: Move name tables to libutil

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

These tables are duplicated in several places, so move them into libutil so that they can be shared.

---
 tests/modetest/modetest.c  |  50 ++-----------------
 tests/proptest/Makefile.am |   4 +-
 tests/proptest/proptest.c  |  40 +--------------
 tests/util/Makefile.am     |   2 +
 tests/util/kms.c           | 122 +++++++++++++++++++++++++++++++++++++++++++++
 tests/util/kms.h           |  33 ++++++++++++
 6 files changed, 165 insertions(+), 86 deletions(-)
 create mode 100644 tests/util/kms.c
 create mode 100644 tests/util/kms.h
tests/modetest/modetest.c +4 -46
index b610956adfcb..d5fd99ebe1fd 100644
@@ -61,6 +61,7 @@
 
 #include "util/common.h"
 #include "util/format.h"
+#include "util/kms.h"
 #include "util/pattern.h"
 
 #include "buffers.h"
@@ -123,11 +124,6 @@ static inline int64_t U642I64(uint64_t val)
 	return (int64_t)*((int64_t *)&val);
 }
 
-struct type_name {
-	int type;
-	const char *name;
-};
-
 #define type_name_fn(res) \
 const char * res##_str(int type) {			\
 	unsigned int i;					\
@@ -138,44 +134,6 @@ const char * res##_str(int type) {			\
 	return "(invalid)";				\
 }
 
-struct type_name encoder_type_names[] = {
-	{ DRM_MODE_ENCODER_NONE, "none" },
-	{ DRM_MODE_ENCODER_DAC, "DAC" },
-	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
-	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
-	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
-};
-
-static type_name_fn(encoder_type)
-
-struct type_name connector_status_names[] = {
-	{ DRM_MODE_CONNECTED, "connected" },
-	{ DRM_MODE_DISCONNECTED, "disconnected" },
-	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
-};
-
-static type_name_fn(connector_status)
-
-struct type_name connector_type_names[] = {
-	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
-	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
-	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
-	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
-	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
-	{ DRM_MODE_CONNECTOR_Composite, "composite" },
-	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
-	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
-	{ DRM_MODE_CONNECTOR_Component, "component" },
-	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
-	{ DRM_MODE_CONNECTOR_DisplayPort, "DP" },
-	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
-	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
-	{ DRM_MODE_CONNECTOR_TV, "TV" },
-	{ DRM_MODE_CONNECTOR_eDP, "eDP" },
-};
-
-static type_name_fn(connector_type)
-
 #define bit_name_fn(res)					\
 const char * res##_str(int type) {				\
 	unsigned int i;						\
@@ -235,7 +193,7 @@ static void dump_encoders(struct device *dev)
 		printf("%d\t%d\t%s\t0x%08x\t0x%08x\n",
 		       encoder->encoder_id,
 		       encoder->crtc_id,
-		       encoder_type_str(encoder->encoder_type),
+		       util_lookup_encoder_type_name(encoder->encoder_type),
 		       encoder->possible_crtcs,
 		       encoder->possible_clones);
 	}
@@ -379,8 +337,8 @@ static void dump_connectors(struct device *dev)
 		printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\t",
 		       connector->connector_id,
 		       connector->encoder_id,
-		       connector_status_str(connector->connection),
-		       connector_type_str(connector->connector_type),
+		       util_lookup_connector_status_name(connector->connection),
+		       util_lookup_connector_type_name(connector->connector_type),
 		       connector->mmWidth, connector->mmHeight,
 		       connector->count_modes);
 
tests/proptest/Makefile.am +3 -1
index f81a3c00846b..c615489b9a92 100644
@@ -1,5 +1,6 @@
 AM_CFLAGS = \
 	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)/tests \
 	-I$(top_srcdir)
 
 noinst_PROGRAMS = \
@@ -8,4 +9,5 @@ noinst_PROGRAMS = \
 proptest_SOURCES = \
 	proptest.c
 proptest_LDADD = \
-	$(top_builddir)/libdrm.la
+	$(top_builddir)/libdrm.la \
+	$(top_builddir)/tests/util/libutil.la
tests/proptest/proptest.c +1 -39
index ee3fa408a310..b442d583d528 100644
@@ -45,44 +45,6 @@ static inline int64_t U642I64(uint64_t val)
 int fd;
 drmModeResPtr res = NULL;
 
-const char *connector_type_str(uint32_t type)
-{
-	switch (type) {
-	case DRM_MODE_CONNECTOR_Unknown:
-		return "Unknown";
-	case DRM_MODE_CONNECTOR_VGA:
-		return "VGA";
-	case DRM_MODE_CONNECTOR_DVII:
-		return "DVI-I";
-	case DRM_MODE_CONNECTOR_DVID:
-		return "DVI-D";
-	case DRM_MODE_CONNECTOR_DVIA:
-		return "DVI-A";
-	case DRM_MODE_CONNECTOR_Composite:
-		return "Composite";
-	case DRM_MODE_CONNECTOR_SVIDEO:
-		return "SVIDEO";
-	case DRM_MODE_CONNECTOR_LVDS:
-		return "LVDS";
-	case DRM_MODE_CONNECTOR_Component:
-		return "Component";
-	case DRM_MODE_CONNECTOR_9PinDIN:
-		return "9PinDin";
-	case DRM_MODE_CONNECTOR_DisplayPort:
-		return "DisplayPort";
-	case DRM_MODE_CONNECTOR_HDMIA:
-		return "HDMI-A";
-	case DRM_MODE_CONNECTOR_HDMIB:
-		return "HDMI-B";
-	case DRM_MODE_CONNECTOR_TV:
-		return "TV";
-	case DRM_MODE_CONNECTOR_eDP:
-		return "eDP";
-	default:
-		return "Invalid";
-	}
-}
-
 /* dump_blob and dump_prop shamelessly copied from ../modetest/modetest.c */
 static void
 dump_blob(uint32_t blob_id)
@@ -226,7 +188,7 @@ static void listConnectorProperties(void)
 		}
 
 		printf("Connector %u (%s-%u)\n", c->connector_id,
-		       connector_type_str(c->connector_type),
+		       util_lookup_connector_type_name(c->connector_type),
 		       c->connector_type_id);
 
 		listObjectProperties(c->connector_id,
tests/util/Makefile.am +2 -0
index 1a2519fbea89..c00574484867 100644
@@ -12,6 +12,8 @@ libutil_la_SOURCES = \
 	common.h \
 	format.c \
 	format.h \
+	kms.c \
+	kms.h \
 	pattern.c \
 	pattern.h
 
tests/util/kms.c new file +122 -0

122 lines not on this page · raw message

tests/util/kms.h new file +33 -0
new file mode 100644
index 000000000000..fa9ab69983ac
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Tungsten Graphics
+ *   Jakob Bornecrantz <[email protected]>
+ * Copyright 2008 Intel Corporation
+ *   Jesse Barnes <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef UTIL_KMS_H
+#define UTIL_KMS_H
+
+const char *util_lookup_encoder_type_name(unsigned int type);
+const char *util_lookup_connector_status_name(unsigned int type);
+const char *util_lookup_connector_type_name(unsigned int type);
+
+#endif /* UTIL_KMS_H */
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw

PATCH 6/11 xf86drmMode.h: Use consistent padding

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

---
 xf86drmMode.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
xf86drmMode.h +8 -8
index 856a6bb0f569..e70c16d437f4 100644
@@ -123,13 +123,13 @@ extern "C" {
 #define DRM_MODE_DITHERING_OFF  0
 #define DRM_MODE_DITHERING_ON   1
 
-#define DRM_MODE_ENCODER_NONE   0
-#define DRM_MODE_ENCODER_DAC    1
-#define DRM_MODE_ENCODER_TMDS   2
-#define DRM_MODE_ENCODER_LVDS   3
-#define DRM_MODE_ENCODER_TVDAC  4
+#define DRM_MODE_ENCODER_NONE    0
+#define DRM_MODE_ENCODER_DAC     1
+#define DRM_MODE_ENCODER_TMDS    2
+#define DRM_MODE_ENCODER_LVDS    3
+#define DRM_MODE_ENCODER_TVDAC   4
 #define DRM_MODE_ENCODER_VIRTUAL 5
-#define DRM_MODE_ENCODER_DSI	6
+#define DRM_MODE_ENCODER_DSI     6
 
 #define DRM_MODE_SUBCONNECTOR_Automatic 0
 #define DRM_MODE_SUBCONNECTOR_Unknown   0
@@ -153,8 +153,8 @@ extern "C" {
 #define DRM_MODE_CONNECTOR_DisplayPort  10
 #define DRM_MODE_CONNECTOR_HDMIA        11
 #define DRM_MODE_CONNECTOR_HDMIB        12
-#define DRM_MODE_CONNECTOR_TV		13
-#define DRM_MODE_CONNECTOR_eDP		14
+#define DRM_MODE_CONNECTOR_TV           13
+#define DRM_MODE_CONNECTOR_eDP          14
 #define DRM_MODE_CONNECTOR_VIRTUAL      15
 #define DRM_MODE_CONNECTOR_DSI          16
 
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

PATCH 7/11 xf86drmMode.h: Add DisplayPort MST encoder type

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

This brings xf86drmMode.h in sync with include/drm/drm_mode.h. Eventually we really should only have a single set of definitions rather than duplicating this in two files.

---
 xf86drmMode.h | 1 +
 1 file changed, 1 insertion(+)
xf86drmMode.h +1 -0
index e70c16d437f4..70f14a1ae506 100644
@@ -130,6 +130,7 @@ extern "C" {
 #define DRM_MODE_ENCODER_TVDAC   4
 #define DRM_MODE_ENCODER_VIRTUAL 5
 #define DRM_MODE_ENCODER_DSI     6
+#define DRM_MODE_ENCODER_DPMST   7
 
 #define DRM_MODE_SUBCONNECTOR_Automatic 0
 #define DRM_MODE_SUBCONNECTOR_Unknown   0
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#18 lore raw

PATCH 8/11 tests: modetest: Accept connector names

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

Allow connector names to be used in the specification of the -s option. This requires storing the string passed on the command-line so that it can later be resolved to a connector ID (after the DRM device has been opened).

---
 tests/modetest/modetest.c | 134 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 123 insertions(+), 11 deletions(-)
tests/modetest/modetest.c +123 -11
index d5fd99ebe1fd..a7cc94f8938c 100644
@@ -82,6 +82,7 @@ struct connector {
 	drmModeConnector *connector;
 	drmModeObjectProperties *props;
 	drmModePropertyRes **props_info;
+	char *name;
 };
 
 struct fb {
@@ -327,7 +328,7 @@ static void dump_connectors(struct device *dev)
 	int i, j;
 
 	printf("Connectors:\n");
-	printf("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\tencoders\n");
+	printf("id\tencoder\tstatus\t\tname\t\tsize (mm)\tmodes\tencoders\n");
 	for (i = 0; i < dev->resources->res->count_connectors; i++) {
 		struct connector *_connector = &dev->resources->connectors[i];
 		drmModeConnector *connector = _connector->connector;
@@ -338,7 +339,7 @@ static void dump_connectors(struct device *dev)
 		       connector->connector_id,
 		       connector->encoder_id,
 		       util_lookup_connector_status_name(connector->connection),
-		       util_lookup_connector_type_name(connector->connector_type),
+		       _connector->name,
 		       connector->mmWidth, connector->mmHeight,
 		       connector->count_modes);
 
@@ -464,12 +465,13 @@ static void dump_planes(struct device *dev)
 
 static void free_resources(struct resources *res)
 {
+	int i;
+
 	if (!res)
 		return;
 
 #define free_resource(_res, __res, type, Type)					\
 	do {									\
-		int i;								\
 		if (!(_res)->type##s)						\
 			break;							\
 		for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) {	\
@@ -482,7 +484,6 @@ static void free_resources(struct resources *res)
 
 #define free_properties(_res, __res, type)					\
 	do {									\
-		int i;								\
 		for (i = 0; i < (int)(_res)->__res->count_##type##s; ++i) {	\
 			drmModeFreeObjectProperties(res->type##s[i].props);	\
 			free(res->type##s[i].props_info);			\
@@ -494,6 +495,10 @@ static void free_resources(struct resources *res)
 
 		free_resource(res, res, crtc, Crtc);
 		free_resource(res, res, encoder, Encoder);
+
+		for (i = 0; i < res->res->count_connectors; i++)
+			free(res->connectors[i].name);
+
 		free_resource(res, res, connector, Connector);
 		free_resource(res, res, fb, FB);
 
@@ -511,6 +516,47 @@ static void free_resources(struct resources *res)
 	free(res);
 }
 
+static unsigned int get_connector_index(struct resources *res, uint32_t type)
+{
+	unsigned int index = 0;
+	int i;
+
+	for (i = 0; i < res->res->count_connectors; i++)
+		if (res->connectors[i].connector->connector_type == type)
+			index++;
+
+	return index - 1;
+}
+
+static unsigned int get_order(unsigned int value)
+{
+	unsigned int order = 0;
+
+	do {
+		value /= 10;
+		order++;
+	} while (value > 0);
+
+	return order - 1;
+}
+
+static void connector_set_name(struct connector *connector,
+			       struct resources *res)
+{
+	uint32_t type = connector->connector->connector_type;
+	const char *type_name;
+	unsigned int index;
+	int len;
+
+	type_name = util_lookup_connector_type_name(type);
+	index = get_connector_index(res, type);
+	len = strlen(type_name) + get_order(index) + 2;
+
+	connector->name = malloc(len + 1);
+	if (connector->name)
+		snprintf(connector->name, len + 1, "%s-%u", type_name,  index);
+}
+
 static struct resources *get_resources(struct device *dev)
 {
 	struct resources *res;
@@ -562,6 +608,12 @@ static struct resources *get_resources(struct device *dev)
 	get_resource(res, res, connector, Connector);
 	get_resource(res, res, fb, FB);
 
+	for (i = 0; i < res->res->count_connectors; i++) {
+		struct connector *connector = &res->connectors[i];
+
+		connector_set_name(connector, res);
+	}
+
 #define get_properties(_res, __res, type, Type)					\
 	do {									\
 		int i;								\
@@ -630,6 +682,21 @@ static int get_crtc_index(struct device *dev, uint32_t id)
 	return -1;
 }
 
+static drmModeConnector *get_connector_by_name(struct device *dev, const char *name)
+{
+	struct connector *connector;
+	int i;
+
+	for (i = 0; i < dev->resources->res->count_connectors; i++) {
+		connector = &dev->resources->connectors[i];
+
+		if (strcmp(connector->name, name) == 0)
+			return connector->connector;
+	}
+
+	return NULL;
+}
+
 static drmModeConnector *get_connector_by_id(struct device *dev, uint32_t id)
 {
 	drmModeConnector *connector;
@@ -670,6 +737,7 @@ static drmModeEncoder *get_encoder_by_id(struct device *dev, uint32_t id)
  * can bind it with a free crtc.
  */
 struct pipe_arg {
+	const char **cons;
 	uint32_t *con_ids;
 	unsigned int num_cons;
 	uint32_t crtc_id;
@@ -784,8 +852,8 @@ static int pipe_find_crtc_and_mode(struct device *dev, struct pipe_arg *pipe)
 					   pipe->mode_str, pipe->vrefresh);
 		if (mode == NULL) {
 			fprintf(stderr,
-				"failed to find mode \"%s\" for connector %u\n",
-				pipe->mode_str, pipe->con_ids[i]);
+				"failed to find mode \"%s\" for connector %s\n",
+				pipe->mode_str, pipe->cons[i]);
 			return -EINVAL;
 		}
 	}
@@ -1054,7 +1122,7 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
 		printf("setting mode %s-%dHz@%s on connectors ",
 		       pipe->mode_str, pipe->mode->vrefresh, pipe->format_str);
 		for (j = 0; j < pipe->num_cons; ++j)
-			printf("%u, ", pipe->con_ids[j]);
+			printf("%s, ", pipe->cons[j]);
 		printf("crtc %d\n", pipe->crtc->crtc->crtc_id);
 
 		ret = drmModeSetCrtc(dev->fd, pipe->crtc->crtc->crtc_id, fb_id,
@@ -1230,18 +1298,28 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg)
 
 	/* Count the number of connectors and allocate them. */
 	pipe->num_cons = 1;
-	for (p = arg; isdigit(*p) || *p == ','; ++p) {
+	for (p = arg; *p && *p != ':' && *p != '@'; ++p) {
 		if (*p == ',')
 			pipe->num_cons++;
 	}
 
-	pipe->con_ids = malloc(pipe->num_cons * sizeof *pipe->con_ids);
+	pipe->cons = malloc(pipe->num_cons * sizeof(*pipe->cons));
+	if (pipe->cons == NULL)
+		return -1;
+
+	pipe->con_ids = malloc(pipe->num_cons * sizeof(*pipe->con_ids));
 	if (pipe->con_ids == NULL)
 		return -1;
 
 	/* Parse the connectors. */
 	for (i = 0, p = arg; i < pipe->num_cons; ++i, p = endp + 1) {
-		pipe->con_ids[i] = strtoul(p, &endp, 10);
+		endp = strpbrk(p, ",@:");
+
+		if (endp)
+			pipe->cons[i] = strndup(p, endp - p);
+		else
+			pipe->cons[i] = strdup(p);
+
 		if (*endp != ',')
 			break;
 	}
@@ -1405,6 +1483,32 @@ static int cursor_supported(void)
 	return 1;
 }
 
+static int pipe_resolve_connectors(struct pipe_arg *pipe, struct device *dev)
+{
+	drmModeConnector *connector;
+	unsigned int i;
+	uint32_t id;
+	char *endp;
+
+	for (i = 0; i < pipe->num_cons; i++) {
+		id = strtoul(pipe->cons[i], &endp, 10);
+		if (endp == pipe->cons[i]) {
+			connector = get_connector_by_name(dev, pipe->cons[i]);
+			if (!connector) {
+				fprintf(stderr, "no connector named %s\n",
+					pipe->cons[i]);
+				return -ENODEV;
+			}
+
+			id = connector->connector_id;
+		}
+
+		pipe->con_ids[i] = id;
+	}
+
+	return 0;
+}
+
 static char optstr[] = "cdD:efM:P:ps:Cvw:";
 
 int main(int argc, char **argv)
@@ -1420,7 +1524,7 @@ int main(int argc, char **argv)
 	char *device = NULL;
 	char *module = NULL;
 	unsigned int i;
-	int count = 0, plane_count = 0;
+	unsigned int count = 0, plane_count = 0;
 	unsigned int prop_count = 0;
 	struct pipe_arg *pipe_args = NULL;
 	struct plane_arg *plane_args = NULL;
@@ -1559,6 +1663,14 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+	for (i = 0; i < count; i++) {
+		if (pipe_resolve_connectors(&pipe_args[i], &dev) < 0) {
+			free_resources(dev.resources);
+			drmClose(dev.fd);
+			return 1;
+		}
+	}
+
 #define dump_resource(dev, res) if (res) dump_##res(dev)
 
 	dump_resource(&dev, encoders);
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#22 lore raw

PATCH 9/11 tests: Add libkms-test library

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

This library contains abstractions for KMS that help remove the need for a lot of boilerplate in KMS test programs.

---
 configure.ac                        |   1 +
 tests/Makefile.am                   |   2 +-
 tests/kms/Makefile.am               |  19 ++++
 tests/kms/libkms-test-crtc.c        |  47 ++++++++
 tests/kms/libkms-test-device.c      | 218 ++++++++++++++++++++++++++++++++++++
 tests/kms/libkms-test-framebuffer.c | 157 ++++++++++++++++++++++++++
 tests/kms/libkms-test-plane.c       | 139 +++++++++++++++++++++++
 tests/kms/libkms-test-screen.c      |  92 +++++++++++++++
 tests/kms/libkms-test.h             | 120 ++++++++++++++++++++
 9 files changed, 794 insertions(+), 1 deletion(-)
 create mode 100644 tests/kms/Makefile.am
 create mode 100644 tests/kms/libkms-test-crtc.c
 create mode 100644 tests/kms/libkms-test-device.c
 create mode 100644 tests/kms/libkms-test-framebuffer.c
 create mode 100644 tests/kms/libkms-test-plane.c
 create mode 100644 tests/kms/libkms-test-screen.c
 create mode 100644 tests/kms/libkms-test.h
configure.ac +1 -0
index 58411b79b682..0a6c414bf9eb 100644
@@ -435,6 +435,7 @@ AC_CONFIG_FILES([
 	tests/Makefile
 	tests/modeprint/Makefile
 	tests/modetest/Makefile
+	tests/kms/Makefile
 	tests/kmstest/Makefile
 	tests/proptest/Makefile
 	tests/radeon/Makefile
tests/Makefile.am +1 -1
index 310032732f6e..e14cc3d24a22 100644
@@ -10,7 +10,7 @@ check_PROGRAMS = \
 	dristat \
 	drmstat
 
-SUBDIRS = util modeprint proptest
+SUBDIRS = util kms modeprint proptest
 
 if HAVE_LIBKMS
 SUBDIRS += kmstest modetest
tests/kms/Makefile.am new file +19 -0
new file mode 100644
index 000000000000..c84bae05d869
@@ -0,0 +1,19 @@
+AM_CPPFLAGS = \
+	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)/tests \
+	-I$(top_srcdir)
+
+AM_CFLAGS = \
+	$(WARN_CFLAGS)
+
+noinst_LTLIBRARIES = libkms-test.la
+
+libkms_test_la_SOURCES = \
+	libkms-test-crtc.c \
+	libkms-test-device.c \
+	libkms-test-framebuffer.c \
+	libkms-test-plane.c \
+	libkms-test-screen.c
+
+libkms_test_la_LIBADD = \
+	$(top_builddir)/libdrm.la
tests/kms/libkms-test-crtc.c new file +47 -0

47 lines not on this page · raw message

tests/kms/libkms-test-device.c new file +218 -0

218 lines not on this page · raw message

tests/kms/libkms-test-framebuffer.c new file +157 -0

157 lines not on this page · raw message

tests/kms/libkms-test-plane.c new file +139 -0

139 lines not on this page · raw message

tests/kms/libkms-test-screen.c new file +92 -0

92 lines not on this page · raw message

tests/kms/libkms-test.h new file +120 -0

120 lines not on this page · raw message

Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#24 lore raw

PATCH 10/11 tests: kms: Implement CRTC stealing test

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

This test program sets a mode and framebuffer on a connector and cycles through all CRTCs, moving the connector to each of them in turn. This is useful to verify that CRTC stealing is properly handled in the DRM core and drivers.

---
 tests/kms/Makefile.am      |  11 ++++
 tests/kms/kms-steal-crtc.c | 161 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 172 insertions(+)
 create mode 100644 tests/kms/kms-steal-crtc.c
tests/kms/Makefile.am +11 -0
index c84bae05d869..10584c8930a4 100644
@@ -17,3 +17,14 @@ libkms_test_la_SOURCES = \
 
 libkms_test_la_LIBADD = \
 	$(top_builddir)/libdrm.la
+
+if HAVE_INSTALL_TESTS
+bin_PROGRAMS = \
+	kms-steal-crtc
+else
+noinst_PROGRAMS = \
+	kms-steal-crtc
+endif
+
+kms_steal_crtc_SOURCES = kms-steal-crtc.c
+kms_steal_crtc_LDADD = libkms-test.la ../util/libutil.la
tests/kms/kms-steal-crtc.c new file +161 -0

161 lines not on this page · raw message

Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#26 lore raw

PATCH 11/11 tests: kms: Implement universal planes test

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

This small program allows universal planes to be tested. Currently this isn't very flexible because it allows only the first plane of a given type to be tested on the first CRTC. However it should be simple to extend this with some additional command-line arguments.

---
 tests/kms/Makefile.am            |   9 +-
 tests/kms/kms-universal-planes.c | 358 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 365 insertions(+), 2 deletions(-)
 create mode 100644 tests/kms/kms-universal-planes.c
tests/kms/Makefile.am +7 -2
index 10584c8930a4..e9589221e489 100644
@@ -20,11 +20,16 @@ libkms_test_la_LIBADD = \
 
 if HAVE_INSTALL_TESTS
 bin_PROGRAMS = \
-	kms-steal-crtc
+	kms-steal-crtc \
+	kms-universal-planes
 else
 noinst_PROGRAMS = \
-	kms-steal-crtc
+	kms-steal-crtc \
+	kms-universal-planes
 endif
 
 kms_steal_crtc_SOURCES = kms-steal-crtc.c
 kms_steal_crtc_LDADD = libkms-test.la ../util/libutil.la
+
+kms_universal_planes_SOURCES = kms-universal-planes.c
+kms_universal_planes_LDADD = libkms-test.la
tests/kms/kms-universal-planes.c new file +358 -0

358 lines not on this page · raw message

Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/11
#2 lore raw

Re: [PATCH libdrm 01/11] libdrm: valgrind-clear a few more IOCTL arguments

In reply to Thierry Reding

Hi Thierry,

Thank you for the patch.

Quoted 5 lines · On Friday 23 January 2015 17:08:14 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

Fixes a few complaints raised by valgrind when running the Tegra tests.

I agree that a fix is needed, and that this patch matches the rest of the code, so

However, shouldn't structures be memset to 0 unconditionally, especially considering the recent discussion regarding reserved fields that should be initialized to default values by userspace ? This can be fixed by a separate patch.

Quoted 24 lines
---
 xf86drmMode.c | 2 ++
 1 file changed, 2 insertions(+)
xf86drmMode.c +2 -0
index 60ce3699f3e3..f6e4416b88b5 100644
@@ -282,6 +282,7 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t
 height, struct drm_mode_fb_cmd2 f;
 	int ret;
 
+	VG_CLEAR(f);
 	f.width  = width;
 	f.height = height;
 	f.pixel_format = pixel_format;
@@ -309,6 +310,7 @@ drmModeFBPtr drmModeGetFB(int fd, uint32_t buf)
 	struct drm_mode_fb_cmd info;
 	drmModeFBPtr r;
 
+	VG_CLEAR(info);
 	info.fb_id = buf;
 
 	if (drmIoctl(fd, DRM_IOCTL_MODE_GETFB, &info))
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 2/11
#4 lore raw

Re: [PATCH libdrm 02/11] libdrm: Remove gratuitous blank lines

In reply to Thierry Reding

Hi Thierry,

Thank you for the patch.

Quoted 6 lines · On Friday 23 January 2015 17:08:15 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

Usage of blank lines can be a matter of taste, of course, but for these we can surely all agree that they're not needed and inconsistent.

Quoted 90 lines
---
 xf86drmMode.c | 11 -----------
 1 file changed, 11 deletions(-)
xf86drmMode.c +0 -8
index f6e4416b88b5..7e228b3e7aa3 100644
@@ -115,7 +115,6 @@ void drmModeFreeResources(drmModeResPtr ptr)
 	drmFree(ptr->connectors);
 	drmFree(ptr->encoders);
 	drmFree(ptr);
-
 }
 
 void drmModeFreeFB(drmModeFBPtr ptr)
@@ -133,7 +132,6 @@ void drmModeFreeCrtc(drmModeCrtcPtr ptr)
 		return;
 
 	drmFree(ptr);
-
 }
 
 void drmModeFreeConnector(drmModeConnectorPtr ptr)
@@ -146,7 +144,6 @@ void drmModeFreeConnector(drmModeConnectorPtr ptr)
 	drmFree(ptr->props);
 	drmFree(ptr->modes);
 	drmFree(ptr);
-
 }
 
 void drmModeFreeEncoder(drmModeEncoderPtr ptr)
@@ -301,8 +298,6 @@ int drmModeAddFB2(int fd, uint32_t width, uint32_t
 height, int drmModeRmFB(int fd, uint32_t bufferId)
 {
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
-
-
 }
 
 drmModeFBPtr drmModeGetFB(int fd, uint32_t buf)
@@ -342,7 +337,6 @@ int drmModeDirtyFB(int fd, uint32_t bufferId,
 	return DRM_IOCTL(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty);
 }
 
-
 /*
  * Crtc functions
  */
@@ -379,7 +373,6 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
 	return r;
 }
 
-
 int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
                    uint32_t x, uint32_t y, uint32_t *connectors, int count,
 drmModeModeInfoPtr mode)
@@ -594,7 +587,6 @@ int drmModeDetachMode(int fd, uint32_t connector_id,
 drmModeModeInfoPtr mode_inf return DRM_IOCTL(fd, DRM_IOCTL_MODE_DETACHMODE,
 &res);
 }
 
-
 drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
 {
xf86drmMode.c +0 -3
 	struct drm_mode_get_property prop;
@@ -812,7 +804,6 @@ int drmCheckModesettingSupported(const char *busid)
 	return 0;
 #endif
 	return -ENOSYS;
-
 }
 
 int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
@@ -914,7 +905,6 @@ int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t
 crtc_id, uint32_t crtc_w, uint32_t crtc_h,
 		    uint32_t src_x, uint32_t src_y,
 		    uint32_t src_w, uint32_t src_h)
-
 {
 	struct drm_mode_set_plane s;
 
@@ -934,7 +924,6 @@ int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t
 crtc_id, return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETPLANE, &s);
 }
 
-
 drmModePlanePtr drmModeGetPlane(int fd, uint32_t plane_id)
 {
 	struct drm_mode_get_plane ovr, counts;
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 3/11
#6 lore raw

Re: [PATCH libdrm 03/11] libdrm: Make indentation consistent

In reply to Thierry Reding

Hi Thierry,

Thank you for the patch.

Quoted 3 lines · On Friday 23 January 2015 17:08:16 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

Quoted 26 lines
---
 xf86drmMode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xf86drmMode.c +2 -2
index 7e228b3e7aa3..3d6b9cc307d1 100644
@@ -250,7 +250,7 @@ err_allocs:
 }
 
 int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
-                 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
+		 uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
 		 uint32_t *buf_id)
 {
 	struct drm_mode_fb_cmd f;
@@ -374,7 +374,7 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
 }
 
 int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
-                   uint32_t x, uint32_t y, uint32_t *connectors, int count,
+		   uint32_t x, uint32_t y, uint32_t *connectors, int count,
 		   drmModeModeInfoPtr mode)
 {
 	struct drm_mode_crtc crtc;
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 4/11
#8 lore raw

Re: [PATCH libdrm 04/11] tests: Split helpers into library

In reply to Thierry Reding

Hi Thierry,

Quoted 7 lines · On Friday 23 January 2015 17:08:17 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

Some of the helpers, such as the pattern drawing helpers or the format lookup helpers, have potential to be reused. Move them into a separate library to make it easier to share them.

Quoted 26 lines
---
 configure.ac                |   1 +
 tests/Makefile.am           |   2 +-
 tests/modeprint/Makefile.am |   1 +
 tests/modeprint/modeprint.c |   2 +-
 tests/modetest/Makefile.am  |   2 +
 tests/modetest/buffers.c    | 956 +----------------------------------------
 tests/modetest/buffers.h    |  12 +-
 tests/modetest/cursor.c     |   4 +-
 tests/modetest/modetest.c   |  25 +-
 tests/proptest/proptest.c   |   3 +-
 tests/util/Makefile.am      |  19 +
 tests/util/common.h         |  33 ++
 tests/util/format.c         | 119 ++++++
 tests/util/format.h         |  65 +++
 tests/util/pattern.c        | 870 ++++++++++++++++++++++++++++++++++++++++
 tests/util/pattern.h        |  39 ++
 tests/vbltest/Makefile.am   |   1 +
 tests/vbltest/vbltest.c     |   2 +-
 18 files changed, 1177 insertions(+), 979 deletions(-)
 create mode 100644 tests/util/Makefile.am
 create mode 100644 tests/util/common.h
 create mode 100644 tests/util/format.c
 create mode 100644 tests/util/format.h
 create mode 100644 tests/util/pattern.c
 create mode 100644 tests/util/pattern.h
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 5/11
#12 lore raw

Re: [PATCH libdrm 05/11] tests: Move name tables to libutil

In reply to Thierry Reding

Hi Thierry,

Thank you for the patch.

Quoted 6 lines · On Friday 23 January 2015 17:08:18 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

These tables are duplicated in several places, so move them into libutil so that they can be shared.

Quoted 357 lines
---
 tests/modetest/modetest.c  |  50 ++-----------------
 tests/proptest/Makefile.am |   4 +-
 tests/proptest/proptest.c  |  40 +--------------
 tests/util/Makefile.am     |   2 +
 tests/util/kms.c           | 122 ++++++++++++++++++++++++++++++++++++++++++
 tests/util/kms.h           |  33 ++++++++++++
 6 files changed, 165 insertions(+), 86 deletions(-)
 create mode 100644 tests/util/kms.c
 create mode 100644 tests/util/kms.h
tests/modetest/modetest.c +4 -46
index b610956adfcb..d5fd99ebe1fd 100644
@@ -61,6 +61,7 @@
 
 #include "util/common.h"
 #include "util/format.h"
+#include "util/kms.h"
 #include "util/pattern.h"
 
 #include "buffers.h"
@@ -123,11 +124,6 @@ static inline int64_t U642I64(uint64_t val)
 	return (int64_t)*((int64_t *)&val);
 }
 
-struct type_name {
-	int type;
-	const char *name;
-};
-
 #define type_name_fn(res) \
 const char * res##_str(int type) {			\
 	unsigned int i;					\
@@ -138,44 +134,6 @@ const char * res##_str(int type) {			\
 	return "(invalid)";				\
 }
 
-struct type_name encoder_type_names[] = {
-	{ DRM_MODE_ENCODER_NONE, "none" },
-	{ DRM_MODE_ENCODER_DAC, "DAC" },
-	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
-	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
-	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
-};
-
-static type_name_fn(encoder_type)
-
-struct type_name connector_status_names[] = {
-	{ DRM_MODE_CONNECTED, "connected" },
-	{ DRM_MODE_DISCONNECTED, "disconnected" },
-	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
-};
-
-static type_name_fn(connector_status)
-
-struct type_name connector_type_names[] = {
-	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
-	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
-	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
-	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
-	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
-	{ DRM_MODE_CONNECTOR_Composite, "composite" },
-	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
-	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
-	{ DRM_MODE_CONNECTOR_Component, "component" },
-	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
-	{ DRM_MODE_CONNECTOR_DisplayPort, "DP" },
-	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
-	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
-	{ DRM_MODE_CONNECTOR_TV, "TV" },
-	{ DRM_MODE_CONNECTOR_eDP, "eDP" },
-};
-
-static type_name_fn(connector_type)
-
 #define bit_name_fn(res)					\
 const char * res##_str(int type) {				\
 	unsigned int i;						\
@@ -235,7 +193,7 @@ static void dump_encoders(struct device *dev)
 		printf("%d\t%d\t%s\t0x%08x\t0x%08x\n",
 		       encoder->encoder_id,
 		       encoder->crtc_id,
-		       encoder_type_str(encoder->encoder_type),
+		       util_lookup_encoder_type_name(encoder->encoder_type),
 		       encoder->possible_crtcs,
 		       encoder->possible_clones);
 	}
@@ -379,8 +337,8 @@ static void dump_connectors(struct device *dev)
 		printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\t",
 		       connector->connector_id,
 		       connector->encoder_id,
-		       connector_status_str(connector->connection),
-		       connector_type_str(connector->connector_type),
+		       util_lookup_connector_status_name(connector->connection),
+		       util_lookup_connector_type_name(connector->connector_type),
 		       connector->mmWidth, connector->mmHeight,
 		       connector->count_modes);
 
tests/proptest/Makefile.am +3 -1
index f81a3c00846b..c615489b9a92 100644
@@ -1,5 +1,6 @@
 AM_CFLAGS = \
 	-I$(top_srcdir)/include/drm \
+	-I$(top_srcdir)/tests \
 	-I$(top_srcdir)
 
 noinst_PROGRAMS = \
@@ -8,4 +9,5 @@ noinst_PROGRAMS = \
 proptest_SOURCES = \
 	proptest.c
 proptest_LDADD = \
-	$(top_builddir)/libdrm.la
+	$(top_builddir)/libdrm.la \
+	$(top_builddir)/tests/util/libutil.la
tests/proptest/proptest.c +1 -39
index ee3fa408a310..b442d583d528 100644
@@ -45,44 +45,6 @@ static inline int64_t U642I64(uint64_t val)
 int fd;
 drmModeResPtr res = NULL;
 
-const char *connector_type_str(uint32_t type)
-{
-	switch (type) {
-	case DRM_MODE_CONNECTOR_Unknown:
-		return "Unknown";
-	case DRM_MODE_CONNECTOR_VGA:
-		return "VGA";
-	case DRM_MODE_CONNECTOR_DVII:
-		return "DVI-I";
-	case DRM_MODE_CONNECTOR_DVID:
-		return "DVI-D";
-	case DRM_MODE_CONNECTOR_DVIA:
-		return "DVI-A";
-	case DRM_MODE_CONNECTOR_Composite:
-		return "Composite";
-	case DRM_MODE_CONNECTOR_SVIDEO:
-		return "SVIDEO";
-	case DRM_MODE_CONNECTOR_LVDS:
-		return "LVDS";
-	case DRM_MODE_CONNECTOR_Component:
-		return "Component";
-	case DRM_MODE_CONNECTOR_9PinDIN:
-		return "9PinDin";
-	case DRM_MODE_CONNECTOR_DisplayPort:
-		return "DisplayPort";
-	case DRM_MODE_CONNECTOR_HDMIA:
-		return "HDMI-A";
-	case DRM_MODE_CONNECTOR_HDMIB:
-		return "HDMI-B";
-	case DRM_MODE_CONNECTOR_TV:
-		return "TV";
-	case DRM_MODE_CONNECTOR_eDP:
-		return "eDP";
-	default:
-		return "Invalid";
-	}
-}
-
 /* dump_blob and dump_prop shamelessly copied from ../modetest/modetest.c
 */ static void
 dump_blob(uint32_t blob_id)
@@ -226,7 +188,7 @@ static void listConnectorProperties(void)
 		}
 
 		printf("Connector %u (%s-%u)\n", c->connector_id,
-		       connector_type_str(c->connector_type),
+		       util_lookup_connector_type_name(c->connector_type),
 		       c->connector_type_id);
 
 		listObjectProperties(c->connector_id,
tests/util/Makefile.am +2 -0
index 1a2519fbea89..c00574484867 100644
@@ -12,6 +12,8 @@ libutil_la_SOURCES = \
 	common.h \
 	format.c \
 	format.h \
+	kms.c \
+	kms.h \
 	pattern.c \
 	pattern.h
 
tests/util/kms.c new file +8 -0
new file mode 100644
index 000000000000..a271ca047c4e
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2008 Tungsten Graphics
+ *   Jakob Bornecrantz <[email protected]>
+ * Copyright 2008 Intel Corporation
+ *   Jesse Barnes <[email protected]>
+ *
+ * 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.
+ */

tests/util/kms.c new file +4 -0
+
+/*
+ * This fairly simple test program dumps output in a similar format to the
+ * "xrandr" tool everyone knows & loves.  It's necessarily slightly

different + * since the kernel separates outputs into encoder and connector structures, + * each with their own unique ID. The program also allows test testing of the + * memory management and mode setting APIs by allowing the user to specify a + * connector and mode to use for mode setting. If all works as expected, a + * blue background should be painted on the monitor attached to the specified + * connector after the selected mode is set.
+ *
+ * TODO: use cairo to write the mode info on the selected output once
+ * the mode has been programmed, along with possible test patterns.
+ */

tests/util/kms.c new file +84 -0
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "xf86drmMode.h"
+
+#include "common.h"
+
+struct type_name {
+	unsigned int type;
+	const char *name;
+};
+
+static const char *util_lookup_type_name(unsigned int type,
+					 const struct type_name *table,
+					 unsigned int count)
+{
+	unsigned int i;
+
+	for (i = 0; i < count; i++)
+		if (table[i].type == type)
+			return table[i].name;
+
+	return NULL;
+}
+
+static const struct type_name encoder_type_names[] = {
+	{ DRM_MODE_ENCODER_NONE, "none" },
+	{ DRM_MODE_ENCODER_DAC, "DAC" },
+	{ DRM_MODE_ENCODER_TMDS, "TMDS" },
+	{ DRM_MODE_ENCODER_LVDS, "LVDS" },
+	{ DRM_MODE_ENCODER_TVDAC, "TVDAC" },
+	{ DRM_MODE_ENCODER_VIRTUAL, "Virtual" },
+	{ DRM_MODE_ENCODER_DSI, "DSI" },
+	{ DRM_MODE_ENCODER_DPMST, "DisplayPort MST" },
+};
+
+const char *util_lookup_encoder_type_name(unsigned int type)
+{
+	return util_lookup_type_name(type, encoder_type_names,
+				     ARRAY_SIZE(encoder_type_names));
+}
+
+static const struct type_name connector_status_names[] = {
+	{ DRM_MODE_CONNECTED, "connected" },
+	{ DRM_MODE_DISCONNECTED, "disconnected" },
+	{ DRM_MODE_UNKNOWNCONNECTION, "unknown" },
+};
+
+const char *util_lookup_connector_status_name(unsigned int status)
+{
+	return util_lookup_type_name(status, connector_status_names,
+				     ARRAY_SIZE(connector_status_names));
+}
+
+static const struct type_name connector_type_names[] = {
+	{ DRM_MODE_CONNECTOR_Unknown, "unknown" },
+	{ DRM_MODE_CONNECTOR_VGA, "VGA" },
+	{ DRM_MODE_CONNECTOR_DVII, "DVI-I" },
+	{ DRM_MODE_CONNECTOR_DVID, "DVI-D" },
+	{ DRM_MODE_CONNECTOR_DVIA, "DVI-A" },
+	{ DRM_MODE_CONNECTOR_Composite, "composite" },
+	{ DRM_MODE_CONNECTOR_SVIDEO, "s-video" },
+	{ DRM_MODE_CONNECTOR_LVDS, "LVDS" },
+	{ DRM_MODE_CONNECTOR_Component, "component" },
+	{ DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" },
+	{ DRM_MODE_CONNECTOR_DisplayPort, "DP" },
+	{ DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" },
+	{ DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" },
+	{ DRM_MODE_CONNECTOR_TV, "TV" },
+	{ DRM_MODE_CONNECTOR_eDP, "eDP" },
+	{ DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" },
+	{ DRM_MODE_CONNECTOR_DSI, "DSI" },
+};
+
+const char *util_lookup_connector_type_name(unsigned int type)
+{
+	return util_lookup_type_name(type, connector_type_names,
+				     ARRAY_SIZE(connector_type_names));
+}
tests/util/kms.h new file +8 -0
new file mode 100644
index 000000000000..fa9ab69983ac
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 Tungsten Graphics
+ *   Jakob Bornecrantz <[email protected]>
+ * Copyright 2008 Intel Corporation
+ *   Jesse Barnes <[email protected]>
+ *
+ * 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.
+ */

tests/util/kms.h new file +9 -0
+
+#ifndef UTIL_KMS_H
+#define UTIL_KMS_H
+
+const char *util_lookup_encoder_type_name(unsigned int type);
+const char *util_lookup_connector_status_name(unsigned int type);
+const char *util_lookup_connector_type_name(unsigned int type);
+
+#endif /* UTIL_KMS_H */
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#15 lore raw

Re: [PATCH libdrm 06/11] xf86drmMode.h: Use consistent padding

In reply to Thierry Reding

Hi Thierry,

Thank you for the patch.

Quoted 18 lines · On Friday 23 January 2015 17:08:19 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

---
 xf86drmMode.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
xf86drmMode.h +0 -3
index 856a6bb0f569..e70c16d437f4 100644
@@ -123,13 +123,13 @@ extern "C" {
 #define DRM_MODE_DITHERING_OFF  0
 #define DRM_MODE_DITHERING_ON   1
 
-#define DRM_MODE_ENCODER_NONE   0
-#define DRM_MODE_ENCODER_DAC    1
-#define DRM_MODE_ENCODER_TMDS   2

xf86drmMode.h extern "C" { · line 132

Quoted 10 lines
xf86drmMode.h +6 -3
-#define DRM_MODE_ENCODER_LVDS   3
-#define DRM_MODE_ENCODER_TVDAC  4
+#define DRM_MODE_ENCODER_NONE    0
+#define DRM_MODE_ENCODER_DAC     1
+#define DRM_MODE_ENCODER_TMDS    2
+#define DRM_MODE_ENCODER_LVDS    3
+#define DRM_MODE_ENCODER_TVDAC   4
 #define DRM_MODE_ENCODER_VIRTUAL 5
-#define DRM_MODE_ENCODER_DSI	6
+#define DRM_MODE_ENCODER_DSI     6

Nitpicking here, I would have aligned everything on the same column for every block of #define's, but that's up to you.

Quoted 13 lines
xf86drmMode.h +2 -2
 #define DRM_MODE_SUBCONNECTOR_Automatic 0
 #define DRM_MODE_SUBCONNECTOR_Unknown   0
@@ -153,8 +153,8 @@ extern "C" {
 #define DRM_MODE_CONNECTOR_DisplayPort  10
 #define DRM_MODE_CONNECTOR_HDMIA        11
 #define DRM_MODE_CONNECTOR_HDMIB        12
-#define DRM_MODE_CONNECTOR_TV		13
-#define DRM_MODE_CONNECTOR_eDP		14
+#define DRM_MODE_CONNECTOR_TV           13
+#define DRM_MODE_CONNECTOR_eDP          14
 #define DRM_MODE_CONNECTOR_VIRTUAL      15
 #define DRM_MODE_CONNECTOR_DSI          16
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#17 lore raw

Re: [PATCH libdrm 07/11] xf86drmMode.h: Add DisplayPort MST encoder type

In reply to Thierry Reding

Hi Thierry,

Thank you for the patch.

Quoted 5 lines · On Friday 23 January 2015 17:08:20 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

This brings xf86drmMode.h in sync with include/drm/drm_mode.h. Eventually we really should only have a single set of definitions rather than duplicating this in two files.

The purpose of these duplicate definitions is to avoid application build breakages when compiled against an old drm.h header that doesn't include drm_modes.h. Given that drm_modes.h has been introduced in 2.6.39 more than 6 years ago, wouldn't it be time to drop this ?

If we need to support old distributions (such as RHEL 5 for instance) shipping kernel headers older than 2.6.39, do we still need to keep the definitions in sync with newer kernel headers ? Build breakages would only occur when compiling an application that makes use of the new definitions against old kernel headers. If the distribution is stuck on <2.6.39 I doubt it will ship applications using recent DRM features.

Quoted 17 lines
---
 xf86drmMode.h | 1 +
 1 file changed, 1 insertion(+)
xf86drmMode.h +1 -0
index e70c16d437f4..70f14a1ae506 100644
@@ -130,6 +130,7 @@ extern "C" {
 #define DRM_MODE_ENCODER_TVDAC   4
 #define DRM_MODE_ENCODER_VIRTUAL 5
 #define DRM_MODE_ENCODER_DSI     6
+#define DRM_MODE_ENCODER_DPMST   7
 
 #define DRM_MODE_SUBCONNECTOR_Automatic 0
 #define DRM_MODE_SUBCONNECTOR_Unknown   0
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#19 lore raw

Re: [PATCH libdrm 08/11] tests: modetest: Accept connector names

In reply to Thierry Reding

Hi Thierry,

Thank you for the patch.

Quoted 16 lines · On Friday 23 January 2015 17:08:21 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

Allow connector names to be used in the specification of the -s option. This requires storing the string passed on the command-line so that it can later be resolved to a connector ID (after the DRM device has been opened).

---
 tests/modetest/modetest.c | 134 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 123 insertions(+), 11 deletions(-)
tests/modetest/modetest.c +0 -0
index d5fd99ebe1fd..a7cc94f8938c 100644

[snip]

Quoted 10 lines
tests/modetest/modetest.c +1 -1
@@ -327,7 +328,7 @@ static void dump_connectors(struct device *dev)
 	int i, j;
 
 	printf("Connectors:\n");
-	printf("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\tencoders\n");
+	printf("id\tencoder\tstatus\t\tname\t\tsize (mm)\tmodes\tencoders\n");
 	for (i = 0; i < dev->resources->res->count_connectors; i++) {
 		struct connector *_connector = &dev->resources->connectors[i];
 		drmModeConnector *connector = _connector->connector;

tests/modetest/modetest.c static void dump_connectors(struct device *dev) · line 344

Quoted 7 lines
tests/modetest/modetest.c +1 -1
@@ -338,7 +339,7 @@ static void dump_connectors(struct device *dev)
 		       connector->connector_id,
 		       connector->encoder_id,
 		       util_lookup_connector_status_name(connector->connection),
-		       util_lookup_connector_type_name(connector->connector_type),
+		       _connector->name,
 		       connector->mmWidth, connector->mmHeight,
 		       connector->count_modes);

As this is a low-level test tool I believe it would be useful to print both the name and the ID. Maybe something like "name (id)" ?

[snip]

Quoted 29 lines
tests/modetest/modetest.c +24 -0
@@ -511,6 +516,47 @@ static void free_resources(struct resources *res)
 	free(res);
 }
 
+static unsigned int get_connector_index(struct resources *res, uint32_t
 type)
+{
+	unsigned int index = 0;
+	int i;
+
+	for (i = 0; i < res->res->count_connectors; i++)
+		if (res->connectors[i].connector->connector_type == type)
+			index++;
+
+	return index - 1;
+}
+
+static unsigned int get_order(unsigned int value)
+{
+	unsigned int order = 0;
+
+	do {
+		value /= 10;
+		order++;
+	} while (value > 0);
+
+	return order - 1;
+}
+

tests/modetest/modetest.c static void free_resources(struct resources *res) · line 553

Quoted 10 lines
tests/modetest/modetest.c +10 -0
+static void connector_set_name(struct connector *connector,
+			       struct resources *res)
+{
+	uint32_t type = connector->connector->connector_type;
+	const char *type_name;
+	unsigned int index;
+	int len;
+
+	type_name = util_lookup_connector_type_name(type);
+	index = get_connector_index(res, type);

The kernel's connector name is created using connector_type_id, not the connector index. Shouldn't we do the same here ?

tests/modetest/modetest.c static void free_resources(struct resources *res) · line 553

Quoted 1 line
tests/modetest/modetest.c +1 -0
+	len = strlen(type_name) + get_order(index) + 2;

This looks like an over-optimization to me, can't you just add 9 to account for the largest possible index ? Or, even better, use asprintf ? The function is a GNU extension but is available on BSD according to its manpage.

Quoted 8 lines
tests/modetest/modetest.c +5 -0
+	connector->name = malloc(len + 1);
+	if (connector->name)
+		snprintf(connector->name, len + 1, "%s-%u", type_name,  index);
+}
+
 static struct resources *get_resources(struct device *dev)
 {
 	struct resources *res;

[snip]

Quoted 5 lines
tests/modetest/modetest.c +1 -0
@@ -1405,6 +1483,32 @@ static int cursor_supported(void)
 	return 1;
 }
 
+static int pipe_resolve_connectors(struct pipe_arg *pipe, struct device

tests/modetest/modetest.c static int cursor_supported(void) · line 1496

Quoted 10 lines
tests/modetest/modetest.c +9 -0
 *dev)
+{
+	drmModeConnector *connector;
+	unsigned int i;
+	uint32_t id;
+	char *endp;
+
+	for (i = 0; i < pipe->num_cons; i++) {
+		id = strtoul(pipe->cons[i], &endp, 10);
+		if (endp == pipe->cons[i]) {

This won't have the expected behaviour for 9-pin DIN connectors, as the name starts with a digit. You should instead test for *endp == '\0'.

Quoted 5 lines
tests/modetest/modetest.c +5 -0
+			connector = get_connector_by_name(dev, pipe->cons[i]);
+			if (!connector) {
+				fprintf(stderr, "no connector named %s\n",
+					pipe->cons[i]);
+				return -ENODEV;

tests/modetest/modetest.c static int cursor_supported(void) · line 1510

Quoted 10 lines
tests/modetest/modetest.c +10 -0
+			}
+
+			id = connector->connector_id;
+		}
+
+		pipe->con_ids[i] = id;
+	}
+
+	return 0;
+}

Could update the help text in usage() to reflect the new usage ?

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#20 lore raw

Re: [PATCH libdrm 08/11] tests: modetest: Accept connector names

Quoted 36 lines · Laurent Pinchart

Hi Thierry,

Thank you for the patch.

Quoted 16 lines · On Friday 23 January 2015 17:08:21 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

Allow connector names to be used in the specification of the -s option. This requires storing the string passed on the command-line so that it can later be resolved to a connector ID (after the DRM device has been opened).

---
 tests/modetest/modetest.c | 134 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 123 insertions(+), 11 deletions(-)
tests/modetest/modetest.c +0 -0
index d5fd99ebe1fd..a7cc94f8938c 100644

[snip]

Quoted 12 lines
tests/modetest/modetest.c +1 -1
@@ -327,7 +328,7 @@ static void dump_connectors(struct device *dev)
 	int i, j;
 
 	printf("Connectors:\n");
-	printf("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\tencoders\n");
+	printf("id\tencoder\tstatus\t\tname\t\tsize (mm)\tmodes\tencoders\n");
 	for (i = 0; i < dev->resources->res->count_connectors; i++) {
 		struct connector *_connector = &dev->resources->connectors[i];
 		drmModeConnector *connector = _connector->connector;
@@ -338,7 +339,7 @@ static void dump_connectors(struct device *dev)
 		       connector->connector_id,
 		       connector->encoder_id,
Quoted 8 lines

tests/modetest/modetest.c static void dump_connectors(struct device *dev) · line 344

Quoted 5 lines
tests/modetest/modetest.c +1 -1
 		       util_lookup_connector_status_name(connector->connection),
-		       util_lookup_connector_type_name(connector->connector_type),
+		       _connector->name,
 		       connector->mmWidth, connector->mmHeight,
 		       connector->count_modes);

As this is a low-level test tool I believe it would be useful to print both the name and the ID. Maybe something like "name (id)" ?

The ID is already printed in the very first column.

Quoted 34 lines
Quoted 34 lines
tests/modetest/modetest.c +29 -0
@@ -511,6 +516,47 @@ static void free_resources(struct resources *res)
 	free(res);
 }
 
+static unsigned int get_connector_index(struct resources *res, uint32_t
 type)
+{
+	unsigned int index = 0;
+	int i;
+
+	for (i = 0; i < res->res->count_connectors; i++)
+		if (res->connectors[i].connector->connector_type == type)
+			index++;
+
+	return index - 1;
+}
+
+static unsigned int get_order(unsigned int value)
+{
+	unsigned int order = 0;
+
+	do {
+		value /= 10;
+		order++;
+	} while (value > 0);
+
+	return order - 1;
+}
+
+static void connector_set_name(struct connector *connector,
+			       struct resources *res)
+{
+	uint32_t type = connector->connector->connector_type;
+	const char *type_name;
Quoted 8 lines

tests/modetest/modetest.c static void free_resources(struct resources *res) · line 552

Quoted 5 lines
tests/modetest/modetest.c +5 -0
+	unsigned int index;
+	int len;
+
+	type_name = util_lookup_connector_type_name(type);
+	index = get_connector_index(res, type);

The kernel's connector name is created using connector_type_id, not the connector index. Shouldn't we do the same here ?

The idea was to mirror what X was doing so that people familiar with the xrandr tool would feel right at home. Note that the index here is by type, not global. So you'd end up with something like this:

	HDMI-A-1
	HDMI-A-2
	LVDS-1

I think that's what most people would find to be the least surprising. Using the connector_type_id would again introduce the potential to get no-deterministic names (dependent on driver probe ordering in case of multiple cards).

That said I now realize that this actually starts numbering connectors at 0, so get_connector_index() should probably return index rather than index - 1 to be consistent with what X does.

Quoted 5 lines

tests/modetest/modetest.c static void free_resources(struct resources *res) · line 553

Quoted 1 line
tests/modetest/modetest.c +1 -0
+	len = strlen(type_name) + get_order(index) + 2;

This looks like an over-optimization to me, can't you just add 9 to account for the largest possible index ? Or, even better, use asprintf ? The function is a GNU extension but is available on BSD according to its manpage.

Always using 9 characters would be wasting 8 bytes per connector for something like 99% of the systems. I had thought about using asprintf but decided not to use it because it isn't always available and it is pretty simple to compute the actual length.

Quoted 6 lines
Quoted 6 lines
tests/modetest/modetest.c +5 -0
+static int pipe_resolve_connectors(struct pipe_arg *pipe, struct device
 *dev)
+{
+	drmModeConnector *connector;
+	unsigned int i;
+	uint32_t id;
Quoted 8 lines

tests/modetest/modetest.c static int cursor_supported(void) · line 1495

Quoted 5 lines
tests/modetest/modetest.c +5 -0
+	char *endp;
+
+	for (i = 0; i < pipe->num_cons; i++) {
+		id = strtoul(pipe->cons[i], &endp, 10);
+		if (endp == pipe->cons[i]) {

This won't have the expected behaviour for 9-pin DIN connectors, as the name starts with a digit. You should instead test for *endp == '\0'.

Good catch. I've changed this check to:

	if (*endp != '\0') {
		... look up by name ...
	}
Quoted 9 lines
Quoted 9 lines
tests/modetest/modetest.c +9 -0
+			connector = get_connector_by_name(dev, pipe->cons[i]);
+			if (!connector) {
+				fprintf(stderr, "no connector named %s\n",
+					pipe->cons[i]);
+				return -ENODEV;
+			}
+
+			id = connector->connector_id;
+		}
Quoted 8 lines

tests/modetest/modetest.c static int cursor_supported(void) · line 1510

Quoted 6 lines
tests/modetest/modetest.c +6 -0
+
+		pipe->con_ids[i] = id;
+	}
+
+	return 0;
+}

Could update the help text in usage() to reflect the new usage ?

Done.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#21 lore raw

Re: [PATCH libdrm 08/11] tests: modetest: Accept connector names

Hi Thierry,

Quoted 47 lines · On Monday 26 January 2015 11:14:32 Thierry Reding wrote:
Quoted 46 lines · Laurent Pinchart
Quoted 17 lines · On Friday 23 January 2015 17:08:21 Thierry Reding wrote:

From: Thierry Reding <[email protected]>

Allow connector names to be used in the specification of the -s option. This requires storing the string passed on the command-line so that it can later be resolved to a connector ID (after the DRM device has been opened).

---

 tests/modetest/modetest.c | 134 +++++++++++++++++++++++++++++++++++----
 1 file changed, 123 insertions(+), 11 deletions(-)
tests/modetest/modetest.c +0 -0
index d5fd99ebe1fd..a7cc94f8938c 100644

[snip]

Quoted 25 lines
tests/modetest/modetest.c +1 -1
@@ -327,7 +328,7 @@ static void dump_connectors(struct device *dev)
 
 	int i, j;
 
 	printf("Connectors:\n");
 
-	printf("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\tencoders\n");
+	printf("id\tencoder\tstatus\t\tname\t\tsize
 (mm)\tmodes\tencoders\n");
tests/modetest/modetest.c +1 -1
 	for (i = 0; i < dev->resources->res->count_connectors; i++) {
 
 		struct connector *_connector = &dev->resources->connectors[i];
 		drmModeConnector *connector = _connector->connector;
@@ -338,7 +339,7 @@ static void dump_connectors(struct device *dev)
 
 		       connector->connector_id,
 		       connector->encoder_id,
 		       util_lookup_connector_status_name(connector->connection),
 
-		       util_lookup_connector_type_name(connector->
 connector_type),
+		       _connector->name,
Quoted 7 lines
Quoted 5 lines

tests/modetest/modetest.c static void dump_connectors(struct device *dev) · line 344

Quoted 2 lines
tests/modetest/modetest.c +0 -0
 		       connector->mmWidth, connector->mmHeight,
 		       connector->count_modes);

As this is a low-level test tool I believe it would be useful to print both the name and the ID. Maybe something like "name (id)" ?

The ID is already printed in the very first column.

My bad.

Quoted 47 lines
Quoted 34 lines
Quoted 34 lines
tests/modetest/modetest.c +29 -0
@@ -511,6 +516,47 @@ static void free_resources(struct resources *res)
 	free(res);
 }
 
+static unsigned int get_connector_index(struct resources *res, uint32_t
 type)
+{
+	unsigned int index = 0;
+	int i;
+
+	for (i = 0; i < res->res->count_connectors; i++)
+		if (res->connectors[i].connector->connector_type == type)
+			index++;
+
+	return index - 1;
+}
+
+static unsigned int get_order(unsigned int value)
+{
+	unsigned int order = 0;
+
+	do {
+		value /= 10;
+		order++;
+	} while (value > 0);
+
+	return order - 1;
+}
+
+static void connector_set_name(struct connector *connector,
+			       struct resources *res)
+{
+	uint32_t type = connector->connector->connector_type;
+	const char *type_name;
Quoted 8 lines

tests/modetest/modetest.c static void free_resources(struct resources *res) · line 552

Quoted 5 lines
tests/modetest/modetest.c +5 -0
+	unsigned int index;
+	int len;
+
+	type_name = util_lookup_connector_type_name(type);
+	index = get_connector_index(res, type);

The kernel's connector name is created using connector_type_id, not the connector index. Shouldn't we do the same here ?

The idea was to mirror what X was doing so that people familiar with the xrandr tool would feel right at home. Note that the index here is by type, not global. So you'd end up with something like this:

Quoted 8 lines
	HDMI-A-1
	HDMI-A-2
	LVDS-1

I think that's what most people would find to be the least surprising. Using the connector_type_id would again introduce the potential to get no-deterministic names (dependent on driver probe ordering in case of multiple cards).

Isn't the index dependent on probe ordering as well ?

Quoted 3 lines

That said I now realize that this actually starts numbering connectors at 0, so get_connector_index() should probably return index rather than index - 1 to be consistent with what X does.

Yes, I think that's a good idea.

Quoted 9 lines
Quoted 6 lines

tests/modetest/modetest.c static void free_resources(struct resources *res) · line 553

Quoted 1 line
tests/modetest/modetest.c +1 -0
+	len = strlen(type_name) + get_order(index) + 2;

This looks like an over-optimization to me, can't you just add 9 to account for the largest possible index ? Or, even better, use asprintf ? The function is a GNU extension but is available on BSD according to its manpage.

Always using 9 characters would be wasting 8 bytes per connector for something like 99% of the systems.

We're talking about 8 bytes per connector for a test tool. With no more than a dozen of connectors. Right ? :-)

Quoted 2 lines

I had thought about using asprintf but decided not to use it because it isn't always available and it is pretty simple to compute the actual length.

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

PATCH 1/1 SQUASH: tests: misc cleanups

In reply to Thierry Reding

Cairo
- Add cflags only when needed (tests/util).
- Leave the link against cairo for the final object, not the static
library.
- Use Makefile.sources for the sources list.
- Drop unused includes

---
 tests/modetest/Makefile.am  |  1 -
 tests/modetest/buffers.c    |  5 -----
 tests/util/Makefile.am      | 12 +++---------
 tests/util/Makefile.sources |  6 ++++++
 4 files changed, 9 insertions(+), 15 deletions(-)
 create mode 100644 tests/util/Makefile.sources
tests/modetest/Makefile.am +0 -1
index 88fde2e..40dad3e 100644
@@ -23,7 +23,6 @@ modetest_LDADD = \
 	-lpthread
 
 if HAVE_CAIRO
-AM_CFLAGS += $(CAIRO_CFLAGS)
 modetest_LDADD += $(CAIRO_LIBS)
 endif
 
tests/modetest/buffers.c +0 -5
index 4db4e9a..2db538c 100644
@@ -44,11 +44,6 @@
 
 #include "buffers.h"
 
-#ifdef HAVE_CAIRO
-#include <math.h>
-#include <cairo.h>
-#endif
-
 struct bo
 {
 	int fd;
tests/util/Makefile.am +3 -9
index 1a2519f..f8e0b17 100644
@@ -1,3 +1,5 @@
+include Makefile.sources
+
 noinst_LTLIBRARIES = \
 	libutil.la
 
@@ -8,12 +10,4 @@ libutil_la_CPPFLAGS = \
 libutil_la_CFLAGS = \
 	$(CAIRO_CFLAGS)
 
-libutil_la_SOURCES = \
-	common.h \
-	format.c \
-	format.h \
-	pattern.c \
-	pattern.h
-
-libutil_la_LIBADD = \
-	$(CAIRO_LIBS)
+libutil_la_SOURCES = $(UTIL_FILES)
tests/util/Makefile.sources new file +6 -0
new file mode 100644
index 0000000..e91fa72
@@ -0,0 +1,6 @@
+UTIL_FILES := \
+	common.h \
+	format.c \
+	format.h \
+	pattern.c \
+	pattern.h
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH 1/1 SQUASH: util: add android build

In reply to Thierry Reding
---
 Android.mk                |  1 +
 CleanSpec.mk              |  1 +
 tests/modetest/Android.mk |  5 ++++-
 tests/util/Android.mk     | 13 +++++++++++++
 4 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 tests/util/Android.mk
Android.mk +1 -0
index 6f76113..af5f7a9 100644
@@ -57,6 +57,7 @@ SUBDIRS := \
 	nouveau \
 	radeon \
 	libkms \
+	tests/util \
 	tests/modetest
 
 mkfiles := $(patsubst %,$(LIBDRM_TOP)/%/Android.mk,$(SUBDIRS))
CleanSpec.mk +1 -0
index 8e23cd2..28a11db 100644
@@ -1,3 +1,4 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/include/libdrm)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/include/freedreno)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libdrm_*intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libdrm_*intermediates)
tests/modetest/Android.mk +4 -1
index aee3564..6cf10dc 100644
@@ -7,8 +7,11 @@ LOCAL_SRC_FILES := $(MODETEST_FILES)
 
 LOCAL_MODULE := modetest
 
-LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/libdrm
+LOCAL_C_INCLUDES += \
+	$(TARGET_OUT_HEADERS)/libdrm \
+	$(LIBDRM_TOP)/tests
 
 LOCAL_SHARED_LIBRARIES := libdrm
+LOCAL_STATIC_LIBRARIES := libdrm_util
 
 include $(BUILD_EXECUTABLE)
tests/util/Android.mk new file +13 -0
new file mode 100644
index 0000000..4dc1cce
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+include $(LOCAL_PATH)/Makefile.sources
+
+LOCAL_SRC_FILES := $(UTIL_FILES)
+
+LOCAL_MODULE := libdrm_util
+
+LOCAL_C_INCLUDES += \
+	$(TARGET_OUT_HEADERS)/libdrm
+
+include $(BUILD_STATIC_LIBRARY)
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH 1/1 SQUASH: util: add the kms.[ch] to makefile.sources

In reply to Thierry Reding
---
 tests/util/Makefile.sources | 2 ++
 1 file changed, 2 insertions(+)
tests/util/Makefile.sources +2 -0
index e91fa72..e5f8511 100644
@@ -2,5 +2,7 @@ UTIL_FILES := \
 	common.h \
 	format.c \
 	format.h \
+	kms.c \
+	kms.h \
 	pattern.c \
 	pattern.h
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#23 lore raw

PATCH 1/1 SQUASH: libkms-test: add missing header to the distribution

In reply to Thierry Reding
---
 tests/kms/Makefile.am | 3 +++
 1 file changed, 3 insertions(+)
tests/kms/Makefile.am +3 -0
index c84bae0..764a00d 100644
@@ -8,6 +8,9 @@ AM_CFLAGS = \
 
 noinst_LTLIBRARIES = libkms-test.la
 
+noinst_HEADERS = \
+	libkms-test.h
+
 libkms_test_la_SOURCES = \
 	libkms-test-crtc.c \
 	libkms-test-device.c \
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#25 lore raw

PATCH 1/1 SQUASH: kms-steal-crtc: link against cairo

In reply to Thierry Reding
---
 tests/kms/Makefile.am | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tests/kms/Makefile.am +7 -1
index 0e1b4ef..d033934 100644
@@ -29,5 +29,11 @@ noinst_PROGRAMS = \
 	kms-steal-crtc
 endif
 
+TEST_LIBS = libkms-test.la
+
+if HAVE_CAIRO
+TEST_LIBS += $(CAIRO_LIBS)
+endif
+
 kms_steal_crtc_SOURCES = kms-steal-crtc.c
-kms_steal_crtc_LDADD = libkms-test.la ../util/libutil.la
+kms_steal_crtc_LDADD = ../util/libutil.la $(TEST_LIBS)
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#27 lore raw

PATCH 1/1 SQUASH: kms-universal-planes: link against cairo

In reply to Thierry Reding
---
 tests/kms/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/kms/Makefile.am +1 -1
index 3b37e3e..fe7dd98 100644
@@ -41,4 +41,4 @@ kms_steal_crtc_SOURCES = kms-steal-crtc.c
 kms_steal_crtc_LDADD = ../util/libutil.la $(TEST_LIBS)
 
 kms_universal_planes_SOURCES = kms-universal-planes.c
-kms_universal_planes_LDADD = libkms-test.la
+kms_universal_planes_LDADD = $(TEST_LIBS)
Signature · 6 lines
2.1.3

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#28 lore raw
In reply to Thierry Reding
Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

This is a stash of commits that I've been carrying for a couple months. Laurent really wanted to have the connector name patch for modetest so I thought I'd send them all out for review.

Hi Thierry,

As mentioned earlier I've noticed a couple of small bits while checking out the Android build. Hope you don't mind my somewhat pedantic nit-picking.

The whole series can be found at

https://github.com/evelikov/libdrm/tree/for-tagr

-Emil

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel