Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/power/process.c - Functions for saving/restoring console. |
| 3 | * |
| 4 | * Originally from swsusp. |
| 5 | */ |
| 6 | |
| 7 | #include <linux/vt_kern.h> |
| 8 | #include <linux/kbd_kern.h> |
| 9 | #include <linux/console.h> |
| 10 | #include "power.h" |
| 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #ifdef SUSPEND_CONSOLE |
| 13 | static int orig_fgconsole, orig_kmsg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
| 15 | int pm_prepare_console(void) |
| 16 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | acquire_console_sem(); |
| 18 | |
| 19 | orig_fgconsole = fg_console; |
| 20 | |
| 21 | if (vc_allocate(SUSPEND_CONSOLE)) { |
| 22 | /* we can't have a free VC for now. Too bad, |
| 23 | * we don't want to mess the screen for now. */ |
| 24 | release_console_sem(); |
| 25 | return 1; |
| 26 | } |
| 27 | |
| 28 | set_console(SUSPEND_CONSOLE); |
| 29 | release_console_sem(); |
| 30 | |
| 31 | if (vt_waitactive(SUSPEND_CONSOLE)) { |
| 32 | pr_debug("Suspend: Can't switch VCs."); |
| 33 | return 1; |
| 34 | } |
| 35 | orig_kmsg = kmsg_redirect; |
| 36 | kmsg_redirect = SUSPEND_CONSOLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | void pm_restore_console(void) |
| 41 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | acquire_console_sem(); |
| 43 | set_console(orig_fgconsole); |
| 44 | release_console_sem(); |
| 45 | kmsg_redirect = orig_kmsg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | return; |
| 47 | } |
Rafael J. Wysocki | f7b8988 | 2006-02-01 03:05:21 -0800 | [diff] [blame] | 48 | #endif |