ACER: Add support for accelerometer sensor
Subsystems (2)
PATCH 1/2 ACER: Add support for accelerometer sensor
This device is present on Iconia Tab W500.
--- drivers/platform/x86/acer-wmi.c | 138 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+)
drivers/platform/x86/acer-wmi.c +138 -0
@@ -95,6 +95,7 @@ MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");enum acer_wmi_event_ids {WMID_HOTKEY_EVENT =0x1 , +WMID_ACCEL_EVENT =0x5 , };static const struct key_entry acer_wmi_keymap[] = {
@@ -130,6 +131,7 @@ static const struct key_entry acer_wmi_keymap[] = { };static struct input_dev *acer_wmi_input_dev; +static struct input_dev *acer_wmi_accel_dev;struct event_return_value {u8 function;
@@ -200,6 +202,7 @@ struct hotkey_function_type_aa {#define ACER_CAP_BLUETOOTH (1<<2)#define ACER_CAP_BRIGHTNESS (1<<3)#define ACER_CAP_THREEG (1<<4) +#define ACER_CAP_ACCEL (1<<5)#define ACER_CAP_ANY (0xFFFFFFFF)/*
@@ -1375,6 +1378,60 @@ static void acer_backlight_exit(void) }/* +* Accelerometer device +*/ +static acpi_handle gsensor_handle; + +static int acer_gsensor_init (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj; + + output.length =sizeof (out_obj); + output.pointer = &out_obj; + status =acpi_evaluate_object (gsensor_handle,"_INI" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +return 0 ; +} + +static int acer_gsensor_open (struct input_dev *input) +{ +return acer_gsensor_init (); +} + +static int acer_gsensor_event (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj[5 ]; + +if (!has_cap (ACER_CAP_ACCEL )) +return -1 ; + + output.length =sizeof (out_obj); + output.pointer = out_obj; + + status =acpi_evaluate_object (gsensor_handle,"RDVL" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +if (out_obj->package.count !=4 ) +return -1 ; + +input_report_abs (acer_wmi_accel_dev,ABS_X , + (s16 )out_obj->package.elements[0 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Y , + (s16 )out_obj->package.elements[1 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Z , + (s16 )out_obj->package.elements[2 ].integer.value); +input_sync (acer_wmi_accel_dev); +return 0 ; +} + +/* * Rfkill devices */ static void acer_rfkill_update (struct work_struct *ignored);
@@ -1649,6 +1706,9 @@ static void acer_wmi_notify(u32 value, void *context) 1, true); }break ; +case WMID_ACCEL_EVENT : +acer_gsensor_event (); +break ;default :pr_warn ("Unknown function number - %d - %d\n" , return_value.function, return_value.key_num);
@@ -1734,6 +1794,74 @@ static int acer_wmi_enable_lm(void)return status; } +static acpi_status __init acer_wmi_get_handle_cb (acpi_handle ah,u32 level, +void *ctx,void **retval) +{ + *(acpi_handle *)retval = ah; +return AE_OK ; +} + +static int __init acer_wmi_get_handle (const char *name,const char *prop, +acpi_handle *ah) +{ +acpi_status status; +acpi_handle handle; + +BUG_ON (!name || !ah); + + handle =0 ; + status =acpi_get_devices (prop, acer_wmi_get_handle_cb, + (void *)name, &handle); + +if (ACPI_SUCCESS (status)) { + *ah = handle; +return 0 ; + }else { +return -ENODEV ; + } +} + +static int __init acer_wmi_accel_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("SENR" ,"BST0001" , &gsensor_handle); +if (err) +return err; + + interface->capability |=ACER_CAP_ACCEL ; + + acer_wmi_accel_dev =input_allocate_device (); +if (!acer_wmi_accel_dev) +return -ENOMEM ; + + acer_wmi_accel_dev->open = acer_gsensor_open; + + acer_wmi_accel_dev->name ="Acer BMA150 accelerometer" ; + acer_wmi_accel_dev->phys ="wmi/input1" ; + acer_wmi_accel_dev->id.bustype =BUS_HOST ; + acer_wmi_accel_dev->evbit[0 ] =BIT_MASK (EV_ABS ); +input_set_abs_params (acer_wmi_accel_dev,ABS_X ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Y ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Z ,-16384 ,16384 ,0 ,0 ); + + err =input_register_device (acer_wmi_accel_dev); +if (err) + goto err_free_dev; + +return 0 ; + +err_free_dev: +input_free_device (acer_wmi_accel_dev); +return err; +} + +static void acer_wmi_accel_destroy (void ) +{ +input_unregister_device (acer_wmi_accel_dev); +input_free_device (acer_wmi_accel_dev); +} +static int __init acer_wmi_input_setup (void ) {acpi_status status;
@@ -1889,6 +2017,9 @@ static int acer_platform_resume(struct platform_device *device)if (has_cap (ACER_CAP_BRIGHTNESS ))set_u32 (data->brightness,ACER_CAP_BRIGHTNESS ); +if (has_cap (ACER_CAP_ACCEL )) +acer_gsensor_init (); +return 0 ; }
@@ -2066,6 +2197,8 @@ static int __init acer_wmi_init(void)return err; } +acer_wmi_accel_setup (); + err =platform_driver_register (&acer_platform_driver);if (err) {pr_err ("Unable to register platform driver\n" );
@@ -2109,6 +2242,8 @@ error_device_alloc: error_platform_register:if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy ();return err; }
@@ -2118,6 +2253,9 @@ static void __exit acer_wmi_exit(void)if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy (); +remove_sysfs (acer_platform_device);remove_debugfs ();platform_device_unregister (acer_platform_device);
Signature · 1 line
1.7.10
PATCH 2/2 ACER: Add support for ambient light sensor
This is the ambient light sensor found on Iconia W500.
--- drivers/platform/x86/acer-wmi.c | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
drivers/platform/x86/acer-wmi.c +86 -0
@@ -203,6 +203,7 @@ struct hotkey_function_type_aa {#define ACER_CAP_BRIGHTNESS (1<<3)#define ACER_CAP_THREEG (1<<4)#define ACER_CAP_ACCEL (1<<5) +#define ACER_CAP_ALS (1<<6)#define ACER_CAP_ANY (0xFFFFFFFF)/*
@@ -1378,6 +1379,63 @@ static void acer_backlight_exit(void) }/* +* Ambient light sensor device +*/ +static acpi_handle alsd_handle; + +static int acer_als_init (void ) +{ +union acpi_object in_obj; +struct acpi_object_list params; +struct acpi_buffer out; +union acpi_object out_obj; +acpi_status status; + + status =acpi_evaluate_object (alsd_handle,"_INI" ,NULL ,NULL ); +if (ACPI_FAILURE (status)) +return -1 ; + + params.count =1 ; + params.pointer = &in_obj; + in_obj.type =ACPI_TYPE_INTEGER ; +/* +* Unknown argument of both GLOV and GUPV, set to 5. +* GLOV - G? Lower Value ? +* GUPV - G? Upper Value ? +*/ + in_obj.integer.value =5 ; + out.length =sizeof (out_obj); + out.pointer = &out_obj; + +acpi_evaluate_object (alsd_handle,"GLOV" , ¶ms, &out); +acpi_evaluate_object (alsd_handle,"GUPV" , ¶ms, &out); + +return 0 ; +} + +static ssize_t acer_als_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj; + + status =acpi_evaluate_object (alsd_handle,"S3WK" ,NULL ,NULL ); +if (ACPI_FAILURE (status)) +return -1 ; + + output.length =sizeof (out_obj); + output.pointer = &out_obj; + status =acpi_evaluate_object (alsd_handle,"_ALI" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +return sprintf (buf,"%d\n" , (u16 )out_obj.integer.value); +} + +static DEVICE_ATTR(ls_switch, S_IRUGO, acer_als_show, NULL); + +/* * Accelerometer device */ static acpi_handle gsensor_handle;
@@ -1856,6 +1914,21 @@ err_free_dev:return err; } +static int __init acer_wmi_alsd_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("ALSD" ,"ACPI0008" , &alsd_handle); +if (err) +return err; + + interface->capability |=ACER_CAP_ALS ; + +acer_als_init (); + +return 0 ; +} +static void acer_wmi_accel_destroy (void ) {input_unregister_device (acer_wmi_accel_dev);
@@ -2020,6 +2093,9 @@ static int acer_platform_resume(struct platform_device *device)if (has_cap (ACER_CAP_ACCEL ))acer_gsensor_init (); +if (has_cap (ACER_CAP_ALS )) +acer_als_init (); +return 0 ; }
@@ -2052,6 +2128,8 @@ static int remove_sysfs(struct platform_device *device) {if (has_cap (ACER_CAP_THREEG ))device_remove_file (&device->dev, &dev_attr_threeg); +if (has_cap (ACER_CAP_ALS )) +device_remove_file (&device->dev, &dev_attr_ls_switch);device_remove_file (&device->dev, &dev_attr_interface);
@@ -2069,6 +2147,13 @@ static int create_sysfs(void) goto error_sysfs; } +if (has_cap (ACER_CAP_ALS )) { + retval =device_create_file (&acer_platform_device->dev, + &dev_attr_ls_switch); +if (retval) + goto error_sysfs; + } + retval =device_create_file (&acer_platform_device->dev, &dev_attr_interface);if (retval)
@@ -2198,6 +2283,7 @@ static int __init acer_wmi_init(void) }acer_wmi_accel_setup (); +acer_wmi_alsd_setup (); err =platform_driver_register (&acer_platform_driver);if (err) {
Signature · 1 line
1.7.10
joeyli
maintainerRe: [PATCH 2/2] ACER: Add support for ambient light sensor
Hi Marek,
於 五,2012-06-01 於 19:11 +0200,Marek Vasut 提到:
Quoted 45 lines
This is the ambient light sensor found on Iconia W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>--- drivers/platform/x86/acer-wmi.c | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)drivers/platform/x86/acer-wmi.c +22
-0@@ -203,6 +203,7 @@ struct hotkey_function_type_aa {#define ACER_CAP_BRIGHTNESS (1<<3)#define ACER_CAP_THREEG (1<<4)#define ACER_CAP_ACCEL (1<<5) +#define ACER_CAP_ALS (1<<6)#define ACER_CAP_ANY (0xFFFFFFFF)/* @@ -1378,6 +1379,63 @@ static void acer_backlight_exit(void) }/* +* Ambient light sensor device +*/ +static acpi_handle alsd_handle; + +static int acer_als_init (void ) +{ +union acpi_object in_obj; +struct acpi_object_list params; +struct acpi_buffer out; +union acpi_object out_obj; +acpi_status status; + + status =acpi_evaluate_object (alsd_handle,"_INI" ,NULL ,NULL ); +if (ACPI_FAILURE (status)) +return -1 ; + + params.count =1 ; + params.pointer = &in_obj; + in_obj.type =ACPI_TYPE_INTEGER ; +/* +* Unknown argument of both GLOV and GUPV, set to 5.
drivers/platform/x86/acer-wmi.c static void acer_backlight_exit(void) · line 1412
Quoted 10 lines
drivers/platform/x86/acer-wmi.c +10
-0+* GLOV - G? Lower Value ? +* GUPV - G? Upper Value ? +*/ + in_obj.integer.value =5 ; + out.length =sizeof (out_obj); + out.pointer = &out_obj; + +acpi_evaluate_object (alsd_handle,"GLOV" , ¶ms, &out); +acpi_evaluate_object (alsd_handle,"GUPV" , ¶ms, &out); +
GUPV/GLOV also call by _INI, why need evaluate it again?
Method (_INI, 0, NotSerialized)
{
...
Store (GUPV (Local1), Local2)
Store (GLOV (Local1), Local3)
And, why use '5' to evaluate GUPV/GLOV?
Quoted 4 lines
drivers/platform/x86/acer-wmi.c +4
-0+return 0 ; +} + +static ssize_t acer_als_show(struct device *dev, struct device_attribute *attr,
drivers/platform/x86/acer-wmi.c static void acer_backlight_exit(void) · line 1426
Quoted 10 lines
drivers/platform/x86/acer-wmi.c +10
-0+ char *buf) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj; + + status =acpi_evaluate_object (alsd_handle,"S3WK" ,NULL ,NULL ); +if (ACPI_FAILURE (status)) +return -1 ; +
Why need evaluate S3WK before _ALI ? Looks like this method call in S3 resume path:
_WAK -> OEMW -> PRJW -> S3WK
Quoted 17 lines
drivers/platform/x86/acer-wmi.c +12
-0+ output.length =sizeof (out_obj); + output.pointer = &out_obj; + status =acpi_evaluate_object (alsd_handle,"_ALI" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +return sprintf (buf,"%d\n" , (u16 )out_obj.integer.value); +} + +static DEVICE_ATTR(ls_switch, S_IRUGO, acer_als_show, NULL); + +/* * Accelerometer device */ static acpi_handle gsensor_handle;@@ -1856,6 +1914,21 @@ err_free_dev:return err;
drivers/platform/x86/acer-wmi.c err_free_dev: · line 1924
Quoted 10 lines
drivers/platform/x86/acer-wmi.c +8
-0} +static int __init acer_wmi_alsd_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("ALSD" ,"ACPI0008" , &alsd_handle); +if (err) +return err; +
Does anybody know why "introduce ACPI ALS device driver" patches from Zhang Rui didn't include in acpi code base?
http://comments.gmane.org/gmane.linux.kernel/884328
There have V6 patches, but didn't see those patches show up in acpi git.
Thanks a lot!
Joey Lee
Quoted 51 lines
drivers/platform/x86/acer-wmi.c +20
-0+ interface->capability |=ACER_CAP_ALS ; + +acer_als_init (); + +return 0 ; +} +static void acer_wmi_accel_destroy (void ) {input_unregister_device (acer_wmi_accel_dev);@@ -2020,6 +2093,9 @@ static int acer_platform_resume(struct platform_device *device)if (has_cap (ACER_CAP_ACCEL ))acer_gsensor_init (); +if (has_cap (ACER_CAP_ALS )) +acer_als_init (); +return 0 ; }@@ -2052,6 +2128,8 @@ static int remove_sysfs(struct platform_device *device) {if (has_cap (ACER_CAP_THREEG ))device_remove_file (&device->dev, &dev_attr_threeg); +if (has_cap (ACER_CAP_ALS )) +device_remove_file (&device->dev, &dev_attr_ls_switch);device_remove_file (&device->dev, &dev_attr_interface);@@ -2069,6 +2147,13 @@ static int create_sysfs(void) goto error_sysfs; } +if (has_cap (ACER_CAP_ALS )) { + retval =device_create_file (&acer_platform_device->dev, + &dev_attr_ls_switch); +if (retval) + goto error_sysfs; + } + retval =device_create_file (&acer_platform_device->dev, &dev_attr_interface);if (retval)@@ -2198,6 +2283,7 @@ static int __init acer_wmi_init(void) }acer_wmi_accel_setup (); +acer_wmi_alsd_setup (); err =platform_driver_register (&acer_platform_driver);if (err) {
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
Dear joeyli,
Quoted 61 lines
Hi Marek,
於 五,2012-06-01 於 19:11 +0200,Marek Vasut 提到:
Quoted 57 lines
This is the ambient light sensor found on Iconia W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>---
drivers/platform/x86/acer-wmi.c | 86+++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
(quoted diff) +0
-0
b/drivers/platform/x86/acer-wmi.cindex edb6bad..a58c415 100644drivers/platform/x86/acer-wmi.c +1
-0@@ -203,6 +203,7 @@ struct hotkey_function_type_aa {#define ACER_CAP_BRIGHTNESS (1<<3)#define ACER_CAP_THREEG (1<<4)#define ACER_CAP_ACCEL (1<<5) +#define ACER_CAP_ALS (1<<6)#define
ACER_CAP_ANY(0xFFFFFFFF)/*
drivers/platform/x86/acer-wmi.c +25
-0@@ -1378,6 +1379,63 @@ static void acer_backlight_exit(void) }/* +* Ambient light sensor device +*/ +static acpi_handle alsd_handle; + +static int acer_als_init (void ) +{ +union acpi_object in_obj; +struct acpi_object_list params; +struct acpi_buffer out; +union acpi_object out_obj; +acpi_status status; + + status =acpi_evaluate_object (alsd_handle,"_INI" ,NULL ,NULL ); +if (ACPI_FAILURE (status)) +return -1 ; + + params.count =1 ; + params.pointer = &in_obj; + in_obj.type =ACPI_TYPE_INTEGER ; +/* +* Unknown argument of both GLOV and GUPV, set to 5. +* GLOV - G? Lower Value ? +* GUPV - G? Upper Value ? +*/ + in_obj.integer.value =5 ;
Quoted 8 lines
drivers/platform/x86/acer-wmi.c static void acer_backlight_exit(void) · line 1412
Quoted 6 lines
drivers/platform/x86/acer-wmi.c +6
-0+ out.length =sizeof (out_obj); + out.pointer = &out_obj; + +acpi_evaluate_object (alsd_handle,"GLOV" , ¶ms, &out); +acpi_evaluate_object (alsd_handle,"GUPV" , ¶ms, &out); +GUPV/GLOV also call by
_INI, why need evaluate it again?
What does _INI set them to though?
Quoted 7 lines
Method (
_INI, 0, NotSerialized)
{
...
Store (GUPV (Local1), Local2)
Store (GLOV (Local1), Local3)And, why use '5' to evaluate GUPV/GLOV?
It seemed like the value that worked the best. I think those packages defined at the begining of the ALSD section define some kind of profiles (maybe, cloudy, bright light etc). And this selects the profile.
Quoted 10 lines
Quoted 10 lines
drivers/platform/x86/acer-wmi.c +8
-0+return 0 ; +} + +static ssize_t acer_als_show (struct device *dev,struct device_attribute *attr, + char *buf) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj;
Quoted 8 lines
drivers/platform/x86/acer-wmi.c static void acer_backlight_exit(void) · line 1426
Quoted 5 lines
drivers/platform/x86/acer-wmi.c +5
-0+ + status =acpi_evaluate_object (alsd_handle,"S3WK" ,NULL ,NULL ); +if (ACPI_FAILURE (status)) +return -1 ; +Why need evaluate S3WK before
_ALI? Looks like this method call in S3 resume path:
It makes the sensor re-read the data and it's faster than calling _INI.
Quoted 37 lines
_WAK-> OEMW -> PRJW -> S3WKQuoted 21 lines
drivers/platform/x86/acer-wmi.c +12
-0+ output.length =sizeof (out_obj); + output.pointer = &out_obj; + status =acpi_evaluate_object (alsd_handle,"_ALI" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +return sprintf (buf,"%d\n" , (u16 )out_obj.integer.value); +} + +static DEVICE_ATTR(ls_switch, S_IRUGO, acer_als_show, NULL); + +/* * Accelerometer device */ static acpi_handle gsensor_handle;@@ -1856,6 +1914,21 @@ err_free_dev:return err;drivers/platform/x86/acer-wmi.c err_free_dev: · line 1925
Quoted 10 lines
drivers/platform/x86/acer-wmi.c +8
-0} +static int __init acer_wmi_alsd_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("ALSD" ,"ACPI0008" , &alsd_handle); +if (err) +return err; +Does anybody know why "introduce ACPI ALS device driver" patches from Zhang Rui didn't include in acpi code base?
Quoted 4 lines
http://comments.gmane.org/gmane.linux.kernel/884328
There have V6 patches, but didn't see those patches show up in acpi git.
Now this would be much cooler to have than this crappy hack of mine :-)
Quoted 3 lines
Thanks a lot!
Joey Lee
Best regards,
Marek Vasut
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
In reply to Marek VasutQuoted 85 lines · Marek Vasut
This is the ambient light sensor found on Iconia W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>---
drivers/platform/x86/acer-wmi.c | 86 +++++++++++++++++++++++++++++++++++++++1 file changed, 86 insertions(+)drivers/platform/x86/acer-wmi.c +58
-0@@ -203,6 +203,7 @@ struct hotkey_function_type_aa { #define ACER_CAP_BRIGHTNESS (1<<3) #define ACER_CAP_THREEG (1<<4) #define ACER_CAP_ACCEL (1<<5) +#define ACER_CAP_ALS (1<<6) #define ACER_CAP_ANY (0xFFFFFFFF) /*@@ -1378,6 +1379,63 @@ static void acer_backlight_exit(void) } /* +* Ambient light sensor device +*/ +static acpi_handle alsd_handle; + +static int acer_als_init (void ) +{ + union acpi_object in_obj; + struct acpi_object_list params; + struct acpi_buffer out; + union acpi_object out_obj; + acpi_status status; + + status = acpi_evaluate_object(alsd_handle, "_INI", NULL, NULL); + if (ACPI_FAILURE(status)) + return -1; + + params.count = 1; + params.pointer = &in_obj; + in_obj.type = ACPI_TYPE_INTEGER; + /* + * Unknown argument of both GLOV and GUPV, set to 5. + * GLOV - G? Lower Value ? + * GUPV - G? Upper Value ? + */ + in_obj.integer.value = 5; + out.length = sizeof(out_obj); + out.pointer = &out_obj; + + acpi_evaluate_object(alsd_handle, "GLOV", ¶ms, &out); + acpi_evaluate_object(alsd_handle, "GUPV", ¶ms, &out); + + return 0; +} + +static ssize_t acer_als_show (struct device *dev,struct device_attribute *attr, + char *buf) +{ + acpi_status status; + struct acpi_buffer output; + union acpi_object out_obj; + + status = acpi_evaluate_object(alsd_handle, "S3WK", NULL, NULL); + if (ACPI_FAILURE(status)) + return -1; + + output.length = sizeof(out_obj); + output.pointer = &out_obj; + status = acpi_evaluate_object(alsd_handle, "_ALI", NULL, &output); + if (ACPI_FAILURE(status)) + return -1; + + return sprintf(buf, "%d\n", (u16)out_obj.integer.value); +} + +static DEVICE_ATTR(ls_switch, S_IRUGO, acer_als_show, NULL); + +/* * Accelerometer device */ static acpi_handle gsensor_handle;
drivers/platform/x86/acer-wmi.c err_free_dev: · line 1923
Quoted 10 lines
drivers/platform/x86/acer-wmi.c +7
-0@@ -1856,6 +1914,21 @@ err_free_dev: return err; } +static int __init acer_wmi_alsd_setup (void ) +{ + int err; + + err = acer_wmi_get_handle("ALSD", "ACPI0008", &alsd_handle); + if (err) + return err;
NACK ! This is a generic device, and should be handled by ACPI core (Samsung laptop have this too). See "ACPI ALS" on linux-acpi.
Quoted 58 lines
drivers/platform/x86/acer-wmi.c +20
-1+ interface->capability |= ACER_CAP_ALS; + + acer_als_init(); + + return 0; +} + static void acer_wmi_accel_destroy(void) { input_unregister_device(acer_wmi_accel_dev);@@ -2020,6 +2093,9 @@ static int acer_platform_resume(struct platform_device *device) if (has_cap(ACER_CAP_ACCEL)) acer_gsensor_init(); + if (has_cap(ACER_CAP_ALS)) + acer_als_init(); + return 0; }@@ -2052,6 +2128,8 @@ static int remove_sysfs(struct platform_device *device) { if (has_cap(ACER_CAP_THREEG)) device_remove_file(&device->dev, &dev_attr_threeg); + if (has_cap(ACER_CAP_ALS)) + device_remove_file(&device->dev, &dev_attr_ls_switch); device_remove_file(&device->dev, &dev_attr_interface);@@ -2069,6 +2147,13 @@ static int create_sysfs(void) goto error_sysfs; } + if (has_cap(ACER_CAP_ALS)) { + retval = device_create_file(&acer_platform_device->dev, + &dev_attr_ls_switch); + if (retval) + goto error_sysfs; + } + retval = device_create_file(&acer_platform_device->dev, &dev_attr_interface); if (retval)@@ -2198,6 +2283,7 @@ static int __init acer_wmi_init(void) } acer_wmi_accel_setup(); + acer_wmi_alsd_setup(); err = platform_driver_register(&acer_platform_driver); if (err) { --1.7.10
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Corentin Chary http://xf.iksaif.net
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
Dear Corentin Chary,
Quoted 6 lines · Marek Vasut
Quoted 5 lines
This is the ambient light sensor found on Iconia W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>---
[...]
Quoted 9 lines
drivers/platform/x86/acer-wmi.c err_free_dev: · line 1923
Quoted 7 lines
drivers/platform/x86/acer-wmi.c +7
-0+static int __init acer_wmi_alsd_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("ALSD" ,"ACPI0008" , &alsd_handle); +if (err) +return err;NACK !
What are you trying to achieve with such attitude? Are you trying to show off how much you can scream at someone new? I'd tell you some really harsh words and would turn my back on all this linux stuff if I wasn't used to people in kernel mailing lists having quite weird manners sometimes.
Quoted 2 lines
This is a generic device, and should be handled by ACPI core (Samsung laptop have this too). See "ACPI ALS" on linux-acpi.
Saying this would be enough. Lee explained to me what this ACPI0008 means, I'm quite new to the ACPI land so pardon my ignorance here. But it then boils down to Lee's question, why wasn't the patch for ACPI ALS that was already proposed accepted? And what can be done to get it in?
Best regards,
Marek Vasut
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
Quoted 21 lines · Marek Vasut
Dear Corentin Chary,
Quoted 6 lines · Marek Vasut
Quoted 5 lines
This is the ambient light sensor found on Iconia W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>---
[...]
Quoted 9 lines
drivers/platform/x86/acer-wmi.c err_free_dev: · line 1923
Quoted 7 lines
drivers/platform/x86/acer-wmi.c +7
-0+static int __init acer_wmi_alsd_setup (void ) +{ + int err; + + err = acer_wmi_get_handle("ALSD", "ACPI0008", &alsd_handle); + if (err) + return err;NACK !
Quoted 4 lines
What are you trying to achieve with such attitude? Are you trying to show off how much you can scream at someone new? I'd tell you some really harsh words and would turn my back on all this linux stuff if I wasn't used to people in kernel mailing lists having quite weird manners sometimes.
Sorry, that really wasn't what I meant. ACK / NACK are traditionnaly written like this arround here, but the "!" was probably too much.
Quoted 8 lines
Quoted 3 lines
This is a generic device, and should be handled by ACPI core (Samsung laptop have this too). See "ACPI ALS" on linux-acpi.
Saying this would be enough. Lee explained to me what this ACPI0008 means, I'm quite new to the ACPI land so pardon my ignorance here. But it then boils down to Lee's question, why wasn't the patch for ACPI ALS that was already proposed accepted? And what can be done to get it in?
Yep, I've seen Lee's message latter. Regarding ACPI ALS status, it was forgotten for a long time, and recently Zhang Rui told that he will take another look at it, but nothing sure. If you want to know more about the status, you can do a quick search on gmane using "ACPI ALS" query on linux.acpi
Signature · 2 lines
Corentin Chary http://xf.iksaif.net
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
Dear Corentin Chary,
Quoted 22 lines · Marek Vasut
Quoted 21 lines
Dear Corentin Chary,
Quoted 6 lines · Marek Vasut
Quoted 5 lines
This is the ambient light sensor found on Iconia W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>---
[...]
Quoted 9 lines
drivers/platform/x86/acer-wmi.c err_free_dev: · line 1923
Quoted 7 lines
drivers/platform/x86/acer-wmi.c +7
-0+static int __init acer_wmi_alsd_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("ALSD" ,"ACPI0008" , &alsd_handle); +if (err) +return err;NACK !
Quoted 8 lines
Quoted 5 lines
What are you trying to achieve with such attitude? Are you trying to show off how much you can scream at someone new? I'd tell you some really harsh words and would turn my back on all this linux stuff if I wasn't used to people in kernel mailing lists having quite weird manners sometimes.
Sorry, that really wasn't what I meant. ACK / NACK are traditionnaly written like this arround here, but the "!" was probably too much.
Ok, don't worry :-) Sorry about my jab above.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
This is a generic device, and should be handled by ACPI core (Samsung laptop have this too). See "ACPI ALS" on linux-acpi.
Saying this would be enough. Lee explained to me what this ACPI0008 means, I'm quite new to the ACPI land so pardon my ignorance here. But it then boils down to Lee's question, why wasn't the patch for ACPI ALS that was already proposed accepted? And what can be done to get it in?
Quoted 5 lines
Yep, I've seen Lee's message latter. Regarding ACPI ALS status, it was forgotten for a long time, and recently Zhang Rui told that he will take another look at it, but nothing sure. If you want to know more about the status, you can do a quick search on gmane using "ACPI ALS" query on linux.acpi
Will do, but I have an exam on 20th so I'll either poke into it if I need some rest or afterwards.
Best regards,
Marek Vasut
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
In reply to Corentin CharyDear Corentin Chary,
[...]
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
This is a generic device, and should be handled by ACPI core (Samsung laptop have this too). See "ACPI ALS" on linux-acpi.
Saying this would be enough. Lee explained to me what this ACPI0008 means, I'm quite new to the ACPI land so pardon my ignorance here. But it then boils down to Lee's question, why wasn't the patch for ACPI ALS that was already proposed accepted? And what can be done to get it in?
Quoted 5 lines
Yep, I've seen Lee's message latter. Regarding ACPI ALS status, it was forgotten for a long time, and recently Zhang Rui told that he will take another look at it, but nothing sure. If you want to know more about the status, you can do a quick search on gmane using "ACPI ALS" query on linux.acpi
Actually, going through the ACPI0008 patch, I see it introduced new sysfs class. Maybe we should rather integrate it with Linux-IIO these days?
Best regards,
Marek Vasut
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
Quoted 12 lines · Marek Vasut
Dear Corentin Chary,
[...]
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
This is a generic device, and should be handled by ACPI core (Samsung laptop have this too). See "ACPI ALS" on linux-acpi.
Saying this would be enough. Lee explained to me what this ACPI0008 means, I'm quite new to the ACPI land so pardon my ignorance here. But it then boils down to Lee's question, why wasn't the patch for ACPI ALS that was already proposed accepted? And what can be done to get it in?
Quoted 9 lines
Quoted 5 lines
Yep, I've seen Lee's message latter. Regarding ACPI ALS status, it was forgotten for a long time, and recently Zhang Rui told that he will take another look at it, but nothing sure. If you want to know more about the status, you can do a quick search on gmane using "ACPI ALS" query on linux.acpi
Actually, going through the ACPI0008 patch, I see it introduced new sysfs class. Maybe we should rather integrate it with Linux-IIO these days?
yes.
please refer to this thread
http://marc.info/?l=linux-acpi&m=132060809120911&w=2
I do not have time to do this right now, and it will be great if you are interested in introducing the ACPI ALS driver.
thanks,
rui
Re: [PATCH 2/2] ACER: Add support for ambient light sensor
Dear Zhang Rui,
Quoted 23 lines · Marek Vasut
Quoted 13 lines
Dear Corentin Chary,
[...]
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
This is a generic device, and should be handled by ACPI core (Samsung laptop have this too). See "ACPI ALS" on linux-acpi.
Saying this would be enough. Lee explained to me what this ACPI0008 means, I'm quite new to the ACPI land so pardon my ignorance here. But it then boils down to Lee's question, why wasn't the patch for ACPI ALS that was already proposed accepted? And what can be done to get it in?
Quoted 8 lines
Quoted 5 lines
Yep, I've seen Lee's message latter. Regarding ACPI ALS status, it was forgotten for a long time, and recently Zhang Rui told that he will take another look at it, but nothing sure. If you want to know more about the status, you can do a quick search on gmane using "ACPI ALS" query on linux.acpi
Actually, going through the ACPI0008 patch, I see it introduced new sysfs class. Maybe we should rather integrate it with Linux-IIO these days?
Quoted 6 lines
yes.
please refer to this thread
http://marc.info/?l=linux-acpi&m=132060809120911&w=2I do not have time to do this right now, and it will be great if you are interested in introducing the ACPI ALS driver.
So, I finally raised from dead again ... sorry I didn't reply earlier. Apparently, one of my students is interested in fixing/writing such driver, therefore I'll land him my hardware and let him do it.
I CCed him, please treat him well.
Best regards,
Marek Vasut
於 五,2012-06-01 於 19:11 +0200,Marek Vasut 提到:
Quoted 4 lines
This device is present on Iconia Tab W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>
This patch is good to me!
Thanks a lot!
Joey Lee
Quoted 216 lines
--- drivers/platform/x86/acer-wmi.c | 138 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+)drivers/platform/x86/acer-wmi.c +138
-0@@ -95,6 +95,7 @@ MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");enum acer_wmi_event_ids {WMID_HOTKEY_EVENT =0x1 , +WMID_ACCEL_EVENT =0x5 , };static const struct key_entry acer_wmi_keymap[] = {@@ -130,6 +131,7 @@ static const struct key_entry acer_wmi_keymap[] = { };static struct input_dev *acer_wmi_input_dev; +static struct input_dev *acer_wmi_accel_dev;struct event_return_value {u8 function;@@ -200,6 +202,7 @@ struct hotkey_function_type_aa {#define ACER_CAP_BLUETOOTH (1<<2)#define ACER_CAP_BRIGHTNESS (1<<3)#define ACER_CAP_THREEG (1<<4) +#define ACER_CAP_ACCEL (1<<5)#define ACER_CAP_ANY (0xFFFFFFFF)/* @@ -1375,6 +1378,60 @@ static void acer_backlight_exit(void) }/* +* Accelerometer device +*/ +static acpi_handle gsensor_handle; + +static int acer_gsensor_init (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj; + + output.length =sizeof (out_obj); + output.pointer = &out_obj; + status =acpi_evaluate_object (gsensor_handle,"_INI" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +return 0 ; +} + +static int acer_gsensor_open (struct input_dev *input) +{ +return acer_gsensor_init (); +} + +static int acer_gsensor_event (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj[5 ]; + +if (!has_cap (ACER_CAP_ACCEL )) +return -1 ; + + output.length =sizeof (out_obj); + output.pointer = out_obj; + + status =acpi_evaluate_object (gsensor_handle,"RDVL" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +if (out_obj->package.count !=4 ) +return -1 ; + +input_report_abs (acer_wmi_accel_dev,ABS_X , + (s16 )out_obj->package.elements[0 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Y , + (s16 )out_obj->package.elements[1 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Z , + (s16 )out_obj->package.elements[2 ].integer.value); +input_sync (acer_wmi_accel_dev); +return 0 ; +} + +/* * Rfkill devices */ static void acer_rfkill_update (struct work_struct *ignored);@@ -1649,6 +1706,9 @@ static void acer_wmi_notify(u32 value, void *context) 1, true); }break ; +case WMID_ACCEL_EVENT : +acer_gsensor_event (); +break ;default :pr_warn ("Unknown function number - %d - %d\n" , return_value.function, return_value.key_num);@@ -1734,6 +1794,74 @@ static int acer_wmi_enable_lm(void)return status; } +static acpi_status __init acer_wmi_get_handle_cb (acpi_handle ah,u32 level, +void *ctx,void **retval) +{ + *(acpi_handle *)retval = ah; +return AE_OK ; +} + +static int __init acer_wmi_get_handle (const char *name,const char *prop, +acpi_handle *ah) +{ +acpi_status status; +acpi_handle handle; + +BUG_ON (!name || !ah); + + handle =0 ; + status =acpi_get_devices (prop, acer_wmi_get_handle_cb, + (void *)name, &handle); + +if (ACPI_SUCCESS (status)) { + *ah = handle; +return 0 ; + }else { +return -ENODEV ; + } +} + +static int __init acer_wmi_accel_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("SENR" ,"BST0001" , &gsensor_handle); +if (err) +return err; + + interface->capability |=ACER_CAP_ACCEL ; + + acer_wmi_accel_dev =input_allocate_device (); +if (!acer_wmi_accel_dev) +return -ENOMEM ; + + acer_wmi_accel_dev->open = acer_gsensor_open; + + acer_wmi_accel_dev->name ="Acer BMA150 accelerometer" ; + acer_wmi_accel_dev->phys ="wmi/input1" ; + acer_wmi_accel_dev->id.bustype =BUS_HOST ; + acer_wmi_accel_dev->evbit[0 ] =BIT_MASK (EV_ABS ); +input_set_abs_params (acer_wmi_accel_dev,ABS_X ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Y ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Z ,-16384 ,16384 ,0 ,0 ); + + err =input_register_device (acer_wmi_accel_dev); +if (err) + goto err_free_dev; + +return 0 ; + +err_free_dev: +input_free_device (acer_wmi_accel_dev); +return err; +} + +static void acer_wmi_accel_destroy (void ) +{ +input_unregister_device (acer_wmi_accel_dev); +input_free_device (acer_wmi_accel_dev); +} +static int __init acer_wmi_input_setup (void ) {acpi_status status;@@ -1889,6 +2017,9 @@ static int acer_platform_resume(struct platform_device *device)if (has_cap (ACER_CAP_BRIGHTNESS ))set_u32 (data->brightness,ACER_CAP_BRIGHTNESS ); +if (has_cap (ACER_CAP_ACCEL )) +acer_gsensor_init (); +return 0 ; }@@ -2066,6 +2197,8 @@ static int __init acer_wmi_init(void)return err; } +acer_wmi_accel_setup (); + err =platform_driver_register (&acer_platform_driver);if (err) {pr_err ("Unable to register platform driver\n" );@@ -2109,6 +2242,8 @@ error_device_alloc: error_platform_register:if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy ();return err; }@@ -2118,6 +2253,9 @@ static void __exit acer_wmi_exit(void)if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy (); +remove_sysfs (acer_platform_device);remove_debugfs ();platform_device_unregister (acer_platform_device);
Dear joeyli,
Quoted 8 lines
於 五,2012-06-01 於 19:11 +0200,Marek Vasut 提到:
Quoted 4 lines
This device is present on Iconia Tab W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>This patch is good to me!
Thanks for your help and guidance throughout the process. Now who'll apply it and when can I expect it in -next or somewhere (where?)?
Quoted 136 lines
Acked-by Lee, Chun-Yi <[email protected]>Thanks a lot!
Joey LeeQuoted 130 lines
---
drivers/platform/x86/acer-wmi.c | 138+++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+)
(quoted diff) +0
-0
b/drivers/platform/x86/acer-wmi.cindex c1a3fd8..edb6bad 100644drivers/platform/x86/acer-wmi.c +1
-0@@ -95,6 +95,7 @@MODULE_ALIAS ("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026" );enum acer_wmi_event_ids {WMID_HOTKEY_EVENT =0x1 , +WMID_ACCEL_EVENT =0x5 ,};
static const struct
key_entryacer_wmi_keymap[] = {drivers/platform/x86/acer-wmi.c +1
-0@@ -130,6 +131,7 @@ static const struct key_entry acer_wmi_keymap[] = { };static struct input_dev *acer_wmi_input_dev; +static struct input_dev *acer_wmi_accel_dev;struct
event_return_value{drivers/platform/x86/acer-wmi.c +1
-0u8 function;@@ -200,6 +202,7 @@ struct hotkey_function_type_aa {#define ACER_CAP_BLUETOOTH (1<<2)#define ACER_CAP_BRIGHTNESS (1<<3)#define ACER_CAP_THREEG (1<<4) +#define ACER_CAP_ACCEL (1<<5)#define
ACER_CAP_ANY(0xFFFFFFFF)/*
drivers/platform/x86/acer-wmi.c +54
-0@@ -1375,6 +1378,60 @@ static void acer_backlight_exit(void) }/* +* Accelerometer device +*/ +static acpi_handle gsensor_handle; + +static int acer_gsensor_init (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj; + + output.length =sizeof (out_obj); + output.pointer = &out_obj; + status =acpi_evaluate_object (gsensor_handle,"_INI" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +return 0 ; +} + +static int acer_gsensor_open (struct input_dev *input) +{ +return acer_gsensor_init (); +} + +static int acer_gsensor_event (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj[5 ]; + +if (!has_cap (ACER_CAP_ACCEL )) +return -1 ; + + output.length =sizeof (out_obj); + output.pointer = out_obj; + + status =acpi_evaluate_object (gsensor_handle,"RDVL" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +if (out_obj->package.count !=4 ) +return -1 ; + +input_report_abs (acer_wmi_accel_dev,ABS_X , + (s16 )out_obj->package.elements[0 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Y , + (s16 )out_obj->package.elements[1 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Z , + (s16 )out_obj->package.elements[2 ].integer.value); +input_sync (acer_wmi_accel_dev); +return 0 ; +} + +/* * Rfkill devices
*/static void
acer_rfkill_update(struct work_struct *ignored);drivers/platform/x86/acer-wmi.c +3
-0@@ -1649,6 +1706,9 @@ static void acer_wmi_notify(u32 value, void *context) 1, true); }break ; +case WMID_ACCEL_EVENT : +acer_gsensor_event (); +break ;default :pr_warn ("Unknown function number - %d - %d\n" , return_value.function, return_value.key_num);
Quoted 8 lines
Quoted 8 lines
drivers/platform/x86/acer-wmi.c +1
-0@@ -1734,6 +1794,74 @@ static int acer_wmi_enable_lm(void)return status; } +static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32level, + void *ctx, void
**retval)
Quoted 127 lines
Quoted 127 lines
drivers/platform/x86/acer-wmi.c +6
-0+{ + *(acpi_handle *)retval = ah; +return AE_OK ; +} + +static int __init acer_wmi_get_handle(const char *name, const char*prop, +
acpi_handle*ah)drivers/platform/x86/acer-wmi.c +62
-0+{ +acpi_status status; +acpi_handle handle; + +BUG_ON (!name || !ah); + + handle =0 ; + status =acpi_get_devices (prop, acer_wmi_get_handle_cb, + (void *)name, &handle); + +if (ACPI_SUCCESS (status)) { + *ah = handle; +return 0 ; + }else { +return -ENODEV ; + } +} + +static int __init acer_wmi_accel_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("SENR" ,"BST0001" , &gsensor_handle); +if (err) +return err; + + interface->capability |=ACER_CAP_ACCEL ; + + acer_wmi_accel_dev =input_allocate_device (); +if (!acer_wmi_accel_dev) +return -ENOMEM ; + + acer_wmi_accel_dev->open = acer_gsensor_open; + + acer_wmi_accel_dev->name ="Acer BMA150 accelerometer" ; + acer_wmi_accel_dev->phys ="wmi/input1" ; + acer_wmi_accel_dev->id.bustype =BUS_HOST ; + acer_wmi_accel_dev->evbit[0 ] =BIT_MASK (EV_ABS ); +input_set_abs_params (acer_wmi_accel_dev,ABS_X ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Y ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Z ,-16384 ,16384 ,0 ,0 ); + + err =input_register_device (acer_wmi_accel_dev); +if (err) + goto err_free_dev; + +return 0 ; + +err_free_dev: +input_free_device (acer_wmi_accel_dev); +return err; +} + +static void acer_wmi_accel_destroy (void ) +{ +input_unregister_device (acer_wmi_accel_dev); +input_free_device (acer_wmi_accel_dev); +} +static int __init acer_wmi_input_setup (void ) {acpi_status status;@@ -1889,6 +2017,9 @@ static int acer_platform_resume(struct platform_device *device)if (has_cap (ACER_CAP_BRIGHTNESS ))set_u32 (data->brightness,ACER_CAP_BRIGHTNESS ); +if (has_cap (ACER_CAP_ACCEL )) +acer_gsensor_init (); +drivers/platform/x86/acer-wmi.c +2
-0return 0 ; }@@ -2066,6 +2197,8 @@ static int __init acer_wmi_init(void)return err; } +acer_wmi_accel_setup (); +drivers/platform/x86/acer-wmi.c +2
-0err =platform_driver_register (&acer_platform_driver);if (err) {pr_err ("Unable to register platform driver\n" );@@ -2109,6 +2242,8 @@ error_device_alloc: error_platform_register:if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy ();drivers/platform/x86/acer-wmi.c +3
-0return err; }@@ -2118,6 +2253,9 @@ static void __exit acer_wmi_exit(void)if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy (); +drivers/platform/x86/acer-wmi.c +0
-0remove_sysfs (acer_platform_device);remove_debugfs ();platform_device_unregister (acer_platform_device);
joeyli
maintainerHi Marek,
於 三,2012-06-06 於 00:52 +0200,Marek Vasut 提到:
Quoted 6 lines
Dear joeyli,
Quoted 4 lines
於 五,2012-06-01 於 19:11 +0200,Marek Vasut 提到:
Quoted 2 lines
This device is present on Iconia Tab W500.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>This patch is good to me!
Thanks for your help and guidance throughout the process. Now who'll apply it and when can I expect it in -next or somewhere (where?)?
Quoted 2 lines
Acked-by Lee, Chun-Yi <[email protected]>
Wait Matthew apply patch to platform driver git.
He already sent merge request to Linus and merged to v3.5-rc1 kernel. I think need wait v3.6.
Thanks
Joey Lee
Quoted 271 lines
Quoted 134 lines
Thanks a lot!
Joey LeeQuoted 130 lines
---
drivers/platform/x86/acer-wmi.c | 138+++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+)
(quoted diff) +0
-0
b/drivers/platform/x86/acer-wmi.cindex c1a3fd8..edb6bad 100644drivers/platform/x86/acer-wmi.c +1
-0@@ -95,6 +95,7 @@MODULE_ALIAS ("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026" );enum acer_wmi_event_ids {WMID_HOTKEY_EVENT =0x1 , +WMID_ACCEL_EVENT =0x5 ,};
static const struct
key_entryacer_wmi_keymap[] = {drivers/platform/x86/acer-wmi.c +1
-0@@ -130,6 +131,7 @@ static const struct key_entry acer_wmi_keymap[] = { };static struct input_dev *acer_wmi_input_dev; +static struct input_dev *acer_wmi_accel_dev;struct
event_return_value{drivers/platform/x86/acer-wmi.c +1
-0u8 function;@@ -200,6 +202,7 @@ struct hotkey_function_type_aa {#define ACER_CAP_BLUETOOTH (1<<2)#define ACER_CAP_BRIGHTNESS (1<<3)#define ACER_CAP_THREEG (1<<4) +#define ACER_CAP_ACCEL (1<<5)#define
ACER_CAP_ANY(0xFFFFFFFF)/*
drivers/platform/x86/acer-wmi.c +54
-0@@ -1375,6 +1378,60 @@ static void acer_backlight_exit(void) }/* +* Accelerometer device +*/ +static acpi_handle gsensor_handle; + +static int acer_gsensor_init (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj; + + output.length =sizeof (out_obj); + output.pointer = &out_obj; + status =acpi_evaluate_object (gsensor_handle,"_INI" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +return 0 ; +} + +static int acer_gsensor_open (struct input_dev *input) +{ +return acer_gsensor_init (); +} + +static int acer_gsensor_event (void ) +{ +acpi_status status; +struct acpi_buffer output; +union acpi_object out_obj[5 ]; + +if (!has_cap (ACER_CAP_ACCEL )) +return -1 ; + + output.length =sizeof (out_obj); + output.pointer = out_obj; + + status =acpi_evaluate_object (gsensor_handle,"RDVL" ,NULL , &output); +if (ACPI_FAILURE (status)) +return -1 ; + +if (out_obj->package.count !=4 ) +return -1 ; + +input_report_abs (acer_wmi_accel_dev,ABS_X , + (s16 )out_obj->package.elements[0 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Y , + (s16 )out_obj->package.elements[1 ].integer.value); +input_report_abs (acer_wmi_accel_dev,ABS_Z , + (s16 )out_obj->package.elements[2 ].integer.value); +input_sync (acer_wmi_accel_dev); +return 0 ; +} + +/* * Rfkill devices
*/static void
acer_rfkill_update(struct work_struct *ignored);drivers/platform/x86/acer-wmi.c +3
-0@@ -1649,6 +1706,9 @@ static void acer_wmi_notify(u32 value, void *context) 1, true); }break ; +case WMID_ACCEL_EVENT : +acer_gsensor_event (); +break ;default :pr_warn ("Unknown function number - %d - %d\n" , return_value.function, return_value.key_num);Quoted 8 lines
Quoted 8 lines
drivers/platform/x86/acer-wmi.c +1
-0@@ -1734,6 +1794,74 @@ static int acer_wmi_enable_lm(void)return status; } +static acpi_status __init acer_wmi_get_handle_cb(acpi_handle ah, u32level, + void *ctx, void
**retval)
Quoted 127 lines
Quoted 127 lines
drivers/platform/x86/acer-wmi.c +6
-0+{ + *(acpi_handle *)retval = ah; +return AE_OK ; +} + +static int __init acer_wmi_get_handle(const char *name, const char*prop, +
acpi_handle*ah)drivers/platform/x86/acer-wmi.c +62
-0+{ +acpi_status status; +acpi_handle handle; + +BUG_ON (!name || !ah); + + handle =0 ; + status =acpi_get_devices (prop, acer_wmi_get_handle_cb, + (void *)name, &handle); + +if (ACPI_SUCCESS (status)) { + *ah = handle; +return 0 ; + }else { +return -ENODEV ; + } +} + +static int __init acer_wmi_accel_setup (void ) +{ +int err; + + err =acer_wmi_get_handle ("SENR" ,"BST0001" , &gsensor_handle); +if (err) +return err; + + interface->capability |=ACER_CAP_ACCEL ; + + acer_wmi_accel_dev =input_allocate_device (); +if (!acer_wmi_accel_dev) +return -ENOMEM ; + + acer_wmi_accel_dev->open = acer_gsensor_open; + + acer_wmi_accel_dev->name ="Acer BMA150 accelerometer" ; + acer_wmi_accel_dev->phys ="wmi/input1" ; + acer_wmi_accel_dev->id.bustype =BUS_HOST ; + acer_wmi_accel_dev->evbit[0 ] =BIT_MASK (EV_ABS ); +input_set_abs_params (acer_wmi_accel_dev,ABS_X ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Y ,-16384 ,16384 ,0 ,0 ); +input_set_abs_params (acer_wmi_accel_dev,ABS_Z ,-16384 ,16384 ,0 ,0 ); + + err =input_register_device (acer_wmi_accel_dev); +if (err) + goto err_free_dev; + +return 0 ; + +err_free_dev: +input_free_device (acer_wmi_accel_dev); +return err; +} + +static void acer_wmi_accel_destroy (void ) +{ +input_unregister_device (acer_wmi_accel_dev); +input_free_device (acer_wmi_accel_dev); +} +static int __init acer_wmi_input_setup (void ) {acpi_status status;@@ -1889,6 +2017,9 @@ static int acer_platform_resume(struct platform_device *device)if (has_cap (ACER_CAP_BRIGHTNESS ))set_u32 (data->brightness,ACER_CAP_BRIGHTNESS ); +if (has_cap (ACER_CAP_ACCEL )) +acer_gsensor_init (); +drivers/platform/x86/acer-wmi.c +2
-0return 0 ; }@@ -2066,6 +2197,8 @@ static int __init acer_wmi_init(void)return err; } +acer_wmi_accel_setup (); +drivers/platform/x86/acer-wmi.c +2
-0err =platform_driver_register (&acer_platform_driver);if (err) {pr_err ("Unable to register platform driver\n" );@@ -2109,6 +2242,8 @@ error_device_alloc: error_platform_register:if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy ();drivers/platform/x86/acer-wmi.c +3
-0return err; }@@ -2118,6 +2253,9 @@ static void __exit acer_wmi_exit(void)if (wmi_has_guid (ACERWMID_EVENT_GUID ))acer_wmi_input_destroy (); +if (has_cap (ACER_CAP_ACCEL )) +acer_wmi_accel_destroy (); +drivers/platform/x86/acer-wmi.c +0
-0remove_sysfs (acer_platform_device);remove_debugfs ();platform_device_unregister (acer_platform_device);
Dear joeyli,
Quoted 18 lines
Hi Marek,
於 三,2012-06-06 於 00:52 +0200,Marek Vasut 提到:
Quoted 14 lines
Dear joeyli,
Quoted 8 lines
於 五,2012-06-01 於 19:11 +0200,Marek Vasut 提到:
Quoted 4 lines
This device is present on Iconia Tab W500.
Signed-off-by Marek Vasut <[email protected]>Cc joeyli <[email protected]>This patch is good to me!
Thanks for your help and guidance throughout the process. Now who'll apply it and when can I expect it in -next or somewhere (where?)?
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Acked-by Lee, Chun-Yi <[email protected]>Wait Matthew apply patch to platform driver git.
He already sent merge request to Linus and merged to v3.5-rc1 kernel. I think need wait v3.6.
Great! Thanks for clearing this!
Quoted 3 lines
Thanks
Joey Lee
Matthew Garrett
AppliedI've applied patch 1 to -next, it'll be in 3.6. Thanks!
Signature · 1 line
Matthew Garrett | [email protected]
Dear Matthew Garrett,
Quoted 1 line
I've applied patch 1 to -next, it'll be in 3.6. Thanks!
Thank you :-)
Best regards,
Marek Vasut