2009-08-04 21:52:16 +02:00
|
|
|
Index: hw/xfree86/os-support/linux/lnx_acpi.c
|
2010-01-18 14:04:02 +01:00
|
|
|
================================================================================
|
|
|
|
--- hw/xfree86/os-support/linux/lnx_acpi.c
|
2009-08-04 21:52:16 +02:00
|
|
|
+++ hw/xfree86/os-support/linux/lnx_acpi.c
|
2006-12-18 15:48:26 +01:00
|
|
|
@@ -32,8 +32,10 @@
|
|
|
|
#define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
|
|
|
|
#define ACPI_VIDEO_HEAD_END (~0u)
|
|
|
|
|
|
|
|
+static PMClose doLnxACPIOpen(void);
|
|
|
|
static void lnxCloseACPI(void);
|
|
|
|
static pointer ACPIihPtr = NULL;
|
|
|
|
+static OsTimerPtr acpiTimer = NULL;
|
|
|
|
PMClose lnxACPIOpen(void);
|
|
|
|
|
|
|
|
/* in milliseconds */
|
2010-01-18 14:04:02 +01:00
|
|
|
@@ -52,6 +54,22 @@
|
2006-12-18 15:48:26 +01:00
|
|
|
|
|
|
|
#define LINE_LENGTH 80
|
|
|
|
|
|
|
|
+static CARD32
|
|
|
|
+lnxACPICheckTimer(OsTimerPtr timer, CARD32 now, pointer arg)
|
|
|
|
+{
|
|
|
|
+#if DEBUG
|
|
|
|
+ ErrorF("ACPI: trying to reopen\n");
|
|
|
|
+#endif
|
|
|
|
+ if (doLnxACPIOpen()) {
|
|
|
|
+#if DEBUG
|
|
|
|
+ ErrorF("ACPI: successfully reopened\n");
|
|
|
|
+#endif
|
|
|
|
+ acpiTimer = NULL;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ return 5000;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int
|
|
|
|
lnxACPIGetEventFromOs(int fd, pmEvent *events, int num)
|
|
|
|
{
|
2010-01-18 14:04:02 +01:00
|
|
|
@@ -127,15 +145,14 @@
|
2006-12-18 15:48:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-PMClose
|
|
|
|
-lnxACPIOpen(void)
|
|
|
|
+static PMClose
|
|
|
|
+doLnxACPIOpen(void)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
struct sockaddr_un addr;
|
|
|
|
int r = -1;
|
2010-01-18 14:04:02 +01:00
|
|
|
static int warned = 0;
|
2006-12-18 15:48:26 +01:00
|
|
|
|
2010-01-18 14:04:02 +01:00
|
|
|
- DebugF("ACPI: OSPMOpen called\n");
|
2006-12-18 15:48:26 +01:00
|
|
|
if (ACPIihPtr || !xf86Info.pmFlag)
|
|
|
|
return NULL;
|
|
|
|
|
2010-01-18 14:04:02 +01:00
|
|
|
@@ -164,6 +181,27 @@
|
2006-12-18 15:48:26 +01:00
|
|
|
return lnxCloseACPI;
|
|
|
|
}
|
|
|
|
|
|
|
|
+PMClose
|
|
|
|
+lnxACPIPoll(void)
|
|
|
|
+{
|
|
|
|
+ TimerSet(NULL, 0, 5000, lnxACPICheckTimer, NULL);
|
|
|
|
+ return lnxCloseACPI;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+PMClose
|
|
|
|
+lnxACPIOpen(void)
|
|
|
|
+{
|
|
|
|
+ PMClose ret;
|
|
|
|
+#ifdef DEBUG
|
|
|
|
+ ErrorF("ACPI: OSPMOpen called\n");
|
|
|
|
+#endif
|
|
|
|
+ if (!(ret = doLnxACPIOpen()))
|
|
|
|
+ xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_SOCKET,
|
|
|
|
+ strerror(errno));
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static void
|
|
|
|
lnxCloseACPI(void)
|
|
|
|
{
|
2010-01-18 14:04:02 +01:00
|
|
|
@@ -175,5 +213,11 @@
|
2006-12-18 15:48:26 +01:00
|
|
|
shutdown(fd, 2);
|
|
|
|
close(fd);
|
|
|
|
ACPIihPtr = NULL;
|
|
|
|
+ xf86PMGetEventFromOs = NULL;
|
|
|
|
+ xf86PMConfirmEventToOs = NULL;
|
|
|
|
+ if (acpiTimer) {
|
|
|
|
+ TimerCancel(acpiTimer);
|
|
|
|
+ acpiTimer = NULL;
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
2010-01-18 14:04:02 +01:00
|
|
|
--- hw/xfree86/os-support/linux/lnx_apm.c
|
2009-08-04 21:52:16 +02:00
|
|
|
+++ hw/xfree86/os-support/linux/lnx_apm.c
|
2006-12-18 15:48:26 +01:00
|
|
|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
|
|
#ifdef HAVE_ACPI
|
|
|
|
extern PMClose lnxACPIOpen(void);
|
|
|
|
+extern PMClose lnxACPIPoll(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_APM
|
2010-03-20 03:42:15 +01:00
|
|
|
@@ -149,6 +150,14 @@
|
2006-12-18 15:48:26 +01:00
|
|
|
ret = lnxAPMOpen();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef HAVE_ACPI
|
|
|
|
+ /* if we can neither open ACPI nor APM poll for an ACPI service to
|
|
|
|
+ become available */
|
|
|
|
+
|
|
|
|
+ if (!ret && !xf86acpiDisableFlag)
|
|
|
|
+ ret = lnxACPIPoll();
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|