Commit aa3b88a3 authored by Frederick van der Wyck's avatar Frederick van der Wyck Committed by Matthew Garrett

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: default avatarFrederick van der Wyck <fvanderwyck@gmail.com>
Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
parent fcb44e12
...@@ -764,7 +764,7 @@ config INTEL_OAKTRAIL ...@@ -764,7 +764,7 @@ config INTEL_OAKTRAIL
config SAMSUNG_Q10 config SAMSUNG_Q10
tristate "Samsung Q10 Extras" tristate "Samsung Q10 Extras"
depends on SERIO_I8042 depends on ACPI
select BACKLIGHT_CLASS_DEVICE select BACKLIGHT_CLASS_DEVICE
---help--- ---help---
This driver provides support for backlight control on Samsung Q10 This driver provides support for backlight control on Samsung Q10
......
...@@ -14,16 +14,12 @@ ...@@ -14,16 +14,12 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/backlight.h> #include <linux/backlight.h>
#include <linux/i8042.h>
#include <linux/dmi.h> #include <linux/dmi.h>
#include <acpi/acpi_drivers.h>
#define SAMSUNGQ10_BL_MAX_INTENSITY 255 #define SAMSUNGQ10_BL_MAX_INTENSITY 7
#define SAMSUNGQ10_BL_DEFAULT_INTENSITY 185
#define SAMSUNGQ10_BL_8042_CMD 0xbe static acpi_handle ec_handle;
#define SAMSUNGQ10_BL_8042_DATA { 0x89, 0x91 }
static int samsungq10_bl_brightness;
static bool force; static bool force;
module_param(force, bool, 0); module_param(force, bool, 0);
...@@ -33,21 +29,26 @@ MODULE_PARM_DESC(force, ...@@ -33,21 +29,26 @@ MODULE_PARM_DESC(force,
static int samsungq10_bl_set_intensity(struct backlight_device *bd) static int samsungq10_bl_set_intensity(struct backlight_device *bd)
{ {
int brightness = bd->props.brightness; acpi_status status;
unsigned char c[3] = SAMSUNGQ10_BL_8042_DATA; int i;
c[2] = (unsigned char)brightness; for (i = 0; i < SAMSUNGQ10_BL_MAX_INTENSITY; i++) {
i8042_lock_chip(); status = acpi_evaluate_object(ec_handle, "_Q63", NULL, NULL);
i8042_command(c, (0x30 << 8) | SAMSUNGQ10_BL_8042_CMD); if (ACPI_FAILURE(status))
i8042_unlock_chip(); return -EIO;
samsungq10_bl_brightness = brightness; }
for (i = 0; i < bd->props.brightness; i++) {
status = acpi_evaluate_object(ec_handle, "_Q64", NULL, NULL);
if (ACPI_FAILURE(status))
return -EIO;
}
return 0; return 0;
} }
static int samsungq10_bl_get_intensity(struct backlight_device *bd) static int samsungq10_bl_get_intensity(struct backlight_device *bd)
{ {
return samsungq10_bl_brightness; return bd->props.brightness;
} }
static const struct backlight_ops samsungq10_bl_ops = { static const struct backlight_ops samsungq10_bl_ops = {
...@@ -55,28 +56,6 @@ static const struct backlight_ops samsungq10_bl_ops = { ...@@ -55,28 +56,6 @@ static const struct backlight_ops samsungq10_bl_ops = {
.update_status = samsungq10_bl_set_intensity, .update_status = samsungq10_bl_set_intensity,
}; };
#ifdef CONFIG_PM_SLEEP
static int samsungq10_suspend(struct device *dev)
{
return 0;
}
static int samsungq10_resume(struct device *dev)
{
struct backlight_device *bd = dev_get_drvdata(dev);
samsungq10_bl_set_intensity(bd);
return 0;
}
#else
#define samsungq10_suspend NULL
#define samsungq10_resume NULL
#endif
static SIMPLE_DEV_PM_OPS(samsungq10_pm_ops,
samsungq10_suspend, samsungq10_resume);
static int samsungq10_probe(struct platform_device *pdev) static int samsungq10_probe(struct platform_device *pdev)
{ {
...@@ -93,9 +72,6 @@ static int samsungq10_probe(struct platform_device *pdev) ...@@ -93,9 +72,6 @@ static int samsungq10_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, bd); platform_set_drvdata(pdev, bd);
bd->props.brightness = SAMSUNGQ10_BL_DEFAULT_INTENSITY;
samsungq10_bl_set_intensity(bd);
return 0; return 0;
} }
...@@ -104,9 +80,6 @@ static int samsungq10_remove(struct platform_device *pdev) ...@@ -104,9 +80,6 @@ static int samsungq10_remove(struct platform_device *pdev)
struct backlight_device *bd = platform_get_drvdata(pdev); struct backlight_device *bd = platform_get_drvdata(pdev);
bd->props.brightness = SAMSUNGQ10_BL_DEFAULT_INTENSITY;
samsungq10_bl_set_intensity(bd);
backlight_device_unregister(bd); backlight_device_unregister(bd);
return 0; return 0;
...@@ -116,7 +89,6 @@ static struct platform_driver samsungq10_driver = { ...@@ -116,7 +89,6 @@ static struct platform_driver samsungq10_driver = {
.driver = { .driver = {
.name = KBUILD_MODNAME, .name = KBUILD_MODNAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.pm = &samsungq10_pm_ops,
}, },
.probe = samsungq10_probe, .probe = samsungq10_probe,
.remove = samsungq10_remove, .remove = samsungq10_remove,
...@@ -172,6 +144,11 @@ static int __init samsungq10_init(void) ...@@ -172,6 +144,11 @@ static int __init samsungq10_init(void)
if (!force && !dmi_check_system(samsungq10_dmi_table)) if (!force && !dmi_check_system(samsungq10_dmi_table))
return -ENODEV; return -ENODEV;
ec_handle = ec_get_handle();
if (!ec_handle)
return -ENODEV;
samsungq10_device = platform_create_bundle(&samsungq10_driver, samsungq10_device = platform_create_bundle(&samsungq10_driver,
samsungq10_probe, samsungq10_probe,
NULL, 0, NULL, 0); NULL, 0, NULL, 0);
......
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