Skip to contentSkip to conversation

intel: Listen for hotplug uevents

PATCH New Keith Packard 4 participants 8 messages Oct 3, 2010 – Oct 4, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel: Listen for hotplug uevents

From: Adam Jackson <[email protected]>

This connects the kernel uevent indicating monitor hotplugging to the RandR notification events so that X applications can be notified automatically when monitors are connected or disconnected.

This also adds a configuration option to disable hotplug events.

---
 configure.ac       |    5 ++
 src/Makefile.am    |    4 +-
 src/intel.h        |   11 +++++
 src/intel_driver.c |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 132 insertions(+), 2 deletions(-)
configure.ac +5 -0
index e066b3d..58fa929 100644
@@ -47,6 +47,11 @@ AC_PROG_LIBTOOL
 PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no])
 AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
 
+PKG_CHECK_MODULES(UDEV, [libudev], [udev=yes], [udev=no])
+if test x"$udev" = xyes; then
+	AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection])
+fi
+
 AH_TOP([#include "xorg-server.h"])
 
 # Define a configure option for an alternate module directory
src/Makefile.am +2 -2
index b0a1cf7..ab70207 100644
@@ -26,13 +26,13 @@ SUBDIRS = xvmc render_program legacy
 # _ladir passes a dummy rpath to libtool so the thing will actually link
 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
 
-AM_CFLAGS = @CWARNFLAGS@ @XORG_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
+AM_CFLAGS = @CWARNFLAGS@ @XORG_CFLAGS@ @UDEV_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
 	@PCIACCESS_CFLAGS@ -I$(top_srcdir)/uxa -I$(top_srcdir)/src/render_program
 
 intel_drv_la_LTLIBRARIES = intel_drv.la
 intel_drv_la_LDFLAGS = -module -avoid-version
 intel_drv_ladir = @moduledir@/drivers
-intel_drv_la_LIBADD = -lm @DRM_LIBS@ -ldrm_intel ../uxa/libuxa.la legacy/liblegacy.la
+intel_drv_la_LIBADD = @UDEV_LIBS@ -lm @DRM_LIBS@ -ldrm_intel ../uxa/libuxa.la legacy/liblegacy.la
 intel_drv_la_LIBADD += @PCIACCESS_LIBS@
 
 NULL:=#
src/intel.h +11 -0
index b816aeb..a80b214 100644
@@ -34,6 +34,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #if 0
 #define I830DEBUG
 #endif
@@ -47,6 +51,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef _I830_H_
 #define _I830_H_
 
+
 #include "xf86_OSproc.h"
 #include "compiler.h"
 #include "xf86PciInfo.h"
@@ -70,6 +75,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "intel_driver.h"
 
+#if HAVE_UDEV
+#include <libudev.h>
+#endif
+
 #include "uxa.h"
 /* XXX
  * The X server gained an *almost* identical implementation in 1.9.
@@ -435,6 +444,8 @@ typedef struct intel_screen_private {
 	 */
 	Bool fallback_debug;
 	unsigned debug_flush;
+	struct udev_monitor *uevent_monitor;
+	InputHandlerProc uevent_handler;
 } intel_screen_private;
 
 enum {
src/intel_driver.c +114 -0

144 lines not on this page · raw message

Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 intel: Listen for hotplug uevents (V2)

From: Adam Jackson <[email protected]>

This connects the kernel uevent indicating monitor hotplugging to the RandR notification events so that X applications can be notified automatically when monitors are connected or disconnected.

This also adds a configuration option to disable hotplug events.

V2: missed a #ifdef HAVE_UDEV around some udev-specific declarations

---
 configure.ac       |    5 ++
 src/Makefile.am    |    4 +-
 src/intel.h        |   12 +++++
 src/intel_driver.c |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 133 insertions(+), 2 deletions(-)
configure.ac +5 -0
index e066b3d..58fa929 100644
@@ -47,6 +47,11 @@ AC_PROG_LIBTOOL
 PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no])
 AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
 
+PKG_CHECK_MODULES(UDEV, [libudev], [udev=yes], [udev=no])
+if test x"$udev" = xyes; then
+	AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection])
+fi
+
 AH_TOP([#include "xorg-server.h"])
 
 # Define a configure option for an alternate module directory
src/Makefile.am +2 -2
index b0a1cf7..ab70207 100644
@@ -26,13 +26,13 @@ SUBDIRS = xvmc render_program legacy
 # _ladir passes a dummy rpath to libtool so the thing will actually link
 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
 
-AM_CFLAGS = @CWARNFLAGS@ @XORG_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
+AM_CFLAGS = @CWARNFLAGS@ @XORG_CFLAGS@ @UDEV_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
 	@PCIACCESS_CFLAGS@ -I$(top_srcdir)/uxa -I$(top_srcdir)/src/render_program
 
 intel_drv_la_LTLIBRARIES = intel_drv.la
 intel_drv_la_LDFLAGS = -module -avoid-version
 intel_drv_ladir = @moduledir@/drivers
-intel_drv_la_LIBADD = -lm @DRM_LIBS@ -ldrm_intel ../uxa/libuxa.la legacy/liblegacy.la
+intel_drv_la_LIBADD = @UDEV_LIBS@ -lm @DRM_LIBS@ -ldrm_intel ../uxa/libuxa.la legacy/liblegacy.la
 intel_drv_la_LIBADD += @PCIACCESS_LIBS@
 
 NULL:=#
src/intel.h +12 -0
index b816aeb..1234b94 100644
@@ -34,6 +34,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #if 0
 #define I830DEBUG
 #endif
@@ -70,6 +74,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "intel_driver.h"
 
+#if HAVE_UDEV
+#include <libudev.h>
+#endif
+
 #include "uxa.h"
 /* XXX
  * The X server gained an *almost* identical implementation in 1.9.
@@ -435,6 +443,10 @@ typedef struct intel_screen_private {
 	 */
 	Bool fallback_debug;
 	unsigned debug_flush;
+#if HAVE_UDEV
+	struct udev_monitor *uevent_monitor;
+	InputHandlerProc uevent_handler;
+#endif
 } intel_screen_private;
 
 enum {
src/intel_driver.c +114 -0

144 lines not on this page · raw message

Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH] intel: Listen for hotplug uevents (V2)

Quoted 3 lines · Keith Packard

This connects the kernel uevent indicating monitor hotplugging to the RandR notification events so that X applications can be notified automatically when monitors are connected or disconnected.

Are these events actually being generated?

If there is the infrastructure to do so, then it seems that the 600ms delay while polling unconnected monitors could easily be removed.

Or has that already been done, but just not for the older hardware?

//Peter

#3 lore raw

Re: [PATCH] intel: Listen for hotplug uevents (V2)

Quoted 2 lines · Peter Stuge

If there is the infrastructure to do so, then it seems that the 600ms delay while polling unconnected monitors could easily be removed.

Newer hardware generates interrupts for VGA and TV hotplug events; older hardware doesn't.

Signature · 1 line
[email protected]

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [Intel-gfx] [PATCH] intel: Listen for hotplug uevents (V2)

In reply to Keith Packard
Quoted 5 lines · Keith Packard

From: Adam Jackson <[email protected]>

This connects the kernel uevent indicating monitor hotplugging to the RandR notification events so that X applications can be notified automatically when monitors are connected or disconnected.

The obvious question: why are we doing this in the driver? It looks very generic and can be shared between any of the drm drivers, so should this be a facility provided by the server? It would be a good start to a KMS module...
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#5 lore raw

Re: [PATCH] intel: Listen for hotplug uevents (V2)

In reply to Keith Packard
Quoted 12 lines · Keith Packard

From: Adam Jackson <[email protected]>
...
+++ b/src/intel_driver.c

src/intel_driver.c +1 -0
@@ -107,6 +107,7 @@ typedef enum {
    OPTION_DEBUG_FLUSH_BATCHES,
    OPTION_DEBUG_FLUSH_CACHES,
    OPTION_DEBUG_WAIT,
+   OPTION_HOTPLUG,
  } I830Opts;
 
  static OptionInfoRec I830Options[] = {

src/intel_driver.c static OptionInfoRec I830Options[] = { · line 132

Quoted 7 lines
src/intel_driver.c +1 -0
@@ -125,6 +126,7 @@ static OptionInfoRec I830Options[] = {
    {OPTION_DEBUG_FLUSH_BATCHES, "DebugFlushBatches", OPTV_BOOLEAN, {0}, FALSE},
    {OPTION_DEBUG_FLUSH_CACHES, "DebugFlushCaches", OPTV_BOOLEAN, {0}, FALSE},
    {OPTION_DEBUG_WAIT, "DebugWait", OPTV_BOOLEAN, {0}, FALSE},
+   {OPTION_HOTPLUG,    "HotPlug",      OPTV_BOOLEAN,   {0},    TRUE},
    {-1,                        NULL,           OPTV_NONE,      {0},    FALSE}
  };
  /* *INDENT-ON* */

The HotPlug option should also be added to the intel man page, right?

Geir Ove

#6 lore raw

PATCH 1/1 intel: Listen for hotplug uevents (V3)

From: Adam Jackson <[email protected]>

This connects the kernel uevent indicating monitor hotplugging to the RandR notification events so that X applications can be notified automatically when monitors are connected or disconnected.

This also adds a configuration option to disable hotplug events.

V2: missed a #ifdef HAVE_UDEV around some udev-specific declarations

V3: document Hotplug option in man page

---
 configure.ac       |    5 ++
 man/intel.man      |    6 +++
 src/Makefile.am    |    4 +-
 src/intel.h        |   12 +++++
 src/intel_driver.c |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 139 insertions(+), 2 deletions(-)
configure.ac +5 -0
index e066b3d..58fa929 100644
@@ -47,6 +47,11 @@ AC_PROG_LIBTOOL
 PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.0], [gen4asm=yes], [gen4asm=no])
 AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
 
+PKG_CHECK_MODULES(UDEV, [libudev], [udev=yes], [udev=no])
+if test x"$udev" = xyes; then
+	AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection])
+fi
+
 AH_TOP([#include "xorg-server.h"])
 
 # Define a configure option for an alternate module directory
man/intel.man +6 -0
index 31860f2..fa7f7dc 100644
@@ -192,6 +192,12 @@ Enable XvMC driver. Current support MPEG2 MC on 915/945 and G33 series.
 User should provide absolute path to libIntelXvMC.so in XvMCConfig file.
 .IP
 Default: Disabled.
+.TP
+.BI "Option \*qHotplug\*q \*q" boolean \*q
+This option controls whether the driver automatically notifies
+applications when monitors are connected or disconnected.
+.IP
+Default: enabled.
 
 .SH OUTPUT CONFIGURATION
 On 830M and better chipsets, the driver supports runtime configuration of
src/Makefile.am +2 -2
index b0a1cf7..ab70207 100644
@@ -26,13 +26,13 @@ SUBDIRS = xvmc render_program legacy
 # _ladir passes a dummy rpath to libtool so the thing will actually link
 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
 
-AM_CFLAGS = @CWARNFLAGS@ @XORG_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
+AM_CFLAGS = @CWARNFLAGS@ @XORG_CFLAGS@ @UDEV_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
 	@PCIACCESS_CFLAGS@ -I$(top_srcdir)/uxa -I$(top_srcdir)/src/render_program
 
 intel_drv_la_LTLIBRARIES = intel_drv.la
 intel_drv_la_LDFLAGS = -module -avoid-version
 intel_drv_ladir = @moduledir@/drivers
-intel_drv_la_LIBADD = -lm @DRM_LIBS@ -ldrm_intel ../uxa/libuxa.la legacy/liblegacy.la
+intel_drv_la_LIBADD = @UDEV_LIBS@ -lm @DRM_LIBS@ -ldrm_intel ../uxa/libuxa.la legacy/liblegacy.la
 intel_drv_la_LIBADD += @PCIACCESS_LIBS@
 
 NULL:=#
src/intel.h +12 -0
index b816aeb..1234b94 100644
@@ -34,6 +34,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #if 0
 #define I830DEBUG
 #endif
@@ -70,6 +74,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "intel_driver.h"
 
+#if HAVE_UDEV
+#include <libudev.h>
+#endif
+
 #include "uxa.h"
 /* XXX
  * The X server gained an *almost* identical implementation in 1.9.
@@ -435,6 +443,10 @@ typedef struct intel_screen_private {
 	 */
 	Bool fallback_debug;
 	unsigned debug_flush;
+#if HAVE_UDEV
+	struct udev_monitor *uevent_monitor;
+	InputHandlerProc uevent_handler;
+#endif
 } intel_screen_private;
 
 enum {
src/intel_driver.c +114 -0

144 lines not on this page · raw message

Signature · 1 line
1.7.1
#7 lore raw

Re: [PATCH] intel: Listen for hotplug uevents (V3)

Quoted 3 lines · Keith Packard

+.BI "Option \*qHotplug\*q \*q" boolean \*q
...
+   {OPTION_HOTPLUG,    "HotPlug",      OPTV_BOOLEAN,   {0},    TRUE},

It probably doesn't matter, but it would be nice to be consistent with the captialization. "Hotplug" or "HotPlug".

Geir Ove