summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-31 19:44:50 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-31 20:48:24 +0100
commit8ecb758697af42e8e68edee0d1945986470a9c04 (patch)
tree712c58bd6662dad6766fed7f6c1aa61e30135a2c /tools
parent57904e8d3d1deef33dd5515f3179b4d60c912712 (diff)
sna: Expand the array of fake outputs if the last is used
Always maintain one spare so that we can reconfigure for any number of desired outputs on the fly. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/intel-virtual-output.man9
-rw-r--r--tools/virtual.c45
2 files changed, 34 insertions, 20 deletions
diff --git a/tools/intel-virtual-output.man b/tools/intel-virtual-output.man
index 7a2e6262..675238c1 100644
--- a/tools/intel-virtual-output.man
+++ b/tools/intel-virtual-output.man
@@ -5,19 +5,12 @@
intel-virtual-output \- Utility for connecting the Integrated Intel GPU to discrete outputs
.SH SYNOPSIS
.nf
-.B "Section \*qDevice\*q"
-.BI " Identifier \*q" devname \*q
-.B " Driver \*qintel\*q"
-.B " Option \*qVirtualHeads\*q" \*q<number>\*q
-\ \ ...
-.B EndSection
-.B ""
.B "intel-virtual-output [<remote display>] <output name>..."
.fi
.SH DESCRIPTION
.B intel-virtual-output
is a utility for Intel integrated graphics chipsets on hybrid systems.
-The tool connects pre-allocated VirtualHeads to a remote output, allowing
+The tool connects local VirtualHeads to a remote output, allowing
the primary display to extend onto the remote outputs.
.SH REPORTING BUGS
diff --git a/tools/virtual.c b/tools/virtual.c
index d3f71a67..00342c9e 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -383,6 +383,37 @@ err:
return ret;
}
+static int claim_virtual(struct output *output)
+{
+ char buf[] = "ClaimVirtualHead";
+ XRRScreenResources *res;
+ XRRModeInfo mode;
+ RRMode id;
+
+ /* Set any mode on the VirtualHead to make the Xserver allocate another */
+ assert(output->rr_output);
+
+ memset(&mode, 0, sizeof(mode));
+ mode.width = 1024;
+ mode.height = 768;
+ mode.name = buf;
+ mode.nameLength = sizeof(buf) - 1;
+
+ id = XRRCreateMode(output->dpy, output->window, &mode);
+ XRRAddOutputMode(output->dpy, output->rr_output, id);
+
+ /* Force a redetection for the ddx to spot the new outputs */
+ res = XRRGetScreenResources(output->dpy, output->window);
+ if (res == NULL)
+ return ENOMEM;
+
+ XRRFreeScreenResources(res);
+ XRRDeleteOutputMode(output->dpy, output->rr_output, id);
+ XRRDestroyMode(output->dpy, id);
+
+ return 0;
+}
+
static int get_current_config(struct output *output)
{
XRRScreenResources *res;
@@ -1471,18 +1502,8 @@ int main(int argc, char **argv)
sprintf(buf, "VIRTUAL%d", ctx.num_clones+1);
ret = clone_output_init(&ctx.clones[ctx.num_clones], &ctx.clones[ctx.num_clones].src, &ctx.display[0], buf);
- if (ret) {
- while (++i < argc)
- ctx.num_clones += strchr(argv[i], ':') == NULL;
- fprintf(stderr,
- "No preallocated VirtualHead found for argv[i].\n"
- "Please increase the number of VirtualHeads in xorg.conf:\n"
- " Section \"Device\"\n"
- " Identifier \"<identifier>\"\n"
- " Driver \"intel\"\n"
- " Option \"VirtualHeads\" \"%d\"\n"
- " ...\n"
- " EndSection\n", ctx.num_clones+1);
+ if (ret || claim_virtual(&ctx.clones[ctx.num_clones].src)) {
+ fprintf(stderr, "Failed to find available VirtualHead for argv[i].\n");
return ret;
}