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 | #define MS_LOGLEVEL_DEBUG 4
|
---|
47 |
|
---|
48 | typedef enum {
|
---|
49 | OPTION_SW_CURSOR,
|
---|
50 | OPTION_DEVICE_PATH,
|
---|
51 | OPTION_SHADOW_FB,
|
---|
52 | OPTION_ACCEL_METHOD,
|
---|
53 | OPTION_PAGEFLIP,
|
---|
54 | OPTION_ZAPHOD_HEADS,
|
---|
55 | } modesettingOpts;
|
---|
56 |
|
---|
57 | typedef struct
|
---|
58 | {
|
---|
59 | int fd;
|
---|
60 | int fd_ref;
|
---|
61 | unsigned long fd_wakeup_registered; /* server generation for which fd has been registered for wakeup handling */
|
---|
62 | int fd_wakeup_ref;
|
---|
63 | unsigned int assigned_crtcs;
|
---|
64 | #ifdef XSERVER_PLATFORM_BUS
|
---|
65 | struct xf86_platform_device *platform_dev;
|
---|
66 | #endif
|
---|
67 | } modesettingEntRec, *modesettingEntPtr;
|
---|
68 |
|
---|
69 | typedef void (*ms_drm_handler_proc)(uint64_t frame,
|
---|
70 | uint64_t usec,
|
---|
71 | void *data);
|
---|
72 |
|
---|
73 | typedef void (*ms_drm_abort_proc)(void *data);
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * A tracked handler for an event that will hopefully be generated by
|
---|
77 | * the kernel, and what to do when it is encountered.
|
---|
78 | */
|
---|
79 | struct ms_drm_queue {
|
---|
80 | struct xorg_list list;
|
---|
81 | xf86CrtcPtr crtc;
|
---|
82 | uint32_t seq;
|
---|
83 | void *data;
|
---|
84 | ScrnInfoPtr scrn;
|
---|
85 | ms_drm_handler_proc handler;
|
---|
86 | ms_drm_abort_proc abort;
|
---|
87 | };
|
---|
88 |
|
---|
89 | typedef struct _modesettingRec {
|
---|
90 | int fd;
|
---|
91 |
|
---|
92 | int Chipset;
|
---|
93 | EntityInfoPtr pEnt;
|
---|
94 | #if XSERVER_LIBPCIACCESS
|
---|
95 | struct pci_device *PciInfo;
|
---|
96 | #else
|
---|
97 | pciVideoPtr PciInfo;
|
---|
98 | PCITAG PciTag;
|
---|
99 | #endif
|
---|
100 |
|
---|
101 | Bool noAccel;
|
---|
102 | CloseScreenProcPtr CloseScreen;
|
---|
103 |
|
---|
104 | unsigned int SaveGeneration;
|
---|
105 |
|
---|
106 | CreateScreenResourcesProcPtr createScreenResources;
|
---|
107 | ScreenBlockHandlerProcPtr BlockHandler;
|
---|
108 | void *driver;
|
---|
109 |
|
---|
110 | drmmode_rec drmmode;
|
---|
111 |
|
---|
112 | drmEventContext event_context;
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * Page flipping stuff.
|
---|
116 | * @{
|
---|
117 | */
|
---|
118 | /** @} */
|
---|
119 |
|
---|
120 | DamagePtr damage;
|
---|
121 | Bool dirty_enabled;
|
---|
122 |
|
---|
123 | uint32_t cursor_width, cursor_height;
|
---|
124 | } modesettingRec, *modesettingPtr;
|
---|
125 |
|
---|
126 | #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
|
---|
127 | modesettingEntPtr ms_ent_priv(ScrnInfoPtr scrn);
|
---|
128 |
|
---|
129 | uint32_t ms_drm_queue_alloc(xf86CrtcPtr crtc,
|
---|
130 | void *data,
|
---|
131 | ms_drm_handler_proc handler,
|
---|
132 | ms_drm_abort_proc abort);
|
---|
133 |
|
---|
134 | void ms_drm_abort(ScrnInfoPtr scrn,
|
---|
135 | Bool (*match)(void *data, void *match_data),
|
---|
136 | void *match_data);
|
---|
137 | void ms_drm_abort_seq(ScrnInfoPtr scrn, uint32_t seq);
|
---|
138 |
|
---|
139 | Bool ms_crtc_on(xf86CrtcPtr crtc);
|
---|
140 |
|
---|
141 | xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw);
|
---|
142 | xf86CrtcPtr ms_covering_crtc(ScrnInfoPtr scrn, BoxPtr box,
|
---|
143 | xf86CrtcPtr desired, BoxPtr crtc_box_ret);
|
---|
144 |
|
---|
145 | int ms_get_crtc_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
|
---|
146 |
|
---|
147 | uint32_t ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect);
|
---|
148 | uint64_t ms_kernel_msc_to_crtc_msc(xf86CrtcPtr crtc, uint32_t sequence);
|
---|
149 |
|
---|
150 |
|
---|
151 | Bool ms_dri2_screen_init(ScreenPtr screen);
|
---|
152 | void ms_dri2_close_screen(ScreenPtr screen);
|
---|
153 |
|
---|
154 | Bool ms_vblank_screen_init(ScreenPtr screen);
|
---|
155 | void ms_vblank_close_screen(ScreenPtr screen);
|
---|
156 |
|
---|
157 | Bool ms_present_screen_init(ScreenPtr screen);
|
---|