[PATCH 12/36] xfree86: add framework for provider support in ddx. (v3)
Dave Airlie
airlied at gmail.com
Thu Jul 5 08:21:13 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.
v3: update for new protocol
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
hw/xfree86/common/xf86str.h | 1 +
hw/xfree86/modes/xf86Crtc.c | 17 +++++++++++++++
hw/xfree86/modes/xf86Crtc.h | 34 +++++++++++++++++++++++++++++
hw/xfree86/modes/xf86RandR12.c | 47 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 99 insertions(+)
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 6bd6a62..0590262 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 2c8878f..62de5a0 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -3202,3 +3202,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 a6a3c2e..58d8cec 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 59b6f82..1eaef9d 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), config);
+
+ RRProviderSetCapabilities(config->randr_provider, pScrn->capabilities);
+ }
+
return TRUE;
}
@@ -1746,6 +1754,41 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn)
}
static Bool
+xf86RandR14ProviderSetProperty(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
+xf86RandR14ProviderGetProperty(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 +1810,10 @@ xf86RandR12Init12(ScreenPtr pScreen)
#endif
rp->rrModeDestroy = xf86RandR12ModeDestroy;
rp->rrSetConfig = NULL;
+
+ rp->rrProviderSetProperty = xf86RandR14ProviderSetProperty;
+ rp->rrProviderGetProperty = xf86RandR14ProviderGetProperty;
+
pScrn->PointerMoved = xf86RandR12PointerMoved;
pScrn->ChangeGamma = xf86RandR12ChangeGamma;
--
1.7.10.2
More information about the xorg-devel
mailing list