summaryrefslogtreecommitdiff
path: root/drivers/hid
AgeCommit message (Collapse)Author
2020-01-04Merge 4.4.208 into android-4.4-pGreg Kroah-Hartman
Changes in 4.4.208 btrfs: do not leak reloc root if we fail to read the fs root btrfs: handle ENOENT in btrfs_uuid_tree_iterate ALSA: hda/ca0132 - Keep power on during processing DSP response ALSA: hda/ca0132 - Avoid endless loop drm: mst: Fix query_payload ack reply struct iio: light: bh1750: Resolve compiler warning and make code more readable spi: Add call to spi_slave_abort() function when spidev driver is released staging: rtl8188eu: fix possible null dereference rtlwifi: prevent memory leak in rtl_usb_probe IB/iser: bound protection_sg size by data_sg size media: am437x-vpfe: Setting STD to current value is not an error media: i2c: ov2659: fix s_stream return value media: i2c: ov2659: Fix missing 720p register config media: ov6650: Fix stored frame format not in sync with hardware tools/power/cpupower: Fix initializer override in hsw_ext_cstates usb: renesas_usbhs: add suspend event support in gadget mode hwrng: omap3-rom - Call clk_disable_unprepare() on exit only if not idled regulator: max8907: Fix the usage of uninitialized variable in max8907_regulator_probe() media: flexcop-usb: fix NULL-ptr deref in flexcop_usb_transfer_init() samples: pktgen: fix proc_cmd command result check logic mwifiex: pcie: Fix memory leak in mwifiex_pcie_init_evt_ring media: ti-vpe: vpe: fix a v4l2-compliance warning about invalid pixel format media: ti-vpe: vpe: fix a v4l2-compliance failure about frame sequence number media: ti-vpe: vpe: Make sure YUYV is set as default format extcon: sm5502: Reset registers during initialization x86/mm: Use the correct function type for native_set_fixmap() perf report: Add warning when libunwind not compiled in iio: adc: max1027: Reset the device at probe time Bluetooth: hci_core: fix init for HCI_USER_CHANNEL drm/gma500: fix memory disclosures due to uninitialized bytes x86/ioapic: Prevent inconsistent state when moving an interrupt arm64: psci: Reduce the waiting time for cpu_psci_cpu_kill() libata: Ensure ata_port probe has completed before detach pinctrl: sh-pfc: sh7734: Fix duplicate TCLK1_B bnx2x: Fix PF-VF communication over multi-cos queues. spi: img-spfi: fix potential double release rtlwifi: fix memory leak in rtl92c_set_fw_rsvdpagepkt() perf probe: Fix to find range-only function instance perf probe: Fix to list probe event with correct line number perf probe: Walk function lines in lexical blocks perf probe: Fix to probe an inline function which has no entry pc perf probe: Fix to show ranges of variables in functions without entry_pc perf probe: Fix to show inlined function callsite without entry_pc perf probe: Skip overlapped location on searching variables perf probe: Return a better scope DIE if there is no best scope perf probe: Fix to show calling lines of inlined functions perf probe: Skip end-of-sequence and non statement lines perf probe: Filter out instances except for inlined subroutine and subprogram ath10k: fix get invalid tx rate for Mesh metric media: pvrusb2: Fix oops on tear-down when radio support is not present media: si470x-i2c: add missed operations in remove EDAC/ghes: Fix grain calculation spi: pxa2xx: Add missed security checks ASoC: rt5677: Mark reg RT5677_PWR_ANLG2 as volatile parport: load lowlevel driver if ports not found cpufreq: Register drivers only after CPU devices have been registered x86/crash: Add a forward declaration of struct kimage spi: tegra20-slink: add missed clk_unprepare btrfs: don't prematurely free work in end_workqueue_fn() iwlwifi: check kasprintf() return value fbtft: Make sure string is NULL terminated crypto: sun4i-ss - Fix 64-bit size_t warnings on sun4i-ss-hash.c crypto: vmx - Avoid weird build failures libtraceevent: Fix memory leakage in copy_filter_type net: phy: initialise phydev speed and duplex sanely Revert "mmc: sdhci: Fix incorrect switch to HS mode" usb: xhci: Fix build warning seen with CONFIG_PM=n btrfs: do not call synchronize_srcu() in inode_tree_del btrfs: return error pointer from alloc_test_extent_buffer btrfs: abort transaction after failed inode updates in create_subvol Btrfs: fix removal logic of the tree mod log that leads to use-after-free issues ALSA: pcm: Avoid possible info leaks from PCM stream buffers af_packet: set defaule value for tmo fjes: fix missed check in fjes_acpi_add mod_devicetable: fix PHY module format net: hisilicon: Fix a BUG trigered by wrong bytes_compl net: nfc: nci: fix a possible sleep-in-atomic-context bug in nci_uart_tty_receive() net: qlogic: Fix error paths in ql_alloc_large_buffers() net: usb: lan78xx: Fix suspend/resume PHY register access error sctp: fully initialize v4 addr in some functions net: dst: Force 4-byte alignment of dst_metrics usbip: Fix error path of vhci_recv_ret_submit() USB: EHCI: Do not return -EPIPE when hub is disconnected platform/x86: hp-wmi: Make buffer for HPWMI_FEATURE2_QUERY 128 bytes staging: comedi: gsc_hpdi: check dma_alloc_coherent() return value ext4: check for directory entries too close to block end powerpc/irq: fix stack overflow verification mmc: sdhci-of-esdhc: fix P2020 errata handling perf probe: Fix to show function entry line as probe-able scsi: mpt3sas: Fix clear pending bit in ioctl status scsi: lpfc: Fix locking on mailbox command completion Input: atmel_mxt_ts - disable IRQ across suspend iommu/tegra-smmu: Fix page tables in > 4 GiB memory scsi: target: compare full CHAP_A Algorithm strings scsi: lpfc: Fix SLI3 hba in loop mode not discovering devices scsi: csiostor: Don't enable IRQs too early powerpc/pseries: Mark accumulate_stolen_time() as notrace dma-debug: add a schedule point in debug_dma_dump_mappings() clocksource/drivers/asm9260: Add a check for of_clk_get powerpc/security/book3s64: Report L1TF status in sysfs jbd2: Fix statistics for the number of logged blocks scsi: tracing: Fix handling of TRANSFER LENGTH == 0 for READ(6) and WRITE(6) scsi: lpfc: Fix duplicate unreg_rpi error in port offline flow clk: qcom: Allow constant ratio freq tables for rcg irqchip/irq-bcm7038-l1: Enable parent IRQ if necessary irqchip: ingenic: Error out if IRQ domain creation failed fs/quota: handle overflows of sysctl fs.quota.* and report as unsigned long scsi: lpfc: fix: Coverity: lpfc_cmpl_els_rsp(): Null pointer dereferences scsi: ufs: fix potential bug which ends in system hang powerpc/pseries/cmm: Implement release() function for sysfs device powerpc/security: Fix wrong message when RFI Flush is disable clk: pxa: fix one of the pxa RTC clocks bcache: at least try to shrink 1 node in bch_mca_scan() HID: Improve Windows Precision Touchpad detection. ext4: work around deleting a file with i_nlink == 0 safely scsi: pm80xx: Fix for SATA device discovery scsi: target: iscsi: Wait for all commands to finish before freeing a session gpio: mpc8xxx: Don't overwrite default irq_set_type callback scripts/kallsyms: fix definitely-lost memory leak cdrom: respect device capabilities during opening action perf regs: Make perf_reg_name() return "unknown" instead of NULL libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h s390/cpum_sf: Check for SDBT and SDB consistency ocfs2: fix passing zero to 'PTR_ERR' warning kernel: sysctl: make drop_caches write-only ALSA: hda - Downgrade error message for single-cmd fallback Make filldir[64]() verify the directory entry filename is valid filldir[64]: remove WARN_ON_ONCE() for bad directory entries net: davinci_cpdma: use dma_addr_t for DMA address netfilter: ebtables: compat: reject all padding in matches/watchers 6pack,mkiss: fix possible deadlock netfilter: bridge: make sure to pull arp header in br_nf_forward_arp() net: icmp: fix data-race in cmp_global_allow() hrtimer: Annotate lockless access to timer->state mmc: sdhci: Update the tuning failed messages to pr_debug level tcp: do not send empty skb from tcp_write_xmit() Linux 4.4.208 Change-Id: I1c710061be5b595f822b45a87d852b85512d7783 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2020-01-04HID: Improve Windows Precision Touchpad detection.Blaž Hrastnik
[ Upstream commit 2dbc6f113acd74c66b04bf49fb027efd830b1c5a ] Per Microsoft spec, usage 0xC5 (page 0xFF) returns a blob containing data used to verify the touchpad as a Windows Precision Touchpad. 0x85, REPORTID_PTPHQA, // REPORT_ID (PTPHQA) 0x09, 0xC5, // USAGE (Vendor Usage 0xC5) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (0xff) 0x75, 0x08, // REPORT_SIZE (8) 0x96, 0x00, 0x01, // REPORT_COUNT (0x100 (256)) 0xb1, 0x02, // FEATURE (Data,Var,Abs) However, some devices, namely Microsoft's Surface line of products instead implement a "segmented device certification report" (usage 0xC6) which returns the same report, but in smaller chunks. 0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined) 0x85, REPORTID_PTPHQA, // REPORT_ID (PTPHQA) 0x09, 0xC6, // USAGE (Vendor usage for segment #) 0x25, 0x08, // LOGICAL_MAXIMUM (8) 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x01, // REPORT_COUNT (1) 0xb1, 0x02, // FEATURE (Data,Var,Abs) 0x09, 0xC7, // USAGE (Vendor Usage) 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (0xff) 0x95, 0x20, // REPORT_COUNT (32) 0xb1, 0x02, // FEATURE (Data,Var,Abs) By expanding Win8 touchpad detection to also look for the segmented report, all Surface touchpads are now properly recognized by hid-multitouch. Signed-off-by: Blaž Hrastnik <blaz@mxxn.io> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-01-02UPSTREAM: HID: input: map digitizer battery usageDmitry Torokhov
We already mapped battery strength reports from the generic device control page, but we did not update capacity from input reports, nor we mapped the battery strength report from the digitizer page, so let's implement this now. Batteries driven by the input reports will now start in "unknown" state, and will get updated once we receive first report containing battery strength from the device. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Bug: 146590412 Change-Id: I15f2e1c1349e2cf044c45a6697015b95596ce760 (cherry picked from commit 581c4484769e692eade761c17c22549aaefe6749) Signed-off-by: Siarhei Vishniakou <svv@google.com>
2020-01-02UPSTREAM: HID: input: ignore the battery in OKLICK Laser BTmouseAlexander E. Patrakov
This mouse, when asked about the battery, ceases to report movements and clicks. So just don't ask. Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Bug: 146590412 Change-Id: I898cf2d9bfa0e46cf94da30333346c7b7a976d5b (cherry picked by commit 5d9374cf5f66ebe38007bccf0b4adc14f0013663) Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-12-05Merge 4.4.206 into android-4.4-pGreg Kroah-Hartman
Changes in 4.4.206 ASoC: compress: fix unsigned integer overflow check ASoC: kirkwood: fix external clock probe defer clk: samsung: exynos5420: Preserve PLL configuration during suspend/resume reset: fix reset_control_ops kerneldoc comment can: peak_usb: report bus recovery as well can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open scripts/gdb: fix debugging modules compiled with hot/cold partitioning block: drbd: remove a stray unlock in __drbd_send_protocol() scsi: lpfc: Fix dif and first burst use in write commands ARM: debug-imx: only define DEBUG_IMX_UART_PORT if needed ARM: dts: imx53-voipac-dmm-668: Fix memory node duplication parisc: Fix serio address output parisc: Fix HP SDC hpa address output arm64: smp: Handle errors reported by the firmware PM / AVS: SmartReflex: NULL check before some freeing functions is not needed ARM: ks8695: fix section mismatch warning ACPI / LPSS: Ignore acpi_device_fix_up_power() return value crypto: user - support incremental algorithm dumps mwifiex: fix potential NULL dereference and use after free mwifiex: debugfs: correct histogram spacing, formatting rtl818x: fix potential use after free xfs: require both realtime inodes to mount ubi: Put MTD device after it is not used ubi: Do not drop UBI device reference before using microblaze: adjust the help to the real behavior microblaze: move "... is ready" messages to arch/microblaze/Makefile gpiolib: Fix return value of gpio_to_desc() stub if !GPIOLIB VSOCK: bind to random port for VMADDR_PORT_ANY btrfs: only track ref_heads in delayed_ref_updates xen/pciback: Check dev_data before using it KVM: s390: unregister debug feature on failing arch init pinctrl: sh-pfc: sh7264: Fix PFCR3 and PFCR0 register configuration pinctrl: sh-pfc: sh7734: Fix shifted values in IPSR10 HID: doc: fix wrong data structure reference for UHID_OUTPUT gfs2: take jdata unstuff into account in do_grow xfs: Align compat attrlist_by_handle with native implementation. IB/qib: Fix an error code in qib_sdma_verbs_send() powerpc/book3s/32: fix number of bats in p/v_block_mapped() powerpc/xmon: fix dump_segments() drivers/regulator: fix a missing check of return value serial: max310x: Fix tx_empty() callback openrisc: Fix broken paths to arch/or32 RDMA/srp: Propagate ib_post_send() failures to the SCSI mid-layer scsi: qla2xxx: deadlock by configfs_depend_item scsi: csiostor: fix incorrect dma device in case of vport ath6kl: Only use match sets when firmware supports it ath6kl: Fix off by one error in scan completion powerpc/prom: fix early DEBUG messages powerpc/mm: Make NULL pointer deferences explicit on bad page faults. powerpc/44x/bamboo: Fix PCI range drbd: reject attach of unsuitable uuids even if connected drbd: fix print_st_err()'s prototype to match the definition regulator: tps65910: fix a missing check of return value net/net_namespace: Check the return value of register_pernet_subsys() um: Make GCOV depend on !KCOV net: stmicro: fix a missing check of clk_prepare atl1e: checking the status of atl1e_write_phy_reg tipc: fix a missing check of genlmsg_put ocfs2: clear journal dirty flag after shutdown journal lib/genalloc.c: use vzalloc_node() to allocate the bitmap lib/genalloc.c: include vmalloc.h mtd: Check add_mtd_device() ret code tipc: fix memory leak in tipc_nl_compat_publ_dump net/core/neighbour: tell kmemleak about hash tables net/core/neighbour: fix kmemleak minimal reference count for hash tables sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe decnet: fix DN_IFREQ_SIZE tipc: fix skb may be leaky in tipc_link_input sfc: initialise found bitmap in efx_ef10_mtd_probe net: fix possible overflow in __sk_mem_raise_allocated() net: dev: Use unsigned integer as an argument to left-shift scsi: libsas: Support SATA PHY connection rate unmatch fixing during discovery ACPI / APEI: Switch estatus pool to use vmalloc memory scsi: libsas: Check SMP PHY control function result powerpc/pseries/dlpar: Fix a missing check in dlpar_parse_cc_property() mtd: Remove a debug trace in mtdpart.c staging: rtl8192e: fix potential use after free USB: serial: ftdi_sio: add device IDs for U-Blox C099-F9P mei: bus: prefix device names on bus with the bus name media: v4l2-ctrl: fix flags for DO_WHITE_BALANCE net: macb: fix error format in dev_err() pwm: Clear chip_data in pwm_put() macvlan: schedule bc_work even if error openvswitch: fix flow command message size slip: Fix use-after-free Read in slip_open openvswitch: drop unneeded BUG_ON() in ovs_flow_cmd_build_info() openvswitch: remove another BUG_ON() tipc: fix link name length check net: sched: fix `tc -s class show` no bstats on class with nolock subqueues HID: core: check whether Usage Page item is after Usage ID items hwrng: stm32 - fix unbalanced pm_runtime_enable platform/x86: hp-wmi: Fix ACPI errors caused by too small buffer Linux 4.4.206 Change-Id: Ie297a77bf4a6cd8f1bf629d43684902c529d23c9 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2019-12-05HID: core: check whether Usage Page item is after Usage ID itemsCandle Sun
commit 1cb0d2aee26335d0bccf29100c7bed00ebece851 upstream. Upstream commit 58e75155009c ("HID: core: move Usage Page concatenation to Main item") adds support for Usage Page item after Usage ID items (such as keyboards manufactured by Primax). Usage Page concatenation in Main item works well for following report descriptor patterns: USAGE_PAGE (Keyboard) 05 07 USAGE_MINIMUM (Keyboard LeftControl) 19 E0 USAGE_MAXIMUM (Keyboard Right GUI) 29 E7 LOGICAL_MINIMUM (0) 15 00 LOGICAL_MAXIMUM (1) 25 01 REPORT_SIZE (1) 75 01 REPORT_COUNT (8) 95 08 INPUT (Data,Var,Abs) 81 02 ------------- USAGE_MINIMUM (Keyboard LeftControl) 19 E0 USAGE_MAXIMUM (Keyboard Right GUI) 29 E7 LOGICAL_MINIMUM (0) 15 00 LOGICAL_MAXIMUM (1) 25 01 REPORT_SIZE (1) 75 01 REPORT_COUNT (8) 95 08 USAGE_PAGE (Keyboard) 05 07 INPUT (Data,Var,Abs) 81 02 But it makes the parser act wrong for the following report descriptor pattern(such as some Gamepads): USAGE_PAGE (Button) 05 09 USAGE (Button 1) 09 01 USAGE (Button 2) 09 02 USAGE (Button 4) 09 04 USAGE (Button 5) 09 05 USAGE (Button 7) 09 07 USAGE (Button 8) 09 08 USAGE (Button 14) 09 0E USAGE (Button 15) 09 0F USAGE (Button 13) 09 0D USAGE_PAGE (Consumer Devices) 05 0C USAGE (Back) 0a 24 02 USAGE (HomePage) 0a 23 02 LOGICAL_MINIMUM (0) 15 00 LOGICAL_MAXIMUM (1) 25 01 REPORT_SIZE (1) 75 01 REPORT_COUNT (11) 95 0B INPUT (Data,Var,Abs) 81 02 With Usage Page concatenation in Main item, parser recognizes all the 11 Usages as consumer keys, it is not the HID device's real intention. This patch checks whether Usage Page is really defined after Usage ID items by comparing usage page using status. Usage Page concatenation on currently defined Usage Page will always do in local parsing when Usage ID items encountered. When Main item is parsing, concatenation will do again with last defined Usage Page if this page has not been used in the previous usages concatenation. Signed-off-by: Candle Sun <candle.sun@unisoc.com> Signed-off-by: Nianfu Bai <nianfu.bai@unisoc.com> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Cc: Siarhei Vishniakou <svv@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-08UPSTREAM: HID: steam: fix deadlock with input devices.Rodrigo Rivas Costa
When using this driver with the wireless dongle and some usermode program that monitors every input device (acpid, for example), while another usermode client opens and closes the low-level device repeadedly, the system eventually deadlocks. The reason is that steam_input_register_device() must not be called with the mutex held, because the input subsystem has its own synchronization that clashes with this one: it is possible that steam_input_open() is called before input_register_device() returns, and since steam_input_open() needs to lock the mutex, it deadlocks. However we must hold the mutex when calling any function that sends commands to the controller. If not, random commands end up falling fail. Reported-by: Simon Gene Gottlieb <simon@gottliebtfreitag.de> Signed-off-by: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> Tested-by: Simon Gene Gottlieb <simon@gottliebtfreitag.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Bug: 136263708 Change-Id: Ia0c37b3117dc605a30b2e1fb5030282bf2e11a11 (cherry picked from commit 6b538cc21334b83f09b25dec4aa2d2726bf07ed0 ("HID: steam: fix deadlock with input devices.")) https://github.com/torvalds/linux/commit/6b538cc21334b83f09b25dec4aa2d2726bf07ed0 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-08UPSTREAM: HID: steam: fix boot loop with bluetooth firmwareRodrigo Rivas Costa
There is a new firmware for the Steam Controller with support for BLE connections. When using such a device with a wired connection, it reboots itself every 10 seconds unless an application has opened it. Doing hid_hw_open() unconditionally on probe fixes the issue, and the code becomes simpler. (cherry-picked from commit cf28aee292e102740e49f74385b4b89c00050763 ("HID: steam: fix boot loop with bluetooth firmware")) https://github.com/torvalds/linux/commit/cf28aee292e102740e49f74385b4b89c00050763 Bug: 136263708 Signed-off-by: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Siarhei Vishniakou <svv@google.com> Change-Id: I55b573d6db1bc336626ce4a6563255374da590ae
2019-11-08UPSTREAM: HID: steam: remove input device when a hid client is running.Rodrigo Rivas Costa
Previously, when a HID client such as the Steam Client was running, this driver disabled its input device to avoid doubling the input events. While it worked mostly fine, some games got confused by the idle gamepad, and switched to two player mode, or asked the user to choose which gamepad to use. Other games just crashed, probably a bug in Unity [1]. With this commit, when a HID client starts, the input device is removed; when the HID client ends the input device is recreated. [1]: https://github.com/ValveSoftware/steam-for-linux/issues/5645 (cherry-picked from commit 385a4886778f6d6e61eff1d4d295af332d7130e1 ("HID: steam: remove input device when a hid client is running")) https://github.com/torvalds/linux/commit/385a4886778f6d6e61eff1d4d295af332d7130e1 Bug: 136263708 Signed-off-by: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Siarhei Vishniakou <svv@google.com> Change-Id: I8b93bb46c508e44d275168933b53ad738795d511
2019-11-08UPSTREAM: HID: steam: use hid_device.driver_data instead of hid_set_drvdata()Rodrigo Rivas Costa
When creating the low-level hidraw device, the reference to steam_device was stored using hid_set_drvdata(). But this value is not guaranteed to be kept when set before calling probe. If this pointer is reset, it crashes when opening the emulated hidraw device. It looks like hid_set_drvdata() is for users "avobe" this hid_device, while hid_device.driver_data it for users "below" this one. In this case, we are creating a virtual hidraw device, so we must use hid_device.driver_data. Signed-off-by: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> Tested-by: Mariusz Ceier <mceier+kernel@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 4bff980f920693693d7a529c06a1bd1e7f77603a ("HID: steam: use hid_device.driver_data instead of hid_set_drvdata()") https://github.com/torvalds/linux/commit/4bff980f920693693d7a529c06a1bd1e7f77603a Change-Id: I650db1803c53bc055be4574b9190df57b6b8aad3 Signed-Off-By: Siarhei Vishniakou <svv@google.com> Bug: 136263708 Test: connect steam controller
2019-11-08UPSTREAM: HID: steam: add missing fields in client initializationJiri Kosina
->product, ->version and ->type fields in the client struct were left out unitialized from the hid device fields; fix that. Reported-by: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 165e2cad5a74bddbe6ca2c42fc5d2816f5e67795 ("HID: steam: add missing fields in client initialization")) https://github.com/torvalds/linux/commit/165e2cad5a74bddbe6ca2c42fc5d2816f5e67795 Change-Id: I6f13c2ad6f86a4e06f81dc93616407f9149753ed Signed-Off-By: Siarhei Vishniakou <svv@google.com> Bug: 136263708 Test: connect steam controller
2019-11-08UPSTREAM: HID: steam: add battery device.Rodrigo Rivas Costa
The wireless Steam Controller is battery operated, so add the battery device and power information. Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit f82719790751742be02142a6fa3ff5c62c52a6ae ("HID: steam: add battery device")) https://github.com/torvalds/linux/commit/f82719790751742be02142a6fa3ff5c62c52a6ae Change-Id: Ie945fffa96103a164c333b2c6c51bca44a41423b Signed-Off-By: Siarhei Vishniakou <svv@google.com> Bug: 136263708 Test: connected steam controller to Android
2019-11-08UPSTREAM: HID: add driver for Valve Steam ControllerRodrigo Rivas Costa
There are two ways to connect the Steam Controller: directly to the USB or with the USB wireless adapter. Both methods are similar, but the wireless adapter can connect up to 4 devices at the same time. The wired device will appear as 3 interfaces: a virtual mouse, a virtual keyboard and a custom HID device. The wireless device will appear as 5 interfaces: a virtual keyboard and 4 custom HID devices, that will remain silent until a device is actually connected. The custom HID device has a report descriptor with all vendor specific usages, so the hid-generic is not very useful. In a PC/SteamBox Valve Steam Client provices a software translation by using hidraw and a creates a uinput virtual gamepad and XTest keyboard/mouse. This driver intercepts the hidraw usage, so it can get out of the way when the Steam Client is in use. (cherry picked from commit c164d6abf3841ffacfdb757c10616f9cb1f67276 ("HID: add driver for Valve Steam Controller")) https://github.com/torvalds/linux/commit/c164d6abf3841ffacfdb757c10616f9cb1f67276 Signed-off-by: Rodrigo Rivas Costa <rodrigorivascosta@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Change-Id: Ic435163998560885afb2a6d71b1604de21fb8b11 Signed-Off-By: Siarhei Vishniakou <svv@google.com> Bug: 136263708 Test: connected steam controller to Android
2019-11-08UPSTREAM: HID: sony: Fix memory corruption issue on cleanup.Roderick Colenbrander
The sony driver is not properly cleaning up from potential failures in sony_input_configured. Currently it calls hid_hw_stop, while hid_connect is still running. This is not a good idea, instead hid_hw_stop should be moved to sony_probe. Similar changes were recently made to Logitech drivers, which were also doing improper cleanup. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> CC: stable@vger.kernel.org Signed-off-by: Jiri Kosina <jkosina@suse.cz> Bug: 139372370 Change-Id: I97dadab125a6a426763efd3beb939ddca017c6b6 (cherry picked from commit 2bcdacb70327013ca2066bfcf2af1009eff01f1d ("HID: sony: Fix memory corruption issue on cleanup.")) Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-08UPSTREAM: HID: sony: Fix race condition between rumble and device remove.Roderick Colenbrander
Valve reported a kernel crash on Ubuntu 18.04 when disconnecting a DS4 gamepad while rumble is enabled. This issue is reproducible with a frequency of 1 in 3 times in the game Borderlands 2 when using an automatic weapon, which triggers many rumble operations. We found the issue to be a race condition between sony_remove and the final device destruction by the HID / input system. The problem was that sony_remove didn't clean some of its work_item state in "struct sony_sc". After sony_remove work, the corresponding evdev node was around for sufficient time for applications to still queue rumble work after "sony_remove". On pre-4.19 kernels the race condition caused a kernel crash due to a NULL-pointer dereference as "sc->output_report_dmabuf" got freed during sony_remove. On newer kernels this crash doesn't happen due the buffer now being allocated using devm_kzalloc. However we can still queue work, while the driver is an undefined state. This patch fixes the described problem, by guarding the work_item "state_worker" with an initialized variable, which we are setting back to 0 on cleanup. Bug: 139372370 Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> CC: stable@vger.kernel.org (cherry picked from commit e0f6974a54d3f7f1b5fdf5a593bd43ce9206ec04 ("HID: sony: Fix race condition between rumble and device remove.")) Signed-off-by: Siarhei Vishniakou <svv@google.com> Change-Id: I08ba1daf2d539f4089b5098cff7b9bc2be2f1645
2019-11-07UPSTREAM: HID: sony: remove redundant check for -ve errColin Ian King
err is being checked for failure each time it is being updated so this err check is totally redundant and can be removed Detected with CoverityScan, CID#1420665 ("Logically dead code") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 040fc001765d374776353cb4f8b03ea7fa41e3cd) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I6ff2852c384d62af4fe074643d509f7d1c965ca2 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Make sure to unregister sensors on failureRoderick Colenbrander
Make sure we sure register any sensor when sony_input_configured failes. Somehow this line got lost during resolving of merge conflicts in the motion sensor patch series and a redudant remove was added as well later on. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit a676bdc422241822130364443a6a65b6520440ba) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: Ic4f7e7b9c5fead2df626c8da6f3ff36ff9177b75 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Make DS4 bt poll interval adjustableRoderick Colenbrander
By default when using bluetooth the DS4 reports data at about 1kHz, which is quite fast especially on weak devices. We now make the device use the USB poll interval, which is a fixed 4ms. In addition we make the value adjustable through sysfs. The error handling in sony_input_configured is a little tricky. It is not easy to add other goto's as not all codepaths have logic for adding this attribute. Luckily we are setting the value for the attribute to a default value, so we can use that to detect if we need to remove the file. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 77b499e739ed5561e5026fa7140ae53f6c4d1d8e) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I9c384d5512173c3fe10191e91143cd966d63578e Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Set proper bit flags on DS4 output reportRoderick Colenbrander
Only set bit flags for the portions of the DS4 output report for which we have data. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 5caceb0695d0498b8c931cbc3cdafd99bd37b8ae) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I9792765a4417cde21febc254e3c605cefb6b0be4 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: DS4 use brighter LED colorsRoderick Colenbrander
These colors are more the default colors normally used on the DS4. The previous ones were faint and not so noticeable. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 39254a13d64bc69b83f4097dacc4117d7b865118) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I83fe88334d35918dd4ba302d7e2a9beabc39f819 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Improve navigation controller axis/button mappingRoderick Colenbrander
The navigation controller is a DS3 (sixaxis) with fewer physical axes and buttons. It utilizes the same HID report as the DS3 and thus reports axes/buttons which aren't physically present. Currently many non-existing buttons and axes are reported, which we are now removing. For the axes/buttons which do exist, we make the axis/button mapping similar to the DS3. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit b8f0970d2c5a03f5a431d51af74dd1a0ec62fe91) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I031dc81bb44268de0ac507b851e8f72a79f70a9e Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Use DS3 MAC address as unique identifier on USBRoderick Colenbrander
The DS3 MAC address is reported as a unique identified when using Bluetooth. For USB there is no unique identifier reported yet, so use the MAC address. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 5a144be39c3a32b3072529ccee79e4ec9eb9b275) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: If19781de9035cf22fee523b5da81d852684177ea Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Perform duplicate device check earlier onRoderick Colenbrander
Game controllers can be connected twice through USB and BT. Only one connection is allowed. Currently we perform a check for duplicate controllers halfway through device initialization. To prevent 'transient' devices, we should do this check as early as we can. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit df848bc05db1c49756a2befbe03ab03ce34a6bcc) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: Ibd372ee52c949c7d4a2dd86284a3e6cc3923b78a Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Expose DS3 motion sensors through separate deviceRoderick Colenbrander
This patch adds a separate evdev node for the DS3 its motion sensors. We only expose the accelerometers as the gyroscope is extremely difficult to manage and behavior varies a lot between hardware revisions. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 510c8b7c168bcad75e2864f73e5125d7218ee3cf) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I566566d2437a0ee70af8a6eb821dd47359d710b3 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Print error on failure to active DS3 / Navigation ↵Roderick Colenbrander
controllers This patch adds printing when we failed to activate DS3 / Nagivation controllers and checks the return value for these failures earlier in sony_input_configured. This paves the way for other configuration logic for these devices, which we don't want to call if for example the activation failed. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 80ecc48c0ade5e99cc9d84febd17c44a4f011c13) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I22ca0420b576036f1788bf63fde9abcdde01ac5c Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: DS3 comply to Linux gamepad specRoderick Colenbrander
The axis and button mapping for the DS3 is strange. This is mostly due to the device reporting many axes as for every digital button it also has an analog button. Due to amount of analog values it is even leaking well into the MT axes range. We felt it is best to remove the many analog buttons and just report digital and comply to the Linux gamepad spec. The analog buttons are rarely used on the official platform, let alone on Linux. This patch does remove motion sensor support (added back in another patch). Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit e19a267b9987135c00155a51e683e434b9abb56b) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I312b269c97a3a38141683e384bcd3b4595760a52 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Mark DS4 touchpad device as a pointerRoderick Colenbrander
Currently the DS4 touchpad device is neither classified as a direct input device nor as a pointer device. It makes most sense to mark it as a pointer device. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit b9f7d245e34b1f42b5389b015962a2f022d4ece2) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I8fa285f5b3c2926e826477c7d366bc2ff8f00d64 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Support motion sensor calibration on dongleRoderick Colenbrander
The DualShock 4 dongle isn't connected to a real DualShock 4 at time of driver loading. When a DualShock 4 is plugged in, we need to obtain calibration data (the dongle would have zeros). This patch adds calibration logic, which we schedule on a hotplug from sony_raw_event. In addition this patch adds dongle state handling. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit f2f47c385d2babf44cbd2ec2be4f2b29b88041bc) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I34b8e1b47d5c2f8268b9c8ec12f6815b64ade380 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Make work handling more genericRoderick Colenbrander
The driver currently uses sony_schedule_work to submit output reports for the different devices for LEDs or rumble. This patch adds a new parameter to sony_schedule_work to allow scheduling for other types of work. The next patch in this series will utilize this functionality. Considering the driver structure and all error handling it felt best to reuse sony_schedule_work and sony_cancel_work. The idea was inspired by the wacom driver which does something similar. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit b53227360dc2e30fb8809815dfdc39339a34b8dd) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I9eaa71a2b27137602e8fb2c8118947e6b49af75f Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Treat the ds4 dongle as a separate deviceRoderick Colenbrander
This patch adds a new quirk, which allows us to differentiate between the DualShock 4 USB and the dongle. So far they have been treated the same, but handling of calibration data differs as the dongle behaves like Bluetooth, for other requests it behaves like USB. In addition this patches changes usb/dongle/bt handling in sony_raw_event, which makes the code cleaner to read. In addition another patch in this series will add more dongle logic, so this change paves the road for that. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 35f436c31ea81d240ed53fe3467946e2a53032bb) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: Idbaebf4df720a782d83abd337eb698118a62c9f8 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Remove report descriptor fixup for DS4Roderick Colenbrander
The DS4 in BT mode sends initial input reports through report 1, which is described in the HID report descriptors. When activated after sending a certain feature report, the device uses report 17. Currently the hid-sony driver fixes up the BT HID report descriptors, so the HID layer can manage input reports for report 17. We think it is best to eliminate this fixup and do the handling ourselves, which is what this patch does. The main motivation is that there are various users of DS4 through hidraw, including various cross-platform applications/games, which have their own HID parsing across Linux/Win/OSX. Due to the fixup the descriptors differ, which is causing pain for many developers including major game publishers (who reached out privately). Without the fixup, the Windows titles also have a fighting chance for working on Wine, which provides HID support now. Overall it felt best because of these reasons to remove the fixup. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit d03ae2e1080026951376d787b96109169926a15c) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I818f4c7ad907fa81f16b825e522d28e221dbe42a Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Report hardware timestamp for DS4 sensor valuesRoderick Colenbrander
Report the hardware timestamp inside each HID report through MSC_TIMESTAMP for motion sensor values. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 80786eb9abebce64ec471de12d8ab3072834b333) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I2915ce7caf286bf5016aef318e441efdc1c95e95 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Calibrate DS4 motion sensorsRoderick Colenbrander
The DS4 motion sensors require calibration for accurate operation. This patch adds calibration for both the accelerometer and the gyroscope. Calibration requires reading device specific scaling factors and offsets. For precision reasons we store these values as a numerator and denominator and apply the values when processing the data. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 55a07d62db0feda2e37f6962a1b2799e2a8b42ba) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I335e4d0e8720e7dc62041b43d107fd69a592d9a9 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Report DS4 motion sensors through a separate deviceRoderick Colenbrander
The DS4 motion sensors are currently mapped by the hid-core driver to non-existing axes in between ABS_MISC and ABS_MT_SLOT, because the device already exhausted ABS_X-ABS_RZ. For a part the mapping by hid-core is accomplished by a fixup in hid-sony as the motion axes actually use vendor specific usage pages. This patch makes the DS4 use a separate input device for the motion sensors and reports acceleration data through ABS_X-ABS_Z and gyroscope data through ABS_RX-ABS_RZ. In addition it extends the event spec to allow gyroscope data through ABS_RX-ABS_RZ when INPUT_PROP_ACCELEROMETER is set. This change was suggested by Peter Hutterer during a discussion on linux-input. [jkosina@suse.cz: rebase onto slightly newer codebase] Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 227c011b2e046dd4d36d9e00e3d9c88097b2a4c3) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I26c22b0b076f114e9965460b589b22014b0c4b2f Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Fix input device leak when connecting a DS4 twice using ↵Roderick Colenbrander
USB/BT When a user connects a DS4 twice using USB and BT, we reject the second device connection after the setup work. We then perform a cleanup, but during cleanup we are not removing the touchpad device. This leads to leakage of an input device, which we would never remove. It can likely result into a kernel oops as well when the touchpad evdev node is accessed and the underlaying HID device has been removed from the system. [jkosina@suse.cz: added stable annotation] Fixes: ac797b95f532 ("HID: sony: Make the DS4 touchpad a separate device") Cc: stable@vger.kernel.org Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit a687c5765b5ae19fe559e14615ddc87ebb46d409) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: Iaf021a5624d96efca291c4890df89cb6ed1550b7 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Use LED_CORE_SUSPENDRESUMEFrank Praznik
The LED subsystem provides the LED_CORE_SUSPENDRESUME flag to handle automatically turning off and restoring the state of device LEDs during suspend/resume. Use this flag instead of saving and restoring the state locally. Signed-off-by: Frank Praznik <frank.praznik@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 765a1077c85e5f2efcc43582f80caf43a052e903) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: Ica87d7e4d9bf24a802a0556b82bd4192f237c6b1 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Ignore DS4 dongle reports when no device is connectedRoderick Colenbrander
When the DS4 dongle is connected, it always generates HID reports even when no DS4 is paired to it. This patch adds logic to ignore HID reports from the dongle if there is no DS4 currently attached. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 405182c2459fe2de4a3994ef39e866993e0e61d1) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I519b484432d92183cdefd3e0f7c89e6e7d32f573 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Use DS4 MAC address as unique identifier on USBRoderick Colenbrander
The DS4 MAC address is reported as a unique identified when using Bluetooth. For USB there is no unique identifier reported yet, so use the MAC address. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit c70d5f70ccbbdf56bb86adb42127db90d0c90976) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I366c1dd01049c7039844e691456f5e49eb9d902f Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Fix error handling bug when touchpad registration failsRoderick Colenbrander
The error handling code in sony_input_configured in general uses goto based cleanup. Recently we migrated code from sony_probe to here, but we didn't update the existing touchpad registration code, which was already here to use the goto. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 2b6579d4a71afb19c6583470783371b992944f67) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I00b37e52eb1798110427b02c72122e464cb9baab Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Comply to Linux gamepad spec for DS4Roderick Colenbrander
The DS4 side of hid-sony used the hid-core layer to assign buttons and axes based on the HID report descriptors. The default mapping was strange e.g. right stick using ABS_Z/ABS_RZ or the physical 'south button' being reported as BTN_EAST etcetera. This patch makes the DS4 side ofi the hid-sony driver comply to the Linux game controller spec as suggested in a discussion with Dmitry on the linux-input list. Currently the main user of the DS4 is the SDL2 library, which has a mapping table using vendor/device/version as a key. In order to not break SDL2 we discussed adjusting the version number, so it can have both mappings. This was discust on linux-input and we discussed privately with SDL2 developers. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 9131f8cc2b4eaf7c08d402243429e0bfba9aa0d6) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I91f52ca8c6b0c3a7bcd71f3b8bf14df160bd2bb4 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Make the DS4 touchpad a separate deviceRoderick Colenbrander
The dualshock 4 supports both analog sticks of which one uses ABS_X/_Y and a touchpad. In a recent discussion with Dmitry about some input-mt changes we proposed for disabling pointer emulation from input_mt_sync_frame, Dmitry mentioned ABS_X/_Y should report the same data as ABS_MT_POSITION_X/_Y. The current driver is mixing axes for different subdevices. It was suggested to make the touchpad its own sub-device. This patch turns the touchpad into its own device. In addition this patch also moves the button underneath the touchpad into the new device. It felt like this button should be part of the device. No known user space application (not even SDL2) seems to be using it. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit ac797b95f53276c132c51d53437e38dd912413d7) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: If3f15f2179850a2029e5112dd34bcd424b7b80af Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Fix memory issue when connecting device using both ↵Roderick Colenbrander
Bluetooth and USB A previous patch moved most input initialization from sony_probe to sony_input_configured to avoid some race conditions. The driver has some special logic to prevent the device to get registered twice in case the user connects it both over Bluetooth and USB. When this condition happens sony_input_configured returns a failure, but sony_probe continues as hid_hw_start doesn't fail. As was discussed on linux-input, it is acceptable for this function to fail. This patch adds a check for the HID_CLAIMED_INPUT flag within sony_probe to determine whether initialization succeeded correctly. The flag is not set by the HID layer when sony_input_configured fails. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 4f967f6d73746f66514528cc1191025f0b5d69b3) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I894f9cb08c672a769975aa5ecf062ee920e55785 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Adjust value range for motion sensorsRoderick Colenbrander
The motion sensor values are 16-bit, so make the value range match. It is hard to reach the upper values, but they can be reached. At least the current accelerometer value of 8192 is very easy to pass. It is still not nice that the motion sensors live in no man's land in between ABS_MISC and ABS_MT_SLOT, but that's something for another time, which the proposed ABS_ACCEL_*/ABS_GYRO_* were meant for. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit bdae9e0e95364123fb7d372872bd7efd1760867c) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I86982a23a443662a88600fe42cbe5ed8ae2686a4 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Handle multiple touch events input recordRoderick Colenbrander
Read the touch history field in the HID descriptor and use this value to determine how many touch events to read from the report. As part of this patch, we did a first attempt of making the offset calculation code less magical. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit cdc1c0215ab449077cd160dde4fcd1c5f41dec6e) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: Ie32bd4ca29d7c0087c10e18c87ac8a6746516df4 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Send ds4 output reports on output end-pointRoderick Colenbrander
Add a CRC value to each output report. This removes the need for the 'no output reports on interrupt end-point' quirk. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit e7ef53adbf47734e90f9fd6e2a7a57df6f1fbc6b) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I5ac1c999b5f2253ae2ef1ceaa9531180a752d4d3 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Perform CRC check on bluetooth input packetsRoderick Colenbrander
Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 49b9ca6c6c361a19d223ff84bd0ff871c01b528a) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I433db7acd8a8e96d4c859e1c7df2abc7d8136085 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Adjust HID report size name definitionsRoderick Colenbrander
Put the report type (feature / output) in the report size definitions. This prevents name collisions later on for other different reports, which use the same report id, but have a different size. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 2c159de05082a70d3b3e75d8e167f4b5ca996405) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I00ce66a3bbec824503daa6c5affd2e4d2ab4a334 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Fix race condition in sony_probeRoderick Colenbrander
Early on the sony_probe function calls hid_hw_start to start the hardware. Afterwards it issues some hardware requests, initializes other functionality like Force Feedback, power classes and others. However by the time hid_hw_start returns, the device nodes have already been created, which leads to a race condition by user space applications which may detect the device prior to completion of initialization. We have observed this problem many times, this patch fixes the problem. This patch moves most of sony_probe to sony_input_configured, which is called prior to device registration. This fixes the race condition and the same approach is used in other HID drivers. Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit e1bc84d0071f59c8b38232e2cb093c47c47e4f9f) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: If8ea300e33413de73aa8ae1bd95f64c810edae58 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Update copyright and add Dualshock 4 rate control noteFrank Praznik
Update the copyright notice with the current year and add a note about values for controlling the Dualshock 4 reporting rate. Processing reports at the default full rate of 1000hz can be too demanding for some low-power embedded processors so noting alternate values for people working with this hardware can be useful. Thanks to Rostislav Pehlivanov for finding these values. Signed-off-by: Frank Praznik <frank.praznik@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit c4425c8f26aad2b49c5959fad277c9d109fb8ca3) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: I65a91d4583662c09253595f7486246a7fe7ca0e0 Signed-off-by: Siarhei Vishniakou <svv@google.com>
2019-11-07UPSTREAM: HID: sony: Defer the initial USB Sixaxis output reportFrank Praznik
When initially connected via USB the Sixaxis isn't fully initialized until the PS logo button is pressed and won't send any input reports nor will any state set by output reports be retained. This adds a 'defer_initialization' flag to the sony_sc struct which, when set, will delay sending any output reports until the first input report has arrived. This flag is used with the USB Sixaxis to ensure that any state sent will persist since, until the PS button is pushed, any changes sent to the controller via an output report will be lost after a couple of seconds. The initial state of the controller is still configured at the time of the initial connection and won't be internally modified after that, so any state set by the user between that time and the recepit of the first input report won't be lost. Signed-off-by: Frank Praznik <frank.praznik@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit 2a2429327711558aa23fd73d770b6fd5e0d10de7) Bug: 111431828 Signed-off-by: Kim Low <kim-huei.low@sony.com> Change-Id: Icf7e4903af38d7a16e0216f7c961f16aa0b7208b Signed-off-by: Siarhei Vishniakou <svv@google.com>