Skip to content

Commit

Permalink
drm/vc4: fkms: Add firmware-kms mode
Browse files Browse the repository at this point in the history
This is a squash of all firmware-kms related patches from previous
branches, up to and including
"drm/vc4: Set the possible crtcs mask correctly for planes with FKMS"
plus a couple of minor fixups for the 5.9 branch.
Please refer to earlier branches for full history.

This patch includes work by Eric Anholt, James Hughes, Phil Elwell,
Dave Stevenson, Dom Cobley, and Jonathon Bell.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drm/vc4: Fixup firmware-kms after "drm/atomic: Pass the full state to CRTC atomic enable/disable"

Prototype for those calls changed, so amend fkms (which isn't
upstream) to match.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drm/vc4: Fixup fkms for API change

Atomic flush and check changed API, so fix up the downstream-only
FKMS driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drm/vc4: Make normalize_zpos conditional on using fkms

Eric's view was that there was no point in having zpos
support on vc4 as all the planes had the same functionality.

Can be later squashed into (and fixes):
drm/vc4: Add firmware-kms mode

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drm/vc4: FKMS: Change of Broadcast RGB mode needs a mode change

The Broadcast RGB (aka HDMI limited/full range) property is only
notified to the firmware on mode change, so this needs to be
signalled when set.

raspberrypi/firmware#1580

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

vc4/drv: Only notify firmware of display done with kms

fkms driver still wants firmware display to be active

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

ydrm/vc4: fkms: Fix margin calculations for the right/bottom edges

The calculations clipped the right/bottom edge of the clipped
range based on the left/top margins.

#4447

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drm/vc4: fkms: Use new devm_rpi_firmware_get api

drm/kms: Add allow_fb_modifiers

Signed-off-by: Dom Cobley <popcornmix@gmail.com>

drm/vc4: Add async update support for cursor planes

Now that cursors are implemented as regular planes, all cursor
movements result in atomic updates. As the firmware-kms driver
doesn't support asynchronous updates, these are synchronous, which
limits the update rate to the screen refresh rate. Xorg seems unaware
of this (or at least of the effect of this), because if the mouse is
configured with a higher update rate than the screen then continuous
mouse movement results in an increasing backlog of mouse events -
cue extreme lag.

Add minimal support for asynchronous updates - limited to cursor
planes - to eliminate the lag.

See: #4971
     #4988

Signed-off-by: Phil Elwell <phil@raspberrypi.com>

drivers/gpu/drm/vc4: Add missing 32-bit RGB formats

The missing 32-bit per pixel ABGR and various "RGB with an X value"
formats are added. Change sent by Dave Stevenson.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>

drm: vc4: Fixup duplicated macro definition in vc4_firmware_kms

Both vc4_drv.h and vc4_firmware_kms.c had definitions for
to_vc4_crtc.

Rename the fkms one to make it unique, and drop the magic
define vc4_crtc vc4_kms_crtc
define to_vc4_crtc to_vc4_kms_crtc
that renamed half the variable and function names in a slightly
unexpected way.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drm/vc4: Fix FKMS for when the YUV chroma planes are different buffers

The code was assuming that it was a single buffer with offsets,
when kmstest uses separate buffers and 0 offsets for each plane.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>

drm/vc4: fkms: Rename plane related functions

The name collide with the Full KMS functions that are going to be made
public.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>

drm/vc4_fkms: Fix up interrupt handler for both 2835/2711 and 2712

2712 has switched from using the SMI peripheral to another interrupt
source for the vsync interrupt, so handle both sources cleanly.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
  • Loading branch information
6by9 authored and popcornmix committed Mar 11, 2024
1 parent bd918f3 commit 03a8730
Show file tree
Hide file tree
Showing 7 changed files with 2,312 additions and 14 deletions.
1 change: 1 addition & 0 deletions drivers/gpu/drm/vc4/Makefile
Expand Up @@ -9,6 +9,7 @@ vc4-y := \
vc4_dpi.o \
vc4_dsi.o \
vc4_fence.o \
vc4_firmware_kms.o \
vc4_kms.o \
vc4_gem.o \
vc4_hdmi.o \
Expand Down
3 changes: 2 additions & 1 deletion drivers/gpu/drm/vc4/vc4_debugfs.c
Expand Up @@ -24,7 +24,8 @@ vc4_debugfs_init(struct drm_minor *minor)
struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
struct drm_device *drm = &vc4->base;

drm_WARN_ON(drm, vc4_hvs_debugfs_init(minor));
if (vc4->hvs)
drm_WARN_ON(drm, vc4_hvs_debugfs_init(minor));

if (vc4->v3d) {
drm_WARN_ON(drm, vc4_bo_debugfs_init(minor));
Expand Down
29 changes: 23 additions & 6 deletions drivers/gpu/drm/vc4/vc4_drv.c
Expand Up @@ -283,6 +283,18 @@ static const struct of_device_id vc4_dma_range_matches[] = {
{}
};

/*
* we need this helper function for determining presence of fkms
* before it's been bound
*/
static bool firmware_kms(void)
{
return of_device_is_available(of_find_compatible_node(NULL, NULL,
"raspberrypi,rpi-firmware-kms")) ||
of_device_is_available(of_find_compatible_node(NULL, NULL,
"raspberrypi,rpi-firmware-kms-2711"));
}

static int vc4_drm_bind(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
Expand Down Expand Up @@ -357,7 +369,7 @@ static int vc4_drm_bind(struct device *dev)
if (ret)
goto err;

if (firmware) {
if (firmware && !firmware_kms()) {
ret = rpi_firmware_property(firmware,
RPI_FIRMWARE_NOTIFY_DISPLAY_DONE,
NULL, 0);
Expand All @@ -375,16 +387,20 @@ static int vc4_drm_bind(struct device *dev)
if (ret)
goto err;

ret = vc4_plane_create_additional_planes(drm);
if (ret)
goto err;
if (!vc4->firmware_kms) {
ret = vc4_plane_create_additional_planes(drm);
if (ret)
goto err;
}

ret = vc4_kms_load(drm);
if (ret < 0)
goto err;

drm_for_each_crtc(crtc, drm)
vc4_crtc_disable_at_boot(crtc);
if (!vc4->firmware_kms) {
drm_for_each_crtc(crtc, drm)
vc4_crtc_disable_at_boot(crtc);
}

ret = drm_dev_register(drm, 0);
if (ret < 0)
Expand Down Expand Up @@ -430,6 +446,7 @@ static struct platform_driver *const component_drivers[] = {
&vc4_dsi_driver,
&vc4_txp_driver,
&vc4_crtc_driver,
&vc4_firmware_kms_driver,
&vc4_v3d_driver,
};

Expand Down
7 changes: 7 additions & 0 deletions drivers/gpu/drm/vc4/vc4_drv.h
Expand Up @@ -87,8 +87,12 @@ struct vc4_dev {

unsigned int irq;

bool firmware_kms;
struct rpi_firmware *firmware;

struct vc4_hvs *hvs;
struct vc4_v3d *v3d;
struct vc4_fkms *fkms;

struct vc4_hang_state *hang_state;

Expand Down Expand Up @@ -963,6 +967,9 @@ extern struct platform_driver vc4_dsi_driver;
/* vc4_fence.c */
extern const struct dma_fence_ops vc4_fence_ops;

/* vc4_firmware_kms.c */
extern struct platform_driver vc4_firmware_kms_driver;

/* vc4_gem.c */
int vc4_gem_init(struct drm_device *dev);
int vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
Expand Down

0 comments on commit 03a8730

Please sign in to comment.