1*4882a593Smuzhiyun Multi-monitor Mode Setting APIs 2*4882a593Smuzhiyun Keith Packard, <keithp@keithp.com 3*4882a593Smuzhiyun 6 March 2007 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun1. Introduction 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThis document describes a set of mode setting APIs added in X server version 8*4882a593Smuzhiyun1.3 that support multiple monitors per card. These interfaces expose the 9*4882a593Smuzhiyununderlying hardware CRTC and output concepts to the xf86 DDX layer so that 10*4882a593Smuzhiyunthe implementation of initial server setup and mode changes through 11*4882a593Smuzhiyunextensions can be shared across drivers. In addition, these new interfaces 12*4882a593Smuzhiyunsupport a new configuration mechanism as well which allows each monitor to 13*4882a593Smuzhiyunbe customized separately providing a consistent cross-driver configuration 14*4882a593Smuzhiyunmechanism that supports the full range of output features. 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunAll of the code implementing this interface can be found in hw/xfree86/modes 17*4882a593Smuzhiyunin the X server sources. 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun2. Overview 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunThis document describes both the driver API and the configuration data 22*4882a593Smuzhiyunplaced in xorg.conf; these are entirely separate as the driver has no 23*4882a593Smuzhiyuninteraction with the configuration information at all. Much of the structure 24*4882a593Smuzhiyunhere is cloned from the RandR extension version 1.2 additions which deal 25*4882a593Smuzhiyunwith the same kinds of information. 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun2.1 API overview 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunThe mode setting API is expressed through two new driver-visible objects, 30*4882a593Smuzhiyunthe 'CRTC' (xf86CrtcRec) and the 'Output' (xf86OutputRec). A CRTC refers to 31*4882a593Smuzhiyunhardware within the video system that can scan a subset of the framebuffer 32*4882a593Smuzhiyunand generate a video signal. An Output receives that signal and transmits it 33*4882a593Smuzhiyunto a monitor, projector or other device. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunThe xf86CrtcRec and xf86OutputRec contain a small amount of state data 36*4882a593Smuzhiyunrelated to the object along with a pointer to a set of functions provided by 37*4882a593Smuzhiyunthe driver that manipulate the object in fairly simple ways. 38*4882a593Smuzhiyun 39*4882a593SmuzhiyunTo emulate older behaviour, one of the outputs is picked as the 'compat' 40*4882a593Smuzhiyunoutput; this output changes over time as outputs are detected and used, the 41*4882a593Smuzhiyungoal is to always have one 'special' output which is used for operations 42*4882a593Smuzhiyunwhich need a single defined monitor (like XFree86-VidModeExtension mode 43*4882a593Smuzhiyunsetting, RandR 1.1 mode setting, DDC property setting, etc.). 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun2.1.1 Output overview 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunAs outputs are connected to monitors, they hold a list of modes supported by 48*4882a593Smuzhiyunthe monitor. If the monitor and output support DDC, then the list of modes 49*4882a593Smuzhiyungenerally comes from the EDID data in the monitor. Otherwise, the server 50*4882a593Smuzhiyunuses the standard VESA modes, pruned by monitor timing. If the configuration 51*4882a593Smuzhiyunfile doesn't contain monitor timing data, the server uses default timing 52*4882a593Smuzhiyuninformation which supports 640x480, 800x600 and 1024x768 all with a 60Hz 53*4882a593Smuzhiyunrefresh rate. 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunAs hardware often limits possible configuration combinations, each output 56*4882a593Smuzhiyunknows the set of CRTCs that it can be connected to as well as the set of 57*4882a593Smuzhiyunother outputs which can be simutaneously connected to a CRTC. 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun2.1.2 CRTC overview 60*4882a593Smuzhiyun 61*4882a593SmuzhiyunCRTCs serve only to stream frame buffer data to outputs using a mode line. 62*4882a593SmuzhiyunIdeally, they would not be presented to the user at all, and in fact the 63*4882a593Smuzhiyunconfiguration file doesn't expose them. The RandR 1.2 protocol does, but the 64*4882a593Smuzhiyunhope there is that client-side applications will hide them carefully away. 65*4882a593Smuzhiyun 66*4882a593SmuzhiyunEach crtc has an associated cursor, along with the current configuration. 67*4882a593SmuzhiyunAll of the data needed to determine valid configurations is contained within 68*4882a593Smuzhiyunthe Outputs. 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun2.2 Configuration overview 71*4882a593Smuzhiyun 72*4882a593SmuzhiyunAs outputs drive monitors, the "Monitor" section has been repurposed to 73*4882a593Smuzhiyundefine their configuration. This provides for a bit more syntax than 74*4882a593Smuzhiyunthe large list of driver-specific options that were used in the past for 75*4882a593Smuzhiyunsimilar configuration. 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunHowever, the existing "Monitor" section referenced by the active "Screen" 78*4882a593Smuzhiyunsection no longer has any use at all; some sensible meaning for this 79*4882a593Smuzhiyunparameter is needed now that a Screen can have multiple Monitors. 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun3. Public Functions 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun3.1 PreInit functions 84*4882a593Smuzhiyun 85*4882a593SmuzhiyunThese functions should be used during the driver PreInit phase, they are 86*4882a593Smuzhiyunarranged in the order they should be invoked. 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun void 89*4882a593Smuzhiyun xf86CrtcConfigInit (ScrnInfoPtr scrn 90*4882a593Smuzhiyun const xf86CrtcConfigFuncsRec *funcs) 91*4882a593Smuzhiyun 92*4882a593SmuzhiyunThis function allocates and initializes structures needed to track CRTC and 93*4882a593SmuzhiyunOutput state. 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun void 96*4882a593Smuzhiyun xf86CrtcSetSizeRange (ScrnInfoPtr scrn, 97*4882a593Smuzhiyun int minWidth, int minHeight, 98*4882a593Smuzhiyun int maxWidth, int maxHeight) 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunThis sets the range of screen sizes supported by the driver. 101*4882a593Smuzhiyun 102*4882a593Smuzhiyun xf86CrtcPtr 103*4882a593Smuzhiyun xf86CrtcCreate (ScrnInfoPtr scrn, 104*4882a593Smuzhiyun const xf86CrtcFuncsRec *funcs) 105*4882a593Smuzhiyun 106*4882a593SmuzhiyunCreate one CRTC object. See the discussion below for a description of the 107*4882a593Smuzhiyuncontents of the xf86CrtcFuncsRec. Note that this is done in PreInit, so it 108*4882a593Smuzhiyunshould not be re-invoked at each server generation. Create one of these for 109*4882a593Smuzhiyuneach CRTC present in the hardware. 110*4882a593Smuzhiyun 111*4882a593Smuzhiyun xf86OutputPtr 112*4882a593Smuzhiyun xf86OutputCreate (ScrnInfoPtr scrn, 113*4882a593Smuzhiyun const xf86OutputFuncsRec *funcs, 114*4882a593Smuzhiyun const char *name) 115*4882a593Smuzhiyun 116*4882a593SmuzhiyunCreate one Output object. See the discussion below for a description of the 117*4882a593Smuzhiyuncontents of the xf86OutputFuncsRec. This is also called from PreInit and 118*4882a593Smuzhiyunneed not be re-invoked at each ScreenInit time. An Output should be created 119*4882a593Smuzhiyunfor every Output present in the hardware, not just for outputs which have 120*4882a593Smuzhiyundetected monitors. 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun Bool 123*4882a593Smuzhiyun xf86OutputRename (xf86OutputPtr output, const char *name) 124*4882a593Smuzhiyun 125*4882a593SmuzhiyunIf necessary, the name of an output can be changed after it is created using 126*4882a593Smuzhiyunthis function. 127*4882a593Smuzhiyun 128*4882a593Smuzhiyun Bool 129*4882a593Smuzhiyun xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow) 130*4882a593Smuzhiyun 131*4882a593SmuzhiyunUsing the resources provided, and the configuration specified by the user, 132*4882a593Smuzhiyunthis function computes an initial configuration for the server. It tries to 133*4882a593Smuzhiyunenable as much hardware as possible using some fairly simple heuristics. 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunThe 'canGrow' parameter indicates that the frame buffer does not have a fixed 136*4882a593Smuzhiyunsize. When the frame buffer has a fixed size, the configuration selects a 137*4882a593Smuzhiyun'reasonablely large' frame buffer so that common reconfiguration options are 138*4882a593Smuzhiyunpossible. For resizable frame buffers, the frame buffer is set to the smallest 139*4882a593Smuzhiyunsize that encloses the desired configuration. 140*4882a593Smuzhiyun 141*4882a593Smuzhiyun3.2 ScreenInit functions 142*4882a593Smuzhiyun 143*4882a593SmuzhiyunThese functions should be used during the driver ScreenInit phase. 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun Bool 146*4882a593Smuzhiyun xf86DiDGAInit (ScreenPtr screen, unsigned long dga_address) 147*4882a593Smuzhiyun 148*4882a593SmuzhiyunThis function provides driver-independent accelerated DGA support for some 149*4882a593Smuzhiyunof the DGA operations; using this, the driver can avoid needing to implement 150*4882a593Smuzhiyunany of the rest of DGA. 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun Bool 153*4882a593Smuzhiyun xf86SaveScreen(ScreenPtr pScreen, int mode) 154*4882a593Smuzhiyun 155*4882a593SmuzhiyunStick this in pScreen->SaveScreen and the core X screen saver will be 156*4882a593Smuzhiyunimplemented by disabling outputs and crtcs using their dpms functions. 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun void 159*4882a593Smuzhiyun xf86DPMSSet(ScrnInfoPtr scrn, int mode, int flags) 160*4882a593Smuzhiyun 161*4882a593SmuzhiyunPass this function to xf86DPMSInit and all DPMS mode switching will be 162*4882a593Smuzhiyunmanaged by using the dpms functions provided by the Outputs and CRTCs. 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun Bool 165*4882a593Smuzhiyun xf86CrtcScreenInit (ScreenPtr screen) 166*4882a593Smuzhiyun 167*4882a593SmuzhiyunThis function completes the screen initialization process for the crtc and 168*4882a593Smuzhiyunoutput objects. Call it near the end of the ScreenInit function, after the 169*4882a593Smuzhiyunframe buffer and acceleration layers have been added. 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun3.3 EnterVT functions 172*4882a593Smuzhiyun 173*4882a593SmuzhiyunFunctions used during EnterVT, or whenever the current configuration needs 174*4882a593Smuzhiyunto be applied to the hardware. 175*4882a593Smuzhiyun 176*4882a593Smuzhiyun Bool 177*4882a593Smuzhiyun xf86SetDesiredModes (ScrnInfoPtr scrn) 178*4882a593Smuzhiyun 179*4882a593Smuzhiyunxf86InitialConfiguration selects the desired configuration at PreInit time; 180*4882a593Smuzhiyunwhen the server finally hits ScreenInit, xf86SetDesiredModes is used by the 181*4882a593Smuzhiyundriver to take that configuration and apply it to the hardware. In addition, 182*4882a593Smuzhiyunsuccessful mode selection at other times updates the configuration that will 183*4882a593Smuzhiyunbe used by this function, so LeaveVT/EnterVT pairs can simply invoke this 184*4882a593Smuzhiyunand return to the previous configuration. 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun3.4 SwitchMode functions 187*4882a593Smuzhiyun 188*4882a593SmuzhiyunFunctions called from the pScrn->SwitchMode hook, which is used by the 189*4882a593SmuzhiyunXFree86-VidModeExtension and the keypad mode switch commands. 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun Bool 192*4882a593Smuzhiyun xf86SetSingleMode (ScrnInfoPtr scrn, 193*4882a593Smuzhiyun DisplayModePtr desired, 194*4882a593Smuzhiyun Rotation rotation) 195*4882a593Smuzhiyun 196*4882a593SmuzhiyunThis function applies the specified mode to all active outputs. Which is to 197*4882a593Smuzhiyunsay, it picks reasonable modes for all active outputs, attempting to get the 198*4882a593Smuzhiyunscreen to the specified size while not breaking anything that is currently 199*4882a593Smuzhiyunworking. 200*4882a593Smuzhiyun 201*4882a593Smuzhiyun3.7 get_modes functions 202*4882a593Smuzhiyun 203*4882a593SmuzhiyunFunctions called during output->get_modes to help build lists of modes 204*4882a593Smuzhiyun 205*4882a593Smuzhiyun xf86MonPtr 206*4882a593Smuzhiyun xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus) 207*4882a593Smuzhiyun 208*4882a593SmuzhiyunThis returns the EDID data structure for the 'output' using the I2C bus 209*4882a593Smuzhiyun'pDDCBus'. This has no effect on 'output' itself. 210*4882a593Smuzhiyun 211*4882a593Smuzhiyun void 212*4882a593Smuzhiyun xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon) 213*4882a593Smuzhiyun 214*4882a593SmuzhiyunOnce the EDID data has been fetched, this call applies the EDID data to the 215*4882a593Smuzhiyunoutput object, setting the physical size and also various properties, like 216*4882a593Smuzhiyunthe DDC root window property (when output is the 'compat' output), and the 217*4882a593SmuzhiyunRandR 1.2 EDID output properties. 218*4882a593Smuzhiyun 219*4882a593Smuzhiyun DisplayModePtr 220*4882a593Smuzhiyun xf86OutputGetEDIDModes (xf86OutputPtr output) 221*4882a593Smuzhiyun 222*4882a593SmuzhiyunGiven an EDID data structure, this function computes a list of suitable 223*4882a593Smuzhiyunmodes. This function also applies a sequence of 'quirks' during this process 224*4882a593Smuzhiyunso that the returned modes may not actually match the mode data present in 225*4882a593Smuzhiyunthe EDID data. 226*4882a593Smuzhiyun 227*4882a593Smuzhiyun3.6 Other functions 228*4882a593Smuzhiyun 229*4882a593SmuzhiyunThese remaining functions in the API can be used by the driver as needed. 230*4882a593Smuzhiyun 231*4882a593Smuzhiyun Bool 232*4882a593Smuzhiyun xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, 233*4882a593Smuzhiyun int x, int y) 234*4882a593Smuzhiyun 235*4882a593SmuzhiyunApplies a mode to a CRTC. All of the outputs which are currently using the 236*4882a593Smuzhiyunspecified CRTC are included in the mode setting process. 'x' and 'y' are the 237*4882a593Smuzhiyunoffset within the frame buffer that the crtc is placed at. No checking is 238*4882a593Smuzhiyundone in this function to ensure that the mode is usable by the active 239*4882a593Smuzhiyunoutputs. 240*4882a593Smuzhiyun 241*4882a593Smuzhiyun void 242*4882a593Smuzhiyun xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY) 243*4882a593Smuzhiyun 244*4882a593SmuzhiyunThis discards the mode lists for all outputs, re-detects monitor presence 245*4882a593Smuzhiyunand then acquires new mode lists for all monitors which are not disconnected. 246*4882a593SmuzhiyunMonitor configuration data is used to modify the mode lists returned by the 247*4882a593Smuzhiyunoutputs. 'maxX' and 'maxY' limit the maximum size modes that will be 248*4882a593Smuzhiyunreturned. 249*4882a593Smuzhiyun 250*4882a593Smuzhiyun void 251*4882a593Smuzhiyun xf86SetScrnInfoModes (ScrnInfoPtr pScrn) 252*4882a593Smuzhiyun 253*4882a593SmuzhiyunThis copies the 'compat' output mode list into the pScrn modes list which is 254*4882a593Smuzhiyunused by the XFree86-VidModeExtension and the keypad mode switching 255*4882a593Smuzhiyunoperations. The current 'desired' mode for the CRTC associated with the 256*4882a593Smuzhiyun'compat' output is placed first in this list to indicate the current mode. 257*4882a593SmuzhiyunUsually, the driver won't need to call this function as 258*4882a593Smuzhiyunxf86InitialConfiguration will do so automatically, as well as any RandR 259*4882a593Smuzhiyunfunctions which reprobe for modes. However, if the driver reprobes for modes 260*4882a593Smuzhiyunat other times using xf86ProbeOutputModes, this function needs to be called. 261*4882a593Smuzhiyun 262*4882a593Smuzhiyun Bool 263*4882a593Smuzhiyun xf86DiDGAReInit (ScreenPtr pScreen) 264*4882a593Smuzhiyun 265*4882a593SmuzhiyunThis is similar to xf86SetScrnInfoModes, but it applies the 'compat' output 266*4882a593Smuzhiyunmode list to the set of modes advertised by the DGA extension; it needs to 267*4882a593Smuzhiyunbe called whenever xf86ProbeOutputModes is invoked. 268*4882a593Smuzhiyun 269*4882a593Smuzhiyun void 270*4882a593Smuzhiyun xf86DisableUnusedFunctions(ScrnInfoPtr pScrn) 271*4882a593Smuzhiyun 272*4882a593SmuzhiyunAfter any sequence of calls using xf86CrtcSetMode, this function cleans up 273*4882a593Smuzhiyunany leftover Output and CRTC objects by disabling them, saving power. It is 274*4882a593Smuzhiyunsafe to call this whenever the server is running as it only disables objects 275*4882a593Smuzhiyunwhich are not currently in use. 276*4882a593Smuzhiyun 277*4882a593Smuzhiyun4. CRTC operations 278*4882a593Smuzhiyun 279*4882a593Smuzhiyun4.1 CRTC functions 280*4882a593Smuzhiyun 281*4882a593SmuzhiyunThese functions provide an abstract interface for the CRTC object; most 282*4882a593Smuzhiyunmanipulation of the CRTC object is done through these functions. 283*4882a593Smuzhiyun 284*4882a593Smuzhiyun void 285*4882a593Smuzhiyun crtc->funcs->dpms (xf86CrtcPtr crtc, int mode) 286*4882a593Smuzhiyun 287*4882a593SmuzhiyunWhere 'mode' is one of DPMSModeOff, DPMSModeSuspend, DPMSModeStandby or 288*4882a593SmuzhiyunDPMSModeOn. This requests that the crtc go to the specified power state. 289*4882a593SmuzhiyunWhen changing power states, the output dpms functions are invoked before the 290*4882a593Smuzhiyuncrtc dpms functions. 291*4882a593Smuzhiyun 292*4882a593Smuzhiyun void 293*4882a593Smuzhiyun crtc->funcs->save (xf86CrtcPtr crtc) 294*4882a593Smuzhiyun 295*4882a593Smuzhiyun void 296*4882a593Smuzhiyun crtc->funcs->restore (xf86CrtcPtr crtc) 297*4882a593Smuzhiyun 298*4882a593SmuzhiyunPreserve/restore any register contents related to the CRTC. These are 299*4882a593Smuzhiyunstrictly a convenience for the driver writer; if the existing driver has 300*4882a593Smuzhiyunfully operation save/restore functions, you need not place any additional 301*4882a593Smuzhiyuncode here. In particular, the server itself never uses this function. 302*4882a593Smuzhiyun 303*4882a593Smuzhiyun Bool 304*4882a593Smuzhiyun crtc->funcs->lock (xf86CrtcPtr crtc) 305*4882a593Smuzhiyun 306*4882a593Smuzhiyun void 307*4882a593Smuzhiyun crtc->funcs->unlock (xf86CrtcPtr crtc) 308*4882a593Smuzhiyun 309*4882a593SmuzhiyunThese functions are invoked around mode setting operations; the intent is 310*4882a593Smuzhiyunthat DRI locking be done here to prevent DRI applications from manipulating 311*4882a593Smuzhiyunthe hardware while the server is busy changing the output configuration. If 312*4882a593Smuzhiyunthe lock function returns FALSE, the unlock function will not be invoked. 313*4882a593Smuzhiyun 314*4882a593Smuzhiyun Bool 315*4882a593Smuzhiyun crtc->funcs->mode_fixup (xf86CrtcPtr crtc, 316*4882a593Smuzhiyun DisplayModePtr mode, 317*4882a593Smuzhiyun DisplayModePtr adjusted_mode) 318*4882a593Smuzhiyun 319*4882a593SmuzhiyunThis call gives the CRTC a chance to see what mode will be set and to 320*4882a593Smuzhiyuncomment on the mode by changing 'adjusted_mode' as needed. This function 321*4882a593Smuzhiyunshall not modify the state of the crtc hardware at all. If the CRTC cannot 322*4882a593Smuzhiyunaccept this mode, this function may return FALSE. 323*4882a593Smuzhiyun 324*4882a593Smuzhiyun void 325*4882a593Smuzhiyun crtc->funcs->prepare (xf86CrtcPtr crtc) 326*4882a593Smuzhiyun 327*4882a593SmuzhiyunThis call is made just before the mode is set to make the hardware ready for 328*4882a593Smuzhiyunthe operation. A usual function to perform here is to disable the crtc so 329*4882a593Smuzhiyunthat mode setting can occur with clocks turned off and outputs deactivated. 330*4882a593Smuzhiyun 331*4882a593Smuzhiyun void 332*4882a593Smuzhiyun crtc->funcs->mode_set (xf86CrtcPtr crtc, 333*4882a593Smuzhiyun DisplayModePtr mode, 334*4882a593Smuzhiyun DisplayModePtr adjusted_mode) 335*4882a593Smuzhiyun 336*4882a593SmuzhiyunThis function applies the specified mode (possibly adjusted by the CRTC 337*4882a593Smuzhiyunand/or Outputs). 338*4882a593Smuzhiyun 339*4882a593Smuzhiyun void 340*4882a593Smuzhiyun crtc->funcs->commit (xf86CrtcPtr crtc) 341*4882a593Smuzhiyun 342*4882a593SmuzhiyunOnce the mode has been applied to the CRTC and Outputs, this function is 343*4882a593Smuzhiyuninvoked to let the hardware turn things back on. 344*4882a593Smuzhiyun 345*4882a593Smuzhiyun void 346*4882a593Smuzhiyun crtc->funcs->gamma_set (xf86CrtcPtr crtc, CARD16 *red, 347*4882a593Smuzhiyun CARD16 *green, CARD16 *blue, int size) 348*4882a593Smuzhiyun 349*4882a593SmuzhiyunThis function adjusts the gamma ramps for the specified crtc. 350*4882a593Smuzhiyun 351*4882a593Smuzhiyun void * 352*4882a593Smuzhiyun crtc->funcs->shadow_allocate (xf86CrtcPtr crtc, int width, int height) 353*4882a593Smuzhiyun 354*4882a593SmuzhiyunThis function allocates frame buffer space for a shadow frame buffer. When 355*4882a593Smuzhiyunallocated, the crtc must scan from the shadow instead of the main frame 356*4882a593Smuzhiyunbuffer. This is used for rotation. The address returned is passed to the 357*4882a593Smuzhiyunshadow_create function. This function should return NULL on failure. 358*4882a593Smuzhiyun 359*4882a593Smuzhiyun PixmapPtr 360*4882a593Smuzhiyun crtc->funcs->shadow_create (xf86CrtcPtr crtc, void *data, 361*4882a593Smuzhiyun int width, int height) 362*4882a593Smuzhiyun 363*4882a593SmuzhiyunThis function creates a pixmap object that will be used as a shadow of the 364*4882a593Smuzhiyunmain frame buffer for CRTCs which are rotated or reflected. 'data' is the 365*4882a593Smuzhiyunvalue returned by shadow_allocate. 366*4882a593Smuzhiyun 367*4882a593Smuzhiyun void 368*4882a593Smuzhiyun crtc->funcs->shadow_destroy (xf86CrtcPtr crtc, PixmapPtr pPixmap, 369*4882a593Smuzhiyun void *data) 370*4882a593Smuzhiyun 371*4882a593SmuzhiyunDestroys any associated shadow objects. If pPixmap is NULL, then a pixmap 372*4882a593Smuzhiyunwas not created, but 'data' may still be non-NULL indicating that the shadow 373*4882a593Smuzhiyunhad been allocated. 374*4882a593Smuzhiyun 375*4882a593Smuzhiyun void 376*4882a593Smuzhiyun crtc->funcs->destroy (xf86CrtcPtr crtc) 377*4882a593Smuzhiyun 378*4882a593SmuzhiyunWhen a CRTC is destroyed (which only happens in error cases), this function 379*4882a593Smuzhiyuncan clean up any driver-specific data. 380*4882a593Smuzhiyun 381*4882a593Smuzhiyun4.2 CRTC fields 382*4882a593Smuzhiyun 383*4882a593SmuzhiyunThe CRTC object is not opaque; there are several fields of interest to the 384*4882a593Smuzhiyundriver writer. 385*4882a593Smuzhiyun 386*4882a593Smuzhiyun struct _xf86Crtc { 387*4882a593Smuzhiyun /** 388*4882a593Smuzhiyun * Associated ScrnInfo 389*4882a593Smuzhiyun */ 390*4882a593Smuzhiyun ScrnInfoPtr scrn; 391*4882a593Smuzhiyun 392*4882a593Smuzhiyun /** 393*4882a593Smuzhiyun * Active state of this CRTC 394*4882a593Smuzhiyun * 395*4882a593Smuzhiyun * Set when this CRTC is driving one or more outputs 396*4882a593Smuzhiyun */ 397*4882a593Smuzhiyun Bool enabled; 398*4882a593Smuzhiyun 399*4882a593Smuzhiyun /** Track whether cursor is within CRTC range */ 400*4882a593Smuzhiyun Bool cursorInRange; 401*4882a593Smuzhiyun 402*4882a593Smuzhiyun /** Track state of cursor associated with this CRTC */ 403*4882a593Smuzhiyun Bool cursorShown; 404*4882a593Smuzhiyun 405*4882a593Smuzhiyun /** 406*4882a593Smuzhiyun * Active mode 407*4882a593Smuzhiyun * 408*4882a593Smuzhiyun * This reflects the mode as set in the CRTC currently 409*4882a593Smuzhiyun * It will be cleared when the VT is not active or 410*4882a593Smuzhiyun * during server startup 411*4882a593Smuzhiyun */ 412*4882a593Smuzhiyun DisplayModeRec mode; 413*4882a593Smuzhiyun Rotation rotation; 414*4882a593Smuzhiyun PixmapPtr rotatedPixmap; 415*4882a593Smuzhiyun void *rotatedData; 416*4882a593Smuzhiyun 417*4882a593Smuzhiyun /** 418*4882a593Smuzhiyun * Position on screen 419*4882a593Smuzhiyun * 420*4882a593Smuzhiyun * Locates this CRTC within the frame buffer 421*4882a593Smuzhiyun */ 422*4882a593Smuzhiyun int x, y; 423*4882a593Smuzhiyun 424*4882a593Smuzhiyun /** 425*4882a593Smuzhiyun * Desired mode 426*4882a593Smuzhiyun * 427*4882a593Smuzhiyun * This is set to the requested mode, independent of 428*4882a593Smuzhiyun * whether the VT is active. In particular, it receives 429*4882a593Smuzhiyun * the startup configured mode and saves the active mode 430*4882a593Smuzhiyun * on VT switch. 431*4882a593Smuzhiyun */ 432*4882a593Smuzhiyun DisplayModeRec desiredMode; 433*4882a593Smuzhiyun Rotation desiredRotation; 434*4882a593Smuzhiyun int desiredX, desiredY; 435*4882a593Smuzhiyun 436*4882a593Smuzhiyun /** crtc-specific functions */ 437*4882a593Smuzhiyun const xf86CrtcFuncsRec *funcs; 438*4882a593Smuzhiyun 439*4882a593Smuzhiyun /** 440*4882a593Smuzhiyun * Driver private 441*4882a593Smuzhiyun * 442*4882a593Smuzhiyun * Holds driver-private information 443*4882a593Smuzhiyun */ 444*4882a593Smuzhiyun void *driver_private; 445*4882a593Smuzhiyun #ifdef RANDR_12_INTERFACE 446*4882a593Smuzhiyun /** 447*4882a593Smuzhiyun * RandR crtc 448*4882a593Smuzhiyun * 449*4882a593Smuzhiyun * When RandR 1.2 is available, this 450*4882a593Smuzhiyun * points at the associated crtc object 451*4882a593Smuzhiyun */ 452*4882a593Smuzhiyun RRCrtcPtr randr_crtc; 453*4882a593Smuzhiyun #else 454*4882a593Smuzhiyun void *randr_crtc; 455*4882a593Smuzhiyun #endif 456*4882a593Smuzhiyun }; 457*4882a593Smuzhiyun 458*4882a593Smuzhiyun 459*4882a593Smuzhiyun5. Output functions. 460*4882a593Smuzhiyun 461*4882a593Smuzhiyun6. Configuration 462*4882a593Smuzhiyun 463*4882a593SmuzhiyunBecause the configuration file syntax is fixed, 464*4882a593Smuzhiyunthis was done by creating new "Driver" section options that hook specific 465*4882a593Smuzhiyunoutputs to specific "Monitor" sections in the file. The option: 466*4882a593Smuzhiyunsection of the form: 467*4882a593Smuzhiyun 468*4882a593Smuzhiyun Option "monitor-VGA" "My VGA Monitor" 469*4882a593Smuzhiyun 470*4882a593Smuzhiyunconnects the VGA output of this driver to the "Monitor" section with 471*4882a593SmuzhiyunIdentifier "My VGA Monitor". All of the usual monitor options can now be 472*4882a593Smuzhiyunplaced in that "Monitor" section and will be applied to the VGA output 473*4882a593Smuzhiyunconfiguration. 474