Skip to contentSkip to conversation

input/touchscreen: Synaptics Touchscreen Driver

RFC PATCH In review Christopher Heiny 3 participants 8 messages Dec 19, 2009 – Jan 6, 2010 Input drivers

lore
Share & tools
lore
#1 lore raw

RFC PATCH 1/1 input/touchscreen: Synaptics Touchscreen Driver

In reply to Christopher Heiny

From: William Manson <[email protected]>

Initial driver for Synaptics touchscreens using RMI4 protocol.

index 32fc8ba..2b950f7 100644

drivers/input/touchscreen/Kconfig +13 -0
@@ -295,6 +295,19 @@ config TOUCHSCREEN_MIGOR
 	  To compile this driver as a module, choose M here: the
 	  module will be called migor_ts.
 
+config TOUCHSCREEN_SYNAPTICS_RMI4_I2C
+	tristate "Synaptics RMI4 I2C touchscreens"
+	depends on I2C
+	help
+	  Say Y here if you have a Synaptics RMI4 I2C touchscreen connected to
+   	  your system. This enables support for Synaptics RMI4 over I2C based
+          touchscreens.
+
+	  If unsure, say N.
+
+	  To compile this driver as a set of modules, choose M here: the
+	  modules will be called rmi, rmi_app_touchpad, rmi_phys_i2c.
+
 config TOUCHSCREEN_TOUCHRIGHT
 	tristate "Touchright serial touchscreen"
 	select SERIO
drivers/input/touchscreen/Makefile +2 -3
index f1f59c9..81f938a 100644
@@ -12,7 +12,6 @@ obj-$(CONFIG_TOUCHSCREEN_ADS7846)	+= ads7846.o
 obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC)	+= atmel_tsadcc.o
 obj-$(CONFIG_TOUCHSCREEN_BITSY)		+= h3600_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_CORGI)		+= corgi_ts.o
-obj-$(CONFIG_TOUCHSCREEN_DYNAPRO)	+= dynapro.o
 obj-$(CONFIG_TOUCHSCREEN_GUNZE)		+= gunze.o
 obj-$(CONFIG_TOUCHSCREEN_EETI)		+= eeti_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ELO)		+= elo.o
@@ -26,9 +25,8 @@ obj-$(CONFIG_TOUCHSCREEN_HP600)		+= hp680_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_HP7XX)		+= jornada720_ts.o
 obj-$(CONFIG_TOUCHSCREEN_HTCPEN)	+= htcpen.o
 obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)	+= usbtouchscreen.o
-obj-$(CONFIG_TOUCHSCREEN_PCAP)		+= pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)	+= penmount.o
-obj-$(CONFIG_TOUCHSCREEN_S3C2410)	+= s3c2410_ts.o
+obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C)	+= rmi_core.o rmi_app_touchpad.o rmi_function_11.o rmi_phys_i2c.o rmi_i2c_gta01.o
 obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213)	+= touchit213.o
 obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT)	+= touchright.o
 obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN)	+= touchwin.o
@@ -44,3 +42,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL)	+= atmel-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)	+= w90p910_ts.o
+obj-$(CONFIG_TOUCHSCREEN_PCAP)		+= pcap_ts.o
drivers/input/touchscreen/rmi.h new file +286 -0

286 lines not on this page · raw message

drivers/input/touchscreen/rmi.mod.c new file +20 -0
new file mode 100755
index 0000000..e11b023
@@ -0,0 +1,20 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+};
+
+static const char __module_depends[]
+__attribute_used__
+__attribute__((section(".modinfo"))) =
+"depends=";
+
drivers/input/touchscreen/rmi_app_touchpad.c new file +152 -0

152 lines not on this page · raw message

It is
+ * only used for the interrupt-driven case. Polling may also be done in this
+ * driver and doesn't use this thread (although I suppose it could be modified
+ * to do polling, too, instead of using timers).
+ */
+int rmitouchd(void *param)
+{
+ struct rmi_application *app = (struct rmi_application *)param; +
+ daemonize("rmitouchd");
+
+ while (!kthread_should_stop()) {
+ if(time_to_quit) break;
+
+ /* wait for interrupt from ATTN line */
+ wait_for_completion_interruptible(&touch_completion);
+
+ if (time_to_quit) break;
+
+ try_to_freeze();
+
+ do {
+ report_sensor_data(app);
+ if(time_to_quit) break; /* check if time to quit so we don't loop when we are in mod_exit(). */
+ } while(rmi_get_attn(app));
+ }
+
+ complete_and_exit(&thread_comp, 0);
+}
+
+/* Head of the list to keep track of who is polling. This is so we can
+ * properly shut down the timers on exit. */
+static struct list_head pollers;
+
+/* Simple structure to keep track of things */
+struct poll_instance {

+  struct delayed_work dw;
+  struct rmi_application *app;
+  struct list_head link;

+};
+
+/* The main routine for the polling case. */ +static void poll_work_callback(struct work_struct *data) +{

+  struct delayed_work *dw = container_of(data, struct delayed_work, work);
+  struct poll_instance *pi = container_of(dw, struct poll_instance, dw);
+  static int calls_with_no_data = 0;
+  int touch = 0;

+
+ if(time_to_quit) return;
+
+ touch = report_sensor_data(pi->app);
+
+ /* This code implements a backoff. If we have a call with data being

+   * received, we decrease the time between polls to hspolljif.  If
+   * there are several calls at that faster rate that do not have data,
+   * we go back to slower polling.
+   */

+ if(touch) calls_with_no_data = 0;
+ if(!time_to_quit) { /* Don't schedule if it's time to quit. */
+ if(calls_with_no_data > 5) {
+ schedule_delayed_work(dw, polljif);
+ } else {
+ if(!touch) calls_with_no_data++;
+ schedule_delayed_work(dw, hspolljif);
+ }
+ }
+}
+
+/**
+ * This is the probe function passed to the RMI4 subsystem that gives us a
+ * chance to recognize an RMI4 device. In this case, we're looking for
+ * Synaptics devices that have data sources - such as touch screens, buttons, etc.
+ */
+static int probe(struct rmi_application *app, const struct rmi_module_info *rmi) +{

+  struct rmi_function_info *rfi;
+  int data_sources = 0;
+  int retval = 0;

+
+ if(!rmi) {
+ printk(KERN_ERR "rmi_app_touchpad.probe: "
+ "Invalid module info: %p\n", rmi);
+ return 0;
+ }
+
+ /* Make sure this is a Synaptics device */
+ if(rmi->mfgid != 1) { /* Synaptics */
+ printk(KERN_ERR "rmi_app_touchpad.probe: "
+ "Invalid mfg id: %p\n", rmi->mfgid);
+ return 0;
+ }
+
+ /* for each function entry in the list accumulate it's number of data sources */
+ list_for_each_entry(rfi, &rmi->functions, link) {
+ data_sources += rfi->numSources;
+ }
+
+ if (data_sources) {

+    retval = 1;
+    /* We have detected one or more data sources such as a 2D Sensors, buttons, etc. */
+    printk(KERN_ERR "rmi_app_touchpad.probe: "

+ "Found %d data sources for : %p\n",data_sources, rmi);
+ } else {
+ /* we don't have any data sources for this sensor - oops! - either an un-flashed sensor or bad!! */
+ printk(KERN_ERR "rmi_app_touchpad.probe: "
+ "No data sources found for : %p\n", rmi);
+ }
+
+ return retval;
+}
+
+static void config(struct rmi_application *app)
+{

+  /* For each data source we had detected print info and set up interrupts or polling. */
+  unsigned char data[14];
+  struct rmi_function_info *rfi;
+  struct rmi_phys_driver *rpd;;
+  struct rmi_module_info *rmi; /* module info has list of functions */

+
+ rpd = app->rpd; /* get ptr to rmi_physical_driver from app */
+ rmi = &(rpd->rmi); /* get ptr to rmi_module_info from physical driver */ +
+ list_for_each_entry(rfi, &rmi->functions, link) {
+ if(rfi->numSources) /* if this function has data sources associated with it...*/
+ {
+ /* Get and print some info about the data sources... */

+ struct rmi_functions *fn;
+ bool found = false;
+
+ list_for_each_entry(fn, &fns_list, link) {
+ /* check if function number matches - if so call that config function */
+ if(fn->functionNum == rfi->functionNum) {
+ found = true;
+ if (fn->config) {
+ fn->config(app, rfi);
+ } else {

+            /* the developer did not add in the pointer to the config function into rmi4_supported_data_src_functions */
+            printk(KERN_ERR "rmi_app_touchpad.config - no config function for function 0x%x\n", rfi->functionNum);
+            break;

+ }
+ }
+ }
+
+ if (!found) {
+ /* if no support found for this RMI4 function it means the developer did not add the appropriate function
+ pointer list into the rmi4_supported_data_src_functions array and/or did not bump up the number of
+ supported RMI4 functions in rmi.h as required */
+ printk(KERN_ERR "rmi_app_touchpad.config - could not find support for function 0x%x\n", rfi->functionNum);
+ }
+
+ /* if we are not doing polling then enable the interrupts for the data sources for this function */
+ if (!rmi_polling_required(app)) {

+        /* Turn on interrupts for this functions data sources. */
+        rmi_write(app, fn01ControlBaseAddr + 1 + rfi->interruptRegister, rfi->interruptMask);
+        printk(KERN_INFO "rmi_app_touchpad.config -  Interrupt Driven - turning on interrupts for function 0x%x\n", rfi->functionNum);

+ }
+ }
+ }
+
+ /* if we are not polling we need to set up the interrupt thread - otherwise we need to
+ set up the polling callback and worker thread. */
+ if(!rmi_polling_required(app)) {
+ /* We're interrupt driven, so turn on the thread. */
+ kthread = kthread_run(&rmitouchd, app, "rmitouchd");
+
+ if(HZ < 500) {
+ /* The default polling frequency of 80 times per

+       * second is too fast (the Linux time slice for
+       * sub-GHz processors is only 100 times per second).
+       * So program it to 40.
+       */
+      rmi_write(app, fn01ControlBaseAddr, RMI_REPORT_RATE_40);
+    }
+  } else {
+    /* We're polling driven, so set up the polling callback and worker thread */
+    struct poll_instance *pi;
+    pi = kmalloc(sizeof(*pi), GFP_KERNEL);

+
+ if(!pi) {
+ printk(KERN_ERR "rmi_app_touchpad.config: "
+ "Out of memory claiming %s\n",
+ rmi->prod_id);
+ continue;
+ }
+
+ INC_ALLOC_STAT(poll);
+ INIT_DELAYED_WORK(&pi->dw, poll_work_callback);
+

+    pi->app     = app;
+    list_add_tail(&pi->link, &pollers);
+    schedule_delayed_work(&pi->dw, polljif);

+ }
+}
+
+/**
+ * The module initialization function in which we register as a RMI4
+ * application driver. We also register with the input subsystem so we can
+ * pass coordinates to it.
+ */
+static int __init mod_init(void)
+{
+ printk(KERN_INFO "rmi_app_touchpad.mod_init: RMI4 TouchPad Driver\n"); +
+ INIT_LIST_HEAD(&pollers);
+

+  time_to_quit = 0;
+  init_completion(&touch_completion);
+  init_completion(&thread_comp);
+
+  /* NOTE: we are creating only one input dev file for this but theoretically
+     you could create a separate one for each data source and store it below.
+     This will let you put 2D sensor events into one dev file, button events into
+     a separate dev file, other data source event like GPIOs, etc. into yet a
+     third dev file. As this is being coded it will dump all events into the
+     one dev file.

+ */
+ input = input_allocate_device();
+ if (input == NULL) {
+ printk(KERN_ERR "rmi_app_touchpad.mod_init: Failed to allocate memory for a new input device.\n");
+ return -ENOMEM;
+ }
+
+ input->name = "RMI4 Touchpad";
+ input->phys = "rmi_app_touchpad";
+
+ /* Set input device specific params for each data source...*/

+ struct rmi_functions *fn;
+ list_for_each_entry(fn, &fns_list, link) {
+ if (fn->init) {
+ fn->input = input; /* store the input_dev ptr for use later */
+ fn->init(fn->input);
+ } else {
+ /* the developer did not add in the pointer to the init function into rmi4_supported_data_src_functions */
+ printk(KERN_ERR "rmi_app_touchpad.mod_init: no init function for function 0x%x\n", fn->functionNum);
+ }
+ }
+
+ input_register_device(input);
+
+ app = rmi_register_application("rmi4_touchpad", attention, probe, config); +
+ if(!app) {

+    printk(KERN_ERR "rmi_app_touchpad.mod_init:  Failed to register app.\n");
+    input_unregister_device(input);
+    return -ENODEV;

+ }
+
+ return 0;
+}
+
+/**
+ * The module exit function.
+ */
+static void __exit mod_exit(void)
+{
+ struct poll_instance *pi, *pi_tmp;
+
+ printk(KERN_INFO "rmi_app_touchpad.mod_exit: RMI4 TouchPad Driver\n"); +
+ time_to_quit = 1;
+
+ complete(&touch_completion); /* Kick the thread awake */
+ list_for_each_entry(pi, &pollers, link) {
+ cancel_delayed_work(&pi->dw); /* Cancel any pending polls */

+  }
+  flush_scheduled_work();	/* Make sure all pollers are stopped */
+  if(kthread) wait_for_completion(&thread_comp);
+
+  /* Unregister everything */
+  printk(KERN_WARNING "rmi_app_touchpad.mod_exit: Unregistering app - %s\n", app->name);
+  rmi_unregister_application(app);
+  input_unregister_device(input);
+
+  /* Free up the structures */
+  list_for_each_entry_safe(pi, pi_tmp, &pollers, link) {
+    list_del(&pi->link);
+    kfree(pi);
+    DEC_ALLOC_STAT(poll);

+ }
+
+ CHECK_ALLOC_STAT(poll);
+}
+
+/** Standard driver module information - the author of the module.
+ */
+MODULE_AUTHOR("Synaptics, Inc.");
+/** Standard driver module information - a summary description of this module.
+ */
+MODULE_DESCRIPTION("RMI4 Driver");
+/** Standard driver module information - the license under which this module
+ * is included in the kernel.
+ */
+MODULE_LICENSE("GPL");
+
+/** Specifies to the kernel that the mod_init() function should be called when
+ * the module is loaded.
+ * \see mod_init()
+ */
+module_init(mod_init);
+/** Specifies to the kernel that the mod_exit() function should be called when
+ * the module is unloaded.
+ * \see mod_exit()
+ */
+module_exit(mod_exit);
+
+/* vim600: set noexpandtab sw=8 ts=8 :*/

drivers/input/touchscreen/rmi_app_touchpad.mod.c new file +20 -0
new file mode 100755
index 0000000..22ed454
@@ -0,0 +1,20 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+};
+
+static const char __module_depends[]
+__attribute_used__
+__attribute__((section(".modinfo"))) =
+"depends=rmi";
+
drivers/input/touchscreen/rmi_core.c new file +188 -0

188 lines not on this page · raw message

drvname, rpd->name);
+ return -EINVAL;
+ }
+ if(!rpd->read) {
+ printk(KERN_ERR "%s: Physical driver %s must specify a reader.\n", drvname, rpd->name);
+ return -EINVAL;
+ }
+ if(!rpd->write_multiple) {
+ printk(KERN_ERR "%s: Physical driver %s must specify a multiple writer.\n", drvname, rpd->name);
+ return -EINVAL;
+ }
+ if(!rpd->read_multiple) {
+ printk(KERN_ERR "%s: Physical driver %s must specify a multiple reader.\n", drvname, rpd->name);
+ return -EINVAL;
+ }
+ if(!rpd->module) {
+ printk(KERN_ERR "%s: Physical driver %s must specify a module.\n",
drvname, rpd->name);
+ return -EINVAL;
+ }
+
+ pr_debug("%s: Registering phys driver %s\n", drvname, rpd->name); +
+ rpd->attention = 0;
+
+ /* Get some information from the device */
+ {

+    int i;
+    unsigned char std_queries[21];
+    unsigned char interruptCount = 0;
+    struct rmi_function_info *rfi = NULL;

+
+
+ printk(KERN_INFO "%s: Functions:\n", drvname);
+
+ struct rmi_function_descriptor rmi_fd;
+
+ /* init the physical drivers RMI module info list of functions */
+ INIT_LIST_HEAD(&rpd->rmi.functions);
+

+    /* Read the Page Descriptor Table to determine what functions are present */
+    for(i = PDT_START_SCAN_LOCATION; i > PDT_END_SCAN_LOCATION; i -= PDT_ENTRY_SIZE )
+    {

+ if (!(retval = rpd->read_multiple(rpd, i, &rmi_fd, sizeof(rmi_fd))))
+ {
+ rfi = NULL;
+
+ if(rmi_fd.functionNum)
+ {
+ switch(rmi_fd.functionNum & 0xff)
+ {
+ case 0x01:
+ printk(KERN_INFO "%s: Fn $01 Found - RMI Device Control\n", drvname);
+ /* Save Fn $01 query and control base addresses since

+                 we'll need them later to get/set properties and check interrupts.
+                 There is only one Fn $01 for the device that is used to control
+                 and query device specific info so we only need to save it globally here
+                 for later use. */
+              fn01QueryBaseAddr = rmi_fd.queryBaseAddr;
+              fn01ControlBaseAddr = rmi_fd.controlBaseAddr;
+              break;

+
+ default:
+ if (rmi_fd.interruptSrcCnt) {
+ rfi = kmalloc(sizeof(*rfi), GFP_KERNEL);
+
+ if(!rfi) {
+ printk(KERN_ERR "%s: could not allocate memory for function 0x%x\n",
+ drvname, rmi_fd.functionNum);
+ retval = -ENOMEM;
+ goto exit_fail;
+ } else {
+ INC_ALLOC_STAT(rfi);
+

+                  /* Get the ptr to the detect function based on the function number */
+                  struct rmi_functions *fn;
+                  bool found = false;

+
+ list_for_each_entry(fn, &fns_list, link) {
+ /* check if function number matches - if so call that detect function */
+ if(fn->functionNum == rmi_fd.functionNum) {
+ found = true;
+ fn->detect(rpd, rfi, &rmi_fd, interruptCount);
+ }
+ }
+
+ if (!found) {
+ printk(KERN_ERR "%s: could not find support for function 0x%x\n",
+ drvname, rmi_fd.functionNum);
+ }
+ }
+ } else {
+ printk(KERN_INFO "%s: Found Function %02x - Ignored.\n", drvname, rmi_fd.functionNum & 0xff);
+ }
+ break;
+ }
+
+ /* bump interrupt count for next iteration */
+ interruptCount += (rmi_fd.interruptSrcCnt & 0x7);
+

+          /* We only want to add functions to the list that have data associated with them. */
+          if (rfi && rmi_fd.interruptSrcCnt)
+          {
+            printk(KERN_INFO "%s: Adding function 0x%x with %d sources. \n", drvname, rfi->functionNum, rfi->numSources);
+
+            /* link this function info to the RMI module infos list of functions */
+            mutex_lock(&rfi_mutex);
+            list_add_tail(&rfi->link, &rpd->rmi.functions);
+            mutex_lock(&rfi_mutex);
+          }
+        } else {
+          /* A zero in the function number signals the end of the PDT */
+          printk(KERN_INFO "%s:   Found End of PDT\n", drvname);
+          break;

+ }
+ } else {
+ /* failed to read next PDT entry - end PDT scan - this may result in an incomplete
+ set of recognized functions - should probably return an error but the driver
+ may still be viable for diagnostics and debugging so let's let it continue. */
+ printk(KERN_ERR "%s: Read Error 0x%x when reading next PDT entry - ending PDT scan.\n", drvname, retval);
+ break;
+ }
+ }
+
+ /* calculate the interrupt register count - used in the ISR to read the correct number of interrupt registers */
+ interruptRegisterCount = (interruptCount + 7) / 8;
+
+ /* Function $01 will be used to query the product properties, and product ID

+     * so we had to read the PDT above first to get the Fn $01 query address and
+     * prior to filling in the product info. NOTE: Even an unflashed
+     * device will still have FN $01.
+     */
+
+    /* Load up the standard queries and get the RMI4 module info */
+    if((retval = rpd->read_multiple(rpd, fn01QueryBaseAddr, std_queries, sizeof(std_queries)))) {
+      printk(KERN_ERR "%s: Fail reading queries\n", drvname);
+      retval = -EIO;
+      goto exit_fail;
+    }
+
+    rpd->rmi.rmi_maj_ver  = 4; /* Currently supported RMI version is 4.0 */
+    rpd->rmi.rmi_min_ver  = 0;

+
+ /* get manufacturer id, properties, product info, date code, tester id, serial num and product id (name) */
+ rpd->rmi.mfgid = std_queries[0];
+
+ rpd->rmi.properties = std_queries[1];
+
+ rpd->rmi.prod_info[0] = std_queries[2];
+ rpd->rmi.prod_info[1] = std_queries[3];
+

+    rpd->rmi.date_code[0] = std_queries[4] & 0x1f; /* year - 2001-2032 */
+    rpd->rmi.date_code[1] = std_queries[5] & 0x0f; /* month - 1-12 */
+    rpd->rmi.date_code[2] = std_queries[6] & 0x1f; /* day - 1-31 */

+
+ rpd->rmi.tester_id = ((std_queries[7] & 0x7f) << 8) | (std_queries[8] & 0x7f);
+
+ rpd->rmi.serial_num = ((std_queries[9] & 0x7f) << 8) | (std_queries[10] & 0x7f);
+
+ for (i = 0; i < 10; i++)
+ {
+ rpd->rmi.prod_id[i] = std_queries[11+i];
+ }
+
+ rpd->rmi.prod_id[10] = 0;
+
+ printk(KERN_INFO "%s: RMI Protocol: %d.%d\n",
+ drvname, rpd->rmi.rmi_maj_ver, rpd->rmi.rmi_min_ver);
+ printk(KERN_INFO "%s: Manufacturer: %d", drvname,
+ rpd->rmi.mfgid);
+
+ if(rpd->rmi.mfgid == 1) {
+ printk(KERN_INFO " (Synaptics)");
+ }
+ printk(KERN_INFO "\n");
+
+ printk(KERN_INFO "%s: Properties: 0x%x \n", drvname, rpd->rmi.properties);
+
+ printk(KERN_INFO "%s: Product Info: 0x%x 0x%x \n", drvname, rpd->rmi.prod_info[0], rpd->rmi.prod_info[1]);
+
+ printk(KERN_INFO "%s: Date Code: Year : %d Month: %d Day: %d\n", drvname, rpd->rmi.date_code[0],
+ rpd->rmi.date_code[1], rpd->rmi.date_code[2]);
+
+ printk(KERN_INFO "%s: Tester ID: %d \n", drvname, rpd->rmi.tester_id);
+
+ printk(KERN_INFO "%s: Serial Number: 0x%x \n", drvname, rpd->rmi.serial_num);
+
+ printk(KERN_INFO "%s: Product ID: %s\n", drvname, rpd->rmi.prod_id);
+ }
+

+  /* Add physical driver struct to list */
+  mutex_lock(&phys_drivers_mutex);
+  list_add_tail(&rpd->drivers, &phys_drivers);
+  mutex_unlock(&phys_drivers_mutex);

+
+ /* Do a probe for any applications that are registered and bind this physical driver to them */
+ list_for_each_entry(app, &app_drivers, apps) {
+ /* Only check apps that are not already bound */
+ if(!app->rpd) {
+ match_and_bind(app, rpd);
+ }
+ }
+
+ pr_debug("Registered phys driver %s\n", rpd->name);
+ return 0;
+
+exit_fail:
+ return retval;
+}
+EXPORT_SYMBOL(rmi_register_phys_driver);
+
+int rmi_unregister_phys_driver(struct rmi_phys_driver *rpd)
+{
+ if(rpd->app) {
+ printk(KERN_WARNING "%s: WARNING: unregister of %s while %s still attached\n",
+ drvname, rpd->name, rpd->app->name);
+ }
+

+  pr_debug("Unregistering phys driver %s\n", rpd->name);
+  mutex_lock(&phys_drivers_mutex);
+  list_del(&rpd->drivers);
+  mutex_unlock(&phys_drivers_mutex);

+
+ return 0;
+}
+EXPORT_SYMBOL(rmi_unregister_phys_driver);
+
+struct rmi_application * rmi_register_application(const char *name,

+  void (*attention)(struct rmi_phys_driver *pd, int instance),
+  int (*probe)(struct rmi_application *app,
+  const struct rmi_module_info *rmi),
+  void (*config)(struct rmi_application *app))

+{
+ struct rmi_application *app;
+ struct rmi_phys_driver *rpd;
+
+ if(!name) {
+ printk(KERN_ERR "%s: Application driver must specify a name\n", drvname);
+ return 0;
+ }
+
+ if(!attention) {
+ printk(KERN_ERR "%s: Application driver %s must specify attention notifier.\n",
+ drvname, name);
+ return 0;
+ }
+
+ if(!probe) {
+ printk(KERN_ERR "%s: Application driver %s must specify a probe function.\n",
+ drvname, name);
+ return 0;
+ }
+
+ if(!config) {
+ printk(KERN_ERR "%s: Application driver %s must specify a config function.\n",
+ drvname, name);
+ return 0;
+ }
+
+ pr_debug("Registering app driver %s\n", name);
+
+ app = kmalloc(sizeof(*app), GFP_KERNEL);
+ if(!app) {
+ printk(KERN_ERR "%s: Out of memory\n", drvname);
+ return 0;
+ }
+ INC_ALLOC_STAT(app);
+

+  app->name      = name;
+  app->attention = attention;
+  app->probe     = probe;
+  app->config    = config;
+  app->rpd       = 0;
+
+  mutex_lock(&app_drivers_mutex);
+  list_add_tail(&app->apps, &app_drivers);
+  mutex_unlock(&app_drivers_mutex);

+
+ /* Probe for any matches with physical drivers and bind them. */
+ list_for_each_entry(rpd, &phys_drivers, drivers) {
+ if(!rpd->app) {
+ match_and_bind(app, rpd);
+ }
+ }
+
+ pr_debug("Registered app driver %s (%p)\n", name, app); +
+ return app;
+}
+EXPORT_SYMBOL(rmi_register_application);
+
+void rmi_unregister_application(struct rmi_application *app) +{
+ struct rmi_application *tmp;
+ int found = 0;
+
+ if(!app) {
+ return;
+ }
+
+ pr_debug("Unregistering app driver %s (%p)\n", app->name, app); +
+ list_for_each_entry(tmp, &app_drivers, apps) {
+ if(tmp == app) {
+ found = 1;
+ break;
+ }
+ }
+
+ if(!found) {
+ printk(KERN_ERR "%s: Removing rmi application %s: not found\n",
+ drvname, app->name);
+ return;
+ }
+
+ if(app->rpd) {

+    /* Release the phys driver so it can be unloaded. */
+    module_put(app->rpd->module);
+    app->rpd->app = 0;
+  }
+	
+  list_del(&app->apps);
+  kfree(app);
+  DEC_ALLOC_STAT(app);

+
+ pr_debug("Unregistered app driver %p\n", app);
+}
+EXPORT_SYMBOL(rmi_unregister_application);
+
+static int __init mod_init(void)
+{
+ printk(KERN_INFO "Register Mapped Interface Data Layer Driver\n"); +
+ /* Initialize global list of RMI4 Functions that have data sources.

+     We need to add all new functions to this list so that we will have pointers
+     to their associated functions for init, config, report and detect. See rmi.h
+     for more details. The developer will add a new RMI4 function number in the
+     array in rmi.h and then add a new file to the build (called rmi_function_XX.c
+     where XX is the hex number for the added RMI4 function). The rest should be
+     automatic.

+ */
+
+ /* for each function number defined in rmi.h creat a new rmi_function struct and
+ initialize the pointers to the servicing functions and then add it into the
+ global list for function support.
+ */
+ for (i = 0; i < rmi4_num_supported_data_src_fns; i++) {

+    /* Add new rmi4 function struct to list */
+    struct rmi_functions *fn = kmalloc(sizeof(*fn), GFP_KERNEL);
+    if(!fn) {

+ printk(KERN_ERR "%s mod_init: could not allocate memory for rmi_function struct for function 0x%x\n",
+ drvname, rmi4_supported_data_src_functions[i]);
+ return -ENOMEM;
+ } else {
+
+ INC_ALLOC_STAT(fn);
+

+      struct rmi_functions_data * rmi4_fn = &rmi4_suported_data_src_functions[i];
+      fn->functionNum = rmi4_fn->functionNumber;
+      /* Fill in ptrs to functions. The functions are linked in from a file
+         called rmi_function_xx.c where xx is the hex number of the RMI4 function
+         from the RMI4 spec. Also, the function prototypes need to be added to
+         rmi_function_xx.h - also where xx is the hex number of the RMI4 function.
+         So that you don't get compile errors and that new header needs to be
+         included in the rmi.h header file.
+      */
+      fn->report = rmi4_fn->reportFn;
+      fn->config = rmi4_fn->configFn;
+      fn->init =   rmi4_fn->initFn;
+      fn->detect = rmi4_fn->detectFn;
+
+      /* Add the new fn to the global list */
+      mutex_lock(&fns_mutex);
+      list_add_tail(&fn->link, &fns_list);
+      mutex_unlock(&fns_mutex);

+ }
+ }
+
+ return 0;
+}
+
+static void __exit mod_exit(void)
+{

+  struct rmi_application *app, *apptmp;
+  struct rmi_function *fn, *fntmp;
+  struct rmi_function_info *rfi, *rfitmp;
+
+  /* These lists should be empty, but just in case . . . */
+  mutex_lock(&app_drivers_mutex);
+  list_for_each_entry_safe(app, apptmp, &app_drivers, apps) {
+    list_del(&app->apps);
+    kfree(app);
+    DEC_ALLOC_STAT(app);

+ }
+ mutex_unlock(&app_drivers_mutex);
+
+ mutex_lock(&fns_mutex);
+ list_for_each_entry_safe(fn, fntmp, &fns_list, link) {

+    list_del(&fn->link);
+    kfree(fn);
+    DEC_ALLOC_STAT(fn);

+ }
+ mutex_unlock(&fns_mutex);
+
+ mutex_lock(&rfi_mutex);
+ list_for_each_entry_safe(rfi, rfitmp, &rpd->rmi.functions, link) {

+    list_del(&fn->link);
+    kfree(fn);
+    DEC_ALLOC_STAT(rfi);

+ }
+ mutex_unlock(&rfi_mutex);
+
+

+  CHECK_ALLOC_STAT(rfi);
+  CHECK_ALLOC_STAT(fn);
+  CHECK_ALLOC_STAT(app);

+}
+
+/** Specifies to the kernel that the mod_init() function should be called when
+ * the module is loaded.
+ * \see mod_init()
+ */
+module_init(mod_init);
+/** Specifies to the kernel that the mod_exit() function should be called when
+ * the module is unloaded.
+ * \see mod_exit()
+ */
+module_exit(mod_exit);
+
+/** Standard driver module information - the author of the module.
+ */
+MODULE_AUTHOR("Synaptics, Inc.");
+/** Standard driver module information - a summary description of this module.
+ */
+MODULE_DESCRIPTION("RMI4 Driver");
+/** Standard driver module information - the license under which this module
+ * is included in the kernel.
+ */
+MODULE_LICENSE("GPL");
+
+/* vim600: set noexpandtab sw=8 ts=8 : */

drivers/input/touchscreen/rmi_core.h new file +54 -0

54 lines not on this page · raw message

drivers/input/touchscreen/rmi_function_11.c new file +313 -0

313 lines not on this page · raw message

drivers/input/touchscreen/rmi_function_11.h new file +37 -0
new file mode 100755
index 0000000..19eadbe
@@ -0,0 +1,37 @@
+/**
+ * \file
+ * Synaptics Register Mapped Interface (RMI4) Function $11 support for 2D.
+ * Copyright (c) 2009 Synaptics Incorporated
+ *
+ * For every RMI4 function that has a data source - like 2D sensors, buttons, LEDs,
+ * GPIOs, etc. - the user will create a new rmi_function_xx.c file and add these
+ * functions to perform the config(), init(), report() and detect() functionality.
+ * The function pointers are then stored under the RMI function info and these
+ * functions will automatically be called by the global config(), init(), report()
+ * and detect() functions that will loop through all data sources and call the
+ * data sources functions using these functions pointed to by the function ptrs.
+ */
+/*
+ * This file is licensed under the GPL2 license.
+ *
+ *#############################################################################
+ * GPL
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ *#############################################################################
+ */
+
+int  FN_11_report(struct rmi_application *app, struct rmi_function_info *rfi, struct input_dev *input);
+void FN_11_config(struct rmi_application *app, struct rmi_function_info *rfi);
+void FN_11_init(struct input_dev *input);
+void FN_11_detect(struct rmi_application *app, struct rmi_function_info *rfi, struct rmi_function_descriptor *fd, unsigned int interruptCount);
+
+/* vim600: set noexpandtab sw=8 ts=8 :*/
drivers/input/touchscreen/rmi_i2c.h new file +52 -0

52 lines not on this page · raw message

drivers/input/touchscreen/rmi_i2c_gta01.c new file +117 -0

117 lines not on this page · raw message

drivers/input/touchscreen/rmi_i2c_gta01.mod.c new file +20 -0
new file mode 100755
index 0000000..e11b023
@@ -0,0 +1,20 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+};
+
+static const char __module_depends[]
+__attribute_used__
+__attribute__((section(".modinfo"))) =
+"depends=";
+
drivers/input/touchscreen/rmi_phys_i2c.c new file +633 -0

633 lines not on this page · raw message

drivers/input/touchscreen/rmi_phys_i2c.mod.c new file +20 -0
new file mode 100755
index 0000000..22ed454
@@ -0,0 +1,20 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+};
+
+static const char __module_depends[]
+__attribute_used__
+__attribute__((section(".modinfo"))) =
+"depends=rmi";
+
#0 lore raw

cover input/touchscreen: Synaptics Touchscreen Driver

This patch adds an initial driver supporting Synaptics ClearPad touchscreens that use the RMI4 protocol, as defined here:

http://www.synaptics.com/sites/default/files/511-000136-01_revA.pdf

This version of the driver does not support all features of the RMI4 protocol yet. We felt it more important to start with a solid implementation of the basic functionality, and then build on that base to support additional features (such as gestures, proximity detection, capacitive buttons, and so on).

Additionally, as this is our team's first venture into the wonderful world of kernel submissions, we figured it was important to start out initially with a fairly simple codebase, just in case we're doing something horribly wrong.

The significant files in this version of the driver are:
rmi_core.c
Implements the basic core of the RMI4 protocol including self-discovery of RMI4 functions. This also implements RMI4 function 0x01, which provides generic device control.
rmi_function_11.c
Implements basic RMI4 function 0x11 (2D sensor) features, including multitouch up to 10 fingers.
rmi_app_touchpad.c
The major driver functions (mod_init, mod_exit, and so on).
More detailed descriptions can be found in each file's comments.

We chose to use multiple source files because it makes it easy to add support for additional RMI4 functions with minimal impact to existing functions. Additionally, this supports future changes to the configuration to allow you to compile in only those RMI4 functions that you need for your particular device.

There are two existing drivers for similar Synaptics devices in the current kernel tree (excluding the PS/2 touchpad driver). These are:

./linux-2.6/drivers/input/mouse/synaptics_i2c.c
A driver for the Exeda 15mm touchpad, written by Mike Rapoport <[email protected]> and Igor Grinberg <[email protected]>

./linux-2.6/drivers/staging/dream/synaptics_i2c_rmi.c
A driver for the HTC Dream ClearPad, written by Arve Hjønnevåg <[email protected]>

We have not extended these drivers for a couple of reasons. First, the two drivers are specific to particular Synaptics products, and it is our desire to produce a general solution that takes advantage of the 'self describing' features of products that use the RMI protocol.

Second, and more importantly, is that the existing drivers are written for an older version of the RMI protocol (aka RMI3) that is being retired in favor of a more recent and substantially changed version (aka RMI4). Most currently shipping Synaptics ClearPads speak the RMI4 protocol, and it will be Synaptics protocol of choice going forward. In almost all respects, RMI4 is not backward compatible with RMI3, making it impractical to support both versions in the same driver.

Comments and other feedback on this driver are welcomed.

Bill Manson
Allie Xiong
Christopher Heiny

PS Synaptics will be on holiday break from December 24th through January 3rd. Feedback received during that time may not get attention until after shutdown.

maintainer
#2 lore raw
In reply to Christopher Heiny

Hi Christopher,

Quoted 3 lines · Christopher Heiny

From: William Manson <[email protected]>

Initial driver for Synaptics touchscreens using RMI4 protocol.

Thank you very much for the driver. Unfortunately your mailer line-wrapped the patch, I also am not sure whether teh identation style was damaged my the mailer or if it is the original style (the kernel's standard is ident with hard TABs).

Some more appearance-related comments inside, I will look at the code more closely later.

Quoted 15 lines

index 32fc8ba..2b950f7 100644

drivers/input/touchscreen/Kconfig +2 -0
@@ -295,6 +295,19 @@ config TOUCHSCREEN_MIGOR
 	  To compile this driver as a module, choose M here: the
 	  module will be called migor_ts.
 
+config TOUCHSCREEN_SYNAPTICS_RMI4_I2C
+	tristate "Synaptics RMI4 I2C touchscreens"

drivers/input/touchscreen/Kconfig config TOUCHSCREEN_MIGOR · line 309

Quoted 10 lines
drivers/input/touchscreen/Kconfig +10 -0
+	depends on I2C
+	help
+	  Say Y here if you have a Synaptics RMI4 I2C touchscreen connected to
+   	  your system. This enables support for Synaptics RMI4 over I2C based
+          touchscreens.
+
+	  If unsure, say N.
+
+	  To compile this driver as a set of modules, choose M here: the
+	  modules will be called rmi, rmi_app_touchpad, rmi_phys_i2c.

I guess I need to read your RMI document but it is funny to see the entry in touchscreens with the only application of touchpad. Do you intend to produce more application modules later?

Quoted 10 lines
drivers/input/touchscreen/Kconfig +1 -0
+
 config TOUCHSCREEN_TOUCHRIGHT
 	tristate "Touchright serial touchscreen"
 	select SERIO
drivers/input/touchscreen/Makefile +0 -0
index f1f59c9..81f938a 100644

drivers/input/touchscreen/Makefile obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o · line 15

Quoted 4 lines
drivers/input/touchscreen/Makefile +0 -1
@@ -12,7 +12,6 @@ obj-$(CONFIG_TOUCHSCREEN_ADS7846)	+= ads7846.o
 obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC)	+= atmel_tsadcc.o
 obj-$(CONFIG_TOUCHSCREEN_BITSY)		+= h3600_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_CORGI)		+= corgi_ts.o
-obj-$(CONFIG_TOUCHSCREEN_DYNAPRO)	+= dynapro.o

Uh-oh, what did you do with dynapro?

Quoted 83 lines
drivers/input/touchscreen/Makefile +1 -2
 obj-$(CONFIG_TOUCHSCREEN_GUNZE)		+= gunze.o
 obj-$(CONFIG_TOUCHSCREEN_EETI)		+= eeti_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ELO)		+= elo.o
@@ -26,9 +25,8 @@ obj-$(CONFIG_TOUCHSCREEN_HP600)		+= hp680_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_HP7XX)		+= jornada720_ts.o
 obj-$(CONFIG_TOUCHSCREEN_HTCPEN)	+= htcpen.o
 obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)	+= usbtouchscreen.o
-obj-$(CONFIG_TOUCHSCREEN_PCAP)		+= pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)	+= penmount.o
-obj-$(CONFIG_TOUCHSCREEN_S3C2410)	+= s3c2410_ts.o
+obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C)	+= rmi_core.o  

rmi_app_touchpad.o rmi_function_11.o rmi_phys_i2c.o rmi_i2c_gta01.o
obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o
obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o

drivers/input/touchscreen/Makefile +1 -0
@@ -44,3 +42,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL)	+= atmel-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)	+= w90p910_ts.o
+obj-$(CONFIG_TOUCHSCREEN_PCAP)		+= pcap_ts.o
drivers/input/touchscreen/rmi.h new file +11 -0
new file mode 100755
index 0000000..6caa66f
@@ -0,0 +1,286 @@
+/**
+ * \file
+ * Synaptics Register Mapped Interface (RMI4) Header File.
+ * Copyright (c) 2007-2009 Synaptics Incorporated
+ *
+ *
+ */
+/*
+ * This file is licensed under the GPL2 license.
+ *
+  

*#############################################################################
+ * GPL
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+
*#############################################################################
+ */

drivers/input/touchscreen/rmi.h new file +5 -0
+
+/** RMI4 Protocol Support
+ */
+
+/** For each function present on the RMI device, we need to get the  

RMI4 Function
+ * Descriptor info from the Page Descriptor Table. This will give us the
+ * addresses for Query, Command, Control, Data and the Source Count (number
+ * of sources for this function) and the function id.
+ */

drivers/input/touchscreen/rmi.h new file +10 -0
+struct rmi_function_descriptor {
+  unsigned char queryBaseAddr;
+  unsigned char commandBaseAddr;
+  unsigned char controlBaseAddr;
+  unsigned char dataBaseAddr;
+  unsigned char interruptSrcCnt;
+  unsigned char functionNum;
+};
+
+/** For each function present on the RMI device, there will be a  

corresponding
+ * entry in the functions list of the rmi_module_info structure. This entry
+ * gives information about the number of data sources and the number of data
+ * registers associated with the function.
+ * \see rmi_module_info
+ */

drivers/input/touchscreen/rmi.h line 55

Quoted 7 lines
drivers/input/touchscreen/rmi.h new file +7 -0
+struct rmi_function_info {
+  unsigned char functionNum;
+
+  /** This is the number of data sources associated with the function.
+   * \note This is not the total number of data registers associated with
+   * this function!
+   * \see data_regs

This style of markups is not used in the kernel, please try adopting kerneldoc style (Documentation/kernel-doc-nano-HOWTO.txt)

Review

Quoted 269 lines
drivers/input/touchscreen/rmi.h new file +5 -0
+   */
+  unsigned char numSources;
+
+  /** This is the number of data points supported - for example, for
+   *  function $11 (2D sensor) the number of data points is equal to  

the number

drivers/input/touchscreen/rmi.h new file +9 -0
+   *  of fingers - for function $19 (buttons)it is the number of buttons.
+   */
+  unsigned char numDataPoints;
+
+  /** This is the number of data registers to read.
+   */
+  unsigned char dataRegBlockSize;
+
+  /** This is the interrupt register and mask - needed for enabling the  

interrupts

drivers/input/touchscreen/rmi.h new file +19 -0
+   *  and for checking what source had caused the attention line interrupt.
+   */
+  unsigned char interruptRegister;
+  unsigned char interruptMask;
+
+  /** This is the RMI function descriptor associated with this function.
+   *  It contains the Base addresses for the functions query, command,
+   *  control, and data registers.
+   */
+  struct rmi_function_descriptor funcDescriptor;
+
+  /** Standard kernel linked list implementation.
+   * Documentation on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   */
+  struct list_head link;
+};
+
+/* This struct is for creating a list of RMI4 functions that have data  

sources

drivers/input/touchscreen/rmi.h new file +8 -0
+   associated with them. This is to facilitate adding new support for other
+   data sources besides 2D sensors.
+
+   To add a new data source support, the developer will create a new file
+   and add these 4 functions below with FN$## in front of the names - where
+   ## is the hex number for the function taken from the RMI4 specification.
+
+   The function number will be associated with this and later will be  

used to
+ match the RMI4 function to the 4 functions for that RMI4 function
number.

drivers/input/touchscreen/rmi.h new file +3 -0
+
+   The user will also have to add code that adds the new rmi_functions item
+   to the global list of RMI4 functions and stores the pointers to the  

4 functions

drivers/input/touchscreen/rmi.h new file +8 -0
+   in the function pointers.
+*/
+struct rmi_functions {
+  unsigned char functionNum;
+
+  struct input_dev *input;
+
+  /* ptrs to function specific functions for report, config, init and  

detect. */

drivers/input/touchscreen/rmi.h new file +2 -0
+  /* These ptrs. need to be filled in for every RMI4 function that has data
+     source(s) associated with it - like fn $11 (2D sensors), fn $19  

(buttons),
+ etc. Each RMI4 function that has data sources will be added into a
list
+ that is used to match the function number against the number
stored here.

drivers/input/touchscreen/rmi.h new file +2 -0
+  */
+  int  (*report)(struct rmi_application *app, struct rmi_function_info  

*rfi, struct input_dev *input);
+ void (*config)(struct rmi_application *app, struct rmi_function_info *rfi);

drivers/input/touchscreen/rmi.h new file +2 -0
+  void (*init)(struct input_dev *input);
+  void (*detect)(struct rmi_application *app, struct rmi_function_info  

*rfi, struct rmi_function_descriptor *fd, unsigned int interruptCount);

drivers/input/touchscreen/rmi.h new file +10 -0
+
+  /** Standard kernel linked list implementation.
+   * Documentation on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   */
+  struct list_head link;
+};
+
+
+/* Each time a new RMI4 function support is added the developer needs  

to bump the number of
+ supported data src functions and add the info for that RMI4 function
to the array along
+ with pointers to the report, config, init and detect functions that
they coded in rmi_function_xx.c
+ and rmi_function_xx.h - where xx is the RMI4 function number for the
new RMI4 data source function.
+ The information for the RMI4 functions is obtained from the RMI4
specification document.

drivers/input/touchscreen/rmi.h new file +4 -0
+*/
+#define rmi4_num_supported_data_src_fns 1
+
+/* add hdr files for all prototypes for RMI4 data source functions  

being supported */

drivers/input/touchscreen/rmi.h new file +4 -0
+#include "rmi_function_11.h"
+/* #include "rmi_function_19.h" */
+
+typedef int(*reportFuncPtr)(struct rmi_application *, struct  

rmi_function_info *, struct input_dev *);
+typedef void(*configFuncPtr)(struct rmi_application *app, struct rmi_function_info *rfi);

drivers/input/touchscreen/rmi.h new file +2 -0
+typedef void(*initFuncPtr)(struct input_dev *);
+typedef void(*detectFuncPtr)(struct rmi_application *, struct  

rmi_function_info *, struct rmi_function_descriptor *, unsigned int);

drivers/input/touchscreen/rmi.h new file +10 -0
+
+struct rmi_functions_data {
+  int functionNumber;
+  reportFuncPtr reportFn;
+  configFuncPtr configFn;
+  initFuncPtr initFn;
+  detectFuncPtr detectFn;
+};
+/* NOTE:
+   Developer - add in any new RMI4 fn data info - function number and  

ptrs to report, config, init and detect functions.
+ This data is used to point to the functions that need to be called
to config, init, detect and report data for the
+ new RMI4 function. These only need to be added for RMI4 functions
that support data source - like 2D sensors, buttons,
+ LEDs, GPIOs, etc. Refer to the RMI4 specification for information on
these RMI4 functions and what data they report.

drivers/input/touchscreen/rmi.h new file +3 -0
+*/
+
+struct rmi_functions_data  

rmi4_supported_data_src_functions[rmi4_num_supported_data_src_fns] =

drivers/input/touchscreen/rmi.h new file +18 -0
+{
+  /* Fn $11 */
+  {0x11, FN_11_report, FN_11_config, FN_11_init, FN_11_detect},
+  /* Fn $19 */
+  /* {0x19, FN_19_report, FN_19_config, FN_19_init, FN_19_detect), */
+
+};
+
+
+/** This encapsulates the information found using the RMI4 Function $01
+ *  query registers. There is only one Function $01 per device.
+ *
+ *  Assuming appropriate endian-ness, you can populate most of this
+ *  structure by reading query registers starting at the query base address
+ *  that was obtained from RMI4 function 0x01 function descriptor info read
+ *  from the Page Descriptor Table.
+ *
+ *  Specific register information is provided in the comments for each  

field.
+ * For further reference, please see the <i>Synaptics RMI4 Interfacing
+ * Guide</i> document.
+ */

drivers/input/touchscreen/rmi.h new file +52 -0
+struct rmi_module_info {
+  /** The Protocol Major Version number.
+   */
+  unsigned rmi_maj_ver;
+
+  /** The Protocol Minor Version number.
+   */
+  unsigned rmi_min_ver;
+
+  /** The manufacturer identification byte.
+   */
+  unsigned char mfgid;
+
+  /** The Product Properties information.
+   */
+  unsigned char properties;
+
+  /** The product info bytes.
+   * You can build a product info string using the following printf
+   * format and args:
+   * \code printf("%i %02i", productInfo[0], productInfo[1]); \endcode
+   */
+  unsigned char prod_info[2];
+
+   /** Date Code - Year, Month, Day.
+    */
+  unsigned char date_code[3];
+
+  /** Tester ID (14 bits).
+   */
+  unsigned short tester_id;
+
+  /** Serial Number (14 bits).
+   */
+  unsigned short serial_num;
+
+  /** A null-terminated string that identifies this particular product.
+   */
+  char prod_id[10];
+
+  /** A list of the function presence queries.
+   * This list uses the standard kernel linked list implementation.
+   * Documentation on on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   * \see rmi_function_info
+   */
+  struct list_head functions;
+};
+
+struct rmi_phys_driver {
+  char *name;
+  int  (*write)(struct rmi_phys_driver *pd, unsigned short address,  

char data);
+ int (*read)(struct rmi_phys_driver *pd, unsigned short address, char *buffer);
+ int (*write_multiple)(struct rmi_phys_driver *pd, unsigned short address, char *buffer, int length);
+ int (*read_multiple)(struct rmi_phys_driver *pd, unsigned short address, char *buffer, int length);

drivers/input/touchscreen/rmi.h new file +15 -0
+  void (*attention)(struct rmi_phys_driver *pd, int instance);
+  int  (*get_attention)(struct rmi_phys_driver *pd);
+  int  polling_required;
+  /* Private elements of the structure */
+  /** Standard kernel linked list implementation.
+   * Documentation on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   */
+  struct list_head drivers;
+  struct rmi_application *app;
+  struct rmi_module_info rmi;
+  struct module *module;
+};
+
+int rmi_read(struct rmi_application *app, unsigned short address, char  

*dest);
+int rmi_write(struct rmi_application *app, unsigned short address, unsigned char data);
+int rmi_read_multiple(struct rmi_application *app, unsigned short address, char *dest, int length);
+int rmi_write_multiple(struct rmi_application *app, unsigned short address, unsigned char *data, int length);

drivers/input/touchscreen/rmi.h new file +6 -0
+int rmi_register_phys_driver(struct rmi_phys_driver *rpd);
+int rmi_unregister_phys_driver(struct rmi_phys_driver *rpd);
+
+struct rmi_application *rmi_register_application(const char *name,
+  void (*attention)(struct rmi_phys_driver *pd, int instance),
+  int (*probe)(struct rmi_application *app, const struct  

rmi_module_info *rmi),

drivers/input/touchscreen/rmi.h new file +28 -0
+  void (*config)(struct rmi_application *app));
+
+void rmi_unregister_application(struct rmi_application *app);
+int  rmi_polling_required(struct rmi_application *app);
+int  rmi_get_attn(struct rmi_application *app);
+
+/** Set this to 1 to turn on code used in detecting buffer leaks. */
+#define RMI_ALLOC_STATS 1
+
+#if RMI_ALLOC_STATS
+extern int appallocsrmi;
+extern int rfiallocsrmi;
+extern int fnallocsrmi;
+
+#   define INC_ALLOC_STAT(X)   X##allocsrmi++
+#   define DEC_ALLOC_STAT(X)   \
+	do { if(X##allocsrmi) X##allocsrmi--; \
+	     else printk("Too many " #X " frees\n"); } while(0)
+#   define CHECK_ALLOC_STAT(X) \
+	do { if(X##allocsrmi) printk("Left over " #X " buffers: %d\n", \
+		X##allocsrmi); } while(0)
+#else
+#   define INC_ALLOC_STAT(X)   do { } while(0)
+#   define DEC_ALLOC_STAT(X)   do { } while(0)
+#   define CHECK_ALLOC_STAT(X) do { } while(0)
+#endif
+
+/* vim600: set noexpandtab sw=8 ts=8 :*/
(quoted diff) +0 -0

This is auto-generated file nad should not be included in the patch.

Quoted 100 lines

b/drivers/input/touchscreen/rmi.mod.c
new file mode 100755
index 0000000..e11b023

drivers/input/touchscreen/rmi.mod.c new file +20 -0
@@ -0,0 +1,20 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+};
+
+static const char __module_depends[]
+__attribute_used__
+__attribute__((section(".modinfo"))) =
+"depends=";
+
drivers/input/touchscreen/rmi_app_touchpad.c new file +3 -0
new file mode 100755
index 0000000..bc4d17f
@@ -0,0 +1,458 @@
+/**
+ * \file
+ * Synaptics Register Mapped Interface (RMI4) TouchPad Application  

Layer Driver.
+ * Copyright (c) 2007-2009 Synaptics Incorporated
+ *
+ *
+ * This code implements a polling mechanism with backoff as well as
+ * interrupt-driven sampling. For polling, the module has two parameters:
+ * polljif (Poll Jiffies) and hspolljif (High Speed Poll Jiffies). The driver
+ * polls at polljif until it sees a press, and then it polls at hspolljif.
+ * When there is no longer a touch, it reverts to the polljif period.
+ *
+ * The polljif parameter can be changed during run time like this:\code
+ * echo 100 > /sys/module/rmi_app_touchpad/parameters/polljif
+ * \endcode
+ *
+ * That will change the pollrate to 1 per second (assuming HZ == 100). The
+ * same is true for hspolljif.
+ *
+ * The parameters have no effect for the interrupt-driven case.
+ *
+ * Note that it is the lower-level drivers that determine whether this driver
+ * has to do polling or interrupt-driven. Polling can always be done, but if
+ * we have an interrupt connected to the attention (ATTN) line, then it is
+ * better to be interrupt driven.
+ *
+ */

drivers/input/touchscreen/rmi_app_touchpad.c new file +4 -0
+/*
+ * This file is licensed under the GPL2 license.
+ *
+  

*#############################################################################
+ * GPL
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+
*#############################################################################
+ */

drivers/input/touchscreen/rmi_app_touchpad.c new file +15 -0
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/kthread.h>
+#include <linux/freezer.h>
+#include <linux/input.h>
+
+#include "rmi_core.h"
+#include "rmi.h"
+
+#if RMI_ALLOC_STATS
+  static int pollallocsrmi = 0;
+#endif
+

drivers/input/touchscreen/rmi_app_touchpad.c line 69

Quoted 10 lines
drivers/input/touchscreen/rmi_app_touchpad.c new file +10 -0
+#define RMI_REPORT_RATE_40 (1 << 6)
+
+/** The number of jiffies between polls without touches */
+static int polljif = HZ/20;
+/** The number of jiffies between polls with touches */
+static int hspolljif = HZ/40;
+module_param(polljif, int, 0644);
+module_param(hspolljif, int, 0644);
+MODULE_PARM_DESC(polljif,   "How many jiffies between low speed polls.");
+MODULE_PARM_DESC(hspolljif, "How many jiffies between high speed polls.");

msecs is better suited for user interface and does not depend on HZ.

drivers/input/touchscreen/rmi_app_touchpad.c line 76

Quoted 7 lines
drivers/input/touchscreen/rmi_app_touchpad.c new file +7 -0
+
+static struct rmi_application *app = NULL;
+static struct completion touch_completion;
+static struct completion thread_comp;
+struct task_struct *kthread = NULL;
+static int time_to_quit = 0;
+static struct input_dev *input = NULL;

No need to initialize statics to 0/NULL.

Quickly scanning the rest there seem to be some more auto-generated files in the patch and also sometimes style does not quite follow the onle we have in the kernel. Would you mind running it through scripts/checkpatch.pl (don't worry about 80 column limit warnings), make sure the mailer does not mange the patch and resubmit so we can concentrate on the meat of the changes instead of cosmetics.

Thanks a lot!

Signature · 1 line
Dmitry
#3 lore raw

Hi Dmitry -

Thanks for the feedback - we really appreciate it. We are currently looking into the issues and the mailer-line wrap issue. We'll be re-sending a patch as soon as we get these issue resolved as soon as possible. Thanks,
William Manson

________________________________________
From: Dmitry Torokhov [[email protected]]
Sent: Saturday, December 19, 2009 7:05 PM
To: Christopher Heiny
Cc: Allie Xiong; William Manson; linux-kernel
Subject: Re: [RFC] [PATCH 1/1] input/touchscreen: Synaptics Touchscreen Driver

Hi Christopher,

Quoted 3 lines · Christopher Heiny

From: William Manson <[email protected]>

Initial driver for Synaptics touchscreens using RMI4 protocol.

Thank you very much for the driver. Unfortunately your mailer line-wrapped the patch, I also am not sure whether teh identation style was damaged my the mailer or if it is the original style (the kernel's standard is ident with hard TABs).

Some more appearance-related comments inside, I will look at the code more closely later.

Quoted 15 lines

index 32fc8ba..2b950f7 100644

drivers/input/touchscreen/Kconfig +2 -0
@@ -295,6 +295,19 @@ config TOUCHSCREEN_MIGOR
        To compile this driver as a module, choose M here: the
        module will be called migor_ts.
 
+config TOUCHSCREEN_SYNAPTICS_RMI4_I2C
+     tristate "Synaptics RMI4 I2C touchscreens"

drivers/input/touchscreen/Kconfig config TOUCHSCREEN_MIGOR · line 309

Quoted 10 lines
drivers/input/touchscreen/Kconfig +10 -0
+     depends on I2C
+     help
+       Say Y here if you have a Synaptics RMI4 I2C touchscreen connected to
+       your system. This enables support for Synaptics RMI4 over I2C based
+          touchscreens.
+
+       If unsure, say N.
+
+       To compile this driver as a set of modules, choose M here: the
+       modules will be called rmi, rmi_app_touchpad, rmi_phys_i2c.

I guess I need to read your RMI document but it is funny to see the entry in touchscreens with the only application of touchpad. Do you intend to produce more application modules later?

Quoted 10 lines
drivers/input/touchscreen/Kconfig +1 -0
+
 config TOUCHSCREEN_TOUCHRIGHT
      tristate "Touchright serial touchscreen"
      select SERIO
drivers/input/touchscreen/Makefile +0 -0
index f1f59c9..81f938a 100644

drivers/input/touchscreen/Makefile obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o · line 15

Quoted 4 lines
drivers/input/touchscreen/Makefile +0 -1
@@ -12,7 +12,6 @@ obj-$(CONFIG_TOUCHSCREEN_ADS7846)   += ads7846.o
 obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC)       += atmel_tsadcc.o
 obj-$(CONFIG_TOUCHSCREEN_BITSY)              += h3600_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_CORGI)              += corgi_ts.o
-obj-$(CONFIG_TOUCHSCREEN_DYNAPRO)    += dynapro.o

Uh-oh, what did you do with dynapro?

Quoted 83 lines
drivers/input/touchscreen/Makefile +1 -2
 obj-$(CONFIG_TOUCHSCREEN_GUNZE)              += gunze.o
 obj-$(CONFIG_TOUCHSCREEN_EETI)               += eeti_ts.o
 obj-$(CONFIG_TOUCHSCREEN_ELO)                += elo.o
@@ -26,9 +25,8 @@ obj-$(CONFIG_TOUCHSCREEN_HP600)             += hp680_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_HP7XX)              += jornada720_ts.o
 obj-$(CONFIG_TOUCHSCREEN_HTCPEN)     += htcpen.o
 obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE)      += usbtouchscreen.o
-obj-$(CONFIG_TOUCHSCREEN_PCAP)               += pcap_ts.o
 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)   += penmount.o
-obj-$(CONFIG_TOUCHSCREEN_S3C2410)    += s3c2410_ts.o
+obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) += rmi_core.o

rmi_app_touchpad.o rmi_function_11.o rmi_phys_i2c.o rmi_i2c_gta01.o
obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o

drivers/input/touchscreen/Makefile +1 -0
@@ -44,3 +42,4 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_ATMEL)      += atmel-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)   += mainstone-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)    += zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)    += w90p910_ts.o
+obj-$(CONFIG_TOUCHSCREEN_PCAP)               += pcap_ts.o
drivers/input/touchscreen/rmi.h new file +11 -0
new file mode 100755
index 0000000..6caa66f
@@ -0,0 +1,286 @@
+/**
+ * \file
+ * Synaptics Register Mapped Interface (RMI4) Header File.
+ * Copyright (c) 2007-2009 Synaptics Incorporated
+ *
+ *
+ */
+/*
+ * This file is licensed under the GPL2 license.
+ *
+

*#############################################################################
+ * GPL
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+
*#############################################################################
+ */

drivers/input/touchscreen/rmi.h new file +5 -0
+
+/** RMI4 Protocol Support
+ */
+
+/** For each function present on the RMI device, we need to get the

RMI4 Function
+ * Descriptor info from the Page Descriptor Table. This will give us the
+ * addresses for Query, Command, Control, Data and the Source Count (number
+ * of sources for this function) and the function id.
+ */

drivers/input/touchscreen/rmi.h new file +10 -0
+struct rmi_function_descriptor {
+  unsigned char queryBaseAddr;
+  unsigned char commandBaseAddr;
+  unsigned char controlBaseAddr;
+  unsigned char dataBaseAddr;
+  unsigned char interruptSrcCnt;
+  unsigned char functionNum;
+};
+
+/** For each function present on the RMI device, there will be a

corresponding
+ * entry in the functions list of the rmi_module_info structure. This entry
+ * gives information about the number of data sources and the number of data
+ * registers associated with the function.
+ * \see rmi_module_info
+ */

drivers/input/touchscreen/rmi.h line 55

Quoted 7 lines
drivers/input/touchscreen/rmi.h new file +7 -0
+struct rmi_function_info {
+  unsigned char functionNum;
+
+  /** This is the number of data sources associated with the function.
+   * \note This is not the total number of data registers associated with
+   * this function!
+   * \see data_regs

This style of markups is not used in the kernel, please try adopting kerneldoc style (Documentation/kernel-doc-nano-HOWTO.txt)

Review

Quoted 269 lines
drivers/input/touchscreen/rmi.h new file +5 -0
+   */
+  unsigned char numSources;
+
+  /** This is the number of data points supported - for example, for
+   *  function $11 (2D sensor) the number of data points is equal to

the number

drivers/input/touchscreen/rmi.h new file +9 -0
+   *  of fingers - for function $19 (buttons)it is the number of buttons.
+   */
+  unsigned char numDataPoints;
+
+  /** This is the number of data registers to read.
+   */
+  unsigned char dataRegBlockSize;
+
+  /** This is the interrupt register and mask - needed for enabling the

interrupts

drivers/input/touchscreen/rmi.h new file +19 -0
+   *  and for checking what source had caused the attention line interrupt.
+   */
+  unsigned char interruptRegister;
+  unsigned char interruptMask;
+
+  /** This is the RMI function descriptor associated with this function.
+   *  It contains the Base addresses for the functions query, command,
+   *  control, and data registers.
+   */
+  struct rmi_function_descriptor funcDescriptor;
+
+  /** Standard kernel linked list implementation.
+   * Documentation on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   */
+  struct list_head link;
+};
+
+/* This struct is for creating a list of RMI4 functions that have data

sources

drivers/input/touchscreen/rmi.h new file +8 -0
+   associated with them. This is to facilitate adding new support for other
+   data sources besides 2D sensors.
+
+   To add a new data source support, the developer will create a new file
+   and add these 4 functions below with FN$## in front of the names - where
+   ## is the hex number for the function taken from the RMI4 specification.
+
+   The function number will be associated with this and later will be

used to
+ match the RMI4 function to the 4 functions for that RMI4 function
number.

drivers/input/touchscreen/rmi.h new file +3 -0
+
+   The user will also have to add code that adds the new rmi_functions item
+   to the global list of RMI4 functions and stores the pointers to the

4 functions

drivers/input/touchscreen/rmi.h new file +8 -0
+   in the function pointers.
+*/
+struct rmi_functions {
+  unsigned char functionNum;
+
+  struct input_dev *input;
+
+  /* ptrs to function specific functions for report, config, init and

detect. */

drivers/input/touchscreen/rmi.h new file +2 -0
+  /* These ptrs. need to be filled in for every RMI4 function that has data
+     source(s) associated with it - like fn $11 (2D sensors), fn $19

(buttons),
+ etc. Each RMI4 function that has data sources will be added into a
list
+ that is used to match the function number against the number
stored here.

drivers/input/touchscreen/rmi.h new file +2 -0
+  */
+  int  (*report)(struct rmi_application *app, struct rmi_function_info

*rfi, struct input_dev *input);
+ void (*config)(struct rmi_application *app, struct rmi_function_info *rfi);

drivers/input/touchscreen/rmi.h new file +2 -0
+  void (*init)(struct input_dev *input);
+  void (*detect)(struct rmi_application *app, struct rmi_function_info

*rfi, struct rmi_function_descriptor *fd, unsigned int interruptCount);

drivers/input/touchscreen/rmi.h new file +10 -0
+
+  /** Standard kernel linked list implementation.
+   * Documentation on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   */
+  struct list_head link;
+};
+
+
+/* Each time a new RMI4 function support is added the developer needs

to bump the number of
+ supported data src functions and add the info for that RMI4 function
to the array along
+ with pointers to the report, config, init and detect functions that
they coded in rmi_function_xx.c
+ and rmi_function_xx.h - where xx is the RMI4 function number for the
new RMI4 data source function.
+ The information for the RMI4 functions is obtained from the RMI4
specification document.

drivers/input/touchscreen/rmi.h new file +4 -0
+*/
+#define rmi4_num_supported_data_src_fns 1
+
+/* add hdr files for all prototypes for RMI4 data source functions

being supported */

drivers/input/touchscreen/rmi.h new file +4 -0
+#include "rmi_function_11.h"
+/* #include "rmi_function_19.h" */
+
+typedef int(*reportFuncPtr)(struct rmi_application *, struct

rmi_function_info *, struct input_dev *);
+typedef void(*configFuncPtr)(struct rmi_application *app, struct rmi_function_info *rfi);

drivers/input/touchscreen/rmi.h new file +2 -0
+typedef void(*initFuncPtr)(struct input_dev *);
+typedef void(*detectFuncPtr)(struct rmi_application *, struct

rmi_function_info *, struct rmi_function_descriptor *, unsigned int);

drivers/input/touchscreen/rmi.h new file +10 -0
+
+struct rmi_functions_data {
+  int functionNumber;
+  reportFuncPtr reportFn;
+  configFuncPtr configFn;
+  initFuncPtr initFn;
+  detectFuncPtr detectFn;
+};
+/* NOTE:
+   Developer - add in any new RMI4 fn data info - function number and

ptrs to report, config, init and detect functions.
+ This data is used to point to the functions that need to be called
to config, init, detect and report data for the
+ new RMI4 function. These only need to be added for RMI4 functions
that support data source - like 2D sensors, buttons,
+ LEDs, GPIOs, etc. Refer to the RMI4 specification for information on
these RMI4 functions and what data they report.

drivers/input/touchscreen/rmi.h new file +3 -0
+*/
+
+struct rmi_functions_data

rmi4_supported_data_src_functions[rmi4_num_supported_data_src_fns] =

drivers/input/touchscreen/rmi.h new file +18 -0
+{
+  /* Fn $11 */
+  {0x11, FN_11_report, FN_11_config, FN_11_init, FN_11_detect},
+  /* Fn $19 */
+  /* {0x19, FN_19_report, FN_19_config, FN_19_init, FN_19_detect), */
+
+};
+
+
+/** This encapsulates the information found using the RMI4 Function $01
+ *  query registers. There is only one Function $01 per device.
+ *
+ *  Assuming appropriate endian-ness, you can populate most of this
+ *  structure by reading query registers starting at the query base address
+ *  that was obtained from RMI4 function 0x01 function descriptor info read
+ *  from the Page Descriptor Table.
+ *
+ *  Specific register information is provided in the comments for each

field.
+ * For further reference, please see the <i>Synaptics RMI4 Interfacing
+ * Guide</i> document.
+ */

drivers/input/touchscreen/rmi.h new file +52 -0
+struct rmi_module_info {
+  /** The Protocol Major Version number.
+   */
+  unsigned rmi_maj_ver;
+
+  /** The Protocol Minor Version number.
+   */
+  unsigned rmi_min_ver;
+
+  /** The manufacturer identification byte.
+   */
+  unsigned char mfgid;
+
+  /** The Product Properties information.
+   */
+  unsigned char properties;
+
+  /** The product info bytes.
+   * You can build a product info string using the following printf
+   * format and args:
+   * \code printf("%i %02i", productInfo[0], productInfo[1]); \endcode
+   */
+  unsigned char prod_info[2];
+
+   /** Date Code - Year, Month, Day.
+    */
+  unsigned char date_code[3];
+
+  /** Tester ID (14 bits).
+   */
+  unsigned short tester_id;
+
+  /** Serial Number (14 bits).
+   */
+  unsigned short serial_num;
+
+  /** A null-terminated string that identifies this particular product.
+   */
+  char prod_id[10];
+
+  /** A list of the function presence queries.
+   * This list uses the standard kernel linked list implementation.
+   * Documentation on on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   * \see rmi_function_info
+   */
+  struct list_head functions;
+};
+
+struct rmi_phys_driver {
+  char *name;
+  int  (*write)(struct rmi_phys_driver *pd, unsigned short address,

char data);
+ int (*read)(struct rmi_phys_driver *pd, unsigned short address, char *buffer);
+ int (*write_multiple)(struct rmi_phys_driver *pd, unsigned short address, char *buffer, int length);
+ int (*read_multiple)(struct rmi_phys_driver *pd, unsigned short address, char *buffer, int length);

drivers/input/touchscreen/rmi.h new file +15 -0
+  void (*attention)(struct rmi_phys_driver *pd, int instance);
+  int  (*get_attention)(struct rmi_phys_driver *pd);
+  int  polling_required;
+  /* Private elements of the structure */
+  /** Standard kernel linked list implementation.
+   * Documentation on how to use it can be found at
+   * http://isis.poly.edu/kulesh/stuff/src/klist/.
+   */
+  struct list_head drivers;
+  struct rmi_application *app;
+  struct rmi_module_info rmi;
+  struct module *module;
+};
+
+int rmi_read(struct rmi_application *app, unsigned short address, char

*dest);
+int rmi_write(struct rmi_application *app, unsigned short address, unsigned char data);
+int rmi_read_multiple(struct rmi_application *app, unsigned short address, char *dest, int length);
+int rmi_write_multiple(struct rmi_application *app, unsigned short address, unsigned char *data, int length);

drivers/input/touchscreen/rmi.h new file +6 -0
+int rmi_register_phys_driver(struct rmi_phys_driver *rpd);
+int rmi_unregister_phys_driver(struct rmi_phys_driver *rpd);
+
+struct rmi_application *rmi_register_application(const char *name,
+  void (*attention)(struct rmi_phys_driver *pd, int instance),
+  int (*probe)(struct rmi_application *app, const struct

rmi_module_info *rmi),

drivers/input/touchscreen/rmi.h new file +28 -0
+  void (*config)(struct rmi_application *app));
+
+void rmi_unregister_application(struct rmi_application *app);
+int  rmi_polling_required(struct rmi_application *app);
+int  rmi_get_attn(struct rmi_application *app);
+
+/** Set this to 1 to turn on code used in detecting buffer leaks. */
+#define RMI_ALLOC_STATS 1
+
+#if RMI_ALLOC_STATS
+extern int appallocsrmi;
+extern int rfiallocsrmi;
+extern int fnallocsrmi;
+
+#   define INC_ALLOC_STAT(X)   X##allocsrmi++
+#   define DEC_ALLOC_STAT(X)   \
+     do { if(X##allocsrmi) X##allocsrmi--; \
+          else printk("Too many " #X " frees\n"); } while(0)
+#   define CHECK_ALLOC_STAT(X) \
+     do { if(X##allocsrmi) printk("Left over " #X " buffers: %d\n", \
+             X##allocsrmi); } while(0)
+#else
+#   define INC_ALLOC_STAT(X)   do { } while(0)
+#   define DEC_ALLOC_STAT(X)   do { } while(0)
+#   define CHECK_ALLOC_STAT(X) do { } while(0)
+#endif
+
+/* vim600: set noexpandtab sw=8 ts=8 :*/
(quoted diff) +0 -0

This is auto-generated file nad should not be included in the patch.

Quoted 100 lines

b/drivers/input/touchscreen/rmi.mod.c
new file mode 100755
index 0000000..e11b023

drivers/input/touchscreen/rmi.mod.c new file +20 -0
@@ -0,0 +1,20 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+ .name = KBUILD_MODNAME,
+ .init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+ .exit = cleanup_module,
+#endif
+};
+
+static const char __module_depends[]
+__attribute_used__
+__attribute__((section(".modinfo"))) =
+"depends=";
+
drivers/input/touchscreen/rmi_app_touchpad.c new file +3 -0
new file mode 100755
index 0000000..bc4d17f
@@ -0,0 +1,458 @@
+/**
+ * \file
+ * Synaptics Register Mapped Interface (RMI4) TouchPad Application

Layer Driver.
+ * Copyright (c) 2007-2009 Synaptics Incorporated
+ *
+ *
+ * This code implements a polling mechanism with backoff as well as
+ * interrupt-driven sampling. For polling, the module has two parameters:
+ * polljif (Poll Jiffies) and hspolljif (High Speed Poll Jiffies). The driver
+ * polls at polljif until it sees a press, and then it polls at hspolljif.
+ * When there is no longer a touch, it reverts to the polljif period.
+ *
+ * The polljif parameter can be changed during run time like this:\code
+ * echo 100 > /sys/module/rmi_app_touchpad/parameters/polljif
+ * \endcode
+ *
+ * That will change the pollrate to 1 per second (assuming HZ == 100). The
+ * same is true for hspolljif.
+ *
+ * The parameters have no effect for the interrupt-driven case.
+ *
+ * Note that it is the lower-level drivers that determine whether this driver
+ * has to do polling or interrupt-driven. Polling can always be done, but if
+ * we have an interrupt connected to the attention (ATTN) line, then it is
+ * better to be interrupt driven.
+ *
+ */

drivers/input/touchscreen/rmi_app_touchpad.c new file +4 -0
+/*
+ * This file is licensed under the GPL2 license.
+ *
+

*#############################################################################
+ * GPL
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+
*#############################################################################
+ */

drivers/input/touchscreen/rmi_app_touchpad.c new file +15 -0
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/kthread.h>
+#include <linux/freezer.h>
+#include <linux/input.h>
+
+#include "rmi_core.h"
+#include "rmi.h"
+
+#if RMI_ALLOC_STATS
+  static int pollallocsrmi = 0;
+#endif
+

drivers/input/touchscreen/rmi_app_touchpad.c line 69

Quoted 10 lines
drivers/input/touchscreen/rmi_app_touchpad.c new file +10 -0
+#define RMI_REPORT_RATE_40 (1 << 6)
+
+/** The number of jiffies between polls without touches */
+static int polljif = HZ/20;
+/** The number of jiffies between polls with touches */
+static int hspolljif = HZ/40;
+module_param(polljif, int, 0644);
+module_param(hspolljif, int, 0644);
+MODULE_PARM_DESC(polljif,   "How many jiffies between low speed polls.");
+MODULE_PARM_DESC(hspolljif, "How many jiffies between high speed polls.");

msecs is better suited for user interface and does not depend on HZ.

drivers/input/touchscreen/rmi_app_touchpad.c line 76

Quoted 7 lines
drivers/input/touchscreen/rmi_app_touchpad.c new file +7 -0
+
+static struct rmi_application *app = NULL;
+static struct completion touch_completion;
+static struct completion thread_comp;
+struct task_struct *kthread = NULL;
+static int time_to_quit = 0;
+static struct input_dev *input = NULL;

No need to initialize statics to 0/NULL.

Quickly scanning the rest there seem to be some more auto-generated files in the patch and also sometimes style does not quite follow the onle we have in the kernel. Would you mind running it through scripts/checkpatch.pl (don't worry about 80 column limit warnings), make sure the mailer does not mange the patch and resubmit so we can concentrate on the meat of the changes instead of cosmetics.

Thanks a lot!

--
Dmitry

maintainer
#4 lore raw

Hi William,

Quoted 6 lines · William Manson

Hi Dmitry -

Thanks for the feedback - we really appreciate it. We are currently looking into the issues and the mailer-line wrap issue. We'll be re-sending a patch as soon as we get these issue resolved as soon as possible.

Could I also ask if you have any plans on extending support for the newer models of your touchpads (especially multi-touch ones) in the PS/2 version of the driver? Or maybe there is updated version of the Interfacing Guide that you could share with the community?

Thank you in advance,

Dmitry

#5 lore raw

Hi Dmitry -

Yes - we are planning on extending support for our new touchpads. As far as I know there is a Linux PS/2 driver in the works but I don't work with that group so I don't know anything about timeframes. I also don't know if it will be made open source or as a proprietary binary - or both. But we are definitely planning on supporting our PS/2 touchpads on Linux.

I will check into the Interfacing Guide and get back to you. The latest is on our web site (http://www.synaptics.com/developers/manuals) but it doesn't have info about multitouch in it. If there is a newer one I'll let you know.

Regards,

William

-----Original Message-----
From: Dmitry Torokhov [mailto:[email protected]]
Sent: Sunday, January 03, 2010 2:30 PM
To: William Manson
Cc: Christopher Heiny; Allie Xiong; linux-kernel
Subject: Re: [RFC] [PATCH 1/1] input/touchscreen: Synaptics Touchscreen Driver

Hi William,

Quoted 6 lines · William Manson

Hi Dmitry -

Thanks for the feedback - we really appreciate it. We are currently looking into the issues and the mailer-line wrap issue. We'll be re-sending a patch as soon as we get these issue resolved as soon as possible.

Could I also ask if you have any plans on extending support for the newer models of your touchpads (especially multi-touch ones) in the PS/2 version of the driver? Or maybe there is updated version of the Interfacing Guide that you could share with the community?

Thank you in advance,

Dmitry

maintainer
#6 lore raw
Quoted 5 lines · William Manson

Hi Dmitry -

Yes - we are planning on extending support for our new touchpads. As far as I know there is a Linux PS/2 driver in the works but I don't work with that group so I don't know anything about timeframes.

Is there a way to get in touch with that group? As you may know we have a pretty stable and reliable version of a driver for your older PS/2 products (thanks to Synaptics releasing very detailed interfacing guide) which is integrated in both kernel and Xorg, and which is used by most distributions. Users also expect "synaptics" to just work with their touchpads. I would rather see patches extending the exsting driver instead of completely new piece of software.

Quoted 10 lines

I also
don't know if it will be made open source or as a proprietary binary - or both. But we are definitely planning on supporting our PS/2 touchpads on Linux.

I will check into the Interfacing Guide and get back to you. The latest is on our web site
(http://www.synaptics.com/developers/manuals) but it doesn't have info about multitouch in it. If there is a newer one I'll let you know.

Thank you, much appreciated.

Signature · 1 line
Dmitry
#7 lore raw

Hi Dmitry -

I'll see if I can get someone in contact with you. I agree with you that patches to extend the existing driver would be preferable. It would probably be someone who is not working on the proprietary binary driver that would have to do the patches as the IP requires that we keep them separated. I wouldn't mind doing that myself as I'm already working on the open source driver for RMI4 over I2C and I have done a few minor things with the current open source kernel PS/2 driver - not patches but changes for minor issues that were for specific customers mostly in the area of configuration. Also, I'm not "tainted" by the proprietary driver - in fact I've never seen the code. I'll discuss with my boss if that's possible.

Regards,
William

-----Original Message-----
From: Dmitry Torokhov [mailto:[email protected]]
Sent: Tuesday, January 05, 2010 2:41 PM
To: William Manson
Cc: Christopher Heiny; Allie Xiong; linux-kernel
Subject: Re: [RFC] [PATCH 1/1] input/touchscreen: Synaptics Touchscreen Driver

Quoted 5 lines · William Manson

Hi Dmitry -

Yes - we are planning on extending support for our new touchpads. As far as I know there is a Linux PS/2 driver in the works but I don't work with that group so I don't know anything about timeframes.

Is there a way to get in touch with that group? As you may know we have a pretty stable and reliable version of a driver for your older PS/2 products (thanks to Synaptics releasing very detailed interfacing guide) which is integrated in both kernel and Xorg, and which is used by most distributions. Users also expect "synaptics" to just work with their touchpads. I would rather see patches extending the exsting driver instead of completely new piece of software.

Quoted 10 lines

I also
don't know if it will be made open source or as a proprietary binary - or both. But we are definitely planning on supporting our PS/2 touchpads on Linux.

I will check into the Interfacing Guide and get back to you. The latest is on our web site
(http://www.synaptics.com/developers/manuals) but it doesn't have info about multitouch in it. If there is a newer one I'll let you know.

Thank you, much appreciated.

--
Dmitry