[PATCH synaptics 1/2] Initialize the vendor/product id property if we know either.

Peter Hutterer peter.hutterer at who-t.net
Mon May 30 19:46:51 PDT 2011


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/eventcomm.c     |   10 ++++++++--
 src/properties.c    |   17 ++++++++++++++++-
 src/synapticsstr.h  |    4 +++-
 test/fake-symbols.c |    6 ++++++
 test/fake-symbols.h |    1 +
 5 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/eventcomm.c b/src/eventcomm.c
index fed8ce2..ba3f36b 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -178,7 +178,7 @@ static model_lookup_t model_lookup_table[] = {
  * @return TRUE on success or FALSE otherwise.
  */
 static Bool
-event_query_model(int fd, enum TouchpadModel *model_out)
+event_query_model(int fd, enum TouchpadModel *model_out, unsigned short *vendor_id, unsigned short *product_id)
 {
     struct input_id id;
     int rc;
@@ -194,6 +194,9 @@ event_query_model(int fd, enum TouchpadModel *model_out)
             *model_out = model_lookup->model;
     }
 
+    *vendor_id = id.vendor;
+    *product_id = id.product;
+
     return TRUE;
 }
 
@@ -500,7 +503,10 @@ EventReadDevDimensions(InputInfoPtr pInfo)
 
     if (event_query_is_touchpad(pInfo->fd, (proto_data) ? proto_data->need_grab : TRUE))
 	event_query_axis_ranges(pInfo);
-    event_query_model(pInfo->fd, &priv->model);
+    event_query_model(pInfo->fd, &priv->model, &priv->id_vendor, &priv->id_product);
+
+    xf86IDrvMsg(pInfo, X_PROBED, "Vendor %#hx Product %#hx\n",
+                priv->id_vendor, priv->id_product);
 }
 
 static Bool
diff --git a/src/properties.c b/src/properties.c
index 23b5a6a..4e831dc 100644
--- a/src/properties.c
+++ b/src/properties.c
@@ -42,6 +42,11 @@
 #ifndef XATOM_FLOAT
 #define XATOM_FLOAT "FLOAT"
 #endif
+
+#ifndef XI_PROP_PRODUCT_ID
+#define XI_PROP_PRODUCT_ID "Device Product ID"
+#endif
+
 static Atom float_type;
 
 Atom prop_edges                 = 0;
@@ -83,6 +88,7 @@ Atom prop_capabilities          = 0;
 Atom prop_resolution            = 0;
 Atom prop_area                  = 0;
 Atom prop_noise_cancellation    = 0;
+Atom prop_product_id            = 0;
 
 static Atom
 InitAtom(DeviceIntPtr dev, char *name, int format, int nvalues, int *values)
@@ -285,6 +291,14 @@ InitDeviceProperties(InputInfoPtr pInfo)
     prop_noise_cancellation = InitAtom(pInfo->dev,
             SYNAPTICS_PROP_NOISE_CANCELLATION, 32, 2, values);
 
+    /* only init product_id property if we actually know them */
+    if (priv->id_vendor || priv->id_product)
+    {
+        values[0] = priv->id_vendor;
+        values[1] = priv->id_product;
+        prop_product_id = InitAtom(pInfo->dev, XI_PROP_PRODUCT_ID, 32, 2, values);
+    }
+
 }
 
 int
@@ -666,7 +680,8 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
             return BadValue;
         para->hyst_x = hyst[0];
         para->hyst_y = hyst[1];
-    }
+    } else if (property == prop_product_id)
+        return BadValue; /* read-only */
 
     return Success;
 }
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 7cda748..e9ac7cb 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -240,7 +240,9 @@ typedef struct _SynapticsPrivateRec
     Bool has_width;			/* device reports finger width */
     Bool has_scrollbuttons;		/* device has physical scrollbuttons */
 
-    enum TouchpadModel model;          /* The detected model */
+    enum TouchpadModel model;		/* The detected model */
+    unsigned short id_vendor;		/* vendor id */
+    unsigned short id_product;		/* product id */
 } SynapticsPrivate;
 
 #endif /* _SYNAPTICSSTR_H_ */
diff --git a/test/fake-symbols.c b/test/fake-symbols.c
index 9657bab..71c3bc5 100644
--- a/test/fake-symbols.c
+++ b/test/fake-symbols.c
@@ -338,6 +338,12 @@ xf86MsgVerb(MessageType type, int verb, const char *format, ...)
     return;
 }
 
+_X_EXPORT void
+xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...)
+{
+    return;
+}
+
 
 _X_EXPORT void
 xf86PostMotionEventP(DeviceIntPtr	device,
diff --git a/test/fake-symbols.h b/test/fake-symbols.h
index cc62679..dfe1355 100644
--- a/test/fake-symbols.h
+++ b/test/fake-symbols.h
@@ -116,6 +116,7 @@ XIRegisterPropertyHandler(DeviceIntPtr         dev,
 extern int InitProximityClassDeviceStruct(DeviceIntPtr dev);
 extern void xf86Msg(MessageType type, const char *format, ...);
 extern void xf86MsgVerb(MessageType type, int verb, const char *format, ...);
+extern void xf86IDrvMsg(InputInfoPtr dev, MessageType type, const char *format, ...);
 
 extern void
 xf86PostMotionEventP(DeviceIntPtr	device,
-- 
1.7.5.1



More information about the xorg-devel mailing list