On other devices, I can write values to LED brightness control interfaces like /sys/class/leds/red/brightness
to turn the LED on/off. However it's not working on Nexus 5.
I'm writing an app that constantly changes the led brightness, so setting via notification is not an option for me.
I've read the kernel driver source leds-qpnp.c. It's a bit different from that for Xperia Z2 in that:
rgb_config_data
: never seen this before.From these information, I came up with a plan:
Yet it still refuse to power up the led. And my rgb_start was cleared back to 0.
Looking at the code for doing this:
/* Checking lut flags is used to glean if the led really was started */
if (!(led_array[i].rgb_cfg->pwm_cfg->lut_params.flags &
PM_PWM_LUT_RAMP_UP))
led_array[i].rgb_cfg->start = 0;
I know that lut_params.flags are already set to leverage LPG. But at this point I don't know how to clear the flags in the clean way without dirty hacks in the kernel.
Anyone?
Alright. I just found out the answer.
Simply set the brightness, then set on_off_ms, then trigger via rgb_start. Note that two transactions will need different numbers to be sent to rgb_start