After synching my source with AOKP for Nougat 7.1.2, I ran into this error when trying to build for the JFLTETMO:

[CODE]
target thumb C: lights.MSM8960 <= hardware/samsung/liblights/lights.c
hardware/samsung/liblights/lights.c:215:40: error: use of undeclared identifier ‘LED_ADJUSTMENT_R’
int red = ((color >> 16) & 0xFF) * LED_ADJUSTMENT_R;
^
hardware/samsung/liblights/lights.c:216:41: error: use of undeclared identifier ‘LED_ADJUSTMENT_G’
int green = ((color >> 8) & 0xFF) * LED_ADJUSTMENT_G;
^
hardware/samsung/liblights/lights.c:217:33: error: use of undeclared identifier ‘LED_ADJUSTMENT_B’
int blue = (color & 0xFF) * LED_ADJUSTMENT_B;
^
hardware/samsung/liblights/lights.c:258:31: error: use of undeclared identifier ‘LED_BRIGHTNESS_BATTERY’
adjusted_brightness = LED_BRIGHTNESS_BATTERY;
^
hardware/samsung/liblights/lights.c:261:31: error: use of undeclared identifier ‘LED_BRIGHTNESS_NOTIFICATION’
adjusted_brightness = LED_BRIGHTNESS_NOTIFICATION;
^
hardware/samsung/liblights/lights.c:264:31: error: use of undeclared identifier ‘LED_BRIGHTNESS_ATTENTION’
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
^
6 errors generated.
[/CODE]

Pretty simple, as we have talked about this before. In the past, I actually removed these lines from the light.c file, but this time I decided I would leave them in, and declare them instead. Essentially, the outcome is the same though for this build.

What these lines do is allow for custom liblight configurations. Perhaps a particular phone or tablet has a built in LED notification light where the green is brighter than the red or blue. In that case, every mixed color made from those LEDs will look strange. This gives the rom maker the option to “dim” down one or all three of the lights. The same applies for the brightness of the battery, notification, or attention lights.

As you can see below, I just declared them with the default values:

[CODE]
return err;
}

// WJH declaring these undeclared lights.
int LED_ADJUSTMENT_R = 1;
int LED_ADJUSTMENT_G = 1;
int LED_ADJUSTMENT_B = 1;
// WJH declaring these undeclared lights.

static int calibrate_color(int color, int brightness)
{
int red = ((color >> 16) & 0xFF) * LED_ADJUSTMENT_R;
int green = ((color >> 8) & 0xFF) * LED_ADJUSTMENT_G;
int blue = (color & 0xFF) * LED_ADJUSTMENT_B;

return (((red * brightness) / 255) << 16) + (((green * brightness) / 255) << 8) + ((blue * brightness) / 255);
}

…………EDITED FOR SPACE………………

led->delay_off = state->flashOffMS;
break;
default:
return -EINVAL;
}

// WJH declaring these brightness adjustments.
int LED_BRIGHTNESS_BATTERY = 255;
int LED_BRIGHTNESS_NOTIFICATION = 255;
int LED_BRIGHTNESS_ATTENTION = 255;
// WJH declaring these brightness adjustments.

switch (type) {
case TYPE_BATTERY:
adjusted_brightness = LED_BRIGHTNESS_BATTERY;
break;
case TYPE_NOTIFICATION:
adjusted_brightness = LED_BRIGHTNESS_NOTIFICATION;
break;
case TYPE_ATTENTION:
adjusted_brightness = LED_BRIGHTNESS_ATTENTION;
break;
default:
adjusted_brightness = 255;
}
[/CODE]

 

For the LED_ADJUSTMENT_R/G/B, I gave a value of 1. If you look at the math, it is used in the next formulae as (a & b) * LED_ADJUSTMENT_R/G/B. So if I set a value of 0, then the mathmatical outcome will be 0. If I set it at 1, then it will always be (a & b).

For the LED_BRIGHTNESS_BATTERY and so forth, I used the adjusted_brightness of 255, which is the default.

For both of these sets, I could have just removed them all together. But I build for several phones using the same source. By leaving them in, I should have an error if the device tree declared what is already declared in the lights.c file. Or at least that is my hope. In that case, then I could remove my handy work to make room for the actual values.

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *