Commit 05950094 authored by Aaron Lu's avatar Aaron Lu Committed by Rafael J. Wysocki

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: default avatarAaron Lu <aaron.lu@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 01c3664d
...@@ -191,19 +191,6 @@ struct acpi_video_device_cap { ...@@ -191,19 +191,6 @@ struct acpi_video_device_cap {
u8 _DDC:1; /* Return the EDID for this device */ 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 { struct acpi_video_device {
unsigned long device_id; unsigned long device_id;
struct acpi_video_device_flags flags; struct acpi_video_device_flags flags;
...@@ -325,7 +312,7 @@ static const struct thermal_cooling_device_ops video_cooling_ops = { ...@@ -325,7 +312,7 @@ static const struct thermal_cooling_device_ops video_cooling_ops = {
*/ */
static int 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) union acpi_object **levels)
{ {
int status; int status;
...@@ -335,7 +322,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, ...@@ -335,7 +322,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device,
*levels = NULL; *levels = NULL;
status = acpi_evaluate_object(device->dev->handle, "_BCL", NULL, &buffer); status = acpi_evaluate_object(handle, "_BCL", NULL, &buffer);
if (!ACPI_SUCCESS(status)) if (!ACPI_SUCCESS(status))
return status; return status;
obj = (union acpi_object *)buffer.pointer; obj = (union acpi_object *)buffer.pointer;
...@@ -766,36 +753,28 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device, ...@@ -766,36 +753,28 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,
return 0; return 0;
} }
int acpi_video_get_levels(struct acpi_device *device,
/* struct acpi_video_device_brightness **dev_br)
* 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)
{ {
union acpi_object *obj = NULL; union acpi_object *obj = NULL;
int i, max_level = 0, count = 0, level_ac_battery = 0; int i, max_level = 0, count = 0, level_ac_battery = 0;
unsigned long long level, level_old;
union acpi_object *o; union acpi_object *o;
struct acpi_video_device_brightness *br = NULL; struct acpi_video_device_brightness *br = NULL;
int result = -EINVAL; int result = 0;
u32 value; 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 " ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
"LCD brightness level\n")); "LCD brightness level\n"));
result = -ENODEV;
goto out; goto out;
} }
if (obj->package.count < 2) if (obj->package.count < 2) {
result = -EINVAL;
goto out; goto out;
}
br = kzalloc(sizeof(*br), GFP_KERNEL); br = kzalloc(sizeof(*br), GFP_KERNEL);
if (!br) { if (!br) {
...@@ -861,6 +840,38 @@ acpi_video_init_brightness(struct acpi_video_device *device) ...@@ -861,6 +840,38 @@ acpi_video_init_brightness(struct acpi_video_device *device)
"Found unordered _BCL package")); "Found unordered _BCL package"));
br->count = count; br->count = count;
*dev_br = br;
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);
if (result)
return result;
device->brightness = br; device->brightness = br;
/* _BQC uses INDEX while _BCL uses VALUE in some laptops */ /* _BQC uses INDEX while _BCL uses VALUE in some laptops */
...@@ -903,17 +914,13 @@ acpi_video_init_brightness(struct acpi_video_device *device) ...@@ -903,17 +914,13 @@ acpi_video_init_brightness(struct acpi_video_device *device)
goto out_free_levels; goto out_free_levels;
ACPI_DEBUG_PRINT((ACPI_DB_INFO, ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"found %d brightness levels\n", count - 2)); "found %d brightness levels\n", br->count - 2));
kfree(obj); return 0;
return result;
out_free_levels: out_free_levels:
kfree(br->levels); kfree(br->levels);
out_free:
kfree(br); kfree(br);
out:
device->brightness = NULL; device->brightness = NULL;
kfree(obj);
return result; return result;
} }
......
...@@ -4,6 +4,19 @@ ...@@ -4,6 +4,19 @@
#include <linux/errno.h> /* for ENODEV */ #include <linux/errno.h> /* for ENODEV */
#include <linux/types.h> /* for bool */ #include <linux/types.h> /* for bool */
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_device; struct acpi_device;
#define ACPI_VIDEO_CLASS "video" #define ACPI_VIDEO_CLASS "video"
...@@ -37,6 +50,8 @@ extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type); ...@@ -37,6 +50,8 @@ extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type);
* may change over time and should not be cached. * may change over time and should not be cached.
*/ */
extern bool acpi_video_handles_brightness_key_presses(void); extern bool acpi_video_handles_brightness_key_presses(void);
extern int acpi_video_get_levels(struct acpi_device *device,
struct acpi_video_device_brightness **dev_br);
#else #else
static inline int acpi_video_register(void) { return 0; } static inline int acpi_video_register(void) { return 0; }
static inline void acpi_video_unregister(void) { return; } static inline void acpi_video_unregister(void) { return; }
...@@ -56,6 +71,11 @@ static inline bool acpi_video_handles_brightness_key_presses(void) ...@@ -56,6 +71,11 @@ static inline bool acpi_video_handles_brightness_key_presses(void)
{ {
return false; return false;
} }
static int acpi_video_get_levels(struct acpi_device *device,
struct acpi_video_device_brightness **dev_br)
{
return -ENODEV;
}
#endif #endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment