xf86Crtc.h revision a5e7ae69e440f6816420fc99599f044e79e716b6
/*
* Copyright © 2006 Keith Packard
* Copyright © 2011 Aaron Plattner
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the name of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#ifndef _XF86CRTC_H_
#define _XF86CRTC_H_
#include <edid.h>
#include "randrstr.h"
#include "xf86Modes.h"
#include "xf86Cursor.h"
#include "xf86i2c.h"
#include "damage.h"
#include "picturestr.h"
/* Compat definitions for older X Servers. */
#ifndef M_T_PREFERRED
#define M_T_PREFERRED 0x08
#endif
#ifndef M_T_DRIVER
#define M_T_DRIVER 0x40
#endif
#ifndef M_T_USERPREF
#define M_T_USERPREF 0x80
#endif
#ifndef HARDWARE_CURSOR_ARGB
#define HARDWARE_CURSOR_ARGB 0x00004000
#endif
/* define a standard for connector types */
typedef enum _xf86ConnectorType {
typedef enum _xf86OutputStatus {
typedef struct _xf86CrtcFuncs {
/**
*
* Unsupported intermediate modes drop to the lower power setting. If the
* mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
* be safe to call mode_set.
*/
void
/**
* Saves the crtc's state for restoration on VT switch.
*/
void
/**
* Restore's the crtc's state at VT switch.
*/
void
/**
* Lock CRTC prior to mode setting, mostly for DRI.
* Returns whether unlock is needed
*/
/**
* Unlock CRTC after mode setting, mostly for DRI
*/
void
/**
* Callback to adjust the mode to be set in the CRTC.
*
* This allows a CRTC to adjust the clock or even the entire set of
* timings, which is used for panels with fixed timings or for
* buses with clock limitations.
*/
/**
* Prepare CRTC for an upcoming mode set.
*/
void
/**
* Callback for setting up a video mode after fixups have been made.
*/
void
DisplayModePtr adjusted_mode, int x, int y);
/**
* Commit mode changes to a CRTC
*/
void
/* Set the color ramps for the CRTC to the given values. */
void
int size);
/**
* Allocate the shadow area, delay the pixmap creation until needed
*/
/**
* Create shadow pixmap for rotation support
*/
/**
* Destroy shadow pixmap
*/
void
/**
* Set cursor colors
*/
void
/**
* Set cursor position
*/
void
/**
* Show cursor
*/
void
/**
* Hide cursor
*/
void
/**
* Load monochrome image
*/
void
/**
* Load ARGB image
*/
void
/**
* Clean up driver-specific bits of the crtc
*/
void
/**
* Less fine-grained mode setting entry point for kernel modesetting
*/
/**
* Callback for panning. Doesn't change the mode.
* Added in ABI version 2
*/
void
/**
*/
#define XF86_CRTC_VERSION 5
struct _xf86Crtc {
/**
* ABI versioning
*/
int version;
/**
* Associated ScrnInfo
*/
/**
* Desired state of this CRTC
*
* Set when this CRTC should be driving one or more outputs
*/
/**
* Active mode
*
* This reflects the mode as set in the CRTC currently
* It will be cleared when the VT is not active or
* during server startup
*/
void *rotatedData;
/**
* Position on screen
*
* Locates this CRTC within the frame buffer
*/
int x, y;
/**
* Desired mode
*
* This is set to the requested mode, independent of
* whether the VT is active. In particular, it receives
* the startup configured mode and saves the active mode
* on VT switch.
*/
/** crtc-specific functions */
const xf86CrtcFuncsRec *funcs;
/**
* Driver private
*
* Holds driver-private information
*/
void *driver_private;
#ifdef RANDR_12_INTERFACE
/**
* RandR crtc
*
* When RandR 1.2 is available, this
* points at the associated crtc object
*/
#else
void *randr_crtc;
#endif
/**
* Current cursor is ARGB
*/
/**
* Track whether cursor is within CRTC range
*/
/**
* Track state of cursor associated with this CRTC
*/
/**
* Current transformation matrix
*/
/* framebuffer_to_crtc was removed in ABI 2 */
int nparams; /* ABI 2 */
int filter_width; /* ABI 2 */
int filter_height; /* ABI 2 */
/**
* Bounding box in screen space
*/
/**
* Panning:
* TotalArea: total panning area, larger than CRTC's size
* TrackingArea: Area of the pointer for which the CRTC is panned
* border: Borders of the displayed CRTC area which induces panning if the pointer reaches them
* Added in ABI version 2
*/
/**
* Current gamma, especially useful after initial config.
* Added in ABI version 3
*/
int gamma_size;
/**
* Actual state of this CRTC
*
* Set to TRUE after modesetting, set to FALSE if no outputs are connected
* Added in ABI version 3
*/
/**
* Clear the shadow
*/
/**
* Indicates that the driver is handling the transform, so the shadow
* surface should be disabled. The driver writes this field before calling
* xf86CrtcRotate to indicate that it is handling the transform (including
* rotation and reflection).
*
* Setting this flag also causes the server to stop adjusting the cursor
* image and position.
*
* Added in ABI version 4
*/
/* Added in ABI version 5
*/
};
typedef struct _xf86OutputFuncs {
/**
* Called to allow the output a chance to create properties after the
* RandR objects have been created.
*/
void
/**
*
* Unsupported intermediate modes drop to the lower power setting. If the
* mode is DPMSModeOff, the output must be disabled, as the DPLL may be
* disabled afterwards.
*/
void
/**
* Saves the output's state for restoration on VT switch.
*/
void
/**
* Restore's the output's state at VT switch.
*/
void
/**
* Callback for testing a video mode for a given output.
*
* This function should only check for cases where a mode can't be supported
* on the output specifically, and not represent generic CRTC limitations.
*
* \return MODE_OK if the mode is valid, or another MODE_* otherwise.
*/
int
/**
* Callback to adjust the mode to be set in the CRTC.
*
* This allows an output to adjust the clock or even the entire set of
* timings, which is used for panels with fixed timings or for
* buses with clock limitations.
*/
/**
* Callback for preparing mode changes on an output
*/
void
/**
* Callback for committing mode changes on an output
*/
void
/**
* Callback for setting up a video mode after fixups have been made.
*
* This is only called while the output is disabled. The dpms callback
* must be all that's necessary for the output, to turn the output on
* after this function is called.
*/
void
/**
* Probe for a connected output, and return detect_status.
*/
/**
* Query the device for the modes it provides.
*
* This function may also update MonInfo, mm_width, and mm_height.
*
* \return singly-linked list of modes or NULL if no modes found.
*/
#ifdef RANDR_12_INTERFACE
/**
* Callback when an output's property has changed.
*/
#endif
#ifdef RANDR_13_INTERFACE
/**
* Callback to get an updated property value
*/
#endif
#ifdef RANDR_GET_CRTC_INTERFACE
/**
* Callback to get current CRTC for a given output
*/
#endif
/**
* Clean up driver-specific bits of the output
*/
void
#define XF86_OUTPUT_VERSION 2
struct _xf86Output {
/**
* ABI versioning
*/
int version;
/**
* Associated ScrnInfo
*/
/**
* Currently connected crtc (if any)
*
* If this output is not in use, this field will be NULL.
*/
/**
* Possible CRTCs for this output as a mask of crtc indices
*/
/**
* Possible outputs to share the same CRTC as a mask of output indices
*/
/**
* Whether this output can support interlaced modes
*/
/**
* Whether this output can support double scan modes
*/
/**
* List of available modes on this output.
*
* This should be the list from get_modes(), plus perhaps additional
* compatible modes added later.
*/
/**
* Options parsed from the related monitor section
*/
/**
* Configured monitor section
*/
/**
* Desired initial position
*/
/**
* Desired initial rotation
*/
/**
* Current connection status
*
* This indicates whether a monitor is known to be connected
* to this output or not, or whether there is no way to tell
*/
/** EDID monitor information */
/** subpixel order */
int subpixel_order;
/** Physical size of the currently attached output device. */
/** Output name */
char *name;
/** output-specific functions */
const xf86OutputFuncsRec *funcs;
/** driver private information */
void *driver_private;
/** Whether to use the old per-screen Monitor config section */
#ifdef RANDR_12_INTERFACE
/**
* RandR 1.2 output structure.
*
* When RandR 1.2 is available, this points at the associated
* RandR output structure and is created when this output is created
*/
#else
void *randr_output;
#endif
/**
* Desired initial panning
* Added in ABI version 2
*/
};
typedef struct _xf86ProviderFuncs {
/**
* Called to allow the provider a chance to create properties after the
* RandR objects have been created.
*/
void
/**
* Callback when an provider's property has changed.
*/
/**
* Callback to get an updated property value
*/
typedef struct _xf86CrtcConfigFuncs {
/**
* Requests that the driver resize the screen.
*
* The driver is responsible for updating scrn->virtualX and scrn->virtualY.
* If the requested size cannot be set, the driver should leave those values
* alone and return FALSE.
*
* A naive driver that cannot reallocate the screen may simply change
* virtual[XY]. A more advanced driver will want to also change the
* devPrivate.ptr and devKind of the screen pixmap, update any offscreen
* pixmaps it may have moved, and change pScrn->displayWidth.
*/
typedef struct _xf86CrtcConfig {
int num_output;
/**
* compat_output is used whenever we deal
* with legacy code that only understands a single
* output. pScrn->modes will be loaded from this output,
* adjust frame will whack this output, etc.
*/
int compat_output;
int num_crtc;
/* For crtc-based rotation */
/* DGA */
unsigned int dga_flags;
unsigned long dga_address;
int dga_nmode;
const xf86CrtcConfigFuncsRec *funcs;
/* Cursor information */
/**
* Options parsed from the related device section
*/
/* wrap screen BlockHandler for rotation */
/* callback when crtc configuration changes */
char *name;
const xf86ProviderFuncsRec *provider_funcs;
#ifdef RANDR_12_INTERFACE
#else
void *randr_provider;
#endif
extern _X_EXPORT int xf86CrtcConfigPrivateIndex;
#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
static _X_INLINE xf86OutputPtr
{
}
static _X_INLINE xf86CrtcPtr
{
if (!compat_output)
return NULL;
return compat_output->crtc;
}
{
if (!compat_crtc)
return NULL;
return compat_crtc->randr_crtc;
}
/*
* Initialize xf86CrtcConfig structure
*/
extern _X_EXPORT void
extern _X_EXPORT void
/*
* Crtc functions
*/
extern _X_EXPORT xf86CrtcPtr
extern _X_EXPORT void
/**
* Sets the given video mode on the given crtc
*/
int y);
int x, int y);
extern _X_EXPORT void
/*
* Assign crtc rotation during mode set
*/
/*
* Clean up any rotation data, used when a crtc is turned off
* as well as when rotation is disabled.
*/
extern _X_EXPORT void
/*
* free shadow memory allocated for all crtcs
*/
extern _X_EXPORT void
/*
* Clean up rotation during CloseScreen
*/
extern _X_EXPORT void
/**
* Return whether any output is assigned to the crtc
*/
/*
* Output functions
*/
extern _X_EXPORT xf86OutputPtr
extern _X_EXPORT void
extern _X_EXPORT void
extern _X_EXPORT void
extern _X_EXPORT void
#ifdef RANDR_13_INTERFACE
#define ScreenInitRetType int
#else
#define ScreenInitRetType Bool
#endif
extern _X_EXPORT void
extern _X_EXPORT void
extern _X_EXPORT DisplayModePtr
/**
* Set the EDID information for the specified output
*/
extern _X_EXPORT void
/**
* Return the list of modes supported by the EDID information
* stored in 'output'
*/
extern _X_EXPORT xf86MonPtr
/**
* Initialize dga for this screen
*/
#ifdef XFreeXDGA
/* this is the real function, used only internally */
/**
* Re-initialize dga for this screen (as when the set of modes changes)
*/
#endif
/* This is the real function, used only internally */
/*
* Set the subpixel order reported for the screen using
* the information from the outputs
*/
extern _X_EXPORT void
/*
* Get a standard string name for a connector type
*/
/*
* Using the desired mode information in each crtc, set
* modes (used in EnterVT functions, or at server startup)
*/
/**
* Initialize the CRTC-based cursor code. CRTC function vectors must
* contain relevant cursor setting functions.
*
* Driver should call this from ScreenInit function
*/
/**
* Called when anything on the screen is reconfigured.
*
* Reloads cursor images as needed, then adjusts cursor positions.
*
* Driver should call this from crtc commit function.
*/
extern _X_EXPORT void
/**
* Called from EnterVT to turn the cursors back on
*/
extern _X_EXPORT void
/**
* Called by the driver to turn cursors off
*/
extern _X_EXPORT void
/**
* Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
*/
extern _X_EXPORT void
/**
* Transform the cursor's coordinates based on the crtc transform. Normally
* this is done by the server, but if crtc->driverIsPerformingTransform is TRUE,
* then the server does not transform the cursor position automatically.
*/
extern _X_EXPORT void
#ifdef XV
/*
* For overlay video, compute the relevant CRTC and
* clip video to that.
* wraps xf86XVClipVideoHelper()
*/
#endif
extern _X_EXPORT void
extern _X_EXPORT void
/**
* Gamma
*/
extern _X_EXPORT void
extern _X_EXPORT void
#endif /* _XF86CRTC_H_ */