ErrorF() doesn't append newlines at the end of messages.diff -r1.7 -r1.8 xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kFb.c
(tsutsui)
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kFb.c 2020/11/04 17:16:13 1.7
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kFb.c 2021/03/11 12:08:57 1.8
@@ -1,195 +1,195 @@ | @@ -1,195 +1,195 @@ | |||
1 | /* $NetBSD: x68kFb.c,v 1.7 2020/11/04 17:16:13 tsutsui Exp $ */ | 1 | /* $NetBSD: x68kFb.c,v 1.8 2021/03/11 12:08:57 tsutsui Exp $ */ | |
2 | /*------------------------------------------------------------------------- | 2 | /*------------------------------------------------------------------------- | |
3 | * Copyright (c) 1996 Yasushi Yamasaki | 3 | * Copyright (c) 1996 Yasushi Yamasaki | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. 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 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | *-----------------------------------------------------------------------*/ | 25 | *-----------------------------------------------------------------------*/ | |
26 | 26 | |||
27 | #include "x68k.h" | 27 | #include "x68k.h" | |
28 | 28 | |||
29 | static void x68kRegSetup(X68kScreenRec *pPriv); | 29 | static void x68kRegSetup(X68kScreenRec *pPriv); | |
30 | 30 | |||
31 | DevPrivateKeyRec x68kScreenPrivateKeyRec; | 31 | DevPrivateKeyRec x68kScreenPrivateKeyRec; | |
32 | 32 | |||
33 | static int cons_dwidth; | 33 | static int cons_dwidth; | |
34 | 34 | |||
35 | /*------------------------------------------------------------------------- | 35 | /*------------------------------------------------------------------------- | |
36 | * function "x68kFbCommonOpen" | 36 | * function "x68kFbCommonOpen" | |
37 | * | 37 | * | |
38 | * purpose: open and map frame buffer, and obtain some FB-specific | 38 | * purpose: open and map frame buffer, and obtain some FB-specific | |
39 | * infomation. then set controller to approppriate mode as | 39 | * infomation. then set controller to approppriate mode as | |
40 | * configured in X68kConfig. | 40 | * configured in X68kConfig. | |
41 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | 41 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | |
42 | * (const char *)device : name of frame buffer device | 42 | * (const char *)device : name of frame buffer device | |
43 | * returns: (Bool): TRUE if succeeded | 43 | * returns: (Bool): TRUE if succeeded | |
44 | * FALSE otherwise | 44 | * FALSE otherwise | |
45 | *-----------------------------------------------------------------------*/ | 45 | *-----------------------------------------------------------------------*/ | |
46 | Bool | 46 | Bool | |
47 | x68kFbCommonOpen(X68kScreenRec *pPriv, const char *device) | 47 | x68kFbCommonOpen(X68kScreenRec *pPriv, const char *device) | |
48 | { | 48 | { | |
49 | struct grfinfo gi; | 49 | struct grfinfo gi; | |
50 | 50 | |||
51 | /* open frame buffer */ | 51 | /* open frame buffer */ | |
52 | if ( ( pPriv->fd = open(device, O_RDWR, 0)) < 0) { | 52 | if ( ( pPriv->fd = open(device, O_RDWR, 0)) < 0) { | |
53 | ErrorF( "Can't open frame buffer" ); | 53 | ErrorF( "Can't open frame buffer\n" ); | |
54 | return FALSE; | 54 | return FALSE; | |
55 | } | 55 | } | |
56 | /* get frame buffer infomation */ | 56 | /* get frame buffer infomation */ | |
57 | if ( ioctl( pPriv->fd, GRFIOCGINFO, &gi ) == -1 ) { | 57 | if ( ioctl( pPriv->fd, GRFIOCGINFO, &gi ) == -1 ) { | |
58 | ErrorF( "Can't get grfinfo" ); | 58 | ErrorF( "Can't get grfinfo\n" ); | |
59 | return FALSE; | 59 | return FALSE; | |
60 | } | 60 | } | |
61 | pPriv->mapsize = gi.gd_regsize + gi.gd_fbsize; | 61 | pPriv->mapsize = gi.gd_regsize + gi.gd_fbsize; | |
62 | 62 | |||
63 | /* map control registers and frame buffer */ | 63 | /* map control registers and frame buffer */ | |
64 | pPriv->reg = (FbReg *)mmap(0, pPriv->mapsize, PROT_READ | PROT_WRITE, | 64 | pPriv->reg = (FbReg *)mmap(0, pPriv->mapsize, PROT_READ | PROT_WRITE, | |
65 | MAP_FILE | MAP_SHARED, pPriv->fd, 0 ); | 65 | MAP_FILE | MAP_SHARED, pPriv->fd, 0 ); | |
66 | if ( pPriv->reg == (FbReg *)-1) { | 66 | if ( pPriv->reg == (FbReg *)-1) { | |
67 | ErrorF( "Can't map frame buffer" ); | 67 | ErrorF( "Can't map frame buffer\n" ); | |
68 | return FALSE; | 68 | return FALSE; | |
69 | } | 69 | } | |
70 | pPriv->fb = (uint8_t *)((uint32_t)pPriv->reg + gi.gd_regsize); | 70 | pPriv->fb = (uint8_t *)((uint32_t)pPriv->reg + gi.gd_regsize); | |
71 | 71 | |||
72 | x68kRegSetup( pPriv ); | 72 | x68kRegSetup( pPriv ); | |
73 | cons_dwidth = gi.gd_dwidth; | 73 | cons_dwidth = gi.gd_dwidth; | |
74 | 74 | |||
75 | return TRUE; | 75 | return TRUE; | |
76 | } | 76 | } | |
77 | 77 | |||
78 | /*------------------------------------------------------------------------- | 78 | /*------------------------------------------------------------------------- | |
79 | * function "x68kFbCommonClose" | 79 | * function "x68kFbCommonClose" | |
80 | * | 80 | * | |
81 | * purpose: unmap and close frame buffer, and | 81 | * purpose: unmap and close frame buffer, and | |
82 | * change video mode to normal ITE mode | 82 | * change video mode to normal ITE mode | |
83 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | 83 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | |
84 | * returns: nothing | 84 | * returns: nothing | |
85 | *-----------------------------------------------------------------------*/ | 85 | *-----------------------------------------------------------------------*/ | |
86 | void | 86 | void | |
87 | x68kFbCommonClose(X68kScreenRec *pPriv) | 87 | x68kFbCommonClose(X68kScreenRec *pPriv) | |
88 | { | 88 | { | |
89 | static const X68kFbReg graphNone_mode16 = { | 89 | static const X68kFbReg graphNone_mode16 = { | |
90 | /* CRT mode 16 (768x512 31.5kHz) */ | 90 | /* CRT mode 16 (768x512 31.5kHz) */ | |
91 | { 137,14, 28, 124, | 91 | { 137,14, 28, 124, | |
92 | 567, 5, 40, 552, | 92 | 567, 5, 40, 552, | |
93 | 27, 0, 0, 0, | 93 | 27, 0, 0, 0, | |
94 | 0, 0, 0, 0, | 94 | 0, 0, 0, 0, | |
95 | 0, 0, 0, 0, | 95 | 0, 0, 0, 0, | |
96 | 0x0416, 0, 0, 0, 0 }, | 96 | 0x0416, 0, 0, 0, 0 }, | |
97 | { 0x0004, 0x21e4, 0x0020 }, | 97 | { 0x0004, 0x21e4, 0x0020 }, | |
98 | 0 | 98 | 0 | |
99 | }; | 99 | }; | |
100 | static const X68kFbReg graphNone_mode19 = { | 100 | static const X68kFbReg graphNone_mode19 = { | |
101 | /* CRT mode 19 (640x480 31.5kHz VGA mode) */ | 101 | /* CRT mode 19 (640x480 31.5kHz VGA mode) */ | |
102 | { 99,11, 13, 93, | 102 | { 99,11, 13, 93, | |
103 | 524, 1, 33, 513, | 103 | 524, 1, 33, 513, | |
104 | 27, 0, 0, 0, | 104 | 27, 0, 0, 0, | |
105 | 0, 0, 0, 0, | 105 | 0, 0, 0, 0, | |
106 | 0, 0, 0, 0, | 106 | 0, 0, 0, 0, | |
107 | 0x0417, 0, 0, 0, 0 }, | 107 | 0x0417, 0, 0, 0, 0 }, | |
108 | { 0x0004, 0x21e4, 0x0020 }, | 108 | { 0x0004, 0x21e4, 0x0020 }, | |
109 | 0 | 109 | 0 | |
110 | }; | 110 | }; | |
111 | /* change video mode */ | 111 | /* change video mode */ | |
112 | pPriv->x68kreg = (cons_dwidth == 640) ? graphNone_mode19 : graphNone_mode16; | 112 | pPriv->x68kreg = (cons_dwidth == 640) ? graphNone_mode19 : graphNone_mode16; | |
113 | x68kRegSetup(pPriv); | 113 | x68kRegSetup(pPriv); | |
114 | 114 | |||
115 | /* unmap and close frame buffer */ | 115 | /* unmap and close frame buffer */ | |
116 | if ( munmap(pPriv->reg, pPriv->mapsize) == -1 ) | 116 | if ( munmap(pPriv->reg, pPriv->mapsize) == -1 ) | |
117 | ErrorF("Can't unmap frame buffer"); | 117 | ErrorF("Can't unmap frame buffer\n"); | |
118 | close(pPriv->fd); | 118 | close(pPriv->fd); | |
119 | } | 119 | } | |
120 | 120 | |||
121 | /*------------------------------------------------------------------------- | 121 | /*------------------------------------------------------------------------- | |
122 | * function "x68kRegSetup" | 122 | * function "x68kRegSetup" | |
123 | * | 123 | * | |
124 | * purpose: set up CRT controller and Video controller | 124 | * purpose: set up CRT controller and Video controller | |
125 | * with register values in pPriv->x68kreg | 125 | * with register values in pPriv->x68kreg | |
126 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | 126 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | |
127 | * returns: nothing | 127 | * returns: nothing | |
128 | *-----------------------------------------------------------------------*/ | 128 | *-----------------------------------------------------------------------*/ | |
129 | #define CRTCSET(r) pPriv->reg->crtc.r = pPriv->x68kreg.crtc.r | 129 | #define CRTCSET(r) pPriv->reg->crtc.r = pPriv->x68kreg.crtc.r | |
130 | #define VIDEOCSET(r) pPriv->reg->videoc.r = pPriv->x68kreg.videoc.r | 130 | #define VIDEOCSET(r) pPriv->reg->videoc.r = pPriv->x68kreg.videoc.r | |
131 | 131 | |||
132 | static void | 132 | static void | |
133 | x68kRegSetup(X68kScreenRec *pPriv) | 133 | x68kRegSetup(X68kScreenRec *pPriv) | |
134 | { | 134 | { | |
135 | uint16_t pr20 = pPriv->reg->crtc.r20; | 135 | uint16_t pr20 = pPriv->reg->crtc.r20; | |
136 | 136 | |||
137 | /* timing registers */ | 137 | /* timing registers */ | |
138 | if ( (pr20 & 0x0003) < (pPriv->x68kreg.crtc.r20 & 0x0003) || | 138 | if ( (pr20 & 0x0003) < (pPriv->x68kreg.crtc.r20 & 0x0003) || | |
139 | ( (pr20 & 0x0003) == (pPriv->x68kreg.crtc.r20 & 0x0003) && | 139 | ( (pr20 & 0x0003) == (pPriv->x68kreg.crtc.r20 & 0x0003) && | |
140 | (pr20 & 0x0010) < (pPriv->x68kreg.crtc.r20 & 0x0010) ) ) { | 140 | (pr20 & 0x0010) < (pPriv->x68kreg.crtc.r20 & 0x0010) ) ) { | |
141 | 141 | |||
142 | /* to higher resolution */ | 142 | /* to higher resolution */ | |
143 | CRTCSET(r00); CRTCSET(r01); CRTCSET(r02);CRTCSET(r03); | 143 | CRTCSET(r00); CRTCSET(r01); CRTCSET(r02);CRTCSET(r03); | |
144 | CRTCSET(r04); CRTCSET(r05); CRTCSET(r06);CRTCSET(r07); | 144 | CRTCSET(r04); CRTCSET(r05); CRTCSET(r06);CRTCSET(r07); | |
145 | CRTCSET(r20); | 145 | CRTCSET(r20); | |
146 | } else { | 146 | } else { | |
147 | /* to lower resolution */ | 147 | /* to lower resolution */ | |
148 | CRTCSET(r20); CRTCSET(r01); CRTCSET(r02);CRTCSET(r03); | 148 | CRTCSET(r20); CRTCSET(r01); CRTCSET(r02);CRTCSET(r03); | |
149 | CRTCSET(r04); CRTCSET(r05); CRTCSET(r06);CRTCSET(r07); | 149 | CRTCSET(r04); CRTCSET(r05); CRTCSET(r06);CRTCSET(r07); | |
150 | CRTCSET(r00); | 150 | CRTCSET(r00); | |
151 | } | 151 | } | |
152 | CRTCSET(r08); | 152 | CRTCSET(r08); | |
153 | 153 | |||
154 | /* scroll registers */ | 154 | /* scroll registers */ | |
155 | CRTCSET(r12); CRTCSET(r13); CRTCSET(r14);CRTCSET(r15); | 155 | CRTCSET(r12); CRTCSET(r13); CRTCSET(r14);CRTCSET(r15); | |
156 | CRTCSET(r16); CRTCSET(r17); CRTCSET(r18);CRTCSET(r19); | 156 | CRTCSET(r16); CRTCSET(r17); CRTCSET(r18);CRTCSET(r19); | |
157 | 157 | |||
158 | /* mode controlling registers */ | 158 | /* mode controlling registers */ | |
159 | VIDEOCSET(r0); VIDEOCSET(r1); VIDEOCSET(r2); | 159 | VIDEOCSET(r0); VIDEOCSET(r1); VIDEOCSET(r2); | |
160 | 160 | |||
161 | /* dot clock bit */ | 161 | /* dot clock bit */ | |
162 | pPriv->reg->sysport.r4 = (pPriv->x68kreg.dotClock)? 0x000e: 0x000c; | 162 | pPriv->reg->sysport.r4 = (pPriv->x68kreg.dotClock)? 0x000e: 0x000c; | |
163 | } | 163 | } | |
164 | 164 | |||
165 | /*------------------------------------------------------------------------- | 165 | /*------------------------------------------------------------------------- | |
166 | * function "x68kSaveScreen" [ screen function ] | 166 | * function "x68kSaveScreen" [ screen function ] | |
167 | * | 167 | * | |
168 | * purpose: activate/deactivate screen saver | 168 | * purpose: activate/deactivate screen saver | |
169 | * argument: (ScreenPtr)ipScreen : target screen to save | 169 | * argument: (ScreenPtr)ipScreen : target screen to save | |
170 | * (int)mode : on/off | 170 | * (int)mode : on/off | |
171 | * returns: nothing | 171 | * returns: nothing | |
172 | *-----------------------------------------------------------------------*/ | 172 | *-----------------------------------------------------------------------*/ | |
173 | Bool | 173 | Bool | |
174 | x68kSaveScreen(ScreenPtr pScreen, Bool on) | 174 | x68kSaveScreen(ScreenPtr pScreen, Bool on) | |
175 | { | 175 | { | |
176 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | 176 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | |
177 | static int status = FALSE; | 177 | static int status = FALSE; | |
178 | static uint16_t r2; | 178 | static uint16_t r2; | |
179 | 179 | |||
180 | if (on == SCREEN_SAVER_ON || on == SCREEN_SAVER_CYCLE) { | 180 | if (on == SCREEN_SAVER_ON || on == SCREEN_SAVER_CYCLE) { | |
181 | if (!status) { | 181 | if (!status) { | |
182 | r2 = pPriv->reg->videoc.r2; | 182 | r2 = pPriv->reg->videoc.r2; | |
183 | pPriv->reg->videoc.r2 = 0x0000; | 183 | pPriv->reg->videoc.r2 = 0x0000; | |
184 | status = TRUE; | 184 | status = TRUE; | |
185 | } | 185 | } | |
186 | } else { | 186 | } else { | |
187 | if (status) { | 187 | if (status) { | |
188 | pPriv->reg->videoc.r2 = r2; | 188 | pPriv->reg->videoc.r2 = r2; | |
189 | status = FALSE; | 189 | status = FALSE; | |
190 | } | 190 | } | |
191 | } | 191 | } | |
192 | return TRUE; | 192 | return TRUE; | |
193 | } | 193 | } | |
194 | 194 | |||
195 | /* EOF x68kFb.c */ | 195 | /* EOF x68kFb.c */ |
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c 2020/11/04 17:16:13 1.9
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c 2021/03/11 12:08:57 1.10
@@ -1,501 +1,501 @@ | @@ -1,501 +1,501 @@ | |||
1 | /* $NetBSD: x68kGraph.c,v 1.9 2020/11/04 17:16:13 tsutsui Exp $ */ | 1 | /* $NetBSD: x68kGraph.c,v 1.10 2021/03/11 12:08:57 tsutsui Exp $ */ | |
2 | /*------------------------------------------------------------------------- | 2 | /*------------------------------------------------------------------------- | |
3 | * Copyright (c) 1996 Yasushi Yamasaki | 3 | * Copyright (c) 1996 Yasushi Yamasaki | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. 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 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | *-----------------------------------------------------------------------*/ | 25 | *-----------------------------------------------------------------------*/ | |
26 | 26 | |||
27 | /* $XConsortium: sunCfb.c,v 1.15.1.2 95/01/12 18:54:42 kaleb Exp $ */ | 27 | /* $XConsortium: sunCfb.c,v 1.15.1.2 95/01/12 18:54:42 kaleb Exp $ */ | |
28 | 28 | |||
29 | /* | 29 | /* | |
30 | Copyright (c) 1990 X Consortium | 30 | Copyright (c) 1990 X Consortium | |
31 | 31 | |||
32 | Permission is hereby granted, free of charge, to any person obtaining a copy | 32 | Permission is hereby granted, free of charge, to any person obtaining a copy | |
33 | of this software and associated documentation files (the "Software"), to deal | 33 | of this software and associated documentation files (the "Software"), to deal | |
34 | in the Software without restriction, including without limitation the rights | 34 | in the Software without restriction, including without limitation the rights | |
35 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 35 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
36 | copies of the Software, and to permit persons to whom the Software is | 36 | copies of the Software, and to permit persons to whom the Software is | |
37 | furnished to do so, subject to the following conditions: | 37 | furnished to do so, subject to the following conditions: | |
38 | 38 | |||
39 | The above copyright notice and this permission notice shall be included in | 39 | The above copyright notice and this permission notice shall be included in | |
40 | all copies or substantial portions of the Software. | 40 | all copies or substantial portions of the Software. | |
41 | 41 | |||
42 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 42 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
43 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 43 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
44 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 44 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
45 | X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | 45 | X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | |
46 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | 46 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | |
47 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 47 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
48 | 48 | |||
49 | Except as contained in this notice, the name of the X Consortium shall not be | 49 | Except as contained in this notice, the name of the X Consortium shall not be | |
50 | used in advertising or otherwise to promote the sale, use or other dealings | 50 | used in advertising or otherwise to promote the sale, use or other dealings | |
51 | in this Software without prior written authorization from the X Consortium. | 51 | in this Software without prior written authorization from the X Consortium. | |
52 | */ | 52 | */ | |
53 | 53 | |||
54 | /************************************************************ | 54 | /************************************************************ | |
55 | Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. | 55 | Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. | |
56 | 56 | |||
57 | All Rights Reserved | 57 | All Rights Reserved | |
58 | 58 | |||
59 | Permission to use, copy, modify, and distribute this | 59 | Permission to use, copy, modify, and distribute this | |
60 | software and its documentation for any purpose and without | 60 | software and its documentation for any purpose and without | |
61 | fee is hereby granted, provided that the above copyright no- | 61 | fee is hereby granted, provided that the above copyright no- | |
62 | tice appear in all copies and that both that copyright no- | 62 | tice appear in all copies and that both that copyright no- | |
63 | tice and this permission notice appear in supporting docu- | 63 | tice and this permission notice appear in supporting docu- | |
64 | mentation, and that the names of Sun or X Consortium | 64 | mentation, and that the names of Sun or X Consortium | |
65 | not be used in advertising or publicity pertaining to | 65 | not be used in advertising or publicity pertaining to | |
66 | distribution of the software without specific prior | 66 | distribution of the software without specific prior | |
67 | written permission. Sun and X Consortium make no | 67 | written permission. Sun and X Consortium make no | |
68 | representations about the suitability of this software for | 68 | representations about the suitability of this software for | |
69 | any purpose. It is provided "as is" without any express or | 69 | any purpose. It is provided "as is" without any express or | |
70 | implied warranty. | 70 | implied warranty. | |
71 | 71 | |||
72 | SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | 72 | SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
73 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | 73 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | |
74 | NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- | 74 | NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- | |
75 | ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | 75 | ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
76 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | 76 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | |
77 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | 77 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
78 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | 78 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | |
79 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | 79 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
80 | 80 | |||
81 | ********************************************************/ | 81 | ********************************************************/ | |
82 | 82 | |||
83 | /* | 83 | /* | |
84 | * Copyright (c) 1987 by the Regents of the University of California | 84 | * Copyright (c) 1987 by the Regents of the University of California | |
85 | * Copyright (c) 1987 by Adam de Boor, UC Berkeley | 85 | * Copyright (c) 1987 by Adam de Boor, UC Berkeley | |
86 | * | 86 | * | |
87 | * Permission to use, copy, modify, and distribute this | 87 | * Permission to use, copy, modify, and distribute this | |
88 | * software and its documentation for any purpose and without | 88 | * software and its documentation for any purpose and without | |
89 | * fee is hereby granted, provided that the above copyright | 89 | * fee is hereby granted, provided that the above copyright | |
90 | * notice appear in all copies. The University of California | 90 | * notice appear in all copies. The University of California | |
91 | * makes no representations about the suitability of this | 91 | * makes no representations about the suitability of this | |
92 | * software for any purpose. It is provided "as is" without | 92 | * software for any purpose. It is provided "as is" without | |
93 | * express or implied warranty. | 93 | * express or implied warranty. | |
94 | */ | 94 | */ | |
95 | 95 | |||
96 | /****************************************************************/ | 96 | /****************************************************************/ | |
97 | /* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */ | 97 | /* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */ | |
98 | /****************************************************************/ | 98 | /****************************************************************/ | |
99 | 99 | |||
100 | /* | 100 | /* | |
101 | * Copyright 1991, 1992, 1993 Kaleb S. Keithley | 101 | * Copyright 1991, 1992, 1993 Kaleb S. Keithley | |
102 | * | 102 | * | |
103 | * Permission to use, copy, modify, and distribute this | 103 | * Permission to use, copy, modify, and distribute this | |
104 | * software and its documentation for any purpose and without | 104 | * software and its documentation for any purpose and without | |
105 | * fee is hereby granted, provided that the above copyright | 105 | * fee is hereby granted, provided that the above copyright | |
106 | * notice appear in all copies. Kaleb S. Keithley makes no | 106 | * notice appear in all copies. Kaleb S. Keithley makes no | |
107 | * representations about the suitability of this software for | 107 | * representations about the suitability of this software for | |
108 | * any purpose. It is provided "as is" without express or | 108 | * any purpose. It is provided "as is" without express or | |
109 | * implied warranty. | 109 | * implied warranty. | |
110 | */ | 110 | */ | |
111 | 111 | |||
112 | #include "x68k.h" | 112 | #include "x68k.h" | |
113 | #include "mi.h" | 113 | #include "mi.h" | |
114 | #include "micmap.h" | 114 | #include "micmap.h" | |
115 | 115 | |||
116 | #include "fb.h" | 116 | #include "fb.h" | |
117 | 117 | |||
118 | /* local functions */ | 118 | /* local functions */ | |
119 | static Bool x68kCfbFinishScreenInit(ScreenPtr pScreen, void *pbits, | 119 | static Bool x68kCfbFinishScreenInit(ScreenPtr pScreen, void *pbits, | |
120 | int xsize, int ysize, | 120 | int xsize, int ysize, | |
121 | int dpix, int dpiy, int width); | 121 | int dpix, int dpiy, int width); | |
122 | static void x68kInstallColormap(ColormapPtr cmap); | 122 | static void x68kInstallColormap(ColormapPtr cmap); | |
123 | static void x68kUninstallColormap(ColormapPtr cmap); | 123 | static void x68kUninstallColormap(ColormapPtr cmap); | |
124 | static int x68kListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapList); | 124 | static int x68kListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapList); | |
125 | static void x68kStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs); | 125 | static void x68kStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs); | |
126 | 126 | |||
127 | static void x68kUpdateColormap(ScreenPtr pScreen, int dex, int count, | 127 | static void x68kUpdateColormap(ScreenPtr pScreen, int dex, int count, | |
128 | uint8_t *rmap, uint8_t *gmap, uint8_t *bmap); | 128 | uint8_t *rmap, uint8_t *gmap, uint8_t *bmap); | |
129 | 129 | |||
130 | /*------------------------------------------------------------------------- | 130 | /*------------------------------------------------------------------------- | |
131 | * function "x68kGraphOpen" [ X68kFBProc function ] | 131 | * function "x68kGraphOpen" [ X68kFBProc function ] | |
132 | * | 132 | * | |
133 | * purpose: call common frame buffer opening procedure | 133 | * purpose: call common frame buffer opening procedure | |
134 | * then set hardware colormap for several static color modes. | 134 | * then set hardware colormap for several static color modes. | |
135 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | 135 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | |
136 | * returns: (Bool): TRUE if successed | 136 | * returns: (Bool): TRUE if successed | |
137 | * FALSE otherwise | 137 | * FALSE otherwise | |
138 | *-----------------------------------------------------------------------*/ | 138 | *-----------------------------------------------------------------------*/ | |
139 | Bool | 139 | Bool | |
140 | x68kGraphOpen(X68kScreenRec *pPriv) | 140 | x68kGraphOpen(X68kScreenRec *pPriv) | |
141 | { | 141 | { | |
142 | if( !x68kFbCommonOpen(pPriv, "/dev/grf1") ) | 142 | if( !x68kFbCommonOpen(pPriv, "/dev/grf1") ) | |
143 | return FALSE; | 143 | return FALSE; | |
144 | 144 | |||
145 | /* initialize hardware colormap | 145 | /* initialize hardware colormap | |
146 | in cases of static visual class */ | 146 | in cases of static visual class */ | |
147 | if (pPriv->depth == 15 && pPriv->class == TrueColor) { | 147 | if (pPriv->depth == 15 && pPriv->class == TrueColor) { | |
148 | /* for 32768 TrueColor mode */ | 148 | /* for 32768 TrueColor mode */ | |
149 | int i; | 149 | int i; | |
150 | uint16_t x = 0x0001; | 150 | uint16_t x = 0x0001; | |
151 | for ( i = 0; i < 256; ) { | 151 | for ( i = 0; i < 256; ) { | |
152 | pPriv->reg->gpal[i++] = x; | 152 | pPriv->reg->gpal[i++] = x; | |
153 | pPriv->reg->gpal[i++] = x; | 153 | pPriv->reg->gpal[i++] = x; | |
154 | x += 0x0202; | 154 | x += 0x0202; | |
155 | } | 155 | } | |
156 | } | 156 | } | |
157 | if (pPriv->depth == 4 && pPriv->class == StaticGray ) { | 157 | if (pPriv->depth == 4 && pPriv->class == StaticGray ) { | |
158 | /* for 16 StaticGray mode */ | 158 | /* for 16 StaticGray mode */ | |
159 | int i; | 159 | int i; | |
160 | for( i = 0; i < 16; i++ ) | 160 | for( i = 0; i < 16; i++ ) | |
161 | pPriv->reg->gpal[i] = (i*2 << 11) | (i*2 << 6) | (i*2 << 1); | 161 | pPriv->reg->gpal[i] = (i*2 << 11) | (i*2 << 6) | (i*2 << 1); | |
162 | } | 162 | } | |
163 | return TRUE; | 163 | return TRUE; | |
164 | } | 164 | } | |
165 | 165 | |||
166 | /*------------------------------------------------------------------------- | 166 | /*------------------------------------------------------------------------- | |
167 | * function "x68kGraphClose" [ X68kFBProc function ] | 167 | * function "x68kGraphClose" [ X68kFBProc function ] | |
168 | * | 168 | * | |
169 | * purpose: close graphic frame buffer | 169 | * purpose: close graphic frame buffer | |
170 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | 170 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | |
171 | * returns: nothing | 171 | * returns: nothing | |
172 | *-----------------------------------------------------------------------*/ | 172 | *-----------------------------------------------------------------------*/ | |
173 | void | 173 | void | |
174 | x68kGraphClose(X68kScreenRec *pPriv) | 174 | x68kGraphClose(X68kScreenRec *pPriv) | |
175 | { | 175 | { | |
176 | x68kFbCommonClose(pPriv); | 176 | x68kFbCommonClose(pPriv); | |
177 | } | 177 | } | |
178 | 178 | |||
179 | /*------------------------------------------------------------------------- | 179 | /*------------------------------------------------------------------------- | |
180 | * function "x68kGraphInit" [ called by DIX AddScreen ] | 180 | * function "x68kGraphInit" [ called by DIX AddScreen ] | |
181 | * | 181 | * | |
182 | * purpose: initialize graphic frame buffer | 182 | * purpose: initialize graphic frame buffer | |
183 | * argument: (ScreenPtr)pScreen : DIX screen record | 183 | * argument: (ScreenPtr)pScreen : DIX screen record | |
184 | * (int)argc, (char **)argv : standard C arguments | 184 | * (int)argc, (char **)argv : standard C arguments | |
185 | * returns: (Bool) : TRUE if succeeded | 185 | * returns: (Bool) : TRUE if succeeded | |
186 | * FALSE otherwise | 186 | * FALSE otherwise | |
187 | *-----------------------------------------------------------------------*/ | 187 | *-----------------------------------------------------------------------*/ | |
188 | Bool | 188 | Bool | |
189 | x68kGraphInit(ScreenPtr pScreen, int argc, char *argv[]) | 189 | x68kGraphInit(ScreenPtr pScreen, int argc, char *argv[]) | |
190 | { | 190 | { | |
191 | X68kScreenRec *pPriv; | 191 | X68kScreenRec *pPriv; | |
192 | 192 | |||
193 | /* get private screen record set by X68KConfig */ | 193 | /* get private screen record set by X68KConfig */ | |
194 | pPriv = x68kGetScreenRecByType(X68K_FB_GRAPHIC); | 194 | pPriv = x68kGetScreenRecByType(X68K_FB_GRAPHIC); | |
195 | 195 | |||
196 | /* store private record into screen */ | 196 | /* store private record into screen */ | |
197 | if (!dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) { | 197 | if (!dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) { | |
198 | ErrorF("dixRegisterPrivateKey failed"); | 198 | ErrorF("dixRegisterPrivateKey failed\n"); | |
199 | return FALSE; | 199 | return FALSE; | |
200 | } | 200 | } | |
201 | x68kSetScreenPrivate(pScreen, pPriv); | 201 | x68kSetScreenPrivate(pScreen, pPriv); | |
202 | 202 | |||
203 | /* register normal cfb screen functions */ | 203 | /* register normal cfb screen functions */ | |
204 | if (!fbSetupScreen(pScreen, pPriv->fb, | 204 | if (!fbSetupScreen(pScreen, pPriv->fb, | |
205 | pPriv->scr_width, pPriv->scr_height, | 205 | pPriv->scr_width, pPriv->scr_height, | |
206 | pPriv->dpi, pPriv->dpi, pPriv->fb_width, | 206 | pPriv->dpi, pPriv->dpi, pPriv->fb_width, | |
207 | pPriv->depth)) | 207 | pPriv->depth)) | |
208 | return FALSE; | 208 | return FALSE; | |
209 | 209 | |||
210 | /* register colormap functions */ | 210 | /* register colormap functions */ | |
211 | pScreen->InstallColormap = x68kInstallColormap; | 211 | pScreen->InstallColormap = x68kInstallColormap; | |
212 | pScreen->UninstallColormap = x68kUninstallColormap; | 212 | pScreen->UninstallColormap = x68kUninstallColormap; | |
213 | pScreen->ListInstalledColormaps = x68kListInstalledColormaps; | 213 | pScreen->ListInstalledColormaps = x68kListInstalledColormaps; | |
214 | pScreen->StoreColors = x68kStoreColors; | 214 | pScreen->StoreColors = x68kStoreColors; | |
215 | 215 | |||
216 | /* visual initialization and etc.. */ | 216 | /* visual initialization and etc.. */ | |
217 | if (!x68kCfbFinishScreenInit(pScreen, pPriv->fb, | 217 | if (!x68kCfbFinishScreenInit(pScreen, pPriv->fb, | |
218 | pPriv->scr_width, pPriv->scr_height, | 218 | pPriv->scr_width, pPriv->scr_height, | |
219 | pPriv->dpi, pPriv->dpi, pPriv->fb_width)) | 219 | pPriv->dpi, pPriv->dpi, pPriv->fb_width)) | |
220 | return FALSE; | 220 | return FALSE; | |
221 | 221 | |||
222 | if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) ) | 222 | if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) ) | |
223 | return FALSE; | 223 | return FALSE; | |
224 | 224 | |||
225 | pScreen->whitePixel = 1; | 225 | pScreen->whitePixel = 1; | |
226 | pScreen->blackPixel = 0; | 226 | pScreen->blackPixel = 0; | |
227 | if ( !miCreateDefColormap(pScreen) ) | 227 | if ( !miCreateDefColormap(pScreen) ) | |
228 | return FALSE; | 228 | return FALSE; | |
229 | 229 | |||
230 | return TRUE; | 230 | return TRUE; | |
231 | } | 231 | } | |
232 | 232 | |||
233 | /*------------------------------------------------------------------------- | 233 | /*------------------------------------------------------------------------- | |
234 | * function "x68kCfbFinishScreenInit" | 234 | * function "x68kCfbFinishScreenInit" | |
235 | * | 235 | * | |
236 | * purpose: initialize visuals and perform miscellaneous settings | 236 | * purpose: initialize visuals and perform miscellaneous settings | |
237 | * argument: (ScreenPtr)pScreen : DIX screen record | 237 | * argument: (ScreenPtr)pScreen : DIX screen record | |
238 | * (void *)pbits : frame buffer | 238 | * (void *)pbits : frame buffer | |
239 | * (int)xsize, (int)ysize : screen size | 239 | * (int)xsize, (int)ysize : screen size | |
240 | * (int)dpix, (int)dpiy : screen resolution in dots per inch | 240 | * (int)dpix, (int)dpiy : screen resolution in dots per inch | |
241 | * (int)width : pixel width of frame buffer | 241 | * (int)width : pixel width of frame buffer | |
242 | * returns: (Bool) : TRUE if succeeded | 242 | * returns: (Bool) : TRUE if succeeded | |
243 | * FALSE otherwise | 243 | * FALSE otherwise | |
244 | *-----------------------------------------------------------------------*/ | 244 | *-----------------------------------------------------------------------*/ | |
245 | static Bool | 245 | static Bool | |
246 | x68kCfbFinishScreenInit( | 246 | x68kCfbFinishScreenInit( | |
247 | ScreenPtr pScreen, | 247 | ScreenPtr pScreen, | |
248 | void *pbits, | 248 | void *pbits, | |
249 | int xsize, int ysize, | 249 | int xsize, int ysize, | |
250 | int dpix, int dpiy, | 250 | int dpix, int dpiy, | |
251 | int width) | 251 | int width) | |
252 | { | 252 | { | |
253 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | 253 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | |
254 | VisualPtr visuals; | 254 | VisualPtr visuals; | |
255 | int nvisuals; | 255 | int nvisuals; | |
256 | DepthPtr depths; | 256 | DepthPtr depths; | |
257 | int ndepths; | 257 | int ndepths; | |
258 | VisualID defaultVisual; | 258 | VisualID defaultVisual; | |
259 | int rootdepth = 0; | 259 | int rootdepth = 0; | |
260 | 260 | |||
261 | /* for 15/16bit TrueColor visual mode */ | 261 | /* for 15/16bit TrueColor visual mode */ | |
262 | if (pPriv->depth == 15 && pPriv->class == TrueColor) { | 262 | if (pPriv->depth == 15 && pPriv->class == TrueColor) { | |
263 | VisualID *vid = NULL; | 263 | VisualID *vid = NULL; | |
264 | 264 | |||
265 | ndepths = 1; | 265 | ndepths = 1; | |
266 | nvisuals = 1; | 266 | nvisuals = 1; | |
267 | depths = malloc( sizeof(DepthRec) ); | 267 | depths = malloc( sizeof(DepthRec) ); | |
268 | visuals = malloc( sizeof(VisualRec) ); | 268 | visuals = malloc( sizeof(VisualRec) ); | |
269 | vid = malloc( sizeof(VisualID) ); | 269 | vid = malloc( sizeof(VisualID) ); | |
270 | if( !depths || !visuals || !vid ) { | 270 | if( !depths || !visuals || !vid ) { | |
271 | free( depths ); | 271 | free( depths ); | |
272 | free( visuals ); | 272 | free( visuals ); | |
273 | free( vid ); | 273 | free( vid ); | |
274 | return FALSE; | 274 | return FALSE; | |
275 | } | 275 | } | |
276 | depths[0].depth = 15; | 276 | depths[0].depth = 15; | |
277 | depths[0].numVids = 1; | 277 | depths[0].numVids = 1; | |
278 | depths[0].vids = vid; | 278 | depths[0].vids = vid; | |
279 | visuals[0].class = TrueColor; | 279 | visuals[0].class = TrueColor; | |
280 | visuals[0].bitsPerRGBValue = 5; | 280 | visuals[0].bitsPerRGBValue = 5; | |
281 | visuals[0].ColormapEntries = 1 << 5; | 281 | visuals[0].ColormapEntries = 1 << 5; | |
282 | visuals[0].nplanes = 15; | 282 | visuals[0].nplanes = 15; | |
283 | visuals[0].vid = *vid = FakeClientID(0); | 283 | visuals[0].vid = *vid = FakeClientID(0); | |
284 | visuals[0].greenMask = 0xf800; | 284 | visuals[0].greenMask = 0xf800; | |
285 | visuals[0].redMask = 0x07c0; | 285 | visuals[0].redMask = 0x07c0; | |
286 | visuals[0].blueMask = 0x003e; | 286 | visuals[0].blueMask = 0x003e; | |
287 | visuals[0].offsetGreen = 11; | 287 | visuals[0].offsetGreen = 11; | |
288 | visuals[0].offsetRed = 6; | 288 | visuals[0].offsetRed = 6; | |
289 | visuals[0].offsetBlue = 1; | 289 | visuals[0].offsetBlue = 1; | |
290 | rootdepth = 15; | 290 | rootdepth = 15; | |
291 | defaultVisual = *vid; | 291 | defaultVisual = *vid; | |
292 | } | 292 | } | |
293 | /* for 4/16bit StaticGray visual mode */ | 293 | /* for 4/16bit StaticGray visual mode */ | |
294 | else if (pPriv->depth == 4 && pPriv->class == StaticGray ) { | 294 | else if (pPriv->depth == 4 && pPriv->class == StaticGray ) { | |
295 | VisualID *vid = NULL; | 295 | VisualID *vid = NULL; | |
296 | 296 | |||
297 | ndepths = 1; | 297 | ndepths = 1; | |
298 | nvisuals = 1; | 298 | nvisuals = 1; | |
299 | depths = malloc( sizeof(DepthRec) ); | 299 | depths = malloc( sizeof(DepthRec) ); | |
300 | visuals = malloc( sizeof(VisualRec) ); | 300 | visuals = malloc( sizeof(VisualRec) ); | |
301 | vid = malloc( sizeof(VisualID) ); | 301 | vid = malloc( sizeof(VisualID) ); | |
302 | if( !depths || !visuals || !vid ) { | 302 | if( !depths || !visuals || !vid ) { | |
303 | free( depths ); | 303 | free( depths ); | |
304 | free( visuals ); | 304 | free( visuals ); | |
305 | free( vid ); | 305 | free( vid ); | |
306 | return FALSE; | 306 | return FALSE; | |
307 | } | 307 | } | |
308 | depths[0].depth = 4; | 308 | depths[0].depth = 4; | |
309 | depths[0].numVids = 1; | 309 | depths[0].numVids = 1; | |
310 | depths[0].vids = vid; | 310 | depths[0].vids = vid; | |
311 | visuals[0].class = StaticGray; | 311 | visuals[0].class = StaticGray; | |
312 | visuals[0].bitsPerRGBValue = 4; | 312 | visuals[0].bitsPerRGBValue = 4; | |
313 | visuals[0].ColormapEntries = 1 << 4; | 313 | visuals[0].ColormapEntries = 1 << 4; | |
314 | visuals[0].nplanes = 4; | 314 | visuals[0].nplanes = 4; | |
315 | visuals[0].vid = *vid = FakeClientID(0); | 315 | visuals[0].vid = *vid = FakeClientID(0); | |
316 | visuals[0].greenMask = 0; | 316 | visuals[0].greenMask = 0; | |
317 | visuals[0].redMask = 0; | 317 | visuals[0].redMask = 0; | |
318 | visuals[0].blueMask = 0; | 318 | visuals[0].blueMask = 0; | |
319 | visuals[0].offsetGreen = 0; | 319 | visuals[0].offsetGreen = 0; | |
320 | visuals[0].offsetRed = 0; | 320 | visuals[0].offsetRed = 0; | |
321 | visuals[0].offsetBlue = 0; | 321 | visuals[0].offsetBlue = 0; | |
322 | rootdepth = 4; | 322 | rootdepth = 4; | |
323 | defaultVisual = *vid; | 323 | defaultVisual = *vid; | |
324 | } | 324 | } | |
325 | /* for other modes ( supports all visuals ) */ | 325 | /* for other modes ( supports all visuals ) */ | |
326 | else if (!miInitVisuals(&visuals, &depths, &nvisuals, &ndepths, | 326 | else if (!miInitVisuals(&visuals, &depths, &nvisuals, &ndepths, | |
327 | &rootdepth, &defaultVisual, 1 << (16 - 1), | 327 | &rootdepth, &defaultVisual, 1 << (16 - 1), | |
328 | 5, PseudoColor)) | 328 | 5, PseudoColor)) | |
329 | return FALSE; | 329 | return FALSE; | |
330 | 330 | |||
331 | if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, | 331 | if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, | |
332 | rootdepth, ndepths, depths, | 332 | rootdepth, ndepths, depths, | |
333 | defaultVisual, nvisuals, visuals)) | 333 | defaultVisual, nvisuals, visuals)) | |
334 | return FALSE; | 334 | return FALSE; | |
335 | 335 | |||
336 | pScreen->CloseScreen = fbCloseScreen; | 336 | pScreen->CloseScreen = fbCloseScreen; | |
337 | pScreen->SaveScreen = x68kSaveScreen; | 337 | pScreen->SaveScreen = x68kSaveScreen; | |
338 | 338 | |||
339 | return TRUE; | 339 | return TRUE; | |
340 | } | 340 | } | |
341 | 341 | |||
342 | /*------------------------------------------------------------------------- | 342 | /*------------------------------------------------------------------------- | |
343 | * function "x68kInstallColormap" [ screen function ] | 343 | * function "x68kInstallColormap" [ screen function ] | |
344 | * | 344 | * | |
345 | * purpose: install colormap, then update hardware colormap. | 345 | * purpose: install colormap, then update hardware colormap. | |
346 | * argument: (ColormapPtr)cmap : colormap to install | 346 | * argument: (ColormapPtr)cmap : colormap to install | |
347 | * returns: nothing | 347 | * returns: nothing | |
348 | *-----------------------------------------------------------------------*/ | 348 | *-----------------------------------------------------------------------*/ | |
349 | static void | 349 | static void | |
350 | x68kInstallColormap(ColormapPtr cmap) | 350 | x68kInstallColormap(ColormapPtr cmap) | |
351 | { | 351 | { | |
352 | X68kScreenRec *pPriv = x68kGetScreenPrivate(cmap->pScreen); | 352 | X68kScreenRec *pPriv = x68kGetScreenPrivate(cmap->pScreen); | |
353 | register int i; | 353 | register int i; | |
354 | register Entry *pent; | 354 | register Entry *pent; | |
355 | register VisualPtr pVisual = cmap->pVisual; | 355 | register VisualPtr pVisual = cmap->pVisual; | |
356 | uint8_t rmap[256], gmap[256], bmap[256]; | 356 | uint8_t rmap[256], gmap[256], bmap[256]; | |
357 | unsigned long rMask, gMask, bMask; | 357 | unsigned long rMask, gMask, bMask; | |
358 | int oRed, oGreen, oBlue; | 358 | int oRed, oGreen, oBlue; | |
359 | 359 | |||
360 | if (cmap == pPriv->installedMap) | 360 | if (cmap == pPriv->installedMap) | |
361 | return; | 361 | return; | |
362 | if (pPriv->installedMap) | 362 | if (pPriv->installedMap) | |
363 | WalkTree(pPriv->installedMap->pScreen, TellLostMap, | 363 | WalkTree(pPriv->installedMap->pScreen, TellLostMap, | |
364 | (void *) &(pPriv->installedMap->mid)); | 364 | (void *) &(pPriv->installedMap->mid)); | |
365 | 365 | |||
366 | if (pPriv->class & DynamicClass) { | 366 | if (pPriv->class & DynamicClass) { | |
367 | if ((cmap->pVisual->class | DynamicClass) == DirectColor) { | 367 | if ((cmap->pVisual->class | DynamicClass) == DirectColor) { | |
368 | rMask = pVisual->redMask; | 368 | rMask = pVisual->redMask; | |
369 | gMask = pVisual->greenMask; | 369 | gMask = pVisual->greenMask; | |
370 | bMask = pVisual->blueMask; | 370 | bMask = pVisual->blueMask; | |
371 | oRed = pVisual->offsetRed; | 371 | oRed = pVisual->offsetRed; | |
372 | oGreen = pVisual->offsetGreen; | 372 | oGreen = pVisual->offsetGreen; | |
373 | oBlue = pVisual->offsetBlue; | 373 | oBlue = pVisual->offsetBlue; | |
374 | for (i = 0; i < 1<<(pPriv->depth); i++) { | 374 | for (i = 0; i < 1<<(pPriv->depth); i++) { | |
375 | rmap[i] = cmap->red[(i & rMask) >> oRed].co.local.red >> 11; | 375 | rmap[i] = cmap->red[(i & rMask) >> oRed].co.local.red >> 11; | |
376 | gmap[i] = cmap->green[(i & gMask) >> oGreen].co.local.green >> 11; | 376 | gmap[i] = cmap->green[(i & gMask) >> oGreen].co.local.green >> 11; | |
377 | bmap[i] = cmap->blue[(i & bMask) >> oBlue].co.local.blue >> 11; | 377 | bmap[i] = cmap->blue[(i & bMask) >> oBlue].co.local.blue >> 11; | |
378 | } | 378 | } | |
379 | } else { | 379 | } else { | |
380 | for (i = 0, pent = cmap->red; | 380 | for (i = 0, pent = cmap->red; | |
381 | i < pVisual->ColormapEntries; | 381 | i < pVisual->ColormapEntries; | |
382 | i++, pent++) { | 382 | i++, pent++) { | |
383 | if (pent->fShared) { | 383 | if (pent->fShared) { | |
384 | rmap[i] = pent->co.shco.red->color >> 11; | 384 | rmap[i] = pent->co.shco.red->color >> 11; | |
385 | gmap[i] = pent->co.shco.green->color >> 11; | 385 | gmap[i] = pent->co.shco.green->color >> 11; | |
386 | bmap[i] = pent->co.shco.blue->color >> 11; | 386 | bmap[i] = pent->co.shco.blue->color >> 11; | |
387 | } | 387 | } | |
388 | else { | 388 | else { | |
389 | rmap[i] = pent->co.local.red >> 11; | 389 | rmap[i] = pent->co.local.red >> 11; | |
390 | gmap[i] = pent->co.local.green >> 11; | 390 | gmap[i] = pent->co.local.green >> 11; | |
391 | bmap[i] = pent->co.local.blue >> 11; | 391 | bmap[i] = pent->co.local.blue >> 11; | |
392 | } | 392 | } | |
393 | } | 393 | } | |
394 | } | 394 | } | |
395 | x68kUpdateColormap(cmap->pScreen, 0, 1<<(pPriv->depth), rmap, gmap, bmap); | 395 | x68kUpdateColormap(cmap->pScreen, 0, 1<<(pPriv->depth), rmap, gmap, bmap); | |
396 | } | 396 | } | |
397 | pPriv->installedMap = cmap; | 397 | pPriv->installedMap = cmap; | |
398 | WalkTree(cmap->pScreen, TellGainedMap, (void *) &(cmap->mid)); | 398 | WalkTree(cmap->pScreen, TellGainedMap, (void *) &(cmap->mid)); | |
399 | } | 399 | } | |
400 | 400 | |||
401 | /*------------------------------------------------------------------------- | 401 | /*------------------------------------------------------------------------- | |
402 | * function "x68kUninstallColormap" [ screen function ] | 402 | * function "x68kUninstallColormap" [ screen function ] | |
403 | * | 403 | * | |
404 | * purpose: uninstall colormap | 404 | * purpose: uninstall colormap | |
405 | * argument: (ColormapPtr)cmap : colormap to uninstall | 405 | * argument: (ColormapPtr)cmap : colormap to uninstall | |
406 | * returns: nothing | 406 | * returns: nothing | |
407 | *-----------------------------------------------------------------------*/ | 407 | *-----------------------------------------------------------------------*/ | |
408 | static void | 408 | static void | |
409 | x68kUninstallColormap(ColormapPtr cmap) | 409 | x68kUninstallColormap(ColormapPtr cmap) | |
410 | { | 410 | { | |
411 | X68kScreenRec *pPriv = x68kGetScreenPrivate(cmap->pScreen); | 411 | X68kScreenRec *pPriv = x68kGetScreenPrivate(cmap->pScreen); | |
412 | 412 | |||
413 | if (cmap == pPriv->installedMap) { | 413 | if (cmap == pPriv->installedMap) { | |
414 | Colormap defMapID = cmap->pScreen->defColormap; | 414 | Colormap defMapID = cmap->pScreen->defColormap; | |
415 | 415 | |||
416 | if (cmap->mid != defMapID) { | 416 | if (cmap->mid != defMapID) { | |
417 | void *retval; | 417 | void *retval; | |
418 | ColormapPtr defMap; | 418 | ColormapPtr defMap; | |
419 | dixLookupResourceByType(&retval, defMapID, RT_COLORMAP, | 419 | dixLookupResourceByType(&retval, defMapID, RT_COLORMAP, | |
420 | serverClient, DixReadAccess); | 420 | serverClient, DixReadAccess); | |
421 | defMap = (ColormapPtr) retval; | 421 | defMap = (ColormapPtr) retval; | |
422 | (*cmap->pScreen->InstallColormap)(defMap); | 422 | (*cmap->pScreen->InstallColormap)(defMap); | |
423 | } | 423 | } | |
424 | } | 424 | } | |
425 | } | 425 | } | |
426 | 426 | |||
427 | /*------------------------------------------------------------------------- | 427 | /*------------------------------------------------------------------------- | |
428 | * function "x68kListInstalledColormaps" [ screen function ] | 428 | * function "x68kListInstalledColormaps" [ screen function ] | |
429 | * | 429 | * | |
430 | * purpose: Get the list of currently installed colormaps. | 430 | * purpose: Get the list of currently installed colormaps. | |
431 | * In X68k, installed colormap in always only one. | 431 | * In X68k, installed colormap in always only one. | |
432 | * argument: (ScreenPtr)pScreen : screen | 432 | * argument: (ScreenPtr)pScreen : screen | |
433 | * (Colormap *)pCmapList : colormap list got | 433 | * (Colormap *)pCmapList : colormap list got | |
434 | * returns: (int) | 434 | * returns: (int) | |
435 | *-----------------------------------------------------------------------*/ | 435 | *-----------------------------------------------------------------------*/ | |
436 | static int | 436 | static int | |
437 | x68kListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapList) | 437 | x68kListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapList) | |
438 | { | 438 | { | |
439 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | 439 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | |
440 | *pCmapList = pPriv->installedMap->mid; | 440 | *pCmapList = pPriv->installedMap->mid; | |
441 | return 1; | 441 | return 1; | |
442 | } | 442 | } | |
443 | 443 | |||
444 | /*------------------------------------------------------------------------- | 444 | /*------------------------------------------------------------------------- | |
445 | * function "x68kStoreColors" [ screen function ] | 445 | * function "x68kStoreColors" [ screen function ] | |
446 | * | 446 | * | |
447 | * purpose: store specified color items | 447 | * purpose: store specified color items | |
448 | * argument: (ColormapPtr)pmap : colormap | 448 | * argument: (ColormapPtr)pmap : colormap | |
449 | * (int)ndef : the number of items | 449 | * (int)ndef : the number of items | |
450 | * (xColorItem *)pdefs : items | 450 | * (xColorItem *)pdefs : items | |
451 | * returns: nothing | 451 | * returns: nothing | |
452 | *-----------------------------------------------------------------------*/ | 452 | *-----------------------------------------------------------------------*/ | |
453 | static void | 453 | static void | |
454 | x68kStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs) | 454 | x68kStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs) | |
455 | { | 455 | { | |
456 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pmap->pScreen); | 456 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pmap->pScreen); | |
457 | uint8_t rmap[256], gmap[256], bmap[256]; | 457 | uint8_t rmap[256], gmap[256], bmap[256]; | |
458 | xColorItem expanddefs[256]; | 458 | xColorItem expanddefs[256]; | |
459 | register int i; | 459 | register int i; | |
460 | 460 | |||
461 | if (pPriv->installedMap != NULL && pPriv->installedMap != pmap) | 461 | if (pPriv->installedMap != NULL && pPriv->installedMap != pmap) | |
462 | return; | 462 | return; | |
463 | if ((pmap->pVisual->class | DynamicClass) == DirectColor) { | 463 | if ((pmap->pVisual->class | DynamicClass) == DirectColor) { | |
464 | ndef = fbExpandDirectColors(pmap, ndef, pdefs, expanddefs); | 464 | ndef = fbExpandDirectColors(pmap, ndef, pdefs, expanddefs); | |
465 | pdefs = expanddefs; | 465 | pdefs = expanddefs; | |
466 | } | 466 | } | |
467 | while (ndef--) { | 467 | while (ndef--) { | |
468 | i = pdefs->pixel; | 468 | i = pdefs->pixel; | |
469 | rmap[i] = pdefs->red >> 11; | 469 | rmap[i] = pdefs->red >> 11; | |
470 | gmap[i] = pdefs->green >> 11; | 470 | gmap[i] = pdefs->green >> 11; | |
471 | bmap[i] = pdefs->blue >> 11; | 471 | bmap[i] = pdefs->blue >> 11; | |
472 | x68kUpdateColormap(pmap->pScreen, i, 1, rmap, gmap, bmap); | 472 | x68kUpdateColormap(pmap->pScreen, i, 1, rmap, gmap, bmap); | |
473 | pdefs++; | 473 | pdefs++; | |
474 | } | 474 | } | |
475 | } | 475 | } | |
476 | 476 | |||
477 | /*------------------------------------------------------------------------- | 477 | /*------------------------------------------------------------------------- | |
478 | * function "x68kUpdateColormap" | 478 | * function "x68kUpdateColormap" | |
479 | * | 479 | * | |
480 | * purpose: update hardware colormap | 480 | * purpose: update hardware colormap | |
481 | * argument: (ScreenPtr)pScreen: screen | 481 | * argument: (ScreenPtr)pScreen: screen | |
482 | * (int)dex : colormap index | 482 | * (int)dex : colormap index | |
483 | * (int)count : count for updating | 483 | * (int)count : count for updating | |
484 | * (uint8_t *)[rgb]map: each map | 484 | * (uint8_t *)[rgb]map: each map | |
485 | * returns: nothing | 485 | * returns: nothing | |
486 | *-----------------------------------------------------------------------*/ | 486 | *-----------------------------------------------------------------------*/ | |
487 | static void | 487 | static void | |
488 | x68kUpdateColormap(ScreenPtr pScreen, int dex, int count, | 488 | x68kUpdateColormap(ScreenPtr pScreen, int dex, int count, | |
489 | uint8_t *rmap, uint8_t *gmap, uint8_t *bmap) | 489 | uint8_t *rmap, uint8_t *gmap, uint8_t *bmap) | |
490 | { | 490 | { | |
491 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | 491 | X68kScreenRec *pPriv = x68kGetScreenPrivate(pScreen); | |
492 | volatile uint16_t *pal = pPriv->reg->gpal; | 492 | volatile uint16_t *pal = pPriv->reg->gpal; | |
493 | 493 | |||
494 | for( ; count > 0; count--,dex++ ) { | 494 | for( ; count > 0; count--,dex++ ) { | |
495 | pal[dex] = (uint16_t)gmap[dex] << 11 | | 495 | pal[dex] = (uint16_t)gmap[dex] << 11 | | |
496 | (uint16_t)rmap[dex] << 6 | | 496 | (uint16_t)rmap[dex] << 6 | | |
497 | (uint16_t)bmap[dex] << 1; | 497 | (uint16_t)bmap[dex] << 1; | |
498 | } | 498 | } | |
499 | } | 499 | } | |
500 | 500 | |||
501 | /* EOF x68kGraph.c */ | 501 | /* EOF x68kGraph.c */ |
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c 2021/02/07 16:55:18 1.9
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c 2021/03/11 12:08:57 1.10
@@ -1,378 +1,378 @@ | @@ -1,378 +1,378 @@ | |||
1 | /* $NetBSD: x68kMouse.c,v 1.9 2021/02/07 16:55:18 tsutsui Exp $ */ | 1 | /* $NetBSD: x68kMouse.c,v 1.10 2021/03/11 12:08:57 tsutsui Exp $ */ | |
2 | /*------------------------------------------------------------------------- | 2 | /*------------------------------------------------------------------------- | |
3 | * Copyright (c) 1996 Yasushi Yamasaki | 3 | * Copyright (c) 1996 Yasushi Yamasaki | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. 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 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | *-----------------------------------------------------------------------*/ | 25 | *-----------------------------------------------------------------------*/ | |
26 | 26 | |||
27 | /*- | 27 | /*- | |
28 | * Copyright (c) 1987 by the Regents of the University of California | 28 | * Copyright (c) 1987 by the Regents of the University of California | |
29 | * | 29 | * | |
30 | * Permission to use, copy, modify, and distribute this | 30 | * Permission to use, copy, modify, and distribute this | |
31 | * software and its documentation for any purpose and without | 31 | * software and its documentation for any purpose and without | |
32 | * fee is hereby granted, provided that the above copyright | 32 | * fee is hereby granted, provided that the above copyright | |
33 | * notice appear in all copies. The University of California | 33 | * notice appear in all copies. The University of California | |
34 | * makes no representations about the suitability of this | 34 | * makes no representations about the suitability of this | |
35 | * software for any purpose. It is provided "as is" without | 35 | * software for any purpose. It is provided "as is" without | |
36 | * express or implied warranty. | 36 | * express or implied warranty. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /************************************************************ | 39 | /************************************************************ | |
40 | Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. | 40 | Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. | |
41 | 41 | |||
42 | All Rights Reserved | 42 | All Rights Reserved | |
43 | 43 | |||
44 | Permission to use, copy, modify, and distribute this | 44 | Permission to use, copy, modify, and distribute this | |
45 | software and its documentation for any purpose and without | 45 | software and its documentation for any purpose and without | |
46 | fee is hereby granted, provided that the above copyright no- | 46 | fee is hereby granted, provided that the above copyright no- | |
47 | tice appear in all copies and that both that copyright no- | 47 | tice appear in all copies and that both that copyright no- | |
48 | tice and this permission notice appear in supporting docu- | 48 | tice and this permission notice appear in supporting docu- | |
49 | mentation, and that the names of Sun or X Consortium | 49 | mentation, and that the names of Sun or X Consortium | |
50 | not be used in advertising or publicity pertaining to | 50 | not be used in advertising or publicity pertaining to | |
51 | distribution of the software without specific prior | 51 | distribution of the software without specific prior | |
52 | written permission. Sun and X Consortium make no | 52 | written permission. Sun and X Consortium make no | |
53 | representations about the suitability of this software for | 53 | representations about the suitability of this software for | |
54 | any purpose. It is provided "as is" without any express or | 54 | any purpose. It is provided "as is" without any express or | |
55 | implied warranty. | 55 | implied warranty. | |
56 | 56 | |||
57 | SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | 57 | SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
58 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | 58 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | |
59 | NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- | 59 | NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- | |
60 | ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | 60 | ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
61 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | 61 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | |
62 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | 62 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
63 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | 63 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | |
64 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | 64 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
65 | 65 | |||
66 | ********************************************************/ | 66 | ********************************************************/ | |
67 | /* | 67 | /* | |
68 | * Copyright 1991, 1992, 1993 Kaleb S. Keithley | 68 | * Copyright 1991, 1992, 1993 Kaleb S. Keithley | |
69 | * | 69 | * | |
70 | * Permission to use, copy, modify, and distribute this | 70 | * Permission to use, copy, modify, and distribute this | |
71 | * software and its documentation for any purpose and without | 71 | * software and its documentation for any purpose and without | |
72 | * fee is hereby granted, provided that the above copyright | 72 | * fee is hereby granted, provided that the above copyright | |
73 | * notice appear in all copies. Kaleb S. Keithley makes no | 73 | * notice appear in all copies. Kaleb S. Keithley makes no | |
74 | * representations about the suitability of this software for | 74 | * representations about the suitability of this software for | |
75 | * any purpose. It is provided "as is" without express or | 75 | * any purpose. It is provided "as is" without express or | |
76 | * implied warranty. | 76 | * implied warranty. | |
77 | */ | 77 | */ | |
78 | 78 | |||
79 | #include "x68k.h" | 79 | #include "x68k.h" | |
80 | #include "mi.h" | 80 | #include "mi.h" | |
81 | #include "input.h" | 81 | #include "input.h" | |
82 | #include "inpututils.h" | 82 | #include "inpututils.h" | |
83 | 83 | |||
84 | #include "exevents.h" | 84 | #include "exevents.h" | |
85 | #include "events.h" | 85 | #include "events.h" | |
86 | #include "eventstr.h" | 86 | #include "eventstr.h" | |
87 | #include <X11/Xatom.h> | 87 | #include <X11/Xatom.h> | |
88 | #include "xserver-properties.h" | 88 | #include "xserver-properties.h" | |
89 | 89 | |||
90 | static void x68kMouseHandlerNotify(int, int, void *); | 90 | static void x68kMouseHandlerNotify(int, int, void *); | |
91 | static Bool x68kCursorOffScreen(ScreenPtr *, int *, int *); | 91 | static Bool x68kCursorOffScreen(ScreenPtr *, int *, int *); | |
92 | static void x68kCrossScreen(ScreenPtr, int); | 92 | static void x68kCrossScreen(ScreenPtr, int); | |
93 | static void x68kWarpCursor(DeviceIntPtr, ScreenPtr, int, int); | 93 | static void x68kWarpCursor(DeviceIntPtr, ScreenPtr, int, int); | |
94 | static void x68kMouseCtrl(DeviceIntPtr, PtrCtrl*); | 94 | static void x68kMouseCtrl(DeviceIntPtr, PtrCtrl*); | |
95 | 95 | |||
96 | miPointerScreenFuncRec x68kPointerScreenFuncs = { | 96 | miPointerScreenFuncRec x68kPointerScreenFuncs = { | |
97 | x68kCursorOffScreen, | 97 | x68kCursorOffScreen, | |
98 | x68kCrossScreen, | 98 | x68kCrossScreen, | |
99 | x68kWarpCursor, | 99 | x68kWarpCursor, | |
100 | }; | 100 | }; | |
101 | 101 | |||
102 | DeviceIntPtr x68kPointerDevice = NULL; | 102 | DeviceIntPtr x68kPointerDevice = NULL; | |
103 | 103 | |||
104 | static X68kMousePriv x68kMousePriv; | 104 | static X68kMousePriv x68kMousePriv; | |
105 | 105 | |||
106 | static void | 106 | static void | |
107 | x68kMouseHandlerNotify(int fd __unused, int ready __unused, void *data __unused) | 107 | x68kMouseHandlerNotify(int fd __unused, int ready __unused, void *data __unused) | |
108 | { | 108 | { | |
109 | } | 109 | } | |
110 | 110 | |||
111 | /*- | 111 | /*- | |
112 | *----------------------------------------------------------------------- | 112 | *----------------------------------------------------------------------- | |
113 | * x68kMouseProc -- | 113 | * x68kMouseProc -- | |
114 | * Handle the initialization, etc. of a mouse | 114 | * Handle the initialization, etc. of a mouse | |
115 | * | 115 | * | |
116 | * Results: | 116 | * Results: | |
117 | * none. | 117 | * none. | |
118 | * | 118 | * | |
119 | * Side Effects: | 119 | * Side Effects: | |
120 | *----------------------------------------------------------------------- | 120 | *----------------------------------------------------------------------- | |
121 | */ | 121 | */ | |
122 | int | 122 | int | |
123 | x68kMouseProc(DeviceIntPtr device, int what) | 123 | x68kMouseProc(DeviceIntPtr device, int what) | |
124 | { | 124 | { | |
125 | DevicePtr pMouse = &device->public; | 125 | DevicePtr pMouse = &device->public; | |
126 | int format; | 126 | int format; | |
127 | static int oformat; | 127 | static int oformat; | |
128 | BYTE map[4]; | 128 | BYTE map[4]; | |
129 | Atom btn_labels[3] = {0}; | 129 | Atom btn_labels[3] = {0}; | |
130 | Atom axes_labels[2] = { 0, 0 }; | 130 | Atom axes_labels[2] = { 0, 0 }; | |
131 | MouseEmu3btnPtr pEmu3btn; | 131 | MouseEmu3btnPtr pEmu3btn; | |
132 | Bool emu3enable; | 132 | Bool emu3enable; | |
133 | int emu3timeout; | 133 | int emu3timeout; | |
134 | 134 | |||
135 | switch (what) { | 135 | switch (what) { | |
136 | case DEVICE_INIT: | 136 | case DEVICE_INIT: | |
137 | pMouse->devicePrivate = (void *) &x68kMousePriv; | 137 | pMouse->devicePrivate = (void *) &x68kMousePriv; | |
138 | if( (x68kMousePriv.fd = open("/dev/mouse", O_RDONLY)) == -1 ) { | 138 | if( (x68kMousePriv.fd = open("/dev/mouse", O_RDONLY)) == -1 ) { | |
139 | ErrorF("Can't open mouse device"); | 139 | ErrorF("Can't open mouse device\n"); | |
140 | return !Success; | 140 | return !Success; | |
141 | } | 141 | } | |
142 | pMouse->on = FALSE; | 142 | pMouse->on = FALSE; | |
143 | map[1] = 1; | 143 | map[1] = 1; | |
144 | map[2] = 2; | 144 | map[2] = 2; | |
145 | map[3] = 3; | 145 | map[3] = 3; | |
146 | btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); | 146 | btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); | |
147 | btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); | 147 | btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); | |
148 | btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); | 148 | btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); | |
149 | axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); | 149 | axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); | |
150 | axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); | 150 | axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); | |
151 | 151 | |||
152 | InitPointerDeviceStruct(pMouse, map, 3, btn_labels, | 152 | InitPointerDeviceStruct(pMouse, map, 3, btn_labels, | |
153 | x68kMouseCtrl, GetMotionHistorySize(), | 153 | x68kMouseCtrl, GetMotionHistorySize(), | |
154 | 2, axes_labels); | 154 | 2, axes_labels); | |
155 | 155 | |||
156 | /* Initialize emulation 3 buttons settings */ | 156 | /* Initialize emulation 3 buttons settings */ | |
157 | emu3enable = TRUE; /* XXX should be configurable */ | 157 | emu3enable = TRUE; /* XXX should be configurable */ | |
158 | emu3timeout = EMU3B_DEF_TIMEOUT; /* XXX should be configurable */ | 158 | emu3timeout = EMU3B_DEF_TIMEOUT; /* XXX should be configurable */ | |
159 | if (emu3enable) { | 159 | if (emu3enable) { | |
160 | pEmu3btn = &x68kMousePriv.emu3btn; | 160 | pEmu3btn = &x68kMousePriv.emu3btn; | |
161 | Emulate3ButtonsEnable(pEmu3btn, device, emu3timeout); | 161 | Emulate3ButtonsEnable(pEmu3btn, device, emu3timeout); | |
162 | } | 162 | } | |
163 | 163 | |||
164 | break; | 164 | break; | |
165 | 165 | |||
166 | case DEVICE_ON: | 166 | case DEVICE_ON: | |
167 | if (ioctl (x68kMousePriv.fd, VUIDGFORMAT, &oformat) == -1) { | 167 | if (ioctl (x68kMousePriv.fd, VUIDGFORMAT, &oformat) == -1) { | |
168 | ErrorF("x68kMouseProc ioctl VUIDGFORMAT"); | 168 | ErrorF("x68kMouseProc ioctl VUIDGFORMAT\n"); | |
169 | return !Success; | 169 | return !Success; | |
170 | } | 170 | } | |
171 | format = VUID_FIRM_EVENT; | 171 | format = VUID_FIRM_EVENT; | |
172 | if (ioctl (x68kMousePriv.fd, VUIDSFORMAT, &format) == -1) { | 172 | if (ioctl (x68kMousePriv.fd, VUIDSFORMAT, &format) == -1) { | |
173 | ErrorF("x68kMouseProc ioctl VUIDSFORMAT"); | 173 | ErrorF("x68kMouseProc ioctl VUIDSFORMAT\n"); | |
174 | return !Success; | 174 | return !Success; | |
175 | } | 175 | } | |
176 | if ( fcntl(x68kMousePriv.fd, F_SETOWN, getpid()) == -1 || | 176 | if ( fcntl(x68kMousePriv.fd, F_SETOWN, getpid()) == -1 || | |
177 | fcntl(x68kMousePriv.fd, F_SETFL, O_NONBLOCK | O_ASYNC) == -1 | 177 | fcntl(x68kMousePriv.fd, F_SETFL, O_NONBLOCK | O_ASYNC) == -1 | |
178 | ) { | 178 | ) { | |
179 | ErrorF("Async mouse I/O failed"); | 179 | ErrorF("Async mouse I/O failed\n"); | |
180 | return !Success; | 180 | return !Success; | |
181 | } | 181 | } | |
182 | x68kMousePriv.bmask = 0; | 182 | x68kMousePriv.bmask = 0; | |
183 | SetNotifyFd(x68kMousePriv.fd, x68kMouseHandlerNotify, | 183 | SetNotifyFd(x68kMousePriv.fd, x68kMouseHandlerNotify, | |
184 | X_NOTIFY_READ, NULL); | 184 | X_NOTIFY_READ, NULL); | |
185 | pMouse->on = TRUE; | 185 | pMouse->on = TRUE; | |
186 | break; | 186 | break; | |
187 | 187 | |||
188 | case DEVICE_OFF: | 188 | case DEVICE_OFF: | |
189 | pMouse->on = FALSE; | 189 | pMouse->on = FALSE; | |
190 | RemoveNotifyFd(x68kMousePriv.fd); | 190 | RemoveNotifyFd(x68kMousePriv.fd); | |
191 | break; | 191 | break; | |
192 | 192 | |||
193 | case DEVICE_CLOSE: | 193 | case DEVICE_CLOSE: | |
194 | if (ioctl (x68kMousePriv.fd, VUIDSFORMAT, &oformat) == -1) | 194 | if (ioctl (x68kMousePriv.fd, VUIDSFORMAT, &oformat) == -1) | |
195 | ErrorF("x68kMouseProc ioctl VUIDSFORMAT"); | 195 | ErrorF("x68kMouseProc ioctl VUIDSFORMAT\n"); | |
196 | break; | 196 | break; | |
197 | 197 | |||
198 | } | 198 | } | |
199 | return Success; | 199 | return Success; | |
200 | } | 200 | } | |
201 | 201 | |||
202 | /*- | 202 | /*- | |
203 | *----------------------------------------------------------------------- | 203 | *----------------------------------------------------------------------- | |
204 | * x68kMouseCtrl -- | 204 | * x68kMouseCtrl -- | |
205 | * Alter the control parameters for the mouse. Since acceleration | 205 | * Alter the control parameters for the mouse. Since acceleration | |
206 | * etc. is done from the PtrCtrl record in the mouse's device record, | 206 | * etc. is done from the PtrCtrl record in the mouse's device record, | |
207 | * there's nothing to do here. | 207 | * there's nothing to do here. | |
208 | * | 208 | * | |
209 | * Results: | 209 | * Results: | |
210 | * None. | 210 | * None. | |
211 | * | 211 | * | |
212 | * Side Effects: | 212 | * Side Effects: | |
213 | * None. | 213 | * None. | |
214 | * | 214 | * | |
215 | *----------------------------------------------------------------------- | 215 | *----------------------------------------------------------------------- | |
216 | */ | 216 | */ | |
217 | /*ARGSUSED*/ | 217 | /*ARGSUSED*/ | |
218 | static void | 218 | static void | |
219 | x68kMouseCtrl(DeviceIntPtr device, PtrCtrl* ctrl) | 219 | x68kMouseCtrl(DeviceIntPtr device, PtrCtrl* ctrl) | |
220 | { | 220 | { | |
221 | } | 221 | } | |
222 | 222 | |||
223 | /*- | 223 | /*- | |
224 | *----------------------------------------------------------------------- | 224 | *----------------------------------------------------------------------- | |
225 | * x68kMouseGetEvents -- | 225 | * x68kMouseGetEvents -- | |
226 | * Return the events waiting in the wings for the given mouse. | 226 | * Return the events waiting in the wings for the given mouse. | |
227 | * | 227 | * | |
228 | * Results: | 228 | * Results: | |
229 | * A pointer to an array of Firm_events or (Firm_event *)0 if no events | 229 | * A pointer to an array of Firm_events or (Firm_event *)0 if no events | |
230 | * The number of events contained in the array. | 230 | * The number of events contained in the array. | |
231 | * A boolean as to whether more events might be available. | 231 | * A boolean as to whether more events might be available. | |
232 | * | 232 | * | |
233 | * Side Effects: | 233 | * Side Effects: | |
234 | * None. | 234 | * None. | |
235 | *----------------------------------------------------------------------- | 235 | *----------------------------------------------------------------------- | |
236 | */ | 236 | */ | |
237 | 237 | |||
238 | Firm_event * | 238 | Firm_event * | |
239 | x68kMouseGetEvents(int fd, int *pNumEvents, Bool *pAgain) | 239 | x68kMouseGetEvents(int fd, int *pNumEvents, Bool *pAgain) | |
240 | { | 240 | { | |
241 | int nBytes; /* number of bytes of events available. */ | 241 | int nBytes; /* number of bytes of events available. */ | |
242 | static Firm_event evBuf[X68K_MAXEVENTS]; /* Buffer for Firm_events */ | 242 | static Firm_event evBuf[X68K_MAXEVENTS]; /* Buffer for Firm_events */ | |
243 | 243 | |||
244 | if ((nBytes = read (fd, (char *)evBuf, sizeof(evBuf))) == -1) { | 244 | if ((nBytes = read (fd, (char *)evBuf, sizeof(evBuf))) == -1) { | |
245 | if (errno == EWOULDBLOCK) { | 245 | if (errno == EWOULDBLOCK) { | |
246 | *pNumEvents = 0; | 246 | *pNumEvents = 0; | |
247 | *pAgain = FALSE; | 247 | *pAgain = FALSE; | |
248 | } else { | 248 | } else { | |
249 | ErrorF("x68kMouseGetEvents read"); | 249 | ErrorF("x68kMouseGetEvents read\n"); | |
250 | FatalError ("Could not read from mouse"); | 250 | FatalError ("Could not read from mouse"); | |
251 | } | 251 | } | |
252 | } else { | 252 | } else { | |
253 | *pNumEvents = nBytes / sizeof (Firm_event); | 253 | *pNumEvents = nBytes / sizeof (Firm_event); | |
254 | *pAgain = (nBytes == sizeof (evBuf)); | 254 | *pAgain = (nBytes == sizeof (evBuf)); | |
255 | } | 255 | } | |
256 | return evBuf; | 256 | return evBuf; | |
257 | } | 257 | } | |
258 | 258 | |||
259 | /*- | 259 | /*- | |
260 | *----------------------------------------------------------------------- | 260 | *----------------------------------------------------------------------- | |
261 | * x68kMouseEnqueueEvent -- | 261 | * x68kMouseEnqueueEvent -- | |
262 | * Given a Firm_event for a mouse, pass it off the the dix layer | 262 | * Given a Firm_event for a mouse, pass it off the the dix layer | |
263 | * properly converted... | 263 | * properly converted... | |
264 | * | 264 | * | |
265 | * Results: | 265 | * Results: | |
266 | * None. | 266 | * None. | |
267 | * | 267 | * | |
268 | * Side Effects: | 268 | * Side Effects: | |
269 | * The cursor may be redrawn...? devPrivate/x/y will be altered. | 269 | * The cursor may be redrawn...? devPrivate/x/y will be altered. | |
270 | * | 270 | * | |
271 | *----------------------------------------------------------------------- | 271 | *----------------------------------------------------------------------- | |
272 | */ | 272 | */ | |
273 | 273 | |||
274 | void | 274 | void | |
275 | x68kMouseEnqueueEvent(DeviceIntPtr device, Firm_event *fe) | 275 | x68kMouseEnqueueEvent(DeviceIntPtr device, Firm_event *fe) | |
276 | { | 276 | { | |
277 | X68kMousePrivPtr pPriv; /* Private data for pointer */ | 277 | X68kMousePrivPtr pPriv; /* Private data for pointer */ | |
278 | int bmask; /* Temporary button mask */ | 278 | int bmask; /* Temporary button mask */ | |
279 | int type, buttons, flag; | 279 | int type, buttons, flag; | |
280 | int valuators[2]; | 280 | int valuators[2]; | |
281 | ValuatorMask mask; | 281 | ValuatorMask mask; | |
282 | 282 | |||
283 | pPriv = (X68kMousePrivPtr)device->public.devicePrivate; | 283 | pPriv = (X68kMousePrivPtr)device->public.devicePrivate; | |
284 | 284 | |||
285 | switch (fe->id) { | 285 | switch (fe->id) { | |
286 | case MS_LEFT: | 286 | case MS_LEFT: | |
287 | case MS_MIDDLE: | 287 | case MS_MIDDLE: | |
288 | case MS_RIGHT: | 288 | case MS_RIGHT: | |
289 | /* | 289 | /* | |
290 | * A button changed state. Sometimes we will get two events | 290 | * A button changed state. Sometimes we will get two events | |
291 | * for a single state change. Should we get a button event which | 291 | * for a single state change. Should we get a button event which | |
292 | * reflects the current state of affairs, that event is discarded. | 292 | * reflects the current state of affairs, that event is discarded. | |
293 | * | 293 | * | |
294 | * Mouse buttons start at 1 as defined in <X11/X.h>. | 294 | * Mouse buttons start at 1 as defined in <X11/X.h>. | |
295 | * | 295 | * | |
296 | * The bmask stores which buttons are currently pressed. | 296 | * The bmask stores which buttons are currently pressed. | |
297 | * This bmask is also used for Emulate3Buttons functions that | 297 | * This bmask is also used for Emulate3Buttons functions that | |
298 | * assume the left button is LSB as defined in mouseEmu3btn.c. | 298 | * assume the left button is LSB as defined in mouseEmu3btn.c. | |
299 | */ | 299 | */ | |
300 | buttons = (fe->id - MS_LEFT) + 1; | 300 | buttons = (fe->id - MS_LEFT) + 1; | |
301 | bmask = 1 << (buttons - 1); | 301 | bmask = 1 << (buttons - 1); | |
302 | if (fe->value == VKEY_UP) { | 302 | if (fe->value == VKEY_UP) { | |
303 | if (pPriv->bmask & bmask) { | 303 | if (pPriv->bmask & bmask) { | |
304 | type = ButtonRelease; | 304 | type = ButtonRelease; | |
305 | pPriv->bmask &= ~bmask; | 305 | pPriv->bmask &= ~bmask; | |
306 | } else { | 306 | } else { | |
307 | return; | 307 | return; | |
308 | } | 308 | } | |
309 | } else { | 309 | } else { | |
310 | if ((pPriv->bmask & bmask) == 0) { | 310 | if ((pPriv->bmask & bmask) == 0) { | |
311 | type = ButtonPress; | 311 | type = ButtonPress; | |
312 | pPriv->bmask |= bmask; | 312 | pPriv->bmask |= bmask; | |
313 | } else { | 313 | } else { | |
314 | return; | 314 | return; | |
315 | } | 315 | } | |
316 | } | 316 | } | |
317 | if (buttons == Button1 || buttons == Button3) { | 317 | if (buttons == Button1 || buttons == Button3) { | |
318 | /* Handle middle button emulation */ | 318 | /* Handle middle button emulation */ | |
319 | Emulate3ButtonsQueueEvent(&pPriv->emu3btn, type, buttons, pPriv->bmask); | 319 | Emulate3ButtonsQueueEvent(&pPriv->emu3btn, type, buttons, pPriv->bmask); | |
320 | } else { | 320 | } else { | |
321 | flag = POINTER_RELATIVE; | 321 | flag = POINTER_RELATIVE; | |
322 | valuator_mask_zero(&mask); | 322 | valuator_mask_zero(&mask); | |
323 | QueuePointerEvents(device, type, buttons, flag, &mask); | 323 | QueuePointerEvents(device, type, buttons, flag, &mask); | |
324 | } | 324 | } | |
325 | break; | 325 | break; | |
326 | case LOC_X_DELTA: | 326 | case LOC_X_DELTA: | |
327 | valuators[0] = fe->value; | 327 | valuators[0] = fe->value; | |
328 | valuators[1] = 0; | 328 | valuators[1] = 0; | |
329 | valuator_mask_set_range(&mask, 0, 2, valuators); | 329 | valuator_mask_set_range(&mask, 0, 2, valuators); | |
330 | flag = POINTER_RELATIVE | POINTER_ACCELERATE; | 330 | flag = POINTER_RELATIVE | POINTER_ACCELERATE; | |
331 | QueuePointerEvents(device, MotionNotify, 0, flag, &mask); | 331 | QueuePointerEvents(device, MotionNotify, 0, flag, &mask); | |
332 | break; | 332 | break; | |
333 | case LOC_Y_DELTA: | 333 | case LOC_Y_DELTA: | |
334 | /* | 334 | /* | |
335 | * For some reason, motion up generates a positive y delta | 335 | * For some reason, motion up generates a positive y delta | |
336 | * and motion down a negative delta, so we must subtract | 336 | * and motion down a negative delta, so we must subtract | |
337 | * here instead of add... | 337 | * here instead of add... | |
338 | */ | 338 | */ | |
339 | valuators[0] = 0; | 339 | valuators[0] = 0; | |
340 | valuators[1] = -fe->value; | 340 | valuators[1] = -fe->value; | |
341 | valuator_mask_set_range(&mask, 0, 2, valuators); | 341 | valuator_mask_set_range(&mask, 0, 2, valuators); | |
342 | flag = POINTER_RELATIVE | POINTER_ACCELERATE; | 342 | flag = POINTER_RELATIVE | POINTER_ACCELERATE; | |
343 | QueuePointerEvents(device, MotionNotify, 0, flag, &mask); | 343 | QueuePointerEvents(device, MotionNotify, 0, flag, &mask); | |
344 | break; | 344 | break; | |
345 | case LOC_X_ABSOLUTE: | 345 | case LOC_X_ABSOLUTE: | |
346 | case LOC_Y_ABSOLUTE: | 346 | case LOC_Y_ABSOLUTE: | |
347 | /* XXX not sure how to get current X and Y position */ | 347 | /* XXX not sure how to get current X and Y position */ | |
348 | default: | 348 | default: | |
349 | FatalError ("%s: unrecognized id\n", __func__); | 349 | FatalError ("%s: unrecognized id\n", __func__); | |
350 | break; | 350 | break; | |
351 | } | 351 | } | |
352 | } | 352 | } | |
353 | 353 | |||
354 | /*ARGSUSED*/ | 354 | /*ARGSUSED*/ | |
355 | static Bool | 355 | static Bool | |
356 | x68kCursorOffScreen(ScreenPtr *pScreen, int *x, int *y) | 356 | x68kCursorOffScreen(ScreenPtr *pScreen, int *x, int *y) | |
357 | { | 357 | { | |
358 | return FALSE; | 358 | return FALSE; | |
359 | } | 359 | } | |
360 | 360 | |||
361 | static void | 361 | static void | |
362 | x68kCrossScreen(ScreenPtr pScreen, int entering) | 362 | x68kCrossScreen(ScreenPtr pScreen, int entering) | |
363 | { | 363 | { | |
364 | } | 364 | } | |
365 | 365 | |||
366 | static void | 366 | static void | |
367 | x68kWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) | 367 | x68kWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) | |
368 | { | 368 | { | |
369 | sigset_t newsigmask; | 369 | sigset_t newsigmask; | |
370 | 370 | |||
371 | (void) sigemptyset (&newsigmask); | 371 | (void) sigemptyset (&newsigmask); | |
372 | (void) sigaddset (&newsigmask, SIGIO); | 372 | (void) sigaddset (&newsigmask, SIGIO); | |
373 | (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL); | 373 | (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL); | |
374 | miPointerWarpCursor (pDev, pScreen, x, y); | 374 | miPointerWarpCursor (pDev, pScreen, x, y); | |
375 | (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL); | 375 | (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL); | |
376 | } | 376 | } | |
377 | 377 | |||
378 | /* EOF x68kMouse.c */ | 378 | /* EOF x68kMouse.c */ |
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c 2020/11/04 17:16:13 1.10
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c 2021/03/11 12:08:57 1.11
@@ -1,411 +1,411 @@ | @@ -1,411 +1,411 @@ | |||
1 | /* $NetBSD: x68kKbd.c,v 1.10 2020/11/04 17:16:13 tsutsui Exp $ */ | 1 | /* $NetBSD: x68kKbd.c,v 1.11 2021/03/11 12:08:57 tsutsui Exp $ */ | |
2 | /*------------------------------------------------------------------------- | 2 | /*------------------------------------------------------------------------- | |
3 | * Copyright (c) 1996 Yasushi Yamasaki | 3 | * Copyright (c) 1996 Yasushi Yamasaki | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. 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 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | *-----------------------------------------------------------------------*/ | 25 | *-----------------------------------------------------------------------*/ | |
26 | 26 | |||
27 | /*- | 27 | /*- | |
28 | * Copyright (c) 1987 by the Regents of the University of California | 28 | * Copyright (c) 1987 by the Regents of the University of California | |
29 | * | 29 | * | |
30 | * Permission to use, copy, modify, and distribute this | 30 | * Permission to use, copy, modify, and distribute this | |
31 | * software and its documentation for any purpose and without | 31 | * software and its documentation for any purpose and without | |
32 | * fee is hereby granted, provided that the above copyright | 32 | * fee is hereby granted, provided that the above copyright | |
33 | * notice appear in all copies. The University of California | 33 | * notice appear in all copies. The University of California | |
34 | * makes no representations about the suitability of this | 34 | * makes no representations about the suitability of this | |
35 | * software for any purpose. It is provided "as is" without | 35 | * software for any purpose. It is provided "as is" without | |
36 | * express or implied warranty. | 36 | * express or implied warranty. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /************************************************************ | 39 | /************************************************************ | |
40 | Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. | 40 | Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. | |
41 | 41 | |||
42 | All Rights Reserved | 42 | All Rights Reserved | |
43 | 43 | |||
44 | Permission to use, copy, modify, and distribute this | 44 | Permission to use, copy, modify, and distribute this | |
45 | software and its documentation for any purpose and without | 45 | software and its documentation for any purpose and without | |
46 | fee is hereby granted, provided that the above copyright no- | 46 | fee is hereby granted, provided that the above copyright no- | |
47 | tice appear in all copies and that both that copyright no- | 47 | tice appear in all copies and that both that copyright no- | |
48 | tice and this permission notice appear in supporting docu- | 48 | tice and this permission notice appear in supporting docu- | |
49 | mentation, and that the names of Sun or X Consortium | 49 | mentation, and that the names of Sun or X Consortium | |
50 | not be used in advertising or publicity pertaining to | 50 | not be used in advertising or publicity pertaining to | |
51 | distribution of the software without specific prior | 51 | distribution of the software without specific prior | |
52 | written permission. Sun and X Consortium make no | 52 | written permission. Sun and X Consortium make no | |
53 | representations about the suitability of this software for | 53 | representations about the suitability of this software for | |
54 | any purpose. It is provided "as is" without any express or | 54 | any purpose. It is provided "as is" without any express or | |
55 | implied warranty. | 55 | implied warranty. | |
56 | 56 | |||
57 | SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | 57 | SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
58 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | 58 | INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- | |
59 | NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- | 59 | NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- | |
60 | ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | 60 | ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
61 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | 61 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | |
62 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | 62 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
63 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | 63 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH | |
64 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | 64 | THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
65 | 65 | |||
66 | ********************************************************/ | 66 | ********************************************************/ | |
67 | 67 | |||
68 | #include "x68k.h" | 68 | #include "x68k.h" | |
69 | #include "mi.h" | 69 | #include "mi.h" | |
70 | 70 | |||
71 | #include <X11/X.h> | 71 | #include <X11/X.h> | |
72 | #include <X11/Xproto.h> | 72 | #include <X11/Xproto.h> | |
73 | #include <X11/keysym.h> | 73 | #include <X11/keysym.h> | |
74 | #include "screenint.h" | 74 | #include "screenint.h" | |
75 | #include "inputstr.h" | 75 | #include "inputstr.h" | |
76 | #include "eventstr.h" | 76 | #include "eventstr.h" | |
77 | #include "misc.h" | 77 | #include "misc.h" | |
78 | #include "scrnintstr.h" | 78 | #include "scrnintstr.h" | |
79 | #include "servermd.h" | 79 | #include "servermd.h" | |
80 | 80 | |||
81 | #include <X11/extensions/XKB.h> | 81 | #include <X11/extensions/XKB.h> | |
82 | #include "xkbsrv.h" | 82 | #include "xkbsrv.h" | |
83 | 83 | |||
84 | #define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */ | 84 | #define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */ | |
85 | #define MAX_KEYCODE 255 /* limited by the protocol */ | 85 | #define MAX_KEYCODE 255 /* limited by the protocol */ | |
86 | 86 | |||
87 | X68kKbdPriv x68kKbdPriv; | 87 | X68kKbdPriv x68kKbdPriv; | |
88 | DeviceIntPtr x68kKeyboardDevice = NULL; | 88 | DeviceIntPtr x68kKeyboardDevice = NULL; | |
89 | 89 | |||
90 | static void x68kKbdHandlerNotify(int, int, void *); | 90 | static void x68kKbdHandlerNotify(int, int, void *); | |
91 | static void x68kInitModMap(KeySymsRec *, CARD8 *); | 91 | static void x68kInitModMap(KeySymsRec *, CARD8 *); | |
92 | static void x68kInitKbdNames(XkbRMLVOSet *, X68kKbdPrivPtr); | 92 | static void x68kInitKbdNames(XkbRMLVOSet *, X68kKbdPrivPtr); | |
93 | static void x68kKbdRingBell(DeviceIntPtr, int, int); | 93 | static void x68kKbdRingBell(DeviceIntPtr, int, int); | |
94 | static void x68kKbdBell(int, DeviceIntPtr, void *, int); | 94 | static void x68kKbdBell(int, DeviceIntPtr, void *, int); | |
95 | static void x68kKbdCtrl(DeviceIntPtr, KeybdCtrl *); | 95 | static void x68kKbdCtrl(DeviceIntPtr, KeybdCtrl *); | |
96 | static void x68kSetLeds(X68kKbdPrivPtr, uint8_t); | 96 | static void x68kSetLeds(X68kKbdPrivPtr, uint8_t); | |
97 | 97 | |||
98 | static void | 98 | static void | |
99 | x68kKbdHandlerNotify(int fd __unused, int ready __unused, void *data __unused) | 99 | x68kKbdHandlerNotify(int fd __unused, int ready __unused, void *data __unused) | |
100 | { | 100 | { | |
101 | } | 101 | } | |
102 | 102 | |||
103 | /*------------------------------------------------------------------------ | 103 | /*------------------------------------------------------------------------ | |
104 | * x68kKbdProc -- | 104 | * x68kKbdProc -- | |
105 | * Handle the initialization, etc. of a keyboard. | 105 | * Handle the initialization, etc. of a keyboard. | |
106 | * | 106 | * | |
107 | * Results: | 107 | * Results: | |
108 | * None. | 108 | * None. | |
109 | * | 109 | * | |
110 | *----------------------------------------------------------------------*/ | 110 | *----------------------------------------------------------------------*/ | |
111 | int | 111 | int | |
112 | x68kKbdProc(DeviceIntPtr pDev, /* Keyboard to manipulate */ | 112 | x68kKbdProc(DeviceIntPtr pDev, /* Keyboard to manipulate */ | |
113 | int what) /* What to do to it */ | 113 | int what) /* What to do to it */ | |
114 | { | 114 | { | |
115 | DevicePtr pKeyboard = &pDev->public; | 115 | DevicePtr pKeyboard = &pDev->public; | |
116 | CARD8 x68kModMap[MAP_LENGTH]; | 116 | CARD8 x68kModMap[MAP_LENGTH]; | |
117 | int mode; | 117 | int mode; | |
118 | XkbRMLVOSet rmlvo; | 118 | XkbRMLVOSet rmlvo; | |
119 | 119 | |||
120 | switch (what) { | 120 | switch (what) { | |
121 | case DEVICE_INIT: | 121 | case DEVICE_INIT: | |
122 | pKeyboard->devicePrivate = (void *)&x68kKbdPriv; | 122 | pKeyboard->devicePrivate = (void *)&x68kKbdPriv; | |
123 | if( (x68kKbdPriv.fd = open("/dev/kbd", O_RDONLY)) == -1 ) { | 123 | if( (x68kKbdPriv.fd = open("/dev/kbd", O_RDONLY)) == -1 ) { | |
124 | ErrorF("Can't open keyboard device"); | 124 | ErrorF("Can't open keyboard device\n"); | |
125 | return !Success; | 125 | return !Success; | |
126 | } | 126 | } | |
127 | pKeyboard->on = FALSE; | 127 | pKeyboard->on = FALSE; | |
128 | x68kInitModMap(x68kKeySyms, x68kModMap); | 128 | x68kInitModMap(x68kKeySyms, x68kModMap); | |
129 | 129 | |||
130 | x68kInitKbdNames(&rmlvo, pKeyboard->devicePrivate); | 130 | x68kInitKbdNames(&rmlvo, pKeyboard->devicePrivate); | |
131 | #if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */ | 131 | #if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */ | |
132 | InitKeyboardDeviceStruct(pDev, &rmlvo, | 132 | InitKeyboardDeviceStruct(pDev, &rmlvo, | |
133 | x68kKbdBell, x68kKbdCtrl); | 133 | x68kKbdBell, x68kKbdCtrl); | |
134 | #else | 134 | #else | |
135 | InitKeyboardDeviceStruct(pDev, NULL, | 135 | InitKeyboardDeviceStruct(pDev, NULL, | |
136 | x68kKbdBell, x68kKbdCtrl); | 136 | x68kKbdBell, x68kKbdCtrl); | |
137 | XkbApplyMappingChange(pDev, x68kKeySyms, | 137 | XkbApplyMappingChange(pDev, x68kKeySyms, | |
138 | x68kKeySyms->minKeyCode, | 138 | x68kKeySyms->minKeyCode, | |
139 | x68kKeySyms->maxKeyCode - x68kKeySyms->minKeyCode + 1, | 139 | x68kKeySyms->maxKeyCode - x68kKeySyms->minKeyCode + 1, | |
140 | x68kModMap, serverClient); | 140 | x68kModMap, serverClient); | |
141 | #endif | 141 | #endif | |
142 | break; | 142 | break; | |
143 | 143 | |||
144 | case DEVICE_ON: | 144 | case DEVICE_ON: | |
145 | mode = 1; | 145 | mode = 1; | |
146 | if ( fcntl(x68kKbdPriv.fd, F_SETOWN, getpid()) == -1 || | 146 | if ( fcntl(x68kKbdPriv.fd, F_SETOWN, getpid()) == -1 || | |
147 | fcntl(x68kKbdPriv.fd, F_SETFL, O_NONBLOCK|O_ASYNC) == -1 || | 147 | fcntl(x68kKbdPriv.fd, F_SETFL, O_NONBLOCK|O_ASYNC) == -1 || | |
148 | ioctl(x68kKbdPriv.fd, KIOCSDIRECT, &mode) == -1 ) { | 148 | ioctl(x68kKbdPriv.fd, KIOCSDIRECT, &mode) == -1 ) { | |
149 | ErrorF("Async keyboard I/O failed"); | 149 | ErrorF("Async keyboard I/O failed\n"); | |
150 | return !Success; | 150 | return !Success; | |
151 | } | 151 | } | |
152 | x68kSetLeds(&x68kKbdPriv, (uint8_t)x68kKbdPriv.leds); | 152 | x68kSetLeds(&x68kKbdPriv, (uint8_t)x68kKbdPriv.leds); | |
153 | SetNotifyFd(x68kKbdPriv.fd, x68kKbdHandlerNotify, | 153 | SetNotifyFd(x68kKbdPriv.fd, x68kKbdHandlerNotify, | |
154 | X_NOTIFY_READ, NULL); | 154 | X_NOTIFY_READ, NULL); | |
155 | pKeyboard->on = TRUE; | 155 | pKeyboard->on = TRUE; | |
156 | break; | 156 | break; | |
157 | 157 | |||
158 | case DEVICE_CLOSE: | 158 | case DEVICE_CLOSE: | |
159 | case DEVICE_OFF: | 159 | case DEVICE_OFF: | |
160 | RemoveNotifyFd(x68kKbdPriv.fd); | 160 | RemoveNotifyFd(x68kKbdPriv.fd); | |
161 | pKeyboard->on = FALSE; | 161 | pKeyboard->on = FALSE; | |
162 | break; | 162 | break; | |
163 | default: | 163 | default: | |
164 | FatalError("Unknown keyboard operation\n"); | 164 | FatalError("Unknown keyboard operation\n"); | |
165 | } | 165 | } | |
166 | return Success; | 166 | return Success; | |
167 | } | 167 | } | |
168 | 168 | |||
169 | /*------------------------------------------------------------------------- | 169 | /*------------------------------------------------------------------------- | |
170 | * function "x68kInitModMap" | 170 | * function "x68kInitModMap" | |
171 | * | 171 | * | |
172 | * purpose: initialize modmap with keysym table | 172 | * purpose: initialize modmap with keysym table | |
173 | * argument: (KeySymsRec *)x68kKeySyms : keysym table | 173 | * argument: (KeySymsRec *)x68kKeySyms : keysym table | |
174 | * (CARD8 *)x68kModMap : result | 174 | * (CARD8 *)x68kModMap : result | |
175 | * returns: nothing | 175 | * returns: nothing | |
176 | *-----------------------------------------------------------------------*/ | 176 | *-----------------------------------------------------------------------*/ | |
177 | static void | 177 | static void | |
178 | x68kInitModMap(KeySymsRec *KeySyms, CARD8 *x68kModMap) | 178 | x68kInitModMap(KeySymsRec *KeySyms, CARD8 *x68kModMap) | |
179 | { | 179 | { | |
180 | int i; | 180 | int i; | |
181 | 181 | |||
182 | for (i = 0; i < MAP_LENGTH; i++) | 182 | for (i = 0; i < MAP_LENGTH; i++) | |
183 | x68kModMap[i] = NoSymbol; | 183 | x68kModMap[i] = NoSymbol; | |
184 | if (KeySyms->minKeyCode < MIN_KEYCODE) { | 184 | if (KeySyms->minKeyCode < MIN_KEYCODE) { | |
185 | KeySyms->minKeyCode += MIN_KEYCODE; | 185 | KeySyms->minKeyCode += MIN_KEYCODE; | |
186 | KeySyms->maxKeyCode += MIN_KEYCODE; | 186 | KeySyms->maxKeyCode += MIN_KEYCODE; | |
187 | } | 187 | } | |
188 | if (KeySyms->maxKeyCode > MAX_KEYCODE) | 188 | if (KeySyms->maxKeyCode > MAX_KEYCODE) | |
189 | KeySyms->maxKeyCode = MAX_KEYCODE; | 189 | KeySyms->maxKeyCode = MAX_KEYCODE; | |
190 | for (i = KeySyms->minKeyCode; | 190 | for (i = KeySyms->minKeyCode; | |
191 | i < KeySyms->maxKeyCode; i++) { | 191 | i < KeySyms->maxKeyCode; i++) { | |
192 | switch (KeySyms->map[(i-KeySyms->minKeyCode)*4]) { | 192 | switch (KeySyms->map[(i-KeySyms->minKeyCode)*4]) { | |
193 | case XK_Shift_L: | 193 | case XK_Shift_L: | |
194 | case XK_Shift_R: | 194 | case XK_Shift_R: | |
195 | x68kModMap[i] = ShiftMask; | 195 | x68kModMap[i] = ShiftMask; | |
196 | break; | 196 | break; | |
197 | case XK_Control_L: | 197 | case XK_Control_L: | |
198 | case XK_Control_R: | 198 | case XK_Control_R: | |
199 | x68kModMap[i] = ControlMask; | 199 | x68kModMap[i] = ControlMask; | |
200 | break; | 200 | break; | |
201 | case XK_Alt_L: | 201 | case XK_Alt_L: | |
202 | case XK_Alt_R: | 202 | case XK_Alt_R: | |
203 | x68kModMap[i] = Mod1Mask; | 203 | x68kModMap[i] = Mod1Mask; | |
204 | break; | 204 | break; | |
205 | case XK_Meta_L: | 205 | case XK_Meta_L: | |
206 | case XK_Meta_R: | 206 | case XK_Meta_R: | |
207 | x68kModMap[i] = Mod2Mask; | 207 | x68kModMap[i] = Mod2Mask; | |
208 | break; | 208 | break; | |
209 | case XK_Caps_Lock: | 209 | case XK_Caps_Lock: | |
210 | x68kModMap[i] = LockMask; | 210 | x68kModMap[i] = LockMask; | |
211 | break; | 211 | break; | |
212 | } | 212 | } | |
213 | } | 213 | } | |
214 | } | 214 | } | |
215 | 215 | |||
216 | /*------------------------------------------------------------------------- | 216 | /*------------------------------------------------------------------------- | |
217 | * function "x68kInitKbdNames" | 217 | * function "x68kInitKbdNames" | |
218 | * | 218 | * | |
219 | * purpose: store xkb database names | 219 | * purpose: store xkb database names | |
220 | * argument: (XkbRMLVOSet *)rmlvo | 220 | * argument: (XkbRMLVOSet *)rmlvo | |
221 | * (X68kKbdPrivPtr)pKbd | 221 | * (X68kKbdPrivPtr)pKbd | |
222 | * returns: nothing | 222 | * returns: nothing | |
223 | *-----------------------------------------------------------------------*/ | 223 | *-----------------------------------------------------------------------*/ | |
224 | static void | 224 | static void | |
225 | x68kInitKbdNames(XkbRMLVOSet *rmlvo, X68kKbdPrivPtr pKbd) | 225 | x68kInitKbdNames(XkbRMLVOSet *rmlvo, X68kKbdPrivPtr pKbd) | |
226 | { | 226 | { | |
227 | #if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */ | 227 | #if 0 /* XXX How should we setup XKB maps for non PS/2 keyboard!? */ | |
228 | rmlvo->rules = "base"; | 228 | rmlvo->rules = "base"; | |
229 | rmlvo->model = "x68k"; | 229 | rmlvo->model = "x68k"; | |
230 | switch (pKbd->type) { | 230 | switch (pKbd->type) { | |
231 | case X68K_KB_STANDARD: | 231 | case X68K_KB_STANDARD: | |
232 | rmlvo->layout = "jp(standard)"; | 232 | rmlvo->layout = "jp(standard)"; | |
233 | break; | 233 | break; | |
234 | case X68K_KB_ASCII: | 234 | case X68K_KB_ASCII: | |
235 | rmlvo->layout = "jp(ascii)"; | 235 | rmlvo->layout = "jp(ascii)"; | |
236 | break; | 236 | break; | |
237 | } | 237 | } | |
238 | rmlvo->variant = "basic"; | 238 | rmlvo->variant = "basic"; | |
239 | rmlvo->options = ""; | 239 | rmlvo->options = ""; | |
240 | #else | 240 | #else | |
241 | rmlvo->rules = "base"; | 241 | rmlvo->rules = "base"; | |
242 | rmlvo->model = NULL; | 242 | rmlvo->model = NULL; | |
243 | rmlvo->layout = NULL; | 243 | rmlvo->layout = NULL; | |
244 | rmlvo->variant = NULL; | 244 | rmlvo->variant = NULL; | |
245 | rmlvo->options = NULL; | 245 | rmlvo->options = NULL; | |
246 | #endif | 246 | #endif | |
247 | } | 247 | } | |
248 | 248 | |||
249 | /*- | 249 | /*- | |
250 | *----------------------------------------------------------------------- | 250 | *----------------------------------------------------------------------- | |
251 | * x68kKbdGetEvents -- | 251 | * x68kKbdGetEvents -- | |
252 | * Return the events waiting in the wings for the given keyboard. | 252 | * Return the events waiting in the wings for the given keyboard. | |
253 | * | 253 | * | |
254 | * Results: | 254 | * Results: | |
255 | * A pointer to an array of Firm_events or (Firm_event *)0 if no events | 255 | * A pointer to an array of Firm_events or (Firm_event *)0 if no events | |
256 | * The number of events contained in the array. | 256 | * The number of events contained in the array. | |
257 | * A boolean as to whether more events might be available. | 257 | * A boolean as to whether more events might be available. | |
258 | * | 258 | * | |
259 | * Side Effects: | 259 | * Side Effects: | |
260 | * None. | 260 | * None. | |
261 | *----------------------------------------------------------------------- | 261 | *----------------------------------------------------------------------- | |
262 | */ | 262 | */ | |
263 | Firm_event * | 263 | Firm_event * | |
264 | x68kKbdGetEvents(int fd, int *pNumEvents, Bool *pAgain) | 264 | x68kKbdGetEvents(int fd, int *pNumEvents, Bool *pAgain) | |
265 | { | 265 | { | |
266 | int nBytes; /* number of bytes of events available. */ | 266 | int nBytes; /* number of bytes of events available. */ | |
267 | static Firm_event evBuf[X68K_MAXEVENTS]; /* Buffer for Firm_events */ | 267 | static Firm_event evBuf[X68K_MAXEVENTS]; /* Buffer for Firm_events */ | |
268 | 268 | |||
269 | if ((nBytes = read (fd, evBuf, sizeof(evBuf))) == -1) { | 269 | if ((nBytes = read (fd, evBuf, sizeof(evBuf))) == -1) { | |
270 | if (errno == EWOULDBLOCK) { | 270 | if (errno == EWOULDBLOCK) { | |
271 | *pNumEvents = 0; | 271 | *pNumEvents = 0; | |
272 | *pAgain = FALSE; | 272 | *pAgain = FALSE; | |
273 | } else { | 273 | } else { | |
274 | ErrorF("Reading keyboard"); | 274 | ErrorF("Reading keyboard\n"); | |
275 | FatalError ("Could not read the keyboard"); | 275 | FatalError ("Could not read the keyboard"); | |
276 | } | 276 | } | |
277 | } else { | 277 | } else { | |
278 | *pNumEvents = nBytes / sizeof (Firm_event); | 278 | *pNumEvents = nBytes / sizeof (Firm_event); | |
279 | *pAgain = (nBytes == sizeof (evBuf)); | 279 | *pAgain = (nBytes == sizeof (evBuf)); | |
280 | } | 280 | } | |
281 | return evBuf; | 281 | return evBuf; | |
282 | } | 282 | } | |
283 | 283 | |||
284 | /*- | 284 | /*- | |
285 | *----------------------------------------------------------------------- | 285 | *----------------------------------------------------------------------- | |
286 | * x68kKbdEnqueueEvent -- | 286 | * x68kKbdEnqueueEvent -- | |
287 | * | 287 | * | |
288 | *----------------------------------------------------------------------- | 288 | *----------------------------------------------------------------------- | |
289 | */ | 289 | */ | |
290 | void | 290 | void | |
291 | x68kKbdEnqueueEvent(DeviceIntPtr pDev, Firm_event *fe) | 291 | x68kKbdEnqueueEvent(DeviceIntPtr pDev, Firm_event *fe) | |
292 | { | 292 | { | |
293 | BYTE keycode; | 293 | BYTE keycode; | |
294 | int type; | 294 | int type; | |
295 | 295 | |||
296 | type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress); | 296 | type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress); | |
297 | keycode = (fe->id & 0x7f) + MIN_KEYCODE; | 297 | keycode = (fe->id & 0x7f) + MIN_KEYCODE; | |
298 | QueueKeyboardEvents(pDev, type, keycode); | 298 | QueueKeyboardEvents(pDev, type, keycode); | |
299 | } | 299 | } | |
300 | 300 | |||
301 | /*- | 301 | /*- | |
302 | *----------------------------------------------------------------------- | 302 | *----------------------------------------------------------------------- | |
303 | * x68kKbdBell -- | 303 | * x68kKbdBell -- | |
304 | * Ring the terminal/keyboard bell | 304 | * Ring the terminal/keyboard bell | |
305 | * | 305 | * | |
306 | * Results: | 306 | * Results: | |
307 | * Ring the keyboard bell for an amount of time proportional to | 307 | * Ring the keyboard bell for an amount of time proportional to | |
308 | * "loudness." | 308 | * "loudness." | |
309 | * | 309 | * | |
310 | * Side Effects: | 310 | * Side Effects: | |
311 | * None, really... | 311 | * None, really... | |
312 | * | 312 | * | |
313 | *----------------------------------------------------------------------- | 313 | *----------------------------------------------------------------------- | |
314 | */ | 314 | */ | |
315 | 315 | |||
316 | static void | 316 | static void | |
317 | x68kKbdRingBell(DeviceIntPtr pDev, int volume, int duration) | 317 | x68kKbdRingBell(DeviceIntPtr pDev, int volume, int duration) | |
318 | { | 318 | { | |
319 | int kbdCmd; /* Command to give keyboard */ | 319 | int kbdCmd; /* Command to give keyboard */ | |
320 | X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate; | 320 | X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate; | |
321 | 321 | |||
322 | if (volume == 0) | 322 | if (volume == 0) | |
323 | return; | 323 | return; | |
324 | 324 | |||
325 | kbdCmd = KBD_CMD_BELL; | 325 | kbdCmd = KBD_CMD_BELL; | |
326 | if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) { | 326 | if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) { | |
327 | ErrorF("Failed to activate bell"); | 327 | ErrorF("Failed to activate bell\n"); | |
328 | return; | 328 | return; | |
329 | } | 329 | } | |
330 | usleep (duration * 1000); | 330 | usleep (duration * 1000); | |
331 | kbdCmd = KBD_CMD_NOBELL; | 331 | kbdCmd = KBD_CMD_NOBELL; | |
332 | if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) | 332 | if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) | |
333 | ErrorF("Failed to deactivate bell"); | 333 | ErrorF("Failed to deactivate bell\n"); | |
334 | } | 334 | } | |
335 | 335 | |||
336 | static void | 336 | static void | |
337 | x68kKbdBell(int volume, DeviceIntPtr pDev, void *ctrl, int unused) | 337 | x68kKbdBell(int volume, DeviceIntPtr pDev, void *ctrl, int unused) | |
338 | { | 338 | { | |
339 | KeybdCtrl* kctrl = (KeybdCtrl*) ctrl; | 339 | KeybdCtrl* kctrl = (KeybdCtrl*) ctrl; | |
340 | 340 | |||
341 | if (kctrl->bell == 0) | 341 | if (kctrl->bell == 0) | |
342 | return; | 342 | return; | |
343 | 343 | |||
344 | x68kKbdRingBell(pDev, volume, kctrl->bell_duration); | 344 | x68kKbdRingBell(pDev, volume, kctrl->bell_duration); | |
345 | } | 345 | } | |
346 | 346 | |||
347 | void | 347 | void | |
348 | DDXRingBell(int volume, int pitch, int duration) | 348 | DDXRingBell(int volume, int pitch, int duration) | |
349 | { | 349 | { | |
350 | DeviceIntPtr pKeyboard; | 350 | DeviceIntPtr pKeyboard; | |
351 | 351 | |||
352 | pKeyboard = x68kKeyboardDevice; | 352 | pKeyboard = x68kKeyboardDevice; | |
353 | if (pKeyboard != NULL) | 353 | if (pKeyboard != NULL) | |
354 | x68kKbdRingBell(pKeyboard, volume, duration); | 354 | x68kKbdRingBell(pKeyboard, volume, duration); | |
355 | } | 355 | } | |
356 | 356 | |||
357 | /*- | 357 | /*- | |
358 | *----------------------------------------------------------------------- | 358 | *----------------------------------------------------------------------- | |
359 | * x68kKbdCtrl -- | 359 | * x68kKbdCtrl -- | |
360 | * Alter some of the keyboard control parameters | 360 | * Alter some of the keyboard control parameters | |
361 | * | 361 | * | |
362 | * Results: | 362 | * Results: | |
363 | * None. | 363 | * None. | |
364 | * | 364 | * | |
365 | * Side Effects: | 365 | * Side Effects: | |
366 | * Some... | 366 | * Some... | |
367 | * | 367 | * | |
368 | *----------------------------------------------------------------------- | 368 | *----------------------------------------------------------------------- | |
369 | */ | 369 | */ | |
370 | #define XKB_LED_ZENKAKU 0x40 | 370 | #define XKB_LED_ZENKAKU 0x40 | |
371 | #define XKB_LED_HIRAGANA 0x20 | 371 | #define XKB_LED_HIRAGANA 0x20 | |
372 | #define XKB_LED_INSERT 0x10 | 372 | #define XKB_LED_INSERT 0x10 | |
373 | #define XKB_LED_CAPS_LOCK 0x08 | 373 | #define XKB_LED_CAPS_LOCK 0x08 | |
374 | #define XKB_LED_CODE_INPUT 0x04 | 374 | #define XKB_LED_CODE_INPUT 0x04 | |
375 | #define XKB_LED_ROMAJI 0x02 | 375 | #define XKB_LED_ROMAJI 0x02 | |
376 | #define XKB_LED_KANA_LOCK 0x01 | 376 | #define XKB_LED_KANA_LOCK 0x01 | |
377 | 377 | |||
378 | static void | 378 | static void | |
379 | x68kKbdCtrl(DeviceIntPtr pDev, KeybdCtrl *ctrl) | 379 | x68kKbdCtrl(DeviceIntPtr pDev, KeybdCtrl *ctrl) | |
380 | { | 380 | { | |
381 | X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate; | 381 | X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate; | |
382 | 382 | |||
383 | if (pPriv->leds != ctrl->leds) { | 383 | if (pPriv->leds != ctrl->leds) { | |
384 | x68kSetLeds(pPriv, (uint8_t)ctrl->leds); | 384 | x68kSetLeds(pPriv, (uint8_t)ctrl->leds); | |
385 | pPriv->leds = ctrl->leds; | 385 | pPriv->leds = ctrl->leds; | |
386 | } | 386 | } | |
387 | } | 387 | } | |
388 | 388 | |||
389 | /*------------------------------------------------------------------------- | 389 | /*------------------------------------------------------------------------- | |
390 | * function "x68kSetLeds" | 390 | * function "x68kSetLeds" | |
391 | * | 391 | * | |
392 | * purpose: set keyboard leds to specified state | 392 | * purpose: set keyboard leds to specified state | |
393 | * argument: (X68kKbdPrivPtr)pPriv | 393 | * argument: (X68kKbdPrivPtr)pPriv | |
394 | * (uint8_t)data; | 394 | * (uint8_t)data; | |
395 | * returns: nothing | 395 | * returns: nothing | |
396 | *-----------------------------------------------------------------------*/ | 396 | *-----------------------------------------------------------------------*/ | |
397 | static void | 397 | static void | |
398 | x68kSetLeds(X68kKbdPrivPtr pPriv, uint8_t data) | 398 | x68kSetLeds(X68kKbdPrivPtr pPriv, uint8_t data) | |
399 | { | 399 | { | |
400 | /* bit sequence of led indicator in xkb and hardware are same */ | 400 | /* bit sequence of led indicator in xkb and hardware are same */ | |
401 | if (ioctl(pPriv->fd, KIOCSLED, &data) == -1) | 401 | if (ioctl(pPriv->fd, KIOCSLED, &data) == -1) | |
402 | ErrorF("Failed to set keyboard lights"); | 402 | ErrorF("Failed to set keyboard lights\n"); | |
403 | } | 403 | } | |
404 | 404 | |||
405 | Bool | 405 | Bool | |
406 | LegalModifier(unsigned int key, DeviceIntPtr pDev) | 406 | LegalModifier(unsigned int key, DeviceIntPtr pDev) | |
407 | { | 407 | { | |
408 | return TRUE; | 408 | return TRUE; | |
409 | } | 409 | } | |
410 | 410 | |||
411 | /* EOF x68kKbd.c */ | 411 | /* EOF x68kKbd.c */ |
--- xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kText.c 2020/11/04 17:16:13 1.5
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kText.c 2021/03/11 12:08:57 1.6
@@ -1,122 +1,122 @@ | @@ -1,122 +1,122 @@ | |||
1 | /* $NetBSD: x68kText.c,v 1.5 2020/11/04 17:16:13 tsutsui Exp $ */ | 1 | /* $NetBSD: x68kText.c,v 1.6 2021/03/11 12:08:57 tsutsui Exp $ */ | |
2 | /*------------------------------------------------------------------------- | 2 | /*------------------------------------------------------------------------- | |
3 | * Copyright (c) 1996 Yasushi Yamasaki | 3 | * Copyright (c) 1996 Yasushi Yamasaki | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. 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 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | *-----------------------------------------------------------------------*/ | 25 | *-----------------------------------------------------------------------*/ | |
26 | 26 | |||
27 | #include "x68k.h" | 27 | #include "x68k.h" | |
28 | #include "mi.h" | 28 | #include "mi.h" | |
29 | #include "micmap.h" | 29 | #include "micmap.h" | |
30 | #include "fb.h" | 30 | #include "fb.h" | |
31 | #include "os.h" | 31 | #include "os.h" | |
32 | 32 | |||
33 | /*------------------------------------------------------------------------- | 33 | /*------------------------------------------------------------------------- | |
34 | * function "x68kTextOpen" [ X68kFBProc function ] | 34 | * function "x68kTextOpen" [ X68kFBProc function ] | |
35 | * | 35 | * | |
36 | * purpose: call common frame buffer opening procedure | 36 | * purpose: call common frame buffer opening procedure | |
37 | * and enable TVRAM simultaneous access mode | 37 | * and enable TVRAM simultaneous access mode | |
38 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | 38 | * argument: (X68kScreenRec *)pPriv : X68k private screen record | |
39 | * returns: (Bool): TRUE if succeeded | 39 | * returns: (Bool): TRUE if succeeded | |
40 | * FALSE otherwise | 40 | * FALSE otherwise | |
41 | *-----------------------------------------------------------------------*/ | 41 | *-----------------------------------------------------------------------*/ | |
42 | static uint16_t r21; | 42 | static uint16_t r21; | |
43 | static uint16_t tpal0; | 43 | static uint16_t tpal0; | |
44 | static uint16_t tpal15; | 44 | static uint16_t tpal15; | |
45 | 45 | |||
46 | Bool | 46 | Bool | |
47 | x68kTextOpen(X68kScreenRec *pPriv) | 47 | x68kTextOpen(X68kScreenRec *pPriv) | |
48 | { | 48 | { | |
49 | if( !x68kFbCommonOpen(pPriv, "/dev/grf0") ) | 49 | if( !x68kFbCommonOpen(pPriv, "/dev/grf0") ) | |
50 | return FALSE; | 50 | return FALSE; | |
51 | 51 | |||
52 | /* enable TVRAM simultaneous access mode */ | 52 | /* enable TVRAM simultaneous access mode */ | |
53 | r21 = pPriv->reg->crtc.r21; | 53 | r21 = pPriv->reg->crtc.r21; | |
54 | pPriv->reg->crtc.r21 = 0x01f0; | 54 | pPriv->reg->crtc.r21 = 0x01f0; | |
55 | 55 | |||
56 | /* initialize scroll registers */ | 56 | /* initialize scroll registers */ | |
57 | pPriv->reg->crtc.r10 = pPriv->reg->crtc.r11 = 0; | 57 | pPriv->reg->crtc.r10 = pPriv->reg->crtc.r11 = 0; | |
58 | 58 | |||
59 | tpal0 = pPriv->reg->tpal[0]; | 59 | tpal0 = pPriv->reg->tpal[0]; | |
60 | tpal15 = pPriv->reg->tpal[15]; | 60 | tpal15 = pPriv->reg->tpal[15]; | |
61 | 61 | |||
62 | pPriv->reg->tpal[0] = 0; | 62 | pPriv->reg->tpal[0] = 0; | |
63 | pPriv->reg->tpal[15] = 0xFFFE; | 63 | pPriv->reg->tpal[15] = 0xFFFE; | |
64 | 64 | |||
65 | return TRUE; | 65 | return TRUE; | |
66 | } | 66 | } | |
67 | 67 | |||
68 | /*------------------------------------------------------------------------- | 68 | /*------------------------------------------------------------------------- | |
69 | * function "x68kTextClose" [ X68kFBProc function ] | 69 | * function "x68kTextClose" [ X68kFBProc function ] | |
70 | * | 70 | * | |
71 | * purpose: close text frame buffer | 71 | * purpose: close text frame buffer | |
72 | * argument: nothing | 72 | * argument: nothing | |
73 | * returns: nothing | 73 | * returns: nothing | |
74 | *-----------------------------------------------------------------------*/ | 74 | *-----------------------------------------------------------------------*/ | |
75 | void | 75 | void | |
76 | x68kTextClose(X68kScreenRec *pPriv) | 76 | x68kTextClose(X68kScreenRec *pPriv) | |
77 | { | 77 | { | |
78 | pPriv->reg->crtc.r21 = r21; /* recover TVRAM mode */ | 78 | pPriv->reg->crtc.r21 = r21; /* recover TVRAM mode */ | |
79 | pPriv->reg->tpal[0] = tpal0; | 79 | pPriv->reg->tpal[0] = tpal0; | |
80 | pPriv->reg->tpal[15] = tpal15; | 80 | pPriv->reg->tpal[15] = tpal15; | |
81 | x68kFbCommonClose(pPriv); | 81 | x68kFbCommonClose(pPriv); | |
82 | } | 82 | } | |
83 | 83 | |||
84 | /*------------------------------------------------------------------------- | 84 | /*------------------------------------------------------------------------- | |
85 | * function "x68kTextInit" [ called by DIX AddScreen ] | 85 | * function "x68kTextInit" [ called by DIX AddScreen ] | |
86 | * | 86 | * | |
87 | * purpose: initialize text frame buffer | 87 | * purpose: initialize text frame buffer | |
88 | * argument: (ScreenPtr)pScreen : DIX screen record | 88 | * argument: (ScreenPtr)pScreen : DIX screen record | |
89 | * (int)argc, (char **)argv : standard C arguments | 89 | * (int)argc, (char **)argv : standard C arguments | |
90 | * returns: (Bool) TRUE if succeeded | 90 | * returns: (Bool) TRUE if succeeded | |
91 | * FALSE otherwise | 91 | * FALSE otherwise | |
92 | *-----------------------------------------------------------------------*/ | 92 | *-----------------------------------------------------------------------*/ | |
93 | Bool | 93 | Bool | |
94 | x68kTextInit(ScreenPtr pScreen, int argc, char *argv[]) | 94 | x68kTextInit(ScreenPtr pScreen, int argc, char *argv[]) | |
95 | { | 95 | { | |
96 | X68kScreenRec *pPriv; | 96 | X68kScreenRec *pPriv; | |
97 | 97 | |||
98 | /* get private screen record set by X68KConfig */ | 98 | /* get private screen record set by X68KConfig */ | |
99 | pPriv = x68kGetScreenRecByType(X68K_FB_TEXT); | 99 | pPriv = x68kGetScreenRecByType(X68K_FB_TEXT); | |
100 | 100 | |||
101 | if ( !dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, 0) ) { | 101 | if ( !dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, 0) ) { | |
102 | ErrorF("dixRegisterPrivateKey failed"); | 102 | ErrorF("dixRegisterPrivateKey failed\n"); | |
103 | return FALSE; | 103 | return FALSE; | |
104 | } | 104 | } | |
105 | x68kSetScreenPrivate(pScreen, pPriv); | 105 | x68kSetScreenPrivate(pScreen, pPriv); | |
106 | 106 | |||
107 | if ( !fbScreenInit(pScreen, pPriv->fb, | 107 | if ( !fbScreenInit(pScreen, pPriv->fb, | |
108 | pPriv->scr_width, pPriv->scr_height, | 108 | pPriv->scr_width, pPriv->scr_height, | |
109 | pPriv->dpi, pPriv->dpi, pPriv->fb_width, 1) ) | 109 | pPriv->dpi, pPriv->dpi, pPriv->fb_width, 1) ) | |
110 | return FALSE; | 110 | return FALSE; | |
111 | pScreen->whitePixel = 1; | 111 | pScreen->whitePixel = 1; | |
112 | pScreen->blackPixel = 0; | 112 | pScreen->blackPixel = 0; | |
113 | if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) ) | 113 | if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) ) | |
114 | return FALSE; | 114 | return FALSE; | |
115 | if ( !miCreateDefColormap(pScreen) ) | 115 | if ( !miCreateDefColormap(pScreen) ) | |
116 | return FALSE; | 116 | return FALSE; | |
117 | pScreen->SaveScreen = x68kSaveScreen; | 117 | pScreen->SaveScreen = x68kSaveScreen; | |
118 | 118 | |||
119 | return TRUE; | 119 | return TRUE; | |
120 | } | 120 | } | |
121 | 121 | |||
122 | /* EOF x68kText.c */ | 122 | /* EOF x68kText.c */ |