summaryrefslogtreecommitdiff
path: root/src/backlight
Commit message (Collapse)AuthorAgeFilesLines
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* backlight: fix issue on multiple graphics cards systemYu Watanabe2022-08-171-1/+61
| | | | | | | | | | | | | | | | If a system has multiple graphics cards, then we cannot associate platform backlight devices to backlight devices under PCI bus. Previously, in such case, vaidate_device() for a raw backlight device might erroneously detect a platform device and return false. So, users could not save/load backlight level. This makes validate_device() give up to associate platform devices on non-PCI bus with raw backlight devices. That may cause unwanted backlight level save or restore by systemd-backlight@.service, but users can workaround that by masking specific instances of the service. Closes #24223.
* backlight: filter out unnecessary backlight devices by device enumeratorYu Watanabe2022-08-171-7/+12
|
* backlight: add/update several logs for validating backlight devicesYu Watanabe2022-08-171-27/+46
|
* backlight: accept embedded display port named e.g. card0-eDP-1Yu Watanabe2022-08-091-1/+1
|
* tree-wide: unify some code that looks for --help in the command lineLennart Poettering2022-03-311-2/+3
|
* backlight: ignore error if the backlight device is already removedYu Watanabe2022-01-051-2/+10
| | | | Fixes #21997.
* alloc-util: add strdupa_safe() + strndupa_safe() and use it everywhereLennart Poettering2021-10-141-1/+1
| | | | | | | | | | | | | Let's define two helpers strdupa_safe() + strndupa_safe() which do the same as their non-safe counterparts, except that they abort if called with allocations larger than ALLOCA_MAX. This should ensure that all our alloca() based allocations are subject to this limit. afaics glibc offers three alloca() based APIs: alloca() itself, strndupa() + strdupa(). With this we have now replacements for all of them, that take the limit into account.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* backlight: refactor get_max_brightness() to appease gccZbigniew Jędrzejewski-Szmek2021-04-011-10/+11
| | | | | | | The old code was just fine, but gcc doesn't understand that max_brightness is initialized. Let's rework it a bit to move some logic to the main function. Now get_max_brightness() just retrieves and parses the attribute, and the main function decides what to do with it.
* backlight: reindent commentsYu Watanabe2021-02-221-32/+22
|
* backlight: reduce indentation a bitYu Watanabe2021-02-221-4/+2
|
* backlight: same_device() may return negative errnoYu Watanabe2021-02-221-1/+1
|
* backlight: exit earlier when unknown verb is specifiedYu Watanabe2021-02-221-1/+4
|
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-011-1/+1
| | | | It may be useful when debugging daemons.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-6/+6
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* backlight: add several debug logs and adjust log level of non critical errorYu Watanabe2020-11-231-2/+6
| | | | This may help to investigate issues.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* various: remove assignments of unread variablesZbigniew Jędrzejewski-Szmek2020-09-221-1/+1
|
* backlight: validate read sysattr valueYu Watanabe2020-09-111-51/+76
| | | | | | | | | | If actual_brightness is larger than max_brightness, then fall back to use brightness attribute. Also, if the saved value is invalid, then this makes remove the file in /var/lib/systemd/backlight. Hopefully fixes #17011.
* backlight: do not claim that ID_BACKLIGHT_CLAMP= property is not setYu Watanabe2020-09-111-1/+2
|
* Add simple usage message to systemd-backlight (#16709)Plan C2020-08-281-0/+28
|
* backlight: read current backlight brightness from 'actual_brightness' attributeYu Watanabe2020-06-301-4/+32
| | | | Closes #16302.
* backlight: call log_setup_service() before loggingYu Watanabe2020-06-301-2/+2
|
* backlight: use SYNTHETIC_ERRNO() macroYu Watanabe2020-06-301-20/+10
|
* util-lib: move shall_restore_state() to shared/reboot-utilZbigniew Jędrzejewski-Szmek2019-09-161-1/+1
| | | | | It's just a small function, but it is higher-level functionality. I don't see a good place for it, reboot-util.[ch] seems least bad
* tree-wide: (void)ify a few unlink() and rmdir()Lennart Poettering2019-03-271-1/+1
| | | | | | Let's be helpful to static analyzers which care about whether we knowingly ignore return values. We do in these cases, since they are usually part of error paths.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+4
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* backlight: handle loading truncated fileTopi Miettinen2019-02-021-1/+1
| | | | | | | | | | | | | | I had accidentally filled my /var partition. This caused backlight to fail to start even with disk space, because the brightness files were truncated to zero size: systemd-backlight[624]: acpi_video0: Failed to parse brightness "": Invalid argument systemd-backlight[624]: acpi_video0: Failed to write system 'brightness' attribute: No such device or address systemd[1]: systemd-backlight@backlight:acpi_video0.service: Main process exited, code=exited, status=1/FAILURE systemd[1]: systemd-backlight@backlight:acpi_video0.service: Failed with result 'exit-code'. systemd[1]: Failed to start Load/Save Screen Backlight Brightness of backlight:acpi_video0. Handle a truncated file like non-existent file.
* tree-wide: port various places over to STARTSWITH_SET()Lennart Poettering2018-11-261-3/+1
|
* backlight: use DEFINE_MAIN_FUNCTION() macroYu Watanabe2018-11-201-57/+37
|
* log: introduce new helper call log_setup_service()Lennart Poettering2018-11-201-3/+1
| | | | | Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
* Move LONG_LINE_MAX definition to fileio.hZbigniew Jędrzejewski-Szmek2018-11-141-1/+0
| | | | | | | | | | | All users of the macro (except for one, in serialize.c), use the macro in connection with read_line(), so they must include fileio.h. Let's not play libc games and require multiple header file to be included for the most common use of a function. The removal of def.h includes is not exact. I mostly went over the commits that switch over to use read_line() and add def.h at the same time and reverted the addition of def.h in those files.
* backlight: use log_device_*()Yu Watanabe2018-10-231-15/+17
|
* tree-wide: use streq() instead of streq_ptr()Yu Watanabe2018-09-231-2/+2
|
* tree-wide: replace ↵Yu Watanabe2018-09-101-6/+2
| | | | device_enumerator_scan_devices()+FOREACH_DEVICE_AND_SUBSYSTEM() by FOREACH_DEVICE()
* backlight: do not unref parent deviceYu Watanabe2018-09-071-5/+4
| | | | Fixes double-free introduced by 9aadd28149ae2d8ce9956495c961d97ba4033b0e.
* backlight: replace udev_device by sd_deviceYu Watanabe2018-08-231-150/+166
|
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop redundant _cleanup_ macros (#8810)Lennart Poettering2018-04-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* backlight: use current brightness if no saved value to trigger clamping (#8526)Sebastian Reichel2018-03-281-5/+40
| | | | This reads current brightness value in case it has not yet been saved. This results in the brightness properly being clamped.
* backlight: minor modernizations (#8528)Lennart Poettering2018-03-231-16/+7
| | | Use strjoina() and STR_IN_SET()
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-2/+2
| | | | | | | | | | | | | This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
* systemctl,networkctl,busctl,backlight: use STRPTR_IN_SETZbigniew Jędrzejewski-Szmek2016-09-241-1/+1
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: check if errno is greater than zero (2)Zbigniew Jędrzejewski-Szmek2016-01-131-1/+1
| | | | | Compare errno with zero in a way that tells gcc that (if the condition is true) errno is positive.