[PATCH] xfree86: add framework for provider support in ddx. (v2)
Dave Airlie
airlied at gmail.com
Wed Jul 4 11:30:07 PDT 2012
From: Dave Airlie <airlied at redhat.com>
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.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
hw/xfree86/common/xf86str.h | 4 +++
hw/xfree86/modes/xf86Crtc.c | 27 ++++++++++++++++++
hw/xfree86/modes/xf86Crtc.h | 37 +++++++++++++++++++++++++
hw/xfree86/modes/xf86RandR12.c | 60 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 128 insertions(+)
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 6bd6a62..56397f1 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -814,6 +814,10 @@ typedef struct _ScrnInfoRec {
funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
Bool is_gpu;
+ uint32_t roles;
+ uint32_t abilities;
+ uint32_t current_role;
+
} ScrnInfoRec;
typedef struct {
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 2c8878f..9efdc6e 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3202,3 +3202,30 @@ 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
+}
+
+void
+xf86SetCurrentRole(ScrnInfoPtr scrn, uint32_t role)
+{
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ scrn->current_role = role;
+
+ if (config->randr_provider)
+ RRProviderSetCurrentRole(config->randr_provider, scrn->current_role);
+}
+
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index a6a3c2e..0a13793 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,11 @@ 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);
+
+extern _X_EXPORT void
+xf86SetCurrentRole(ScrnInfoPtr scrn, uint32_t role);
+
#endif /* _XF86CRTC_H_ */
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 59b6f82..d0926b7 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1552,6 +1552,18 @@ 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), config);
+
+ if (pScrn->is_gpu) {
+ RRProviderSetRolesAbilities(config->randr_provider, pScrn->roles,
+ pScrn->abilities);
+ RRProviderSetCurrentRole(config->randr_provider, pScrn->current_role);
+ }
+ }
+
return TRUE;
}
@@ -1746,6 +1758,50 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn)
}
static Bool
+xf86RandR15ProviderSetRole(ScreenPtr pScreen,
+ RRProviderPtr provider,
+ uint32_t new_role)
+{
+ /* do nothing so far */
+ return TRUE;
+}
+
+static Bool
+xf86RandR15ProviderSetProperty(ScreenPtr pScreen,
+ RRProviderPtr randr_provider,
+ Atom property, RRPropertyValuePtr value)
+{
+ xf86CrtcConfigPtr config = randr_provider->devPrivate;
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+
+ /* 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
+xf86RandR15ProviderGetProperty(ScreenPtr pScreen,
+ RRProviderPtr randr_provider, Atom property)
+{
+ xf86CrtcConfigPtr config = randr_provider->devPrivate;
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+ 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 +1823,10 @@ xf86RandR12Init12(ScreenPtr pScreen)
#endif
rp->rrModeDestroy = xf86RandR12ModeDestroy;
rp->rrSetConfig = NULL;
+
+ rp->rrProviderSetRole = xf86RandR15ProviderSetRole;
+ rp->rrProviderSetProperty = xf86RandR15ProviderSetProperty;
+ rp->rrProviderGetProperty = xf86RandR15ProviderGetProperty;
pScrn->PointerMoved = xf86RandR12PointerMoved;
pScrn->ChangeGamma = xf86RandR12ChangeGamma;
--
1.7.10.2
More information about the xorg-devel
mailing list