diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-29 23:00:05 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-08-30 08:57:25 +0100 |
commit | 68d139388a2a037347fa5c838391e67e006793ee (patch) | |
tree | fcac6d4c98fd88b1c9bd24483972da6a95cbd739 /src/sna/sna_display_fake.c | |
parent | 92a43caab96e7f49c541fb999b75925914d9981a (diff) |
sna: Allow user specification of number of VirtualHeads
Previously, we instantiated a fake output in case we had a machine with
no output. (For certain server-class products.) The Bumblee project were
also doing something very similar in order to fake an extended desktop
on the Intel igfx and copy portions onto a discrete GPU. (The preferred
method for doing this upstream is through the use of PRIME). As the code
is very similar, we can support both use-cases simultaneously.
This adds the option:
Section "Device"
Driver "intel"
Option "VirtualHeads" "<count>"
EndSection
to allow the user to specify an additional set of fake outputs, which
can then be controlled using xrandr.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_display_fake.c')
-rw-r--r-- | src/sna/sna_display_fake.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/sna/sna_display_fake.c b/src/sna/sna_display_fake.c index 6231eb52..afd5588f 100644 --- a/src/sna/sna_display_fake.c +++ b/src/sna/sna_display_fake.c @@ -143,7 +143,7 @@ sna_output_dpms(xf86OutputPtr output, int dpms) static xf86OutputStatus sna_output_detect(xf86OutputPtr output) { - return XF86OutputStatusDisconnected; + return XF86OutputStatusUnknown; } static Bool @@ -178,12 +178,15 @@ static const xf86OutputFuncsRec sna_output_funcs = { }; static bool -sna_output_fake(struct sna *sna) +sna_output_fake(struct sna *sna, int n, int num_fake, int num_real_crtc, int num_real_output) { ScrnInfoPtr scrn = sna->scrn; xf86OutputPtr output; + unsigned mask; + char buf[80]; - output = xf86OutputCreate(scrn, &sna_output_funcs, "FAKE"); + sprintf(buf, "VIRTUAL%d", n+1); + output = xf86OutputCreate(scrn, &sna_output_funcs, buf); if (!output) return false; @@ -192,8 +195,9 @@ sna_output_fake(struct sna *sna) output->subpixel_order = SubPixelNone; - output->possible_crtcs = 1; - output->possible_clones = 0; + mask = (1 << num_fake) - 1; + output->possible_crtcs = mask << num_real_crtc; + output->possible_clones = mask << num_real_output; output->interlaceAllowed = FALSE; return true; @@ -241,8 +245,28 @@ static const xf86CrtcConfigFuncsRec sna_mode_funcs = { sna_mode_resize }; -bool sna_mode_fake_init(struct sna *sna) +bool sna_mode_fake_init(struct sna *sna, int num_fake) { - xf86CrtcConfigInit(sna->scrn, &sna_mode_funcs); - return sna_crtc_fake(sna) && sna_output_fake(sna); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(sna->scrn); + int n, num_real_crtc, num_real_output; + + if (num_fake == 0) + return true; + + num_real_crtc = xf86_config->num_crtc; + num_real_output = xf86_config->num_output; + + if (num_real_crtc == 0) + xf86CrtcConfigInit(sna->scrn, &sna_mode_funcs); + + for (n = 0; n < num_fake; n++) { + if (!sna_crtc_fake(sna)) + return false; + + if (!sna_output_fake(sna, n, num_fake, + num_real_crtc, num_real_output)) + return false; + } + + return true; } |