summaryrefslogtreecommitdiff
path: root/hw/xfree86/common/xf86PM.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-03-21 12:55:09 -0700
committerKeith Packard <keithp@keithp.com>2012-03-21 13:54:42 -0700
commit9838b7032ea9792bec21af424c53c07078636d21 (patch)
treeb72d0827dac50f0f3b8eab29b3b7639546d735d7 /hw/xfree86/common/xf86PM.c
parent75199129c603fc8567185ac31866c9518193cb78 (diff)
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh' from util/modular. Compared to the patch that Daniel posted in January, I've added a few indent flags: -bap -psl -T PrivatePtr -T pmWait -T _XFUNCPROTOBEGIN -T _XFUNCPROTOEND -T _X_EXPORT The typedefs were needed to make the output of sdksyms.sh match the previous output, otherwise, the code is formatted badly enough that sdksyms.sh generates incorrect output. The generated code was compared with the previous version and found to be essentially identical -- "assert" line numbers and BUILD_TIME were the only differences found. The comparison was done with this script: dir1=$1 dir2=$2 for dir in $dir1 $dir2; do (cd $dir && find . -name '*.o' | while read file; do dir=`dirname $file` base=`basename $file .o` dump=$dir/$base.dump objdump -d $file > $dump done) done find $dir1 -name '*.dump' | while read dump; do otherdump=`echo $dump | sed "s;$dir1;$dir2;"` diff -u $dump $otherdump done Signed-off-by: Keith Packard <keithp@keithp.com> Acked-by: Daniel Stone <daniel@fooishbar.org> Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'hw/xfree86/common/xf86PM.c')
-rw-r--r--hw/xfree86/common/xf86PM.c223
1 files changed, 127 insertions, 96 deletions
diff --git a/hw/xfree86/common/xf86PM.c b/hw/xfree86/common/xf86PM.c
index 47e0297d6..f69fffa0e 100644
--- a/hw/xfree86/common/xf86PM.c
+++ b/hw/xfree86/common/xf86PM.c
@@ -35,60 +35,90 @@
#include "xf86Xinput.h"
#include "xf86_OSproc.h"
-int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num) = NULL;
-pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event) = NULL;
+int (*xf86PMGetEventFromOs) (int fd, pmEvent * events, int num) = NULL;
+pmWait (*xf86PMConfirmEventToOs) (int fd, pmEvent event) = NULL;
static Bool suspended = FALSE;
static int
eventName(pmEvent event, const char **str)
{
- switch(event) {
- case XF86_APM_SYS_STANDBY: *str="System Standby Request"; return 0;
- case XF86_APM_SYS_SUSPEND: *str="System Suspend Request"; return 0;
- case XF86_APM_CRITICAL_SUSPEND: *str="Critical Suspend"; return 0;
- case XF86_APM_USER_STANDBY: *str="User System Standby Request"; return 0;
- case XF86_APM_USER_SUSPEND: *str="User System Suspend Request"; return 0;
- case XF86_APM_STANDBY_RESUME: *str="System Standby Resume"; return 0;
- case XF86_APM_NORMAL_RESUME: *str="Normal Resume System"; return 0;
- case XF86_APM_CRITICAL_RESUME: *str="Critical Resume System"; return 0;
- case XF86_APM_LOW_BATTERY: *str="Battery Low"; return 3;
- case XF86_APM_POWER_STATUS_CHANGE: *str="Power Status Change";return 3;
- case XF86_APM_UPDATE_TIME: *str="Update Time";return 3;
- case XF86_APM_CAPABILITY_CHANGED: *str="Capability Changed"; return 3;
- case XF86_APM_STANDBY_FAILED: *str="Standby Request Failed"; return 0;
- case XF86_APM_SUSPEND_FAILED: *str="Suspend Request Failed"; return 0;
- default: *str="Unknown Event"; return 0;
+ switch (event) {
+ case XF86_APM_SYS_STANDBY:
+ *str = "System Standby Request";
+ return 0;
+ case XF86_APM_SYS_SUSPEND:
+ *str = "System Suspend Request";
+ return 0;
+ case XF86_APM_CRITICAL_SUSPEND:
+ *str = "Critical Suspend";
+ return 0;
+ case XF86_APM_USER_STANDBY:
+ *str = "User System Standby Request";
+ return 0;
+ case XF86_APM_USER_SUSPEND:
+ *str = "User System Suspend Request";
+ return 0;
+ case XF86_APM_STANDBY_RESUME:
+ *str = "System Standby Resume";
+ return 0;
+ case XF86_APM_NORMAL_RESUME:
+ *str = "Normal Resume System";
+ return 0;
+ case XF86_APM_CRITICAL_RESUME:
+ *str = "Critical Resume System";
+ return 0;
+ case XF86_APM_LOW_BATTERY:
+ *str = "Battery Low";
+ return 3;
+ case XF86_APM_POWER_STATUS_CHANGE:
+ *str = "Power Status Change";
+ return 3;
+ case XF86_APM_UPDATE_TIME:
+ *str = "Update Time";
+ return 3;
+ case XF86_APM_CAPABILITY_CHANGED:
+ *str = "Capability Changed";
+ return 3;
+ case XF86_APM_STANDBY_FAILED:
+ *str = "Standby Request Failed";
+ return 0;
+ case XF86_APM_SUSPEND_FAILED:
+ *str = "Suspend Request Failed";
+ return 0;
+ default:
+ *str = "Unknown Event";
+ return 0;
}
}
static int sigio_blocked_for_suspend;
static void
-suspend (pmEvent event, Bool undo)
+suspend(pmEvent event, Bool undo)
{
int i;
InputInfoPtr pInfo;
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
}
pInfo = xf86InputDevs;
while (pInfo) {
- DisableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
+ DisableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
}
sigio_blocked_for_suspend = xf86BlockSIGIO();
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->PMEvent)
- xf86Screens[i]->PMEvent(i,event,undo);
- else {
- xf86Screens[i]->LeaveVT(i, 0);
- xf86Screens[i]->vtSema = FALSE;
- }
+ if (xf86Screens[i]->PMEvent)
+ xf86Screens[i]->PMEvent(i, event, undo);
+ else {
+ xf86Screens[i]->LeaveVT(i, 0);
+ xf86Screens[i]->vtSema = FALSE;
+ }
}
- xf86AccessLeave();
+ xf86AccessLeave();
}
@@ -100,23 +130,23 @@ resume(pmEvent event, Bool undo)
xf86AccessEnter();
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->PMEvent)
- xf86Screens[i]->PMEvent(i,event,undo);
- else {
- xf86Screens[i]->vtSema = TRUE;
- xf86Screens[i]->EnterVT(i, 0);
- }
+ if (xf86Screens[i]->PMEvent)
+ xf86Screens[i]->PMEvent(i, event, undo);
+ else {
+ xf86Screens[i]->vtSema = TRUE;
+ xf86Screens[i]->EnterVT(i, 0);
+ }
}
xf86UnblockSIGIO(sigio_blocked_for_suspend);
for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
+ if (xf86Screens[i]->EnableDisableFBAccess)
+ (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
}
dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
pInfo = xf86InputDevs;
while (pInfo) {
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
+ EnableDevice(pInfo->dev, TRUE);
+ pInfo = pInfo->next;
}
}
@@ -124,43 +154,44 @@ static void
DoApmEvent(pmEvent event, Bool undo)
{
int i, was_blocked;
-
- switch(event) {
+
+ switch (event) {
#if 0
case XF86_APM_SYS_STANDBY:
case XF86_APM_USER_STANDBY:
#endif
case XF86_APM_SYS_SUSPEND:
- case XF86_APM_CRITICAL_SUSPEND: /*do we want to delay a critical suspend?*/
+ case XF86_APM_CRITICAL_SUSPEND: /*do we want to delay a critical suspend? */
case XF86_APM_USER_SUSPEND:
- /* should we do this ? */
- if (!undo && !suspended) {
- suspend(event,undo);
- suspended = TRUE;
- } else if (undo && suspended) {
- resume(event,undo);
- suspended = FALSE;
- }
- break;
+ /* should we do this ? */
+ if (!undo && !suspended) {
+ suspend(event, undo);
+ suspended = TRUE;
+ }
+ else if (undo && suspended) {
+ resume(event, undo);
+ suspended = FALSE;
+ }
+ break;
#if 0
case XF86_APM_STANDBY_RESUME:
#endif
case XF86_APM_NORMAL_RESUME:
case XF86_APM_CRITICAL_RESUME:
- if (suspended) {
- resume(event,undo);
- suspended = FALSE;
- }
- break;
+ if (suspended) {
+ resume(event, undo);
+ suspended = FALSE;
+ }
+ break;
default:
- was_blocked = xf86BlockSIGIO();
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->PMEvent) {
- xf86Screens[i]->PMEvent(i,event,undo);
- }
- }
- xf86UnblockSIGIO(was_blocked);
- break;
+ was_blocked = xf86BlockSIGIO();
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (xf86Screens[i]->PMEvent) {
+ xf86Screens[i]->PMEvent(i, event, undo);
+ }
+ }
+ xf86UnblockSIGIO(was_blocked);
+ break;
}
}
@@ -170,39 +201,39 @@ void
xf86HandlePMEvents(int fd, pointer data)
{
pmEvent events[MAX_NO_EVENTS];
- int i,n;
+ int i, n;
Bool wait = FALSE;
if (!xf86PMGetEventFromOs)
- return;
-
- if ((n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS))) {
- do {
- for (i = 0; i < n; i++) {
- const char *str = NULL;
- int verb = eventName(events[i],&str);
-
- xf86MsgVerb(X_INFO,verb,"PM Event received: %s\n",str);
- DoApmEvent(events[i],FALSE);
- switch (xf86PMConfirmEventToOs(fd,events[i])) {
- case PM_WAIT:
- wait = TRUE;
- break;
- case PM_CONTINUE:
- wait = FALSE;
- break;
- case PM_FAILED:
- DoApmEvent(events[i],TRUE);
- wait = FALSE;
- break;
- default:
- break;
- }
- }
- if (wait)
- n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS);
- else
- break;
- } while (1);
+ return;
+
+ if ((n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS))) {
+ do {
+ for (i = 0; i < n; i++) {
+ const char *str = NULL;
+ int verb = eventName(events[i], &str);
+
+ xf86MsgVerb(X_INFO, verb, "PM Event received: %s\n", str);
+ DoApmEvent(events[i], FALSE);
+ switch (xf86PMConfirmEventToOs(fd, events[i])) {
+ case PM_WAIT:
+ wait = TRUE;
+ break;
+ case PM_CONTINUE:
+ wait = FALSE;
+ break;
+ case PM_FAILED:
+ DoApmEvent(events[i], TRUE);
+ wait = FALSE;
+ break;
+ default:
+ break;
+ }
+ }
+ if (wait)
+ n = xf86PMGetEventFromOs(fd, events, MAX_NO_EVENTS);
+ else
+ break;
+ } while (1);
}
}