1 | /*
|
---|
2 | * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
---|
3 | * All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
6 | * copy of this software and associated documentation files (the
|
---|
7 | * "Software"), to deal in the Software without restriction, including
|
---|
8 | * without limitation the rights to use, copy, modify, merge, publish,
|
---|
9 | * distribute, sub license, and/or sell copies of the Software, and to
|
---|
10 | * permit persons to whom the Software is furnished to do so, subject to
|
---|
11 | * the following conditions:
|
---|
12 | *
|
---|
13 | * The above copyright notice and this permission notice (including the
|
---|
14 | * next paragraph) shall be included in all copies or substantial portions
|
---|
15 | * of the Software.
|
---|
16 | *
|
---|
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
---|
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
---|
20 | * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
---|
21 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
---|
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
---|
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
24 | *
|
---|
25 | *
|
---|
26 | * Author: Alan Hourihane <[email protected]>
|
---|
27 | *
|
---|
28 | */
|
---|
29 |
|
---|
30 | #include <errno.h>
|
---|
31 | #include <drm.h>
|
---|
32 | #include <xf86drm.h>
|
---|
33 | #include <xf86Crtc.h>
|
---|
34 | #include <damage.h>
|
---|
35 |
|
---|
36 | #ifdef GLAMOR
|
---|
37 | #define GLAMOR_FOR_XORG 1
|
---|
38 | #include "glamor.h"
|
---|
39 | #ifdef GLAMOR_HAS_GBM
|
---|
40 | #include <gbm.h>
|
---|
41 | #endif
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #include "drmmode_display.h"
|
---|
45 | #define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
|
---|
46 |
|
---|
47 | typedef struct {
|
---|
48 | int lastInstance;
|
---|
49 | int refCount;
|
---|
50 | ScrnInfoPtr pScrn_1;
|
---|
51 | ScrnInfoPtr pScrn_2;
|
---|
52 | } EntRec, *EntPtr;
|
---|
53 |
|
---|
54 | typedef void (*ms_drm_handler_proc)(uint64_t frame,
|
---|
55 | uint64_t usec,
|
---|
56 | void *data);
|
---|
57 |
|
---|
58 | typedef void (*ms_drm_abort_proc)(void *data);
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * A tracked handler for an event that will hopefully be generated by
|
---|
62 | * the kernel, and what to do when it is encountered.
|
---|
63 | */
|
---|
64 | struct ms_drm_queue {
|
---|
65 | struct xorg_list list;
|
---|
66 | xf86CrtcPtr crtc;
|
---|
67 | uint32_t seq;
|
---|
68 | void *data;
|
---|
69 | ScrnInfoPtr scrn;
|
---|
70 | ms_drm_handler_proc handler;
|
---|
71 | ms_drm_abort_proc abort;
|
---|
72 | };
|
---|
73 |
|
---|
74 | typedef struct _modesettingRec {
|
---|
75 | int fd;
|
---|
76 |
|
---|
77 | EntPtr entityPrivate;
|
---|
78 |
|
---|
79 | int Chipset;
|
---|
80 | EntityInfoPtr pEnt;
|
---|
81 | #if XSERVER_LIBPCIACCESS
|
---|
82 | struct pci_device *PciInfo;
|
---|
83 | #else
|
---|
84 | pciVideoPtr PciInfo;
|
---|
85 | PCITAG PciTag;
|
---|
86 | #endif
|
---|
87 |
|
---|
88 | Bool noAccel;
|
---|
89 | CloseScreenProcPtr CloseScreen;
|
---|
90 |
|
---|
91 | /* Broken-out options. */
|
---|
92 | OptionInfoPtr Options;
|
---|
93 |
|
---|
94 | unsigned int SaveGeneration;
|
---|
95 |
|
---|
96 | CreateScreenResourcesProcPtr createScreenResources;
|
---|
97 | ScreenBlockHandlerProcPtr BlockHandler;
|
---|
98 | void *driver;
|
---|
99 |
|
---|
100 | drmmode_rec drmmode;
|
---|
101 |
|
---|
102 | drmEventContext event_context;
|
---|
103 |
|
---|
104 | DamagePtr damage;
|
---|
105 | Bool dirty_enabled;
|
---|
106 |
|
---|
107 | uint32_t cursor_width, cursor_height;
|
---|
108 | } modesettingRec, *modesettingPtr;
|
---|
109 |
|
---|
110 | #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
|
---|
111 |
|
---|
112 | uint32_t ms_drm_queue_alloc(xf86CrtcPtr crtc,
|
---|
113 | void *data,
|
---|
114 | ms_drm_handler_proc handler,
|
---|
115 | ms_drm_abort_proc abort);
|
---|
116 |
|
---|
117 | void ms_drm_abort(ScrnInfoPtr scrn,
|
---|
118 | Bool (*match)(void *data, void *match_data),
|
---|
119 | void *match_data);
|
---|
120 |
|
---|
121 | xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw);
|
---|
122 | xf86CrtcPtr ms_covering_crtc(ScrnInfoPtr scrn, BoxPtr box,
|
---|
123 | xf86CrtcPtr desired, BoxPtr crtc_box_ret);
|
---|
124 |
|
---|
125 | int ms_get_crtc_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
|
---|
126 |
|
---|
127 | uint32_t ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect);
|
---|
128 | uint64_t ms_kernel_msc_to_crtc_msc(xf86CrtcPtr crtc, uint32_t sequence);
|
---|
129 |
|
---|
130 |
|
---|
131 | Bool ms_dri2_screen_init(ScreenPtr screen);
|
---|
132 | void ms_dri2_close_screen(ScreenPtr screen);
|
---|
133 |
|
---|
134 | Bool ms_vblank_screen_init(ScreenPtr screen);
|
---|
135 | void ms_vblank_close_screen(ScreenPtr screen);
|
---|
136 |
|
---|
137 | Bool ms_present_screen_init(ScreenPtr screen);
|
---|