Commit e4e34476 authored by Keith Packard's avatar Keith Packard Committed by Adam Jackson

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's avatarKeith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson's avatarAdam Jackson <ajax@redhat.com>
parent 023d4aba
......@@ -759,7 +759,7 @@ dnl List of libraries that require a specific version
LIBAPPLEWM="applewm >= 1.4"
LIBDMX="dmx >= 1.0.99.1"
LIBDRI="dri >= 7.8.0"
LIBDRM="libdrm >= 2.3.1"
LIBDRM="libdrm >= 2.4.89"
LIBEGL="egl"
LIBGBM="gbm >= 10.2.0"
LIBGL="gl >= 7.1.0"
......
......@@ -1804,6 +1804,9 @@ CloseScreen(ScreenPtr pScreen)
free(ms->drmmode.shadow_fb2);
ms->drmmode.shadow_fb2 = NULL;
}
drmmode_terminate_leases(pScrn, &ms->drmmode);
drmmode_uevent_fini(pScrn, &ms->drmmode);
drmmode_free_bos(pScrn, &ms->drmmode);
......
......@@ -2085,8 +2085,152 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
return FALSE;
}
static void
drmmode_validate_leases(ScrnInfoPtr scrn)
{
ScreenPtr screen = scrn->pScreen;
rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
modesettingPtr ms = modesettingPTR(scrn);
drmmode_ptr drmmode = &ms->drmmode;
drmModeLesseeListPtr lessees;
RRLeasePtr lease, next;
int l;
/* We can't talk to the kernel about leases when VT switched */
if (!scrn->vtSema)
return;
lessees = drmModeListLessees(drmmode->fd);
if (!lessees)
return;
xorg_list_for_each_entry_safe(lease, next, &scr_priv->leases, list) {
drmmode_lease_private_ptr lease_private = lease->devPrivate;
for (l = 0; l < lessees->count; l++) {
if (lessees->lessees[l] == lease_private->lessee_id)
break;
}
/* check to see if the lease has gone away */
if (l == lessees->count) {
free(lease_private);
lease->devPrivate = NULL;
xf86CrtcLeaseTerminated(lease);
}
}
free(lessees);
}
static int
drmmode_create_lease(RRLeasePtr lease, int *fd)
{
ScreenPtr screen = lease->screen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
drmmode_ptr drmmode = &ms->drmmode;
int ncrtc = lease->numCrtcs;
int noutput = lease->numOutputs;
int nobjects;
int c, o;
int i;
int lease_fd;
uint32_t *objects;
drmmode_lease_private_ptr lease_private;
nobjects = ncrtc + noutput;
if (nobjects == 0)
return BadValue;
lease_private = calloc(1, sizeof (drmmode_lease_private_rec));
if (!lease_private)
return BadAlloc;
objects = xallocarray(nobjects, sizeof (uint32_t));
if (!objects) {
free(lease_private);
return BadAlloc;
}
i = 0;
/* Add CRTC ids */
for (c = 0; c < ncrtc; c++) {
xf86CrtcPtr crtc = lease->crtcs[c]->devPrivate;
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
objects[i++] = drmmode_crtc->mode_crtc->crtc_id;
}
/* Add connector ids */
for (o = 0; o < noutput; o++) {
xf86OutputPtr output = lease->outputs[o]->devPrivate;
drmmode_output_private_ptr drmmode_output = output->driver_private;
objects[i++] = drmmode_output->mode_output->connector_id;
}
/* call kernel to create lease */
assert (i == nobjects);
lease_fd = drmModeCreateLease(drmmode->fd, objects, nobjects, 0, &lease_private->lessee_id);
free(objects);
if (lease_fd < 0) {
free(lease_private);
return BadMatch;
}
lease->devPrivate = lease_private;
xf86CrtcLeaseStarted(lease);
*fd = lease_fd;
return Success;
}
static void
drmmode_terminate_lease(RRLeasePtr lease)
{
ScreenPtr screen = lease->screen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
drmmode_ptr drmmode = &ms->drmmode;
drmmode_lease_private_ptr lease_private = lease->devPrivate;
if (drmModeRevokeLease(drmmode->fd, lease_private->lessee_id) == 0) {
free(lease_private);
lease->devPrivate = NULL;
xf86CrtcLeaseTerminated(lease);
}
}
void
drmmode_terminate_leases(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
{
ScreenPtr screen = xf86ScrnToScreen(pScrn);
rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
RRLeasePtr lease, next;
xorg_list_for_each_entry_safe(lease, next, &scr_priv->leases, list) {
drmmode_lease_private_ptr lease_private = lease->devPrivate;
drmModeRevokeLease(drmmode->fd, lease_private->lessee_id);
free(lease_private);
lease->devPrivate = NULL;
RRLeaseTerminated(lease);
RRLeaseFree(lease);
}
}
static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
drmmode_xf86crtc_resize
.resize = drmmode_xf86crtc_resize,
.create_lease = drmmode_create_lease,
.terminate_lease = drmmode_terminate_lease
};
Bool
......@@ -2222,6 +2366,10 @@ drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, Bool set_hw)
return FALSE;
}
}
/* Validate leases on VT re-entry */
drmmode_validate_leases(pScrn);
return TRUE;
}
......@@ -2427,6 +2575,9 @@ drmmode_handle_uevents(int fd, void *closure)
drmmode_output_init(scrn, drmmode, mode_res, i, TRUE, 0);
}
/* Check to see if a lessee has disappeared */
drmmode_validate_leases(scrn);
if (changed) {
RRSetChanged(xf86ScrnToScreen(scrn));
RRTellChanged(xf86ScrnToScreen(scrn));
......
......@@ -143,6 +143,10 @@ typedef struct {
int enc_clone_mask;
} drmmode_output_private_rec, *drmmode_output_private_ptr;
typedef struct {
uint32_t lessee_id;
} drmmode_lease_private_rec, *drmmode_lease_private_ptr;
typedef struct _msPixmapPriv {
uint32_t fb_id;
struct dumb_bo *backing_bo; /* if this pixmap is backed by a dumb bo */
......@@ -191,6 +195,8 @@ extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
extern void drmmode_terminate_leases(ScrnInfoPtr scrn, drmmode_ptr drmmode);
Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
void *drmmode_map_front_bo(drmmode_ptr drmmode);
Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
......
......@@ -254,7 +254,7 @@ xf86CrtcSetModeTransform(xf86CrtcPtr crtc, DisplayModePtr mode,
RRTransformRec saved_transform;
Bool saved_transform_present;
crtc->enabled = xf86CrtcInUse(crtc);
crtc->enabled = xf86CrtcInUse(crtc) && !RRCrtcIsLeased(crtc->randr_crtc);;
/* We only hit this if someone explicitly sends a "disabled" modeset. */
if (!crtc->enabled) {
......@@ -411,6 +411,10 @@ xf86CrtcSetOrigin(xf86CrtcPtr crtc, int x, int y)
crtc->x = x;
crtc->y = y;
if (RRCrtcIsLeased(crtc->randr_crtc))
return;
if (crtc->funcs->set_origin) {
if (!xf86CrtcRotate(crtc))
return;
......@@ -2652,6 +2656,9 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
static void
xf86DisableCrtc(xf86CrtcPtr crtc)
{
if (RRCrtcIsLeased(crtc->randr_crtc))
return;
crtc->funcs->dpms(crtc, DPMSModeOff);
xf86_crtc_hide_cursor(crtc);
}
......@@ -2670,6 +2677,9 @@ xf86PrepareOutputs(ScrnInfoPtr scrn)
for (o = 0; o < config->num_output; o++) {
xf86OutputPtr output = config->output[o];
if (RROutputIsLeased(output->randr_output))
continue;
#if RANDR_GET_CRTC_INTERFACE
/* Disable outputs that are unused or will be re-routed */
if (!output->funcs->get_crtc ||
......@@ -2687,12 +2697,15 @@ xf86PrepareCrtcs(ScrnInfoPtr scrn)
int c;
for (c = 0; c < config->num_crtc; c++) {
#if RANDR_GET_CRTC_INTERFACE
xf86CrtcPtr crtc = config->crtc[c];
#if RANDR_GET_CRTC_INTERFACE
xf86OutputPtr output = NULL;
uint32_t desired_outputs = 0, current_outputs = 0;
int o;
if (RRCrtcIsLeased(crtc->randr_crtc))
continue;
for (o = 0; o < config->num_output; o++) {
output = config->output[o];
if (output->crtc == crtc)
......@@ -2713,6 +2726,9 @@ xf86PrepareCrtcs(ScrnInfoPtr scrn)
if (desired_outputs != current_outputs || !desired_outputs)
xf86DisableCrtc(crtc);
#else
if (RRCrtcIsLeased(crtc->randr_crtc))
continue;
xf86DisableCrtc(crtc);
#endif
}
......@@ -2948,7 +2964,7 @@ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
for (i = 0; i < config->num_output; i++) {
xf86OutputPtr output = config->output[i];
if (output->crtc != NULL)
if (!RROutputIsLeased(output->randr_output) && output->crtc != NULL)
(*output->funcs->dpms) (output, mode);
}
}
......@@ -2964,7 +2980,7 @@ xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags)
for (i = 0; i < config->num_output; i++) {
xf86OutputPtr output = config->output[i];
if (output->crtc != NULL)
if (!RROutputIsLeased(output->randr_output) && output->crtc != NULL)
(*output->funcs->dpms) (output, mode);
}
}
......
......@@ -47,6 +47,7 @@
typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr;
typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;
typedef struct _xf86Lease xf86LeaseRec, *xf86LeasePtr;
/* define a standard for connector types */
typedef enum _xf86ConnectorType {
......@@ -677,6 +678,54 @@ typedef struct _xf86ProviderFuncs {
} xf86ProviderFuncsRec, *xf86ProviderFuncsPtr;
#define XF86_LEASE_VERSION 1
struct _xf86Lease {
/**
* ABI versioning
*/
int version;
/**
* Associated ScrnInfo
*/
ScrnInfoPtr scrn;
/**
* Driver private
*/
void *driver_private;
/**
* RandR lease
*/
RRLeasePtr randr_lease;
/*
* Contents of the lease
*/
/**
* Number of leased CRTCs
*/
int num_crtc;
/**
* Number of leased outputs
*/
int num_output;
/**
* Array of pointers to leased CRTCs
*/
RRCrtcPtr *crtcs;
/**
* Array of pointers to leased outputs
*/
RROutputPtr *outputs;
};
typedef struct _xf86CrtcConfigFuncs {
/**
* Requests that the driver resize the screen.
......@@ -692,8 +741,29 @@ typedef struct _xf86CrtcConfigFuncs {
*/
Bool
(*resize) (ScrnInfoPtr scrn, int width, int height);
/**
* Requests that the driver create a lease
*/
int (*create_lease)(RRLeasePtr lease, int *fd);
/**
* Ask the driver to terminate a lease, freeing all
* driver resources
*/
void (*terminate_lease)(RRLeasePtr lease);
} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr;
/*
* The driver calls this when it detects that a lease
* has been terminated
*/
extern _X_EXPORT void
xf86CrtcLeaseTerminated(RRLeasePtr lease);
extern _X_EXPORT void
xf86CrtcLeaseStarted(RRLeasePtr lease);
typedef void (*xf86_crtc_notify_proc_ptr) (ScreenPtr pScreen);
typedef struct _xf86CrtcConfig {
......@@ -1009,6 +1079,12 @@ extern _X_EXPORT Bool
extern _X_EXPORT void
xf86_crtc_hide_cursor(xf86CrtcPtr crtc);
/**
* Called by the driver to turn a single crtc's cursor on
*/
extern _X_EXPORT Bool
xf86_crtc_show_cursor(xf86CrtcPtr crtc);
/**
* Called by the driver to turn cursors off
*/
......
......@@ -344,11 +344,13 @@ xf86_hide_cursors(ScrnInfoPtr scrn)
}
}
static Bool
Bool
xf86_crtc_show_cursor(xf86CrtcPtr crtc)
{
if (!crtc->cursor_in_range)
if (!crtc->cursor_in_range) {
crtc->funcs->hide_cursor(crtc);
return TRUE;
}
if (!crtc->cursor_shown)
crtc->cursor_shown = xf86_driver_show_cursor(crtc);
......
......@@ -2205,6 +2205,131 @@ xf86RandR14ProviderDestroy(ScreenPtr screen, RRProviderPtr provider)
config->randr_provider = NULL;
}
static void
xf86CrtcCheckReset(xf86CrtcPtr crtc) {
if (xf86CrtcInUse(crtc)) {
RRTransformPtr transform;
if (crtc->desiredTransformPresent)
transform = &crtc->desiredTransform;
else
transform = NULL;
xf86CrtcSetModeTransform(crtc, &crtc->desiredMode,
crtc->desiredRotation, transform,
crtc->desiredX, crtc->desiredY);
xf86_crtc_show_cursor(crtc);
}
}
void
xf86CrtcLeaseTerminated(RRLeasePtr lease)
{
int c;
int o;
RRLeaseTerminated(lease);
/*
* Force a full mode set on any crtc in the expiring lease which
* was running before the lease started
*/
for (c = 0; c < lease->numCrtcs; c++) {
RRCrtcPtr randr_crtc = lease->crtcs[c];
xf86CrtcPtr crtc = randr_crtc->devPrivate;
xf86CrtcCheckReset(crtc);
}
/* Check to see if any leased output is using a crtc which
* was not reset in the above loop
*/
for (o = 0; o < lease->numOutputs; o++) {
RROutputPtr randr_output = lease->outputs[o];
xf86OutputPtr output = randr_output->devPrivate;
xf86CrtcPtr crtc = output->crtc;
if (crtc) {
for (c = 0; c < lease->numCrtcs; c++)
if (lease->crtcs[c] == crtc->randr_crtc)
break;
if (c != lease->numCrtcs)
continue;
xf86CrtcCheckReset(crtc);
}
}
RRLeaseFree(lease);
}
static Bool
xf86CrtcSoleOutput(xf86CrtcPtr crtc, xf86OutputPtr output)
{
ScrnInfoPtr scrn = crtc->scrn;
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
int o;
for (o = 0; o < config->num_output; o++) {
xf86OutputPtr other = config->output[o];
if (other != output && other->crtc == crtc)
return FALSE;
}
return TRUE;
}
void
xf86CrtcLeaseStarted(RRLeasePtr lease)
{
int c;
int o;
for (c = 0; c < lease->numCrtcs; c++) {
RRCrtcPtr randr_crtc = lease->crtcs[c];
xf86CrtcPtr crtc = randr_crtc->devPrivate;
if (crtc->enabled) {
/*
* Leave the primary plane enabled so we can
* flip without blanking the screen. Hide
* the cursor so it doesn't remain on the screen
* while the lease is active
*/
xf86_crtc_hide_cursor(crtc);
crtc->enabled = FALSE;
}
}
for (o = 0; o < lease->numOutputs; o++) {
RROutputPtr randr_output = lease->outputs[o];
xf86OutputPtr output = randr_output->devPrivate;
xf86CrtcPtr crtc = output->crtc;
if (crtc)
if (xf86CrtcSoleOutput(crtc, output))
crtc->enabled = FALSE;
}
}
static int
xf86RandR16CreateLease(ScreenPtr screen, RRLeasePtr randr_lease, int *fd)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
if (config->funcs->create_lease)
return config->funcs->create_lease(randr_lease, fd);
else
return BadMatch;
}
static void
xf86RandR16TerminateLease(ScreenPtr screen, RRLeasePtr randr_lease)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
if (config->funcs->terminate_lease)
config->funcs->terminate_lease(randr_lease);
}
static Bool
xf86RandR12Init12(ScreenPtr pScreen)
{
......@@ -2234,6 +2359,9 @@ xf86RandR12Init12(ScreenPtr pScreen)
rp->rrCrtcSetScanoutPixmap = xf86CrtcSetScanoutPixmap;
rp->rrProviderDestroy = xf86RandR14ProviderDestroy;
rp->rrCreateLease = xf86RandR16CreateLease;
rp->rrTerminateLease = xf86RandR16TerminateLease;
pScrn->PointerMoved = xf86RandR12PointerMoved;
pScrn->ChangeGamma = xf86RandR12ChangeGamma;
......
......@@ -73,7 +73,7 @@
/* RandR */
#define SERVER_RANDR_MAJOR_VERSION 1
#define SERVER_RANDR_MINOR_VERSION 5
#define SERVER_RANDR_MINOR_VERSION 6
/* Record */
#define SERVER_RECORD_MAJOR_VERSION 1
......
......@@ -154,7 +154,7 @@ if (host_machine.system() != 'darwin' and
xwayland_dep = [
dependency('wayland-client', version: '>= 1.3.0', required: xwayland_required),
dependency('wayland-protocols', version: '>= 1.10', required: xwayland_required),
dependency('libdrm', version: '>= 2.3.1', required: xwayland_required),
dependency('libdrm', version: '>= 2.4.89', required: xwayland_required),
dependency('epoxy', required: xwayland_required),
]
......
......@@ -14,6 +14,7 @@ librandr_la_SOURCES = \
rrcrtc.c \
rrdispatch.c \
rrinfo.c \
rrlease.c \
rrmode.c \
rrmonitor.c \
rroutput.c \
......
......@@ -3,6 +3,7 @@ srcs_randr = [
'rrcrtc.c',
'rrdispatch.c',
'rrinfo.c',
'rrlease.c',
'rrmode.c',
'rrmonitor.c',
'rroutput.c',
......
......@@ -2,6 +2,7 @@
* Copyright © 2000 Compaq Computer Corporation
* Copyright © 2002 Hewlett-Packard Company
* Copyright © 2006 Intel Corporation
* Copyright © 2017 Keith Packard
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
......@@ -222,6 +223,19 @@ SRRResourceChangeNotifyEvent(xRRResourceChangeNotifyEvent * from,
cpswapl(from->window, to->window);
}
static void _X_COLD
SRRLeaseNotifyEvent(xRRLeaseNotifyEvent * from,
xRRLeaseNotifyEvent * to)
{
to->type = from->type;
to->subCode = from->subCode;
cpswaps(from->sequenceNumber, to->sequenceNumber);
cpswapl(from->timestamp, to->timestamp);
cpswapl(from->window, to->window);
cpswapl(from->lease, to->lease);
to->created = from->created;
}
static void _X_COLD
SRRNotifyEvent(xEvent *from, xEvent *to)
{
......@@ -249,6 +263,11 @@ SRRNotifyEvent(xEvent *from, xEvent *to)
case RRNotify_ResourceChange:
SRRResourceChangeNotifyEvent((xRRResourceChangeNotifyEvent *) from,
(xRRResourceChangeNotifyEvent *) to);
break;
case RRNotify_Lease:
SRRLeaseNotifyEvent((xRRLeaseNotifyEvent *) from,
(xRRLeaseNotifyEvent *) to);
break;
default:
break;
}
......@@ -268,6 +287,8 @@ RRInit(void)
return FALSE;
if (!RRProviderInit())
return FALSE;
if (!RRLeaseInit())
return FALSE;
RRGeneration = serverGeneration;
}
if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0))
......@@ -335,6 +356,8 @@ RRScreenInit(ScreenPtr pScreen)
pScrPriv->numCrtcs = 0;
pScrPriv->crtcs = NULL;
xorg_list_init(&pScrPriv->leases);
RRMonitorInit(pScreen);
RRNScreens += 1; /* keep count of screens that implement randr */
......@@ -532,6 +555,12 @@ TellChanged(WindowPtr pWin, void *value)
RRDeliverResourceEvent(client, pWin);
}
}
if (pRREvent->mask & RRLeaseNotifyMask) {
if (pScrPriv->leasesChanged) {
RRDeliverLeaseEvent(client, pWin);
}
}
}
return WT_WALKCHILDREN;
}
......
......@@ -63,6 +63,7 @@ typedef XID RRMode;
typedef XID RROutput;
typedef XID RRCrtc;
typedef XID RRProvider;
typedef XID RRLease;
extern int RREventBase, RRErrorBase;
......@@ -81,6 +82,7 @@ typedef struct _rrCrtc RRCrtcRec, *RRCrtcPtr;
typedef struct _rrOutput RROutputRec, *RROutputPtr;
typedef struct _rrProvider RRProviderRec, *RRProviderPtr;
typedef struct _rrMonitor RRMonitorRec, *RRMonitorPtr;
typedef struct _rrLease RRLeaseRec, *RRLeasePtr;
struct _rrMode {
int refcnt;
......@@ -188,6 +190,20 @@ struct _rrMonitor {
RRMonitorGeometryRec geometry;
};
typedef enum _rrLeaseState { RRLeaseCreating, RRLeaseRunning, RRLeaseTerminating } RRLeaseState;
struct _rrLease {
struct xorg_list list;
ScreenPtr screen;
RRLease id;
RRLeaseState state;
void *devPrivate;
int numCrtcs;
RRCrtcPtr *crtcs;
int numOutputs;
RROutputPtr *outputs;
};
#if RANDR_12_INTERFACE
typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr pScreen,
CARD16 width,
......@@ -255,6 +271,15 @@ typedef Bool (*RRProviderSetOffloadSinkProcPtr)(ScreenPtr pScreen,
typedef void (*RRProviderDestroyProcPtr)(ScreenPtr pScreen,
RRProviderPtr provider);
/* Additions for 1.6 */
typedef int (*RRCreateLeaseProcPtr)(ScreenPtr screen,
RRLeasePtr lease,
int *fd);
typedef void (*RRTerminateLeaseProcPtr)(ScreenPtr screen,
RRLeasePtr lease);
/* These are for 1.0 compatibility */
typedef struct _rrRefresh {
......@@ -327,6 +352,10 @@ typedef struct _rrScrPriv {
RRProviderSetOffloadSinkProcPtr rrProviderSetOffloadSink;
RRProviderGetPropertyProcPtr rrProviderGetProperty;
RRProviderSetPropertyProcPtr rrProviderSetProperty;
RRCreateLeaseProcPtr rrCreateLease;
RRTerminateLeaseProcPtr rrTerminateLease;
/*
* Private part of the structure; not considered part of the ABI
*/
......@@ -338,6 +367,7 @@ typedef struct _rrScrPriv {