1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1999 Nick Sayer (who stole shamelessly from blank_saver)
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer,
12 * without modification, immediately at the beginning of the file.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * $FreeBSD: stable/12/sys/dev/syscons/apm/apm_saver.c 326255 2017-11-27 14:52:40Z pfg $
31 */
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/condvar.h>
36 #include <sys/kernel.h>
37 #include <sys/kthread.h>
38 #include <sys/lock.h>
39 #include <sys/module.h>
40 #include <sys/mutex.h>
41 #include <sys/consio.h>
42 #include <sys/fbio.h>
43
44 #include <dev/fb/fbreg.h>
45 #include <dev/fb/splashreg.h>
46 #include <dev/syscons/syscons.h>
47
48 #include <sys/selinfo.h>
49 #include <machine/apm_bios.h>
50 #include <machine/pc/bios.h>
51 #include <machine/bus.h>
52 #include <i386/bios/apm.h>
53
54 extern int apm_display(int newstate);
55
56 extern struct apm_softc apm_softc;
57
58 static int blanked=0;
59
60 static int
apm_saver(video_adapter_t * adp,int blank)61 apm_saver(video_adapter_t *adp, int blank)
62 {
63 if (!apm_softc.initialized || !apm_softc.active)
64 return 0;
65
66 if (blank==blanked)
67 return 0;
68
69 blanked=blank;
70
71 apm_display(!blanked);
72
73 return 0;
74 }
75
76 static int
apm_init(video_adapter_t * adp)77 apm_init(video_adapter_t *adp)
78 {
79 if (!apm_softc.initialized || !apm_softc.active)
80 printf("WARNING: apm_saver module requires apm enabled\n");
81 return 0;
82 }
83
84 static int
apm_term(video_adapter_t * adp)85 apm_term(video_adapter_t *adp)
86 {
87 return 0;
88 }
89
90 static scrn_saver_t apm_module = {
91 "apm_saver", apm_init, apm_term, apm_saver, NULL,
92 };
93
94 SAVER_MODULE(apm_saver, apm_module);
95 MODULE_DEPEND(apm_saver, apm, 1, 1, 1);
96