Skip to contentSkip to conversation

Input: synaptics-rmi4: Create common functions for 2D sensors

PATCH In review Andrew Duggan 3 participants 3 messages Nov 5, 2015 – Nov 9, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 20/26 Input: synaptics-rmi4: Create common functions for 2D sensors

RMI4 defines two functions for 2D sensors. This patch moves some of the code which is shared between the two functions into a new file to avoid duplicating the code on rmi_f11.c and rmi_f12.c.

---
 .../bindings/input/rmi4/rmi_2d_sensor.txt          |  55 +++
 drivers/input/rmi4/Kconfig                         |  11 +
 drivers/input/rmi4/Makefile                        |   2 +
 drivers/input/rmi4/rmi_2d_sensor.c                 | 370 ++++++++++++++++
 drivers/input/rmi4/rmi_2d_sensor.h                 |  87 ++++
 drivers/input/rmi4/rmi_f11.c                       | 487 +++++----------------
 include/linux/rmi.h                                |  30 +-
 7 files changed, 639 insertions(+), 403 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt
 create mode 100644 drivers/input/rmi4/rmi_2d_sensor.c
 create mode 100644 drivers/input/rmi4/rmi_2d_sensor.h
Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt new file +55 -0
new file mode 100644
index 0000000..79411c0
@@ -0,0 +1,55 @@
+Synaptics RMI4 2D Sensor Device Binding
+
+The Synaptics RMI4 core is able to support RMI4 devices using differnet
+transports and differnet functions. This file describes the device tree
+bindings for devices which contain 2D sensors using Function 11 or
+Function 12. Complete documentation for transports and other functions
+can be found in:
+Documentation/devicetree/bindings/input/rmi4.
+
+RMI4 Function 11 and Function 12 are for 2D touch position sensing.
+Additional documentation for F11 can be found at:
+http://www.synaptics.com/sites/default/files/511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf
+
+Optional Properties:
+- syna,swap-axes: Swap X and Y positions when reporting (boolean).
+- syna,flip-x: Reverse the direction of X (boolean).
+- syna,flip-y: Reverse the direction of Y (boolean).
+- syna,clip-x-low: Sets a minimum value for X.
+- syna,clip-y-low: Sets a minimum value for Y.
+- syna,clip-x-high: Sets a maximum value for X.
+- syna,clip-y-high: Sets a maximum value for Y.
+- syna,offset-x: Add an offset to X.
+- syna,offset_y: Add an offset to Y.
+- syna,delta-x-threshold: Set the minimum distance on the X axis required
+				to generate an interrupt in reduced reporting
+				mode.
+- syna,delta-y-threshold: Set the minimum distance on the Y axis required
+				to generate an interrupt in reduced reporting
+				mode.
+- syna,type-a: Report type A multitouch events.
+- syna,sensor-type: Set the sensor type. 1 for touchscreen 2 for touchpad.
+- syna,x-mm: The length in millimeters of the X axis.
+- syna,y-mm: The length in millimeters of the Y axis.
+- syna,disable-report-mask: Mask for disabling posiiton reporting. Used to
+				disable reporing absolute position data.
+- syna,rezero-wait: Time in miliseconds to wait after issuing a rezero
+				command.
+
+
+Example of a RMI4 I2C device with F11:
+Example:
+	&i2c1 {
+		rmi-i2c-dev@2c {
+			compatible = "syna,rmi-i2c";
+
+			...
+
+			rmi-f11@11 {
+				reg = <0x11>;
+				syna,flip-y;
+				syna,sensor-type = <2>;
+			};
+		};
+	};
+
drivers/input/rmi4/Kconfig +11 -0
index 88a3919..db2c1be 100644
@@ -45,6 +45,17 @@ config RMI4_SPI
 
 	  If unsure, say N.
 
+config RMI4_2D_SENSOR
+	bool "RMI4 2D Sensors"
+	depends on RMI4_CORE
+	default y if RMI4_CORE
+	help
+	  Say Y here if you want to add support for 2D Sensors.
+
+	  Provides core functionality for 2D multifinger pointing for
+	  touchscreens and touchpads using RMI4 functions 11 and 12. This
+	  feature is needed is the device contains either F11 or F12.
+
 config RMI4_F11
 	bool "RMI4 Function 11 (2D pointing)"
 	depends on RMI4_CORE
drivers/input/rmi4/Makefile +2 -0
index 1745757..e4812d8 100644
@@ -1,6 +1,8 @@
 obj-$(CONFIG_RMI4_CORE) += rmi_core.o
 rmi_core-y := rmi_bus.o rmi_driver.o rmi_f01.o
 
+rmi_core-$(CONFIG_RMI4_2D_SENSOR) += rmi_2d_sensor.o
+
 # Function drivers
 rmi_core-$(CONFIG_RMI4_F11) += rmi_f11.o
 
drivers/input/rmi4/rmi_2d_sensor.c new file +370 -0

370 lines not on this page · raw message

drivers/input/rmi4/rmi_2d_sensor.h new file +87 -0

87 lines not on this page · raw message

drivers/input/rmi4/rmi_f11.c +99 -388

661 lines not on this page · raw message

include/linux/rmi.h +15 -15
index c781d09..0092787 100644
@@ -32,7 +32,7 @@ enum rmi_attn_polarity {
 };
 
 /**
- * struct rmi_f11_axis_alignment - target axis alignment
+ * struct rmi_2d_axis_alignment - target axis alignment
  * @swap_axes: set to TRUE if desired to swap x- and y-axis
  * @flip_x: set to TRUE if desired to flip direction on x-axis
  * @flip_y: set to TRUE if desired to flip direction on y-axis
@@ -49,10 +49,10 @@ enum rmi_attn_polarity {
  * @rel_report_enabled - if set to true, the relative reporting will be
  *               automatically enabled for this sensor.
  */
-struct rmi_f11_2d_axis_alignment {
-	u32 swap_axes;	/* boolean, but u32 is needed by debugfs API */
-	u32 flip_x;	/* boolean */
-	u32 flip_y;	/* boolean */
+struct rmi_2d_axis_alignment {
+	bool swap_axes;
+	bool flip_x;
+	bool flip_y;
 	u16 clip_x_low;
 	u16 clip_y_low;
 	u16 clip_x_high;
@@ -73,16 +73,16 @@ struct rmi_f11_2d_axis_alignment {
  * @rmi_f11_sensor_touchpad - thread the sensor as a touchpad (indirect
  * pointing).
  */
-enum rmi_f11_sensor_type {
-	rmi_f11_sensor_default = 0,
-	rmi_f11_sensor_touchscreen,
-	rmi_f11_sensor_touchpad
+enum rmi_sensor_type {
+	rmi_sensor_default = 0,
+	rmi_sensor_touchscreen,
+	rmi_sensor_touchpad
 };
 
 #define RMI_F11_DISABLE_ABS_REPORT      BIT(0)
 
 /**
- * struct rmi_f11_sensor_data - overrides defaults for a single F11 2D sensor.
+ * struct rmi_2d_sensor_data - overrides defaults for a 2D sensor.
  * @axis_align - provides axis alignment overrides (see above).
  * @sensor_type - Forces the driver to treat the sensor as an indirect
  * pointing device (touchpad) rather than a direct pointing device
@@ -101,12 +101,13 @@ enum rmi_f11_sensor_type {
  * @dmax - the maximum distance (in sensor units) the kernel tracking allows two
  * distincts fingers to be considered the same.
  */
-struct rmi_f11_sensor_data {
-	struct rmi_f11_2d_axis_alignment axis_align;
-	enum rmi_f11_sensor_type sensor_type;
+struct rmi_2d_sensor_platform_data {
+	struct rmi_2d_axis_alignment axis_align;
+	enum rmi_sensor_type sensor_type;
 	int x_mm;
 	int y_mm;
 	int disable_report_mask;
+	u16 rezero_wait;
 	bool topbuttonpad;
 	bool kernel_tracking;
 	int dmax;
@@ -268,8 +269,7 @@ struct rmi_device_platform_data {
 	struct rmi_device_platform_data_spi spi_data;
 
 	/* function handler pdata */
-	struct rmi_f11_sensor_data *f11_sensor_data;
-	u16 f11_rezero_wait;
+	struct rmi_2d_sensor_platform_data *sensor_pdata;
 	struct rmi_f01_power_management power_management;
 	struct rmi_button_map *f19_button_map;
 	struct rmi_button_map *f1a_button_map;
Signature · 1 line
2.1.4
Reviewed-by on v1 20/26
#1 lore raw
Quoted 7 lines · Andrew Duggan

RMI4 defines two functions for 2D sensors. This patch moves some of the code which is shared between the two functions into a new file to avoid duplicating the code on rmi_f11.c and rmi_f12.c.

 .../bindings/input/rmi4/rmi_2d_sensor.txt          |  55 +++

Split off and send to [email protected] I see you augmented the binding as I wanted it so:

Quoted 6 lines
 drivers/input/rmi4/Kconfig                         |  11 +
 drivers/input/rmi4/Makefile                        |   2 +
 drivers/input/rmi4/rmi_2d_sensor.c                 | 370 ++++++++++++++++
 drivers/input/rmi4/rmi_2d_sensor.h                 |  87 ++++
 drivers/input/rmi4/rmi_f11.c                       | 487 +++++----------------
 include/linux/rmi.h                                |  30 +-

Should this be squashed into the F11 and F12 driver patches and a big F11+F12 patch come out instead? I think that is the best.

Quoted 4 lines
drivers/input/rmi4/Kconfig +4 -0
+config RMI4_2D_SENSOR
+       bool "RMI4 2D Sensors"
+       depends on RMI4_CORE
+       default y if RMI4_CORE

drivers/input/rmi4/Kconfig config RMI4_SPI · line 61

Quoted 10 lines
drivers/input/rmi4/Kconfig +7 -0
+       help
+         Say Y here if you want to add support for 2D Sensors.
+
+         Provides core functionality for 2D multifinger pointing for
+         touchscreens and touchpads using RMI4 functions 11 and 12. This
+         feature is needed is the device contains either F11 or F12.
+
 config RMI4_F11
        bool "RMI4 Function 11 (2D pointing)"
        depends on RMI4_CORE

Shouldn't F11 and F12 depend on RMI4_2D_SENSOR, or even select it?

I think RMI4_2D_SENSOR should be hidden, i.e. just:

drivers/input/rmi4/Kconfig config RMI4_SPI · line 50

Quoted 3 lines
drivers/input/rmi4/Kconfig +3 -0
+config RMI4_2D_SENSOR
+       bool
+       depends on RMI4_CORE

And then F11 and F12 select this hidden option.

Yours,
Linus Walleij

maintainer
#2 lore raw
In reply to Andrew Duggan

drivers/input/rmi4/Kconfig config RMI4_SPI · line 49

Quoted 2 lines · Andrew Duggan
drivers/input/rmi4/Kconfig +2 -0
+config RMI4_2D_SENSOR
+	bool "RMI4 2D Sensors"

Should this be a hidden option that is selected by RMI4_F11 and RMI4_F12 instead?

Thanks.

Quoted 11 lines
drivers/input/rmi4/Kconfig +9 -0
+	depends on RMI4_CORE
+	default y if RMI4_CORE
+	help
+	  Say Y here if you want to add support for 2D Sensors.
+
+	  Provides core functionality for 2D multifinger pointing for
+	  touchscreens and touchpads using RMI4 functions 11 and 12. This
+	  feature is needed is the device contains either F11 or F12.
+
 config RMI4_F11
 	bool "RMI4 Function 11 (2D pointing)"
Signature · 1 line
Dmitry