summaryrefslogtreecommitdiff
path: root/randr/rroutput.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-02-12 13:51:56 -0800
committerAdam Jackson <ajax@redhat.com>2018-02-27 12:39:50 -0500
commite4e3447603b5fd3a38a92c3f972396d1f81168ad (patch)
tree46492faafe60037e5112d6b6702b7dc9b17987df /randr/rroutput.c
parent023d4aba8d45e9e3630b944ecfb650c081799b96 (diff)
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting driver, creating a lease using new kernel infrastructure and returning that to a client through an fd which will have access to only those resources. v2: Restore CRTC mode when leases terminate When a lease terminates for a crtc we have saved data for, go ahead and restore the saved mode. v3: Report RR_Rotate_0 rotations for leased crtcs. Ignore leased CRTCs when selecting screen size. Stop leasing encoders, the kernel doesn't do that anymore. Turn off crtc->enabled while leased so that modesetting ignores them. Check lease status before calling any driver mode functions When starting a lease, mark leased CRTCs as disabled and hide their cursors. Also, check to see if there are other non-leased CRTCs which are driving leased Outputs and mark them as disabled as well. Sometimes an application will lease an idle crtc instead of the one already associated with the leased output. When terminating a lease, reset any CRTCs which are driving outputs that are no longer leased so that they start working again. This required splitting the DIX level lease termination code into two pieces, one to remove the lease from the system (RRLeaseTerminated) and a new function that frees the lease data structure (RRLeaseFree). v4: Report RR_Rotate_0 rotation for leased crtcs. v5: Terminate all leases on server reset. Leases hang around after the associated client exits so that the client doesn't need to occupy an X server client slot and consume a file descriptor once it has gotten the output resources necessary. Any leases still hanging around when the X server resets or shuts down need to be cleaned up by calling the kernel to terminate the lease and freeing any DIX structures. Note that we cannot simply use the existing drmmode_terminate_lease function on each lease as that wants to also reset the video mode, and during server shut down that modesetting: Validate leases on VT enter The kernel doesn't allow any master ioctls to run when another VT is active, including simple things like listing the active leases. To deal with that, we check the list of leases whenever the X server VT is activated. xfree86: hide disabled cursors when resetting after lease termination The lessee may well have played with cursors and left one active on our screen. Just tell the kernel to turn it off. v6: Add meson build infrastructure [Also bumped libdrm requirement - ajax] Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'randr/rroutput.c')
-rw-r--r--randr/rroutput.c138
1 files changed, 87 insertions, 51 deletions
diff --git a/randr/rroutput.c b/randr/rroutput.c
index d5c30aded..b0ffedea8 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -449,66 +449,99 @@ ProcRRGetOutputInfo(ClientPtr client)
RROutput *clones;
char *name;
int i;
+ Bool leased;
REQUEST_SIZE_MATCH(xRRGetOutputInfoReq);
VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
+ leased = RROutputIsLeased(output);
+
pScreen = output->pScreen;
pScrPriv = rrGetScrPriv(pScreen);
- rep = (xRRGetOutputInfoReply) {
- .type = X_Reply,
- .status = RRSetConfigSuccess,
- .sequenceNumber = client->sequence,
- .length = bytes_to_int32(OutputInfoExtra),
- .timestamp = pScrPriv->lastSetTime.milliseconds,
- .crtc = output->crtc ? output->crtc->id : None,
- .mmWidth = output->mmWidth,
- .mmHeight = output->mmHeight,
- .connection = output->nonDesktop ? RR_Disconnected : output->connection,
- .connection = output->connection,
- .subpixelOrder = output->subpixelOrder,
- .nCrtcs = output->numCrtcs,
- .nModes = output->numModes + output->numUserModes,
- .nPreferred = output->numPreferred,
- .nClones = output->numClones,
- .nameLength = output->nameLength
- };
- extraLen = ((output->numCrtcs +
- output->numModes + output->numUserModes +
- output->numClones + bytes_to_int32(rep.nameLength)) << 2);
-
- if (extraLen) {
- rep.length += bytes_to_int32(extraLen);
- extra = calloc(1, extraLen);
- if (!extra)
- return BadAlloc;
- }
- else
- extra = NULL;
+ if (leased) {
+ rep = (xRRGetOutputInfoReply) {
+ .type = X_Reply,
+ .status = RRSetConfigSuccess,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(OutputInfoExtra),
+ .timestamp = pScrPriv->lastSetTime.milliseconds,
+ .crtc = None,
+ .mmWidth = 0,
+ .mmHeight = 0,
+ .connection = RR_Disconnected,
+ .subpixelOrder = SubPixelUnknown,
+ .nCrtcs = 0,
+ .nModes = 0,
+ .nPreferred = 0,
+ .nClones = 0,
+ .nameLength = output->nameLength
+ };
+ extraLen = bytes_to_int32(rep.nameLength) << 2;
+ if (extraLen) {
+ rep.length += bytes_to_int32(extraLen);
+ extra = calloc(1, extraLen);
+ if (!extra)
+ return BadAlloc;
+ }
+ else
+ extra = NULL;
+
+ name = (char *) extra;
+ } else {
+ rep = (xRRGetOutputInfoReply) {
+ .type = X_Reply,
+ .status = RRSetConfigSuccess,
+ .sequenceNumber = client->sequence,
+ .length = bytes_to_int32(OutputInfoExtra),
+ .timestamp = pScrPriv->lastSetTime.milliseconds,
+ .crtc = output->crtc ? output->crtc->id : None,
+ .mmWidth = output->mmWidth,
+ .mmHeight = output->mmHeight,
+ .connection = output->nonDesktop ? RR_Disconnected : output->connection,
+ .subpixelOrder = output->subpixelOrder,
+ .nCrtcs = output->numCrtcs,
+ .nModes = output->numModes + output->numUserModes,
+ .nPreferred = output->numPreferred,
+ .nClones = output->numClones,
+ .nameLength = output->nameLength
+ };
+ extraLen = ((output->numCrtcs +
+ output->numModes + output->numUserModes +
+ output->numClones + bytes_to_int32(rep.nameLength)) << 2);
+
+ if (extraLen) {
+ rep.length += bytes_to_int32(extraLen);
+ extra = calloc(1, extraLen);
+ if (!extra)
+ return BadAlloc;
+ }
+ else
+ extra = NULL;
- crtcs = (RRCrtc *) extra;
- modes = (RRMode *) (crtcs + output->numCrtcs);
- clones = (RROutput *) (modes + output->numModes + output->numUserModes);
- name = (char *) (clones + output->numClones);
+ crtcs = (RRCrtc *) extra;
+ modes = (RRMode *) (crtcs + output->numCrtcs);
+ clones = (RROutput *) (modes + output->numModes + output->numUserModes);
+ name = (char *) (clones + output->numClones);
- for (i = 0; i < output->numCrtcs; i++) {
- crtcs[i] = output->crtcs[i]->id;
- if (client->swapped)
- swapl(&crtcs[i]);
- }
- for (i = 0; i < output->numModes + output->numUserModes; i++) {
- if (i < output->numModes)
- modes[i] = output->modes[i]->mode.id;
- else
- modes[i] = output->userModes[i - output->numModes]->mode.id;
- if (client->swapped)
- swapl(&modes[i]);
- }
- for (i = 0; i < output->numClones; i++) {
- clones[i] = output->clones[i]->id;
- if (client->swapped)
- swapl(&clones[i]);
+ for (i = 0; i < output->numCrtcs; i++) {
+ crtcs[i] = output->crtcs[i]->id;
+ if (client->swapped)
+ swapl(&crtcs[i]);
+ }
+ for (i = 0; i < output->numModes + output->numUserModes; i++) {
+ if (i < output->numModes)
+ modes[i] = output->modes[i]->mode.id;
+ else
+ modes[i] = output->userModes[i - output->numModes]->mode.id;
+ if (client->swapped)
+ swapl(&modes[i]);
+ }
+ for (i = 0; i < output->numClones; i++) {
+ clones[i] = output->clones[i]->id;
+ if (client->swapped)
+ swapl(&clones[i]);
+ }
}
memcpy(name, output->name, output->nameLength);
if (client->swapped) {
@@ -575,6 +608,9 @@ ProcRRSetOutputPrimary(ClientPtr client)
if (stuff->output) {
VERIFY_RR_OUTPUT(stuff->output, output, DixReadAccess);
+ if (RROutputIsLeased(output))
+ return BadAccess;
+
if (!output->pScreen->isGPU && output->pScreen != pWin->drawable.pScreen) {
client->errorValue = stuff->window;
return BadMatch;