blob: 5187136fe1de961a4ceaee2e8729b9aaa39daa38 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Salomonb6f448e2008-04-28 02:15:03 -070010#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include "power.h"
12
Rafael J. Wysocki46cd2f32006-02-07 12:58:50 -080013#if defined(CONFIG_VT) && defined(CONFIG_VT_CONSOLE)
14#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016static int orig_fgconsole, orig_kmsg;
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
18int pm_prepare_console(void)
19{
Alan Cox8d233552009-09-19 13:13:25 -070020 orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
21 if (orig_fgconsole < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 orig_kmsg = kmsg_redirect;
25 kmsg_redirect = SUSPEND_CONSOLE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 return 0;
27}
28
29void pm_restore_console(void)
30{
Alan Cox8d233552009-09-19 13:13:25 -070031 if (orig_fgconsole >= 0) {
32 vt_move_to_console(orig_fgconsole, 0);
33 kmsg_redirect = orig_kmsg;
Andres Salomonb6f448e2008-04-28 02:15:03 -070034 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070035}
Rafael J. Wysockif7b89882006-02-01 03:05:21 -080036#endif