Remove BSD APM support.
None of the current BSD is actually using this code. (checked DragonFly 5.8.1, FreeBSD 11.2, NetBSD 9.0 and OpenBSD 6.7) Signed-off-by: Matthieu Herrb <matthieu@herrb.eu>
This commit is contained in:
		
							parent
							
								
									b5b529799a
								
							
						
					
					
						commit
						5dc16f6fec
					
				|  | @ -237,15 +237,6 @@ dnl OpenBSD /dev/xf86 aperture driver | ||||||
| if test -c /dev/xf86 ; then | if test -c /dev/xf86 ; then | ||||||
| 	AC_DEFINE(HAS_APERTURE_DRV, 1, [System has /dev/xf86 aperture driver]) | 	AC_DEFINE(HAS_APERTURE_DRV, 1, [System has /dev/xf86 aperture driver]) | ||||||
| fi | fi | ||||||
| 
 |  | ||||||
| dnl BSD APM support  |  | ||||||
| AC_CHECK_HEADER([machine/apmvar.h],[ |  | ||||||
| 	AC_CHECK_HEADER([sys/event.h], |  | ||||||
| 		ac_cv_BSD_KQUEUE_APM=yes, |  | ||||||
| 		ac_cv_BSD_APM=yes)]) |  | ||||||
| 
 |  | ||||||
| AM_CONDITIONAL(BSD_APM, [test "x$ac_cv_BSD_APM" = xyes]) |  | ||||||
| AM_CONDITIONAL(BSD_KQUEUE_APM, [test "x$ac_cv_BSD_KQUEUE_APM" = xyes]) |  | ||||||
| 	 | 	 | ||||||
| dnl glibc backtrace support check | dnl glibc backtrace support check | ||||||
| AC_CHECK_HEADER([execinfo.h],[ | AC_CHECK_HEADER([execinfo.h],[ | ||||||
|  |  | ||||||
|  | @ -1,15 +1,7 @@ | ||||||
| noinst_LTLIBRARIES = libbsd.la | noinst_LTLIBRARIES = libbsd.la | ||||||
| 
 | 
 | ||||||
| # APM support.
 | # No APM support.
 | ||||||
| if BSD_KQUEUE_APM |  | ||||||
| APM_SOURCES = $(srcdir)/bsd_kqueue_apm.c |  | ||||||
| else  |  | ||||||
| if BSD_APM |  | ||||||
| APM_SOURCES = $(srcdir)/bsd_apm.c |  | ||||||
| else |  | ||||||
| APM_SOURCES = $(srcdir)/../shared/pm_noop.c | APM_SOURCES = $(srcdir)/../shared/pm_noop.c | ||||||
| endif |  | ||||||
| endif |  | ||||||
| 
 | 
 | ||||||
| if FREEBSD_KLDLOAD | if FREEBSD_KLDLOAD | ||||||
| KMOD_SOURCES = bsd_kmod.c | KMOD_SOURCES = bsd_kmod.c | ||||||
|  |  | ||||||
|  | @ -1,137 +0,0 @@ | ||||||
| #ifdef HAVE_XORG_CONFIG_H |  | ||||||
| #include <xorg-config.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <X11/X.h> |  | ||||||
| #include "os.h" |  | ||||||
| #include "xf86.h" |  | ||||||
| #include "xf86Priv.h" |  | ||||||
| #define XF86_OS_PRIVS |  | ||||||
| #include "xf86_OSproc.h" |  | ||||||
| #include "xf86_OSlib.h" |  | ||||||
| 
 |  | ||||||
| #include <machine/apmvar.h> |  | ||||||
| 
 |  | ||||||
| #define APM_DEVICE "/dev/apm" |  | ||||||
| 
 |  | ||||||
| static void *APMihPtr = NULL; |  | ||||||
| static void bsdCloseAPM(void); |  | ||||||
| 
 |  | ||||||
| static struct { |  | ||||||
|     u_int apmBsd; |  | ||||||
|     pmEvent xf86; |  | ||||||
| } bsdToXF86Array[] = { |  | ||||||
|     {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, |  | ||||||
|     {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, |  | ||||||
|     {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, |  | ||||||
|     {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, |  | ||||||
|     {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, |  | ||||||
|     {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, |  | ||||||
|     {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, |  | ||||||
|     {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, |  | ||||||
|     {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, |  | ||||||
|     {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, |  | ||||||
|     {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, |  | ||||||
| #ifdef APM_CAPABILITY_CHANGE |  | ||||||
|     {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, |  | ||||||
| #endif |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| static pmEvent |  | ||||||
| bsdToXF86(int type) |  | ||||||
| { |  | ||||||
|     int i; |  | ||||||
| 
 |  | ||||||
|     for (i = 0; i < ARRAY_SIZE(bsdToXF86Array); i++) { |  | ||||||
|         if (type == bsdToXF86Array[i].apmBsd) { |  | ||||||
|             return bsdToXF86Array[i].xf86; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     return XF86_APM_UNKNOWN; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /*
 |  | ||||||
|  * APM events can be requested direclty from /dev/apm |  | ||||||
|  */ |  | ||||||
| static int |  | ||||||
| bsdPMGetEventFromOS(int fd, pmEvent * events, int num) |  | ||||||
| { |  | ||||||
|     struct apm_event_info bsdEvent; |  | ||||||
|     int i; |  | ||||||
| 
 |  | ||||||
|     for (i = 0; i < num; i++) { |  | ||||||
| 
 |  | ||||||
|         if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) { |  | ||||||
|             if (errno != EAGAIN) { |  | ||||||
|                 xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT" |  | ||||||
|                         " %s\n", strerror(errno)); |  | ||||||
|             } |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|         events[i] = bsdToXF86(bsdEvent.type); |  | ||||||
|     } |  | ||||||
|     return i; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /*
 |  | ||||||
|  * XXX This won't work on /dev/apm ! |  | ||||||
|  *     We should either use /dev/apm_ctl (and kill apmd(8)) |  | ||||||
|  *     or talk to apmd (but its protocol is not publically available)... |  | ||||||
|  */ |  | ||||||
| static pmWait |  | ||||||
| bsdPMConfirmEventToOs(int fd, pmEvent event) |  | ||||||
| { |  | ||||||
|     switch (event) { |  | ||||||
|     case XF86_APM_SYS_STANDBY: |  | ||||||
|     case XF86_APM_USER_STANDBY: |  | ||||||
|         if (ioctl(fd, APM_IOC_STANDBY, NULL) == 0) |  | ||||||
|             return PM_WAIT;     /* should we stop the Xserver in standby, too? */ |  | ||||||
|         else |  | ||||||
|             return PM_NONE; |  | ||||||
|     case XF86_APM_SYS_SUSPEND: |  | ||||||
|     case XF86_APM_CRITICAL_SUSPEND: |  | ||||||
|     case XF86_APM_USER_SUSPEND: |  | ||||||
|         if (ioctl(fd, APM_IOC_SUSPEND, NULL) == 0) |  | ||||||
|             return PM_WAIT; |  | ||||||
|         else |  | ||||||
|             return PM_NONE; |  | ||||||
|     case XF86_APM_STANDBY_RESUME: |  | ||||||
|     case XF86_APM_NORMAL_RESUME: |  | ||||||
|     case XF86_APM_CRITICAL_RESUME: |  | ||||||
|     case XF86_APM_STANDBY_FAILED: |  | ||||||
|     case XF86_APM_SUSPEND_FAILED: |  | ||||||
|         return PM_CONTINUE; |  | ||||||
|     default: |  | ||||||
|         return PM_NONE; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| PMClose |  | ||||||
| xf86OSPMOpen(void) |  | ||||||
| { |  | ||||||
|     int fd; |  | ||||||
| 
 |  | ||||||
|     if (APMihPtr || !xf86Info.pmFlag) { |  | ||||||
|         return NULL; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { |  | ||||||
|         return NULL; |  | ||||||
|     } |  | ||||||
|     xf86PMGetEventFromOs = bsdPMGetEventFromOS; |  | ||||||
|     xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; |  | ||||||
|     APMihPtr = xf86AddGeneralHandler(fd, xf86HandlePMEvents, NULL); |  | ||||||
|     return bsdCloseAPM; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void |  | ||||||
| bsdCloseAPM(void) |  | ||||||
| { |  | ||||||
|     int fd; |  | ||||||
| 
 |  | ||||||
|     if (APMihPtr) { |  | ||||||
|         fd = xf86RemoveGeneralHandler(APMihPtr); |  | ||||||
|         close(fd); |  | ||||||
|         APMihPtr = NULL; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  | @ -1,199 +0,0 @@ | ||||||
| /*
 |  | ||||||
|  * Copyright (C) 2001 The XFree86 Project, Inc.  All Rights Reserved. |  | ||||||
|  * |  | ||||||
|  * Permission is hereby granted, free of charge, to any person obtaining |  | ||||||
|  * a copy of this software and associated documentation files (the |  | ||||||
|  * "Software"), to deal in the Software without restriction, including |  | ||||||
|  * without limitation the rights to use, copy, modify, merge, publish, |  | ||||||
|  * distribute, sublicense, and/or sell copies of the Software, and to |  | ||||||
|  * permit persons to whom the Software is furnished to do so, subject to |  | ||||||
|  * the following conditions: |  | ||||||
|  * |  | ||||||
|  * The above copyright notice and this permission notice shall be |  | ||||||
|  * included in all copies or substantial portions of the Software. |  | ||||||
|  * |  | ||||||
|  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |  | ||||||
|  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |  | ||||||
|  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |  | ||||||
|  * IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES |  | ||||||
|  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |  | ||||||
|  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |  | ||||||
|  * THE USE OR OTHER DEALINGS IN THE SOFTWARE. |  | ||||||
|  * |  | ||||||
|  * Except as contained in this notice, the name of the XFree86 Project |  | ||||||
|  * shall not be used in advertising or otherwise to promote the sale, use |  | ||||||
|  * or other dealings in this Software without prior written authorization |  | ||||||
|  * from the XFree86 Project. |  | ||||||
|  */ |  | ||||||
| 
 |  | ||||||
| #ifdef HAVE_XORG_CONFIG_H |  | ||||||
| #include <xorg-config.h> |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| #include <X11/X.h> |  | ||||||
| #include "os.h" |  | ||||||
| #include "xf86.h" |  | ||||||
| #include "xf86Priv.h" |  | ||||||
| #define XF86_OS_PRIVS |  | ||||||
| #include "xf86_OSproc.h" |  | ||||||
| #include "xf86_OSlib.h" |  | ||||||
| 
 |  | ||||||
| #include <sys/event.h> |  | ||||||
| #include <machine/apmvar.h> |  | ||||||
| 
 |  | ||||||
| #define _PATH_APM_SOCKET	"/var/run/apmdev" |  | ||||||
| #define _PATH_APM_DEV		"/dev/apm" |  | ||||||
| #define _PATH_APM_CTLDEV	"/dev/apmctl" |  | ||||||
| 
 |  | ||||||
| static void *APMihPtr = NULL; |  | ||||||
| static int devFd = -1; |  | ||||||
| static int ctlFd = -1; |  | ||||||
| static void bsdCloseAPM(void); |  | ||||||
| 
 |  | ||||||
| static struct { |  | ||||||
|     u_int apmBsd; |  | ||||||
|     pmEvent xf86; |  | ||||||
| } bsdToXF86Array[] = { |  | ||||||
|     {APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, |  | ||||||
|     {APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, |  | ||||||
|     {APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, |  | ||||||
|     {APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, |  | ||||||
|     {APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, |  | ||||||
|     {APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, |  | ||||||
|     {APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, |  | ||||||
|     {APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, |  | ||||||
|     {APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, |  | ||||||
|     {APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, |  | ||||||
|     {APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME}, |  | ||||||
| #ifdef APM_CAPABILITY_CHANGE |  | ||||||
|     {APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED}, |  | ||||||
| #endif |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| static pmEvent |  | ||||||
| bsdToXF86(int type) |  | ||||||
| { |  | ||||||
|     int i; |  | ||||||
| 
 |  | ||||||
|     for (i = 0; i < ARRAY_SIZE(bsdToXF86Array); i++) { |  | ||||||
|         if (type == bsdToXF86Array[i].apmBsd) { |  | ||||||
|             return bsdToXF86Array[i].xf86; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     return XF86_APM_UNKNOWN; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /*
 |  | ||||||
|  * APM events can be requested direclty from /dev/apm |  | ||||||
|  */ |  | ||||||
| static int |  | ||||||
| bsdPMGetEventFromOS(int kq, pmEvent * events, int num) |  | ||||||
| { |  | ||||||
|     struct kevent ev; |  | ||||||
|     int i, result; |  | ||||||
|     struct timespec ts = { 0, 0 }; |  | ||||||
| 
 |  | ||||||
|     for (i = 0; i < num; i++) { |  | ||||||
|         result = kevent(kq, NULL, 0, &ev, 1, &ts); |  | ||||||
|         if (result == 0 || APM_EVENT_TYPE(ev.data) == APM_NOEVENT) { |  | ||||||
|             /* no event */ |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|         else if (result < 0) { |  | ||||||
|             xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns" |  | ||||||
|                     " %s\n", strerror(errno)); |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|         events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data)); |  | ||||||
|     } |  | ||||||
|     return i; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /*
 |  | ||||||
|  * If apmd(8) is running, he will get the events and handle them, |  | ||||||
|  * so, we've nothing to do here. |  | ||||||
|  * Otherwise, opening /dev/apmctl will succeed and we have to send the |  | ||||||
|  * confirmations to /dev/apmctl. |  | ||||||
|  */ |  | ||||||
| static pmWait |  | ||||||
| bsdPMConfirmEventToOs(int dummyfd, pmEvent event) |  | ||||||
| { |  | ||||||
|     if (ctlFd < 0) { |  | ||||||
|         if ((ctlFd = open(_PATH_APM_CTLDEV, O_RDWR)) < 0) { |  | ||||||
|             return PM_NONE; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     /* apmctl open succeedeed */ |  | ||||||
|     switch (event) { |  | ||||||
|     case XF86_APM_SYS_STANDBY: |  | ||||||
|     case XF86_APM_USER_STANDBY: |  | ||||||
|         if (ioctl(ctlFd, APM_IOC_STANDBY, NULL) == 0) |  | ||||||
|             return PM_WAIT;     /* should we stop the Xserver in standby, too? */ |  | ||||||
|         else |  | ||||||
|             return PM_NONE; |  | ||||||
| 
 |  | ||||||
|     case XF86_APM_SYS_SUSPEND: |  | ||||||
|     case XF86_APM_CRITICAL_SUSPEND: |  | ||||||
|     case XF86_APM_USER_SUSPEND: |  | ||||||
|         if (ioctl(ctlFd, APM_IOC_SUSPEND, NULL) == 0) |  | ||||||
|             return PM_WAIT; |  | ||||||
|         else |  | ||||||
|             return PM_NONE; |  | ||||||
|         break; |  | ||||||
|     case XF86_APM_STANDBY_RESUME: |  | ||||||
|     case XF86_APM_NORMAL_RESUME: |  | ||||||
|     case XF86_APM_CRITICAL_RESUME: |  | ||||||
|     case XF86_APM_STANDBY_FAILED: |  | ||||||
|     case XF86_APM_SUSPEND_FAILED: |  | ||||||
|         return PM_CONTINUE; |  | ||||||
|         break; |  | ||||||
|     default: |  | ||||||
|         return PM_NONE; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| PMClose |  | ||||||
| xf86OSPMOpen(void) |  | ||||||
| { |  | ||||||
|     int kq; |  | ||||||
|     struct kevent ev; |  | ||||||
| 
 |  | ||||||
|     if (APMihPtr || !xf86Info.pmFlag) { |  | ||||||
|         return NULL; |  | ||||||
|     } |  | ||||||
|     if ((devFd = open(_PATH_APM_DEV, O_RDONLY)) == -1) { |  | ||||||
|         return NULL; |  | ||||||
|     } |  | ||||||
|     if ((kq = kqueue()) <= 0) { |  | ||||||
|         close(devFd); |  | ||||||
|         return NULL; |  | ||||||
|     } |  | ||||||
|     EV_SET(&ev, devFd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, NULL); |  | ||||||
|     if (kevent(kq, &ev, 1, NULL, 0, NULL) < 0) { |  | ||||||
|         close(devFd); |  | ||||||
|         return NULL; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     xf86PMGetEventFromOs = bsdPMGetEventFromOS; |  | ||||||
|     xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; |  | ||||||
|     APMihPtr = xf86AddGeneralHandler(kq, xf86HandlePMEvents, NULL); |  | ||||||
|     return bsdCloseAPM; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void |  | ||||||
| bsdCloseAPM(void) |  | ||||||
| { |  | ||||||
|     int kq; |  | ||||||
| 
 |  | ||||||
|     if (APMihPtr) { |  | ||||||
|         kq = xf86RemoveGeneralHandler(APMihPtr); |  | ||||||
|         close(devFd); |  | ||||||
|         devFd = -1; |  | ||||||
|         close(kq); |  | ||||||
|         if (ctlFd >= 0) { |  | ||||||
|             close(ctlFd); |  | ||||||
|             ctlFd = -1; |  | ||||||
|         } |  | ||||||
|         APMihPtr = NULL; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  | @ -96,18 +96,9 @@ elif host_machine.system().endswith('bsd') | ||||||
|         'bsd/bsd_VTsw.c', |         'bsd/bsd_VTsw.c', | ||||||
|         'bsd/bsd_bell.c', |         'bsd/bsd_bell.c', | ||||||
|         'bsd/bsd_init.c', |         'bsd/bsd_init.c', | ||||||
|  | 	'shared/pm_noop.c' | ||||||
|     ] |     ] | ||||||
| 
 | 
 | ||||||
|     if cc.has_header('machine/apmvar.h') |  | ||||||
|         if cc.has_header('sys/event.h') |  | ||||||
|             srcs_xorg_os_support += 'bsd/bsd_kqueue_apm.c' |  | ||||||
|         else |  | ||||||
|             srcs_xorg_os_support += 'bsd/bsd_apm.c' |  | ||||||
|         endif |  | ||||||
|     else |  | ||||||
|         srcs_xorg_os_support += 'shared/pm_noop.c' |  | ||||||
|     endif |  | ||||||
| 
 |  | ||||||
|     if host_machine.cpu_family() == 'x86_64' |     if host_machine.cpu_family() == 'x86_64' | ||||||
|         srcs_xorg_os_support += 'bsd/i386_video.c' |         srcs_xorg_os_support += 'bsd/i386_video.c' | ||||||
|         if host_machine.system() == 'netbsd' |         if host_machine.system() == 'netbsd' | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue