提交 e539c2f6 编写于 作者: C Corentin Chary 提交者: Len Brown

asus-laptop: add GPS support

Just adds GPS support found in R2H thanks to Sam Lin.  It will
make a "gps" file in /sys/devices/platform/asus-laptop/.
Signed-off-by: NCorentin Chary <corentincj@iksaif.net>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 a9dbcb37
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* Eric Burghard - LED display support for W1N * Eric Burghard - LED display support for W1N
* Josh Green - Light Sens support * Josh Green - Light Sens support
* Thomas Tuttle - His first patch for led support was very helpfull * Thomas Tuttle - His first patch for led support was very helpfull
* * Sam Lin - GPS support
*/ */
#include <linux/autoconf.h> #include <linux/autoconf.h>
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#define PLED_ON 0x20 //Phone LED #define PLED_ON 0x20 //Phone LED
#define GLED_ON 0x40 //Gaming LED #define GLED_ON 0x40 //Gaming LED
#define LCD_ON 0x80 //LCD backlight #define LCD_ON 0x80 //LCD backlight
#define GPS_ON 0x100 //GPS
#define ASUS_LOG ASUS_HOTK_FILE ": " #define ASUS_LOG ASUS_HOTK_FILE ": "
#define ASUS_ERR KERN_ERR ASUS_LOG #define ASUS_ERR KERN_ERR ASUS_LOG
...@@ -162,6 +163,12 @@ ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L ...@@ -162,6 +163,12 @@ ASUS_HANDLE(display_get, "\\_SB.PCI0.P0P1.VGA.GETD", /* A6B, A6K A6R A7D F3JM L
ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */ ASUS_HANDLE(ls_switch, ASUS_HOTK_PREFIX "ALSC"); /* Z71A Z71V */
ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */ ASUS_HANDLE(ls_level, ASUS_HOTK_PREFIX "ALSL"); /* Z71A Z71V */
/* GPS */
/* R2H use different handle for GPS on/off */
ASUS_HANDLE(gps_on, ASUS_HOTK_PREFIX "SDON"); /* R2H */
ASUS_HANDLE(gps_off, ASUS_HOTK_PREFIX "SDOF"); /* R2H */
ASUS_HANDLE(gps_status, ASUS_HOTK_PREFIX "GPST");
/* /*
* This is the main structure, we can use it to store anything interesting * This is the main structure, we can use it to store anything interesting
* about the hotk device * about the hotk device
...@@ -278,12 +285,27 @@ static int read_wireless_status(int mask) ...@@ -278,12 +285,27 @@ static int read_wireless_status(int mask)
return (hotk->status & mask) ? 1 : 0; return (hotk->status & mask) ? 1 : 0;
} }
static int read_gps_status(void) {
ulong status;
acpi_status rv = AE_OK;
rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status);
if (ACPI_FAILURE(rv))
printk(ASUS_WARNING "Error reading GPS status\n");
else
return status ? 1 : 0;
return (hotk->status & GPS_ON) ? 1 : 0;
}
/* Generic LED functions */ /* Generic LED functions */
static int read_status(int mask) static int read_status(int mask)
{ {
/* There is a special method for both wireless devices */ /* There is a special method for both wireless devices */
if (mask == BT_ON || mask == WL_ON) if (mask == BT_ON || mask == WL_ON)
return read_wireless_status(mask); return read_wireless_status(mask);
else if(mask == GPS_ON)
return read_gps_status();
return (hotk->status & mask) ? 1 : 0; return (hotk->status & mask) ? 1 : 0;
} }
...@@ -299,6 +321,10 @@ static void write_status(acpi_handle handle, int out, int mask) ...@@ -299,6 +321,10 @@ static void write_status(acpi_handle handle, int out, int mask)
case GLED_ON: case GLED_ON:
out = (out & 0x1) + 1; out = (out & 0x1) + 1;
break; break;
case GPS_ON:
handle = (out) ? gps_on_handle : gps_off_handle;
out = 0x02;
break;
default: default:
out &= 0x1; out &= 0x1;
break; break;
...@@ -667,6 +693,21 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, ...@@ -667,6 +693,21 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr,
return rv; return rv;
} }
/*
* GPS
*/
static ssize_t show_gps(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", read_status(GPS_ON));
}
static ssize_t store_gps(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
return store_status(buf, count, NULL, GPS_ON);
}
static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
{ {
/* TODO Find a better way to handle events count. */ /* TODO Find a better way to handle events count. */
...@@ -715,6 +756,7 @@ static ASUS_CREATE_DEVICE_ATTR(display); ...@@ -715,6 +756,7 @@ static ASUS_CREATE_DEVICE_ATTR(display);
static ASUS_CREATE_DEVICE_ATTR(ledd); static ASUS_CREATE_DEVICE_ATTR(ledd);
static ASUS_CREATE_DEVICE_ATTR(ls_switch); static ASUS_CREATE_DEVICE_ATTR(ls_switch);
static ASUS_CREATE_DEVICE_ATTR(ls_level); static ASUS_CREATE_DEVICE_ATTR(ls_level);
static ASUS_CREATE_DEVICE_ATTR(gps);
static struct attribute *asuspf_attributes[] = { static struct attribute *asuspf_attributes[] = {
&dev_attr_infos.attr, &dev_attr_infos.attr,
...@@ -724,6 +766,7 @@ static struct attribute *asuspf_attributes[] = { ...@@ -724,6 +766,7 @@ static struct attribute *asuspf_attributes[] = {
&dev_attr_ledd.attr, &dev_attr_ledd.attr,
&dev_attr_ls_switch.attr, &dev_attr_ls_switch.attr,
&dev_attr_ls_level.attr, &dev_attr_ls_level.attr,
&dev_attr_gps.attr,
NULL NULL
}; };
...@@ -763,6 +806,9 @@ static void asus_hotk_add_fs(void) ...@@ -763,6 +806,9 @@ static void asus_hotk_add_fs(void)
ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl); ASUS_SET_DEVICE_ATTR(ls_level, 0644, show_lslvl, store_lslvl);
ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw); ASUS_SET_DEVICE_ATTR(ls_switch, 0644, show_lssw, store_lssw);
} }
if(gps_status_handle && gps_on_handle && gps_off_handle)
ASUS_SET_DEVICE_ATTR(gps, 0644, show_gps, store_gps);
} }
static int asus_handle_init(char *name, acpi_handle * handle, static int asus_handle_init(char *name, acpi_handle * handle,
...@@ -893,6 +939,10 @@ static int asus_hotk_get_info(void) ...@@ -893,6 +939,10 @@ static int asus_hotk_get_info(void)
if (ASUS_HANDLE_INIT(ls_switch)) if (ASUS_HANDLE_INIT(ls_switch))
ASUS_HANDLE_INIT(ls_level); ASUS_HANDLE_INIT(ls_level);
ASUS_HANDLE_INIT(gps_on);
ASUS_HANDLE_INIT(gps_off);
ASUS_HANDLE_INIT(gps_status);
kfree(model); kfree(model);
return AE_OK; return AE_OK;
...@@ -981,6 +1031,9 @@ static int asus_hotk_add(struct acpi_device *device) ...@@ -981,6 +1031,9 @@ static int asus_hotk_add(struct acpi_device *device)
if (ls_level_handle) if (ls_level_handle)
set_light_sens_level(hotk->light_level); set_light_sens_level(hotk->light_level);
/* GPS is on by default */
write_status(NULL, 1, GPS_ON);
end: end:
if (result) { if (result) {
kfree(hotk->name); kfree(hotk->name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册