Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
m1k1o
GitHub Repository: m1k1o/neko
Path: blob/master/utils/xorg-deps/xf86-video-dummy/01_v0.3.8_xdummy-randr.patch
1007 views
1
diff --git a/src/dummy.h b/src/dummy.h
2
index c3fdd6e..9c74f56 100644
3
--- a/src/dummy.h
4
+++ b/src/dummy.h
5
@@ -13,6 +13,8 @@
6
7
#include "compat-api.h"
8
9
+#define DUMMY_MAX_SCREENS 4
10
+
11
/* Supported chipsets */
12
typedef enum {
13
DUMMY_CHIP
14
@@ -72,6 +74,12 @@ typedef struct dummyRec
15
pointer* FBBase;
16
Bool (*CreateWindow)() ; /* wrapped CreateWindow */
17
Bool prop;
18
+ /* XRANDR support begin */
19
+ int num_screens;
20
+ struct _xf86Crtc *paCrtcs[DUMMY_MAX_SCREENS];
21
+ struct _xf86Output *paOutputs[DUMMY_MAX_SCREENS];
22
+ int connected_outputs;
23
+ /* XRANDR support end */
24
} DUMMYRec, *DUMMYPtr;
25
26
/* The privates of the DUMMY driver */
27
diff --git a/src/dummy_driver.c b/src/dummy_driver.c
28
index 2656602..069e330 100644
29
--- a/src/dummy_driver.c
30
+++ b/src/dummy_driver.c
31
@@ -34,6 +34,8 @@
32
#include <X11/extensions/Xv.h>
33
#endif
34
35
+#include "xf86Crtc.h"
36
+
37
/*
38
* Driver data structures.
39
*/
40
@@ -141,6 +143,219 @@ static XF86ModuleVersionInfo dummyVersRec =
41
{0,0,0,0}
42
};
43
44
+
45
+/************************
46
+ * XRANDR support begin *
47
+ ************************/
48
+
49
+static Bool dummy_config_resize(ScrnInfoPtr pScrn, int cw, int ch);
50
+static Bool DUMMYAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height);
51
+
52
+static const xf86CrtcConfigFuncsRec DUMMYCrtcConfigFuncs = {
53
+ .resize = dummy_config_resize
54
+};
55
+
56
+
57
+static void
58
+dummy_crtc_dpms(xf86CrtcPtr crtc, int mode)
59
+{
60
+}
61
+
62
+static Bool
63
+dummy_crtc_lock (xf86CrtcPtr crtc)
64
+{
65
+ return FALSE;
66
+}
67
+
68
+static Bool
69
+dummy_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode,
70
+ DisplayModePtr adjusted_mode)
71
+{
72
+ return TRUE;
73
+}
74
+
75
+static void
76
+dummy_crtc_stub (xf86CrtcPtr crtc)
77
+{
78
+}
79
+
80
+static void
81
+dummy_crtc_gamma_set (xf86CrtcPtr crtc, CARD16 *red,
82
+ CARD16 *green, CARD16 *blue, int size)
83
+{
84
+}
85
+
86
+static void *
87
+dummy_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height)
88
+{
89
+ return NULL;
90
+}
91
+
92
+static void
93
+dummy_crtc_mode_set (xf86CrtcPtr crtc, DisplayModePtr mode,
94
+ DisplayModePtr adjusted_mode, int x, int y)
95
+{
96
+}
97
+
98
+static const xf86CrtcFuncsRec DUMMYCrtcFuncs = {
99
+ .dpms = dummy_crtc_dpms,
100
+ .save = NULL, /* These two are never called by the server. */
101
+ .restore = NULL,
102
+ .lock = dummy_crtc_lock,
103
+ .unlock = NULL, /* This will not be invoked if lock returns FALSE. */
104
+ .mode_fixup = dummy_crtc_mode_fixup,
105
+ .prepare = dummy_crtc_stub,
106
+ .mode_set = dummy_crtc_mode_set,
107
+ .commit = dummy_crtc_stub,
108
+ .gamma_set = dummy_crtc_gamma_set,
109
+ .shadow_allocate = dummy_crtc_shadow_allocate,
110
+ .shadow_create = NULL, /* These two should not be invoked if allocate
111
+ returns NULL. */
112
+ .shadow_destroy = NULL,
113
+ .set_cursor_colors = NULL,
114
+ .set_cursor_position = NULL,
115
+ .show_cursor = NULL,
116
+ .hide_cursor = NULL,
117
+ .load_cursor_argb = NULL,
118
+ .destroy = dummy_crtc_stub
119
+};
120
+
121
+static void
122
+dummy_output_stub (xf86OutputPtr output)
123
+{
124
+}
125
+
126
+static void
127
+dummy_output_dpms (xf86OutputPtr output, int mode)
128
+{
129
+}
130
+
131
+static int
132
+dummy_output_mode_valid (xf86OutputPtr output, DisplayModePtr mode)
133
+{
134
+ return MODE_OK;
135
+}
136
+
137
+static Bool
138
+dummy_output_mode_fixup (xf86OutputPtr output, DisplayModePtr mode,
139
+ DisplayModePtr adjusted_mode)
140
+{
141
+ return TRUE;
142
+}
143
+
144
+static void
145
+dummy_output_mode_set (xf86OutputPtr output, DisplayModePtr mode,
146
+ DisplayModePtr adjusted_mode)
147
+{
148
+ DUMMYPtr dPtr = DUMMYPTR(output->scrn);
149
+ int index = (int64_t)output->driver_private;
150
+
151
+ /* set to connected at first mode set */
152
+ dPtr->connected_outputs |= 1 << index;
153
+}
154
+
155
+/* The first virtual monitor is always connected. Others only after setting its
156
+ * mode */
157
+static xf86OutputStatus
158
+dummy_output_detect (xf86OutputPtr output)
159
+{
160
+ DUMMYPtr dPtr = DUMMYPTR(output->scrn);
161
+ int index = (int64_t)output->driver_private;
162
+
163
+ if (dPtr->connected_outputs & (1 << index))
164
+ return XF86OutputStatusConnected;
165
+ else
166
+ return XF86OutputStatusDisconnected;
167
+}
168
+
169
+static DisplayModePtr
170
+dummy_output_get_modes (xf86OutputPtr output)
171
+{
172
+ DisplayModePtr pModes = NULL, pMode, pModeSrc;
173
+
174
+ /* copy modes from config */
175
+ for (pModeSrc = output->scrn->modes; pModeSrc; pModeSrc = pModeSrc->next)
176
+ {
177
+ pMode = xnfcalloc(1, sizeof(DisplayModeRec));
178
+ memcpy(pMode, pModeSrc, sizeof(DisplayModeRec));
179
+ pMode->next = NULL;
180
+ pMode->prev = NULL;
181
+ pMode->name = strdup(pModeSrc->name);
182
+ pModes = xf86ModesAdd(pModes, pMode);
183
+ if (pModeSrc->next == output->scrn->modes)
184
+ break;
185
+ }
186
+ return pModes;
187
+}
188
+
189
+
190
+static const xf86OutputFuncsRec DUMMYOutputFuncs = {
191
+ .create_resources = dummy_output_stub,
192
+ .dpms = dummy_output_dpms,
193
+ .save = NULL, /* These two are never called by the server. */
194
+ .restore = NULL,
195
+ .mode_valid = dummy_output_mode_valid,
196
+ .mode_fixup = dummy_output_mode_fixup,
197
+ .prepare = dummy_output_stub,
198
+ .commit = dummy_output_stub,
199
+ .mode_set = dummy_output_mode_set,
200
+ .detect = dummy_output_detect,
201
+ .get_modes = dummy_output_get_modes,
202
+#ifdef RANDR_12_INTERFACE
203
+ .set_property = NULL,
204
+#endif
205
+ .destroy = dummy_output_stub
206
+};
207
+
208
+static Bool
209
+dummy_config_resize(ScrnInfoPtr pScrn, int cw, int ch)
210
+{
211
+ if (!pScrn->vtSema) {
212
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
213
+ "We do not own the active VT, exiting.\n");
214
+ return TRUE;
215
+ }
216
+ return DUMMYAdjustScreenPixmap(pScrn, cw, ch);
217
+}
218
+
219
+Bool DUMMYAdjustScreenPixmap(ScrnInfoPtr pScrn, int width, int height)
220
+{
221
+ ScreenPtr pScreen = pScrn->pScreen;
222
+ PixmapPtr pPixmap = pScreen->GetScreenPixmap(pScreen);
223
+ DUMMYPtr dPtr = DUMMYPTR(pScrn);
224
+ uint64_t cbLine = (width * xf86GetBppFromDepth(pScrn, pScrn->depth) / 8 + 3) & ~3;
225
+ int displayWidth = cbLine * 8 / xf86GetBppFromDepth(pScrn, pScrn->depth);
226
+
227
+ if ( width == pScrn->virtualX
228
+ && height == pScrn->virtualY
229
+ && displayWidth == pScrn->displayWidth)
230
+ return TRUE;
231
+ if (!pPixmap) {
232
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
233
+ "Failed to get the screen pixmap.\n");
234
+ return FALSE;
235
+ }
236
+ if (cbLine > UINT32_MAX || cbLine * height >= pScrn->videoRam * 1024)
237
+ {
238
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
239
+ "Unable to set up a virtual screen size of %dx%d with %d Kb of video memory available. Please increase the video memory size.\n",
240
+ width, height, pScrn->videoRam);
241
+ return FALSE;
242
+ }
243
+ pScreen->ModifyPixmapHeader(pPixmap, width, height,
244
+ pScrn->depth, xf86GetBppFromDepth(pScrn, pScrn->depth), cbLine,
245
+ pPixmap->devPrivate.ptr);
246
+ pScrn->virtualX = width;
247
+ pScrn->virtualY = height;
248
+ pScrn->displayWidth = displayWidth;
249
+
250
+ return TRUE;
251
+}
252
+
253
+/**********************
254
+ * XRANDR support end *
255
+ **********************/
256
+
257
/*
258
* This is the module init data.
259
* Its name has to be the driver name followed by ModuleData
260
@@ -568,6 +783,56 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
261
262
xf86SetBlackWhitePixels(pScreen);
263
264
+ /* initialize XRANDR */
265
+ xf86CrtcConfigInit(pScrn, &DUMMYCrtcConfigFuncs);
266
+ /* FIXME */
267
+ dPtr->num_screens = DUMMY_MAX_SCREENS;
268
+
269
+ for (int i=0; i < dPtr->num_screens; i++) {
270
+ char szOutput[256];
271
+
272
+ dPtr->paCrtcs[i] = xf86CrtcCreate(pScrn, &DUMMYCrtcFuncs);
273
+ dPtr->paCrtcs[i]->driver_private = (void *)(uintptr_t)i;
274
+
275
+ /* Set up our virtual outputs. */
276
+ snprintf(szOutput, sizeof(szOutput), "DUMMY%u", i);
277
+ dPtr->paOutputs[i] = xf86OutputCreate(pScrn, &DUMMYOutputFuncs,
278
+ szOutput);
279
+
280
+
281
+ xf86OutputUseScreenMonitor(dPtr->paOutputs[i], FALSE);
282
+ dPtr->paOutputs[i]->possible_crtcs = 1 << i;
283
+ dPtr->paOutputs[i]->possible_clones = 0;
284
+ dPtr->paOutputs[i]->driver_private = (void *)(uintptr_t)i;
285
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Created crtc (%p) and output %s (%p)\n",
286
+ (void *)dPtr->paCrtcs[i], szOutput,
287
+ (void *)dPtr->paOutputs[i]);
288
+
289
+ }
290
+
291
+ /* bitmask */
292
+ dPtr->connected_outputs = 1;
293
+
294
+ xf86CrtcSetSizeRange(pScrn, 64, 64, DUMMY_MAX_WIDTH, DUMMY_MAX_HEIGHT);
295
+
296
+
297
+ /* Now create our initial CRTC/output configuration. */
298
+ if (!xf86InitialConfiguration(pScrn, TRUE)) {
299
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Initial CRTC configuration failed!\n");
300
+ return (FALSE);
301
+ }
302
+
303
+ /* Initialise randr 1.2 mode-setting functions and set first mode.
304
+ * Note that the mode won't be usable until the server has resized the
305
+ * framebuffer to something reasonable. */
306
+ if (!xf86CrtcScreenInit(pScreen)) {
307
+ return FALSE;
308
+ }
309
+ if (!xf86SetDesiredModes(pScrn)) {
310
+ return FALSE;
311
+ }
312
+ /* XRANDR initialization end */
313
+
314
#ifdef USE_DGA
315
DUMMYDGAInit(pScreen);
316
#endif
317
318