mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
drm/appletbdrm: Add suspend and resume support
The driver has no USB power management callbacks, so the USB core
unbinds it before system suspend and binds it again on resume. The DRM
device is unregistered and registered again on every suspend and resume
cycle, userspace driving the Touch Bar through it (such as tiny-dfr)
loses its device, and the Touch Bar stays dark after resume.
Implement suspend and resume with drm_mode_config_helper_suspend() and
drm_mode_config_helper_resume(), so the device stays registered and the
last committed state is restored on resume. If the device was reset
while suspended, repeat the probe-time handshake first.
Fixes: 0670c2f56e ("drm/tiny: add driver for Apple Touch Bars in x86 Macs")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Vasilij Markin <vasilij.kernel@tototo.si>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Link: https://patch.msgid.link/20261015-appletbdrm-pm-v3-1-47377176619a@tototo.si
This commit is contained in:
parent
382c1e8ba4
commit
6f6a6b9ae0
|
|
@ -30,6 +30,7 @@
|
|||
#include <drm/drm_gem_atomic_helper.h>
|
||||
#include <drm/drm_gem_framebuffer_helper.h>
|
||||
#include <drm/drm_gem_shmem_helper.h>
|
||||
#include <drm/drm_modeset_helper.h>
|
||||
#include <drm/drm_plane.h>
|
||||
#include <drm/drm_print.h>
|
||||
#include <drm/drm_probe_helper.h>
|
||||
|
|
@ -821,6 +822,48 @@ static void appletbdrm_shutdown(struct usb_interface *intf)
|
|||
drm_atomic_helper_shutdown(&adev->drm);
|
||||
}
|
||||
|
||||
static int appletbdrm_suspend(struct usb_interface *intf, pm_message_t message)
|
||||
{
|
||||
struct appletbdrm_device *adev = usb_get_intfdata(intf);
|
||||
|
||||
return drm_mode_config_helper_suspend(&adev->drm);
|
||||
}
|
||||
|
||||
static int appletbdrm_resume(struct usb_interface *intf)
|
||||
{
|
||||
struct appletbdrm_device *adev = usb_get_intfdata(intf);
|
||||
|
||||
return drm_mode_config_helper_resume(&adev->drm);
|
||||
}
|
||||
|
||||
static int appletbdrm_reset_resume(struct usb_interface *intf)
|
||||
{
|
||||
struct appletbdrm_device *adev = usb_get_intfdata(intf);
|
||||
struct drm_device *drm = &adev->drm;
|
||||
int ret, resume_ret;
|
||||
|
||||
/*
|
||||
* A reset puts the device back into its initial state, where it
|
||||
* expects the same handshake as during probe. Resume the DRM side
|
||||
* even if the handshake fails, so that the state saved on suspend
|
||||
* is released.
|
||||
*/
|
||||
ret = appletbdrm_get_information(adev);
|
||||
if (ret) {
|
||||
drm_err(drm, "Failed to get display information\n");
|
||||
goto resume;
|
||||
}
|
||||
|
||||
ret = appletbdrm_signal_readiness(adev);
|
||||
if (ret)
|
||||
drm_err(drm, "Failed to signal readiness\n");
|
||||
|
||||
resume:
|
||||
resume_ret = drm_mode_config_helper_resume(drm);
|
||||
|
||||
return ret ? ret : resume_ret;
|
||||
}
|
||||
|
||||
static const struct usb_device_id appletbdrm_usb_id_table[] = {
|
||||
{ USB_DEVICE_INTERFACE_CLASS(0x05ac, 0x8302, USB_CLASS_AUDIO_VIDEO) },
|
||||
{}
|
||||
|
|
@ -832,6 +875,9 @@ static struct usb_driver appletbdrm_usb_driver = {
|
|||
.probe = appletbdrm_probe,
|
||||
.disconnect = appletbdrm_disconnect,
|
||||
.shutdown = appletbdrm_shutdown,
|
||||
.suspend = appletbdrm_suspend,
|
||||
.resume = appletbdrm_resume,
|
||||
.reset_resume = appletbdrm_reset_resume,
|
||||
.id_table = appletbdrm_usb_id_table,
|
||||
};
|
||||
module_usb_driver(appletbdrm_usb_driver);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user