[PATCH 32/36] randr: add hooks for offload sink provider protocol

Dave Airlie airlied at gmail.com
Thu Jul 5 08:21:33 PDT 2012


From: Dave Airlie <airlied at redhat.com>

This adds the protocol handler and associated providers handling
for the offload slaves, it allows two providers to be connected as
offload sink/source.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 randr/randrstr.h   |   10 ++++++++++
 randr/rrdispatch.c |    2 +-
 randr/rrprovider.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/randr/randrstr.h b/randr/randrstr.h
index d7b0804..64c9afb 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -165,6 +165,7 @@ struct _rrProvider {
     int nameLength;
     RRPropertyPtr properties;
     Bool pendingProperties;
+    struct _rrProvider *offload_sink;
     struct _rrProvider *output_source;
 };
 
@@ -231,6 +232,11 @@ typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen,
                                           RRProviderPtr provider,
                                           RRProviderPtr output_source);
 
+typedef Bool (*RRProviderSetOffloadSinkProcPtr)(ScreenPtr pScreen,
+                                         RRProviderPtr provider,
+                                         RRProviderPtr offload_sink);
+
+
 /* These are for 1.0 compatibility */
 
 typedef struct _rrRefresh {
@@ -283,6 +289,7 @@ typedef struct _rrScrPriv {
     RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap;
 
     RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource;
+    RRProviderSetOffloadSinkProcPtr rrProviderSetOffloadSink;
     RRProviderGetPropertyProcPtr rrProviderGetProperty;
     RRProviderSetPropertyProcPtr rrProviderSetProperty;
     /*
@@ -893,6 +900,9 @@ ProcRRGetProviderInfo(ClientPtr client);
 extern _X_EXPORT int
 ProcRRSetProviderOutputSource(ClientPtr client);
 
+extern _X_EXPORT int
+ProcRRSetProviderOffloadSink(ClientPtr client);
+
 extern _X_EXPORT Bool
 RRProviderInit(void);
 
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 6fe51c7..1942d74 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -245,7 +245,7 @@ int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = {
 /* V1.4 additions */
         ProcRRGetProviders,     /* 32 */
         ProcRRGetProviderInfo,  /* 33 */
-        NULL, /* 34 */
+        ProcRRSetProviderOffloadSink, /* 34 */
         ProcRRSetProviderOutputSource, /* 35 */
         ProcRRListProviderProperties,    /* 36 */
         ProcRRQueryProviderProperty,     /* 37 */
diff --git a/randr/rrprovider.c b/randr/rrprovider.c
index bf53d8b..cd353a0 100644
--- a/randr/rrprovider.c
+++ b/randr/rrprovider.c
@@ -175,10 +175,15 @@ ProcRRGetProviderInfo (ClientPtr client)
 
     /* count associated providers */
     rep.nAssociatedProviders = 0;
+    if (provider->offload_sink)
+        rep.nAssociatedProviders++;
     if (provider->output_source)
         rep.nAssociatedProviders++;
     xorg_list_for_each_entry(provscreen, &pScreen->output_slave_list, output_head)
         rep.nAssociatedProviders++;
+    xorg_list_for_each_entry(provscreen, &pScreen->offload_slave_list, offload_head)
+        rep.nAssociatedProviders++;
+
     rep.length = (pScrPriv->numCrtcs + pScrPriv->numOutputs +
                   (rep.nAssociatedProviders * 2) + bytes_to_int32(rep.nameLength));
 
@@ -210,6 +215,15 @@ ProcRRGetProviderInfo (ClientPtr client)
     }
 
     i = 0;
+    if (provider->offload_sink) {
+        providers[i] = provider->offload_sink->id;
+        if (client->swapped)
+            swapl(&providers[i]);
+        prov_cap[i] = RR_Capability_SinkOffload;
+        if (client->swapped)
+            swapl(&prov_cap[i]);
+        i++;
+    }
     if (provider->output_source) {
         providers[i] = provider->output_source->id;
         if (client->swapped)
@@ -228,6 +242,17 @@ ProcRRGetProviderInfo (ClientPtr client)
             swapl(&prov_cap[i]);
         i++;
     }
+    xorg_list_for_each_entry(provscreen, &pScreen->offload_slave_list, offload_head) {
+        pScrProvPriv = rrGetScrPriv(provscreen);
+        providers[i] = pScrProvPriv->provider->id;
+        if (client->swapped)
+            swapl(&providers[i]);
+        prov_cap[i] = RR_Capability_SourceOffload;
+        if (client->swapped)
+            swapl(&prov_cap[i]);
+        i++;
+    }
+
 
     memcpy(name, provider->name, rep.nameLength);
     if (client->swapped) {
@@ -279,6 +304,35 @@ ProcRRSetProviderOutputSource(ClientPtr client)
     return Success;
 }
 
+int
+ProcRRSetProviderOffloadSink(ClientPtr client)
+{
+    REQUEST(xRRSetProviderOffloadSinkReq);
+    rrScrPrivPtr pScrPriv;
+    RRProviderPtr provider, sink_provider = NULL;
+    ScreenPtr pScreen;
+
+    REQUEST_AT_LEAST_SIZE(xRRSetProviderOffloadSinkReq);
+
+    VERIFY_RR_PROVIDER(stuff->provider, provider, DixReadAccess);
+    if (!(provider->capabilities & RR_Capability_SourceOffload))
+        return BadValue;
+
+    if (stuff->sink_provider) {
+        VERIFY_RR_PROVIDER(stuff->sink_provider, sink_provider, DixReadAccess);
+        if (!(sink_provider->capabilities & RR_Capability_SinkOffload))
+            return BadValue;
+    }
+    pScreen = provider->pScreen;
+    pScrPriv = rrGetScrPriv(pScreen);
+
+    pScrPriv->rrProviderSetOffloadSink(pScreen, provider, sink_provider);
+
+    RRTellChanged (pScreen);
+
+    return Success;
+}
+
 RRProviderPtr
 RRProviderCreate(ScreenPtr pScreen, const char *name,
                  int nameLength, void *devPrivate)
-- 
1.7.10.2



More information about the xorg-devel mailing list