Module Name:    src
Committed By:   maya
Date:           Sun Apr 19 17:19:13 UTC 2020

Modified Files:
        src/sys/external/bsd/drm2/dist/drm: drm_drv.c drm_probe_helper.c
        src/sys/external/bsd/drm2/dist/include/drm: drmP.h

Log Message:
For drm drivers and on monitor hotplug, report a 'display-cycle' hotkey click

If powerd is running, it will invoke the script
/etc/powerd/actions/display-cycle


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/dist/drm/drm_drv.c
cvs rdiff -u -r1.4 -r1.5 \
    src/sys/external/bsd/drm2/dist/drm/drm_probe_helper.c
cvs rdiff -u -r1.39 -r1.40 src/sys/external/bsd/drm2/dist/include/drm/drmP.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/drm_drv.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_drv.c:1.13 src/sys/external/bsd/drm2/dist/drm/drm_drv.c:1.14
--- src/sys/external/bsd/drm2/dist/drm/drm_drv.c:1.13	Thu Mar  5 07:46:59 2020
+++ src/sys/external/bsd/drm2/dist/drm/drm_drv.c	Sun Apr 19 17:19:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_drv.c,v 1.13 2020/03/05 07:46:59 riastradh Exp $	*/
+/*	$NetBSD: drm_drv.c,v 1.14 2020/04/19 17:19:13 maya Exp $	*/
 
 /*
  * Created: Fri Jan 19 10:48:35 2001 by fa...@acm.org
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.13 2020/03/05 07:46:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.14 2020/04/19 17:19:13 maya Exp $");
 
 #include <linux/debugfs.h>
 #include <linux/fs.h>
@@ -660,6 +660,14 @@ struct drm_device *drm_dev_alloc(struct 
 	kref_init(&dev->ref);
 	dev->dev = parent;
 	dev->driver = driver;
+#ifdef __NetBSD__
+	dev->sc_monitor_hotplug.smpsw_name = PSWITCH_HK_DISPLAY_CYCLE;
+	dev->sc_monitor_hotplug.smpsw_type = PSWITCH_TYPE_HOTKEY;
+
+	ret = sysmon_pswitch_register(&dev->sc_monitor_hotplug);
+	if (ret)
+		goto err_pswitch;
+#endif
 
 	INIT_LIST_HEAD(&dev->filelist);
 	INIT_LIST_HEAD(&dev->ctxlist);
@@ -727,6 +735,10 @@ err_free:
 	mutex_destroy(&dev->master_mutex);
 	mutex_destroy(&dev->ctxlist_mutex);
 	mutex_destroy(&dev->struct_mutex);
+#ifdef __NetBSD__
+err_pswitch:
+	sysmon_pswitch_unregister(&dev->sc_monitor_hotplug);
+#endif
 	kfree(dev);
 	return NULL;
 }
@@ -739,6 +751,10 @@ static void drm_dev_release(struct kref 
 	if (drm_core_check_feature(dev, DRIVER_GEM))
 		drm_gem_destroy(dev);
 
+#ifdef __NetBSD__
+	sysmon_pswitch_unregister(&dev->sc_monitor_hotplug);
+#endif
+
 	drm_legacy_ctxbitmap_cleanup(dev);
 	drm_ht_remove(&dev->map_hash);
 	drm_fs_inode_free(dev->anon_inode);

Index: src/sys/external/bsd/drm2/dist/drm/drm_probe_helper.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_probe_helper.c:1.4 src/sys/external/bsd/drm2/dist/drm/drm_probe_helper.c:1.5
--- src/sys/external/bsd/drm2/dist/drm/drm_probe_helper.c:1.4	Fri Feb 14 14:34:57 2020
+++ src/sys/external/bsd/drm2/dist/drm/drm_probe_helper.c	Sun Apr 19 17:19:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_probe_helper.c,v 1.4 2020/02/14 14:34:57 maya Exp $	*/
+/*	$NetBSD: drm_probe_helper.c,v 1.5 2020/04/19 17:19:13 maya Exp $	*/
 
 /*
  * Copyright (c) 2006-2008 Intel Corporation
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_probe_helper.c,v 1.4 2020/02/14 14:34:57 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_probe_helper.c,v 1.5 2020/04/19 17:19:13 maya Exp $");
 
 #include <linux/export.h>
 #include <linux/moduleparam.h>
@@ -328,6 +328,9 @@ EXPORT_SYMBOL(drm_helper_probe_single_co
  */
 void drm_kms_helper_hotplug_event(struct drm_device *dev)
 {
+#ifdef __NetBSD__
+	sysmon_pswitch_event(&dev->sc_monitor_hotplug, PSWITCH_EVENT_PRESSED);
+#endif
 	/* send a uevent + call fbdev */
 	drm_sysfs_hotplug_event(dev);
 	if (dev->mode_config.funcs->output_poll_changed)

Index: src/sys/external/bsd/drm2/dist/include/drm/drmP.h
diff -u src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.39 src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.40
--- src/sys/external/bsd/drm2/dist/include/drm/drmP.h:1.39	Thu Mar  5 08:36:53 2020
+++ src/sys/external/bsd/drm2/dist/include/drm/drmP.h	Sun Apr 19 17:19:13 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: drmP.h,v 1.39 2020/03/05 08:36:53 riastradh Exp $	*/
+/*	$NetBSD: drmP.h,v 1.40 2020/04/19 17:19:13 maya Exp $	*/
 
 /*
  * Internal Header for the Direct Rendering Manager
@@ -903,6 +903,7 @@ struct drm_device {
 	int irq;
 #ifdef __NetBSD__
 	struct drm_bus_irq_cookie *irq_cookie;
+	struct sysmon_pswitch sc_monitor_hotplug;
 #endif
 
 	/*

Reply via email to