egl_dri2: Fix initialization with EGL_DEFAULT_DISPLAY
[mesa.git] / src / glx / mini / driver.h
1 /**
2 * \file driver.h
3 * \brief DRI utility functions definitions.
4 *
5 * This module acts as glue between GLX and the actual hardware driver. A DRI
6 * driver doesn't really \e have to use any of this - it's optional. But, some
7 * useful stuff is done here that otherwise would have to be duplicated in most
8 * drivers.
9 *
10 * Basically, these utility functions take care of some of the dirty details of
11 * screen initialization, context creation, context binding, DRM setup, etc.
12 *
13 * These functions are compiled into each DRI driver so libGL.so knows nothing
14 * about them.
15 *
16 * Look for more comments in the dri_util.c file.
17 *
18 * \author Kevin E. Martin <kevin@precisioninsight.com>
19 * \author Brian Paul <brian@precisioninsight.com>
20 */
21
22 /*
23 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
24 * All Rights Reserved.
25 *
26 * Permission is hereby granted, free of charge, to any person obtaining a
27 * copy of this software and associated documentation files (the
28 * "Software"), to deal in the Software without restriction, including
29 * without limitation the rights to use, copy, modify, merge, publish,
30 * distribute, sub license, and/or sell copies of the Software, and to
31 * permit persons to whom the Software is furnished to do so, subject to
32 * the following conditions:
33 *
34 * The above copyright notice and this permission notice (including the
35 * next paragraph) shall be included in all copies or substantial portions
36 * of the Software.
37 *
38 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
39 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
40 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
41 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
42 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
43 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
44 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45 */
46
47 #ifndef _driver_H_
48 #define _driver_H_
49
50 #include "GL/gl.h"
51 #include "GL/internal/glcore.h"
52
53 #include "drm.h"
54 #include "drm_sarea.h"
55
56 /**
57 * \brief DRIDriverContext type.
58 */
59 typedef struct DRIDriverContextRec {
60 const char *pciBusID;
61 int pciBus;
62 int pciDevice;
63 int pciFunc;
64 int chipset;
65 int bpp;
66 int cpp;
67 int agpmode;
68 int isPCI;
69
70 int colorTiling; /**< \brief color tiling is enabled */
71
72 unsigned long FBStart; /**< \brief physical address of the framebuffer */
73 unsigned long MMIOStart; /**< \brief physical address of the MMIO region */
74
75 int FBSize; /**< \brief size of the mmap'd framebuffer in bytes */
76 int MMIOSize; /**< \brief size of the mmap'd MMIO region in bytes */
77
78 void *FBAddress; /**< \brief start of the mmap'd framebuffer */
79 void *MMIOAddress; /**< \brief start of the mmap'd MMIO region */
80
81 /**
82 * \brief Client configuration details
83 *
84 * These are computed on the server and sent to clients as part of
85 * the initial handshaking.
86 */
87 struct {
88 drm_handle_t hSAREA;
89 int SAREASize;
90 drm_handle_t hFrameBuffer;
91 int fbOrigin;
92 int fbSize;
93 int fbStride;
94 int virtualWidth;
95 int virtualHeight;
96 int Width;
97 } shared;
98
99 /**
100 * \name From DRIInfoRec
101 */
102 /*@{*/
103 int drmFD; /**< \brief DRM device file descriptor */
104 drm_sarea_t *pSAREA;
105 unsigned int serverContext; /**< \brief DRM context only active on server */
106 /*@}*/
107
108
109 /**
110 * \name Driver private
111 *
112 * Populated by __driInitFBDev()
113 */
114 /*@{*/
115 void *driverPrivate;
116 void *driverClientMsg;
117 int driverClientMsgSize;
118 /*@}*/
119 } DRIDriverContext;
120
121 /**
122 * \brief Interface to the DRI driver.
123 *
124 * This structure is retrieved from the loadable driver by the \e
125 * __driDriver symbol to access the Mini GLX specific hardware
126 * initialization and take down routines.
127 */
128 typedef struct DRIDriverRec {
129 /**
130 * \brief Validate the framebuffer device mode
131 */
132 int (*validateMode)( const DRIDriverContext *context );
133
134 /**
135 * \brief Examine mode returned by fbdev (may differ from the one
136 * requested), restore any hw regs clobbered by fbdev.
137 */
138 int (*postValidateMode)( const DRIDriverContext *context );
139
140 /**
141 * \brief Initialize the framebuffer device.
142 */
143 int (*initFBDev)( DRIDriverContext *context );
144
145 /**
146 * \brief Halt the framebuffer device.
147 */
148 void (*haltFBDev)( DRIDriverContext *context );
149
150
151 /**
152 * \brief Idle and shutdown hardware in preparation for a VT switch.
153 */
154 int (*shutdownHardware)( const DRIDriverContext *context );
155
156 /**
157 * \brief Restore hardware state after regaining the VT.
158 */
159 int (*restoreHardware)( const DRIDriverContext *context );
160
161 /**
162 * \brief Notify hardware driver of gain/loose focus. May be zero
163 * as this is of limited utility for most drivers.
164 */
165 void (*notifyFocus)( int have_focus );
166 } DRIDriver;
167
168 #endif /* _driver_H_ */