summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-rmi.c
AgeCommit message (Collapse)Author
2016-11-23HID: rmi: make transfer buffers DMA capableBenjamin Tissoires
Kernel v4.9 strictly enforces DMA capable buffers, so we need to remove buffers allocated on the stack. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2016-01-27HID: rmi: Check that the device is a RMI device in suspend and resume callbacksAndrew Duggan
Commit 092563604217 ("HID: rmi: Disable scanning if the device is not a wake source") introduced a regression for devices which use hid-rmi to handle composite USB devices. The suspend or resume callbacks are not checking that the device is a RMI device before calling rmi_read or rmi_write. This results in dereferencing uninitialized variables on non RMI devices. This patch checks that the RMI_DEVICE flag is set before sending RMI commands to the device. Reported-by: Rodrigo Gomes <rodrigo.toste.gomes@gmail.com> Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-11-05HID: hid-input: allow input_configured callback return errorsDmitry Torokhov
When configuring input device via input_configured callback we may encounter errors (for example input_mt_init_slots() may fail). Instead of continuing with half-initialized input device let's allow driver indicate failures. Signed-off-by: Jaikumar Ganesh <jaikumarg@android.com> Signed-off-by: Arve Hjønnevåg <arve@android.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Acked-by: Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com> Acked-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-07-17HID: rmi: Set F01 interrupt enable register when not setAndrew Duggan
A firmware bug in some touchpads causes the F01 interrupt enable register to be cleared on reset. This register controls which RMI functions generate interrupts and when it is cleared, the touchpad stops reporting all data. This patch looks for the cleared F01 control register and writes the correct value based on interrupt mask computed while scanning the PDT. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=91102 Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
2015-07-13HID: rmi: Write updated F11 control registers after resetAndrew Duggan
When a device is reset the values of control registers will be reset to the defaults. This patch reapplies the control register values set for F11 by the driver. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
2015-07-09HID: rmi: Disable scanning if the device is not a wake sourceAndrew Duggan
Some touchpads are configured with firmware which continues to scan for fingers at a minimal scan rate even after receiving the HID power sleep command. This allows a finger touching the touchpad to genrate a wake event. This patch ensures that scanning is disabled if the touchpad is not a wake source and ensures scanning is enabled on resume. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
2015-06-22Merge branches 'for-4.2/i2c-hid', 'for-4.2/lenovo', 'for-4.2/plantronics', ↵Jiri Kosina
'for-4.2/rmi', 'for-4.2/sensor-hub', 'for-4.2/sjoy', 'for-4.2/sony' and 'for-4.2/wacom' into for-linus Conflicts: drivers/hid/wacom_wac.c
2015-06-16HID: rmi: Disable populating F30 when the touchpad has physical buttonsAndrew Duggan
Physical buttons do not use F30 to report their state and in some cases the data reported in F30 is incorrect and inconsistent with what is reported by the HID descriptor. When physical buttons are present, ignore F30 and let hid-input report buttons based on what is defined in the HID descriptor. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-18HID: rmi: fix some harmless BIT() mistakesDan Carpenter
These defines are used like this: if (!(test_bit(RMI_STARTED, &hdata->flags))) So the intent was to use bits 0, 1 and 2 but because of the extra BIT() shifts we're actually using 1, 2 and 4. It's harmless because it's done consistently but static checkers will complain. Fixes: 9fb6bf02e3ad ('HID: rmi: introduce RMI driver for Synaptics touchpads') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-25HID: rmi: disable palm detect gesture when presentAndrew Duggan
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 <aduggan@synaptics.com> Tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-25HID: rmi: disable dribble packets on Synaptics touchpadsAndrew Duggan
When a finger is lifted from a Synaptics touchpad the firmware will continue to interrupts for up to a second. These additional interrupts are know and dribble interrupts. Since the data read from the touchpad does not change the input subsystem only reports a single event. This makes the servicing of dribble interrupts on Linux unnecessary. This patch simply disables dribble interupts when configuring the touchpad. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-25HID: rmi: Add functions for writing to registersAndrew Duggan
Writing to registers is needed for setting configuration parameters. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-17HID: rmi: Print the firmware id of the touchpadAndrew Duggan
Knowing the firmware id is extremely useful when debugging issues related to the touchpad. It can be used to determine the hardware, firmware version, and configuation of the touchpad. This patch queries the firmware id and prints it as the touchpad is starting so that it will show up in the dmesg output included in bug reports. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-01-12HID: rmi: Add support for the touchpad in the Razer Blade 14 laptopAndrew Duggan
Have hid-rmi handle all of the Razer Blade HID devices that are part of the composite USB device. This will allow hid-rmi to operate the touchpad in rmi mode while passing events from the other devices to hid-input. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-01-12HID: rmi: Support touchpads with external buttonsAndrew Duggan
The external buttons on HID touchpads are connected as pass through devices and button events are not reported in the rmi registers. As a result on these devices we need to allow the HID generic desktop button events to be processed by hid-input. Unfortunately, there is no way to query the touchpad to determine that it has pass through buttons so the RMI_DEVICE_HAS_PHYS_BUTTONS should be set manually when adding the device to rmi_id[]. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-01-12HID: rmi: Use hid_report_len to compute the size of reportsAndrew Duggan
Now that hid_report_len is in hid.h we can use this function instead of duplicating the code which computes it. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-12-22HID: rmi: Support non rmi devices by passing events to hid-inputAndrew Duggan
Allowing hid-rmi to bind to non rmi devices allows us to support composite USB devices which contain several HID devices one of which is a HID touchpad. Since all of the devices have the same VID and PID we can add the device to the hid_have_special_driver list and have hid-rmi handle all of the devices. Then hid-rmi's probe can look for the rmi specific HID report IDs and decide if it should handle the device as a rmi device or simply report that the events needs additional processing. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-12-12HID: rmi: The address of query8 must be calculated based on which query ↵Andrew Duggan
registers are present If a touchpad does not report relative data then query 6 will not be present and the address of query 8 will be one less. This patches calculates the location of query 8 instead of hardcoding the offset. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-12-12HID: rmi: Check for additional ACM registers appended to F11 data reportAndrew Duggan
If a touchpad reports the F11 data40 register then this indicates that the touchpad reports additional ACM (Accidental Contact Mitigation) data after the F11 data in the HID attention report. These additional bytes shift the position of the F30 button data causing the driver to incorrectly report button state when this functionality is present. This patch accounts for the additional data in the report. Fixes: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1398533 Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-09-12HID: rmi: check sanity of the incoming reportBenjamin Tissoires
In the Dell XPS 13 9333, it appears that sometimes the bus get confused and corrupts the incoming data. It fills the input report with the sentinel value "ff". Synaptics told us that such behavior does not comes from the touchpad itself, so we filter out such reports here. Unfortunately, we can not simply discard the incoming data because they may contain useful information. Most of the time, the misbehavior is quite near the end of the report, so we can still use the valid part of it. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1123584 Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-08-14HID: rmi: print an error if F11 is not found instead of stopping the deviceAndrew Duggan
Currently rmi_probe will return -EIO if the device doesn't report that it has F11. This would indicate that something happened and the device is in the bootloader. We can recover the device using a userspace firmware update tool, but it needs access to the device through the hidraw device file. If the probe returns -EIO the hidraw device won't be created. So instead of failing the probe, just print an error message, but leave the device accessible from userspace. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-07-29HID: rmi: check that report ids exist in the report_id_hash before accessing ↵Andrew Duggan
their size It is possible that the hid-rmi driver could get loaded onto a device which does not have the expected report ids. This should not happen because it would indicate that the hid-rmi driver is not compatible with that device. However, if it does happen it should return an error from probe instead of dereferencing a null pointer. related bug: https://bugzilla.kernel.org/show_bug.cgi?id=80091 Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-07-29HID: rmi: change logging level of log messages related to unexpected reportsAndrew Duggan
Userspace tools may use hidraw to perform operations on the device from userspace while hid-rmi is bound to the device. This can cause hid-rmi to print error messages when its ->raw_event() callback gets called as the reports pass through the HID stack. In this case receiving responses which were not initiated by hid-rmi is not actually an error so the resulting error messages are incorrect and misleading. This patch changes the log messages to debug so that the messages can be turned on in the event that there is a problem and there is not a userspace tool running. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-07-29HID: rmi: make compututation of the address of Query 12 more carefulAndrew Duggan
There are additional queries which are optional and may not be present depending on the configuration of the firmware. Knowing which queries are present is needed to properly compute the address of Query 12 and all subsequent queries. Additional bits in Query 1 are used to indicate the presence of these optional queries. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-06-12HID: rmi: Protect PM-only functions by #ifdef CONFIG_PMGeert Uytterhoeven
If CONFIG_PM=n: drivers/hid/hid-rmi.c:432: warning: ‘rmi_post_reset’ defined but not used drivers/hid/hid-rmi.c:437: warning: ‘rmi_post_resume’ defined but not used Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-05-22HID: rmi: do not handle touchscreens through hid-rmiBenjamin Tissoires
Currently, hid-rmi drives every Synaptics product, but the touchscreens on the Windows tablets should be handled through hid-multitouch. Instead of providing a long list of PIDs, rely on the scan_report capability to detect which should go to hid-multitouch, and which should not go to hid-rmi. related bug: https://bugzilla.kernel.org/show_bug.cgi?id=74241 https://bugzilla.redhat.com/show_bug.cgi?id=1089583 Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-05-16HID: rmi: fix masks for x and w_x dataAndrew Duggan
The F11 data in the HID report contains four bits of data for w_x and the least significant bits of x. Currently only the first three bits are being used which is resulting in small jumps in the position data on the x axis and in the w_x data. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-05-13HID: rmi: fix wrong struct field nameJiri Kosina
x_size_mm should be y_size_mm, otherwise neither the duplicated condition nor the assignment make any sense whatsoever. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-05-13HID: rmi: do not fetch more than 16 bytes in a queryBenjamin Tissoires
A firmware bug is present on the XPS Haswell edition which silently split the request in two responses when the caller ask for a read of more than 16 bytes. The FW sends the first 16 then the 4 next, but it says that it answered the 20 bytes in the first report. This occurs only on the retrieving of the min/max of X and Y of the F11 function. We only use the first 10 bytes of the Ctrl register, so we can get only those 10 bytes to prevent the bug from happening. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1090161 Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-05-13HID: rmi: check for the existence of some optional queries before reading ↵Andrew Duggan
query 12 The rmi4 spec defines some optional query registers in F11 which appear before query 12. This patch checks for the existence of some of the lesser used queries to compute the location of query12 and all subsequent query registers. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-09HID: rmi: do not stop the device at the end of probeBenjamin Tissoires
Well, this is embarrassing, if the device is stopped at the end of probe, we get into big trouble. This was a leftover of an attempt to be smart when sending the patch, I deeply apologies. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-04-09HID: rmi: introduce RMI driver for Synaptics touchpadsBenjamin Tissoires
This driver add support for RMI4 over USB or I2C. The current state is that it uses its own RMI4 implementation, but once RMI4 is merged upstream, the driver will be a transport driver for the RMI4 library. Part of this driver should be considered as temporary. Most of the RMI4 processing and input handling will be deleted at some point. I based my work on Andrew's regarding its port of RMI4 over HID (see https://github.com/mightybigcar/synaptics-rmi4/tree/rmihid ) This repo presents how the driver may looks like at the end: https://github.com/mightybigcar/synaptics-rmi4/blob/rmihid/drivers/input/rmi4/rmi_hid.c Without this temporary solution, the workaround we gave to users is to disable i2c-hid, which leads to disabling the touchscreen on the XPS 11 and 12 (Haswell generation). Related bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1048314 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1218973 Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>