4 Copyright (c) 1995 Jon Tombs
5 Copyright (c) 1995, 1996, 1999 XFree86 Inc
9 #ifdef HAVE_XORG_CONFIG_H
10 #include <xorg-config.h>
16 #include <X11/Xproto.h>
18 #include "dixstruct.h"
19 #include "extnsionst.h"
20 #include "colormapst.h"
21 #include "cursorstr.h"
22 #include "scrnintstr.h"
24 #define _XF86DGA_SERVER_
25 #include <X11/extensions/xf86dga.h>
26 #include <X11/extensions/xf86dgastr.h>
30 #include "xf86dgaext.h"
33 static DISPATCH_PROC(ProcXF86DGADirectVideo
);
34 static DISPATCH_PROC(ProcXF86DGAGetVidPage
);
35 static DISPATCH_PROC(ProcXF86DGAGetVideoLL
);
36 static DISPATCH_PROC(ProcXF86DGAGetViewPortSize
);
37 static DISPATCH_PROC(ProcXF86DGASetVidPage
);
38 static DISPATCH_PROC(ProcXF86DGASetViewPort
);
39 static DISPATCH_PROC(ProcXF86DGAInstallColormap
);
40 static DISPATCH_PROC(ProcXF86DGAQueryDirectVideo
);
41 static DISPATCH_PROC(ProcXF86DGAViewPortChanged
);
45 ProcXF86DGAGetVideoLL(ClientPtr client
)
47 REQUEST(xXF86DGAGetVideoLLReq
);
48 xXF86DGAGetVideoLLReply rep
;
50 int num
, offset
, flags
;
53 if (stuff
->screen
> screenInfo
.numScreens
)
56 REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq
);
59 rep
.sequenceNumber
= client
->sequence
;
61 if(!DGAAvailable(stuff
->screen
))
62 return (DGAErrorBase
+ XF86DGANoDirectVideoMode
);
64 if(!(num
= DGAGetOldDGAMode(stuff
->screen
)))
65 return (DGAErrorBase
+ XF86DGANoDirectVideoMode
);
67 /* get the parameters for the mode that best matches */
68 DGAGetModeInfo(stuff
->screen
, &mode
, num
);
70 if(!DGAOpenFramebuffer(stuff
->screen
, &name
,
71 (unsigned char**)(&rep
.offset
),
72 (int*)(&rep
.bank_size
), &offset
, &flags
))
75 rep
.offset
+= mode
.offset
;
76 rep
.width
= mode
.bytesPerScanline
/ (mode
.bitsPerPixel
>> 3);
77 rep
.ram_size
= rep
.bank_size
>> 10;
79 WriteToClient(client
, SIZEOF(xXF86DGAGetVideoLLReply
), (char *)&rep
);
80 return (client
->noClientException
);
84 ProcXF86DGADirectVideo(ClientPtr client
)
89 REQUEST(xXF86DGADirectVideoReq
);
91 if (stuff
->screen
> screenInfo
.numScreens
)
94 REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq
);
96 if (!DGAAvailable(stuff
->screen
))
97 return DGAErrorBase
+ XF86DGANoDirectVideoMode
;
99 if (stuff
->enable
& XF86DGADirectGraphics
) {
100 if(!(num
= DGAGetOldDGAMode(stuff
->screen
)))
101 return (DGAErrorBase
+ XF86DGANoDirectVideoMode
);
105 if(Success
!= DGASetMode(stuff
->screen
, num
, &mode
, &pix
))
106 return (DGAErrorBase
+ XF86DGAScreenNotActive
);
108 DGASetInputMode (stuff
->screen
,
109 (stuff
->enable
& XF86DGADirectKeyb
) != 0,
110 (stuff
->enable
& XF86DGADirectMouse
) != 0);
112 return (client
->noClientException
);
116 ProcXF86DGAGetViewPortSize(ClientPtr client
)
120 REQUEST(xXF86DGAGetViewPortSizeReq
);
121 xXF86DGAGetViewPortSizeReply rep
;
123 if (stuff
->screen
> screenInfo
.numScreens
)
126 REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq
);
129 rep
.sequenceNumber
= client
->sequence
;
131 if (!DGAAvailable(stuff
->screen
))
132 return (DGAErrorBase
+ XF86DGANoDirectVideoMode
);
134 if(!(num
= DGAGetOldDGAMode(stuff
->screen
)))
135 return (DGAErrorBase
+ XF86DGANoDirectVideoMode
);
137 DGAGetModeInfo(stuff
->screen
, &mode
, num
);
139 rep
.width
= mode
.viewportWidth
;
140 rep
.height
= mode
.viewportHeight
;
142 WriteToClient(client
, SIZEOF(xXF86DGAGetViewPortSizeReply
), (char *)&rep
);
143 return (client
->noClientException
);
147 ProcXF86DGASetViewPort(ClientPtr client
)
149 REQUEST(xXF86DGASetViewPortReq
);
151 if (stuff
->screen
> screenInfo
.numScreens
)
154 REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq
);
156 if (!DGAActive(stuff
->screen
))
162 if(!(num
= DGAGetOldDGAMode(stuff
->screen
)))
163 return (DGAErrorBase
+ XF86DGANoDirectVideoMode
);
164 if(Success
!= DGASetMode(stuff
->screen
, num
, &mode
, &pix
))
165 return (DGAErrorBase
+ XF86DGAScreenNotActive
);
168 if (DGASetViewport(stuff
->screen
, stuff
->x
, stuff
->y
, DGA_FLIP_RETRACE
)
170 return DGAErrorBase
+ XF86DGADirectNotActivated
;
172 return (client
->noClientException
);
176 ProcXF86DGAGetVidPage(ClientPtr client
)
178 REQUEST(xXF86DGAGetVidPageReq
);
179 xXF86DGAGetVidPageReply rep
;
181 if (stuff
->screen
> screenInfo
.numScreens
)
184 REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq
);
187 rep
.sequenceNumber
= client
->sequence
;
188 rep
.vpage
= 0; /* silently fail */
190 WriteToClient(client
, SIZEOF(xXF86DGAGetVidPageReply
), (char *)&rep
);
191 return (client
->noClientException
);
196 ProcXF86DGASetVidPage(ClientPtr client
)
198 REQUEST(xXF86DGASetVidPageReq
);
200 if (stuff
->screen
> screenInfo
.numScreens
)
203 REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq
);
207 return (client
->noClientException
);
212 ProcXF86DGAInstallColormap(ClientPtr client
)
215 REQUEST(xXF86DGAInstallColormapReq
);
217 REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq
);
219 if (!DGAActive(stuff
->screen
))
220 return (DGAErrorBase
+ XF86DGADirectNotActivated
);
222 pcmp
= (ColormapPtr
)LookupIDByType(stuff
->id
, RT_COLORMAP
);
224 DGAInstallCmap(pcmp
);
225 return (client
->noClientException
);
227 client
->errorValue
= stuff
->id
;
233 ProcXF86DGAQueryDirectVideo(ClientPtr client
)
235 REQUEST(xXF86DGAQueryDirectVideoReq
);
236 xXF86DGAQueryDirectVideoReply rep
;
238 if (stuff
->screen
> screenInfo
.numScreens
)
241 REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq
);
244 rep
.sequenceNumber
= client
->sequence
;
247 if (DGAAvailable(stuff
->screen
))
248 rep
.flags
= XF86DGADirectPresent
;
250 WriteToClient(client
, SIZEOF(xXF86DGAQueryDirectVideoReply
), (char *)&rep
);
251 return (client
->noClientException
);
255 ProcXF86DGAViewPortChanged(ClientPtr client
)
257 REQUEST(xXF86DGAViewPortChangedReq
);
258 xXF86DGAViewPortChangedReply rep
;
260 if (stuff
->screen
> screenInfo
.numScreens
)
263 REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq
);
265 if (!DGAActive(stuff
->screen
))
266 return (DGAErrorBase
+ XF86DGADirectNotActivated
);
270 rep
.sequenceNumber
= client
->sequence
;
273 WriteToClient(client
, SIZEOF(xXF86DGAViewPortChangedReply
), (char *)&rep
);
274 return (client
->noClientException
);
278 ProcXF86DGADispatch(register ClientPtr client
)
284 case X_XF86DGAGetVideoLL
:
285 return ProcXF86DGAGetVideoLL(client
);
286 case X_XF86DGADirectVideo
:
287 return ProcXF86DGADirectVideo(client
);
288 case X_XF86DGAGetViewPortSize
:
289 return ProcXF86DGAGetViewPortSize(client
);
290 case X_XF86DGASetViewPort
:
291 return ProcXF86DGASetViewPort(client
);
292 case X_XF86DGAGetVidPage
:
293 return ProcXF86DGAGetVidPage(client
);
294 case X_XF86DGASetVidPage
:
295 return ProcXF86DGASetVidPage(client
);
296 case X_XF86DGAInstallColormap
:
297 return ProcXF86DGAInstallColormap(client
);
298 case X_XF86DGAQueryDirectVideo
:
299 return ProcXF86DGAQueryDirectVideo(client
);
300 case X_XF86DGAViewPortChanged
:
301 return ProcXF86DGAViewPortChanged(client
);