Miniglx clients now authorize with server DRM
[mesa.git] / src / glx / mini / miniglxP.h
1 /**
2 * \file miniglxP.h
3 * \brief Define replacements for some X data types and define the DRI-related
4 * data structures.
5 *
6 * \note Cut down version of glxclient.h.
7 *
8 */
9
10 #ifndef _mini_GLX_client_h_
11 #define _mini_GLX_client_h_
12
13 #include <signal.h>
14 #include <linux/fb.h>
15
16 #include <GL/miniglx.h>
17 #include "glheader.h"
18 #include "mtypes.h"
19
20 #include "driver.h"
21 #include "GL/internal/dri_interface.h"
22
23 /**
24 * \brief Supported pixel formats.
25 */
26 enum PixelFormat {
27 PF_B8G8R8, /**< \brief 24-bit BGR */
28 PF_B8G8R8A8, /**< \brief 32-bit BGRA */
29 PF_B5G6R5, /**< \brief 16-bit BGR */
30 PF_B5G5R5, /**< \brief 15-bit BGR */
31 PF_CI8 /**< \brief 8-bit color index */
32 };
33
34 /**
35 * \brief X Visual type.
36 *
37 * \sa ::Visual, \ref datatypes.
38 */
39 struct MiniGLXVisualRec {
40 /** \brief GLX visual information */
41 const __GLcontextModes *mode;
42
43 /** \brief pointer back to corresponding ::XVisualInfo */
44 XVisualInfo *visInfo;
45
46 /** \brief display handle */
47 Display *dpy;
48
49 /** \brief pixel format */
50 enum PixelFormat pixelFormat;
51 };
52
53
54
55 /**
56 * \brief X Window type.
57 *
58 * \sa ::Window, \ref datatypes.
59 */
60 struct MiniGLXWindowRec {
61 Visual *visual;
62 /** \brief position (always 0,0) */
63 int x, y;
64 /** \brief size */
65 unsigned int w, h;
66 void *frontStart; /**< \brief start of front color buffer */
67 void *backStart; /**< \brief start of back color buffer */
68 size_t size; /**< \brief color buffer size, in bytes */
69 GLuint bytesPerPixel;
70 GLuint rowStride; /**< \brief in bytes */
71 GLubyte *frontBottom; /**< \brief pointer to last row */
72 GLubyte *backBottom; /**< \brief pointer to last row */
73 GLubyte *curBottom; /**< = frontBottom or backBottom */
74 __DRIdrawable driDrawable;
75 GLuint ismapped;
76 };
77
78
79 /**
80 * \brief GLXContext type.
81 *
82 * \sa ::GLXContext, \ref datatypes.
83 */
84 struct MiniGLXContextRec {
85 Window drawBuffer; /**< \brief drawing buffer */
86 Window curBuffer; /**< \brief current buffer */
87 VisualID vid; /**< \brief visual ID */
88 __DRIcontext driContext; /**< \brief context dependent methods */
89 };
90
91 #define MINIGLX_BUF_SIZE 512
92 #define MINIGLX_MAX_SERVER_FDS 10
93 #define MINIGLX_MAX_CLIENT_FDS 1
94 #define MINIGLX_EVENT_QUEUE_SZ 16
95 #define MINIGLX_EVENT_QUEUE_MASK (MINIGLX_EVENT_QUEUE_SZ-1)
96
97 /**
98 * A connection to/from the server
99 *
100 * All information is to/from the server is buffered and then dispatched by
101 * __miniglx_Select() to avoid blocking the server.
102 */
103 struct MiniGLXConnection {
104 int fd; /**< \brief file descriptor */
105 char readbuf[MINIGLX_BUF_SIZE]; /**< \brief read buffer */
106 char writebuf[MINIGLX_BUF_SIZE]; /**< \brief write buffer */
107 int readbuf_count; /**< \brief count of bytes waiting to be read */
108 int writebuf_count; /**< \brief count of bytes waiting to be written */
109 };
110
111
112 /**
113 * \brief X Display type
114 *
115 * \sa ::Display, \ref datatypes.
116 */
117 struct MiniGLXDisplayRec {
118 /** \brief fixed framebuffer screen info */
119 struct fb_fix_screeninfo FixedInfo;
120 /** \brief original and current variable framebuffer screen info */
121 struct fb_var_screeninfo OrigVarInfo, VarInfo;
122 struct sigaction OrigSigUsr1;
123 struct sigaction OrigSigUsr2;
124 int OriginalVT;
125 int ConsoleFD; /**< \brief console TTY device file descriptor */
126 int FrameBufferFD; /**< \brief framebuffer device file descriptor */
127 int NumWindows; /**< \brief number of open windows */
128 Window TheWindow; /**< \brief open window - only allow one window for now */
129 int rotateMode;
130
131
132 volatile int vtSignalFlag;
133 volatile int haveVT; /**< \brief whether the VT is hold */
134 int hwActive; /**< \brief whether the hardware is active -- mimics
135 the variations of MiniGLXDisplayRec::haveVT */
136
137
138 int IsClient; /**< \brief whether it's a client or the server */
139 int clientID;
140 int nrFds; /**< \brief number of connections (usually just one for the clients) */
141 struct MiniGLXConnection *fd; /**< \brief connections */
142 int drmFd; /**< \brief handle to drm device */
143 int authorized; /**< \brief has server authorized this process? */
144
145 struct {
146 int nr, head, tail;
147 XEvent queue[MINIGLX_EVENT_QUEUE_SZ];
148 } eventqueue;
149
150 /**
151 * \name Visuals
152 *
153 * Visuals (configs) in this screen.
154 */
155 /*@{*/
156 const __GLcontextModes *driver_modes; /**< \brief Modes filtered by driver. */
157 /*@}*/
158
159 /**
160 * \name From __GLXdisplayPrivate
161 */
162 /*@{*/
163 PFNCREATENEWSCREENFUNC createNewScreen; /**< \brief \e __driCreateScreen hook */
164 __DRIscreen driScreen; /**< \brief Screen dependent methods */
165 void *dlHandle; /**<
166 * \brief handle to the client dynamic
167 * library
168 */
169 /*@}*/
170
171 /**
172 * \brief Mini GLX specific driver hooks
173 */
174 struct DRIDriverRec *driver;
175 struct DRIDriverContextRec driverContext;
176
177 /**
178 * \name Configuration details
179 *
180 * They are read from a configuration file by __read_config_file().
181 */
182 /*@{*/
183 const char *fbdevDevice;
184 const char *clientDriverName;
185 /*@}*/
186 };
187
188 /** Character messages. */
189 enum msgs {
190 _CanIHaveFocus,
191 _IDontWantFocus,
192 _YouveGotFocus,
193 _YouveLostFocus,
194 _RepaintPlease,
195 _Authorize,
196 };
197 extern int send_msg( Display *dpy, int i, const void *msg, size_t sz );
198 extern int send_char_msg( Display *dpy, int i, char msg );
199 extern int blocking_read( Display *dpy, int connection, char *msg, size_t msg_size );
200 extern int handle_fd_events( Display *dpy, int nonblock );
201
202
203 extern Bool __glXWindowExists(__DRInativeDisplay *dpy, GLXDrawable draw);
204
205 extern int __miniglx_open_connections( Display *dpy );
206 extern void __miniglx_close_connections( Display *dpy );
207
208 #endif /* !_mini_GLX_client_h_ */