This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

bh1780gli Ambien Light Sensor

Other Parts Discussed in Thread: 4430

Hi all,

I have found the bh1780gli.c driver located in kernel/drivers/input/misc/

I am trying to port the driver for this particular chip on my custom board. I managed to communicate to the sensor with the following message but it failed to register and here is the message shown below too.
bh1780 4-0029: Ambient Light Sensor, Rev : 1    (Sensor communication is valid)
Error: Driver 'bh1780' is already registered, aborting... (Driver is fail to register)
I am not sure what does the driver goes wrong? Can anyone of you please comment it?
The kernel I am using is 4AI.1.4-P1 and my android will be ICS.
Thank for all your help in advance.
Best Regards
Yong
  • Yong,

    It looks like the driver is trying to register itself multiple times.  In the 4AI.1.4-P1 release, INPUT_BH1780 is enabled for MACH_OMAP_4430 in /arch/arm/mach-omap2/Kconfig.  This causes the driver in /drivers/input/misc/bh1780gli.c to be built in.  Did you add code to initialize this driver anywhere else for your custom platform?

    Regards,
    Gina 

  • Hi Gina,
    Thank you, very appreciated you did come back to me.
    Yes, I had figure out the problem now because there are two bh1780gli drivers existed in difference path and both of them enabled in Kconfig. Problem solved.
    But I have problem in my HAL layer. The problem I am facing is, the sensor doesn't seem to turn on when I try to enable AutoBrightness in Android OS or open AndroSensor Apps. I have to manually turn it on in the debug console by entering,
    echo 3 > power_state 
    Any idea why the sensor can not turn on itself when it has been called?
  • Hi Gina,

    Another useful information here:

    When I enable the AutoBrightness option, I received this in the logcat

    D/Sensors (  167): LightSensor:Trying to enable //I add this line for debugging purposes in the int LightSensor::enable(int32_t handle, int en)

    E/SensorService(  167): Error activating sensor 3 (Operation not permitted)

    or

    E/lights  (  165): write_int failed to open /sys/class/leds/keyboard-backlight/brightness

    I hope you can provide me some directions.

    Another thing I do not understand is, I am controlling the LCD's backlight but why it is trying to control keyboard-backlight? Is there something wrong in LightSensor.cpp or sensors.h?

  • Hi Zhi Yong,

    Please apply the attached patch

    0407.ambient_light_sensor_patch1.txt .

    After applying this patch you dont have to use echo command for fetching light values.

    Thanks

    Abhijit