1 | /*
|
---|
2 | * Copyright © 2007 Red Hat, Inc.
|
---|
3 | *
|
---|
4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
5 | * copy of this software and associated documentation files (the "Software"),
|
---|
6 | * to deal in the Software without restriction, including without limitation
|
---|
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
8 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
9 | * Software is furnished to do so, subject to the following conditions:
|
---|
10 | *
|
---|
11 | * The above copyright notice and this permission notice (including the next
|
---|
12 | * paragraph) shall be included in all copies or substantial portions of the
|
---|
13 | * Software.
|
---|
14 | *
|
---|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
---|
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
---|
21 | * SOFTWARE.
|
---|
22 | *
|
---|
23 | * Authors:
|
---|
24 | * Dave Airlie <[email protected]>
|
---|
25 | *
|
---|
26 | */
|
---|
27 | #ifndef DRMMODE_DISPLAY_H
|
---|
28 | #define DRMMODE_DISPLAY_H
|
---|
29 |
|
---|
30 | #include "xf86drmMode.h"
|
---|
31 | #ifdef CONFIG_UDEV_KMS
|
---|
32 | #include "libudev.h"
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | #include "dumb_bo.h"
|
---|
36 |
|
---|
37 | struct gbm_device;
|
---|
38 |
|
---|
39 | typedef struct {
|
---|
40 | struct dumb_bo *dumb;
|
---|
41 | #ifdef GLAMOR_HAS_GBM
|
---|
42 | struct gbm_bo *gbm;
|
---|
43 | #endif
|
---|
44 | } drmmode_bo;
|
---|
45 |
|
---|
46 | typedef struct {
|
---|
47 | int fd;
|
---|
48 | unsigned fb_id;
|
---|
49 | unsigned old_fb_id;
|
---|
50 | drmModeResPtr mode_res;
|
---|
51 | drmModeFBPtr mode_fb;
|
---|
52 | int cpp;
|
---|
53 | ScrnInfoPtr scrn;
|
---|
54 |
|
---|
55 | struct gbm_device *gbm;
|
---|
56 |
|
---|
57 | #ifdef CONFIG_UDEV_KMS
|
---|
58 | struct udev_monitor *uevent_monitor;
|
---|
59 | InputHandlerProc uevent_handler;
|
---|
60 | #endif
|
---|
61 | drmEventContext event_context;
|
---|
62 | drmmode_bo front_bo;
|
---|
63 | Bool sw_cursor;
|
---|
64 |
|
---|
65 | Bool glamor;
|
---|
66 | Bool shadow_enable;
|
---|
67 | void *shadow_fb;
|
---|
68 |
|
---|
69 | /**
|
---|
70 | * A screen-sized pixmap when we're doing triple-buffered DRI2
|
---|
71 | * pageflipping.
|
---|
72 | *
|
---|
73 | * One is shared between all drawables that flip to the front
|
---|
74 | * buffer, and it only gets reallocated when root pixmap size
|
---|
75 | * changes.
|
---|
76 | */
|
---|
77 | PixmapPtr triple_buffer_pixmap;
|
---|
78 |
|
---|
79 | /** The GEM name for triple_buffer_pixmap */
|
---|
80 | uint32_t triple_buffer_name;
|
---|
81 |
|
---|
82 | DevPrivateKeyRec pixmapPrivateKeyRec;
|
---|
83 | } drmmode_rec, *drmmode_ptr;
|
---|
84 |
|
---|
85 | typedef struct {
|
---|
86 | drmmode_ptr drmmode;
|
---|
87 | drmModeCrtcPtr mode_crtc;
|
---|
88 | uint32_t vblank_pipe;
|
---|
89 | int dpms_mode;
|
---|
90 | struct dumb_bo *cursor_bo;
|
---|
91 | Bool cursor_up;
|
---|
92 | uint16_t lut_r[256], lut_g[256], lut_b[256];
|
---|
93 | DamagePtr slave_damage;
|
---|
94 |
|
---|
95 | drmmode_bo rotate_bo;
|
---|
96 | unsigned rotate_fb_id;
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * @{ MSC (vblank count) handling for the PRESENT extension.
|
---|
100 | *
|
---|
101 | * The kernel's vblank counters are 32 bits and apparently full of
|
---|
102 | * lies, and we need to give a reliable 64-bit msc for GL, so we
|
---|
103 | * have to track and convert to a userland-tracked 64-bit msc.
|
---|
104 | */
|
---|
105 | int32_t vblank_offset;
|
---|
106 | uint32_t msc_prev;
|
---|
107 | uint64_t msc_high;
|
---|
108 | /** @} */
|
---|
109 | } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
|
---|
110 |
|
---|
111 | typedef struct {
|
---|
112 | drmModePropertyPtr mode_prop;
|
---|
113 | uint64_t value;
|
---|
114 | int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
|
---|
115 | Atom *atoms;
|
---|
116 | } drmmode_prop_rec, *drmmode_prop_ptr;
|
---|
117 |
|
---|
118 | typedef struct {
|
---|
119 | drmmode_ptr drmmode;
|
---|
120 | int output_id;
|
---|
121 | drmModeConnectorPtr mode_output;
|
---|
122 | drmModeEncoderPtr *mode_encoders;
|
---|
123 | drmModePropertyBlobPtr edid_blob;
|
---|
124 | int dpms_enum_id;
|
---|
125 | int num_props;
|
---|
126 | drmmode_prop_ptr props;
|
---|
127 | int enc_mask;
|
---|
128 | int enc_clone_mask;
|
---|
129 | } drmmode_output_private_rec, *drmmode_output_private_ptr;
|
---|
130 |
|
---|
131 | typedef struct _msPixmapPriv {
|
---|
132 | uint32_t fb_id;
|
---|
133 | struct dumb_bo *backing_bo; /* if this pixmap is backed by a dumb bo */
|
---|
134 | } msPixmapPrivRec, *msPixmapPrivPtr;
|
---|
135 |
|
---|
136 | extern DevPrivateKeyRec msPixmapPrivateKeyRec;
|
---|
137 |
|
---|
138 | #define msPixmapPrivateKey (&msPixmapPrivateKeyRec)
|
---|
139 |
|
---|
140 | #define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
|
---|
141 |
|
---|
142 | uint32_t drmmode_bo_get_handle(drmmode_bo *bo);
|
---|
143 | Bool drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode);
|
---|
144 | void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
|
---|
145 | Bool drmmode_SetSlaveBO(PixmapPtr ppix,
|
---|
146 | drmmode_ptr drmmode,
|
---|
147 | int fd_handle, int pitch, int size);
|
---|
148 |
|
---|
149 | extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
|
---|
150 | void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
|
---|
151 | extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
152 | extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
|
---|
153 |
|
---|
154 | extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
|
---|
155 | extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
|
---|
156 |
|
---|
157 | Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
158 | void *drmmode_map_front_bo(drmmode_ptr drmmode);
|
---|
159 | Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
160 | void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
161 | void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
|
---|
162 | int *depth, int *bpp);
|
---|
163 |
|
---|
164 |
|
---|
165 | #ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
|
---|
166 | #define DRM_CAP_DUMB_PREFERRED_DEPTH 3
|
---|
167 | #endif
|
---|
168 | #ifndef DRM_CAP_DUMB_PREFER_SHADOW
|
---|
169 | #define DRM_CAP_DUMB_PREFER_SHADOW 4
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #define MS_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
---|
173 |
|
---|
174 | #endif
|
---|