blob: b1dc456474b57d80664560c202ce027cce73db13 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
H Hartley Sweeten37cce262011-09-21 22:47:55 +02002 * Functions for saving/restoring console.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
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#define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1)
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015static int orig_fgconsole, orig_kmsg;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17int pm_prepare_console(void)
18{
Alan Cox8d233552009-09-19 13:13:25 -070019 orig_fgconsole = vt_move_to_console(SUSPEND_CONSOLE, 1);
20 if (orig_fgconsole < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Bernhard Walle5ada9182009-12-14 18:00:43 -080023 orig_kmsg = vt_kmsg_redirect(SUSPEND_CONSOLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 return 0;
25}
26
27void pm_restore_console(void)
28{
Alan Cox8d233552009-09-19 13:13:25 -070029 if (orig_fgconsole >= 0) {
30 vt_move_to_console(orig_fgconsole, 0);
Bernhard Walle5ada9182009-12-14 18:00:43 -080031 vt_kmsg_redirect(orig_kmsg);
Andres Salomonb6f448e2008-04-28 02:15:03 -070032 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070033}