netstar pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=8629f7e73586803706d004e50810f97c072f8a98

commit 8629f7e73586803706d004e50810f97c072f8a98
Author: Alastair Poole <nets...@gmail.com>
Date:   Thu Feb 4 10:12:53 2021 +0000

    backlight: Add support for FreeBSD 13
    
    Initial backlight support.
---
 src/bin/system/e_system.h           |  5 +++++
 src/bin/system/e_system_backlight.c | 43 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/bin/system/e_system.h b/src/bin/system/e_system.h
index 8ecef6d3d..74c82fcd8 100644
--- a/src/bin/system/e_system.h
+++ b/src/bin/system/e_system.h
@@ -74,6 +74,11 @@ void *alloca (size_t);
 # include <sys/sysctl.h>
 #endif
 
+#if defined (__FreeBSD_kernel__)
+# include <sys/ioctl.h>
+# include <sys/backlight.h>
+#endif
+
 # ifndef _POSIX_HOST_NAME_MAX
 #  define _POSIX_HOST_NAME_MAX 255
 # endif
diff --git a/src/bin/system/e_system_backlight.c 
b/src/bin/system/e_system_backlight.c
index 00d68175e..0c81ef687 100644
--- a/src/bin/system/e_system_backlight.c
+++ b/src/bin/system/e_system_backlight.c
@@ -44,8 +44,19 @@ _light_set(Light *lig, int val)
         close(fd);
      }
 #elif defined(__FreeBSD_kernel__)
+#if __FreeBSD__ > 12
+   int fd = open("/dev/backlight/backlight0", O_RDWR);
+   if (fd >= 0)
+     {
+        struct backlight_props props;
+        props.brightness = lig->val;
+        ioctl(fd, BACKLIGHTUPDATESTATUS, &props);
+        close(fd);
+     }
+#else
    sysctlbyname(lig->dev, NULL, NULL, &(lig->val), sizeof(lig->val));
 #endif
+#endif
 }
 
 static void
@@ -72,9 +83,22 @@ _light_get(Light *lig)
         eina_stringshare_del(s);
      }
 #elif defined(__FreeBSD_kernel__)
+#if __FreeBSD__ > 12
+   struct backlight_props props;
+   int fd = open("/dev/backlight/backlight0", O_RDWR);
+   if (fd >= 0)
+     {
+        if (ioctl(fd, BACKLIGHTGETSTATUS, &props) != -1)
+          {
+             lig->val = props.brightness;
+          }
+        close(fd);
+     }
+#else
    size_t plen = sizeof(lig->val);
    sysctlbyname(lig->dev, &(lig->val), &plen, NULL, 0);
 #endif
+#endif
 }
 
 static void
@@ -178,9 +202,22 @@ _light_add(const char *dev)
      }
    if (lig->max <= 0) lig->max = 255;
    lig->prefer = eeze_udev_syspath_check_sysattr(lig->dev, "type", "firmware");
-#elif defined(__FreeBSD_kernel__)
+#elif defined (__FreeBSD_kernel__)
+#if __FreeBSD__ > 12
+   struct backlight_props props;
+   int fd = open("/dev/backlight/backlight0", O_RDWR);
+   if (fd >= 0)
+     {
+        if (ioctl(fd, BACKLIGHTGETSTATUS, &props) != -1)
+          {
+             lig->val = props.brightness;
+          }
+        close(fd);
+     }
+# else
    size_t plen = sizeof(lig->val);
    sysctlbyname(lig->dev, &(lig->val), &plen, NULL, 0);
+#endif
    lig->max = 100;
 #endif
    _devices = eina_list_append(_devices, lig);
@@ -238,8 +275,12 @@ _light_refresh_devices()
      }
 #elif defined(__FreeBSD_kernel__)
    // XXX; shouldn't we scan for devices?
+#if __FreeBSD__ > 12
+   _light_add("backlight0");
+#else
    _light_add("hw.acpi.video.lcd0.brightness");
 #endif
+#endif
 }
 
 static Light *

-- 


Reply via email to