Commit Graph
170 Commits
Author SHA1 Message Date
Guido Günther f639f7d103 feedback-manager: Instantiate .Haptic DBus interface
Make the haptic interface available on the Bus when a haptic
motor is found at daemon startup.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/80

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:54:40 +01:00
Guido Günther 31c7bf7d6b haptic-manager: New object to handle the Haptic DBus interface
To trigger a 200ms rumble at 100%, a 50ms pause and a 300ms rumble at 50%:

   busctl call --user org.sigxcpu.Feedback /org/sigxcpu/Feedback org.sigxcpu.Feedback.Haptic Vibrate 'sa(du)' org.foo.app 3 1.0 200  0.0 50  0.5 300

To cancel an ongoing pattern:

   busctl call --user org.sigxcpu.Feedback /org/sigxcpu/Feedback org.sigxcpu.Feedback.Haptic Vibrate 'sa(du)' org.foo.app 0

The API has lower priority than the event based API to e.g.  not miss
incoming phone calls or cell broadast messages.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:54:40 +01:00
Guido Günther 9cebb2c081 feedback-vibra: Add support for patterns
Add a new class that takes an array of durations and magnitudes.
A magnitude of 0 indicates a pause.

We can consider dropping the VibraRumble class at some point as that
is a special case of VibraPeriodic now however as the feedbacks are
encoded in the themes let's make sure VibraPattern is good API before
deprecating VibraRumble.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:58 +01:00
Guido Günther 386c98c381 dev-vibra: Allow to set magnitude
Allows for more subtle feedback

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:44 +01:00
Guido Günther 58221c7416 feedback-vibra: Allow derived classes to override duration
This allows the derived classes to perform the length duration
calculation.  The parent class can thus still keep track of the total
feedback length.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:25 +01:00
Guido Günther 18f2c88746 feedback-vibra: Clear timer id
Make sure we clear the timer id when vibra ended.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:21 +01:00
Guido Günther 24736b9490 feedback-vibra: Use g_timeout_add_once
Fix some indent while at that

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:17 +01:00
Guido Günther 5ed445a81d feedback-manager: Don't trigger haptic feedbacks when vibra is busy
This just gives odd vibration. Later on we should use priorities to
allow for higher priority events like phone calls to override lower
priority events like e.g. button presses. This is similar to how we want
to handle LED patterns.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:35:04 +01:00
Guido Günther cdf5fb2b2d feedback-manager: Split out feedback level calculation
This allows to use it from other places too and while at that
documents it.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:35 +01:00
Guido Günther 8a11565cc1 dev-vibra: Allow to check if the device is busy
We accept `NULL` to make the case of no haptic easy to handle.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:28 +01:00
Guido Günther 5238d46968 feedback-rumble: Fix indent
There were some tabs from day 0

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:25 +01:00
Guido Günther b724789ab1 dev-vibra: Untabify
Gbp-Dch: Ignore
Signed-off-by: Guido Günther <agx@sigxcpu.org>
2024-12-15 18:34:16 +01:00
Dang Huynh f2e59a4ee0 fbd-ledctrl: Add null pointer check for groups
The set_perms function does not check if getgrnam returns a null
pointer.

This causes the fbd-ledctrl to crash when a non-existent group is
passed.
2024-11-16 21:35:40 +01:00
Guido Günther 0a2392db3f fbd-alert-slider: Small service to track alert sliders
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.
2024-09-27 07:27:08 +00:00
Guido Günther 929d41b7db feedback-manager: End too noisy feedbacks on profile level change
When the profile gets lowered from e.g. quiet to silent we want to end
all ongoing feedbacks that belong to the quiet level.

This allows to e.g. silence an incoming phone call by switching the
feedback level via phosh's quick setting.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/13
Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/55
2024-06-21 19:57:29 +00:00
Guido Günther 3c02259156 event: Allow to end events by level
The level here is an abstract value but in fact matches the profile
level. Well make this a property when fixing #35.
2024-06-21 19:57:29 +00:00
Guido Günther 0a16ebe4af event: Make removing feedbacks more self contained
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.
2024-06-21 19:57:29 +00:00
Guido Günther 924320bbf9 fbd-event: Fix some indent
Gbp-Dch: Ignore
2024-06-21 19:57:29 +00:00
Guido Günther 2b6a9508a0 feedback-theme: Fix indent
Gbp-Dch: Ignore
2024-06-21 19:57:29 +00:00
Guido Günther 8f67dbd120 feedback-led: Allow to prefer flash LEDs over notification LEDs 2024-06-15 11:14:40 +02:00
Guido Günther ffd939c536 leds: Probe flash LED 2024-06-15 11:14:40 +02:00
Guido Günther e47ce8e09e led: Add flash LED type
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.
2024-06-15 11:14:40 +02:00
Guido Günther e16dc3cdab feedback-led: Check if at least one LED is available
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.
2024-06-15 11:14:40 +02:00
Guido Günther 417b34be89 led: Drop FBD_FEEDBACK_LED_COLOR_LAST
With new led types we might not loop over all of them. This makes
it a bit more obvious.
2024-06-15 11:14:40 +02:00
Guido Günther a71fd7d470 manager: Move schema name to header
This makes it available to other compilation units
2024-06-15 11:14:40 +02:00
Guido Günther a4c35a8e61 led: Parse color values and pass them down the chain
We parse RGB color values as HEX ('#RRGGBB') and use those when a RGB
LED is available. Single color LEDs won't see a change.
2024-06-13 15:19:03 +02:00
Guido Günther efd088daa8 feedback-led: Document hw LED types 2024-06-13 15:17:52 +02:00
Guido Günther 4afc8398e2 feedbackd: Pass GMOBILE_USE_UNSTABLE_API to all files
No need to ack that individually
2024-06-13 15:17:52 +02:00
Guido Günther 5bd398ed18 feedback-led: Support colors as strings
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.
2024-06-13 15:17:51 +02:00
Guido Günther 4551b1c939 fbd-feedback-led: Modernize property definitions
Adapt current phosh coding style before making other changes
2024-06-13 07:44:42 +02:00
Guido Günther 6e9e5700c0 dev-led-multicolor: Use correct format specifier
The values are unsigned int
2024-06-13 07:44:34 +02:00
Guido Günther 9aa6696eb8 build: Let daemon dependency depend on generated enum headers
Otherwise it might not be available in the tests
2024-06-13 07:44:25 +02:00
Guido Günther 3c588fdb8f led-qcom: Check for LED driver
The hw_pattern attribute is driver specific. Ensure we don't apply the
LED pattern to unknown drivers.

Closes: https://source.puri.sm/Librem5/feedbackd/-/issues/77
2024-06-10 15:50:50 +02:00
Guido Günther f581c15842 led-qcom-multicolor: Don't leak qcom_led 2024-06-10 10:33:05 +02:00
Guido Günther 255856822a led-qcom-multicolor: Drop unused defines 2024-06-10 10:33:03 +02:00
Guido Günther fcd210ef22 led-qcom: Use char instead of gchar
We prefer the C types in new code.
2024-06-10 10:33:03 +02:00
Dylan Van Assche 6b1eb92b7a fbd-dev-leds: Probe QCOM HW LED types
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.
2024-06-09 11:21:20 +02:00
Dylan Van Assche 2b53725fcb fbd-dev-led-qcom-multicolor: Support QCOM LPG LED multicolor
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.
2024-06-09 11:21:20 +02:00
Dylan Van Assche 10e6d3cba8 fbd-dev-led-qcom: Support QCOM LPG LED single color
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.
2024-06-09 11:21:20 +02:00
Dylan Van Assche 22e4c33606 fbd-dev-led-multicolor: Support red, green, blue and white LED colors
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.
2024-06-09 11:21:20 +02:00
Dylan Van Assche 60ce9ecb3c fbd-dev-led: Check max_brightness_percentage range
Percentages are always between 0.0 and 100.0.
Also fix a typo along the way.
2024-06-09 11:21:20 +02:00
Dylan Van Assche 63b564494b fbd-ledctrl: Set permissions for hw_pattern
Allow access to hw_pattern sysfs node for feedbackd, similar to other nodes.
2024-06-09 11:21:20 +02:00
Dylan Van Assche e43126b007 fbd-dev-led: Rework color API
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.
2024-06-09 11:21:19 +02:00
Dylan Van Assche bcd37b0aa5 fbd-dev-led-*: Adjust to method convention
fbd_dev_led_ is the convention for methods, adjust them all.
2024-06-09 11:18:09 +02:00
Dylan Van Assche 94afe719a9 fbd-dev-led: Scan for RGB color as well
Multicolor LEDs have the color 'rgb', we should also scan it
as they are also a FbdDevLed.
2024-06-07 10:15:39 +02:00
Dylan Van Assche 7f69813e84 fbd-dev-led-multicolor: Fix typo in error message
multicololo -> multicolor LED
2024-06-07 10:15:30 +02:00
Dylan Van Assche 66b616677d fbd-dev-led-multicolor: Use separate log domain
Debugging driver probing is much easier when each driver has its own log domain.
2024-06-07 10:14:45 +02:00
Guido Günther f6a92231db fbd-theme-validate: Use G_NORETURN 2024-05-17 06:24:50 +00:00
Guido Günther 95c51c021d fbd-dev-led-multicolor: Drop unused variable 2024-05-17 06:24:50 +00:00
Guido Günther 973c7e006e led: Don't forget to init variable 2024-05-17 06:24:50 +00:00