blob: 218e5af9015637af8808caad1aaf05c476428371 [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>
Bernhard Walle5ada9182009-12-14 18:00:43 -08009#include <linux/vt.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
Bernhard Walle5ada9182009-12-14 18:00:43 -080024 orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 return 0;
26}
27
28void pm_restore_console(void)
29{
Alan Cox8d233552009-09-19 13:13:25 -070030 if (orig_fgconsole >= 0) {
31 vt_move_to_console(orig_fgconsole, 0);
Bernhard Walle5ada9182009-12-14 18:00:43 -080032 vt_kmsg_redirect(orig_kmsg);
Andres Salomonb6f448e2008-04-28 02:15:03 -070033 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070034}
Rafael J. Wysockif7b89882006-02-01 03:05:21 -080035#endif