On Mon, Apr 18, 2011 at 11:26:41AM -0700, Jason Gerecke wrote:
> This tweaks the prior ToolSerials patch to use the existing
> infrastructure where appropriate. For instance, using the 'WacomTool'
> struct instead of the custom 'WacomToolSerial' struct.
> 
> This should actually be integrated as a "fixup", but is included
> here to more easily see the changes from the original.

Thanks, I've squashed 1 and 2 together and merged them in, together with the
man page patch.

> Signed-off-by: Jason Gerecke <killert...@gmail.com>
> ---
>  src/wcmCommon.c         |   13 +++++---
>  src/wcmValidateDevice.c |   69 
> +++++++++++++++++++++++------------------------
>  src/xf86WacomDefs.h     |   22 +-------------
>  3 files changed, 44 insertions(+), 60 deletions(-)
> 
> diff --git a/src/wcmCommon.c b/src/wcmCommon.c
> index 822306c..3905b07 100644
> --- a/src/wcmCommon.c
> +++ b/src/wcmCommon.c
> @@ -1390,12 +1390,15 @@ void wcmFreeCommon(WacomCommonPtr *ptr)
>       if (--common->refcnt == 0)
>       {
>               free(common->private);
> -             while (--common->nserials >= 0)
> +             while (common->serials)
>               {
> -                     DBG(10, common, "Free common serial %d: %d %s\n", 
> common->nserials,
> -                                     
> common->serials[common->nserials]->serial,
> -                                     
> common->serials[common->nserials]->name);
> -                     free(common->serials[common->nserials]);
> +                     DBG(10, common, "Free common serial: %d %s\n",
> +                                     common->serials->serial,
> +                                     common->serials->name);
> +
> +                     WacomToolPtr next = common->serials->next;

for better or worse, we don't mix code and declarations. Moved the
declaration up.

Cheers,
  Peter

> +                     free(common->serials);
> +                     common->serials = next;
>               }
>               free(common);
>       }
> diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
> index 1a67994..8e4f4cd 100644
> --- a/src/wcmValidateDevice.c
> +++ b/src/wcmValidateDevice.c
> @@ -311,7 +311,7 @@ static InputOption *wcmOptionDupConvert(InputInfoPtr 
> pInfo, const char* basename
>       WacomDevicePtr priv = pInfo->private;
>       WacomCommonPtr common = priv->common;
>       pointer original = pInfo->options;
> -     WacomToolSerialPtr ser = common->serials[iserial];
> +     WacomToolPtr ser = common->serials;
>       InputOption *iopts = NULL, *new;
>       char *name;
>       pointer options;
> @@ -330,6 +330,8 @@ static InputOption *wcmOptionDupConvert(InputInfoPtr 
> pInfo, const char* basename
>  #endif
>       if (iserial > -1)
>       {
> +             while (ser->serial && ser->serial != iserial)
> +                     ser = ser->next;
>  
>               if (strlen(ser->name) > 0)
>                       rc = asprintf(&name, "%s %s %s", basename, ser->name, 
> type);
> @@ -474,29 +476,26 @@ void wcmHotplugSerials(InputInfoPtr pInfo, const char 
> *basename)
>  {
>       WacomDevicePtr  priv = (WacomDevicePtr)pInfo->private;
>       WacomCommonPtr  common = priv->common;
> -        int i;
> +     WacomToolPtr    ser = common->serials;
>  
> -     if (common->nserials > 0)
> +     while (ser)
>       {
> -             for (i = 0; i < common->nserials; i++)
> -             {
> -                     WacomToolSerialPtr ser = common->serials[i];
> -                     xf86Msg(X_INFO, "%s: hotplugging serial %d.\n", 
> pInfo->name, ser->serial);
> +             xf86Msg(X_INFO, "%s: hotplugging serial %d.\n", pInfo->name, 
> ser->serial);
>  
> -                     if (wcmIsAValidType(pInfo, "stylus") &&
> -                         (ser->types & SERIAL_HAS_STYLUS))
> -                             wcmQueueHotplug(pInfo, basename, "stylus", i);
> +             if (wcmIsAValidType(pInfo, "stylus") &&
> +                 (ser->typeid & STYLUS_ID))
> +                     wcmQueueHotplug(pInfo, basename, "stylus", ser->serial);
>  
> -                     if (wcmIsAValidType(pInfo, "eraser") &&
> -                         (ser->types & SERIAL_HAS_ERASER))
> -                             wcmQueueHotplug(pInfo, basename, "eraser", i);
> +             if (wcmIsAValidType(pInfo, "eraser") &&
> +                 (ser->typeid & ERASER_ID))
> +                     wcmQueueHotplug(pInfo, basename, "eraser", ser->serial);
>  
> -                     if (wcmIsAValidType(pInfo, "cursor") &&
> -                         (ser->types & SERIAL_HAS_CURSOR))
> -                             wcmQueueHotplug(pInfo, basename, "cursor", i);
> -             }
> -     }
> +             if (wcmIsAValidType(pInfo, "cursor") &&
> +                 (ser->typeid & CURSOR_ID))
> +                     wcmQueueHotplug(pInfo, basename, "cursor", ser->serial);
>  
> +             ser = ser->next;
> +     }
>  }
>  
>  void wcmHotplugOthers(InputInfoPtr pInfo, const char *basename)
> @@ -574,22 +573,21 @@ int wcmParseSerials (InputInfoPtr pInfo)
>       WacomCommonPtr  common = priv->common;
>       char            *s;
>  
> -     if (common->nserials > 0)
> +     if (common->serials)
>       {
> -             return 0; /*Parsing has been already done*/
> +             return 0; /*Parse has been already done*/
>       }
>  
>       s = xf86SetStrOption(pInfo->options, "ToolSerials", NULL);
>       if (s) /*Dont parse again, if the commons have values already*/
>       {
> -             int nserials = 0;
>               char* tok = strtok(s, ";");
> -             while ((tok != NULL) && (nserials < WCM_MAX_SERIALS))
> +             while (tok != NULL)
>               {
>                       int serial, nmatch;
>                       char type[strlen(tok) + 1];
>                       char name[strlen(tok) + 1];
> -                     WacomToolSerialPtr ser = calloc(1, 
> sizeof(WacomToolSerial));
> +                     WacomToolPtr ser = calloc(1, sizeof(WacomTool));
>  
>                       if (ser == NULL)
>                               return 1;
> @@ -610,7 +608,7 @@ int wcmParseSerials (InputInfoPtr pInfo)
>  
>                               ser->serial = serial;
>  
> -                             ser->types = SERIAL_HAS_STYLUS | 
> SERIAL_HAS_ERASER; /*Default to both tools*/
> +                             ser->typeid = STYLUS_ID | ERASER_ID; /*Default 
> to both tools*/
>                       }
>  
>                       if (nmatch >= 2)
> @@ -618,11 +616,11 @@ int wcmParseSerials (InputInfoPtr pInfo)
>                               xf86Msg(X_CONFIG, "%s: Tool %d has type %s.\n",
>                                       pInfo->name, serial, type);
>                               if ((strcmp(type, "pen") == 0) || (strcmp(type, 
> "airbrush") == 0))
> -                                     ser->types = SERIAL_HAS_STYLUS | 
> SERIAL_HAS_ERASER;
> +                                     ser->typeid = STYLUS_ID | ERASER_ID;
>                               else if (strcmp(type, "artpen") == 0)
> -                                     ser->types = SERIAL_HAS_STYLUS;
> +                                     ser->typeid = STYLUS_ID;
>                               else if (strcmp(type, "cursor") == 0)
> -                                     ser->types = SERIAL_HAS_CURSOR;
> +                                     ser->typeid = CURSOR_ID;
>                               else    xf86Msg(X_CONFIG, "%s: Invalid type %s, 
> defaulting to pen.\n",
>                                       pInfo->name, type);
>                       }
> @@ -635,17 +633,18 @@ int wcmParseSerials (InputInfoPtr pInfo)
>                       }
>                       else ser->name = ""; /*no name yet*/
>  
> -                     common->serials[nserials] = ser;
> +                     if (common->serials == NULL)
> +                             common->serials = ser;
> +                     else
> +                     {
> +                             WacomToolPtr tool = common->serials;
> +                             while (tool->next)
> +                                     tool = tool->next;
> +                             tool->next = ser;
> +                     }
>  
>                       tok = strtok(NULL,";");
> -                     nserials++;
>               }
> -             common->nserials = nserials;
> -
> -             if ((nserials == WCM_MAX_SERIALS) && (tok != NULL))
> -                     xf86Msg(X_CONFIG, "%s: Only %d tool serials supported, 
> ignored the rest.\n",
> -                             pInfo->name, WCM_MAX_SERIALS);
> -
>       }
>       return 0;
>  }
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index f045762..8bc3ab2 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -117,8 +117,6 @@ typedef struct _WacomFilterState WacomFilterState, 
> *WacomFilterStatePtr;
>  typedef struct _WacomDeviceClass WacomDeviceClass, *WacomDeviceClassPtr;
>  typedef struct _WacomTool WacomTool, *WacomToolPtr;
>  typedef struct _WacomToolArea WacomToolArea, *WacomToolAreaPtr;
> -typedef struct _WacomToolSerial WacomToolSerial, *WacomToolSerialPtr;
> -
>  
>  
> /******************************************************************************
>   * WacomModel - model-specific device capabilities
> @@ -199,7 +197,6 @@ struct _WacomModel
>                                        * For backword compability support, 
>                                        * tablet buttons besides the strips are
>                                        * treated as buttons */
> -#define WCM_MAX_SERIALS              32      /* maximum number of tool 
> serials to be hotplugged */
>  
>  /* get/set/property */
>  typedef struct _PROPINFO PROPINFO;
> @@ -413,10 +410,6 @@ enum WacomProtocol {
>       WCM_PROTOCOL_5
>  };
>  
> -#define SERIAL_HAS_ERASER 1
> -#define SERIAL_HAS_STYLUS 2
> -#define SERIAL_HAS_CURSOR 4
> -
>  struct _WacomCommonRec 
>  {
>       /* Do not move device_path, same offset as priv->name. Used by DBG 
> macro */
> @@ -490,8 +483,7 @@ struct _WacomCommonRec
>       void *private;               /* backend-specific information */
>  
>       WacomToolPtr wcmTool; /* List of unique tools */
> -     WacomToolSerialPtr serials[WCM_MAX_SERIALS];/* Serial numbers provided 
> at startup*/
> -     int nserials;                /*Number of serials configured*/
> +     WacomToolPtr serials; /* Serial numbers provided at startup*/
>  
>       /* DO NOT TOUCH THIS. use wcmRefCommon() instead */
>       int refcnt;                     /* number of devices sharing this 
> struct */
> @@ -509,21 +501,11 @@ struct _WacomTool
>       int typeid; /* Tool type */
>       int serial; /* Serial id, 0 == no serial id */
>       Bool enabled;
> +     char *name;
>  
>       InputInfoPtr device; /* The InputDevice connected to this tool */
>  };
>  
> -/******************************************************************************
> - * WacomToolSerial
> - 
> *****************************************************************************/
> -struct _WacomToolSerial
> -{
> -
> -     uint  serial; /* Serial id */
> -     uint  types;  /* Tool types this serial has */
> -     char *name;   /* Label for the tool*/
> -};
> -
>  #endif /*__XF86_XF86WACOMDEFS_H */
>  
>  /* vim: set noexpandtab tabstop=8 shiftwidth=8: */
> -- 
> 1.7.4.1
> 
> 
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload 
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve 
> application availability and disaster protection. Learn more about boosting 
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
> 

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to