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.
This commit is contained in:
Dylan Van Assche
2024-06-09 11:21:20 +02:00
committed by Guido Günther
parent 22e4c33606
commit 10e6d3cba8
6 changed files with 302 additions and 0 deletions
+31
View File
@@ -8,6 +8,7 @@
#include "fbd-feedback-led.h"
#include "fbd-dev-led.h"
#include "fbd-dev-led-multicolor.h"
#include "fbd-dev-led-qcom.h"
#include "testlib.h"
@@ -67,6 +68,33 @@ test_fbd_dev_led_multicolor (FbdUmockdevFixture *fixture, gconstpointer unused)
}
static void
test_fbd_dev_led_qcom_simple (FbdUmockdevFixture *fixture, gconstpointer unused)
{
GUdevClient *client;
g_autolist (GUdevDevice) leds = NULL;
FbdDevLed *led;
g_autoptr (GError) err = NULL;
GUdevDevice *dev;
client = g_udev_client_new ((const char *const []){ "leds", NULL});
leds = g_udev_client_query_by_subsystem (client, "leds");
/* There should be a single device only */
g_assert_cmpint (g_list_length (leds), ==, 1);
dev = G_UDEV_DEVICE (leds->data);
g_assert_cmpstr (g_udev_device_get_property (dev, "FEEDBACKD_TYPE"), ==, "led");
led = fbd_dev_led_qcom_new (dev, &err);
g_assert_no_error (err);
g_assert_cmpint (fbd_dev_led_get_max_brightness (led), ==, 511);
g_assert_true (fbd_dev_led_supports_color (led, FBD_FEEDBACK_LED_COLOR_WHITE));
g_assert_true (fbd_dev_led_start_periodic (led, 50, 50));
g_assert_finalize_object (led);
}
gint
main (gint argc, gchar *argv[])
{
@@ -78,6 +106,9 @@ main (gint argc, gchar *argv[])
FBD_UMOCKDEV_TEST_ADD ("/feedbackd/fbd/dev/led/multicolor",
test_fbd_dev_led_multicolor,
"led-multicolor");
FBD_UMOCKDEV_TEST_ADD ("/feedbackd/fbd/dev/led/qcom/simple",
test_fbd_dev_led_qcom_simple,
"led-qcom-simple");
return g_test_run();
}