From 66be7ed8222bd633f07cbe83c9825d242de5388c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 11 Nov 2025 18:45:08 +0100 Subject: [PATCH 1/3] data: Fix match rule description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: 249da02 ("data: Introduce udev rules and hwdb to track wakeup keys") Signed-off-by: Guido Günther Part-of: --- data/61-gmobile-wakeup.hwdb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/61-gmobile-wakeup.hwdb b/data/61-gmobile-wakeup.hwdb index 7fd3dc5..502e6f4 100644 --- a/data/61-gmobile-wakeup.hwdb +++ b/data/61-gmobile-wakeup.hwdb @@ -17,19 +17,19 @@ # Supported hardware matches are: # # - AT keyboard DMI data matches: -# evdev:atkbd:dmi:bvn*:bvr*:bd*:svn:pn:pvr* +# gmobile:atkbd:dmi:bvn*:bvr*:bd*:svn:pn:pvr* # and are the firmware-provided strings # exported by the kernel DMI modalias, see /sys/class/dmi/id/modalias. # # - Input driver device name and DMI data match: -# evdev:name::dmi:bvn*:bvr*:bd*:svn:pn* +# gmobile:name::dmi:bvn*:bvr*:bd*:svn:pn* # is the name of the device specified by the # driver, is the firmware-provided string exported # by the kernel DMI modalias, see /sys/class/dmi/id/modalias # -# - Input driver device name and device tree compatible match -# evdev:name::dt:* -# is the name device specified by the +# - Input driver device name and machine's device tree compatible match +# gmobile:name::dt:* +# is the device name specified by the # driver, is the first entry of the device tree's compatible # string from /sys/firmware/devicetree/base/compatible. # -- GitLab From df307f5c4b6b12905ae98fcf70dae9fdc29b8cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 11 Nov 2025 18:40:56 +0100 Subject: [PATCH 2/3] data: Add hwdb for torch brightness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to specify a minimum brightness. Signed-off-by: Guido Günther Part-of: --- data/61-gmobile-torch.hwdb | 47 ++++++++++++++++++++++++++++++++++++++ data/61-gmobile.rules | 7 +++++- data/meson.build | 1 + doc/gmobile.udev.rst | 19 ++++++++++++++- 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 data/61-gmobile-torch.hwdb diff --git a/data/61-gmobile-torch.hwdb b/data/61-gmobile-torch.hwdb new file mode 100644 index 0000000..e2181e5 --- /dev/null +++ b/data/61-gmobile-torch.hwdb @@ -0,0 +1,47 @@ +# Copyright 2025 Phosh.mobi e.V. +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of gmobile. +# +# This file contains metadata to apply to keyboards and +# keyboard-like input devices: +# +# - Torch minimum brightness +# +# ########################### MATCHING ####################################### +# +# The lookup keys are composed in: +# 61-gmobile-rules +# +# Supported hardware matches are: +# +# - LEDs device tree name and machine's device tree compatible match +# gmobile:name::dt:* +# is the LED's name as specified in the device tree, +# is the first entry of the device tree's compatible +# string from /sys/firmware/devicetree/base/compatible. +# +# Note that the format of this file might change without notice so device +# specific rules should be submitted to gmobile upstream so they can be kept +# in sync. + +# ######################### TORCH BRIGHTNESS ################################# +# +# The torch brightness specifies a minimum torch brightness value that is +# useful to the user and clearly distinguishable from a `0` brightness. +# It should be great than zero and smaller than the LEDs maximum brightness. +# GM_TORCH_MIN_BRIGHTNESS=10 +# would set the minimum brightness to 10. + +########################################################### +# OnePlus +########################################################### + +# OnePlus 6T +gmobile:name:white:flash:dt:oneplus,fajita* + GM_TORCH_MIN_BRIGHTNESS=1 + +gmobile:name:yellow:flash:dt:oneplus,fajita* + GM_TORCH_MIN_BRIGHTNESS=1 + diff --git a/data/61-gmobile.rules b/data/61-gmobile.rules index d08859e..9a726be 100644 --- a/data/61-gmobile.rules +++ b/data/61-gmobile.rules @@ -7,7 +7,7 @@ # Do not edit this file, it will be overwritten on update ACTION=="remove", GOTO="gmobile_end" -KERNEL!="event*", GOTO="gmobile_end" +KERNEL!="event*|*:torch|*:flash", GOTO="gmobile_end" # AT keyboard matching by the machine's DMI data DRIVERS=="atkbd", \ @@ -24,4 +24,9 @@ KERNELS=="input*", \ IMPORT{builtin}="hwdb 'gmobile:name:$attr{name}:dt:$attr{[devicetree/base]compatible}'", \ ENV{.HAVE_HWDB_PROPERTIES}="1" +# LEDs matching by OF name and the machine's device tree compatible +SUBSYSTEM=="leds", \ + IMPORT{builtin}="hwdb 'gmobile:name:$kernel:dt:$attr{[devicetree/base]compatible}'", \ + ENV{.HAVE_HWDB_PROPERTIES}="1" + LABEL="gmobile_end" diff --git a/data/meson.build b/data/meson.build index 0bdd972..0f779a9 100644 --- a/data/meson.build +++ b/data/meson.build @@ -7,5 +7,6 @@ gm_resources = gnome.compile_resources( if get_option('hwdb') install_data('61-gmobile-wakeup.hwdb', install_dir: udevdir / 'hwdb.d') + install_data('61-gmobile-torch.hwdb', install_dir: udevdir / 'hwdb.d') install_data('61-gmobile.rules', install_dir: udevdir / 'rules.d') endif diff --git a/doc/gmobile.udev.rst b/doc/gmobile.udev.rst index 15f1855..d4497f1 100644 --- a/doc/gmobile.udev.rst +++ b/doc/gmobile.udev.rst @@ -40,6 +40,23 @@ responsible for applying it. For details on how to add these properties to hwdb see below. +TORCH BRIGHTNESS +---------------- + +A LED that is uses as camera flash can also be used as torch. The minimum torch +brightness should still be visible to the user to avoid battery drain. This is +usually the case at level ``1``. The ``GM_TORCH_MIN_BRIGHTNESS`` +allows to override this value. + +:: + + GM_TORCH_MIN_BRIGHTNESS=10 + +Note that gmobile merely provides that information. The applications using the +flash as torch is responsible for applying it. + +For details on how to add these properties to hwdb see below. + CONFIGURING HWDB ---------------- @@ -174,4 +191,4 @@ as the hwdb format might change without notice. See also -------- -``hwdb(7)`` ``systemd-hwdb(8)`` ``phoc(1)`` +``hwdb(7)`` ``systemd-hwdb(8)`` ``phoc(1)`` ``phosh(1)`` -- GitLab From 767d1924f9e809f99a333666ddd8134e05a26885 Mon Sep 17 00:00:00 2001 From: Robert Eckelmann Date: Wed, 12 Nov 2025 10:19:31 +0100 Subject: [PATCH 3/3] data: Add more torch min brightness values Signed-off-by: Robert Eckelmann Part-of: --- data/61-gmobile-torch.hwdb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/data/61-gmobile-torch.hwdb b/data/61-gmobile-torch.hwdb index e2181e5..d0d7808 100644 --- a/data/61-gmobile-torch.hwdb +++ b/data/61-gmobile-torch.hwdb @@ -45,3 +45,21 @@ gmobile:name:white:flash:dt:oneplus,fajita* gmobile:name:yellow:flash:dt:oneplus,fajita* GM_TORCH_MIN_BRIGHTNESS=1 +########################################################### +# Purism +########################################################### + +# Purism Librem L5 +gmobile:name:white:flash:dt:purism,librem5* + GM_TORCH_MIN_BRIGHTNESS=1 + +########################################################### +# Xiaomi +########################################################### + +# Xiaomi Pocophone F1 +gmobile:name:white:flash:dt:xiaomi,beryllium* + GM_TORCH_MIN_BRIGHTNESS=1 + +gmobile:name:yellow:flash:dt:xiaomi,beryllium* + GM_TORCH_MIN_BRIGHTNESS=1 -- GitLab