]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
Input: elan_i2c - do not query the info if they are provided
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Tue, 28 May 2019 01:42:48 +0000 (18:42 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 28 May 2019 01:50:44 +0000 (18:50 -0700)
See the previous patch for a long explanation.

TL;DR: the P52 and the t480s from Lenovo can't rely on I2C to fetch
the information, so we need it from PS/2.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/mouse/elan_i2c_core.c

index 2c0561e20b7fa28767e4228c0ae0d2535ef4107d..3b78f58d80f57c0f4899143d8e5c82811d7a2a19 100644 (file)
@@ -366,27 +366,59 @@ static unsigned int elan_convert_resolution(u8 val)
 
 static int elan_query_device_parameters(struct elan_tp_data *data)
 {
+       struct i2c_client *client = data->client;
        unsigned int x_traces, y_traces;
+       u32 x_mm, y_mm;
        u8 hw_x_res, hw_y_res;
        int error;
 
-       error = data->ops->get_max(data->client, &data->max_x, &data->max_y);
-       if (error)
-               return error;
-
-       error = data->ops->get_num_traces(data->client, &x_traces, &y_traces);
-       if (error)
-               return error;
+       if (device_property_read_u32(&client->dev,
+                                    "touchscreen-size-x", &data->max_x) ||
+           device_property_read_u32(&client->dev,
+                                    "touchscreen-size-y", &data->max_y)) {
+               error = data->ops->get_max(data->client,
+                                          &data->max_x,
+                                          &data->max_y);
+               if (error)
+                       return error;
+       } else {
+               /* size is the maximum + 1 */
+               --data->max_x;
+               --data->max_y;
+       }
 
+       if (device_property_read_u32(&client->dev,
+                                    "elan,x_traces",
+                                    &x_traces) ||
+           device_property_read_u32(&client->dev,
+                                    "elan,y_traces",
+                                    &y_traces)) {
+               error = data->ops->get_num_traces(data->client,
+                                                 &x_traces, &y_traces);
+               if (error)
+                       return error;
+       }
        data->width_x = data->max_x / x_traces;
        data->width_y = data->max_y / y_traces;
 
-       error = data->ops->get_resolution(data->client, &hw_x_res, &hw_y_res);
-       if (error)
-               return error;
+       if (device_property_read_u32(&client->dev,
+                                    "touchscreen-x-mm", &x_mm) ||
+           device_property_read_u32(&client->dev,
+                                    "touchscreen-y-mm", &y_mm)) {
+               error = data->ops->get_resolution(data->client,
+                                                 &hw_x_res, &hw_y_res);
+               if (error)
+                       return error;
+
+               data->x_res = elan_convert_resolution(hw_x_res);
+               data->y_res = elan_convert_resolution(hw_y_res);
+       } else {
+               data->x_res = (data->max_x + 1) / x_mm;
+               data->y_res = (data->max_y + 1) / y_mm;
+       }
 
-       data->x_res = elan_convert_resolution(hw_x_res);
-       data->y_res = elan_convert_resolution(hw_y_res);
+       if (device_property_read_bool(&client->dev, "elan,clickpad"))
+               data->clickpad = 1;
 
        return 0;
 }