drm: Add DPMS ioctl
Subsystems (2)
PATCH 1/1 drm: Add DPMS ioctl
Display power management should be available to user no matter whether display server implements it or not and should be made server agnostic (X.Org, Wayland compositor), without need of TTY change.
Reasons:
1. User implements an own universal power management daemon. He has no interest to deal with server or switch to a free TTY, he wants to turn off the monitor in a simple way, like he controls power of other system components.
2. Some applications under X.Org like Electron-based ones like to prevent screen goning off giving user no way to fix that.
3. Many fresh new Wayland compositors don't implement DPMS at all and at the same time have TTY switch broken.
--- drivers/gpu/drm/drm_crtc_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 1 + drivers/gpu/drm/drm_mode_object.c | 41 +++++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 1 + 4 files changed, 45 insertions(+)
drivers/gpu/drm/drm_crtc_internal.h +2 -0
@@ -122,6 +122,8 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int drm_mode_obj_set_property_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); +int drm_mode_connector_dpms_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv);/* drm_encoder.c */ int drm_encoder_register_all (struct drm_device *dev);
drivers/gpu/drm/drm_ioctl.c +1 -0
@@ -632,6 +632,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_DETACHMODE , drm_noop,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPERTY , drm_mode_getproperty_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_SETPROPERTY , drm_mode_connector_property_set_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_DPMS , drm_mode_connector_dpms_ioctl,DRM_ROOT_ONLY |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPBLOB , drm_mode_getblob_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETFB , drm_mode_getfb,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED),
drivers/gpu/drm/drm_mode_object.c +41 -0
44 lines not on this page · raw message
include/uapi/drm/drm.h +1 -0
@@ -862,6 +862,7 @@ extern "C" {#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait)#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array)#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array) +#define DRM_IOCTL_MODE_DPMS DRM_IOWR(0xC6, struct drm_mode_connector_set_property)/** * Device specific ioctls should only be in their respective headers
Signature · 6 lines
2.14.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 14 lines · Alex Ivanov
Display power management should be available to user no matter whether display server implements it or not and should be made server agnostic (X.Org, Wayland compositor), without need of TTY change.
Reasons:
1. User implements an own universal power management daemon. He has no interest to deal with server or switch to a free TTY, he wants to turn off the monitor in a simple way, like he controls power of other system components.
2. Some applications under X.Org like Electron-based ones like to prevent screen goning off giving user no way to fix that.
3. Many fresh new Wayland compositors don't implement DPMS at all and at the same time have TTY switch broken.
Quoted 1 line
Signed-off-by Alex Ivanov <[email protected]>
Why exactly is the existing dpms ioctl not good enough? it's implemented as the "DPMS" property attached to connectors, but that's the only difference compared to your code here.
Also, that one doesn't have any XXX about atomic like yours.
I also have no idea how this fixes any of your above problems. -Daniel
Quoted 100 lines
--- drivers/gpu/drm/drm_crtc_internal.h | 2 ++ drivers/gpu/drm/drm_ioctl.c | 1 + drivers/gpu/drm/drm_mode_object.c | 41 +++++++++++++++++++++++++++++++++++++ include/uapi/drm/drm.h | 1 + 4 files changed, 45 insertions(+)drivers/gpu/drm/drm_crtc_internal.h +2
-0@@ -122,6 +122,8 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv);int drm_mode_obj_set_property_ioctl (struct drm_device *dev,void *data,struct drm_file *file_priv); +int drm_mode_connector_dpms_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv);/* drm_encoder.c */ int drm_encoder_register_all (struct drm_device *dev);drivers/gpu/drm/drm_ioctl.c +1
-0@@ -632,6 +632,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {DRM_IOCTL_DEF (DRM_IOCTL_MODE_DETACHMODE , drm_noop,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPERTY , drm_mode_getproperty_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_SETPROPERTY , drm_mode_connector_property_set_ioctl,DRM_MASTER |DRM_CONTROL_ALLOW |DRM_UNLOCKED ), +DRM_IOCTL_DEF (DRM_IOCTL_MODE_DPMS , drm_mode_connector_dpms_ioctl,DRM_ROOT_ONLY |DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETPROPBLOB , drm_mode_getblob_ioctl,DRM_CONTROL_ALLOW |DRM_UNLOCKED ),DRM_IOCTL_DEF (DRM_IOCTL_MODE_GETFB , drm_mode_getfb,DRM_CONTROL_ALLOW |DRM_UNLOCKED ), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_CONTROL_ALLOW|DRM_UNLOCKED),drivers/gpu/drm/drm_mode_object.c +41
-0@@ -500,3 +500,44 @@ int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,drm_mode_object_put (arg_obj);return ret; } + +int drm_mode_connector_dpms_ioctl (struct drm_device *dev, +void *data,struct drm_file *file_priv) +{ +struct drm_mode_connector_set_property *conn_set_prop = data; +struct drm_mode_obj_set_property obj_set_prop = { + .value = conn_set_prop->value, + .obj_id = conn_set_prop->connector_id, + .obj_type =DRM_MODE_OBJECT_CONNECTOR + }; + +struct drm_mode_obj_set_property *arg = &obj_set_prop; +struct drm_mode_object *arg_obj; +struct drm_property *property; +int ret = -EINVAL ; + +struct drm_connector *connector; + +if (!drm_core_check_feature (dev,DRIVER_MODESET )) +return -EINVAL ; + + arg_obj =drm_mode_object_find (dev, arg->obj_id, arg->obj_type); +if (!arg_obj) +return -ENOENT ; + +if (!arg_obj->properties) + goto out_unref; + +/* XXX atomic */ + connector =obj_to_connector (arg_obj); + property = connector->dev->mode_config.dpms_property; + +if (drm_drv_uses_atomic_modeset (property->dev)) + ret =set_property_atomic (arg_obj, property, arg->value); +else + ret =set_property_legacy (arg_obj, property, arg->value); + +out_unref: +drm_mode_object_put (arg_obj); +return ret; +}include/uapi/drm/drm.h +1
-0@@ -862,6 +862,7 @@ extern "C" {#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait)#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array)#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array) +#define DRM_IOCTL_MODE_DPMS DRM_IOWR(0xC6, struct drm_mode_connector_set_property)/** * Device specific ioctls should only be in their respective headers Signature · 6 lines
2.14.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Daniel Vetter
Why exactly is the existing dpms ioctl not good enough? it's implemented as the "DPMS" property attached to connectors, but that's the only difference compared to your code here.
Also, that one doesn't have any XXX about atomic like yours.
I also have no idea how this fixes any of your above problems. -Daniel
It's not good enough because it will only succeed if caller is current DRM master. Which means it will work only in console, since X.Org and Wayland hold DRM_MASTER.
But as a security measure this new separate ioctl requires calling process to be root one.
I will fix XXX atomic in second version of this patch, it's pretty mechanical change. Current stage is to get acceptance by public.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · Alex Ivanov
Quoted 5 lines · Daniel Vetter
Why exactly is the existing dpms ioctl not good enough? it's implemented as the "DPMS" property attached to connectors, but that's the only difference compared to your code here.
Quoted 7 lines
Quoted 4 lines
Also, that one doesn't have any XXX about atomic like yours.
I also have no idea how this fixes any of your above problems. -Daniel
It's not good enough because it will only succeed if caller is current DRM master. Which means it will work only in console, since X.Org and Wayland hold
DRM_MASTER.
As said elsewhere in the thread, this is a feature, not a bug.
BR,
Jani.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi,
Quoted 4 lines · Alex Ivanov
Display power management should be available to user no matter whether display server implements it or not and should be made server agnostic (X.Org, Wayland compositor), without need of TTY change.
Quoted 9 lines
Reasons:
1. User implements an own universal power management daemon. He has no interest to deal with server or switch to a free TTY, he wants to turn off the monitor in a simple way, like he controls power of other system components.
2. Some applications under X.Org like Electron-based ones like to prevent screen goning off giving user no way to fix that.
3. Many fresh new Wayland compositors don't implement DPMS at all and at the same time have TTY switch broken.
I'm sorry, but this is not the right way to go about things. If Xorg or GNOME Shell or Weston or whatever thinks the monitor is DPMS-off, the fact that someone else has forcibly switched it back on will not make them continue painting. Conversely, if they are painting and someone does DPMS-off from underneath them, they'll keep painting
anyway: if they're using the legacy API that means the display will switch straight back on, and if they're using atomic that means their commits will suddenly fail for an unknown reason and they'll be very confused.
If people are doing fancy new compositors without DPMS support, then I recommend they use an existing compositor base, such as libweston (others are also available) which actually implement DPMS. For Electron apps, there are a number of idle-inhibition options available for X11, and also for Wayland when that support lands in Electron. Unfortunately I don't think there is any way to just route around the compositor as this patch does.
Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Daniel Stone
I'm sorry, but this is not the right way to go about things. If Xorg or GNOME Shell or Weston or whatever thinks the monitor is DPMS-off, the fact that someone else has forcibly switched it back on will not make them continue painting.
User should disable DPMS management of display server before using this ioctl.
Quoted 6 lines
Conversely, if they are painting and
someone does DPMS-off from underneath them, they'll keep painting
anyway: if they're using the legacy API that means the display will switch straight back on, and if they're using atomic that means their commits will suddenly fail for an unknown reason and they'll be very confused.
That's sad to hear. Is that the reason why xf86-video-intel driver switches the display back on, while modesetting driver doesn't do anything? DPMS is disabled in X.Org config.
Quoted 7 lines
If people are doing fancy new compositors without DPMS support, then I recommend they use an existing compositor base, such as libweston (others are also available) which actually implement DPMS. For Electron apps, there are a number of idle-inhibition options available for X11, and also for Wayland when that support lands in Electron. Unfortunately I don't think there is any way to just route around the compositor as this patch does.
libweston is still too tied to Weston at this moment, and other libraries are still underway.
Your phrase is a great marker of how much complexity and trickery for user is added into display power management in comparison to power management of other components.
Quoted 3 lines
Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Alex,
Quoted 9 lines · Alex Ivanov
Quoted 7 lines · Daniel Stone
If people are doing fancy new compositors without DPMS support, then I recommend they use an existing compositor base, such as libweston (others are also available) which actually implement DPMS. For Electron apps, there are a number of idle-inhibition options available for X11, and also for Wayland when that support lands in Electron. Unfortunately I don't think there is any way to just route around the compositor as this patch does.
Quoted 6 lines
libweston is still too tied to Weston at this moment, and other libraries are still underway.
Your phrase is a great marker of how much complexity and trickery for user is added into display power management in comparison to power management of other components.
Unfortunately it is indeed quite complex, but this approach doesn't fundamentally remove complexity, but instead _add_ it. I'd much rather fix these problems at the source - add idle-inhibition or DPMS support where required to compositors and clients - than try to route around it.
Cheers,
Daniel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 19 lines · Daniel Stone
Hi Alex,
Quoted 9 lines · Alex Ivanov
Quoted 7 lines · Daniel Stone
If people are doing fancy new compositors without DPMS support, then I recommend they use an existing compositor base, such as libweston (others are also available) which actually implement DPMS. For Electron apps, there are a number of idle-inhibition options available for X11, and also for Wayland when that support lands in Electron. Unfortunately I don't think there is any way to just route around the compositor as this patch does.
Quoted 6 lines
libweston is still too tied to Weston at this moment, and other libraries are still underway.
Your phrase is a great marker of how much complexity and trickery for user is added into display power management in comparison to power management of other components.
Quoted 5 lines
Unfortunately it is indeed quite complex, but this approach doesn't fundamentally remove complexity, but instead _add_ it. I'd much rather fix these problems at the source - add idle-inhibition or DPMS support where required to compositors and clients - than try to route around it.
Yes now that I understand that your goal is to just bypass the compositor it's clear to me we don't want this. Implementing a compositor is hard, hacking around broken compositors is worse. As Daniel explained, changing kms state behind the compositor's back is not going to work reliably either.
Please fix your userspace.
Thanks, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel