Skip to contentSkip to conversation

drm: emit change events when mode config changes

RFC In review Jesse Barnes 3 participants 4 messages Apr 14, 2011 – Apr 15, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 drm: emit change events when mode config changes

We've already seen that apps want to monitor the display config, and some (like upowerd) poll for changes since we don't provide a notification for general mode config changes, just hotplug events. So add a new drm event, with CHANGE=1 set in the event, to allow for it.

drivers/gpu/drm/drm_crtc.c +2 -0
index 4c95b5f..174ee64 100644
@@ -1589,6 +1589,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 	set.fb = fb;
 	ret = crtc->funcs->set_config(&set);
 
+	drm_sysfs_change_event(dev);
+
 out:
 	kfree(connector_set);
 	mutex_unlock(&dev->mode_config.mutex);
drivers/gpu/drm/drm_fb_helper.c +2 -0
index 9507204..df946d4 100644
@@ -822,6 +822,8 @@ int drm_fb_helper_set_par(struct fb_info *info)
 			return ret;
 		}
 	}
+
+	drm_sysfs_change_event(dev);
 	mutex_unlock(&dev->mode_config.mutex);
 
 	if (fb_helper->delayed_hotplug) {
drivers/gpu/drm/drm_sysfs.c +21 -3
index 2eee8e0..fd3af31 100644
@@ -467,9 +467,9 @@ EXPORT_SYMBOL(drm_sysfs_connector_remove);
  * drm_sysfs_hotplug_event - generate a DRM uevent
  * @dev: DRM device
  *
- * Send a uevent for the DRM device specified by @dev.  Currently we only
- * set HOTPLUG=1 in the uevent environment, but this could be expanded to
- * deal with other types of events.
+ * Send a uevent for the DRM device specified by @dev.  Set HOTPLUG=1 in the
+ * event to indicate a display config change occurred, probably due to a
+ * display being added or removed.
  */
 void drm_sysfs_hotplug_event(struct drm_device *dev)
 {
@@ -483,6 +483,24 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
 EXPORT_SYMBOL(drm_sysfs_hotplug_event);
 
 /**
+ * drm_sysfs_change_event - generate a DRM uevent indicating a display config change
+ * @dev: DRM device
+ *
+ * Send a uevent for the DRM device specified by @dev.  Set CHANGE=1 to
+ * indicate that a userspace initiated display configuration change occurred.
+ */
+void drm_sysfs_change_event(struct drm_device *dev)
+{
+	char *event_string = "CHANGE=1";
+	char *envp[] = { event_string, NULL };
+
+	DRM_DEBUG("generating hotplug event\n");
+
+	kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, envp);
+}
+EXPORT_SYMBOL(drm_sysfs_change_event);
+
+/**
  * drm_sysfs_device_add - adds a class device to sysfs for a character driver
  * @dev: DRM device to be added
  * @head: DRM head in question
include/drm/drmP.h +1 -0
index ad5770f..3aff8fc 100644
@@ -1506,6 +1506,7 @@ extern struct class *drm_sysfs_create(struct module *owner, char *name);
 extern void drm_sysfs_destroy(void);
 extern int drm_sysfs_device_add(struct drm_minor *minor);
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
+extern void drm_sysfs_change_event(struct drm_device *dev);
 extern void drm_sysfs_device_remove(struct drm_minor *minor);
 extern char *drm_get_connector_status_name(enum drm_connector_status status);
 extern int drm_sysfs_connector_add(struct drm_connector *connector);

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#1 lore raw
Quoted 56 lines · Jesse Barnes

We've already seen that apps want to monitor the display config, and some (like upowerd) poll for changes since we don't provide a notification for general mode config changes, just hotplug events. So add a new drm event, with CHANGE=1 set in the event, to allow for it.

drivers/gpu/drm/drm_crtc.c +2 -0
index 4c95b5f..174ee64 100644
@@ -1589,6 +1589,8 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
 	set.fb = fb;
 	ret = crtc->funcs->set_config(&set);
 
+	drm_sysfs_change_event(dev);
+
 out:
 	kfree(connector_set);
 	mutex_unlock(&dev->mode_config.mutex);
drivers/gpu/drm/drm_fb_helper.c +2 -0
index 9507204..df946d4 100644
@@ -822,6 +822,8 @@ int drm_fb_helper_set_par(struct fb_info *info)
 			return ret;
 		}
 	}
+
+	drm_sysfs_change_event(dev);
 	mutex_unlock(&dev->mode_config.mutex);
 
 	if (fb_helper->delayed_hotplug) {
drivers/gpu/drm/drm_sysfs.c +5 -3
index 2eee8e0..fd3af31 100644
@@ -467,9 +467,9 @@ EXPORT_SYMBOL(drm_sysfs_connector_remove);
  * drm_sysfs_hotplug_event - generate a DRM uevent
  * @dev: DRM device
  *
- * Send a uevent for the DRM device specified by @dev.  Currently we only
- * set HOTPLUG=1 in the uevent environment, but this could be expanded to
- * deal with other types of events.
+ * Send a uevent for the DRM device specified by @dev.  Set HOTPLUG=1 in the
+ * event to indicate a display config change occurred, probably due to a
+ * display being added or removed.
  */
 void drm_sysfs_hotplug_event(struct drm_device *dev)
 {
@@ -483,6 +483,24 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
 EXPORT_SYMBOL(drm_sysfs_hotplug_event);
 
 /**
+ * drm_sysfs_change_event - generate a DRM uevent indicating a display config change
+ * @dev: DRM device

drivers/gpu/drm/drm_sysfs.c void drm_sysfs_hotplug_event(struct drm_device *dev) · line 497

Quoted 10 lines
drivers/gpu/drm/drm_sysfs.c +10 -0
+ *
+ * Send a uevent for the DRM device specified by @dev.  Set CHANGE=1 to
+ * indicate that a userspace initiated display configuration change occurred.
+ */
+void drm_sysfs_change_event(struct drm_device *dev)
+{
+	char *event_string = "CHANGE=1";
+	char *envp[] = { event_string, NULL };
+
+	DRM_DEBUG("generating hotplug event\n");

Should be "change event" here?

Quoted 29 lines
drivers/gpu/drm/drm_sysfs.c +6 -0
+
+	kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, envp);
+}
+EXPORT_SYMBOL(drm_sysfs_change_event);
+
+/**
  * drm_sysfs_device_add - adds a class device to sysfs for a character driver
  * @dev: DRM device to be added
  * @head: DRM head in question
include/drm/drmP.h +1 -1
index ad5770f..3aff8fc 100644
@@ -1506,6 +1506,7 @@ extern struct class *drm_sysfs_create(struct module *owner, char *name);
 extern void drm_sysfs_destroy(void);
 extern int drm_sysfs_device_add(struct drm_minor *minor);
 extern void drm_sysfs_hotplug_event(struct drm_device *dev);
+extern void drm_sysfs_change_event(struct drm_device *dev);
 extern void drm_sysfs_device_remove(struct drm_minor *minor);
 extern char *drm_get_connector_status_name(enum drm_connector_status status);
 extern int drm_sysfs_connector_add(struct drm_connector *connector);
 
------------------------------------------------------------------------------

Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
--

Quoted 8 lines

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

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel

#2 lore raw
Quoted 16 lines · On Fri, 15 Apr 2011 09:23:38 -0500 Chris Bandy <[email protected]> wrote:

drivers/gpu/drm/drm_sysfs.c void drm_sysfs_hotplug_event(struct drm_device *dev) · line 497

Quoted 13 lines · Jesse Barnes

/**
+ * drm_sysfs_change_event - generate a DRM uevent indicating a display config change
+ * @dev: DRM device
+ *
+ * Send a uevent for the DRM device specified by @dev. Set CHANGE=1 to
+ * indicate that a userspace initiated display configuration change occurred.
+ */

drivers/gpu/drm/drm_sysfs.c +6 -0
+void drm_sysfs_change_event(struct drm_device *dev)
+{
+	char *event_string = "CHANGE=1";
+	char *envp[] = { event_string, NULL };
+
+	DRM_DEBUG("generating hotplug event\n");

Should be "change event" here?

Yeah, I noticed after I sent it out, I think I'll just drop the DRM_DEBUG altogether though.

Signature · 13 lines
Jesse Barnes, Intel Open Source Technology Center

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
Reviewed-by on v1 1/1
#3 lore raw
In reply to Jesse Barnes
Quoted 6 lines · Jesse Barnes

We've already seen that apps want to monitor the display config, and some (like upowerd) poll for changes since we don't provide a notification for general mode config changes, just hotplug events. So add a new drm event, with CHANGE=1 set in the event, to allow for it.

- ajax

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel