From owner-freebsd-hackers@FreeBSD.ORG Tue May 13 08:42:07 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 16824A23 for ; Tue, 13 May 2014 08:42:07 +0000 (UTC) Received: from mail.machdep.com (mail.machdep.com [195.91.211.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE8BC2CBC for ; Tue, 13 May 2014 08:42:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=machdep.com) by mail.machdep.com with smtp (Exim 4.82 (FreeBSD)) (envelope-from ) id 1Wk8Fs-000IWy-VX; Tue, 13 May 2014 12:40:09 +0400 Received: by machdep.com (nbSMTP-1.00) for uid 1001 br@machdep.com; Tue, 13 May 2014 12:40:08 +0400 (MSK) Date: Tue, 13 May 2014 12:40:08 +0400 From: Ruslan Bukin To: Maxim Ignatenko Subject: Re: Keyboard drivers, polling vs. non-polling mode Message-ID: <20140513084008.GA71115@machdep.com> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="X1bOJ3K7DJ5YkBrT" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 May 2014 08:42:07 -0000 --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline On Sun, May 11, 2014 at 11:33:42PM +0100, Maxim Ignatenko wrote: > Hello, > > I'm trying trying to get keyboard working in DDB on HP Chromebook 11 (ARM). > br@ said that it doesn't work there because polling mode is not implemented yet. > Where can I read about the difference between polling and non-polling > modes (and about keyboard drivers in general)? > sys/dev/kbd/kbdreg.h describes some structures and method signatures, > but I have no clue what is the expected behaviour of those methods. > > My current guess is that in polling mode keyboard driver just queues > up all the input coming from keyboard and then gives it to consumer > upon request, while in non-polling mode it invokes some callback > instead of queueing. But I cannot find any documentation to confirm or > disprove that. > Chrome Embedded Controller (EC) provides interrupt (KB_GPIO_INT pin, active low) reporting that there are pending data and you need to read the data using ec_command(..). After all data was read, pin comes to 1 (not active). We have no interrupts in KDB, so you have to check pin status manually and if status == 0 (active) then read new data. Probably you can start with patch attached (I did't tested). -Ruslan --X1bOJ3K7DJ5YkBrT Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="patch.polling" Index: sys/arm/samsung/exynos/chrome_kb.c =================================================================== --- sys/arm/samsung/exynos/chrome_kb.c (revision 265947) +++ sys/arm/samsung/exynos/chrome_kb.c (working copy) @@ -131,6 +131,8 @@ int rows; int cols; device_t dev; + device_t gpio_dev; + struct thread *sc_poll_thread; uint8_t *scan_local; @@ -331,6 +333,7 @@ uint16_t key; int oldbit; int newbit; + int status; sc = kbd->kb_data; @@ -347,7 +350,11 @@ }; if (sc->sc_flags & CKB_FLAG_POLLING) { - /* TODO */ + GPIO_PIN_GET(sc->gpio_dev, KB_GPIO_INT, &status); + if (status == 0) { + ec_command(EC_CMD_MKBP_STATE, sc->scan, sc->cols, + sc->scan, sc->cols); + } }; for (i = 0; i < sc->cols; i++) { @@ -710,6 +717,12 @@ if ((error = parse_dts(sc)) != 0) return error; + sc->gpio_dev = devclass_get_device(devclass_find("gpio"), 0); + if (sc->gpio_dev == NULL) { + device_printf(sc->dev, "cant find gpio_dev\n"); + return (1); + } + #if 0 device_printf(sc->dev, "Keyboard matrix [%dx%d]\n", sc->cols, sc->rows); --X1bOJ3K7DJ5YkBrT--