Re: [PATCH v3] HID: rmi: Make hid-rmi a transport driver for synaptics-rmi4

2016-08-10 Thread Andrew Duggan

On 08/10/2016 01:28 AM, Benjamin Tissoires wrote:

Hi Andrew,

On Jun 24 2016 or thereabouts, Andrew Duggan wrote:

The Synaptics RMI4 driver provides support for RMI4 devices. Instead of
duplicating the RMI4 processing code, make hid-rmi a transport driver
and register it with the Synaptics RMI4 core.

Signed-off-by: Andrew Duggan 
---
In v3 I went ahead and added RMI4_F12 to the Kconfig so we will have it
ready for Precision Touchpad. I also added documentation for xport in
rmi_data.

Also, after thinking about this a bit more I think it makes sense to
enable dribble by default. With dribble disable the device reports
a single lift event. If that report gets dropped for some reason then
that will result in stuck contacts. The downside of dribble packets is that
it increases the amount of interrupts. But, this increase is really not
significant to overall performace. I also don't think it is worth trying
to identify platforms which have issues with dropped reports so that we
can set quirks or maintain a device list to enable dribble only on those
devices.

Andrew

  drivers/hid/Kconfig   |   4 +
  drivers/hid/hid-rmi.c | 963 --
  2 files changed, 142 insertions(+), 825 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 4117225..336b79d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -747,6 +747,10 @@ config HID_SUNPLUS
  config HID_RMI
tristate "Synaptics RMI4 device support"
depends on HID
+   select RMI4_CORE
+   select RMI4_F11
+   select RMI4_F12
+   select RMI4_F30
---help---
Support for Synaptics RMI4 touchpads.
Say Y here if you have a Synaptics RMI4 touchpads over i2c-hid or usbhid
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 9cd2ca3..d2739db 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -19,6 +19,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  #include "hid-ids.h"
  
  #define RMI_MOUSE_REPORT_ID		0x01 /* Mouse emulation Report */

@@ -33,9 +35,6 @@
  #define RMI_READ_DATA_PENDING 1
  #define RMI_STARTED   2
  
-#define RMI_SLEEP_NORMAL		0x0

-#define RMI_SLEEP_DEEP_SLEEP   0x1
-
  /* device flags */
  #define RMI_DEVICEBIT(0)
  #define RMI_DEVICE_HAS_PHYS_BUTTONS   BIT(1)
@@ -54,18 +53,10 @@ enum rmi_mode_type {
RMI_MODE_NO_PACKED_ATTN_REPORTS = 2,
  };
  
-struct rmi_function {

-   unsigned page;  /* page of the function */
-   u16 query_base_addr;/* base address for queries */
-   u16 command_base_addr;  /* base address for commands */
-   u16 control_base_addr;  /* base address for controls */
-   u16 data_base_addr; /* base address for datas */
-   unsigned int interrupt_base;/* cross-function interrupt number
-* (uniq in the device)*/
-   unsigned int interrupt_count;   /* number of interrupts */
-   unsigned int report_size;   /* size of a report */
-   unsigned long irq_mask; /* mask of the interrupts
-* (to be applied against ATTN IRQ) */
+/* Structure for storing attn report plus size of valid data in the kfifo */
+struct rmi_attn_report {
+   int size;
+   u8 data[];
  };
  
  /**

@@ -73,6 +64,7 @@ struct rmi_function {
   *
   * @page_mutex: Locks current page to avoid changing pages in unexpected ways.
   * @page: Keeps track of the current virtual page
+ * @xport: transport device to be registered with the RMI4 core.
   *
   * @wait: Used for waiting for read data
   *
@@ -84,26 +76,22 @@ struct rmi_function {
   *
   * @flags: flags for the current device (started, reading, etc...)
   *
- * @f11: placeholder of internal RMI function F11 description
- * @f30: placeholder of internal RMI function F30 description
- *
- * @max_fingers: maximum finger count reported by the device
- * @max_x: maximum x value reported by the device
- * @max_y: maximum y value reported by the device
- *
- * @gpio_led_count: count of GPIOs + LEDs reported by F30
- * @button_count: actual physical buttons count
- * @button_mask: button mask used to decode GPIO ATTN reports
- * @button_state_mask: pull state of the buttons
- *
- * @input: pointer to the kernel input device
- *
   * @reset_work: worker which will be called in case of a mouse report
+ * @attn_work: worker used for processing attention reports
   * @hdev: pointer to the struct hid_device
+ *
+ * @device_flags: flags which describe the device
+ *
+ * @attn_report_fifo: Store attn reports for deferred processing by worker
+ * @attn_report_size: size of an input report plus the size int
+ * @attn_report: buffer for storing the attn report while it is being processes
+ * @in_attn_report: buffer for storing input report plus size before adding it
+ * to the fifo.
   */
  struct 

Re: [PATCH v3] HID: rmi: Make hid-rmi a transport driver for synaptics-rmi4

2016-08-10 Thread Andrew Duggan

On 08/10/2016 01:28 AM, Benjamin Tissoires wrote:

Hi Andrew,

On Jun 24 2016 or thereabouts, Andrew Duggan wrote:

The Synaptics RMI4 driver provides support for RMI4 devices. Instead of
duplicating the RMI4 processing code, make hid-rmi a transport driver
and register it with the Synaptics RMI4 core.

Signed-off-by: Andrew Duggan 
---
In v3 I went ahead and added RMI4_F12 to the Kconfig so we will have it
ready for Precision Touchpad. I also added documentation for xport in
rmi_data.

Also, after thinking about this a bit more I think it makes sense to
enable dribble by default. With dribble disable the device reports
a single lift event. If that report gets dropped for some reason then
that will result in stuck contacts. The downside of dribble packets is that
it increases the amount of interrupts. But, this increase is really not
significant to overall performace. I also don't think it is worth trying
to identify platforms which have issues with dropped reports so that we
can set quirks or maintain a device list to enable dribble only on those
devices.

Andrew

  drivers/hid/Kconfig   |   4 +
  drivers/hid/hid-rmi.c | 963 --
  2 files changed, 142 insertions(+), 825 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 4117225..336b79d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -747,6 +747,10 @@ config HID_SUNPLUS
  config HID_RMI
tristate "Synaptics RMI4 device support"
depends on HID
+   select RMI4_CORE
+   select RMI4_F11
+   select RMI4_F12
+   select RMI4_F30
---help---
Support for Synaptics RMI4 touchpads.
Say Y here if you have a Synaptics RMI4 touchpads over i2c-hid or usbhid
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 9cd2ca3..d2739db 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -19,6 +19,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  #include "hid-ids.h"
  
  #define RMI_MOUSE_REPORT_ID		0x01 /* Mouse emulation Report */

@@ -33,9 +35,6 @@
  #define RMI_READ_DATA_PENDING 1
  #define RMI_STARTED   2
  
-#define RMI_SLEEP_NORMAL		0x0

-#define RMI_SLEEP_DEEP_SLEEP   0x1
-
  /* device flags */
  #define RMI_DEVICEBIT(0)
  #define RMI_DEVICE_HAS_PHYS_BUTTONS   BIT(1)
@@ -54,18 +53,10 @@ enum rmi_mode_type {
RMI_MODE_NO_PACKED_ATTN_REPORTS = 2,
  };
  
-struct rmi_function {

-   unsigned page;  /* page of the function */
-   u16 query_base_addr;/* base address for queries */
-   u16 command_base_addr;  /* base address for commands */
-   u16 control_base_addr;  /* base address for controls */
-   u16 data_base_addr; /* base address for datas */
-   unsigned int interrupt_base;/* cross-function interrupt number
-* (uniq in the device)*/
-   unsigned int interrupt_count;   /* number of interrupts */
-   unsigned int report_size;   /* size of a report */
-   unsigned long irq_mask; /* mask of the interrupts
-* (to be applied against ATTN IRQ) */
+/* Structure for storing attn report plus size of valid data in the kfifo */
+struct rmi_attn_report {
+   int size;
+   u8 data[];
  };
  
  /**

@@ -73,6 +64,7 @@ struct rmi_function {
   *
   * @page_mutex: Locks current page to avoid changing pages in unexpected ways.
   * @page: Keeps track of the current virtual page
+ * @xport: transport device to be registered with the RMI4 core.
   *
   * @wait: Used for waiting for read data
   *
@@ -84,26 +76,22 @@ struct rmi_function {
   *
   * @flags: flags for the current device (started, reading, etc...)
   *
- * @f11: placeholder of internal RMI function F11 description
- * @f30: placeholder of internal RMI function F30 description
- *
- * @max_fingers: maximum finger count reported by the device
- * @max_x: maximum x value reported by the device
- * @max_y: maximum y value reported by the device
- *
- * @gpio_led_count: count of GPIOs + LEDs reported by F30
- * @button_count: actual physical buttons count
- * @button_mask: button mask used to decode GPIO ATTN reports
- * @button_state_mask: pull state of the buttons
- *
- * @input: pointer to the kernel input device
- *
   * @reset_work: worker which will be called in case of a mouse report
+ * @attn_work: worker used for processing attention reports
   * @hdev: pointer to the struct hid_device
+ *
+ * @device_flags: flags which describe the device
+ *
+ * @attn_report_fifo: Store attn reports for deferred processing by worker
+ * @attn_report_size: size of an input report plus the size int
+ * @attn_report: buffer for storing the attn report while it is being processes
+ * @in_attn_report: buffer for storing input report plus size before adding it
+ * to the fifo.
   */
  struct rmi_data {

Re: [PATCH v3] HID: rmi: Make hid-rmi a transport driver for synaptics-rmi4

2016-08-10 Thread Benjamin Tissoires
Hi Andrew,

On Jun 24 2016 or thereabouts, Andrew Duggan wrote:
> The Synaptics RMI4 driver provides support for RMI4 devices. Instead of
> duplicating the RMI4 processing code, make hid-rmi a transport driver
> and register it with the Synaptics RMI4 core.
> 
> Signed-off-by: Andrew Duggan 
> ---
> In v3 I went ahead and added RMI4_F12 to the Kconfig so we will have it
> ready for Precision Touchpad. I also added documentation for xport in
> rmi_data.
> 
> Also, after thinking about this a bit more I think it makes sense to
> enable dribble by default. With dribble disable the device reports
> a single lift event. If that report gets dropped for some reason then
> that will result in stuck contacts. The downside of dribble packets is that
> it increases the amount of interrupts. But, this increase is really not
> significant to overall performace. I also don't think it is worth trying
> to identify platforms which have issues with dropped reports so that we
> can set quirks or maintain a device list to enable dribble only on those
> devices.
> 
> Andrew
> 
>  drivers/hid/Kconfig   |   4 +
>  drivers/hid/hid-rmi.c | 963 
> --
>  2 files changed, 142 insertions(+), 825 deletions(-)
> 
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index 4117225..336b79d 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -747,6 +747,10 @@ config HID_SUNPLUS
>  config HID_RMI
>   tristate "Synaptics RMI4 device support"
>   depends on HID
> + select RMI4_CORE
> + select RMI4_F11
> + select RMI4_F12
> + select RMI4_F30
>   ---help---
>   Support for Synaptics RMI4 touchpads.
>   Say Y here if you have a Synaptics RMI4 touchpads over i2c-hid or usbhid
> diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
> index 9cd2ca3..d2739db 100644
> --- a/drivers/hid/hid-rmi.c
> +++ b/drivers/hid/hid-rmi.c
> @@ -19,6 +19,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include "hid-ids.h"
>  
>  #define RMI_MOUSE_REPORT_ID  0x01 /* Mouse emulation Report */
> @@ -33,9 +35,6 @@
>  #define RMI_READ_DATA_PENDING1
>  #define RMI_STARTED  2
>  
> -#define RMI_SLEEP_NORMAL 0x0
> -#define RMI_SLEEP_DEEP_SLEEP 0x1
> -
>  /* device flags */
>  #define RMI_DEVICE   BIT(0)
>  #define RMI_DEVICE_HAS_PHYS_BUTTONS  BIT(1)
> @@ -54,18 +53,10 @@ enum rmi_mode_type {
>   RMI_MODE_NO_PACKED_ATTN_REPORTS = 2,
>  };
>  
> -struct rmi_function {
> - unsigned page;  /* page of the function */
> - u16 query_base_addr;/* base address for queries */
> - u16 command_base_addr;  /* base address for commands */
> - u16 control_base_addr;  /* base address for controls */
> - u16 data_base_addr; /* base address for datas */
> - unsigned int interrupt_base;/* cross-function interrupt number
> -  * (uniq in the device)*/
> - unsigned int interrupt_count;   /* number of interrupts */
> - unsigned int report_size;   /* size of a report */
> - unsigned long irq_mask; /* mask of the interrupts
> -  * (to be applied against ATTN IRQ) */
> +/* Structure for storing attn report plus size of valid data in the kfifo */
> +struct rmi_attn_report {
> + int size;
> + u8 data[];
>  };
>  
>  /**
> @@ -73,6 +64,7 @@ struct rmi_function {
>   *
>   * @page_mutex: Locks current page to avoid changing pages in unexpected 
> ways.
>   * @page: Keeps track of the current virtual page
> + * @xport: transport device to be registered with the RMI4 core.
>   *
>   * @wait: Used for waiting for read data
>   *
> @@ -84,26 +76,22 @@ struct rmi_function {
>   *
>   * @flags: flags for the current device (started, reading, etc...)
>   *
> - * @f11: placeholder of internal RMI function F11 description
> - * @f30: placeholder of internal RMI function F30 description
> - *
> - * @max_fingers: maximum finger count reported by the device
> - * @max_x: maximum x value reported by the device
> - * @max_y: maximum y value reported by the device
> - *
> - * @gpio_led_count: count of GPIOs + LEDs reported by F30
> - * @button_count: actual physical buttons count
> - * @button_mask: button mask used to decode GPIO ATTN reports
> - * @button_state_mask: pull state of the buttons
> - *
> - * @input: pointer to the kernel input device
> - *
>   * @reset_work: worker which will be called in case of a mouse report
> + * @attn_work: worker used for processing attention reports
>   * @hdev: pointer to the struct hid_device
> + *
> + * @device_flags: flags which describe the device
> + *
> + * @attn_report_fifo: Store attn reports for deferred processing by worker
> + * @attn_report_size: size of an input report plus the size int
> + * @attn_report: buffer for storing the attn report 

Re: [PATCH v3] HID: rmi: Make hid-rmi a transport driver for synaptics-rmi4

2016-08-10 Thread Benjamin Tissoires
Hi Andrew,

On Jun 24 2016 or thereabouts, Andrew Duggan wrote:
> The Synaptics RMI4 driver provides support for RMI4 devices. Instead of
> duplicating the RMI4 processing code, make hid-rmi a transport driver
> and register it with the Synaptics RMI4 core.
> 
> Signed-off-by: Andrew Duggan 
> ---
> In v3 I went ahead and added RMI4_F12 to the Kconfig so we will have it
> ready for Precision Touchpad. I also added documentation for xport in
> rmi_data.
> 
> Also, after thinking about this a bit more I think it makes sense to
> enable dribble by default. With dribble disable the device reports
> a single lift event. If that report gets dropped for some reason then
> that will result in stuck contacts. The downside of dribble packets is that
> it increases the amount of interrupts. But, this increase is really not
> significant to overall performace. I also don't think it is worth trying
> to identify platforms which have issues with dropped reports so that we
> can set quirks or maintain a device list to enable dribble only on those
> devices.
> 
> Andrew
> 
>  drivers/hid/Kconfig   |   4 +
>  drivers/hid/hid-rmi.c | 963 
> --
>  2 files changed, 142 insertions(+), 825 deletions(-)
> 
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index 4117225..336b79d 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -747,6 +747,10 @@ config HID_SUNPLUS
>  config HID_RMI
>   tristate "Synaptics RMI4 device support"
>   depends on HID
> + select RMI4_CORE
> + select RMI4_F11
> + select RMI4_F12
> + select RMI4_F30
>   ---help---
>   Support for Synaptics RMI4 touchpads.
>   Say Y here if you have a Synaptics RMI4 touchpads over i2c-hid or usbhid
> diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
> index 9cd2ca3..d2739db 100644
> --- a/drivers/hid/hid-rmi.c
> +++ b/drivers/hid/hid-rmi.c
> @@ -19,6 +19,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include "hid-ids.h"
>  
>  #define RMI_MOUSE_REPORT_ID  0x01 /* Mouse emulation Report */
> @@ -33,9 +35,6 @@
>  #define RMI_READ_DATA_PENDING1
>  #define RMI_STARTED  2
>  
> -#define RMI_SLEEP_NORMAL 0x0
> -#define RMI_SLEEP_DEEP_SLEEP 0x1
> -
>  /* device flags */
>  #define RMI_DEVICE   BIT(0)
>  #define RMI_DEVICE_HAS_PHYS_BUTTONS  BIT(1)
> @@ -54,18 +53,10 @@ enum rmi_mode_type {
>   RMI_MODE_NO_PACKED_ATTN_REPORTS = 2,
>  };
>  
> -struct rmi_function {
> - unsigned page;  /* page of the function */
> - u16 query_base_addr;/* base address for queries */
> - u16 command_base_addr;  /* base address for commands */
> - u16 control_base_addr;  /* base address for controls */
> - u16 data_base_addr; /* base address for datas */
> - unsigned int interrupt_base;/* cross-function interrupt number
> -  * (uniq in the device)*/
> - unsigned int interrupt_count;   /* number of interrupts */
> - unsigned int report_size;   /* size of a report */
> - unsigned long irq_mask; /* mask of the interrupts
> -  * (to be applied against ATTN IRQ) */
> +/* Structure for storing attn report plus size of valid data in the kfifo */
> +struct rmi_attn_report {
> + int size;
> + u8 data[];
>  };
>  
>  /**
> @@ -73,6 +64,7 @@ struct rmi_function {
>   *
>   * @page_mutex: Locks current page to avoid changing pages in unexpected 
> ways.
>   * @page: Keeps track of the current virtual page
> + * @xport: transport device to be registered with the RMI4 core.
>   *
>   * @wait: Used for waiting for read data
>   *
> @@ -84,26 +76,22 @@ struct rmi_function {
>   *
>   * @flags: flags for the current device (started, reading, etc...)
>   *
> - * @f11: placeholder of internal RMI function F11 description
> - * @f30: placeholder of internal RMI function F30 description
> - *
> - * @max_fingers: maximum finger count reported by the device
> - * @max_x: maximum x value reported by the device
> - * @max_y: maximum y value reported by the device
> - *
> - * @gpio_led_count: count of GPIOs + LEDs reported by F30
> - * @button_count: actual physical buttons count
> - * @button_mask: button mask used to decode GPIO ATTN reports
> - * @button_state_mask: pull state of the buttons
> - *
> - * @input: pointer to the kernel input device
> - *
>   * @reset_work: worker which will be called in case of a mouse report
> + * @attn_work: worker used for processing attention reports
>   * @hdev: pointer to the struct hid_device
> + *
> + * @device_flags: flags which describe the device
> + *
> + * @attn_report_fifo: Store attn reports for deferred processing by worker
> + * @attn_report_size: size of an input report plus the size int
> + * @attn_report: buffer for storing the attn report while it is being 
> 

[PATCH v3] HID: rmi: Make hid-rmi a transport driver for synaptics-rmi4

2016-06-24 Thread Andrew Duggan
The Synaptics RMI4 driver provides support for RMI4 devices. Instead of
duplicating the RMI4 processing code, make hid-rmi a transport driver
and register it with the Synaptics RMI4 core.

Signed-off-by: Andrew Duggan 
---
In v3 I went ahead and added RMI4_F12 to the Kconfig so we will have it
ready for Precision Touchpad. I also added documentation for xport in
rmi_data.

Also, after thinking about this a bit more I think it makes sense to
enable dribble by default. With dribble disable the device reports
a single lift event. If that report gets dropped for some reason then
that will result in stuck contacts. The downside of dribble packets is that
it increases the amount of interrupts. But, this increase is really not
significant to overall performace. I also don't think it is worth trying
to identify platforms which have issues with dropped reports so that we
can set quirks or maintain a device list to enable dribble only on those
devices.

Andrew

 drivers/hid/Kconfig   |   4 +
 drivers/hid/hid-rmi.c | 963 --
 2 files changed, 142 insertions(+), 825 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 4117225..336b79d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -747,6 +747,10 @@ config HID_SUNPLUS
 config HID_RMI
tristate "Synaptics RMI4 device support"
depends on HID
+   select RMI4_CORE
+   select RMI4_F11
+   select RMI4_F12
+   select RMI4_F30
---help---
Support for Synaptics RMI4 touchpads.
Say Y here if you have a Synaptics RMI4 touchpads over i2c-hid or usbhid
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 9cd2ca3..d2739db 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -19,6 +19,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "hid-ids.h"
 
 #define RMI_MOUSE_REPORT_ID0x01 /* Mouse emulation Report */
@@ -33,9 +35,6 @@
 #define RMI_READ_DATA_PENDING  1
 #define RMI_STARTED2
 
-#define RMI_SLEEP_NORMAL   0x0
-#define RMI_SLEEP_DEEP_SLEEP   0x1
-
 /* device flags */
 #define RMI_DEVICE BIT(0)
 #define RMI_DEVICE_HAS_PHYS_BUTTONSBIT(1)
@@ -54,18 +53,10 @@ enum rmi_mode_type {
RMI_MODE_NO_PACKED_ATTN_REPORTS = 2,
 };
 
-struct rmi_function {
-   unsigned page;  /* page of the function */
-   u16 query_base_addr;/* base address for queries */
-   u16 command_base_addr;  /* base address for commands */
-   u16 control_base_addr;  /* base address for controls */
-   u16 data_base_addr; /* base address for datas */
-   unsigned int interrupt_base;/* cross-function interrupt number
-* (uniq in the device)*/
-   unsigned int interrupt_count;   /* number of interrupts */
-   unsigned int report_size;   /* size of a report */
-   unsigned long irq_mask; /* mask of the interrupts
-* (to be applied against ATTN IRQ) */
+/* Structure for storing attn report plus size of valid data in the kfifo */
+struct rmi_attn_report {
+   int size;
+   u8 data[];
 };
 
 /**
@@ -73,6 +64,7 @@ struct rmi_function {
  *
  * @page_mutex: Locks current page to avoid changing pages in unexpected ways.
  * @page: Keeps track of the current virtual page
+ * @xport: transport device to be registered with the RMI4 core.
  *
  * @wait: Used for waiting for read data
  *
@@ -84,26 +76,22 @@ struct rmi_function {
  *
  * @flags: flags for the current device (started, reading, etc...)
  *
- * @f11: placeholder of internal RMI function F11 description
- * @f30: placeholder of internal RMI function F30 description
- *
- * @max_fingers: maximum finger count reported by the device
- * @max_x: maximum x value reported by the device
- * @max_y: maximum y value reported by the device
- *
- * @gpio_led_count: count of GPIOs + LEDs reported by F30
- * @button_count: actual physical buttons count
- * @button_mask: button mask used to decode GPIO ATTN reports
- * @button_state_mask: pull state of the buttons
- *
- * @input: pointer to the kernel input device
- *
  * @reset_work: worker which will be called in case of a mouse report
+ * @attn_work: worker used for processing attention reports
  * @hdev: pointer to the struct hid_device
+ *
+ * @device_flags: flags which describe the device
+ *
+ * @attn_report_fifo: Store attn reports for deferred processing by worker
+ * @attn_report_size: size of an input report plus the size int
+ * @attn_report: buffer for storing the attn report while it is being processes
+ * @in_attn_report: buffer for storing input report plus size before adding it
+ * to the fifo.
  */
 struct rmi_data {
struct mutex page_mutex;
int page;
+   struct rmi_transport_dev xport;
 

[PATCH v3] HID: rmi: Make hid-rmi a transport driver for synaptics-rmi4

2016-06-24 Thread Andrew Duggan
The Synaptics RMI4 driver provides support for RMI4 devices. Instead of
duplicating the RMI4 processing code, make hid-rmi a transport driver
and register it with the Synaptics RMI4 core.

Signed-off-by: Andrew Duggan 
---
In v3 I went ahead and added RMI4_F12 to the Kconfig so we will have it
ready for Precision Touchpad. I also added documentation for xport in
rmi_data.

Also, after thinking about this a bit more I think it makes sense to
enable dribble by default. With dribble disable the device reports
a single lift event. If that report gets dropped for some reason then
that will result in stuck contacts. The downside of dribble packets is that
it increases the amount of interrupts. But, this increase is really not
significant to overall performace. I also don't think it is worth trying
to identify platforms which have issues with dropped reports so that we
can set quirks or maintain a device list to enable dribble only on those
devices.

Andrew

 drivers/hid/Kconfig   |   4 +
 drivers/hid/hid-rmi.c | 963 --
 2 files changed, 142 insertions(+), 825 deletions(-)

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 4117225..336b79d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -747,6 +747,10 @@ config HID_SUNPLUS
 config HID_RMI
tristate "Synaptics RMI4 device support"
depends on HID
+   select RMI4_CORE
+   select RMI4_F11
+   select RMI4_F12
+   select RMI4_F30
---help---
Support for Synaptics RMI4 touchpads.
Say Y here if you have a Synaptics RMI4 touchpads over i2c-hid or usbhid
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 9cd2ca3..d2739db 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -19,6 +19,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "hid-ids.h"
 
 #define RMI_MOUSE_REPORT_ID0x01 /* Mouse emulation Report */
@@ -33,9 +35,6 @@
 #define RMI_READ_DATA_PENDING  1
 #define RMI_STARTED2
 
-#define RMI_SLEEP_NORMAL   0x0
-#define RMI_SLEEP_DEEP_SLEEP   0x1
-
 /* device flags */
 #define RMI_DEVICE BIT(0)
 #define RMI_DEVICE_HAS_PHYS_BUTTONSBIT(1)
@@ -54,18 +53,10 @@ enum rmi_mode_type {
RMI_MODE_NO_PACKED_ATTN_REPORTS = 2,
 };
 
-struct rmi_function {
-   unsigned page;  /* page of the function */
-   u16 query_base_addr;/* base address for queries */
-   u16 command_base_addr;  /* base address for commands */
-   u16 control_base_addr;  /* base address for controls */
-   u16 data_base_addr; /* base address for datas */
-   unsigned int interrupt_base;/* cross-function interrupt number
-* (uniq in the device)*/
-   unsigned int interrupt_count;   /* number of interrupts */
-   unsigned int report_size;   /* size of a report */
-   unsigned long irq_mask; /* mask of the interrupts
-* (to be applied against ATTN IRQ) */
+/* Structure for storing attn report plus size of valid data in the kfifo */
+struct rmi_attn_report {
+   int size;
+   u8 data[];
 };
 
 /**
@@ -73,6 +64,7 @@ struct rmi_function {
  *
  * @page_mutex: Locks current page to avoid changing pages in unexpected ways.
  * @page: Keeps track of the current virtual page
+ * @xport: transport device to be registered with the RMI4 core.
  *
  * @wait: Used for waiting for read data
  *
@@ -84,26 +76,22 @@ struct rmi_function {
  *
  * @flags: flags for the current device (started, reading, etc...)
  *
- * @f11: placeholder of internal RMI function F11 description
- * @f30: placeholder of internal RMI function F30 description
- *
- * @max_fingers: maximum finger count reported by the device
- * @max_x: maximum x value reported by the device
- * @max_y: maximum y value reported by the device
- *
- * @gpio_led_count: count of GPIOs + LEDs reported by F30
- * @button_count: actual physical buttons count
- * @button_mask: button mask used to decode GPIO ATTN reports
- * @button_state_mask: pull state of the buttons
- *
- * @input: pointer to the kernel input device
- *
  * @reset_work: worker which will be called in case of a mouse report
+ * @attn_work: worker used for processing attention reports
  * @hdev: pointer to the struct hid_device
+ *
+ * @device_flags: flags which describe the device
+ *
+ * @attn_report_fifo: Store attn reports for deferred processing by worker
+ * @attn_report_size: size of an input report plus the size int
+ * @attn_report: buffer for storing the attn report while it is being processes
+ * @in_attn_report: buffer for storing input report plus size before adding it
+ * to the fifo.
  */
 struct rmi_data {
struct mutex page_mutex;
int page;
+   struct rmi_transport_dev xport;
 
wait_queue_head_t wait;
 
@@ -115,34