On Tue, Nov 01, 2016 at 11:43:42AM -0700, Jason Gerecke wrote:
> The driver has historically normalized the pressure range of all kernel
> devices to 0..2047 rather than using their native range to keep things
> like the application of the pressure curve simple. Pens that report more
> than 2048 pressure levels are also normalized down to this range though,
> reducing their precision. In order to accomodate the new 8K pen (and any
> future pens with even higher precision), this patch bumps up the full-
> scale range to be 0..65535. This number was chosen both because it far
> exceeds anything currently known about, and also because it matches the
> normalization range used over the wire by the Wayland tablet protocol.
>
> Note that the WACOM_PROP_PRESSURE_THRESHOLD value has been tied to the
> normalized (2048-level) pressure range for some time, meaning that we
> cannot simply change the range without causing a change in the perceived
> threshold for users. To ensure compatibility, the value is interpreted
> as a fraction of 2048 and then scaled to the actual normalization range.
>
> Signed-off-by: Jason Gerecke <[email protected]>
> ---
> Changes from v1:
> * Added helper functions to isolate the scaling to/from the 2048-level
> range historically used.
>
> src/wcmXCommand.c | 26 +++++++++++++++++++++++++-
> src/xf86WacomDefs.h | 2 +-
> 2 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
> index 02278ba..df7fcea 100644
> --- a/src/wcmXCommand.c
> +++ b/src/wcmXCommand.c
> @@ -104,6 +104,26 @@ static Atom prop_debuglevels;
> #endif
>
> /**
> + * Calculate a user-visible pressure level from a driver-internal pressure
> + * level. Pressure settings exposed to the user assume a range of 0-2047
> + * while the driver scales everything to a range of 0-FILTER_PRESSURE_RES.
> + */
> +static inline int wcmInternalToUserPressure(int pressure)
> +{
> + return pressure / (FILTER_PRESSURE_RES / 2048);
> +}
> +
> +/**
> + * Calculate a driver-internal pressure level from a user-visible pressure
> + * level. Pressure settings exposed to the user assume a range of 0-2047
> + * while the driver scales everything to a range of 0-FILTER_PRESSURE_RES.
> + */
> +static inline int wcmUserToInternalPressure(int pressure)
> +{
> + return pressure * (FILTER_PRESSURE_RES / 2048);
> +}
> +
> +/**
> * Resets an arbitrary Action property, given a pointer to the old
> * handler and information about the new Action.
> */
> @@ -256,6 +276,7 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
> }
>
> values[0] = (!common->wcmMaxZ) ? 0 : common->wcmThreshold;
> + values[0] = wcmInternalToUserPressure(values[0]);
> prop_threshold = InitWcmAtom(pInfo->dev, WACOM_PROP_PRESSURE_THRESHOLD,
> XA_INTEGER, 32, 1, values);
>
> values[0] = common->wcmSuppress;
> @@ -827,6 +848,7 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property,
> XIPropertyValuePtr prop,
> common->wcmCursorProxoutDist = value;
> } else if (property == prop_threshold)
> {
> + const INT32 MAXIMUM =
> wcmInternalToUserPressure(FILTER_PRESSURE_RES);
this one {sh|c}ould be static but I think the compiler would optimise this
correctly anyway.
Reviewed-by: Peter Hutterer <[email protected]>
Cheers,
Peter
> INT32 value;
>
> if (prop->size != 1 || prop->format != 32)
> @@ -836,8 +858,10 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property,
> XIPropertyValuePtr prop,
>
> if (value == -1)
> value = DEFAULT_THRESHOLD;
> - else if ((value < 1) || (value > FILTER_PRESSURE_RES))
> + else if ((value < 1) || (value > MAXIMUM))
> return BadValue;
> + else
> + value = wcmUserToInternalPressure(value);
>
> if (!checkonly)
> common->wcmThreshold = value;
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index 31355ed..3961545 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -180,7 +180,7 @@ struct _WacomModel
>
> #define IsUSBDevice(common) ((common)->wcmDevCls == &gWacomUSBDevice)
>
> -#define FILTER_PRESSURE_RES 2048 /* maximum points in pressure curve */
> +#define FILTER_PRESSURE_RES 65536 /* maximum points in pressure curve */
> /* Tested result for setting the pressure threshold to a reasonable value */
> #define THRESHOLD_TOLERANCE (FILTER_PRESSURE_RES / 125)
> #define DEFAULT_THRESHOLD (FILTER_PRESSURE_RES / 75)
> --
> 2.10.1
>
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel