Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 321880
b: refs/heads/master
c: 0c7bbeb
h: refs/heads/master
v: v3
  • Loading branch information
Maxim Mikityanskiy authored and Matthew Garrett committed Aug 20, 2012
1 parent 3a39c08 commit d33249d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 07a4a4fc83dd95bc7eb842cf9510ddcb45691a88
refs/heads/master: 0c7bbeb9f1373cea9e8efb43221118be2102a01c
11 changes: 11 additions & 0 deletions trunk/Documentation/ABI/testing/sysfs-platform-ideapad-laptop
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,15 @@ Contact: "Ike Panhc <ike.pan@canonical.com>"
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.6
Contact: "Maxim Mikityanskiy <maxtram95@gmail.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

43 changes: 40 additions & 3 deletions trunk/drivers/platform/x86/ideapad-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ enum {
VPCCMD_R_3G,
VPCCMD_W_3G,
VPCCMD_R_ODD, /* 0x21 */
VPCCMD_R_RF = 0x23,
VPCCMD_W_FAN,
VPCCMD_R_RF,
VPCCMD_W_RF,
VPCCMD_R_FAN = 0x2B,
VPCCMD_R_SPECIAL_BUTTONS = 0x31,
VPCCMD_W_BL_POWER = 0x33,
};
Expand Down Expand Up @@ -358,14 +360,46 @@ static ssize_t store_ideapad_cam(struct device *dev,
return -EINVAL;
ret = write_ec_cmd(ideapad_handle, VPCCMD_W_CAMERA, state);
if (ret < 0)
return ret;
return -EIO;
return count;
}

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;
if (state < 0 || state > 4 || state == 3)
return -EINVAL;
ret = write_ec_cmd(ideapad_handle, VPCCMD_W_FAN, state);
if (ret < 0)
return -EIO;
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
};

Expand All @@ -379,7 +413,10 @@ static umode_t ideapad_is_visible(struct kobject *kobj,

if (attr == &dev_attr_camera_power.attr)
supported = test_bit(CFG_CAMERA_BIT, &(priv->cfg));
else
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;
Expand Down

0 comments on commit d33249d

Please sign in to comment.