xref: /OK3568_Linux_fs/external/xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Derived from VTsw_usl.c which is
3  * Copyright 1993 by David Wexelblat <dwex@goblin.org>
4  * by S_ren Schmidt (sos@login.dkuug.dk)
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of David Wexelblat not be used in
11  * advertising or publicity pertaining to distribution of the software without
12  * specific, written prior permission.  David Wexelblat makes no representations
13  * about the suitability of this software for any purpose.  It is provided
14  * "as is" without express or implied warranty.
15  *
16  * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22  * PERFORMANCE OF THIS SOFTWARE.
23  *
24  */
25 
26 #ifdef HAVE_XORG_CONFIG_H
27 #include <xorg-config.h>
28 #endif
29 
30 #include <X11/X.h>
31 #include "xf86.h"
32 #include "xf86Priv.h"
33 #include "xf86_OSlib.h"
34 
35 /*
36  * Handle the VT-switching interface for OSs that use USL-style ioctl()s
37  * (the bsd, sysv, sco, and linux subdirs).
38  */
39 
40 /*
41  * This function is the signal handler for the VT-switching signal.  It
42  * is only referenced inside the OS-support layer.
43  */
44 void
xf86VTRequest(int sig)45 xf86VTRequest(int sig)
46 {
47 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
48     if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
49         xf86Info.vtRequestsPending = TRUE;
50     }
51 #endif
52     return;
53 }
54 
55 Bool
xf86VTSwitchPending()56 xf86VTSwitchPending()
57 {
58 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
59     if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
60         return xf86Info.vtRequestsPending ? TRUE : FALSE;
61     }
62 #endif
63     return FALSE;
64 }
65 
66 Bool
xf86VTSwitchAway()67 xf86VTSwitchAway()
68 {
69 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
70     if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
71         xf86Info.vtRequestsPending = FALSE;
72         if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
73             return FALSE;
74         else
75             return TRUE;
76     }
77 #endif
78     return FALSE;
79 }
80 
81 Bool
xf86VTSwitchTo()82 xf86VTSwitchTo()
83 {
84 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
85     if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
86         xf86Info.vtRequestsPending = FALSE;
87         if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
88             return FALSE;
89         else
90             return TRUE;
91     }
92 #endif
93     return TRUE;
94 }
95 
96 Bool
xf86VTActivate(int vtno)97 xf86VTActivate(int vtno)
98 {
99     if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) {
100         return FALSE;
101     }
102     return TRUE;
103 }
104