[PATCH libdrm v2 05/10] modetest: Fix printing of big-endian fourcc values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Big-endian fourcc values have the MSB set, as that is the
DRM_FORMAT_BIG_ENDIAN flag.  Hence printing the last byte unmodified
leads to weird characters.

Fix this by stripping the DRM_FORMAT_BIG_ENDIAN flag, and appending "be"
for big-endian formats.

Sample impact:

     Planes:
     id     crtc    fb      CRTC x,y        x,y     gamma size      possible crtcs
     32     34      36      0,0             0,0     0               0x00000001
    -  formats: C1   C2   C4   C8   RG16 RG1� XR24
    +  formats: C1   C2   C4   C8   RG16 RG16be XR24
       props:
            8 type:
                    flags: immutable enum
                    enums: Overlay=0 Primary=1 Cursor=2
                    value: 1
            30 IN_FORMATS:
                    flags: immutable blob
                    blobs:

                    value:
                            00000001000000000000000700000018
                            00000001000000382020314320203243
                            202034432020384336314752b6314752
                            3432525800000000000000000000007f
                            00000000000000000000000000000000
                    in_formats blob decoded:
                             C1  :  LINEAR
                             C2  :  LINEAR
                             C4  :  LINEAR
                             C8  :  LINEAR
                             RG16:  LINEAR
    -                        RG1�:  LINEAR
    +                        RG16be:  LINEAR
                             XR24:  LINEAR

Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
---
v2:
  - New.
---
 tests/modetest/modetest.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 1d87046f0fdfaf24..f70043d1e6815497 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -198,11 +198,15 @@ static bit_name_fn(mode_flag)
 
 static void dump_fourcc(uint32_t fourcc)
 {
-	printf(" %c%c%c%c",
+	bool be = fourcc & DRM_FORMAT_BIG_ENDIAN;
+
+	fourcc &= ~DRM_FORMAT_BIG_ENDIAN;
+	printf(" %c%c%c%c%s",
 		fourcc,
 		fourcc >> 8,
 		fourcc >> 16,
-		fourcc >> 24);
+		fourcc >> 24,
+		be ? "be" : "");
 }
 
 static void dump_encoders(struct device *dev)
-- 
2.25.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux