xf86-video-intel: src/backlight.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Feb 16 07:39:18 UTC 2017


 src/backlight.c |   86 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 46 insertions(+), 40 deletions(-)

New commits:
commit 860c3664fe79c1fe92095ff345068f1fc7e4e651
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Feb 16 07:36:22 2017 +0000

    backlight: Provide backlight_find_for_device() stub for BSD
    
    BSD implements a single backlight controller interface and doesn't need
    the sysfs searching of Linux. Just report that there is no per-device
    backlight to fallback to using the ioctl (and in the process avoid
    calling undefined functions inside the BSD block).
    
    Reported-by: David Shao <davshao at gmail.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99833

diff --git a/src/backlight.c b/src/backlight.c
index 3cba577..fcbb279 100644
--- a/src/backlight.c
+++ b/src/backlight.c
@@ -129,6 +129,11 @@ int backlight_get(struct backlight *b)
 	return param.curval;
 }
 
+char *backlight_find_for_device(struct pci_device *pci)
+{
+	return NULL;
+}
+
 int backlight_open(struct backlight *b, char *iface)
 {
 	struct wsdisplay_param param;
@@ -167,6 +172,7 @@ int backlight_off(struct backlight *b)
 {
 	return 0;
 }
+
 #else
 
 static int
@@ -441,6 +447,46 @@ __backlight_find(void)
 	return best_iface;
 }
 
+char *backlight_find_for_device(struct pci_device *pci)
+{
+	char path[200];
+	unsigned best_type = INT_MAX;
+	char *best_iface = NULL;
+	DIR *dir;
+	struct dirent *de;
+
+	snprintf(path, sizeof(path),
+		 "/sys/bus/pci/devices/%04x:%02x:%02x.%d/backlight",
+		 pci->domain, pci->bus, pci->dev, pci->func);
+
+	dir = opendir(path);
+	if (dir == NULL)
+		return NULL;
+
+	while ((de = readdir(dir))) {
+		int v;
+
+		if (*de->d_name == '.')
+			continue;
+
+		v = __backlight_exists(de->d_name);
+		if (v < 0)
+			continue;
+
+		if (v < best_type) {
+			char *copy = strdup(de->d_name);
+			if (copy) {
+				free(best_iface);
+				best_iface = copy;
+				best_type = v;
+			}
+		}
+	}
+	closedir(dir);
+
+	return best_iface;
+}
+
 int backlight_open(struct backlight *b, char *iface)
 {
 	int level, type;
@@ -547,43 +593,3 @@ void backlight_close(struct backlight *b)
 	if (b->pid > 0)
 		waitpid(b->pid, NULL, 0);
 }
-
-char *backlight_find_for_device(struct pci_device *pci)
-{
-	char path[200];
-	unsigned best_type = INT_MAX;
-	char *best_iface = NULL;
-	DIR *dir;
-	struct dirent *de;
-
-	snprintf(path, sizeof(path),
-		 "/sys/bus/pci/devices/%04x:%02x:%02x.%d/backlight",
-		 pci->domain, pci->bus, pci->dev, pci->func);
-
-	dir = opendir(path);
-	if (dir == NULL)
-		return NULL;
-
-	while ((de = readdir(dir))) {
-		int v;
-
-		if (*de->d_name == '.')
-			continue;
-
-		v = __backlight_exists(de->d_name);
-		if (v < 0)
-			continue;
-
-		if (v < best_type) {
-			char *copy = strdup(de->d_name);
-			if (copy) {
-				free(best_iface);
-				best_iface = copy;
-				best_type = v;
-			}
-		}
-	}
-	closedir(dir);
-
-	return best_iface;
-}


More information about the xorg-commit mailing list