diff options
author | Frederick van der Wyck <fvanderwyck@gmail.com> | 2013-07-08 17:34:56 -0400 |
---|---|---|
committer | Matthew Garrett <matthew.garrett@nebula.com> | 2013-09-05 08:51:33 -0400 |
commit | aa3b88a3a4b75c4dd17e3091280cd94538489147 (patch) | |
tree | e059257bd02423a021f13a24c5ce437dd4fa5faa | |
parent | fcb44e12d38a18f99d22ff66e739bb2f2ac762f0 (diff) |
platform samsung-q10: use ACPI instead of direct EC calls
This patch changes the Samsung Q10 backlight driver to use ACPI methods
(the same ones as triggered by the brightness up/down function keys)
instead of direct EC calls. The advantage is that the brightness setting
is not lost on shutdown.
Signed-off-by: Frederick van der Wyck <fvanderwyck@gmail.com>
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
-rw-r--r-- | drivers/platform/x86/Kconfig | 2 | ||||
-rw-r--r-- | drivers/platform/x86/samsung-q10.c | 65 |
2 files changed, 22 insertions, 45 deletions
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 36a9e6023395..e5b17b1c8398 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig | |||
@@ -764,7 +764,7 @@ config INTEL_OAKTRAIL | |||
764 | 764 | ||
765 | config SAMSUNG_Q10 | 765 | config SAMSUNG_Q10 |
766 | tristate "Samsung Q10 Extras" | 766 | tristate "Samsung Q10 Extras" |
767 | depends on SERIO_I8042 | 767 | depends on ACPI |
768 | select BACKLIGHT_CLASS_DEVICE | 768 | select BACKLIGHT_CLASS_DEVICE |
769 | ---help--- | 769 | ---help--- |
770 | This driver provides support for backlight control on Samsung Q10 | 770 | This driver provides support for backlight control on Samsung Q10 |
diff --git a/drivers/platform/x86/samsung-q10.c b/drivers/platform/x86/samsung-q10.c index 1a90b62a71c6..9d6609d0d90a 100644 --- a/drivers/platform/x86/samsung-q10.c +++ b/drivers/platform/x86/samsung-q10.c | |||
@@ -14,16 +14,12 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/platform_device.h> | 15 | #include <linux/platform_device.h> |
16 | #include <linux/backlight.h> | 16 | #include <linux/backlight.h> |
17 | #include <linux/i8042.h> | ||
18 | #include <linux/dmi.h> | 17 | #include <linux/dmi.h> |
18 | #include <acpi/acpi_drivers.h> | ||
19 | 19 | ||
20 | #define SAMSUNGQ10_BL_MAX_INTENSITY 255 | 20 | #define SAMSUNGQ10_BL_MAX_INTENSITY 7 |
21 | #define SAMSUNGQ10_BL_DEFAULT_INTENSITY 185 | ||
22 | 21 | ||
23 | #define SAMSUNGQ10_BL_8042_CMD 0xbe | 22 | static acpi_handle ec_handle; |
24 | #define SAMSUNGQ10_BL_8042_DATA { 0x89, 0x91 } | ||
25 | |||
26 | static int samsungq10_bl_brightness; | ||
27 | 23 | ||
28 | static bool force; | 24 | static bool force; |
29 | module_param(force, bool, 0); | 25 | module_param(force, bool, 0); |
@@ -33,21 +29,26 @@ MODULE_PARM_DESC(force, | |||
33 | static int samsungq10_bl_set_intensity(struct backlight_device *bd) | 29 | static int samsungq10_bl_set_intensity(struct backlight_device *bd) |
34 | { | 30 | { |
35 | 31 | ||
36 | int brightness = bd->props.brightness; | 32 | acpi_status status; |
37 | unsigned char c[3] = SAMSUNGQ10_BL_8042_DATA; | 33 | int i; |
38 | 34 | ||
39 | c[2] = (unsigned char)brightness; | 35 | for (i = 0; i < SAMSUNGQ10_BL_MAX_INTENSITY; i++) { |
40 | i8042_lock_chip(); | 36 | status = acpi_evaluate_object(ec_handle, "_Q63", NULL, NULL); |
41 | i8042_command(c, (0x30 << 8) | SAMSUNGQ10_BL_8042_CMD); | 37 | if (ACPI_FAILURE(status)) |
42 | i8042_unlock_chip(); | 38 | return -EIO; |
43 | samsungq10_bl_brightness = brightness; | 39 | } |
40 | for (i = 0; i < bd->props.brightness; i++) { | ||
41 | status = acpi_evaluate_object(ec_handle, "_Q64", NULL, NULL); | ||
42 | if (ACPI_FAILURE(status)) | ||
43 | return -EIO; | ||
44 | } | ||
44 | 45 | ||
45 | return 0; | 46 | return 0; |
46 | } | 47 | } |
47 | 48 | ||
48 | static int samsungq10_bl_get_intensity(struct backlight_device *bd) | 49 | static int samsungq10_bl_get_intensity(struct backlight_device *bd) |
49 | { | 50 | { |
50 | return samsungq10_bl_brightness; | 51 | return bd->props.brightness; |
51 | } | 52 | } |
52 | 53 | ||
53 | static const struct backlight_ops samsungq10_bl_ops = { | 54 | static const struct backlight_ops samsungq10_bl_ops = { |
@@ -55,28 +56,6 @@ static const struct backlight_ops samsungq10_bl_ops = { | |||
55 | .update_status = samsungq10_bl_set_intensity, | 56 | .update_status = samsungq10_bl_set_intensity, |
56 | }; | 57 | }; |
57 | 58 | ||
58 | #ifdef CONFIG_PM_SLEEP | ||
59 | static int samsungq10_suspend(struct device *dev) | ||
60 | { | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static int samsungq10_resume(struct device *dev) | ||
65 | { | ||
66 | |||
67 | struct backlight_device *bd = dev_get_drvdata(dev); | ||
68 | |||
69 | samsungq10_bl_set_intensity(bd); | ||
70 | return 0; | ||
71 | } | ||
72 | #else | ||
73 | #define samsungq10_suspend NULL | ||
74 | #define samsungq10_resume NULL | ||
75 | #endif | ||
76 | |||
77 | static SIMPLE_DEV_PM_OPS(samsungq10_pm_ops, | ||
78 | samsungq10_suspend, samsungq10_resume); | ||
79 | |||
80 | static int samsungq10_probe(struct platform_device *pdev) | 59 | static int samsungq10_probe(struct platform_device *pdev) |
81 | { | 60 | { |
82 | 61 | ||
@@ -93,9 +72,6 @@ static int samsungq10_probe(struct platform_device *pdev) | |||
93 | 72 | ||
94 | platform_set_drvdata(pdev, bd); | 73 | platform_set_drvdata(pdev, bd); |
95 | 74 | ||
96 | bd->props.brightness = SAMSUNGQ10_BL_DEFAULT_INTENSITY; | ||
97 | samsungq10_bl_set_intensity(bd); | ||
98 | |||
99 | return 0; | 75 | return 0; |
100 | } | 76 | } |
101 | 77 | ||
@@ -104,9 +80,6 @@ static int samsungq10_remove(struct platform_device *pdev) | |||
104 | 80 | ||
105 | struct backlight_device *bd = platform_get_drvdata(pdev); | 81 | struct backlight_device *bd = platform_get_drvdata(pdev); |
106 | 82 | ||
107 | bd->props.brightness = SAMSUNGQ10_BL_DEFAULT_INTENSITY; | ||
108 | samsungq10_bl_set_intensity(bd); | ||
109 | |||
110 | backlight_device_unregister(bd); | 83 | backlight_device_unregister(bd); |
111 | 84 | ||
112 | return 0; | 85 | return 0; |
@@ -116,7 +89,6 @@ static struct platform_driver samsungq10_driver = { | |||
116 | .driver = { | 89 | .driver = { |
117 | .name = KBUILD_MODNAME, | 90 | .name = KBUILD_MODNAME, |
118 | .owner = THIS_MODULE, | 91 | .owner = THIS_MODULE, |
119 | .pm = &samsungq10_pm_ops, | ||
120 | }, | 92 | }, |
121 | .probe = samsungq10_probe, | 93 | .probe = samsungq10_probe, |
122 | .remove = samsungq10_remove, | 94 | .remove = samsungq10_remove, |
@@ -172,6 +144,11 @@ static int __init samsungq10_init(void) | |||
172 | if (!force && !dmi_check_system(samsungq10_dmi_table)) | 144 | if (!force && !dmi_check_system(samsungq10_dmi_table)) |
173 | return -ENODEV; | 145 | return -ENODEV; |
174 | 146 | ||
147 | ec_handle = ec_get_handle(); | ||
148 | |||
149 | if (!ec_handle) | ||
150 | return -ENODEV; | ||
151 | |||
175 | samsungq10_device = platform_create_bundle(&samsungq10_driver, | 152 | samsungq10_device = platform_create_bundle(&samsungq10_driver, |
176 | samsungq10_probe, | 153 | samsungq10_probe, |
177 | NULL, 0, NULL, 0); | 154 | NULL, 0, NULL, 0); |