diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h index 9e3826cbc..03ea50e46 100644 --- a/hw/xfree86/common/xf86.h +++ b/hw/xfree86/common/xf86.h @@ -137,6 +137,8 @@ void xf86EnterServerState(xf86State state); ScrnInfoPtr xf86FindScreenForEntity(int entityIndex); Bool xf86NoSharedResources(int screenIndex, resType res); resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2); +void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg); +Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func); int xf86GetLastScrnFlag(int entityIndex); void xf86SetLastScrnFlag(int entityIndex, int scrnIndex); diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 039b2959a..3030a04ea 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -95,6 +95,10 @@ _X_EXPORT resRange res8514Shared[] = {_8514_SHARED, _END}; static Bool needRAC = FALSE; static Bool doFramebufferMode = FALSE; +/* state change notification callback list */ +static StateChangeNotificationPtr StateChangeNotificationList; +static void notifyStateChange(xf86NotifyState state); + #undef MIN #define MIN(x,y) ((xfunc = func; + ptr->arg = arg; + ptr->next = StateChangeNotificationList; + StateChangeNotificationList = ptr; +} + +_X_EXPORT Bool +xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func) +{ + StateChangeNotificationPtr *ptr = &StateChangeNotificationList; + StateChangeNotificationPtr tmp; + + while (*ptr) { + if ((*ptr)->func == func) { + tmp = (*ptr); + (*ptr) = (*ptr)->next; + xfree(tmp); + return TRUE; + } + ptr = &((*ptr)->next); + } + return FALSE; +} + +static void +notifyStateChange(xf86NotifyState state) +{ + StateChangeNotificationPtr ptr = StateChangeNotificationList; + while (ptr) { + ptr->func(state,ptr->arg); + ptr = ptr->next; + } +} + /* Multihead accel sharing accessor functions and entity Private handling */ _X_EXPORT int diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h index d28190a23..c5f5dcce7 100644 --- a/hw/xfree86/common/xf86Bus.h +++ b/hw/xfree86/common/xf86Bus.h @@ -119,6 +119,14 @@ typedef struct x_BusAccRec { } busdep; } BusAccRec, *BusAccPtr; +/* state change notification callback */ +typedef struct _stateChange { + xf86StateChangeNotificationCallbackFunc func; + pointer arg; + struct _stateChange *next; +} StateChangeNotificationRec, *StateChangeNotificationPtr; + + extern EntityPtr *xf86Entities; extern int xf86NumEntities; extern xf86AccessRec AccessNULL; diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index b57b7bd22..8c211234b 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -778,6 +778,18 @@ typedef enum { OPERATING } xf86State; +typedef enum { + NOTIFY_SETUP_TRANSITION, + NOTIFY_SETUP, + NOTIFY_OPERATING, + NOTIFY_OPERATING_TRANSITION, + NOTIFY_ENABLE, + NOTIFY_ENTER, + NOTIFY_LEAVE +} xf86NotifyState; + +typedef void (*xf86StateChangeNotificationCallbackFunc)(xf86NotifyState state,pointer); + /* DGA */ typedef struct { diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c index 4fc83f219..40b9ba4fb 100644 --- a/hw/xfree86/loader/xf86sym.c +++ b/hw/xfree86/loader/xf86sym.c @@ -321,6 +321,8 @@ _X_HIDDEN void *xfree86LookupTab[] = { SYMFUNC(xf86IsEntityPrimary) SYMFUNC(xf86SetOperatingState) SYMFUNC(xf86FindScreenForEntity) + SYMFUNC(xf86RegisterStateChangeNotificationCallback) + SYMFUNC(xf86DeregisterStateChangeNotificationCallback) /* Shared Accel Accessor Functions */ SYMFUNC(xf86GetLastScrnFlag) SYMFUNC(xf86SetLastScrnFlag)