All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: joeyli <jlee@suse.com>
Cc: platform-driver-x86@vger.kernel.org, rui.zhang@intel.com
Subject: Re: [PATCH 2/2] ACER: Add support for ambient light sensor
Date: Mon, 4 Jun 2012 11:29:43 +0200	[thread overview]
Message-ID: <201206041129.43676.marex@denx.de> (raw)
In-Reply-To: <1338800893.6374.71.camel@linux-s257.site>

Dear joeyli,

> Hi Marek,
> 
> 於 五,2012-06-01 於 19:11 +0200,Marek Vasut 提到:
> 
> > This is the ambient light sensor found on Iconia W500.
> > 
> > Signed-off-by: Marek Vasut <marex@denx.de>
> > Cc: joeyli <jlee@suse.com>
> > ---
> > 
> >  drivers/platform/x86/acer-wmi.c |   86
> >  +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86
> >  insertions(+)
> > 
> > diff --git a/drivers/platform/x86/acer-wmi.c
> > b/drivers/platform/x86/acer-wmi.c index edb6bad..a58c415 100644
> > --- a/drivers/platform/x86/acer-wmi.c
> > +++ b/drivers/platform/x86/acer-wmi.c
> > @@ -203,6 +203,7 @@ struct hotkey_function_type_aa {
> > 
> >  #define ACER_CAP_BRIGHTNESS		(1<<3)
> >  #define ACER_CAP_THREEG			(1<<4)
> >  #define ACER_CAP_ACCEL			(1<<5)
> > 
> > +#define ACER_CAP_ALS			(1<<6)
> > 
> >  #define ACER_CAP_ANY			(0xFFFFFFFF)
> >  
> >  /*
> > 
> > @@ -1378,6 +1379,63 @@ static void acer_backlight_exit(void)
> > 
> >  }
> >  
> >  /*
> > 
> > + * Ambient light sensor device
> > + */
> > +static acpi_handle alsd_handle;
> > +
> > +static int acer_als_init(void)
> > +{
> > +	union acpi_object in_obj;
> > +	struct acpi_object_list params;
> > +	struct acpi_buffer out;
> > +	union acpi_object out_obj;
> > +	acpi_status status;
> > +
> > +	status = acpi_evaluate_object(alsd_handle, "_INI", NULL, NULL);
> > +	if (ACPI_FAILURE(status))
> > +		return -1;
> > +
> > +	params.count = 1;
> > +	params.pointer = &in_obj;
> > +	in_obj.type = ACPI_TYPE_INTEGER;
> > +	/*
> > +	 * Unknown argument of both GLOV and GUPV, set to 5.
> > +	 * GLOV - G? Lower Value ?
> > +	 * GUPV - G? Upper Value ?
> > +	 */
> > +	in_obj.integer.value = 5;
> > +	out.length = sizeof(out_obj);
> > +	out.pointer = &out_obj;
> > +
> > +	acpi_evaluate_object(alsd_handle, "GLOV", &params, &out);
> > +	acpi_evaluate_object(alsd_handle, "GUPV", &params, &out);
> > +
> 
> GUPV/GLOV also call by _INI, why need evaluate it again?

What does _INI set them to though?

>             Method (_INI, 0, NotSerialized)
>             {
> ...
>                 Store (GUPV (Local1), Local2)
>                 Store (GLOV (Local1), Local3)
> 
> And, why use '5' to evaluate GUPV/GLOV?

It seemed like the value that worked the best. I think those packages defined at 
the begining of the ALSD section define some kind of profiles (maybe, cloudy, 
bright light etc). And this selects the profile.

> 
> > +	return 0;
> > +}
> > +
> > +static ssize_t acer_als_show(struct device *dev, struct device_attribute
> > *attr, +			char *buf)
> > +{
> > +	acpi_status status;
> > +	struct acpi_buffer output;
> > +	union acpi_object out_obj;
> > +
> > +	status = acpi_evaluate_object(alsd_handle, "S3WK", NULL, NULL);
> > +	if (ACPI_FAILURE(status))
> > +		return -1;
> > +
> 
> Why need evaluate S3WK before _ALI ? Looks like this method call in S3
> resume path:

It makes the sensor re-read the data and it's faster than calling _INI.

>  _WAK -> OEMW -> PRJW -> S3WK
> 
> > +	output.length = sizeof(out_obj);
> > +	output.pointer = &out_obj;
> > +	status = acpi_evaluate_object(alsd_handle, "_ALI", NULL, &output);
> > +	if (ACPI_FAILURE(status))
> > +		return -1;
> > +
> > +	return sprintf(buf, "%d\n", (u16)out_obj.integer.value);
> > +}
> > +
> > +static DEVICE_ATTR(ls_switch, S_IRUGO, acer_als_show, NULL);
> > +
> > +/*
> > 
> >   * Accelerometer device
> >   */
> >  
> >  static acpi_handle gsensor_handle;
> > 
> > @@ -1856,6 +1914,21 @@ err_free_dev:
> >  	return err;
> >  
> >  }
> > 
> > +static int __init acer_wmi_alsd_setup(void)
> > +{
> > +	int err;
> > +
> > +	err = acer_wmi_get_handle("ALSD", "ACPI0008", &alsd_handle);
> > +	if (err)
> > +		return err;
> > +
> 
> Does anybody know why "introduce ACPI ALS device driver" patches from
> Zhang Rui didn't include in acpi code base?
> 
> http://comments.gmane.org/gmane.linux.kernel/884328
> 
> 
> There have V6 patches, but didn't see those patches show up in acpi git.

Now this would be much cooler to have than this crappy hack of mine :-)

> Thanks a lot!
> Joey Lee
> 

Best regards,
Marek Vasut

  reply	other threads:[~2012-06-04  9:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-01 17:11 [PATCH 1/2] ACER: Add support for accelerometer sensor Marek Vasut
2012-06-01 17:11 ` [PATCH 2/2] ACER: Add support for ambient light sensor Marek Vasut
2012-06-04  9:08   ` joeyli
2012-06-04  9:29     ` Marek Vasut [this message]
2012-06-04 11:13   ` Corentin Chary
2012-06-04 17:14     ` Marek Vasut
2012-06-05 12:49       ` Corentin Chary
2012-06-05 13:06         ` Marek Vasut
2012-06-05 22:55         ` Marek Vasut
2012-06-06  1:22           ` Zhang Rui
2012-06-22 20:20             ` Marek Vasut
2012-06-04  8:23 ` [PATCH 1/2] ACER: Add support for accelerometer sensor joeyli
2012-06-05 22:52   ` Marek Vasut
2012-06-06  0:15     ` joeyli
2012-06-06 10:13       ` Marek Vasut
2012-06-26 18:41 ` Matthew Garrett
2012-06-26 18:52   ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201206041129.43676.marex@denx.de \
    --to=marex@denx.de \
    --cc=jlee@suse.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.