In case you guys are waiting for my feedback, you can put:
From: Ping Cheng <[email protected]> and
Signed-off-by: Ping Cheng <[email protected]>
to the patch and commit it. One nitpick inline.
Ping
On Thu, Jan 26, 2012 at 5:54 AM, Jason Gerecke <[email protected]> wrote:
> Signed-off-by: Jason Gerecke <[email protected]>
> ---
> 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. <[email protected]>
> - * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
> + * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
> *
> * 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. <[email protected]>
> - * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
> + * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
> *
> * 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 <config.h>
> #endif
>
> +#include <libudev.h>
> #include "xf86Wacom.h"
> #include "wcmFilter.h"
> #include <sys/stat.h>
> @@ -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->fd_sysfs[i] >= 0)
> + {
> + SYSCALL(err = read(common->fd_sysfs[i], buf, 1));
> + if (err < -1)
> + {
> + xf86Msg(X_WARNING, "%s: failed to get
> led%d status\n", pInfo->name, i);
> + }
> + else
> + common->led_status[i] = buf[0] - '0';
> + }
> + else
> + DBG(2, common, "No LED%d sysfs on %s for %s\n",
> + i, fs_path, pInfo->name);
> + }
> +
> +out:
> + free(device);
> +}
> +
> /* wcmPreInit - called for each input devices with the driver set to
> * "wacom" */
> #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
> @@ -524,9 +572,14 @@ static int wcmPreInit(InputDriverPtr drv,
> InputInfoPtr pInfo, int flags)
>
> /* check if this is the first tool on the port */
> if (!wcmMatchDevice(pInfo, &common))
> + {
> /* initialize supported keys with the first tool on the
> port */
> wcmDeviceTypeKeys(pInfo);
>
> + /* store lED sysfs file descriptor and initial status */
>
You meant LED, didn't you?
> + wcmStoreLEDsysfsInfo(pInfo);
> + }
> +
> common->debugLevel = xf86SetIntOption(pInfo->options,
> "CommonDBG",
> common->debugLevel);
> oldname = pInfo->name;
> diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
> index 40393dc..1c649df 100644
> --- a/src/wcmXCommand.c
> +++ b/src/wcmXCommand.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright 2007-2010 by Ping Cheng, Wacom. <[email protected]>
> + * Copyright 2007-2012 by Ping Cheng, Wacom. <[email protected]>
> *
> * This program is free software; you can redistribute it and/or
> * modify it under the terms of the GNU General Public License
> @@ -91,6 +91,7 @@ Atom prop_tv_resolutions;
> Atom prop_cursorprox;
> Atom prop_threshold;
> Atom prop_suppress;
> +Atom prop_led;
> Atom prop_touch;
> Atom prop_gesture;
> Atom prop_gesture_param;
> @@ -206,6 +207,10 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
> values[1] = common->wcmRawSample;
> prop_suppress = InitWcmAtom(pInfo->dev, WACOM_PROP_SAMPLE,
> XA_INTEGER, 32, 2, values);
>
> + values[0] = common->led_status[0];
> + values[1] = common->led_status[1];
> + prop_led = InitWcmAtom(pInfo->dev, WACOM_PROP_LED, XA_INTEGER, 8,
> 2, values);
> +
> values[0] = common->wcmTouch;
> prop_touch = InitWcmAtom(pInfo->dev, WACOM_PROP_TOUCH, XA_INTEGER,
> 8, 1, values);
>
> @@ -695,6 +700,31 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property,
> XIPropertyValuePtr prop,
> common->wcmSuppress = values[0];
> common->wcmRawSample = values[1];
> }
> + } else if (property == prop_led)
> + {
> + CARD8 *values;
> + int i;
> +
> + if (prop->size != 2 || prop->format != 8)
> + return BadValue;
> +
> + values = (CARD8*)prop->data;
> +
> + for (i = 0; i < prop->size; i++)
> + {
> + if (values[i] < 0 || values[i] > 3)
> + return BadValue;
> +
> + if (common->fd_sysfs[i] >= 0 && !checkonly)
> + {
> + char buf[10];
> + int err = -1;
> + sprintf(buf, "%d", values[i]);
> + err = xf86WriteSerial(common->fd_sysfs[i],
> buf, strlen(buf));
> + if (err == strlen(buf))
> + common->led_status[i] = values[i];
> + }
> + }
> } else if (property == prop_rotation)
> {
> CARD8 value;
> diff --git a/src/xf86Wacom.c b/src/xf86Wacom.c
> index d1c149f..5be7363 100644
> --- a/src/xf86Wacom.c
> +++ b/src/xf86Wacom.c
> @@ -1,6 +1,6 @@
> /*
> * Copyright 1995-2002 by Frederic Lepied, France. <[email protected]>
> - * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
> + * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
> *
> * This program is free software; you can redistribute it and/or
> * modify it under the terms of the GNU General Public License
> @@ -758,6 +758,7 @@ static void wcmDevClose(InputInfoPtr pInfo)
> {
> WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
> WacomCommonPtr common = priv->common;
> + int i;
>
> DBG(4, priv, "Wacom number of open devices = %d\n",
> common->fd_refs);
>
> @@ -770,6 +771,12 @@ static void wcmDevClose(InputInfoPtr pInfo)
> xf86CloseSerial (common->fd);
> }
> }
> +
> + for (i = 0; i < ARRAY_SIZE(common->fd_sysfs); i++)
> + {
> + xf86CloseSerial(common->fd_sysfs[i]);
> + common->fd_sysfs[i] = -1;
> + }
> }
>
> static void wcmEnableDisableTool(DeviceIntPtr dev, Bool enable)
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index 2f3f7b4..eb39c4f 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -1,6 +1,6 @@
> /*
> * Copyright 1995-2002 by Frederic Lepied, France. <[email protected]>
> - * Copyright 2002-2010 by Ping Cheng, Wacom. <[email protected]>
> + * Copyright 2002-2012 by Ping Cheng, Wacom. <[email protected]>
> *
> * This program is free software; you can redistribute it and/or
> * modify it under the terms of the GNU General Public License
> @@ -420,6 +420,8 @@ struct _WacomCommonRec
> int tablet_type; /* bitmask of tablet features
> (WCM_LCD, WCM_PEN, etc) */
> int fd; /* file descriptor to tablet */
> int fd_refs; /* number of references to fd; if =0,
> fd is invalid */
> + int fd_sysfs[2]; /* file descriptor to sysfs led0 and
> led1 */
> + unsigned char led_status[2]; /* Left and Right LED status */
> unsigned long wcmKeys[NBITS(KEY_MAX)]; /* supported tool types for
> the device */
> WacomDevicePtr wcmTouchDevice; /* The pointer for pen to access the
> touch tool of the same device id
> */
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index 9ab285b..83fb610 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -361,6 +361,22 @@ static param_t parameters[] =
> .get_func = get_map,
> },
> {
> + .name = "LED0",
> + .desc = "Selects which LED in the first bank of LEDs
> should be lit. ",
> + .prop_name = WACOM_PROP_LED,
> + .prop_format = 8,
> + .prop_offset = 0,
> + .arg_count = 1,
> + },
> + {
> + .name = "LED1",
> + .desc = "Selects which LED in the second bank of LEDs
> should be lit. ",
> + .prop_name = WACOM_PROP_LED,
> + .prop_format = 8,
> + .prop_offset = 1,
> + .arg_count = 1,
> + },
> + {
> .name = "Threshold",
> .desc = "Sets tip/eraser pressure threshold "
> "(default is 27). ",
> @@ -2689,7 +2705,7 @@ static void test_parameter_number(void)
> * deprecated them.
> * Numbers include trailing NULL entry.
> */
> - assert(ARRAY_SIZE(parameters) == 36);
> + assert(ARRAY_SIZE(parameters) == 38);
> assert(ARRAY_SIZE(deprecated_parameters) == 17);
> }
>
> --
> 1.7.7.3
>
>
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Linuxwacom-devel mailing list
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel