[package] base-files, ppp: fix interface shutdown
[openwrt.git] / target / linux / goldfish / patches-2.6.30 / 0071-PM-earlysuspend-Add-console-switch-when-user-reque.patch
1 From 0083b2afe89dea4a06bfd967b164318ad0bccd11 Mon Sep 17 00:00:00 2001
2 From: =?utf-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= <arve@android.com>
3 Date: Wed, 15 Oct 2008 17:52:20 -0700
4 Subject: [PATCH 071/134] PM: earlysuspend: Add console switch when user requested sleep state changes.
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=utf-8
7 Content-Transfer-Encoding: 8bit
8
9 Signed-off-by: Arve Hjønnevåg <arve@android.com>
10 ---
11 kernel/power/Kconfig | 17 ++++++++
12 kernel/power/Makefile | 1 +
13 kernel/power/consoleearlysuspend.c | 78 ++++++++++++++++++++++++++++++++++++
14 3 files changed, 96 insertions(+), 0 deletions(-)
15 create mode 100644 kernel/power/consoleearlysuspend.c
16
17 --- a/kernel/power/Kconfig
18 +++ b/kernel/power/Kconfig
19 @@ -157,6 +157,23 @@ config EARLYSUSPEND
20 Call early suspend handlers when the user requested sleep state
21 changes.
22
23 +choice
24 + prompt "User-space screen access"
25 + default CONSOLE_EARLYSUSPEND
26 + depends on HAS_EARLYSUSPEND
27 +
28 + config NO_USER_SPACE_SCREEN_ACCESS_CONTROL
29 + bool "None"
30 +
31 + config CONSOLE_EARLYSUSPEND
32 + bool "Console switch on early-suspend"
33 + depends on HAS_EARLYSUSPEND && VT
34 + ---help---
35 + Register early suspend handler to perform a console switch to
36 + when user-space should stop drawing to the screen and a switch
37 + back when it should resume.
38 +endchoice
39 +
40 config HIBERNATION
41 bool "Hibernation (aka 'suspend to disk')"
42 depends on PM && SWAP && ARCH_HIBERNATION_POSSIBLE
43 --- a/kernel/power/Makefile
44 +++ b/kernel/power/Makefile
45 @@ -9,6 +9,7 @@ obj-$(CONFIG_FREEZER) += process.o
46 obj-$(CONFIG_WAKELOCK) += wakelock.o
47 obj-$(CONFIG_USER_WAKELOCK) += userwakelock.o
48 obj-$(CONFIG_EARLYSUSPEND) += earlysuspend.o
49 +obj-$(CONFIG_CONSOLE_EARLYSUSPEND) += consoleearlysuspend.o
50 obj-$(CONFIG_HIBERNATION) += swsusp.o disk.o snapshot.o swap.o user.o
51
52 obj-$(CONFIG_MAGIC_SYSRQ) += poweroff.o
53 --- /dev/null
54 +++ b/kernel/power/consoleearlysuspend.c
55 @@ -0,0 +1,78 @@
56 +/* kernel/power/consoleearlysuspend.c
57 + *
58 + * Copyright (C) 2005-2008 Google, Inc.
59 + *
60 + * This software is licensed under the terms of the GNU General Public
61 + * License version 2, as published by the Free Software Foundation, and
62 + * may be copied, distributed, and modified under those terms.
63 + *
64 + * This program is distributed in the hope that it will be useful,
65 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
66 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67 + * GNU General Public License for more details.
68 + *
69 + */
70 +
71 +#include <linux/console.h>
72 +#include <linux/earlysuspend.h>
73 +#include <linux/kbd_kern.h>
74 +#include <linux/module.h>
75 +#include <linux/vt_kern.h>
76 +#include <linux/wait.h>
77 +
78 +#define EARLY_SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
79 +
80 +static int orig_fgconsole;
81 +static void console_early_suspend(struct early_suspend *h)
82 +{
83 + acquire_console_sem();
84 + orig_fgconsole = fg_console;
85 + if (vc_allocate(EARLY_SUSPEND_CONSOLE))
86 + goto err;
87 + if (set_console(EARLY_SUSPEND_CONSOLE))
88 + goto err;
89 + release_console_sem();
90 +
91 + if (vt_waitactive(EARLY_SUSPEND_CONSOLE))
92 + pr_warning("console_early_suspend: Can't switch VCs.\n");
93 + return;
94 +err:
95 + pr_warning("console_early_suspend: Can't set console\n");
96 + release_console_sem();
97 +}
98 +
99 +static void console_late_resume(struct early_suspend *h)
100 +{
101 + int ret;
102 + acquire_console_sem();
103 + ret = set_console(orig_fgconsole);
104 + release_console_sem();
105 + if (ret) {
106 + pr_warning("console_late_resume: Can't set console.\n");
107 + return;
108 + }
109 +
110 + if (vt_waitactive(orig_fgconsole))
111 + pr_warning("console_late_resume: Can't switch VCs.\n");
112 +}
113 +
114 +static struct early_suspend console_early_suspend_desc = {
115 + .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING,
116 + .suspend = console_early_suspend,
117 + .resume = console_late_resume,
118 +};
119 +
120 +static int __init console_early_suspend_init(void)
121 +{
122 + register_early_suspend(&console_early_suspend_desc);
123 + return 0;
124 +}
125 +
126 +static void __exit console_early_suspend_exit(void)
127 +{
128 + unregister_early_suspend(&console_early_suspend_desc);
129 +}
130 +
131 +module_init(console_early_suspend_init);
132 +module_exit(console_early_suspend_exit);
133 +
This page took 0.048177 seconds and 5 git commands to generate.