aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-lg4ff.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2015-05-07HID: hid-lg4ff: Allow the driver to continue without sysfs interfaceMichal Malý1-4/+3
Allow the driver to continue without sysfs interface. Instead of bailing out allow the driver to continue in a degraded mode. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Constify members of lg4ff_device_entryMichal Malý1-15/+39
Constify those members of lg4ff_device_entry struct whose value is not supposed to change. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Store pointer to the output HID report struct in the device entry structMichal Malý1-35/+32
Store pointer to the output HID report struct in the device entry struct. This eliminates the need to look the HID report struct up every time it is needed. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Protect concurrent access to output HID reportMichal Malý1-0/+110
Protect concurrent access to output HID report with a spinlock. The HID report structure used to submit commands to wheels is shared amongst all functions that need to do so and some of these functions can be executed in parallel. Additionally, lg4ff_play() can be called from interrupt context by ff-memless module. Locking is necessary to prevent sending bogus data to the wheels. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Stop the hid device from lg4ffMichal Malý1-0/+2
Stop the hid device from lg4ff. Originally hid-lg was responsible for stopping of the device. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Make lg4ff_wheel_data a separate structureMichal Malý1-78/+88
Make lg4ff_wheel_data a separate structure stored within lg4ff_device_entry. Adjust the initialization process accordingly. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Update a warning messageMichal Malý1-2/+3
Update a warning message for a case where device is incorrectly flagged to be handled by hid-lg4ff in hid-lg. The original warning message was highly misleading. This warning can be triggered only if a device is flagged to be handled by hid-lg4ff in hid-lg but hid-lg4ff lacks support for such device. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Explicit casts from void * are not necessaryMichal Malý1-2/+2
Explicit casts from void * are not necessary. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Remove unused variable from the "lg4ff_device_entry" struct.Michal Malý1-1/+0
Remove unused variable from the "lg4ff_device_entry" struct. This is a leftover from times where hid_get|set_drvdata() was not available to hid-lg4ff so it had to keep track of the devices it managed by itself. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Replace DEVICE_ATTR_RW with DEVICE_ATTR to have all internal functions prefixed with "lg4ff_"Michal Malý1-6/+6
Replace DEVICE_ATTR_RW with DEVICE_ATTR to have all internal functions prefixed with "lg4ff_". All internal functions should be prefixed with just "lg4ff_". Usage of DEVICE_ATTR_RW breaks this scheme because it expects the functions' names to match the name of the respective sysfs entry. This partially reverts "2f1cec3250e38609bf9252db52dbbe61603c04a7" Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Remove "hid_" prefix from some functions' namesMichal Malý1-14/+14
Remove "hid_" prefix from some functions' names. All internal functions of hid-lg4ff should be prefixed with just "lg4ff_" Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-05-07HID: hid-lg4ff: Remove double underscore prefix from numeric typesMichal Malý1-26/+26
Remove double underscore prefix from numeric types. This code will never be used outside the kernel so the prefixes are unnecessary. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-18HID: hid-lg4ff: Fix "undefined reference" build issue with CONFIG_USB disabledMichal Malý1-8/+9
Fix "undefined reference" build issue with CONFIG_USB disabled; make the driver use generic HID API instead. Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-18HID: hid-lg4ff: Allow switching of Logitech gaming wheels between compatibility modesMichal Malý1-29/+175
Allow switching of Logitech gaming wheels between available compatibility modes through sysfs. This only applies to multimode wheels. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Tested-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-18HID: hid-lg4ff: Introduce a module parameter to disable automatic switch of compatibility modeMichal Malý1-1/+3
Introduce a module parameter to disable automatic switch of Logitech gaming wheels from compatibility to native mode. This only applies to multimode wheels. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Tested-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-18HID: hid-lg4ff: Export the real wheel model and supported alternate modesMichal Malý1-7/+198
Display the real wheel model and supported alternate modes through sysfs. This applies only to multimode wheels. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Tested-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-02-18HID: hid-lg4ff: Identify Logitech gaming wheels in compatibility modesMichal Malý1-76/+190
Identify Logitech gaming wheels in compatibility modes accordingly to Logitech specifications. Logitech specification contains a general method of identifying various models of their gaming wheels while they are in "compatibility" mode. This patch implements the method instead of checking against known values of bcdDevice. Handling of the mode switch upon initialization is also adjusted so that the driver does not have to go through the entire initialization routine because the wheels are set to perform a USB detach before they reappear in "native" mode. Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net> Tested-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-01-19HID: hid-lg4ff: use DEVICE_ATTR_RW macroVivien Didelot1-7/+5
Use the DEVICE_ATTR_RW macro to reduce boiler plate and move the attribute declaration to get rid of function signatures. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-01-19HID: hid-lg4ff: fix sysfs attribute permissionVivien Didelot1-1/+2
There is no reason to set the range attribute executable to the user and group, and writable to the group. Fix the permission to 0644. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-08-15HID: logitech: Prevent possibility of infinite loop when using /sys interfaceSimon Wood1-2/+2
If the device data is not accessible for some reason, returning 0 will cause the call to be continuously called again as none of the string has been 'consumed'. Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2014-05-14drivers/hid/hid-lg4ff.c: avoid world-writable sysfs files.Rusty Russell1-1/+1
In line with practice for module parameters, we're adding a build-time check that sysfs files aren't world-writable. Cc: Simon Wood <simon@mungewell.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2014-03-14HID: hid-lg4ff: Support new version of G27Simon Wood1-0/+2
It has been reported that there is a new hardware version of the G27 in the 'wild'. This patch add's this new revision so that it can be sent the command to switch to native mode. Reported-by: "Ivan Baldo" <ibaldo@adinet.com.uy> Tested-by: "evilcow" <evilcow93@yahoo.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-08HID:hid-lg4ff: Correct Auto-center strength for wheels other than MOMO and MOMO2Simon Wood1-0/+24
The MOMO and MOMO2 wheels have a slightly different autocenter command, and accept values in the range 0..F (rather than 0..7 for the other wheels). This patch uses the product ID to determine how to compute the strength. Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-08HID:hid-lg4ff: Initialize device properties before we touch autocentering.Simon Wood1-11/+11
Re-arrange code slightly to ensure that device properties are configured before calling auto-center command. Reported-by: Michal Malý <madcatxster@prifuk.cz> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-08HID:hid-lg4ff: ensure ConstantForce is disabled when set to 0Simon Wood1-0/+15
When 'Constant Force' is set to 0 it is not turned off completely, the wheel feels 'heavy'. This patch issues the '13 00..' command to ensure that the force in slot 1 (the Constant Force) is deactivated. Reported-by: Elias Vanderstuyft <elias.vds@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-08HID:hid-lg4ff: Switch autocentering off when strength is set to zero.Simon Wood1-0/+25
When the autocenter is set to zero, this patch issues a command to totally disable the autocenter - this results in less resistance in the wheel. Reported-by: Elias Vanderstuyft <elias.vds@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-11-08HID:hid-lg4ff: Scale autocentering force properly on Logitech wheelSimon Wood1-3/+12
Adjust the scaling and lineartity to match that of the Windows driver (from MOMO testing). Reported-by: Elias Vanderstuyft <elias.vds@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-09-13HID: LG: validate HID output report detailsKees Cook1-19/+1
A HID device could send a malicious output report that would cause the lg, lg3, and lg4 HID drivers to write beyond the output report allocation during an event, causing a heap overflow: [ 325.245240] usb 1-1: New USB device found, idVendor=046d, idProduct=c287 ... [ 414.518960] BUG kmalloc-4096 (Not tainted): Redzone overwritten Additionally, while lg2 did correctly validate the report details, it was cleaned up and shortened. CVE-2013-2893 Signed-off-by: Kees Cook <keescook@chromium.org> Cc: stable@vger.kernel.org Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-04-30Merge branches 'for-3.10/appleir', 'for-3.10/hid-debug', 'for-3.10/hid-driver-transport-cleanups', 'for-3.10/i2c-hid' and 'for-3.10/logitech' into for-linusJiri Kosina1-9/+11
2013-04-27HID: hid-lg4ff add support for new version of DFGT wheelSimon Wood1-0/+2
It has been reported that there is a new version (different USB rev) of the Logitech DFGT in the 'wild'. This patch allows the kernel to recognise this wheel and send it the command to enter native mode. Reported-by: "Denis Jovic" <djovic78@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-02-25HID: use hid_hw_request() instead of direct call to usbhidBenjamin Tissoires1-9/+9
This allows the hid drivers to be independent from the transport layer. The patch was constructed by replacing all occurences of usbhid_submit_report() by its hid_hw_request() counterpart. Then, drivers not requiring USB_HID anymore have their USB_HID dependency cleaned in the Kconfig file. Finally, few drivers still depends on USB_HID. Many of them are requiring the io wait callback. They are found in the next patch. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> For the sensor-hub part: Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2013-02-20HID: LG4FF: Remove unnecessary deadzone codeSimon Wood1-17/+0
This patch removes code which is now unnecessary for setting the fuzz/flat characterics for the logitech DFP wheel. This is now done in the previous patch by marking the wheel as a multi-axis device. Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-10-01Merge branch 'upstream' into for-linusJiri Kosina1-2/+2
Conflicts: drivers/hid/usbhid/hid-quirks.c
2012-09-25HID: lg4ff: Minor coding style fixes in lg4ff and hid-lgMichal Malý1-2/+2
Fixes a couple of minor coding style issues. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-09-25HID: hid-lg4ff: Set absolute axes parametes on DFPMichal Malý1-0/+17
The lg4ff driver doesn't fill the "input_absinfo" struct so it is left with default values. Applications with rely on information in this struct therefore do not work correctly with the wheel. Other Logitech wheels probably need this fix too, but again I do not have enough information to write it. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-09-25HID: hid-lg4ff: Adjust X axis input value accordingly to selected range.Michal Malý1-0/+54
Range limiting command for the Driving Force Pro wheel is only a FF_SPRING effect so that the wheel creates resistance when the user tries to turn it past the limit. It is however possible to overpower the FFB motors quite easily which leads to the X axis value exceeding the expected limit. This confuses games which dynamically adjust calibration using the highest/lowest min and max values reported by the wheel. Joydev device driver also doesn't take in account any changes in an axis range after the joystick device is created. This patch recalculates received ABS_X axis value so it is always in <0; 16383> range where 0 is the left limit and 16383 the right limit. Logitech driver for Windows does the same thing. As for any concerns about possible loss of precision, I compared a large set of raw/adjusted values generated by "mult_frac" to values returned by the Windows driver and I got a 100% match. Other Logitech wheels will probably need a similar fix, but I currently lack the information needed to write one. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-09-25HID: hid-lg4ff: Minor code cleanup to improve readabilityMichal Malý1-57/+64
This patch replaces all occurrences of "report->field[0]->value[n]" with just "value[n]" to get rid of the lengthy trains we have now. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-09-17HID: lg4ff: Remove unnecessary casts of void pointersAxel Lin1-2/+2
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-04-23HID: hid-lg4ff: remove unused label in !LEDS_CLASS caseJiri Kosina1-2/+1
'out' label will be unused of CONFIG_LEDS_CLASS is unset. Move it into conditional block. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-04-23HID: hid-lg4ff: Update CommentsSimon Wood1-3/+4
Updated comments to say that this driver now supports all Logitech gaming wheels, and not just the WiiWheel. Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-04-23HID: hid-lg4ff: Add support for G27 LEDsSimon Wood1-1/+157
This patch adds supports for controlling the LED 'tachometer' on the G27 wheel, via the LED subsystem. The 5 LEDs are arranged from right (1=grn, 2=grn, 3=yel, 4=yel, 5=red) and 'mirrored' to the left (10 LEDs in total). Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-04-13HID: lg4ff: Take advantage of private driver dataMichal Malý1-50/+42
lg4ff now calls hid_get/set_drvdata() to read or store device configuration. Signed-off-by: Michal Malý <madcatxster@gmail.com> Tested-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-04-03HID: lg4ff: Remove sysfs iface before deallocating memoryMichal Malý1-2/+4
This patch fixes a possible race condition caused by the sysfs interface being removed after the memory used by the interface was already kfree'd. Signed-off-by: Michal Malý <madcatsxter@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-11-11HID: hid-lg4ff: Casting (void *) value returned by kmalloc is uselessThomas Meyer1-1/+1
Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14. The semantic patch that makes this change is available in scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci. Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-23HID: hid-lg4ff: add a kfree() to an error pathDan Carpenter1-2/+2
There is a small rare potential memory leak here. Also Walter Harms points out that we can do a small cleanup as well by using kstrdup(). Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-23HID: hid-lg4ff: silence sparse complaintDan Carpenter1-2/+2
Sparse complains that: drivers/hid/hid-lg4ff.c:288:44: warning: Using plain integer as NULL pointer drivers/hid/hid-lg4ff.c:311:44: warning: Using plain integer as NULL pointer Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-04HID: lg4ff - Add autocentering command accepted by Formula Force EXMichal Malý1-3/+33
The Logitech driver sends Formula Force EX wheel a different command to autocenering force. FFEX will accept the standard command used by the rest of the wheels, but it won't set the centering properly. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-04HID: lg4ff - Add range setting support and sysfs interfaceMichal Malý1-12/+220
Wheel range of certain Logitech wheels - namely Driving Force GT, Driving Force Pro, G25 and G27 can be adjusted. Minimu is 40 degrees, maximum 900. DFGT, G25 and G27 all use a common command, DFP uses another one. Range can be set from userspace by writing to "/sys/module/hid_logitech/drivers/hid:logitech/<dev>range". The driver use list to store range of each connected wheel; it's not possible to use driver_data in hid_device struct as it's already b hig-lg driver. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-04HID: lg4ff - Add support for native mode switchingMichal Malý1-0/+89
This patch allows the lg4ff driver to switch wheels to the native mode. Since this is specific to Logitech wheels only, it's handled in hid-lg4ff rather than hid-lg. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2011-08-04HID: lg4ff - Move handling of Logitech wheels to lg4ff driverMichal Malý1-22/+48
This is the first out of five patches me and Simon Wood (CC'd) have been working on. It separates the handling of Logite from the generic lgff driver and adds additional features specific for the Logitech wheels, namely - Native mode support for Driving Force GT, Driving Force Pro, G25 and G27 wheels Every Logitech wheel reports itself as generic Logitech Driving Force wheel (VID 046d, PID c294). This is done to ensu wheel will work on every USB HID-aware system even when no Logitech driver is available. It however limits the capabilit wheel - range is limited to 200 degrees, G25/G27 don't report the clutch pedal and there is only one combined axis for t brake. The switch to native mode is done via hardware-specific command which is different for each wheel. When the wheel receives such command, it simulates reconnect and reports to the OS with its actual PID. - Adjustable wheel range DFGT, DFP, G25 and G27 have variable range of the steering wheel. The range is limited by applying a maximum constant when the wheel is turned beyond the allowed range. The limit as also set by a hardware-specific command. There is a comm command for DFGT, G25 and G27 and another one for DFP. It is probably possible to use the DFP command to limit the range other Logitech wheels too, but this is not supported by the official Logitech driver for Windows. The patch adds a sysfs interface which allows for the range to be set from userspace. - Fixed autocentering command All Logitech wheels support FF_AUTOCENTER effect. The original implementation in the lgff driver didn't work well with patch fixes it. According to USB communication sniffs the Formula Force EX (pretty much rebranded original Driving Force accept the generic autocentering command, this issue is also addressed by the patch There are still some features this patch doesn't cover, but since some of them will most likely require modifications of memless driver we have decided not to include them yet. As first we decided to move the handling of Logitech wheels from hid-lgff driver to hid-lg4ff driver (originally used fo At also adds PID of Logitech Driving Force GT. Signed-off-by: Michal Malý <madcatxster@gmail.com> Signed-off-by: Simon Wood <simon@mungewell.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>