USB keyboard problem
plasma
plasmaball at pchome.com.tw
Fri Sep 26 11:16:19 PDT 2003
Hi all,
I tried to find what the problem is. I add the following patch to
ukbd.c:
[[[
--- /usr/src/sys/dev/usb/ukbd.c.orig Mon Mar 31 08:31:35 2003
+++ /usr/src/sys/dev/usb/ukbd.c Sat Sep 27 01:31:54 2003
@@ -693,6 +693,12 @@
int mod, omod;
int key, c;
int i, j;
+#ifdef USB_DEBUG
+ static int dumped_empty_queue = 1;
+#endif
+#if 1
+ int no, nn;
+#endif
#define ADDKEY1(c) \
if (state->ks_inputs < INPUTBUFSIZE) { \
@@ -728,20 +734,121 @@
? KEY_PRESS : KEY_RELEASE));
}
+#ifdef USB_DEBUG
+ if (ud->keycode[0] || !dumped_empty_queue) {
+ DPRINTF(("before old: "));
+ for (i = 0; i < NKEYCODE; i++) {
+ if (state->ks_odata.keycode[i])
+ DPRINTF(("%d ", state->ks_odata.keycode[i]));
+ }
+ DPRINTF(("\n"));
+ DPRINTF(("before new: "));
+ for (i = 0; i < NKEYCODE; i++) {
+ if (ud->keycode[i])
+ DPRINTF(("%d ", ud->keycode[i]));
+ }
+ DPRINTF(("\n"));
+
+ dumped_empty_queue = (ud->keycode[0]) ? 0 : 1;
+ }
+#endif /* USB_DEBUG */
+
+#if 1
+ /* Calculate length of old and new data */
+ for (no = 0; no < NKEYCODE; no++) {
+ if (!state->ks_odata.keycode[no])
+ break;
+ }
+ for (nn = 0; nn < NKEYCODE; nn++) {
+ if (!ud->keycode[nn])
+ break;
+ }
+
+#ifdef USB_DEBUG
+ if (no != 0 || nn != 0) {
+ DPRINTF(("no: %d, nn: %d\n", no, nn));
+ }
+#endif /* USB_DEBUG */
]]]
Add 'options USB_DEBUG' in kernel config, and build kernel. Do
'sysctl -w hw.usb.ukbd.debug=1' as well. Now I can see what's going
on inside.
A very interesting things show up. Below is a segment of generated
log:
Sep 27 01:37:28 plasmanb /kernel: before old: 12
Sep 27 01:37:28 plasmanb /kernel: before new: 22 12
Sep 27 01:37:28 plasmanb /kernel: no: 0, nn: 1
Sep 27 01:37:28 plasmanb /kernel: 0x16 (22) pressed
Sep 27 01:37:28 plasmanb /kernel: 22 12
Sep 27 01:37:28 plasmanb /kernel: before old: 22 12
Sep 27 01:37:28 plasmanb /kernel: before new: 22 12
Sep 27 01:37:28 plasmanb /kernel: no: 1, nn: 1
Sep 27 01:37:28 plasmanb /kernel: before old: 22 12
Sep 27 01:37:28 plasmanb /kernel: before new: 22
Sep 27 01:37:28 plasmanb /kernel: no: 1, nn: 1
Sep 27 01:37:28 plasmanb /kernel: before old: 22
Sep 27 01:37:28 plasmanb /kernel: before new: 22
Sep 27 01:37:28 plasmanb /kernel: no: 1, nn: 1
Sep 27 01:37:28 plasmanb /kernel: before old: 22
Sep 27 01:37:28 plasmanb /kernel: before new: 22
Sep 27 01:37:28 plasmanb /kernel: no: 1, nn: 1
Sep 27 01:37:28 plasmanb /kernel: before old: 22
Sep 27 01:37:28 plasmanb /kernel: before new: 22 44
Sep 27 01:37:28 plasmanb /kernel: no: 1, nn: 2
Sep 27 01:37:28 plasmanb /kernel: 0x2c (44) pressed
Sep 27 01:37:28 plasmanb /kernel: 22 44
Sep 27 01:37:28 plasmanb /kernel: before old: 22 44
Sep 27 01:37:28 plasmanb /kernel: before new: 22 44
Sep 27 01:37:28 plasmanb /kernel: no: 2, nn: 2
Sep 27 01:37:28 plasmanb /kernel: before old: 22 44
Sep 27 01:37:28 plasmanb /kernel: before new: 22 44
Sep 27 01:37:28 plasmanb /kernel: no: 2, nn: 2
Sep 27 01:37:28 plasmanb /kernel: before old: 22 44
Sep 27 01:37:28 plasmanb /kernel: before new: 44
Sep 27 01:37:28 plasmanb /kernel: no: 2, nn: 0
Sep 27 01:37:28 plasmanb /kernel: 0x416 (1046) released
Sep 27 01:37:28 plasmanb /kernel: 0x42c (1068) released
Sep 27 01:37:28 plasmanb /kernel: 44
The problem is here:
Sep 27 01:37:28 plasmanb /kernel: before old: 22 44
Sep 27 01:37:28 plasmanb /kernel: before new: 44
Sep 27 01:37:28 plasmanb /kernel: no: 2, nn: 0
Sep 27 01:37:28 plasmanb /kernel: 0x416 (1046) released
Sep 27 01:37:28 plasmanb /kernel: 0x42c (1068) released
The dumping code
for (i = 0; i < NKEYCODE; i++) {
if (ud->keycode[i])
DPRINTF(("%d ", ud->keycode[i]));
}
shows there's one element in the new key data, but the later counting
loop
for (nn = 0; nn < NKEYCODE; nn++) {
if (!ud->keycode[nn])
break;
}
says there's no element inside the new key data. How could it be
possible? And why?
I believe if this mystery could be solved, then we'll have a happy usb
keyboard driver.
plasma
==========================================================
¦¬¨ì±b³æ«á³Ì¾á¤ßªº¨Æ
http://edm-prg.epaper.com.tw/click.php?ad_code=25227
==========================================================
PChome½u¤WÁʪ«¶g¦~¼y¡G©â¨T¨®¡BDV¤Ñ¤Ñ°e
http://shopping.pchome.com.tw/
==========================================================
More information about the freebsd-stable
mailing list