Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: add new LED_FUNCTION_PLAYER for player LEDs for game controllers.

Player LEDs are commonly found on game controllers from Nintendo and Sony
to indicate a player ID across a number of LEDs. For example, "Player 2"
might be indicated as "-x--" on a device with 4 LEDs where "x" means on.

This patch introduces LED_FUNCTION_PLAYER1-5 defines to properly indicate
player LEDs from the kernel. Until now there was no good standard, which
resulted in inconsistent behavior across xpad, hid-sony, hid-wiimote and
other drivers. Moving forward new drivers should use LED_FUNCTION_PLAYERx.

Note: management of Player IDs is left to user space, though a kernel
driver may pick a default value.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Roderick Colenbrander and committed by
Jiri Kosina
61177c08 fc97b4d6

+21
+14
Documentation/leds/well-known-leds.txt
··· 16 16 17 17 Notice there's a list of functions in include/dt-bindings/leds/common.h . 18 18 19 + * Gamepads and joysticks 20 + 21 + Game controllers may feature LEDs to indicate a player number. This is commonly 22 + used on game consoles in which multiple controllers can be connected to a system. 23 + The "player LEDs" are then programmed with a pattern to indicate a particular 24 + player. For example, a game controller with 4 LEDs, may be programmed with "x---" 25 + to indicate player 1, "-x--" to indicate player 2 etcetera where "x" means on. 26 + Input drivers can utilize the LED class to expose the individual player LEDs 27 + of a game controller using the function "player". 28 + Note: tracking and management of Player IDs is the responsibility of user space, 29 + though drivers may pick a default value. 30 + 31 + Good: "input*:*:player-{1,2,3,4,5} 32 + 19 33 * Keyboards 20 34 21 35 Good: "input*:*:capslock"
+7
include/dt-bindings/leds/common.h
··· 60 60 #define LED_FUNCTION_MICMUTE "micmute" 61 61 #define LED_FUNCTION_MUTE "mute" 62 62 63 + /* Used for player LEDs as found on game controllers from e.g. Nintendo, Sony. */ 64 + #define LED_FUNCTION_PLAYER1 "player-1" 65 + #define LED_FUNCTION_PLAYER2 "player-2" 66 + #define LED_FUNCTION_PLAYER3 "player-3" 67 + #define LED_FUNCTION_PLAYER4 "player-4" 68 + #define LED_FUNCTION_PLAYER5 "player-5" 69 + 63 70 /* Miscelleaus functions. Use functions above if you can. */ 64 71 #define LED_FUNCTION_ACTIVITY "activity" 65 72 #define LED_FUNCTION_ALARM "alarm"