* [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads
@ 2014-03-31 21:11 Christopher Heiny
2014-03-31 21:11 ` [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting Christopher Heiny
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Christopher Heiny @ 2014-03-31 21:11 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linux Input, Christopher Heiny, Andrew Duggan, Vincent Huang,
Vivian Ly, Linus Walleij, Benjamin Tissoires, David Herrmann,
Jiri Kosina
When the device is a touchpad additional capabilities need to
be set and reported.
Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Acked-by: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Linux Walleij <linus.walleij@linaro.org>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>
---
drivers/input/rmi4/rmi_f11.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index 8709abe..92eac8a 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -717,7 +717,7 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
if (sensor->data.rel_pos)
rmi_f11_rel_pos_report(sensor, i);
}
- input_mt_sync(sensor->input);
+ input_mt_sync_frame(sensor->input);
input_sync(sensor->input);
}
@@ -1104,13 +1104,10 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11)
/* We assume touchscreen unless demonstrably a touchpad or specified
* as a touchpad in the platform data
*/
- if (sensor->sensor_type == rmi_f11_sensor_touchpad ||
- (sensor->sens_query.has_info2 &&
- !sensor->sens_query.is_clear))
- input_flags = INPUT_PROP_POINTER;
+ if (sensor->sensor_type == rmi_f11_sensor_touchpad)
+ input_flags = INPUT_MT_POINTER;
else
- input_flags = INPUT_PROP_DIRECT;
- set_bit(input_flags, input->propbit);
+ input_flags = INPUT_MT_DIRECT;
if (sensor->axis_align.swap_axes) {
int temp = device_x_max;
@@ -1220,11 +1217,20 @@ static int rmi_f11_initialize(struct rmi_function *fn)
return rc;
}
+ if (sensor->sens_query.has_info2) {
+ if (sensor->sens_query.is_clear)
+ sensor->sensor_type = rmi_f11_sensor_touchscreen;
+ else
+ sensor->sensor_type = rmi_f11_sensor_touchpad;
+ }
+
if (pdata->f11_sensor_data) {
sensor->axis_align =
pdata->f11_sensor_data->axis_align;
sensor->type_a = pdata->f11_sensor_data->type_a;
- sensor->sensor_type =
+
+ if (sensor->sensor_type == rmi_f11_sensor_default)
+ sensor->sensor_type =
pdata->f11_sensor_data->sensor_type;
}
@@ -1490,6 +1496,7 @@ static struct rmi_function_handler rmi_f11_handler = {
module_rmi_driver(rmi_f11_handler);
MODULE_AUTHOR("Christopher Heiny <cheiny@synaptics.com");
+MODULE_AUTHOR("Andrew Duggan <aduggan@synaptics.com");
MODULE_DESCRIPTION("RMI F11 module");
MODULE_LICENSE("GPL");
MODULE_VERSION(RMI_DRIVER_VERSION);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting
2014-03-31 21:11 [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Christopher Heiny
@ 2014-03-31 21:11 ` Christopher Heiny
2014-04-09 18:19 ` Benjamin Tissoires
2014-03-31 21:11 ` [PATCH v2 3/3] Input: synaptics-rmi4 - report sensor resolution Christopher Heiny
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Christopher Heiny @ 2014-03-31 21:11 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linux Input, Christopher Heiny, Andrew Duggan, Vincent Huang,
Vivian Ly, Linus Walleij, Benjamin Tissoires, David Herrmann,
Jiri Kosina
If the firmware provides reporting both relative and absolute
coordinates, reporting both can cause userspace confusion, so
default to reporting only the absolute coordinates. In certain
cases in may be desirable to force only reporting relative
coordinates so a mask is provided in the platform data for
disabling absolute reporting and falling back to reporting
relative coordinates.
Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Acked-by: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Linux Walleij <linus.walleij@linaro.org>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>
---
drivers/input/rmi4/rmi_f11.c | 122 +++++++++++++++++++++----------------------
include/linux/rmi.h | 5 ++
2 files changed, 64 insertions(+), 63 deletions(-)
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index e98fa75..ee47b7e 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -499,9 +499,7 @@ struct f11_2d_data {
* assume we have one of those sensors and report events appropriately.
* @sensor_type - indicates whether we're touchscreen or touchpad.
* @input - input device for absolute pointing stream
- * @mouse_input - input device for relative pointing stream.
* @input_phys - buffer for the absolute phys name for this sensor.
- * @input_phys_mouse - buffer for the relative phys name for this sensor.
*/
struct f11_2d_sensor {
struct rmi_f11_2d_axis_alignment axis_align;
@@ -516,10 +514,10 @@ struct f11_2d_sensor {
u32 type_a; /* boolean but debugfs API requires u32 */
enum rmi_f11_sensor_type sensor_type;
struct input_dev *input;
- struct input_dev *mouse_input;
struct rmi_function *fn;
char input_phys[NAME_BUFFER_SIZE];
- char input_phys_mouse[NAME_BUFFER_SIZE];
+ u8 report_abs;
+ u8 report_rel;
};
/** Data pertaining to F11 in general. For per-sensor data, see struct
@@ -544,6 +542,9 @@ struct f11_data {
struct mutex dev_controls_mutex;
u16 rezero_wait_ms;
struct f11_2d_sensor sensor;
+ unsigned long *abs_mask;
+ unsigned long *rel_mask;
+ unsigned long *result_bits;
};
enum finger_state_values {
@@ -591,10 +592,7 @@ static void rmi_f11_rel_pos_report(struct f11_2d_sensor *sensor, u8 n_finger)
if (x || y) {
input_report_rel(sensor->input, REL_X, x);
input_report_rel(sensor->input, REL_Y, y);
- input_report_rel(sensor->mouse_input, REL_X, x);
- input_report_rel(sensor->mouse_input, REL_Y, y);
}
- input_sync(sensor->mouse_input);
}
static void rmi_f11_abs_pos_report(struct f11_data *f11,
@@ -691,13 +689,17 @@ static void rmi_f11_abs_pos_report(struct f11_data *f11,
}
static void rmi_f11_finger_handler(struct f11_data *f11,
- struct f11_2d_sensor *sensor)
+ struct f11_2d_sensor *sensor,
+ unsigned long *irq_bits, int num_irq_regs)
{
const u8 *f_state = sensor->data.f_state;
u8 finger_state;
u8 finger_pressed_count;
u8 i;
+ int rel_bits;
+ int abs_bits;
+
for (i = 0, finger_pressed_count = 0; i < sensor->nbr_fingers; i++) {
/* Possible of having 4 fingers per f_statet register */
finger_state = (f_state[i / 4] >> (2 * (i % 4))) &
@@ -711,10 +713,14 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
finger_pressed_count++;
}
- if (sensor->data.abs_pos)
+ abs_bits = bitmap_and(f11->result_bits, irq_bits, f11->abs_mask,
+ num_irq_regs);
+ if (abs_bits)
rmi_f11_abs_pos_report(f11, sensor, finger_state, i);
- if (sensor->data.rel_pos)
+ rel_bits = bitmap_and(f11->result_bits, irq_bits, f11->rel_mask,
+ num_irq_regs);
+ if (rel_bits)
rmi_f11_rel_pos_report(sensor, i);
}
input_mt_sync_frame(sensor->input);
@@ -1171,21 +1177,36 @@ static int rmi_f11_initialize(struct rmi_function *fn)
u16 max_x_pos, max_y_pos, temp;
int rc;
const struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev);
+ struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
struct f11_2d_sensor *sensor;
u8 buf;
+ int mask_size;
dev_dbg(&fn->dev, "Initializing F11 values for %s.\n",
pdata->sensor_name);
+ mask_size = BITS_TO_LONGS(drvdata->irq_count) * sizeof(unsigned long);
+
/*
** init instance data, fill in values and create any sysfs files
*/
- f11 = devm_kzalloc(&fn->dev, sizeof(struct f11_data), GFP_KERNEL);
+ f11 = devm_kzalloc(&fn->dev, sizeof(struct f11_data) + mask_size * 3,
+ GFP_KERNEL);
if (!f11)
return -ENOMEM;
f11->rezero_wait_ms = pdata->f11_rezero_wait;
+ f11->abs_mask = (unsigned long*)((char *)f11
+ + sizeof(struct f11_data));
+ f11->rel_mask = (unsigned long*)((char *)f11
+ + sizeof(struct f11_data) + mask_size);
+ f11->result_bits = (unsigned long*)((char *)f11
+ + sizeof(struct f11_data) + mask_size * 2);
+
+ set_bit(fn->irq_pos, f11->abs_mask);
+ set_bit(fn->irq_pos + 1, f11->rel_mask);
+
query_base_addr = fn->fd.query_base_addr;
control_base_addr = fn->fd.control_base_addr;
@@ -1224,6 +1245,8 @@ static int rmi_f11_initialize(struct rmi_function *fn)
sensor->sensor_type = rmi_f11_sensor_touchpad;
}
+ sensor->report_abs = sensor->sens_query.has_abs;
+
if (pdata->f11_sensor_data) {
sensor->axis_align =
pdata->f11_sensor_data->axis_align;
@@ -1232,8 +1255,19 @@ static int rmi_f11_initialize(struct rmi_function *fn)
if (sensor->sensor_type == rmi_f11_sensor_default)
sensor->sensor_type =
pdata->f11_sensor_data->sensor_type;
+
+ sensor->report_abs = sensor->report_abs
+ && !(pdata->f11_sensor_data->disable_report_mask
+ & RMI_F11_DISABLE_ABS_REPORT);
}
+ if (!sensor->report_abs)
+ /*
+ * If device doesn't have abs or if it has been disables
+ * fallback to reporting rel data.
+ */
+ sensor->report_rel = sensor->sens_query.has_rel;
+
rc = rmi_read_block(rmi_dev,
control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
(u8 *)&max_x_pos, sizeof(max_x_pos));
@@ -1293,7 +1327,6 @@ static int rmi_f11_register_devices(struct rmi_function *fn)
struct rmi_device *rmi_dev = fn->rmi_dev;
struct f11_data *f11 = dev_get_drvdata(&fn->dev);
struct input_dev *input_dev;
- struct input_dev *input_dev_mouse;
struct rmi_driver *driver = rmi_dev->driver;
struct f11_2d_sensor *sensor = &f11->sensor;
int rc;
@@ -1324,9 +1357,10 @@ static int rmi_f11_register_devices(struct rmi_function *fn)
set_bit(EV_ABS, input_dev->evbit);
input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
- f11_set_abs_params(fn, f11);
+ if (sensor->report_abs)
+ f11_set_abs_params(fn, f11);
- if (sensor->sens_query.has_rel) {
+ if (sensor->report_rel) {
set_bit(EV_REL, input_dev->evbit);
set_bit(REL_X, input_dev->relbit);
set_bit(REL_Y, input_dev->relbit);
@@ -1338,56 +1372,10 @@ static int rmi_f11_register_devices(struct rmi_function *fn)
goto error_unregister;
}
- if (sensor->sens_query.has_rel) {
- /*create input device for mouse events */
- input_dev_mouse = input_allocate_device();
- if (!input_dev_mouse) {
- rc = -ENOMEM;
- goto error_unregister;
- }
-
- sensor->mouse_input = input_dev_mouse;
- if (driver->set_input_params) {
- rc = driver->set_input_params(rmi_dev,
- input_dev_mouse);
- if (rc < 0) {
- dev_err(&fn->dev,
- "%s: Error in setting input device.\n",
- __func__);
- goto error_unregister;
- }
- }
- sprintf(sensor->input_phys_mouse, "%s.rel/input0",
- dev_name(&fn->dev));
- set_bit(EV_REL, input_dev_mouse->evbit);
- set_bit(REL_X, input_dev_mouse->relbit);
- set_bit(REL_Y, input_dev_mouse->relbit);
-
- set_bit(BTN_MOUSE, input_dev_mouse->evbit);
- /* Register device's buttons and keys */
- set_bit(EV_KEY, input_dev_mouse->evbit);
- set_bit(BTN_LEFT, input_dev_mouse->keybit);
- set_bit(BTN_MIDDLE, input_dev_mouse->keybit);
- set_bit(BTN_RIGHT, input_dev_mouse->keybit);
-
- rc = input_register_device(input_dev_mouse);
- if (rc) {
- input_free_device(input_dev_mouse);
- sensor->mouse_input = NULL;
- goto error_unregister;
- }
-
- set_bit(BTN_RIGHT, input_dev_mouse->keybit);
- }
-
return 0;
error_unregister:
if (f11->sensor.input) {
- if (f11->sensor.mouse_input) {
- input_unregister_device(f11->sensor.mouse_input);
- f11->sensor.mouse_input = NULL;
- }
input_unregister_device(f11->sensor.input);
f11->sensor.input = NULL;
}
@@ -1398,8 +1386,16 @@ error_unregister:
static int rmi_f11_config(struct rmi_function *fn)
{
struct f11_data *f11 = dev_get_drvdata(&fn->dev);
+ struct rmi_driver *drv = fn->rmi_dev->driver;
+ struct f11_2d_sensor *sensor = &f11->sensor;
int rc;
+ if (!sensor->report_abs)
+ drv->clear_irq_bits(fn->rmi_dev, f11->abs_mask);
+
+ if (!sensor->report_rel)
+ drv->clear_irq_bits(fn->rmi_dev, f11->rel_mask);
+
rc = f11_write_control_regs(fn, &f11->sensor.sens_query,
&f11->dev_controls, fn->fd.query_base_addr);
if (rc < 0)
@@ -1411,6 +1407,7 @@ static int rmi_f11_config(struct rmi_function *fn)
static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits)
{
struct rmi_device *rmi_dev = fn->rmi_dev;
+ struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
struct f11_data *f11 = dev_get_drvdata(&fn->dev);
u16 data_base_addr = fn->fd.data_base_addr;
u16 data_base_addr_offset = 0;
@@ -1423,7 +1420,8 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits)
if (error)
return error;
- rmi_f11_finger_handler(f11, &f11->sensor);
+ rmi_f11_finger_handler(f11, &f11->sensor, irq_bits,
+ drvdata->num_of_irq_regs);
data_base_addr_offset += f11->sensor.pkt_size;
return 0;
@@ -1477,8 +1475,6 @@ static void rmi_f11_remove(struct rmi_function *fn)
if (f11->sensor.input)
input_unregister_device(f11->sensor.input);
- if (f11->sensor.mouse_input)
- input_unregister_device(f11->sensor.mouse_input);
}
static struct rmi_function_handler rmi_f11_handler = {
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 735e978..164b813 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -76,6 +76,8 @@ enum rmi_f11_sensor_type {
rmi_f11_sensor_touchpad
};
+#define RMI_F11_DISABLE_ABS_REPORT BIT(0)
+
/**
* struct rmi_f11_sensor_data - overrides defaults for a single F11 2D sensor.
* @axis_align - provides axis alignment overrides (see above).
@@ -86,11 +88,14 @@ enum rmi_f11_sensor_type {
* pointing device (touchpad) rather than a direct pointing device
* (touchscreen). This is useful when F11_2D_QUERY14 register is not
* available.
+ * @disable_report_mask - Force data to not be reported even if it is supported
+ * by the firware.
*/
struct rmi_f11_sensor_data {
struct rmi_f11_2d_axis_alignment axis_align;
bool type_a;
enum rmi_f11_sensor_type sensor_type;
+ int disable_report_mask;
};
/**
--
1.8.3.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] Input: synaptics-rmi4 - report sensor resolution
2014-03-31 21:11 [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Christopher Heiny
2014-03-31 21:11 ` [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting Christopher Heiny
@ 2014-03-31 21:11 ` Christopher Heiny
2014-04-09 18:21 ` Benjamin Tissoires
2014-04-09 18:13 ` [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Benjamin Tissoires
2014-07-23 6:06 ` Dmitry Torokhov
3 siblings, 1 reply; 8+ messages in thread
From: Christopher Heiny @ 2014-03-31 21:11 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Linux Input, Christopher Heiny, Andrew Duggan, Vincent Huang,
Vivian Ly, Linus Walleij, Benjamin Tissoires, David Herrmann,
Jiri Kosina
Reports the sensor resolution by reading the size of the sensor
from F11 query registers or from the platform data if the firmware
does not contain the appropriate query registers.
Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Acked-by: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Linux Walleij <linus.walleij@linaro.org>
Cc: David Herrmann <dh.herrmann@gmail.com>
Cc: Jiri Kosina <jkosina@suse.cz>
---
drivers/input/rmi4/rmi_f11.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
include/linux/rmi.h | 2 ++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
index ee47b7e..9c682f0 100644
--- a/drivers/input/rmi4/rmi_f11.c
+++ b/drivers/input/rmi4/rmi_f11.c
@@ -408,6 +408,10 @@ struct f11_2d_sensor_queries {
u8 clickpad_props;
u8 mouse_buttons;
bool has_advanced_gestures;
+
+ /* Query 15 - 18 */
+ u16 x_sensor_size_mm;
+ u16 y_sensor_size_mm;
};
/* Defs for Ctrl0. */
@@ -518,6 +522,8 @@ struct f11_2d_sensor {
char input_phys[NAME_BUFFER_SIZE];
u8 report_abs;
u8 report_rel;
+ u8 x_mm;
+ u8 y_mm;
};
/** Data pertaining to F11 in general. For per-sensor data, see struct
@@ -1064,7 +1070,7 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
query_size++;
}
- if (f11->has_query12 && sensor_query->has_info2) {
+ if (sensor_query->has_info2) {
rc = rmi_read(rmi_dev, query_base_addr + query_size, query_buf);
if (rc < 0)
return rc;
@@ -1085,6 +1091,20 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
query_size++;
}
+ if (sensor_query->has_physical_props) {
+ rc = rmi_read_block(rmi_dev, query_base_addr
+ + query_size, query_buf, 4);
+ if (rc < 0)
+ return rc;
+
+ sensor_query->x_sensor_size_mm =
+ (query_buf[0] | (query_buf[1] << 8)) / 10;
+ sensor_query->y_sensor_size_mm =
+ (query_buf[2] | (query_buf[3] << 8)) / 10;
+
+ query_size += 4;
+ }
+
return query_size;
}
@@ -1106,6 +1126,7 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11)
((f11->dev_controls.ctrl0_9[9] & 0x0F) << 8);
u16 x_min, x_max, y_min, y_max;
unsigned int input_flags;
+ int res_x, res_y;
/* We assume touchscreen unless demonstrably a touchpad or specified
* as a touchpad in the platform data
@@ -1156,6 +1177,18 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11)
x_min, x_max, 0, 0);
input_set_abs_params(input, ABS_MT_POSITION_Y,
y_min, y_max, 0, 0);
+
+ if (sensor->x_mm && sensor->y_mm) {
+ res_x = (x_max - x_min) / sensor->x_mm;
+ res_y = (y_max - y_min) / sensor->y_mm;
+
+ input_abs_set_res(input, ABS_X, res_x);
+ input_abs_set_res(input, ABS_Y, res_y);
+
+ input_abs_set_res(input, ABS_MT_POSITION_X, res_x);
+ input_abs_set_res(input, ABS_MT_POSITION_Y, res_y);
+ }
+
if (!sensor->type_a)
input_mt_init_slots(input, sensor->nbr_fingers, input_flags);
if (IS_ENABLED(CONFIG_RMI4_F11_PEN) && sensor->sens_query.has_pen)
@@ -1252,6 +1285,14 @@ static int rmi_f11_initialize(struct rmi_function *fn)
pdata->f11_sensor_data->axis_align;
sensor->type_a = pdata->f11_sensor_data->type_a;
+ if (sensor->sens_query.has_physical_props) {
+ sensor->x_mm = sensor->sens_query.x_sensor_size_mm;
+ sensor->y_mm = sensor->sens_query.y_sensor_size_mm;
+ } else if (pdata->f11_sensor_data) {
+ sensor->x_mm = pdata->f11_sensor_data->x_mm;
+ sensor->y_mm = pdata->f11_sensor_data->y_mm;
+ }
+
if (sensor->sensor_type == rmi_f11_sensor_default)
sensor->sensor_type =
pdata->f11_sensor_data->sensor_type;
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index 164b813..ca35b2f 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -95,6 +95,8 @@ struct rmi_f11_sensor_data {
struct rmi_f11_2d_axis_alignment axis_align;
bool type_a;
enum rmi_f11_sensor_type sensor_type;
+ int x_mm;
+ int y_mm;
int disable_report_mask;
};
--
1.8.3.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads
2014-03-31 21:11 [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Christopher Heiny
2014-03-31 21:11 ` [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting Christopher Heiny
2014-03-31 21:11 ` [PATCH v2 3/3] Input: synaptics-rmi4 - report sensor resolution Christopher Heiny
@ 2014-04-09 18:13 ` Benjamin Tissoires
2014-07-23 6:06 ` Dmitry Torokhov
3 siblings, 0 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2014-04-09 18:13 UTC (permalink / raw)
To: Christopher Heiny
Cc: Dmitry Torokhov, Linux Input, Andrew Duggan, Vincent Huang,
Vivian Ly, Linus Walleij, Benjamin Tissoires, David Herrmann,
Jiri Kosina
On Mon, Mar 31, 2014 at 5:11 PM, Christopher Heiny <cheiny@synaptics.com> wrote:
> When the device is a touchpad additional capabilities need to
> be set and reported.
>
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> Acked-by: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Linux Walleij <linus.walleij@linaro.org>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Jiri Kosina <jkosina@suse.cz>
>
> ---
> drivers/input/rmi4/rmi_f11.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index 8709abe..92eac8a 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -717,7 +717,7 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
> if (sensor->data.rel_pos)
> rmi_f11_rel_pos_report(sensor, i);
> }
> - input_mt_sync(sensor->input);
> + input_mt_sync_frame(sensor->input);
Small nitpicking here: I think we should add an if (!sensor->type_a)
before this statement.
However, it should still be harmless for protocol A device because
input->mt is null.
So Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> for this one.
Also I wanted to apologize regarding the rebase I asked for in the v1,
it looks like I hallucinated because the synaptics-rmi4 branch is
plugged to a v3.7-rc+ and contains the multitouch changes I said that
were not in.
Cheers,
Benjamin
> input_sync(sensor->input);
> }
>
> @@ -1104,13 +1104,10 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11)
> /* We assume touchscreen unless demonstrably a touchpad or specified
> * as a touchpad in the platform data
> */
> - if (sensor->sensor_type == rmi_f11_sensor_touchpad ||
> - (sensor->sens_query.has_info2 &&
> - !sensor->sens_query.is_clear))
> - input_flags = INPUT_PROP_POINTER;
> + if (sensor->sensor_type == rmi_f11_sensor_touchpad)
> + input_flags = INPUT_MT_POINTER;
> else
> - input_flags = INPUT_PROP_DIRECT;
> - set_bit(input_flags, input->propbit);
> + input_flags = INPUT_MT_DIRECT;
>
> if (sensor->axis_align.swap_axes) {
> int temp = device_x_max;
> @@ -1220,11 +1217,20 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> return rc;
> }
>
> + if (sensor->sens_query.has_info2) {
> + if (sensor->sens_query.is_clear)
> + sensor->sensor_type = rmi_f11_sensor_touchscreen;
> + else
> + sensor->sensor_type = rmi_f11_sensor_touchpad;
> + }
> +
> if (pdata->f11_sensor_data) {
> sensor->axis_align =
> pdata->f11_sensor_data->axis_align;
> sensor->type_a = pdata->f11_sensor_data->type_a;
> - sensor->sensor_type =
> +
> + if (sensor->sensor_type == rmi_f11_sensor_default)
> + sensor->sensor_type =
> pdata->f11_sensor_data->sensor_type;
> }
>
> @@ -1490,6 +1496,7 @@ static struct rmi_function_handler rmi_f11_handler = {
> module_rmi_driver(rmi_f11_handler);
>
> MODULE_AUTHOR("Christopher Heiny <cheiny@synaptics.com");
> +MODULE_AUTHOR("Andrew Duggan <aduggan@synaptics.com");
> MODULE_DESCRIPTION("RMI F11 module");
> MODULE_LICENSE("GPL");
> MODULE_VERSION(RMI_DRIVER_VERSION);
> --
> 1.8.3.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting
2014-03-31 21:11 ` [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting Christopher Heiny
@ 2014-04-09 18:19 ` Benjamin Tissoires
2014-04-30 21:41 ` Christopher Heiny
0 siblings, 1 reply; 8+ messages in thread
From: Benjamin Tissoires @ 2014-04-09 18:19 UTC (permalink / raw)
To: Christopher Heiny
Cc: Dmitry Torokhov, Linux Input, Andrew Duggan, Vincent Huang,
Vivian Ly, Linus Walleij, Benjamin Tissoires, David Herrmann,
Jiri Kosina
On Mon, Mar 31, 2014 at 5:11 PM, Christopher Heiny <cheiny@synaptics.com> wrote:
> If the firmware provides reporting both relative and absolute
> coordinates, reporting both can cause userspace confusion, so
> default to reporting only the absolute coordinates. In certain
> cases in may be desirable to force only reporting relative
> coordinates so a mask is provided in the platform data for
> disabling absolute reporting and falling back to reporting
> relative coordinates.
>
>
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> Acked-by: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Linux Walleij <linus.walleij@linaro.org>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Jiri Kosina <jkosina@suse.cz>
>
> ---
> drivers/input/rmi4/rmi_f11.c | 122 +++++++++++++++++++++----------------------
> include/linux/rmi.h | 5 ++
> 2 files changed, 64 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index e98fa75..ee47b7e 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -499,9 +499,7 @@ struct f11_2d_data {
> * assume we have one of those sensors and report events appropriately.
> * @sensor_type - indicates whether we're touchscreen or touchpad.
> * @input - input device for absolute pointing stream
> - * @mouse_input - input device for relative pointing stream.
> * @input_phys - buffer for the absolute phys name for this sensor.
> - * @input_phys_mouse - buffer for the relative phys name for this sensor.
> */
> struct f11_2d_sensor {
> struct rmi_f11_2d_axis_alignment axis_align;
> @@ -516,10 +514,10 @@ struct f11_2d_sensor {
> u32 type_a; /* boolean but debugfs API requires u32 */
> enum rmi_f11_sensor_type sensor_type;
> struct input_dev *input;
> - struct input_dev *mouse_input;
> struct rmi_function *fn;
> char input_phys[NAME_BUFFER_SIZE];
> - char input_phys_mouse[NAME_BUFFER_SIZE];
> + u8 report_abs;
> + u8 report_rel;
> };
>
> /** Data pertaining to F11 in general. For per-sensor data, see struct
> @@ -544,6 +542,9 @@ struct f11_data {
> struct mutex dev_controls_mutex;
> u16 rezero_wait_ms;
> struct f11_2d_sensor sensor;
> + unsigned long *abs_mask;
> + unsigned long *rel_mask;
> + unsigned long *result_bits;
> };
>
> enum finger_state_values {
> @@ -591,10 +592,7 @@ static void rmi_f11_rel_pos_report(struct f11_2d_sensor *sensor, u8 n_finger)
> if (x || y) {
> input_report_rel(sensor->input, REL_X, x);
> input_report_rel(sensor->input, REL_Y, y);
> - input_report_rel(sensor->mouse_input, REL_X, x);
> - input_report_rel(sensor->mouse_input, REL_Y, y);
> }
> - input_sync(sensor->mouse_input);
> }
>
> static void rmi_f11_abs_pos_report(struct f11_data *f11,
> @@ -691,13 +689,17 @@ static void rmi_f11_abs_pos_report(struct f11_data *f11,
> }
>
> static void rmi_f11_finger_handler(struct f11_data *f11,
> - struct f11_2d_sensor *sensor)
> + struct f11_2d_sensor *sensor,
> + unsigned long *irq_bits, int num_irq_regs)
> {
> const u8 *f_state = sensor->data.f_state;
> u8 finger_state;
> u8 finger_pressed_count;
> u8 i;
>
> + int rel_bits;
> + int abs_bits;
> +
> for (i = 0, finger_pressed_count = 0; i < sensor->nbr_fingers; i++) {
> /* Possible of having 4 fingers per f_statet register */
> finger_state = (f_state[i / 4] >> (2 * (i % 4))) &
> @@ -711,10 +713,14 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
> finger_pressed_count++;
> }
>
> - if (sensor->data.abs_pos)
> + abs_bits = bitmap_and(f11->result_bits, irq_bits, f11->abs_mask,
> + num_irq_regs);
> + if (abs_bits)
I am finding this bitmask gymnastic quite difficult to follow.
I am also wondering if the following test will give the same result:
"if (sensor->data.abs_pos && sensor->report_abs)"
> rmi_f11_abs_pos_report(f11, sensor, finger_state, i);
>
> - if (sensor->data.rel_pos)
> + rel_bits = bitmap_and(f11->result_bits, irq_bits, f11->rel_mask,
> + num_irq_regs);
> + if (rel_bits)
Same for rel bits here
The rest of the patch looks fine to me (except that if my previous
assumptions are right, ew could remove the whole bitmask alloc and
handling).
Cheers,
Benjamin
> rmi_f11_rel_pos_report(sensor, i);
> }
> input_mt_sync_frame(sensor->input);
> @@ -1171,21 +1177,36 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> u16 max_x_pos, max_y_pos, temp;
> int rc;
> const struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev);
> + struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
> struct f11_2d_sensor *sensor;
> u8 buf;
> + int mask_size;
>
> dev_dbg(&fn->dev, "Initializing F11 values for %s.\n",
> pdata->sensor_name);
>
> + mask_size = BITS_TO_LONGS(drvdata->irq_count) * sizeof(unsigned long);
> +
> /*
> ** init instance data, fill in values and create any sysfs files
> */
> - f11 = devm_kzalloc(&fn->dev, sizeof(struct f11_data), GFP_KERNEL);
> + f11 = devm_kzalloc(&fn->dev, sizeof(struct f11_data) + mask_size * 3,
> + GFP_KERNEL);
> if (!f11)
> return -ENOMEM;
>
> f11->rezero_wait_ms = pdata->f11_rezero_wait;
>
> + f11->abs_mask = (unsigned long*)((char *)f11
> + + sizeof(struct f11_data));
> + f11->rel_mask = (unsigned long*)((char *)f11
> + + sizeof(struct f11_data) + mask_size);
> + f11->result_bits = (unsigned long*)((char *)f11
> + + sizeof(struct f11_data) + mask_size * 2);
> +
> + set_bit(fn->irq_pos, f11->abs_mask);
> + set_bit(fn->irq_pos + 1, f11->rel_mask);
> +
> query_base_addr = fn->fd.query_base_addr;
> control_base_addr = fn->fd.control_base_addr;
>
> @@ -1224,6 +1245,8 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> sensor->sensor_type = rmi_f11_sensor_touchpad;
> }
>
> + sensor->report_abs = sensor->sens_query.has_abs;
> +
> if (pdata->f11_sensor_data) {
> sensor->axis_align =
> pdata->f11_sensor_data->axis_align;
> @@ -1232,8 +1255,19 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> if (sensor->sensor_type == rmi_f11_sensor_default)
> sensor->sensor_type =
> pdata->f11_sensor_data->sensor_type;
> +
> + sensor->report_abs = sensor->report_abs
> + && !(pdata->f11_sensor_data->disable_report_mask
> + & RMI_F11_DISABLE_ABS_REPORT);
> }
>
> + if (!sensor->report_abs)
> + /*
> + * If device doesn't have abs or if it has been disables
> + * fallback to reporting rel data.
> + */
> + sensor->report_rel = sensor->sens_query.has_rel;
> +
> rc = rmi_read_block(rmi_dev,
> control_base_addr + F11_CTRL_SENSOR_MAX_X_POS_OFFSET,
> (u8 *)&max_x_pos, sizeof(max_x_pos));
> @@ -1293,7 +1327,6 @@ static int rmi_f11_register_devices(struct rmi_function *fn)
> struct rmi_device *rmi_dev = fn->rmi_dev;
> struct f11_data *f11 = dev_get_drvdata(&fn->dev);
> struct input_dev *input_dev;
> - struct input_dev *input_dev_mouse;
> struct rmi_driver *driver = rmi_dev->driver;
> struct f11_2d_sensor *sensor = &f11->sensor;
> int rc;
> @@ -1324,9 +1357,10 @@ static int rmi_f11_register_devices(struct rmi_function *fn)
> set_bit(EV_ABS, input_dev->evbit);
> input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
>
> - f11_set_abs_params(fn, f11);
> + if (sensor->report_abs)
> + f11_set_abs_params(fn, f11);
>
> - if (sensor->sens_query.has_rel) {
> + if (sensor->report_rel) {
> set_bit(EV_REL, input_dev->evbit);
> set_bit(REL_X, input_dev->relbit);
> set_bit(REL_Y, input_dev->relbit);
> @@ -1338,56 +1372,10 @@ static int rmi_f11_register_devices(struct rmi_function *fn)
> goto error_unregister;
> }
>
> - if (sensor->sens_query.has_rel) {
> - /*create input device for mouse events */
> - input_dev_mouse = input_allocate_device();
> - if (!input_dev_mouse) {
> - rc = -ENOMEM;
> - goto error_unregister;
> - }
> -
> - sensor->mouse_input = input_dev_mouse;
> - if (driver->set_input_params) {
> - rc = driver->set_input_params(rmi_dev,
> - input_dev_mouse);
> - if (rc < 0) {
> - dev_err(&fn->dev,
> - "%s: Error in setting input device.\n",
> - __func__);
> - goto error_unregister;
> - }
> - }
> - sprintf(sensor->input_phys_mouse, "%s.rel/input0",
> - dev_name(&fn->dev));
> - set_bit(EV_REL, input_dev_mouse->evbit);
> - set_bit(REL_X, input_dev_mouse->relbit);
> - set_bit(REL_Y, input_dev_mouse->relbit);
> -
> - set_bit(BTN_MOUSE, input_dev_mouse->evbit);
> - /* Register device's buttons and keys */
> - set_bit(EV_KEY, input_dev_mouse->evbit);
> - set_bit(BTN_LEFT, input_dev_mouse->keybit);
> - set_bit(BTN_MIDDLE, input_dev_mouse->keybit);
> - set_bit(BTN_RIGHT, input_dev_mouse->keybit);
> -
> - rc = input_register_device(input_dev_mouse);
> - if (rc) {
> - input_free_device(input_dev_mouse);
> - sensor->mouse_input = NULL;
> - goto error_unregister;
> - }
> -
> - set_bit(BTN_RIGHT, input_dev_mouse->keybit);
> - }
> -
> return 0;
>
> error_unregister:
> if (f11->sensor.input) {
> - if (f11->sensor.mouse_input) {
> - input_unregister_device(f11->sensor.mouse_input);
> - f11->sensor.mouse_input = NULL;
> - }
> input_unregister_device(f11->sensor.input);
> f11->sensor.input = NULL;
> }
> @@ -1398,8 +1386,16 @@ error_unregister:
> static int rmi_f11_config(struct rmi_function *fn)
> {
> struct f11_data *f11 = dev_get_drvdata(&fn->dev);
> + struct rmi_driver *drv = fn->rmi_dev->driver;
> + struct f11_2d_sensor *sensor = &f11->sensor;
> int rc;
>
> + if (!sensor->report_abs)
> + drv->clear_irq_bits(fn->rmi_dev, f11->abs_mask);
> +
> + if (!sensor->report_rel)
> + drv->clear_irq_bits(fn->rmi_dev, f11->rel_mask);
> +
> rc = f11_write_control_regs(fn, &f11->sensor.sens_query,
> &f11->dev_controls, fn->fd.query_base_addr);
> if (rc < 0)
> @@ -1411,6 +1407,7 @@ static int rmi_f11_config(struct rmi_function *fn)
> static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits)
> {
> struct rmi_device *rmi_dev = fn->rmi_dev;
> + struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
> struct f11_data *f11 = dev_get_drvdata(&fn->dev);
> u16 data_base_addr = fn->fd.data_base_addr;
> u16 data_base_addr_offset = 0;
> @@ -1423,7 +1420,8 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits)
> if (error)
> return error;
>
> - rmi_f11_finger_handler(f11, &f11->sensor);
> + rmi_f11_finger_handler(f11, &f11->sensor, irq_bits,
> + drvdata->num_of_irq_regs);
> data_base_addr_offset += f11->sensor.pkt_size;
>
> return 0;
> @@ -1477,8 +1475,6 @@ static void rmi_f11_remove(struct rmi_function *fn)
>
> if (f11->sensor.input)
> input_unregister_device(f11->sensor.input);
> - if (f11->sensor.mouse_input)
> - input_unregister_device(f11->sensor.mouse_input);
> }
>
> static struct rmi_function_handler rmi_f11_handler = {
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index 735e978..164b813 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -76,6 +76,8 @@ enum rmi_f11_sensor_type {
> rmi_f11_sensor_touchpad
> };
>
> +#define RMI_F11_DISABLE_ABS_REPORT BIT(0)
> +
> /**
> * struct rmi_f11_sensor_data - overrides defaults for a single F11 2D sensor.
> * @axis_align - provides axis alignment overrides (see above).
> @@ -86,11 +88,14 @@ enum rmi_f11_sensor_type {
> * pointing device (touchpad) rather than a direct pointing device
> * (touchscreen). This is useful when F11_2D_QUERY14 register is not
> * available.
> + * @disable_report_mask - Force data to not be reported even if it is supported
> + * by the firware.
> */
> struct rmi_f11_sensor_data {
> struct rmi_f11_2d_axis_alignment axis_align;
> bool type_a;
> enum rmi_f11_sensor_type sensor_type;
> + int disable_report_mask;
> };
>
> /**
> --
> 1.8.3.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] Input: synaptics-rmi4 - report sensor resolution
2014-03-31 21:11 ` [PATCH v2 3/3] Input: synaptics-rmi4 - report sensor resolution Christopher Heiny
@ 2014-04-09 18:21 ` Benjamin Tissoires
0 siblings, 0 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2014-04-09 18:21 UTC (permalink / raw)
To: Christopher Heiny
Cc: Dmitry Torokhov, Linux Input, Andrew Duggan, Vincent Huang,
Vivian Ly, Linus Walleij, Benjamin Tissoires, David Herrmann,
Jiri Kosina
On Mon, Mar 31, 2014 at 5:11 PM, Christopher Heiny <cheiny@synaptics.com> wrote:
> Reports the sensor resolution by reading the size of the sensor
> from F11 query registers or from the platform data if the firmware
> does not contain the appropriate query registers.
>
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> Acked-by: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Linux Walleij <linus.walleij@linaro.org>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Jiri Kosina <jkosina@suse.cz>
>
> ---
Looks fine to me:
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cheers,
Benjamin
> drivers/input/rmi4/rmi_f11.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
> include/linux/rmi.h | 2 ++
> 2 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index ee47b7e..9c682f0 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -408,6 +408,10 @@ struct f11_2d_sensor_queries {
> u8 clickpad_props;
> u8 mouse_buttons;
> bool has_advanced_gestures;
> +
> + /* Query 15 - 18 */
> + u16 x_sensor_size_mm;
> + u16 y_sensor_size_mm;
> };
>
> /* Defs for Ctrl0. */
> @@ -518,6 +522,8 @@ struct f11_2d_sensor {
> char input_phys[NAME_BUFFER_SIZE];
> u8 report_abs;
> u8 report_rel;
> + u8 x_mm;
> + u8 y_mm;
> };
>
> /** Data pertaining to F11 in general. For per-sensor data, see struct
> @@ -1064,7 +1070,7 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> query_size++;
> }
>
> - if (f11->has_query12 && sensor_query->has_info2) {
> + if (sensor_query->has_info2) {
> rc = rmi_read(rmi_dev, query_base_addr + query_size, query_buf);
> if (rc < 0)
> return rc;
> @@ -1085,6 +1091,20 @@ static int rmi_f11_get_query_parameters(struct rmi_device *rmi_dev,
> query_size++;
> }
>
> + if (sensor_query->has_physical_props) {
> + rc = rmi_read_block(rmi_dev, query_base_addr
> + + query_size, query_buf, 4);
> + if (rc < 0)
> + return rc;
> +
> + sensor_query->x_sensor_size_mm =
> + (query_buf[0] | (query_buf[1] << 8)) / 10;
> + sensor_query->y_sensor_size_mm =
> + (query_buf[2] | (query_buf[3] << 8)) / 10;
> +
> + query_size += 4;
> + }
> +
> return query_size;
> }
>
> @@ -1106,6 +1126,7 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11)
> ((f11->dev_controls.ctrl0_9[9] & 0x0F) << 8);
> u16 x_min, x_max, y_min, y_max;
> unsigned int input_flags;
> + int res_x, res_y;
>
> /* We assume touchscreen unless demonstrably a touchpad or specified
> * as a touchpad in the platform data
> @@ -1156,6 +1177,18 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11)
> x_min, x_max, 0, 0);
> input_set_abs_params(input, ABS_MT_POSITION_Y,
> y_min, y_max, 0, 0);
> +
> + if (sensor->x_mm && sensor->y_mm) {
> + res_x = (x_max - x_min) / sensor->x_mm;
> + res_y = (y_max - y_min) / sensor->y_mm;
> +
> + input_abs_set_res(input, ABS_X, res_x);
> + input_abs_set_res(input, ABS_Y, res_y);
> +
> + input_abs_set_res(input, ABS_MT_POSITION_X, res_x);
> + input_abs_set_res(input, ABS_MT_POSITION_Y, res_y);
> + }
> +
> if (!sensor->type_a)
> input_mt_init_slots(input, sensor->nbr_fingers, input_flags);
> if (IS_ENABLED(CONFIG_RMI4_F11_PEN) && sensor->sens_query.has_pen)
> @@ -1252,6 +1285,14 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> pdata->f11_sensor_data->axis_align;
> sensor->type_a = pdata->f11_sensor_data->type_a;
>
> + if (sensor->sens_query.has_physical_props) {
> + sensor->x_mm = sensor->sens_query.x_sensor_size_mm;
> + sensor->y_mm = sensor->sens_query.y_sensor_size_mm;
> + } else if (pdata->f11_sensor_data) {
> + sensor->x_mm = pdata->f11_sensor_data->x_mm;
> + sensor->y_mm = pdata->f11_sensor_data->y_mm;
> + }
> +
> if (sensor->sensor_type == rmi_f11_sensor_default)
> sensor->sensor_type =
> pdata->f11_sensor_data->sensor_type;
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index 164b813..ca35b2f 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -95,6 +95,8 @@ struct rmi_f11_sensor_data {
> struct rmi_f11_2d_axis_alignment axis_align;
> bool type_a;
> enum rmi_f11_sensor_type sensor_type;
> + int x_mm;
> + int y_mm;
> int disable_report_mask;
> };
>
> --
> 1.8.3.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting
2014-04-09 18:19 ` Benjamin Tissoires
@ 2014-04-30 21:41 ` Christopher Heiny
0 siblings, 0 replies; 8+ messages in thread
From: Christopher Heiny @ 2014-04-30 21:41 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Dmitry Torokhov, Linux Input, Andrew Duggan, Vincent Huang,
Vivian Ly, Linus Walleij, Benjamin Tissoires, David Herrmann,
Jiri Kosina
On 04/09/2014 11:19 AM, Benjamin Tissoires wrote:
> On Mon, Mar 31, 2014 at 5:11 PM, Christopher Heiny <cheiny@synaptics.com> wrote:
>> If the firmware provides reporting both relative and absolute
>> coordinates, reporting both can cause userspace confusion, so
>> default to reporting only the absolute coordinates. In certain
>> cases in may be desirable to force only reporting relative
>> coordinates so a mask is provided in the platform data for
>> disabling absolute reporting and falling back to reporting
>> relative coordinates.
>>
>>
>> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
>> Acked-by: Christopher Heiny <cheiny@synaptics.com>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>> Cc: Linux Walleij <linus.walleij@linaro.org>
>> Cc: David Herrmann <dh.herrmann@gmail.com>
>> Cc: Jiri Kosina <jkosina@suse.cz>
>>
>> ---
>> drivers/input/rmi4/rmi_f11.c | 122 +++++++++++++++++++++----------------------
>> include/linux/rmi.h | 5 ++
>> 2 files changed, 64 insertions(+), 63 deletions(-)
>>
>> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
>> index e98fa75..ee47b7e 100644
>> --- a/drivers/input/rmi4/rmi_f11.c
>> +++ b/drivers/input/rmi4/rmi_f11.c
>> @@ -499,9 +499,7 @@ struct f11_2d_data {
>> * assume we have one of those sensors and report events appropriately.
>> * @sensor_type - indicates whether we're touchscreen or touchpad.
>> * @input - input device for absolute pointing stream
>> - * @mouse_input - input device for relative pointing stream.
>> * @input_phys - buffer for the absolute phys name for this sensor.
>> - * @input_phys_mouse - buffer for the relative phys name for this sensor.
>> */
>> struct f11_2d_sensor {
>> struct rmi_f11_2d_axis_alignment axis_align;
>> @@ -516,10 +514,10 @@ struct f11_2d_sensor {
>> u32 type_a; /* boolean but debugfs API requires u32 */
>> enum rmi_f11_sensor_type sensor_type;
>> struct input_dev *input;
>> - struct input_dev *mouse_input;
>> struct rmi_function *fn;
>> char input_phys[NAME_BUFFER_SIZE];
>> - char input_phys_mouse[NAME_BUFFER_SIZE];
>> + u8 report_abs;
>> + u8 report_rel;
>> };
>>
>> /** Data pertaining to F11 in general. For per-sensor data, see struct
>> @@ -544,6 +542,9 @@ struct f11_data {
>> struct mutex dev_controls_mutex;
>> u16 rezero_wait_ms;
>> struct f11_2d_sensor sensor;
>> + unsigned long *abs_mask;
>> + unsigned long *rel_mask;
>> + unsigned long *result_bits;
>> };
>>
>> enum finger_state_values {
>> @@ -591,10 +592,7 @@ static void rmi_f11_rel_pos_report(struct f11_2d_sensor *sensor, u8 n_finger)
>> if (x || y) {
>> input_report_rel(sensor->input, REL_X, x);
>> input_report_rel(sensor->input, REL_Y, y);
>> - input_report_rel(sensor->mouse_input, REL_X, x);
>> - input_report_rel(sensor->mouse_input, REL_Y, y);
>> }
>> - input_sync(sensor->mouse_input);
>> }
>>
>> static void rmi_f11_abs_pos_report(struct f11_data *f11,
>> @@ -691,13 +689,17 @@ static void rmi_f11_abs_pos_report(struct f11_data *f11,
>> }
>>
>> static void rmi_f11_finger_handler(struct f11_data *f11,
>> - struct f11_2d_sensor *sensor)
>> + struct f11_2d_sensor *sensor,
>> + unsigned long *irq_bits, int num_irq_regs)
>> {
>> const u8 *f_state = sensor->data.f_state;
>> u8 finger_state;
>> u8 finger_pressed_count;
>> u8 i;
>>
>> + int rel_bits;
>> + int abs_bits;
>> +
>> for (i = 0, finger_pressed_count = 0; i < sensor->nbr_fingers; i++) {
>> /* Possible of having 4 fingers per f_statet register */
>> finger_state = (f_state[i / 4] >> (2 * (i % 4))) &
>> @@ -711,10 +713,14 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
>> finger_pressed_count++;
>> }
>>
>> - if (sensor->data.abs_pos)
>> + abs_bits = bitmap_and(f11->result_bits, irq_bits, f11->abs_mask,
>> + num_irq_regs);
>> + if (abs_bits)
>
> I am finding this bitmask gymnastic quite difficult to follow.
> I am also wondering if the following test will give the same result:
> "if (sensor->data.abs_pos && sensor->report_abs)"
>
>> rmi_f11_abs_pos_report(f11, sensor, finger_state, i);
>>
>> - if (sensor->data.rel_pos)
>> + rel_bits = bitmap_and(f11->result_bits, irq_bits, f11->rel_mask,
>> + num_irq_regs);
>> + if (rel_bits)
>
> Same for rel bits here
>
> The rest of the patch looks fine to me (except that if my previous
> assumptions are right, ew could remove the whole bitmask alloc and
> handling).
[snip]
I'm very sorry for the delayed reply to this - I though I'd done that,
but apparently didn't. Andrew has kindly applied a prod or two (ouch
ouch all right already).
Anyway, the main reason for doing the bit masking is for situations
where both relative and absolute reporting is enabled (surprisingly,
those are do occur, although they are not common). We'll enter the
rmi_f11_attention() when either rel_data is ready, or abs_data is ready,
or both, but we don't know which data is actually valid without checking
the interrupt status register bits against the enabled interrupt bits.
An example of where this could occur is where a finger moves very
rapidly across the touch surface. The absolute data could be reported
as one (or a few) absolute reports, but the relative data might be so
large that it requires several reports to play out all the deltas. If
those deltas are still playing out while the finger is sufficiently
stationary (and thus the absolute interrupt status bit is 0), it is
possible for the absolute data to be incorrect in those reports.
As a secondary condition, in diagnostic and prototyping environments you
sometimes need to turn either rel or abs (or both) on and off at various
points to figure out what the heck is going on or to test out something
new. That implies that we need to allocate the rel_data and abs_data
buffers ahead of time, so they can't be used as flags. Well, OK, we
could use allocate/deallocate of the buffers as flags, but that implies
a bunch of locking to prevent kernel panics.
Maybe it would be clearer to have a well-named macro or inline that did
the bitmask gymnastics, maybe something like enabled_report_has_data().
Thanks,
Chris
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads
2014-03-31 21:11 [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Christopher Heiny
` (2 preceding siblings ...)
2014-04-09 18:13 ` [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Benjamin Tissoires
@ 2014-07-23 6:06 ` Dmitry Torokhov
3 siblings, 0 replies; 8+ messages in thread
From: Dmitry Torokhov @ 2014-07-23 6:06 UTC (permalink / raw)
To: Christopher Heiny
Cc: Linux Input, Andrew Duggan, Vincent Huang, Vivian Ly,
Linus Walleij, Benjamin Tissoires, David Herrmann, Jiri Kosina
Hi Christopher,
On Mon, Mar 31, 2014 at 02:11:05PM -0700, Christopher Heiny wrote:
> When the device is a touchpad additional capabilities need to
> be set and reported.
>
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> Acked-by: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Linux Walleij <linus.walleij@linaro.org>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Jiri Kosina <jkosina@suse.cz>
I rebased the branch to 3.14 and applied all 3 patches, thank you.
>
> ---
> drivers/input/rmi4/rmi_f11.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c
> index 8709abe..92eac8a 100644
> --- a/drivers/input/rmi4/rmi_f11.c
> +++ b/drivers/input/rmi4/rmi_f11.c
> @@ -717,7 +717,7 @@ static void rmi_f11_finger_handler(struct f11_data *f11,
> if (sensor->data.rel_pos)
> rmi_f11_rel_pos_report(sensor, i);
> }
> - input_mt_sync(sensor->input);
> + input_mt_sync_frame(sensor->input);
> input_sync(sensor->input);
> }
>
> @@ -1104,13 +1104,10 @@ static void f11_set_abs_params(struct rmi_function *fn, struct f11_data *f11)
> /* We assume touchscreen unless demonstrably a touchpad or specified
> * as a touchpad in the platform data
> */
> - if (sensor->sensor_type == rmi_f11_sensor_touchpad ||
> - (sensor->sens_query.has_info2 &&
> - !sensor->sens_query.is_clear))
> - input_flags = INPUT_PROP_POINTER;
> + if (sensor->sensor_type == rmi_f11_sensor_touchpad)
> + input_flags = INPUT_MT_POINTER;
> else
> - input_flags = INPUT_PROP_DIRECT;
> - set_bit(input_flags, input->propbit);
> + input_flags = INPUT_MT_DIRECT;
>
> if (sensor->axis_align.swap_axes) {
> int temp = device_x_max;
> @@ -1220,11 +1217,20 @@ static int rmi_f11_initialize(struct rmi_function *fn)
> return rc;
> }
>
> + if (sensor->sens_query.has_info2) {
> + if (sensor->sens_query.is_clear)
> + sensor->sensor_type = rmi_f11_sensor_touchscreen;
> + else
> + sensor->sensor_type = rmi_f11_sensor_touchpad;
> + }
> +
> if (pdata->f11_sensor_data) {
> sensor->axis_align =
> pdata->f11_sensor_data->axis_align;
> sensor->type_a = pdata->f11_sensor_data->type_a;
> - sensor->sensor_type =
> +
> + if (sensor->sensor_type == rmi_f11_sensor_default)
> + sensor->sensor_type =
> pdata->f11_sensor_data->sensor_type;
> }
>
> @@ -1490,6 +1496,7 @@ static struct rmi_function_handler rmi_f11_handler = {
> module_rmi_driver(rmi_f11_handler);
>
> MODULE_AUTHOR("Christopher Heiny <cheiny@synaptics.com");
> +MODULE_AUTHOR("Andrew Duggan <aduggan@synaptics.com");
> MODULE_DESCRIPTION("RMI F11 module");
> MODULE_LICENSE("GPL");
> MODULE_VERSION(RMI_DRIVER_VERSION);
> --
> 1.8.3.2
>
--
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-07-23 6:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-31 21:11 [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Christopher Heiny
2014-03-31 21:11 ` [PATCH v2 2/3] Input: synaptics-rmi4 - F11 abs or rel reporting Christopher Heiny
2014-04-09 18:19 ` Benjamin Tissoires
2014-04-30 21:41 ` Christopher Heiny
2014-03-31 21:11 ` [PATCH v2 3/3] Input: synaptics-rmi4 - report sensor resolution Christopher Heiny
2014-04-09 18:21 ` Benjamin Tissoires
2014-04-09 18:13 ` [PATCH v2 1/3] Input: synaptics-rmi4 - add F11 capabilities for touchpads Benjamin Tissoires
2014-07-23 6:06 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).