All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
@ 2010-10-30 16:44 Joey Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Joey Lee @ 2010-10-30 16:44 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: corentin.chary, dmitry.torokhov, Takashi Iwai, Thomas Renninger,
	mjg59, carlos, jbenc, trenn, linux-input

Add CC. Thomas

於 日,2010-10-31 於 00:36 +0800,Lee, Chun-Yi 提到:
> Enabled Acer Launch Manager mode to disable the EC raw behavior for
> communication devices when WMID3 method available. And, we also add a
> ec_raw_mode kernel module option for enable The EC raw behavior mode
> when anyone what reset it back.
> When Acer Launch Manager mode enabled, EC will stop to touch any
> communication devices' RF state or power state that causes conflict
> with rfkill_input or any userland daemon to charge the rfkill rules.
> 
> Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
> ---
>  drivers/platform/x86/acer-wmi.c |  113 +++++++++++++++++++++++++++++++++++++++
>  1 files changed, 113 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index 930df56..0b870d3 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
>  #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
>  #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
>  #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
> +#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
>  
>  /*
>   * Acer ACPI event GUIDs
> @@ -120,6 +121,20 @@ struct event_return_value {
>  	u32 reserved;
>  } __attribute__((packed));
>  
> +struct lm_input_params {
> +	u8 function_num;	/* Function Number */
> +	u16 commun_devices;	/* Communication type devices default status */
> +	u16 devices;		/* Other type devices default status */
> +	u8 lm_status;		/* Launch Manager Status */
> +	u16 reserved;
> +} __attribute__((packed));
> +
> +struct lm_return_value {
> +	u8 error_code;		/* Error Code */
> +	u8 ec_return_value;	/* EC Return Value */
> +	u16 reserved;
> +} __attribute__((packed));
> +
>  /*
>   * Interface capability flags
>   */
> @@ -150,15 +165,18 @@ static int mailled = -1;
>  static int brightness = -1;
>  static int threeg = -1;
>  static int force_series;
> +static bool ec_raw_mode;
>  
>  module_param(mailled, int, 0444);
>  module_param(brightness, int, 0444);
>  module_param(threeg, int, 0444);
>  module_param(force_series, int, 0444);
> +module_param(ec_raw_mode, bool, 0444);
>  MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
>  MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
>  MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
>  MODULE_PARM_DESC(force_series, "Force a different laptop series");
> +MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
>  
>  struct acer_data {
>  	int mailled;
> @@ -1393,6 +1411,87 @@ error_debugfs:
>  	return -ENOMEM;
>  }
>  
> +static acpi_status
> +wmid3_set_lm_mode(struct lm_input_params *params,
> +			struct lm_return_value *return_value)
> +{
> +	acpi_status status;
> +	union acpi_object *obj;
> +
> +	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
> +	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
> +
> +	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
> +	if (ACPI_FAILURE(status))
> +		return status;
> +
> +	obj = output.pointer;
> +
> +	if (!obj)
> +		return -EINVAL;
> +	else if (obj->type != ACPI_TYPE_BUFFER) {
> +		kfree(obj);
> +		return -EINVAL;
> +	}
> +	if (obj->buffer.length != 4) {
> +		printk(ACER_WARNING "Unknown buffer length %d\n",
> +			obj->buffer.length);
> +		kfree(obj);
> +		return -EINVAL;
> +	}
> +
> +	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
> +	kfree(obj);
> +
> +	return status;
> +}
> +
> +static int acer_wmi_enable_ec_raw(void)
> +{
> +	struct lm_return_value return_value;
> +	acpi_status status;
> +	struct lm_input_params params = {
> +		.function_num = 0x1,
> +		.commun_devices = 0xFFFF,
> +		.devices = 0xFFFF,
> +		.lm_status = 0x00,		/* Launch Manager Deactive */
> +	};
> +
> +	status = wmid3_set_lm_mode(&params, &return_value);
> +
> +	if (return_value.error_code || return_value.ec_return_value)
> +		printk(ACER_WARNING "Enabling EC raw mode failed: "
> +			"0x%x - 0x%x\n", return_value.error_code,
> +			return_value.ec_return_value);
> +	else
> +		printk(ACER_INFO "Enabled EC raw mode");
> +
> +	return status;
> +}
> +
> +static int acer_wmi_enable_lm(void)
> +{
> +	struct lm_return_value return_value;
> +	acpi_status status;
> +	struct lm_input_params params = {
> +		.function_num = 0x1,
> +		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
> +		.devices = 0xFFFF,
> +		.lm_status = 0x41,		/* Launch Manager Active */
> +	};
> +
> +	status = wmid3_set_lm_mode(&params, &return_value);
> +
> +	if (return_value.error_code || return_value.ec_return_value)
> +		printk(ACER_WARNING "Enabling Launch Manager failed: "
> +			"0x%x - 0x%x\n", return_value.error_code,
> +			return_value.ec_return_value);
> +	else
> +		printk(ACER_INFO "Enabled Launch Manager");
> +
> +	return status;
> +}
> +
>  static int __init acer_wmi_init(void)
>  {
>  	int err;
> @@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
>  		       "generic video driver\n");
>  	}
>  
> +	if (wmi_has_guid(WMID_GUID3)) {
> +		if (ec_raw_mode) {
> +			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
> +				printk(ACER_ERR "Cannot enable EC raw mode\n");
> +				return -ENODEV;
> +			}
> +		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
> +			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
> +			return -ENODEV;
> +		}
> +	} else if (!wmi_has_guid(WMID_GUID3) && ec_raw_mode) {
> +		printk(ACER_INFO "No WMID EC raw mode enable method\n");
> +	}
> +
>  	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
>  		err = acer_wmi_input_setup();
>  		if (err)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
@ 2010-12-06  8:20 Joey Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Joey Lee @ 2010-12-06  8:20 UTC (permalink / raw)
  To: corentin.chary
  Cc: dmitry.torokhov, Takashi Iwai, mjg, mjg59, carlos, jbenc,
	jdelvare, trenn, linux-input, platform-driver-x86

Hi Corentin, 

於 一,2010-12-06 於 08:17 +0100,Corentin Chary 提到:
> >>
> >> Just noticed - this function (and others similar to this in your
> >> subsequent patces) mixes acpi-style return values (acpi_status) with
> >> Linux ones (-ERRXXX). You need to pick one standard (I'd advocate Linux
> >> style) and stick with it.
> >>
> >
> > Thank's for your review and suggestion, I choice use acpi-style because
> > it don't need change too much and old functions in acer-wmi also follow
> > acpi-style.
> > I replaced the -EINVAL with AE_ERROR, the following is new patch. If it's OK,
> > I will modify patch 2/4 and patch 3/4 then re-send patchset again.
> >
> >
> 
> But if you use acpi-style errors won't be able to go back to the user (errno)
> and userspace programs won't be able to display appropriate errors (on modprobe,
> manipulating sysfs files, etc...). I didn't read the code, so it may
> not be an issue here,

Yes, those functions are internal used in acer-wmi, and acer_wmi_init
function will transfer all ACPI error to Linux style then send to
userland.
So, yes, there have no any issue even mix 2 different style return
value.

> but you should check that meaningful error codes are sent back to userspace.
> 

I still replaced the -EINVAL with AE_ERROR because those 2 functions
declare return a acpi_status.


Thank's a lot!
Joey Lee

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
  2010-12-06  7:11 ` Joey Lee
  (?)
@ 2010-12-06  7:17 ` Corentin Chary
  -1 siblings, 0 replies; 12+ messages in thread
From: Corentin Chary @ 2010-12-06  7:17 UTC (permalink / raw)
  To: Joey Lee
  Cc: dmitry.torokhov, Takashi Iwai, mjg, mjg59, carlos, jbenc,
	jdelvare, trenn, linux-input, platform-driver-x86

>>
>> Just noticed - this function (and others similar to this in your
>> subsequent patces) mixes acpi-style return values (acpi_status) with
>> Linux ones (-ERRXXX). You need to pick one standard (I'd advocate Linux
>> style) and stick with it.
>>
>
> Thank's for your review and suggestion, I choice use acpi-style because
> it don't need change too much and old functions in acer-wmi also follow
> acpi-style.
> I replaced the -EINVAL with AE_ERROR, the following is new patch. If it's OK,
> I will modify patch 2/4 and patch 3/4 then re-send patchset again.
>
>

But if you use acpi-style errors won't be able to go back to the user (errno)
and userspace programs won't be able to display appropriate errors (on modprobe,
manipulating sysfs files, etc...). I didn't read the code, so it may
not be an issue here,
but you should check that meaningful error codes are sent back to userspace.

-- 
Corentin Chary
http://xf.iksaif.net

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
@ 2010-12-06  7:11 ` Joey Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Joey Lee @ 2010-12-06  7:11 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: corentin.chary, corentincj, Takashi Iwai, mjg, mjg59, carlos,
	jbenc, jdelvare, trenn, linux-input, platform-driver-x86

hi Dmitry, 

於 五,2010-12-03 於 17:42 -0800,Dmitry Torokhov 提到:
> Hi Joey,
> 
> On Sat, Dec 04, 2010 at 09:03:24AM +0800, Lee, Chun-Yi wrote:
> >  
> > +static acpi_status
> > +wmid3_set_lm_mode(struct lm_input_params *params,
> > +			struct lm_return_value *return_value)
> > +{
> > +	acpi_status status;
> > +	union acpi_object *obj;
> > +
> > +	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
> > +	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
> > +
> > +	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
> > +	if (ACPI_FAILURE(status))
> > +		return status;
> > +
> > +	obj = output.pointer;
> > +
> > +	if (!obj)
> > +		return -EINVAL;
> > +	else if (obj->type != ACPI_TYPE_BUFFER) {
> > +		kfree(obj);
> > +		return -EINVAL;
> 
> Just noticed - this function (and others similar to this in your
> subsequent patces) mixes acpi-style return values (acpi_status) with
> Linux ones (-ERRXXX). You need to pick one standard (I'd advocate Linux
> style) and stick with it.
> 

Thank's for your review and suggestion, I choice use acpi-style because
it don't need change too much and old functions in acer-wmi also follow
acpi-style.
I replaced the -EINVAL with AE_ERROR, the following is new patch. If it's OK,
I will modify patch 2/4 and patch 3/4 then re-send patchset again.


Thank's a lot!
Joey Lee


From 4c2932ead2967483e44903310d6a3e246edd1aa6 Mon Sep 17 00:00:00 2001
From: Lee, Chun-Yi <jlee@novell.com>
Date: Mon, 22 Nov 2010 18:30:58 +0800
Subject: [PATCH 2/4] acer-wmi: Enabled Acer Launch Manager mode

Enabled Acer Launch Manager mode to disable the EC raw behavior for
communication devices when WMID3 method available. And, we also add a
ec_raw_mode kernel module option for enable The EC raw behavior mode
when anyone what reset it back.
When Acer Launch Manager mode enabled, EC will stop to touch any
communication devices' RF state or power state that causes conflict
with rfkill_input or any userland daemon to charge the rfkill rules.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Acked-by: Thomas Renninger <trenn@suse.de>
Acked-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: Dmitry Torokhov <dtor@mail.ru> 
---
 drivers/platform/x86/acer-wmi.c |  113 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 930df56..1568721 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
 #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
 #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
 #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
+#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
 
 /*
  * Acer ACPI event GUIDs
@@ -120,6 +121,20 @@ struct event_return_value {
 	u32 reserved;
 } __attribute__((packed));
 
+struct lm_input_params {
+	u8 function_num;	/* Function Number */
+	u16 commun_devices;	/* Communication type devices default status */
+	u16 devices;		/* Other type devices default status */
+	u8 lm_status;		/* Launch Manager Status */
+	u16 reserved;
+} __attribute__((packed));
+
+struct lm_return_value {
+	u8 error_code;		/* Error Code */
+	u8 ec_return_value;	/* EC Return Value */
+	u16 reserved;
+} __attribute__((packed));
+
 /*
  * Interface capability flags
  */
@@ -150,15 +165,18 @@ static int mailled = -1;
 static int brightness = -1;
 static int threeg = -1;
 static int force_series;
+static bool ec_raw_mode;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
 module_param(threeg, int, 0444);
 module_param(force_series, int, 0444);
+module_param(ec_raw_mode, bool, 0444);
 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
 MODULE_PARM_DESC(force_series, "Force a different laptop series");
+MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
 
 struct acer_data {
 	int mailled;
@@ -1393,6 +1411,87 @@ error_debugfs:
 	return -ENOMEM;
 }
 
+static acpi_status
+wmid3_set_lm_mode(struct lm_input_params *params,
+			struct lm_return_value *return_value)
+{
+	acpi_status status;
+	union acpi_object *obj;
+
+	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return AE_ERROR;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return AE_ERROR;
+	}
+	if (obj->buffer.length != 4) {
+		printk(ACER_WARNING "Unknown buffer length %d\n",
+			obj->buffer.length);
+		kfree(obj);
+		return AE_ERROR;
+	}
+
+	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	return status;
+}
+
+static int acer_wmi_enable_ec_raw(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0xFFFF,
+		.devices = 0xFFFF,
+		.lm_status = 0x00,		/* Launch Manager Deactive */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling EC raw mode failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled EC raw mode");
+
+	return status;
+}
+
+static int acer_wmi_enable_lm(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
+		.devices = 0xFFFF,
+		.lm_status = 0x41,		/* Launch Manager Active */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling Launch Manager failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled Launch Manager");
+
+	return status;
+}
+
 static int __init acer_wmi_init(void)
 {
 	int err;
@@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
 		       "generic video driver\n");
 	}
 
+	if (wmi_has_guid(WMID_GUID3)) {
+		if (ec_raw_mode) {
+			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
+				printk(ACER_ERR "Cannot enable EC raw mode\n");
+				return -ENODEV;
+			}
+		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
+			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
+			return -ENODEV;
+		}
+	} else if (ec_raw_mode) {
+		printk(ACER_INFO "No WMID EC raw mode enable method\n");
+	}
+
 	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
 		err = acer_wmi_input_setup();
 		if (err)
-- 
1.6.0.2



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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
@ 2010-12-06  7:11 ` Joey Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Joey Lee @ 2010-12-06  7:11 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: corentin.chary, corentincj, Takashi Iwai, mjg, mjg59, carlos,
	jbenc, jdelvare, trenn, linux-input, platform-driver-x86

hi Dmitry, 

於 五,2010-12-03 於 17:42 -0800,Dmitry Torokhov 提到:
> Hi Joey,
> 
> On Sat, Dec 04, 2010 at 09:03:24AM +0800, Lee, Chun-Yi wrote:
> >  
> > +static acpi_status
> > +wmid3_set_lm_mode(struct lm_input_params *params,
> > +			struct lm_return_value *return_value)
> > +{
> > +	acpi_status status;
> > +	union acpi_object *obj;
> > +
> > +	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
> > +	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
> > +
> > +	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
> > +	if (ACPI_FAILURE(status))
> > +		return status;
> > +
> > +	obj = output.pointer;
> > +
> > +	if (!obj)
> > +		return -EINVAL;
> > +	else if (obj->type != ACPI_TYPE_BUFFER) {
> > +		kfree(obj);
> > +		return -EINVAL;
> 
> Just noticed - this function (and others similar to this in your
> subsequent patces) mixes acpi-style return values (acpi_status) with
> Linux ones (-ERRXXX). You need to pick one standard (I'd advocate Linux
> style) and stick with it.
> 

Thank's for your review and suggestion, I choice use acpi-style because
it don't need change too much and old functions in acer-wmi also follow
acpi-style.
I replaced the -EINVAL with AE_ERROR, the following is new patch. If it's OK,
I will modify patch 2/4 and patch 3/4 then re-send patchset again.


Thank's a lot!
Joey Lee


>From 4c2932ead2967483e44903310d6a3e246edd1aa6 Mon Sep 17 00:00:00 2001
From: Lee, Chun-Yi <jlee@novell.com>
Date: Mon, 22 Nov 2010 18:30:58 +0800
Subject: [PATCH 2/4] acer-wmi: Enabled Acer Launch Manager mode

Enabled Acer Launch Manager mode to disable the EC raw behavior for
communication devices when WMID3 method available. And, we also add a
ec_raw_mode kernel module option for enable The EC raw behavior mode
when anyone what reset it back.
When Acer Launch Manager mode enabled, EC will stop to touch any
communication devices' RF state or power state that causes conflict
with rfkill_input or any userland daemon to charge the rfkill rules.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Acked-by: Thomas Renninger <trenn@suse.de>
Acked-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: Dmitry Torokhov <dtor@mail.ru> 
---
 drivers/platform/x86/acer-wmi.c |  113 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 930df56..1568721 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
 #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
 #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
 #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
+#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
 
 /*
  * Acer ACPI event GUIDs
@@ -120,6 +121,20 @@ struct event_return_value {
 	u32 reserved;
 } __attribute__((packed));
 
+struct lm_input_params {
+	u8 function_num;	/* Function Number */
+	u16 commun_devices;	/* Communication type devices default status */
+	u16 devices;		/* Other type devices default status */
+	u8 lm_status;		/* Launch Manager Status */
+	u16 reserved;
+} __attribute__((packed));
+
+struct lm_return_value {
+	u8 error_code;		/* Error Code */
+	u8 ec_return_value;	/* EC Return Value */
+	u16 reserved;
+} __attribute__((packed));
+
 /*
  * Interface capability flags
  */
@@ -150,15 +165,18 @@ static int mailled = -1;
 static int brightness = -1;
 static int threeg = -1;
 static int force_series;
+static bool ec_raw_mode;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
 module_param(threeg, int, 0444);
 module_param(force_series, int, 0444);
+module_param(ec_raw_mode, bool, 0444);
 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
 MODULE_PARM_DESC(force_series, "Force a different laptop series");
+MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
 
 struct acer_data {
 	int mailled;
@@ -1393,6 +1411,87 @@ error_debugfs:
 	return -ENOMEM;
 }
 
+static acpi_status
+wmid3_set_lm_mode(struct lm_input_params *params,
+			struct lm_return_value *return_value)
+{
+	acpi_status status;
+	union acpi_object *obj;
+
+	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return AE_ERROR;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return AE_ERROR;
+	}
+	if (obj->buffer.length != 4) {
+		printk(ACER_WARNING "Unknown buffer length %d\n",
+			obj->buffer.length);
+		kfree(obj);
+		return AE_ERROR;
+	}
+
+	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	return status;
+}
+
+static int acer_wmi_enable_ec_raw(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0xFFFF,
+		.devices = 0xFFFF,
+		.lm_status = 0x00,		/* Launch Manager Deactive */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling EC raw mode failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled EC raw mode");
+
+	return status;
+}
+
+static int acer_wmi_enable_lm(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
+		.devices = 0xFFFF,
+		.lm_status = 0x41,		/* Launch Manager Active */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling Launch Manager failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled Launch Manager");
+
+	return status;
+}
+
 static int __init acer_wmi_init(void)
 {
 	int err;
@@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
 		       "generic video driver\n");
 	}
 
+	if (wmi_has_guid(WMID_GUID3)) {
+		if (ec_raw_mode) {
+			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
+				printk(ACER_ERR "Cannot enable EC raw mode\n");
+				return -ENODEV;
+			}
+		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
+			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
+			return -ENODEV;
+		}
+	} else if (ec_raw_mode) {
+		printk(ACER_INFO "No WMID EC raw mode enable method\n");
+	}
+
 	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
 		err = acer_wmi_input_setup();
 		if (err)
-- 
1.6.0.2



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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
  2010-12-04  1:03   ` [PATCH 2/4] Enabled Acer Launch Manager mode Lee, Chun-Yi
@ 2010-12-04  1:42     ` Dmitry Torokhov
  0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2010-12-04  1:42 UTC (permalink / raw)
  To: Lee, Chun-Yi
  Cc: mjg, carlos, corentin.chary, corentincj, tiwai, mjg59, jbenc,
	jdelvare, trenn, platform-driver-x86, linux-input, Lee, Chun-Yi

Hi Joey,

On Sat, Dec 04, 2010 at 09:03:24AM +0800, Lee, Chun-Yi wrote:
>  
> +static acpi_status
> +wmid3_set_lm_mode(struct lm_input_params *params,
> +			struct lm_return_value *return_value)
> +{
> +	acpi_status status;
> +	union acpi_object *obj;
> +
> +	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
> +	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
> +
> +	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
> +	if (ACPI_FAILURE(status))
> +		return status;
> +
> +	obj = output.pointer;
> +
> +	if (!obj)
> +		return -EINVAL;
> +	else if (obj->type != ACPI_TYPE_BUFFER) {
> +		kfree(obj);
> +		return -EINVAL;

Just noticed - this function (and others similar to this in your
subsequent patces) mixes acpi-style return values (acpi_status) with
Linux ones (-ERRXXX). You need to pick one standard (I'd advocate Linux
style) and stick with it.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/4] Enabled Acer Launch Manager mode
  2010-12-04  1:03 ` [PATCH 1/4] Add acer wmi hotkey events support Lee, Chun-Yi
@ 2010-12-04  1:03   ` Lee, Chun-Yi
  2010-12-04  1:42     ` Dmitry Torokhov
  0 siblings, 1 reply; 12+ messages in thread
From: Lee, Chun-Yi @ 2010-12-04  1:03 UTC (permalink / raw)
  To: mjg
  Cc: carlos, corentin.chary, dmitry.torokhov, corentincj, tiwai,
	mjg59, jbenc, jdelvare, trenn, platform-driver-x86, linux-input,
	Lee, Chun-Yi, Dmitry Torokhov

Enabled Acer Launch Manager mode to disable the EC raw behavior for
communication devices when WMID3 method available. And, we also add a
ec_raw_mode kernel module option for enable The EC raw behavior mode
when anyone what reset it back.
When Acer Launch Manager mode enabled, EC will stop to touch any
communication devices' RF state or power state that causes conflict
with rfkill_input or any userland daemon to charge the rfkill rules.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Acked-by: Thomas Renninger <trenn@suse.de>
Acked-by: Jiri Benc <jbenc@suse.cz>
Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: Dmitry Torokhov <dtor@mail.ru> 
---
 drivers/platform/x86/acer-wmi.c |  113 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 930df56..1568721 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
 #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
 #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
 #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
+#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
 
 /*
  * Acer ACPI event GUIDs
@@ -120,6 +121,20 @@ struct event_return_value {
 	u32 reserved;
 } __attribute__((packed));
 
+struct lm_input_params {
+	u8 function_num;	/* Function Number */
+	u16 commun_devices;	/* Communication type devices default status */
+	u16 devices;		/* Other type devices default status */
+	u8 lm_status;		/* Launch Manager Status */
+	u16 reserved;
+} __attribute__((packed));
+
+struct lm_return_value {
+	u8 error_code;		/* Error Code */
+	u8 ec_return_value;	/* EC Return Value */
+	u16 reserved;
+} __attribute__((packed));
+
 /*
  * Interface capability flags
  */
@@ -150,15 +165,18 @@ static int mailled = -1;
 static int brightness = -1;
 static int threeg = -1;
 static int force_series;
+static bool ec_raw_mode;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
 module_param(threeg, int, 0444);
 module_param(force_series, int, 0444);
+module_param(ec_raw_mode, bool, 0444);
 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
 MODULE_PARM_DESC(force_series, "Force a different laptop series");
+MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
 
 struct acer_data {
 	int mailled;
@@ -1393,6 +1411,87 @@ error_debugfs:
 	return -ENOMEM;
 }
 
+static acpi_status
+wmid3_set_lm_mode(struct lm_input_params *params,
+			struct lm_return_value *return_value)
+{
+	acpi_status status;
+	union acpi_object *obj;
+
+	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return -EINVAL;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return -EINVAL;
+	}
+	if (obj->buffer.length != 4) {
+		printk(ACER_WARNING "Unknown buffer length %d\n",
+			obj->buffer.length);
+		kfree(obj);
+		return -EINVAL;
+	}
+
+	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	return status;
+}
+
+static int acer_wmi_enable_ec_raw(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0xFFFF,
+		.devices = 0xFFFF,
+		.lm_status = 0x00,		/* Launch Manager Deactive */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling EC raw mode failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled EC raw mode");
+
+	return status;
+}
+
+static int acer_wmi_enable_lm(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
+		.devices = 0xFFFF,
+		.lm_status = 0x41,		/* Launch Manager Active */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling Launch Manager failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled Launch Manager");
+
+	return status;
+}
+
 static int __init acer_wmi_init(void)
 {
 	int err;
@@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
 		       "generic video driver\n");
 	}
 
+	if (wmi_has_guid(WMID_GUID3)) {
+		if (ec_raw_mode) {
+			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
+				printk(ACER_ERR "Cannot enable EC raw mode\n");
+				return -ENODEV;
+			}
+		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
+			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
+			return -ENODEV;
+		}
+	} else if (ec_raw_mode) {
+		printk(ACER_INFO "No WMID EC raw mode enable method\n");
+	}
+
 	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
 		err = acer_wmi_input_setup();
 		if (err)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
  2010-11-24 17:39   ` [PATCH 2/4] Enabled Acer Launch Manager mode Lee, Chun-Yi
@ 2010-11-24 19:49     ` Carlos Corbacho
  0 siblings, 0 replies; 12+ messages in thread
From: Carlos Corbacho @ 2010-11-24 19:49 UTC (permalink / raw)
  To: Lee, Chun-Yi
  Cc: mjg59, corentin.chary, dmitry.torokhov, tiwai, jbenc, jdelvare,
	trenn, linux-input, platform-driver-x86, Lee, Chun-Yi,
	Corentin Chary, Dmitry Torokhov

Signed-off-by: Carlos Corbacho <carlos@strangeworlds.co.uk>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/4] Enabled Acer Launch Manager mode
  2010-11-24 17:39 ` [PATCH 1/4] Add acer wmi hotkey events support Lee, Chun-Yi
@ 2010-11-24 17:39   ` Lee, Chun-Yi
  2010-11-24 19:49     ` Carlos Corbacho
  0 siblings, 1 reply; 12+ messages in thread
From: Lee, Chun-Yi @ 2010-11-24 17:39 UTC (permalink / raw)
  To: mjg59
  Cc: corentin.chary, dmitry.torokhov, tiwai, carlos, jbenc, jdelvare,
	trenn, linux-input, platform-driver-x86, Lee, Chun-Yi,
	Corentin Chary, Dmitry Torokhov

Enabled Acer Launch Manager mode to disable the EC raw behavior for
communication devices when WMID3 method available. And, we also add a
ec_raw_mode kernel module option for enable The EC raw behavior mode
when anyone what reset it back.
When Acer Launch Manager mode enabled, EC will stop to touch any
communication devices' RF state or power state that causes conflict
with rfkill_input or any userland daemon to charge the rfkill rules.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
Acked-by: Thomas Renninger <trenn@suse.de>
Acked-by: Jiri Benc <jbenc@suse.cz>
Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: Dmitry Torokhov <dtor@mail.ru> 
---
 drivers/platform/x86/acer-wmi.c |  113 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 930df56..1568721 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
 #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
 #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
 #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
+#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
 
 /*
  * Acer ACPI event GUIDs
@@ -120,6 +121,20 @@ struct event_return_value {
 	u32 reserved;
 } __attribute__((packed));
 
+struct lm_input_params {
+	u8 function_num;	/* Function Number */
+	u16 commun_devices;	/* Communication type devices default status */
+	u16 devices;		/* Other type devices default status */
+	u8 lm_status;		/* Launch Manager Status */
+	u16 reserved;
+} __attribute__((packed));
+
+struct lm_return_value {
+	u8 error_code;		/* Error Code */
+	u8 ec_return_value;	/* EC Return Value */
+	u16 reserved;
+} __attribute__((packed));
+
 /*
  * Interface capability flags
  */
@@ -150,15 +165,18 @@ static int mailled = -1;
 static int brightness = -1;
 static int threeg = -1;
 static int force_series;
+static bool ec_raw_mode;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
 module_param(threeg, int, 0444);
 module_param(force_series, int, 0444);
+module_param(ec_raw_mode, bool, 0444);
 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
 MODULE_PARM_DESC(force_series, "Force a different laptop series");
+MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
 
 struct acer_data {
 	int mailled;
@@ -1393,6 +1411,87 @@ error_debugfs:
 	return -ENOMEM;
 }
 
+static acpi_status
+wmid3_set_lm_mode(struct lm_input_params *params,
+			struct lm_return_value *return_value)
+{
+	acpi_status status;
+	union acpi_object *obj;
+
+	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return -EINVAL;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return -EINVAL;
+	}
+	if (obj->buffer.length != 4) {
+		printk(ACER_WARNING "Unknown buffer length %d\n",
+			obj->buffer.length);
+		kfree(obj);
+		return -EINVAL;
+	}
+
+	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	return status;
+}
+
+static int acer_wmi_enable_ec_raw(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0xFFFF,
+		.devices = 0xFFFF,
+		.lm_status = 0x00,		/* Launch Manager Deactive */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling EC raw mode failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled EC raw mode");
+
+	return status;
+}
+
+static int acer_wmi_enable_lm(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
+		.devices = 0xFFFF,
+		.lm_status = 0x41,		/* Launch Manager Active */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling Launch Manager failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled Launch Manager");
+
+	return status;
+}
+
 static int __init acer_wmi_init(void)
 {
 	int err;
@@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
 		       "generic video driver\n");
 	}
 
+	if (wmi_has_guid(WMID_GUID3)) {
+		if (ec_raw_mode) {
+			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
+				printk(ACER_ERR "Cannot enable EC raw mode\n");
+				return -ENODEV;
+			}
+		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
+			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
+			return -ENODEV;
+		}
+	} else if (ec_raw_mode) {
+		printk(ACER_INFO "No WMID EC raw mode enable method\n");
+	}
+
 	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
 		err = acer_wmi_input_setup();
 		if (err)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
@ 2010-11-03 17:07 ` Joey Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Joey Lee @ 2010-11-03 17:07 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: corentin.chary, dmitry.torokhov, Takashi Iwai, Thomas Renninger,
	mjg59, carlos, jbenc, trenn, linux-input

Hi all, 

於 六,2010-10-30 於 10:44 -0600,Joey Lee 提到:
> Add CC. Thomas
> >  
> > +	if (wmi_has_guid(WMID_GUID3)) {
> > +		if (ec_raw_mode) {
> > +			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
> > +				printk(ACER_ERR "Cannot enable EC raw mode\n");
> > +				return -ENODEV;
> > +			}
> > +		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
> > +			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
> > +			return -ENODEV;
> > +		}
> > +	} else if (!wmi_has_guid(WMID_GUID3) && ec_raw_mode) {
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Actually, Don't need check wmi_has_guid(WMID_GUID3).
Thank's for Thomas's review. :-)

The following is modified patch:

From d590461aa239b6db646fe5bd9e10e5ebeba63df7 Mon Sep 17 00:00:00 2001
From: Lee, Chun-Yi <jlee@novell.com>
Date: Sun, 31 Oct 2010 00:03:36 -0400
Subject: [PATCH 2/4] Enabled Acer Launch Manager mode

Enabled Acer Launch Manager mode to disable the EC raw behavior for
communication devices when WMID3 method available. And, we also add a
ec_raw_mode kernel module option for enable The EC raw behavior mode
when anyone what reset it back.
When Acer Launch Manager mode enabled, EC will stop to touch any
communication devices' RF state or power state that causes conflict
with rfkill_input or any userland daemon to charge the rfkill rules.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
---
 drivers/platform/x86/acer-wmi.c |  113
+++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c
b/drivers/platform/x86/acer-wmi.c
index 930df56..0b870d3 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
 #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
 #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
 #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
+#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
 
 /*
  * Acer ACPI event GUIDs
@@ -120,6 +121,20 @@ struct event_return_value {
 	u32 reserved;
 } __attribute__((packed));
 
+struct lm_input_params {
+	u8 function_num;	/* Function Number */
+	u16 commun_devices;	/* Communication type devices default status */
+	u16 devices;		/* Other type devices default status */
+	u8 lm_status;		/* Launch Manager Status */
+	u16 reserved;
+} __attribute__((packed));
+
+struct lm_return_value {
+	u8 error_code;		/* Error Code */
+	u8 ec_return_value;	/* EC Return Value */
+	u16 reserved;
+} __attribute__((packed));
+
 /*
  * Interface capability flags
  */
@@ -150,15 +165,18 @@ static int mailled = -1;
 static int brightness = -1;
 static int threeg = -1;
 static int force_series;
+static bool ec_raw_mode;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
 module_param(threeg, int, 0444);
 module_param(force_series, int, 0444);
+module_param(ec_raw_mode, bool, 0444);
 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
 MODULE_PARM_DESC(force_series, "Force a different laptop series");
+MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
 
 struct acer_data {
 	int mailled;
@@ -1393,6 +1411,87 @@ error_debugfs:
 	return -ENOMEM;
 }
 
+static acpi_status
+wmid3_set_lm_mode(struct lm_input_params *params,
+			struct lm_return_value *return_value)
+{
+	acpi_status status;
+	union acpi_object *obj;
+
+	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return -EINVAL;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return -EINVAL;
+	}
+	if (obj->buffer.length != 4) {
+		printk(ACER_WARNING "Unknown buffer length %d\n",
+			obj->buffer.length);
+		kfree(obj);
+		return -EINVAL;
+	}
+
+	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	return status;
+}
+
+static int acer_wmi_enable_ec_raw(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0xFFFF,
+		.devices = 0xFFFF,
+		.lm_status = 0x00,		/* Launch Manager Deactive */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling EC raw mode failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled EC raw mode");
+
+	return status;
+}
+
+static int acer_wmi_enable_lm(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
+		.devices = 0xFFFF,
+		.lm_status = 0x41,		/* Launch Manager Active */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling Launch Manager failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled Launch Manager");
+
+	return status;
+}
+
 static int __init acer_wmi_init(void)
 {
 	int err;
@@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
 		       "generic video driver\n");
 	}
 
+	if (wmi_has_guid(WMID_GUID3)) {
+		if (ec_raw_mode) {
+			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
+				printk(ACER_ERR "Cannot enable EC raw mode\n");
+				return -ENODEV;
+			}
+		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
+			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
+			return -ENODEV;
+		}
+	} else if (ec_raw_mode) {
+		printk(ACER_INFO "No WMID EC raw mode enable method\n");
+	}
+
 	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
 		err = acer_wmi_input_setup();
 		if (err)
-- 
1.6.0.2



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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/4] Enabled Acer Launch Manager mode
@ 2010-11-03 17:07 ` Joey Lee
  0 siblings, 0 replies; 12+ messages in thread
From: Joey Lee @ 2010-11-03 17:07 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: corentin.chary, dmitry.torokhov, Takashi Iwai, Thomas Renninger,
	mjg59, carlos, jbenc, trenn, linux-input

Hi all, 

於 六,2010-10-30 於 10:44 -0600,Joey Lee 提到:
> Add CC. Thomas
> >  
> > +	if (wmi_has_guid(WMID_GUID3)) {
> > +		if (ec_raw_mode) {
> > +			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
> > +				printk(ACER_ERR "Cannot enable EC raw mode\n");
> > +				return -ENODEV;
> > +			}
> > +		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
> > +			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
> > +			return -ENODEV;
> > +		}
> > +	} else if (!wmi_has_guid(WMID_GUID3) && ec_raw_mode) {
	^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Actually, Don't need check wmi_has_guid(WMID_GUID3).
Thank's for Thomas's review. :-)

The following is modified patch:

>From d590461aa239b6db646fe5bd9e10e5ebeba63df7 Mon Sep 17 00:00:00 2001
From: Lee, Chun-Yi <jlee@novell.com>
Date: Sun, 31 Oct 2010 00:03:36 -0400
Subject: [PATCH 2/4] Enabled Acer Launch Manager mode

Enabled Acer Launch Manager mode to disable the EC raw behavior for
communication devices when WMID3 method available. And, we also add a
ec_raw_mode kernel module option for enable The EC raw behavior mode
when anyone what reset it back.
When Acer Launch Manager mode enabled, EC will stop to touch any
communication devices' RF state or power state that causes conflict
with rfkill_input or any userland daemon to charge the rfkill rules.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
---
 drivers/platform/x86/acer-wmi.c |  113
+++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c
b/drivers/platform/x86/acer-wmi.c
index 930df56..0b870d3 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
 #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
 #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
 #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
+#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
 
 /*
  * Acer ACPI event GUIDs
@@ -120,6 +121,20 @@ struct event_return_value {
 	u32 reserved;
 } __attribute__((packed));
 
+struct lm_input_params {
+	u8 function_num;	/* Function Number */
+	u16 commun_devices;	/* Communication type devices default status */
+	u16 devices;		/* Other type devices default status */
+	u8 lm_status;		/* Launch Manager Status */
+	u16 reserved;
+} __attribute__((packed));
+
+struct lm_return_value {
+	u8 error_code;		/* Error Code */
+	u8 ec_return_value;	/* EC Return Value */
+	u16 reserved;
+} __attribute__((packed));
+
 /*
  * Interface capability flags
  */
@@ -150,15 +165,18 @@ static int mailled = -1;
 static int brightness = -1;
 static int threeg = -1;
 static int force_series;
+static bool ec_raw_mode;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
 module_param(threeg, int, 0444);
 module_param(force_series, int, 0444);
+module_param(ec_raw_mode, bool, 0444);
 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
 MODULE_PARM_DESC(force_series, "Force a different laptop series");
+MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
 
 struct acer_data {
 	int mailled;
@@ -1393,6 +1411,87 @@ error_debugfs:
 	return -ENOMEM;
 }
 
+static acpi_status
+wmid3_set_lm_mode(struct lm_input_params *params,
+			struct lm_return_value *return_value)
+{
+	acpi_status status;
+	union acpi_object *obj;
+
+	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return -EINVAL;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return -EINVAL;
+	}
+	if (obj->buffer.length != 4) {
+		printk(ACER_WARNING "Unknown buffer length %d\n",
+			obj->buffer.length);
+		kfree(obj);
+		return -EINVAL;
+	}
+
+	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	return status;
+}
+
+static int acer_wmi_enable_ec_raw(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0xFFFF,
+		.devices = 0xFFFF,
+		.lm_status = 0x00,		/* Launch Manager Deactive */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling EC raw mode failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled EC raw mode");
+
+	return status;
+}
+
+static int acer_wmi_enable_lm(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
+		.devices = 0xFFFF,
+		.lm_status = 0x41,		/* Launch Manager Active */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling Launch Manager failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled Launch Manager");
+
+	return status;
+}
+
 static int __init acer_wmi_init(void)
 {
 	int err;
@@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
 		       "generic video driver\n");
 	}
 
+	if (wmi_has_guid(WMID_GUID3)) {
+		if (ec_raw_mode) {
+			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
+				printk(ACER_ERR "Cannot enable EC raw mode\n");
+				return -ENODEV;
+			}
+		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
+			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
+			return -ENODEV;
+		}
+	} else if (ec_raw_mode) {
+		printk(ACER_INFO "No WMID EC raw mode enable method\n");
+	}
+
 	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
 		err = acer_wmi_input_setup();
 		if (err)
-- 
1.6.0.2



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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/4] Enabled Acer Launch Manager mode
  2010-10-30 16:36 [PATCH 1/4] Add acer wmi hotkey events support Lee, Chun-Yi
@ 2010-10-30 16:36 ` Lee, Chun-Yi
  0 siblings, 0 replies; 12+ messages in thread
From: Lee, Chun-Yi @ 2010-10-30 16:36 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: linux-input, carlos, corentin.chary, dmitry.torokhov, tiwai,
	trenn, mjg59, jbenc, Lee, Chun-Yi

Enabled Acer Launch Manager mode to disable the EC raw behavior for
communication devices when WMID3 method available. And, we also add a
ec_raw_mode kernel module option for enable The EC raw behavior mode
when anyone what reset it back.
When Acer Launch Manager mode enabled, EC will stop to touch any
communication devices' RF state or power state that causes conflict
with rfkill_input or any userland daemon to charge the rfkill rules.

Signed-off-by: Lee, Chun-Yi <jlee@novell.com>
---
 drivers/platform/x86/acer-wmi.c |  113 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 930df56..0b870d3 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -85,6 +85,7 @@ MODULE_LICENSE("GPL");
 #define AMW0_GUID2		"431F16ED-0C2B-444C-B267-27DEB140CF9C"
 #define WMID_GUID1		"6AF4F258-B401-42fd-BE91-3D4AC2D7C0D3"
 #define WMID_GUID2		"95764E09-FB56-4e83-B31A-37761F60994A"
+#define WMID_GUID3		"61EF69EA-865C-4BC3-A502-A0DEBA0CB531"
 
 /*
  * Acer ACPI event GUIDs
@@ -120,6 +121,20 @@ struct event_return_value {
 	u32 reserved;
 } __attribute__((packed));
 
+struct lm_input_params {
+	u8 function_num;	/* Function Number */
+	u16 commun_devices;	/* Communication type devices default status */
+	u16 devices;		/* Other type devices default status */
+	u8 lm_status;		/* Launch Manager Status */
+	u16 reserved;
+} __attribute__((packed));
+
+struct lm_return_value {
+	u8 error_code;		/* Error Code */
+	u8 ec_return_value;	/* EC Return Value */
+	u16 reserved;
+} __attribute__((packed));
+
 /*
  * Interface capability flags
  */
@@ -150,15 +165,18 @@ static int mailled = -1;
 static int brightness = -1;
 static int threeg = -1;
 static int force_series;
+static bool ec_raw_mode;
 
 module_param(mailled, int, 0444);
 module_param(brightness, int, 0444);
 module_param(threeg, int, 0444);
 module_param(force_series, int, 0444);
+module_param(ec_raw_mode, bool, 0444);
 MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
 MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
 MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
 MODULE_PARM_DESC(force_series, "Force a different laptop series");
+MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
 
 struct acer_data {
 	int mailled;
@@ -1393,6 +1411,87 @@ error_debugfs:
 	return -ENOMEM;
 }
 
+static acpi_status
+wmid3_set_lm_mode(struct lm_input_params *params,
+			struct lm_return_value *return_value)
+{
+	acpi_status status;
+	union acpi_object *obj;
+
+	struct acpi_buffer input = { sizeof(struct lm_input_params), params };
+	struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
+
+	status = wmi_evaluate_method(WMID_GUID3, 0, 0x1, &input, &output);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	obj = output.pointer;
+
+	if (!obj)
+		return -EINVAL;
+	else if (obj->type != ACPI_TYPE_BUFFER) {
+		kfree(obj);
+		return -EINVAL;
+	}
+	if (obj->buffer.length != 4) {
+		printk(ACER_WARNING "Unknown buffer length %d\n",
+			obj->buffer.length);
+		kfree(obj);
+		return -EINVAL;
+	}
+
+	*return_value = *((struct lm_return_value *)obj->buffer.pointer);
+	kfree(obj);
+
+	return status;
+}
+
+static int acer_wmi_enable_ec_raw(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0xFFFF,
+		.devices = 0xFFFF,
+		.lm_status = 0x00,		/* Launch Manager Deactive */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling EC raw mode failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled EC raw mode");
+
+	return status;
+}
+
+static int acer_wmi_enable_lm(void)
+{
+	struct lm_return_value return_value;
+	acpi_status status;
+	struct lm_input_params params = {
+		.function_num = 0x1,
+		.commun_devices = 0x0041,	/* WiFi on, 3G on, BT off */
+		.devices = 0xFFFF,
+		.lm_status = 0x41,		/* Launch Manager Active */
+	};
+
+	status = wmid3_set_lm_mode(&params, &return_value);
+
+	if (return_value.error_code || return_value.ec_return_value)
+		printk(ACER_WARNING "Enabling Launch Manager failed: "
+			"0x%x - 0x%x\n", return_value.error_code,
+			return_value.ec_return_value);
+	else
+		printk(ACER_INFO "Enabled Launch Manager");
+
+	return status;
+}
+
 static int __init acer_wmi_init(void)
 {
 	int err;
@@ -1454,6 +1553,20 @@ static int __init acer_wmi_init(void)
 		       "generic video driver\n");
 	}
 
+	if (wmi_has_guid(WMID_GUID3)) {
+		if (ec_raw_mode) {
+			if (ACPI_FAILURE(acer_wmi_enable_ec_raw())) {
+				printk(ACER_ERR "Cannot enable EC raw mode\n");
+				return -ENODEV;
+			}
+		} else if (ACPI_FAILURE(acer_wmi_enable_lm())) {
+			printk(ACER_ERR "Cannot enable Launch Manager mode\n");
+			return -ENODEV;
+		}
+	} else if (!wmi_has_guid(WMID_GUID3) && ec_raw_mode) {
+		printk(ACER_INFO "No WMID EC raw mode enable method\n");
+	}
+
 	if (wmi_has_guid(ACERWMID_EVENT_GUID)) {
 		err = acer_wmi_input_setup();
 		if (err)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-12-06  8:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-30 16:44 [PATCH 2/4] Enabled Acer Launch Manager mode Joey Lee
  -- strict thread matches above, loose matches on Subject: below --
2010-12-06  8:20 Joey Lee
2010-12-06  7:11 Joey Lee
2010-12-06  7:11 ` Joey Lee
2010-12-06  7:17 ` Corentin Chary
2010-12-04  1:03 [PATCH 0/4] Add new wmi support to acer-wmi driver Lee, Chun-Yi
2010-12-04  1:03 ` [PATCH 1/4] Add acer wmi hotkey events support Lee, Chun-Yi
2010-12-04  1:03   ` [PATCH 2/4] Enabled Acer Launch Manager mode Lee, Chun-Yi
2010-12-04  1:42     ` Dmitry Torokhov
2010-11-24 17:39 [PATCH 0/4] Add new wmi support to acer-wmi driver Lee, Chun-Yi
2010-11-24 17:39 ` [PATCH 1/4] Add acer wmi hotkey events support Lee, Chun-Yi
2010-11-24 17:39   ` [PATCH 2/4] Enabled Acer Launch Manager mode Lee, Chun-Yi
2010-11-24 19:49     ` Carlos Corbacho
2010-11-03 17:07 Joey Lee
2010-11-03 17:07 ` Joey Lee
2010-10-30 16:36 [PATCH 1/4] Add acer wmi hotkey events support Lee, Chun-Yi
2010-10-30 16:36 ` [PATCH 2/4] Enabled Acer Launch Manager mode Lee, Chun-Yi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.