Hello guys. I have a strange issue about Adaptive Brightness feature on IMX8MQ. I have used OPT3001 Ambient light sensor. I have succesfully add this sensor on kernel side, ı have seen it on dmesg log and ı can read the lux value successfully. Let me show you some useful outputs.
----------------------------------------------------------------------
smarc_mx8mq:/sdcard $ dmesg | grep opt3001
[ 2.901412] opt3001 0-0044: Found TI OPT3001
smarc_mx8mq:/sdcard $
----------------------------------------------------------------------
cat /sys/bus/i2c/devices/0-0044/iio:device0/in_illuminance_input
113.440000 (it is just an example, it shows different based on ambient light).
----------------------------------------------------------------------
So as you can see, sensor is working in kernel side.
For HAL side, ı have drive a service to control this ambient light lux values and write to FMQ.
Actually, it is better the show directly.
This is the output of dumpsys sensorservice
smarc_mx8mq:/ $ dumpsys sensorservice
Captured at: 10:27:38.483
Sensor Device:
Total 1 h/w sensors, 1 running 0 disabled clients:
0x00000001) active-count = 1; sampling_period(ms) = {250.0}, selected = 250.00 ms; batching_period(ms) = {0.0}, selected = 0.00 ms
Sensor List:
0x00000001) OPT3001 Ambient Light | Texas Instruments | ver: 1 | type: android.sensor.light(5) | perm: n/a | flags: 0x00000002
on-change | maxDelay=0us | maxRate=5.00Hz | no batching | non-wakeUp |
Fusion States:
9-axis fusion disabled (0 clients), gyro-rate= 200.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
game fusion(no mag) disabled (0 clients), gyro-rate= 200.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
geomag fusion (no gyro) disabled (0 clients), gyro-rate= 200.00Hz, q=< 0, 0, 0, 0 > (0), b=< 0, 0, 0 >
Recent Sensor events:
Active sensors:
OPT3001 Ambient Light (handle=0x00000001, connections=1)
Socket Buffer size = 39 events
WakeLock Status: not held
Mode : NORMAL
Sensor Privacy: disabled
1 active connections
Connection Number: 0
Operating Mode: NORMAL
com.android.server.display.AutomaticBrightnessController | WakeLockRefCount 0 | uid 1000 | cache size 0 | max cache size 0
OPT3001 Ambient Light 0x00000001 | status: active | pending flush events 0
0 direct connections
Previous Registrations:
09:42:02 + 0x00000001 pid= 551 uid= 1000 package=com.android.server.display.AutomaticBrightnessController samplingPeriod=250000us batchingPeriod=0us
09:37:56 - 0x00000001 pid= 551 uid= 1000 package=com.android.server.display.AutomaticBrightnessController
09:35:28 + 0x00000001 pid= 551 uid= 1000 package=com.android.server.display.AutomaticBrightnessController samplingPeriod=250000us batchingPeriod=0us
smarc_mx8mq:/ $
As you can see, automoticbrgihtnesscontroller is actually know the sensor.
----------------------------------------------------------------------
This is the dumpsys display output for automatic brightness controller
dumpsys display
Automatic Brightness Controller Configuration:
mScreenBrightnessRangeMinimum=0.035433073
mScreenBrightnessRangeMaximum=1.0
mDozeScaleFactor=1.0
mInitialLightSensorRate=250
mNormalLightSensorRate=250
mLightSensorWarmUpTimeConfig=0
mBrighteningLightDebounceConfig=4000
mDarkeningLightDebounceConfig=8000
mResetAmbientLuxAfterWarmUpConfig=true
mAmbientLightHorizon=10000
mWeightingIntercept=10000
Automatic Brightness Controller State:
mLightSensor={Sensor name="OPT3001 Ambient Light", vendor="Texas Instruments", version=1, type=5, maxRange=100000.0, resolution=0.01, power=0.001, minDelay=200000}
mLightSensorEnabled=true
mLightSensorEnableTime=470926 (2805217 ms ago)
mCurrentLightSensorRate=250
mAmbientLux=0.0
mAmbientLuxValid=false
mAmbientBrighteningThreshold=0.0
mAmbientDarkeningThreshold=0.0
mScreenBrighteningThreshold=0.0
mScreenDarkeningThreshold=0.0
mLastObservedLux=0.0
mLastObservedLuxTime=0 (3276143 ms ago)
mRecentLightSamples=0
mAmbientLightRingBuffer=[]
mScreenAutoBrightness=NaN
mDisplayPolicy=BRIGHT
mShortTermModelTimeout=300000
mShortTermModelAnchor=-1.0
mShortTermModelValid=true
mBrightnessAdjustmentSamplePending=false
mBrightnessAdjustmentSampleOldLux=0.0
mBrightnessAdjustmentSampleOldBrightness=0.0
mForegroundAppPackageName=com.android.settings
mPendingForegroundAppPackageName=null
mForegroundAppCategory=-1
mPendingForegroundAppCategory=-1
--------------------------------------------------------------------------------
smarc_mx8mq:/ $ getprop | grep sensor
[init.svc.sensor_fusion]: [stopped]
[init.svc.vendor.sensors]: [running]
[init.svc_debug_pid.sensor_fusion]: []
[init.svc_debug_pid.vendor.sensors]: [351]
[ro.boottime.sensor_fusion]: [24640145010]
[ro.boottime.vendor.sensors]: [20921317621]
[ro.hardware.lightsensor]: [/sys/class/i2c-dev/i2c-0/device/0-0044/]
[vendor.ro.lightsensor.threshold]: [20]
smarc_mx8mq:/ $
I do not know what are ro.hardware.lightsensor and vendor.ro.lightsensor.threshold. I did not include them these were already included. I have used opt3001 and it is also use 0x44 i2c addres by chance.
This is my service
[init.svc.vendor.sensors]: [running]
Actually everthing looks good, but just changing brightness based on ambient light doesnt work.
Normally, my backlight was not changing by setting brightness slider, and ı have generate a service to do this purpose also before. So, now when ı change the brightness by command line by using
ettings put system screen_brightness , it change the backlight of my lcd. So there is no problem with driving backlight normally.
What can ı do for driving bakclight by using lux value of ALS ? I will attach my outputs such as logcat (which ı have add some log to debug in service), service files, dumpsys display and sensorservice outputs.
Please let me know if anyone faced this issue. Not just for answer, you can chare your opinion also. Anything is accepted.
Please check files in atachement. zip file includes service files which ı have create. Please check it .
KEYWOD: AMBIENT LIGHT SENSOR, IMX8MQ, BACKLGIGHT, BRIGHTNESS, SLIDER, LUX VALUE
Hello,
For this you may refer to the generic Android documentation, please refer to the following:
ALSO, ı can not change the flag type of sensor. You can see on dumpsys sensorservice output, it is
Sensor List:
0x00000001) OPT3001 Ambient Light | Texas Instruments | ver: 1 | type: android.sensor.light(5) | perm: n/a | flags: 0x00000002
on-change | maxDelay=0us | maxRate=5.00Hz | no batching | non-wakeUp |
I have set in service file as flag 0x00 which is contnuous but it never change. Do you know how can i change this sensor flag from 0x02 to 0x00.
Regards