Skip to contentSkip to conversation

modetest: fix printing of fourcc on BE machines

PATCH In review Ilia Mirkin 2 participants 2 messages Apr 18, 2017 – Apr 19, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 modetest: fix printing of fourcc on BE machines

fourcc is not a string, it's a packed integer. This happens to work out on LE, but gets reversed on BE.

---
 tests/modetest/modetest.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tests/modetest/modetest.c +10 -1
index c390d87..b8891ff 100644
@@ -174,6 +174,15 @@ static const char *mode_flag_names[] = {
 
 static bit_name_fn(mode_flag)
 
+static void dump_fourcc(uint32_t fourcc)
+{
+	printf(" %c%c%c%c",
+		fourcc,
+		fourcc >> 8,
+		fourcc >> 16,
+		fourcc >> 24);
+}
+
 static void dump_encoders(struct device *dev)
 {
 	drmModeEncoder *encoder;
@@ -443,7 +452,7 @@ static void dump_planes(struct device *dev)
 
 		printf("  formats:");
 		for (j = 0; j < ovr->count_formats; j++)
-			printf(" %4.4s", (char *)&ovr->formats[j]);
+			dump_fourcc(ovr->formats[j]);
 		printf("\n");
 
 		if (plane->props) {
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Ilia Mirkin

fourcc is not a string, it's a packed integer. This happens to work out on LE, but gets reversed on BE.

---
 tests/modetest/modetest.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tests/modetest/modetest.c +9 -0
index c390d87..b8891ff 100644
@@ -174,6 +174,15 @@ static const char *mode_flag_names[] = {
 
 static bit_name_fn(mode_flag)
 
+static void dump_fourcc(uint32_t fourcc)
+{
+	printf(" %c%c%c%c",
+		fourcc,
+		fourcc >> 8,
+		fourcc >> 16,
+		fourcc >> 24);
+}
+
 static void dump_encoders(struct device *dev)
 {
 	drmModeEncoder *encoder;

tests/modetest/modetest.c static void dump_planes(struct device *dev) · line 458

Quoted 8 lines
tests/modetest/modetest.c +1 -1
@@ -443,7 +452,7 @@ static void dump_planes(struct device *dev)
 
 		printf("  formats:");
 		for (j = 0; j < ovr->count_formats; j++)
-			printf(" %4.4s", (char *)&ovr->formats[j]);
+			dump_fourcc(ovr->formats[j]);
 		printf("\n");
 
 		if (plane->props) {
Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel