blob: 504c8ad6979494bda354900bf1974174f8432653 [file] [log] [blame]
Rob Clark4b8f30a2011-08-28 12:51:26 -05001/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
2
3/*
4 * Copyright © 2011 Texas Instruments, Inc
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Authors:
26 * Rob Clark <rob@ti.com>
27 */
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include "omap_driver.h"
Rob Clark0fdd91f2011-10-20 09:56:11 -050034#include "omap_exa.h"
Rob Clark4b8f30a2011-08-28 12:51:26 -050035
36#include "xf86drmMode.h"
37#include "dri2.h"
38
39/* any point to support earlier? */
40#if DRI2INFOREC_VERSION < 4
41# error "Requires newer DRI2"
42#endif
43
44
45typedef struct {
46 DRI2BufferRec base;
47
Rob Clark99ab80d2012-04-12 17:38:07 -050048 /**
49 * Pixmap that is backing the buffer
50 *
51 * NOTE: don't track the pixmap ptr for the front buffer if it is
52 * a window.. this could get reallocated from beneath us, so we should
53 * always use draw2pix to be sure to have the correct one
54 */
Rob Clark4b8f30a2011-08-28 12:51:26 -050055 PixmapPtr pPixmap;
56
57 /**
Rob Clark0bdd3702012-04-20 14:47:51 -050058 * The DRI2 buffers are reference counted to avoid crashyness when the
59 * client detaches a dri2 drawable while we are still waiting for a
60 * page_flip event.
61 */
62 int refcnt;
63
Rob Clark4b8f30a2011-08-28 12:51:26 -050064} OMAPDRI2BufferRec, *OMAPDRI2BufferPtr;
65
66#define OMAPBUF(p) ((OMAPDRI2BufferPtr)(p))
67#define DRIBUF(p) ((DRI2BufferPtr)(&(p)->base))
68
69
Rob Clark4b8f30a2011-08-28 12:51:26 -050070static inline DrawablePtr
71dri2draw(DrawablePtr pDraw, DRI2BufferPtr buf)
72{
73 if (buf->attachment == DRI2BufferFrontLeft) {
74 return pDraw;
75 } else {
76 return &(OMAPBUF(buf)->pPixmap->drawable);
77 }
78}
79
80static inline Bool
Rob Clark99ab80d2012-04-12 17:38:07 -050081canexchange(DrawablePtr pDraw, DRI2BufferPtr a, DRI2BufferPtr b)
Rob Clark4b8f30a2011-08-28 12:51:26 -050082{
Rob Clark99ab80d2012-04-12 17:38:07 -050083 DrawablePtr da = dri2draw(pDraw, a);
84 DrawablePtr db = dri2draw(pDraw, b);
85
86 return DRI2CanFlip(pDraw) &&
87 (da->width == db->width) &&
88 (da->height == db->height) &&
89 (da->depth == db->depth);
Rob Clark4b8f30a2011-08-28 12:51:26 -050090}
91
92static Bool
93canflip(DrawablePtr pDraw)
94{
95 return (pDraw->type == DRAWABLE_WINDOW) &&
Rob Clark99ab80d2012-04-12 17:38:07 -050096 DRI2CanFlip(pDraw);
Rob Clark4b8f30a2011-08-28 12:51:26 -050097}
98
99static inline Bool
100exchangebufs(DrawablePtr pDraw, DRI2BufferPtr a, DRI2BufferPtr b)
101{
Rob Clark4b8f30a2011-08-28 12:51:26 -0500102 OMAPPixmapExchange(draw2pix(dri2draw(pDraw, a)),
103 draw2pix(dri2draw(pDraw, b)));
104 exchange(a->name, b->name);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500105 return TRUE;
106}
107
108static PixmapPtr
109createpix(DrawablePtr pDraw)
110{
111 ScreenPtr pScreen = pDraw->pScreen;
112 int flags = canflip(pDraw) ? OMAP_CREATE_PIXMAP_SCANOUT : 0;
113 return pScreen->CreatePixmap(pScreen,
114 pDraw->width, pDraw->height, pDraw->depth, flags);
115}
116
117/**
118 * Create Buffer.
119 *
120 * Note that 'format' is used from the client side to specify the DRI buffer
121 * format, which could differ from the drawable format. For example, the
122 * drawable could be 32b RGB, but the DRI buffer some YUV format (video) or
123 * perhaps lower bit depth RGB (GL). The color conversion is handled when
124 * blitting to front buffer, and page-flipping (overlay or flipchain) can
125 * only be used if the display supports.
126 */
127static DRI2BufferPtr
128OMAPDRI2CreateBuffer(DrawablePtr pDraw, unsigned int attachment,
129 unsigned int format)
130{
131 ScreenPtr pScreen = pDraw->pScreen;
132 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
133 OMAPPtr pOMAP = OMAPPTR(pScrn);
134 OMAPDRI2BufferPtr buf = calloc(1, sizeof(*buf));
135 PixmapPtr pPixmap;
136 struct omap_bo *bo;
137 int ret;
138
139 DEBUG_MSG("pDraw=%p, attachment=%d, format=%08x",
140 pDraw, attachment, format);
141
142 if (!buf) {
143 return NULL;
144 }
145
146 if (attachment == DRI2BufferFrontLeft) {
147 pPixmap = draw2pix(pDraw);
148
Rob Clark834f6462012-04-20 15:40:51 -0500149 /* to do flipping, if we don't have DMM, then we need a scanout
150 * capable (physically contiguous) buffer.. this bit of gymnastics
151 * ensures that.
Rob Clark4b8f30a2011-08-28 12:51:26 -0500152 *
Rob Clark834f6462012-04-20 15:40:51 -0500153 * TODO we may want to re-allocate and switch back to non-scanout
Rob Clark4b8f30a2011-08-28 12:51:26 -0500154 * buffer when client disconnects from drawable..
155 */
Raymond Smith2b4620b2012-05-01 12:00:41 +0100156
157/* TODO: We don't have enough memory to allocate three physically contiguous buffers at the same time! Because all our
158 * buffers are scanout-able we'll not bother allocating *another* scanout buffer and just use the one we already have
159 * and save that extra buffer size */
160#if 0
Rob Clark834f6462012-04-20 15:40:51 -0500161 if (canflip(pDraw) && !has_dmm(pOMAP) &&
162 (OMAPPixmapBo(pPixmap) != pOMAP->scanout)) {
163
Rob Clark4b8f30a2011-08-28 12:51:26 -0500164 /* need to re-allocate pixmap to get a scanout capable buffer */
165 PixmapPtr pNewPix = createpix(pDraw);
166
167 // TODO copy contents..
168
169 OMAPPixmapExchange(pPixmap, pNewPix);
170
171 pScreen->DestroyPixmap(pNewPix);
172 }
Raymond Smith2b4620b2012-05-01 12:00:41 +0100173#endif
Rob Clark0bdd3702012-04-20 14:47:51 -0500174
175 pPixmap->refcnt++;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500176 } else {
177 pPixmap = createpix(pDraw);
178 }
179
180 bo = OMAPPixmapBo(pPixmap);
Raymond Smithd15a7342012-05-01 12:01:52 +0100181 if (!bo)
182 {
183 ERROR_MSG("Attempting to DRI2 wrap a pixmap with no DRM buffer object backing");
184 /* TODO: Returning NULL here ends up in a segfault all the way in pixman which has no backtrace. We get
185 * a more friendly segfault if we just let it be dereferenced in a few lines */
186 }
Rob Clark4b8f30a2011-08-28 12:51:26 -0500187
188 DRIBUF(buf)->attachment = attachment;
189 DRIBUF(buf)->pitch = exaGetPixmapPitch(pPixmap);
190 DRIBUF(buf)->cpp = pPixmap->drawable.bitsPerPixel / 8;
191 DRIBUF(buf)->format = format;
Rob Clark0bdd3702012-04-20 14:47:51 -0500192 buf->refcnt = 1;
193 buf->pPixmap = pPixmap;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500194
195 ret = omap_bo_get_name(bo, &DRIBUF(buf)->name);
196 if (ret) {
197 ERROR_MSG("could not get buffer name: %d", ret);
198 /* TODO cleanup */
199 return NULL;
200 }
201
Rob Clark4b8f30a2011-08-28 12:51:26 -0500202 /* Q: how to know across OMAP generations what formats that the display
203 * can support directly?
204 * A: attempt to create a drm_framebuffer, and if that fails then the
David Garbett7d6a6e72012-05-11 11:52:45 +0100205 * hw must not support.. then fall back to blitting
Rob Clark4b8f30a2011-08-28 12:51:26 -0500206 */
David Garbett7d6a6e72012-05-11 11:52:45 +0100207 if (canflip(pDraw) && attachment != DRI2BufferFrontLeft) {
208 uint32_t new_fb_id;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500209 int ret = drmModeAddFB(pOMAP->drmFD, pDraw->width, pDraw->height,
210 pDraw->depth, pDraw->bitsPerPixel, DRIBUF(buf)->pitch,
David Garbett7d6a6e72012-05-11 11:52:45 +0100211 omap_bo_handle(bo), &new_fb_id);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500212 if (ret) {
213 /* to-bad, so-sad, we can't flip */
214 WARNING_MSG("could not create fb: %d", ret);
David Garbett7d6a6e72012-05-11 11:52:45 +0100215 } else {
216 omap_bo_set_fb(bo, new_fb_id);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500217 }
218 }
219
220 return DRIBUF(buf);
221}
222
223/**
224 * Destroy Buffer
225 *
226 * TODO: depending on how flipping ends up working, we may need a refcnt or
227 * something like this to defer destroying a buffer that is currently being
228 * scanned out..
229 */
230static void
231OMAPDRI2DestroyBuffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
232{
Rob Clark0bdd3702012-04-20 14:47:51 -0500233 OMAPDRI2BufferPtr buf = OMAPBUF(buffer);
234 /* Note: pDraw may already be deleted, so use the pPixmap here
235 * instead (since it is at least refcntd)
236 */
237 ScreenPtr pScreen = buf->pPixmap->drawable.pScreen;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500238 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
239 OMAPPtr pOMAP = OMAPPTR(pScrn);
Rob Clark0bdd3702012-04-20 14:47:51 -0500240
241 if (--buf->refcnt > 0)
242 return;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500243
244 DEBUG_MSG("pDraw=%p, buffer=%p", pDraw, buffer);
245
Rob Clark0bdd3702012-04-20 14:47:51 -0500246 pScreen->DestroyPixmap(buf->pPixmap);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500247
248 free(buf);
249}
250
Rob Clark0bdd3702012-04-20 14:47:51 -0500251static void
252OMAPDRI2ReferenceBuffer(DRI2BufferPtr buffer)
253{
254 OMAPDRI2BufferPtr buf = OMAPBUF(buffer);
255 buf->refcnt++;
256}
257
Rob Clark4b8f30a2011-08-28 12:51:26 -0500258/**
259 *
260 */
261static void
262OMAPDRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
263 DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer)
264{
265 ScreenPtr pScreen = pDraw->pScreen;
266 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
267 DrawablePtr pSrcDraw = dri2draw(pDraw, pSrcBuffer);
268 DrawablePtr pDstDraw = dri2draw(pDraw, pDstBuffer);
269 RegionPtr pCopyClip;
270 GCPtr pGC;
271
272 DEBUG_MSG("pDraw=%p, pDstBuffer=%p (%p), pSrcBuffer=%p (%p)",
273 pDraw, pDstBuffer, pSrcDraw, pSrcBuffer, pDstDraw);
274
275 pGC = GetScratchGC(pDstDraw->depth, pScreen);
276 if (!pGC) {
277 return;
278 }
279
280 pCopyClip = REGION_CREATE(pScreen, NULL, 0);
281 RegionCopy(pCopyClip, pRegion);
282 (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pCopyClip, 0);
283 ValidateGC(pDstDraw, pGC);
284
285 /* If the dst is the framebuffer, and we had a way to
286 * schedule a deferred blit synchronized w/ vsync, that
287 * would be a nice thing to do utilize here to avoid
288 * tearing.. when we have sync object support for GEM
289 * buffers, I think we could do something more clever
290 * here.
291 */
292
293 pGC->ops->CopyArea(pSrcDraw, pDstDraw, pGC,
294 0, 0, pDraw->width, pDraw->height, 0, 0);
295
Rob Clarke450d412012-01-08 19:33:48 -0600296 FreeScratchGC(pGC);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500297}
298
299/**
300 * Get current frame count and frame count timestamp, based on drawable's
301 * crtc.
302 */
303static int
304OMAPDRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc)
305{
306 ScreenPtr pScreen = pDraw->pScreen;
307 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
308 OMAPPtr pOMAP = OMAPPTR(pScrn);
309 drmVBlank vbl = { .request = {
310 .type = DRM_VBLANK_RELATIVE,
311 .sequence = 0,
312 } };
313 int ret;
314
315 ret = drmWaitVBlank(pOMAP->drmFD, &vbl);
316 if (ret) {
317 static int limit = 5;
318 if (limit) {
319 ERROR_MSG("get vblank counter failed: %s", strerror(errno));
320 limit--;
321 }
322 return FALSE;
323 }
324
325 if (ust) {
326 *ust = ((CARD64)vbl.reply.tval_sec * 1000000) + vbl.reply.tval_usec;
327 }
328 if (msc) {
329 *msc = vbl.reply.sequence;
330 }
331
332 return TRUE;
333}
334
335struct _OMAPDRISwapCmd {
Rob Clarka6762ef2012-04-12 17:38:39 -0500336 int type;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500337 ClientPtr client;
Rob Clark0bdd3702012-04-20 14:47:51 -0500338 ScreenPtr pScreen;
339 /* Note: store drawable ID, rather than drawable. It's possible that
340 * the drawable can be destroyed while we wait for page flip event:
341 */
342 XID draw_id;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500343 DRI2BufferPtr pDstBuffer;
344 DRI2BufferPtr pSrcBuffer;
345 DRI2SwapEventPtr func;
346 void *data;
347};
348
Rob Clark0bdd3702012-04-20 14:47:51 -0500349static const char *swap_names[] = {
350 [DRI2_EXCHANGE_COMPLETE] = "exchange",
351 [DRI2_BLIT_COMPLETE] = "blit",
352 [DRI2_FLIP_COMPLETE] = "flip,"
353};
354
Rob Clark4b8f30a2011-08-28 12:51:26 -0500355void
356OMAPDRI2SwapComplete(OMAPDRISwapCmd *cmd)
357{
Rob Clark0bdd3702012-04-20 14:47:51 -0500358 ScreenPtr pScreen = cmd->pScreen;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500359 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
Rob Clark67b875f2012-04-20 19:13:57 -0500360 OMAPPtr pOMAP = OMAPPTR(pScrn);
Rob Clark0bdd3702012-04-20 14:47:51 -0500361 DrawablePtr pDraw = NULL;
362 int status;
David Garbett3688b332012-05-11 12:17:34 +0100363 OMAPPixmapPrivPtr dst_priv;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500364
Rob Clark0bdd3702012-04-20 14:47:51 -0500365 DEBUG_MSG("%s complete: %d -> %d", swap_names[cmd->type],
366 cmd->pSrcBuffer->attachment, cmd->pDstBuffer->attachment);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500367
Rob Clark0bdd3702012-04-20 14:47:51 -0500368 status = dixLookupDrawable(&pDraw, cmd->draw_id, serverClient,
369 M_ANY, DixWriteAccess);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500370
Rob Clark0bdd3702012-04-20 14:47:51 -0500371 if (status == Success) {
372 if (cmd->type != DRI2_BLIT_COMPLETE)
373 exchangebufs(pDraw, cmd->pSrcBuffer, cmd->pDstBuffer);
374
375 DRI2SwapComplete(cmd->client, pDraw, 0, 0, 0, cmd->type,
376 cmd->func, cmd->data);
377 }
378
David Garbett3688b332012-05-11 12:17:34 +0100379 dst_priv = exaGetPixmapDriverPrivate(draw2pix(dri2draw(pDraw, cmd->pDstBuffer)));
380
381 set_scanout_bo(pScrn, dst_priv->bo);
382
Rob Clark0bdd3702012-04-20 14:47:51 -0500383 /* drop extra refcnt we obtained prior to swap:
384 */
385 OMAPDRI2DestroyBuffer(pDraw, cmd->pSrcBuffer);
386 OMAPDRI2DestroyBuffer(pDraw, cmd->pDstBuffer);
Rob Clark67b875f2012-04-20 19:13:57 -0500387 pOMAP->pending_flips--;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500388
389 free(cmd);
390}
391
392/**
393 * ScheduleSwap is responsible for requesting a DRM vblank event for the
394 * appropriate frame.
395 *
396 * In the case of a blit (e.g. for a windowed swap) or buffer exchange,
397 * the vblank requested can simply be the last queued swap frame + the swap
398 * interval for the drawable.
399 *
400 * In the case of a page flip, we request an event for the last queued swap
401 * frame + swap interval - 1, since we'll need to queue the flip for the frame
402 * immediately following the received event.
403 */
404static int
405OMAPDRI2ScheduleSwap(ClientPtr client, DrawablePtr pDraw,
406 DRI2BufferPtr pDstBuffer, DRI2BufferPtr pSrcBuffer,
407 CARD64 *target_msc, CARD64 divisor, CARD64 remainder,
408 DRI2SwapEventPtr func, void *data)
409{
410 ScreenPtr pScreen = pDraw->pScreen;
411 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
Rob Clark67b875f2012-04-20 19:13:57 -0500412 OMAPPtr pOMAP = OMAPPTR(pScrn);
Rob Clark4b8f30a2011-08-28 12:51:26 -0500413 OMAPDRI2BufferPtr src = OMAPBUF(pSrcBuffer);
414 OMAPDRI2BufferPtr dst = OMAPBUF(pDstBuffer);
415 OMAPDRISwapCmd *cmd = calloc(1, sizeof(*cmd));
David Garbett7d6a6e72012-05-11 11:52:45 +0100416 int src_fb_id, dst_fb_id;
417 OMAPPixmapPrivPtr src_priv, dst_priv;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500418
419 cmd->client = client;
Rob Clark0bdd3702012-04-20 14:47:51 -0500420 cmd->pScreen = pScreen;
421 cmd->draw_id = pDraw->id;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500422 cmd->pSrcBuffer = pSrcBuffer;
423 cmd->pDstBuffer = pDstBuffer;
424 cmd->func = func;
425 cmd->data = data;
426
427 DEBUG_MSG("%d -> %d", pSrcBuffer->attachment, pDstBuffer->attachment);
428
Rob Clark0bdd3702012-04-20 14:47:51 -0500429 /* obtain extra ref on buffers to avoid them going away while we await
430 * the page flip event:
431 */
432 OMAPDRI2ReferenceBuffer(pSrcBuffer);
433 OMAPDRI2ReferenceBuffer(pDstBuffer);
Rob Clark67b875f2012-04-20 19:13:57 -0500434 pOMAP->pending_flips++;
Rob Clark0bdd3702012-04-20 14:47:51 -0500435
David Garbett7d6a6e72012-05-11 11:52:45 +0100436 src_priv = exaGetPixmapDriverPrivate(src->pPixmap);
437 dst_priv = exaGetPixmapDriverPrivate(dst->pPixmap);
438
439 src_fb_id = omap_bo_get_fb(src_priv->bo);
440 dst_fb_id = omap_bo_get_fb(dst_priv->bo);
441
442 if (src_fb_id && dst_fb_id) {
443 DEBUG_MSG("can flip: %d -> %d", src_fb_id, dst_fb_id);
Rob Clarka6762ef2012-04-12 17:38:39 -0500444 cmd->type = DRI2_FLIP_COMPLETE;
David Garbett7d6a6e72012-05-11 11:52:45 +0100445 drmmode_page_flip(pDraw, src_fb_id, cmd);
Rob Clark99ab80d2012-04-12 17:38:07 -0500446 } else if (canexchange(pDraw, pSrcBuffer, pDstBuffer)) {
447 /* we can get away w/ pointer swap.. yah! */
Rob Clarka6762ef2012-04-12 17:38:39 -0500448 cmd->type = DRI2_EXCHANGE_COMPLETE;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500449 OMAPDRI2SwapComplete(cmd);
450 } else {
451 /* fallback to blit: */
452 BoxRec box = {
453 .x1 = 0,
454 .y1 = 0,
455 .x2 = pDraw->width,
456 .y2 = pDraw->height,
457 };
458 RegionRec region;
459 RegionInit(&region, &box, 0);
460 OMAPDRI2CopyRegion(pDraw, &region, pDstBuffer, pSrcBuffer);
Rob Clarka6762ef2012-04-12 17:38:39 -0500461 cmd->type = DRI2_BLIT_COMPLETE;
Rob Clark4b8f30a2011-08-28 12:51:26 -0500462 OMAPDRI2SwapComplete(cmd);
463 }
464
465 return TRUE;
466}
467
468/**
469 * Request a DRM event when the requested conditions will be satisfied.
470 *
471 * We need to handle the event and ask the server to wake up the client when
472 * we receive it.
473 */
474static int
475OMAPDRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
476 CARD64 divisor, CARD64 remainder)
477{
478 ScreenPtr pScreen = pDraw->pScreen;
479 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
480// OMAPPtr pOMAP = OMAPPTR(pScrn);
481
482#if 0
483#endif
484 ERROR_MSG("not implemented");
485 return FALSE;
486}
487
488/**
489 * The DRI2 ScreenInit() function.. register our handler fxns w/ DRI2 core
490 */
491Bool
492OMAPDRI2ScreenInit(ScreenPtr pScreen)
493{
494 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
495 OMAPPtr pOMAP = OMAPPTR(pScrn);
496 DRI2InfoRec info = {
497 .version = 5,
498 .fd = pOMAP->drmFD,
499 .driverName = "omap",
500 .deviceName = pOMAP->deviceName,
501 .CreateBuffer = OMAPDRI2CreateBuffer,
502 .DestroyBuffer = OMAPDRI2DestroyBuffer,
503 .CopyRegion = OMAPDRI2CopyRegion,
504 .ScheduleSwap = OMAPDRI2ScheduleSwap,
505 .ScheduleWaitMSC = OMAPDRI2ScheduleWaitMSC,
506 .GetMSC = OMAPDRI2GetMSC,
507 .AuthMagic = drmAuthMagic,
508 };
509 int minor = 1, major = 0;
510
511 if (xf86LoaderCheckSymbol("DRI2Version")) {
512 DRI2Version(&major, &minor);
513 }
514
515 if (minor < 1) {
516 WARNING_MSG("DRI2 requires DRI2 module version 1.1.0 or later");
517 return FALSE;
518 }
519
520 return DRI2ScreenInit(pScreen, &info);
521}
522
523/**
524 * The DRI2 CloseScreen() function.. unregister ourself w/ DRI2 core.
525 */
526void
527OMAPDRI2CloseScreen(ScreenPtr pScreen)
528{
Rob Clark67b875f2012-04-20 19:13:57 -0500529 ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
530 OMAPPtr pOMAP = OMAPPTR(pScrn);
531 while (pOMAP->pending_flips > 0) {
532 DEBUG_MSG("waiting..");
533 drmmode_wait_for_event(pScrn);
534 }
Rob Clark4b8f30a2011-08-28 12:51:26 -0500535 DRI2CloseScreen(pScreen);
536}