summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/tiny/appletbdrm.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/gpu/drm/tiny/appletbdrm.c b/drivers/gpu/drm/tiny/appletbdrm.c
index 4297d9c1125e..350dc598c9e7 100644
--- a/drivers/gpu/drm/tiny/appletbdrm.c
+++ b/drivers/gpu/drm/tiny/appletbdrm.c
@@ -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);