Hi,

I've created a new touchscreen driver to support the Wolfson
WM9705/WM9712 as found in the Dell Axim and Toshiba e740. This driver is
based on the existing h3600 driver.

Unfortunatly, I couldn't get cvs diff to diff the new directory I had
created for the driver, so I've attached a patch and the new files.

The wolfson.diff is the changes in configure.in and the makefiles to
support the new driver.

I've also attached the driver (wm97xx_ts.c) and it's Makefile.am.
These should both live in inputdrivers/wm97xx_ts/

Cheers

Liam

-- 
Liam Girdwood <[EMAIL PROTECTED]>


Wolfson Microelectronics plc
http://www.wolfsonmicro.com
t: +44 131 272-7000
f: +44 131 272-7001
Registered in Scotland 89839

This message may contain confidential or proprietary information. If you receive this 
message in error, please
immediately delete it, destroy all copies of it and notify the sender. Any views 
expressed in this message are those of the individual sender,
except where the message states otherwise. We take reasonable precautions to ensure 
our Emails are virus free.
However, we cannot accept responsibility for any virus transmitted by us
and recommend that you subject any incoming Email to your own virus
checking procedures.

Index: configure.in
===================================================================
RCS file: /cvs/directfb/DirectFB/configure.in,v
retrieving revision 1.169
diff -u -r1.169 configure.in
--- configure.in	28 Jul 2003 19:36:47 -0000	1.169
+++ configure.in	31 Jul 2003 09:56:32 -0000
@@ -795,6 +795,11 @@
     enable_mutouch="$enableval", enable_mutouch=no)
 fi
 
+  dnl Test for WM97xx Touchscreen support
+  AC_CHECK_HEADER( [linux/wm97xx.h], wm97xx_ts=yes, wm97xx_ts=no  
+    AC_MSG_WARN([
+*** WM97XX Touchscreen driver will not be built.]))
+
 
 AC_ARG_WITH(tools,
   [  --without-tools           do not build any tools])
@@ -820,6 +825,7 @@
 AM_CONDITIONAL(SONYPI, test x$sonypi = xyes)
 AM_CONDITIONAL(DBOX2REMOTE, test x$dbox2remote = xyes)
 AM_CONDITIONAL(MUTOUCH_TS, test x$enable_mutouch = xyes)
+AM_CONDITIONAL(WM97XX_TS, test x$wm97xx_ts = xyes)
 
 AM_CONDITIONAL(BUILD_TOOLS, test x$with_tools = xyes)
 
@@ -919,6 +925,7 @@
 inputdrivers/serialmouse/Makefile
 inputdrivers/sonypi/Makefile
 inputdrivers/ucb1x00_ts/Makefile
+inputdrivers/wm97xx_ts/Makefile
 interfaces/Makefile
 interfaces/IDirectFBFont/Makefile
 interfaces/IDirectFBImageProvider/Makefile
@@ -989,7 +996,8 @@
   H3600 Touchscreen     $h3600_ts
   ucb1x00 Touchscreen   $have_arm
   MuTouch touchscreen   $enable_mutouch
-  SonyPI Jogdial        $sonypi]);
+  SonyPI Jogdial        $sonypi
+  WM97xx Touchscreen    $wm97xx_ts]);
 fi
 
 AC_MSG_RESULT([$png_warning $jpeg_warning $freetype_warning
Index: inputdrivers/Makefile.am
===================================================================
RCS file: /cvs/directfb/DirectFB/inputdrivers/Makefile.am,v
retrieving revision 1.13
diff -u -r1.13 Makefile.am
--- inputdrivers/Makefile.am	29 Jan 2003 12:33:53 -0000	1.13
+++ inputdrivers/Makefile.am	31 Jul 2003 09:56:32 -0000
@@ -24,6 +24,10 @@
 MUTOUCH_TS_DIR = mutouch
 endif
 
+if WM97XX_TS
+WM97XX_TS_DIR = wm97xx_ts
+endif
+
 SUBDIRS = \
 	joystick		\
 	keyboard		\
@@ -35,4 +39,5 @@
 	$(UCB1X00_TS_DIR)	\
 	$(MUTOUCH_TS_DIR)	\
 	$(SONYPI_DIR)		\
-	$(DBOX2REMOTE_DIR)
+	$(DBOX2REMOTE_DIR)  \
+	$(WM97XX_TS_DIR)
## Makefile.am for DirectFB/inputdrivers/wm97xx

INCLUDES = \
	-I$(top_srcdir)/include	\
	-I$(top_srcdir)/src

input_LTLIBRARIES = libdirectfb_wm97xx_ts.la

inputdir = $(MODULEDIR)/inputdrivers

libdirectfb_wm97xx_ts_la_SOURCES =	\
	wm97xx_ts.c

libdirectfb_wm97xx_ts_la_LDFLAGS = \
        -export-dynamic		\
	-avoid-version		\
        $(DFB_LDFLAGS)
/*

   Driver for Wolfson WM9705/WM9712 touchscreen controllers as
   found in the Dell Axim and Toshiba e740.
   
   [EMAIL PROTECTED]
   
   NOTE: Please make sure that pressure measurement is enable in the 
         kernel driver. (i.e. pil != 0) Please read 
		  wolfson-touchscreen.txt in your kernel documentation for
		  details.
   
   Based on the h3600_ts.c driver by convergence GmbH.

   (c) Copyright 2000-2002  convergence integrated media GmbH.
   (c) Copyright 2002       convergence GmbH.
   
   All rights reserved.

   Written by Denis Oliver Kropp <[EMAIL PROTECTED]>,
              Andreas Hundt <[EMAIL PROTECTED]> and
              Sven Neumann <[EMAIL PROTECTED]>.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#include <fcntl.h>
#include <sys/ioctl.h>

#include <linux/wm97xx.h>

#include <directfb.h>

#include <core/coredefs.h>
#include <core/coretypes.h>

#include <core/input.h>
#include <core/thread.h>

#include <misc/conf.h>
#include <misc/mem.h>

#include <core/input_driver.h>


DFB_INPUT_DRIVER( wm97xx_ts )

typedef struct {
     InputDevice   *device;
     CoreThread    *thread;

     int            fd;
} WM97xxTSData;

static void *
wm97xxtsEventThread( CoreThread *thread, void *driver_data )
{
     WM97xxTSData *data = (WM97xxTSData*) driver_data;

     TS_EVENT ts_event;

     int readlen;

     unsigned short old_x = -1;
     unsigned short old_y = -1;
     unsigned short old_pressure = 0;

     while ((readlen = read(data->fd, &ts_event, sizeof(TS_EVENT))) > 0  ||
            errno == EINTR)
     {
          DFBInputEvent evt;

          dfb_thread_testcancel( thread );

          if (readlen < 1)
               continue;

          if (ts_event.pressure) {
               if (ts_event.x != old_x) {
                    evt.type    = DIET_AXISMOTION;
                    evt.flags   = DIEF_AXISABS;
                    evt.axis    = DIAI_X;
                    evt.axisabs = ts_event.x;

                    dfb_input_dispatch( data->device, &evt );

                    old_x = ts_event.x;
               }

               if (ts_event.y != old_y) {
                    evt.type    = DIET_AXISMOTION;
                    evt.flags   = DIEF_AXISABS;
                    evt.axis    = DIAI_Y;
                    evt.axisabs = ts_event.y;

                    dfb_input_dispatch( data->device, &evt );

                    old_y = ts_event.y;
               }
          }

          if ((ts_event.pressure && !old_pressure) ||
              (!ts_event.pressure && old_pressure)) {
               evt.type   = (ts_event.pressure ?
                             DIET_BUTTONPRESS : DIET_BUTTONRELEASE);
               evt.flags  = DIEF_NONE;
               evt.button = DIBI_LEFT;

               dfb_input_dispatch( data->device, &evt );

               old_pressure = ts_event.pressure;
          }
     }

     if (readlen <= 0)
          PERRORMSG ("WM97xx Touchscreen thread died\n");

     return NULL;
}


/* exported symbols */

static int driver_get_available()
{
     int fd;

     fd = open( "/dev/touchscreen/wm97xx", O_RDONLY | O_NOCTTY );
     if (fd < 0)
          return 0;

     close( fd );

     return 1;
}

static void
driver_get_info( InputDriverInfo *info )
{
     /* fill driver info structure */
     snprintf( info->name,
               DFB_INPUT_DRIVER_INFO_NAME_LENGTH, "WM97xx Touchscreen Driver" );

     snprintf( info->vendor,
               DFB_INPUT_DRIVER_INFO_VENDOR_LENGTH,
               "convergence integrated media GmbH" );

     info->version.major = 0;
     info->version.minor = 1;
}

static DFBResult
driver_open_device( InputDevice      *device,
                    unsigned int      number,
                    InputDeviceInfo  *info,
                    void            **driver_data )
{
     int          fd;
     WM97xxTSData *data;

     /* open device */
     fd = open( "/dev/touchscreen/wm97xx", O_RDONLY | O_NOCTTY );
     if (fd < 0) {
          PERRORMSG( "DirectFB/WM97xx: Error opening `/dev/touchscreen/wm97xx'!\n" );
          return DFB_INIT;
     }

     /* fill device info structure */
     snprintf( info->desc.name,
               DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "WM97xx Touchscreen" );

     snprintf( info->desc.vendor,
               DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Wolfson Microelectronics" );

     info->prefered_id     = DIDID_MOUSE;

     info->desc.type       = DIDTF_MOUSE;
     info->desc.caps       = DICAPS_AXES | DICAPS_BUTTONS;
     info->desc.max_axis   = DIAI_Y;
     info->desc.max_button = DIBI_LEFT;

     /* allocate and fill private data */
     data = DFBCALLOC( 1, sizeof(WM97xxTSData) );

     data->fd     = fd;
     data->device = device;

     /* start input thread */
     data->thread = dfb_thread_create( CTT_INPUT, wm97xxtsEventThread, data );

     /* set private data pointer */
     *driver_data = data;

     return DFB_OK;
}

/*
 * Fetch one entry from the device's keymap if supported.
 */
static DFBResult
driver_get_keymap_entry( InputDevice               *device,
                         void                      *driver_data,
                         DFBInputDeviceKeymapEntry *entry )
{
     return DFB_UNSUPPORTED;
}

static void
driver_close_device( void *driver_data )
{
     WM97xxTSData *data = (WM97xxTSData*) driver_data;

     /* stop input thread */
     dfb_thread_cancel( data->thread );
     dfb_thread_join( data->thread );
     dfb_thread_destroy( data->thread );

     /* close device */
     if (close( data->fd ) < 0)
          PERRORMSG( "DirectFB/WM97xx: Error closing `/dev/touchscreen/wm97xx'!\n" );

     /* free private data */
     DFBFREE( data );
}

Reply via email to