VirtualBox

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

Last change on this file since 99743 was 17471, checked in by vboxsync, 16 years ago

export to OSE

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