Skip to content

Commit 146561e

Browse files
ziyao233MingcongBai
authored andcommitted
BACKPORT: FROMLIST: platform/loongarch: laptop: Support backlight power control
loongson_laptop_turn_{on,off}_backlight() are designed for controlling power of the backlight, but they aren't really used in the driver previously. Unify these two functions since they only differ in arguments passed to ACPI method, and wire up loongson_laptop_backlight_update() to update power state of the backlight as well. Tested on TongFang L860-T2 3A5000 laptop. Signed-off-by: Yao Zi <[email protected]> Link: https://lore.kernel.org/loongarch/[email protected]/ Signed-off-by: Mingcong Bai <[email protected]>
1 parent dd2a5d6 commit 146561e

File tree

1 file changed

+19
-34
lines changed

1 file changed

+19
-34
lines changed

drivers/platform/loongarch/loongson-laptop.c

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ static struct input_dev *generic_inputdev;
5656
static acpi_handle hotkey_handle;
5757
static struct key_entry hotkey_keycode_map[GENERIC_HOTKEY_MAP_MAX];
5858

59-
int loongson_laptop_turn_on_backlight(void);
60-
int loongson_laptop_turn_off_backlight(void);
6159
static int loongson_laptop_backlight_update(struct backlight_device *bd);
6260

6361
/* 2. ACPI Helpers and device model */
@@ -354,6 +352,22 @@ static int ec_backlight_level(u8 level)
354352
return level;
355353
}
356354

355+
static int ec_backlight_set_power(bool state)
356+
{
357+
int status;
358+
union acpi_object arg0 = { ACPI_TYPE_INTEGER };
359+
struct acpi_object_list args = { 1, &arg0 };
360+
361+
arg0.integer.value = state;
362+
status = acpi_evaluate_object(NULL, "\\BLSW", &args, NULL);
363+
if (ACPI_FAILURE(status)) {
364+
pr_info("Loongson lvds error: 0x%x\n", status);
365+
return -EIO;
366+
}
367+
368+
return 0;
369+
}
370+
357371
static int loongson_laptop_backlight_update(struct backlight_device *bd)
358372
{
359373
int lvl = ec_backlight_level(bd->props.brightness);
@@ -363,6 +377,8 @@ static int loongson_laptop_backlight_update(struct backlight_device *bd)
363377
if (ec_set_brightness(lvl))
364378
return -EIO;
365379

380+
ec_backlight_set_power(bd->props.power == BACKLIGHT_POWER_ON ? true : false);
381+
366382
return 0;
367383
}
368384

@@ -394,6 +410,7 @@ static int laptop_backlight_register(void)
394410

395411
props.brightness = ec_get_brightness();
396412
props.max_brightness = status;
413+
props.power = BACKLIGHT_POWER_ON;
397414
props.type = BACKLIGHT_PLATFORM;
398415

399416
backlight_device_register("loongson_laptop",
@@ -402,38 +419,6 @@ static int laptop_backlight_register(void)
402419
return 0;
403420
}
404421

405-
int loongson_laptop_turn_on_backlight(void)
406-
{
407-
int status;
408-
union acpi_object arg0 = { ACPI_TYPE_INTEGER };
409-
struct acpi_object_list args = { 1, &arg0 };
410-
411-
arg0.integer.value = 1;
412-
status = acpi_evaluate_object(NULL, "\\BLSW", &args, NULL);
413-
if (ACPI_FAILURE(status)) {
414-
pr_info("Loongson lvds error: 0x%x\n", status);
415-
return -ENODEV;
416-
}
417-
418-
return 0;
419-
}
420-
421-
int loongson_laptop_turn_off_backlight(void)
422-
{
423-
int status;
424-
union acpi_object arg0 = { ACPI_TYPE_INTEGER };
425-
struct acpi_object_list args = { 1, &arg0 };
426-
427-
arg0.integer.value = 0;
428-
status = acpi_evaluate_object(NULL, "\\BLSW", &args, NULL);
429-
if (ACPI_FAILURE(status)) {
430-
pr_info("Loongson lvds error: 0x%x\n", status);
431-
return -ENODEV;
432-
}
433-
434-
return 0;
435-
}
436-
437422
static int __init event_init(struct generic_sub_driver *sub_driver)
438423
{
439424
int ret;

0 commit comments

Comments
 (0)