Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-22 Thread Peter Hutterer
On Sat, Feb 18, 2012 at 12:42:21PM +, Bastien Nocera wrote:
> Peter Hutterer  writes:
> > On Wed, Feb 08, 2012 at 08:30:58AM -0800, Jason Gerecke wrote:
> > > Any feedback on the changes or ideas on exposing the properties?
> > 
> > sorry for the delay. short answer - I don't think we should merge this
> > support as properties. properties are not well-suited for this, they are too
> > generic and too much knowledge must reside in the client setting them.
> 
> Exactly. But the client should be the one handling the mode switching, and the
> button actions in the first place. So I don't see what's wrong with exposing
> it as a property. It would make it available now, and make it possible for me 
> to make the mode switching work in GNOME 3.4 (I really don't want to have mode
> switching enabled if I can't show the user that the mode has indeed switched).
> 
> So I'm in favour of one property per LED group, and a bitmask as to which one
> is lit up (if even just an index, if we want to force 1 LED lit at all times).
> 
> > Instead, we should extend the protocol for XI 2.3 to add a LED class and the
> > required requests to modify the LEDs support. This gives us
> > more flexibility handling LEDs and less driver-dependent behaviour.
> 
> That's nice. It doesn't require using properties. but it does still require
> the client having special knowledge of the device. It's not like one would set
> the LEDs the same way on a Wacom tablet and a PS3 joypad for example.

It doesn't tell us where the LEDs are and what they could mean (unless we
employ XKB-like geometry) but it gives us a number of other options, most
importantly a valid range. The current LEDs may only support bitmasks, they
may be arranged in groups but there's no guarantee that this will be the
same in the next generation of devices. Properties cannot give us this
information, we need a real API for this.

Changing properties is painful, they're a soft API. Appending and removing
is relatively easy provided clients are written correctly, but anything else
is annoying at best and impossible at worst.

Cheers,
  Peter

--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-18 Thread Bastien Nocera
Peter Hutterer  writes:
> On Wed, Feb 08, 2012 at 08:30:58AM -0800, Jason Gerecke wrote:
> > Any feedback on the changes or ideas on exposing the properties?
> 
> sorry for the delay. short answer - I don't think we should merge this
> support as properties. properties are not well-suited for this, they are too
> generic and too much knowledge must reside in the client setting them.

Exactly. But the client should be the one handling the mode switching, and the
button actions in the first place. So I don't see what's wrong with exposing
it as a property. It would make it available now, and make it possible for me 
to make the mode switching work in GNOME 3.4 (I really don't want to have mode
switching enabled if I can't show the user that the mode has indeed switched).

So I'm in favour of one property per LED group, and a bitmask as to which one
is lit up (if even just an index, if we want to force 1 LED lit at all times).

> Instead, we should extend the protocol for XI 2.3 to add a LED class and the
> required requests to modify the LEDs support. This gives us
> more flexibility handling LEDs and less driver-dependent behaviour.

That's nice. It doesn't require using properties. but it does still require
the client having special knowledge of the device. It's not like one would set
the LEDs the same way on a Wacom tablet and a PS3 joypad for example.

Cheers


--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-11 Thread Ping Cheng
On Sat, Feb 11, 2012 at 1:24 AM, Peter Hutterer wrote:

> On Sat, Feb 11, 2012 at 12:03:19AM +0800, Ping Cheng wrote:
> > On Fri, Feb 10, 2012 at 4:29 PM, Peter Hutterer <
> peter.hutte...@who-t.net>wrote:
> >
> > > On Wed, Feb 08, 2012 at 08:30:58AM -0800, Jason Gerecke wrote:
> > > > On Wed, Jan 25, 2012 at 1:57 PM, Jason Gerecke  >
> > > wrote:
> > > > > This covers most of the suggested changes. I'm not sure yet how we
> > > > > want to expose the properties through X, so changes regarding that
> > > > > haven't been folded in.
> > >
> > > [...]
> > > >
> > > > Any feedback on the changes or ideas on exposing the properties?
> > >
> > > sorry for the delay. short answer - I don't think we should merge this
> > > support as properties. properties are not well-suited for this, they
> are
> > > too
> > > generic and too much knowledge must reside in the client setting them.
> > >
> > > Instead, we should extend the protocol for XI 2.3
> >
> >
> > How do we support XI older than 2.3, then?
>
> we don't, at least not in xf86-input-wacom and I very much doubt that e.g.
> gnome would then. While I understand the need for keeping backwards-compat
> with older servers for new hardware,


Just as much as you understand me on this issue, I know your point. This
support is mainly for RHEL6. So, we'll need to tell the users to file a
request at redhat bugzilla.

Ping


> I don't think LED support is that
> crucial that we should merge and support an interface that can only be
> badly
> supported (and is driver-specific, again, like too many other features).
>  If
> the need is that big, you could branch off but I doubt LED support is worth
> the effort.
>
> Cheers,
>  Peter
>
> > > to add a LED class and the
> > > required requests to modify the LEDs support. This gives us
> > > more flexibility handling LEDs and less driver-dependent behaviour.
> > >
> > > Cheers,
> > >  Peter
>
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-10 Thread Peter Hutterer
On Sat, Feb 11, 2012 at 12:03:19AM +0800, Ping Cheng wrote:
> On Fri, Feb 10, 2012 at 4:29 PM, Peter Hutterer 
> wrote:
> 
> > On Wed, Feb 08, 2012 at 08:30:58AM -0800, Jason Gerecke wrote:
> > > On Wed, Jan 25, 2012 at 1:57 PM, Jason Gerecke 
> > wrote:
> > > > This covers most of the suggested changes. I'm not sure yet how we
> > > > want to expose the properties through X, so changes regarding that
> > > > haven't been folded in.
> >
> > [...]
> > >
> > > Any feedback on the changes or ideas on exposing the properties?
> >
> > sorry for the delay. short answer - I don't think we should merge this
> > support as properties. properties are not well-suited for this, they are
> > too
> > generic and too much knowledge must reside in the client setting them.
> >
> > Instead, we should extend the protocol for XI 2.3
> 
> 
> How do we support XI older than 2.3, then?

we don't, at least not in xf86-input-wacom and I very much doubt that e.g.
gnome would then. While I understand the need for keeping backwards-compat
with older servers for new hardware, I don't think LED support is that
crucial that we should merge and support an interface that can only be badly
supported (and is driver-specific, again, like too many other features).  If
the need is that big, you could branch off but I doubt LED support is worth
the effort.

Cheers,
  Peter

> > to add a LED class and the
> > required requests to modify the LEDs support. This gives us
> > more flexibility handling LEDs and less driver-dependent behaviour.
> >
> > Cheers,
> >  Peter

--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-10 Thread Ping Cheng
On Fri, Feb 10, 2012 at 4:29 PM, Peter Hutterer wrote:

> On Wed, Feb 08, 2012 at 08:30:58AM -0800, Jason Gerecke wrote:
> > On Wed, Jan 25, 2012 at 1:57 PM, Jason Gerecke 
> wrote:
> > > This covers most of the suggested changes. I'm not sure yet how we
> > > want to expose the properties through X, so changes regarding that
> > > haven't been folded in.
>
> [...]
> >
> > Any feedback on the changes or ideas on exposing the properties?
>
> sorry for the delay. short answer - I don't think we should merge this
> support as properties. properties are not well-suited for this, they are
> too
> generic and too much knowledge must reside in the client setting them.
>
> Instead, we should extend the protocol for XI 2.3


How do we support XI older than 2.3, then?

Ping


> to add a LED class and the
> required requests to modify the LEDs support. This gives us
> more flexibility handling LEDs and less driver-dependent behaviour.
>
> Cheers,
>  Peter
>
>
> --
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> ___
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
>
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-10 Thread Peter Hutterer
On Wed, Feb 08, 2012 at 08:30:58AM -0800, Jason Gerecke wrote:
> On Wed, Jan 25, 2012 at 1:57 PM, Jason Gerecke  wrote:
> > This covers most of the suggested changes. I'm not sure yet how we
> > want to expose the properties through X, so changes regarding that
> > haven't been folded in.

[...]
> 
> Any feedback on the changes or ideas on exposing the properties?

sorry for the delay. short answer - I don't think we should merge this
support as properties. properties are not well-suited for this, they are too
generic and too much knowledge must reside in the client setting them.

Instead, we should extend the protocol for XI 2.3 to add a LED class and the
required requests to modify the LEDs support. This gives us
more flexibility handling LEDs and less driver-dependent behaviour.
 
Cheers,
  Peter

--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-09 Thread Ping Cheng
In case you guys are waiting for my feedback, you can put:

From: Ping Cheng  and
Signed-off-by: Ping Cheng 

to the patch and commit it. One nitpick inline.

Ping

On Thu, Jan 26, 2012 at 5:54 AM, Jason Gerecke  wrote:

> Signed-off-by: Jason Gerecke 
> ---
> Changes from v2:
>Deduplicate storing in sysfs
>Deduplicate fd closing
>Deduplicate LED setting by looping through all groups

   Change wording of xsetwacom property description
>Consolidate led{0,1}_status variables into led_status array
>Stop udev device leak
>Change variables fd_sysfs{0,1} to an array fd_sysfs[2]
>Remove superflous function name
>
>  include/wacom-properties.h |3 ++
>  man/xsetwacom.man  |7 +
>  src/wcmCommon.c|4 ++-
>  src/wcmConfig.c|   55
> +++-
>  src/wcmXCommand.c  |   32 -
>  src/xf86Wacom.c|9 ++-
>  src/xf86WacomDefs.h|4 ++-
>  tools/xsetwacom.c  |   18 +-
>  8 files changed, 126 insertions(+), 6 deletions(-)
>
> diff --git a/include/wacom-properties.h b/include/wacom-properties.h
> index 0bb84b1..b2a3523 100644
> --- a/include/wacom-properties.h
> +++ b/include/wacom-properties.h
> @@ -46,6 +46,9 @@
>   */
>  #define WACOM_PROP_STRIPBUTTONS "Wacom Strip Buttons"
>
> +/* 8 bit, 2 values, LED0 (right side) and LED1 (left side) */
> +#define WACOM_PROP_LED "Wacom LEDs"
> +
>  /* 8 bit, 6 values, rel wheel up, rel wheel down, abs wheel up, abs wheel
> down, abs wheel 2 up, abs wheel 2 down
>OR
>Atom, 6 values , rel wheel up, rel wheel down, abs wheel up, abs wheel
> down, abs wheel 2 up, abs wheel 2 down
> diff --git a/man/xsetwacom.man b/man/xsetwacom.man
> index dc0995f..58a4427 100644
> --- a/man/xsetwacom.man
> +++ b/man/xsetwacom.man
> @@ -201,6 +201,13 @@ sets the max distance from tablet to stop reporting
> movement for cursor in
>  relative mode. Default for Intuos series is 10, for Graphire series
> (including
>  Volitos) is 42. Only available for the cursor/puck device.
>  .TP
> +\fBLED0\fR status
> +Selects which LED in the first bank of LEDs should be lit. Intuos4/Cintiq
> 21UX/Cintiq 24HD. Default:  0,
> +range of 0 to 3.
> +.TP
> +\fBLED1\fR status
> +Selects which LED in the second bank of LEDs should be lit. Cintiq
> 21UX/24HD. Default:  0, range of 0 to 3.
> +.TP
>  \fBThreshold\fR level
>  Set the minimum pressure necessary to generate a Button event for the
> stylus
>  tip, eraser, or touch.  The pressure levels of all tablets are normalized
> to
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 0f041e3..a337441 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -1,6 +1,6 @@
>  /*
>  * Copyright 1995-2002 by Frederic Lepied, France. 
> - * Copyright 2002-2010 by Ping Cheng, Wacom. 
> + * Copyright 2002-2012 by Ping Cheng, Wacom. 
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
> @@ -1472,6 +1472,8 @@ WacomCommonPtr wcmNewCommon(void)
>common->wcmMaxStripY = 4096;   /* Max fingerstrip Y */
>common->wcmMaxtiltX = 128; /* Max tilt in X directory */
>common->wcmMaxtiltY = 128; /* Max tilt in Y directory */
> +   common->fd_sysfs[0] = -1;  /* file descriptor to sysfs
> led0 */
> +   common->fd_sysfs[1] = -1;  /* file descriptor to sysfs
> led1 */
>common->wcmCursorProxoutDistDefault = PROXOUT_INTUOS_DISTANCE;
>/* default to Intuos */
>common->wcmSuppress = DEFAULT_SUPPRESS;
> diff --git a/src/wcmConfig.c b/src/wcmConfig.c
> index 5920e11..1dd9d03 100644
> --- a/src/wcmConfig.c
> +++ b/src/wcmConfig.c
> @@ -1,6 +1,6 @@
>  /*
>  * Copyright 1995-2002 by Frederic Lepied, France. 
> - * Copyright 2002-2010 by Ping Cheng, Wacom. 
> + * Copyright 2002-2012 by Ping Cheng, Wacom. 
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
> @@ -21,6 +21,7 @@
>  #include 
>  #endif
>
> +#include 
>  #include "xf86Wacom.h"
>  #include "wcmFilter.h"
>  #include 
> @@ -441,6 +442,53 @@ static int wcmIsHotpluggedDevice(InputInfoPtr pInfo)
>return !strcmp(source, "_driver/wacom");
>  }
>
> +static void wcmStoreLEDsysfsInfo(InputInfoPtr pInfo)
> +{
> +   WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
> +   WacomCommonPtr  common = priv->common;
> +   struct stat st;
> +   struct udev *udev = udev_new();
> +   struct udev_device *parent;
> +   struct udev_device *device;
> +   char fs_path[128], buf[10];
> +   int err = -1;
> +   int i;
> +
> +   stat(common->device_path, &st);
> +   device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
> +   if (!device)
> +   return;
> +
> +   parent = udev_device_get_parent_with_subsystem_devtype(device,
> + 

Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-02-08 Thread Jason Gerecke
On Wed, Jan 25, 2012 at 1:57 PM, Jason Gerecke  wrote:
> This covers most of the suggested changes. I'm not sure yet how we
> want to expose the properties through X, so changes regarding that
> haven't been folded in.
>
> Jason
>
> ---
> Day xee-nee-svsh duu-'ushtlh-ts'it;
> nuu-wee-ya' duu-xan' 'vm-nvshtlh-ts'it.
> Huu-chan xuu naa~-gha.
>
>
>
> On Wed, Jan 25, 2012 at 1:54 PM, Jason Gerecke  wrote:
>> Signed-off-by: Jason Gerecke 
>> ---
>> Changes from v2:
>>    Deduplicate storing in sysfs
>>    Deduplicate fd closing
>>    Deduplicate LED setting by looping through all groups
>>    Change wording of xsetwacom property description
>>    Consolidate led{0,1}_status variables into led_status array
>>    Stop udev device leak
>>    Change variables fd_sysfs{0,1} to an array fd_sysfs[2]
>>    Remove superflous function name
>>
>>  include/wacom-properties.h |    3 ++
>>  man/xsetwacom.man          |    7 +
>>  src/wcmCommon.c            |    4 ++-
>>  src/wcmConfig.c            |   55 
>> +++-
>>  src/wcmXCommand.c          |   32 -
>>  src/xf86Wacom.c            |    9 ++-
>>  src/xf86WacomDefs.h        |    4 ++-
>>  tools/xsetwacom.c          |   18 +-
>>  8 files changed, 126 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/wacom-properties.h b/include/wacom-properties.h
>> index 0bb84b1..b2a3523 100644
>> --- a/include/wacom-properties.h
>> +++ b/include/wacom-properties.h
>> @@ -46,6 +46,9 @@
>>   */
>>  #define WACOM_PROP_STRIPBUTTONS "Wacom Strip Buttons"
>>
>> +/* 8 bit, 2 values, LED0 (right side) and LED1 (left side) */
>> +#define WACOM_PROP_LED "Wacom LEDs"
>> +
>>  /* 8 bit, 6 values, rel wheel up, rel wheel down, abs wheel up, abs wheel 
>> down, abs wheel 2 up, abs wheel 2 down
>>    OR
>>    Atom, 6 values , rel wheel up, rel wheel down, abs wheel up, abs wheel 
>> down, abs wheel 2 up, abs wheel 2 down
>> diff --git a/man/xsetwacom.man b/man/xsetwacom.man
>> index dc0995f..58a4427 100644
>> --- a/man/xsetwacom.man
>> +++ b/man/xsetwacom.man
>> @@ -201,6 +201,13 @@ sets the max distance from tablet to stop reporting 
>> movement for cursor in
>>  relative mode. Default for Intuos series is 10, for Graphire series 
>> (including
>>  Volitos) is 42. Only available for the cursor/puck device.
>>  .TP
>> +\fBLED0\fR status
>> +Selects which LED in the first bank of LEDs should be lit. Intuos4/Cintiq 
>> 21UX/Cintiq 24HD. Default:  0,
>> +range of 0 to 3.
>> +.TP
>> +\fBLED1\fR status
>> +Selects which LED in the second bank of LEDs should be lit. Cintiq 
>> 21UX/24HD. Default:  0, range of 0 to 3.
>> +.TP
>>  \fBThreshold\fR level
>>  Set the minimum pressure necessary to generate a Button event for the stylus
>>  tip, eraser, or touch.  The pressure levels of all tablets are normalized to
>> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
>> index 0f041e3..a337441 100644
>> --- a/src/wcmCommon.c
>> +++ b/src/wcmCommon.c
>> @@ -1,6 +1,6 @@
>>  /*
>>  * Copyright 1995-2002 by Frederic Lepied, France. 
>> - * Copyright 2002-2010 by Ping Cheng, Wacom. 
>> + * Copyright 2002-2012 by Ping Cheng, Wacom. 
>>  *
>>  * This program is free software; you can redistribute it and/or
>>  * modify it under the terms of the GNU General Public License
>> @@ -1472,6 +1472,8 @@ WacomCommonPtr wcmNewCommon(void)
>>        common->wcmMaxStripY = 4096;       /* Max fingerstrip Y */
>>        common->wcmMaxtiltX = 128;         /* Max tilt in X directory */
>>        common->wcmMaxtiltY = 128;         /* Max tilt in Y directory */
>> +       common->fd_sysfs[0] = -1;          /* file descriptor to sysfs led0 
>> */
>> +       common->fd_sysfs[1] = -1;          /* file descriptor to sysfs led1 
>> */
>>        common->wcmCursorProxoutDistDefault = PROXOUT_INTUOS_DISTANCE;
>>                        /* default to Intuos */
>>        common->wcmSuppress = DEFAULT_SUPPRESS;
>> diff --git a/src/wcmConfig.c b/src/wcmConfig.c
>> index 5920e11..1dd9d03 100644
>> --- a/src/wcmConfig.c
>> +++ b/src/wcmConfig.c
>> @@ -1,6 +1,6 @@
>>  /*
>>  * Copyright 1995-2002 by Frederic Lepied, France. 
>> - * Copyright 2002-2010 by Ping Cheng, Wacom. 
>> + * Copyright 2002-2012 by Ping Cheng, Wacom. 
>>  *
>>  * This program is free software; you can redistribute it and/or
>>  * modify it under the terms of the GNU General Public License
>> @@ -21,6 +21,7 @@
>>  #include 
>>  #endif
>>
>> +#include 
>>  #include "xf86Wacom.h"
>>  #include "wcmFilter.h"
>>  #include 
>> @@ -441,6 +442,53 @@ static int wcmIsHotpluggedDevice(InputInfoPtr pInfo)
>>        return !strcmp(source, "_driver/wacom");
>>  }
>>
>> +static void wcmStoreLEDsysfsInfo(InputInfoPtr pInfo)
>> +{
>> +       WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
>> +       WacomCommonPtr  common = priv->common;
>> +       struct stat st;
>> +       struct udev *udev = udev_new();
>> +       struct udev_device *parent;
>> +       struct udev_device *device;
>> +       char fs_path[128]

Re: [Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-01-25 Thread Jason Gerecke
This covers most of the suggested changes. I'm not sure yet how we
want to expose the properties through X, so changes regarding that
haven't been folded in.

Jason

---
Day xee-nee-svsh duu-'ushtlh-ts'it;
nuu-wee-ya' duu-xan' 'vm-nvshtlh-ts'it.
Huu-chan xuu naa~-gha.



On Wed, Jan 25, 2012 at 1:54 PM, Jason Gerecke  wrote:
> Signed-off-by: Jason Gerecke 
> ---
> Changes from v2:
>    Deduplicate storing in sysfs
>    Deduplicate fd closing
>    Deduplicate LED setting by looping through all groups
>    Change wording of xsetwacom property description
>    Consolidate led{0,1}_status variables into led_status array
>    Stop udev device leak
>    Change variables fd_sysfs{0,1} to an array fd_sysfs[2]
>    Remove superflous function name
>
>  include/wacom-properties.h |    3 ++
>  man/xsetwacom.man          |    7 +
>  src/wcmCommon.c            |    4 ++-
>  src/wcmConfig.c            |   55 
> +++-
>  src/wcmXCommand.c          |   32 -
>  src/xf86Wacom.c            |    9 ++-
>  src/xf86WacomDefs.h        |    4 ++-
>  tools/xsetwacom.c          |   18 +-
>  8 files changed, 126 insertions(+), 6 deletions(-)
>
> diff --git a/include/wacom-properties.h b/include/wacom-properties.h
> index 0bb84b1..b2a3523 100644
> --- a/include/wacom-properties.h
> +++ b/include/wacom-properties.h
> @@ -46,6 +46,9 @@
>   */
>  #define WACOM_PROP_STRIPBUTTONS "Wacom Strip Buttons"
>
> +/* 8 bit, 2 values, LED0 (right side) and LED1 (left side) */
> +#define WACOM_PROP_LED "Wacom LEDs"
> +
>  /* 8 bit, 6 values, rel wheel up, rel wheel down, abs wheel up, abs wheel 
> down, abs wheel 2 up, abs wheel 2 down
>    OR
>    Atom, 6 values , rel wheel up, rel wheel down, abs wheel up, abs wheel 
> down, abs wheel 2 up, abs wheel 2 down
> diff --git a/man/xsetwacom.man b/man/xsetwacom.man
> index dc0995f..58a4427 100644
> --- a/man/xsetwacom.man
> +++ b/man/xsetwacom.man
> @@ -201,6 +201,13 @@ sets the max distance from tablet to stop reporting 
> movement for cursor in
>  relative mode. Default for Intuos series is 10, for Graphire series 
> (including
>  Volitos) is 42. Only available for the cursor/puck device.
>  .TP
> +\fBLED0\fR status
> +Selects which LED in the first bank of LEDs should be lit. Intuos4/Cintiq 
> 21UX/Cintiq 24HD. Default:  0,
> +range of 0 to 3.
> +.TP
> +\fBLED1\fR status
> +Selects which LED in the second bank of LEDs should be lit. Cintiq 
> 21UX/24HD. Default:  0, range of 0 to 3.
> +.TP
>  \fBThreshold\fR level
>  Set the minimum pressure necessary to generate a Button event for the stylus
>  tip, eraser, or touch.  The pressure levels of all tablets are normalized to
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 0f041e3..a337441 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -1,6 +1,6 @@
>  /*
>  * Copyright 1995-2002 by Frederic Lepied, France. 
> - * Copyright 2002-2010 by Ping Cheng, Wacom. 
> + * Copyright 2002-2012 by Ping Cheng, Wacom. 
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
> @@ -1472,6 +1472,8 @@ WacomCommonPtr wcmNewCommon(void)
>        common->wcmMaxStripY = 4096;       /* Max fingerstrip Y */
>        common->wcmMaxtiltX = 128;         /* Max tilt in X directory */
>        common->wcmMaxtiltY = 128;         /* Max tilt in Y directory */
> +       common->fd_sysfs[0] = -1;          /* file descriptor to sysfs led0 */
> +       common->fd_sysfs[1] = -1;          /* file descriptor to sysfs led1 */
>        common->wcmCursorProxoutDistDefault = PROXOUT_INTUOS_DISTANCE;
>                        /* default to Intuos */
>        common->wcmSuppress = DEFAULT_SUPPRESS;
> diff --git a/src/wcmConfig.c b/src/wcmConfig.c
> index 5920e11..1dd9d03 100644
> --- a/src/wcmConfig.c
> +++ b/src/wcmConfig.c
> @@ -1,6 +1,6 @@
>  /*
>  * Copyright 1995-2002 by Frederic Lepied, France. 
> - * Copyright 2002-2010 by Ping Cheng, Wacom. 
> + * Copyright 2002-2012 by Ping Cheng, Wacom. 
>  *
>  * This program is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU General Public License
> @@ -21,6 +21,7 @@
>  #include 
>  #endif
>
> +#include 
>  #include "xf86Wacom.h"
>  #include "wcmFilter.h"
>  #include 
> @@ -441,6 +442,53 @@ static int wcmIsHotpluggedDevice(InputInfoPtr pInfo)
>        return !strcmp(source, "_driver/wacom");
>  }
>
> +static void wcmStoreLEDsysfsInfo(InputInfoPtr pInfo)
> +{
> +       WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
> +       WacomCommonPtr  common = priv->common;
> +       struct stat st;
> +       struct udev *udev = udev_new();
> +       struct udev_device *parent;
> +       struct udev_device *device;
> +       char fs_path[128], buf[10];
> +       int err = -1;
> +       int i;
> +
> +       stat(common->device_path, &st);
> +       device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
> +       if (!device)
> +      

[Linuxwacom-devel] [PATCH v3] Enable LED status change through xsetwacom

2012-01-25 Thread Jason Gerecke
Signed-off-by: Jason Gerecke 
---
Changes from v2:
Deduplicate storing in sysfs
Deduplicate fd closing
Deduplicate LED setting by looping through all groups
Change wording of xsetwacom property description
Consolidate led{0,1}_status variables into led_status array
Stop udev device leak
Change variables fd_sysfs{0,1} to an array fd_sysfs[2]
Remove superflous function name

 include/wacom-properties.h |3 ++
 man/xsetwacom.man  |7 +
 src/wcmCommon.c|4 ++-
 src/wcmConfig.c|   55 +++-
 src/wcmXCommand.c  |   32 -
 src/xf86Wacom.c|9 ++-
 src/xf86WacomDefs.h|4 ++-
 tools/xsetwacom.c  |   18 +-
 8 files changed, 126 insertions(+), 6 deletions(-)

diff --git a/include/wacom-properties.h b/include/wacom-properties.h
index 0bb84b1..b2a3523 100644
--- a/include/wacom-properties.h
+++ b/include/wacom-properties.h
@@ -46,6 +46,9 @@
   */
 #define WACOM_PROP_STRIPBUTTONS "Wacom Strip Buttons"
 
+/* 8 bit, 2 values, LED0 (right side) and LED1 (left side) */
+#define WACOM_PROP_LED "Wacom LEDs"
+
 /* 8 bit, 6 values, rel wheel up, rel wheel down, abs wheel up, abs wheel 
down, abs wheel 2 up, abs wheel 2 down
OR
Atom, 6 values , rel wheel up, rel wheel down, abs wheel up, abs wheel 
down, abs wheel 2 up, abs wheel 2 down
diff --git a/man/xsetwacom.man b/man/xsetwacom.man
index dc0995f..58a4427 100644
--- a/man/xsetwacom.man
+++ b/man/xsetwacom.man
@@ -201,6 +201,13 @@ sets the max distance from tablet to stop reporting 
movement for cursor in
 relative mode. Default for Intuos series is 10, for Graphire series (including
 Volitos) is 42. Only available for the cursor/puck device.
 .TP
+\fBLED0\fR status
+Selects which LED in the first bank of LEDs should be lit. Intuos4/Cintiq 
21UX/Cintiq 24HD. Default:  0,
+range of 0 to 3.
+.TP
+\fBLED1\fR status
+Selects which LED in the second bank of LEDs should be lit. Cintiq 21UX/24HD. 
Default:  0, range of 0 to 3.
+.TP
 \fBThreshold\fR level
 Set the minimum pressure necessary to generate a Button event for the stylus
 tip, eraser, or touch.  The pressure levels of all tablets are normalized to
diff --git a/src/wcmCommon.c b/src/wcmCommon.c
index 0f041e3..a337441 100644
--- a/src/wcmCommon.c
+++ b/src/wcmCommon.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-2002 by Frederic Lepied, France. 
- * Copyright 2002-2010 by Ping Cheng, Wacom. 
+ * Copyright 2002-2012 by Ping Cheng, Wacom. 
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -1472,6 +1472,8 @@ WacomCommonPtr wcmNewCommon(void)
common->wcmMaxStripY = 4096;   /* Max fingerstrip Y */
common->wcmMaxtiltX = 128; /* Max tilt in X directory */
common->wcmMaxtiltY = 128; /* Max tilt in Y directory */
+   common->fd_sysfs[0] = -1;  /* file descriptor to sysfs led0 */
+   common->fd_sysfs[1] = -1;  /* file descriptor to sysfs led1 */
common->wcmCursorProxoutDistDefault = PROXOUT_INTUOS_DISTANCE;
/* default to Intuos */
common->wcmSuppress = DEFAULT_SUPPRESS;
diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 5920e11..1dd9d03 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -1,6 +1,6 @@
 /*
  * Copyright 1995-2002 by Frederic Lepied, France. 
- * Copyright 2002-2010 by Ping Cheng, Wacom. 
+ * Copyright 2002-2012 by Ping Cheng, Wacom. 
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
 #include 
 #endif
 
+#include 
 #include "xf86Wacom.h"
 #include "wcmFilter.h"
 #include 
@@ -441,6 +442,53 @@ static int wcmIsHotpluggedDevice(InputInfoPtr pInfo)
return !strcmp(source, "_driver/wacom");
 }
 
+static void wcmStoreLEDsysfsInfo(InputInfoPtr pInfo)
+{
+   WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
+   WacomCommonPtr  common = priv->common;
+   struct stat st;
+   struct udev *udev = udev_new();
+   struct udev_device *parent;
+   struct udev_device *device;
+   char fs_path[128], buf[10];
+   int err = -1;
+   int i;
+
+   stat(common->device_path, &st);
+   device = udev_device_new_from_devnum(udev, 'c', st.st_rdev);
+   if (!device)
+   return;
+
+   parent = udev_device_get_parent_with_subsystem_devtype(device,
+"usb", NULL);
+
+   if (!parent)
+   goto out;
+
+   for (i = 0; i < ARRAY_SIZE(common->led_status); i++)
+   {
+   sprintf(fs_path, "%s/wacom_led/status_led%d_select",
+   udev_device_get_syspath(parent), i);
+   common->fd_sysfs[i] = open(fs_path, O_RDWR);
+   if (common->f