[PATCH synaptics 1/8] United functions of SynapticsDefaultDimensions() and ReadDevDimensions()

Peter Hutterer peter.hutterer at who-t.net
Sun Feb 27 19:14:02 PST 2011


On Sun, Feb 27, 2011 at 01:11:44AM +0500, Alexandr Shadchin wrote:
> There is no point doing the same thing in different places
> 
> Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>
> ---
>  src/alpscomm.c     |    2 +-
>  src/ps2comm.c      |    2 +-
>  src/psmcomm.c      |    2 +-
>  src/synaptics.c    |   96 ++++++++++++++++++++-------------------------------
>  src/synapticsstr.h |    3 --
>  5 files changed, 41 insertions(+), 64 deletions(-)
> 
> diff --git a/src/alpscomm.c b/src/alpscomm.c
> index 84d2136..c5af681 100644
> --- a/src/alpscomm.c
> +++ b/src/alpscomm.c
> @@ -233,5 +233,5 @@ struct SynapticsProtocolOperations alps_proto_operations = {
>      ALPSQueryHardware,
>      ALPSReadHwState,
>      ALPSAutoDevProbe,
> -    SynapticsDefaultDimensions
> +    NULL
>  };
> diff --git a/src/ps2comm.c b/src/ps2comm.c
> index 4e372b3..a34613e 100644
> --- a/src/ps2comm.c
> +++ b/src/ps2comm.c
> @@ -672,5 +672,5 @@ struct SynapticsProtocolOperations psaux_proto_operations = {
>      PS2QueryHardware,
>      PS2ReadHwState,
>      PS2AutoDevProbe,
> -    SynapticsDefaultDimensions
> +    NULL
>  };
> diff --git a/src/psmcomm.c b/src/psmcomm.c
> index 741cd1d..903e6dd 100644
> --- a/src/psmcomm.c
> +++ b/src/psmcomm.c
> @@ -181,5 +181,5 @@ struct SynapticsProtocolOperations psm_proto_operations = {
>      PSMQueryHardware,
>      PSMReadHwState,
>      PSMAutoDevProbe,
> -    SynapticsDefaultDimensions
> +    NULL
>  };
> diff --git a/src/synaptics.c b/src/synaptics.c
> index 56ce725..daa0542 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -174,63 +174,6 @@ _X_EXPORT XF86ModuleData synapticsModuleData = {
>  /*****************************************************************************
>   *	Function Definitions
>   ****************************************************************************/
> -/**
> - * Fill in default dimensions for backends that cannot query the hardware.
> - * Eventually, we want the edges to be 1900/5400 for x, 1900/4000 for y.
> - * These values are based so that calculate_edge_widths() will give us the
> - * right values.
> - *
> - * The default values 1900, etc. come from the dawn of time, when men where
> - * men, or possibly apes.
> - */
> -void
> -SynapticsDefaultDimensions(InputInfoPtr pInfo)
> -{
> -    SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
> -
> -    if (priv->minx >= priv->maxx)
> -    {
> -	priv->minx = 1615;
> -	priv->maxx = 5685;
> -	priv->resx = 0;
> -
> -	xf86Msg(X_PROBED,
> -		"%s: invalid x-axis range.  defaulting to %d - %d\n",
> -		pInfo->name, priv->minx, priv->maxx);
> -    }
> -
> -    if (priv->miny >= priv->maxy)
> -    {
> -	priv->miny = 1729;
> -	priv->maxy = 4171;
> -	priv->resx = 0;
> -
> -	xf86Msg(X_PROBED,
> -		"%s: invalid y-axis range.  defaulting to %d - %d\n",
> -		pInfo->name, priv->miny, priv->maxy);
> -    }
> -
> -    if (priv->minp >= priv->maxp)
> -    {
> -	priv->minp = 0;
> -	priv->maxp = 256;
> -
> -	xf86Msg(X_PROBED,
> -		"%s: invalid pressure range.  defaulting to %d - %d\n",
> -		pInfo->name, priv->minp, priv->maxp);
> -    }
> -
> -    if (priv->minw >= priv->maxw)
> -    {
> -	priv->minw = 0;
> -	priv->maxw = 16;
> -
> -	xf86Msg(X_PROBED,
> -		"%s: invalid finger width range.  defaulting to %d - %d\n",
> -		pInfo->name, priv->minw, priv->maxw);
> -    }
> -}
> -
>  static void
>  SetDeviceAndProtocol(InputInfoPtr pInfo)
>  {
> @@ -444,7 +387,6 @@ static void set_default_parameters(InputInfoPtr pInfo)
>       * If the range was autodetected, apply these edge widths to all four
>       * sides.
>       */
> -    SynapticsDefaultDimensions(pInfo);
>  
>      width = abs(priv->maxx - priv->minx);
>      height = abs(priv->maxy - priv->miny);
> @@ -2613,6 +2555,44 @@ ReadDevDimensions(InputInfoPtr pInfo)
>  
>      if (priv->proto_ops->ReadDevDimensions)
>  	priv->proto_ops->ReadDevDimensions(pInfo);
> +
> +    if (priv->minx >= priv->maxx) {
> +        priv->minx = 1615;
> +        priv->maxx = 5685;
> +        priv->resx = 0;
> +
> +        xf86Msg(X_PROBED,
> +                "%s: invalid x-axis range.  defaulting to %d - %d\n",
> +                pInfo->name, priv->minx, priv->maxx);
> +    }
> +
> +    if (priv->miny >= priv->maxy) {
> +        priv->miny = 1729;
> +        priv->maxy = 4171;
> +        priv->resy = 0;
> +
> +        xf86Msg(X_PROBED,
> +                "%s: invalid y-axis range.  defaulting to %d - %d\n",
> +                pInfo->name, priv->miny, priv->maxy);
> +    }
> +
> +    if (priv->minp >= priv->maxp) {
> +        priv->minp = 0;
> +        priv->maxp = 256;
> +
> +        xf86Msg(X_PROBED,
> +                "%s: invalid pressure range.  defaulting to %d - %d\n",
> +                pInfo->name, priv->minp, priv->maxp);
> +    }
> +
> +    if (priv->minw >= priv->maxw) {
> +        priv->minw = 0;
> +        priv->maxw = 16;
> +
> +        xf86Msg(X_PROBED,
> +                "%s: invalid finger width range.  defaulting to %d - %d\n",
> +                pInfo->name, priv->minw, priv->maxw);
> +    }
>  }
>  
>  static Bool
> diff --git a/src/synapticsstr.h b/src/synapticsstr.h
> index 066b3f3..8f6593e 100644
> --- a/src/synapticsstr.h
> +++ b/src/synapticsstr.h
> @@ -243,7 +243,4 @@ typedef struct _SynapticsPrivateRec
>      enum TouchpadModel model;          /* The detected model */
>  } SynapticsPrivate;
>  
> -
> -extern void SynapticsDefaultDimensions(InputInfoPtr pInfo);
> -
>  #endif /* _SYNAPTICSSTR_H_ */
> -- 
> 1.7.3.5

yes and no. I don't see the need for removing the actual function since it
aids readabilty. Though it is a bit of a misnomer, it should probably be
called SanitizeDimensions or so. and simply be called after
the ReadDevDimensions backend-specific hook is called.

Cheers,
  Peter


More information about the xorg-devel mailing list