I'm trying to add an Ambient Light Sensor to an imx8mq Android 10 project.
Steps so far:
BoardConfig:
+ BOARD_USE_SENSOR_FUSION := true
MyBoard.mk
+PRODUCT_PACKAGES += \
android.hardware.sensors@1.0-impl \
android.hardware.sensors@1.0-service \
sensors.imx8
init.rc
+ added permissions and sys path to my ALS sensor can read lux and set mode.
/vendor/nxp-opensource/imx/libsensors_sensorhub
+ modified LightSensor to be specific to my device
+ modified sensors.cpp to include my ALS sensor in mSensors and SensorList
At run time, I've modified the functions in sensors.cpp to have an ALOGD statement in the various functions. open_sensors is called and you can see my sensor in pos 0 (the only sensor) has a valid fd.
08-07 21:01:55.009 3157 3157 I Sensors : open_sensors
08-07 21:01:55.009 3157 3157 I Sensors : sensors_poll_context_t
08-07 21:01:55.504 3157 3157 I Sensors : fillPollFd
08-07 21:01:55.504 3157 3157 I Sensors : mSensors[0].fd = 7
There is also some statements about the service starting up and being registered.
08-07 21:01:55.524 3157 3157 I ServiceManagement: Registered android.hardware.sensors@1.0::ISensors/default (start delay of 689ms)
08-07 21:01:55.524 3157 3157 I ServiceManagement: Removing namespace from process name android.hardware.sensors@1.0-service to sensors@1.0-service.
08-07 21:01:55.524 3157 3157 I android.hardware.sensors@1.0-service: Registration complete for android.hardware.sensors@1.0::ISensors/default.
However, adb shell:
>dumpsys sensor server
No Sensors on the device
devInitCheck : -19
I noticed also that sensors__get_sensors_list was never called.
So it seems I'm missing some step in the glue between the system service and the hw implementation. Any suggestions where I might find that?
FWIW, I can go to the sys directory and manually check the device is reporting lux right. Also
> getevent -vl /dev/input/event2
0003 0028 0000000b
0000 0000 00000000
0003 0028 00000062
0000 0000 00000000
0003 0028 00000034
0000 0000 00000000
0003 0028 00000062
0000 0000 00000000
The device driver appears to be working correctly and reporting events that are sensitive to when I'm covering up the ALS or not.
Solved! Go to Solution.
Ok I found the missing step. Since I started with a board config that had no sensors, the vendor manifest didn't include the HAL entry for the sensors.
in /vendor/etc/vintf/manifest.xml
+ <hal format="hidl">
+ <name>android.hardware.sensors</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>ISensors</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
After adding that, the HAL layer properly communicates the sensors to Android and the light sensor is now available:
Ok I found the missing step. Since I started with a board config that had no sensors, the vendor manifest didn't include the HAL entry for the sensors.
in /vendor/etc/vintf/manifest.xml
+ <hal format="hidl">
+ <name>android.hardware.sensors</name>
+ <transport>hwbinder</transport>
+ <version>1.0</version>
+ <interface>
+ <name>ISensors</name>
+ <instance>default</instance>
+ </interface>
+ </hal>
After adding that, the HAL layer properly communicates the sensors to Android and the light sensor is now available:
Can you please help me to integrate the lsm6dsm sensor on Android source code and get the values of the sensor in a application.
Steps that i have followed:
1.Driver was loaded and I can get the values in my pc terminal by:cat sys/class/i2c-dev/i2c-2/device/2-006b/iio\:device1/in_accel_x_raw
Then what i need to modify so that to achive the sensor values in any application??
Thankyou in advance..
Hello,
You may find it helpful to refer to the following community thread where a sensor implementation to the HAL was made: https://community.nxp.com/thread/525702
Hope it helps.
BR,
Ivan.