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> |
Bernhard Walle | 5ada918 | 2009-12-14 18:00:43 -0800 | [diff] [blame] | 9 | #include <linux/vt.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 | |
Bernhard Walle | 5ada918 | 2009-12-14 18:00:43 -0800 | [diff] [blame] | 24 | orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | void pm_restore_console(void) |
| 29 | { |
Alan Cox | 8d23355 | 2009-09-19 13:13:25 -0700 | [diff] [blame] | 30 | if (orig_fgconsole >= 0) { |
| 31 | vt_move_to_console(orig_fgconsole, 0); |
Bernhard Walle | 5ada918 | 2009-12-14 18:00:43 -0800 | [diff] [blame] | 32 | vt_kmsg_redirect(orig_kmsg); |
Andres Salomon | b6f448e | 2008-04-28 02:15:03 -0700 | [diff] [blame] | 33 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | } |
Rafael J. Wysocki | f7b8988 | 2006-02-01 03:05:21 -0800 | [diff] [blame] | 35 | #endif |