aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2015-12-22 13:09:48 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-12-31 21:14:51 -0500
commit90b066b15eda028ed44299f01236f8576dd8551d (patch)
tree31f5d270508137734424f5f1474d35bc86976df5
parent74bf8efb5fa6e958d2d7c7917b8bb672085ec0c6 (diff)
ACPI / video: Add a acpi_video_handles_brightness_key_presses() helper
Several drivers want to know if the acpi-video is generating key-presses for brightness change hotkeys to avoid sending double key-events to userspace for these. Currently these driver use this construct for this: if (acpi_video_get_backlight_type() == acpi_backlight_vendor) report_brightness_key_event(); This indirect way of detecting if acpi-video is active does not make the code easier to understand, and in some cases it is wrong because just because the preferred type != vendor does not mean that acpi-video is actually listening for brightness events, e.g. there may be no acpi-video bus on the system at all. This commit adds a acpi_video_handles_brightness_key_presses() helper function, making the code needing this functionality both easier to read and more correct. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/acpi_video.c12
-rw-r--r--include/acpi/video.h6
2 files changed, 18 insertions, 0 deletions
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 3405f7a41e25..2a649f3edefb 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -2072,6 +2072,18 @@ void acpi_video_unregister_backlight(void)
2072 mutex_unlock(&register_count_mutex); 2072 mutex_unlock(&register_count_mutex);
2073} 2073}
2074 2074
2075bool acpi_video_handles_brightness_key_presses(void)
2076{
2077 bool have_video_busses;
2078
2079 mutex_lock(&video_list_lock);
2080 have_video_busses = !list_empty(&video_bus_head);
2081 mutex_unlock(&video_list_lock);
2082
2083 return have_video_busses;
2084}
2085EXPORT_SYMBOL(acpi_video_handles_brightness_key_presses);
2086
2075/* 2087/*
2076 * This is kind of nasty. Hardware using Intel chipsets may require 2088 * This is kind of nasty. Hardware using Intel chipsets may require
2077 * the video opregion code to be run first in order to initialise 2089 * the video opregion code to be run first in order to initialise
diff --git a/include/acpi/video.h b/include/acpi/video.h
index c62392d9b52a..f11d342b4567 100644
--- a/include/acpi/video.h
+++ b/include/acpi/video.h
@@ -2,6 +2,7 @@
2#define __ACPI_VIDEO_H 2#define __ACPI_VIDEO_H
3 3
4#include <linux/errno.h> /* for ENODEV */ 4#include <linux/errno.h> /* for ENODEV */
5#include <linux/types.h> /* for bool */
5 6
6struct acpi_device; 7struct acpi_device;
7 8
@@ -31,6 +32,7 @@ extern int acpi_video_get_edid(struct acpi_device *device, int type,
31 int device_id, void **edid); 32 int device_id, void **edid);
32extern enum acpi_backlight_type acpi_video_get_backlight_type(void); 33extern enum acpi_backlight_type acpi_video_get_backlight_type(void);
33extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type); 34extern void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type);
35extern bool acpi_video_handles_brightness_key_presses(void);
34#else 36#else
35static inline int acpi_video_register(void) { return 0; } 37static inline int acpi_video_register(void) { return 0; }
36static inline void acpi_video_unregister(void) { return; } 38static inline void acpi_video_unregister(void) { return; }
@@ -46,6 +48,10 @@ static inline enum acpi_backlight_type acpi_video_get_backlight_type(void)
46static inline void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type) 48static inline void acpi_video_set_dmi_backlight_type(enum acpi_backlight_type type)
47{ 49{
48} 50}
51static inline bool acpi_video_handles_brightness_key_presses(void)
52{
53 return false;
54}
49#endif 55#endif
50 56
51#endif 57#endif