vmwgfx_driver.h revision 34a0776d
1/*
2 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
3 * Copyright 2011 VMWare, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright n<otice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 *
27 * Author: Alan Hourihane <alanh@tungstengraphics.com>
28 * Author: Jakob Bornecrantz <wallbraker@gmail.com>
29 * Author: Thomas Hellstrom <thellstrom@vmware.com>
30 */
31
32#ifndef _VMWGFX_DRIVER_H_
33#define _VMWGFX_DRIVER_H_
34
35
36#include <stddef.h>
37#include <stdint.h>
38#include <errno.h>
39#include <drm.h>
40#include <xf86drm.h>
41#include <xf86drmMode.h>
42#include <xorg-server.h>
43#include <xf86.h>
44#include <xf86Crtc.h>
45#include <xf86xv.h>
46#include <xa_tracker.h>
47#include <xf86Module.h>
48
49#include "../src/compat-api.h"
50#ifdef DRI2
51#include <dri2.h>
52#if (!defined(DRI2INFOREC_VERSION) || (DRI2INFOREC_VERSION < 3))
53#undef DRI2
54#endif
55#endif
56
57#ifdef HAVE_LIBUDEV
58#include <libudev.h>
59#endif
60
61#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 12
62#define _swapl(x, n) swapl(x,n)
63#define _swaps(x, n) swaps(x,n)
64#else
65#define _swapl(x, n) (void) n; swapl(x)
66#define _swaps(x, n) (void) n; swaps(x)
67#endif
68
69#define DRV_ERROR(msg)	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
70#define debug_printf(...)
71
72#define VMWGFX_DRI_DEVICE_LEN 80
73
74typedef struct
75{
76    int lastInstance;
77    int refCount;
78    ScrnInfoPtr pScrn_1;
79    ScrnInfoPtr pScrn_2;
80} EntRec, *EntPtr;
81
82#define XORG_NR_FENCES 3
83
84enum xorg_throttling_reason {
85    THROTTLE_RENDER,
86    THROTTLE_SWAP
87};
88
89struct vmwgfx_hosted;
90struct xf86_platform_device;
91struct vmwgfx_layout;
92
93typedef struct _modesettingRec
94{
95    /* drm */
96    int fd;
97    int drm_major;
98    int drm_minor;
99    int drm_patch;
100
101    /* X */
102    EntPtr entityPrivate;
103
104    int Chipset;
105    EntityInfoPtr pEnt;
106    struct pci_device *PciInfo;
107    struct xf86_platform_device *platform_dev;
108
109    /* Accel */
110    Bool accelerate_render;
111    MessageType from_render;
112    Bool rendercheck;
113    MessageType from_rendercheck;
114    Bool SWCursor;
115    CursorPtr cursor;
116    Bool enable_dri;
117    MessageType from_dri;
118    Bool direct_presents;
119    MessageType from_dp;
120    Bool only_hw_presents;
121    MessageType from_hwp;
122    Bool isMaster;
123    Bool has_screen_targets;
124
125
126    /* Broken-out options. */
127    OptionInfoPtr Options;
128
129    ScreenBlockHandlerProcPtr saved_BlockHandler;
130    CreateScreenResourcesProcPtr saved_CreateScreenResources;
131    CloseScreenProcPtr saved_CloseScreen;
132    Bool (*saved_EnterVT)(VT_FUNC_ARGS_DECL);
133    void (*saved_LeaveVT)(VT_FUNC_ARGS_DECL);
134    void (*saved_AdjustFrame)(ADJUST_FRAME_ARGS_DECL);
135    Bool (*saved_UseHWCursor)(ScreenPtr, CursorPtr);
136    Bool (*saved_UseHWCursorARGB)(ScreenPtr, CursorPtr);
137
138    uint16_t lut_r[256], lut_g[256], lut_b[256];
139
140    Bool check_fb_size;
141    size_t max_fb_size;
142
143    struct xa_tracker *xat;
144    const struct vmwgfx_hosted_driver *hdriver;
145    struct vmwgfx_hosted *hosted;
146#ifdef DRI2
147    Bool dri2_available;
148    char dri2_device_name[VMWGFX_DRI_DEVICE_LEN];
149#endif
150#ifdef HAVE_LIBUDEV
151    struct udev_monitor *uevent_monitor;
152    InputHandlerProc uevent_handler;
153    struct vmwgfx_layout *layout;
154#endif
155    Bool autoLayout;
156} modesettingRec, *modesettingPtr;
157
158#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
159
160void xorg_flush(ScreenPtr pScreen);
161/***********************************************************************
162 * xorg_dri2.c
163 */
164Bool
165xorg_dri2_init(ScreenPtr pScreen);
166
167void
168xorg_dri2_close(ScreenPtr pScreen);
169
170
171/***********************************************************************
172 * xorg_crtc.c
173 */
174void
175xorg_crtc_init(ScrnInfoPtr pScrn);
176
177void
178xorg_crtc_cursor_destroy(xf86CrtcPtr crtc);
179
180void
181vmwgfx_disable_scanout(ScrnInfoPtr pScrn);
182
183PixmapPtr
184crtc_get_scanout(xf86CrtcPtr crtc);
185
186
187/***********************************************************************
188 * xorg_output.c
189 */
190void
191xorg_output_init(ScrnInfoPtr pScrn);
192
193unsigned
194xorg_output_get_id(xf86OutputPtr output);
195
196Bool
197vmwgfx_output_explicit_overlap(ScrnInfoPtr pScrn);
198void
199vmwgfx_uevent_init(ScrnInfoPtr scrn, modesettingPtr ms);
200void
201vmwgfx_uevent_fini(ScrnInfoPtr scrn, modesettingPtr ms);
202Bool
203vmwgfx_output_has_origin(xf86OutputPtr output);
204void
205vmwgfx_output_origin(xf86OutputPtr output, int *x, int *y);
206void
207vmwgfx_outputs_off(ScrnInfoPtr pScrn);
208void
209vmwgfx_outputs_on(ScrnInfoPtr pScrn);
210
211/***********************************************************************
212 * vmwgfx_layout.c
213 */
214struct vmwgfx_layout *
215vmwgfx_layout_from_kms(ScrnInfoPtr pScrn);
216void
217vmwgfx_layout_configuration(ScrnInfoPtr pScrn, struct vmwgfx_layout *layout);
218void
219vmwgfx_layout_handler(ScrnInfoPtr pScrn);
220
221/***********************************************************************
222 * xorg_xv.c
223 */
224void
225xorg_xv_init(ScreenPtr pScreen);
226
227XF86VideoAdaptorPtr
228vmw_video_init_adaptor(ScrnInfoPtr pScrn);
229void
230vmw_video_free_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports);
231
232void
233vmw_ctrl_ext_init(ScrnInfoPtr pScrn);
234
235#endif /* _XORG_TRACKER_H_ */
236