Skip to contentSkip to conversation

asus-wmi: provide access to ALS control

PATCH Applied Oleksij Rempel 3 participants 7 messages Apr 1, 2016 – May 25, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 asus-wmi: provide access to ALS control

Asus Zenbook ux31a is providing ACPI0008 interface for ALS (Ambient Light Sensor), which is accessible for OS => Win 7. This sensor can be used with iio/acpi-als driver. Since it is disabled by default, we should use asus-wmi interface to enable it.

---
 drivers/platform/x86/asus-wmi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/asus-wmi.c +5 -0
index a96630d..a26dca3 100644
@@ -114,6 +114,7 @@ MODULE_LICENSE("GPL");
 #define ASUS_WMI_DEVID_LED6		0x00020016
 
 /* Backlight and Brightness */
+#define ASUS_WMI_DEVID_ALS_ENABLE	0x00050001 /* Ambient Light Sensor */
 #define ASUS_WMI_DEVID_BACKLIGHT	0x00050011
 #define ASUS_WMI_DEVID_BRIGHTNESS	0x00050012
 #define ASUS_WMI_DEVID_KBD_BACKLIGHT	0x00050021
@@ -1730,6 +1731,7 @@ ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
 ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
 ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
 ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
+ASUS_WMI_CREATE_DEVICE_ATTR(als_enable, 0644, ASUS_WMI_DEVID_ALS_ENABLE);
 
 static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
 			   const char *buf, size_t count)
@@ -1756,6 +1758,7 @@ static struct attribute *platform_attributes[] = {
 	&dev_attr_cardr.attr,
 	&dev_attr_touchpad.attr,
 	&dev_attr_lid_resume.attr,
+	&dev_attr_als_enable.attr,
 	NULL
 };
 
@@ -1776,6 +1779,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
 		devid = ASUS_WMI_DEVID_TOUCHPAD;
 	else if (attr == &dev_attr_lid_resume.attr)
 		devid = ASUS_WMI_DEVID_LID_RESUME;
+	else if (attr == &dev_attr_als_enable.attr)
+		devid = ASUS_WMI_DEVID_ALS_ENABLE;
 
 	if (devid != -1)
 		ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
Signature · 1 line
2.5.0
#1 lore raw
Quoted 6 lines · Oleksij Rempel

Asus Zenbook ux31a is providing ACPI0008 interface for ALS (Ambient Light Sensor), which is accessible for OS => Win 7. This sensor can be used with iio/acpi-als driver. Since it is disabled by default, we should use asus-wmi interface to enable it.

Corentin, any concerns?

Quoted 10 lines
---
 drivers/platform/x86/asus-wmi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/asus-wmi.c +0 -0
index a96630d..a26dca3 100644

drivers/platform/x86/asus-wmi.c MODULE_LICENSE("GPL"); · line 120

Quoted 7 lines
drivers/platform/x86/asus-wmi.c +1 -0
@@ -114,6 +114,7 @@ MODULE_LICENSE("GPL");
 #define ASUS_WMI_DEVID_LED6		0x00020016
 
 /* Backlight and Brightness */
+#define ASUS_WMI_DEVID_ALS_ENABLE	0x00050001 /* Ambient Light Sensor */
 #define ASUS_WMI_DEVID_BACKLIGHT	0x00050011
 #define ASUS_WMI_DEVID_BRIGHTNESS	0x00050012
 #define ASUS_WMI_DEVID_KBD_BACKLIGHT	0x00050021

Following this is:

#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */

Is there any relationship with this patch and that device? It would be useful to understand the difference between these two DEVIDs (a comment in the source).

Otherwise, I'm happy with the patch.

Quoted 29 lines
drivers/platform/x86/asus-wmi.c +4 -0
@@ -1730,6 +1731,7 @@ ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
 ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
 ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
 ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
+ASUS_WMI_CREATE_DEVICE_ATTR(als_enable, 0644, ASUS_WMI_DEVID_ALS_ENABLE);
 
 static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
 			   const char *buf, size_t count)
@@ -1756,6 +1758,7 @@ static struct attribute *platform_attributes[] = {
 	&dev_attr_cardr.attr,
 	&dev_attr_touchpad.attr,
 	&dev_attr_lid_resume.attr,
+	&dev_attr_als_enable.attr,
 	NULL
 };
 
@@ -1776,6 +1779,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
 		devid = ASUS_WMI_DEVID_TOUCHPAD;
 	else if (attr == &dev_attr_lid_resume.attr)
 		devid = ASUS_WMI_DEVID_LID_RESUME;
+	else if (attr == &dev_attr_als_enable.attr)
+		devid = ASUS_WMI_DEVID_ALS_ENABLE;
 
 	if (devid != -1)
 		ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
Signature · 1 line
2.5.0
Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#2 lore raw

Am 10.04.2016 um 05:06 schrieb Darren Hart:

Quoted 30 lines · Oleksij Rempel
Quoted 6 lines

Asus Zenbook ux31a is providing ACPI0008 interface for ALS (Ambient Light Sensor), which is accessible for OS => Win 7. This sensor can be used with iio/acpi-als driver. Since it is disabled by default, we should use asus-wmi interface to enable it.

Corentin, any concerns?

Quoted 10 lines
---
 drivers/platform/x86/asus-wmi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/asus-wmi.c +0 -0
index a96630d..a26dca3 100644

drivers/platform/x86/asus-wmi.c MODULE_LICENSE("GPL"); · line 120

Quoted 7 lines
drivers/platform/x86/asus-wmi.c +1 -0
@@ -114,6 +114,7 @@ MODULE_LICENSE("GPL");
 #define ASUS_WMI_DEVID_LED6		0x00020016
 
 /* Backlight and Brightness */
+#define ASUS_WMI_DEVID_ALS_ENABLE	0x00050001 /* Ambient Light Sensor */
 #define ASUS_WMI_DEVID_BACKLIGHT	0x00050011
 #define ASUS_WMI_DEVID_BRIGHTNESS	0x00050012
 #define ASUS_WMI_DEVID_KBD_BACKLIGHT	0x00050021

Following this is:

Quoted 4 lines

#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */

Is there any relationship with this patch and that device? It would be useful to understand the difference between these two DEVIDs (a comment in the source).

I don't have this ID on my laptop. Hard to say what is it.

Quoted 33 lines

Otherwise, I'm happy with the patch.

Quoted 29 lines
drivers/platform/x86/asus-wmi.c +4 -0
@@ -1730,6 +1731,7 @@ ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
 ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
 ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
 ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
+ASUS_WMI_CREATE_DEVICE_ATTR(als_enable, 0644, ASUS_WMI_DEVID_ALS_ENABLE);
 
 static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
 			   const char *buf, size_t count)
@@ -1756,6 +1758,7 @@ static struct attribute *platform_attributes[] = {
 	&dev_attr_cardr.attr,
 	&dev_attr_touchpad.attr,
 	&dev_attr_lid_resume.attr,
+	&dev_attr_als_enable.attr,
 	NULL
 };
 
@@ -1776,6 +1779,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
 		devid = ASUS_WMI_DEVID_TOUCHPAD;
 	else if (attr == &dev_attr_lid_resume.attr)
 		devid = ASUS_WMI_DEVID_LID_RESUME;
+	else if (attr == &dev_attr_als_enable.attr)
+		devid = ASUS_WMI_DEVID_ALS_ENABLE;
 
 	if (devid != -1)
 		ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
Signature · 1 line
2.5.0
Signature · 2 lines
Regards,
Oleksij
maintainer
#3 lore raw
Quoted 32 lines · Oleksij Rempel

Am 10.04.2016 um 05:06 schrieb Darren Hart:

Quoted 30 lines · Oleksij Rempel
Quoted 6 lines

Asus Zenbook ux31a is providing ACPI0008 interface for ALS (Ambient Light Sensor), which is accessible for OS => Win 7. This sensor can be used with iio/acpi-als driver. Since it is disabled by default, we should use asus-wmi interface to enable it.

Corentin, any concerns?

Quoted 10 lines
---
 drivers/platform/x86/asus-wmi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/asus-wmi.c +0 -0
index a96630d..a26dca3 100644

drivers/platform/x86/asus-wmi.c MODULE_LICENSE("GPL"); · line 120

Quoted 7 lines
drivers/platform/x86/asus-wmi.c +1 -0
@@ -114,6 +114,7 @@ MODULE_LICENSE("GPL");
 #define ASUS_WMI_DEVID_LED6         0x00020016
 
 /* Backlight and Brightness */
+#define ASUS_WMI_DEVID_ALS_ENABLE   0x00050001 /* Ambient Light Sensor */
 #define ASUS_WMI_DEVID_BACKLIGHT    0x00050011
 #define ASUS_WMI_DEVID_BRIGHTNESS   0x00050012
 #define ASUS_WMI_DEVID_KBD_BACKLIGHT        0x00050021

Following this is:

Quoted 7 lines
Quoted 4 lines

#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */

Is there any relationship with this patch and that device? It would be useful to understand the difference between these two DEVIDs (a comment in the source).

I don't have this ID on my laptop. Hard to say what is it.

I believe I found out this was somehow related to light sensors because the WMI device contained that kind of information, but it's likely that Asus didn't use this ID in a consistent way.

Quoted 40 lines
Quoted 27 lines

Otherwise, I'm happy with the patch.

Quoted 23 lines
drivers/platform/x86/asus-wmi.c +4 -0
@@ -1730,6 +1731,7 @@ ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
 ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
 ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
 ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
+ASUS_WMI_CREATE_DEVICE_ATTR(als_enable, 0644, ASUS_WMI_DEVID_ALS_ENABLE);
 
 static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
                        const char *buf, size_t count)
@@ -1756,6 +1758,7 @@ static struct attribute *platform_attributes[] = {
     &dev_attr_cardr.attr,
     &dev_attr_touchpad.attr,
     &dev_attr_lid_resume.attr,
+    &dev_attr_als_enable.attr,
     NULL
 };
 
@@ -1776,6 +1779,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
             devid = ASUS_WMI_DEVID_TOUCHPAD;
     else if (attr == &dev_attr_lid_resume.attr)
             devid = ASUS_WMI_DEVID_LID_RESUME;
+    else if (attr == &dev_attr_als_enable.attr)
+            devid = ASUS_WMI_DEVID_ALS_ENABLE;
 
Quoted 7 lines
Quoted 6 lines
drivers/platform/x86/asus-wmi.c +0 -1
     if (devid != -1)
             ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
--

2.5.0

--
Regards,
Oleksij

Signature · 2 lines
Corentin Chary
http://xf.iksaif.net
#4 lore raw
Quoted 38 lines · Corentin Chary
Quoted 37 lines · Oleksij Rempel

Am 10.04.2016 um 05:06 schrieb Darren Hart:

Quoted 34 lines · Oleksij Rempel
Quoted 6 lines

Asus Zenbook ux31a is providing ACPI0008 interface for ALS (Ambient Light Sensor), which is accessible for OS => Win 7. This sensor can be used with iio/acpi-als driver. Since it is disabled by default, we should use asus-wmi interface to enable it.

Corentin, any concerns?

Quoted 10 lines
---
 drivers/platform/x86/asus-wmi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/asus-wmi.c +0 -0
index a96630d..a26dca3 100644

drivers/platform/x86/asus-wmi.c MODULE_LICENSE("GPL"); · line 120

Quoted 7 lines
drivers/platform/x86/asus-wmi.c +1 -0
@@ -114,6 +114,7 @@ MODULE_LICENSE("GPL");
 #define ASUS_WMI_DEVID_LED6         0x00020016
 
 /* Backlight and Brightness */
+#define ASUS_WMI_DEVID_ALS_ENABLE   0x00050001 /* Ambient Light Sensor */
 #define ASUS_WMI_DEVID_BACKLIGHT    0x00050011
 #define ASUS_WMI_DEVID_BRIGHTNESS   0x00050012
 #define ASUS_WMI_DEVID_KBD_BACKLIGHT        0x00050021

Following this is:

#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */

Is there any relationship with this patch and that device? It would be useful to understand the difference between these two DEVIDs (a comment in the source).

Quoted 6 lines
Quoted 2 lines

I don't have this ID on my laptop. Hard to say what is it.

I believe I found out this was somehow related to light sensors because the WMI device contained that kind of information, but it's likely that Asus didn't use this ID in a consistent way.

Thanks for the follow-up. This one is already queued for 4.7.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#5 lore raw
In reply to Darren Hart

ping

Am 10.04.2016 um 05:06 schrieb Darren Hart:

Quoted 67 lines · Oleksij Rempel
Quoted 6 lines

Asus Zenbook ux31a is providing ACPI0008 interface for ALS (Ambient Light Sensor), which is accessible for OS => Win 7. This sensor can be used with iio/acpi-als driver. Since it is disabled by default, we should use asus-wmi interface to enable it.

Corentin, any concerns?

Quoted 10 lines
---
 drivers/platform/x86/asus-wmi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/asus-wmi.c +0 -0
index a96630d..a26dca3 100644

drivers/platform/x86/asus-wmi.c MODULE_LICENSE("GPL"); · line 120

Quoted 7 lines
drivers/platform/x86/asus-wmi.c +1 -0
@@ -114,6 +114,7 @@ MODULE_LICENSE("GPL");
 #define ASUS_WMI_DEVID_LED6		0x00020016
 
 /* Backlight and Brightness */
+#define ASUS_WMI_DEVID_ALS_ENABLE	0x00050001 /* Ambient Light Sensor */
 #define ASUS_WMI_DEVID_BACKLIGHT	0x00050011
 #define ASUS_WMI_DEVID_BRIGHTNESS	0x00050012
 #define ASUS_WMI_DEVID_KBD_BACKLIGHT	0x00050021

Following this is:

#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */

Is there any relationship with this patch and that device? It would be useful to understand the difference between these two DEVIDs (a comment in the source).

Otherwise, I'm happy with the patch.

Quoted 29 lines
drivers/platform/x86/asus-wmi.c +4 -0
@@ -1730,6 +1731,7 @@ ASUS_WMI_CREATE_DEVICE_ATTR(touchpad, 0644, ASUS_WMI_DEVID_TOUCHPAD);
 ASUS_WMI_CREATE_DEVICE_ATTR(camera, 0644, ASUS_WMI_DEVID_CAMERA);
 ASUS_WMI_CREATE_DEVICE_ATTR(cardr, 0644, ASUS_WMI_DEVID_CARDREADER);
 ASUS_WMI_CREATE_DEVICE_ATTR(lid_resume, 0644, ASUS_WMI_DEVID_LID_RESUME);
+ASUS_WMI_CREATE_DEVICE_ATTR(als_enable, 0644, ASUS_WMI_DEVID_ALS_ENABLE);
 
 static ssize_t store_cpufv(struct device *dev, struct device_attribute *attr,
 			   const char *buf, size_t count)
@@ -1756,6 +1758,7 @@ static struct attribute *platform_attributes[] = {
 	&dev_attr_cardr.attr,
 	&dev_attr_touchpad.attr,
 	&dev_attr_lid_resume.attr,
+	&dev_attr_als_enable.attr,
 	NULL
 };
 
@@ -1776,6 +1779,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
 		devid = ASUS_WMI_DEVID_TOUCHPAD;
 	else if (attr == &dev_attr_lid_resume.attr)
 		devid = ASUS_WMI_DEVID_LID_RESUME;
+	else if (attr == &dev_attr_als_enable.attr)
+		devid = ASUS_WMI_DEVID_ALS_ENABLE;
 
 	if (devid != -1)
 		ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
Signature · 1 line
2.5.0
Signature · 2 lines
Regards,
Oleksij
Applied
#6 lore raw
Quoted 1 line · Oleksij Rempel

ping

Merged, thanks for the ping.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center