Replace huge argument list in xf86CrtcSetModeTransform with struct
xf86CrtcSetModeTransform was starting to get ridiculous with 6 arguments, this change has it take a single structure that contains all of those values along with a set of flags that says which have changed. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Aaron Plattner <aplattner@nvidia.com>
This commit is contained in:
parent
f5b8bd620f
commit
8b35118c03
|
@ -247,15 +247,14 @@ xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen)
|
||||||
* Sets the given video mode on the given crtc
|
* Sets the given video mode on the given crtc
|
||||||
*/
|
*/
|
||||||
Bool
|
Bool
|
||||||
xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
|
xf86CrtcSet(xf86CrtcPtr crtc, xf86CrtcSetRec *set)
|
||||||
RRTransformPtr transform, int x, int y)
|
|
||||||
{
|
{
|
||||||
ScrnInfoPtr scrn = crtc->scrn;
|
ScrnInfoPtr scrn = crtc->scrn;
|
||||||
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
|
||||||
int i;
|
int i;
|
||||||
Bool ret = FALSE;
|
Bool ret = FALSE;
|
||||||
Bool didLock = FALSE;
|
Bool didLock = FALSE;
|
||||||
DisplayModePtr adjusted_mode;
|
DisplayModePtr adjusted_mode = NULL;
|
||||||
DisplayModeRec saved_mode;
|
DisplayModeRec saved_mode;
|
||||||
int saved_x, saved_y;
|
int saved_x, saved_y;
|
||||||
Rotation saved_rotation;
|
Rotation saved_rotation;
|
||||||
|
@ -272,8 +271,9 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
adjusted_mode = xf86DuplicateMode(mode);
|
/* See if nothing has changed */
|
||||||
|
if (!set->flags)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
saved_mode = crtc->mode;
|
saved_mode = crtc->mode;
|
||||||
saved_x = crtc->x;
|
saved_x = crtc->x;
|
||||||
|
@ -288,21 +288,44 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
|
||||||
/* Update crtc values up front so the driver can rely on them for mode
|
/* Update crtc values up front so the driver can rely on them for mode
|
||||||
* setting.
|
* setting.
|
||||||
*/
|
*/
|
||||||
crtc->mode = *mode;
|
if (set->flags & XF86CrtcSetMode)
|
||||||
crtc->x = x;
|
crtc->mode = *set->mode;
|
||||||
crtc->y = y;
|
if (set->flags & XF86CrtcSetOrigin) {
|
||||||
crtc->rotation = rotation;
|
crtc->x = set->x;
|
||||||
if (transform) {
|
crtc->y = set->y;
|
||||||
RRTransformCopy (&crtc->transform, transform);
|
}
|
||||||
crtc->transformPresent = TRUE;
|
if (set->flags & XF86CrtcSetRotation)
|
||||||
} else
|
crtc->rotation = set->rotation;
|
||||||
crtc->transformPresent = FALSE;
|
|
||||||
|
|
||||||
if (crtc->funcs->set_mode_major) {
|
if (set->flags & XF86CrtcSetTransform) {
|
||||||
ret = crtc->funcs->set_mode_major(crtc, mode, rotation, x, y);
|
if (set->transform) {
|
||||||
|
RRTransformCopy (&crtc->transform, set->transform);
|
||||||
|
crtc->transformPresent = TRUE;
|
||||||
|
} else
|
||||||
|
crtc->transformPresent = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crtc->funcs->set) {
|
||||||
|
ret = crtc->funcs->set(crtc, set->flags);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (set->flags == XF86CrtcSetOrigin && crtc->funcs->set_origin) {
|
||||||
|
ret = xf86CrtcRotate(crtc);
|
||||||
|
if (ret)
|
||||||
|
crtc->funcs->set_origin(crtc, crtc->x, crtc->y);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (crtc->funcs->set_mode_major) {
|
||||||
|
ret = crtc->funcs->set_mode_major(crtc, &crtc->mode,
|
||||||
|
crtc->rotation,
|
||||||
|
crtc->x, crtc->y);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
adjusted_mode = xf86DuplicateMode(&crtc->mode);
|
||||||
|
|
||||||
didLock = crtc->funcs->lock (crtc);
|
didLock = crtc->funcs->lock (crtc);
|
||||||
/* Pass our mode to the outputs and the CRTC to give them a chance to
|
/* Pass our mode to the outputs and the CRTC to give them a chance to
|
||||||
* adjust it according to limitations or output properties, and also
|
* adjust it according to limitations or output properties, and also
|
||||||
|
@ -314,12 +337,12 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
|
||||||
if (output->crtc != crtc)
|
if (output->crtc != crtc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!output->funcs->mode_fixup(output, mode, adjusted_mode)) {
|
if (!output->funcs->mode_fixup(output, &crtc->mode, adjusted_mode)) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!crtc->funcs->mode_fixup(crtc, mode, adjusted_mode)) {
|
if (!crtc->funcs->mode_fixup(crtc, &crtc->mode, adjusted_mode)) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,12 +365,12 @@ xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotati
|
||||||
/* Set up the DPLL and any output state that needs to adjust or depend
|
/* Set up the DPLL and any output state that needs to adjust or depend
|
||||||
* on the DPLL.
|
* on the DPLL.
|
||||||
*/
|
*/
|
||||||
crtc->funcs->mode_set(crtc, mode, adjusted_mode, crtc->x, crtc->y);
|
crtc->funcs->mode_set(crtc, &crtc->mode, adjusted_mode, crtc->x, crtc->y);
|
||||||
for (i = 0; i < xf86_config->num_output; i++)
|
for (i = 0; i < xf86_config->num_output; i++)
|
||||||
{
|
{
|
||||||
xf86OutputPtr output = xf86_config->output[i];
|
xf86OutputPtr output = xf86_config->output[i];
|
||||||
if (output->crtc == crtc)
|
if (output->crtc == crtc)
|
||||||
output->funcs->mode_set(output, mode, adjusted_mode);
|
output->funcs->mode_set(output, &crtc->mode, adjusted_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only upload when needed, to avoid unneeded delays. */
|
/* Only upload when needed, to avoid unneeded delays. */
|
||||||
|
@ -383,8 +406,10 @@ done:
|
||||||
crtc->transformPresent = saved_transform_present;
|
crtc->transformPresent = saved_transform_present;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(adjusted_mode->name);
|
if (adjusted_mode) {
|
||||||
free(adjusted_mode);
|
free(adjusted_mode->name);
|
||||||
|
free(adjusted_mode);
|
||||||
|
}
|
||||||
|
|
||||||
if (didLock)
|
if (didLock)
|
||||||
crtc->funcs->unlock (crtc);
|
crtc->funcs->unlock (crtc);
|
||||||
|
@ -392,36 +417,20 @@ done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the given video mode on the given crtc, but without providing
|
|
||||||
* a transform
|
|
||||||
*/
|
|
||||||
Bool
|
|
||||||
xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
|
|
||||||
int x, int y)
|
|
||||||
{
|
|
||||||
return xf86CrtcSetModeTransform (crtc, mode, rotation, NULL, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pans the screen, does not change the mode
|
* Pans the screen, does not change the mode
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y)
|
xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y)
|
||||||
{
|
{
|
||||||
ScrnInfoPtr scrn = crtc->scrn;
|
xf86CrtcSetRec set;
|
||||||
|
|
||||||
crtc->x = x;
|
if (x != crtc->x || y != crtc->y) {
|
||||||
crtc->y = y;
|
set.x = x;
|
||||||
if (crtc->funcs->set_origin) {
|
set.y = y;
|
||||||
if (!xf86CrtcRotate (crtc))
|
set.flags = XF86CrtcSetOrigin;
|
||||||
return;
|
(void) xf86CrtcSet(crtc, &set);
|
||||||
crtc->funcs->set_origin (crtc, x, y);
|
|
||||||
if (scrn->ModeSet)
|
|
||||||
scrn->ModeSet(scrn);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
xf86CrtcSetMode (crtc, &crtc->mode, crtc->rotation, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2617,6 +2626,7 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
|
||||||
for (c = 0; c < config->num_crtc; c++)
|
for (c = 0; c < config->num_crtc; c++)
|
||||||
{
|
{
|
||||||
xf86OutputPtr output = NULL;
|
xf86OutputPtr output = NULL;
|
||||||
|
xf86CrtcSetRec set;
|
||||||
int o;
|
int o;
|
||||||
RRTransformPtr transform;
|
RRTransformPtr transform;
|
||||||
|
|
||||||
|
@ -2660,8 +2670,15 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
|
||||||
transform = &crtc->desiredTransform;
|
transform = &crtc->desiredTransform;
|
||||||
else
|
else
|
||||||
transform = NULL;
|
transform = NULL;
|
||||||
if (!xf86CrtcSetModeTransform (crtc, &crtc->desiredMode, crtc->desiredRotation,
|
set.mode = &crtc->desiredMode;
|
||||||
transform, crtc->desiredX, crtc->desiredY))
|
set.rotation = crtc->desiredRotation;
|
||||||
|
set.transform = transform;
|
||||||
|
set.x = crtc->desiredX;
|
||||||
|
set.y = crtc->desiredY;
|
||||||
|
set.flags = (XF86CrtcSetMode | XF86CrtcSetOutput |
|
||||||
|
XF86CrtcSetOrigin | XF86CrtcSetTransform |
|
||||||
|
XF86CrtcSetRotation);
|
||||||
|
if (!xf86CrtcSet(crtc, &set))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2765,6 +2782,7 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
|
||||||
xf86CrtcPtr crtc = config->crtc[c];
|
xf86CrtcPtr crtc = config->crtc[c];
|
||||||
DisplayModePtr crtc_mode = NULL;
|
DisplayModePtr crtc_mode = NULL;
|
||||||
int o;
|
int o;
|
||||||
|
xf86CrtcSetRec set;
|
||||||
|
|
||||||
if (!crtc->enabled)
|
if (!crtc->enabled)
|
||||||
continue;
|
continue;
|
||||||
|
@ -2792,7 +2810,15 @@ xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation)
|
||||||
crtc->enabled = FALSE;
|
crtc->enabled = FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!xf86CrtcSetModeTransform (crtc, crtc_mode, rotation, NULL, 0, 0))
|
set.mode = crtc_mode;
|
||||||
|
set.rotation = rotation;
|
||||||
|
set.transform = NULL;
|
||||||
|
set.x = 0;
|
||||||
|
set.y = 0;
|
||||||
|
set.flags = (XF86CrtcSetMode | XF86CrtcSetOutput |
|
||||||
|
XF86CrtcSetOrigin | XF86CrtcSetTransform |
|
||||||
|
XF86CrtcSetRotation);
|
||||||
|
if (!xf86CrtcSet (crtc, &set))
|
||||||
ok = FALSE;
|
ok = FALSE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,6 +72,23 @@ typedef enum _xf86OutputStatus {
|
||||||
XF86OutputStatusUnknown
|
XF86OutputStatusUnknown
|
||||||
} xf86OutputStatus;
|
} xf86OutputStatus;
|
||||||
|
|
||||||
|
typedef enum _xf86CrtcSetFlags {
|
||||||
|
XF86CrtcSetMode = 1, /* mode */
|
||||||
|
XF86CrtcSetOutput = 2, /* outputs */
|
||||||
|
XF86CrtcSetOrigin = 4, /* x/y */
|
||||||
|
XF86CrtcSetTransform = 8, /* transform */
|
||||||
|
XF86CrtcSetRotation = 16, /* rotation */
|
||||||
|
XF86CrtcSetProperty = 32, /* output property */
|
||||||
|
} xf86CrtcSetFlags;
|
||||||
|
|
||||||
|
typedef struct _xf86CrtcSet {
|
||||||
|
xf86CrtcSetFlags flags;
|
||||||
|
DisplayModePtr mode;
|
||||||
|
Rotation rotation;
|
||||||
|
RRTransformPtr transform;
|
||||||
|
int x, y;
|
||||||
|
} xf86CrtcSetRec;
|
||||||
|
|
||||||
typedef struct _xf86CrtcFuncs {
|
typedef struct _xf86CrtcFuncs {
|
||||||
/**
|
/**
|
||||||
* Turns the crtc on/off, or sets intermediate power levels if available.
|
* Turns the crtc on/off, or sets intermediate power levels if available.
|
||||||
|
@ -221,6 +238,12 @@ typedef struct _xf86CrtcFuncs {
|
||||||
void
|
void
|
||||||
(*set_origin)(xf86CrtcPtr crtc, int x, int y);
|
(*set_origin)(xf86CrtcPtr crtc, int x, int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* General mode setting entry point that does everything
|
||||||
|
*/
|
||||||
|
Bool
|
||||||
|
(*set)(xf86CrtcPtr crtc, xf86CrtcSetFlags flags);
|
||||||
|
|
||||||
} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
|
} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
|
||||||
|
|
||||||
#define XF86_CRTC_VERSION 3
|
#define XF86_CRTC_VERSION 3
|
||||||
|
@ -738,18 +761,12 @@ xf86CrtcCreate (ScrnInfoPtr scrn,
|
||||||
extern _X_EXPORT void
|
extern _X_EXPORT void
|
||||||
xf86CrtcDestroy (xf86CrtcPtr crtc);
|
xf86CrtcDestroy (xf86CrtcPtr crtc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the given video mode on the given crtc
|
* Change a crtc configuration (modes, outputs, etc)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern _X_EXPORT Bool
|
extern _X_EXPORT Bool
|
||||||
xf86CrtcSetModeTransform (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
|
xf86CrtcSet (xf86CrtcPtr crtc, xf86CrtcSetRec *set);
|
||||||
RRTransformPtr transform, int x, int y);
|
|
||||||
|
|
||||||
extern _X_EXPORT Bool
|
|
||||||
xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
|
|
||||||
int x, int y);
|
|
||||||
|
|
||||||
extern _X_EXPORT void
|
extern _X_EXPORT void
|
||||||
xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y);
|
xf86CrtcSetOrigin (xf86CrtcPtr crtc, int x, int y);
|
||||||
|
|
|
@ -1133,7 +1133,7 @@ xf86RandR12CrtcSet (ScreenPtr pScreen,
|
||||||
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
||||||
xf86CrtcPtr crtc = randr_crtc->devPrivate;
|
xf86CrtcPtr crtc = randr_crtc->devPrivate;
|
||||||
RRTransformPtr transform;
|
RRTransformPtr transform;
|
||||||
Bool changed = FALSE;
|
xf86CrtcSetFlags flags = 0;
|
||||||
int o, ro;
|
int o, ro;
|
||||||
xf86CrtcPtr *save_crtcs;
|
xf86CrtcPtr *save_crtcs;
|
||||||
Bool save_enabled = crtc->enabled;
|
Bool save_enabled = crtc->enabled;
|
||||||
|
@ -1143,22 +1143,22 @@ xf86RandR12CrtcSet (ScreenPtr pScreen,
|
||||||
|
|
||||||
save_crtcs = malloc(config->num_output * sizeof (xf86CrtcPtr));
|
save_crtcs = malloc(config->num_output * sizeof (xf86CrtcPtr));
|
||||||
if ((randr_mode != NULL) != crtc->enabled)
|
if ((randr_mode != NULL) != crtc->enabled)
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetMode;
|
||||||
else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode))
|
else if (randr_mode && !xf86RandRModeMatches (randr_mode, &crtc->mode))
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetMode;
|
||||||
|
|
||||||
if (rotation != crtc->rotation)
|
if (rotation != crtc->rotation)
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetRotation;
|
||||||
|
|
||||||
transform = RRCrtcGetTransform (randr_crtc);
|
transform = RRCrtcGetTransform (randr_crtc);
|
||||||
if ((transform != NULL) != crtc->transformPresent)
|
if ((transform != NULL) != crtc->transformPresent)
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetTransform;
|
||||||
else if (transform && memcmp (&transform->transform, &crtc->transform.transform,
|
else if (transform && memcmp (&transform->transform, &crtc->transform.transform,
|
||||||
sizeof (transform->transform)) != 0)
|
sizeof (transform->transform)) != 0)
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetTransform;
|
||||||
|
|
||||||
if (x != crtc->x || y != crtc->y)
|
if (x != crtc->x || y != crtc->y)
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetOrigin;
|
||||||
for (o = 0; o < config->num_output; o++)
|
for (o = 0; o < config->num_output; o++)
|
||||||
{
|
{
|
||||||
xf86OutputPtr output = config->output[o];
|
xf86OutputPtr output = config->output[o];
|
||||||
|
@ -1178,16 +1178,16 @@ xf86RandR12CrtcSet (ScreenPtr pScreen,
|
||||||
}
|
}
|
||||||
if (new_crtc != output->crtc)
|
if (new_crtc != output->crtc)
|
||||||
{
|
{
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetOutput;
|
||||||
output->crtc = new_crtc;
|
output->crtc = new_crtc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ro = 0; ro < num_randr_outputs; ro++)
|
for (ro = 0; ro < num_randr_outputs; ro++)
|
||||||
if (randr_outputs[ro]->pendingProperties)
|
if (randr_outputs[ro]->pendingProperties)
|
||||||
changed = TRUE;
|
flags |= XF86CrtcSetProperty;
|
||||||
|
|
||||||
/* XXX need device-independent mode setting code through an API */
|
/* XXX need device-independent mode setting code through an API */
|
||||||
if (changed)
|
if (flags)
|
||||||
{
|
{
|
||||||
crtc->enabled = randr_mode != NULL;
|
crtc->enabled = randr_mode != NULL;
|
||||||
|
|
||||||
|
@ -1195,9 +1195,16 @@ xf86RandR12CrtcSet (ScreenPtr pScreen,
|
||||||
{
|
{
|
||||||
DisplayModeRec mode;
|
DisplayModeRec mode;
|
||||||
RRTransformPtr transform = RRCrtcGetTransform (randr_crtc);
|
RRTransformPtr transform = RRCrtcGetTransform (randr_crtc);
|
||||||
|
xf86CrtcSetRec set;
|
||||||
|
|
||||||
xf86RandRModeConvert (pScrn, randr_mode, &mode);
|
xf86RandRModeConvert (pScrn, randr_mode, &mode);
|
||||||
if (!xf86CrtcSetModeTransform (crtc, &mode, rotation, transform, x, y))
|
set.mode = &mode;
|
||||||
|
set.rotation = rotation;
|
||||||
|
set.transform = transform;
|
||||||
|
set.x = x;
|
||||||
|
set.y = y;
|
||||||
|
set.flags = flags;
|
||||||
|
if (!xf86CrtcSet(crtc, &set))
|
||||||
{
|
{
|
||||||
crtc->enabled = save_enabled;
|
crtc->enabled = save_enabled;
|
||||||
for (o = 0; o < config->num_output; o++)
|
for (o = 0; o < config->num_output; o++)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user