[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

XFree86's HasLinuxInput symbol and m68k



[[[ Background for debian-68k readers:

On Tue, Jun 10, 2003 at 01:32:16PM +0100, James Troup wrote:
> X Strike Force SVN Admin <branden@debian.org> writes:
>
> > + /* m68k has no 2.4 kernel yet */
> > + #   ifndef Mc68020Architecture
> > + #    define HasLinuxInput         YES
> >  @@ -701,7 +714,7 @@
>
> This seems out-of-date?

[Branden wrote the following]

Hmm, yes, but only recently so.  :)

I'll handle this for the trunk.  Daniel or ISHIKAWA-san, can you merge
the change over to branches/4.3.0/sid once I have fixed it on the trunk?

]]]

On Tue, Jun 10, 2003 at 04:58:57PM -0400, Christian T. Steigies wrote:
> On Tue, Jun 10, 2003 at 02:56:45PM -0500, Branden Robinson wrote:
> 
> > > afaik 2.4 doesn't boot on all the m68k (ex)vendors... amiga does... mac
> > > does not.. :/
> > 
> > That's not what I seem to recall from recent traffic on debian-68k.
> 
> But it's true, my Mac does not boot with 2.4.20, and yours probably neither.
> Its just none of the mac users noticed yet. And I have no reports about
> Atari, and the three VMEs. Is it important for XFree86, I mean will 4.3 only
> work with a 2.4 kernel? I heard Ray Knight is trying to get some
> improvements from the powerpc kernel. If somebody can make it work on Macs,
> its Ray...

Please don't freak about this.  That symbol has very limited effect:

[0] branden@redwald:~/packages/xfree86/4.2.1/xfree86-4.2.1/build-tree/xc % grep -r HasLinuxInput *
config/cf/linux.cf:#    define HasLinuxInput            YES
config/cf/linux.cf:#ifndef HasLinuxInput
config/cf/linux.cf:#  define HasLinuxInput YES
config/cf/xfree86.cf:#ifndef HasLinuxInput
config/cf/xfree86.cf:# define HasLinuxInput NO
programs/Xserver/hw/xfree86/input/hyperpen/Imakefile:#if HasLinuxInput
programs/Xserver/hw/xfree86/input/wacom/Imakefile:#if HasLinuxInput
[0] branden@redwald:~/packages/xfree86/4.2.1/xfree86-4.2.1/build-tree/xc % grep -2 HasLinuxInput programs/Xserver/hw/xfree86/input/hyperpen/Imakefile programs/Xserver/hw/xfree86/input/wacom/Imakefile
programs/Xserver/hw/xfree86/input/hyperpen/Imakefile-#include <Server.tmpl>
programs/Xserver/hw/xfree86/input/hyperpen/Imakefile-
programs/Xserver/hw/xfree86/input/hyperpen/Imakefile:#if HasLinuxInput
programs/Xserver/hw/xfree86/input/hyperpen/Imakefile-DEFINES = -DLINUX_INPUT
programs/Xserver/hw/xfree86/input/hyperpen/Imakefile-#endif
--
programs/Xserver/hw/xfree86/input/wacom/Imakefile-#include <Server.tmpl>
programs/Xserver/hw/xfree86/input/wacom/Imakefile-
programs/Xserver/hw/xfree86/input/wacom/Imakefile:#if HasLinuxInput
programs/Xserver/hw/xfree86/input/wacom/Imakefile-DEFINES = -DLINUX_INPUT
programs/Xserver/hw/xfree86/input/wacom/Imakefile-#endif

And the only actual C file that appears to do anything with this is the
wacom input driver:

[0] branden@redwald:~/packages/xfree86/4.2.1/xfree86-4.2.1/build-tree/xc/programs/Xserver/hw/xfree86/input
% grep -r LINUX_INPUT *
acecad/acecad.c:#ifdef LINUX_INPUT
hyperpen/Imakefile:DEFINES = -DLINUX_INPUT
wacom/Imakefile:DEFINES = -DLINUX_INPUT
wacom/xf86Wacom.c:#ifdef LINUX_INPUT
wacom/xf86Wacom.c:#ifdef LINUX_INPUT
wacom/xf86Wacom.c:#ifdef LINUX_INPUT
wacom/xf86Wacom.c:#endif /* LINUX_INPUT */
wacom/xf86Wacom.c:#ifdef LINUX_INPUT
wacom/xf86Wacom.c:#ifdef LINUX_INPUT

(The acecad driver references it, but there's no way for it to be
defined in the build environment.  The hyperpen Imakefile will define
it, but the hyperpen code doesn't use it.  These are typical examples of
the close attention paid to input drivers in XFree86 ;-) )

And here are the relevant chunks of xf86Wacom.c:

  #ifdef LINUX_INPUT
  #include <asm/types.h>
  #include <linux/input.h>

  /* max number of input events to read in one read call */
  #define MAX_EVENTS 50

  /* keithp - a hack to avoid redefinitions of these in xf86str.h */
  #ifdef BUS_PCI
  #undef BUS_PCI
  #endif
  #ifdef BUS_ISA
  #undef BUS_ISA
  #endif
  #endif
[...]
  #ifdef LINUX_INPUT
  static void xf86WcmReadUSBInput(LocalDevicePtr);
  static Bool xf86WcmUSBOpen(LocalDevicePtr);
  #endif
[...]
  #ifdef LINUX_INPUT
  /*
   ***************************************************************************
   *
   * xf86WcmIsUSBLine --
   *      Test if the attached device is a USB one.
   *
   ***************************************************************************
   */
  static int
  xf86WcmIsUSBLine(int    fd)
  {
      int version;
      int err;

      SYSCALL(err = ioctl(fd, EVIOCGVERSION, &version));

      if (!err) {
          ErrorF("%s Wacom Kernel Input driver version is %d.%d.%d\n", XCONFIG_PROBED,
                 version >> 16, (version >> 8) & 0xff, version & 0xff);
          return 1;
      } else {
          return 0;
      }
  }

  /*
   ***************************************************************************
   *
   * xf86WcmReadUSBInput --
   *      Read the new events from the device, and enqueue them.
   *
   ***************************************************************************
   */
  static void
  xf86WcmReadUSBInput(LocalDevicePtr         local)
  {
      WacomDevicePtr      priv = (WacomDevicePtr) local->private;
      WacomCommonPtr      common = priv->common;
      int serial = common->wcmLastSerial;
      int is_proximity = priv->oldProximity;
      int x = priv->oldX;
      int y = priv->oldY;
      int pressure = priv->oldZ;
      int buttons = priv->oldButtons;
      int tilt_x = priv->oldTiltX;
      int tilt_y = priv->oldTiltY;
      int wheel = priv->oldWheel;

      ssize_t              len;
      int                  idx;
      struct input_event * event;
      char                 eventbuf[sizeof(struct input_event) * MAX_EVENTS];
  #define MOD_BUTTONS(bit, value) \
      { int _b=bit, _v=value; buttons = (((_v) != 0) ? (buttons | _b) : (buttons & ~ _b)); }

      SYSCALL(len = read(local->fd, eventbuf, sizeof(eventbuf)));

      if (len <= 0) {
          ErrorF("Error reading wacom device : %s\n", strerror(errno));
          return;
      }

      for (event=(struct input_event *)eventbuf;
           event<(struct input_event *)(eventbuf+len); event++) {
          DBG(10, ErrorF("xf86WcmReadUSBInput event->type=%d\n", event->type));

          switch (event->type) {
          case EV_ABS:
              DBG(10, ErrorF("xf86WcmReadUSBInput event->code=%d\n", event->code));
              switch (event->code) {
              case ABS_X:
                  x = event->value;
                  break;

              case ABS_Y:
                  y = event->value;
                  break;

              case ABS_TILT_X:
              case ABS_RZ:
                  tilt_x = event->value;
                  break;

              case ABS_TILT_Y:
                  tilt_y = event->value;
                  break;

              case ABS_PRESSURE:
                  pressure = event->value;
                  MOD_BUTTONS (1, event->value > common->wcmThreshold ? 1 : 0);
                  break;

              case ABS_DISTANCE:
                  /* This is not sent by the driver */
                  break;

              case ABS_MISC:
                  serial = event->value;
                  DBG(10, ErrorF("wacom tool serial id=%d\n", serial));
                  break;

              case ABS_WHEEL:
              case ABS_THROTTLE:
                  wheel = event->value;
                  break;

              }
              break; /* EV_ABS */

          case EV_REL:
              switch (event->code) {
              case REL_WHEEL:
                  /* FIXME */
                  break;
              default:
                  ErrorF("wacom: relative event received (%d)!!!\n", event->code);
                  break;
              }
              break; /* EV_REL */

          case EV_KEY:
              switch (event->code) {
              case BTN_TOOL_PEN:
              case BTN_TOOL_PENCIL:
              case BTN_TOOL_BRUSH:
              case BTN_TOOL_AIRBRUSH:
                  DBG(10, ErrorF("USB Stylus detected %x\n", event->code));
                  common->wcmIndex = STYLUS_ID;
                  is_proximity = (event->value != 0);
                  break;

              case BTN_TOOL_RUBBER:
                  DBG(10, ErrorF("USB eraser detected %x\n", event->code));
                  common->wcmIndex = ERASER_ID;
                  is_proximity = (event->value != 0);
                  break;

              case BTN_TOOL_MOUSE:
              case BTN_TOOL_LENS:
                  DBG(10, ErrorF("USB mouse detected %x\n", event->code));
                  common->wcmIndex = CURSOR_ID;
                  is_proximity = (event->value != 0);
                  break;

              case BTN_TOUCH:
                  /* we use the pressure to determine the button 1 */
                  break;

              case BTN_STYLUS:
                  MOD_BUTTONS (2, event->value);
                  break;

              case BTN_STYLUS2:
                  MOD_BUTTONS (4, event->value);
                  break;

              case BTN_LEFT:
                  MOD_BUTTONS (1, event->value);
                  break;

              case BTN_MIDDLE:
                  MOD_BUTTONS (2, event->value);
                  break;

              case BTN_RIGHT:
                  MOD_BUTTONS (4, event->value);
                  break;

              case BTN_SIDE:
                  MOD_BUTTONS (8, event->value);
                  break;

              case BTN_EXTRA:
                  MOD_BUTTONS (16, event->value);
                  break;
              }
              break; /* EV_KEY */
          } /* switch event->type */

          /* ABS_MISC is the event terminator */
          if (event->type != EV_ABS || event->code != ABS_MISC) {
              continue;
          }

          if ((is_proximity == priv->oldProximity) &&
              (buttons == priv->oldButtons) &&
              (ABS(x - priv->oldX) <= common->wcmSuppress) &&
              (ABS(y - priv->oldY) <= common->wcmSuppress) &&
              (ABS(pressure - priv->oldZ) < 3) &&
              (ABS(tilt_x - priv->oldTiltX) < 3) &&
              (ABS(tilt_y - priv->oldTiltY) < 3)) {
              DBG(10, ErrorF("filtered\n"));
              continue;
          }

      for (idx=0; idx<common->wcmNumDevices; idx++) {
          WacomDevicePtr  dev = common->wcmDevices[idx]->private;
          int             id;

          id  = DEVICE_ID (dev->flags);

          /* Find the device the current events are meant for */
          if (id == common->wcmIndex) {
              xf86WcmSendEvents(common->wcmDevices[idx],
                          common->wcmIndex,
                          serial,
                          (common->wcmIndex == STYLUS_ID || common->wcmIndex == ERASER_ID),
                          !!(buttons),
                          is_proximity,
                          x, y, pressure, buttons,
                          tilt_x, tilt_y, wheel
                          );
          }
      }
      priv->oldX = x;
      priv->oldY = y;
      priv->oldZ = pressure;
      priv->oldTiltX = tilt_x;
      priv->oldTiltY = tilt_y;
      priv->oldProximity = is_proximity;
      priv->oldButtons = buttons;
      priv->oldWheel = wheel;
      common->wcmLastSerial = serial;
      }
  }

  /*
   ***************************************************************************
   *
   * xf86WcmUSBOpen --
   *
   ***************************************************************************
   */

  #define BITS_PER_LONG (sizeof(long) * 8)
  #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
  #define test_bit(bit, array)    ((array[LONG(bit)] >> OFF(bit)) & 1)
  #define OFF(x)  ((x)%BITS_PER_LONG)
  #define LONG(x) ((x)/BITS_PER_LONG)

  static Bool
  xf86WcmUSBOpen(LocalDevicePtr   local)
  {
      int                 err = 0;
      WacomDevicePtr      priv = (WacomDevicePtr)local->private;
      WacomCommonPtr      common = priv->common;
      char                name[256] = "Unknown";
      int                 abs[5];
      unsigned long       bit[EV_MAX][NBITS(KEY_MAX)];
      int                 i, j;

      local->fd = xf86OpenSerial(local->options);
      if (local->fd == -1) {
          ErrorF("Error opening %s : %s\n", common->wcmDevice, strerror(errno));
          return !Success;
      }

      ioctl(local->fd, EVIOCGNAME(sizeof(name)), name);
      ErrorF("%s Wacom Kernel Input device name: \"%s\"\n", XCONFIG_PROBED, name);

      memset(bit, 0, sizeof(bit));
      ioctl(local->fd, EVIOCGBIT(0, EV_MAX), bit[0]);

      for (i = 0; i < EV_MAX; i++)
          if (test_bit(i, bit[0])) {
              ioctl(local->fd, EVIOCGBIT(i, KEY_MAX), bit[i]);
              for (j = 0; j < KEY_MAX; j++)
                  if (test_bit(j, bit[i])) {
                      if (i == EV_ABS) {
                          ioctl(local->fd, EVIOCGABS(j), abs);
                          switch (j) {
                          case ABS_X:
                              if (common->wcmMaxX == 0) {
                                  common->wcmMaxX = abs[2];
                              }
                              break;

                          case ABS_Y:
                              if (common->wcmMaxY == 0) {
                                  common->wcmMaxY = abs[2];
                              }
                              break;

                          case ABS_Z:
                              if (common->wcmMaxZ == DEFAULT_MAXZ) {
                                  common->wcmMaxZ = abs[2];
                              }
                              break;
                          }
                      }
                  }
          }

      DBG(2, ErrorF("setup is max X=%d max Y=%d resol X=%d resol Y=%d\n",
                    common->wcmMaxX, common->wcmMaxY, common->wcmResolX,
                    common->wcmResolY));

      /* send the tilt mode command after setup because it must be enabled */
      /* after multi-mode to take precedence */
      if (HANDLE_TILT(common)) {
        /* Unfortunately, the USB driver doesn't allow to send this
         * command to the tablet. Any other solutions ? */
          DBG(2, ErrorF("Sending tilt mode order\n"));
      }

      {
          if (common->wcmSuppress < 0) {
              common->wcmSuppress = 0;
          } else {
              if (common->wcmSuppress > 100) {
                  common->wcmSuppress = 99;
              }
          }
          /* Cannot send WC_SUPPRESS to the table. Will have to do
           * this manually. */
      }

      priv->topX = 0;
      priv->bottomX = common->wcmMaxX;
      priv->topY = 0;
      priv->bottomY = common->wcmMaxY;

      if (xf86Verbose)
          ErrorF("%s Wacom tablet maximum X=%d maximum Y=%d "
                 "X resolution=%d Y resolution=%d suppress=%d%s\n",
                 XCONFIG_PROBED, common->wcmMaxX, common->wcmMaxY,
                 common->wcmResolX, common->wcmResolY, common->wcmSuppress,
                 HANDLE_TILT(common) ? " Tilt" : "");
      if (err < 0) {
          ErrorF("ERROR: %d\n", err);
          SYSCALL(close(local->fd));
          return !Success;
      }

      /* to have the button field handled as a bit field */
      common->wcmProtocolLevel = 5;

      return Success;
  }

  #endif /* LINUX_INPUT */
[...]
  #ifdef LINUX_INPUT
      DBG(1, ErrorF("testing USB\n"));

      if (xf86WcmIsUSBLine(local->fd)) {
          int     loop;

          SYSCALL(close(local->fd));

          for(loop=0; loop<common->wcmNumDevices; loop++) {
              common->wcmDevices[loop]->read_input=xf86WcmReadUSBInput;
          }
          common->wcmOpen=xf86WcmUSBOpen;

          return xf86WcmUSBOpen(local);
      }
  #endif
[...]
  #ifdef LINUX_INPUT
      if (xf86SetBoolOption(local->options, "USB", (common->wcmOpen == xf86WcmUSBOpen))) {
          local->read_input=xf86WcmReadUSBInput;
          common->wcmOpen=xf86WcmUSBOpen;
          xf86Msg(X_CONFIG, "%s: reading USB link\n", dev->identifier);
  #else
      if (xf86SetBoolOption(local->options, "USB", 0)) {
          ErrorF("The USB version of the driver isn't available for your platform\n");
  #endif

Will it kill anyone to have this code in the XFree86 packages for m68k?

I'm going to go ahead and commit the change.  If you can make a case for
reverting it, I'll revert it.

-- 
G. Branden Robinson                |     It's not a matter of alienating
Debian GNU/Linux                   |     authors.  They have every right to
branden@debian.org                 |     license their software however we
http://people.debian.org/~branden/ |     like.  -- Craig Sanders

Attachment: pgpjGL_XZVwP1.pgp
Description: PGP signature


Reply to: