From 316f57fb3f0c83d15b7c682a7b0e0a63f31cbea5 Mon Sep 17 00:00:00 2001 From: Roderick Colenbrander Date: Sat, 29 Oct 2022 11:48:45 -0700 Subject: [PATCH] HID: playstation: make LED brightness adjustable in ps_led_register. Make the max_brightness adjustable through ps_led_info struct. This paves the way for a next DualShock4 patch to allow larger brightness values. Signed-off-by: Roderick Colenbrander Signed-off-by: Jiri Kosina --- drivers/hid/hid-playstation.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 319f400dd946..662c6f220571 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -60,6 +60,7 @@ struct ps_calibration_data { struct ps_led_info { const char *name; const char *color; + int max_brightness; enum led_brightness (*brightness_get)(struct led_classdev *cdev); int (*brightness_set)(struct led_classdev *cdev, enum led_brightness); }; @@ -703,7 +704,7 @@ static int ps_led_register(struct ps_device *ps_dev, struct led_classdev *led, return -ENOMEM; led->brightness = 0; - led->max_brightness = 1; + led->max_brightness = led_info->max_brightness; led->flags = LED_CORE_SUSPENDRESUME; led->brightness_get = led_info->brightness_get; led->brightness_set_blocking = led_info->brightness_set; @@ -1459,15 +1460,15 @@ static struct ps_device *dualsense_create(struct hid_device *hdev) int i, ret; static const struct ps_led_info player_leds_info[] = { - { LED_FUNCTION_PLAYER1, "white", dualsense_player_led_get_brightness, + { LED_FUNCTION_PLAYER1, "white", 1, dualsense_player_led_get_brightness, dualsense_player_led_set_brightness }, - { LED_FUNCTION_PLAYER2, "white", dualsense_player_led_get_brightness, + { LED_FUNCTION_PLAYER2, "white", 1, dualsense_player_led_get_brightness, dualsense_player_led_set_brightness }, - { LED_FUNCTION_PLAYER3, "white", dualsense_player_led_get_brightness, + { LED_FUNCTION_PLAYER3, "white", 1, dualsense_player_led_get_brightness, dualsense_player_led_set_brightness }, - { LED_FUNCTION_PLAYER4, "white", dualsense_player_led_get_brightness, + { LED_FUNCTION_PLAYER4, "white", 1, dualsense_player_led_get_brightness, dualsense_player_led_set_brightness }, - { LED_FUNCTION_PLAYER5, "white", dualsense_player_led_get_brightness, + { LED_FUNCTION_PLAYER5, "white", 1, dualsense_player_led_get_brightness, dualsense_player_led_set_brightness } };