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 | drmModeFBPtr mode_fb;
|
---|
50 | int cpp;
|
---|
51 | ScrnInfoPtr scrn;
|
---|
52 |
|
---|
53 | struct gbm_device *gbm;
|
---|
54 |
|
---|
55 | #ifdef CONFIG_UDEV_KMS
|
---|
56 | struct udev_monitor *uevent_monitor;
|
---|
57 | InputHandlerProc uevent_handler;
|
---|
58 | #endif
|
---|
59 | drmEventContext event_context;
|
---|
60 | drmmode_bo front_bo;
|
---|
61 | Bool sw_cursor;
|
---|
62 |
|
---|
63 | /* Broken-out options. */
|
---|
64 | OptionInfoPtr Options;
|
---|
65 |
|
---|
66 | Bool glamor;
|
---|
67 | Bool shadow_enable;
|
---|
68 | /** Is Option "PageFlip" enabled? */
|
---|
69 | Bool pageflip;
|
---|
70 | void *shadow_fb;
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * A screen-sized pixmap when we're doing triple-buffered DRI2
|
---|
74 | * pageflipping.
|
---|
75 | *
|
---|
76 | * One is shared between all drawables that flip to the front
|
---|
77 | * buffer, and it only gets reallocated when root pixmap size
|
---|
78 | * changes.
|
---|
79 | */
|
---|
80 | PixmapPtr triple_buffer_pixmap;
|
---|
81 |
|
---|
82 | /** The GEM name for triple_buffer_pixmap */
|
---|
83 | uint32_t triple_buffer_name;
|
---|
84 |
|
---|
85 | DevPrivateKeyRec pixmapPrivateKeyRec;
|
---|
86 |
|
---|
87 | Bool reverse_prime_offload_mode;
|
---|
88 |
|
---|
89 | Bool is_secondary;
|
---|
90 | } drmmode_rec, *drmmode_ptr;
|
---|
91 |
|
---|
92 | typedef struct {
|
---|
93 | drmmode_ptr drmmode;
|
---|
94 | drmModeCrtcPtr mode_crtc;
|
---|
95 | uint32_t vblank_pipe;
|
---|
96 | int dpms_mode;
|
---|
97 | struct dumb_bo *cursor_bo;
|
---|
98 | Bool cursor_up;
|
---|
99 | uint16_t lut_r[256], lut_g[256], lut_b[256];
|
---|
100 | DamagePtr slave_damage;
|
---|
101 |
|
---|
102 | drmmode_bo rotate_bo;
|
---|
103 | unsigned rotate_fb_id;
|
---|
104 | unsigned prime_pixmap_x;
|
---|
105 | /**
|
---|
106 | * @{ MSC (vblank count) handling for the PRESENT extension.
|
---|
107 | *
|
---|
108 | * The kernel's vblank counters are 32 bits and apparently full of
|
---|
109 | * lies, and we need to give a reliable 64-bit msc for GL, so we
|
---|
110 | * have to track and convert to a userland-tracked 64-bit msc.
|
---|
111 | */
|
---|
112 | int32_t vblank_offset;
|
---|
113 | uint32_t msc_prev;
|
---|
114 | uint64_t msc_high;
|
---|
115 | /** @} */
|
---|
116 |
|
---|
117 | Bool need_modeset;
|
---|
118 | } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
|
---|
119 |
|
---|
120 | typedef struct {
|
---|
121 | drmModePropertyPtr mode_prop;
|
---|
122 | uint64_t value;
|
---|
123 | int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
|
---|
124 | Atom *atoms;
|
---|
125 | } drmmode_prop_rec, *drmmode_prop_ptr;
|
---|
126 |
|
---|
127 | typedef struct {
|
---|
128 | drmmode_ptr drmmode;
|
---|
129 | int output_id;
|
---|
130 | drmModeConnectorPtr mode_output;
|
---|
131 | drmModeEncoderPtr *mode_encoders;
|
---|
132 | drmModePropertyBlobPtr edid_blob;
|
---|
133 | drmModePropertyBlobPtr tile_blob;
|
---|
134 | int dpms_enum_id;
|
---|
135 | int num_props;
|
---|
136 | drmmode_prop_ptr props;
|
---|
137 | int enc_mask;
|
---|
138 | int enc_clone_mask;
|
---|
139 | } drmmode_output_private_rec, *drmmode_output_private_ptr;
|
---|
140 |
|
---|
141 | typedef struct _msPixmapPriv {
|
---|
142 | uint32_t fb_id;
|
---|
143 | struct dumb_bo *backing_bo; /* if this pixmap is backed by a dumb bo */
|
---|
144 | } msPixmapPrivRec, *msPixmapPrivPtr;
|
---|
145 |
|
---|
146 | extern DevPrivateKeyRec msPixmapPrivateKeyRec;
|
---|
147 |
|
---|
148 | #define msPixmapPrivateKey (&msPixmapPrivateKeyRec)
|
---|
149 |
|
---|
150 | #define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
|
---|
151 |
|
---|
152 | Bool drmmode_bo_for_pixmap(drmmode_ptr drmmode, drmmode_bo *bo, PixmapPtr pixmap);
|
---|
153 | int drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo);
|
---|
154 | uint32_t drmmode_bo_get_pitch(drmmode_bo *bo);
|
---|
155 | uint32_t drmmode_bo_get_handle(drmmode_bo *bo);
|
---|
156 | Bool drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode);
|
---|
157 | void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
|
---|
158 | Bool drmmode_SetSlaveBO(PixmapPtr ppix,
|
---|
159 | drmmode_ptr drmmode,
|
---|
160 | int fd_handle, int pitch, int size);
|
---|
161 |
|
---|
162 | extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
|
---|
163 | void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
|
---|
164 | extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
165 | extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn);
|
---|
166 |
|
---|
167 | extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode);
|
---|
168 | extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode);
|
---|
169 |
|
---|
170 | Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
171 | void *drmmode_map_front_bo(drmmode_ptr drmmode);
|
---|
172 | Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
173 | void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
|
---|
174 | void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
|
---|
175 | int *depth, int *bpp);
|
---|
176 |
|
---|
177 |
|
---|
178 | #ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
|
---|
179 | #define DRM_CAP_DUMB_PREFERRED_DEPTH 3
|
---|
180 | #endif
|
---|
181 | #ifndef DRM_CAP_DUMB_PREFER_SHADOW
|
---|
182 | #define DRM_CAP_DUMB_PREFER_SHADOW 4
|
---|
183 | #endif
|
---|
184 |
|
---|
185 | #define MS_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
---|
186 |
|
---|
187 | #endif
|
---|