Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forcing /dev/fbN assignments for DRM cards #5660

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Oct 18, 2023

Following on from #5629 for DRM device naming, add the option of forcing the mapping of /dev/fbN to particular DRM cards.

In a similar way to I2C etc, it looks for the highest numbered alias, and unassigned devices will be put beyond that number on the normal first-come, first-served basis.

If you assign something to fb1 but nothing to fb0, then you won't get a console unless you also use fbcon=map=<1> in the kernel command line.

Aliases only created for Pi5 as that's the one we hit this with more with DSI (x2), DPI, and VEC all being separate cards, but we could add it for the SPI display overlays and Pi0-4 as well. The SPI overlays are currently largely using fbdev drivers rather than DRM ones. I am working on a new tinydrm overlay to use mimic the fbtft overlay but using the TinyDRM drivers, but it's only got 2 drivers working at present.
(There is also panel-mipi-dbi which takes a firmware file to configure an SPI display, but AFAIK there is no repository yet of those firmware files to make it useful).

drivers/video/fbdev/core/fbmem.c Outdated Show resolved Hide resolved
drivers/gpu/drm/drm_fb_helper.c Show resolved Hide resolved
Add a flag custom_fb_num to denote that the client has
requested a specific fbdev node number via node.

Signed-off-by: Dave Stevenson <[email protected]>
For situations where there are multiple DRM cards in a system,
add a query of DT for "drm_fb" designations for cards to set
their preferred /dev/fbN designation.

Signed-off-by: Dave Stevenson <[email protected]>
Adds dtparam overrides to the base Pi5 DT such that vc4,
DSI0, DSI1, or DPI can be requested to be /dev/fb[012].
No override is specified by default, so the order will be
based on probe order (aka semi-random). Any device that
doesn't have an override specified will be placed above
all specified overrides. Having an fb1 or fb2 override but
no fb0 one will result in no console via fbcon.

Signed-off-by: Dave Stevenson <[email protected]>
@pelwell
Copy link
Contributor

pelwell commented Oct 18, 2023

Looks good to me - nice use of the new "assign a literal path string" feature.

Feel free to merge when the auto-builds have completed.

@pelwell pelwell merged commit 61b138a into raspberrypi:rpi-6.1.y Oct 18, 2023
11 of 12 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Oct 19, 2023
See: raspberrypi/linux#5661

kernel: Swap DT aliases from underscore to hyphen
See: raspberrypi/linux#5662

kernel: Add DT aliases to map to DRM card names
See: raspberrypi/linux#5629

kernel: Forcing /dev/fbN assignments for DRM cards
See: raspberrypi/linux#5660

kernel: dts: bcm2712: Use the new model name
See: https://forums.raspberrypi.com/viewtopic.php?p=2146474#p2146474
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Oct 19, 2023
See: raspberrypi/linux#5661

kernel: Swap DT aliases from underscore to hyphen
See: raspberrypi/linux#5662

kernel: Add DT aliases to map to DRM card names
See: raspberrypi/linux#5629

kernel: Forcing /dev/fbN assignments for DRM cards
See: raspberrypi/linux#5660

kernel: dts: bcm2712: Use the new model name
See: https://forums.raspberrypi.com/viewtopic.php?p=2146474#p2146474
@hailfinger
Copy link
Contributor

Is there a variant of this for Pi 4B which I could test? Sometimes my tinydrm SPI display shows up as /dev/fb0, sometimes as /dev/fb1. HDMI is attached as well, so I get the bootup log randomly on HDMI or SPI display.

@6by9
Copy link
Contributor Author

6by9 commented Oct 20, 2023

Is there a variant of this for Pi 4B which I could test? Sometimes my tinydrm SPI display shows up as /dev/fb0, sometimes as /dev/fb1. HDMI is attached as well, so I get the bootup log randomly on HDMI or SPI display.

That's exactly the situation we have on Pi5 with DSI, DPI, or the VEC being separate cards.
NB This is only for DRM drivers, not fbdev.

I hadn't added it for Pi0-4 as it's only going to be SPI type displays that have the potential to cause grief, and the main niggle with this override is that if the card assigned fb0 doesn't load correctly, you end up with no console.

Can I ask which SPI display you're using?
I've started creating a tinydrm overlay to replace fbtft (https://github.com/6by9/linux/blob/rpi-6.1.y-tinydrm/arch/arm/boot/dts/overlays/tinydrm-overlay.dts).
piscreen, pitft28-resistive, pitft35-resistive, watterott-display all have a drm override to select the TinyDRM driver instead of fbdev, but add in touch controllers too.
adafruit-st7735r is TinyDRM only and should probably be moved into tinydrm only.

Once the SPI display overlays are tidied up some more, I'll add an override to them, and for Pi0-4. The main issue I have is with regard testing as I only have about 5 SPI displays (piscreen, pitft35-resistive, the 2 in tinydrm-overlay, and I think I have one other in my parts drawer at home).

@hailfinger
Copy link
Contributor

Is there a variant of this for Pi 4B which I could test? Sometimes my tinydrm SPI display shows up as /dev/fb0, sometimes as /dev/fb1. HDMI is attached as well, so I get the bootup log randomly on HDMI or SPI display.

That's exactly the situation we have on Pi5 with DSI, DPI, or the VEC being separate cards. NB This is only for DRM drivers, not fbdev.

Understood. I'm using tinydrm.

I hadn't added it for Pi0-4 as it's only going to be SPI type displays that have the potential to cause grief, and the main niggle with this override is that if the card assigned fb0 doesn't load correctly, you end up with no console.

Can I ask which SPI display you're using? I've started creating a tinydrm overlay to replace fbtft (https://github.com/6by9/linux/blob/rpi-6.1.y-tinydrm/arch/arm/boot/dts/overlays/tinydrm-overlay.dts). piscreen, pitft28-resistive, pitft35-resistive, watterott-display all have a drm override to select the TinyDRM driver instead of fbdev, but add in touch controllers too. adafruit-st7735r is TinyDRM only and should probably be moved into tinydrm only.

Hardware: Waveshare 2.0 inch 240x320 display with ST7789V controller.
I'm using the mipi-dbi-spi overlay and it works reasonably well (needs to run kmsprint if the display wasn't activated otherwise by Xorg or something). See https://forums.raspberrypi.com/viewtopic.php?t=337019 for details including an init sequence for generating the firmware file.

Once the SPI display overlays are tidied up some more, I'll add an override to them, and for Pi0-4. The main issue I have is with regard testing as I only have about 5 SPI displays (piscreen, pitft35-resistive, the 2 in tinydrm-overlay, and I think I have one other in my parts drawer at home).

I have a bunch of other SPI display models here, but the ST7789V display is the one attached right now, so any immediate tests will target that one. Willing to test other displays later this week.

@6by9
Copy link
Contributor Author

6by9 commented Oct 23, 2023

Hardware: Waveshare 2.0 inch 240x320 display with ST7789V controller. I'm using the mipi-dbi-spi overlay and it works reasonably well (needs to run kmsprint if the display wasn't activated otherwise by Xorg or something). See https://forums.raspberrypi.com/viewtopic.php?t=337019 for details including an init sequence for generating the firmware file.

This is where I'm a little lost over TinyDRM display specific drivers vs mipi-dbi-spi firmware files.
AFAIK there is no repository of firmware files for those not covered. For a general user this makes mipi-dbi-spi too big a step to be accessible. At least the dedicated drivers can be instantiated from overlays with no further involvement.

Also note that currently mipi-dbi-spi is not registered in Mesa as a kmsro driver, so Wayfire currently barfs on it due to falling back to software rendering. It needs the equivalent of https://gitlab.freedesktop.org/mesa/mesa/-/commit/8cfc17bdda31a381bfbaadc75f0d34dada0e8c91 (as does ili9486) - unless someone beats me to it, I'll be making a PR to Mesa with the relevant change soon.

I have a bunch of other SPI display models here, but the ST7789V display is the one attached right now, so any immediate tests will target that one. Willing to test other displays later this week.

I may take you up on that. The main niggle with the panel specific drivers is noting that many of them have the opposite sense for the reset line, so it's not necessarily a trivial conversion of the overlay.

Just for you - #5675.
dtparam=drm_fb0_vc4 should lock /dev/fb0 to the vc4 HDMI/DSI/DPI display on Pi0-4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants