wiki:linux/display

Version 2 (modified by Tim Harvey, 6 years ago) ( diff )

update /sys/class/drm examples to show scenarios with multiple drm devices

Goals

The purpose of this page is to help educate about display output on upstream Linux (not to be confused with the 'downstream' vendor kernel provided in Yocto).

Direct Rendering Manager (DRM)

DRM is the driver subsystem in the kernel that is able to communicate with video drivers, such as the Freescale I.MX6 processors. Through ioctl() calls, multiple userspace programs can draw to a display at any given time as DRM will manage these requests. DRM is also able to interface with the graphics processor (GPU) in order to hardware accelerate these requests. This is separate from framebuffer in that it only allowed raw writes to a display. DRM exposes some information via sysfs in the /sys/class/drm directory.

For example, to retrieve info about the DRM devices found on your system (Gateworks GW540x Linux 4.18):

root@bionic-armhf:~# ls /sys/class/drm
card0  card1  card1-HDMI-A-1  card1-LVDS-1  renderD128  version
# show 
  • card0 is from etnaviv the GPU driver (if enabled)
  • card1 is from the IPU display driver

Kernel Mode Settings (KMS)

KMS is part of DRM, but solely focuses on configuring display modes (i.e. screen resolution, refresh rate etc).

When booting your kernel, mode settings are read by what appears in the kernel command line, else defaults are chosen. DRM exports the available modes for a given display in the DRM 'modes' file:

root@bionic-armhf:~# for i in $(ls -1 /sys/class/drm/*/modes); do echo "$i:"; cat $i; done 
/sys/class/drm/card1-HDMI-A-1/modes:
1920x1080
1280x1024
1440x900
1280x800
1152x864
1024x768
1024x768
800x600
800x600
640x480
640x480
720x400
/sys/class/drm/card1-LVDS-1/modes:
  • the above shows that the HDMI is connected to a 1080p capable monitor with several resolutions available and that the board also has an LVDS connector but it is disabled

Mode settings can be passed to the kernel via the video= parameter from within U-Boot. The format of this is as follows: video=<conn>:<xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]

Note the following variables (see also modedb.txt):

  • <conn>: Connector
  • <xres> x <yres>: Resolution
  • M: Display timings will be calculated using VESA(TM) Coordinated Video Timings instead of a lookup table (Please see modedb.txt for more details)
  • R: Do "Reduce Blanking" calculation for digital displays
  • -<bpp>: color depth
  • i: Calculate timings for an interlaced Mode
  • m: Add margins to the calculation (1.8% of xres rounded down to 8 pixels and 1.8% of yres)
  • e: Output Forced On
  • D: Output Forced On and use Digital Outputs
  • d: Output Forced Off

Examples:

  • Disable both the LVDS and HDMI outputs on a Gateworks GW540x:
    setenv video 'video=LVDS-1:d video=HDMI-A-1:d'
    

Then, when booted:

root@OpenWrt:/# dmesg | grep -E "LVDS-1|HDMI-A-1"
[    0.000000] Kernel command line: console=ttymxc1,115200 ubi0:ubi ubi.mtd=2 rootfstype=squashfs,ubifs video=LVDS-1:d video=HDMI-A-1:d
[   12.181930] [drm] forcing HDMI-A-1 connector OFF
[   12.196641] [drm] forcing LVDS-1 connector OFF
  • Set HDMI output to 800x600 @ 60Hz refresh rate and disable LVDS:
    setenv video 'video=LVDS-1:d video=HDMI-A-1:800x600@60'
    

Limitations

Using the upstream kernel currently has some limitations on the imx platform. For example, the driver is limited to the number of display outputs it can do. That means if both LVDS and HDMI were connected, both resolutions would be scaled to the display with the lower resolution. Both outputs are also mirror's of each other and cannot be run independently. However, using the 'downstream' vendor kernel that we provide on our Yocto BSPs do have features that allow for independently controlled displays, even allowing for an 'overlay' buffer for the first two displays.

To see more on the downstream vendor kernel provided in Yocto, please see here.

References

Note: See TracWiki for help on using the wiki.