Re: Read light sensor fast from Nexus 5 or Nexus 7

180 views
Skip to first unread message

YANGZHE

unread,
May 12, 2015, 4:12:46 AM5/12/15
to android-...@googlegroups.com
Hi, the reason I need to read it fast is for research purpose. We have a project that needs detect the quick change of the environment light.

I think the hardware does support the high sampling rate. It is the driver that blocks it. Any suggestions?


Daniel Doron

unread,
May 13, 2015, 9:53:55 AM5/13/15
to android-...@googlegroups.com
BTW, here is the sensor datasheet: http://www.avagotech.com/docs/AV02-3190EN

Daniel Doron

unread,
May 13, 2015, 9:54:02 AM5/13/15
to android-...@googlegroups.com
I checked both AOSP tree and Kernel tree for Nexus 5 (hammerhead)

In AOSP tree in device/lge/hammerhead/libsensors/sensors.h
The light sensor is Avago (used this info to look for it in the Kernel tree).
The communication is via I2C. 
I2C is pretty fast, so should not be a problem to sample the sensor at high rate. 

In the Kernel tree, the hammerhead device tree file (dtsi) defines using the Avago_apds993x driver. (msm8974-hammerhead-sensor.dtsi)

The driver for the avago light sensor is in drivers/misc/apds993x.c
apds993x.c - Linux kernel modules for ambient light + proximity sensor


You can look at the apds993x_als_ioctl() function. 
I have noted there is a function to define the polling delay... apds993x_set_als_poll_delay()

I guess you can continue your research from here...


Apply the same logic for the Nexus 7

Hope this helps. 

Daniel. 





On Tuesday, May 12, 2015 at 11:12:46 AM UTC+3, zhe yang wrote:

Daniel Doron

unread,
May 14, 2015, 2:44:16 PM5/14/15
to android-...@googlegroups.com
I dug a little deeper on the issue. It seems that in the case of Nexus 5 (hammerhead) the Avago_apds993x driver is NOT used. 
LG is providing its own sensors lib which seems to provide a userspace driver for the sensors (/system/vendor/lib/hw/sensors.msm8974.so
I am not sure how it communicates with the I2C bus...you'll have to dig for more.

Daniel. 
Reply all
Reply to author
Forward
0 new messages