patch to import Jon Smirl's work from Bitkeeper
[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 #define CAPI /* XXX this should be globally defined somewhere */
51
52 #include "GL/gl.h"
53 #include "GL/internal/glcore.h"
54
55 /**
56 * \brief Clip rectangle definition.
57 */
58 typedef struct _XF86DRIClipRect {
59 unsigned short x1; /**< \brief Upper: inclusive */
60 unsigned short y1; /**< \brief Left: inclusive */
61 unsigned short x2; /**< \brief Lower: exclusive */
62 unsigned short y2; /**< \brief Right: exclusive */
63 } XF86DRIClipRectRec, *XF86DRIClipRectPtr;
64
65 /**
66 * \brief DRIDriverContext type.
67 */
68 typedef struct DRIDriverContextRec {
69 const char *pciBusID;
70 int pciBus;
71 int pciDevice;
72 int pciFunc;
73 int chipset;
74 int bpp;
75 int cpp;
76
77 unsigned long FBStart; /**< \brief physical address of the framebuffer */
78 unsigned long MMIOStart; /**< \brief physical address of the MMIO region */
79
80 int FBSize; /**< \brief size of the mmap'd framebuffer in bytes */
81 int MMIOSize; /**< \brief size of the mmap'd MMIO region in bytes */
82
83 void *FBAddress; /**< \brief start of the mmap'd framebuffer */
84 void *MMIOAddress; /**< \brief start of the mmap'd MMIO region */
85
86 /**
87 * \brief Client configuration details
88 *
89 * These are computed on the server and sent to clients as part of
90 * the initial handshaking.
91 */
92 struct {
93 unsigned long hSAREA;
94 int SAREASize;
95 unsigned long hFrameBuffer;
96 int fbOrigin;
97 int fbSize;
98 int fbStride;
99 int virtualWidth;
100 int virtualHeight;
101 } shared;
102
103 /**
104 * \name From DRIInfoRec
105 */
106 /*@{*/
107 int drmFD; /**< \brief DRM device file descriptor */
108 struct _XF86DRISAREA *pSAREA;
109 unsigned int serverContext; /**< \brief DRM context only active on server */
110 /*@}*/
111
112
113 /**
114 * \name Driver private
115 *
116 * Populated by __driInitFBDev()
117 */
118 /*@{*/
119 void *driverPrivate;
120 void *driverClientMsg;
121 int driverClientMsgSize;
122 /*@}*/
123 } DRIDriverContext;
124
125 /**
126 * \brief Interface to the DRI driver.
127 *
128 * This structure is retrieved from the loadable driver by the \e
129 * __driDriver symbol to access the Mini GLX specific hardware
130 * initialization and take down routines.
131 */
132 typedef struct DRIDriverRec {
133 /**
134 * \brief Get the list of supported gl context modes.
135 */
136 int (*initContextModes)( const DRIDriverContext *context,
137 int *numModes, const __GLcontextModes **modes );
138 /**
139 * \brief Validate the framebuffer device mode
140 */
141 int (*validateMode)( const DRIDriverContext *context );
142
143 /**
144 * \brief Examine mode returned by fbdev (may differ from the one
145 * requested), restore any hw regs clobbered by fbdev.
146 */
147 int (*postValidateMode)( const DRIDriverContext *context );
148
149 /**
150 * \brief Initialize the framebuffer device.
151 */
152 int (*initFBDev)( DRIDriverContext *context );
153
154 /**
155 * \brief Halt the framebuffer device.
156 */
157 void (*haltFBDev)( DRIDriverContext *context );
158
159
160 /**
161 * \brief Idle and shutdown hardware in preparation for a VT switch.
162 */
163 int (*shutdownHardware)( const DRIDriverContext *context );
164
165 /**
166 * \brief Restore hardware state after regaining the VT.
167 */
168 int (*restoreHardware)( const DRIDriverContext *context );
169
170 /**
171 * \brief Notify hardware driver of gain/loose focus. May be zero
172 * as this is of limited utility for most drivers.
173 */
174 void (*notifyFocus)( int have_focus );
175 } DRIDriver;
176
177 #endif /* _driver_H_ */