* [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
@ 2012-05-21 15:50 Максим Микитянский
2012-05-22 4:04 ` Ike Panhc
0 siblings, 1 reply; 11+ messages in thread
From: Максим Микитянский @ 2012-05-21 15:50 UTC (permalink / raw)
To: platform-driver-x86; +Cc: ike.pan
From: Maxim Mikityanskiy <maxtram95@gmail.com>
The patch adds support for Lenovo IdeaPad Z570 laptop. It makes all special
keys working, adds possibility to control fan like Windows does and controls
Touchpad Disabled LED.
Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
---
--- linux-source-3.2.0/drivers/platform/x86/ideapad-laptop.c.orig 2012-01-05
01:55:44.000000000 +0200
+++ linux-source-3.2.0/drivers/platform/x86/ideapad-laptop.c 2012-05-20
14:59:45.192052303 +0300
@@ -62,9 +62,12 @@ enum {
VPCCMD_W_CAMERA,
VPCCMD_R_3G,
VPCCMD_W_3G,
- VPCCMD_R_ODD, /* 0x21 */
- VPCCMD_R_RF = 0x23,
- VPCCMD_W_RF,
+ VPCCMD_R_ODD,
+ VPCCMD_W_FAN,
+ VPCCMD_R_RF,
+ VPCCMD_W_RF, /* 0x24 */
+ VPCCMD_R_FAN = 0x2B,
+ VPCCMD_R_SPECIAL_BUTTONS = 0x31,
VPCCMD_W_BL_POWER = 0x33,
};
@@ -363,8 +366,47 @@ static ssize_t store_ideapad_cam(struct
static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam);
+static ssize_t show_ideapad_fan(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ unsigned long result;
+
+ if (read_ec_data(ideapad_handle, VPCCMD_R_FAN, &result))
+ return sprintf(buf, "-1\n");
+ return sprintf(buf, "%lu\n", result);
+}
+
+static ssize_t store_ideapad_fan(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret, state;
+
+ if (!count)
+ return 0;
+ if (sscanf(buf, "%i", &state) != 1)
+ return -EINVAL;
+ /* WARNING: these fan states are not speed
+ * so it isn't cooling_device interface
+ * 0 = super silent mode
+ * 1 = standard mode
+ * 2 = dust cleaning
+ * 4 = efficient thermal dissipation mode
+ */
+ if (state < 0 || state > 4 || state == 3)
+ return -EINVAL;
+ ret = write_ec_cmd(ideapad_handle, VPCCMD_W_FAN, state);
+ if (ret < 0)
+ return ret;
+ return count;
+}
+
+static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
+
static struct attribute *ideapad_attributes[] = {
&dev_attr_camera_power.attr,
+ &dev_attr_fan_mode.attr,
NULL
};
@@ -379,6 +421,12 @@ static mode_t ideapad_is_visible(struct
if (attr == &dev_attr_camera_power.attr)
supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg));
else
+ if (attr == &dev_attr_fan_mode.attr)
+ /* I don't know a way to determine is there fan control
+ * on the device or not. For now suppose it is always
+ */
+ supported = true;
+ else
supported = true;
return supported ? attr->mode : 0;
@@ -519,9 +567,15 @@ static void ideapad_platform_exit(struct
*/
static const struct key_entry ideapad_keymap[] = {
{ KE_KEY, 6, { KEY_SWITCHVIDEOMODE } },
+ { KE_KEY, 7, { KEY_CAMERA } },
+ { KE_KEY, 11, { KEY_SWITCHVIDEOMODE } },
{ KE_KEY, 13, { KEY_WLAN } },
{ KE_KEY, 16, { KEY_PROG1 } },
{ KE_KEY, 17, { KEY_PROG2 } },
+ { KE_KEY, 64, { KEY_PROG3 } },
+ { KE_KEY, 65, { KEY_PROG4 } },
+ { KE_KEY, 66, { KEY_TOUCHPAD_OFF } },
+ { KE_KEY, 67, { KEY_TOUCHPAD_ON } },
{ KE_END, 0 },
};
@@ -767,6 +821,25 @@ static int __devexit ideapad_acpi_remove
return 0;
}
+static void ideapad_check_special_buttons(struct ideapad_private
*priv, unsigned long state)
+{
+ unsigned long bit;
+ for (bit = 0; bit < 16; bit++) {
+ if (test_bit(bit, &state)) {
+ switch (bit) {
+ case 6:
+ /* Thermal Management button */
+ ideapad_input_report(priv, 65);
+ break;
+ case 1:
+ /* OneKey Theater button */
+ ideapad_input_report(priv, 64);
+ break;
+ }
+ }
+ }
+}
+
static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event)
{
struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
@@ -785,6 +858,19 @@ static void ideapad_acpi_notify(struct a
case 9:
ideapad_sync_rfk_state(priv);
break;
+ case 5:
+ {
+ unsigned long value;
+ /* DO NOT DELETE: Without reading from EC touchpad LED doesn't
switch state */
+ if (!read_ec_data(handle, VPCCMD_R_TOUCHPAD, &value)) {
+ /* WARNING: IdeaPad doesn't really turn off touchpad -
+ * it only switches the LED state. Userspace should
+ * turn touchpad off and on. We send KEY_TOUCHPAD_OFF and
+ * KEY_TOUCHPAD_ON to not to get out of sync with LED */
+ ideapad_input_report(priv, value ? 67 : 66);
+ }
+ }
+ break;
case 4:
ideapad_backlight_notify_brightness(priv);
break;
@@ -794,6 +880,13 @@ static void ideapad_acpi_notify(struct a
case 2:
ideapad_backlight_notify_power(priv);
break;
+ case 0:
+ {
+ unsigned long value;
+ read_ec_data(handle, VPCCMD_R_SPECIAL_BUTTONS, &value);
+ ideapad_check_special_buttons(priv, value);
+ }
+ break;
default:
ideapad_input_report(priv, vpc_bit);
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-05-21 15:50 [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support Максим Микитянский
@ 2012-05-22 4:04 ` Ike Panhc
2012-05-22 8:53 ` Максим Микитянский
0 siblings, 1 reply; 11+ messages in thread
From: Ike Panhc @ 2012-05-22 4:04 UTC (permalink / raw)
To: Максим Микитянский
Cc: platform-driver-x86
This is a quick reply. Will make fully review later.
On 05/21/2012 11:50 PM, Максим Микитянский wrote:
> From: Maxim Mikityanskiy <maxtram95@gmail.com>
>
> The patch adds support for Lenovo IdeaPad Z570 laptop. It makes all special
> keys working, adds possibility to control fan like Windows does and controls
> Touchpad Disabled LED.
> Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
> ---
> --- linux-source-3.2.0/drivers/platform/x86/ideapad-laptop.c.orig 2012-01-05
> 01:55:44.000000000 +0200
> +++ linux-source-3.2.0/drivers/platform/x86/ideapad-laptop.c 2012-05-20
> 14:59:45.192052303 +0300
> @@ -62,9 +62,12 @@ enum {
> VPCCMD_W_CAMERA,
> VPCCMD_R_3G,
> VPCCMD_W_3G,
> - VPCCMD_R_ODD, /* 0x21 */
> - VPCCMD_R_RF = 0x23,
> - VPCCMD_W_RF,
> + VPCCMD_R_ODD,
> + VPCCMD_W_FAN,
> + VPCCMD_R_RF,
> + VPCCMD_W_RF, /* 0x24 */
> + VPCCMD_R_FAN = 0x2B,
> + VPCCMD_R_SPECIAL_BUTTONS = 0x31,
> VPCCMD_W_BL_POWER = 0x33,
> };
>
> @@ -363,8 +366,47 @@ static ssize_t store_ideapad_cam(struct
>
> static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam);
>
> +static ssize_t show_ideapad_fan(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + unsigned long result;
> +
> + if (read_ec_data(ideapad_handle, VPCCMD_R_FAN, &result))
> + return sprintf(buf, "-1\n");
> + return sprintf(buf, "%lu\n", result);
> +}
> +
> +static ssize_t store_ideapad_fan(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + int ret, state;
> +
> + if (!count)
> + return 0;
> + if (sscanf(buf, "%i", &state) != 1)
> + return -EINVAL;
> + /* WARNING: these fan states are not speed
> + * so it isn't cooling_device interface
> + * 0 = super silent mode
> + * 1 = standard mode
> + * 2 = dust cleaning
> + * 4 = efficient thermal dissipation mode
> + */
> + if (state < 0 || state > 4 || state == 3)
> + return -EINVAL;
IIRC 3 is also a valid number.
On your ideapad, what is the response after 3 is written?
> + ret = write_ec_cmd(ideapad_handle, VPCCMD_W_FAN, state);
> + if (ret < 0)
> + return ret;
> + return count;
> +}
> +
> +static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
> +
> static struct attribute *ideapad_attributes[] = {
> &dev_attr_camera_power.attr,
> + &dev_attr_fan_mode.attr,
Please also update Documentation/ABI/testing/sysfs-platform-ideapad-laptop
> NULL
> };
>
> @@ -379,6 +421,12 @@ static mode_t ideapad_is_visible(struct
> if (attr == &dev_attr_camera_power.attr)
> supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg));
> else
> + if (attr == &dev_attr_fan_mode.attr)
> + /* I don't know a way to determine is there fan control
> + * on the device or not. For now suppose it is always
> + */
> + supported = true;
> + else
Use VPCCMD_R_FAN maybe a good idea
> supported = true;
>
> return supported ? attr->mode : 0;
> @@ -519,9 +567,15 @@ static void ideapad_platform_exit(struct
> */
> static const struct key_entry ideapad_keymap[] = {
> { KE_KEY, 6, { KEY_SWITCHVIDEOMODE } },
> + { KE_KEY, 7, { KEY_CAMERA } },
> + { KE_KEY, 11, { KEY_SWITCHVIDEOMODE } },
Actually this is resolution change, I am not 100% comfortable with SWITCHVIDEOMODE.
I do not write it because I dont think we have keycode for resolution change.
> { KE_KEY, 13, { KEY_WLAN } },
> { KE_KEY, 16, { KEY_PROG1 } },
> { KE_KEY, 17, { KEY_PROG2 } },
> + { KE_KEY, 64, { KEY_PROG3 } },
> + { KE_KEY, 65, { KEY_PROG4 } },
> + { KE_KEY, 66, { KEY_TOUCHPAD_OFF } },
> + { KE_KEY, 67, { KEY_TOUCHPAD_ON } },
> { KE_END, 0 },
> };
>
> @@ -767,6 +821,25 @@ static int __devexit ideapad_acpi_remove
> return 0;
> }
>
> +static void ideapad_check_special_buttons(struct ideapad_private
> *priv, unsigned long state)
line over 80 characters. There are same 9 warnings from checkpatch.pl
> +{
> + unsigned long bit;
> + for (bit = 0; bit < 16; bit++) {
> + if (test_bit(bit, &state)) {
> + switch (bit) {
> + case 6:
> + /* Thermal Management button */
> + ideapad_input_report(priv, 65);
> + break;
> + case 1:
> + /* OneKey Theater button */
> + ideapad_input_report(priv, 64);
> + break;
> + }
> + }
> + }
> +}
> +
> static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event)
> {
> struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
> @@ -785,6 +858,19 @@ static void ideapad_acpi_notify(struct a
> case 9:
> ideapad_sync_rfk_state(priv);
> break;
> + case 5:
> + {
> + unsigned long value;
> + /* DO NOT DELETE: Without reading from EC touchpad LED doesn't
> switch state */
> + if (!read_ec_data(handle, VPCCMD_R_TOUCHPAD, &value)) {
> + /* WARNING: IdeaPad doesn't really turn off touchpad -
> + * it only switches the LED state. Userspace should
> + * turn touchpad off and on. We send KEY_TOUCHPAD_OFF and
> + * KEY_TOUCHPAD_ON to not to get out of sync with LED */
> + ideapad_input_report(priv, value ? 67 : 66);
> + }
> + }
On the ideapad I have, its EC to turn off the touchpad and camera, so I choose not
to report the event. How's the situation on your ideapad?
> + break;
> case 4:
> ideapad_backlight_notify_brightness(priv);
> break;
> @@ -794,6 +880,13 @@ static void ideapad_acpi_notify(struct a
> case 2:
> ideapad_backlight_notify_power(priv);
> break;
> + case 0:
> + {
> + unsigned long value;
> + read_ec_data(handle, VPCCMD_R_SPECIAL_BUTTONS, &value);
> + ideapad_check_special_buttons(priv, value);
> + }
> + break;
> default:
> ideapad_input_report(priv, vpc_bit);
> }
>
And could you also put the acpidump somewhere I can reach?
Many thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-05-22 4:04 ` Ike Panhc
@ 2012-05-22 8:53 ` Максим Микитянский
2012-05-25 10:19 ` Максим Микитянский
0 siblings, 1 reply; 11+ messages in thread
From: Максим Микитянский @ 2012-05-22 8:53 UTC (permalink / raw)
To: Ike Panhc; +Cc: platform-driver-x86
>IIRC 3 is also a valid number.
>On your ideapad, what is the response after 3 is written?
Writing 3 does the same thing as writing 4. But if I read with VPCCMD_R_FAN
after writing 3, I get 4. So I dropped 3, because it does absolutely the same
thing as 4 and EC never reports fan state as 3.
>Please also update Documentation/ABI/testing/sysfs-platform-ideapad-laptop
>Use VPCCMD_R_FAN maybe a good idea
>line over 80 characters. There are same 9 warnings from checkpatch.pl
Thank you, I fixed it.
>Actually this is resolution change, I am not 100% comfortable with SWITCHVIDEOMODE.
>I do not write it because I dont think we have keycode for resolution change.
I didn't find appropriate keycode, so decided to send KEY_SWITCHVIDEOMODE.
Of course, it is always possible to remap it via udev.
Really, my ideapad has Fn+F3 key, which should switch between one or two
screens and send KEY_SWITCHVIDEOMODE keycode, but it actually sends the same
codes as WinKey+P does, and I think, it is impossible to change that behavior
without reflashing patched BIOS. Fn+F4 should switch resolution, but we haven't
appropriate keycode. Would it be good idea to send KEY_F16 when pressing Fn+F4,
so that user could bind custom command, such as "gnome-control-center display"?
>On the ideapad I have, its EC to turn off the touchpad and camera, so I choose not
>to report the event. How's the situation on your ideapad?
I think it's good idea to report all events, so that userspace could display
some notifications. For example, GNOME shows nice notification when touchpad is
turned on and off. Also, my ideapad does not actually turn off touchpad. It
just changes the LED state, but touchpad needs to be turned off by software, so
reporting event is necessary.
Also, it is necessary to read from EC with VPCCMD_R_TOUCHPAD after receiving
touchpad event, because my ideapad doesn't even switch the LED state without
it. BTW, VPCCMD_W_TOUCHPAD does nothing on my ideapad.
The camera is turned on and off by EC without problems. But I think it's also
good idea to report this event to userspace too. Maybe, somewhen, GNOME or any
other program will show nice notifications about camera turning on and off, so
the driver will be ready to it. And finally, why not report event if we can and
it does not cause any problems?
>And could you also put the acpidump somewhere I can reach?
Yes, of course: http://paste.ubuntu.com/1000469/plain/
It is fixed version of patch:
--
The patch adds support for Lenovo IdeaPad Z570 laptop. It makes all special
keys working, adds possibility to control fan like Windows does and controls
Touchpad Disabled LED.
Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
--- linux-source-3.2.0/drivers/platform/x86/ideapad-laptop.c.orig 2012-01-05
01:55:44.000000000 +0200
+++ linux-source-3.2.0/drivers/platform/x86/ideapad-laptop.c 2012-05-22
11:14:34.119448775 +0300
@@ -62,9 +62,12 @@ enum {
VPCCMD_W_CAMERA,
VPCCMD_R_3G,
VPCCMD_W_3G,
- VPCCMD_R_ODD, /* 0x21 */
- VPCCMD_R_RF = 0x23,
- VPCCMD_W_RF,
+ VPCCMD_R_ODD,
+ VPCCMD_W_FAN,
+ VPCCMD_R_RF,
+ VPCCMD_W_RF, /* 0x24 */
+ VPCCMD_R_FAN = 0x2B,
+ VPCCMD_R_SPECIAL_BUTTONS = 0x31,
VPCCMD_W_BL_POWER = 0x33,
};
@@ -363,8 +366,47 @@ static ssize_t store_ideapad_cam(struct
static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam);
+static ssize_t show_ideapad_fan(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ unsigned long result;
+
+ if (read_ec_data(ideapad_handle, VPCCMD_R_FAN, &result))
+ return sprintf(buf, "-1\n");
+ return sprintf(buf, "%lu\n", result);
+}
+
+static ssize_t store_ideapad_fan(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret, state;
+
+ if (!count)
+ return 0;
+ if (sscanf(buf, "%i", &state) != 1)
+ return -EINVAL;
+ /* WARNING: these fan states are not speed
+ * so it isn't cooling_device interface
+ * 0 = super silent mode
+ * 1 = standard mode
+ * 2 = dust cleaning
+ * 4 = efficient thermal dissipation mode
+ */
+ if (state < 0 || state > 4 || state == 3)
+ return -EINVAL;
+ ret = write_ec_cmd(ideapad_handle, VPCCMD_W_FAN, state);
+ if (ret < 0)
+ return ret;
+ return count;
+}
+
+static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
+
static struct attribute *ideapad_attributes[] = {
&dev_attr_camera_power.attr,
+ &dev_attr_fan_mode.attr,
NULL
};
@@ -379,6 +421,10 @@ static mode_t ideapad_is_visible(struct
if (attr == &dev_attr_camera_power.attr)
supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg));
else
+ if (attr == &dev_attr_fan_mode.attr) {
+ unsigned long value;
+ supported = !read_ec_cmd(ideapad_handle, VPCCMD_R_FAN, &value);
+ } else
supported = true;
return supported ? attr->mode : 0;
@@ -519,9 +565,15 @@ static void ideapad_platform_exit(struct
*/
static const struct key_entry ideapad_keymap[] = {
{ KE_KEY, 6, { KEY_SWITCHVIDEOMODE } },
+ { KE_KEY, 7, { KEY_CAMERA } },
+ { KE_KEY, 11, { KEY_F16 } },
{ KE_KEY, 13, { KEY_WLAN } },
{ KE_KEY, 16, { KEY_PROG1 } },
{ KE_KEY, 17, { KEY_PROG2 } },
+ { KE_KEY, 64, { KEY_PROG3 } },
+ { KE_KEY, 65, { KEY_PROG4 } },
+ { KE_KEY, 66, { KEY_TOUCHPAD_OFF } },
+ { KE_KEY, 67, { KEY_TOUCHPAD_ON } },
{ KE_END, 0 },
};
@@ -767,6 +819,26 @@ static int __devexit ideapad_acpi_remove
return 0;
}
+static void ideapad_check_special_buttons(struct ideapad_private *priv,
+ unsigned long state)
+{
+ unsigned long bit;
+ for (bit = 0; bit < 16; bit++) {
+ if (test_bit(bit, &state)) {
+ switch (bit) {
+ case 6:
+ /* Thermal Management button */
+ ideapad_input_report(priv, 65);
+ break;
+ case 1:
+ /* OneKey Theater button */
+ ideapad_input_report(priv, 64);
+ break;
+ }
+ }
+ }
+}
+
static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event)
{
struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
@@ -785,6 +857,24 @@ static void ideapad_acpi_notify(struct a
case 9:
ideapad_sync_rfk_state(priv);
break;
+ case 5:
+ {
+ unsigned long value;
+ /* DO NOT DELETE: Without reading from EC
+ * touchpad LED doesn't switch state */
+ if (!read_ec_data(handle, VPCCMD_R_TOUCHPAD,
+ &value)) {
+ /* WARNING: IdeaPad doesn't really turn
+ * off touchpad - it only switches the
+ * LED state. Userspace should turn
+ * touchpad off and on. We send
+ * KEY_TOUCHPAD_OFF and KEY_TOUCHPAD_ON
+ * to not to get out of sync with LED */
+ ideapad_input_report(priv,
+ value ? 67 : 66);
+ }
+ }
+ break;
case 4:
ideapad_backlight_notify_brightness(priv);
break;
@@ -794,6 +884,14 @@ static void ideapad_acpi_notify(struct a
case 2:
ideapad_backlight_notify_power(priv);
break;
+ case 0:
+ {
+ unsigned long value;
+ read_ec_data(handle, VPCCMD_R_SPECIAL_BUTTONS,
+ &value);
+ ideapad_check_special_buttons(priv, value);
+ }
+ break;
default:
ideapad_input_report(priv, vpc_bit);
}
--- linux-source-3.2.0/Documentation/ABI/testing/sysfs-platform-ideapad-laptop.orig 2012-05-22
10:13:05.367557763 +0300
+++ linux-source-3.2.0/Documentation/ABI/testing/sysfs-platform-ideapad-laptop 2012-05-22
10:16:00.399552595 +0300
@@ -5,4 +5,14 @@ Contact: "Ike Panhc <ike.pan@canonical.c
Description:
Control the power of camera module. 1 means on, 0 means off.
-
+What: /sys/devices/platform/ideapad/fan_mode
+Date: May 2012
+KernelVersion: 3.2.14
+Contact: "Ike Panhc <ike.pan@canonical.com>"
+Description:
+ Change fan mode
+ There are four available modes:
+ * 0 -> Super Silent Mode
+ * 1 -> Standard Mode
+ * 2 -> Dust Cleaning
+ * 4 -> Efficient Thermal Dissipation Mode
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-05-22 8:53 ` Максим Микитянский
@ 2012-05-25 10:19 ` Максим Микитянский
0 siblings, 0 replies; 11+ messages in thread
From: Максим Микитянский @ 2012-05-25 10:19 UTC (permalink / raw)
To: Ike Panhc; +Cc: platform-driver-x86
>+ supported = !read_ec_cmd(ideapad_handle, VPCCMD_R_FAN, &value);
I'm sorry, there is a typo, this line should look like this:
+ supported = !read_ec_data(ideapad_handle, VPCCMD_R_FAN, &value);
Here is the latest version of the patch: http://paste.ubuntu.com/1006185/
Didn't send it in letter body, because it's mostly the same as previous.
So what about the patch?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
@ 2012-06-04 11:56 Maxim Mikityanskiy
2012-06-26 18:31 ` Matthew Garrett
0 siblings, 1 reply; 11+ messages in thread
From: Maxim Mikityanskiy @ 2012-06-04 11:56 UTC (permalink / raw)
To: platform-driver-x86; +Cc: ike.pan
The patch adds support for Lenovo IdeaPad Z570 laptop. It makes all special
keys working, adds possibility to control fan like Windows does and controls
Touchpad Disabled LED.
Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
--- linux/drivers/platform/x86/ideapad-laptop.c
+++ linux/drivers/platform/x86/ideapad-laptop.c
@@ -62,9 +62,12 @@ enum {
VPCCMD_W_CAMERA,
VPCCMD_R_3G,
VPCCMD_W_3G,
- VPCCMD_R_ODD, /* 0x21 */
- VPCCMD_R_RF = 0x23,
- VPCCMD_W_RF,
+ VPCCMD_R_ODD,
+ VPCCMD_W_FAN,
+ VPCCMD_R_RF,
+ VPCCMD_W_RF, /* 0x24 */
+ VPCCMD_R_FAN = 0x2B,
+ VPCCMD_R_SPECIAL_BUTTONS = 0x31,
VPCCMD_W_BL_POWER = 0x33,
};
@@ -363,8 +366,47 @@ static ssize_t store_ideapad_cam(struct
static DEVICE_ATTR(camera_power, 0644, show_ideapad_cam, store_ideapad_cam);
+static ssize_t show_ideapad_fan(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ unsigned long result;
+
+ if (read_ec_data(ideapad_handle, VPCCMD_R_FAN, &result))
+ return sprintf(buf, "-1\n");
+ return sprintf(buf, "%lu\n", result);
+}
+
+static ssize_t store_ideapad_fan(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret, state;
+
+ if (!count)
+ return 0;
+ if (sscanf(buf, "%i", &state) != 1)
+ return -EINVAL;
+ /* WARNING: these fan states are not speed
+ * so it isn't cooling_device interface
+ * 0 = super silent mode
+ * 1 = standard mode
+ * 2 = dust cleaning
+ * 4 = efficient thermal dissipation mode
+ */
+ if (state < 0 || state > 4 || state == 3)
+ return -EINVAL;
+ ret = write_ec_cmd(ideapad_handle, VPCCMD_W_FAN, state);
+ if (ret < 0)
+ return ret;
+ return count;
+}
+
+static DEVICE_ATTR(fan_mode, 0644, show_ideapad_fan, store_ideapad_fan);
+
static struct attribute *ideapad_attributes[] = {
&dev_attr_camera_power.attr,
+ &dev_attr_fan_mode.attr,
NULL
};
@@ -379,6 +421,10 @@ static mode_t ideapad_is_visible(struct
if (attr == &dev_attr_camera_power.attr)
supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg));
else
+ if (attr == &dev_attr_fan_mode.attr) {
+ unsigned long value;
+ supported = !read_ec_data(ideapad_handle, VPCCMD_R_FAN, &value);
+ } else
supported = true;
return supported ? attr->mode : 0;
@@ -519,9 +565,15 @@ static void ideapad_platform_exit(struct
*/
static const struct key_entry ideapad_keymap[] = {
{ KE_KEY, 6, { KEY_SWITCHVIDEOMODE } },
+ { KE_KEY, 7, { KEY_CAMERA } },
+ { KE_KEY, 11, { KEY_F16 } },
{ KE_KEY, 13, { KEY_WLAN } },
{ KE_KEY, 16, { KEY_PROG1 } },
{ KE_KEY, 17, { KEY_PROG2 } },
+ { KE_KEY, 64, { KEY_PROG3 } },
+ { KE_KEY, 65, { KEY_PROG4 } },
+ { KE_KEY, 66, { KEY_TOUCHPAD_OFF } },
+ { KE_KEY, 67, { KEY_TOUCHPAD_ON } },
{ KE_END, 0 },
};
@@ -767,6 +819,26 @@ static int __devexit ideapad_acpi_remove
return 0;
}
+static void ideapad_check_special_buttons(struct ideapad_private *priv,
+ unsigned long state)
+{
+ unsigned long bit;
+ for (bit = 0; bit < 16; bit++) {
+ if (test_bit(bit, &state)) {
+ switch (bit) {
+ case 6:
+ /* Thermal Management button */
+ ideapad_input_report(priv, 65);
+ break;
+ case 1:
+ /* OneKey Theater button */
+ ideapad_input_report(priv, 64);
+ break;
+ }
+ }
+ }
+}
+
static void ideapad_acpi_notify(struct acpi_device *adevice, u32 event)
{
struct ideapad_private *priv = dev_get_drvdata(&adevice->dev);
@@ -785,6 +857,24 @@ static void ideapad_acpi_notify(struct a
case 9:
ideapad_sync_rfk_state(priv);
break;
+ case 5:
+ {
+ unsigned long value;
+ /* DO NOT DELETE: Without reading from EC
+ * touchpad LED doesn't switch state */
+ if (!read_ec_data(handle, VPCCMD_R_TOUCHPAD,
+ &value)) {
+ /* WARNING: IdeaPad doesn't really turn
+ * off touchpad - it only switches the
+ * LED state. Userspace should turn
+ * touchpad off and on. We send
+ * KEY_TOUCHPAD_OFF and KEY_TOUCHPAD_ON
+ * to not to get out of sync with LED */
+ ideapad_input_report(priv,
+ value ? 67 : 66);
+ }
+ }
+ break;
case 4:
ideapad_backlight_notify_brightness(priv);
break;
@@ -794,6 +884,14 @@ static void ideapad_acpi_notify(struct a
case 2:
ideapad_backlight_notify_power(priv);
break;
+ case 0:
+ {
+ unsigned long value;
+ read_ec_data(handle, VPCCMD_R_SPECIAL_BUTTONS,
+ &value);
+ ideapad_check_special_buttons(priv, value);
+ }
+ break;
default:
ideapad_input_report(priv, vpc_bit);
}
--- linux/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
+++ linux/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
@@ -5,4 +5,14 @@ Contact: "Ike Panhc <ike.pan@canonical.c
Description:
Control the power of camera module. 1 means on, 0 means off.
-
+What: /sys/devices/platform/ideapad/fan_mode
+Date: June 2012
+KernelVersion: 3.5
+Contact: "Ike Panhc <ike.pan@canonical.com>"
+Description:
+ Change fan mode
+ There are four available modes:
+ * 0 -> Super Silent Mode
+ * 1 -> Standard Mode
+ * 2 -> Dust Cleaning
+ * 4 -> Efficient Thermal Dissipation Mode
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-06-04 11:56 Maxim Mikityanskiy
@ 2012-06-26 18:31 ` Matthew Garrett
2012-06-28 9:55 ` Ike Panhc
2012-07-04 10:09 ` Ike Panhc
0 siblings, 2 replies; 11+ messages in thread
From: Matthew Garrett @ 2012-06-26 18:31 UTC (permalink / raw)
To: Maxim Mikityanskiy; +Cc: platform-driver-x86, ike.pan
Ike, feelings on this? Do we know that these EC offsets are stable?
--
Matthew Garrett | mjg59@srcf.ucam.org
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-06-26 18:31 ` Matthew Garrett
@ 2012-06-28 9:55 ` Ike Panhc
2012-07-04 10:09 ` Ike Panhc
1 sibling, 0 replies; 11+ messages in thread
From: Ike Panhc @ 2012-06-28 9:55 UTC (permalink / raw)
To: Matthew Garrett; +Cc: Maxim Mikityanskiy, platform-driver-x86
On 06/27/2012 02:31 AM, Matthew Garrett wrote:
> Ike, feelings on this? Do we know that these EC offsets are stable?
>
They are stable. Since we have several ideapad patches for this cycle, I will prepare the git branch for you to pull soon.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-06-26 18:31 ` Matthew Garrett
2012-06-28 9:55 ` Ike Panhc
@ 2012-07-04 10:09 ` Ike Panhc
2012-07-04 15:09 ` Maxim Mikityanskiy
1 sibling, 1 reply; 11+ messages in thread
From: Ike Panhc @ 2012-07-04 10:09 UTC (permalink / raw)
To: Matthew Garrett; +Cc: Maxim Mikityanskiy, platform-driver-x86
On 06/27/2012 02:31 AM, Matthew Garrett wrote:
> Ike, feelings on this? Do we know that these EC offsets are stable?
>
Hi Maxim,
I separate your patch into three smaller patch. It makes me easier to understand the detail. Please review if all function are still working fine on your ideapad
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-07-04 10:09 ` Ike Panhc
@ 2012-07-04 15:09 ` Maxim Mikityanskiy
2012-07-05 11:09 ` Ike Panhc
0 siblings, 1 reply; 11+ messages in thread
From: Maxim Mikityanskiy @ 2012-07-04 15:09 UTC (permalink / raw)
To: Ike Panhc; +Cc: Matthew Garrett, platform-driver-x86
> Hi Maxim,
>
> I separate your patch into three smaller patch. It makes me easier to understand the detail. Please review if all function are still working fine on your ideapad
Hello Ike,
I have tested these patches and there is one problem in the part 2 of patch.
Build fails, because you missed '+#include <linux/i8042.h>' line of original
patch. Errors are at lines:
> + i8042_command(¶m, value ? I8042_CMD_AUX_ENABLE :
> + I8042_CMD_AUX_DISABLE);
When I add '#include <linux/i8042.h>' manually, build succeeds and all
functions work properly. Please add missing include to the second patch.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-07-04 15:09 ` Maxim Mikityanskiy
@ 2012-07-05 11:09 ` Ike Panhc
2012-07-05 11:41 ` Maxim Mikityanskiy
0 siblings, 1 reply; 11+ messages in thread
From: Ike Panhc @ 2012-07-05 11:09 UTC (permalink / raw)
To: Maxim Mikityanskiy; +Cc: Matthew Garrett, platform-driver-x86
Thanks. I have the patch tested on my ideapads. They all looks fine.
The last thing I need is ACK for psmouse patch.
On 07/04/2012 11:09 PM, Maxim Mikityanskiy wrote:
>> Hi Maxim,
>>
>> I separate your patch into three smaller patch. It makes me easier to understand the detail. Please review if all function are still working fine on your ideapad
>
> Hello Ike,
>
> I have tested these patches and there is one problem in the part 2 of patch.
> Build fails, because you missed '+#include <linux/i8042.h>' line of original
> patch. Errors are at lines:
>
>> + i8042_command(¶m, value ? I8042_CMD_AUX_ENABLE :
>> + I8042_CMD_AUX_DISABLE);
>
> When I add '#include <linux/i8042.h>' manually, build succeeds and all
> functions work properly. Please add missing include to the second patch.
>
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" 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] 11+ messages in thread
* Re: [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support
2012-07-05 11:09 ` Ike Panhc
@ 2012-07-05 11:41 ` Maxim Mikityanskiy
0 siblings, 0 replies; 11+ messages in thread
From: Maxim Mikityanskiy @ 2012-07-05 11:41 UTC (permalink / raw)
To: Ike Panhc; +Cc: Matthew Garrett, platform-driver-x86
> Thanks. I have the patch tested on my ideapads. They all looks fine.
>
> The last thing I need is ACK for psmouse patch.
Psmouse patch is not needed any more, all things work without it because now
touchpad is being toggled with i8042_command() without any intrusion into
psmouse driver.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-07-05 11:41 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-21 15:50 [PATCH] drivers/platform/x86: Lenovo IdeaPad Z570 support Максим Микитянский
2012-05-22 4:04 ` Ike Panhc
2012-05-22 8:53 ` Максим Микитянский
2012-05-25 10:19 ` Максим Микитянский
-- strict thread matches above, loose matches on Subject: below --
2012-06-04 11:56 Maxim Mikityanskiy
2012-06-26 18:31 ` Matthew Garrett
2012-06-28 9:55 ` Ike Panhc
2012-07-04 10:09 ` Ike Panhc
2012-07-04 15:09 ` Maxim Mikityanskiy
2012-07-05 11:09 ` Ike Panhc
2012-07-05 11:41 ` Maxim Mikityanskiy
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.