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> |
Andres Salomon | b6f448e | 2008-04-28 02:15:03 -0700 | [diff] [blame] | 10 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include "power.h" |
| 12 | |
Rafael J. Wysocki | 46cd2f3 | 2006-02-07 12:58:50 -0800 | [diff] [blame] | 13 | #if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE) |
| 14 | #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) |
| 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | static int orig_fgconsole, orig_kmsg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | int pm_prepare_console(void) |
| 19 | { |
Alan Cox | 8d23355 | 2009-09-19 13:13:25 -0700 | [diff] [blame^] | 20 | orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1); |
| 21 | if (orig_fgconsole < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | orig_kmsg = kmsg_redirect; |
| 25 | kmsg_redirect = SUSPEND_CONSOLE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | void pm_restore_console(void) |
| 30 | { |
Alan Cox | 8d23355 | 2009-09-19 13:13:25 -0700 | [diff] [blame^] | 31 | if (orig_fgconsole >= 0) { |
| 32 | vt_move_to_console(orig_fgconsole, 0); |
| 33 | kmsg_redirect = orig_kmsg; |
Andres Salomon | b6f448e | 2008-04-28 02:15:03 -0700 | [diff] [blame] | 34 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } |
Rafael J. Wysocki | f7b8988 | 2006-02-01 03:05:21 -0800 | [diff] [blame] | 36 | #endif |