diff options
author | Dave Airlie <airlied@redhat.com> | 2015-04-01 12:13:51 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2015-04-01 14:23:19 +1000 |
commit | f2c71e8826ebeb68694ca2ed8a54cce8ca35c4a7 (patch) | |
tree | 9a1fba109ce6d9ea9f96a072e4ef0c1826bd81ed | |
parent | 4ff0cd91ac04e4fe45697522607df841efec4029 (diff) |
randr/monitor: add initial monitorsrandr-1.5
-rw-r--r-- | hw/xfree86/modes/xf86RandR12.c | 66 | ||||
-rw-r--r-- | randr/randrstr.h | 9 | ||||
-rw-r--r-- | 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 b1c306a88..642127e2b 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 438a52aeb..03974fd4f 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 fbdd352f6..7e962633c 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); |