xf86-video-intel: 3 commits - src/backlight.c src/fd.c src/fd.h src/sna/sna_display.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Aug 21 00:19:22 PDT 2014


 src/backlight.c       |    2 +-
 src/fd.c              |   24 ++++++++++++++++++++++++
 src/fd.h              |    1 +
 src/sna/sna_display.c |   30 ++++++++++++++++++------------
 4 files changed, 44 insertions(+), 13 deletions(-)

New commits:
commit 9b2cf5c7ab6e1a4a9aa46b297fb2f90cb09124ec
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Aug 21 08:17:41 2014 +0100

    sna: Propagate failure from changing backlight value
    
    Especially when we delete the output property halfway through and the
    ChangeProperty routine then attempts to wire it back up...
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82833
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 710f938..ea0324b 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -595,10 +595,11 @@ static void sna_backlight_drain_uevents(struct sna *sna) { }
 static void sna_backlight_close(struct sna *sna) { }
 #endif
 
-static void
+static int
 sna_output_backlight_set(struct sna_output *sna_output, int level)
 {
 	xf86OutputPtr output = sna_output->base;
+	int ret = 0;
 
 	DBG(("%s(%s) level=%d, max=%d\n", __FUNCTION__,
 	     output->name, level, sna_output->backlight.max));
@@ -612,6 +613,7 @@ sna_output_backlight_set(struct sna_output *sna_output, int level)
 			RRDeleteOutputProperty(output->randr_output, backlight_atom);
 			RRDeleteOutputProperty(output->randr_output, backlight_deprecated_atom);
 		}
+		ret = -1;
 	}
 
 	/* Consume the uevent notification now so that we don't misconstrue
@@ -619,6 +621,7 @@ sna_output_backlight_set(struct sna_output *sna_output, int level)
 	 * state.
 	 */
 	sna_backlight_drain_uevents(to_sna(output->scrn));
+	return ret;
 }
 
 static int
@@ -3156,6 +3159,7 @@ sna_output_set_property(xf86OutputPtr output, Atom property,
 
 	if (property == backlight_atom || property == backlight_deprecated_atom) {
 		INT32 val;
+		int ret = 0;
 
 		if (value->type != XA_INTEGER || value->format != 32 ||
 		    value->size != 1)
@@ -3171,8 +3175,8 @@ sna_output_set_property(xf86OutputPtr output, Atom property,
 
 		sna_output->backlight_active_level = val;
 		if (sna_output->dpms_mode == DPMSModeOn)
-			sna_output_backlight_set(sna_output, val);
-		return TRUE;
+			ret = sna_output_backlight_set(sna_output, val);
+		return ret == 0;
 	}
 
 	if (!sna_output->id)
commit 61ec162dc9f4204e26e7786ef26e7abf9ed37ed2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Aug 21 07:21:59 2014 +0100

    backlight: Move the fd out of the select range
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/backlight.c b/src/backlight.c
index bb53aba..129afea 100644
--- a/src/backlight.c
+++ b/src/backlight.c
@@ -271,7 +271,7 @@ enum backlight_type backlight_exists(const char *iface)
 
 static int __backlight_init(struct backlight *b, char *iface, int fd)
 {
-	b->fd = fd_set_cloexec(fd_set_nonblock(fd));
+	b->fd = fd_move_cloexec(fd_set_nonblock(fd));
 	b->iface = iface;
 	return 1;
 }
diff --git a/src/fd.c b/src/fd.c
index 9e1fb6c..445e3f4 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -31,8 +31,32 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#include <misc.h> /* MAXCLIENTS */
+
 #include "fd.h"
 
+int fd_move_cloexec(int fd)
+{
+	int newfd;
+
+	newfd = fcntl(fd,
+#ifdef F_DUPFD_CLOEXEC
+		      F_DUPFD_CLOEXEC,
+#else
+		      F_DUPFD,
+#endif
+		      MAXCLIENTS);
+	if (newfd < 0)
+		return fd;
+
+#ifndef F_DUPFD_CLOEXEC
+	newfd = fd_set_cloexec(newfd);
+#endif
+
+	close(fd);
+	return newfd;
+}
+
 int fd_set_cloexec(int fd)
 {
 	int flags;
diff --git a/src/fd.h b/src/fd.h
index c860e0a..d71fa7b 100644
--- a/src/fd.h
+++ b/src/fd.h
@@ -27,6 +27,7 @@
 #ifndef FD_H
 #define FD_H
 
+int fd_move_cloexec(int fd);
 int fd_set_cloexec(int fd);
 int fd_set_nonblock(int fd);
 
commit 726f1a38a572a8a6121e5194269fb549c363d9f6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Aug 21 07:04:01 2014 +0100

    sna: Only send the bl change notification if the randr_output exists
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index ebda05e..710f938 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -510,15 +510,17 @@ sna_backlight_uevent(int fd, void *closure)
 
 		sna_output->backlight_active_level = val;
 
-		DBG(("%s(%s): sending change notification\n", __FUNCTION__, output->name));
-		RRChangeOutputProperty(output->randr_output,
-				       backlight_atom, XA_INTEGER,
-				       32, PropModeReplace, 1, &val,
-				       TRUE, FALSE);
-		RRChangeOutputProperty(output->randr_output,
-				       backlight_deprecated_atom, XA_INTEGER,
-				       32, PropModeReplace, 1, &val,
-				       TRUE, FALSE);
+		if (output->randr_output) {
+			DBG(("%s(%s): sending change notification\n", __FUNCTION__, output->name));
+			RRChangeOutputProperty(output->randr_output,
+					       backlight_atom, XA_INTEGER,
+					       32, PropModeReplace, 1, &val,
+					       TRUE, FALSE);
+			RRChangeOutputProperty(output->randr_output,
+					       backlight_deprecated_atom, XA_INTEGER,
+					       32, PropModeReplace, 1, &val,
+					       TRUE, FALSE);
+		}
 	}
 }
 


More information about the xorg-commit mailing list