Re: [PATCH 3/4] asus-laptop: Pegatron Lucid accelerometer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ccing Dmitry and Matthew, they may want to comment that one.

On Thu, Mar 24, 2011 at 11:02 PM, Andy Ross <andy.ross@xxxxxxxxxxxxx> wrote:
> Support the built-in accelerometer on the Lucid tablets as a standard
> 3-axis input device.
>
> Signed-off-by: Andy Ross <andy.ross@xxxxxxxxxxxxx>
> ---
> Âdrivers/platform/x86/Kconfig    |  Â9 ++-
> Âdrivers/platform/x86/asus-laptop.c | Â137 +++++++++++++++++++++++++++++++++++-
> Â2 files changed, 141 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index b6f983e..43906f5 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -67,10 +67,11 @@ config ASUS_LAPTOP
> Â Â Â Â ÂThis is a driver for Asus laptops and the Pegatron Lucid
> Â Â Â Â Âtablet. It may also support some MEDION, JVC or VICTOR
> Â Â Â Â Âlaptops. It makes all the extra buttons generate standard
> - Â Â Â Â ACPI events and input events. It also adds support for video
> - Â Â Â Â output switching, LCD backlight control, Bluetooth and Wlan
> - Â Â Â Â control, and most importantly, allows you to blink those
> - Â Â Â Â fancy LEDs.
> + Â Â Â Â ACPI events and input events, and on the Lucid the built-in
> + Â Â Â Â accelerometer appears as an input device. ÂIt also adds
> + Â Â Â Â support for video output switching, LCD backlight control,
> + Â Â Â Â Bluetooth and Wlan control, and most importantly, allows you
> + Â Â Â Â to blink those fancy LEDs.
>
> Â Â Â Â ÂFor more information and a userspace daemon for handling the extra
> Â Â Â Â Âbuttons see <http://acpi4asus.sf.net>.
> diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> index 6651d8c..9b07368 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -224,6 +224,14 @@ static char *display_get_paths[] = {
> Â#define PEGA_READ_ALS_H Â Â Â Â0x02
> Â#define PEGA_READ_ALS_L Â Â Â Â0x03
>
> +#define PEGA_ACCEL_NAME "pega_accel"
> +#define PEGA_ACCEL_DESC "Pegatron Lucid Tablet Accelerometer"
> +#define METHOD_XLRX "XLRX"
> +#define METHOD_XLRY "XLRY"
> +#define METHOD_XLRZ "XLRZ"
> +#define PEGA_ACC_CLAMP 512 /* 1G accel is reported as ~256, so clamp to 2G */
> +#define PEGA_ACC_RETRIES 3
> +
> Â/*
> Â* Define a specific led structure to keep the main structure clean
> Â*/
> @@ -249,6 +257,7 @@ struct asus_laptop {
>
> Â Â Â Âstruct input_dev *inputdev;
> Â Â Â Âstruct key_entry *keymap;
> + Â Â Â struct input_polled_dev *pega_accel_poll;
>
> Â Â Â Âstruct asus_led mled;
> Â Â Â Âstruct asus_led tled;
> @@ -262,6 +271,10 @@ struct asus_laptop {
> Â Â Â Âbool have_rsts;
> Â Â Â Âbool have_pega_lucid;
> Â Â Â Âint lcd_state;
> + Â Â Â bool pega_acc_live;
> + Â Â Â int pega_acc_x;
> + Â Â Â int pega_acc_y;
> + Â Â Â int pega_acc_z;
>
> Â Â Â Âstruct rfkill *gps_rfkill;
>
> @@ -390,6 +403,99 @@ static int asus_pega_lucid_set(struct asus_laptop *asus, int unit, bool enable)
> Â Â Â Âreturn write_acpi_int(asus->handle, method, unit);
> Â}
>
> +static int pega_acc_axis(struct asus_laptop *asus, int curr, char *method)
> +{
> + Â Â Â int i, delta;
> + Â Â Â unsigned long long val;
> + Â Â Â for (i = 0; i < PEGA_ACC_RETRIES; i++) {
> + Â Â Â Â Â Â Â acpi_evaluate_integer(asus->handle, method, NULL, &val);
> +
> + Â Â Â Â Â Â Â /* The output is noisy. ÂFrom reading the ASL
> + Â Â Â Â Â Â Â Â* dissassembly, timeout errors are returned with 1's
> + Â Â Â Â Â Â Â Â* in the high word, and the lack of locking around
> + Â Â Â Â Â Â Â Â* thei hi/lo byte reads means that a transition
> + Â Â Â Â Â Â Â Â* between (for example) -1 and 0 could be read as
> + Â Â Â Â Â Â Â Â* 0xff00 or 0x00ff. */
> + Â Â Â Â Â Â Â delta = abs(curr - (short)val);
> + Â Â Â Â Â Â Â if (delta < 128 && !(val & ~0xffff))
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â }
> + Â Â Â return clamp_val((short)val, -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP);
> +}

Wow :/ How long is an acpi_evaluate_integer call here ?

> +static int asus_platform_probe(struct platform_device *pd)
> +{
> + Â Â Â struct asus_laptop *asus = dev_get_drvdata(&pd->dev);
> +
> + Â Â Â /* This is instantiated during platform driver initialization
> + Â Â Â Â* becuase if it's done from underneath asus_acpi_add(), the
> + Â Â Â Â* resulting input device can be grabbed by an early userspace
> + Â Â Â Â* reader before ACPI initialization is finished and something
> + Â Â Â Â* oopses underneath the acpi_evaluate_integer() call out of
> + Â Â Â Â* pega_accel_poll(). ÂFirmware bug? */
> + Â Â Â pega_accel_probe(asus);
> +
> + Â Â Â return 0;
> +}

When is asus_platform_probe called exactly ? Because I'd say it's
called during asus_platform_probe(), and that doesn't fix your issue
right ?

-- 
Corentin Chary
http://xf.iksaif.net
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux