[PATCH 1/3] asus-wmi: add scalar board brightness adj. support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some of the ASUS ET2012 All-in-One machines that use a scalar board
to control the brightness, and it only accepts brightness up or down
comm. So, I introduced a get_scalar_command() function to pass the
command to the scalar board through WMI.

Besides, we have to store the brightness value locally, for we need the
old value to know the brightness is increasing or decreasing.

BTW, since there is no way to retrieve the actual brightness(it would be
a fixed value), and the max brightness value would be fixed to 1, so we
have to keep passing the brightness up/down command when we reached the
max brightness value or 0.

Signed-off-by: AceLan Kao <acelan.kao@xxxxxxxxxxxxx>
---
 drivers/platform/x86/asus-wmi.c  |   21 +++++++++++++++++++++
 drivers/platform/x86/asus-wmi.h  |    1 +
 drivers/platform/x86/eeepc-wmi.c |   13 +++++++++++++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 72d731c..48e96f3 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1116,6 +1116,25 @@ static int read_brightness(struct backlight_device *bd)
 	return retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK;
 }
 
+static u32 get_scalar_command(struct backlight_device *bd)
+{
+	struct asus_wmi *asus = bl_get_data(bd);
+	u32 ctrl_param = 0;
+	static int brightness_old = -1;
+
+	if (brightness_old == -1)
+		brightness_old = bd->props.brightness;
+
+	if ((brightness_old < bd->props.brightness) || bd->props.brightness == read_brightness_max(asus))
+		ctrl_param = 0x00008001;
+	else if ((brightness_old > bd->props.brightness) || bd->props.brightness == 0)
+		ctrl_param = 0x00008000;
+
+	brightness_old = bd->props.brightness;
+
+	return ctrl_param;
+}
+
 static int update_bl_status(struct backlight_device *bd)
 {
 	struct asus_wmi *asus = bl_get_data(bd);
@@ -1123,6 +1142,8 @@ static int update_bl_status(struct backlight_device *bd)
 	int power, err;
 
 	ctrl_param = bd->props.brightness;
+	if (unlikely(asus->driver->scalar_panel_brightness))
+		ctrl_param = get_scalar_command (bd);
 
 	err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BRIGHTNESS,
 				    ctrl_param, NULL);
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
index 8147c10..45fb62c 100644
--- a/drivers/platform/x86/asus-wmi.h
+++ b/drivers/platform/x86/asus-wmi.h
@@ -37,6 +37,7 @@ struct asus_wmi;
 
 struct asus_wmi_driver {
 	bool			hotplug_wireless;
+	bool			scalar_panel_brightness;
 	int			wapf;
 
 	const char		*name;
diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
index 9f6e643..c5f4c64 100644
--- a/drivers/platform/x86/eeepc-wmi.c
+++ b/drivers/platform/x86/eeepc-wmi.c
@@ -161,11 +161,24 @@ static void eeepc_dmi_check(struct asus_wmi_driver *driver)
 		driver->hotplug_wireless = true;
 		pr_info("wlan hotplug enabled\n");
 	}
+
+	if (strncmp(model, "ET2012", 6) == 0) {
+		const struct dmi_device *dev = NULL;
+		char oemstring[30];
+		while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
+			if (sscanf(dev->name, "AEMS%24c", oemstring) == 1) {
+				if (oemstring[18] == '3')
+					driver->scalar_panel_brightness = true;
+				break;
+			}
+		}
+	}
 }
 
 static void eeepc_wmi_quirks(struct asus_wmi_driver *driver)
 {
 	driver->hotplug_wireless = hotplug_wireless;
+	driver->scalar_panel_brightness = false;
 	driver->wapf = -1;
 	eeepc_dmi_check(driver);
 }
-- 
1.7.9

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux