diff --git a/data/61-gmobile-torch.hwdb b/data/61-gmobile-torch.hwdb new file mode 100644 index 0000000000000000000000000000000000000000..d0d7808cc71f0ea3af7cd023d91aa2a4bd7206b8 --- /dev/null +++ b/data/61-gmobile-torch.hwdb @@ -0,0 +1,65 @@ +# 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 + +########################################################### +# 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 diff --git a/data/61-gmobile-wakeup.hwdb b/data/61-gmobile-wakeup.hwdb index 7fd3dc5fe9515cd2551c1bf2708ad9a9cd518291..502e6f4c3c67301eaebb35695d75a41984c3ecdd 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. # diff --git a/data/61-gmobile.rules b/data/61-gmobile.rules index d08859ec6d68af2b39b0661b39bd61fcd4e53284..9a726be31bb5d92b7c74ce5eef6448d97551eb8e 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 0bdd972b433fe3bd7a43b42055bffb1c3c233983..0f779a912af8301fc683f3922365c227df5d04ca 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 15f1855520b9f53851106cd00b53e3f17fcd744b..d4497f13d249e6f6e0e0431b6f9e1b6308a5ca6b 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)``