From 76424950e373d3b04ac3dd13019151bfba3e8423 Mon Sep 17 00:00:00 2001 From: sumuel Date: Mon, 17 Aug 2026 20:44:55 +0000 Subject: Add the files --- src/detection/brightness/brightness_obsd.c | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/detection/brightness/brightness_obsd.c (limited to 'src/detection/brightness/brightness_obsd.c') diff --git a/src/detection/brightness/brightness_obsd.c b/src/detection/brightness/brightness_obsd.c new file mode 100644 index 0000000..102a8c2 --- /dev/null +++ b/src/detection/brightness/brightness_obsd.c @@ -0,0 +1,44 @@ +#include "brightness.h" +#include "common/io.h" + +#include +#include +#include +#include + +const char* ffDetectBrightness(FF_A_UNUSED FFBrightnessOptions* options, FFlist* result) { + char path[] = "/dev/ttyCX"; + for (char i = '0'; i <= '9'; ++i) { + path[strlen("/dev/ttyC")] = i; + + FF_AUTO_CLOSE_FD int devfd = open(path, O_RDONLY | O_CLOEXEC); + + if (devfd < 0) { + if (errno == EACCES && i == '0') { + return "Permission denied when opening tty device"; + } + if (errno == ENOENT) { + break; + } + continue; + } + + struct wsdisplay_param param = { + .param = WSDISPLAYIO_PARAM_BRIGHTNESS, + }; + + if (ioctl(devfd, WSDISPLAYIO_GETPARAM, ¶m) < 0) { + continue; + } + + FFBrightnessResult* brightness = FF_LIST_ADD(FFBrightnessResult, *result); + ffStrbufInitF(&brightness->name, "ttyC%c", i); + + brightness->max = param.max; + brightness->min = param.min; + brightness->current = param.curval; + brightness->builtin = true; + } + + return NULL; +} -- cgit v1.2.3