Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 46470
b: refs/heads/master
c: 8b85735
h: refs/heads/master
v: v3
  • Loading branch information
Corentin Chary authored and Len Brown committed Jan 30, 2007
1 parent 97b946a commit 20eaca2
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 722ad97153015aaf5becba3084565e98e71a2aed
refs/heads/master: 8b857353237c144113b9bbbf9e0236b3f0e7d315
84 changes: 84 additions & 0 deletions trunk/drivers/misc/asus-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ ASUS_HANDLE(display_get,
"\\INFB", /* A2H D1 L2D L3D L3H L2E L5D L5C M1A M2E L4L W3V */
"\\SSTE"); /* A3F A6F A3N A3L M6N W3N W6A */

ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */
ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */

/*
* This is the main structure, we can use it to store anything interesting
* about the hotk device
Expand All @@ -155,6 +158,8 @@ struct asus_hotk {
acpi_handle handle; //the handle of the hotk device
char status; //status of the hotk, for LEDs, ...
u32 ledd_status; //status of the LED display
u8 light_level; //light sensor level
u8 light_switch; //light sensor switch value
u16 event_count[128]; //count for each event TODO make this better
};

Expand Down Expand Up @@ -590,6 +595,62 @@ static ssize_t store_disp(struct device *dev, struct device_attribute *attr,
return rv;
}

/*
* Light Sens
*/
static void set_light_sens_switch(int value)
{
if (!write_acpi_int(ls_switch_handle, NULL, value, NULL))
printk(ASUS_WARNING "Error setting light sensor switch\n");
hotk->light_switch = value;
}

static ssize_t show_lssw(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", hotk->light_switch);
}

static ssize_t store_lssw(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int rv, value;

rv = parse_arg(buf, count, &value);
if (rv > 0)
set_light_sens_switch(value ? 1 : 0);

return rv;
}

static void set_light_sens_level(int value)
{
if (!write_acpi_int(ls_level_handle, NULL, value, NULL))
printk(ASUS_WARNING "Error setting light sensor level\n");
hotk->light_level = value;
}

static ssize_t show_lslvl(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", hotk->light_level);
}

static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int rv, value;

rv = parse_arg(buf, count, &value);
if (rv > 0) {
value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
/* 0 <= value <= 15 */
set_light_sens_level(value);
}

return rv;
}

static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
{
/* TODO Find a better way to handle events count. */
Expand Down Expand Up @@ -636,13 +697,17 @@ static ASUS_CREATE_DEVICE_ATTR(wlan);
static ASUS_CREATE_DEVICE_ATTR(bluetooth);
static ASUS_CREATE_DEVICE_ATTR(display);
static ASUS_CREATE_DEVICE_ATTR(ledd);
static ASUS_CREATE_DEVICE_ATTR(ls_switch);
static ASUS_CREATE_DEVICE_ATTR(ls_level);

static struct attribute *asuspf_attributes[] = {
&dev_attr_infos.attr,
&dev_attr_wlan.attr,
&dev_attr_bluetooth.attr,
&dev_attr_display.attr,
&dev_attr_ledd.attr,
&dev_attr_ls_switch.attr,
&dev_attr_ls_level.attr,
NULL
};

Expand Down Expand Up @@ -679,6 +744,10 @@ static void asus_hotk_add_fs(void)
if (ledd_set_handle)
ASUS_SET_DEVICE_ATTR(ledd, 0644, show_ledd, store_ledd);

if (ls_switch_handle && ls_level_handle) {
ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl);
ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw);
}
}

static int asus_handle_init(char *name, acpi_handle *handle,
Expand Down Expand Up @@ -800,6 +869,11 @@ static int asus_hotk_get_info(void)
ASUS_HANDLE_INIT(display_set);
ASUS_HANDLE_INIT(display_get);

/* There is a lot of models with "ALSL", but a few get
a real light sens, so we need to check it. */
if(ASUS_HANDLE_INIT(ls_switch))
ASUS_HANDLE_INIT(ls_level);

kfree(model);

return AE_OK;
Expand Down Expand Up @@ -874,6 +948,16 @@ static int asus_hotk_add(struct acpi_device *device)
/* LED display is off by default */
hotk->ledd_status = 0xFFF;

/* Set initial values of light sensor and level */
hotk->light_switch = 1; /* Default to light sensor disabled */
hotk->light_level = 0; /* level 5 for sensor sensitivity */

if (ls_switch_handle)
set_light_sens_switch(hotk->light_switch);

if (ls_level_handle)
set_light_sens_level(hotk->light_level);

end:
if (result) {
kfree(hotk->name);
Expand Down

0 comments on commit 20eaca2

Please sign in to comment.