drm/client: Add acquire_outputs callback; implement for fbdev emulation

Add the callback acquire_outputs to drm_client_funcs to inform an internal
DRM client that vga-switcheroo is about to switch the physical outputs to
the client's device. Allows the client to prepare its internal state for
the upcoming switch.

Wire up the DRM client helpers to invoke the helper for a device's
clients.

Implement acquire_outputs for fbdev emulation. Invoke fb_switch_outputs(),
which remaps framebuffers to virtual terminals in fbcon. Currently this
is still being done by vga-switcheroo. With more DRM clients becoming
available, vga-switcheroo needs to become client agonostic.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Maxime Ripard <mripard@kernel.org>
Acked-by: Helge Deller <deller@gmx.de>
Link: https://patch.msgid.link/20260709092215.168172-3-tzimmermann@suse.de
This commit is contained in:
Thomas Zimmermann committed 2026-09-11 16:52:43 +02:00
1 parent 138e7ff66a
commit 4e089d048a
4 files changed
+51 -7

No files matched your search

+16 -7
View File
@@ -47,6 +47,14 @@ static int drm_fbdev_client_restore(struct drm_client_dev *client, bool force)
return 0;
}
static void drm_fbdev_client_acquire_outputs(struct drm_client_dev *client)
{
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
if (fb_helper->info)
fb_switch_outputs(fb_helper->info);
}
static int drm_fbdev_client_hotplug(struct drm_client_dev *client)
{
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
@@ -95,13 +103,14 @@ static int drm_fbdev_client_resume(struct drm_client_dev *client)
}
static const struct drm_client_funcs drm_fbdev_client_funcs = {
.owner = THIS_MODULE,
.free = drm_fbdev_client_free,
.unregister = drm_fbdev_client_unregister,
.restore = drm_fbdev_client_restore,
.hotplug = drm_fbdev_client_hotplug,
.suspend = drm_fbdev_client_suspend,
.resume = drm_fbdev_client_resume,
.owner = THIS_MODULE,
.free = drm_fbdev_client_free,
.unregister = drm_fbdev_client_unregister,
.restore = drm_fbdev_client_restore,
.acquire_outputs = drm_fbdev_client_acquire_outputs,
.hotplug = drm_fbdev_client_hotplug,
.suspend = drm_fbdev_client_suspend,
.resume = drm_fbdev_client_resume,
};
/**
+18
View File
@@ -123,6 +123,24 @@ void drm_client_dev_restore(struct drm_device *dev, bool force)
mutex_unlock(&dev->clientlist_mutex);
}
void drm_client_dev_acquire_outputs(struct drm_device *dev)
{
struct drm_client_dev *client;
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return;
mutex_lock(&dev->clientlist_mutex);
list_for_each_entry(client, &dev->clientlist, list) {
if (!client->funcs || !client->funcs->acquire_outputs)
continue;
client->funcs->acquire_outputs(client);
}
mutex_unlock(&dev->clientlist_mutex);
}
EXPORT_SYMBOL(drm_client_dev_acquire_outputs);
static int drm_client_suspend(struct drm_client_dev *client)
{
struct drm_device *dev = client->dev;
+14
View File
@@ -66,6 +66,20 @@ struct drm_client_funcs {
*/
int (*restore)(struct drm_client_dev *client, bool force);
/**
* @acquire_outputs:
*
* Called by vga-switcheroo. Informs the client that the outputs will
* be switched to its device. When @acquire_outputs runs, the outputs
* have not been switched yet. The client should only prepare the software
* state. After the switch happened, the client might get a hotplug
* event to update the hardware state.
*
* This callback exists for remapping framebuffers to virtual terminals
* in fbcon.
*/
void (*acquire_outputs)(struct drm_client_dev *client);
/**
* @hotplug:
*
+3
View File
@@ -11,6 +11,7 @@ struct drm_device;
void drm_client_dev_unregister(struct drm_device *dev);
void drm_client_dev_hotplug(struct drm_device *dev);
void drm_client_dev_restore(struct drm_device *dev, bool force);
void drm_client_dev_acquire_outputs(struct drm_device *dev);
void drm_client_dev_suspend(struct drm_device *dev);
void drm_client_dev_resume(struct drm_device *dev);
#else
@@ -20,6 +21,8 @@ static inline void drm_client_dev_hotplug(struct drm_device *dev)
{ }
static inline void drm_client_dev_restore(struct drm_device *dev, bool force)
{ }
static inline void drm_client_dev_acquire_outputs(struct drm_device *dev)
{ }
static inline void drm_client_dev_suspend(struct drm_device *dev)
{ }
static inline void drm_client_dev_resume(struct drm_device *dev)