mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 10:31:33 -04:00
Merge branch 'for-7.3/apple' into for-linus
- backlight fixes and improvements (Andre Eikmeyer)
This commit is contained in:
@@ -91,6 +91,9 @@ struct apple_sc_backlight {
|
||||
struct hid_device *hdev;
|
||||
};
|
||||
|
||||
/* T2 VHCI re-enumerates the internal keyboard across system resume. */
|
||||
static int apple_backlight_resume_brightness = -1;
|
||||
|
||||
struct apple_backlight_config_report {
|
||||
u8 report_id;
|
||||
u8 version;
|
||||
@@ -827,6 +830,7 @@ static int apple_backlight_led_set(struct led_classdev *led_cdev,
|
||||
static int apple_backlight_init(struct hid_device *hdev)
|
||||
{
|
||||
int ret;
|
||||
int brightness;
|
||||
struct apple_sc *asc = hid_get_drvdata(hdev);
|
||||
struct apple_backlight_config_report *rep;
|
||||
|
||||
@@ -859,16 +863,23 @@ static int apple_backlight_init(struct hid_device *hdev)
|
||||
}
|
||||
|
||||
asc->backlight->hdev = hdev;
|
||||
asc->backlight->cdev.name = "apple::kbd_backlight";
|
||||
asc->backlight->cdev.name = ":white:" LED_FUNCTION_KBD_BACKLIGHT;
|
||||
asc->backlight->cdev.max_brightness = rep->backlight_on_max;
|
||||
asc->backlight->cdev.brightness_set_blocking = apple_backlight_led_set;
|
||||
asc->backlight->cdev.flags = LED_CORE_SUSPENDRESUME;
|
||||
/* VHCI re-enumeration restores the cached brightness in the next probe. */
|
||||
|
||||
ret = apple_backlight_set(hdev, 0, 0);
|
||||
brightness = READ_ONCE(apple_backlight_resume_brightness);
|
||||
if (brightness < 0)
|
||||
brightness = LED_OFF;
|
||||
else
|
||||
brightness = min_t(int, brightness, rep->backlight_on_max);
|
||||
|
||||
ret = apple_backlight_set(hdev, brightness, 0);
|
||||
if (ret < 0) {
|
||||
hid_err(hdev, "backlight set request failed: %d\n", ret);
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
asc->backlight->cdev.brightness = brightness;
|
||||
|
||||
ret = devm_led_classdev_register(&hdev->dev, &asc->backlight->cdev);
|
||||
|
||||
@@ -1001,6 +1012,9 @@ static void apple_remove(struct hid_device *hdev)
|
||||
|
||||
if (asc->quirks & APPLE_RDESC_BATTERY)
|
||||
timer_delete_sync(&asc->battery_timer);
|
||||
if (asc->backlight)
|
||||
WRITE_ONCE(apple_backlight_resume_brightness,
|
||||
asc->backlight->cdev.brightness);
|
||||
|
||||
hid_hw_stop(hdev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user