| @@ -1,1782 +1,1808 @@ | | | @@ -1,1782 +1,1808 @@ |
1 | /* | | 1 | /* |
2 | * Copyright © 2001-2012 Matthieu Herrb | | 2 | * Copyright © 2001-2012 Matthieu Herrb |
3 | * All rights reserved. | | 3 | * All rights reserved. |
4 | * | | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | | 6 | * modification, are permitted provided that the following conditions |
7 | * are met: | | 7 | * are met: |
8 | * | | 8 | * |
9 | * - Redistributions of source code must retain the above copyright | | 9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above | | 11 | * - Redistributions in binary form must reproduce the above |
12 | * copyright notice, this list of conditions and the following | | 12 | * copyright notice, this list of conditions and the following |
13 | * disclaimer in the documentation and/or other materials provided | | 13 | * disclaimer in the documentation and/or other materials provided |
14 | * with the distribution. | | 14 | * with the distribution. |
15 | * | | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | | 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | | 17 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | | 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | | 19 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
20 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | | 20 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 22 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | | 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 24 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
26 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 26 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
27 | * POSSIBILITY OF SUCH DAMAGE. | | 27 | * POSSIBILITY OF SUCH DAMAGE. |
28 | * | | 28 | * |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | /* | | 31 | /* |
32 | * Based on fbdev.c written by: | | 32 | * Based on fbdev.c written by: |
33 | * | | 33 | * |
34 | * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> | | 34 | * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> |
35 | * Michel Dänzer, <michdaen@iiic.ethz.ch> | | 35 | * Michel Dänzer, <michdaen@iiic.ethz.ch> |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #ifdef HAVE_CONFIG_H | | 38 | #ifdef HAVE_CONFIG_H |
39 | #include "config.h" | | 39 | #include "config.h" |
40 | #endif | | 40 | #endif |
41 | | | 41 | |
42 | #include <errno.h> | | 42 | #include <errno.h> |
43 | #include <fcntl.h> | | 43 | #include <fcntl.h> |
44 | #include <unistd.h> | | 44 | #include <unistd.h> |
45 | #include <sys/ioctl.h> | | 45 | #include <sys/ioctl.h> |
46 | #include <sys/types.h> | | 46 | #include <sys/types.h> |
47 | #include <sys/mman.h> | | 47 | #include <sys/mman.h> |
48 | #include <sys/time.h> | | 48 | #include <sys/time.h> |
49 | #include <errno.h> | | 49 | #include <errno.h> |
50 | #include <dev/wscons/wsconsio.h> | | 50 | #include <dev/wscons/wsconsio.h> |
51 | | | 51 | |
52 | /* All drivers need this. */ | | 52 | /* All drivers need this. */ |
53 | #include "xf86.h" | | 53 | #include "xf86.h" |
54 | #include "xf86_OSproc.h" | | 54 | #include "xf86_OSproc.h" |
55 | #include "xf86_OSlib.h" | | 55 | #include "xf86_OSlib.h" |
56 | | | 56 | |
57 | #include "mipointer.h" | | 57 | #include "mipointer.h" |
58 | #include "micmap.h" | | 58 | #include "micmap.h" |
59 | #include "colormapst.h" | | 59 | #include "colormapst.h" |
60 | #include "xf86cmap.h" | | 60 | #include "xf86cmap.h" |
61 | #include "shadow.h" | | 61 | #include "shadow.h" |
62 | #include "dgaproc.h" | | 62 | #include "dgaproc.h" |
63 | | | 63 | |
64 | /* For visuals */ | | 64 | /* For visuals */ |
65 | #include "fb.h" | | 65 | #include "fb.h" |
66 | | | 66 | |
67 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 | | 67 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 |
68 | #include "xf86Resources.h" | | 68 | #include "xf86Resources.h" |
69 | #include "xf86RAC.h" | | 69 | #include "xf86RAC.h" |
70 | #endif | | 70 | #endif |
71 | | | 71 | |
72 | #ifdef XvExtension | | 72 | #ifdef XvExtension |
73 | #include "xf86xv.h" | | 73 | #include "xf86xv.h" |
74 | #endif | | 74 | #endif |
75 | | | 75 | |
76 | #include "wsfb.h" | | 76 | #include "wsfb.h" |
77 | | | 77 | |
78 | /* #include "wsconsio.h" */ | | 78 | /* #include "wsconsio.h" */ |
79 | | | 79 | |
80 | #include <sys/mman.h> | | 80 | #include <sys/mman.h> |
81 | | | 81 | |
82 | #ifdef X_PRIVSEP | | 82 | #ifdef X_PRIVSEP |
83 | extern int priv_open_device(const char *); | | 83 | extern int priv_open_device(const char *); |
84 | #else | | 84 | #else |
85 | #define priv_open_device(n) open(n,O_RDWR|O_NONBLOCK|O_EXCL) | | 85 | #define priv_open_device(n) open(n,O_RDWR|O_NONBLOCK|O_EXCL) |
86 | #endif | | 86 | #endif |
87 | | | 87 | |
88 | #if defined(__NetBSD__) | | 88 | #if defined(__NetBSD__) |
89 | #define WSFB_DEFAULT_DEV "/dev/ttyE0" | | 89 | #define WSFB_DEFAULT_DEV "/dev/ttyE0" |
90 | #else | | 90 | #else |
91 | #define WSFB_DEFAULT_DEV "/dev/ttyC0" | | 91 | #define WSFB_DEFAULT_DEV "/dev/ttyC0" |
92 | #endif | | 92 | #endif |
93 | | | 93 | |
94 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 6 | | 94 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) > 6 |
95 | #define xf86LoaderReqSymLists(...) do {} while (0) | | 95 | #define xf86LoaderReqSymLists(...) do {} while (0) |
96 | #define LoaderRefSymLists(...) do {} while (0) | | 96 | #define LoaderRefSymLists(...) do {} while (0) |
97 | #define xf86LoaderReqSymbols(...) do {} while (0) | | 97 | #define xf86LoaderReqSymbols(...) do {} while (0) |
98 | #endif | | 98 | #endif |
99 | | | 99 | |
100 | #define DEBUG 0 | | 100 | #define DEBUG 0 |
101 | | | 101 | |
102 | #if DEBUG | | 102 | #if DEBUG |
103 | # define TRACE_ENTER(str) ErrorF("wsfb: " str " %d\n",pScrn->scrnIndex) | | 103 | # define TRACE_ENTER(str) ErrorF("wsfb: " str " %d\n",pScrn->scrnIndex) |
104 | # define TRACE_EXIT(str) ErrorF("wsfb: " str " done\n") | | 104 | # define TRACE_EXIT(str) ErrorF("wsfb: " str " done\n") |
105 | # define TRACE(str) ErrorF("wsfb trace: " str "\n") | | 105 | # define TRACE(str) ErrorF("wsfb trace: " str "\n") |
106 | #else | | 106 | #else |
107 | # define TRACE_ENTER(str) | | 107 | # define TRACE_ENTER(str) |
108 | # define TRACE_EXIT(str) | | 108 | # define TRACE_EXIT(str) |
109 | # define TRACE(str) | | 109 | # define TRACE(str) |
110 | #endif | | 110 | #endif |
111 | | | 111 | |
112 | /* Prototypes */ | | 112 | /* Prototypes */ |
113 | static pointer WsfbSetup(pointer, pointer, int *, int *); | | 113 | static pointer WsfbSetup(pointer, pointer, int *, int *); |
114 | static Bool WsfbGetRec(ScrnInfoPtr); | | 114 | static Bool WsfbGetRec(ScrnInfoPtr); |
115 | static void WsfbFreeRec(ScrnInfoPtr); | | 115 | static void WsfbFreeRec(ScrnInfoPtr); |
116 | static const OptionInfoRec * WsfbAvailableOptions(int, int); | | 116 | static const OptionInfoRec * WsfbAvailableOptions(int, int); |
117 | static void WsfbIdentify(int); | | 117 | static void WsfbIdentify(int); |
118 | static Bool WsfbProbe(DriverPtr, int); | | 118 | static Bool WsfbProbe(DriverPtr, int); |
119 | static Bool WsfbPreInit(ScrnInfoPtr, int); | | 119 | static Bool WsfbPreInit(ScrnInfoPtr, int); |
120 | static Bool WsfbScreenInit(SCREEN_INIT_ARGS_DECL); | | 120 | static Bool WsfbScreenInit(SCREEN_INIT_ARGS_DECL); |
121 | static Bool WsfbCloseScreen(CLOSE_SCREEN_ARGS_DECL); | | 121 | static Bool WsfbCloseScreen(CLOSE_SCREEN_ARGS_DECL); |
122 | static void *WsfbWindowLinear(ScreenPtr, CARD32, CARD32, int, CARD32 *, | | 122 | static void *WsfbWindowLinear(ScreenPtr, CARD32, CARD32, int, CARD32 *, |
123 | void *); | | 123 | void *); |
124 | static void WsfbPointerMoved(SCRN_ARG_TYPE, int, int); | | 124 | static void WsfbPointerMoved(SCRN_ARG_TYPE, int, int); |
125 | static Bool WsfbEnterVT(VT_FUNC_ARGS_DECL); | | 125 | static Bool WsfbEnterVT(VT_FUNC_ARGS_DECL); |
126 | static void WsfbLeaveVT(VT_FUNC_ARGS_DECL); | | 126 | static void WsfbLeaveVT(VT_FUNC_ARGS_DECL); |
127 | static Bool WsfbSwitchMode(SWITCH_MODE_ARGS_DECL); | | 127 | static Bool WsfbSwitchMode(SWITCH_MODE_ARGS_DECL); |
128 | static int WsfbValidMode(SCRN_ARG_TYPE, DisplayModePtr, Bool, int); | | 128 | static int WsfbValidMode(SCRN_ARG_TYPE, DisplayModePtr, Bool, int); |
129 | static void WsfbLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); | | 129 | static void WsfbLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr); |
130 | static Bool WsfbSaveScreen(ScreenPtr, int); | | 130 | static Bool WsfbSaveScreen(ScreenPtr, int); |
131 | static void WsfbSave(ScrnInfoPtr); | | 131 | static void WsfbSave(ScrnInfoPtr); |
132 | static void WsfbRestore(ScrnInfoPtr); | | 132 | static void WsfbRestore(ScrnInfoPtr); |
133 | | | 133 | |
134 | /* DGA stuff */ | | 134 | /* DGA stuff */ |
135 | #ifdef XFreeXDGA | | 135 | #ifdef XFreeXDGA |
136 | static Bool WsfbDGAOpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, | | 136 | static Bool WsfbDGAOpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, |
137 | int *, int *, int *); | | 137 | int *, int *, int *); |
138 | static Bool WsfbDGASetMode(ScrnInfoPtr, DGAModePtr); | | 138 | static Bool WsfbDGASetMode(ScrnInfoPtr, DGAModePtr); |
139 | static void WsfbDGASetViewport(ScrnInfoPtr, int, int, int); | | 139 | static void WsfbDGASetViewport(ScrnInfoPtr, int, int, int); |
140 | static Bool WsfbDGAInit(ScrnInfoPtr, ScreenPtr); | | 140 | static Bool WsfbDGAInit(ScrnInfoPtr, ScreenPtr); |
141 | #endif | | 141 | #endif |
142 | | | 142 | |
143 | static void WsfbShadowUpdateSwap32(ScreenPtr, shadowBufPtr); | | 143 | static void WsfbShadowUpdateSwap32(ScreenPtr, shadowBufPtr); |
144 | static void WsfbShadowUpdateSplit(ScreenPtr, shadowBufPtr); | | 144 | static void WsfbShadowUpdateSplit(ScreenPtr, shadowBufPtr); |
145 | | | 145 | |
146 | static Bool WsfbDriverFunc(ScrnInfoPtr, xorgDriverFuncOp, pointer); | | 146 | static Bool WsfbDriverFunc(ScrnInfoPtr, xorgDriverFuncOp, pointer); |
147 | | | 147 | |
148 | /* Helper functions */ | | 148 | /* Helper functions */ |
149 | static int wsfb_open(const char *); | | 149 | static int wsfb_open(const char *); |
150 | static pointer wsfb_mmap(size_t, off_t, int); | | 150 | static pointer wsfb_mmap(size_t, off_t, int); |
151 | | | 151 | |
152 | enum { WSFB_ROTATE_NONE = 0, | | 152 | enum { WSFB_ROTATE_NONE = 0, |
153 | WSFB_ROTATE_CCW = 90, | | 153 | WSFB_ROTATE_CCW = 90, |
154 | WSFB_ROTATE_UD = 180, | | 154 | WSFB_ROTATE_UD = 180, |
155 | WSFB_ROTATE_CW = 270 | | 155 | WSFB_ROTATE_CW = 270 |
156 | }; | | 156 | }; |
157 | | | 157 | |
158 | /* | | 158 | /* |
159 | * This is intentionally screen-independent. | | 159 | * This is intentionally screen-independent. |
160 | * It indicates the binding choice made in the first PreInit. | | 160 | * It indicates the binding choice made in the first PreInit. |
161 | */ | | 161 | */ |
162 | static int pix24bpp = 0; | | 162 | static int pix24bpp = 0; |
163 | | | 163 | |
164 | #define WSFB_VERSION 4000 | | 164 | #define WSFB_VERSION 4000 |
165 | #define WSFB_NAME "wsfb" | | 165 | #define WSFB_NAME "wsfb" |
166 | #define WSFB_DRIVER_NAME "wsfb" | | 166 | #define WSFB_DRIVER_NAME "wsfb" |
167 | | | 167 | |
168 | _X_EXPORT DriverRec WSFB = { | | 168 | _X_EXPORT DriverRec WSFB = { |
169 | WSFB_VERSION, | | 169 | WSFB_VERSION, |
170 | WSFB_DRIVER_NAME, | | 170 | WSFB_DRIVER_NAME, |
171 | WsfbIdentify, | | 171 | WsfbIdentify, |
172 | WsfbProbe, | | 172 | WsfbProbe, |
173 | WsfbAvailableOptions, | | 173 | WsfbAvailableOptions, |
174 | NULL, | | 174 | NULL, |
175 | 0, | | 175 | 0, |
176 | WsfbDriverFunc | | 176 | WsfbDriverFunc |
177 | }; | | 177 | }; |
178 | | | 178 | |
179 | /* Supported "chipsets" */ | | 179 | /* Supported "chipsets" */ |
180 | static SymTabRec WsfbChipsets[] = { | | 180 | static SymTabRec WsfbChipsets[] = { |
181 | { 0, "wsfb" }, | | 181 | { 0, "wsfb" }, |
182 | { -1, NULL } | | 182 | { -1, NULL } |
183 | }; | | 183 | }; |
184 | | | 184 | |
185 | /* Supported options */ | | 185 | /* Supported options */ |
186 | typedef enum { | | 186 | typedef enum { |
187 | OPTION_SHADOW_FB, | | 187 | OPTION_SHADOW_FB, |
188 | OPTION_ROTATE, | | 188 | OPTION_ROTATE, |
189 | OPTION_HW_CURSOR, | | 189 | OPTION_HW_CURSOR, |
190 | OPTION_SW_CURSOR | | 190 | OPTION_SW_CURSOR |
191 | } WsfbOpts; | | 191 | } WsfbOpts; |
192 | | | 192 | |
193 | static const OptionInfoRec WsfbOptions[] = { | | 193 | static const OptionInfoRec WsfbOptions[] = { |
194 | { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, | | 194 | { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE}, |
195 | { OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE}, | | 195 | { OPTION_ROTATE, "Rotate", OPTV_STRING, {0}, FALSE}, |
196 | { OPTION_HW_CURSOR, "HWCursor", OPTV_BOOLEAN, {1}, FALSE}, | | 196 | { OPTION_HW_CURSOR, "HWCursor", OPTV_BOOLEAN, {1}, FALSE}, |
197 | { -1, NULL, OPTV_NONE, {0}, FALSE} | | 197 | { -1, NULL, OPTV_NONE, {0}, FALSE} |
198 | }; | | 198 | }; |
199 | | | 199 | |
200 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) <= 6 | | 200 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) <= 6 |
201 | /* Symbols needed from other modules */ | | 201 | /* Symbols needed from other modules */ |
202 | static const char *fbSymbols[] = { | | 202 | static const char *fbSymbols[] = { |
203 | "fbPictureInit", | | 203 | "fbPictureInit", |
204 | "fbScreenInit", | | 204 | "fbScreenInit", |
205 | NULL | | 205 | NULL |
206 | }; | | 206 | }; |
207 | static const char *shadowSymbols[] = { | | 207 | static const char *shadowSymbols[] = { |
208 | "shadowAdd", | | 208 | "shadowAdd", |
209 | "shadowSetup", | | 209 | "shadowSetup", |
210 | "shadowUpdatePacked", | | 210 | "shadowUpdatePacked", |
211 | "shadowUpdatePackedWeak", | | 211 | "shadowUpdatePackedWeak", |
212 | "shadowUpdateRotatePacked", | | 212 | "shadowUpdateRotatePacked", |
213 | "shadowUpdateRotatePackedWeak", | | 213 | "shadowUpdateRotatePackedWeak", |
214 | NULL | | 214 | NULL |
215 | }; | | 215 | }; |
216 | | | 216 | |
217 | static const char *ramdacSymbols[] = { | | 217 | static const char *ramdacSymbols[] = { |
218 | "xf86CreateCursorInfoRec", | | 218 | "xf86CreateCursorInfoRec", |
219 | "xf86DestroyCursorInfoRec", | | 219 | "xf86DestroyCursorInfoRec", |
220 | "xf86InitCursor", | | 220 | "xf86InitCursor", |
221 | NULL | | 221 | NULL |
222 | }; | | 222 | }; |
223 | #endif | | 223 | #endif |
224 | | | 224 | |
225 | static XF86ModuleVersionInfo WsfbVersRec = { | | 225 | static XF86ModuleVersionInfo WsfbVersRec = { |
226 | "wsfb", | | 226 | "wsfb", |
227 | MODULEVENDORSTRING, | | 227 | MODULEVENDORSTRING, |
228 | MODINFOSTRING1, | | 228 | MODINFOSTRING1, |
229 | MODINFOSTRING2, | | 229 | MODINFOSTRING2, |
230 | XORG_VERSION_CURRENT, | | 230 | XORG_VERSION_CURRENT, |
231 | PACKAGE_VERSION_MAJOR, | | 231 | PACKAGE_VERSION_MAJOR, |
232 | PACKAGE_VERSION_MINOR, | | 232 | PACKAGE_VERSION_MINOR, |
233 | PACKAGE_VERSION_PATCHLEVEL, | | 233 | PACKAGE_VERSION_PATCHLEVEL, |
234 | ABI_CLASS_VIDEODRV, | | 234 | ABI_CLASS_VIDEODRV, |
235 | ABI_VIDEODRV_VERSION, | | 235 | ABI_VIDEODRV_VERSION, |
236 | NULL, | | 236 | NULL, |
237 | {0, 0, 0, 0} | | 237 | {0, 0, 0, 0} |
238 | }; | | 238 | }; |
239 | | | 239 | |
240 | _X_EXPORT XF86ModuleData wsfbModuleData = { &WsfbVersRec, WsfbSetup, NULL }; | | 240 | _X_EXPORT XF86ModuleData wsfbModuleData = { &WsfbVersRec, WsfbSetup, NULL }; |
241 | | | 241 | |
242 | static pointer | | 242 | static pointer |
243 | WsfbSetup(pointer module, pointer opts, int *errmaj, int *errmin) | | 243 | WsfbSetup(pointer module, pointer opts, int *errmaj, int *errmin) |
244 | { | | 244 | { |
245 | static Bool setupDone = FALSE; | | 245 | static Bool setupDone = FALSE; |
246 | | | 246 | |
247 | #if !(defined __NetBSD__ || defined __OpenBSD__) | | 247 | #if !(defined __NetBSD__ || defined __OpenBSD__) |
248 | /* Check that we're being loaded on a OpenBSD or NetBSD system. */ | | 248 | /* Check that we're being loaded on a OpenBSD or NetBSD system. */ |
249 | if (errmaj) | | 249 | if (errmaj) |
250 | *errmaj = LDR_BADOS; | | 250 | *errmaj = LDR_BADOS; |
251 | if (errmin) | | 251 | if (errmin) |
252 | *errmin = 0; | | 252 | *errmin = 0; |
253 | return NULL; | | 253 | return NULL; |
254 | #endif | | 254 | #endif |
255 | if (!setupDone) { | | 255 | if (!setupDone) { |
256 | setupDone = TRUE; | | 256 | setupDone = TRUE; |
257 | xf86AddDriver(&WSFB, module, HaveDriverFuncs); | | 257 | xf86AddDriver(&WSFB, module, HaveDriverFuncs); |
258 | LoaderRefSymLists(fbSymbols, shadowSymbols, ramdacSymbols, | | 258 | LoaderRefSymLists(fbSymbols, shadowSymbols, ramdacSymbols, |
259 | NULL); | | 259 | NULL); |
260 | return (pointer)1; | | 260 | return (pointer)1; |
261 | } else { | | 261 | } else { |
262 | if (errmaj != NULL) | | 262 | if (errmaj != NULL) |
263 | *errmaj = LDR_ONCEONLY; | | 263 | *errmaj = LDR_ONCEONLY; |
264 | return NULL; | | 264 | return NULL; |
265 | } | | 265 | } |
266 | } | | 266 | } |
267 | | | 267 | |
268 | static Bool | | 268 | static Bool |
269 | WsfbGetRec(ScrnInfoPtr pScrn) | | 269 | WsfbGetRec(ScrnInfoPtr pScrn) |
270 | { | | 270 | { |
271 | | | 271 | |
272 | if (pScrn->driverPrivate != NULL) | | 272 | if (pScrn->driverPrivate != NULL) |
273 | return TRUE; | | 273 | return TRUE; |
274 | | | 274 | |
275 | pScrn->driverPrivate = xnfcalloc(sizeof(WsfbRec), 1); | | 275 | pScrn->driverPrivate = xnfcalloc(sizeof(WsfbRec), 1); |
276 | return TRUE; | | 276 | return TRUE; |
277 | } | | 277 | } |
278 | | | 278 | |
279 | static void | | 279 | static void |
280 | WsfbFreeRec(ScrnInfoPtr pScrn) | | 280 | WsfbFreeRec(ScrnInfoPtr pScrn) |
281 | { | | 281 | { |
282 | | | 282 | |
283 | if (pScrn->driverPrivate == NULL) | | 283 | if (pScrn->driverPrivate == NULL) |
284 | return; | | 284 | return; |
285 | free(pScrn->driverPrivate); | | 285 | free(pScrn->driverPrivate); |
286 | pScrn->driverPrivate = NULL; | | 286 | pScrn->driverPrivate = NULL; |
287 | } | | 287 | } |
288 | | | 288 | |
289 | static const OptionInfoRec * | | 289 | static const OptionInfoRec * |
290 | WsfbAvailableOptions(int chipid, int busid) | | 290 | WsfbAvailableOptions(int chipid, int busid) |
291 | { | | 291 | { |
292 | return WsfbOptions; | | 292 | return WsfbOptions; |
293 | } | | 293 | } |
294 | | | 294 | |
295 | static void | | 295 | static void |
296 | WsfbIdentify(int flags) | | 296 | WsfbIdentify(int flags) |
297 | { | | 297 | { |
298 | xf86PrintChipsets(WSFB_NAME, "driver for wsdisplay framebuffer", | | 298 | xf86PrintChipsets(WSFB_NAME, "driver for wsdisplay framebuffer", |
299 | WsfbChipsets); | | 299 | WsfbChipsets); |
300 | } | | 300 | } |
301 | | | 301 | |
302 | /* Open the framebuffer device. */ | | 302 | /* Open the framebuffer device. */ |
303 | static int | | 303 | static int |
304 | wsfb_open(const char *dev) | | 304 | wsfb_open(const char *dev) |
305 | { | | 305 | { |
306 | int fd = -1; | | 306 | int fd = -1; |
307 | | | 307 | |
308 | /* Try argument from xorg.conf first. */ | | 308 | /* Try argument from xorg.conf first. */ |
309 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { | | 309 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { |
310 | /* Second: environment variable. */ | | 310 | /* Second: environment variable. */ |
311 | dev = getenv("XDEVICE"); | | 311 | dev = getenv("XDEVICE"); |
312 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { | | 312 | if (dev == NULL || ((fd = priv_open_device(dev)) == -1)) { |
313 | /* Last try: default device. */ | | 313 | /* Last try: default device. */ |
314 | dev = WSFB_DEFAULT_DEV; | | 314 | dev = WSFB_DEFAULT_DEV; |
315 | if ((fd = priv_open_device(dev)) == -1) { | | 315 | if ((fd = priv_open_device(dev)) == -1) { |
316 | return -1; | | 316 | return -1; |
317 | } | | 317 | } |
318 | } | | 318 | } |
319 | } | | 319 | } |
320 | return fd; | | 320 | return fd; |
321 | } | | 321 | } |
322 | | | 322 | |
323 | /* Map the framebuffer's memory. */ | | 323 | /* Map the framebuffer's memory. */ |
324 | static pointer | | 324 | static pointer |
325 | wsfb_mmap(size_t len, off_t off, int fd) | | 325 | wsfb_mmap(size_t len, off_t off, int fd) |
326 | { | | 326 | { |
327 | int pagemask, mapsize; | | 327 | int pagemask, mapsize; |
328 | caddr_t addr; | | 328 | caddr_t addr; |
329 | pointer mapaddr; | | 329 | pointer mapaddr; |
330 | | | 330 | |
331 | pagemask = getpagesize() - 1; | | 331 | pagemask = getpagesize() - 1; |
332 | mapsize = ((int) len + pagemask) & ~pagemask; | | 332 | mapsize = ((int) len + pagemask) & ~pagemask; |
333 | addr = 0; | | 333 | addr = 0; |
334 | | | 334 | |
335 | /* | | 335 | /* |
336 | * Try and make it private first, that way once we get it, an | | 336 | * Try and make it private first, that way once we get it, an |
337 | * interloper, e.g. another server, can't get this frame buffer, | | 337 | * interloper, e.g. another server, can't get this frame buffer, |
338 | * and if another server already has it, this one won't. | | 338 | * and if another server already has it, this one won't. |
339 | */ | | 339 | */ |
340 | mapaddr = (pointer) mmap(addr, mapsize, | | 340 | mapaddr = (pointer) mmap(addr, mapsize, |
341 | PROT_READ | PROT_WRITE, MAP_SHARED, | | 341 | PROT_READ | PROT_WRITE, MAP_SHARED, |
342 | fd, off); | | 342 | fd, off); |
343 | if (mapaddr == MAP_FAILED) { | | 343 | if (mapaddr == MAP_FAILED) { |
344 | mapaddr = NULL; | | 344 | mapaddr = NULL; |
345 | } | | 345 | } |
346 | #if DEBUG | | 346 | #if DEBUG |
347 | ErrorF("mmap returns: addr %p len 0x%x\n", mapaddr, mapsize); | | 347 | ErrorF("mmap returns: addr %p len 0x%x\n", mapaddr, mapsize); |
348 | #endif | | 348 | #endif |
349 | return mapaddr; | | 349 | return mapaddr; |
350 | } | | 350 | } |
351 | | | 351 | |
352 | static Bool | | 352 | static Bool |
353 | WsfbProbe(DriverPtr drv, int flags) | | 353 | WsfbProbe(DriverPtr drv, int flags) |
354 | { | | 354 | { |
355 | int i, fd, entity; | | 355 | int i, fd, entity; |
356 | GDevPtr *devSections; | | 356 | GDevPtr *devSections; |
357 | int numDevSections; | | 357 | int numDevSections; |
358 | const char *dev; | | 358 | const char *dev; |
359 | Bool foundScreen = FALSE; | | 359 | Bool foundScreen = FALSE; |
360 | | | 360 | |
361 | TRACE("probe start"); | | 361 | TRACE("probe start"); |
362 | | | 362 | |
363 | /* For now, just bail out for PROBE_DETECT. */ | | 363 | /* For now, just bail out for PROBE_DETECT. */ |
364 | if (flags & PROBE_DETECT) | | 364 | if (flags & PROBE_DETECT) |
365 | return FALSE; | | 365 | return FALSE; |
366 | | | 366 | |
367 | if ((numDevSections = xf86MatchDevice(WSFB_DRIVER_NAME, | | 367 | if ((numDevSections = xf86MatchDevice(WSFB_DRIVER_NAME, |
368 | &devSections)) <= 0) | | 368 | &devSections)) <= 0) |
369 | return FALSE; | | 369 | return FALSE; |
370 | | | 370 | |
371 | /* Do not attach if the modesetting driver is active */ | | 371 | /* Do not attach if the modesetting driver is active */ |
372 | if (fbSlotClaimed == TRUE) { | | 372 | if (fbSlotClaimed == TRUE) { |
373 | DriverPtr fbSlotDrv = xf86GetEntityInfo(0)->driver; | | 373 | DriverPtr fbSlotDrv = xf86GetEntityInfo(0)->driver; |
374 | if (strcmp(fbSlotDrv->driverName, "modesetting") == 0) | | 374 | if (strcmp(fbSlotDrv->driverName, "modesetting") == 0) |
375 | return FALSE; | | 375 | return FALSE; |
376 | } | | 376 | } |
377 | | | 377 | |
378 | for (i = 0; i < numDevSections; i++) { | | 378 | for (i = 0; i < numDevSections; i++) { |
379 | ScrnInfoPtr pScrn = NULL; | | 379 | ScrnInfoPtr pScrn = NULL; |
380 | | | 380 | |
381 | dev = xf86FindOptionValue(devSections[i]->options, "device"); | | 381 | dev = xf86FindOptionValue(devSections[i]->options, "device"); |
382 | if ((fd = wsfb_open(dev)) >= 0) { | | 382 | if ((fd = wsfb_open(dev)) >= 0) { |
383 | entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE); | | 383 | entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE); |
384 | pScrn = xf86ConfigFbEntity(NULL,0,entity, | | 384 | pScrn = xf86ConfigFbEntity(NULL,0,entity, |
385 | NULL,NULL,NULL,NULL); | | 385 | NULL,NULL,NULL,NULL); |
386 | if (pScrn != NULL) { | | 386 | if (pScrn != NULL) { |
387 | foundScreen = TRUE; | | 387 | foundScreen = TRUE; |
388 | pScrn->driverVersion = WSFB_VERSION; | | 388 | pScrn->driverVersion = WSFB_VERSION; |
389 | pScrn->driverName = WSFB_DRIVER_NAME; | | 389 | pScrn->driverName = WSFB_DRIVER_NAME; |
390 | pScrn->name = WSFB_NAME; | | 390 | pScrn->name = WSFB_NAME; |
391 | pScrn->Probe = WsfbProbe; | | 391 | pScrn->Probe = WsfbProbe; |
392 | pScrn->PreInit = WsfbPreInit; | | 392 | pScrn->PreInit = WsfbPreInit; |
393 | pScrn->ScreenInit = WsfbScreenInit; | | 393 | pScrn->ScreenInit = WsfbScreenInit; |
394 | pScrn->SwitchMode = WsfbSwitchMode; | | 394 | pScrn->SwitchMode = WsfbSwitchMode; |
395 | pScrn->AdjustFrame = NULL; | | 395 | pScrn->AdjustFrame = NULL; |
396 | pScrn->EnterVT = WsfbEnterVT; | | 396 | pScrn->EnterVT = WsfbEnterVT; |
397 | pScrn->LeaveVT = WsfbLeaveVT; | | 397 | pScrn->LeaveVT = WsfbLeaveVT; |
398 | pScrn->ValidMode = WsfbValidMode; | | 398 | pScrn->ValidMode = WsfbValidMode; |
399 | | | 399 | |
400 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, | | 400 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
401 | "using %s\n", dev != NULL ? dev : | | 401 | "using %s\n", dev != NULL ? dev : |
402 | "default device"); | | 402 | "default device"); |
403 | } | | 403 | } |
404 | } | | 404 | } |
405 | } | | 405 | } |
406 | free(devSections); | | 406 | free(devSections); |
407 | TRACE("probe done"); | | 407 | TRACE("probe done"); |
408 | return foundScreen; | | 408 | return foundScreen; |
409 | } | | 409 | } |
410 | | | 410 | |
411 | static Bool | | 411 | static Bool |
412 | WsfbPreInit(ScrnInfoPtr pScrn, int flags) | | 412 | WsfbPreInit(ScrnInfoPtr pScrn, int flags) |
413 | { | | 413 | { |
414 | WsfbPtr fPtr; | | 414 | WsfbPtr fPtr; |
415 | int default_depth, bitsperpixel, wstype; | | 415 | int default_depth, bitsperpixel, wstype; |
416 | const char *dev, *s; | | 416 | const char *dev, *s; |
417 | char *mod = NULL; | | 417 | char *mod = NULL; |
418 | const char *reqSym = NULL; | | 418 | const char *reqSym = NULL; |
419 | Gamma zeros = {0.0, 0.0, 0.0}; | | 419 | Gamma zeros = {0.0, 0.0, 0.0}; |
420 | DisplayModePtr mode; | | 420 | DisplayModePtr mode; |
421 | MessageType from; | | 421 | MessageType from; |
422 | | | 422 | |
423 | if (flags & PROBE_DETECT) return FALSE; | | 423 | if (flags & PROBE_DETECT) return FALSE; |
424 | | | 424 | |
425 | TRACE_ENTER("PreInit"); | | 425 | TRACE_ENTER("PreInit"); |
426 | | | 426 | |
427 | if (pScrn->numEntities != 1) return FALSE; | | 427 | if (pScrn->numEntities != 1) return FALSE; |
428 | | | 428 | |
429 | pScrn->monitor = pScrn->confScreen->monitor; | | 429 | pScrn->monitor = pScrn->confScreen->monitor; |
430 | | | 430 | |
431 | WsfbGetRec(pScrn); | | 431 | WsfbGetRec(pScrn); |
432 | fPtr = WSFBPTR(pScrn); | | 432 | fPtr = WSFBPTR(pScrn); |
433 | | | 433 | |
434 | fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); | | 434 | fPtr->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); |
435 | | | 435 | |
436 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 | | 436 | #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 6 |
437 | pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; | | 437 | pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT; |
438 | pScrn->racIoFlags = pScrn->racMemFlags; | | 438 | pScrn->racIoFlags = pScrn->racMemFlags; |
439 | #endif | | 439 | #endif |
440 | | | 440 | |
441 | dev = xf86FindOptionValue(fPtr->pEnt->device->options, "device"); | | 441 | dev = xf86FindOptionValue(fPtr->pEnt->device->options, "device"); |
442 | fPtr->fd = wsfb_open(dev); | | 442 | fPtr->fd = wsfb_open(dev); |
443 | if (fPtr->fd == -1) { | | 443 | if (fPtr->fd == -1) { |
444 | return FALSE; | | 444 | return FALSE; |
445 | } | | 445 | } |
446 | | | 446 | |
447 | if (ioctl(fPtr->fd, WSDISPLAYIO_GET_FBINFO, &fPtr->fbi) != 0) { | | 447 | if (ioctl(fPtr->fd, WSDISPLAYIO_GET_FBINFO, &fPtr->fbi) != 0) { |
448 | struct wsdisplay_fbinfo info; | | 448 | struct wsdisplay_fbinfo info; |
449 | struct wsdisplayio_fbinfo *fbi = &fPtr->fbi; | | 449 | struct wsdisplayio_fbinfo *fbi = &fPtr->fbi; |
450 | int lb; | | 450 | int lb; |
451 | | | 451 | |
452 | xf86Msg(X_WARNING, "ioctl(WSDISPLAYIO_GET_FBINFO) failed, " \ | | 452 | xf86Msg(X_WARNING, "ioctl(WSDISPLAYIO_GET_FBINFO) failed, " \ |
453 | "falling back to old method\n"); | | 453 | "falling back to old method\n"); |
454 | if (ioctl(fPtr->fd, WSDISPLAYIO_GINFO, &info) == -1) { | | 454 | if (ioctl(fPtr->fd, WSDISPLAYIO_GINFO, &info) == -1) { |
455 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 455 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
456 | "ioctl WSDISPLAY_GINFO: %s\n", | | 456 | "ioctl WSDISPLAY_GINFO: %s\n", |
457 | strerror(errno)); | | 457 | strerror(errno)); |
458 | return FALSE; | | 458 | return FALSE; |
459 | } | | 459 | } |
460 | if (ioctl(fPtr->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { | | 460 | if (ioctl(fPtr->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { |
461 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 461 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
462 | "ioctl WSDISPLAY_GTYPE: %s\n", | | 462 | "ioctl WSDISPLAY_GTYPE: %s\n", |
463 | strerror(errno)); | | 463 | strerror(errno)); |
464 | return FALSE; | | 464 | return FALSE; |
465 | } | | 465 | } |
466 | if (ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, &lb) == -1) { | | 466 | if (ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, &lb) == -1) { |
467 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 467 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
468 | "ioctl WSDISPLAYIO_LINEBYTES: %s\n", | | 468 | "ioctl WSDISPLAYIO_LINEBYTES: %s\n", |
469 | strerror(errno)); | | 469 | strerror(errno)); |
470 | return FALSE; | | 470 | return FALSE; |
471 | } | | 471 | } |
472 | /* ok, fake up a new style fbinfo */ | | 472 | /* ok, fake up a new style fbinfo */ |
473 | fbi->fbi_width = info.width; | | 473 | fbi->fbi_width = info.width; |
474 | fbi->fbi_height = info.height; | | 474 | fbi->fbi_height = info.height; |
475 | fbi->fbi_stride = lb; | | 475 | fbi->fbi_stride = lb; |
476 | fbi->fbi_bitsperpixel = info.depth; | | 476 | fbi->fbi_bitsperpixel = info.depth; |
477 | if (info.depth > 16) { | | 477 | if (info.depth > 16) { |
478 | fbi->fbi_pixeltype = WSFB_RGB; | | 478 | fbi->fbi_pixeltype = WSFB_RGB; |
479 | if (wstype == WSDISPLAY_TYPE_SUN24 || | | 479 | if (wstype == WSDISPLAY_TYPE_SUN24 || |
480 | wstype == WSDISPLAY_TYPE_SUNCG12 || | | 480 | wstype == WSDISPLAY_TYPE_SUNCG12 || |
481 | wstype == WSDISPLAY_TYPE_SUNCG14 || | | 481 | wstype == WSDISPLAY_TYPE_SUNCG14 || |
482 | wstype == WSDISPLAY_TYPE_SUNTCX || | | 482 | wstype == WSDISPLAY_TYPE_SUNTCX || |
483 | wstype == WSDISPLAY_TYPE_SUNFFB || | | 483 | wstype == WSDISPLAY_TYPE_SUNFFB || |
484 | wstype == WSDISPLAY_TYPE_XVR1000 || | | 484 | wstype == WSDISPLAY_TYPE_XVR1000 || |
485 | wstype == WSDISPLAY_TYPE_VC4) { | | 485 | wstype == WSDISPLAY_TYPE_VC4) { |
486 | fbi->fbi_subtype.fbi_rgbmasks.red_offset = 0; | | 486 | fbi->fbi_subtype.fbi_rgbmasks.red_offset = 0; |
487 | fbi->fbi_subtype.fbi_rgbmasks.red_size = 8; | | 487 | fbi->fbi_subtype.fbi_rgbmasks.red_size = 8; |
488 | fbi->fbi_subtype.fbi_rgbmasks.green_offset = 8; | | 488 | fbi->fbi_subtype.fbi_rgbmasks.green_offset = 8; |
489 | fbi->fbi_subtype.fbi_rgbmasks.green_size = 8; | | 489 | fbi->fbi_subtype.fbi_rgbmasks.green_size = 8; |
490 | fbi->fbi_subtype.fbi_rgbmasks.blue_offset = 16; | | 490 | fbi->fbi_subtype.fbi_rgbmasks.blue_offset = 16; |
491 | fbi->fbi_subtype.fbi_rgbmasks.blue_size = 8; | | 491 | fbi->fbi_subtype.fbi_rgbmasks.blue_size = 8; |
492 | } else { | | 492 | } else { |
493 | fbi->fbi_subtype.fbi_rgbmasks.red_offset = 16; | | 493 | fbi->fbi_subtype.fbi_rgbmasks.red_offset = 16; |
494 | fbi->fbi_subtype.fbi_rgbmasks.red_size = 8; | | 494 | fbi->fbi_subtype.fbi_rgbmasks.red_size = 8; |
495 | fbi->fbi_subtype.fbi_rgbmasks.green_offset = 8; | | 495 | fbi->fbi_subtype.fbi_rgbmasks.green_offset = 8; |
496 | fbi->fbi_subtype.fbi_rgbmasks.green_size = 8; | | 496 | fbi->fbi_subtype.fbi_rgbmasks.green_size = 8; |
497 | fbi->fbi_subtype.fbi_rgbmasks.blue_offset = 0; | | 497 | fbi->fbi_subtype.fbi_rgbmasks.blue_offset = 0; |
498 | fbi->fbi_subtype.fbi_rgbmasks.blue_size = 8; | | 498 | fbi->fbi_subtype.fbi_rgbmasks.blue_size = 8; |
499 | } | | 499 | } |
500 | fbi->fbi_subtype.fbi_rgbmasks.alpha_offset = 0; | | 500 | fbi->fbi_subtype.fbi_rgbmasks.alpha_offset = 0; |
501 | fbi->fbi_subtype.fbi_rgbmasks.alpha_size = 0; | | 501 | fbi->fbi_subtype.fbi_rgbmasks.alpha_size = 0; |
502 | } else if (info.depth <= 8) { | | 502 | } else if (info.depth <= 8) { |
503 | fbi->fbi_pixeltype = WSFB_CI; | | 503 | fbi->fbi_pixeltype = WSFB_CI; |
504 | fbi->fbi_subtype.fbi_cmapinfo.cmap_entries = info.cmsize; | | 504 | fbi->fbi_subtype.fbi_cmapinfo.cmap_entries = info.cmsize; |
505 | } | | 505 | } |
506 | fbi->fbi_flags = 0; | | 506 | fbi->fbi_flags = 0; |
507 | fbi->fbi_fbsize = lb * info.height; | | 507 | fbi->fbi_fbsize = lb * info.height; |
508 | #ifdef WSDISPLAY_TYPE_LUNA | | 508 | #ifdef WSDISPLAY_TYPE_LUNA |
509 | if (wstype == WSDISPLAY_TYPE_LUNA) { | | 509 | if (wstype == WSDISPLAY_TYPE_LUNA) { |
510 | /* | | 510 | /* |
511 | * XXX | | 511 | * XXX |
512 | * LUNA's FB seems to have 64 dot (8 byte) offset. | | 512 | * LUNA's FB seems to have 64 dot (8 byte) offset. |
513 | * This might be able to be changed in kernel | | 513 | * This might be able to be changed in kernel |
514 | * lunafb driver, but current setting was pulled | | 514 | * lunafb driver, but current setting was pulled |
515 | * from 4.4BSD-Lite2/luna68k. | | 515 | * from 4.4BSD-Lite2/luna68k. |
516 | */ | | 516 | */ |
517 | fbi->fbi_fboffset = 8; | | 517 | fbi->fbi_fboffset = 8; |
518 | } else | | 518 | } else |
519 | #endif | | 519 | #endif |
520 | fbi->fbi_fboffset = 0; | | 520 | fbi->fbi_fboffset = 0; |
521 | } | | 521 | } |
522 | xf86Msg(X_INFO, "fboffset %x\n", (int)fPtr->fbi.fbi_fboffset); | | 522 | xf86Msg(X_INFO, "fboffset %x\n", (int)fPtr->fbi.fbi_fboffset); |
523 | /* | | 523 | /* |
524 | * Allocate room for saving the colormap. | | 524 | * Allocate room for saving the colormap. |
525 | */ | | 525 | */ |
526 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI && | | 526 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI && |
527 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries > 0) { | | 527 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries > 0) { |
528 | fPtr->saved_cmap.red = | | 528 | fPtr->saved_cmap.red = |
529 | (unsigned char *)malloc(fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); | | 529 | (unsigned char *)malloc(fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); |
530 | if (fPtr->saved_cmap.red == NULL) { | | 530 | if (fPtr->saved_cmap.red == NULL) { |
531 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 531 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
532 | "Cannot malloc %d bytes\n", | | 532 | "Cannot malloc %d bytes\n", |
533 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); | | 533 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); |
534 | return FALSE; | | 534 | return FALSE; |
535 | } | | 535 | } |
536 | fPtr->saved_cmap.green = | | 536 | fPtr->saved_cmap.green = |
537 | (unsigned char *)malloc(fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); | | 537 | (unsigned char *)malloc(fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); |
538 | if (fPtr->saved_cmap.green == NULL) { | | 538 | if (fPtr->saved_cmap.green == NULL) { |
539 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 539 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
540 | "Cannot malloc %d bytes\n", | | 540 | "Cannot malloc %d bytes\n", |
541 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); | | 541 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); |
542 | free(fPtr->saved_cmap.red); | | 542 | free(fPtr->saved_cmap.red); |
543 | return FALSE; | | 543 | return FALSE; |
544 | } | | 544 | } |
545 | fPtr->saved_cmap.blue = | | 545 | fPtr->saved_cmap.blue = |
546 | (unsigned char *)malloc(fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); | | 546 | (unsigned char *)malloc(fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); |
547 | if (fPtr->saved_cmap.blue == NULL) { | | 547 | if (fPtr->saved_cmap.blue == NULL) { |
548 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 548 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
549 | "Cannot malloc %d bytes\n", | | 549 | "Cannot malloc %d bytes\n", |
550 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); | | 550 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries); |
551 | free(fPtr->saved_cmap.red); | | 551 | free(fPtr->saved_cmap.red); |
552 | free(fPtr->saved_cmap.green); | | 552 | free(fPtr->saved_cmap.green); |
553 | return FALSE; | | 553 | return FALSE; |
554 | } | | 554 | } |
555 | } | | 555 | } |
556 | | | 556 | |
557 | /* Handle depth */ | | 557 | /* Handle depth */ |
558 | default_depth = fPtr->fbi.fbi_bitsperpixel <= 24 ? fPtr->fbi.fbi_bitsperpixel : 24; | | 558 | default_depth = fPtr->fbi.fbi_bitsperpixel <= 24 ? fPtr->fbi.fbi_bitsperpixel : 24; |
559 | bitsperpixel = fPtr->fbi.fbi_bitsperpixel == 15 ? 16 : fPtr->fbi.fbi_bitsperpixel; | | 559 | bitsperpixel = fPtr->fbi.fbi_bitsperpixel == 15 ? 16 : fPtr->fbi.fbi_bitsperpixel; |
560 | #if defined(__NetBSD__) && defined(WSDISPLAY_TYPE_LUNA) | | 560 | #if defined(__NetBSD__) && defined(WSDISPLAY_TYPE_LUNA) |
561 | if (wstype == WSDISPLAY_TYPE_LUNA) { | | 561 | if (wstype == WSDISPLAY_TYPE_LUNA) { |
562 | /* | | 562 | /* |
563 | * XXX | | 563 | * XXX |
564 | * LUNA's color framebuffers support 4bpp or 8bpp | | 564 | * LUNA's color framebuffers support 4bpp or 8bpp |
565 | * but they have multiple 1bpp VRAM planes like ancient VGA. | | 565 | * but they have multiple 1bpp VRAM planes like ancient VGA. |
566 | * For now, Xorg server supports only the first one plane | | 566 | * For now, Xorg server supports only the first one plane |
567 | * as 1bpp monochrome server. | | 567 | * as 1bpp monochrome server. |
568 | * | | 568 | * |
569 | * Note OpenBSD/luna88k workarounds this by switching depth | | 569 | * Note OpenBSD/luna88k workarounds this by switching depth |
570 | * and palette settings by WSDISPLAYIO_SETGFXMODE ioctl. | | 570 | * and palette settings by WSDISPLAYIO_SETGFXMODE ioctl. |
571 | */ | | 571 | */ |
572 | default_depth = 1; | | 572 | default_depth = 1; |
573 | bitsperpixel = 1; | | 573 | bitsperpixel = 1; |
574 | } | | 574 | } |
575 | #endif | | 575 | #endif |
576 | if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, | | 576 | if (!xf86SetDepthBpp(pScrn, default_depth, default_depth, |
577 | bitsperpixel, | | 577 | bitsperpixel, |
578 | bitsperpixel >= 24 ? Support24bppFb|Support32bppFb : 0)) | | 578 | bitsperpixel >= 24 ? Support24bppFb|Support32bppFb : 0)) |
579 | return FALSE; | | 579 | return FALSE; |
580 | | | 580 | |
581 | /* Check consistency. */ | | 581 | /* Check consistency. */ |
582 | if (pScrn->bitsPerPixel != bitsperpixel) { | | 582 | if (pScrn->bitsPerPixel != bitsperpixel) { |
583 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 583 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
584 | "specified depth (%d) or bpp (%d) doesn't match " | | 584 | "specified depth (%d) or bpp (%d) doesn't match " |
585 | "framebuffer depth (%d)\n", pScrn->depth, | | 585 | "framebuffer depth (%d)\n", pScrn->depth, |
586 | pScrn->bitsPerPixel, bitsperpixel); | | 586 | pScrn->bitsPerPixel, bitsperpixel); |
587 | return FALSE; | | 587 | return FALSE; |
588 | } | | 588 | } |
589 | xf86PrintDepthBpp(pScrn); | | 589 | xf86PrintDepthBpp(pScrn); |
590 | | | 590 | |
591 | /* Get the depth24 pixmap format. */ | | 591 | /* Get the depth24 pixmap format. */ |
592 | if (pScrn->depth == 24 && pix24bpp == 0) | | 592 | if (pScrn->depth == 24 && pix24bpp == 0) |
593 | pix24bpp = xf86GetBppFromDepth(pScrn, 24); | | 593 | pix24bpp = xf86GetBppFromDepth(pScrn, 24); |
594 | | | 594 | |
595 | /* Handle options. */ | | 595 | /* Handle options. */ |
596 | xf86CollectOptions(pScrn, NULL); | | 596 | xf86CollectOptions(pScrn, NULL); |
597 | fPtr->Options = (OptionInfoRec *)malloc(sizeof(WsfbOptions)); | | 597 | fPtr->Options = (OptionInfoRec *)malloc(sizeof(WsfbOptions)); |
598 | if (fPtr->Options == NULL) | | 598 | if (fPtr->Options == NULL) |
599 | return FALSE; | | 599 | return FALSE; |
600 | memcpy(fPtr->Options, WsfbOptions, sizeof(WsfbOptions)); | | 600 | memcpy(fPtr->Options, WsfbOptions, sizeof(WsfbOptions)); |
601 | xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, | | 601 | xf86ProcessOptions(pScrn->scrnIndex, fPtr->pEnt->device->options, |
602 | fPtr->Options); | | 602 | fPtr->Options); |
603 | | | 603 | |
604 | /* Use shadow framebuffer by default, on depth >= 8 */ | | 604 | /* Use shadow framebuffer by default, on depth >= 8 */ |
605 | xf86Msg(X_INFO, "fbi_flags: %x\n", fPtr->fbi.fbi_flags); | | 605 | xf86Msg(X_INFO, "fbi_flags: %x\n", fPtr->fbi.fbi_flags); |
606 | if ((pScrn->depth >= 8) && | | 606 | if ((pScrn->depth >= 8) && |
607 | ((fPtr->fbi.fbi_flags & WSFB_VRAM_IS_RAM) == 0)) { | | 607 | ((fPtr->fbi.fbi_flags & WSFB_VRAM_IS_RAM) == 0)) { |
608 | fPtr->shadowFB = xf86ReturnOptValBool(fPtr->Options, | | 608 | fPtr->shadowFB = xf86ReturnOptValBool(fPtr->Options, |
609 | OPTION_SHADOW_FB, TRUE); | | 609 | OPTION_SHADOW_FB, TRUE); |
610 | } else | | 610 | } else |
611 | if (xf86ReturnOptValBool(fPtr->Options, | | 611 | if (xf86ReturnOptValBool(fPtr->Options, |
612 | OPTION_SHADOW_FB, FALSE)) { | | 612 | OPTION_SHADOW_FB, FALSE)) { |
613 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, | | 613 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
614 | "Shadow FB option ignored on depth < 8"); | | 614 | "Shadow FB option ignored on depth < 8"); |
615 | } | | 615 | } |
616 | if (fPtr->fbi.fbi_flags & WSFB_VRAM_IS_SPLIT) { | | 616 | if (fPtr->fbi.fbi_flags & WSFB_VRAM_IS_SPLIT) { |
617 | if (!fPtr->shadowFB) { | | 617 | if (!fPtr->shadowFB) { |
618 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, | | 618 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
619 | "Shadow FB forced on for split framebuffer"); | | 619 | "Shadow FB forced on for split framebuffer"); |
620 | fPtr->shadowFB = TRUE; | | 620 | fPtr->shadowFB = TRUE; |
621 | } | | 621 | } |
622 | } | | 622 | } |
623 | /* Rotation */ | | 623 | /* Rotation */ |
624 | fPtr->rotate = WSFB_ROTATE_NONE; | | 624 | fPtr->rotate = WSFB_ROTATE_NONE; |
625 | if ((s = xf86GetOptValString(fPtr->Options, OPTION_ROTATE))) { | | 625 | if ((s = xf86GetOptValString(fPtr->Options, OPTION_ROTATE))) { |
626 | if (pScrn->depth >= 8) { | | 626 | if (pScrn->depth >= 8) { |
627 | if (!xf86NameCmp(s, "CW")) { | | 627 | if (!xf86NameCmp(s, "CW")) { |
628 | fPtr->shadowFB = TRUE; | | 628 | fPtr->shadowFB = TRUE; |
629 | fPtr->rotate = WSFB_ROTATE_CW; | | 629 | fPtr->rotate = WSFB_ROTATE_CW; |
630 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 630 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
631 | "Rotating screen clockwise\n"); | | 631 | "Rotating screen clockwise\n"); |
632 | } else if (!xf86NameCmp(s, "CCW")) { | | 632 | } else if (!xf86NameCmp(s, "CCW")) { |
633 | fPtr->shadowFB = TRUE; | | 633 | fPtr->shadowFB = TRUE; |
634 | fPtr->rotate = WSFB_ROTATE_CCW; | | 634 | fPtr->rotate = WSFB_ROTATE_CCW; |
635 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 635 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
636 | "Rotating screen counter clockwise\n"); | | 636 | "Rotating screen counter clockwise\n"); |
637 | } else if (!xf86NameCmp(s, "UD")) { | | 637 | } else if (!xf86NameCmp(s, "UD")) { |
638 | fPtr->shadowFB = TRUE; | | 638 | fPtr->shadowFB = TRUE; |
639 | fPtr->rotate = WSFB_ROTATE_UD; | | 639 | fPtr->rotate = WSFB_ROTATE_UD; |
640 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 640 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
641 | "Rotating screen upside down\n"); | | 641 | "Rotating screen upside down\n"); |
642 | } else { | | 642 | } else { |
643 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 643 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
644 | "\"%s\" is not a valid value for Option " | | 644 | "\"%s\" is not a valid value for Option " |
645 | "\"Rotate\"\n", s); | | 645 | "\"Rotate\"\n", s); |
646 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, | | 646 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
647 | "Valid options are \"CW\", \"CCW\"," | | 647 | "Valid options are \"CW\", \"CCW\"," |
648 | " or \"UD\"\n"); | | 648 | " or \"UD\"\n"); |
649 | } | | 649 | } |
650 | } else { | | 650 | } else { |
651 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, | | 651 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
652 | "Option \"Rotate\" ignored on depth < 8"); | | 652 | "Option \"Rotate\" ignored on depth < 8"); |
653 | } | | 653 | } |
654 | } | | 654 | } |
655 | | | 655 | |
656 | | | 656 | |
657 | fPtr->useSwap32 = FALSE; | | 657 | fPtr->useSwap32 = FALSE; |
658 | /* Color weight */ | | 658 | /* Color weight */ |
659 | if (fPtr->fbi.fbi_pixeltype == WSFB_RGB) { | | 659 | if (fPtr->fbi.fbi_pixeltype == WSFB_RGB) { |
660 | rgb zeros = { 0, 0, 0 }, masks; | | 660 | rgb zeros = { 0, 0, 0 }, masks; |
661 | | | 661 | |
662 | if (fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_size > 0) { | | 662 | if (fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_size > 0) { |
663 | uint32_t msk; | | 663 | uint32_t msk; |
664 | | | 664 | |
665 | /* | | 665 | /* |
666 | * see if we need to byte-swap pixels | | 666 | * see if we need to byte-swap pixels |
667 | * XXX this requires a shadow FB and is incompatible | | 667 | * XXX this requires a shadow FB and is incompatible |
668 | * (for now ) with rotation | | 668 | * (for now ) with rotation |
669 | */ | | 669 | */ |
670 | if ((fPtr->fbi.fbi_bitsperpixel == 32) && | | 670 | if ((fPtr->fbi.fbi_bitsperpixel == 32) && |
671 | (fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_offset == 24) && | | 671 | (fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_offset == 24) && |
672 | (fPtr->rotate == WSFB_ROTATE_NONE) && | | 672 | (fPtr->rotate == WSFB_ROTATE_NONE) && |
673 | (fPtr->shadowFB == TRUE)) { | | 673 | (fPtr->shadowFB == TRUE)) { |
674 | /* | | 674 | /* |
675 | * looks like BGRA - set the swap flag and flip | | 675 | * looks like BGRA - set the swap flag and flip |
676 | * the offsets | | 676 | * the offsets |
677 | */ | | 677 | */ |
678 | xf86Msg(X_INFO, "endian-flipped RGB framebuffer " | | 678 | xf86Msg(X_INFO, "endian-flipped RGB framebuffer " |
679 | "detected, using WsfbShadowUpdateSwap32()\n"); | | 679 | "detected, using WsfbShadowUpdateSwap32()\n"); |
680 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_offset = 0; | | 680 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_offset = 0; |
681 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.green_offset = 8; | | 681 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.green_offset = 8; |
682 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_offset = 16; | | 682 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_offset = 16; |
683 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.alpha_offset = 24; | | 683 | fPtr->fbi.fbi_subtype.fbi_rgbmasks.alpha_offset = 24; |
684 | fPtr->useSwap32 = TRUE; | | 684 | fPtr->useSwap32 = TRUE; |
685 | } | | 685 | } |
686 | | | 686 | |
687 | msk = 0xffffffff; | | 687 | msk = 0xffffffff; |
688 | msk = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_size; | | 688 | msk = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_size; |
689 | msk = ~msk; | | 689 | msk = ~msk; |
690 | masks.red = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_offset; | | 690 | masks.red = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.red_offset; |
691 | | | 691 | |
692 | msk = 0xffffffff; | | 692 | msk = 0xffffffff; |
693 | msk = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.green_size; | | 693 | msk = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.green_size; |
694 | msk = ~msk; | | 694 | msk = ~msk; |
695 | masks.green = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.green_offset; | | 695 | masks.green = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.green_offset; |
696 | | | 696 | |
697 | msk = 0xffffffff; | | 697 | msk = 0xffffffff; |
698 | msk = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_size; | | 698 | msk = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_size; |
699 | msk = ~msk; | | 699 | msk = ~msk; |
700 | masks.blue = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_offset; | | 700 | masks.blue = msk << fPtr->fbi.fbi_subtype.fbi_rgbmasks.blue_offset; |
701 | xf86Msg(X_INFO, "masks generated: %08lx %08lx %08lx\n", | | 701 | xf86Msg(X_INFO, "masks generated: %08lx %08lx %08lx\n", |
702 | (unsigned long)masks.red, | | 702 | (unsigned long)masks.red, |
703 | (unsigned long)masks.green, | | 703 | (unsigned long)masks.green, |
704 | (unsigned long)masks.blue); | | 704 | (unsigned long)masks.blue); |
705 | } else { | | 705 | } else { |
706 | masks.red = 0; | | 706 | masks.red = 0; |
707 | masks.green = 0; | | 707 | masks.green = 0; |
708 | masks.blue = 0; | | 708 | masks.blue = 0; |
709 | } | | 709 | } |
710 | | | 710 | |
711 | if (!xf86SetWeight(pScrn, zeros, masks)) | | 711 | if (!xf86SetWeight(pScrn, zeros, masks)) |
712 | return FALSE; | | 712 | return FALSE; |
713 | } | | 713 | } |
714 | | | 714 | |
715 | /* Visual init */ | | 715 | /* Visual init */ |
716 | if (!xf86SetDefaultVisual(pScrn, -1)) | | 716 | if (!xf86SetDefaultVisual(pScrn, -1)) |
717 | return FALSE; | | 717 | return FALSE; |
718 | | | 718 | |
719 | /* We don't currently support DirectColor at > 8bpp . */ | | 719 | /* We don't currently support DirectColor at > 8bpp . */ |
720 | if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { | | 720 | if (pScrn->depth > 8 && pScrn->defaultVisual != TrueColor) { |
721 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" | | 721 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual" |
722 | " (%s) is not supported at depth %d\n", | | 722 | " (%s) is not supported at depth %d\n", |
723 | xf86GetVisualName(pScrn->defaultVisual), | | 723 | xf86GetVisualName(pScrn->defaultVisual), |
724 | pScrn->depth); | | 724 | pScrn->depth); |
725 | return FALSE; | | 725 | return FALSE; |
726 | } | | 726 | } |
727 | | | 727 | |
728 | xf86SetGamma(pScrn,zeros); | | 728 | xf86SetGamma(pScrn,zeros); |
729 | | | 729 | |
730 | pScrn->progClock = TRUE; | | 730 | pScrn->progClock = TRUE; |
731 | pScrn->rgbBits = (pScrn->depth >= 8) ? 8 : pScrn->depth; | | 731 | pScrn->rgbBits = (pScrn->depth >= 8) ? 8 : pScrn->depth; |
732 | pScrn->chipset = "wsfb"; | | 732 | pScrn->chipset = "wsfb"; |
733 | pScrn->videoRam = fPtr->fbi.fbi_fbsize; | | 733 | pScrn->videoRam = fPtr->fbi.fbi_fbsize; |
734 | | | 734 | |
735 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Vidmem: %dk\n", | | 735 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Vidmem: %dk\n", |
736 | pScrn->videoRam/1024); | | 736 | pScrn->videoRam/1024); |
737 | | | 737 | |
738 | /* Fake video mode struct. */ | | 738 | /* Fake video mode struct. */ |
739 | mode = (DisplayModePtr)malloc(sizeof(DisplayModeRec)); | | 739 | mode = (DisplayModePtr)malloc(sizeof(DisplayModeRec)); |
740 | mode->prev = mode; | | 740 | mode->prev = mode; |
741 | mode->next = mode; | | 741 | mode->next = mode; |
742 | mode->name = "wsfb current mode"; | | 742 | mode->name = "wsfb current mode"; |
743 | mode->status = MODE_OK; | | 743 | mode->status = MODE_OK; |
744 | mode->type = M_T_BUILTIN; | | 744 | mode->type = M_T_BUILTIN; |
745 | mode->Clock = 0; | | 745 | mode->Clock = 0; |
746 | mode->HDisplay = fPtr->fbi.fbi_width; | | 746 | mode->HDisplay = fPtr->fbi.fbi_width; |
747 | mode->HSyncStart = 0; | | 747 | mode->HSyncStart = 0; |
748 | mode->HSyncEnd = 0; | | 748 | mode->HSyncEnd = 0; |
749 | mode->HTotal = 0; | | 749 | mode->HTotal = 0; |
750 | mode->HSkew = 0; | | 750 | mode->HSkew = 0; |
751 | mode->VDisplay = fPtr->fbi.fbi_height; | | 751 | mode->VDisplay = fPtr->fbi.fbi_height; |
752 | mode->VSyncStart = 0; | | 752 | mode->VSyncStart = 0; |
753 | mode->VSyncEnd = 0; | | 753 | mode->VSyncEnd = 0; |
754 | mode->VTotal = 0; | | 754 | mode->VTotal = 0; |
755 | mode->VScan = 0; | | 755 | mode->VScan = 0; |
756 | mode->Flags = 0; | | 756 | mode->Flags = 0; |
757 | if (pScrn->modes != NULL) { | | 757 | if (pScrn->modes != NULL) { |
758 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, | | 758 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
759 | "Ignoring mode specification from screen section\n"); | | 759 | "Ignoring mode specification from screen section\n"); |
760 | } | | 760 | } |
761 | pScrn->currentMode = pScrn->modes = mode; | | 761 | pScrn->currentMode = pScrn->modes = mode; |
762 | pScrn->virtualX = fPtr->fbi.fbi_width; | | 762 | pScrn->virtualX = fPtr->fbi.fbi_width; |
763 | pScrn->virtualY = fPtr->fbi.fbi_height; | | 763 | pScrn->virtualY = fPtr->fbi.fbi_height; |
764 | pScrn->displayWidth = pScrn->virtualX; | | 764 | pScrn->displayWidth = pScrn->virtualX; |
765 | | | 765 | |
766 | /* Set the display resolution. */ | | 766 | /* Set the display resolution. */ |
767 | xf86SetDpi(pScrn, 0, 0); | | 767 | xf86SetDpi(pScrn, 0, 0); |
768 | | | 768 | |
769 | from = X_DEFAULT; | | 769 | from = X_DEFAULT; |
770 | fPtr->HWCursor = TRUE; | | 770 | fPtr->HWCursor = TRUE; |
771 | if (xf86GetOptValBool(fPtr->Options, OPTION_HW_CURSOR, &fPtr->HWCursor)) | | 771 | if (xf86GetOptValBool(fPtr->Options, OPTION_HW_CURSOR, &fPtr->HWCursor)) |
772 | from = X_CONFIG; | | 772 | from = X_CONFIG; |
773 | if (xf86ReturnOptValBool(fPtr->Options, OPTION_SW_CURSOR, FALSE)) { | | 773 | if (xf86ReturnOptValBool(fPtr->Options, OPTION_SW_CURSOR, FALSE)) { |
774 | from = X_CONFIG; | | 774 | from = X_CONFIG; |
775 | fPtr->HWCursor = FALSE; | | 775 | fPtr->HWCursor = FALSE; |
776 | } | | 776 | } |
777 | xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", | | 777 | xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n", |
778 | fPtr->HWCursor ? "HW" : "SW"); | | 778 | fPtr->HWCursor ? "HW" : "SW"); |
779 | | | 779 | |
780 | /* Load bpp-specific modules. */ | | 780 | /* Load bpp-specific modules. */ |
781 | switch(pScrn->bitsPerPixel) { | | 781 | switch(pScrn->bitsPerPixel) { |
782 | case 1: | | 782 | case 1: |
783 | case 4: | | 783 | case 4: |
784 | default: | | 784 | default: |
785 | mod = "fb"; | | 785 | mod = "fb"; |
786 | break; | | 786 | break; |
787 | } | | 787 | } |
788 | | | 788 | |
789 | | | 789 | |
790 | /* Load shadow if needed. */ | | 790 | /* Load shadow if needed. */ |
791 | if (fPtr->shadowFB) { | | 791 | if (fPtr->shadowFB) { |
792 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, | | 792 | xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, |
793 | "Using \"Shadow Framebuffer\"\n"); | | 793 | "Using \"Shadow Framebuffer\"\n"); |
794 | if (xf86LoadSubModule(pScrn, "shadow") == NULL) { | | 794 | if (xf86LoadSubModule(pScrn, "shadow") == NULL) { |
795 | WsfbFreeRec(pScrn); | | 795 | WsfbFreeRec(pScrn); |
796 | return FALSE; | | 796 | return FALSE; |
797 | } | | 797 | } |
798 | } | | 798 | } |
799 | | | 799 | |
800 | if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { | | 800 | if (mod && xf86LoadSubModule(pScrn, mod) == NULL) { |
801 | WsfbFreeRec(pScrn); | | 801 | WsfbFreeRec(pScrn); |
802 | return FALSE; | | 802 | return FALSE; |
803 | } | | 803 | } |
804 | | | 804 | |
805 | if (xf86LoadSubModule(pScrn, "ramdac") == NULL) { | | 805 | if (xf86LoadSubModule(pScrn, "ramdac") == NULL) { |
806 | WsfbFreeRec(pScrn); | | 806 | WsfbFreeRec(pScrn); |
807 | return FALSE; | | 807 | return FALSE; |
808 | } | | 808 | } |
809 | | | 809 | |
810 | if (mod) { | | 810 | if (mod) { |
811 | if (reqSym) { | | 811 | if (reqSym) { |
812 | xf86LoaderReqSymbols(reqSym, NULL); | | 812 | xf86LoaderReqSymbols(reqSym, NULL); |
813 | } else { | | 813 | } else { |
814 | xf86LoaderReqSymLists(fbSymbols, NULL); | | 814 | xf86LoaderReqSymLists(fbSymbols, NULL); |
815 | } | | 815 | } |
816 | } | | 816 | } |
817 | TRACE_EXIT("PreInit"); | | 817 | TRACE_EXIT("PreInit"); |
818 | return TRUE; | | 818 | return TRUE; |
819 | } | | 819 | } |
820 | | | 820 | |
821 | static Bool | | 821 | static Bool |
822 | WsfbCreateScreenResources(ScreenPtr pScreen) | | 822 | WsfbCreateScreenResources(ScreenPtr pScreen) |
823 | { | | 823 | { |
824 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 824 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
825 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 825 | WsfbPtr fPtr = WSFBPTR(pScrn); |
826 | PixmapPtr pPixmap; | | 826 | PixmapPtr pPixmap; |
827 | Bool ret; | | 827 | Bool ret; |
828 | void (*shadowproc)(ScreenPtr, shadowBufPtr); | | 828 | void (*shadowproc)(ScreenPtr, shadowBufPtr); |
829 | | | 829 | |
830 | pScreen->CreateScreenResources = fPtr->CreateScreenResources; | | 830 | pScreen->CreateScreenResources = fPtr->CreateScreenResources; |
831 | ret = pScreen->CreateScreenResources(pScreen); | | 831 | ret = pScreen->CreateScreenResources(pScreen); |
832 | pScreen->CreateScreenResources = WsfbCreateScreenResources; | | 832 | pScreen->CreateScreenResources = WsfbCreateScreenResources; |
833 | | | 833 | |
834 | if (!ret) | | 834 | if (!ret) |
835 | return FALSE; | | 835 | return FALSE; |
836 | | | 836 | |
837 | pPixmap = pScreen->GetScreenPixmap(pScreen); | | 837 | pPixmap = pScreen->GetScreenPixmap(pScreen); |
838 | if (fPtr->fbi.fbi_flags & WSFB_VRAM_IS_SPLIT) { | | 838 | if (fPtr->fbi.fbi_flags & WSFB_VRAM_IS_SPLIT) { |
839 | shadowproc = WsfbShadowUpdateSplit; | | 839 | shadowproc = WsfbShadowUpdateSplit; |
840 | } else if (fPtr->useSwap32) { | | 840 | } else if (fPtr->useSwap32) { |
841 | shadowproc = WsfbShadowUpdateSwap32; | | 841 | shadowproc = WsfbShadowUpdateSwap32; |
842 | } else if (fPtr->rotate) { | | 842 | } else if (fPtr->rotate) { |
843 | shadowproc = shadowUpdateRotatePacked; | | 843 | shadowproc = shadowUpdateRotatePacked; |
844 | } else | | 844 | } else |
845 | shadowproc = shadowUpdatePacked; | | 845 | shadowproc = shadowUpdatePacked; |
846 | | | 846 | |
847 | if (!shadowAdd(pScreen, pPixmap, shadowproc, | | 847 | if (!shadowAdd(pScreen, pPixmap, shadowproc, |
848 | WsfbWindowLinear, fPtr->rotate, NULL)) { | | 848 | WsfbWindowLinear, fPtr->rotate, NULL)) { |
849 | return FALSE; | | 849 | return FALSE; |
850 | } | | 850 | } |
851 | return TRUE; | | 851 | return TRUE; |
852 | } | | 852 | } |
853 | | | 853 | |
854 | | | 854 | |
855 | static Bool | | 855 | static Bool |
856 | WsfbShadowInit(ScreenPtr pScreen) | | 856 | WsfbShadowInit(ScreenPtr pScreen) |
857 | { | | 857 | { |
858 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 858 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
859 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 859 | WsfbPtr fPtr = WSFBPTR(pScrn); |
860 | | | 860 | |
861 | if (!shadowSetup(pScreen)) | | 861 | if (!shadowSetup(pScreen)) |
862 | return FALSE; | | 862 | return FALSE; |
863 | fPtr->CreateScreenResources = pScreen->CreateScreenResources; | | 863 | fPtr->CreateScreenResources = pScreen->CreateScreenResources; |
864 | pScreen->CreateScreenResources = WsfbCreateScreenResources; | | 864 | pScreen->CreateScreenResources = WsfbCreateScreenResources; |
865 | | | 865 | |
866 | return TRUE; | | 866 | return TRUE; |
867 | } | | 867 | } |
868 | | | 868 | |
869 | static Bool | | 869 | static Bool |
870 | WsfbScreenInit(SCREEN_INIT_ARGS_DECL) | | 870 | WsfbScreenInit(SCREEN_INIT_ARGS_DECL) |
871 | { | | 871 | { |
872 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 872 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
873 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 873 | WsfbPtr fPtr = WSFBPTR(pScrn); |
874 | VisualPtr visual; | | 874 | VisualPtr visual; |
875 | int ret, flags, ncolors; | | 875 | int ret, flags, ncolors; |
876 | int wsmode = WSDISPLAYIO_MODE_DUMBFB; | | 876 | int wsmode = WSDISPLAYIO_MODE_DUMBFB; |
877 | int wstype; | | 877 | int wstype; |
| | | 878 | int width; |
878 | size_t len; | | 879 | size_t len; |
879 | | | 880 | |
880 | TRACE_ENTER("WsfbScreenInit"); | | 881 | TRACE_ENTER("WsfbScreenInit"); |
881 | #if DEBUG | | 882 | #if DEBUG |
882 | ErrorF("\tbitsPerPixel=%d, depth=%d, defaultVisual=%s\n" | | 883 | ErrorF("\tbitsPerPixel=%d, depth=%d, defaultVisual=%s\n" |
883 | "\tmask: %x,%x,%x, offset: %u,%u,%u\n", | | 884 | "\tmask: %x,%x,%x, offset: %u,%u,%u\n", |
884 | pScrn->bitsPerPixel, | | 885 | pScrn->bitsPerPixel, |
885 | pScrn->depth, | | 886 | pScrn->depth, |
886 | xf86GetVisualName(pScrn->defaultVisual), | | 887 | xf86GetVisualName(pScrn->defaultVisual), |
887 | pScrn->mask.red,pScrn->mask.green,pScrn->mask.blue, | | 888 | pScrn->mask.red,pScrn->mask.green,pScrn->mask.blue, |
888 | pScrn->offset.red,pScrn->offset.green,pScrn->offset.blue); | | 889 | pScrn->offset.red,pScrn->offset.green,pScrn->offset.blue); |
889 | #endif | | 890 | #endif |
890 | switch (fPtr->fbi.fbi_bitsperpixel) { | | 891 | switch (fPtr->fbi.fbi_bitsperpixel) { |
891 | case 1: | | 892 | case 1: |
892 | case 4: | | 893 | case 4: |
893 | case 8: | | 894 | case 8: |
894 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; | | 895 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; |
895 | break; | | 896 | break; |
896 | case 15: | | 897 | case 15: |
897 | case 16: | | 898 | case 16: |
898 | if (fPtr->fbi.fbi_stride == fPtr->fbi.fbi_width) { | | 899 | if (fPtr->fbi.fbi_stride == fPtr->fbi.fbi_width) { |
899 | xf86Msg(X_ERROR, "Bogus stride == width in 16bit colour\n"); | | 900 | xf86Msg(X_ERROR, "Bogus stride == width in 16bit colour\n"); |
900 | len = fPtr->fbi.fbi_width * fPtr->fbi.fbi_height * sizeof(short); | | 901 | len = fPtr->fbi.fbi_width * fPtr->fbi.fbi_height * sizeof(short); |
901 | } else { | | 902 | } else { |
902 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; | | 903 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; |
903 | } | | 904 | } |
904 | break; | | 905 | break; |
905 | case 24: | | 906 | case 24: |
906 | if (fPtr->fbi.fbi_stride == fPtr->fbi.fbi_width) { | | 907 | if (fPtr->fbi.fbi_stride == fPtr->fbi.fbi_width) { |
907 | xf86Msg(X_ERROR, "Bogus stride == width in 24bit colour\n"); | | 908 | xf86Msg(X_ERROR, "Bogus stride == width in 24bit colour\n"); |
908 | len = fPtr->fbi.fbi_width * fPtr->fbi.fbi_height * 3; | | 909 | len = fPtr->fbi.fbi_width * fPtr->fbi.fbi_height * 3; |
909 | } else { | | 910 | } else { |
910 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; | | 911 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; |
911 | } | | 912 | } |
912 | break; | | 913 | break; |
913 | case 32: | | 914 | case 32: |
914 | if (fPtr->fbi.fbi_stride == fPtr->fbi.fbi_width) { | | 915 | if (fPtr->fbi.fbi_stride == fPtr->fbi.fbi_width) { |
915 | xf86Msg(X_ERROR, "Bogus stride == width in 32bit colour\n"); | | 916 | xf86Msg(X_ERROR, "Bogus stride == width in 32bit colour\n"); |
916 | len = fPtr->fbi.fbi_width * fPtr->fbi.fbi_height * sizeof(int); | | 917 | len = fPtr->fbi.fbi_width * fPtr->fbi.fbi_height * sizeof(int); |
917 | } else { | | 918 | } else { |
918 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; | | 919 | len = fPtr->fbi.fbi_stride * fPtr->fbi.fbi_height; |
919 | } | | 920 | } |
920 | break; | | 921 | break; |
921 | default: | | 922 | default: |
922 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 923 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
923 | "unsupported depth %d\n", fPtr->fbi.fbi_bitsperpixel); | | 924 | "unsupported depth %d\n", fPtr->fbi.fbi_bitsperpixel); |
924 | return FALSE; | | 925 | return FALSE; |
925 | } | | 926 | } |
926 | /* Switch to graphics mode - required before mmap. */ | | 927 | /* Switch to graphics mode - required before mmap. */ |
927 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) { | | 928 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &wsmode) == -1) { |
928 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 929 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
929 | "ioctl WSDISPLAYIO_SMODE: %s\n", | | 930 | "ioctl WSDISPLAYIO_SMODE: %s\n", |
930 | strerror(errno)); | | 931 | strerror(errno)); |
931 | return FALSE; | | 932 | return FALSE; |
932 | } | | 933 | } |
933 | /* Get wsdisplay type to handle quirks */ | | 934 | /* Get wsdisplay type to handle quirks */ |
934 | if (ioctl(fPtr->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { | | 935 | if (ioctl(fPtr->fd, WSDISPLAYIO_GTYPE, &wstype) == -1) { |
935 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 936 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
936 | "ioctl WSDISPLAY_GTYPE: %s\n", | | 937 | "ioctl WSDISPLAY_GTYPE: %s\n", |
937 | strerror(errno)); | | 938 | strerror(errno)); |
938 | return FALSE; | | 939 | return FALSE; |
939 | } | | 940 | } |
940 | len = max(len, fPtr->fbi.fbi_fbsize); | | 941 | len = max(len, fPtr->fbi.fbi_fbsize); |
941 | fPtr->fbmem = wsfb_mmap(len + fPtr->fbi.fbi_fboffset, 0, fPtr->fd); | | 942 | fPtr->fbmem = wsfb_mmap(len + fPtr->fbi.fbi_fboffset, 0, fPtr->fd); |
942 | | | 943 | |
943 | if (fPtr->fbmem == NULL) { | | 944 | if (fPtr->fbmem == NULL) { |
944 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 945 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
945 | "wsfb_mmap: %s\n", strerror(errno)); | | 946 | "wsfb_mmap: %s\n", strerror(errno)); |
946 | return FALSE; | | 947 | return FALSE; |
947 | } | | 948 | } |
948 | fPtr->fbmem_len = len; | | 949 | fPtr->fbmem_len = len; |
949 | | | 950 | |
950 | WsfbSave(pScrn); | | 951 | WsfbSave(pScrn); |
951 | pScrn->vtSema = TRUE; | | 952 | pScrn->vtSema = TRUE; |
952 | | | 953 | |
953 | /* MI layer */ | | 954 | /* MI layer */ |
954 | miClearVisualTypes(); | | 955 | miClearVisualTypes(); |
955 | if (pScrn->bitsPerPixel > 8) { | | 956 | if (pScrn->bitsPerPixel > 8) { |
956 | if (!miSetVisualTypes(pScrn->depth, TrueColorMask, | | 957 | if (!miSetVisualTypes(pScrn->depth, TrueColorMask, |
957 | pScrn->rgbBits, TrueColor)) | | 958 | pScrn->rgbBits, TrueColor)) |
958 | return FALSE; | | 959 | return FALSE; |
959 | } else { | | 960 | } else { |
960 | if (!miSetVisualTypes(pScrn->depth, | | 961 | if (!miSetVisualTypes(pScrn->depth, |
961 | miGetDefaultVisualMask(pScrn->depth), | | 962 | miGetDefaultVisualMask(pScrn->depth), |
962 | pScrn->rgbBits, pScrn->defaultVisual)) | | 963 | pScrn->rgbBits, pScrn->defaultVisual)) |
963 | return FALSE; | | 964 | return FALSE; |
964 | } | | 965 | } |
965 | if (!miSetPixmapDepths()) | | 966 | if (!miSetPixmapDepths()) |
966 | return FALSE; | | 967 | return FALSE; |
967 | | | 968 | |
968 | if (fPtr->rotate == WSFB_ROTATE_CW | | 969 | if (fPtr->rotate == WSFB_ROTATE_CW |
969 | || fPtr->rotate == WSFB_ROTATE_CCW) { | | 970 | || fPtr->rotate == WSFB_ROTATE_CCW) { |
970 | int tmp = pScrn->virtualX; | | 971 | int tmp = pScrn->virtualX; |
971 | pScrn->virtualX = pScrn->displayWidth = pScrn->virtualY; | | 972 | pScrn->virtualX = pScrn->displayWidth = pScrn->virtualY; |
972 | pScrn->virtualY = tmp; | | 973 | pScrn->virtualY = tmp; |
973 | } | | 974 | } |
974 | if (fPtr->rotate && !fPtr->PointerMoved) { | | 975 | if (fPtr->rotate && !fPtr->PointerMoved) { |
975 | fPtr->PointerMoved = pScrn->PointerMoved; | | 976 | fPtr->PointerMoved = pScrn->PointerMoved; |
976 | pScrn->PointerMoved = WsfbPointerMoved; | | 977 | pScrn->PointerMoved = WsfbPointerMoved; |
977 | } | | 978 | } |
978 | | | 979 | |
979 | fPtr->fbstart = fPtr->fbmem + fPtr->fbi.fbi_fboffset; | | 980 | fPtr->fbstart = fPtr->fbmem + fPtr->fbi.fbi_fboffset; |
980 | | | 981 | |
981 | if (fPtr->shadowFB) { | | 982 | if (fPtr->shadowFB) { |
982 | fPtr->shadow = calloc(1, fPtr->fbi.fbi_stride * pScrn->virtualY); | | 983 | if (fPtr->rotate) { |
| | | 984 | /* |
| | | 985 | * Note Rotate and Shadow FB options are valid |
| | | 986 | * only on depth >= 8. |
| | | 987 | */ |
| | | 988 | len = pScrn->virtualX * pScrn->virtualY * |
| | | 989 | (pScrn->bitsPerPixel >> 3); |
| | | 990 | } else { |
| | | 991 | len = fPtr->fbi.fbi_stride * pScrn->virtualY; |
| | | 992 | } |
| | | 993 | fPtr->shadow = calloc(1, len); |
983 | | | 994 | |
984 | if (!fPtr->shadow) { | | 995 | if (!fPtr->shadow) { |
985 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 996 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
986 | "Failed to allocate shadow framebuffer\n"); | | 997 | "Failed to allocate shadow framebuffer\n"); |
987 | return FALSE; | | 998 | return FALSE; |
988 | } | | 999 | } |
989 | } | | 1000 | } |
990 | | | 1001 | |
| | | 1002 | /* |
| | | 1003 | * fbScreenInit() seems to require "pixel width of frame buffer" |
| | | 1004 | * but it is actually "stride in pixel" of frame buffer, |
| | | 1005 | * per xorg/xserver/tree/fb/fbscreen.c. |
| | | 1006 | */ |
| | | 1007 | if (fPtr->rotate) { |
| | | 1008 | width = pScrn->displayWidth; |
| | | 1009 | } else { |
| | | 1010 | if (pScrn->bitsPerPixel > 8) { |
| | | 1011 | width = |
| | | 1012 | fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3); |
| | | 1013 | } else { |
| | | 1014 | width = |
| | | 1015 | fPtr->fbi.fbi_stride * (8 / pScrn->bitsPerPixel); |
| | | 1016 | } |
| | | 1017 | } |
991 | switch (pScrn->bitsPerPixel) { | | 1018 | switch (pScrn->bitsPerPixel) { |
992 | case 1: | | 1019 | case 1: |
993 | ret = fbScreenInit(pScreen, | | 1020 | ret = fbScreenInit(pScreen, |
994 | fPtr->fbstart, | | 1021 | fPtr->fbstart, |
995 | pScrn->virtualX, pScrn->virtualY, | | 1022 | pScrn->virtualX, pScrn->virtualY, |
996 | pScrn->xDpi, pScrn->yDpi, | | 1023 | pScrn->xDpi, pScrn->yDpi, |
997 | fPtr->fbi.fbi_stride * 8, pScrn->bitsPerPixel); | | 1024 | width, pScrn->bitsPerPixel); |
998 | break; | | 1025 | break; |
999 | case 4: | | 1026 | case 4: |
1000 | case 8: | | 1027 | case 8: |
1001 | case 16: | | 1028 | case 16: |
1002 | case 24: | | 1029 | case 24: |
1003 | case 32: | | 1030 | case 32: |
1004 | ret = fbScreenInit(pScreen, | | 1031 | ret = fbScreenInit(pScreen, |
1005 | fPtr->shadowFB ? fPtr->shadow : fPtr->fbstart, | | 1032 | fPtr->shadowFB ? fPtr->shadow : fPtr->fbstart, |
1006 | pScrn->virtualX, pScrn->virtualY, | | 1033 | pScrn->virtualX, pScrn->virtualY, |
1007 | pScrn->xDpi, pScrn->yDpi, | | 1034 | pScrn->xDpi, pScrn->yDpi, |
1008 | /* apparently fb wants stride in pixels, not bytes */ | | 1035 | width, |
1009 | fPtr->fbi.fbi_stride / (pScrn->bitsPerPixel >> 3), | | | |
1010 | pScrn->bitsPerPixel); | | 1036 | pScrn->bitsPerPixel); |
1011 | break; | | 1037 | break; |
1012 | default: | | 1038 | default: |
1013 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1039 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1014 | "Unsupported bpp: %d", pScrn->bitsPerPixel); | | 1040 | "Unsupported bpp: %d", pScrn->bitsPerPixel); |
1015 | return FALSE; | | 1041 | return FALSE; |
1016 | } /* case */ | | 1042 | } /* case */ |
1017 | | | 1043 | |
1018 | if (!ret) | | 1044 | if (!ret) |
1019 | return FALSE; | | 1045 | return FALSE; |
1020 | | | 1046 | |
1021 | if (pScrn->bitsPerPixel > 8) { | | 1047 | if (pScrn->bitsPerPixel > 8) { |
1022 | /* Fixup RGB ordering. */ | | 1048 | /* Fixup RGB ordering. */ |
1023 | visual = pScreen->visuals + pScreen->numVisuals; | | 1049 | visual = pScreen->visuals + pScreen->numVisuals; |
1024 | while (--visual >= pScreen->visuals) { | | 1050 | while (--visual >= pScreen->visuals) { |
1025 | if ((visual->class | DynamicClass) == DirectColor) { | | 1051 | if ((visual->class | DynamicClass) == DirectColor) { |
1026 | visual->offsetRed = pScrn->offset.red; | | 1052 | visual->offsetRed = pScrn->offset.red; |
1027 | visual->offsetGreen = pScrn->offset.green; | | 1053 | visual->offsetGreen = pScrn->offset.green; |
1028 | visual->offsetBlue = pScrn->offset.blue; | | 1054 | visual->offsetBlue = pScrn->offset.blue; |
1029 | visual->redMask = pScrn->mask.red; | | 1055 | visual->redMask = pScrn->mask.red; |
1030 | visual->greenMask = pScrn->mask.green; | | 1056 | visual->greenMask = pScrn->mask.green; |
1031 | visual->blueMask = pScrn->mask.blue; | | 1057 | visual->blueMask = pScrn->mask.blue; |
1032 | } | | 1058 | } |
1033 | } | | 1059 | } |
1034 | } | | 1060 | } |
1035 | | | 1061 | |
1036 | if (pScrn->bitsPerPixel >= 8) { | | 1062 | if (pScrn->bitsPerPixel >= 8) { |
1037 | if (!fbPictureInit(pScreen, NULL, 0)) | | 1063 | if (!fbPictureInit(pScreen, NULL, 0)) |
1038 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, | | 1064 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
1039 | "RENDER extension initialisation failed."); | | 1065 | "RENDER extension initialisation failed."); |
1040 | } | | 1066 | } |
1041 | if (fPtr->shadowFB && !WsfbShadowInit(pScreen)) { | | 1067 | if (fPtr->shadowFB && !WsfbShadowInit(pScreen)) { |
1042 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1068 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1043 | "shadow framebuffer initialization failed\n"); | | 1069 | "shadow framebuffer initialization failed\n"); |
1044 | return FALSE; | | 1070 | return FALSE; |
1045 | } | | 1071 | } |
1046 | | | 1072 | |
1047 | #ifdef XFreeXDGA | | 1073 | #ifdef XFreeXDGA |
1048 | if (!fPtr->rotate) | | 1074 | if (!fPtr->rotate) |
1049 | WsfbDGAInit(pScrn, pScreen); | | 1075 | WsfbDGAInit(pScrn, pScreen); |
1050 | else | | 1076 | else |
1051 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotated display, " | | 1077 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Rotated display, " |
1052 | "disabling DGA\n"); | | 1078 | "disabling DGA\n"); |
1053 | #endif | | 1079 | #endif |
1054 | if (fPtr->rotate) { | | 1080 | if (fPtr->rotate) { |
1055 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Enabling Driver Rotation, " | | 1081 | xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Enabling Driver Rotation, " |
1056 | "disabling RandR\n"); | | 1082 | "disabling RandR\n"); |
1057 | #if 0 | | 1083 | #if 0 |
1058 | xf86DisableRandR(); | | 1084 | xf86DisableRandR(); |
1059 | #endif | | 1085 | #endif |
1060 | if (pScrn->bitsPerPixel == 24) | | 1086 | if (pScrn->bitsPerPixel == 24) |
1061 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, | | 1087 | xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
1062 | "Rotation might be broken in 24 bpp\n"); | | 1088 | "Rotation might be broken in 24 bpp\n"); |
1063 | } | | 1089 | } |
1064 | | | 1090 | |
1065 | xf86SetBlackWhitePixels(pScreen); | | 1091 | xf86SetBlackWhitePixels(pScreen); |
1066 | xf86SetBackingStore(pScreen); | | 1092 | xf86SetBackingStore(pScreen); |
1067 | | | 1093 | |
1068 | /* Software cursor. */ | | 1094 | /* Software cursor. */ |
1069 | miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); | | 1095 | miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); |
1070 | | | 1096 | |
1071 | /* check for hardware cursor support */ | | 1097 | /* check for hardware cursor support */ |
1072 | if (fPtr->HWCursor) | | 1098 | if (fPtr->HWCursor) |
1073 | WsfbSetupCursor(pScreen); | | 1099 | WsfbSetupCursor(pScreen); |
1074 | | | 1100 | |
1075 | /* | | 1101 | /* |
1076 | * Colormap | | 1102 | * Colormap |
1077 | * | | 1103 | * |
1078 | * Note that, even on less than 8 bit depth frame buffers, we | | 1104 | * Note that, even on less than 8 bit depth frame buffers, we |
1079 | * expect the colormap to be programmable with 8 bit values. | | 1105 | * expect the colormap to be programmable with 8 bit values. |
1080 | * As of now, this is indeed the case on all OpenBSD supported | | 1106 | * As of now, this is indeed the case on all OpenBSD supported |
1081 | * graphics hardware. | | 1107 | * graphics hardware. |
1082 | */ | | 1108 | */ |
1083 | if (!miCreateDefColormap(pScreen)) | | 1109 | if (!miCreateDefColormap(pScreen)) |
1084 | return FALSE; | | 1110 | return FALSE; |
1085 | flags = CMAP_RELOAD_ON_MODE_SWITCH; | | 1111 | flags = CMAP_RELOAD_ON_MODE_SWITCH; |
1086 | | | 1112 | |
1087 | ncolors = 0; | | 1113 | ncolors = 0; |
1088 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI) { | | 1114 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI) { |
1089 | ncolors = fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries; | | 1115 | ncolors = fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries; |
1090 | } | | 1116 | } |
1091 | | | 1117 | |
1092 | /* On StaticGray visuals, fake a 256 entries colormap. */ | | 1118 | /* On StaticGray visuals, fake a 256 entries colormap. */ |
1093 | if (ncolors == 0) | | 1119 | if (ncolors == 0) |
1094 | ncolors = 256; | | 1120 | ncolors = 256; |
1095 | | | 1121 | |
1096 | if(!xf86HandleColormaps(pScreen, ncolors, 8, WsfbLoadPalette, | | 1122 | if(!xf86HandleColormaps(pScreen, ncolors, 8, WsfbLoadPalette, |
1097 | NULL, flags)) | | 1123 | NULL, flags)) |
1098 | return FALSE; | | 1124 | return FALSE; |
1099 | | | 1125 | |
1100 | #if defined(__NetBSD__) && defined(WSDISPLAY_TYPE_LUNA) | | 1126 | #if defined(__NetBSD__) && defined(WSDISPLAY_TYPE_LUNA) |
1101 | if (wstype == WSDISPLAY_TYPE_LUNA) { | | 1127 | if (wstype == WSDISPLAY_TYPE_LUNA) { |
1102 | ncolors = fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries; | | 1128 | ncolors = fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries; |
1103 | if (ncolors > 0) { | | 1129 | if (ncolors > 0) { |
1104 | /* | | 1130 | /* |
1105 | * Override palette to use 4bpp/8bpp framebuffers as | | 1131 | * Override palette to use 4bpp/8bpp framebuffers as |
1106 | * monochrome server by using only the first plane. | | 1132 | * monochrome server by using only the first plane. |
1107 | * See also comment in WsfbPreInit(). | | 1133 | * See also comment in WsfbPreInit(). |
1108 | */ | | 1134 | */ |
1109 | struct wsdisplay_cmap cmap; | | 1135 | struct wsdisplay_cmap cmap; |
1110 | uint8_t r[256], g[256], b[256]; | | 1136 | uint8_t r[256], g[256], b[256]; |
1111 | int p; | | 1137 | int p; |
1112 | | | 1138 | |
1113 | for (p = 0; p < ncolors; p++) | | 1139 | for (p = 0; p < ncolors; p++) |
1114 | r[p] = g[p] = b[p] = (p & 1) ? 0xff : 0; | | 1140 | r[p] = g[p] = b[p] = (p & 1) ? 0xff : 0; |
1115 | cmap.index = 0; | | 1141 | cmap.index = 0; |
1116 | cmap.count = ncolors; | | 1142 | cmap.count = ncolors; |
1117 | cmap.red = r; | | 1143 | cmap.red = r; |
1118 | cmap.green = g; | | 1144 | cmap.green = g; |
1119 | cmap.blue = b; | | 1145 | cmap.blue = b; |
1120 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, &cmap) == -1) { | | 1146 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, &cmap) == -1) { |
1121 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1147 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1122 | "ioctl WSDISPLAYIO_PUTCMAP: %s\n", | | 1148 | "ioctl WSDISPLAYIO_PUTCMAP: %s\n", |
1123 | strerror(errno)); | | 1149 | strerror(errno)); |
1124 | } | | 1150 | } |
1125 | } | | 1151 | } |
1126 | } | | 1152 | } |
1127 | #endif | | 1153 | #endif |
1128 | | | 1154 | |
1129 | pScreen->SaveScreen = WsfbSaveScreen; | | 1155 | pScreen->SaveScreen = WsfbSaveScreen; |
1130 | | | 1156 | |
1131 | #ifdef XvExtension | | 1157 | #ifdef XvExtension |
1132 | { | | 1158 | { |
1133 | XF86VideoAdaptorPtr *ptr; | | 1159 | XF86VideoAdaptorPtr *ptr; |
1134 | | | 1160 | |
1135 | int n = xf86XVListGenericAdaptors(pScrn,&ptr); | | 1161 | int n = xf86XVListGenericAdaptors(pScrn,&ptr); |
1136 | if (n) { | | 1162 | if (n) { |
1137 | xf86XVScreenInit(pScreen,ptr,n); | | 1163 | xf86XVScreenInit(pScreen,ptr,n); |
1138 | } | | 1164 | } |
1139 | } | | 1165 | } |
1140 | #endif | | 1166 | #endif |
1141 | | | 1167 | |
1142 | /* Wrap the current CloseScreen function. */ | | 1168 | /* Wrap the current CloseScreen function. */ |
1143 | fPtr->CloseScreen = pScreen->CloseScreen; | | 1169 | fPtr->CloseScreen = pScreen->CloseScreen; |
1144 | pScreen->CloseScreen = WsfbCloseScreen; | | 1170 | pScreen->CloseScreen = WsfbCloseScreen; |
1145 | | | 1171 | |
1146 | TRACE_EXIT("WsfbScreenInit"); | | 1172 | TRACE_EXIT("WsfbScreenInit"); |
1147 | return TRUE; | | 1173 | return TRUE; |
1148 | } | | 1174 | } |
1149 | | | 1175 | |
1150 | static Bool | | 1176 | static Bool |
1151 | WsfbCloseScreen(CLOSE_SCREEN_ARGS_DECL) | | 1177 | WsfbCloseScreen(CLOSE_SCREEN_ARGS_DECL) |
1152 | { | | 1178 | { |
1153 | ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); | | 1179 | ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
1154 | PixmapPtr pPixmap; | | 1180 | PixmapPtr pPixmap; |
1155 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1181 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1156 | | | 1182 | |
1157 | | | 1183 | |
1158 | TRACE_ENTER("WsfbCloseScreen"); | | 1184 | TRACE_ENTER("WsfbCloseScreen"); |
1159 | | | 1185 | |
1160 | pPixmap = pScreen->GetScreenPixmap(pScreen); | | 1186 | pPixmap = pScreen->GetScreenPixmap(pScreen); |
1161 | if (fPtr->shadowFB) | | 1187 | if (fPtr->shadowFB) |
1162 | shadowRemove(pScreen, pPixmap); | | 1188 | shadowRemove(pScreen, pPixmap); |
1163 | | | 1189 | |
1164 | if (pScrn->vtSema) { | | 1190 | if (pScrn->vtSema) { |
1165 | WsfbRestore(pScrn); | | 1191 | WsfbRestore(pScrn); |
1166 | if (munmap(fPtr->fbmem, fPtr->fbmem_len + fPtr->fbi.fbi_fboffset) == -1) { | | 1192 | if (munmap(fPtr->fbmem, fPtr->fbmem_len + fPtr->fbi.fbi_fboffset) == -1) { |
1167 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1193 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1168 | "munmap: %s\n", strerror(errno)); | | 1194 | "munmap: %s\n", strerror(errno)); |
1169 | } | | 1195 | } |
1170 | | | 1196 | |
1171 | fPtr->fbmem = NULL; | | 1197 | fPtr->fbmem = NULL; |
1172 | } | | 1198 | } |
1173 | #ifdef XFreeXDGA | | 1199 | #ifdef XFreeXDGA |
1174 | if (fPtr->pDGAMode) { | | 1200 | if (fPtr->pDGAMode) { |
1175 | free(fPtr->pDGAMode); | | 1201 | free(fPtr->pDGAMode); |
1176 | fPtr->pDGAMode = NULL; | | 1202 | fPtr->pDGAMode = NULL; |
1177 | fPtr->nDGAMode = 0; | | 1203 | fPtr->nDGAMode = 0; |
1178 | } | | 1204 | } |
1179 | #endif | | 1205 | #endif |
1180 | pScrn->vtSema = FALSE; | | 1206 | pScrn->vtSema = FALSE; |
1181 | | | 1207 | |
1182 | /* Unwrap CloseScreen. */ | | 1208 | /* Unwrap CloseScreen. */ |
1183 | pScreen->CloseScreen = fPtr->CloseScreen; | | 1209 | pScreen->CloseScreen = fPtr->CloseScreen; |
1184 | TRACE_EXIT("WsfbCloseScreen"); | | 1210 | TRACE_EXIT("WsfbCloseScreen"); |
1185 | return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); | | 1211 | return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS); |
1186 | } | | 1212 | } |
1187 | | | 1213 | |
1188 | static void * | | 1214 | static void * |
1189 | WsfbWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, | | 1215 | WsfbWindowLinear(ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, |
1190 | CARD32 *size, void *closure) | | 1216 | CARD32 *size, void *closure) |
1191 | { | | 1217 | { |
1192 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 1218 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
1193 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1219 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1194 | | | 1220 | |
1195 | /* | | 1221 | /* |
1196 | * XXX | | 1222 | * XXX |
1197 | * This should never happen. Is it really necessary? | | 1223 | * This should never happen. Is it really necessary? |
1198 | */ | | 1224 | */ |
1199 | if (fPtr->fbi.fbi_stride) | | 1225 | if (fPtr->fbi.fbi_stride) |
1200 | *size = fPtr->fbi.fbi_stride; | | 1226 | *size = fPtr->fbi.fbi_stride; |
1201 | else { | | 1227 | else { |
1202 | if (ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, size) == -1) | | 1228 | if (ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, size) == -1) |
1203 | return NULL; | | 1229 | return NULL; |
1204 | fPtr->fbi.fbi_stride = *size; | | 1230 | fPtr->fbi.fbi_stride = *size; |
1205 | } | | 1231 | } |
1206 | return ((CARD8 *)fPtr->fbstart + row * fPtr->fbi.fbi_stride + offset); | | 1232 | return ((CARD8 *)fPtr->fbstart + row * fPtr->fbi.fbi_stride + offset); |
1207 | } | | 1233 | } |
1208 | | | 1234 | |
1209 | static void | | 1235 | static void |
1210 | WsfbPointerMoved(SCRN_ARG_TYPE arg, int x, int y) | | 1236 | WsfbPointerMoved(SCRN_ARG_TYPE arg, int x, int y) |
1211 | { | | 1237 | { |
1212 | SCRN_INFO_PTR(arg); | | 1238 | SCRN_INFO_PTR(arg); |
1213 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1239 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1214 | int newX, newY; | | 1240 | int newX, newY; |
1215 | | | 1241 | |
1216 | switch (fPtr->rotate) | | 1242 | switch (fPtr->rotate) |
1217 | { | | 1243 | { |
1218 | case WSFB_ROTATE_CW: | | 1244 | case WSFB_ROTATE_CW: |
1219 | /* 90 degrees CW rotation. */ | | 1245 | /* 90 degrees CW rotation. */ |
1220 | newX = pScrn->pScreen->height - y - 1; | | 1246 | newX = pScrn->pScreen->height - y - 1; |
1221 | newY = x; | | 1247 | newY = x; |
1222 | break; | | 1248 | break; |
1223 | | | 1249 | |
1224 | case WSFB_ROTATE_CCW: | | 1250 | case WSFB_ROTATE_CCW: |
1225 | /* 90 degrees CCW rotation. */ | | 1251 | /* 90 degrees CCW rotation. */ |
1226 | newX = y; | | 1252 | newX = y; |
1227 | newY = pScrn->pScreen->width - x - 1; | | 1253 | newY = pScrn->pScreen->width - x - 1; |
1228 | break; | | 1254 | break; |
1229 | | | 1255 | |
1230 | case WSFB_ROTATE_UD: | | 1256 | case WSFB_ROTATE_UD: |
1231 | /* 180 degrees UD rotation. */ | | 1257 | /* 180 degrees UD rotation. */ |
1232 | newX = pScrn->pScreen->width - x - 1; | | 1258 | newX = pScrn->pScreen->width - x - 1; |
1233 | newY = pScrn->pScreen->height - y - 1; | | 1259 | newY = pScrn->pScreen->height - y - 1; |
1234 | break; | | 1260 | break; |
1235 | | | 1261 | |
1236 | default: | | 1262 | default: |
1237 | /* No rotation. */ | | 1263 | /* No rotation. */ |
1238 | newX = x; | | 1264 | newX = x; |
1239 | newY = y; | | 1265 | newY = y; |
1240 | break; | | 1266 | break; |
1241 | } | | 1267 | } |
1242 | | | 1268 | |
1243 | /* Pass adjusted pointer coordinates to wrapped PointerMoved function. */ | | 1269 | /* Pass adjusted pointer coordinates to wrapped PointerMoved function. */ |
1244 | (*fPtr->PointerMoved)(arg, newX, newY); | | 1270 | (*fPtr->PointerMoved)(arg, newX, newY); |
1245 | } | | 1271 | } |
1246 | | | 1272 | |
1247 | static Bool | | 1273 | static Bool |
1248 | WsfbEnterVT(VT_FUNC_ARGS_DECL) | | 1274 | WsfbEnterVT(VT_FUNC_ARGS_DECL) |
1249 | { | | 1275 | { |
1250 | SCRN_INFO_PTR(arg); | | 1276 | SCRN_INFO_PTR(arg); |
1251 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1277 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1252 | int mode; | | 1278 | int mode; |
1253 | | | 1279 | |
1254 | TRACE_ENTER("EnterVT"); | | 1280 | TRACE_ENTER("EnterVT"); |
1255 | pScrn->vtSema = TRUE; | | 1281 | pScrn->vtSema = TRUE; |
1256 | | | 1282 | |
1257 | /* Restore the graphics mode. */ | | 1283 | /* Restore the graphics mode. */ |
1258 | mode = WSDISPLAYIO_MODE_DUMBFB; | | 1284 | mode = WSDISPLAYIO_MODE_DUMBFB; |
1259 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { | | 1285 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { |
1260 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1286 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1261 | "error setting graphics mode %s\n", strerror(errno)); | | 1287 | "error setting graphics mode %s\n", strerror(errno)); |
1262 | } | | 1288 | } |
1263 | | | 1289 | |
1264 | TRACE_EXIT("EnterVT"); | | 1290 | TRACE_EXIT("EnterVT"); |
1265 | return TRUE; | | 1291 | return TRUE; |
1266 | } | | 1292 | } |
1267 | | | 1293 | |
1268 | static void | | 1294 | static void |
1269 | WsfbLeaveVT(VT_FUNC_ARGS_DECL) | | 1295 | WsfbLeaveVT(VT_FUNC_ARGS_DECL) |
1270 | { | | 1296 | { |
1271 | SCRN_INFO_PTR(arg); | | 1297 | SCRN_INFO_PTR(arg); |
1272 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1298 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1273 | int mode; | | 1299 | int mode; |
1274 | | | 1300 | |
1275 | TRACE_ENTER("LeaveVT"); | | 1301 | TRACE_ENTER("LeaveVT"); |
1276 | | | 1302 | |
1277 | /* | | 1303 | /* |
1278 | * stuff to do: | | 1304 | * stuff to do: |
1279 | * - turn off hw cursor | | 1305 | * - turn off hw cursor |
1280 | * - restore colour map if WSFB_CI | | 1306 | * - restore colour map if WSFB_CI |
1281 | * - ioctl(WSDISPLAYIO_MODE_EMUL) to notify the kernel driver that | | 1307 | * - ioctl(WSDISPLAYIO_MODE_EMUL) to notify the kernel driver that |
1282 | * we're backing off | | 1308 | * we're backing off |
1283 | */ | | 1309 | */ |
1284 | | | 1310 | |
1285 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI && | | 1311 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI && |
1286 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries > 0) { | | 1312 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries > 0) { |
1287 | /* reset colormap for text mode */ | | 1313 | /* reset colormap for text mode */ |
1288 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, | | 1314 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, |
1289 | &(fPtr->saved_cmap)) == -1) { | | 1315 | &(fPtr->saved_cmap)) == -1) { |
1290 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1316 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1291 | "error restoring colormap %s\n", | | 1317 | "error restoring colormap %s\n", |
1292 | strerror(errno)); | | 1318 | strerror(errno)); |
1293 | } | | 1319 | } |
1294 | } | | 1320 | } |
1295 | | | 1321 | |
1296 | /* Restore the text mode. */ | | 1322 | /* Restore the text mode. */ |
1297 | mode = WSDISPLAYIO_MODE_EMUL; | | 1323 | mode = WSDISPLAYIO_MODE_EMUL; |
1298 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { | | 1324 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { |
1299 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1325 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1300 | "error setting text mode %s\n", strerror(errno)); | | 1326 | "error setting text mode %s\n", strerror(errno)); |
1301 | } | | 1327 | } |
1302 | | | 1328 | |
1303 | pScrn->vtSema = FALSE; | | 1329 | pScrn->vtSema = FALSE; |
1304 | TRACE_EXIT("LeaveVT"); | | 1330 | TRACE_EXIT("LeaveVT"); |
1305 | } | | 1331 | } |
1306 | | | 1332 | |
1307 | static Bool | | 1333 | static Bool |
1308 | WsfbSwitchMode(SWITCH_MODE_ARGS_DECL) | | 1334 | WsfbSwitchMode(SWITCH_MODE_ARGS_DECL) |
1309 | { | | 1335 | { |
1310 | TRACE_ENTER("SwitchMode"); | | 1336 | TRACE_ENTER("SwitchMode"); |
1311 | /* Nothing else to do. */ | | 1337 | /* Nothing else to do. */ |
1312 | return TRUE; | | 1338 | return TRUE; |
1313 | } | | 1339 | } |
1314 | | | 1340 | |
1315 | static int | | 1341 | static int |
1316 | WsfbValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) | | 1342 | WsfbValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) |
1317 | { | | 1343 | { |
1318 | TRACE_ENTER("ValidMode"); | | 1344 | TRACE_ENTER("ValidMode"); |
1319 | return MODE_OK; | | 1345 | return MODE_OK; |
1320 | } | | 1346 | } |
1321 | | | 1347 | |
1322 | static void | | 1348 | static void |
1323 | WsfbLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, | | 1349 | WsfbLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, |
1324 | LOCO *colors, VisualPtr pVisual) | | 1350 | LOCO *colors, VisualPtr pVisual) |
1325 | { | | 1351 | { |
1326 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1352 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1327 | struct wsdisplay_cmap cmap; | | 1353 | struct wsdisplay_cmap cmap; |
1328 | unsigned char red[256],green[256],blue[256]; | | 1354 | unsigned char red[256],green[256],blue[256]; |
1329 | int i, indexMin=256, indexMax=0; | | 1355 | int i, indexMin=256, indexMax=0; |
1330 | | | 1356 | |
1331 | TRACE_ENTER("LoadPalette"); | | 1357 | TRACE_ENTER("LoadPalette"); |
1332 | | | 1358 | |
1333 | /* nothing to do if there is no color palette support */ | | 1359 | /* nothing to do if there is no color palette support */ |
1334 | if (fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries == 0) | | 1360 | if (fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries == 0) |
1335 | return; | | 1361 | return; |
1336 | | | 1362 | |
1337 | cmap.count = 1; | | 1363 | cmap.count = 1; |
1338 | cmap.red = red; | | 1364 | cmap.red = red; |
1339 | cmap.green = green; | | 1365 | cmap.green = green; |
1340 | cmap.blue = blue; | | 1366 | cmap.blue = blue; |
1341 | | | 1367 | |
1342 | if (numColors == 1) { | | 1368 | if (numColors == 1) { |
1343 | /* Optimisation */ | | 1369 | /* Optimisation */ |
1344 | cmap.index = indices[0]; | | 1370 | cmap.index = indices[0]; |
1345 | red[0] = colors[indices[0]].red; | | 1371 | red[0] = colors[indices[0]].red; |
1346 | green[0] = colors[indices[0]].green; | | 1372 | green[0] = colors[indices[0]].green; |
1347 | blue[0] = colors[indices[0]].blue; | | 1373 | blue[0] = colors[indices[0]].blue; |
1348 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) | | 1374 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) |
1349 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); | | 1375 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); |
1350 | } else { | | 1376 | } else { |
1351 | /* | | 1377 | /* |
1352 | * Change all colors in 2 ioctls | | 1378 | * Change all colors in 2 ioctls |
1353 | * and limit the data to be transfered. | | 1379 | * and limit the data to be transfered. |
1354 | */ | | 1380 | */ |
1355 | for (i = 0; i < numColors; i++) { | | 1381 | for (i = 0; i < numColors; i++) { |
1356 | if (indices[i] < indexMin) | | 1382 | if (indices[i] < indexMin) |
1357 | indexMin = indices[i]; | | 1383 | indexMin = indices[i]; |
1358 | if (indices[i] > indexMax) | | 1384 | if (indices[i] > indexMax) |
1359 | indexMax = indices[i]; | | 1385 | indexMax = indices[i]; |
1360 | } | | 1386 | } |
1361 | cmap.index = indexMin; | | 1387 | cmap.index = indexMin; |
1362 | cmap.count = indexMax - indexMin + 1; | | 1388 | cmap.count = indexMax - indexMin + 1; |
1363 | cmap.red = &red[indexMin]; | | 1389 | cmap.red = &red[indexMin]; |
1364 | cmap.green = &green[indexMin]; | | 1390 | cmap.green = &green[indexMin]; |
1365 | cmap.blue = &blue[indexMin]; | | 1391 | cmap.blue = &blue[indexMin]; |
1366 | /* Get current map. */ | | 1392 | /* Get current map. */ |
1367 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, &cmap) == -1) | | 1393 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, &cmap) == -1) |
1368 | ErrorF("ioctl FBIOGETCMAP: %s\n", strerror(errno)); | | 1394 | ErrorF("ioctl FBIOGETCMAP: %s\n", strerror(errno)); |
1369 | /* Change the colors that require updating. */ | | 1395 | /* Change the colors that require updating. */ |
1370 | for (i = 0; i < numColors; i++) { | | 1396 | for (i = 0; i < numColors; i++) { |
1371 | red[indices[i]] = colors[indices[i]].red; | | 1397 | red[indices[i]] = colors[indices[i]].red; |
1372 | green[indices[i]] = colors[indices[i]].green; | | 1398 | green[indices[i]] = colors[indices[i]].green; |
1373 | blue[indices[i]] = colors[indices[i]].blue; | | 1399 | blue[indices[i]] = colors[indices[i]].blue; |
1374 | } | | 1400 | } |
1375 | /* Write the colormap back. */ | | 1401 | /* Write the colormap back. */ |
1376 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) | | 1402 | if (ioctl(fPtr->fd,WSDISPLAYIO_PUTCMAP, &cmap) == -1) |
1377 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); | | 1403 | ErrorF("ioctl FBIOPUTCMAP: %s\n", strerror(errno)); |
1378 | } | | 1404 | } |
1379 | TRACE_EXIT("LoadPalette"); | | 1405 | TRACE_EXIT("LoadPalette"); |
1380 | } | | 1406 | } |
1381 | | | 1407 | |
1382 | static Bool | | 1408 | static Bool |
1383 | WsfbSaveScreen(ScreenPtr pScreen, int mode) | | 1409 | WsfbSaveScreen(ScreenPtr pScreen, int mode) |
1384 | { | | 1410 | { |
1385 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 1411 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
1386 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1412 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1387 | int state; | | 1413 | int state; |
1388 | | | 1414 | |
1389 | TRACE_ENTER("SaveScreen"); | | 1415 | TRACE_ENTER("SaveScreen"); |
1390 | | | 1416 | |
1391 | if (!pScrn->vtSema) | | 1417 | if (!pScrn->vtSema) |
1392 | return TRUE; | | 1418 | return TRUE; |
1393 | | | 1419 | |
1394 | if (mode != SCREEN_SAVER_FORCER) { | | 1420 | if (mode != SCREEN_SAVER_FORCER) { |
1395 | state = xf86IsUnblank(mode)?WSDISPLAYIO_VIDEO_ON: | | 1421 | state = xf86IsUnblank(mode)?WSDISPLAYIO_VIDEO_ON: |
1396 | WSDISPLAYIO_VIDEO_OFF; | | 1422 | WSDISPLAYIO_VIDEO_OFF; |
1397 | ioctl(fPtr->fd, | | 1423 | ioctl(fPtr->fd, |
1398 | WSDISPLAYIO_SVIDEO, &state); | | 1424 | WSDISPLAYIO_SVIDEO, &state); |
1399 | } | | 1425 | } |
1400 | TRACE_EXIT("SaveScreen"); | | 1426 | TRACE_EXIT("SaveScreen"); |
1401 | return TRUE; | | 1427 | return TRUE; |
1402 | } | | 1428 | } |
1403 | | | 1429 | |
1404 | | | 1430 | |
1405 | static void | | 1431 | static void |
1406 | WsfbSave(ScrnInfoPtr pScrn) | | 1432 | WsfbSave(ScrnInfoPtr pScrn) |
1407 | { | | 1433 | { |
1408 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1434 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1409 | | | 1435 | |
1410 | TRACE_ENTER("WsfbSave"); | | 1436 | TRACE_ENTER("WsfbSave"); |
1411 | | | 1437 | |
1412 | /* nothing to save if we don't run in colour-indexed mode */ | | 1438 | /* nothing to save if we don't run in colour-indexed mode */ |
1413 | if (fPtr->fbi.fbi_pixeltype != WSFB_CI) | | 1439 | if (fPtr->fbi.fbi_pixeltype != WSFB_CI) |
1414 | return; | | 1440 | return; |
1415 | | | 1441 | |
1416 | /* nothing to do if no color palette support */ | | 1442 | /* nothing to do if no color palette support */ |
1417 | if (fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries == 0) | | 1443 | if (fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries == 0) |
1418 | return; | | 1444 | return; |
1419 | | | 1445 | |
1420 | fPtr->saved_cmap.index = 0; | | 1446 | fPtr->saved_cmap.index = 0; |
1421 | fPtr->saved_cmap.count = fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries; | | 1447 | fPtr->saved_cmap.count = fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries; |
1422 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, | | 1448 | if (ioctl(fPtr->fd, WSDISPLAYIO_GETCMAP, |
1423 | &(fPtr->saved_cmap)) == -1) { | | 1449 | &(fPtr->saved_cmap)) == -1) { |
1424 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1450 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1425 | "error saving colormap %s\n", strerror(errno)); | | 1451 | "error saving colormap %s\n", strerror(errno)); |
1426 | } | | 1452 | } |
1427 | TRACE_EXIT("WsfbSave"); | | 1453 | TRACE_EXIT("WsfbSave"); |
1428 | | | 1454 | |
1429 | } | | 1455 | } |
1430 | | | 1456 | |
1431 | static void | | 1457 | static void |
1432 | WsfbRestore(ScrnInfoPtr pScrn) | | 1458 | WsfbRestore(ScrnInfoPtr pScrn) |
1433 | { | | 1459 | { |
1434 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1460 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1435 | int mode; | | 1461 | int mode; |
1436 | | | 1462 | |
1437 | TRACE_ENTER("WsfbRestore"); | | 1463 | TRACE_ENTER("WsfbRestore"); |
1438 | | | 1464 | |
1439 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI && | | 1465 | if (fPtr->fbi.fbi_pixeltype == WSFB_CI && |
1440 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries > 0) { | | 1466 | fPtr->fbi.fbi_subtype.fbi_cmapinfo.cmap_entries > 0) { |
1441 | /* reset colormap for text mode */ | | 1467 | /* reset colormap for text mode */ |
1442 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, | | 1468 | if (ioctl(fPtr->fd, WSDISPLAYIO_PUTCMAP, |
1443 | &(fPtr->saved_cmap)) == -1) { | | 1469 | &(fPtr->saved_cmap)) == -1) { |
1444 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1470 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1445 | "error restoring colormap %s\n", | | 1471 | "error restoring colormap %s\n", |
1446 | strerror(errno)); | | 1472 | strerror(errno)); |
1447 | } | | 1473 | } |
1448 | } | | 1474 | } |
1449 | | | 1475 | |
1450 | /* Clear the screen. */ | | 1476 | /* Clear the screen. */ |
1451 | memset(fPtr->fbstart, 0, fPtr->fbmem_len); | | 1477 | memset(fPtr->fbstart, 0, fPtr->fbmem_len); |
1452 | | | 1478 | |
1453 | /* Restore the text mode. */ | | 1479 | /* Restore the text mode. */ |
1454 | mode = WSDISPLAYIO_MODE_EMUL; | | 1480 | mode = WSDISPLAYIO_MODE_EMUL; |
1455 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { | | 1481 | if (ioctl(fPtr->fd, WSDISPLAYIO_SMODE, &mode) == -1) { |
1456 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, | | 1482 | xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
1457 | "error setting text mode %s\n", strerror(errno)); | | 1483 | "error setting text mode %s\n", strerror(errno)); |
1458 | } | | 1484 | } |
1459 | TRACE_EXIT("WsfbRestore"); | | 1485 | TRACE_EXIT("WsfbRestore"); |
1460 | } | | 1486 | } |
1461 | | | 1487 | |
1462 | #ifdef XFreeXDGA | | 1488 | #ifdef XFreeXDGA |
1463 | /*********************************************************************** | | 1489 | /*********************************************************************** |
1464 | * DGA stuff | | 1490 | * DGA stuff |
1465 | ***********************************************************************/ | | 1491 | ***********************************************************************/ |
1466 | | | 1492 | |
1467 | static Bool | | 1493 | static Bool |
1468 | WsfbDGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName, | | 1494 | WsfbDGAOpenFramebuffer(ScrnInfoPtr pScrn, char **DeviceName, |
1469 | unsigned char **ApertureBase, int *ApertureSize, | | 1495 | unsigned char **ApertureBase, int *ApertureSize, |
1470 | int *ApertureOffset, int *flags) | | 1496 | int *ApertureOffset, int *flags) |
1471 | { | | 1497 | { |
1472 | *DeviceName = NULL; /* No special device */ | | 1498 | *DeviceName = NULL; /* No special device */ |
1473 | *ApertureBase = (unsigned char *)(pScrn->memPhysBase); | | 1499 | *ApertureBase = (unsigned char *)(pScrn->memPhysBase); |
1474 | *ApertureSize = pScrn->videoRam; | | 1500 | *ApertureSize = pScrn->videoRam; |
1475 | *ApertureOffset = pScrn->fbOffset; | | 1501 | *ApertureOffset = pScrn->fbOffset; |
1476 | *flags = 0; | | 1502 | *flags = 0; |
1477 | | | 1503 | |
1478 | return TRUE; | | 1504 | return TRUE; |
1479 | } | | 1505 | } |
1480 | | | 1506 | |
1481 | static Bool | | 1507 | static Bool |
1482 | WsfbDGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode) | | 1508 | WsfbDGASetMode(ScrnInfoPtr pScrn, DGAModePtr pDGAMode) |
1483 | { | | 1509 | { |
1484 | DisplayModePtr pMode; | | 1510 | DisplayModePtr pMode; |
1485 | int scrnIdx = pScrn->pScreen->myNum; | | 1511 | int scrnIdx = pScrn->pScreen->myNum; |
1486 | int frameX0, frameY0; | | 1512 | int frameX0, frameY0; |
1487 | | | 1513 | |
1488 | if (pDGAMode) { | | 1514 | if (pDGAMode) { |
1489 | pMode = pDGAMode->mode; | | 1515 | pMode = pDGAMode->mode; |
1490 | frameX0 = frameY0 = 0; | | 1516 | frameX0 = frameY0 = 0; |
1491 | } else { | | 1517 | } else { |
1492 | if (!(pMode = pScrn->currentMode)) | | 1518 | if (!(pMode = pScrn->currentMode)) |
1493 | return TRUE; | | 1519 | return TRUE; |
1494 | | | 1520 | |
1495 | frameX0 = pScrn->frameX0; | | 1521 | frameX0 = pScrn->frameX0; |
1496 | frameY0 = pScrn->frameY0; | | 1522 | frameY0 = pScrn->frameY0; |
1497 | } | | 1523 | } |
1498 | | | 1524 | |
1499 | if (!(*pScrn->SwitchMode)(SWITCH_MODE_ARGS(pScrn, pMode))) | | 1525 | if (!(*pScrn->SwitchMode)(SWITCH_MODE_ARGS(pScrn, pMode))) |
1500 | return FALSE; | | 1526 | return FALSE; |
1501 | (*pScrn->AdjustFrame)(ADJUST_FRAME_ARGS(pScrn, frameX0, frameY0)); | | 1527 | (*pScrn->AdjustFrame)(ADJUST_FRAME_ARGS(pScrn, frameX0, frameY0)); |
1502 | | | 1528 | |
1503 | return TRUE; | | 1529 | return TRUE; |
1504 | } | | 1530 | } |
1505 | | | 1531 | |
1506 | static void | | 1532 | static void |
1507 | WsfbDGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) | | 1533 | WsfbDGASetViewport(ScrnInfoPtr pScrn, int x, int y, int flags) |
1508 | { | | 1534 | { |
1509 | (*pScrn->AdjustFrame)(ADJUST_FRAME_ARGS(pScrn, x, y)); | | 1535 | (*pScrn->AdjustFrame)(ADJUST_FRAME_ARGS(pScrn, x, y)); |
1510 | } | | 1536 | } |
1511 | | | 1537 | |
1512 | static int | | 1538 | static int |
1513 | WsfbDGAGetViewport(ScrnInfoPtr pScrn) | | 1539 | WsfbDGAGetViewport(ScrnInfoPtr pScrn) |
1514 | { | | 1540 | { |
1515 | return (0); | | 1541 | return (0); |
1516 | } | | 1542 | } |
1517 | | | 1543 | |
1518 | static DGAFunctionRec WsfbDGAFunctions = | | 1544 | static DGAFunctionRec WsfbDGAFunctions = |
1519 | { | | 1545 | { |
1520 | WsfbDGAOpenFramebuffer, | | 1546 | WsfbDGAOpenFramebuffer, |
1521 | NULL, /* CloseFramebuffer */ | | 1547 | NULL, /* CloseFramebuffer */ |
1522 | WsfbDGASetMode, | | 1548 | WsfbDGASetMode, |
1523 | WsfbDGASetViewport, | | 1549 | WsfbDGASetViewport, |
1524 | WsfbDGAGetViewport, | | 1550 | WsfbDGAGetViewport, |
1525 | NULL, /* Sync */ | | 1551 | NULL, /* Sync */ |
1526 | NULL, /* FillRect */ | | 1552 | NULL, /* FillRect */ |
1527 | NULL, /* BlitRect */ | | 1553 | NULL, /* BlitRect */ |
1528 | NULL, /* BlitTransRect */ | | 1554 | NULL, /* BlitTransRect */ |
1529 | }; | | 1555 | }; |
1530 | | | 1556 | |
1531 | static void | | 1557 | static void |
1532 | WsfbDGAAddModes(ScrnInfoPtr pScrn) | | 1558 | WsfbDGAAddModes(ScrnInfoPtr pScrn) |
1533 | { | | 1559 | { |
1534 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1560 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1535 | DisplayModePtr pMode = pScrn->modes; | | 1561 | DisplayModePtr pMode = pScrn->modes; |
1536 | DGAModePtr pDGAMode; | | 1562 | DGAModePtr pDGAMode; |
1537 | | | 1563 | |
1538 | do { | | 1564 | do { |
1539 | pDGAMode = realloc(fPtr->pDGAMode, | | 1565 | pDGAMode = realloc(fPtr->pDGAMode, |
1540 | (fPtr->nDGAMode + 1) * sizeof(DGAModeRec)); | | 1566 | (fPtr->nDGAMode + 1) * sizeof(DGAModeRec)); |
1541 | if (!pDGAMode) | | 1567 | if (!pDGAMode) |
1542 | break; | | 1568 | break; |
1543 | | | 1569 | |
1544 | fPtr->pDGAMode = pDGAMode; | | 1570 | fPtr->pDGAMode = pDGAMode; |
1545 | pDGAMode += fPtr->nDGAMode; | | 1571 | pDGAMode += fPtr->nDGAMode; |
1546 | (void)memset(pDGAMode, 0, sizeof(DGAModeRec)); | | 1572 | (void)memset(pDGAMode, 0, sizeof(DGAModeRec)); |
1547 | | | 1573 | |
1548 | ++fPtr->nDGAMode; | | 1574 | ++fPtr->nDGAMode; |
1549 | pDGAMode->mode = pMode; | | 1575 | pDGAMode->mode = pMode; |
1550 | pDGAMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; | | 1576 | pDGAMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE; |
1551 | pDGAMode->byteOrder = pScrn->imageByteOrder; | | 1577 | pDGAMode->byteOrder = pScrn->imageByteOrder; |
1552 | pDGAMode->depth = pScrn->depth; | | 1578 | pDGAMode->depth = pScrn->depth; |
1553 | pDGAMode->bitsPerPixel = pScrn->bitsPerPixel; | | 1579 | pDGAMode->bitsPerPixel = pScrn->bitsPerPixel; |
1554 | pDGAMode->red_mask = pScrn->mask.red; | | 1580 | pDGAMode->red_mask = pScrn->mask.red; |
1555 | pDGAMode->green_mask = pScrn->mask.green; | | 1581 | pDGAMode->green_mask = pScrn->mask.green; |
1556 | pDGAMode->blue_mask = pScrn->mask.blue; | | 1582 | pDGAMode->blue_mask = pScrn->mask.blue; |
1557 | pDGAMode->visualClass = pScrn->bitsPerPixel > 8 ? | | 1583 | pDGAMode->visualClass = pScrn->bitsPerPixel > 8 ? |
1558 | TrueColor : PseudoColor; | | 1584 | TrueColor : PseudoColor; |
1559 | pDGAMode->xViewportStep = 1; | | 1585 | pDGAMode->xViewportStep = 1; |
1560 | pDGAMode->yViewportStep = 1; | | 1586 | pDGAMode->yViewportStep = 1; |
1561 | pDGAMode->viewportWidth = pMode->HDisplay; | | 1587 | pDGAMode->viewportWidth = pMode->HDisplay; |
1562 | pDGAMode->viewportHeight = pMode->VDisplay; | | 1588 | pDGAMode->viewportHeight = pMode->VDisplay; |
1563 | | | 1589 | |
1564 | if (fPtr->fbi.fbi_stride) | | 1590 | if (fPtr->fbi.fbi_stride) |
1565 | pDGAMode->bytesPerScanline = fPtr->fbi.fbi_stride; | | 1591 | pDGAMode->bytesPerScanline = fPtr->fbi.fbi_stride; |
1566 | else { | | 1592 | else { |
1567 | ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, | | 1593 | ioctl(fPtr->fd, WSDISPLAYIO_LINEBYTES, |
1568 | &fPtr->fbi.fbi_stride); | | 1594 | &fPtr->fbi.fbi_stride); |
1569 | pDGAMode->bytesPerScanline = fPtr->fbi.fbi_stride; | | 1595 | pDGAMode->bytesPerScanline = fPtr->fbi.fbi_stride; |
1570 | } | | 1596 | } |
1571 | | | 1597 | |
1572 | pDGAMode->imageWidth = pMode->HDisplay; | | 1598 | pDGAMode->imageWidth = pMode->HDisplay; |
1573 | pDGAMode->imageHeight = pMode->VDisplay; | | 1599 | pDGAMode->imageHeight = pMode->VDisplay; |
1574 | pDGAMode->pixmapWidth = pDGAMode->imageWidth; | | 1600 | pDGAMode->pixmapWidth = pDGAMode->imageWidth; |
1575 | pDGAMode->pixmapHeight = pDGAMode->imageHeight; | | 1601 | pDGAMode->pixmapHeight = pDGAMode->imageHeight; |
1576 | pDGAMode->maxViewportX = pScrn->virtualX - | | 1602 | pDGAMode->maxViewportX = pScrn->virtualX - |
1577 | pDGAMode->viewportWidth; | | 1603 | pDGAMode->viewportWidth; |
1578 | pDGAMode->maxViewportY = pScrn->virtualY - | | 1604 | pDGAMode->maxViewportY = pScrn->virtualY - |
1579 | pDGAMode->viewportHeight; | | 1605 | pDGAMode->viewportHeight; |
1580 | | | 1606 | |
1581 | pDGAMode->address = fPtr->fbstart; | | 1607 | pDGAMode->address = fPtr->fbstart; |
1582 | | | 1608 | |
1583 | pMode = pMode->next; | | 1609 | pMode = pMode->next; |
1584 | } while (pMode != pScrn->modes); | | 1610 | } while (pMode != pScrn->modes); |
1585 | } | | 1611 | } |
1586 | | | 1612 | |
1587 | static Bool | | 1613 | static Bool |
1588 | WsfbDGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen) | | 1614 | WsfbDGAInit(ScrnInfoPtr pScrn, ScreenPtr pScreen) |
1589 | { | | 1615 | { |
1590 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1616 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1591 | | | 1617 | |
1592 | if (pScrn->depth < 8) | | 1618 | if (pScrn->depth < 8) |
1593 | return FALSE; | | 1619 | return FALSE; |
1594 | | | 1620 | |
1595 | if (!fPtr->nDGAMode) | | 1621 | if (!fPtr->nDGAMode) |
1596 | WsfbDGAAddModes(pScrn); | | 1622 | WsfbDGAAddModes(pScrn); |
1597 | | | 1623 | |
1598 | return (DGAInit(pScreen, &WsfbDGAFunctions, | | 1624 | return (DGAInit(pScreen, &WsfbDGAFunctions, |
1599 | fPtr->pDGAMode, fPtr->nDGAMode)); | | 1625 | fPtr->pDGAMode, fPtr->nDGAMode)); |
1600 | } | | 1626 | } |
1601 | #endif | | 1627 | #endif |
1602 | | | 1628 | |
1603 | static Bool | | 1629 | static Bool |
1604 | WsfbDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, | | 1630 | WsfbDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, |
1605 | pointer ptr) | | 1631 | pointer ptr) |
1606 | { | | 1632 | { |
1607 | xorgHWFlags *flag; | | 1633 | xorgHWFlags *flag; |
1608 | | | 1634 | |
1609 | switch (op) { | | 1635 | switch (op) { |
1610 | case GET_REQUIRED_HW_INTERFACES: | | 1636 | case GET_REQUIRED_HW_INTERFACES: |
1611 | flag = (CARD32*)ptr; | | 1637 | flag = (CARD32*)ptr; |
1612 | (*flag) = 0; | | 1638 | (*flag) = 0; |
1613 | return TRUE; | | 1639 | return TRUE; |
1614 | default: | | 1640 | default: |
1615 | return FALSE; | | 1641 | return FALSE; |
1616 | } | | 1642 | } |
1617 | } | | 1643 | } |
1618 | | | 1644 | |
1619 | static inline void | | 1645 | static inline void |
1620 | memcpy32sw(void *dest, void *src, int len) | | 1646 | memcpy32sw(void *dest, void *src, int len) |
1621 | { | | 1647 | { |
1622 | uint32_t *d = dest, *s = src; | | 1648 | uint32_t *d = dest, *s = src; |
1623 | | | 1649 | |
1624 | #if DEBUG | | 1650 | #if DEBUG |
1625 | if ((((long)dest & 3) + ((long)src & 3) + (len & 3)) != 0) { | | 1651 | if ((((long)dest & 3) + ((long)src & 3) + (len & 3)) != 0) { |
1626 | xf86Msg(X_ERROR, "unaligned %s\n", __func__); | | 1652 | xf86Msg(X_ERROR, "unaligned %s\n", __func__); |
1627 | return; | | 1653 | return; |
1628 | } | | 1654 | } |
1629 | #endif | | 1655 | #endif |
1630 | while (len > 0) { | | 1656 | while (len > 0) { |
1631 | *d = bswap32(*s); | | 1657 | *d = bswap32(*s); |
1632 | d++; | | 1658 | d++; |
1633 | s++; | | 1659 | s++; |
1634 | len -= 4; | | 1660 | len -= 4; |
1635 | } | | 1661 | } |
1636 | } | | 1662 | } |
1637 | | | 1663 | |
1638 | /* adapted from miext/shadow/shpacked.c::shadowUpdatePacked() */ | | 1664 | /* adapted from miext/shadow/shpacked.c::shadowUpdatePacked() */ |
1639 | void | | 1665 | void |
1640 | WsfbShadowUpdateSwap32(ScreenPtr pScreen, shadowBufPtr pBuf) | | 1666 | WsfbShadowUpdateSwap32(ScreenPtr pScreen, shadowBufPtr pBuf) |
1641 | { | | 1667 | { |
1642 | RegionPtr damage = DamageRegion (pBuf->pDamage); | | 1668 | RegionPtr damage = DamageRegion (pBuf->pDamage); |
1643 | PixmapPtr pShadow = pBuf->pPixmap; | | 1669 | PixmapPtr pShadow = pBuf->pPixmap; |
1644 | int nbox = RegionNumRects (damage); | | 1670 | int nbox = RegionNumRects (damage); |
1645 | BoxPtr pbox = RegionRects (damage); | | 1671 | BoxPtr pbox = RegionRects (damage); |
1646 | FbBits *shaBase, *shaLine, *sha; | | 1672 | FbBits *shaBase, *shaLine, *sha; |
1647 | FbStride shaStride; | | 1673 | FbStride shaStride; |
1648 | int scrBase, scrLine, scr; | | 1674 | int scrBase, scrLine, scr; |
1649 | int shaBpp; | | 1675 | int shaBpp; |
1650 | int shaXoff, shaYoff; /* XXX assumed to be zero */ | | 1676 | int shaXoff, shaYoff; /* XXX assumed to be zero */ |
1651 | int x, y, w, h, width; | | 1677 | int x, y, w, h, width; |
1652 | int i; | | 1678 | int i; |
1653 | FbBits *winBase = NULL, *win; | | 1679 | FbBits *winBase = NULL, *win; |
1654 | CARD32 winSize; | | 1680 | CARD32 winSize; |
1655 | | | 1681 | |
1656 | fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); | | 1682 | fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); |
1657 | while (nbox--) | | 1683 | while (nbox--) |
1658 | { | | 1684 | { |
1659 | x = pbox->x1 * shaBpp; | | 1685 | x = pbox->x1 * shaBpp; |
1660 | y = pbox->y1; | | 1686 | y = pbox->y1; |
1661 | w = (pbox->x2 - pbox->x1) * shaBpp; | | 1687 | w = (pbox->x2 - pbox->x1) * shaBpp; |
1662 | h = pbox->y2 - pbox->y1; | | 1688 | h = pbox->y2 - pbox->y1; |
1663 | | | 1689 | |
1664 | scrLine = (x >> FB_SHIFT); | | 1690 | scrLine = (x >> FB_SHIFT); |
1665 | shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); | | 1691 | shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); |
1666 | | | 1692 | |
1667 | x &= FB_MASK; | | 1693 | x &= FB_MASK; |
1668 | w = (w + x + FB_MASK) >> FB_SHIFT; | | 1694 | w = (w + x + FB_MASK) >> FB_SHIFT; |
1669 | | | 1695 | |
1670 | while (h--) | | 1696 | while (h--) |
1671 | { | | 1697 | { |
1672 | winSize = 0; | | 1698 | winSize = 0; |
1673 | scrBase = 0; | | 1699 | scrBase = 0; |
1674 | width = w; | | 1700 | width = w; |
1675 | scr = scrLine; | | 1701 | scr = scrLine; |
1676 | sha = shaLine; | | 1702 | sha = shaLine; |
1677 | while (width) { | | 1703 | while (width) { |
1678 | /* how much remains in this window */ | | 1704 | /* how much remains in this window */ |
1679 | i = scrBase + winSize - scr; | | 1705 | i = scrBase + winSize - scr; |
1680 | if (i <= 0 || scr < scrBase) | | 1706 | if (i <= 0 || scr < scrBase) |
1681 | { | | 1707 | { |
1682 | winBase = (FbBits *) (*pBuf->window) (pScreen, | | 1708 | winBase = (FbBits *) (*pBuf->window) (pScreen, |
1683 | y, | | 1709 | y, |
1684 | scr * sizeof (FbBits), | | 1710 | scr * sizeof (FbBits), |
1685 | SHADOW_WINDOW_WRITE, | | 1711 | SHADOW_WINDOW_WRITE, |
1686 | &winSize, | | 1712 | &winSize, |
1687 | pBuf->closure); | | 1713 | pBuf->closure); |
1688 | if(!winBase) | | 1714 | if(!winBase) |
1689 | return; | | 1715 | return; |
1690 | scrBase = scr; | | 1716 | scrBase = scr; |
1691 | winSize /= sizeof (FbBits); | | 1717 | winSize /= sizeof (FbBits); |
1692 | i = winSize; | | 1718 | i = winSize; |
1693 | } | | 1719 | } |
1694 | win = winBase + (scr - scrBase); | | 1720 | win = winBase + (scr - scrBase); |
1695 | if (i > width) | | 1721 | if (i > width) |
1696 | i = width; | | 1722 | i = width; |
1697 | width -= i; | | 1723 | width -= i; |
1698 | scr += i; | | 1724 | scr += i; |
1699 | memcpy32sw(win, sha, i * sizeof(FbBits)); | | 1725 | memcpy32sw(win, sha, i * sizeof(FbBits)); |
1700 | sha += i; | | 1726 | sha += i; |
1701 | } | | 1727 | } |
1702 | shaLine += shaStride; | | 1728 | shaLine += shaStride; |
1703 | y++; | | 1729 | y++; |
1704 | } | | 1730 | } |
1705 | pbox++; | | 1731 | pbox++; |
1706 | } | | 1732 | } |
1707 | } | | 1733 | } |
1708 | | | 1734 | |
1709 | void | | 1735 | void |
1710 | WsfbShadowUpdateSplit(ScreenPtr pScreen, shadowBufPtr pBuf) | | 1736 | WsfbShadowUpdateSplit(ScreenPtr pScreen, shadowBufPtr pBuf) |
1711 | { | | 1737 | { |
1712 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; | | 1738 | ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; |
1713 | WsfbPtr fPtr = WSFBPTR(pScrn); | | 1739 | WsfbPtr fPtr = WSFBPTR(pScrn); |
1714 | RegionPtr damage = DamageRegion (pBuf->pDamage); | | 1740 | RegionPtr damage = DamageRegion (pBuf->pDamage); |
1715 | PixmapPtr pShadow = pBuf->pPixmap; | | 1741 | PixmapPtr pShadow = pBuf->pPixmap; |
1716 | int nbox = RegionNumRects (damage); | | 1742 | int nbox = RegionNumRects (damage); |
1717 | BoxPtr pbox = RegionRects (damage); | | 1743 | BoxPtr pbox = RegionRects (damage); |
1718 | FbBits *shaBase, *shaLine, *sha; | | 1744 | FbBits *shaBase, *shaLine, *sha; |
1719 | FbStride shaStride; | | 1745 | FbStride shaStride; |
1720 | int scrBase, scrLine, scr; | | 1746 | int scrBase, scrLine, scr; |
1721 | int shaBpp; | | 1747 | int shaBpp; |
1722 | int shaXoff, shaYoff; /* XXX assumed to be zero */ | | 1748 | int shaXoff, shaYoff; /* XXX assumed to be zero */ |
1723 | int x, y, w, h, width; | | 1749 | int x, y, w, h, width; |
1724 | int i; | | 1750 | int i; |
1725 | FbBits *winBase = NULL, *win, *win2; | | 1751 | FbBits *winBase = NULL, *win, *win2; |
1726 | unsigned long split = fPtr->fbi.fbi_fbsize / 2; | | 1752 | unsigned long split = fPtr->fbi.fbi_fbsize / 2; |
1727 | CARD32 winSize; | | 1753 | CARD32 winSize; |
1728 | | | 1754 | |
1729 | fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); | | 1755 | fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff); |
1730 | while (nbox--) | | 1756 | while (nbox--) |
1731 | { | | 1757 | { |
1732 | x = pbox->x1 * shaBpp; | | 1758 | x = pbox->x1 * shaBpp; |
1733 | y = pbox->y1; | | 1759 | y = pbox->y1; |
1734 | w = (pbox->x2 - pbox->x1) * shaBpp; | | 1760 | w = (pbox->x2 - pbox->x1) * shaBpp; |
1735 | h = pbox->y2 - pbox->y1; | | 1761 | h = pbox->y2 - pbox->y1; |
1736 | | | 1762 | |
1737 | scrLine = (x >> FB_SHIFT); | | 1763 | scrLine = (x >> FB_SHIFT); |
1738 | shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); | | 1764 | shaLine = shaBase + y * shaStride + (x >> FB_SHIFT); |
1739 | | | 1765 | |
1740 | x &= FB_MASK; | | 1766 | x &= FB_MASK; |
1741 | w = (w + x + FB_MASK) >> FB_SHIFT; | | 1767 | w = (w + x + FB_MASK) >> FB_SHIFT; |
1742 | | | 1768 | |
1743 | while (h--) | | 1769 | while (h--) |
1744 | { | | 1770 | { |
1745 | winSize = 0; | | 1771 | winSize = 0; |
1746 | scrBase = 0; | | 1772 | scrBase = 0; |
1747 | width = w; | | 1773 | width = w; |
1748 | scr = scrLine; | | 1774 | scr = scrLine; |
1749 | sha = shaLine; | | 1775 | sha = shaLine; |
1750 | while (width) { | | 1776 | while (width) { |
1751 | /* how much remains in this window */ | | 1777 | /* how much remains in this window */ |
1752 | i = scrBase + winSize - scr; | | 1778 | i = scrBase + winSize - scr; |
1753 | if (i <= 0 || scr < scrBase) | | 1779 | if (i <= 0 || scr < scrBase) |
1754 | { | | 1780 | { |
1755 | winBase = (FbBits *) (*pBuf->window) (pScreen, | | 1781 | winBase = (FbBits *) (*pBuf->window) (pScreen, |
1756 | y, | | 1782 | y, |
1757 | scr * sizeof (FbBits), | | 1783 | scr * sizeof (FbBits), |
1758 | SHADOW_WINDOW_WRITE, | | 1784 | SHADOW_WINDOW_WRITE, |
1759 | &winSize, | | 1785 | &winSize, |
1760 | pBuf->closure); | | 1786 | pBuf->closure); |
1761 | if(!winBase) | | 1787 | if(!winBase) |
1762 | return; | | 1788 | return; |
1763 | scrBase = scr; | | 1789 | scrBase = scr; |
1764 | winSize /= sizeof (FbBits); | | 1790 | winSize /= sizeof (FbBits); |
1765 | i = winSize; | | 1791 | i = winSize; |
1766 | } | | 1792 | } |
1767 | win = winBase + (scr - scrBase); | | 1793 | win = winBase + (scr - scrBase); |
1768 | win2 = (FbBits *)(split + (unsigned long)win); | | 1794 | win2 = (FbBits *)(split + (unsigned long)win); |
1769 | if (i > width) | | 1795 | if (i > width) |
1770 | i = width; | | 1796 | i = width; |
1771 | width -= i; | | 1797 | width -= i; |
1772 | scr += i; | | 1798 | scr += i; |
1773 | memcpy(win, sha, i * sizeof(FbBits)); | | 1799 | memcpy(win, sha, i * sizeof(FbBits)); |
1774 | memcpy(win2, sha, i * sizeof(FbBits)); | | 1800 | memcpy(win2, sha, i * sizeof(FbBits)); |
1775 | sha += i; | | 1801 | sha += i; |
1776 | } | | 1802 | } |
1777 | shaLine += shaStride; | | 1803 | shaLine += shaStride; |
1778 | y++; | | 1804 | y++; |
1779 | } | | 1805 | } |
1780 | pbox++; | | 1806 | pbox++; |
1781 | } | | 1807 | } |
1782 | } | | 1808 | } |