dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings
@ 2017-01-30 10:29 Thierry Reding
  2017-01-30 10:29 ` [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice Thierry Reding
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thierry Reding @ 2017-01-30 10:29 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

Apply editorconfig settings to the tests/util library code in order to
facilitate making subsequent changes.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 tests/util/format.c  |  128 ++---
 tests/util/format.h  |   36 +-
 tests/util/kms.c     |  186 +++----
 tests/util/pattern.c | 1446 +++++++++++++++++++++++++-------------------------
 tests/util/pattern.h |   10 +-
 5 files changed, 899 insertions(+), 907 deletions(-)

diff --git a/tests/util/format.c b/tests/util/format.c
index 043cfe7f1eaf..b1055cfc8bbd 100644
--- a/tests/util/format.c
+++ b/tests/util/format.c
@@ -37,84 +37,84 @@
 #include "format.h"
 
 #define MAKE_RGB_INFO(rl, ro, gl, go, bl, bo, al, ao) \
-	.rgb = { { (rl), (ro) }, { (gl), (go) }, { (bl), (bo) }, { (al), (ao) } }
+    .rgb = { { (rl), (ro) }, { (gl), (go) }, { (bl), (bo) }, { (al), (ao) } }
 
 #define MAKE_YUV_INFO(order, xsub, ysub, chroma_stride) \
-	.yuv = { (order), (xsub), (ysub), (chroma_stride) }
+    .yuv = { (order), (xsub), (ysub), (chroma_stride) }
 
 static const struct util_format_info format_info[] = {
-	/* YUV packed */
-	{ DRM_FORMAT_UYVY, "UYVY", MAKE_YUV_INFO(YUV_YCbCr | YUV_CY, 2, 2, 2) },
-	{ DRM_FORMAT_VYUY, "VYUY", MAKE_YUV_INFO(YUV_YCrCb | YUV_CY, 2, 2, 2) },
-	{ DRM_FORMAT_YUYV, "YUYV", MAKE_YUV_INFO(YUV_YCbCr | YUV_YC, 2, 2, 2) },
-	{ DRM_FORMAT_YVYU, "YVYU", MAKE_YUV_INFO(YUV_YCrCb | YUV_YC, 2, 2, 2) },
-	/* YUV semi-planar */
-	{ DRM_FORMAT_NV12, "NV12", MAKE_YUV_INFO(YUV_YCbCr, 2, 2, 2) },
-	{ DRM_FORMAT_NV21, "NV21", MAKE_YUV_INFO(YUV_YCrCb, 2, 2, 2) },
-	{ DRM_FORMAT_NV16, "NV16", MAKE_YUV_INFO(YUV_YCbCr, 2, 1, 2) },
-	{ DRM_FORMAT_NV61, "NV61", MAKE_YUV_INFO(YUV_YCrCb, 2, 1, 2) },
-	/* YUV planar */
-	{ DRM_FORMAT_YUV420, "YU12", MAKE_YUV_INFO(YUV_YCbCr, 2, 2, 1) },
-	{ DRM_FORMAT_YVU420, "YV12", MAKE_YUV_INFO(YUV_YCrCb, 2, 2, 1) },
-	/* RGB16 */
-	{ DRM_FORMAT_ARGB4444, "AR12", MAKE_RGB_INFO(4, 8, 4, 4, 4, 0, 4, 12) },
-	{ DRM_FORMAT_XRGB4444, "XR12", MAKE_RGB_INFO(4, 8, 4, 4, 4, 0, 0, 0) },
-	{ DRM_FORMAT_ABGR4444, "AB12", MAKE_RGB_INFO(4, 0, 4, 4, 4, 8, 4, 12) },
-	{ DRM_FORMAT_XBGR4444, "XB12", MAKE_RGB_INFO(4, 0, 4, 4, 4, 8, 0, 0) },
-	{ DRM_FORMAT_RGBA4444, "RA12", MAKE_RGB_INFO(4, 12, 4, 8, 4, 4, 4, 0) },
-	{ DRM_FORMAT_RGBX4444, "RX12", MAKE_RGB_INFO(4, 12, 4, 8, 4, 4, 0, 0) },
-	{ DRM_FORMAT_BGRA4444, "BA12", MAKE_RGB_INFO(4, 4, 4, 8, 4, 12, 4, 0) },
-	{ DRM_FORMAT_BGRX4444, "BX12", MAKE_RGB_INFO(4, 4, 4, 8, 4, 12, 0, 0) },
-	{ DRM_FORMAT_ARGB1555, "AR15", MAKE_RGB_INFO(5, 10, 5, 5, 5, 0, 1, 15) },
-	{ DRM_FORMAT_XRGB1555, "XR15", MAKE_RGB_INFO(5, 10, 5, 5, 5, 0, 0, 0) },
-	{ DRM_FORMAT_ABGR1555, "AB15", MAKE_RGB_INFO(5, 0, 5, 5, 5, 10, 1, 15) },
-	{ DRM_FORMAT_XBGR1555, "XB15", MAKE_RGB_INFO(5, 0, 5, 5, 5, 10, 0, 0) },
-	{ DRM_FORMAT_RGBA5551, "RA15", MAKE_RGB_INFO(5, 11, 5, 6, 5, 1, 1, 0) },
-	{ DRM_FORMAT_RGBX5551, "RX15", MAKE_RGB_INFO(5, 11, 5, 6, 5, 1, 0, 0) },
-	{ DRM_FORMAT_BGRA5551, "BA15", MAKE_RGB_INFO(5, 1, 5, 6, 5, 11, 1, 0) },
-	{ DRM_FORMAT_BGRX5551, "BX15", MAKE_RGB_INFO(5, 1, 5, 6, 5, 11, 0, 0) },
-	{ DRM_FORMAT_RGB565, "RG16", MAKE_RGB_INFO(5, 11, 6, 5, 5, 0, 0, 0) },
-	{ DRM_FORMAT_BGR565, "BG16", MAKE_RGB_INFO(5, 0, 6, 5, 5, 11, 0, 0) },
-	/* RGB24 */
-	{ DRM_FORMAT_BGR888, "BG24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 0, 0) },
-	{ DRM_FORMAT_RGB888, "RG24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 0) },
-	/* RGB32 */
-	{ DRM_FORMAT_ARGB8888, "AR24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 8, 24) },
-	{ DRM_FORMAT_XRGB8888, "XR24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 0) },
-	{ DRM_FORMAT_ABGR8888, "AB24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 8, 24) },
-	{ DRM_FORMAT_XBGR8888, "XB24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 0, 0) },
-	{ DRM_FORMAT_RGBA8888, "RA24", MAKE_RGB_INFO(8, 24, 8, 16, 8, 8, 8, 0) },
-	{ DRM_FORMAT_RGBX8888, "RX24", MAKE_RGB_INFO(8, 24, 8, 16, 8, 8, 0, 0) },
-	{ DRM_FORMAT_BGRA8888, "BA24", MAKE_RGB_INFO(8, 8, 8, 16, 8, 24, 8, 0) },
-	{ DRM_FORMAT_BGRX8888, "BX24", MAKE_RGB_INFO(8, 8, 8, 16, 8, 24, 0, 0) },
-	{ DRM_FORMAT_ARGB2101010, "AR30", MAKE_RGB_INFO(10, 20, 10, 10, 10, 0, 2, 30) },
-	{ DRM_FORMAT_XRGB2101010, "XR30", MAKE_RGB_INFO(10, 20, 10, 10, 10, 0, 0, 0) },
-	{ DRM_FORMAT_ABGR2101010, "AB30", MAKE_RGB_INFO(10, 0, 10, 10, 10, 20, 2, 30) },
-	{ DRM_FORMAT_XBGR2101010, "XB30", MAKE_RGB_INFO(10, 0, 10, 10, 10, 20, 0, 0) },
-	{ DRM_FORMAT_RGBA1010102, "RA30", MAKE_RGB_INFO(10, 22, 10, 12, 10, 2, 2, 0) },
-	{ DRM_FORMAT_RGBX1010102, "RX30", MAKE_RGB_INFO(10, 22, 10, 12, 10, 2, 0, 0) },
-	{ DRM_FORMAT_BGRA1010102, "BA30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 2, 0) },
-	{ DRM_FORMAT_BGRX1010102, "BX30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 0, 0) },
+    /* YUV packed */
+    { DRM_FORMAT_UYVY, "UYVY", MAKE_YUV_INFO(YUV_YCbCr | YUV_CY, 2, 2, 2) },
+    { DRM_FORMAT_VYUY, "VYUY", MAKE_YUV_INFO(YUV_YCrCb | YUV_CY, 2, 2, 2) },
+    { DRM_FORMAT_YUYV, "YUYV", MAKE_YUV_INFO(YUV_YCbCr | YUV_YC, 2, 2, 2) },
+    { DRM_FORMAT_YVYU, "YVYU", MAKE_YUV_INFO(YUV_YCrCb | YUV_YC, 2, 2, 2) },
+    /* YUV semi-planar */
+    { DRM_FORMAT_NV12, "NV12", MAKE_YUV_INFO(YUV_YCbCr, 2, 2, 2) },
+    { DRM_FORMAT_NV21, "NV21", MAKE_YUV_INFO(YUV_YCrCb, 2, 2, 2) },
+    { DRM_FORMAT_NV16, "NV16", MAKE_YUV_INFO(YUV_YCbCr, 2, 1, 2) },
+    { DRM_FORMAT_NV61, "NV61", MAKE_YUV_INFO(YUV_YCrCb, 2, 1, 2) },
+    /* YUV planar */
+    { DRM_FORMAT_YUV420, "YU12", MAKE_YUV_INFO(YUV_YCbCr, 2, 2, 1) },
+    { DRM_FORMAT_YVU420, "YV12", MAKE_YUV_INFO(YUV_YCrCb, 2, 2, 1) },
+    /* RGB16 */
+    { DRM_FORMAT_ARGB4444, "AR12", MAKE_RGB_INFO(4, 8, 4, 4, 4, 0, 4, 12) },
+    { DRM_FORMAT_XRGB4444, "XR12", MAKE_RGB_INFO(4, 8, 4, 4, 4, 0, 0, 0) },
+    { DRM_FORMAT_ABGR4444, "AB12", MAKE_RGB_INFO(4, 0, 4, 4, 4, 8, 4, 12) },
+    { DRM_FORMAT_XBGR4444, "XB12", MAKE_RGB_INFO(4, 0, 4, 4, 4, 8, 0, 0) },
+    { DRM_FORMAT_RGBA4444, "RA12", MAKE_RGB_INFO(4, 12, 4, 8, 4, 4, 4, 0) },
+    { DRM_FORMAT_RGBX4444, "RX12", MAKE_RGB_INFO(4, 12, 4, 8, 4, 4, 0, 0) },
+    { DRM_FORMAT_BGRA4444, "BA12", MAKE_RGB_INFO(4, 4, 4, 8, 4, 12, 4, 0) },
+    { DRM_FORMAT_BGRX4444, "BX12", MAKE_RGB_INFO(4, 4, 4, 8, 4, 12, 0, 0) },
+    { DRM_FORMAT_ARGB1555, "AR15", MAKE_RGB_INFO(5, 10, 5, 5, 5, 0, 1, 15) },
+    { DRM_FORMAT_XRGB1555, "XR15", MAKE_RGB_INFO(5, 10, 5, 5, 5, 0, 0, 0) },
+    { DRM_FORMAT_ABGR1555, "AB15", MAKE_RGB_INFO(5, 0, 5, 5, 5, 10, 1, 15) },
+    { DRM_FORMAT_XBGR1555, "XB15", MAKE_RGB_INFO(5, 0, 5, 5, 5, 10, 0, 0) },
+    { DRM_FORMAT_RGBA5551, "RA15", MAKE_RGB_INFO(5, 11, 5, 6, 5, 1, 1, 0) },
+    { DRM_FORMAT_RGBX5551, "RX15", MAKE_RGB_INFO(5, 11, 5, 6, 5, 1, 0, 0) },
+    { DRM_FORMAT_BGRA5551, "BA15", MAKE_RGB_INFO(5, 1, 5, 6, 5, 11, 1, 0) },
+    { DRM_FORMAT_BGRX5551, "BX15", MAKE_RGB_INFO(5, 1, 5, 6, 5, 11, 0, 0) },
+    { DRM_FORMAT_RGB565, "RG16", MAKE_RGB_INFO(5, 11, 6, 5, 5, 0, 0, 0) },
+    { DRM_FORMAT_BGR565, "BG16", MAKE_RGB_INFO(5, 0, 6, 5, 5, 11, 0, 0) },
+    /* RGB24 */
+    { DRM_FORMAT_BGR888, "BG24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 0, 0) },
+    { DRM_FORMAT_RGB888, "RG24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 0) },
+    /* RGB32 */
+    { DRM_FORMAT_ARGB8888, "AR24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 8, 24) },
+    { DRM_FORMAT_XRGB8888, "XR24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 0) },
+    { DRM_FORMAT_ABGR8888, "AB24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 8, 24) },
+    { DRM_FORMAT_XBGR8888, "XB24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 0, 0) },
+    { DRM_FORMAT_RGBA8888, "RA24", MAKE_RGB_INFO(8, 24, 8, 16, 8, 8, 8, 0) },
+    { DRM_FORMAT_RGBX8888, "RX24", MAKE_RGB_INFO(8, 24, 8, 16, 8, 8, 0, 0) },
+    { DRM_FORMAT_BGRA8888, "BA24", MAKE_RGB_INFO(8, 8, 8, 16, 8, 24, 8, 0) },
+    { DRM_FORMAT_BGRX8888, "BX24", MAKE_RGB_INFO(8, 8, 8, 16, 8, 24, 0, 0) },
+    { DRM_FORMAT_ARGB2101010, "AR30", MAKE_RGB_INFO(10, 20, 10, 10, 10, 0, 2, 30) },
+    { DRM_FORMAT_XRGB2101010, "XR30", MAKE_RGB_INFO(10, 20, 10, 10, 10, 0, 0, 0) },
+    { DRM_FORMAT_ABGR2101010, "AB30", MAKE_RGB_INFO(10, 0, 10, 10, 10, 20, 2, 30) },
+    { DRM_FORMAT_XBGR2101010, "XB30", MAKE_RGB_INFO(10, 0, 10, 10, 10, 20, 0, 0) },
+    { DRM_FORMAT_RGBA1010102, "RA30", MAKE_RGB_INFO(10, 22, 10, 12, 10, 2, 2, 0) },
+    { DRM_FORMAT_RGBX1010102, "RX30", MAKE_RGB_INFO(10, 22, 10, 12, 10, 2, 0, 0) },
+    { DRM_FORMAT_BGRA1010102, "BA30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 2, 0) },
+    { DRM_FORMAT_BGRX1010102, "BX30", MAKE_RGB_INFO(10, 2, 10, 12, 10, 22, 0, 0) },
 };
 
 uint32_t util_format_fourcc(const char *name)
 {
-	unsigned int i;
+    unsigned int i;
 
-	for (i = 0; i < ARRAY_SIZE(format_info); i++)
-		if (!strcmp(format_info[i].name, name))
-			return format_info[i].format;
+    for (i = 0; i < ARRAY_SIZE(format_info); i++)
+        if (!strcmp(format_info[i].name, name))
+            return format_info[i].format;
 
-	return 0;
+    return 0;
 }
 
 const struct util_format_info *util_format_info_find(uint32_t format)
 {
-	unsigned int i;
+    unsigned int i;
 
-	for (i = 0; i < ARRAY_SIZE(format_info); i++)
-		if (format_info[i].format == format)
-			return &format_info[i];
+    for (i = 0; i < ARRAY_SIZE(format_info); i++)
+        if (format_info[i].format == format)
+            return &format_info[i];
 
-	return NULL;
+    return NULL;
 }
diff --git a/tests/util/format.h b/tests/util/format.h
index 2ce1c021fd78..3e3cd5469958 100644
--- a/tests/util/format.h
+++ b/tests/util/format.h
@@ -27,36 +27,36 @@
 #define UTIL_FORMAT_H
 
 struct util_color_component {
-	unsigned int length;
-	unsigned int offset;
+    unsigned int length;
+    unsigned int offset;
 };
 
 struct util_rgb_info {
-	struct util_color_component red;
-	struct util_color_component green;
-	struct util_color_component blue;
-	struct util_color_component alpha;
+    struct util_color_component red;
+    struct util_color_component green;
+    struct util_color_component blue;
+    struct util_color_component alpha;
 };
 
 enum util_yuv_order {
-	YUV_YCbCr = 1,
-	YUV_YCrCb = 2,
-	YUV_YC = 4,
-	YUV_CY = 8,
+    YUV_YCbCr = 1,
+    YUV_YCrCb = 2,
+    YUV_YC = 4,
+    YUV_CY = 8,
 };
 
 struct util_yuv_info {
-	enum util_yuv_order order;
-	unsigned int xsub;
-	unsigned int ysub;
-	unsigned int chroma_stride;
+    enum util_yuv_order order;
+    unsigned int xsub;
+    unsigned int ysub;
+    unsigned int chroma_stride;
 };
 
 struct util_format_info {
-	uint32_t format;
-	const char *name;
-	const struct util_rgb_info rgb;
-	const struct util_yuv_info yuv;
+    uint32_t format;
+    const char *name;
+    const struct util_rgb_info rgb;
+    const struct util_yuv_info yuv;
 };
 
 uint32_t util_format_fourcc(const char *name);
diff --git a/tests/util/kms.c b/tests/util/kms.c
index 959b688158bd..d866398237bb 100644
--- a/tests/util/kms.c
+++ b/tests/util/kms.c
@@ -53,131 +53,131 @@
 #include "common.h"
 
 struct type_name {
-	unsigned int type;
-	const char *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)
+                                         const struct type_name *table,
+                                         unsigned int count)
 {
-	unsigned int i;
+    unsigned int i;
 
-	for (i = 0; i < count; i++)
-		if (table[i].type == type)
-			return table[i].name;
+    for (i = 0; i < count; i++)
+        if (table[i].type == type)
+            return table[i].name;
 
-	return NULL;
+    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, "DPMST" },
+    { 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, "DPMST" },
 };
 
 const char *util_lookup_encoder_type_name(unsigned int type)
 {
-	return util_lookup_type_name(type, encoder_type_names,
-				     ARRAY_SIZE(encoder_type_names));
+    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" },
+    { 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));
+    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" },
+    { 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));
+    return util_lookup_type_name(type, connector_type_names,
+                                 ARRAY_SIZE(connector_type_names));
 }
 
 static const char * const modules[] = {
-	"i915",
-	"amdgpu",
-	"radeon",
-	"nouveau",
-	"vmwgfx",
-	"omapdrm",
-	"exynos",
-	"tilcdc",
-	"msm",
-	"sti",
-	"tegra",
-	"imx-drm",
-	"rockchip",
-	"atmel-hlcdc",
-	"fsl-dcu-drm",
-	"vc4",
-	"virtio_gpu",
-	"mediatek",
-	"meson",
+    "i915",
+    "amdgpu",
+    "radeon",
+    "nouveau",
+    "vmwgfx",
+    "omapdrm",
+    "exynos",
+    "tilcdc",
+    "msm",
+    "sti",
+    "tegra",
+    "imx-drm",
+    "rockchip",
+    "atmel-hlcdc",
+    "fsl-dcu-drm",
+    "vc4",
+    "virtio_gpu",
+    "mediatek",
+    "meson",
 };
 
 int util_open(const char *device, const char *module)
 {
-	int fd;
-
-	if (module) {
-		fd = drmOpen(module, device);
-		if (fd < 0) {
-			fprintf(stderr, "failed to open device '%s': %s\n",
-				module, strerror(errno));
-			return -errno;
-		}
-	} else {
-		unsigned int i;
-
-		for (i = 0; i < ARRAY_SIZE(modules); i++) {
-			printf("trying to open device '%s'...", modules[i]);
-
-			fd = drmOpen(modules[i], device);
-			if (fd < 0) {
-				printf("failed\n");
-			} else {
-				printf("done\n");
-				break;
-			}
-		}
-
-		if (fd < 0) {
-			fprintf(stderr, "no device found\n");
-			return -ENODEV;
-		}
-	}
-
-	return fd;
+    int fd;
+
+    if (module) {
+        fd = drmOpen(module, device);
+        if (fd < 0) {
+            fprintf(stderr, "failed to open device '%s': %s\n",
+                module, strerror(errno));
+            return -errno;
+        }
+    } else {
+        unsigned int i;
+
+        for (i = 0; i < ARRAY_SIZE(modules); i++) {
+            printf("trying to open device '%s'...", modules[i]);
+
+            fd = drmOpen(modules[i], device);
+            if (fd < 0) {
+                printf("failed\n");
+            } else {
+                printf("done\n");
+                break;
+            }
+        }
+
+        if (fd < 0) {
+            fprintf(stderr, "no device found\n");
+            return -ENODEV;
+        }
+    }
+
+    return fd;
 }
diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 00b08a8cb8eb..5d653afbee24 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -43,499 +43,497 @@
 #include "pattern.h"
 
 struct color_rgb24 {
-	unsigned int value:24;
+    unsigned int value:24;
 } __attribute__((__packed__));
 
 struct color_yuv {
-	unsigned char y;
-	unsigned char u;
-	unsigned char v;
+    unsigned char y;
+    unsigned char u;
+    unsigned char v;
 };
 
 #define MAKE_YUV_601_Y(r, g, b) \
-	((( 66 * (r) + 129 * (g) +  25 * (b) + 128) >> 8) + 16)
+    ((( 66 * (r) + 129 * (g) +  25 * (b) + 128) >> 8) + 16)
 #define MAKE_YUV_601_U(r, g, b) \
-	(((-38 * (r) -  74 * (g) + 112 * (b) + 128) >> 8) + 128)
+    (((-38 * (r) -  74 * (g) + 112 * (b) + 128) >> 8) + 128)
 #define MAKE_YUV_601_V(r, g, b) \
-	(((112 * (r) -  94 * (g) -  18 * (b) + 128) >> 8) + 128)
+    (((112 * (r) -  94 * (g) -  18 * (b) + 128) >> 8) + 128)
 
 #define MAKE_YUV_601(r, g, b) \
-	{ .y = MAKE_YUV_601_Y(r, g, b), \
-	  .u = MAKE_YUV_601_U(r, g, b), \
-	  .v = MAKE_YUV_601_V(r, g, b) }
+    { .y = MAKE_YUV_601_Y(r, g, b), \
+      .u = MAKE_YUV_601_U(r, g, b), \
+      .v = MAKE_YUV_601_V(r, g, b) }
 
 #define MAKE_RGBA(rgb, r, g, b, a) \
-	((((r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \
-	 (((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \
-	 (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \
-	 (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset))
+    ((((r) >> (8 - (rgb)->red.length)) << (rgb)->red.offset) | \
+     (((g) >> (8 - (rgb)->green.length)) << (rgb)->green.offset) | \
+     (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \
+     (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset))
 
 #define MAKE_RGB24(rgb, r, g, b) \
-	{ .value = MAKE_RGBA(rgb, r, g, b, 0) }
+    { .value = MAKE_RGBA(rgb, r, g, b, 0) }
 
 static void fill_smpte_yuv_planar(const struct util_yuv_info *yuv,
-				  unsigned char *y_mem, unsigned char *u_mem,
-				  unsigned char *v_mem, unsigned int width,
-				  unsigned int height, unsigned int stride)
+                                  unsigned char *y_mem, unsigned char *u_mem,
+                                  unsigned char *v_mem, unsigned int width,
+                                  unsigned int height, unsigned int stride)
 {
-	const struct color_yuv colors_top[] = {
-		MAKE_YUV_601(191, 192, 192),	/* grey */
-		MAKE_YUV_601(192, 192, 0),	/* yellow */
-		MAKE_YUV_601(0, 192, 192),	/* cyan */
-		MAKE_YUV_601(0, 192, 0),	/* green */
-		MAKE_YUV_601(192, 0, 192),	/* magenta */
-		MAKE_YUV_601(192, 0, 0),	/* red */
-		MAKE_YUV_601(0, 0, 192),	/* blue */
-	};
-	const struct color_yuv colors_middle[] = {
-		MAKE_YUV_601(0, 0, 192),	/* blue */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(192, 0, 192),	/* magenta */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(0, 192, 192),	/* cyan */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(192, 192, 192),	/* grey */
-	};
-	const struct color_yuv colors_bottom[] = {
-		MAKE_YUV_601(0, 33, 76),	/* in-phase */
-		MAKE_YUV_601(255, 255, 255),	/* super white */
-		MAKE_YUV_601(50, 0, 106),	/* quadrature */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(9, 9, 9),		/* 3.5% */
-		MAKE_YUV_601(19, 19, 19),	/* 7.5% */
-		MAKE_YUV_601(29, 29, 29),	/* 11.5% */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-	};
-	unsigned int cs = yuv->chroma_stride;
-	unsigned int xsub = yuv->xsub;
-	unsigned int ysub = yuv->ysub;
-	unsigned int x;
-	unsigned int y;
-
-	/* Luma */
-	for (y = 0; y < height * 6 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			y_mem[x] = colors_top[x * 7 / width].y;
-		y_mem += stride;
-	}
-
-	for (; y < height * 7 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			y_mem[x] = colors_middle[x * 7 / width].y;
-		y_mem += stride;
-	}
-
-	for (; y < height; ++y) {
-		for (x = 0; x < width * 5 / 7; ++x)
-			y_mem[x] = colors_bottom[x * 4 / (width * 5 / 7)].y;
-		for (; x < width * 6 / 7; ++x)
-			y_mem[x] = colors_bottom[(x - width * 5 / 7) * 3
-						 / (width / 7) + 4].y;
-		for (; x < width; ++x)
-			y_mem[x] = colors_bottom[7].y;
-		y_mem += stride;
-	}
-
-	/* Chroma */
-	for (y = 0; y < height / ysub * 6 / 9; ++y) {
-		for (x = 0; x < width; x += xsub) {
-			u_mem[x*cs/xsub] = colors_top[x * 7 / width].u;
-			v_mem[x*cs/xsub] = colors_top[x * 7 / width].v;
-		}
-		u_mem += stride * cs / xsub;
-		v_mem += stride * cs / xsub;
-	}
-
-	for (; y < height / ysub * 7 / 9; ++y) {
-		for (x = 0; x < width; x += xsub) {
-			u_mem[x*cs/xsub] = colors_middle[x * 7 / width].u;
-			v_mem[x*cs/xsub] = colors_middle[x * 7 / width].v;
-		}
-		u_mem += stride * cs / xsub;
-		v_mem += stride * cs / xsub;
-	}
-
-	for (; y < height / ysub; ++y) {
-		for (x = 0; x < width * 5 / 7; x += xsub) {
-			u_mem[x*cs/xsub] =
-				colors_bottom[x * 4 / (width * 5 / 7)].u;
-			v_mem[x*cs/xsub] =
-				colors_bottom[x * 4 / (width * 5 / 7)].v;
-		}
-		for (; x < width * 6 / 7; x += xsub) {
-			u_mem[x*cs/xsub] = colors_bottom[(x - width * 5 / 7) *
-							 3 / (width / 7) + 4].u;
-			v_mem[x*cs/xsub] = colors_bottom[(x - width * 5 / 7) *
-							 3 / (width / 7) + 4].v;
-		}
-		for (; x < width; x += xsub) {
-			u_mem[x*cs/xsub] = colors_bottom[7].u;
-			v_mem[x*cs/xsub] = colors_bottom[7].v;
-		}
-		u_mem += stride * cs / xsub;
-		v_mem += stride * cs / xsub;
-	}
+    const struct color_yuv colors_top[] = {
+        MAKE_YUV_601(191, 192, 192),    /* grey */
+        MAKE_YUV_601(192, 192, 0),  /* yellow */
+        MAKE_YUV_601(0, 192, 192),  /* cyan */
+        MAKE_YUV_601(0, 192, 0),    /* green */
+        MAKE_YUV_601(192, 0, 192),  /* magenta */
+        MAKE_YUV_601(192, 0, 0),    /* red */
+        MAKE_YUV_601(0, 0, 192),    /* blue */
+    };
+    const struct color_yuv colors_middle[] = {
+        MAKE_YUV_601(0, 0, 192),    /* blue */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(192, 0, 192),  /* magenta */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(0, 192, 192),  /* cyan */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(192, 192, 192),    /* grey */
+    };
+    const struct color_yuv colors_bottom[] = {
+        MAKE_YUV_601(0, 33, 76),    /* in-phase */
+        MAKE_YUV_601(255, 255, 255),    /* super white */
+        MAKE_YUV_601(50, 0, 106),   /* quadrature */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(9, 9, 9),      /* 3.5% */
+        MAKE_YUV_601(19, 19, 19),   /* 7.5% */
+        MAKE_YUV_601(29, 29, 29),   /* 11.5% */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+    };
+    unsigned int cs = yuv->chroma_stride;
+    unsigned int xsub = yuv->xsub;
+    unsigned int ysub = yuv->ysub;
+    unsigned int x;
+    unsigned int y;
+
+    /* Luma */
+    for (y = 0; y < height * 6 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            y_mem[x] = colors_top[x * 7 / width].y;
+        y_mem += stride;
+    }
+
+    for (; y < height * 7 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            y_mem[x] = colors_middle[x * 7 / width].y;
+        y_mem += stride;
+    }
+
+    for (; y < height; ++y) {
+        for (x = 0; x < width * 5 / 7; ++x)
+            y_mem[x] = colors_bottom[x * 4 / (width * 5 / 7)].y;
+        for (; x < width * 6 / 7; ++x)
+            y_mem[x] = colors_bottom[(x - width * 5 / 7) * 3
+                         / (width / 7) + 4].y;
+        for (; x < width; ++x)
+            y_mem[x] = colors_bottom[7].y;
+        y_mem += stride;
+    }
+
+    /* Chroma */
+    for (y = 0; y < height / ysub * 6 / 9; ++y) {
+        for (x = 0; x < width; x += xsub) {
+            u_mem[x*cs/xsub] = colors_top[x * 7 / width].u;
+            v_mem[x*cs/xsub] = colors_top[x * 7 / width].v;
+        }
+        u_mem += stride * cs / xsub;
+        v_mem += stride * cs / xsub;
+    }
+
+    for (; y < height / ysub * 7 / 9; ++y) {
+        for (x = 0; x < width; x += xsub) {
+            u_mem[x*cs/xsub] = colors_middle[x * 7 / width].u;
+            v_mem[x*cs/xsub] = colors_middle[x * 7 / width].v;
+        }
+        u_mem += stride * cs / xsub;
+        v_mem += stride * cs / xsub;
+    }
+
+    for (; y < height / ysub; ++y) {
+        for (x = 0; x < width * 5 / 7; x += xsub) {
+            u_mem[x*cs/xsub] =
+                colors_bottom[x * 4 / (width * 5 / 7)].u;
+            v_mem[x*cs/xsub] =
+                colors_bottom[x * 4 / (width * 5 / 7)].v;
+        }
+        for (; x < width * 6 / 7; x += xsub) {
+            u_mem[x*cs/xsub] = colors_bottom[(x - width * 5 / 7) *
+                             3 / (width / 7) + 4].u;
+            v_mem[x*cs/xsub] = colors_bottom[(x - width * 5 / 7) *
+                             3 / (width / 7) + 4].v;
+        }
+        for (; x < width; x += xsub) {
+            u_mem[x*cs/xsub] = colors_bottom[7].u;
+            v_mem[x*cs/xsub] = colors_bottom[7].v;
+        }
+        u_mem += stride * cs / xsub;
+        v_mem += stride * cs / xsub;
+    }
 }
 
 static void fill_smpte_yuv_packed(const struct util_yuv_info *yuv, void *mem,
-				  unsigned int width, unsigned int height,
-				  unsigned int stride)
+                                  unsigned int width, unsigned int height,
+                                  unsigned int stride)
 {
-	const struct color_yuv colors_top[] = {
-		MAKE_YUV_601(191, 192, 192),	/* grey */
-		MAKE_YUV_601(192, 192, 0),	/* yellow */
-		MAKE_YUV_601(0, 192, 192),	/* cyan */
-		MAKE_YUV_601(0, 192, 0),	/* green */
-		MAKE_YUV_601(192, 0, 192),	/* magenta */
-		MAKE_YUV_601(192, 0, 0),	/* red */
-		MAKE_YUV_601(0, 0, 192),	/* blue */
-	};
-	const struct color_yuv colors_middle[] = {
-		MAKE_YUV_601(0, 0, 192),	/* blue */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(192, 0, 192),	/* magenta */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(0, 192, 192),	/* cyan */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(192, 192, 192),	/* grey */
-	};
-	const struct color_yuv colors_bottom[] = {
-		MAKE_YUV_601(0, 33, 76),	/* in-phase */
-		MAKE_YUV_601(255, 255, 255),	/* super white */
-		MAKE_YUV_601(50, 0, 106),	/* quadrature */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-		MAKE_YUV_601(9, 9, 9),		/* 3.5% */
-		MAKE_YUV_601(19, 19, 19),	/* 7.5% */
-		MAKE_YUV_601(29, 29, 29),	/* 11.5% */
-		MAKE_YUV_601(19, 19, 19),	/* black */
-	};
-	unsigned char *y_mem = (yuv->order & YUV_YC) ? mem : mem + 1;
-	unsigned char *c_mem = (yuv->order & YUV_CY) ? mem : mem + 1;
-	unsigned int u = (yuv->order & YUV_YCrCb) ? 2 : 0;
-	unsigned int v = (yuv->order & YUV_YCbCr) ? 2 : 0;
-	unsigned int x;
-	unsigned int y;
-
-	/* Luma */
-	for (y = 0; y < height * 6 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			y_mem[2*x] = colors_top[x * 7 / width].y;
-		y_mem += stride;
-	}
-
-	for (; y < height * 7 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			y_mem[2*x] = colors_middle[x * 7 / width].y;
-		y_mem += stride;
-	}
-
-	for (; y < height; ++y) {
-		for (x = 0; x < width * 5 / 7; ++x)
-			y_mem[2*x] = colors_bottom[x * 4 / (width * 5 / 7)].y;
-		for (; x < width * 6 / 7; ++x)
-			y_mem[2*x] = colors_bottom[(x - width * 5 / 7) * 3
-						   / (width / 7) + 4].y;
-		for (; x < width; ++x)
-			y_mem[2*x] = colors_bottom[7].y;
-		y_mem += stride;
-	}
-
-	/* Chroma */
-	for (y = 0; y < height * 6 / 9; ++y) {
-		for (x = 0; x < width; x += 2) {
-			c_mem[2*x+u] = colors_top[x * 7 / width].u;
-			c_mem[2*x+v] = colors_top[x * 7 / width].v;
-		}
-		c_mem += stride;
-	}
-
-	for (; y < height * 7 / 9; ++y) {
-		for (x = 0; x < width; x += 2) {
-			c_mem[2*x+u] = colors_middle[x * 7 / width].u;
-			c_mem[2*x+v] = colors_middle[x * 7 / width].v;
-		}
-		c_mem += stride;
-	}
-
-	for (; y < height; ++y) {
-		for (x = 0; x < width * 5 / 7; x += 2) {
-			c_mem[2*x+u] = colors_bottom[x * 4 / (width * 5 / 7)].u;
-			c_mem[2*x+v] = colors_bottom[x * 4 / (width * 5 / 7)].v;
-		}
-		for (; x < width * 6 / 7; x += 2) {
-			c_mem[2*x+u] = colors_bottom[(x - width * 5 / 7) *
-						     3 / (width / 7) + 4].u;
-			c_mem[2*x+v] = colors_bottom[(x - width * 5 / 7) *
-						     3 / (width / 7) + 4].v;
-		}
-		for (; x < width; x += 2) {
-			c_mem[2*x+u] = colors_bottom[7].u;
-			c_mem[2*x+v] = colors_bottom[7].v;
-		}
-		c_mem += stride;
-	}
+    const struct color_yuv colors_top[] = {
+        MAKE_YUV_601(191, 192, 192),    /* grey */
+        MAKE_YUV_601(192, 192, 0),  /* yellow */
+        MAKE_YUV_601(0, 192, 192),  /* cyan */
+        MAKE_YUV_601(0, 192, 0),    /* green */
+        MAKE_YUV_601(192, 0, 192),  /* magenta */
+        MAKE_YUV_601(192, 0, 0),    /* red */
+        MAKE_YUV_601(0, 0, 192),    /* blue */
+    };
+    const struct color_yuv colors_middle[] = {
+        MAKE_YUV_601(0, 0, 192),    /* blue */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(192, 0, 192),  /* magenta */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(0, 192, 192),  /* cyan */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(192, 192, 192),    /* grey */
+    };
+    const struct color_yuv colors_bottom[] = {
+        MAKE_YUV_601(0, 33, 76),    /* in-phase */
+        MAKE_YUV_601(255, 255, 255),    /* super white */
+        MAKE_YUV_601(50, 0, 106),   /* quadrature */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+        MAKE_YUV_601(9, 9, 9),      /* 3.5% */
+        MAKE_YUV_601(19, 19, 19),   /* 7.5% */
+        MAKE_YUV_601(29, 29, 29),   /* 11.5% */
+        MAKE_YUV_601(19, 19, 19),   /* black */
+    };
+    unsigned char *y_mem = (yuv->order & YUV_YC) ? mem : mem + 1;
+    unsigned char *c_mem = (yuv->order & YUV_CY) ? mem : mem + 1;
+    unsigned int u = (yuv->order & YUV_YCrCb) ? 2 : 0;
+    unsigned int v = (yuv->order & YUV_YCbCr) ? 2 : 0;
+    unsigned int x;
+    unsigned int y;
+
+    /* Luma */
+    for (y = 0; y < height * 6 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            y_mem[2*x] = colors_top[x * 7 / width].y;
+        y_mem += stride;
+    }
+
+    for (; y < height * 7 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            y_mem[2*x] = colors_middle[x * 7 / width].y;
+        y_mem += stride;
+    }
+
+    for (; y < height; ++y) {
+        for (x = 0; x < width * 5 / 7; ++x)
+            y_mem[2*x] = colors_bottom[x * 4 / (width * 5 / 7)].y;
+        for (; x < width * 6 / 7; ++x)
+            y_mem[2*x] = colors_bottom[(x - width * 5 / 7) * 3
+                           / (width / 7) + 4].y;
+        for (; x < width; ++x)
+            y_mem[2*x] = colors_bottom[7].y;
+        y_mem += stride;
+    }
+
+    /* Chroma */
+    for (y = 0; y < height * 6 / 9; ++y) {
+        for (x = 0; x < width; x += 2) {
+            c_mem[2*x+u] = colors_top[x * 7 / width].u;
+            c_mem[2*x+v] = colors_top[x * 7 / width].v;
+        }
+        c_mem += stride;
+    }
+
+    for (; y < height * 7 / 9; ++y) {
+        for (x = 0; x < width; x += 2) {
+            c_mem[2*x+u] = colors_middle[x * 7 / width].u;
+            c_mem[2*x+v] = colors_middle[x * 7 / width].v;
+        }
+        c_mem += stride;
+    }
+
+    for (; y < height; ++y) {
+        for (x = 0; x < width * 5 / 7; x += 2) {
+            c_mem[2*x+u] = colors_bottom[x * 4 / (width * 5 / 7)].u;
+            c_mem[2*x+v] = colors_bottom[x * 4 / (width * 5 / 7)].v;
+        }
+        for (; x < width * 6 / 7; x += 2) {
+            c_mem[2*x+u] = colors_bottom[(x - width * 5 / 7) *
+                             3 / (width / 7) + 4].u;
+            c_mem[2*x+v] = colors_bottom[(x - width * 5 / 7) *
+                             3 / (width / 7) + 4].v;
+        }
+        for (; x < width; x += 2) {
+            c_mem[2*x+u] = colors_bottom[7].u;
+            c_mem[2*x+v] = colors_bottom[7].v;
+        }
+        c_mem += stride;
+    }
 }
 
 static void fill_smpte_rgb16(const struct util_rgb_info *rgb, void *mem,
-			     unsigned int width, unsigned int height,
-			     unsigned int stride)
+                             unsigned int width, unsigned int height,
+                             unsigned int stride)
 {
-	const uint16_t colors_top[] = {
-		MAKE_RGBA(rgb, 192, 192, 192, 255),	/* grey */
-		MAKE_RGBA(rgb, 192, 192, 0, 255),	/* yellow */
-		MAKE_RGBA(rgb, 0, 192, 192, 255),	/* cyan */
-		MAKE_RGBA(rgb, 0, 192, 0, 255),		/* green */
-		MAKE_RGBA(rgb, 192, 0, 192, 255),	/* magenta */
-		MAKE_RGBA(rgb, 192, 0, 0, 255),		/* red */
-		MAKE_RGBA(rgb, 0, 0, 192, 255),		/* blue */
-	};
-	const uint16_t colors_middle[] = {
-		MAKE_RGBA(rgb, 0, 0, 192, 127),		/* blue */
-		MAKE_RGBA(rgb, 19, 19, 19, 127),	/* black */
-		MAKE_RGBA(rgb, 192, 0, 192, 127),	/* magenta */
-		MAKE_RGBA(rgb, 19, 19, 19, 127),	/* black */
-		MAKE_RGBA(rgb, 0, 192, 192, 127),	/* cyan */
-		MAKE_RGBA(rgb, 19, 19, 19, 127),	/* black */
-		MAKE_RGBA(rgb, 192, 192, 192, 127),	/* grey */
-	};
-	const uint16_t colors_bottom[] = {
-		MAKE_RGBA(rgb, 0, 33, 76, 255),		/* in-phase */
-		MAKE_RGBA(rgb, 255, 255, 255, 255),	/* super white */
-		MAKE_RGBA(rgb, 50, 0, 106, 255),	/* quadrature */
-		MAKE_RGBA(rgb, 19, 19, 19, 255),	/* black */
-		MAKE_RGBA(rgb, 9, 9, 9, 255),		/* 3.5% */
-		MAKE_RGBA(rgb, 19, 19, 19, 255),	/* 7.5% */
-		MAKE_RGBA(rgb, 29, 29, 29, 255),	/* 11.5% */
-		MAKE_RGBA(rgb, 19, 19, 19, 255),	/* black */
-	};
-	unsigned int x;
-	unsigned int y;
-
-	for (y = 0; y < height * 6 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			((uint16_t *)mem)[x] = colors_top[x * 7 / width];
-		mem += stride;
-	}
-
-	for (; y < height * 7 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			((uint16_t *)mem)[x] = colors_middle[x * 7 / width];
-		mem += stride;
-	}
-
-	for (; y < height; ++y) {
-		for (x = 0; x < width * 5 / 7; ++x)
-			((uint16_t *)mem)[x] =
-				colors_bottom[x * 4 / (width * 5 / 7)];
-		for (; x < width * 6 / 7; ++x)
-			((uint16_t *)mem)[x] =
-				colors_bottom[(x - width * 5 / 7) * 3
-					      / (width / 7) + 4];
-		for (; x < width; ++x)
-			((uint16_t *)mem)[x] = colors_bottom[7];
-		mem += stride;
-	}
+    const uint16_t colors_top[] = {
+        MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */
+        MAKE_RGBA(rgb, 192, 192, 0, 255),   /* yellow */
+        MAKE_RGBA(rgb, 0, 192, 192, 255),   /* cyan */
+        MAKE_RGBA(rgb, 0, 192, 0, 255),     /* green */
+        MAKE_RGBA(rgb, 192, 0, 192, 255),   /* magenta */
+        MAKE_RGBA(rgb, 192, 0, 0, 255),     /* red */
+        MAKE_RGBA(rgb, 0, 0, 192, 255),     /* blue */
+    };
+    const uint16_t colors_middle[] = {
+        MAKE_RGBA(rgb, 0, 0, 192, 127),     /* blue */
+        MAKE_RGBA(rgb, 19, 19, 19, 127),    /* black */
+        MAKE_RGBA(rgb, 192, 0, 192, 127),   /* magenta */
+        MAKE_RGBA(rgb, 19, 19, 19, 127),    /* black */
+        MAKE_RGBA(rgb, 0, 192, 192, 127),   /* cyan */
+        MAKE_RGBA(rgb, 19, 19, 19, 127),    /* black */
+        MAKE_RGBA(rgb, 192, 192, 192, 127), /* grey */
+    };
+    const uint16_t colors_bottom[] = {
+        MAKE_RGBA(rgb, 0, 33, 76, 255),     /* in-phase */
+        MAKE_RGBA(rgb, 255, 255, 255, 255), /* super white */
+        MAKE_RGBA(rgb, 50, 0, 106, 255),    /* quadrature */
+        MAKE_RGBA(rgb, 19, 19, 19, 255),    /* black */
+        MAKE_RGBA(rgb, 9, 9, 9, 255),       /* 3.5% */
+        MAKE_RGBA(rgb, 19, 19, 19, 255),    /* 7.5% */
+        MAKE_RGBA(rgb, 29, 29, 29, 255),    /* 11.5% */
+        MAKE_RGBA(rgb, 19, 19, 19, 255),    /* black */
+    };
+    unsigned int x;
+    unsigned int y;
+
+    for (y = 0; y < height * 6 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            ((uint16_t *)mem)[x] = colors_top[x * 7 / width];
+        mem += stride;
+    }
+
+    for (; y < height * 7 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            ((uint16_t *)mem)[x] = colors_middle[x * 7 / width];
+        mem += stride;
+    }
+
+    for (; y < height; ++y) {
+        for (x = 0; x < width * 5 / 7; ++x)
+            ((uint16_t *)mem)[x] =
+                colors_bottom[x * 4 / (width * 5 / 7)];
+        for (; x < width * 6 / 7; ++x)
+            ((uint16_t *)mem)[x] =
+                colors_bottom[(x - width * 5 / 7) * 3
+                          / (width / 7) + 4];
+        for (; x < width; ++x)
+            ((uint16_t *)mem)[x] = colors_bottom[7];
+        mem += stride;
+    }
 }
 
 static void fill_smpte_rgb24(const struct util_rgb_info *rgb, void *mem,
-			     unsigned int width, unsigned int height,
-			     unsigned int stride)
+                             unsigned int width, unsigned int height,
+                             unsigned int stride)
 {
-	const struct color_rgb24 colors_top[] = {
-		MAKE_RGB24(rgb, 192, 192, 192),	/* grey */
-		MAKE_RGB24(rgb, 192, 192, 0),	/* yellow */
-		MAKE_RGB24(rgb, 0, 192, 192),	/* cyan */
-		MAKE_RGB24(rgb, 0, 192, 0),	/* green */
-		MAKE_RGB24(rgb, 192, 0, 192),	/* magenta */
-		MAKE_RGB24(rgb, 192, 0, 0),	/* red */
-		MAKE_RGB24(rgb, 0, 0, 192),	/* blue */
-	};
-	const struct color_rgb24 colors_middle[] = {
-		MAKE_RGB24(rgb, 0, 0, 192),	/* blue */
-		MAKE_RGB24(rgb, 19, 19, 19),	/* black */
-		MAKE_RGB24(rgb, 192, 0, 192),	/* magenta */
-		MAKE_RGB24(rgb, 19, 19, 19),	/* black */
-		MAKE_RGB24(rgb, 0, 192, 192),	/* cyan */
-		MAKE_RGB24(rgb, 19, 19, 19),	/* black */
-		MAKE_RGB24(rgb, 192, 192, 192),	/* grey */
-	};
-	const struct color_rgb24 colors_bottom[] = {
-		MAKE_RGB24(rgb, 0, 33, 76),	/* in-phase */
-		MAKE_RGB24(rgb, 255, 255, 255),	/* super white */
-		MAKE_RGB24(rgb, 50, 0, 106),	/* quadrature */
-		MAKE_RGB24(rgb, 19, 19, 19),	/* black */
-		MAKE_RGB24(rgb, 9, 9, 9),	/* 3.5% */
-		MAKE_RGB24(rgb, 19, 19, 19),	/* 7.5% */
-		MAKE_RGB24(rgb, 29, 29, 29),	/* 11.5% */
-		MAKE_RGB24(rgb, 19, 19, 19),	/* black */
-	};
-	unsigned int x;
-	unsigned int y;
-
-	for (y = 0; y < height * 6 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			((struct color_rgb24 *)mem)[x] =
-				colors_top[x * 7 / width];
-		mem += stride;
-	}
-
-	for (; y < height * 7 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			((struct color_rgb24 *)mem)[x] =
-				colors_middle[x * 7 / width];
-		mem += stride;
-	}
-
-	for (; y < height; ++y) {
-		for (x = 0; x < width * 5 / 7; ++x)
-			((struct color_rgb24 *)mem)[x] =
-				colors_bottom[x * 4 / (width * 5 / 7)];
-		for (; x < width * 6 / 7; ++x)
-			((struct color_rgb24 *)mem)[x] =
-				colors_bottom[(x - width * 5 / 7) * 3
-					      / (width / 7) + 4];
-		for (; x < width; ++x)
-			((struct color_rgb24 *)mem)[x] = colors_bottom[7];
-		mem += stride;
-	}
+    const struct color_rgb24 colors_top[] = {
+        MAKE_RGB24(rgb, 192, 192, 192), /* grey */
+        MAKE_RGB24(rgb, 192, 192, 0),   /* yellow */
+        MAKE_RGB24(rgb, 0, 192, 192),   /* cyan */
+        MAKE_RGB24(rgb, 0, 192, 0), /* green */
+        MAKE_RGB24(rgb, 192, 0, 192),   /* magenta */
+        MAKE_RGB24(rgb, 192, 0, 0), /* red */
+        MAKE_RGB24(rgb, 0, 0, 192), /* blue */
+    };
+    const struct color_rgb24 colors_middle[] = {
+        MAKE_RGB24(rgb, 0, 0, 192), /* blue */
+        MAKE_RGB24(rgb, 19, 19, 19),    /* black */
+        MAKE_RGB24(rgb, 192, 0, 192),   /* magenta */
+        MAKE_RGB24(rgb, 19, 19, 19),    /* black */
+        MAKE_RGB24(rgb, 0, 192, 192),   /* cyan */
+        MAKE_RGB24(rgb, 19, 19, 19),    /* black */
+        MAKE_RGB24(rgb, 192, 192, 192), /* grey */
+    };
+    const struct color_rgb24 colors_bottom[] = {
+        MAKE_RGB24(rgb, 0, 33, 76), /* in-phase */
+        MAKE_RGB24(rgb, 255, 255, 255), /* super white */
+        MAKE_RGB24(rgb, 50, 0, 106),    /* quadrature */
+        MAKE_RGB24(rgb, 19, 19, 19),    /* black */
+        MAKE_RGB24(rgb, 9, 9, 9),   /* 3.5% */
+        MAKE_RGB24(rgb, 19, 19, 19),    /* 7.5% */
+        MAKE_RGB24(rgb, 29, 29, 29),    /* 11.5% */
+        MAKE_RGB24(rgb, 19, 19, 19),    /* black */
+    };
+    unsigned int x;
+    unsigned int y;
+
+    for (y = 0; y < height * 6 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            ((struct color_rgb24 *)mem)[x] =
+                colors_top[x * 7 / width];
+        mem += stride;
+    }
+
+    for (; y < height * 7 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            ((struct color_rgb24 *)mem)[x] =
+                colors_middle[x * 7 / width];
+        mem += stride;
+    }
+
+    for (; y < height; ++y) {
+        for (x = 0; x < width * 5 / 7; ++x)
+            ((struct color_rgb24 *)mem)[x] =
+                colors_bottom[x * 4 / (width * 5 / 7)];
+        for (; x < width * 6 / 7; ++x)
+            ((struct color_rgb24 *)mem)[x] =
+                colors_bottom[(x - width * 5 / 7) * 3
+                          / (width / 7) + 4];
+        for (; x < width; ++x)
+            ((struct color_rgb24 *)mem)[x] = colors_bottom[7];
+        mem += stride;
+    }
 }
 
 static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem,
-			     unsigned int width, unsigned int height,
-			     unsigned int stride)
+                             unsigned int width, unsigned int height,
+                             unsigned int stride)
 {
-	const uint32_t colors_top[] = {
-		MAKE_RGBA(rgb, 192, 192, 192, 255),	/* grey */
-		MAKE_RGBA(rgb, 192, 192, 0, 255),	/* yellow */
-		MAKE_RGBA(rgb, 0, 192, 192, 255),	/* cyan */
-		MAKE_RGBA(rgb, 0, 192, 0, 255),		/* green */
-		MAKE_RGBA(rgb, 192, 0, 192, 255),	/* magenta */
-		MAKE_RGBA(rgb, 192, 0, 0, 255),		/* red */
-		MAKE_RGBA(rgb, 0, 0, 192, 255),		/* blue */
-	};
-	const uint32_t colors_middle[] = {
-		MAKE_RGBA(rgb, 0, 0, 192, 127),		/* blue */
-		MAKE_RGBA(rgb, 19, 19, 19, 127),	/* black */
-		MAKE_RGBA(rgb, 192, 0, 192, 127),	/* magenta */
-		MAKE_RGBA(rgb, 19, 19, 19, 127),	/* black */
-		MAKE_RGBA(rgb, 0, 192, 192, 127),	/* cyan */
-		MAKE_RGBA(rgb, 19, 19, 19, 127),	/* black */
-		MAKE_RGBA(rgb, 192, 192, 192, 127),	/* grey */
-	};
-	const uint32_t colors_bottom[] = {
-		MAKE_RGBA(rgb, 0, 33, 76, 255),		/* in-phase */
-		MAKE_RGBA(rgb, 255, 255, 255, 255),	/* super white */
-		MAKE_RGBA(rgb, 50, 0, 106, 255),	/* quadrature */
-		MAKE_RGBA(rgb, 19, 19, 19, 255),	/* black */
-		MAKE_RGBA(rgb, 9, 9, 9, 255),		/* 3.5% */
-		MAKE_RGBA(rgb, 19, 19, 19, 255),	/* 7.5% */
-		MAKE_RGBA(rgb, 29, 29, 29, 255),	/* 11.5% */
-		MAKE_RGBA(rgb, 19, 19, 19, 255),	/* black */
-	};
-	unsigned int x;
-	unsigned int y;
-
-	for (y = 0; y < height * 6 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			((uint32_t *)mem)[x] = colors_top[x * 7 / width];
-		mem += stride;
-	}
-
-	for (; y < height * 7 / 9; ++y) {
-		for (x = 0; x < width; ++x)
-			((uint32_t *)mem)[x] = colors_middle[x * 7 / width];
-		mem += stride;
-	}
-
-	for (; y < height; ++y) {
-		for (x = 0; x < width * 5 / 7; ++x)
-			((uint32_t *)mem)[x] =
-				colors_bottom[x * 4 / (width * 5 / 7)];
-		for (; x < width * 6 / 7; ++x)
-			((uint32_t *)mem)[x] =
-				colors_bottom[(x - width * 5 / 7) * 3
-					      / (width / 7) + 4];
-		for (; x < width; ++x)
-			((uint32_t *)mem)[x] = colors_bottom[7];
-		mem += stride;
-	}
+    const uint32_t colors_top[] = {
+        MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */
+        MAKE_RGBA(rgb, 192, 192, 0, 255),   /* yellow */
+        MAKE_RGBA(rgb, 0, 192, 192, 255),   /* cyan */
+        MAKE_RGBA(rgb, 0, 192, 0, 255),     /* green */
+        MAKE_RGBA(rgb, 192, 0, 192, 255),   /* magenta */
+        MAKE_RGBA(rgb, 192, 0, 0, 255),     /* red */
+        MAKE_RGBA(rgb, 0, 0, 192, 255),     /* blue */
+    };
+    const uint32_t colors_middle[] = {
+        MAKE_RGBA(rgb, 0, 0, 192, 127),     /* blue */
+        MAKE_RGBA(rgb, 19, 19, 19, 127),    /* black */
+        MAKE_RGBA(rgb, 192, 0, 192, 127),   /* magenta */
+        MAKE_RGBA(rgb, 19, 19, 19, 127),    /* black */
+        MAKE_RGBA(rgb, 0, 192, 192, 127),   /* cyan */
+        MAKE_RGBA(rgb, 19, 19, 19, 127),    /* black */
+        MAKE_RGBA(rgb, 192, 192, 192, 127), /* grey */
+    };
+    const uint32_t colors_bottom[] = {
+        MAKE_RGBA(rgb, 0, 33, 76, 255),     /* in-phase */
+        MAKE_RGBA(rgb, 255, 255, 255, 255), /* super white */
+        MAKE_RGBA(rgb, 50, 0, 106, 255),    /* quadrature */
+        MAKE_RGBA(rgb, 19, 19, 19, 255),    /* black */
+        MAKE_RGBA(rgb, 9, 9, 9, 255),       /* 3.5% */
+        MAKE_RGBA(rgb, 19, 19, 19, 255),    /* 7.5% */
+        MAKE_RGBA(rgb, 29, 29, 29, 255),    /* 11.5% */
+        MAKE_RGBA(rgb, 19, 19, 19, 255),    /* black */
+    };
+    unsigned int x;
+    unsigned int y;
+
+    for (y = 0; y < height * 6 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            ((uint32_t *)mem)[x] = colors_top[x * 7 / width];
+        mem += stride;
+    }
+
+    for (; y < height * 7 / 9; ++y) {
+        for (x = 0; x < width; ++x)
+            ((uint32_t *)mem)[x] = colors_middle[x * 7 / width];
+        mem += stride;
+    }
+
+    for (; y < height; ++y) {
+        for (x = 0; x < width * 5 / 7; ++x)
+            ((uint32_t *)mem)[x] =
+                colors_bottom[x * 4 / (width * 5 / 7)];
+        for (; x < width * 6 / 7; ++x)
+            ((uint32_t *)mem)[x] =
+                colors_bottom[(x - width * 5 / 7) * 3
+                          / (width / 7) + 4];
+        for (; x < width; ++x)
+            ((uint32_t *)mem)[x] = colors_bottom[7];
+        mem += stride;
+    }
 }
 
 static void fill_smpte(const struct util_format_info *info, void *planes[3],
-		       unsigned int width, unsigned int height,
-		       unsigned int stride)
+                       unsigned int width, unsigned int height,
+                       unsigned int stride)
 {
-	unsigned char *u, *v;
-
-	switch (info->format) {
-	case DRM_FORMAT_UYVY:
-	case DRM_FORMAT_VYUY:
-	case DRM_FORMAT_YUYV:
-	case DRM_FORMAT_YVYU:
-		return fill_smpte_yuv_packed(&info->yuv, planes[0], width,
-					     height, stride);
-
-	case DRM_FORMAT_NV12:
-	case DRM_FORMAT_NV21:
-	case DRM_FORMAT_NV16:
-	case DRM_FORMAT_NV61:
-		u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1;
-		v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1;
-		return fill_smpte_yuv_planar(&info->yuv, planes[0], u, v,
-					     width, height, stride);
-
-	case DRM_FORMAT_YUV420:
-		return fill_smpte_yuv_planar(&info->yuv, planes[0], planes[1],
-					     planes[2], width, height, stride);
-
-	case DRM_FORMAT_YVU420:
-		return fill_smpte_yuv_planar(&info->yuv, planes[0], planes[2],
-					     planes[1], width, height, stride);
-
-	case DRM_FORMAT_ARGB4444:
-	case DRM_FORMAT_XRGB4444:
-	case DRM_FORMAT_ABGR4444:
-	case DRM_FORMAT_XBGR4444:
-	case DRM_FORMAT_RGBA4444:
-	case DRM_FORMAT_RGBX4444:
-	case DRM_FORMAT_BGRA4444:
-	case DRM_FORMAT_BGRX4444:
-	case DRM_FORMAT_RGB565:
-	case DRM_FORMAT_BGR565:
-	case DRM_FORMAT_ARGB1555:
-	case DRM_FORMAT_XRGB1555:
-	case DRM_FORMAT_ABGR1555:
-	case DRM_FORMAT_XBGR1555:
-	case DRM_FORMAT_RGBA5551:
-	case DRM_FORMAT_RGBX5551:
-	case DRM_FORMAT_BGRA5551:
-	case DRM_FORMAT_BGRX5551:
-		return fill_smpte_rgb16(&info->rgb, planes[0],
-					width, height, stride);
-
-	case DRM_FORMAT_BGR888:
-	case DRM_FORMAT_RGB888:
-		return fill_smpte_rgb24(&info->rgb, planes[0],
-					width, height, stride);
-	case DRM_FORMAT_ARGB8888:
-	case DRM_FORMAT_XRGB8888:
-	case DRM_FORMAT_ABGR8888:
-	case DRM_FORMAT_XBGR8888:
-	case DRM_FORMAT_RGBA8888:
-	case DRM_FORMAT_RGBX8888:
-	case DRM_FORMAT_BGRA8888:
-	case DRM_FORMAT_BGRX8888:
-	case DRM_FORMAT_ARGB2101010:
-	case DRM_FORMAT_XRGB2101010:
-	case DRM_FORMAT_ABGR2101010:
-	case DRM_FORMAT_XBGR2101010:
-	case DRM_FORMAT_RGBA1010102:
-	case DRM_FORMAT_RGBX1010102:
-	case DRM_FORMAT_BGRA1010102:
-	case DRM_FORMAT_BGRX1010102:
-		return fill_smpte_rgb32(&info->rgb, planes[0],
-					width, height, stride);
-	}
+    unsigned char *u, *v;
+
+    switch (info->format) {
+    case DRM_FORMAT_UYVY:
+    case DRM_FORMAT_VYUY:
+    case DRM_FORMAT_YUYV:
+    case DRM_FORMAT_YVYU:
+        return fill_smpte_yuv_packed(&info->yuv, planes[0], width, height,
+                                     stride);
+
+    case DRM_FORMAT_NV12:
+    case DRM_FORMAT_NV21:
+    case DRM_FORMAT_NV16:
+    case DRM_FORMAT_NV61:
+        u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1;
+        v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1;
+        return fill_smpte_yuv_planar(&info->yuv, planes[0], u, v, width,
+                                     height, stride);
+
+    case DRM_FORMAT_YUV420:
+        return fill_smpte_yuv_planar(&info->yuv, planes[0], planes[1],
+                                     planes[2], width, height, stride);
+
+    case DRM_FORMAT_YVU420:
+        return fill_smpte_yuv_planar(&info->yuv, planes[0], planes[2],
+                                     planes[1], width, height, stride);
+
+    case DRM_FORMAT_ARGB4444:
+    case DRM_FORMAT_XRGB4444:
+    case DRM_FORMAT_ABGR4444:
+    case DRM_FORMAT_XBGR4444:
+    case DRM_FORMAT_RGBA4444:
+    case DRM_FORMAT_RGBX4444:
+    case DRM_FORMAT_BGRA4444:
+    case DRM_FORMAT_BGRX4444:
+    case DRM_FORMAT_RGB565:
+    case DRM_FORMAT_BGR565:
+    case DRM_FORMAT_ARGB1555:
+    case DRM_FORMAT_XRGB1555:
+    case DRM_FORMAT_ABGR1555:
+    case DRM_FORMAT_XBGR1555:
+    case DRM_FORMAT_RGBA5551:
+    case DRM_FORMAT_RGBX5551:
+    case DRM_FORMAT_BGRA5551:
+    case DRM_FORMAT_BGRX5551:
+        return fill_smpte_rgb16(&info->rgb, planes[0], width, height, stride);
+
+    case DRM_FORMAT_BGR888:
+    case DRM_FORMAT_RGB888:
+        return fill_smpte_rgb24(&info->rgb, planes[0], width, height, stride);
+
+    case DRM_FORMAT_ARGB8888:
+    case DRM_FORMAT_XRGB8888:
+    case DRM_FORMAT_ABGR8888:
+    case DRM_FORMAT_XBGR8888:
+    case DRM_FORMAT_RGBA8888:
+    case DRM_FORMAT_RGBX8888:
+    case DRM_FORMAT_BGRA8888:
+    case DRM_FORMAT_BGRX8888:
+    case DRM_FORMAT_ARGB2101010:
+    case DRM_FORMAT_XRGB2101010:
+    case DRM_FORMAT_ABGR2101010:
+    case DRM_FORMAT_XBGR2101010:
+    case DRM_FORMAT_RGBA1010102:
+    case DRM_FORMAT_RGBX1010102:
+    case DRM_FORMAT_BGRA1010102:
+    case DRM_FORMAT_BGRX1010102:
+        return fill_smpte_rgb32(&info->rgb, planes[0], width, height, stride);
+    }
 }
 
 /* swap these for big endian.. */
@@ -544,291 +542,285 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
 #define BLUE  0
 
 static void make_pwetty(void *data, unsigned int width, unsigned int height,
-			unsigned int stride, uint32_t format)
+                        unsigned int stride, uint32_t format)
 {
 #ifdef HAVE_CAIRO
-	cairo_surface_t *surface;
-	cairo_t *cr;
-	int x, y;
-	cairo_format_t cairo_format;
-
-	/* we can ignore the order of R,G,B channels */
-	switch (format) {
-	case DRM_FORMAT_XRGB8888:
-	case DRM_FORMAT_ARGB8888:
-	case DRM_FORMAT_XBGR8888:
-	case DRM_FORMAT_ABGR8888:
-		cairo_format = CAIRO_FORMAT_ARGB32;
-		break;
-	case DRM_FORMAT_RGB565:
-	case DRM_FORMAT_BGR565:
-		cairo_format = CAIRO_FORMAT_RGB16_565;
-		break;
-	default:
-		return;
-	}
-
-	surface = cairo_image_surface_create_for_data(data,
-						      cairo_format,
-						      width, height,
-						      stride);
-	cr = cairo_create(surface);
-	cairo_surface_destroy(surface);
-
-	cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
-	for (x = 0; x < width; x += 250)
-		for (y = 0; y < height; y += 250) {
-			char buf[64];
-
-			cairo_move_to(cr, x, y - 20);
-			cairo_line_to(cr, x, y + 20);
-			cairo_move_to(cr, x - 20, y);
-			cairo_line_to(cr, x + 20, y);
-			cairo_new_sub_path(cr);
-			cairo_arc(cr, x, y, 10, 0, M_PI * 2);
-			cairo_set_line_width(cr, 4);
-			cairo_set_source_rgb(cr, 0, 0, 0);
-			cairo_stroke_preserve(cr);
-			cairo_set_source_rgb(cr, 1, 1, 1);
-			cairo_set_line_width(cr, 2);
-			cairo_stroke(cr);
-
-			snprintf(buf, sizeof buf, "%d, %d", x, y);
-			cairo_move_to(cr, x + 20, y + 20);
-			cairo_text_path(cr, buf);
-			cairo_set_source_rgb(cr, 0, 0, 0);
-			cairo_stroke_preserve(cr);
-			cairo_set_source_rgb(cr, 1, 1, 1);
-			cairo_fill(cr);
-		}
-
-	cairo_destroy(cr);
+    cairo_surface_t *surface;
+    cairo_t *cr;
+    int x, y;
+    cairo_format_t cairo_format;
+
+    /* we can ignore the order of R,G,B channels */
+    switch (format) {
+    case DRM_FORMAT_XRGB8888:
+    case DRM_FORMAT_ARGB8888:
+    case DRM_FORMAT_XBGR8888:
+    case DRM_FORMAT_ABGR8888:
+        cairo_format = CAIRO_FORMAT_ARGB32;
+        break;
+    case DRM_FORMAT_RGB565:
+    case DRM_FORMAT_BGR565:
+        cairo_format = CAIRO_FORMAT_RGB16_565;
+        break;
+    default:
+        return;
+    }
+
+    surface = cairo_image_surface_create_for_data(data, cairo_format, width,
+                                                  height, stride);
+    cr = cairo_create(surface);
+    cairo_surface_destroy(surface);
+
+    cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
+    for (x = 0; x < width; x += 250)
+        for (y = 0; y < height; y += 250) {
+            char buf[64];
+
+            cairo_move_to(cr, x, y - 20);
+            cairo_line_to(cr, x, y + 20);
+            cairo_move_to(cr, x - 20, y);
+            cairo_line_to(cr, x + 20, y);
+            cairo_new_sub_path(cr);
+            cairo_arc(cr, x, y, 10, 0, M_PI * 2);
+            cairo_set_line_width(cr, 4);
+            cairo_set_source_rgb(cr, 0, 0, 0);
+            cairo_stroke_preserve(cr);
+            cairo_set_source_rgb(cr, 1, 1, 1);
+            cairo_set_line_width(cr, 2);
+            cairo_stroke(cr);
+
+            snprintf(buf, sizeof buf, "%d, %d", x, y);
+            cairo_move_to(cr, x + 20, y + 20);
+            cairo_text_path(cr, buf);
+            cairo_set_source_rgb(cr, 0, 0, 0);
+            cairo_stroke_preserve(cr);
+            cairo_set_source_rgb(cr, 1, 1, 1);
+            cairo_fill(cr);
+        }
+
+    cairo_destroy(cr);
 #endif
 }
 
 static void fill_tiles_yuv_planar(const struct util_format_info *info,
-				  unsigned char *y_mem, unsigned char *u_mem,
-				  unsigned char *v_mem, unsigned int width,
-				  unsigned int height, unsigned int stride)
+                                  unsigned char *y_mem, unsigned char *u_mem,
+                                  unsigned char *v_mem, unsigned int width,
+                                  unsigned int height, unsigned int stride)
 {
-	const struct util_yuv_info *yuv = &info->yuv;
-	unsigned int cs = yuv->chroma_stride;
-	unsigned int xsub = yuv->xsub;
-	unsigned int ysub = yuv->ysub;
-	unsigned int x;
-	unsigned int y;
-
-	for (y = 0; y < height; ++y) {
-		for (x = 0; x < width; ++x) {
-			div_t d = div(x+y, width);
-			uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
-				       + 0x000a1120 * (d.rem >> 6);
-			struct color_yuv color =
-				MAKE_YUV_601((rgb32 >> 16) & 0xff,
-					     (rgb32 >> 8) & 0xff, rgb32 & 0xff);
-
-			y_mem[x] = color.y;
-			u_mem[x/xsub*cs] = color.u;
-			v_mem[x/xsub*cs] = color.v;
-		}
-
-		y_mem += stride;
-		if ((y + 1) % ysub == 0) {
-			u_mem += stride * cs / xsub;
-			v_mem += stride * cs / xsub;
-		}
-	}
+    const struct util_yuv_info *yuv = &info->yuv;
+    unsigned int cs = yuv->chroma_stride;
+    unsigned int xsub = yuv->xsub;
+    unsigned int ysub = yuv->ysub;
+    unsigned int x;
+    unsigned int y;
+
+    for (y = 0; y < height; ++y) {
+        for (x = 0; x < width; ++x) {
+            div_t d = div(x+y, width);
+            uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
+                       + 0x000a1120 * (d.rem >> 6);
+            struct color_yuv color =
+                MAKE_YUV_601((rgb32 >> 16) & 0xff,
+                         (rgb32 >> 8) & 0xff, rgb32 & 0xff);
+
+            y_mem[x] = color.y;
+            u_mem[x/xsub*cs] = color.u;
+            v_mem[x/xsub*cs] = color.v;
+        }
+
+        y_mem += stride;
+        if ((y + 1) % ysub == 0) {
+            u_mem += stride * cs / xsub;
+            v_mem += stride * cs / xsub;
+        }
+    }
 }
 
 static void fill_tiles_yuv_packed(const struct util_format_info *info,
-				  void *mem, unsigned int width,
-				  unsigned int height, unsigned int stride)
+                                  void *mem, unsigned int width,
+                                  unsigned int height, unsigned int stride)
 {
-	const struct util_yuv_info *yuv = &info->yuv;
-	unsigned char *y_mem = (yuv->order & YUV_YC) ? mem : mem + 1;
-	unsigned char *c_mem = (yuv->order & YUV_CY) ? mem : mem + 1;
-	unsigned int u = (yuv->order & YUV_YCrCb) ? 2 : 0;
-	unsigned int v = (yuv->order & YUV_YCbCr) ? 2 : 0;
-	unsigned int x;
-	unsigned int y;
-
-	for (y = 0; y < height; ++y) {
-		for (x = 0; x < width; x += 2) {
-			div_t d = div(x+y, width);
-			uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
-				       + 0x000a1120 * (d.rem >> 6);
-			struct color_yuv color =
-				MAKE_YUV_601((rgb32 >> 16) & 0xff,
-					     (rgb32 >> 8) & 0xff, rgb32 & 0xff);
-
-			y_mem[2*x] = color.y;
-			c_mem[2*x+u] = color.u;
-			y_mem[2*x+2] = color.y;
-			c_mem[2*x+v] = color.v;
-		}
-
-		y_mem += stride;
-		c_mem += stride;
-	}
+    const struct util_yuv_info *yuv = &info->yuv;
+    unsigned char *y_mem = (yuv->order & YUV_YC) ? mem : mem + 1;
+    unsigned char *c_mem = (yuv->order & YUV_CY) ? mem : mem + 1;
+    unsigned int u = (yuv->order & YUV_YCrCb) ? 2 : 0;
+    unsigned int v = (yuv->order & YUV_YCbCr) ? 2 : 0;
+    unsigned int x;
+    unsigned int y;
+
+    for (y = 0; y < height; ++y) {
+        for (x = 0; x < width; x += 2) {
+            div_t d = div(x+y, width);
+            uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
+                       + 0x000a1120 * (d.rem >> 6);
+            struct color_yuv color =
+                MAKE_YUV_601((rgb32 >> 16) & 0xff,
+                         (rgb32 >> 8) & 0xff, rgb32 & 0xff);
+
+            y_mem[2*x] = color.y;
+            c_mem[2*x+u] = color.u;
+            y_mem[2*x+2] = color.y;
+            c_mem[2*x+v] = color.v;
+        }
+
+        y_mem += stride;
+        c_mem += stride;
+    }
 }
 
 static void fill_tiles_rgb16(const struct util_format_info *info, void *mem,
-			     unsigned int width, unsigned int height,
-			     unsigned int stride)
+                             unsigned int width, unsigned int height,
+                             unsigned int stride)
 {
-	const struct util_rgb_info *rgb = &info->rgb;
-	void *mem_base = mem;
-	unsigned int x, y;
-
-	for (y = 0; y < height; ++y) {
-		for (x = 0; x < width; ++x) {
-			div_t d = div(x+y, width);
-			uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
-				       + 0x000a1120 * (d.rem >> 6);
-			uint16_t color =
-				MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff,
-					  (rgb32 >> 8) & 0xff, rgb32 & 0xff,
-					  255);
-
-			((uint16_t *)mem)[x] = color;
-		}
-		mem += stride;
-	}
-
-	make_pwetty(mem_base, width, height, stride, info->format);
+    const struct util_rgb_info *rgb = &info->rgb;
+    void *mem_base = mem;
+    unsigned int x, y;
+
+    for (y = 0; y < height; ++y) {
+        for (x = 0; x < width; ++x) {
+            div_t d = div(x+y, width);
+            uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
+                       + 0x000a1120 * (d.rem >> 6);
+            uint16_t color =
+                MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff,
+                      (rgb32 >> 8) & 0xff, rgb32 & 0xff,
+                      255);
+
+            ((uint16_t *)mem)[x] = color;
+        }
+        mem += stride;
+    }
+
+    make_pwetty(mem_base, width, height, stride, info->format);
 }
 
 static void fill_tiles_rgb24(const struct util_format_info *info, void *mem,
-			     unsigned int width, unsigned int height,
-			     unsigned int stride)
+                             unsigned int width, unsigned int height,
+                             unsigned int stride)
 {
-	const struct util_rgb_info *rgb = &info->rgb;
-	unsigned int x, y;
-
-	for (y = 0; y < height; ++y) {
-		for (x = 0; x < width; ++x) {
-			div_t d = div(x+y, width);
-			uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
-				       + 0x000a1120 * (d.rem >> 6);
-			struct color_rgb24 color =
-				MAKE_RGB24(rgb, (rgb32 >> 16) & 0xff,
-					   (rgb32 >> 8) & 0xff, rgb32 & 0xff);
-
-			((struct color_rgb24 *)mem)[x] = color;
-		}
-		mem += stride;
-	}
+    const struct util_rgb_info *rgb = &info->rgb;
+    unsigned int x, y;
+
+    for (y = 0; y < height; ++y) {
+        for (x = 0; x < width; ++x) {
+            div_t d = div(x+y, width);
+            uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
+                       + 0x000a1120 * (d.rem >> 6);
+            struct color_rgb24 color =
+                MAKE_RGB24(rgb, (rgb32 >> 16) & 0xff,
+                       (rgb32 >> 8) & 0xff, rgb32 & 0xff);
+
+            ((struct color_rgb24 *)mem)[x] = color;
+        }
+        mem += stride;
+    }
 }
 
 static void fill_tiles_rgb32(const struct util_format_info *info, void *mem,
-			     unsigned int width, unsigned int height,
-			     unsigned int stride)
+                             unsigned int width, unsigned int height,
+                             unsigned int stride)
 {
-	const struct util_rgb_info *rgb = &info->rgb;
-	void *mem_base = mem;
-	unsigned int x, y;
-
-	for (y = 0; y < height; ++y) {
-		for (x = 0; x < width; ++x) {
-			div_t d = div(x+y, width);
-			uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
-				       + 0x000a1120 * (d.rem >> 6);
-			uint32_t alpha = ((y < height/2) && (x < width/2)) ? 127 : 255;
-			uint32_t color =
-				MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff,
-					  (rgb32 >> 8) & 0xff, rgb32 & 0xff,
-					  alpha);
-
-			((uint32_t *)mem)[x] = color;
-		}
-		mem += stride;
-	}
-
-	make_pwetty(mem_base, width, height, stride, info->format);
+    const struct util_rgb_info *rgb = &info->rgb;
+    void *mem_base = mem;
+    unsigned int x, y;
+
+    for (y = 0; y < height; ++y) {
+        for (x = 0; x < width; ++x) {
+            div_t d = div(x+y, width);
+            uint32_t rgb32 = 0x00130502 * (d.quot >> 6)
+                       + 0x000a1120 * (d.rem >> 6);
+            uint32_t alpha = ((y < height/2) && (x < width/2)) ? 127 : 255;
+            uint32_t color =
+                MAKE_RGBA(rgb, (rgb32 >> 16) & 0xff,
+                      (rgb32 >> 8) & 0xff, rgb32 & 0xff,
+                      alpha);
+
+            ((uint32_t *)mem)[x] = color;
+        }
+        mem += stride;
+    }
+
+    make_pwetty(mem_base, width, height, stride, info->format);
 }
 
 static void fill_tiles(const struct util_format_info *info, void *planes[3],
-		       unsigned int width, unsigned int height,
-		       unsigned int stride)
+                       unsigned int width, unsigned int height,
+                       unsigned int stride)
 {
-	unsigned char *u, *v;
-
-	switch (info->format) {
-	case DRM_FORMAT_UYVY:
-	case DRM_FORMAT_VYUY:
-	case DRM_FORMAT_YUYV:
-	case DRM_FORMAT_YVYU:
-		return fill_tiles_yuv_packed(info, planes[0],
-					     width, height, stride);
-
-	case DRM_FORMAT_NV12:
-	case DRM_FORMAT_NV21:
-	case DRM_FORMAT_NV16:
-	case DRM_FORMAT_NV61:
-		u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1;
-		v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1;
-		return fill_tiles_yuv_planar(info, planes[0], u, v,
-					     width, height, stride);
-
-	case DRM_FORMAT_YUV420:
-		return fill_tiles_yuv_planar(info, planes[0], planes[1],
-					     planes[2], width, height, stride);
-
-	case DRM_FORMAT_YVU420:
-		return fill_tiles_yuv_planar(info, planes[0], planes[2],
-					     planes[1], width, height, stride);
-
-	case DRM_FORMAT_ARGB4444:
-	case DRM_FORMAT_XRGB4444:
-	case DRM_FORMAT_ABGR4444:
-	case DRM_FORMAT_XBGR4444:
-	case DRM_FORMAT_RGBA4444:
-	case DRM_FORMAT_RGBX4444:
-	case DRM_FORMAT_BGRA4444:
-	case DRM_FORMAT_BGRX4444:
-	case DRM_FORMAT_RGB565:
-	case DRM_FORMAT_BGR565:
-	case DRM_FORMAT_ARGB1555:
-	case DRM_FORMAT_XRGB1555:
-	case DRM_FORMAT_ABGR1555:
-	case DRM_FORMAT_XBGR1555:
-	case DRM_FORMAT_RGBA5551:
-	case DRM_FORMAT_RGBX5551:
-	case DRM_FORMAT_BGRA5551:
-	case DRM_FORMAT_BGRX5551:
-		return fill_tiles_rgb16(info, planes[0],
-					width, height, stride);
-
-	case DRM_FORMAT_BGR888:
-	case DRM_FORMAT_RGB888:
-		return fill_tiles_rgb24(info, planes[0],
-					width, height, stride);
-	case DRM_FORMAT_ARGB8888:
-	case DRM_FORMAT_XRGB8888:
-	case DRM_FORMAT_ABGR8888:
-	case DRM_FORMAT_XBGR8888:
-	case DRM_FORMAT_RGBA8888:
-	case DRM_FORMAT_RGBX8888:
-	case DRM_FORMAT_BGRA8888:
-	case DRM_FORMAT_BGRX8888:
-	case DRM_FORMAT_ARGB2101010:
-	case DRM_FORMAT_XRGB2101010:
-	case DRM_FORMAT_ABGR2101010:
-	case DRM_FORMAT_XBGR2101010:
-	case DRM_FORMAT_RGBA1010102:
-	case DRM_FORMAT_RGBX1010102:
-	case DRM_FORMAT_BGRA1010102:
-	case DRM_FORMAT_BGRX1010102:
-		return fill_tiles_rgb32(info, planes[0],
-					width, height, stride);
-	}
+    unsigned char *u, *v;
+
+    switch (info->format) {
+    case DRM_FORMAT_UYVY:
+    case DRM_FORMAT_VYUY:
+    case DRM_FORMAT_YUYV:
+    case DRM_FORMAT_YVYU:
+        return fill_tiles_yuv_packed(info, planes[0], width, height, stride);
+
+    case DRM_FORMAT_NV12:
+    case DRM_FORMAT_NV21:
+    case DRM_FORMAT_NV16:
+    case DRM_FORMAT_NV61:
+        u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1;
+        v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1;
+        return fill_tiles_yuv_planar(info, planes[0], u, v, width, height,
+                                     stride);
+
+    case DRM_FORMAT_YUV420:
+        return fill_tiles_yuv_planar(info, planes[0], planes[1], planes[2],
+                                     width, height, stride);
+
+    case DRM_FORMAT_YVU420:
+        return fill_tiles_yuv_planar(info, planes[0], planes[2], planes[1],
+                                     width, height, stride);
+
+    case DRM_FORMAT_ARGB4444:
+    case DRM_FORMAT_XRGB4444:
+    case DRM_FORMAT_ABGR4444:
+    case DRM_FORMAT_XBGR4444:
+    case DRM_FORMAT_RGBA4444:
+    case DRM_FORMAT_RGBX4444:
+    case DRM_FORMAT_BGRA4444:
+    case DRM_FORMAT_BGRX4444:
+    case DRM_FORMAT_RGB565:
+    case DRM_FORMAT_BGR565:
+    case DRM_FORMAT_ARGB1555:
+    case DRM_FORMAT_XRGB1555:
+    case DRM_FORMAT_ABGR1555:
+    case DRM_FORMAT_XBGR1555:
+    case DRM_FORMAT_RGBA5551:
+    case DRM_FORMAT_RGBX5551:
+    case DRM_FORMAT_BGRA5551:
+    case DRM_FORMAT_BGRX5551:
+        return fill_tiles_rgb16(info, planes[0], width, height, stride);
+
+    case DRM_FORMAT_BGR888:
+    case DRM_FORMAT_RGB888:
+        return fill_tiles_rgb24(info, planes[0], width, height, stride);
+    case DRM_FORMAT_ARGB8888:
+    case DRM_FORMAT_XRGB8888:
+    case DRM_FORMAT_ABGR8888:
+    case DRM_FORMAT_XBGR8888:
+    case DRM_FORMAT_RGBA8888:
+    case DRM_FORMAT_RGBX8888:
+    case DRM_FORMAT_BGRA8888:
+    case DRM_FORMAT_BGRX8888:
+    case DRM_FORMAT_ARGB2101010:
+    case DRM_FORMAT_XRGB2101010:
+    case DRM_FORMAT_ABGR2101010:
+    case DRM_FORMAT_XBGR2101010:
+    case DRM_FORMAT_RGBA1010102:
+    case DRM_FORMAT_RGBX1010102:
+    case DRM_FORMAT_BGRA1010102:
+    case DRM_FORMAT_BGRX1010102:
+        return fill_tiles_rgb32(info, planes[0], width, height, stride);
+    }
 }
 
 static void fill_plain(const struct util_format_info *info, void *planes[3],
-		       unsigned int width, unsigned int height,
-		       unsigned int stride)
+                       unsigned int width, unsigned int height,
+                       unsigned int stride)
 {
-	memset(planes[0], 0x77, stride * height);
+    memset(planes[0], 0x77, stride * height);
 }
 
 /*
@@ -844,27 +836,27 @@ static void fill_plain(const struct util_format_info *info, void *planes[3],
  * Supported formats vary depending on the selected pattern.
  */
 void util_fill_pattern(uint32_t format, enum util_fill_pattern pattern,
-		       void *planes[3], unsigned int width,
-		       unsigned int height, unsigned int stride)
+                       void *planes[3], unsigned int width,
+                       unsigned int height, unsigned int stride)
 {
-	const struct util_format_info *info;
+    const struct util_format_info *info;
 
-	info = util_format_info_find(format);
-	if (info == NULL)
-		return;
+    info = util_format_info_find(format);
+    if (info == NULL)
+        return;
 
-	switch (pattern) {
-	case UTIL_PATTERN_TILES:
-		return fill_tiles(info, planes, width, height, stride);
+    switch (pattern) {
+    case UTIL_PATTERN_TILES:
+        return fill_tiles(info, planes, width, height, stride);
 
-	case UTIL_PATTERN_SMPTE:
-		return fill_smpte(info, planes, width, height, stride);
+    case UTIL_PATTERN_SMPTE:
+        return fill_smpte(info, planes, width, height, stride);
 
-	case UTIL_PATTERN_PLAIN:
-		return fill_plain(info, planes, width, height, stride);
+    case UTIL_PATTERN_PLAIN:
+        return fill_plain(info, planes, width, height, stride);
 
-	default:
-		printf("Error: unsupported test pattern %u.\n", pattern);
-		break;
-	}
+    default:
+        printf("Error: unsupported test pattern %u.\n", pattern);
+        break;
+    }
 }
diff --git a/tests/util/pattern.h b/tests/util/pattern.h
index d5c4260cc6ed..80fade3856de 100644
--- a/tests/util/pattern.h
+++ b/tests/util/pattern.h
@@ -27,13 +27,13 @@
 #define UTIL_PATTERN_H
 
 enum util_fill_pattern {
-	UTIL_PATTERN_TILES,
-	UTIL_PATTERN_PLAIN,
-	UTIL_PATTERN_SMPTE,
+    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);
+                       void *planes[3], unsigned int width,
+                       unsigned int height, unsigned int stride);
 
 #endif /* UTIL_PATTERN_H */
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice
  2017-01-30 10:29 [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding
@ 2017-01-30 10:29 ` Thierry Reding
  2017-02-01 12:47   ` Emil Velikov
  2017-01-30 10:29 ` [PATCH libdrm 3/3] tests/util: Add some API documentation Thierry Reding
  2017-01-30 10:32 ` [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding
  2 siblings, 1 reply; 6+ messages in thread
From: Thierry Reding @ 2017-01-30 10:29 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

The util_open() helper is used in a couple of test programs to open an
appropriate device. It takes a device path and a module name, both are
optional, as parameters. If a device path is specified, it will try to
open the given device. Otherwise it will try all available devices. If
only a specific subset is desired, the module parameter can be used as
a filter. The function will use it to open only devices whose kernel
driver matches the given module name.

Instead of relying on the legacy drmOpen() function to do this, convert
util_open() to use the new drmDevice helpers. This gets it functionally
much closer to what other DRM/KMS users, such as the X.Org Server or a
Wayland server, do.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 tests/util/kms.c | 167 +++++++++++++++++++++++++++++++++++++++++--------------
 tests/util/kms.h |  43 ++++++++++++++
 2 files changed, 168 insertions(+), 42 deletions(-)

diff --git a/tests/util/kms.c b/tests/util/kms.c
index d866398237bb..c5d35ab616d1 100644
--- a/tests/util/kms.c
+++ b/tests/util/kms.c
@@ -42,15 +42,18 @@
 #endif
 
 #include <errno.h>
+#include <fcntl.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 #include "xf86drm.h"
 #include "xf86drmMode.h"
 
 #include "common.h"
+#include "kms.h"
 
 struct type_name {
     unsigned int type;
@@ -125,58 +128,138 @@ const char *util_lookup_connector_type_name(unsigned int type)
                                  ARRAY_SIZE(connector_type_names));
 }
 
-static const char * const modules[] = {
-    "i915",
-    "amdgpu",
-    "radeon",
-    "nouveau",
-    "vmwgfx",
-    "omapdrm",
-    "exynos",
-    "tilcdc",
-    "msm",
-    "sti",
-    "tegra",
-    "imx-drm",
-    "rockchip",
-    "atmel-hlcdc",
-    "fsl-dcu-drm",
-    "vc4",
-    "virtio_gpu",
-    "mediatek",
-    "meson",
-};
+char *util_get_driver(int fd)
+{
+    drmVersionPtr version;
+    char *driver;
 
-int util_open(const char *device, const char *module)
+    version = drmGetVersion(fd);
+    if (!version)
+        return NULL;
+
+    driver = strdup(version->name);
+
+    drmFreeVersion(version);
+
+    return driver;
+}
+
+int util_get_devices(drmDevicePtr **devicesp, uint32_t flags)
+{
+    drmDevicePtr *devices;
+    unsigned int count;
+    int err;
+
+    err = drmGetDevices2(flags, NULL, 0);
+    if (err < 0)
+        return err;
+
+    /*
+     * If the caller hasn't specified a return pointer for the new devices
+     * array, all of the below is pointless, so simply return the number of
+     * devices available.
+     */
+    if (!devicesp)
+        return err;
+
+    count = err;
+
+    devices = calloc(count, sizeof(*devices));
+    if (!devices)
+        return -ENOMEM;
+
+    err = drmGetDevices2(flags, devices, count);
+    if (err < 0) {
+        free(devices);
+        return err;
+    }
+
+    if (devicesp)
+        *devicesp = devices;
+    else
+        free(devices);
+
+    return count;
+}
+
+void util_free_devices(drmDevicePtr *devices, unsigned int count)
+{
+    drmFreeDevices(devices, count);
+    free(devices);
+}
+
+int util_open_with_module(const char *device, const char *module)
 {
-    int fd;
+    int fd, err = 0;
+
+    if (module)
+        printf("trying to open `%s' with `%s'...", device, module);
+    else
+        printf("trying to open `%s'...", device);
+
+    fd = open(device, O_RDWR);
+    if (fd < 0) {
+        err = -errno;
+        goto out;
+    }
 
     if (module) {
-        fd = drmOpen(module, device);
-        if (fd < 0) {
-            fprintf(stderr, "failed to open device '%s': %s\n",
-                module, strerror(errno));
-            return -errno;
+        char *driver = util_get_driver(fd);
+        if (!driver) {
+            err = -EINVAL;
+            goto close;
         }
-    } else {
-        unsigned int i;
 
-        for (i = 0; i < ARRAY_SIZE(modules); i++) {
-            printf("trying to open device '%s'...", modules[i]);
+        if (strcmp(module, driver) != 0)
+            err = -EINVAL;
+
+        free(driver);
+
+        if (err < 0)
+            goto close;
+    }
+
+    printf("done\n");
+    return fd;
+
+close:
+    close(fd);
+out:
+    printf("failed\n");
+    return err;
+}
 
-            fd = drmOpen(modules[i], device);
-            if (fd < 0) {
-                printf("failed\n");
-            } else {
-                printf("done\n");
+int util_open(const char *device, const char *module)
+{
+    int fd, err;
+
+    if (!device) {
+        drmDevicePtr *devices, dev;
+        unsigned int count, i, j;
+        const char *node;
+
+        err = util_get_devices(&devices, 0);
+        if (err < 0)
+            return err;
+
+        count = err;
+
+        util_for_each_device(dev, i, devices, count) {
+            node = util_device_get_node(dev, DRM_NODE_PRIMARY);
+            if (!node)
+                continue;
+
+            fd = util_open_with_module(node, module);
+            if (fd >= 0)
                 break;
-            }
         }
 
-        if (fd < 0) {
-            fprintf(stderr, "no device found\n");
-            return -ENODEV;
-        }
+        util_free_devices(devices, count);
+
+        if (i == count)
+            fd = -ENOENT;
+    } else {
+        fd = util_open_with_module(device, module);
     }
 
     return fd;
diff --git a/tests/util/kms.h b/tests/util/kms.h
index dde2ed2c5636..b7b5b4747950 100644
--- a/tests/util/kms.h
+++ b/tests/util/kms.h
@@ -30,6 +30,49 @@ 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);
 
+char *util_get_driver(int fd);
+
+int util_get_devices(drmDevicePtr **devicesp, uint32_t flags);
+void util_free_devices(drmDevicePtr *devices, unsigned int count);
+
+static inline drmDevicePtr util_get_device(drmDevicePtr *devices,
+                                           unsigned int count,
+                                           unsigned int index)
+{
+    if (index >= count)
+        return NULL;
+
+    return devices[index];
+}
+
+#define util_for_each_device(device, index, devices, count)     \
+    for (device = util_get_device(devices, count, (index) = 0); \
+         (index) < (count);                                     \
+         device = util_get_device(devices, count, ++(index)))
+
+static inline char *util_device_get_node(drmDevicePtr device,
+                                         unsigned int type)
+{
+    if (type >= DRM_NODE_MAX)
+        return NULL;
+
+    return device->nodes[type];
+}
+
+#define for_each_if(condition) \
+    if (!(condition)) {        \
+    } else
+
+#define util_device_for_each_node(node, type, device)     \
+    for (node = util_device_get_node(device, (type) = 0); \
+         (type) < DRM_NODE_MAX;                           \
+         node = util_device_get_node(device, ++(type)))
+
+#define util_device_for_each_available_node(node, type, device)     \
+        util_device_for_each_node(node, type, device)               \
+            for_each_if ((device)->available_nodes & (1 << (type)))
+
+int util_open_with_module(const char *device, const char *module);
 int util_open(const char *device, const char *module);
 
 #endif /* UTIL_KMS_H */
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* [PATCH libdrm 3/3] tests/util: Add some API documentation
  2017-01-30 10:29 [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding
  2017-01-30 10:29 ` [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice Thierry Reding
@ 2017-01-30 10:29 ` Thierry Reding
  2017-01-30 10:32 ` [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding
  2 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2017-01-30 10:29 UTC (permalink / raw)
  To: dri-devel

From: Thierry Reding <treding@nvidia.com>

None of the helpers currently have any documentation. Add some to make
it more obvious how these should be used.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 tests/util/kms.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/tests/util/kms.c b/tests/util/kms.c
index c5d35ab616d1..226386519d49 100644
--- a/tests/util/kms.c
+++ b/tests/util/kms.c
@@ -128,6 +128,13 @@ const char *util_lookup_connector_type_name(unsigned int type)
                                  ARRAY_SIZE(connector_type_names));
 }
 
+/**
+ * Retrieve the name of the kernel driver for a DRM device.
+ *
+ * \param fd the file descriptor of the DRM device
+ *
+ * \return On success, returns the name of the kernel driver.
+ */
 char *util_get_driver(int fd)
 {
     drmVersionPtr version;
@@ -144,6 +151,16 @@ char *util_get_driver(int fd)
     return driver;
 }
 
+/**
+ * Retrieve a list of available DRM devices.
+ *
+ * \param devicesp return location for the list of DRM devices
+ * \param flags bitmask of flags controlling operation
+ *
+ * \return On success, returns the number of devices found. The list of DRM
+ * devices is dynamically allocated and needs to be freed by a call to the
+ * util_free_devices() function.
+ */
 int util_get_devices(drmDevicePtr **devicesp, uint32_t flags)
 {
     drmDevicePtr *devices;
@@ -182,12 +199,32 @@ int util_get_devices(drmDevicePtr **devicesp, uint32_t flags)
     return count;
 }
 
+/**
+ * Free a list of DRM devices.
+ *
+ * \param devices a list of DRM devices, allocated by util_get_devices()
+ * \param count the number of DRM devices in \p devices
+ */
 void util_free_devices(drmDevicePtr *devices, unsigned int count)
 {
     drmFreeDevices(devices, count);
     free(devices);
 }
 
+/**
+ * Opens a DRM device, optionally checking against its kernel driver.
+ *
+ * \param device path to DRM device
+ * \param module optional name of kernel driver
+ *
+ * \return On success, a file descriptor to \p device, or a negative error
+ * code on failure.
+ *
+ * If the caller doesn't care about the kernel driver associated with the DRM
+ * device, then the \p module parameter can be NULL. If \p module is not NULL
+ * this function will retrieve the name of the kernel driver and compare it
+ * to the \p module parameter. If the names don't match, the call will fail.
+ */
 int util_open_with_module(const char *device, const char *module)
 {
     int fd, err = 0;
@@ -229,6 +266,20 @@ out:
     return err;
 }
 
+/**
+ * Opens a DRM device, optionally checking against its kernel driver.
+ *
+ * \param device
+ * \param module
+ *
+ * \return On success, a file descriptor to \p device, or a negative error
+ * code on failure.
+ *
+ * This is similar to util_open_with_module(), except that \p device can be
+ * NULL, in which case all available devices will be tried. If \p module is
+ * specified it will act as a filter. Otherwise the first available device
+ * that can be opened will be used.
+ */
 int util_open(const char *device, const char *module)
 {
     int fd, err;
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings
  2017-01-30 10:29 [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding
  2017-01-30 10:29 ` [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice Thierry Reding
  2017-01-30 10:29 ` [PATCH libdrm 3/3] tests/util: Add some API documentation Thierry Reding
@ 2017-01-30 10:32 ` Thierry Reding
  2 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2017-01-30 10:32 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 6420 bytes --]

On Mon, Jan 30, 2017 at 11:29:21AM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Apply editorconfig settings to the tests/util library code in order to
> facilitate making subsequent changes.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  tests/util/format.c  |  128 ++---
>  tests/util/format.h  |   36 +-
>  tests/util/kms.c     |  186 +++----
>  tests/util/pattern.c | 1446 +++++++++++++++++++++++++-------------------------
>  tests/util/pattern.h |   10 +-
>  5 files changed, 899 insertions(+), 907 deletions(-)

This is obviously a lot of churn, but for reference, here's the diff
ignoring all whitespace changes (--ignore-all-space):

--- >8 ---
commit f920fb0b72ddd12f18c42ddd96114213868331e3
Author: Thierry Reding <treding@nvidia.com>
Date:   Fri Jan 27 11:36:10 2017 +0100

    tests/util: Reindent using editorconfig settings
    
    Apply editorconfig settings to the tests/util library code in order to
    facilitate making subsequent changes.
    
    Signed-off-by: Thierry Reding <treding@nvidia.com>

diff --git a/tests/util/pattern.c b/tests/util/pattern.c
index 00b08a8cb8eb..5d653afbee24 100644
--- a/tests/util/pattern.c
+++ b/tests/util/pattern.c
@@ -472,8 +472,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_VYUY:
     case DRM_FORMAT_YUYV:
     case DRM_FORMAT_YVYU:
-		return fill_smpte_yuv_packed(&info->yuv, planes[0], width,
-					     height, stride);
+        return fill_smpte_yuv_packed(&info->yuv, planes[0], width, height,
+                                     stride);
 
     case DRM_FORMAT_NV12:
     case DRM_FORMAT_NV21:
@@ -481,8 +481,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_NV61:
         u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1;
         v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1;
-		return fill_smpte_yuv_planar(&info->yuv, planes[0], u, v,
-					     width, height, stride);
+        return fill_smpte_yuv_planar(&info->yuv, planes[0], u, v, width,
+                                     height, stride);
 
     case DRM_FORMAT_YUV420:
         return fill_smpte_yuv_planar(&info->yuv, planes[0], planes[1],
@@ -510,13 +510,12 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_RGBX5551:
     case DRM_FORMAT_BGRA5551:
     case DRM_FORMAT_BGRX5551:
-		return fill_smpte_rgb16(&info->rgb, planes[0],
-					width, height, stride);
+        return fill_smpte_rgb16(&info->rgb, planes[0], width, height, stride);
 
     case DRM_FORMAT_BGR888:
     case DRM_FORMAT_RGB888:
-		return fill_smpte_rgb24(&info->rgb, planes[0],
-					width, height, stride);
+        return fill_smpte_rgb24(&info->rgb, planes[0], width, height, stride);
+
     case DRM_FORMAT_ARGB8888:
     case DRM_FORMAT_XRGB8888:
     case DRM_FORMAT_ABGR8888:
@@ -533,8 +532,7 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_RGBX1010102:
     case DRM_FORMAT_BGRA1010102:
     case DRM_FORMAT_BGRX1010102:
-		return fill_smpte_rgb32(&info->rgb, planes[0],
-					width, height, stride);
+        return fill_smpte_rgb32(&info->rgb, planes[0], width, height, stride);
     }
 }
 
@@ -568,10 +566,8 @@ static void make_pwetty(void *data, unsigned int width, unsigned int height,
         return;
     }
 
-	surface = cairo_image_surface_create_for_data(data,
-						      cairo_format,
-						      width, height,
-						      stride);
+    surface = cairo_image_surface_create_for_data(data, cairo_format, width,
+                                                  height, stride);
     cr = cairo_create(surface);
     cairo_surface_destroy(surface);
 
@@ -758,8 +754,7 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_VYUY:
     case DRM_FORMAT_YUYV:
     case DRM_FORMAT_YVYU:
-		return fill_tiles_yuv_packed(info, planes[0],
-					     width, height, stride);
+        return fill_tiles_yuv_packed(info, planes[0], width, height, stride);
 
     case DRM_FORMAT_NV12:
     case DRM_FORMAT_NV21:
@@ -767,16 +762,16 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_NV61:
         u = info->yuv.order & YUV_YCbCr ? planes[1] : planes[1] + 1;
         v = info->yuv.order & YUV_YCrCb ? planes[1] : planes[1] + 1;
-		return fill_tiles_yuv_planar(info, planes[0], u, v,
-					     width, height, stride);
+        return fill_tiles_yuv_planar(info, planes[0], u, v, width, height,
+                                     stride);
 
     case DRM_FORMAT_YUV420:
-		return fill_tiles_yuv_planar(info, planes[0], planes[1],
-					     planes[2], width, height, stride);
+        return fill_tiles_yuv_planar(info, planes[0], planes[1], planes[2],
+                                     width, height, stride);
 
     case DRM_FORMAT_YVU420:
-		return fill_tiles_yuv_planar(info, planes[0], planes[2],
-					     planes[1], width, height, stride);
+        return fill_tiles_yuv_planar(info, planes[0], planes[2], planes[1],
+                                     width, height, stride);
 
     case DRM_FORMAT_ARGB4444:
     case DRM_FORMAT_XRGB4444:
@@ -796,13 +791,11 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_RGBX5551:
     case DRM_FORMAT_BGRA5551:
     case DRM_FORMAT_BGRX5551:
-		return fill_tiles_rgb16(info, planes[0],
-					width, height, stride);
+        return fill_tiles_rgb16(info, planes[0], width, height, stride);
 
     case DRM_FORMAT_BGR888:
     case DRM_FORMAT_RGB888:
-		return fill_tiles_rgb24(info, planes[0],
-					width, height, stride);
+        return fill_tiles_rgb24(info, planes[0], width, height, stride);
     case DRM_FORMAT_ARGB8888:
     case DRM_FORMAT_XRGB8888:
     case DRM_FORMAT_ABGR8888:
@@ -819,8 +812,7 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3],
     case DRM_FORMAT_RGBX1010102:
     case DRM_FORMAT_BGRA1010102:
     case DRM_FORMAT_BGRX1010102:
-		return fill_tiles_rgb32(info, planes[0],
-					width, height, stride);
+        return fill_tiles_rgb32(info, planes[0], width, height, stride);
     }
 }
 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice
  2017-01-30 10:29 ` [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice Thierry Reding
@ 2017-02-01 12:47   ` Emil Velikov
  2017-02-01 15:59     ` Thierry Reding
  0 siblings, 1 reply; 6+ messages in thread
From: Emil Velikov @ 2017-02-01 12:47 UTC (permalink / raw)
  To: Thierry Reding; +Cc: ML dri-devel

On 30 January 2017 at 10:29, Thierry Reding <thierry.reding@gmail.com> wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> The util_open() helper is used in a couple of test programs to open an
> appropriate device. It takes a device path and a module name, both are
> optional, as parameters. If a device path is specified, it will try to
> open the given device. Otherwise it will try all available devices. If
> only a specific subset is desired, the module parameter can be used as
> a filter. The function will use it to open only devices whose kernel
> driver matches the given module name.
>
> Instead of relying on the legacy drmOpen() function to do this, convert
> util_open() to use the new drmDevice helpers. This gets it functionally
> much closer to what other DRM/KMS users, such as the X.Org Server or a
> Wayland server, do.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  tests/util/kms.c | 167 +++++++++++++++++++++++++++++++++++++++++--------------
>  tests/util/kms.h |  43 ++++++++++++++
>  2 files changed, 168 insertions(+), 42 deletions(-)
>
> diff --git a/tests/util/kms.c b/tests/util/kms.c
> index d866398237bb..c5d35ab616d1 100644
> --- a/tests/util/kms.c
> +++ b/tests/util/kms.c

> +int util_get_devices(drmDevicePtr **devicesp, uint32_t flags)
Personally I would not have bothered with this helper, but it's nice to have ;-)

> +{

> +    if (!devicesp)
> +        return err;
> +

> +
> +    if (devicesp)
With the "if !devicesp" check above this should always be true, no ?



> +int util_open_with_module(const char *device, const char *module)
Name and thus distinction vs util_open is blurred - here we require
non-null device... which we should check for.
Sadly I'm out of ideas for better name(s) :-(

>  {
> -    int fd;
> +    int fd, err = 0;
> +
> +    if (module)
> +        printf("trying to open `%s' with `%s'...", device, module);
> +    else
> +        printf("trying to open `%s'...", device);
> +
> +    fd = open(device, O_RDWR);
Not sure how much we should care here, but O_CLOEXEC would be nice.


> +int util_open(const char *device, const char *module)
> +{


> +    } else {
> +        fd = util_open_with_module(device, module);
Nit: one can drop a level of indentation/brackets - I have no strong
preference either way.

int util_open(...)
{
   if (device)
      return util_open_with_module(device, module);

   ...
   get_devices
   ...
}


> --- a/tests/util/kms.h
> +++ b/tests/util/kms.h

> +
> +static inline char *util_device_get_node(drmDevicePtr device,
> +                                         unsigned int type)
> +{
> +    if (type >= DRM_NODE_MAX)
> +        return NULL;
> +
IMHO it's better to honour the ::available_nodes bitmask here, since
we already check if we're within range.

This the above the series is
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>

-Emil
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice
  2017-02-01 12:47   ` Emil Velikov
@ 2017-02-01 15:59     ` Thierry Reding
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2017-02-01 15:59 UTC (permalink / raw)
  To: Emil Velikov; +Cc: ML dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4195 bytes --]

On Wed, Feb 01, 2017 at 12:47:21PM +0000, Emil Velikov wrote:
> On 30 January 2017 at 10:29, Thierry Reding <thierry.reding@gmail.com> wrote:
> > From: Thierry Reding <treding@nvidia.com>
> >
> > The util_open() helper is used in a couple of test programs to open an
> > appropriate device. It takes a device path and a module name, both are
> > optional, as parameters. If a device path is specified, it will try to
> > open the given device. Otherwise it will try all available devices. If
> > only a specific subset is desired, the module parameter can be used as
> > a filter. The function will use it to open only devices whose kernel
> > driver matches the given module name.
> >
> > Instead of relying on the legacy drmOpen() function to do this, convert
> > util_open() to use the new drmDevice helpers. This gets it functionally
> > much closer to what other DRM/KMS users, such as the X.Org Server or a
> > Wayland server, do.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> >  tests/util/kms.c | 167 +++++++++++++++++++++++++++++++++++++++++--------------
> >  tests/util/kms.h |  43 ++++++++++++++
> >  2 files changed, 168 insertions(+), 42 deletions(-)
> >
> > diff --git a/tests/util/kms.c b/tests/util/kms.c
> > index d866398237bb..c5d35ab616d1 100644
> > --- a/tests/util/kms.c
> > +++ b/tests/util/kms.c
> 
> > +int util_get_devices(drmDevicePtr **devicesp, uint32_t flags)
> Personally I would not have bothered with this helper, but it's nice to have ;-)

Yeah, I added this after realizing that I was typing the same code
sequence for the second time.

> > +{
> 
> > +    if (!devicesp)
> > +        return err;
> > +
> 
> > +
> > +    if (devicesp)
> With the "if !devicesp" check above this should always be true, no ?

Yes, you're absolutely right. I added the above shortcut in a very late
iteration and forgot to update the tail of the function.

> > +int util_open_with_module(const char *device, const char *module)
> Name and thus distinction vs util_open is blurred - here we require
> non-null device... which we should check for.

Yes, I've added a check for that now.

> Sadly I'm out of ideas for better name(s) :-(

I know this isn't ideal, but hopefully the doxygen in patch 3/3 will
clarify somewhat how these are to be used.

> 
> >  {
> > -    int fd;
> > +    int fd, err = 0;
> > +
> > +    if (module)
> > +        printf("trying to open `%s' with `%s'...", device, module);
> > +    else
> > +        printf("trying to open `%s'...", device);
> > +
> > +    fd = open(device, O_RDWR);
> Not sure how much we should care here, but O_CLOEXEC would be nice.

Yes, added.

> > +int util_open(const char *device, const char *module)
> > +{
> 
> 
> > +    } else {
> > +        fd = util_open_with_module(device, module);
> Nit: one can drop a level of indentation/brackets - I have no strong
> preference either way.
> 
> int util_open(...)
> {
>    if (device)
>       return util_open_with_module(device, module);
> 
>    ...
>    get_devices
>    ...
> }

This looks better indeed. It's also nice how the implementation now very
closely matches the description in the doxygen comment introduced in
patch 3/3.

> > --- a/tests/util/kms.h
> > +++ b/tests/util/kms.h
> 
> > +
> > +static inline char *util_device_get_node(drmDevicePtr device,
> > +                                         unsigned int type)
> > +{
> > +    if (type >= DRM_NODE_MAX)
> > +        return NULL;
> > +
> IMHO it's better to honour the ::available_nodes bitmask here, since
> we already check if we're within range.

This was meant to be a very low-level accessor that can be used to
implement the iterators rather than be used standalone. If you look at
the util_device_for_each_{,available}_node iterators, they make a
distinction, though it is admittedly somewhat questionable how useful
the iterator over all nodes, available or not, really is.

It's probably best to just drop the util_device_for_each() iterator
altogether.

> This the above the series is
> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>

Thanks,
Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-02-01 15:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-30 10:29 [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding
2017-01-30 10:29 ` [PATCH libdrm 2/3] tests/util: Make util_open() use drmDevice Thierry Reding
2017-02-01 12:47   ` Emil Velikov
2017-02-01 15:59     ` Thierry Reding
2017-01-30 10:29 ` [PATCH libdrm 3/3] tests/util: Add some API documentation Thierry Reding
2017-01-30 10:32 ` [PATCH libdrm 1/3] tests/util: Reindent using editorconfig settings Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).