[PATCH 3/3] xf86Crtc/monitors: create initial monitors for tiled outputs

Dave Airlie airlied at gmail.com
Tue Mar 31 21:32:47 PDT 2015


From: Dave Airlie <airlied at redhat.com>

This creates an automatic monitor for a tiled monitor at startup.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/modes/xf86RandR12.c | 66 ++++++++++++++++++++++++++++++++++++++++++
 randr/randrstr.h               |  9 ++++++
 randr/rrmonitor.c              |  6 ++--
 3 files changed, 78 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index b1c306a..642127e 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -1564,6 +1564,70 @@ xf86RandR12CreateObjects12(ScreenPtr pScreen)
     return TRUE;
 }
 
+static void
+xf86RandR12CreateMonitors(ScreenPtr pScreen)
+{
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int o, ot;
+    int ht, vt;
+    int ret;
+    char buf[25];
+
+    for (o = 0; o < config->num_output; o++) {
+        xf86OutputPtr output = config->output[o];
+        struct xf86CrtcTileInfo *tile_info = &output->tile_info, *this_tile;
+        RRMonitorPtr monitor;
+        int output_num, num_outputs;
+        if (!tile_info->group_id)
+            continue;
+
+        if (tile_info->tile_h_loc ||
+            tile_info->tile_v_loc)
+            continue;
+
+        num_outputs = tile_info->num_h_tile * tile_info->num_v_tile;
+
+        monitor = RRMonitorAlloc(num_outputs);
+        if (!monitor)
+            return;
+        monitor->pScreen = pScreen;
+        snprintf(buf, 25, "Auto-Monitor-%d", tile_info->group_id);
+        monitor->name = MakeAtom(buf, strlen(buf), TRUE);
+        monitor->primary = 0;
+        monitor->automatic = TRUE;
+        memset(&monitor->geometry.box, 0, sizeof(monitor->geometry.box));
+
+        output_num = 0;
+        for (ht = 0; ht < tile_info->num_h_tile; ht++) {
+            for (vt = 0; vt < tile_info->num_v_tile; vt++) {
+
+                for (ot = 0; ot < config->num_output; ot++) {
+                    this_tile = &config->output[ot]->tile_info;
+
+                    if (this_tile->group_id != tile_info->group_id)
+                        continue;
+
+                    if (this_tile->tile_h_loc != ht ||
+                        this_tile->tile_v_loc != vt)
+                        continue;
+
+                    monitor->outputs[output_num] = config->output[ot]->randr_output->id;
+                    output_num++;
+
+                }
+
+            }
+        }
+
+        ret = RRMonitorAdd(serverClient, pScreen, monitor);
+        if (ret) {
+            RRMonitorFree(monitor);
+            return;
+        }
+    }
+}
+
 static Bool
 xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
 {
@@ -1579,6 +1643,8 @@ xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
 
     RRScreenSetSizeRange(pScreen, config->minWidth, config->minHeight,
                          config->maxWidth, config->maxHeight);
+
+    xf86RandR12CreateMonitors(pScreen);
     return TRUE;
 }
 
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 438a52a..03974fd 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -1016,6 +1016,15 @@ RRMonitorFreeList(RRMonitorPtr monitors, int nmon);
 void
 RRMonitorClose(ScreenPtr screen);
 
+RRMonitorPtr
+RRMonitorAlloc(int noutput);
+
+int
+RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor);
+
+void
+RRMonitorFree(RRMonitorPtr monitor);
+
 int
 ProcRRGetMonitors(ClientPtr client);
 
diff --git a/randr/rrmonitor.c b/randr/rrmonitor.c
index fbdd352..7e96263 100644
--- a/randr/rrmonitor.c
+++ b/randr/rrmonitor.c
@@ -389,13 +389,13 @@ RRMonitorCountList(ScreenPtr screen)
     return nmon;
 }
 
-static void
+void
 RRMonitorFree(RRMonitorPtr monitor)
 {
     free(monitor);
 }
 
-static RRMonitorPtr
+RRMonitorPtr
 RRMonitorAlloc(int noutput)
 {
     RRMonitorPtr        monitor;
@@ -451,7 +451,7 @@ RRMonitorMatchesOutputName(ScreenPtr screen, Atom name)
     return FALSE;
 }
 
-static int
+int
 RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor)
 {
     rrScrPrivPtr        pScrPriv = rrGetScrPriv(screen);
-- 
2.3.3



More information about the xorg-devel mailing list