sm8150-common: lights: Drop notification LED support

* Unfortunately our devices do not support such a
  ~ luxurious ~ feature.

Change-Id: I252a0262df5caa18f5b1a3e81387f71cf843f862
This commit is contained in:
LuK1337 2019-07-08 19:14:26 +02:00
parent c3b35b8a37
commit 5155090e15
3 changed files with 0 additions and 96 deletions

View File

@ -56,10 +56,7 @@ static int rgbToBrightness(const LightState& state) {
}
Light::Light() {
mLights.emplace(Type::ATTENTION, std::bind(&Light::handleRgb, this, std::placeholders::_1, 0));
mLights.emplace(Type::BACKLIGHT, std::bind(&Light::handleBacklight, this, std::placeholders::_1));
mLights.emplace(Type::BATTERY, std::bind(&Light::handleRgb, this, std::placeholders::_1, 1));
mLights.emplace(Type::NOTIFICATIONS, std::bind(&Light::handleRgb, this, std::placeholders::_1, 2));
}
void Light::handleBacklight(const LightState& state) {
@ -74,89 +71,6 @@ void Light::handleBacklight(const LightState& state) {
set("/sys/class/backlight/panel0-backlight/brightness", brightness);
}
void Light::handleRgb(const LightState& state, size_t index) {
mLightStates.at(index) = state;
LightState stateToUse = mLightStates.front();
for (const auto& lightState : mLightStates) {
if (lightState.color & 0xffffff) {
stateToUse = lightState;
break;
}
}
std::map<std::string, int> colorValues;
colorValues["red"] = (stateToUse.color >> 16) & 0xff;
// lower green and blue brightness to adjust for the (lower) brightness of red
colorValues["green"] = ((stateToUse.color >> 8) & 0xff) / 2;
colorValues["blue"] = (stateToUse.color & 0xff) / 2;
int onMs = stateToUse.flashMode == Flash::TIMED ? stateToUse.flashOnMs : 0;
int offMs = stateToUse.flashMode == Flash::TIMED ? stateToUse.flashOffMs : 0;
// LUT has 63 entries, we could theoretically use them as 3 (colors) * 21 (steps).
// However, the last LUT entries don't seem to behave correctly for unknown
// reasons, so we use 17 steps for a total of 51 LUT entries only.
static constexpr int kRampSteps = 16;
static constexpr int kRampMaxStepDurationMs = 15;
auto makeLedPath = [](const std::string& led, const std::string& op) -> std::string {
return "/sys/class/leds/" + led + "/" + op;
};
auto getScaledDutyPercent = [](int brightness) -> std::string {
std::string output;
for (int i = 0; i <= kRampSteps; i++) {
if (i != 0) {
output += ",";
}
output += std::to_string(i * 512 * brightness / (255 * kRampSteps));
}
return output;
};
// Disable all blinking before starting
for (const auto& entry : colorValues) {
set(makeLedPath(entry.first, "blink"), 0);
}
if (onMs > 0 && offMs > 0) {
int pauseLo, pauseHi, stepDuration, index = 0;
if (kRampMaxStepDurationMs * kRampSteps > onMs) {
stepDuration = onMs / kRampSteps;
pauseHi = 0;
pauseLo = offMs;
} else {
stepDuration = kRampMaxStepDurationMs;
pauseHi = onMs - kRampSteps * stepDuration;
pauseLo = offMs - kRampSteps * stepDuration;
}
for (const auto& entry : colorValues) {
set(makeLedPath(entry.first, "lut_flags"), 95);
set(makeLedPath(entry.first, "start_idx"), index);
set(makeLedPath(entry.first, "duty_pcts"), getScaledDutyPercent(entry.second));
set(makeLedPath(entry.first, "pause_lo"), pauseLo);
set(makeLedPath(entry.first, "pause_hi"), pauseHi);
set(makeLedPath(entry.first, "ramp_step_ms"), stepDuration);
index += kRampSteps + 1;
}
// Start blinking
for (const auto& entry : colorValues) {
set(makeLedPath(entry.first, "blink"), entry.second);
}
} else {
for (const auto& entry : colorValues) {
set(makeLedPath(entry.first, "brightness"), entry.second);
}
}
LOG(DEBUG) << base::StringPrintf(
"handleRgb: mode=%d, color=%08X, onMs=%d, offMs=%d",
static_cast<std::underlying_type<Flash>::type>(stateToUse.flashMode), stateToUse.color,
onMs, offMs);
}
Return<Status> Light::setLight(Type type, const LightState& state) {
auto it = mLights.find(type);

View File

@ -45,11 +45,9 @@ class Light : public ILight {
private:
void handleBacklight(const LightState& state);
void handleRgb(const LightState& state, size_t index);
std::mutex mLock;
std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
std::array<LightState, 3> mLightStates;
};
} // namespace implementation

View File

@ -1,11 +1,3 @@
on boot
chown system system /sys/class/leds/red/start_idx
chown system system /sys/class/leds/green/start_idx
chown system system /sys/class/leds/blue/start_idx
chown system system /sys/class/leds/red/lut_flags
chown system system /sys/class/leds/green/lut_flags
chown system system /sys/class/leds/blue/lut_flags
service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service.oneplus_msmnile
interface android.hardware.light@2.0::ILight default
class hal