diff options
author | Aaron Lu <aaron.lu@intel.com> | 2016-04-27 08:45:04 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-05-04 17:41:14 -0400 |
commit | 059500940defe285222d3b189b366dfe7f299cae (patch) | |
tree | e2e3ba34a6c7460821d45aac319d26481563c9ca /drivers/acpi | |
parent | 01c3664de62f89f6777e59173ad8e20b5a4c267f (diff) |
ACPI/video: export acpi_video_get_levels
The acpi_video_get_levels is useful for other drivers, i.e. the
to-be-added int3406 thermal driver, so export it.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/acpi_video.c | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 4361bc98ef4c..3d5b8a099351 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c | |||
@@ -191,19 +191,6 @@ struct acpi_video_device_cap { | |||
191 | u8 _DDC:1; /* Return the EDID for this device */ | 191 | u8 _DDC:1; /* Return the EDID for this device */ |
192 | }; | 192 | }; |
193 | 193 | ||
194 | struct acpi_video_brightness_flags { | ||
195 | u8 _BCL_no_ac_battery_levels:1; /* no AC/Battery levels in _BCL */ | ||
196 | u8 _BCL_reversed:1; /* _BCL package is in a reversed order */ | ||
197 | u8 _BQC_use_index:1; /* _BQC returns an index value */ | ||
198 | }; | ||
199 | |||
200 | struct acpi_video_device_brightness { | ||
201 | int curr; | ||
202 | int count; | ||
203 | int *levels; | ||
204 | struct acpi_video_brightness_flags flags; | ||
205 | }; | ||
206 | |||
207 | struct acpi_video_device { | 194 | struct acpi_video_device { |
208 | unsigned long device_id; | 195 | unsigned long device_id; |
209 | struct acpi_video_device_flags flags; | 196 | struct acpi_video_device_flags flags; |
@@ -325,7 +312,7 @@ static const struct thermal_cooling_device_ops video_cooling_ops = { | |||
325 | */ | 312 | */ |
326 | 313 | ||
327 | static int | 314 | static int |
328 | acpi_video_device_lcd_query_levels(struct acpi_video_device *device, | 315 | acpi_video_device_lcd_query_levels(acpi_handle handle, |
329 | union acpi_object **levels) | 316 | union acpi_object **levels) |
330 | { | 317 | { |
331 | int status; | 318 | int status; |
@@ -335,7 +322,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, | |||
335 | 322 | ||
336 | *levels = NULL; | 323 | *levels = NULL; |
337 | 324 | ||
338 | status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer); | 325 | status = acpi_evaluate_object(handle, "_BCL", NULL, &buffer); |
339 | if (!ACPI_SUCCESS(status)) | 326 | if (!ACPI_SUCCESS(status)) |
340 | return status; | 327 | return status; |
341 | obj = (union acpi_object *)buffer.pointer; | 328 | obj = (union acpi_object *)buffer.pointer; |
@@ -766,36 +753,28 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device, | |||
766 | return 0; | 753 | return 0; |
767 | } | 754 | } |
768 | 755 | ||
769 | 756 | int acpi_video_get_levels(struct acpi_device *device, | |
770 | /* | 757 | struct acpi_video_device_brightness **dev_br) |
771 | * Arg: | ||
772 | * device : video output device (LCD, CRT, ..) | ||
773 | * | ||
774 | * Return Value: | ||
775 | * Maximum brightness level | ||
776 | * | ||
777 | * Allocate and initialize device->brightness. | ||
778 | */ | ||
779 | |||
780 | static int | ||
781 | acpi_video_init_brightness(struct acpi_video_device *device) | ||
782 | { | 758 | { |
783 | union acpi_object *obj = NULL; | 759 | union acpi_object *obj = NULL; |
784 | int i, max_level = 0, count = 0, level_ac_battery = 0; | 760 | int i, max_level = 0, count = 0, level_ac_battery = 0; |
785 | unsigned long long level, level_old; | ||
786 | union acpi_object *o; | 761 | union acpi_object *o; |
787 | struct acpi_video_device_brightness *br = NULL; | 762 | struct acpi_video_device_brightness *br = NULL; |
788 | int result = -EINVAL; | 763 | int result = 0; |
789 | u32 value; | 764 | u32 value; |
790 | 765 | ||
791 | if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) { | 766 | if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device->handle, |
767 | &obj))) { | ||
792 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available " | 768 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available " |
793 | "LCD brightness level\n")); | 769 | "LCD brightness level\n")); |
770 | result = -ENODEV; | ||
794 | goto out; | 771 | goto out; |
795 | } | 772 | } |
796 | 773 | ||
797 | if (obj->package.count < 2) | 774 | if (obj->package.count < 2) { |
775 | result = -EINVAL; | ||
798 | goto out; | 776 | goto out; |
777 | } | ||
799 | 778 | ||
800 | br = kzalloc(sizeof(*br), GFP_KERNEL); | 779 | br = kzalloc(sizeof(*br), GFP_KERNEL); |
801 | if (!br) { | 780 | if (!br) { |
@@ -861,6 +840,38 @@ acpi_video_init_brightness(struct acpi_video_device *device) | |||
861 | "Found unordered _BCL package")); | 840 | "Found unordered _BCL package")); |
862 | 841 | ||
863 | br->count = count; | 842 | br->count = count; |
843 | *dev_br = br; | ||
844 | |||
845 | out: | ||
846 | kfree(obj); | ||
847 | return result; | ||
848 | out_free: | ||
849 | kfree(br); | ||
850 | goto out; | ||
851 | } | ||
852 | EXPORT_SYMBOL(acpi_video_get_levels); | ||
853 | |||
854 | /* | ||
855 | * Arg: | ||
856 | * device : video output device (LCD, CRT, ..) | ||
857 | * | ||
858 | * Return Value: | ||
859 | * Maximum brightness level | ||
860 | * | ||
861 | * Allocate and initialize device->brightness. | ||
862 | */ | ||
863 | |||
864 | static int | ||
865 | acpi_video_init_brightness(struct acpi_video_device *device) | ||
866 | { | ||
867 | int i, max_level = 0; | ||
868 | unsigned long long level, level_old; | ||
869 | struct acpi_video_device_brightness *br = NULL; | ||
870 | int result = -EINVAL; | ||
871 | |||
872 | result = acpi_video_get_levels(device->dev, &br); | ||
873 | if (result) | ||
874 | return result; | ||
864 | device->brightness = br; | 875 | device->brightness = br; |
865 | 876 | ||
866 | /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ | 877 | /* _BQC uses INDEX while _BCL uses VALUE in some laptops */ |
@@ -903,17 +914,13 @@ set_level: | |||
903 | goto out_free_levels; | 914 | goto out_free_levels; |
904 | 915 | ||
905 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 916 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
906 | "found %d brightness levels\n", count - 2)); | 917 | "found %d brightness levels\n", br->count - 2)); |
907 | kfree(obj); | 918 | return 0; |
908 | return result; | ||
909 | 919 | ||
910 | out_free_levels: | 920 | out_free_levels: |
911 | kfree(br->levels); | 921 | kfree(br->levels); |
912 | out_free: | ||
913 | kfree(br); | 922 | kfree(br); |
914 | out: | ||
915 | device->brightness = NULL; | 923 | device->brightness = NULL; |
916 | kfree(obj); | ||
917 | return result; | 924 | return result; |
918 | } | 925 | } |
919 | 926 | ||