Backlight HAL driver or how to control backlight of the VU7+

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

joerg wrote:
Wed Mar 10, 2021 8:37 pm
You can find it in the Odroid Settings.
As I saw now, you would need to put pwm_d-backlight there, if you are on N2. But it points to pin35. There is a conflict with the default setting in GpioShutdownService App wpi 24. You must then select another pin for shutdown.
Thanks for your help.
I changed pin24 of shutdownservice app as i need it. Using 21 now.

After reboot, it's always not working

Image

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

Image

Image

User avatar
joerg
Posts: 1349
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 87 times
Been thanked: 198 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by joerg »

You can, maybe you must, delete the other pwm overlays and reboot. It seems to be a conflict as it is now.
Then for test you can connect the gray wire not to pin 35, but to GND and to 3.3V to see if the hardware connection to works generally and the backlight goes off and on.
And after rebooting you can connect with adb and do a logcat|grep light to see if Android HAL is connecting to driver.

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

Here is logcat

Code: Select all

:/ # logcat|grep light
03-10 13:48:04.848     0     0 I         : [    0.000000@0] Kernel command line: rootfstype=ramfs init=/init console=ttyS0,115200n8 no_console_suspend earlyprintk=aml-uart,0xff803000 quiet ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 max_freq_a73=2208 max_freq_a53=1908 modeline=1024,600,49000,37347,60,1024,1029,1042,1312,600,602,605,622,0,1,1 customwidth=1024 customheight=600 disable_vu7=false touch_invert_x=false touch_invert_y=false zoom_rate=100 test_mt_vid=0000 test_mt_pid=0000 backlight_pwm=yes suspend_hdmiphy=1 prevent_sleep=1 usb-xhci.tablesize=2 boot_device=mmcblk0 androidboot.selinux=permissive androidboot.firstboot= jtag=disable androidboot.hardware=odroidn2 otg_device=1 buildvariant=eng colorattribute=444,8bit disablehpd=false logo=osd0,loaded,0x3d800000 cvbsmode=576cvbs hdmimode=custombuilt voutmode=hdmi cvbscable= osd_reverse=0 video_reverse=0 gpiopower= enable_wol=0 backlight_pwm=yes otg_device=1 buildvariant=userdebug
03-10 13:48:04.853     0     0 W         : [    0.763456@5] backlight supply power not found, using dummy regulator
03-10 13:48:04.862     0     0 I [    2.387051@2] init: Parsing file /vendor/etc/init/android.hardware.light@2.0-service.rc...
03-10 13:48:14.887  3345  3345 I SystemServerTiming: OnBootPhase_550_com.android.server.twilight.TwilightService
03-10 13:48:14.887  3345  3345 D SystemServerTiming: OnBootPhase_550_com.android.server.twilight.TwilightService took to complete: 0ms
03-10 13:48:15.060  3345  3345 I SystemServerTiming: OnBootPhase_600_com.android.server.lights.LightsService
03-10 13:48:15.061  3345  3345 D SystemServerTiming: OnBootPhase_600_com.android.server.lights.LightsService took to complete: 0ms
03-10 13:48:15.096  3345  3345 I SystemServerTiming: OnBootPhase_600_com.android.server.twilight.TwilightService
03-10 13:48:15.096  3345  3345 D SystemServerTiming: OnBootPhase_600_com.android.server.twilight.TwilightService took to complete: 0ms
03-10 13:48:15.162  3345  3345 I SystemServerTiming: ssm.onStartUser-0_com.android.server.lights.LightsService
03-10 13:48:15.163  3345  3345 D SystemServerTiming: ssm.onStartUser-0_com.android.server.lights.LightsService took to complete: 0ms
03-10 13:48:15.182  3345  3345 I SystemServerTiming: ssm.onStartUser-0_com.android.server.twilight.TwilightService
03-10 13:48:15.182  3345  3345 D SystemServerTiming: ssm.onStartUser-0_com.android.server.twilight.TwilightService took to complete: 0ms
03-10 13:48:24.147  3345  3365 I ActivityManagerTiming: OnBootPhase_1000_com.android.server.lights.LightsService
03-10 13:48:24.147  3345  3365 D ActivityManagerTiming: OnBootPhase_1000_com.android.server.lights.LightsService took to complete: 0ms
03-10 13:48:24.176  3345  3365 I ActivityManagerTiming: OnBootPhase_1000_com.android.server.twilight.TwilightService
03-10 13:48:24.178  3345  3365 D TwilightService: startListening
03-10 13:48:24.217  3345  3365 D ActivityManagerTiming: OnBootPhase_1000_com.android.server.twilight.TwilightService took to complete: 40ms
03-10 13:48:24.641  3345  3371 I SystemServerTimingAsync: ssm.onUnlockingUser-0_com.android.server.lights.LightsService
03-10 13:48:24.641  3345  3371 D SystemServerTimingAsync: ssm.onUnlockingUser-0_com.android.server.lights.LightsService took to complete: 0ms
03-10 13:48:24.678  3345  3371 I SystemServerTimingAsync: ssm.onUnlockingUser-0_com.android.server.twilight.TwilightService
03-10 13:48:24.678  3345  3371 D SystemServerTimingAsync: ssm.onUnlockingUser-0_com.android.server.twilight.TwilightService took to complete: 0ms
03-10 13:48:24.800  3345  3371 I SystemServerTimingAsync: ssm.onUnlockedUser-0_com.android.server.lights.LightsService
03-10 13:48:24.800  3345  3371 D SystemServerTimingAsync: ssm.onUnlockedUser-0_com.android.server.lights.LightsService took to complete: 0ms
03-10 13:48:24.802  3345  3371 I SystemServerTimingAsync: ssm.onUnlockedUser-0_com.android.server.twilight.TwilightService
03-10 13:48:24.802  3345  3371 D SystemServerTimingAsync: ssm.onUnlockedUser-0_com.android.server.twilight.TwilightService took to complete: 0ms
03-10 13:49:07.710  3089  3089 D lights.odroid: set_light_buttons: Not implemented.
03-10 13:49:18.140  3089  3089 D lights.odroid: set_light_buttons: Not implemented.
03-10 13:49:46.226  6853  6853 W LayerDrawable:         at com.android.settings.widget.HighlightablePreferenceGroupAdapter.onBindViewHolder(HighlightablePreferenceGroupAdapter.java:110)
03-10 13:49:46.226  6853  6853 W LayerDrawable:         at com.android.settings.widget.HighlightablePreferenceGroupAdapter.onBindViewHolder(HighlightablePreferenceGroupAdapter.java:43)
03-10 13:50:17.219  3089  3089 D lights.odroid: set_light_buttons: Not implemented.
03-10 13:50:22.956  3089  3089 D lights.odroid: set_light_buttons: Not implemented.
When connecting to ground or 3.3v, backlight is working. The Android slider does just not work.
I have removed others pwm overlays, rebooted but not luck

User avatar
joerg
Posts: 1349
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 87 times
Been thanked: 198 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by joerg »

This indicates that the driver is started: lights.odroid.
I need to try it by myself with N2+ and LOS18, to get an idea why it's not working. Stay connected ... it only can take hours ... ;)
These users thanked the author joerg for the post:
zyssai (Wed Mar 10, 2021 10:06 pm)

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

joerg wrote:
Wed Mar 10, 2021 10:03 pm
This indicates that the driver is started: lights.odroid.
I need to try it by myself with N2+ and LOS18, to get an idea why it's not working. Stay connected ... it only can take hours ... ;)
Really appreciate your help ;)

User avatar
joerg
Posts: 1349
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 87 times
Been thanked: 198 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by joerg »

I am not yet sure. It seems that the lights driver doesn't export the pwm0 correct.

Code: Select all

odroidn2:/sys/class/pwm/pwmchip4 # ls
device  export  npwm  power  subsystem  uevent  unexport
After enabling at commandline in adb:

Code: Select all

echo 0 > export
ls                                          
device  export  npwm  power  pwm0  subsystem  uevent  unexport
Then can be given commands as on wiki page:

Code: Select all

echo 1000000 > period
echo 1 > enable
echo 500000 > duty_cycle 
I see with oscilloscope pwm at pin 33.

But why it is not working with the lights driver?

I tried with this in/vendor/etc/init/hw/init.odroidn2.rc, but no success.

Code: Select all

    #for pwm backlight control
    chmod 666 /sys/class/pwm/pwmchip4/export
Need to ask @voodik, why this is not working.
If this is in the lights driver:

Code: Select all

char backlight_control[64] = "/sys/class/gpio/export";
char backlight_gpio491[64] = "/sys/class/gpio/gpio491/direction";
char backlight_export[64] = "/sys/class/pwm/pwmchip4/export";
char backlight_unexport[64] = "/sys/class/pwm/pwmchip4/unexport";
char backlight_en[64] = "/sys/class/pwm/pwmchip4/pwm0/enable";
char backlight_period[64] = "/sys/class/pwm/pwmchip4/pwm0/period";
char backlight_duty_cycle[64] = "/sys/class/pwm/pwmchip4/pwm0/duty_cycle";
This is from Pie sources.

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

It exceed my skills, i let you Ask @voodik if you can :?:

User avatar
joerg
Posts: 1349
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 87 times
Been thanked: 198 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by joerg »

@zyssai, I have found a workaround to make it work.

You need Magisk installed.
You open an adb shell.
In shell you cd to /data/adb/post-fs-data.d/ and there you create a script backlight_pwm.sh:

Code: Select all

odroidn2:/ # cd /data/adb/post-fs-data.d
odroidn2:/data/adb/post-fs-data.d # nano backlight_pwm.sh
You put this inside:

Code: Select all

#!/system/bin/sh
echo 0 > /sys/class/pwm/pwmchip4/export
chmod 666 /sys/class/pwm/pwmchip4/pwm0/enable
chmod 666 /sys/class/pwm/pwmchip4/pwm0/period
chmod 666 /sys/class/pwm/pwmchip4/pwm0/duty_cycle
echo 1000000 > /sys/class/pwm/pwmchip4/pwm0/period
echo 500000 > /sys/class/pwm/pwmchip4/pwm0/duty_cycle
echo 1 > /sys/class/pwm/pwmchip4/pwm0/enable
This commandos should the lights driver do, but it doesn't. They are for initializing the pwm0. Magisk starts this script at boot time.
Then this script must be executable:

Code: Select all

odroidn2:/data/adb/post-fs-data.d # chmod 755 backlight_pwm.sh
In Overlays I have only i2c0 pwm_cd.
After reboot there should be pwm at pin 33.
But be careful, with minimum brightness the screen becomes black.
These users thanked the author joerg for the post:
voodik (Thu Mar 11, 2021 10:34 pm)

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

joerg wrote:
Thu Mar 11, 2021 3:51 am
...
Awesome, it works perfectly !!
Thanks for your help!
At minimum brightness, it is not fully dark, i can see the display ;)

User avatar
joerg
Posts: 1349
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 87 times
Been thanked: 198 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by joerg »

Maybe your eyes are younger than mine ...
These users thanked the author joerg for the post:
odroid (Thu Mar 11, 2021 9:26 am)

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

Hi!

I need to make this project one time again.
Do I need exactly 100ohm resistance? I don't have one anymore.

Thanks

User avatar
joerg
Posts: 1349
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 87 times
Been thanked: 198 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by joerg »

150, 220, 470 are also o.k. Also a wire would work. But it must not be a high value resistor like 10k, 100k. I used a resistor, because this way I can connect easily a dupont connector.
These users thanked the author joerg for the post:
zyssai (Sun May 23, 2021 3:15 am)

zyssai
Posts: 131
Joined: Wed Jan 27, 2021 6:42 pm
languages_spoken: english, french
ODROIDs: Odroid N2+ 2Gb
Vu7a+
Has thanked: 42 times
Been thanked: 16 times
Contact:

Re: Backlight HAL driver or how to control backlight of the VU7+

Post by zyssai »

joerg wrote:
Sun May 23, 2021 2:36 am
150, 220, 470 are also o.k. Also a wire would work. But it must not be a high value resistor like 10k, 100k. I used a resistor, because this way I can connect easily a dupont connector.
Thanks you, i think I have those values ;)

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 2 guests