Date: Tue, 15 Jun 2004 09:47:26 +0200 From: John Hay <jhay@icomtek.csir.co.za> To: Nick Rogness <nick@rogness.net> Cc: freebsd-hardware@freebsd.org Subject: Re: Lilliput 7" touchscreen LCD Message-ID: <20040615074726.GA10987@zibbi.icomtek.csir.co.za> In-Reply-To: <Pine.LNX.4.44.0406111436360.1588-100000@skywalker.rogness.net> References: <20040611182805.GA60159@zibbi.icomtek.csir.co.za> <Pine.LNX.4.44.0406111436360.1588-100000@skywalker.rogness.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jun 11, 2004 at 02:43:19PM -0600, Nick Rogness wrote: > On Fri, 11 Jun 2004, John Hay wrote: > > > On Thu, Jun 10, 2004 at 05:53:15PM -0600, Nick Rogness wrote: > > > > > > Does anyone know if there exists a driver for the Lilliput 7" touchscreen > > > LCD for FreeBSD? Drivers exist for Linux, Mac, & Win. > > > > > > People appear to be using a USB touchkit driver from eGalax, Inc: > > > > > > http://www.egalax.com.tw/Download.htm > > > > > > It is a usb device, so just wondering if anyone has anything written for > > > this or could provide information where to find it. > > > > Interesting, I just bought one myself. :-) There is a NetBSD driver for > > it, uep(4). I had a quick look at it and one "issue" I have with it, is > > that they push the data into their wscons driver, so we will have to do > > something else there. I did thought of making the data available to the > > moused daemon, but I'm not sure if that is doable because mice normally > > work in relative values, while the touch screen work with absolute > > values. > > > > I see that their Linux drivers ship with source, so maybe one can use > > their X driver and make our kernel driver such that the two can work > > together? > > That would be ideal. I have the source for the Linux driver > available (which includes the x86driver, Linux usb driver, and > userland apps) at: > > http://www.rapidnet.com/~nick/lilliput/touchkit.tgz > > I REALLY want to get a usb driver written for this thing. Too bad > I know jack squat about the usb stack in FreeBSD. I guess it's > time to do some serious learning. > > Any pointers would be helpful. I could use some help if you or > anyone is interested and doesn't mind answering stupid questions. Ok, I wrote a little program using the ugen device just to see how to access the device. Actually if you are not interested in sending anything to the device, you can just open /dev/ugen0.1 and read the touch values. I'll look at modifying the NetBSD uep(4) device driver later this week so that one can just open /dev/uep0 and read and write to it. That should make it useable to the linux/X driver I think. I'm just a little slow because of flu at the moment. :-/ John -- John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org ##################### tstouch.c ###################### #include <sys/types.h> #include <sys/ioctl.h> #include <sys/uio.h> #include <fcntl.h> #include <stdio.h> #include <unistd.h> #include <dev/usb/usb.h> int main(int argc, char **argv) { unsigned char txb[4], rxb[100]; int fd, wrfd, ret, x, y; usb_device_descriptor_t usbdd; struct usb_ctl_request req; wrfd = open("/dev/ugen0", O_RDWR); if (wrfd == -1) { printf("Oops(1), could not open ugen0\n"); return 1; } ret = ioctl(wrfd, USB_GET_DEVICE_DESC, &usbdd); if (ret == -1) { printf("ioctl error\n"); return 1; } printf("idVendor 0x%X\n", UGETW(usbdd.idVendor)); printf("idProduct 0x%X\n", UGETW(usbdd.idProduct)); fd = open("/dev/ugen0.1", O_RDONLY); if (fd == -1) { printf("Oops(1), could not open ugen0.1\n"); return 1; } txb[0] = 0x0a; txb[1] = 0x01; txb[2] = 'A'; req.ucr_request.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.ucr_request.bRequest = 0; USETW(req.ucr_request.wValue, 0); USETW(req.ucr_request.wIndex, 0); USETW(req.ucr_request.wLength, 3); req.ucr_data = txb; ret = ioctl(wrfd, USB_DO_REQUEST, &req); if (ret != 0) { printf("Oops ioctl returned %d\n", ret); return 1; } ret = read(fd, rxb, 3); if (ret != 3) { printf("Oops(3) only read %d bytes\n", ret); return 1; } printf("Check Active %2X %2X %c\n", rxb[0], rxb[1], rxb[2]); usleep(5000); txb[0] = 0x0a; txb[1] = 0x01; txb[2] = 'D'; req.ucr_request.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.ucr_request.bRequest = 0; USETW(req.ucr_request.wValue, 0); USETW(req.ucr_request.wIndex, 0); USETW(req.ucr_request.wLength, 3); req.ucr_data = txb; ret = ioctl(wrfd, USB_DO_REQUEST, &req); if (ret != 0) { printf("Oops ioctl returned %d\n", ret); return 1; } ret = read(fd, rxb, 2); if (ret != 2) { printf("Oops(3) only read %d bytes\n", ret); return 1; } ret = read(fd, &rxb[2], rxb[1]); if (ret < 2) { printf("Oops(3) only read %d bytes\n", ret); return 1; } rxb[2 + rxb[1]] = '\0'; printf("Firmware %2X %2X %c %s\n", rxb[0], rxb[1], rxb[2], &rxb[3]); usleep(5000); txb[0] = 0x0a; txb[1] = 0x01; txb[2] = 'E'; req.ucr_request.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.ucr_request.bRequest = 0; USETW(req.ucr_request.wValue, 0); USETW(req.ucr_request.wIndex, 0); USETW(req.ucr_request.wLength, 3); req.ucr_data = txb; ret = ioctl(wrfd, USB_DO_REQUEST, &req); if (ret != 0) { printf("Oops ioctl returned %d\n", ret); return 1; } ret = read(fd, rxb, 2); if (ret != 2) { printf("Oops(3) only read %d bytes\n", ret); return 1; } ret = read(fd, &rxb[2], rxb[1]); if (ret < 2) { printf("Oops(3) only read %d bytes\n", ret); return 1; } rxb[2 + rxb[1]] = '\0'; printf("Type %2X %2X %c %s\n", rxb[0], rxb[1], rxb[2], &rxb[3]); while(1) { ret = read(fd, rxb, 5); if (ret != 5) { printf("out of sync\n"); } if ((rxb[0] & 0xfe) != 0x80) { printf("out of sync, start %2X\n", rxb[0]); return 1; } x = rxb[2]; x |= rxb[1] << 7; y = rxb[4]; y |= rxb[3] << 7; printf("X %4d, Y %4d, %s\n", x, y, rxb[0] & 1 ? "down" : "up"); } return 0; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040615074726.GA10987>