Sat Feb 17 16:17:17 2024 UTC (106d)
Pull up following revision(s) (requested by tsutsui in ticket #596):

	sys/dev/dec/dzkbd.c: revision 1.32
	sys/dev/dec/lk201var.h: revision 1.8
	sys/dev/dec/lk201_ws.c: revision 1.11

Fix a fatal typo that causes dzkbd_cngetc() to stall.

Use proper macro for return values and remove #if 0'ed out block.
Mostly from OpenBSD/vax. No binary changes.


(martin)
diff -r1.30 -r1.30.6.1 src/sys/dev/dec/dzkbd.c
diff -r1.10 -r1.10.50.1 src/sys/dev/dec/lk201_ws.c
diff -r1.7 -r1.7.50.1 src/sys/dev/dec/lk201var.h

cvs diff -r1.30 -r1.30.6.1 src/sys/dev/dec/dzkbd.c (expand / switch to unified diff)

--- src/sys/dev/dec/dzkbd.c 2021/08/07 16:19:10 1.30
+++ src/sys/dev/dec/dzkbd.c 2024/02/17 16:17:17 1.30.6.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dzkbd.c,v 1.30 2021/08/07 16:19:10 thorpej Exp $ */ 1/* $NetBSD: dzkbd.c,v 1.30.6.1 2024/02/17 16:17:17 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This software was developed by the Computer Systems Engineering group 7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley. 9 * contributed to Berkeley.
10 * 10 *
11 * All advertising materials mentioning features or use of this software 11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement: 12 * must display the following acknowledgement:
13 * This product includes software developed by the University of 13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory. 14 * California, Lawrence Berkeley Laboratory.
@@ -35,27 +35,27 @@ @@ -35,27 +35,27 @@
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE. 38 * SUCH DAMAGE.
39 * 39 *
40 * @(#)kbd.c 8.2 (Berkeley) 10/30/93 40 * @(#)kbd.c 8.2 (Berkeley) 10/30/93
41 */ 41 */
42 42
43/* 43/*
44 * LK200/LK400 keyboard attached to line 0 of the DZ*-11 44 * LK200/LK400 keyboard attached to line 0 of the DZ*-11
45 */ 45 */
46 46
47#include <sys/cdefs.h> 47#include <sys/cdefs.h>
48__KERNEL_RCSID(0, "$NetBSD: dzkbd.c,v 1.30 2021/08/07 16:19:10 thorpej Exp $"); 48__KERNEL_RCSID(0, "$NetBSD: dzkbd.c,v 1.30.6.1 2024/02/17 16:17:17 martin Exp $");
49 49
50#include <sys/param.h> 50#include <sys/param.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
52#include <sys/device.h> 52#include <sys/device.h>
53#include <sys/ioctl.h> 53#include <sys/ioctl.h>
54#include <sys/syslog.h> 54#include <sys/syslog.h>
55#include <sys/malloc.h> 55#include <sys/malloc.h>
56#include <sys/intr.h> 56#include <sys/intr.h>
57 57
58#include <dev/wscons/wsconsio.h> 58#include <dev/wscons/wsconsio.h>
59#include <dev/wscons/wskbdvar.h> 59#include <dev/wscons/wskbdvar.h>
60#include <dev/wscons/wsksymdef.h> 60#include <dev/wscons/wsksymdef.h>
61#include <dev/wscons/wsksymvar.h> 61#include <dev/wscons/wsksymvar.h>
@@ -227,27 +227,27 @@ dzkbd_sendchar(void *v, u_char c) @@ -227,27 +227,27 @@ dzkbd_sendchar(void *v, u_char c)
227 dzputc(ls, c); 227 dzputc(ls, c);
228 splx(s); 228 splx(s);
229 return (0); 229 return (0);
230} 230}
231 231
232static void 232static void
233dzkbd_cngetc(void *v, u_int *type, int *data) 233dzkbd_cngetc(void *v, u_int *type, int *data)
234{ 234{
235 struct dzkbd_internal *dzi = v; 235 struct dzkbd_internal *dzi = v;
236 int c; 236 int c;
237 237
238 do { 238 do {
239 c = dzgetc(dzi->dzi_ls); 239 c = dzgetc(dzi->dzi_ls);
240 } while (!lk201_decode(&dzi->dzi_ks, 0, c, type, data) == LKD_NODATA); 240 } while (lk201_decode(&dzi->dzi_ks, 0, c, type, data) == LKD_NODATA);
241} 241}
242 242
243static void 243static void
244dzkbd_cnpollc(void *v, int on) 244dzkbd_cnpollc(void *v, int on)
245{ 245{
246#if 0 246#if 0
247 struct dzkbd_internal *dzi = v; 247 struct dzkbd_internal *dzi = v;
248#endif 248#endif
249} 249}
250 250
251static void 251static void
252dzkbd_set_leds(void *v, int leds) 252dzkbd_set_leds(void *v, int leds)
253{ 253{

cvs diff -r1.10 -r1.10.50.1 src/sys/dev/dec/lk201_ws.c (expand / switch to unified diff)

--- src/sys/dev/dec/lk201_ws.c 2016/07/11 10:55:35 1.10
+++ src/sys/dev/dec/lk201_ws.c 2024/02/17 16:17:17 1.10.50.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lk201_ws.c,v 1.10 2016/07/11 10:55:35 skrll Exp $ */ 1/* $NetBSD: lk201_ws.c,v 1.10.50.1 2024/02/17 16:17:17 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 4 * Copyright (c) 1998
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * 26 *
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: lk201_ws.c,v 1.10 2016/07/11 10:55:35 skrll Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: lk201_ws.c,v 1.10.50.1 2024/02/17 16:17:17 martin Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/callout.h> 34#include <sys/callout.h>
35 35
36#include <dev/wscons/wsconsio.h> 36#include <dev/wscons/wsconsio.h>
37 37
38#include <dev/dec/lk201reg.h> 38#include <dev/dec/lk201reg.h>
39#include <dev/dec/lk201var.h> 39#include <dev/dec/lk201var.h>
40#include <dev/dec/wskbdmap_lk201.h> /* for {MIN,MAX}_LK201_KEY */ 40#include <dev/dec/wskbdmap_lk201.h> /* for {MIN,MAX}_LK201_KEY */
41 41
42#define send(lks, c) ((*((lks)->attmt.sendchar))((lks)->attmt.cookie, c)) 42#define send(lks, c) ((*((lks)->attmt.sendchar))((lks)->attmt.cookie, c))
43 43
@@ -123,92 +123,85 @@ lk201_init(struct lk201_state *lks) @@ -123,92 +123,85 @@ lk201_init(struct lk201_state *lks)
123 123
124int 124int
125lk201_decode(struct lk201_state *lks, int wantmulti, int datain, u_int *type, int *dataout) 125lk201_decode(struct lk201_state *lks, int wantmulti, int datain, u_int *type, int *dataout)
126{ 126{
127 int i, freeslot; 127 int i, freeslot;
128 128
129 if (lks->waitack != 0) { 129 if (lks->waitack != 0) {
130 lks->ackdata = datain; 130 lks->ackdata = datain;
131 lks->waitack = 0; 131 lks->waitack = 0;
132 return LKD_NODATA; 132 return LKD_NODATA;
133 } 133 }
134 134
135 switch (datain) { 135 switch (datain) {
136#if 0 
137 case LK_KEY_UP: 
138 for (i = 0; i < LK_KLL; i++) 
139 lks->down_keys_list[i] = -1; 
140 *type = WSCONS_EVENT_ALL_KEYS_UP; 
141 return (1); 
142#endif 
143 case LK_POWER_UP: 136 case LK_POWER_UP:
144 printf("lk201_decode: powerup detected\n"); 137 printf("lk201_decode: powerup detected\n");
145 lk201_init(lks); 138 lk201_init(lks);
146 return (0); 139 return LKD_NODATA;
147 case LK_KDOWN_ERROR: 140 case LK_KDOWN_ERROR:
148 case LK_POWER_ERROR: 141 case LK_POWER_ERROR:
149 case LK_OUTPUT_ERROR: 142 case LK_OUTPUT_ERROR:
150 case LK_INPUT_ERROR: 143 case LK_INPUT_ERROR:
151 printf("lk201_decode: error %x\n", datain); 144 printf("lk201_decode: error %x\n", datain);
152 /* FALLTHRU */ 145 /* FALLTHRU */
153 case LK_KEY_REPEAT: /* autorepeat handled by wskbd */ 146 case LK_KEY_REPEAT: /* autorepeat handled by wskbd */
154 case LK_MODE_CHANGE: /* ignore silently */ 147 case LK_MODE_CHANGE: /* ignore silently */
155 return (0); 148 return LKD_NODATA;
156 } 149 }
157 150
158 151
159 if (datain == LK_KEY_UP) { 152 if (datain == LK_KEY_UP) {
160 if (wantmulti) { 153 if (wantmulti) {
161 for (i = 0; i < LK_KLL; i++) 154 for (i = 0; i < LK_KLL; i++)
162 if (lks->down_keys_list[i] != -1) { 155 if (lks->down_keys_list[i] != -1) {
163 *type = WSCONS_EVENT_KEY_UP; 156 *type = WSCONS_EVENT_KEY_UP;
164 *dataout = lks->down_keys_list[i] - 157 *dataout = lks->down_keys_list[i] -
165 MIN_LK201_KEY; 158 MIN_LK201_KEY;
166 lks->down_keys_list[i] = -1; 159 lks->down_keys_list[i] = -1;
167 return (LKD_MORE); 160 return LKD_MORE;
168 } 161 }
169 return (LKD_NODATA); 162 return LKD_NODATA;
170 } else { 163 } else {
171 for (i = 0; i < LK_KLL; i++) 164 for (i = 0; i < LK_KLL; i++)
172 lks->down_keys_list[i] = -1; 165 lks->down_keys_list[i] = -1;
173 *type = WSCONS_EVENT_ALL_KEYS_UP; 166 *type = WSCONS_EVENT_ALL_KEYS_UP;
174 return (LKD_COMPLETE); 167 return LKD_COMPLETE;
175 } 168 }
176 } else if (datain < MIN_LK201_KEY || datain > MAX_LK201_KEY) { 169 } else if (datain < MIN_LK201_KEY || datain > MAX_LK201_KEY) {
177 printf("lk201_decode: %x\n", datain); 170 printf("lk201_decode: %x\n", datain);
178 return (0); 171 return LKD_NODATA;
179 } 172 }
180 173
181 *dataout = datain - MIN_LK201_KEY; 174 *dataout = datain - MIN_LK201_KEY;
182 175
183 freeslot = -1; 176 freeslot = -1;
184 for (i = 0; i < LK_KLL; i++) { 177 for (i = 0; i < LK_KLL; i++) {
185 if (lks->down_keys_list[i] == datain) { 178 if (lks->down_keys_list[i] == datain) {
186 *type = WSCONS_EVENT_KEY_UP; 179 *type = WSCONS_EVENT_KEY_UP;
187 lks->down_keys_list[i] = -1; 180 lks->down_keys_list[i] = -1;
188 return (1); 181 return LKD_COMPLETE;
189 } 182 }
190 if (lks->down_keys_list[i] == -1 && freeslot == -1) 183 if (lks->down_keys_list[i] == -1 && freeslot == -1)
191 freeslot = i; 184 freeslot = i;
192 } 185 }
193 186
194 if (freeslot == -1) { 187 if (freeslot == -1) {
195 printf("lk201_decode: down(%d) no free slot\n", datain); 188 printf("lk201_decode: down(%d) no free slot\n", datain);
196 return (0); 189 return LKD_NODATA;
197 } 190 }
198 191
199 *type = WSCONS_EVENT_KEY_DOWN; 192 *type = WSCONS_EVENT_KEY_DOWN;
200 lks->down_keys_list[freeslot] = datain; 193 lks->down_keys_list[freeslot] = datain;
201 return (1); 194 return LKD_COMPLETE;
202} 195}
203 196
204void 197void
205lk201_bell(struct lk201_state *lks, struct wskbd_bell_data *bell) 198lk201_bell(struct lk201_state *lks, struct wskbd_bell_data *bell)
206{ 199{
207 unsigned int vol; 200 unsigned int vol;
208 201
209 if (bell->which & WSKBD_BELL_DOVOLUME) { 202 if (bell->which & WSKBD_BELL_DOVOLUME) {
210 vol = 8 - bell->volume * 8 / 100; 203 vol = 8 - bell->volume * 8 / 100;
211 if (vol > 7) 204 if (vol > 7)
212 vol = 7; 205 vol = 7;
213 } else 206 } else
214 vol = 3; 207 vol = 3;

cvs diff -r1.7 -r1.7.50.1 src/sys/dev/dec/lk201var.h (expand / switch to unified diff)

--- src/sys/dev/dec/lk201var.h 2015/01/02 21:32:26 1.7
+++ src/sys/dev/dec/lk201var.h 2024/02/17 16:17:17 1.7.50.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lk201var.h,v 1.7 2015/01/02 21:32:26 jklos Exp $ */ 1/* $NetBSD: lk201var.h,v 1.7.50.1 2024/02/17 16:17:17 martin Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 4 * Copyright (c) 1998
5 * Matthias Drochner. All rights reserved. 5 * Matthias Drochner. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -44,17 +44,17 @@ struct lk201_state { @@ -44,17 +44,17 @@ struct lk201_state {
44#define LK_KLL 8 44#define LK_KLL 8
45 int down_keys_list[LK_KLL]; 45 int down_keys_list[LK_KLL];
46 int bellvol; 46 int bellvol;
47 int leds_state; 47 int leds_state;
48 int kcvol; 48 int kcvol;
49}; 49};
50 50
51int lk201_init(struct lk201_state *); 51int lk201_init(struct lk201_state *);
52int lk201_decode(struct lk201_state *, int, int, u_int *, int *); 52int lk201_decode(struct lk201_state *, int, int, u_int *, int *);
53void lk201_bell(struct lk201_state *, struct wskbd_bell_data *); 53void lk201_bell(struct lk201_state *, struct wskbd_bell_data *);
54void lk201_set_leds(struct lk201_state *, int); 54void lk201_set_leds(struct lk201_state *, int);
55void lk201_set_keyclick(struct lk201_state *, int); 55void lk201_set_keyclick(struct lk201_state *, int);
56 56
 57/* Values returned by lk201_decode */
57#define LKD_NODATA 0x00 58#define LKD_NODATA 0x00
58#define LKD_COMPLETE 0x01 59#define LKD_COMPLETE 0x01
59#define LKD_MORE 0x02 60#define LKD_MORE 0x02
60