Modetest for Display Link Up

Multimedia User Guide (UG1449)

Document ID
UG1449
Release Date
2023-10-19
Revision
1.7 English

Use the modetest tool, provided by the libdrm library, to:

  • List all display capabilities: CRTCs, encoders & connectors (DP, HDMI, SDI ...), planes, modes...
  • Perform basic tests: display a test pattern, display 2 layers, perform a vsync test
  • Specify the video mode: resolution and refresh rate
Note: For information about the modetest tool, refer to https://wiki.st.com/stm32mpu/wiki/DRM_KMS_overview#cite_note-mesa_libdrm-3.

Find the bus_id by running the following command:

cat /sys/kerne/debug/dri/<corresponding id>/name

Running the modetest command with the -D option and passing the bus_id provides HDMI connector status and maximum supported resolutions, frame rate, and supporting plane formats. The following is the example HDMI-Tx command.

$ modetest -D a0070000.v_mix
Encoders:
id      crtc    type    possible crtcs  possible clones 
43      42      TMDS    0x00000001      0x00000000

Connectors:
id      encoder status          name            size (mm)       modes   encoders
44      43      connected       HDMI-A-1        700x390         49      43
  modes:
        name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  3840x2160 60.00 3840 3888 3920 4000 2160 2163 2168 2222 533250 flags: phsync, nvsync; type: 
                                                                            preferred, driver
  3840x2160 60.00 3840 4016 4104 4400 2160 2168 2178 2250 594000 flags: phsync, pvsync; type: driver
  3840x2160 59.94 3840 4016 4104 4400 2160 2168 2178 2250 593407 flags: phsync, pvsync; type: driver
  3840x2160 50.00 3840 4896 4984 5280 2160 2168 2178 2250 594000 flags: phsync, pvsync; type: driver
  3840x2160 30.00 3840 4016 4104 4400 2160 2168 2178 2250 297000 flags: phsync, pvsync; type: driver
  3840x2160 30.00 3840 4016 4104 4400 2160 2168 2178 2250 297000 flags: phsync, pvsync; type: driver

The preceding command also shows information about the number of planes and formats, and the DRM properties of those particular planes.

Planes:
id      crtc    fb      CRTC x,y        x,y     gamma size      possible crtcs
41      0       0       0,0             0,0     0               0x00000001
  formats: BG24
  props:
        8 type:
                flags: immutable enum
                enums: Overlay=0 Primary=1 Cursor=2
                value: 1
        17 FB_ID:
                flags: object
                value: 0
        18 IN_FENCE_FD:
                flags: signed range
                values: -1 2147483647
                value: -1
        20 CRTC_ID:
                flags: object
                value: 0
        13 CRTC_X:
                flags: signed range
                values: -2147483648 2147483647
                value: 0
        14 CRTC_Y:
                flags: signed range
                values: -2147483648 2147483647
                value: 0
        15 CRTC_W:
                flags: range
                values: 0 2147483647
                value: 3840
        16 CRTC_H:
                flags: range
                values: 0 2147483647
                value: 2160
        9 SRC_X:
                flags: range
                values: 0 4294967295
                value: 0
        10 SRC_Y:
                flags: range
                values: 0 4294967295
                value: 0
        11 SRC_W:
                flags: range
                values: 0 4294967295
                value: 251658240
        12 SRC_H:
                flags: range
                values: 0 4294967295
                value: 141557760

To run the color pattern on the connected HDMI screen, run the following command:

$modetest -D <bus-id> -s <connector_id>[,<connector_id>][@<crtc_id>]:<mode>[-<vrefresh>][@<format>]
$modetest -D a0070000.v_mix -s 41:3840x2160-60@BG2