Date: Sat, 27 Sep 2003 02:16:07 +0800 From: plasma <plasmaball@pchome.com.tw> To: stable@freebsd.org Subject: Re: USB keyboard problem Message-ID: <20030926181607.GA927@plasmanb.plasma.idv.tw> In-Reply-To: <20030925093548.GA1062@plasmanb.plasma.idv.tw> References: <20030925093548.GA1062@plasmanb.plasma.idv.tw>
next in thread | previous in thread | raw e-mail | index | archive | help
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 ========================================================== 收到帳單後最擔心的事 http://edm-prg.epaper.com.tw/click.php?ad_code=25227 ========================================================== PChome線上購物週年慶:抽汽車、DV天天送 http://shopping.pchome.com.tw/ ==========================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030926181607.GA927>