Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/drm Hook up drm suspend/resume.



details:   https://anonhg.NetBSD.org/src/rev/c01c13460604
branches:  trunk
changeset: 330410:c01c13460604
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Jul 07 20:21:31 2014 +0000

description:
Hook up drm suspend/resume.

diffstat:

 sys/external/bsd/drm2/drm/drm_drv.c |  54 +++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 2 deletions(-)

diffs (114 lines):

diff -r 07f8ab0d2c44 -r c01c13460604 sys/external/bsd/drm2/drm/drm_drv.c
--- a/sys/external/bsd/drm2/drm/drm_drv.c       Mon Jul 07 20:14:43 2014 +0000
+++ b/sys/external/bsd/drm2/drm/drm_drv.c       Mon Jul 07 20:21:31 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_drv.c,v 1.5 2014/06/13 00:47:08 riastradh Exp $    */
+/*     $NetBSD: drm_drv.c,v 1.6 2014/07/07 20:21:31 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.5 2014/06/13 00:47:08 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.6 2014/07/07 20:21:31 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -44,6 +44,7 @@
 /* XXX Mega-kludge because modules are broken.  */
 #include <sys/once.h>
 #endif
+#include <sys/pmf.h>
 #include <sys/poll.h>
 #ifndef _MODULE
 #include <sys/reboot.h>                /* XXX drm_init kludge */
@@ -54,6 +55,8 @@
 
 #include <prop/proplib.h>
 
+#include <linux/pm.h>
+
 #include <drm/drmP.h>
 
 #include "ioconf.h"
@@ -97,6 +100,9 @@
 static ONCE_DECL(drm_init_once);
 #endif
 
+static bool    drm_suspend(device_t, const pmf_qual_t *);
+static bool    drm_resume(device_t, const pmf_qual_t *);
+
 static void    drm_undo_fill_in_dev(struct drm_device *);
 
 static struct drm_softc *drm_dev_softc(dev_t);
@@ -386,10 +392,22 @@
                }
        }
 
+       if (!pmf_device_register(parent, NULL, NULL)) {
+               aprint_error_dev(parent, "unable to establish power handler");
+               goto fail2;
+       }
+       if (!pmf_device_register(self, &drm_suspend, &drm_resume)) {
+               aprint_error_dev(self, "unable to establish power handler");
+               goto fail3;
+       }
+
        /* Success!  */
        sc->sc_initialized = true;
        return;
 
+fail4: __unused
+       pmf_device_deregister(self);
+fail3: pmf_device_deregister(parent);
 fail2: if (dev->driver->unload != NULL)
                (*dev->driver->unload)(dev);
 fail1: drm_undo_fill_in_dev(dev);
@@ -411,6 +429,9 @@
        if (sc->sc_opencount != 0)
                return EBUSY;
 
+       pmf_device_deregister(self);
+       pmf_device_deregister(device_parent(self));
+
        /* XXX The placement of this is pretty random...  */
        if (dev->driver->unload != NULL)
                (*dev->driver->unload)(dev);
@@ -509,6 +530,35 @@
        spin_lock_destroy(&dev->count_lock);
 }
 
+static bool
+drm_suspend(device_t self, const pmf_qual_t *qual)
+{
+       struct drm_softc *const sc = device_private(self);
+       struct drm_device *const dev = sc->sc_drm_dev;
+       int error;
+
+       error = (*dev->driver->suspend)(dev,
+           (pm_message_t) { .event = PM_EVENT_SUSPEND });
+       if (error)
+               return false;
+
+       return true;
+}
+
+static bool
+drm_resume(device_t self, const pmf_qual_t *qual)
+{
+       struct drm_softc *const sc = device_private(self);
+       struct drm_device *const dev = sc->sc_drm_dev;
+       int error;
+
+       error = (*dev->driver->resume)(dev);
+       if (error)
+               return false;
+
+       return true;
+}
+
 static struct drm_softc *
 drm_dev_softc(dev_t d)
 {



Home | Main Index | Thread Index | Old Index