Skip to content

Commit f097dee

Browse files
aduggan-synaJiri Kosina
authored andcommitted
HID: rmi: disable palm detect gesture when present
A touchpad may have firmware based palm detection code enabled which suppresses 2D data from being reported when the firmware believes a palm is on the touchpad. This functionality is meant to be used in mouse mode without a driver. When a driver is present, the driver can do a better job of determining if a contact is a palm. If this gesture is enabled on a touchpad operating in rmi mode then the firmware will not properly clear the palm detect interrupt, causing the touchpad to interrupt indefinately. This patch disables the palm detect gesture when the touchpad is operating in rmi mode. Signed-off-by: Andrew Duggan <[email protected]> Tested-by: Gabriele Mazzotta <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 05ba999 commit f097dee

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

drivers/hid/hid-rmi.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ static int rmi_populate_f11(struct hid_device *hdev)
752752
bool has_rel;
753753
bool has_data40 = false;
754754
bool has_dribble = false;
755+
bool has_palm_detect = false;
755756
unsigned x_size, y_size;
756757
u16 query_offset;
757758

@@ -820,6 +821,7 @@ static int rmi_populate_f11(struct hid_device *hdev)
820821
ret);
821822
return ret;
822823
}
824+
has_palm_detect = !!(buf[0] & BIT(0));
823825
has_query10 = !!(buf[0] & BIT(2));
824826

825827
query_offset += 2; /* query 7 and 8 are present */
@@ -906,11 +908,11 @@ static int rmi_populate_f11(struct hid_device *hdev)
906908
* retrieve the ctrl registers
907909
* the ctrl register has a size of 20 but a fw bug split it into 16 + 4,
908910
* and there is no way to know if the first 20 bytes are here or not.
909-
* We use only the first 10 bytes, so get only them.
911+
* We use only the first 12 bytes, so get only them.
910912
*/
911-
ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 10);
913+
ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 12);
912914
if (ret) {
913-
hid_err(hdev, "can not read ctrl block of size 10: %d.\n", ret);
915+
hid_err(hdev, "can not read ctrl block of size 11: %d.\n", ret);
914916
return ret;
915917
}
916918

@@ -927,6 +929,17 @@ static int rmi_populate_f11(struct hid_device *hdev)
927929
}
928930
}
929931

932+
if (has_palm_detect) {
933+
buf[11] = buf[11] & ~BIT(0);
934+
ret = rmi_write(hdev, data->f11.control_base_addr + 11,
935+
&buf[11]);
936+
if (ret) {
937+
hid_err(hdev, "can not write to control reg 11: %d.\n",
938+
ret);
939+
return ret;
940+
}
941+
}
942+
930943
return 0;
931944
}
932945

0 commit comments

Comments
 (0)