VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.3.0.0/xf86Crtc.h@ 32915

Last change on this file since 32915 was 25078, checked in by vboxsync, 15 years ago

Additions/x11/x11include: exported and set eol-style on new headers

  • Property svn:eol-style set to native
File size: 17.5 KB
Line 
1/*
2 * Copyright © 2006 Keith Packard
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 * OF THIS SOFTWARE.
21 */
22#ifndef _XF86CRTC_H_
23#define _XF86CRTC_H_
24
25#include <edid.h>
26#include "randrstr.h"
27#if XF86_MODES_RENAME
28#include "xf86Rename.h"
29#endif
30#include "xf86Modes.h"
31#include "xf86Cursor.h"
32#include "damage.h"
33
34/* Compat definitions for older X Servers. */
35#ifndef M_T_PREFERRED
36#define M_T_PREFERRED 0x08
37#endif
38#ifndef M_T_DRIVER
39#define M_T_DRIVER 0x40
40#endif
41#ifndef HARDWARE_CURSOR_ARGB
42#define HARDWARE_CURSOR_ARGB 0x00004000
43#endif
44
45typedef struct _xf86Crtc xf86CrtcRec, *xf86CrtcPtr;
46typedef struct _xf86Output xf86OutputRec, *xf86OutputPtr;
47
48/* define a standard for connector types */
49typedef enum _xf86ConnectorType {
50 XF86ConnectorNone,
51 XF86ConnectorVGA,
52 XF86ConnectorDVI_I,
53 XF86ConnectorDVI_D,
54 XF86ConnectorDVI_A,
55 XF86ConnectorComposite,
56 XF86ConnectorSvideo,
57 XF86ConnectorComponent,
58 XF86ConnectorLFP,
59 XF86ConnectorProprietary,
60} xf86ConnectorType;
61
62typedef enum _xf86OutputStatus {
63 XF86OutputStatusConnected,
64 XF86OutputStatusDisconnected,
65 XF86OutputStatusUnknown,
66} xf86OutputStatus;
67
68typedef struct _xf86CrtcFuncs {
69 /**
70 * Turns the crtc on/off, or sets intermediate power levels if available.
71 *
72 * Unsupported intermediate modes drop to the lower power setting. If the
73 * mode is DPMSModeOff, the crtc must be disabled sufficiently for it to
74 * be safe to call mode_set.
75 */
76 void
77 (*dpms)(xf86CrtcPtr crtc,
78 int mode);
79
80 /**
81 * Saves the crtc's state for restoration on VT switch.
82 */
83 void
84 (*save)(xf86CrtcPtr crtc);
85
86 /**
87 * Restore's the crtc's state at VT switch.
88 */
89 void
90 (*restore)(xf86CrtcPtr crtc);
91
92 /**
93 * Lock CRTC prior to mode setting, mostly for DRI.
94 * Returns whether unlock is needed
95 */
96 Bool
97 (*lock) (xf86CrtcPtr crtc);
98
99 /**
100 * Unlock CRTC after mode setting, mostly for DRI
101 */
102 void
103 (*unlock) (xf86CrtcPtr crtc);
104
105 /**
106 * Callback to adjust the mode to be set in the CRTC.
107 *
108 * This allows a CRTC to adjust the clock or even the entire set of
109 * timings, which is used for panels with fixed timings or for
110 * buses with clock limitations.
111 */
112 Bool
113 (*mode_fixup)(xf86CrtcPtr crtc,
114 DisplayModePtr mode,
115 DisplayModePtr adjusted_mode);
116
117 /**
118 * Prepare CRTC for an upcoming mode set.
119 */
120 void
121 (*prepare)(xf86CrtcPtr crtc);
122
123 /**
124 * Callback for setting up a video mode after fixups have been made.
125 */
126 void
127 (*mode_set)(xf86CrtcPtr crtc,
128 DisplayModePtr mode,
129 DisplayModePtr adjusted_mode,
130 int x, int y);
131
132 /**
133 * Commit mode changes to a CRTC
134 */
135 void
136 (*commit)(xf86CrtcPtr crtc);
137
138 /* Set the color ramps for the CRTC to the given values. */
139 void
140 (*gamma_set)(xf86CrtcPtr crtc, CARD16 *red, CARD16 *green, CARD16 *blue,
141 int size);
142
143 /**
144 * Allocate the shadow area, delay the pixmap creation until needed
145 */
146 void *
147 (*shadow_allocate) (xf86CrtcPtr crtc, int width, int height);
148
149 /**
150 * Create shadow pixmap for rotation support
151 */
152 PixmapPtr
153 (*shadow_create) (xf86CrtcPtr crtc, void *data, int width, int height);
154
155 /**
156 * Destroy shadow pixmap
157 */
158 void
159 (*shadow_destroy) (xf86CrtcPtr crtc, PixmapPtr pPixmap, void *data);
160
161 /**
162 * Set cursor colors
163 */
164 void
165 (*set_cursor_colors) (xf86CrtcPtr crtc, int bg, int fg);
166
167 /**
168 * Set cursor position
169 */
170 void
171 (*set_cursor_position) (xf86CrtcPtr crtc, int x, int y);
172
173 /**
174 * Show cursor
175 */
176 void
177 (*show_cursor) (xf86CrtcPtr crtc);
178
179 /**
180 * Hide cursor
181 */
182 void
183 (*hide_cursor) (xf86CrtcPtr crtc);
184
185 /**
186 * Load monochrome image
187 */
188 void
189 (*load_cursor_image) (xf86CrtcPtr crtc, CARD8 *image);
190
191 /**
192 * Load ARGB image
193 */
194 void
195 (*load_cursor_argb) (xf86CrtcPtr crtc, CARD32 *image);
196
197 /**
198 * Clean up driver-specific bits of the crtc
199 */
200 void
201 (*destroy) (xf86CrtcPtr crtc);
202} xf86CrtcFuncsRec, *xf86CrtcFuncsPtr;
203
204struct _xf86Crtc {
205 /**
206 * Associated ScrnInfo
207 */
208 ScrnInfoPtr scrn;
209
210 /**
211 * Active state of this CRTC
212 *
213 * Set when this CRTC is driving one or more outputs
214 */
215 Bool enabled;
216
217 /**
218 * Active mode
219 *
220 * This reflects the mode as set in the CRTC currently
221 * It will be cleared when the VT is not active or
222 * during server startup
223 */
224 DisplayModeRec mode;
225 Rotation rotation;
226 PixmapPtr rotatedPixmap;
227 void *rotatedData;
228
229 /**
230 * Position on screen
231 *
232 * Locates this CRTC within the frame buffer
233 */
234 int x, y;
235
236 /**
237 * Desired mode
238 *
239 * This is set to the requested mode, independent of
240 * whether the VT is active. In particular, it receives
241 * the startup configured mode and saves the active mode
242 * on VT switch.
243 */
244 DisplayModeRec desiredMode;
245 Rotation desiredRotation;
246 int desiredX, desiredY;
247
248 /** crtc-specific functions */
249 const xf86CrtcFuncsRec *funcs;
250
251 /**
252 * Driver private
253 *
254 * Holds driver-private information
255 */
256 void *driver_private;
257
258#ifdef RANDR_12_INTERFACE
259 /**
260 * RandR crtc
261 *
262 * When RandR 1.2 is available, this
263 * points at the associated crtc object
264 */
265 RRCrtcPtr randr_crtc;
266#else
267 void *randr_crtc;
268#endif
269
270 /**
271 * Current cursor is ARGB
272 */
273 Bool cursor_argb;
274 /**
275 * Track whether cursor is within CRTC range
276 */
277 Bool cursor_in_range;
278 /**
279 * Track state of cursor associated with this CRTC
280 */
281 Bool cursor_shown;
282};
283
284typedef struct _xf86OutputFuncs {
285 /**
286 * Called to allow the output a chance to create properties after the
287 * RandR objects have been created.
288 */
289 void
290 (*create_resources)(xf86OutputPtr output);
291
292 /**
293 * Turns the output on/off, or sets intermediate power levels if available.
294 *
295 * Unsupported intermediate modes drop to the lower power setting. If the
296 * mode is DPMSModeOff, the output must be disabled, as the DPLL may be
297 * disabled afterwards.
298 */
299 void
300 (*dpms)(xf86OutputPtr output,
301 int mode);
302
303 /**
304 * Saves the output's state for restoration on VT switch.
305 */
306 void
307 (*save)(xf86OutputPtr output);
308
309 /**
310 * Restore's the output's state at VT switch.
311 */
312 void
313 (*restore)(xf86OutputPtr output);
314
315 /**
316 * Callback for testing a video mode for a given output.
317 *
318 * This function should only check for cases where a mode can't be supported
319 * on the output specifically, and not represent generic CRTC limitations.
320 *
321 * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
322 */
323 int
324 (*mode_valid)(xf86OutputPtr output,
325 DisplayModePtr pMode);
326
327 /**
328 * Callback to adjust the mode to be set in the CRTC.
329 *
330 * This allows an output to adjust the clock or even the entire set of
331 * timings, which is used for panels with fixed timings or for
332 * buses with clock limitations.
333 */
334 Bool
335 (*mode_fixup)(xf86OutputPtr output,
336 DisplayModePtr mode,
337 DisplayModePtr adjusted_mode);
338
339 /**
340 * Callback for preparing mode changes on an output
341 */
342 void
343 (*prepare)(xf86OutputPtr output);
344
345 /**
346 * Callback for committing mode changes on an output
347 */
348 void
349 (*commit)(xf86OutputPtr output);
350
351 /**
352 * Callback for setting up a video mode after fixups have been made.
353 *
354 * This is only called while the output is disabled. The dpms callback
355 * must be all that's necessary for the output, to turn the output on
356 * after this function is called.
357 */
358 void
359 (*mode_set)(xf86OutputPtr output,
360 DisplayModePtr mode,
361 DisplayModePtr adjusted_mode);
362
363 /**
364 * Probe for a connected output, and return detect_status.
365 */
366 xf86OutputStatus
367 (*detect)(xf86OutputPtr output);
368
369 /**
370 * Query the device for the modes it provides.
371 *
372 * This function may also update MonInfo, mm_width, and mm_height.
373 *
374 * \return singly-linked list of modes or NULL if no modes found.
375 */
376 DisplayModePtr
377 (*get_modes)(xf86OutputPtr output);
378
379#ifdef RANDR_12_INTERFACE
380 /**
381 * Callback when an output's property has changed.
382 */
383 Bool
384 (*set_property)(xf86OutputPtr output,
385 Atom property,
386 RRPropertyValuePtr value);
387#endif
388 /**
389 * Clean up driver-specific bits of the output
390 */
391 void
392 (*destroy) (xf86OutputPtr output);
393} xf86OutputFuncsRec, *xf86OutputFuncsPtr;
394
395struct _xf86Output {
396 /**
397 * Associated ScrnInfo
398 */
399 ScrnInfoPtr scrn;
400
401 /**
402 * Currently connected crtc (if any)
403 *
404 * If this output is not in use, this field will be NULL.
405 */
406 xf86CrtcPtr crtc;
407
408 /**
409 * Possible CRTCs for this output as a mask of crtc indices
410 */
411 CARD32 possible_crtcs;
412
413 /**
414 * Possible outputs to share the same CRTC as a mask of output indices
415 */
416 CARD32 possible_clones;
417
418 /**
419 * Whether this output can support interlaced modes
420 */
421 Bool interlaceAllowed;
422
423 /**
424 * Whether this output can support double scan modes
425 */
426 Bool doubleScanAllowed;
427
428 /**
429 * List of available modes on this output.
430 *
431 * This should be the list from get_modes(), plus perhaps additional
432 * compatible modes added later.
433 */
434 DisplayModePtr probed_modes;
435
436 /**
437 * Options parsed from the related monitor section
438 */
439 OptionInfoPtr options;
440
441 /**
442 * Configured monitor section
443 */
444 XF86ConfMonitorPtr conf_monitor;
445
446 /**
447 * Desired initial position
448 */
449 int initial_x, initial_y;
450
451 /**
452 * Desired initial rotation
453 */
454 Rotation initial_rotation;
455
456 /**
457 * Current connection status
458 *
459 * This indicates whether a monitor is known to be connected
460 * to this output or not, or whether there is no way to tell
461 */
462 xf86OutputStatus status;
463
464 /** EDID monitor information */
465 xf86MonPtr MonInfo;
466
467 /** subpixel order */
468 int subpixel_order;
469
470 /** Physical size of the currently attached output device. */
471 int mm_width, mm_height;
472
473 /** Output name */
474 char *name;
475
476 /** output-specific functions */
477 const xf86OutputFuncsRec *funcs;
478
479 /** driver private information */
480 void *driver_private;
481
482 /** Whether to use the old per-screen Monitor config section */
483 Bool use_screen_monitor;
484
485#ifdef RANDR_12_INTERFACE
486 /**
487 * RandR 1.2 output structure.
488 *
489 * When RandR 1.2 is available, this points at the associated
490 * RandR output structure and is created when this output is created
491 */
492 RROutputPtr randr_output;
493#else
494 void *randr_output;
495#endif
496};
497
498typedef struct _xf86CrtcConfigFuncs {
499 /**
500 * Requests that the driver resize the screen.
501 *
502 * The driver is responsible for updating scrn->virtualX and scrn->virtualY.
503 * If the requested size cannot be set, the driver should leave those values
504 * alone and return FALSE.
505 *
506 * A naive driver that cannot reallocate the screen may simply change
507 * virtual[XY]. A more advanced driver will want to also change the
508 * devPrivate.ptr and devKind of the screen pixmap, update any offscreen
509 * pixmaps it may have moved, and change pScrn->displayWidth.
510 */
511 Bool
512 (*resize)(ScrnInfoPtr scrn,
513 int width,
514 int height);
515} xf86CrtcConfigFuncsRec, *xf86CrtcConfigFuncsPtr;
516
517typedef struct _xf86CrtcConfig {
518 int num_output;
519 xf86OutputPtr *output;
520 /**
521 * compat_output is used whenever we deal
522 * with legacy code that only understands a single
523 * output. pScrn->modes will be loaded from this output,
524 * adjust frame will whack this output, etc.
525 */
526 int compat_output;
527
528 int num_crtc;
529 xf86CrtcPtr *crtc;
530
531 int minWidth, minHeight;
532 int maxWidth, maxHeight;
533
534 /* For crtc-based rotation */
535 DamagePtr rotation_damage;
536 Bool rotation_damage_registered;
537
538 /* DGA */
539 unsigned int dga_flags;
540 unsigned long dga_address;
541 DGAModePtr dga_modes;
542 int dga_nmode;
543 int dga_width, dga_height, dga_stride;
544 DisplayModePtr dga_save_mode;
545
546 const xf86CrtcConfigFuncsRec *funcs;
547
548 CreateScreenResourcesProcPtr CreateScreenResources;
549
550 CloseScreenProcPtr CloseScreen;
551
552 /* Cursor information */
553 xf86CursorInfoPtr cursor_info;
554 CursorPtr cursor;
555 CARD8 *cursor_image;
556 Bool cursor_on;
557 CARD32 cursor_fg, cursor_bg;
558} xf86CrtcConfigRec, *xf86CrtcConfigPtr;
559
560extern int xf86CrtcConfigPrivateIndex;
561
562#define XF86_CRTC_CONFIG_PTR(p) ((xf86CrtcConfigPtr) ((p)->privates[xf86CrtcConfigPrivateIndex].ptr))
563
564/*
565 * Initialize xf86CrtcConfig structure
566 */
567
568void
569xf86CrtcConfigInit (ScrnInfoPtr scrn,
570 const xf86CrtcConfigFuncsRec *funcs);
571
572void
573xf86CrtcSetSizeRange (ScrnInfoPtr scrn,
574 int minWidth, int minHeight,
575 int maxWidth, int maxHeight);
576
577/*
578 * Crtc functions
579 */
580xf86CrtcPtr
581xf86CrtcCreate (ScrnInfoPtr scrn,
582 const xf86CrtcFuncsRec *funcs);
583
584void
585xf86CrtcDestroy (xf86CrtcPtr crtc);
586
587
588/**
589 * Sets the given video mode on the given crtc
590 */
591Bool
592xf86CrtcSetMode (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation,
593 int x, int y);
594
595/*
596 * Assign crtc rotation during mode set
597 */
598Bool
599xf86CrtcRotate (xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation);
600
601/*
602 * Clean up rotation during CloseScreen
603 */
604void
605xf86RotateCloseScreen (ScreenPtr pScreen);
606
607/**
608 * Return whether any output is assigned to the crtc
609 */
610Bool
611xf86CrtcInUse (xf86CrtcPtr crtc);
612
613/*
614 * Output functions
615 */
616xf86OutputPtr
617xf86OutputCreate (ScrnInfoPtr scrn,
618 const xf86OutputFuncsRec *funcs,
619 const char *name);
620
621void
622xf86OutputUseScreenMonitor (xf86OutputPtr output, Bool use_screen_monitor);
623
624Bool
625xf86OutputRename (xf86OutputPtr output, const char *name);
626
627void
628xf86OutputDestroy (xf86OutputPtr output);
629
630void
631xf86ProbeOutputModes (ScrnInfoPtr pScrn, int maxX, int maxY);
632
633void
634xf86SetScrnInfoModes (ScrnInfoPtr pScrn);
635
636Bool
637xf86CrtcScreenInit (ScreenPtr pScreen);
638
639Bool
640xf86InitialConfiguration (ScrnInfoPtr pScrn, Bool canGrow);
641
642void
643xf86DPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags);
644
645Bool
646xf86SaveScreen(ScreenPtr pScreen, int mode);
647
648void
649xf86DisableUnusedFunctions(ScrnInfoPtr pScrn);
650
651DisplayModePtr
652xf86OutputFindClosestMode (xf86OutputPtr output, DisplayModePtr desired);
653
654Bool
655xf86SetSingleMode (ScrnInfoPtr pScrn, DisplayModePtr desired, Rotation rotation);
656
657/**
658 * Set the EDID information for the specified output
659 */
660void
661xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon);
662
663/**
664 * Return the list of modes supported by the EDID information
665 * stored in 'output'
666 */
667DisplayModePtr
668xf86OutputGetEDIDModes (xf86OutputPtr output);
669
670xf86MonPtr
671xf86OutputGetEDID (xf86OutputPtr output, I2CBusPtr pDDCBus);
672
673/**
674 * Initialize dga for this screen
675 */
676
677Bool
678xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address);
679
680/**
681 * Re-initialize dga for this screen (as when the set of modes changes)
682 */
683
684Bool
685xf86DiDGAReInit (ScreenPtr pScreen);
686
687/*
688 * Set the subpixel order reported for the screen using
689 * the information from the outputs
690 */
691
692void
693xf86CrtcSetScreenSubpixelOrder (ScreenPtr pScreen);
694
695/*
696 * Get a standard string name for a connector type
697 */
698char *
699xf86ConnectorGetName(xf86ConnectorType connector);
700
701/*
702 * Using the desired mode information in each crtc, set
703 * modes (used in EnterVT functions, or at server startup)
704 */
705
706Bool
707xf86SetDesiredModes (ScrnInfoPtr pScrn);
708
709/**
710 * Initialize the CRTC-based cursor code. CRTC function vectors must
711 * contain relevant cursor setting functions.
712 *
713 * Driver should call this from ScreenInit function
714 */
715Bool
716xf86_cursors_init (ScreenPtr screen, int max_width, int max_height, int flags);
717
718/**
719 * Called when anything on the screen is reconfigured.
720 *
721 * Reloads cursor images as needed, then adjusts cursor positions.
722 *
723 * Driver should call this from crtc commit function.
724 */
725void
726xf86_reload_cursors (ScreenPtr screen);
727
728/**
729 * Called from EnterVT to turn the cursors back on
730 */
731void
732xf86_show_cursors (ScrnInfoPtr scrn);
733
734/**
735 * Called by the driver to turn cursors off
736 */
737void
738xf86_hide_cursors (ScrnInfoPtr scrn);
739
740/**
741 * Clean up CRTC-based cursor code. Driver must call this at CloseScreen time.
742 */
743void
744xf86_cursors_fini (ScreenPtr screen);
745
746#endif /* _XF86CRTC_H_ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette