diff options
author | Dave Airlie <airlied@redhat.com> | 2012-06-13 14:17:06 +0100 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-07-06 22:16:08 +0100 |
commit | 9b5cf2ed76b00937af12304e0e8dbd60df62067e (patch) | |
tree | b73c7f0b28c507ade786f68a784a60dcb41740b9 | |
parent | 66d92afeaeed9f4a19267d95a1f81b9bf27162a5 (diff) |
xfree86: add framework for provider support in ddx. (v4)
This adds the framework for DDX provider support.
v2: as per keithp's suggestion remove the xf86 provider object
and just store it in the toplevel object.
v3: update for new protocol
v4: drop devPrivate, free name
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | hw/xfree86/common/xf86str.h | 1 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86Crtc.c | 18 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86Crtc.h | 34 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86RandR12.c | 48 |
4 files changed, 101 insertions, 0 deletions
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h index 6bd6a6218..059026243 100644 --- a/hw/xfree86/common/xf86str.h +++ b/hw/xfree86/common/xf86str.h @@ -814,6 +814,7 @@ typedef struct _ScrnInfoRec { funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; Bool is_gpu; + uint32_t capabilities; } ScrnInfoRec; typedef struct { diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 2c8878fa7..a2cd85652 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -738,6 +738,7 @@ xf86CrtcCloseScreen(ScreenPtr screen) } xf86RandR12CloseScreen(screen); + free(config->name); return screen->CloseScreen(screen); } @@ -3202,3 +3203,20 @@ xf86_crtc_supports_gamma(ScrnInfoPtr pScrn) return FALSE; } + +void +xf86ProviderSetup(ScrnInfoPtr scrn, + const xf86ProviderFuncsRec *funcs, const char *name) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + + assert(!xf86_config->name); + assert(name); + + xf86_config->name = strdup(name); + xf86_config->provider_funcs = funcs; +#ifdef RANDR_12_INTERFACE + xf86_config->randr_provider = NULL; +#endif +} + diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h index a6a3c2e95..58d8cecc5 100644 --- a/hw/xfree86/modes/xf86Crtc.h +++ b/hw/xfree86/modes/xf86Crtc.h @@ -607,6 +607,29 @@ struct _xf86Output { INT16 initialBorder[4]; }; +typedef struct _xf86ProviderFuncs { + /** + * Called to allow the provider a chance to create properties after the + * RandR objects have been created. + */ + void + (*create_resources) (ScrnInfoPtr scrn); + + /** + * Callback when an provider's property has changed. + */ + Bool + (*set_property) (ScrnInfoPtr scrn, + Atom property, RRPropertyValuePtr value); + + /** + * Callback to get an updated property value + */ + Bool + (*get_property) (ScrnInfoPtr provider, Atom property); + +} xf86ProviderFuncsRec, *xf86ProviderFuncsPtr; + typedef struct _xf86CrtcConfigFuncs { /** * Requests that the driver resize the screen. @@ -681,6 +704,13 @@ typedef struct _xf86CrtcConfig { /* callback when crtc configuration changes */ xf86_crtc_notify_proc_ptr xf86_crtc_notify; + char *name; + const xf86ProviderFuncsRec *provider_funcs; +#ifdef RANDR_12_INTERFACE + RRProviderPtr randr_provider; +#else + void *randr_provider; +#endif } xf86CrtcConfigRec, *xf86CrtcConfigPtr; extern _X_EXPORT int xf86CrtcConfigPrivateIndex; @@ -975,4 +1005,8 @@ extern _X_EXPORT void extern _X_EXPORT Bool xf86_crtc_supports_gamma(ScrnInfoPtr pScrn); +extern _X_EXPORT void +xf86ProviderSetup(ScrnInfoPtr scrn, + const xf86ProviderFuncsRec * funcs, const char *name); + #endif /* _XF86CRTC_H_ */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 59b6f8217..41c0b1134 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1552,6 +1552,14 @@ xf86RandR12CreateObjects12(ScreenPtr pScreen) output->funcs->create_resources(output); RRPostPendingProperties(output->randr_output); } + + if (config->name) { + config->randr_provider = RRProviderCreate(pScreen, config->name, + strlen(config->name)); + + RRProviderSetCapabilities(config->randr_provider, pScrn->capabilities); + } + return TRUE; } @@ -1746,6 +1754,42 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn) } static Bool +xf86RandR14ProviderSetProperty(ScreenPtr pScreen, + RRProviderPtr randr_provider, + Atom property, RRPropertyValuePtr value) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + + /* If we don't have any property handler, then we don't care what the + * user is setting properties to. + */ + if (config->provider_funcs->set_property == NULL) + return TRUE; + + /* + * This function gets called even when vtSema is FALSE, as + * drivers will need to remember the correct value to apply + * when the VT switch occurs + */ + return config->provider_funcs->set_property(pScrn, property, value); +} + +static Bool +xf86RandR14ProviderGetProperty(ScreenPtr pScreen, + RRProviderPtr randr_provider, Atom property) +{ + ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + + if (config->provider_funcs->get_property == NULL) + return TRUE; + + /* Should be safe even w/o vtSema */ + return config->provider_funcs->get_property(pScrn, property); +} + +static Bool xf86RandR12Init12(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); @@ -1767,6 +1811,10 @@ xf86RandR12Init12(ScreenPtr pScreen) #endif rp->rrModeDestroy = xf86RandR12ModeDestroy; rp->rrSetConfig = NULL; + + rp->rrProviderSetProperty = xf86RandR14ProviderSetProperty; + rp->rrProviderGetProperty = xf86RandR14ProviderGetProperty; + pScrn->PointerMoved = xf86RandR12PointerMoved; pScrn->ChangeGamma = xf86RandR12ChangeGamma; |