From: "Arve Hjønnevåg" <arve@android.com>
To: linux-pm@lists.linux-foundation.org
Cc: ncunningham@crca.org.au, u.luckas@road.de, swetland@google.com
Subject: [PATCH 07/10] PM: earlysuspend: Add console switch when user requested sleep state changes.
Date: Tue, 10 Feb 2009 17:49:12 -0800 [thread overview]
Message-ID: <1234316955-31304-8-git-send-email-arve@android.com> (raw)
In-Reply-To: <1234316955-31304-7-git-send-email-arve@android.com>
When early-suspend is enabled, the framebuffer is turned off at
early-suspend. If CONSOLE_EARLYSUSPEND is enabled, a console switch
is used to notify user space that it should stop drawing before
the framebuffer is disabled, and that it should repaint and resume
drawing after the framebuffer is turned back on.
Signed-off-by: Arve Hjønnevåg <arve@android.com>
---
kernel/power/Kconfig | 17 ++++++++
kernel/power/Makefile | 1 +
kernel/power/consoleearlysuspend.c | 78 ++++++++++++++++++++++++++++++++++++
3 files changed, 96 insertions(+), 0 deletions(-)
create mode 100644 kernel/power/consoleearlysuspend.c
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index ccc55be..04e6fad 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -159,6 +159,23 @@ config EARLYSUSPEND
Call early suspend handlers when the user requested sleep state
changes.
+choice
+ prompt "User-space screen access"
+ default CONSOLE_EARLYSUSPEND
+ depends on EARLYSUSPEND
+
+ config NO_USER_SPACE_SCREEN_ACCESS_CONTROL
+ bool "None"
+
+ config CONSOLE_EARLYSUSPEND
+ bool "Console switch on early-suspend"
+ depends on EARLYSUSPEND && VT
+ ---help---
+ Register early suspend handler to perform a console switch
+ when user-space should stop drawing to the screen and a switch
+ back when it should resume.
+endchoice
+
config HIBERNATION
bool "Hibernation (aka 'suspend to disk')"
depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index d3467b3..8bf293d 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_FREEZER) += process.o
obj-$(CONFIG_WAKELOCK) += wakelock.o
obj-$(CONFIG_USER_WAKELOCK) += userwakelock.o
obj-$(CONFIG_EARLYSUSPEND) += earlysuspend.o
+obj-$(CONFIG_CONSOLE_EARLYSUSPEND) += consoleearlysuspend.o
obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
diff --git a/kernel/power/consoleearlysuspend.c b/kernel/power/consoleearlysuspend.c
new file mode 100644
index 0000000..a8befb4
--- /dev/null
+++ b/kernel/power/consoleearlysuspend.c
@@ -0,0 +1,78 @@
+/* kernel/power/consoleearlysuspend.c
+ *
+ * Copyright (C) 2005-2008 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/console.h>
+#include <linux/earlysuspend.h>
+#include <linux/kbd_kern.h>
+#include <linux/module.h>
+#include <linux/vt_kern.h>
+#include <linux/wait.h>
+
+#define EARLY_SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
+
+static int orig_fgconsole;
+static void console_early_suspend(struct early_suspend *h)
+{
+ acquire_console_sem();
+ orig_fgconsole = fg_console;
+ if (vc_allocate(EARLY_SUSPEND_CONSOLE))
+ goto err;
+ if (set_console(EARLY_SUSPEND_CONSOLE))
+ goto err;
+ release_console_sem();
+
+ if (vt_waitactive(EARLY_SUSPEND_CONSOLE))
+ pr_warning("console_early_suspend: Can't switch VCs.\n");
+ return;
+err:
+ pr_warning("console_early_suspend: Can't set console\n");
+ release_console_sem();
+}
+
+static void console_late_resume(struct early_suspend *h)
+{
+ int ret;
+ acquire_console_sem();
+ ret = set_console(orig_fgconsole);
+ release_console_sem();
+ if (ret) {
+ pr_warning("console_late_resume: Can't set console.\n");
+ return;
+ }
+
+ if (vt_waitactive(orig_fgconsole))
+ pr_warning("console_late_resume: Can't switch VCs.\n");
+}
+
+static struct early_suspend console_early_suspend_desc = {
+ .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING,
+ .suspend = console_early_suspend,
+ .resume = console_late_resume,
+};
+
+static int __init console_early_suspend_init(void)
+{
+ register_early_suspend(&console_early_suspend_desc);
+ return 0;
+}
+
+static void __exit console_early_suspend_exit(void)
+{
+ unregister_early_suspend(&console_early_suspend_desc);
+}
+
+module_init(console_early_suspend_init);
+module_exit(console_early_suspend_exit);
+
--
1.6.1
_______________________________________________
linux-pm mailing list
linux-pm@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
next prev parent reply other threads:[~2009-02-11 1:49 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-11 1:49 [RFC][PATCH 00/11] Android PM extensions (version 3) Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 01/10] PM: Add wake lock api Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 02/10] PM: wakelock: Override wakelocks when not using /sys/power/request_state Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 03/10] PM: wakelock: Add driver to access wakelocks from user-space Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 04/10] PM: wakelock: Abort task freezing if a wakelock is locked Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 05/10] PM: Add option to disable /sys/power/state interface Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 06/10] PM: Add early suspend api Arve Hjønnevåg
2009-02-11 1:49 ` Arve Hjønnevåg [this message]
2009-02-11 1:49 ` [PATCH 08/10] PM: earlysuspend: Removing dependence on console Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 09/10] Input: Hold wake lock while event queue is not empty Arve Hjønnevåg
2009-02-11 1:49 ` [PATCH 10/10] ledtrig-sleep: Add led trigger for sleep debugging Arve Hjønnevåg
2009-02-12 11:31 ` [PATCH 09/10] Input: Hold wake lock while event queue is not empty Matthew Garrett
2009-02-13 0:27 ` Arve Hjønnevåg
2009-02-13 0:34 ` Matthew Garrett
2009-02-13 0:38 ` Arve Hjønnevåg
2009-02-13 0:40 ` Matthew Garrett
2009-02-13 0:52 ` Arve Hjønnevåg
2009-02-13 0:57 ` Matthew Garrett
2009-02-13 23:06 ` Rafael J. Wysocki
2009-02-13 23:51 ` Arve Hjønnevåg
2009-02-14 0:09 ` Matthew Garrett
2009-02-14 0:13 ` Arve Hjønnevåg
2009-02-14 0:18 ` Matthew Garrett
2009-02-12 11:28 ` [PATCH 07/10] PM: earlysuspend: Add console switch when user requested sleep state changes Matthew Garrett
2009-02-12 11:34 ` [PATCH 06/10] PM: Add early suspend api Matthew Garrett
2009-02-12 22:00 ` [PATCH 01/10] PM: Add wake lock api mark gross
2009-02-12 23:06 ` Arve Hjønnevåg
2009-02-17 21:05 ` [RFC][PATCH 00/11] Android PM extensions (version 3) Pavel Machek
2009-02-19 1:43 ` Arve Hjønnevåg
2009-02-19 12:54 ` Rafael J. Wysocki
2009-02-22 13:48 ` Pavel Machek
2009-02-23 23:31 ` Arve Hjønnevåg
2009-02-23 23:54 ` Rafael J. Wysocki
2009-02-25 13:23 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1234316955-31304-8-git-send-email-arve@android.com \
--to=arve@android.com \
--cc=linux-pm@lists.linux-foundation.org \
--cc=ncunningham@crca.org.au \
--cc=swetland@google.com \
--cc=u.luckas@road.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox