* [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS
@ 2011-01-24 22:48 Andy Ross
[not found] ` <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Andy Ross @ 2011-01-24 22:48 UTC (permalink / raw)
To: Dmitry Torokhov, Corentin Chary, linux-input, acpi4asus-user,
platform-driver-x86
Resubmission and update of the Pegatron Lucid tablet accelerometer and
ambient light sensor drivers.
Patches 1-3 are against asus-laptop, and apply in order.
Patch 4 is against input, and can be commited separately (obviously
relies on the detection code in asus-laptop at runtime, but will build
and load independently).
Andy
^ permalink raw reply [flat|nested] 12+ messages in thread[parent not found: <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>]
* [PATCH 1/4] asus-laptop: Device detection for Pegatron Lucid tablets [not found] ` <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> @ 2011-01-24 22:48 ` Andy Ross 2011-01-24 23:05 ` [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Dmitry Torokhov 1 sibling, 0 replies; 12+ messages in thread From: Andy Ross @ 2011-01-24 22:48 UTC (permalink / raw) To: Dmitry Torokhov, Corentin Chary, linux-input-u79uwXL29TY76Z2rM5mHXA, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, platform-driver-x86-u79uwXL29TY76Z2rM5mHXA Recognize the Pegatron Lucid tablet devices (which share the same "\_SB.ATKD" namespace) by the result of their INIT method and the presence of some specific methods. Signed-off-by: Andy Ross <andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> --- drivers/platform/x86/asus-laptop.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index d235f44..6f542af 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -4,6 +4,7 @@ * * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor * Copyright (C) 2006-2007 Corentin Chary + * Copyright (C) 2011 Wind River Systems * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -210,6 +211,18 @@ static char *display_get_paths[] = { #define METHOD_KBD_LIGHT_SET "SLKB" #define METHOD_KBD_LIGHT_GET "GLKB" +/* For Pegatron Lucid tablet */ +#define DEVICE_NAME_PEGA "Lucid" + +#define METHOD_PEGA_ENABLE "ENPR" +#define METHOD_PEGA_DISABLE "DAPR" +#define PEGA_ALS 0x04 +#define PEGA_ALS_POWER 0x05 + +#define METHOD_PEGA_READ "RDLN" +#define PEGA_READ_ALS_H 0x02 +#define PEGA_READ_ALS_L 0x03 + /* * Define a specific led structure to keep the main structure clean */ @@ -246,6 +259,7 @@ struct asus_laptop { int wireless_status; bool have_rsts; + bool have_pega_lucid; int lcd_state; struct rfkill *gps_rfkill; @@ -361,6 +375,14 @@ static int acpi_check_handle(acpi_handle handle, const char *method, return 0; } +static bool asus_check_pega_lucid(struct asus_laptop *asus) +{ + return !strcmp(asus->name, DEVICE_NAME_PEGA) && + !acpi_check_handle(asus->handle, METHOD_PEGA_ENABLE, NULL) && + !acpi_check_handle(asus->handle, METHOD_PEGA_DISABLE, NULL) && + !acpi_check_handle(asus->handle, METHOD_PEGA_READ, NULL); +} + /* Generic LED function */ static int asus_led_set(struct asus_laptop *asus, const char *method, int value) @@ -1334,7 +1356,6 @@ static mode_t asus_sysfs_is_visible(struct kobject *kobj, attr == &dev_attr_ls_level.attr) { supported = !acpi_check_handle(handle, METHOD_ALS_CONTROL, NULL) && !acpi_check_handle(handle, METHOD_ALS_LEVEL, NULL); - } else if (attr == &dev_attr_gps.attr) { supported = !acpi_check_handle(handle, METHOD_GPS_ON, NULL) && !acpi_check_handle(handle, METHOD_GPS_OFF, NULL) && @@ -1605,6 +1626,8 @@ static int __devinit asus_acpi_add(struct acpi_device *device) if (result) goto fail_rfkill; + asus->have_pega_lucid = asus_check_pega_lucid(asus); + asus_device_present = true; return 0; -- 1.7.1 ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS [not found] ` <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> 2011-01-24 22:48 ` [PATCH 1/4] asus-laptop: Device detection for Pegatron Lucid tablets Andy Ross @ 2011-01-24 23:05 ` Dmitry Torokhov 2011-01-25 7:30 ` Corentin Chary 1 sibling, 1 reply; 12+ messages in thread From: Dmitry Torokhov @ 2011-01-24 23:05 UTC (permalink / raw) To: Andy Ross Cc: acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, platform-driver-x86-u79uwXL29TY76Z2rM5mHXA, linux-input-u79uwXL29TY76Z2rM5mHXA On Mon, Jan 24, 2011 at 02:48:04PM -0800, Andy Ross wrote: > Resubmission and update of the Pegatron Lucid tablet accelerometer and > ambient light sensor drivers. > > Patches 1-3 are against asus-laptop, and apply in order. > > Patch 4 is against input, and can be commited separately (obviously > relies on the detection code in asus-laptop at runtime, but will build > and load independently). > I am happy with the input part but I wonder if it really needs to be separate? If you roll it up into asus-laptop you would not need a new platform device and then it would be what - 20 lines of code? Corentin, what do you think? Thanks. -- Dmitry ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS 2011-01-24 23:05 ` [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Dmitry Torokhov @ 2011-01-25 7:30 ` Corentin Chary 2011-01-25 16:43 ` Andy Ross 0 siblings, 1 reply; 12+ messages in thread From: Corentin Chary @ 2011-01-25 7:30 UTC (permalink / raw) To: Dmitry Torokhov Cc: Andy Ross, linux-input, acpi4asus-user, platform-driver-x86 On Tue, Jan 25, 2011 at 12:05 AM, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote: > On Mon, Jan 24, 2011 at 02:48:04PM -0800, Andy Ross wrote: >> Resubmission and update of the Pegatron Lucid tablet accelerometer and >> ambient light sensor drivers. >> >> Patches 1-3 are against asus-laptop, and apply in order. >> >> Patch 4 is against input, and can be commited separately (obviously >> relies on the detection code in asus-laptop at runtime, but will build >> and load independently). >> > > I am happy with the input part but I wonder if it really needs to be > separate? If you roll it up into asus-laptop you would not need a new > platform device and then it would be what - 20 lines of code? > > Corentin, what do you think? I think that it should be consistent, if there is already some code for pegatron tablet in asus-laptop, then why a new platform device only for the accelerometer ? On the other side, having to load "asus-laptop" on a pegatron tablet (or on a lenovo laptop) isn't very intuitive. The real name of this module should be atk010x_acpi, but it's not really better, and it's probably too late for that. Andy, what is shared with asus-laptop exactly ? What sysfs files are working and enabled ? Are backlight and led classes working ? Thanks, -- Corentin Chary http://xf.iksaif.net ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS 2011-01-25 7:30 ` Corentin Chary @ 2011-01-25 16:43 ` Andy Ross 2011-01-25 17:05 ` Corentin Chary 0 siblings, 1 reply; 12+ messages in thread From: Andy Ross @ 2011-01-25 16:43 UTC (permalink / raw) To: Corentin Chary Cc: Dmitry Torokhov, linux-input, acpi4asus-user, platform-driver-x86 On 01/24/2011 11:30 PM, Corentin Chary wrote: > Dmitry Torokhov wrote: > > I am happy with the input part but I wonder if it really needs to be > > separate? If you roll it up into asus-laptop you would not need a new > > platform device and then it would be what - 20 lines of code? > > > > Corentin, what do you think? > > I think that it should be consistent, if there is already some code > for pegatron tablet in asus-laptop, then why a new platform device > only for the accelerometer ? No strong feelings here. I made it a separate file because asus-laptop.c is already very large and this was something that could be fairly easily split out, but obviously it's a really trivial device. > Andy, what is shared with asus-laptop exactly ? What sysfs files are > working and enabled ? Are backlight and led classes working ? Just the key device, which exports the single touch area in the corner of the tablet as KEY_MEDIA. Some of the other sysfs devices (bluetooth, display, leds) appear because the methods exist, but they're stubbed out in the ASL and thus noops. Andy ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS 2011-01-25 16:43 ` Andy Ross @ 2011-01-25 17:05 ` Corentin Chary [not found] ` <AANLkTi=tQpQ0wjfx-Cp13FuCSQNFitN7XAg-V2AcSHz2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2011-01-25 17:12 ` Dmitry Torokhov 0 siblings, 2 replies; 12+ messages in thread From: Corentin Chary @ 2011-01-25 17:05 UTC (permalink / raw) To: Andy Ross Cc: Dmitry Torokhov, linux-input, acpi4asus-user, platform-driver-x86 On Tue, Jan 25, 2011 at 4:43 PM, Andy Ross <andy.ross@windriver.com> wrote: > On 01/24/2011 11:30 PM, Corentin Chary wrote: >> Dmitry Torokhov wrote: >> > I am happy with the input part but I wonder if it really needs to be >> > separate? If you roll it up into asus-laptop you would not need a new >> > platform device and then it would be what - 20 lines of code? >> > >> > Corentin, what do you think? >> >> I think that it should be consistent, if there is already some code >> for pegatron tablet in asus-laptop, then why a new platform device >> only for the accelerometer ? > > No strong feelings here. I made it a separate file because > asus-laptop.c is already very large and this was something that could > be fairly easily split out, but obviously it's a really trivial > device. > >> Andy, what is shared with asus-laptop exactly ? What sysfs files are >> working and enabled ? Are backlight and led classes working ? > > Just the key device, which exports the single touch area in the corner > of the tablet as KEY_MEDIA. Some of the other sysfs devices > (bluetooth, display, leds) appear because the methods exist, but > they're stubbed out in the ASL and thus noops. > > Andy If everybody is ok with that, I think you should move the code back into asus-laptop.c. But if you do so, don't forget to modify the help text of ASUS_LAPTOP section in KConfig. Should we also change the description to "Asus/Medion/JVC/Lenovo/Pegatron Extra" ? That seems really ugly but.... -- Corentin Chary http://xf.iksaif.net ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <AANLkTi=tQpQ0wjfx-Cp13FuCSQNFitN7XAg-V2AcSHz2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS [not found] ` <AANLkTi=tQpQ0wjfx-Cp13FuCSQNFitN7XAg-V2AcSHz2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2011-01-25 17:09 ` Andy Ross [not found] ` <4D3F03B0.7030607-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> 0 siblings, 1 reply; 12+ messages in thread From: Andy Ross @ 2011-01-25 17:09 UTC (permalink / raw) To: Corentin Chary Cc: platform-driver-x86-u79uwXL29TY76Z2rM5mHXA, Dmitry Torokhov, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, linux-input-u79uwXL29TY76Z2rM5mHXA On 01/25/2011 09:05 AM, Corentin Chary wrote: > If everybody is ok with that, I think you should move the code back > into asus-laptop.c. But if you do so, don't forget to modify the help > text of ASUS_LAPTOP section in KConfig. OK. Though one gotcha I just realized is that this will pull input-polldev into the dependency list for asus-laptop, which may not be desirable just to support one obscure device. But again, that's a small module... I have a few things to take care of this morning first, hopefully I'll have another version ready in a few hours. Andy ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ^ permalink raw reply [flat|nested] 12+ messages in thread
[parent not found: <4D3F03B0.7030607-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>]
* Re: [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS [not found] ` <4D3F03B0.7030607-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> @ 2011-01-25 17:10 ` Corentin Chary 0 siblings, 0 replies; 12+ messages in thread From: Corentin Chary @ 2011-01-25 17:10 UTC (permalink / raw) To: Andy Ross Cc: platform-driver-x86-u79uwXL29TY76Z2rM5mHXA, Dmitry Torokhov, acpi4asus-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, linux-input-u79uwXL29TY76Z2rM5mHXA On Tue, Jan 25, 2011 at 5:09 PM, Andy Ross <andy.ross@windriver.com> wrote: > On 01/25/2011 09:05 AM, Corentin Chary wrote: >> If everybody is ok with that, I think you should move the code back >> into asus-laptop.c. But if you do so, don't forget to modify the help >> text of ASUS_LAPTOP section in KConfig. > > OK. Though one gotcha I just realized is that this will pull input-polldev > into the dependency list for asus-laptop, which may not be desirable just to > support one obscure device. But again, that's a small module... Maybe you can make pegatron support optional in asus-laptop ? (with a checkbox or something like that) -- Corentin Chary http://xf.iksaif.net ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Acpi4asus-user mailing list Acpi4asus-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/acpi4asus-user ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS 2011-01-25 17:05 ` Corentin Chary [not found] ` <AANLkTi=tQpQ0wjfx-Cp13FuCSQNFitN7XAg-V2AcSHz2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2011-01-25 17:12 ` Dmitry Torokhov 1 sibling, 0 replies; 12+ messages in thread From: Dmitry Torokhov @ 2011-01-25 17:12 UTC (permalink / raw) To: Corentin Chary Cc: Andy Ross, linux-input, acpi4asus-user, platform-driver-x86 On Tue, Jan 25, 2011 at 05:05:05PM +0000, Corentin Chary wrote: > On Tue, Jan 25, 2011 at 4:43 PM, Andy Ross <andy.ross@windriver.com> wrote: > > On 01/24/2011 11:30 PM, Corentin Chary wrote: > >> Dmitry Torokhov wrote: > >> > I am happy with the input part but I wonder if it really needs to be > >> > separate? If you roll it up into asus-laptop you would not need a new > >> > platform device and then it would be what - 20 lines of code? > >> > > >> > Corentin, what do you think? > >> > >> I think that it should be consistent, if there is already some code > >> for pegatron tablet in asus-laptop, then why a new platform device > >> only for the accelerometer ? > > > > No strong feelings here. I made it a separate file because > > asus-laptop.c is already very large and this was something that could > > be fairly easily split out, but obviously it's a really trivial > > device. > > > >> Andy, what is shared with asus-laptop exactly ? What sysfs files are > >> working and enabled ? Are backlight and led classes working ? > > > > Just the key device, which exports the single touch area in the corner > > of the tablet as KEY_MEDIA. Some of the other sysfs devices > > (bluetooth, display, leds) appear because the methods exist, but > > they're stubbed out in the ASL and thus noops. > > > > Andy > > If everybody is ok with that, I think you should move the code back > into asus-laptop.c. But if you do so, don't forget to modify the help > text of ASUS_LAPTOP section in KConfig. > > Should we also change the description to > "Asus/Medion/JVC/Lenovo/Pegatron Extra" ? That seems really ugly > but.... "Kitchen sink" so we do not need to adjust the description going forward? ;P -- Dmitry -- 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
* [PATCH 2/4] asus-laptop: Pegatron Lucid ALS support 2011-01-24 22:48 [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Andy Ross [not found] ` <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> @ 2011-01-24 22:48 ` Andy Ross 2011-01-24 22:48 ` [PATCH 3/4] asus-laptop: Support pega_accel accelerometer driver Andy Ross 2011-01-24 22:48 ` [PATCH 4/4] input: Pegatron Lucid accelerometer Andy Ross 3 siblings, 0 replies; 12+ messages in thread From: Andy Ross @ 2011-01-24 22:48 UTC (permalink / raw) To: Dmitry Torokhov, Corentin Chary, linux-input, acpi4asus-user, platform-driver-x86 Add support for the ambient light sensor on the Pegatron Lucid tablet. This uses a different inteface but the same sysfs interface for ls_switch, has no equivalent to the existing ls_value threshold setting, and exports the actual brightness via a new attribute "ls_value". Signed-off-by: Andy Ross <andy.ross@windriver.com> --- drivers/platform/x86/asus-laptop.c | 64 +++++++++++++++++++++++++++++++++--- 1 files changed, 59 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index 6f542af..b397a4c 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -383,6 +383,12 @@ static bool asus_check_pega_lucid(struct asus_laptop *asus) !acpi_check_handle(asus->handle, METHOD_PEGA_READ, NULL); } +static int asus_pega_lucid_set(struct asus_laptop *asus, int unit, bool enable) +{ + char *method = enable ? METHOD_PEGA_ENABLE : METHOD_PEGA_DISABLE; + return write_acpi_int(asus->handle, method, unit); +} + /* Generic LED function */ static int asus_led_set(struct asus_laptop *asus, const char *method, int value) @@ -1051,7 +1057,15 @@ static ssize_t store_disp(struct device *dev, struct device_attribute *attr, */ static void asus_als_switch(struct asus_laptop *asus, int value) { - if (write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value)) + int ret; + if (asus->have_pega_lucid) { + ret = asus_pega_lucid_set(asus, PEGA_ALS, value); + if (!ret) + ret = asus_pega_lucid_set(asus, PEGA_ALS_POWER, value); + } else { + ret = write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value); + } + if (ret) pr_warning("Error setting light sensor switch\n"); asus->light_switch = value; } @@ -1108,6 +1122,35 @@ static ssize_t store_lslvl(struct device *dev, struct device_attribute *attr, return rv; } +static int pega_int_read(struct asus_laptop *asus, int arg, int *result) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + int err = write_acpi_int_ret(asus->handle, METHOD_PEGA_READ, arg, + &buffer); + if (!err) { + union acpi_object *obj = buffer.pointer; + if (obj && obj->type == ACPI_TYPE_INTEGER) + *result = obj->integer.value; + else + err = -EIO; + } + return err; +} + +static ssize_t show_lsvalue(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_laptop *asus = dev_get_drvdata(dev); + int err, hi, lo; + + err = pega_int_read(asus, PEGA_READ_ALS_H, &hi); + if (!err) + err = pega_int_read(asus, PEGA_READ_ALS_L, &lo); + if (!err) + return sprintf(buf, "%d\n", 10 * hi + lo); + return err; +} + /* * GPS */ @@ -1305,6 +1348,7 @@ static DEVICE_ATTR(wimax, S_IRUGO | S_IWUSR, show_wimax, store_wimax); static DEVICE_ATTR(wwan, S_IRUGO | S_IWUSR, show_wwan, store_wwan); static DEVICE_ATTR(display, S_IRUGO | S_IWUSR, show_disp, store_disp); static DEVICE_ATTR(ledd, S_IRUGO | S_IWUSR, show_ledd, store_ledd); +static DEVICE_ATTR(ls_value, S_IRUGO, show_lsvalue, NULL); static DEVICE_ATTR(ls_level, S_IRUGO | S_IWUSR, show_lslvl, store_lslvl); static DEVICE_ATTR(ls_switch, S_IRUGO | S_IWUSR, show_lssw, store_lssw); static DEVICE_ATTR(gps, S_IRUGO | S_IWUSR, show_gps, store_gps); @@ -1317,6 +1361,7 @@ static struct attribute *asus_attributes[] = { &dev_attr_wwan.attr, &dev_attr_display.attr, &dev_attr_ledd.attr, + &dev_attr_ls_value.attr, &dev_attr_ls_level.attr, &dev_attr_ls_switch.attr, &dev_attr_gps.attr, @@ -1354,8 +1399,15 @@ static mode_t asus_sysfs_is_visible(struct kobject *kobj, } else if (attr == &dev_attr_ls_switch.attr || attr == &dev_attr_ls_level.attr) { - supported = !acpi_check_handle(handle, METHOD_ALS_CONTROL, NULL) && - !acpi_check_handle(handle, METHOD_ALS_LEVEL, NULL); + if (asus_check_pega_lucid(asus)) { + /* no ls_level interface on the Lucid */ + supported = attr == &dev_attr_ls_switch.attr; + } else { + supported = !acpi_check_handle(handle, METHOD_ALS_CONTROL, NULL) && + !acpi_check_handle(handle, METHOD_ALS_LEVEL, NULL); + } + } else if (attr == &dev_attr_ls_value.attr) { + supported = asus_check_pega_lucid(asus); } else if (attr == &dev_attr_gps.attr) { supported = !acpi_check_handle(handle, METHOD_GPS_ON, NULL) && !acpi_check_handle(handle, METHOD_GPS_OFF, NULL) && @@ -1567,8 +1619,10 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus) asus->light_switch = 0; /* Default to light sensor disabled */ asus->light_level = 5; /* level 5 for sensor sensitivity */ - if (!acpi_check_handle(asus->handle, METHOD_ALS_CONTROL, NULL) && - !acpi_check_handle(asus->handle, METHOD_ALS_LEVEL, NULL)) { + if (asus->have_pega_lucid) { + asus_als_switch(asus, asus->light_switch); + } else if (!acpi_check_handle(asus->handle, METHOD_ALS_CONTROL, NULL) && + !acpi_check_handle(asus->handle, METHOD_ALS_LEVEL, NULL)) { asus_als_switch(asus, asus->light_switch); asus_als_level(asus, asus->light_level); } -- 1.7.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/4] asus-laptop: Support pega_accel accelerometer driver 2011-01-24 22:48 [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Andy Ross [not found] ` <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org> 2011-01-24 22:48 ` [PATCH 2/4] asus-laptop: Pegatron Lucid ALS support Andy Ross @ 2011-01-24 22:48 ` Andy Ross 2011-01-24 22:48 ` [PATCH 4/4] input: Pegatron Lucid accelerometer Andy Ross 3 siblings, 0 replies; 12+ messages in thread From: Andy Ross @ 2011-01-24 22:48 UTC (permalink / raw) To: Dmitry Torokhov, Corentin Chary, linux-input, acpi4asus-user, platform-driver-x86 Add device detecton for the ACPI accelerometer interface on Pegatron Lucid tablets. Signed-off-by: Andy Ross <andy.ross@windriver.com> --- drivers/platform/x86/asus-laptop.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c index b397a4c..75c84f8 100644 --- a/drivers/platform/x86/asus-laptop.c +++ b/drivers/platform/x86/asus-laptop.c @@ -261,6 +261,7 @@ struct asus_laptop { bool have_rsts; bool have_pega_lucid; int lcd_state; + struct platform_device *pega_accel; struct rfkill *gps_rfkill; @@ -1631,6 +1632,19 @@ static int __devinit asus_acpi_init(struct asus_laptop *asus) return result; } +static void __devinit asus_pega_accel_init(struct asus_laptop *asus) +{ + /* Pegatron Lucid tablets expose their accelerometer through ACPI. + * Check for XLR{X,Y,Z} methods */ + if (acpi_check_handle(asus->handle, "XLRX", NULL) || + acpi_check_handle(asus->handle, "XLRY", NULL) || + acpi_check_handle(asus->handle, "XLRZ", NULL)) + return; + + asus->pega_accel = platform_device_register_simple("pega_accel", -1, + NULL, 0); +} + static bool asus_device_present; static int __devinit asus_acpi_add(struct acpi_device *device) @@ -1681,6 +1695,8 @@ static int __devinit asus_acpi_add(struct acpi_device *device) goto fail_rfkill; asus->have_pega_lucid = asus_check_pega_lucid(asus); + if (asus->have_pega_lucid) + asus_pega_accel_init(asus); asus_device_present = true; return 0; @@ -1704,6 +1720,9 @@ static int asus_acpi_remove(struct acpi_device *device, int type) { struct asus_laptop *asus = acpi_driver_data(device); + if (asus->pega_accel) + platform_device_unregister(asus->pega_accel); + asus_backlight_exit(asus); asus_rfkill_exit(asus); asus_led_exit(asus); -- 1.7.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/4] input: Pegatron Lucid accelerometer 2011-01-24 22:48 [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Andy Ross ` (2 preceding siblings ...) 2011-01-24 22:48 ` [PATCH 3/4] asus-laptop: Support pega_accel accelerometer driver Andy Ross @ 2011-01-24 22:48 ` Andy Ross 3 siblings, 0 replies; 12+ messages in thread From: Andy Ross @ 2011-01-24 22:48 UTC (permalink / raw) To: Dmitry Torokhov, Corentin Chary, linux-input, acpi4asus-user, platform-driver-x86 Add driver for the ACPI accelerometer interface on the Pegatron Lucid tablet. Signed-off-by: Andy Ross <andy.ross@windriver.com> --- drivers/input/misc/Kconfig | 10 +++ drivers/input/misc/Makefile | 2 +- drivers/input/misc/pega-accel.c | 130 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+), 1 deletions(-) create mode 100644 drivers/input/misc/pega-accel.c diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index b99b8cb..e60af95 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -74,6 +74,16 @@ config INPUT_PCSPKR To compile this driver as a module, choose M here: the module will be called pcspkr. +config INPUT_PEGA_ACCEL + tristate "Support Pegatron Lucid accelerometer" + depends on ASUS_LAPTOP + help + Say Y here if you want support for the built-in ACPI + accelerometer device on Pegatron Lucid tablet devices. + + To compile this driver as a module, choose M here: the module + will be called pega_accel. + config INPUT_SPARCSPKR tristate "SPARC Speaker support" depends on PCI && SPARC64 diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index 1fe1f6c..79aca4d 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_INPUT_PCAP) += pcap_keys.o obj-$(CONFIG_INPUT_PCF50633_PMU) += pcf50633-input.o obj-$(CONFIG_INPUT_PCF8574) += pcf8574_keypad.o obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o +obj-$(CONFIG_INPUT_PEGA_ACCEL) += pega-accel.o obj-$(CONFIG_INPUT_POWERMATE) += powermate.o obj-$(CONFIG_INPUT_PWM_BEEPER) += pwm-beeper.o obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o @@ -42,4 +43,3 @@ obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o obj-$(CONFIG_INPUT_YEALINK) += yealink.o - diff --git a/drivers/input/misc/pega-accel.c b/drivers/input/misc/pega-accel.c new file mode 100644 index 0000000..7005b46 --- /dev/null +++ b/drivers/input/misc/pega-accel.c @@ -0,0 +1,130 @@ +/* + * Driver for accelerometer in Pegatron Lucid tablets + * + * Copyright (c) 2011 Wind River Systems + * + * Author: Andy Ross <andy.ross@windriver.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <linux/input-polldev.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <acpi/acpi_bus.h> + +#define DRIVER_NAME "pega_accel" +#define DRIVER_DESC "Pegatron Lucid Tablet Accelerometer" + +/* 1G accel is reported as ~256, so clamp to 2G */ +#define CLAMP 512 + +static struct input_polled_dev *ipdev; + +/* FIXME: this mechanism is *very* slow: ~50ms to read the three + * values. Pre-caching an acpi handle with acpi_get_handle has no + * effect, so the issue isn't in the parsing or tree walking... */ +static int acpi_s16(char *method) +{ + unsigned long long val = 0; + acpi_evaluate_integer(NULL, method, NULL, &val); + return (short)val; +} + +static void pega_accel_poll(struct input_polled_dev *ipdev) +{ + /* Note transform, convert to "right/up/out" in the native + * landscape orientation (i.e. the vector is the direction of + * "real up" in the device's cartiesian coordinates). FIXME: + * is there a relevant convention to adhere to? */ + int x = -acpi_s16("\\_SB.ATKD.XLRX"); + int y = -acpi_s16("\\_SB.ATKD.XLRY"); + int z = acpi_s16("\\_SB.ATKD.XLRZ"); + + x = clamp_val(x, -CLAMP, CLAMP); + y = clamp_val(y, -CLAMP, CLAMP); + z = clamp_val(z, -CLAMP, CLAMP); + + input_report_abs(ipdev->input, ABS_X, x); + input_report_abs(ipdev->input, ABS_Y, y); + input_report_abs(ipdev->input, ABS_Z, z); + input_sync(ipdev->input); +} + +static int __devinit platform_probe(struct platform_device *pd) +{ + int err; + + ipdev = input_allocate_polled_device(); + if (!ipdev) + return -ENOMEM; + + ipdev->poll = pega_accel_poll; + ipdev->poll_interval = 100; + ipdev->poll_interval_min = 10; + ipdev->poll_interval_max = 2000; + + ipdev->input->dev.parent = &pd->dev; + ipdev->input->id.bustype = BUS_HOST; + + ipdev->input->name = DRIVER_DESC; + ipdev->input->phys = DRIVER_NAME "/input0"; + + set_bit(EV_ABS, ipdev->input->evbit); + input_set_abs_params(ipdev->input, ABS_X, -CLAMP, CLAMP, 0, 0); + input_set_abs_params(ipdev->input, ABS_Y, -CLAMP, CLAMP, 0, 0); + input_set_abs_params(ipdev->input, ABS_Z, -CLAMP, CLAMP, 0, 0); + + err = input_register_polled_device(ipdev); + if (err) + input_free_polled_device(ipdev); + + return err; +} + +static int __devexit platform_remove(struct platform_device *pd) +{ + input_unregister_polled_device(ipdev); + input_free_polled_device(ipdev); + ipdev = NULL; + return 0; +} + +static struct platform_driver platform_driver = { + .driver = { + .owner = THIS_MODULE, + .name = DRIVER_NAME, + }, + .probe = platform_probe, + .remove = __devexit_p(platform_remove), +}; + +static int __init mod_init(void) +{ + return platform_driver_register(&platform_driver); +} + +static void __exit mod_exit(void) +{ + platform_driver_unregister(&platform_driver); +} + +module_init(mod_init); +module_exit(mod_exit); + +MODULE_AUTHOR("Andy Ross <andy.ross@windriver.com>"); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_ALIAS("dmi:*:bvrLucid-CE-133:*"); -- 1.7.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-01-25 17:12 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-24 22:48 [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Andy Ross
[not found] ` <1295909288-32650-1-git-send-email-andy.ross-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2011-01-24 22:48 ` [PATCH 1/4] asus-laptop: Device detection for Pegatron Lucid tablets Andy Ross
2011-01-24 23:05 ` [PATCH 0/4] Pegatron Lucid tablet acceleromter/ALS Dmitry Torokhov
2011-01-25 7:30 ` Corentin Chary
2011-01-25 16:43 ` Andy Ross
2011-01-25 17:05 ` Corentin Chary
[not found] ` <AANLkTi=tQpQ0wjfx-Cp13FuCSQNFitN7XAg-V2AcSHz2-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-01-25 17:09 ` Andy Ross
[not found] ` <4D3F03B0.7030607-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org>
2011-01-25 17:10 ` Corentin Chary
2011-01-25 17:12 ` Dmitry Torokhov
2011-01-24 22:48 ` [PATCH 2/4] asus-laptop: Pegatron Lucid ALS support Andy Ross
2011-01-24 22:48 ` [PATCH 3/4] asus-laptop: Support pega_accel accelerometer driver Andy Ross
2011-01-24 22:48 ` [PATCH 4/4] input: Pegatron Lucid accelerometer Andy Ross
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.