From owner-freebsd-embedded@FreeBSD.ORG Sun Apr 12 14:45:42 2015 Return-Path: Delivered-To: embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 153202B0; Sun, 12 Apr 2015 14:45:42 +0000 (UTC) Received: from mail-wg0-x22c.google.com (mail-wg0-x22c.google.com [IPv6:2a00:1450:400c:c00::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AF13AA8D; Sun, 12 Apr 2015 14:45:41 +0000 (UTC) Received: by wgyo15 with SMTP id o15so57808806wgy.2; Sun, 12 Apr 2015 07:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8pmKJyeQFOOPvIrWj0XlC/fgNFJbqig+ThhkAv/E9DQ=; b=NoDCsNhIpQ+5T1RExsZk2wsqwMe7Dr5oDM9m4xryKvwgS8pAFrKTGMZJKF27NmZyvw 7ptDFEiGfVAdH3hOySxyq8USnS2lgCnKCV46XWZ/3vlZRiUAUCsi3Drf7G3Y0UBYuJ/0 1D/pNjzNcNVYc1UUlwja2P5QdFZlRbypR5zPlgsBOiInG5DB+kynfRymVlE1i3MVZM9R t9QxhwjhdrKNSzKMXrSTb9VQTE8Q491YYVw9xKZ8rki+A9XqUIIbtEhY47+54WILOaks I7jIMk2R2QH+q2eg89v8Ler13GZdxlDB5gAOOsFKXm9TzYOg0cCPPoO5TP3D9xTKmkHg Sp1Q== MIME-Version: 1.0 X-Received: by 10.180.73.198 with SMTP id n6mr11143159wiv.3.1428849940229; Sun, 12 Apr 2015 07:45:40 -0700 (PDT) Received: by 10.180.195.106 with HTTP; Sun, 12 Apr 2015 07:45:40 -0700 (PDT) In-Reply-To: <7527478.9HOi23WthO@akita> References: <7527478.9HOi23WthO@akita> Date: Sun, 12 Apr 2015 11:45:40 -0300 Message-ID: Subject: Re: using libgpio to bitbang LCDs! From: Luiz Otavio O Souza To: Rui Paulo Content-Type: text/plain; charset=UTF-8 Cc: "freebsd-embedded@freebsd.org" , freebsd-arch@freebsd.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2015 14:45:42 -0000 On 11 April 2015 at 22:00, Rui Paulo wrote: > On Saturday 11 April 2015 17:11:47 Adrian Chadd wrote: >> Hi! >> >> I just ported an adafruit LCD driver to FreeBSD. This was a pretty trivial >> task: >> >> * convert C++ to C, which was done primarily to not rely on the >> arduino-isms; * use libgpio to bitbang the SPI bus needed to write to the >> LCD. >> >> It worked third time. First was "oh it runs on 5v power and 3.3v >> signaling", and I had it hooked up to 3.3. Second was "Oh, I haven't >> set the pins to be output pins yet." Third time worked - just slowly. >> >> However - using libgpio was just pleasant. Get a handle, set the pin >> config, set the pins high/low. It was pretty damned wonderful. >> >> It turns out that to fill the screen with individual pixel writes >> takes quite a few seconds pinning my AR9331 CPU doing ~ 190,000 >> syscalls a second. Ian's suggested something sensible - a bulk data >> ioctl() that can bit bang a series of GPIO pins in the kernel. Ie, one >> syscall, a big chunk of data with instructions and timings. > > Since this is an LCD, you probably want a way to export the GPIO bank via mmap > with write-combining enabled. It's not really a safe operation as it could > hang the GPIO driver, but it could be useful. > >> The other interesting thing would be a kind of bulk pin set/get - ie, >> instead of doing rmw for one pin at a time, communicate down masks of >> pins to do together. > > I think that's sensible and could be done via a separate (new) ioctl. I've patches for this (bank read and writing), it is pretty simple and should not block other approaches (mmap, bulk transfers, ...). Luiz