From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 29 17:34:31 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D958816A400 for ; Thu, 29 Mar 2007 17:34:31 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.245]) by mx1.freebsd.org (Postfix) with ESMTP id 8F3C713C465 for ; Thu, 29 Mar 2007 17:34:31 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by an-out-0708.google.com with SMTP id c24so236651ana for ; Thu, 29 Mar 2007 10:34:30 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=PMgFDHNnSeGw7az2PY3oFAS6yNQiwzISAsPB4WyocZEUR7CR4TP/KUyBFak84gs+EmYmnw/yRR7oMgqXyYnTCojOgS7RrbQopeMA3zpPLIuerql+pmfYr++RIyViwP5ZJOgKaVHRQucLEalolWXCb39V0qi1cYyUnR7SUT3XgWo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dUdu2ALW28s47ClTxdTBqv+ZKq34BCCB0ZmMrSuaY7xPT55/8D5OwLRYD1Xtq3J7AGQEb64uuGMQdOTV6KXua70t5M+g53CrVa/w8ssGkc/fbcgfk4vvFd1J8RSV2pYsP2B3H2U4UiurBqg1QlOkhNlaqwpwKC+k0kD14WJ3ZNY= Received: by 10.100.128.8 with SMTP id a8mr607843and.1175188134849; Thu, 29 Mar 2007 10:08:54 -0700 (PDT) Received: by 10.100.177.10 with HTTP; Thu, 29 Mar 2007 10:08:54 -0700 (PDT) Message-ID: Date: Thu, 29 Mar 2007 09:08:54 -0800 From: "Maksim Yevmenkin" To: "Timothy Bourke" , hackers@freebsd.org In-Reply-To: <20070325015717.GA797@triptrop> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070325015717.GA797@triptrop> Cc: Subject: Re: enable/disable in kbd drivers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Mar 2007 17:34:31 -0000 On 3/24/07, Timothy Bourke wrote: > I have almost finished a ppbus-based driver for Super Nintendo > controllers. It presents itself as a keyboard to the operating system. I > wanted to start and stop the polling thread via, respectively, the > kbd_enable_t and kbd_disable_t hooks, but these do not seem to be called > properly. Hence this post. > > The enable and disable functions are identical across the keyboard > drivers (atkbd, ukbd, vkbd, kbdmux). Enable calls the KBD_ACTIVATE macro > which increments the kb_active count. Disable calls the KBD_DEACTIVATE > macro which decrements the kb_active count. It seems reasonable to > assume that the two functions should be called in pairs. > > However, enable is called too many times and disable is never called. > > In the kbdmux_ioctl routine: > KBADDKBD: enable is called via the KBDMUX_ENABLE macro. > KBRELKBD: does NOT call disable > > Taking dev/usb/ukbd.c as an example, the effect can be seen by adding > this line to the ukbd_enable function (after the call to KBD_ACTIVATE): > printf("ukbd_enable: %d\n", KBD_IS_ACTIVE(kbd)); > And similarly for ukbd_disable and then running dmesg or kbdcontrol. > > Additionally, each kbd driver calls its own enable function when > attached. For example, in USB_ATTACH(ukbd): > (*sw->enable)(kbd); > This would appear to be unnecessary for keyboards connected via kbdmux. > I am less certain about those connected directly, but the syscons > sccngetch routine does seems to call enable and disable. Perhaps it > should also call enable when it first starts? > > Does the attached patch seem reasonable? It would fix my immediate > problem. sorry for the delay. i'm not sure about this patch. basically, i do not think that keyboard should be disabled if it is released from kbdmux. it is perfectly fine, imo, to have two (or more) active keyboards attached to the system as long as only one of them is primary. it is possible to use /dev/kbdX interface to talk to non-primary keyboard(s) directly. thanks, max > I could write a patch to remove the calls to enable in the driver init > routines but tI don't really understand how syscons works. > > Tim. > > >