maru_pm: Add suspend / wakeup notifier. 59/12559/1
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 19 Nov 2013 05:21:19 +0000 (14:21 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Tue, 19 Nov 2013 05:21:19 +0000 (14:21 +0900)
Add suspend / wakeup notifier to tell sdb.

Change-Id: I038f70f7a97cc3b60fab357a7c637c754aa035f9
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/guest_server.h
tizen/src/hw/maru_pm.c

index 81d46de..e869584 100644 (file)
@@ -40,7 +40,7 @@ void shutdown_guest_server( void );
 gchar *get_tizen_sdk_data_path(void);
 
 
-#define STATE_RESUME 0
+#define STATE_RUNNING 0
 #define STATE_SUSPEND 1
 void notify_all_sdb_clients(int state);
 
index a9da1a9..9bb2b68 100644 (file)
@@ -31,6 +31,7 @@
 #include "sysemu/sysemu.h"
 
 #include "debug_ch.h"
+#include "guest_server.h"
 
 /* define debug channel */
 MULTI_DEBUG_CHANNEL(tizen, maru_pm);
@@ -38,6 +39,9 @@ MULTI_DEBUG_CHANNEL(tizen, maru_pm);
 ACPIREGS *maru_pm_ar;
 acpi_update_sci_fn maru_pm_update_sci;
 
+static Notifier maru_suspend;
+static Notifier maru_wakeup;
+
 void resume(void)
 {
     TRACE("resume called.\n");
@@ -45,8 +49,21 @@ void resume(void)
     maru_pm_update_sci(maru_pm_ar);
 }
 
+static void maru_notify_suspend(Notifier *notifier, void *data) {
+    notify_all_sdb_clients(STATE_SUSPEND);
+}
+
+static void maru_notify_wakeup(Notifier *notifier, void *data) {
+    notify_all_sdb_clients(STATE_RUNNING);
+}
+
 void acpi_maru_pm_init(ACPIREGS *ar, acpi_update_sci_fn update_sci) {
     maru_pm_ar = ar;
     qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_OTHER, 1);
     maru_pm_update_sci = update_sci;
+
+    maru_suspend.notify = maru_notify_suspend;
+    maru_wakeup.notify = maru_notify_wakeup;
+    qemu_register_suspend_notifier(&maru_suspend);
+    qemu_register_wakeup_notifier(&maru_wakeup);
 }