This tracks the alert slider on OnePlus 6/6T devices
and adjusts the profile level accordingly.
This is based on a script by "isyourbrain foss" in the Phosh matrix
channel.
If the feedback is in our list of feedbacks disconnect signals
and drop the reference we hold.
As we have removed the signal handler that would invoke `check_ended()`
we invoke this manually when the list becomes empty.
Camera flashes are also exported via the LED subsystem. We use a
separate LED type so they're not picked by default.
We don't use them as fallbacks either.
So far we didn't create any FbdDevLeds if there wasn't at least one
usable LED. Once we introduce flash LEDs we might probe the LED but the
LED might not be usable as the user hasn't enabled using it. Prepare for
that scenario.
The FbdDevLedColor enum defines the hardware color of the LED. We used
it for the feedbacks color value as long as the kernel mostly had
single color LEDs. As multicolor LEDs are common nowadays switch the
color to a string which will allow us to use RGB values later on.
Try first the QCOM hardware LED types which require the most features of
LED drivers. Try until we have a single color GPIO LED which is the
minimal LED driver support we require. If the LED does not meet that
expectation either, we ignore the LED.
QCOM LPG LEDs can also operate in a multicolor fashion.
Re-use the probing sequence of multicolor LEDs and the hw_pattern
configuration of single color QCOM LPG LEDs.
QCOM LPG LEDs expose a hw_pattern sysfs entry which accepts a limited
set of patterns but allows to use dedicated hardware for blinking the
LED. This way, battery life can be improved and the LED still blinks,
even if the device is suspended.
Provide our own supports_color method to specify which colors are
actually implemented by the driver. RGB LEDs could provide different
colors as well such as orange, purple, etc. but those are not supported
yet.
Drop has_color API since supported colors are set during probing
and can be handled completely separately from the classes for
each type of hardware.
Rename set_color to set_supported_color because the usage
of this API is to check if the color is supported, but not
setting it. Setting the color is also separated from
start_periodic API to re-use multicolor across multiple LED types
with a set_color API. Multicolor LEDs are actually the same as
regular LEDs but they require a few additional sysfs entries to
actually set the color. Single color LEDs only have a single color
so the set_color method just returns TRUE for these LEDs.
Supported colors are advertised through the supports_color API now.
This way, each LED driver define which colors are supported
through supports_color API. RGB multicolor LEDs will report only fixed colors
like red, blue, green and white until the kernel can expose if a diffusor
is present to mix these colors.
When all feedbacks are done the event signals "feedbacks-ended" which
lets the manager dispose the feedback. When all feedbacks end instantly
and synchronously (as is the case with the dummy feedback) this triggers
the disposal of the event within the loop leading to a crash.
Make sure the object doesn't go away be referencing it during the loop
iteration.
We didn't see this before as glib's slice allocator for lists papered
over this for us.
Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/69