htcleo: add Cotulla's fixes for non-android touchscreen!
[htc-linux.git] / kernel / power / consoleearlysuspend.c
bloba3edcb2673896d456de72c76c53228f8638de311
1 /* kernel/power/consoleearlysuspend.c
3 * Copyright (C) 2005-2008 Google, Inc.
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <linux/console.h>
17 #include <linux/earlysuspend.h>
18 #include <linux/kbd_kern.h>
19 #include <linux/module.h>
20 #include <linux/vt_kern.h>
21 #include <linux/wait.h>
23 #define EARLY_SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
25 static int orig_fgconsole;
26 static void console_early_suspend(struct early_suspend *h)
28 acquire_console_sem();
29 orig_fgconsole = fg_console;
30 if (vc_allocate(EARLY_SUSPEND_CONSOLE))
31 goto err;
32 if (set_console(EARLY_SUSPEND_CONSOLE))
33 goto err;
34 release_console_sem();
36 if (vt_waitactive(EARLY_SUSPEND_CONSOLE + 1))
37 pr_warning("console_early_suspend: Can't switch VCs.\n");
38 return;
39 err:
40 pr_warning("console_early_suspend: Can't set console\n");
41 release_console_sem();
44 static void console_late_resume(struct early_suspend *h)
46 int ret;
47 acquire_console_sem();
48 ret = set_console(orig_fgconsole);
49 release_console_sem();
50 if (ret) {
51 pr_warning("console_late_resume: Can't set console.\n");
52 return;
55 if (vt_waitactive(orig_fgconsole + 1))
56 pr_warning("console_late_resume: Can't switch VCs.\n");
59 static struct early_suspend console_early_suspend_desc = {
60 .level = EARLY_SUSPEND_LEVEL_STOP_DRAWING,
61 .suspend = console_early_suspend,
62 .resume = console_late_resume,
65 static int __init console_early_suspend_init(void)
67 register_early_suspend(&console_early_suspend_desc);
68 return 0;
71 static void __exit console_early_suspend_exit(void)
73 unregister_early_suspend(&console_early_suspend_desc);
76 module_init(console_early_suspend_init);
77 module_exit(console_early_suspend_exit);