Lines 13-19
Link Here
|
13 |
#include <errno.h> |
13 |
#include <errno.h> |
14 |
|
14 |
|
15 |
#define ACPI_SOCKET "/var/run/acpid.socket" |
15 |
#define ACPI_SOCKET "/var/run/acpid.socket" |
16 |
#define ACPI_EVENTS "/proc/acpi/event" |
|
|
17 |
|
16 |
|
18 |
#define ACPI_VIDEO_NOTIFY_SWITCH 0x80 |
17 |
#define ACPI_VIDEO_NOTIFY_SWITCH 0x80 |
19 |
#define ACPI_VIDEO_NOTIFY_PROBE 0x81 |
18 |
#define ACPI_VIDEO_NOTIFY_PROBE 0x81 |
Lines 46-51
Link Here
|
46 |
|
45 |
|
47 |
n = read( fd, ev, LINE_LENGTH ); |
46 |
n = read( fd, ev, LINE_LENGTH ); |
48 |
|
47 |
|
|
|
48 |
if (n <= 0) { |
49 |
lnxCloseACPI(); |
50 |
sleep (3); |
51 |
lnxACPIOpen(); |
52 |
return 0; |
53 |
} |
54 |
|
49 |
/* Check that we have a video event */ |
55 |
/* Check that we have a video event */ |
50 |
if (strstr(ev, "video") == ev) { |
56 |
if (strstr(ev, "video") == ev) { |
51 |
char *video = NULL; |
57 |
char *video = NULL; |
Lines 129-152
Link Here
|
129 |
addr.sun_family = AF_UNIX; |
135 |
addr.sun_family = AF_UNIX; |
130 |
strcpy(addr.sun_path, ACPI_SOCKET); |
136 |
strcpy(addr.sun_path, ACPI_SOCKET); |
131 |
if ((r = connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1) { |
137 |
if ((r = connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1) { |
132 |
shutdown(fd, 2); |
138 |
close(fd); |
133 |
fd = -1; |
139 |
xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_SOCKET, |
134 |
} |
|
|
135 |
} |
136 |
|
137 |
/* acpid's socket isn't available, so try going direct */ |
138 |
if (fd == -1) { |
139 |
if ((fd = open(ACPI_EVENTS, O_RDONLY)) < 0) { |
140 |
xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_EVENTS, |
141 |
strerror(errno)); |
140 |
strerror(errno)); |
142 |
return NULL; |
141 |
return NULL; |
143 |
} |
142 |
} |
144 |
} |
143 |
} |
145 |
|
144 |
|
146 |
xf86PMGetEventFromOs = lnxACPIGetEventFromOs; |
145 |
xf86PMGetEventFromOs = lnxACPIGetEventFromOs; |
147 |
xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs; |
146 |
xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs; |
148 |
ACPIihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL); |
147 |
ACPIihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL); |
149 |
xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", (r != -1) ? ACPI_SOCKET : ACPI_EVENTS); |
148 |
xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET); |
150 |
|
149 |
|
151 |
return lnxCloseACPI; |
150 |
return lnxCloseACPI; |
152 |
} |
151 |
} |
Lines 161-167
Link Here
|
161 |
#endif |
160 |
#endif |
162 |
if (ACPIihPtr) { |
161 |
if (ACPIihPtr) { |
163 |
fd = xf86RemoveInputHandler(ACPIihPtr); |
162 |
fd = xf86RemoveInputHandler(ACPIihPtr); |
164 |
shutdown(fd, 2); |
163 |
close(fd); |
165 |
ACPIihPtr = NULL; |
164 |
ACPIihPtr = NULL; |
166 |
} |
165 |
} |
167 |
} |
166 |
} |