diff options
author | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-09-11 04:34:46 -0300 |
---|---|---|
committer | André Fabian Silva Delgado <emulatorman@parabola.nu> | 2016-09-11 04:34:46 -0300 |
commit | 863981e96738983919de841ec669e157e6bdaeb0 (patch) | |
tree | d6d89a12e7eb8017837c057935a2271290907f76 /drivers/acpi/acpi_video.c | |
parent | 8dec7c70575785729a6a9e6719a955e9c545bcab (diff) |
Linux-libre 4.7.1-gnupck-4.7.1-gnu
Diffstat (limited to 'drivers/acpi/acpi_video.c')
-rw-r--r-- | drivers/acpi/acpi_video.c | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 4361bc98e..c1d138e12 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c @@ -191,19 +191,6 @@ struct acpi_video_device_cap { u8 _DDC:1; /* Return the EDID for this device */ }; -struct acpi_video_brightness_flags { - u8 _BCL_no_ac_battery_levels:1; /* no AC/Battery levels in _BCL */ - u8 _BCL_reversed:1; /* _BCL package is in a reversed order */ - u8 _BQC_use_index:1; /* _BQC returns an index value */ -}; - -struct acpi_video_device_brightness { - int curr; - int count; - int *levels; - struct acpi_video_brightness_flags flags; -}; - struct acpi_video_device { unsigned long device_id; struct acpi_video_device_flags flags; @@ -325,7 +312,7 @@ static const struct thermal_cooling_device_ops video_cooling_ops = { */ static int -acpi_video_device_lcd_query_levels(struct acpi_video_device *device, +acpi_video_device_lcd_query_levels(acpi_handle handle, union acpi_object **levels) { int status; @@ -335,7 +322,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, *levels = NULL; - status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer); + status = acpi_evaluate_object(handle, "_BCL", NULL, &buffer); if (!ACPI_SUCCESS(status)) return status; obj = (union acpi_object *)buffer.pointer; @@ -766,36 +753,29 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device, return 0; } - -/* - * Arg: - * device : video output device (LCD, CRT, ..) - * - * Return Value: - * Maximum brightness level - * - * Allocate and initialize device->brightness. - */ - -static int -acpi_video_init_brightness(struct acpi_video_device *device) +int acpi_video_get_levels(struct acpi_device *device, + struct acpi_video_device_brightness **dev_br, + int *pmax_level) { union acpi_object *obj = NULL; int i, max_level = 0, count = 0, level_ac_battery = 0; - unsigned long long level, level_old; union acpi_object *o; struct acpi_video_device_brightness *br = NULL; - int result = -EINVAL; + int result = 0; u32 value; - if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) { + if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device->handle, + &obj))) { ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available " "LCD brightness level\n")); + result = -ENODEV; goto out; } - if (obj->package.count < 2) + if (obj->package.count < 2) { + result = -EINVAL; goto out; + } br = kzalloc(sizeof(*br), GFP_KERNEL); if (!br) { @@ -861,6 +841,40 @@ acpi_video_init_brightness(struct acpi_video_device *device) "Found unordered _BCL package")); br->count = count; + *dev_br = br; + if (pmax_level) + *pmax_level = max_level; + +out: + kfree(obj); + return result; +out_free: + kfree(br); + goto out; +} +EXPORT_SYMBOL(acpi_video_get_levels); + +/* + * Arg: + * device : video output device (LCD, CRT, ..) + * + * Return Value: + * Maximum brightness level + * + * Allocate and initialize device->brightness. + */ + +static int +acpi_video_init_brightness(struct acpi_video_device *device) +{ + int i, max_level = 0; + unsigned long long level, level_old; + struct acpi_video_device_brightness *br = NULL; + int result = -EINVAL; + + result = acpi_video_get_levels(device->dev, &br, &max_level); + if (result) + return result; device->brightness = br; /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ @@ -903,17 +917,13 @@ set_level: goto out_free_levels; ACPI_DEBUG_PRINT((ACPI_DB_INFO, - "found %d brightness levels\n", count - 2)); - kfree(obj); - return result; + "found %d brightness levels\n", br->count - 2)); + return 0; out_free_levels: kfree(br->levels); -out_free: kfree(br); -out: device->brightness = NULL; - kfree(obj); return result; } @@ -1730,7 +1740,7 @@ static void acpi_video_run_bcl_for_osi(struct acpi_video_bus *video) mutex_lock(&video->device_list_lock); list_for_each_entry(dev, &video->video_device_list, entry) { - if (!acpi_video_device_lcd_query_levels(dev, &levels)) + if (!acpi_video_device_lcd_query_levels(dev->dev->handle, &levels)) kfree(levels); } mutex_unlock(&video->device_list_lock); |