From owner-freebsd-stable@FreeBSD.ORG Fri Sep 26 11:16:19 2003 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8513516A4B3 for ; Fri, 26 Sep 2003 11:16:19 -0700 (PDT) Received: from msx.pchome.com.tw (msx.pchome.com.tw [211.20.188.141]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4D5F443FF9 for ; Fri, 26 Sep 2003 11:16:17 -0700 (PDT) (envelope-from plasmaball@pchome.com.tw) Received: from me (sw68-101-165.adsl.seed.net.tw [210.68.101.165]) by msx.pchome.com.tw (Tomail v3 Lilith) with SMTP id B59CD65E940 for ; Sat, 27 Sep 2003 02:16:15 +0800 (CST) Received: (nullmailer pid 1300 invoked by uid 1001); Fri, 26 Sep 2003 18:16:07 -0000 Date: Sat, 27 Sep 2003 02:16:07 +0800 From: plasma To: stable@freebsd.org Message-ID: <20030926181607.GA927@plasmanb.plasma.idv.tw> References: <20030925093548.GA1062@plasmanb.plasma.idv.tw> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030925093548.GA1062@plasmanb.plasma.idv.tw> User-Agent: Mutt/1.5.4i Subject: Re: USB keyboard problem X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Sep 2003 18:16:19 -0000 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/ ==========================================================