[PATCH 19/29] randr: add output source setup

Dave Airlie airlied at gmail.com
Thu Jul 5 13:30:26 PDT 2012


From: Dave Airlie <airlied at redhat.com>

This adds the output sources to the associated list and adds the protocol
handler for the randr SetProviderOutputSource.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 randr/randrstr.h   |    8 ++++++++
 randr/rrdispatch.c |    2 +-
 randr/rrprovider.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/randr/randrstr.h b/randr/randrstr.h
index 4ed581d..d7b0804 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -165,6 +165,7 @@ struct _rrProvider {
     int nameLength;
     RRPropertyPtr properties;
     Bool pendingProperties;
+    struct _rrProvider *output_source;
 };
 
 #if RANDR_12_INTERFACE
@@ -226,6 +227,10 @@ typedef Bool (*RRProviderSetPropertyProcPtr) (ScreenPtr pScreen,
 typedef Bool (*RRGetInfoProcPtr) (ScreenPtr pScreen, Rotation * rotations);
 typedef Bool (*RRCloseScreenProcPtr) (ScreenPtr pscreen);
 
+typedef Bool (*RRProviderSetOutputSourceProcPtr)(ScreenPtr pScreen,
+                                          RRProviderPtr provider,
+                                          RRProviderPtr output_source);
+
 /* These are for 1.0 compatibility */
 
 typedef struct _rrRefresh {
@@ -277,6 +282,7 @@ typedef struct _rrScrPriv {
     /* TODO #if RANDR_15_INTERFACE */
     RRCrtcSetScanoutPixmapProcPtr rrCrtcSetScanoutPixmap;
 
+    RRProviderSetOutputSourceProcPtr rrProviderSetOutputSource;
     RRProviderGetPropertyProcPtr rrProviderGetProperty;
     RRProviderSetPropertyProcPtr rrProviderSetProperty;
     /*
@@ -884,6 +890,8 @@ ProcRRGetProviders(ClientPtr client);
 extern _X_EXPORT int
 ProcRRGetProviderInfo(ClientPtr client);
 
+extern _X_EXPORT int
+ProcRRSetProviderOutputSource(ClientPtr client);
 
 extern _X_EXPORT Bool
 RRProviderInit(void);
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 054e47a..6fe51c7 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -246,7 +246,7 @@ int (*ProcRandrVector[RRNumberRequests]) (ClientPtr) = {
         ProcRRGetProviders,     /* 32 */
         ProcRRGetProviderInfo,  /* 33 */
         NULL, /* 34 */
-        NULL, /* 35 */
+        ProcRRSetProviderOutputSource, /* 35 */
         ProcRRListProviderProperties,    /* 36 */
         ProcRRQueryProviderProperty,     /* 37 */
         ProcRRConfigureProviderProperty, /* 38 */
diff --git a/randr/rrprovider.c b/randr/rrprovider.c
index 33cb77d..9237860 100644
--- a/randr/rrprovider.c
+++ b/randr/rrprovider.c
@@ -137,7 +137,7 @@ ProcRRGetProviderInfo (ClientPtr client)
 {
     REQUEST(xRRGetProviderInfoReq);
     xRRGetProviderInfoReply rep;
-    rrScrPrivPtr pScrPriv;
+    rrScrPrivPtr pScrPriv, pScrProvPriv;
     RRProviderPtr provider;
     ScreenPtr pScreen;
     CARD8 *extra;
@@ -168,6 +168,10 @@ ProcRRGetProviderInfo (ClientPtr client)
 
     /* count associated providers */
     rep.nAssociatedProviders = 0;
+    if (provider->output_source)
+        rep.nAssociatedProviders++;
+    xorg_list_for_each_entry(provscreen, &pScreen->output_slave_list, output_head)
+        rep.nAssociatedProviders++;
     rep.length = (pScrPriv->numCrtcs + pScrPriv->numOutputs +
                   (rep.nAssociatedProviders * 2) + bytes_to_int32(rep.nameLength));
 
@@ -198,6 +202,26 @@ ProcRRGetProviderInfo (ClientPtr client)
             swapl(&outputs[i]);
     }
 
+    i = 0;
+    if (provider->output_source) {
+        providers[i] = provider->output_source->id;
+        if (client->swapped)
+            swapl(&providers[i]);
+        prov_cap[i] = RR_Capability_SourceOutput;
+            swapl(&prov_cap[i]);
+        i++;
+    }
+    xorg_list_for_each_entry(provscreen, &pScreen->output_slave_list, output_head) {
+        pScrProvPriv = rrGetScrPriv(provscreen);
+        providers[i] = pScrProvPriv->provider->id;
+        if (client->swapped)
+            swapl(&providers[i]);
+        prov_cap[i] = RR_Capability_SinkOutput;
+        if (client->swapped)
+            swapl(&prov_cap[i]);
+        i++;
+    }
+
     memcpy(name, provider->name, rep.nameLength);
     if (client->swapped) {
               swaps(&rep.sequenceNumber);
@@ -216,6 +240,38 @@ ProcRRGetProviderInfo (ClientPtr client)
     return Success;
 }
 
+int
+ProcRRSetProviderOutputSource(ClientPtr client)
+{
+    REQUEST(xRRSetProviderOutputSourceReq);
+    rrScrPrivPtr pScrPriv;
+    RRProviderPtr provider, source_provider = NULL;
+    ScreenPtr pScreen;
+
+    REQUEST_AT_LEAST_SIZE(xRRSetProviderOutputSourceReq);
+
+    VERIFY_RR_PROVIDER(stuff->provider, provider, DixReadAccess);
+
+    if (!(provider->capabilities & RR_Capability_SinkOutput))
+        return BadValue;
+
+    if (stuff->source_provider) {
+        VERIFY_RR_PROVIDER(stuff->source_provider, source_provider, DixReadAccess);
+
+        if (!(source_provider->capabilities & RR_Capability_SourceOutput))
+            return BadValue;
+    }
+
+    pScreen = provider->pScreen;
+    pScrPriv = rrGetScrPriv(pScreen);
+
+    pScrPriv->rrProviderSetOutputSource(pScreen, provider, source_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