[Pkg-raspi-maintainers] Bug#969287: raspi-firmware: Dual HDMI support for RaspberryPI4

ibu radempa ibu at radempa.de
Sun Aug 30 20:14:24 BST 2020


Package: raspi-firmware
Version: 1.20200601-3
Severity: wishlist

I'd like to run two HDMI displays on RaspberryPI4.
I've tried hard, but cannot get it to work.
It works with RaspberryPI OS and obviously also on gentoo.
I have limited knowledge w.r.t. video; maybe I have overlooked
something very simple. Below I'm copying my findings.

## Dual HDMI support for RaspberryPI4

RaspberryPI4 has two HDMI connectors and the GPU can produce two
video signals (in case of 2 connected 4k-monitors only at 30Hz, both).

Currently, Debian only has support for one monitor (connected to
HDMI0, that one of the two connectors which is near the power connector).

### Current situation

The current situation (with kernel 5.8 from experimental and otherwise
the family 4 image from https://raspi.debian.net/tested-images/ with
updates) is the following:

* The code in EEPROM reads config.txt from the first partition of the
  sdcard. (bootcode.bin is not used on the PI4.)
* Therein the start_file and fixup_file files can be defined,
  defaulting to start4.elf and fixup4.dat, respectively.
  start4.elf is a binary blob with GPU firmware from Broadcom.
  It gets loaded.
* Before booting linux the device tree bcm2711-rpi-4-b.dtb gets
  patched with a "chosen" section containing framebuffer at 3e3cf000.
* The kernel and initramfs defined in config.txt are loaded and
  the kernel is executed with some generated boot params (to which
  custom params can be appended using cmdline=... in config.txt),
  among them video=HDMI-A-1:1920x1080M at 60 and if a second HDMI display
  is detected at that time, also video=HDMI-A-2:1920x1080M at 60.
* Lacking graphics card devices the kernel ignores the video=...
  params and instead initializes a simple-framebuffer [1] as
  obtained from the device tree:
```
Feb 14 11:11:59 rpi4 kernel: simple-framebuffer 3e3cf000.framebuffer: framebuffer at 0x3e3cf000, 0x7f8000 bytes, mapped to 0x(____ptrval____)
Feb 14 11:11:59 rpi4 kernel: simple-framebuffer 3e3cf000.framebuffer: format=a8r8g8b8, mode=1920x1080x32, linelength=7680
Feb 14 11:11:59 rpi4 kernel: Console: switching to colour frame buffer device 240x67
Feb 14 11:11:59 rpi4 kernel: simple-framebuffer 3e3cf000.framebuffer: fb0: simplefb registered!
```
* The X server also uses [2] this /dev/fb0.
  No /dev/dri/* is present.
  No /sys/devices/platform/gpu exists.
  No DRM, no KMS.

### RaspberryPi OS without vc4

I have looked a bit into how RaspberryPi OS handles the case of two HDMI
displays. As long as the vc4 driver is not enabled in config.txt, it
uses a kernel module bcm2708_fb (
https://github.com/raspberrypi/linux/blob/rpi-5.4.y/drivers/video/fbdev/bcm2708_fb.c
) from broadcom for framebuffer setup:
```
Aug 30 09:07:43 raspberrypi kernel: bcm2708_fb soc:fb: FB found 2 display(s)
Aug 30 09:07:43 raspberrypi kernel: Console: switching to colour frame buffer device 240x67
Aug 30 09:07:43 raspberrypi kernel: bcm2708_fb soc:fb: Registered framebuffer for display 0, size 1920x1080
Aug 30 09:07:43 raspberrypi kernel: bcm2708_fb soc:fb: Registered framebuffer for display 1, size 1920x1080
```
And obviously this can handle two displays. (There is just one framebuffer
device, /dev/fb0.) The second display is however not used by X; it displays
a splashscreen with a coloful raspberry and and some log info during startup.

bcm2708_fb is not in mainline linux.

The firmware also adds kernel params for this module:
    bcm2708_fb.fbwidth=1920
    bcm2708_fb.fbheight=1080
    bcm2708_fb.fbswap=1
And the video=... params are not there.

Later also a module rpivid_mem gets loaded:
```
Aug 30 09:07:43 raspberrypi kernel: rpivid-mem feb00000.hevc-decoder: rpivid-hevcmem initialised: Registers at 0xfeb00000 length 0x00010000
Aug 30 09:07:43 raspberrypi kernel: rpivid-mem feb10000.rpivid-local-intc: rpivid-intcmem initialised: Registers at 0xfeb10000 length 0x00001000
Aug 30 09:07:43 raspberrypi kernel: rpivid-mem feb20000.h264-decoder: rpivid-h264mem initialised: Registers at 0xfeb20000 length 0x00010000
Aug 30 09:07:43 raspberrypi kernel: rpivid-mem feb30000.vp9-decoder: rpivid-vp9mem initialised: Registers at 0xfeb30000 length 0x00010000
```

### RaspberryPi OS with vc4

Only if I enable device tree overlays for vc4 (dtoverlay=vc4-fkms-v3d in
config.txt, or dtoverlay=vc4-kms-v3d), X runs on both displays.

The kernel is executed with params
video=HDMI-A-1:1920x1080M at 60 video=HDMI-A-2:1920x1080M at 60 .

Looking at dmesg we find that now several modules get loaded:

```
Aug 30 05:23:58 raspberrypi kernel: vchiq: vchiq_init_state: slot_zero = (____ptrval____)
...
Aug 30 05:23:58 raspberrypi kernel: rpivid-mem feb00000.hevc-decoder: rpivid-hevcmem initialised: Registers at 0xfeb00000 length 0x00010000
Aug 30 05:23:58 raspberrypi kernel: rpivid-mem feb10000.rpivid-local-intc: rpivid-intcmem initialised: Registers at 0xfeb10000 length 0x00001000
Aug 30 05:23:58 raspberrypi kernel: rpivid-mem feb20000.h264-decoder: rpivid-h264mem initialised: Registers at 0xfeb20000 length 0x00010000
Aug 30 05:23:58 raspberrypi kernel: rpivid-mem feb30000.vp9-decoder: rpivid-vp9mem initialised: Registers at 0xfeb30000 length 0x00010000
Aug 30 05:23:59 raspberrypi kernel: vc_sm_cma: module is from the staging directory, the quality is unknown, you have been warned.
Aug 30 05:23:59 raspberrypi kernel: bcm2835_vc_sm_cma_probe: Videocore shared memory driver
Aug 30 05:23:59 raspberrypi kernel: [vc_sm_connected_init]: start
Aug 30 05:23:59 raspberrypi kernel: mc: Linux media interface: v0.10
Aug 30 05:23:59 raspberrypi kernel: [vc_sm_connected_init]: installed successfully
...
Aug 30 05:23:59 raspberrypi kernel: videodev: Linux video capture interface: v2.00
Aug 30 05:23:59 raspberrypi kernel: bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
Aug 30 05:23:59 raspberrypi kernel: bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
Aug 30 05:23:59 raspberrypi kernel: bcm2835_mmal_vchiq: module is from the staging directory, the quality is unknown, you have been warned.
Aug 30 05:23:59 raspberrypi kernel: bcm2835_v4l2: module is from the staging directory, the quality is unknown, you have been warned.
Aug 30 05:23:59 raspberrypi kernel: bcm2835_codec: module is from the staging directory, the quality is unknown, you have been warned.
Aug 30 05:23:59 raspberrypi kernel: bcm2835_isp: module is from the staging directory, the quality is unknown, you have been warned.
Aug 30 05:23:59 raspberrypi kernel: cfg80211: Loading compiled-in X.509 certificates for regulatory database
Aug 30 05:23:59 raspberrypi kernel: [drm] Initialized v3d 1.0.0 20180419 for fec00000.v3d on minor 0
Aug 30 05:23:59 raspberrypi kernel: cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
Aug 30 05:23:59 raspberrypi kernel: vc4-drm gpu: bound fe600000.firmwarekms (ops vc4_fkms_ops [vc4])
Aug 30 05:23:59 raspberrypi kernel: checking generic (3e3cd000 7f8000) vs hw (0 ffffffffffffffff)
Aug 30 05:23:59 raspberrypi kernel: fb0: switching to vc4drmfb from simple
Aug 30 05:23:59 raspberrypi kernel: Console: switching to colour dummy device 80x25
Aug 30 05:23:59 raspberrypi kernel: [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
Aug 30 05:23:59 raspberrypi kernel: [drm] No driver support for vblank timestamp query.
Aug 30 05:23:59 raspberrypi kernel: [drm] Setting vblank_disable_immediate to false because get_vblank_timestamp == NULL
Aug 30 05:23:59 raspberrypi kernel: [drm] Initialized vc4 0.0.0 20140616 for gpu on minor 1
```
We now obtain /dev/fb0 from vc4drmfb.
Module vchiq creates /dev/vchiq, the VideoCore Host Interface Queue.

A /dev/dri/card0 is present and /sys/devices/platform/gpu, too.

In RasbperryPI OS we find these module dependencies for vc4 and v3d:
```
vc4                   253952  3
cec                    49152  1 vc4
v3d                    69632  3
drm_kms_helper        192512  3 vc4
gpu_sched              36864  1 v3d
drm                   491520  10 gpu_sched,drm_kms_helper,v3d,vc4
snd_soc_core          208896  1 vc4
snd_pcm               122880  4 vc4,snd_bcm2835,snd_soc_core,snd_pcm_dmaengine
```
and some more modules being loaded that are not part of mainline linux, e.g.:
bcm2835_isp, bcm2835_codec, rpivid_mem, bcm2835_mmal_vchiq, bcm2835_v4l2,
vc_sm_cma

### vc4 on debian

In the debian system, enabling dtoverlay=vc4-fkms-v3d and loading module vc4
(incl. in initramfs) does not bring up a /dev/dri/card0 as it seems to do in
gentoo: https://wiki.gentoo.org/wiki/Raspberry_Pi_VC4 .
I have also tried with the same firmware as used in the raspi image.
(Using this firmware, I get a /sys/devices/platform/gpu however.)
And installing mesa-vulkan-drivers (also from experimental) has no effect
either.

### Summary

It seems vc4 is required for dual display support.
I'm not expert enough to tell which of the SOC-specific modules
are required to get vc4 running the displays. Since most of them
are missing in mainline linux however, it seems that dual display
support in debian will take some time.


[1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/Documentation/devicetree/bindings/display/simple-framebuffer.yaml?h=v5.8.5
[2] https://01.org/linuxgraphics/gfx-docs/drm/fb/framebuffer.html


Some more links (less relevant):

https://www.raspberrypi.org/documentation/configuration/config-txt/
https://www.raspberrypi.org/documentation/configuration/boot_folder.md
https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md
https://www.raspberrypi.org/documentation/configuration/device-tree.md
https://www.raspberrypi.org/documentation/configuration/config-txt/video.md
https://www.raspberrypi.org/documentation/configuration/cmdline-txt.md
https://www.raspberrypi.org/documentation/configuration/config-txt/memory.md

https://github.com/raspberrypi/firmware
https://github.com/raspberrypi/linux

https://github.com/raspberrypi/firmware/issues?q=is%3Aissue+hdmi1
http://moi.vonos.net/linux/framebuffer-drivers/
https://unix.stackexchange.com/questions/tagged/framebuffer?sort=votes
https://github.com/raspberrypi/firmware/issues/771
https://elinux.org/RPi_Framebuffer
https://www.raspberrypi.org/forums/viewtopic.php?p=1514067
https://linux.debian.ports.arm.narkive.com/eDF17svh/the-state-of-arm64-on-raspberry-pi-and-its-documentation


-- System Information:
Debian Release: 10.5
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'unstable'), (1, 'experimental')
Architecture: arm64 (aarch64)

Kernel: Linux 5.8.0-trunk-arm64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_CRAP, TAINT_UNSIGNED_MODULE
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE=C.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages raspi-firmware depends on:
ii  dosfstools  4.1-2
ii  dpkg        1.19.7

raspi-firmware recommends no packages.

raspi-firmware suggests no packages.

-- no debconf information



More information about the Pkg-raspi-maintainers mailing list