Skip to contentSkip to conversation

drm: Call sysfs_notify after changing drm_connector::dpms

PATCH In review Karsten Wiese 3 participants 11 messages Sep 19, 2017 – Sep 27, 2017

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

PATCH 1/1 drm: Call sysfs_notify after changing drm_connector::dpms

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

Tested with i915 suspended by XScreenServer and
suspend to RAM.

---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +4 -0
index 2fd383d..b6fa87b 100644
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,
 out:
 	if (ret != 0)
 		connector->dpms = old_mode;
+	else
+		if (connector->dpms != old_mode)
+			sysfs_notify(&connector->kdev->kobj, NULL, "dpms");
+
 	return ret;
 }
 
drivers/gpu/drm/drm_atomic_helper.c +5 -1
index 4e53aae..6198772 100644
@@ -921,12 +921,16 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 		crtc = new_conn_state->crtc;
 		if ((!crtc && old_conn_state->crtc) ||
 		    (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) {
-			int mode = DRM_MODE_DPMS_OFF;
+			int old_mode, mode = DRM_MODE_DPMS_OFF;
 
 			if (crtc && crtc->state->active)
 				mode = DRM_MODE_DPMS_ON;
 
+			old_mode = connector->dpms;
 			connector->dpms = mode;
+			if (old_mode != mode)
+				sysfs_notify(&connector->kdev->kobj,
+						NULL, "dpms");
 		}
 	}
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 2 lines · Karsten Wiese

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

We have zero sysfs_notify in all of drm AFAICT.

BR,
Jani.

Quoted 46 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +4 -0
index 2fd383d..b6fa87b 100644
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,
 out:
 	if (ret != 0)
 		connector->dpms = old_mode;
+	else
+		if (connector->dpms != old_mode)
+			sysfs_notify(&connector->kdev->kobj, NULL, "dpms");
+
 	return ret;
 }
 
drivers/gpu/drm/drm_atomic_helper.c +5 -1
index 4e53aae..6198772 100644
@@ -921,12 +921,16 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 		crtc = new_conn_state->crtc;
 		if ((!crtc && old_conn_state->crtc) ||
 		    (crtc && drm_atomic_crtc_needs_modeset(crtc->state))) {
-			int mode = DRM_MODE_DPMS_OFF;
+			int old_mode, mode = DRM_MODE_DPMS_OFF;
 
 			if (crtc && crtc->state->active)
 				mode = DRM_MODE_DPMS_ON;
 
+			old_mode = connector->dpms;
 			connector->dpms = mode;
+			if (old_mode != mode)
+				sysfs_notify(&connector->kdev->kobj,
+						NULL, "dpms");
 		}
 	}
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 7 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

​
The patch enables cpu cycle less waiting for dpms flag changes.

Here it lets a screen brightness ​setting daemon know which monitor to handle.
One of the attached screens gets confused if it is set just after being switched on,
hence the daemon leaves it untouched until it has been active for some seconds.

Without the p​atch the daemon would have to actively read the dpms flag every once in a while.

Quoted 2 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but didn't find any.

BR,
Karsten

Quoted 57 lines

BR,
Jani.

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct

Quoted 15 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +0 -0
index 2fd383d..b6fa87b 100644
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Review

Quoted 5 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_legacy_modeset_state(struct

drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(crtc->state)))

{

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, · line 935

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev->kobj,
+                                             NULL, "dpms");
              }
      }
Quoted 3 lines

--
Jani Nikula, Intel Open Source Technology Center

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

#3 lore raw
Quoted 9 lines · Karsten Wiese

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 7 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

Quoted 7 lines

​
The patch enables cpu cycle less waiting for dpms flag changes.

Here it lets a screen brightness ​setting daemon know which monitor to handle. One of the attached screens gets confused if it is set just after being switched on, hence the daemon leaves it untouched until it has been active for some seconds.

Screen brightness settings daemon? What exactly do you mean by "if it is set"? What interface are you using to change brightness? What happens when the display "gets confused"?

My first instinct is that you're proposing a new kernel ABI to solve an issue you shouldn't be solving in userspace to begin with. Or that perhaps the userspace should be doing this in cooperation with the drm master, not standalone.

BR,
Jani.

Quoted 75 lines

Without the p​atch the daemon would have to actively read the dpms flag every once in a while.

Quoted 2 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but didn't find any.

BR,
Karsten

Quoted 60 lines

BR,
Jani.

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct

Quoted 15 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +0 -0
index 2fd383d..b6fa87b 100644
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Review

Quoted 5 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_legacy_modeset_state(struct

drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(crtc->state)))

{

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, · line 935

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev->kobj,
+                                             NULL, "dpms");
              }
      }

--
Jani Nikula, Intel Open Source Technology Center

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

2017-09-27 9:18 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 13 lines · Karsten Wiese
Quoted 12 lines

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 7 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

​
The patch enables cpu cycle less waiting for dpms flag changes.

Quoted 7 lines
Quoted 4 lines

Here it lets a screen brightness ​setting daemon know which monitor to handle. One of the attached screens gets confused if it is set just after being switched on, hence the daemon leaves it untouched until it has been active for some seconds.

Screen brightness settings daemon?

Running on a laptop lacking an ambient light sensor employing it's webcam instead to measure ambient light and adjust monitors' brightnesses accordingly.

What exactly do you mean by "if it is

Quoted 1 line

set"? What interface are you using to change brightness?

The external monitor's brightness is adjusted by DDC/CI via the /dev/i2c-x the monitor is attached to.
I there a saner interface to use?

What happens

Quoted 2 lines

when the display "gets confused"?

The monitor wrongly toggles sharpness if it receives the brightness adjusting​
​ DDC/CI soon after resuming from power saving state.

Quoted 3 lines

My first instinct is that you're proposing a new kernel ABI to solve an issue you shouldn't be solving in userspace to begin with.

Calculating ambient light from pictures acquired via ​ ​v4l​2 in kernel seamed wrong to me.

Or that

Quoted 3 lines

perhaps the userspace should be doing this in cooperation with the drm master, not standalone.

Is there a way to call into the drm-master (xscreensaver/xserver​ here​ ​) ​with the call only returning if a monitor's power state changed?

There is DPMSInfo, but it returns immediately rendering the daemon less efficient.

BR,

Karsten

Quoted 80 lines

BR,
Jani.

Quoted 10 lines

Without the p​atch the daemon would have to actively read the dpms flag every once in a while.

Quoted 2 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but

didn't

Quoted 14 lines

find any.

BR,
Karsten

Quoted 9 lines

BR,
Jani.

Quoted 4 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic.c

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct

Quoted 4 lines

index 2fd383d..b6fa87b 100644

drivers/gpu/drm/drm_atomic.c +0 -0
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_

legacy_modeset_state(struct

Quoted 4 lines
Quoted 4 lines

drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(

crtc->state)))

Quoted 15 lines
Quoted 15 lines

{

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev->kobj,
+                                             NULL, "dpms");
              }
      }
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

--
Jani Nikula, Intel Open Source Technology Center

--
Jani Nikula, Intel Open Source Technology Center

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

#5 lore raw
Quoted 27 lines · Karsten Wiese

2017-09-27 9:18 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 13 lines · Karsten Wiese
Quoted 12 lines

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 7 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

​
The patch enables cpu cycle less waiting for dpms flag changes.

Quoted 7 lines
Quoted 4 lines

Here it lets a screen brightness ​setting daemon know which monitor to handle. One of the attached screens gets confused if it is set just after being switched on, hence the daemon leaves it untouched until it has been active for some seconds.

Screen brightness settings daemon?

Running on a laptop lacking an ambient light sensor employing it's webcam instead to measure ambient light and adjust monitors' brightnesses accordingly.

Quoted 6 lines

What exactly do you mean by "if it is

Quoted 1 line

set"? What interface are you using to change brightness?

The external monitor's brightness is adjusted by DDC/CI via the /dev/i2c-x the monitor is attached to.
I there a saner interface to use?

There's supposed to be a backlight property on the panel, exposed by the X driver. If there's not, then that needs to be fixed/adjusted.

There's also plans to directly link that up on the kernel side, but that's a bit more involved due to how screwed up the backlight driver design on linux is right now.
-Daniel

Quoted 122 lines

What happens

Quoted 2 lines

when the display "gets confused"?

The monitor wrongly toggles sharpness if it receives the brightness adjusting​
​ DDC/CI soon after resuming from power saving state.

Quoted 3 lines

My first instinct is that you're proposing a new kernel ABI to solve an issue you shouldn't be solving in userspace to begin with.

Calculating ambient light from pictures acquired via ​ ​v4l​2 in kernel seamed wrong to me.

Or that

Quoted 3 lines

perhaps the userspace should be doing this in cooperation with the drm master, not standalone.

Is there a way to call into the drm-master (xscreensaver/xserver​ here​ ​) ​with the call only returning if a monitor's power state changed?

There is DPMSInfo, but it returns immediately rendering the daemon less efficient.

BR,

Karsten

Quoted 80 lines

BR,
Jani.

Quoted 10 lines

Without the p​atch the daemon would have to actively read the dpms flag every once in a while.

Quoted 2 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but

didn't

Quoted 14 lines

find any.

BR,
Karsten

Quoted 9 lines

BR,
Jani.

Quoted 4 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic.c

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct

Quoted 4 lines

index 2fd383d..b6fa87b 100644

drivers/gpu/drm/drm_atomic.c +0 -0
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_

legacy_modeset_state(struct

Quoted 4 lines
Quoted 4 lines

drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(

crtc->state)))

Quoted 15 lines
Quoted 15 lines

{

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev->kobj,
+                                             NULL, "dpms");
              }
      }
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

--
Jani Nikula, Intel Open Source Technology Center

--
Jani Nikula, Intel Open Source Technology Center

_______________________________________________
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
#6 lore raw
Quoted 29 lines · Daniel Vetter
Quoted 28 lines · Karsten Wiese

2017-09-27 9:18 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 13 lines · Karsten Wiese
Quoted 12 lines

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 7 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

​
The patch enables cpu cycle less waiting for dpms flag changes.

Quoted 7 lines
Quoted 4 lines

Here it lets a screen brightness ​setting daemon know which monitor to handle. One of the attached screens gets confused if it is set just after being switched on, hence the daemon leaves it untouched until it has been active for some seconds.

Screen brightness settings daemon?

Running on a laptop lacking an ambient light sensor employing it's webcam instead to measure ambient light and adjust monitors' brightnesses accordingly.

What exactly do you mean by "if it is

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

set"? What interface are you using to change brightness?

The external monitor's brightness is adjusted by DDC/CI via the /dev/i2c-x the monitor is attached to.
I there a saner interface to use?

There's supposed to be a backlight property on the panel, exposed by the X driver. If there's not, then that needs to be fixed/adjusted.

For eDP/LVDS in Intel driver yes, for external displays not. For external displays DDC/CI is currently probably the best bet.

However, DDC/CI is overall not very robust. I think we have prior bug reports about it, but it's never really been very high on our list of priorities.

Quoted 3 lines

There's also plans to directly link that up on the kernel side, but that's a bit more involved due to how screwed up the backlight driver design on linux is right now.

It's going to take forever and a half before DDC/CI for external displays get that treatment, if ever.

It still feels wrong to add sysfs notify support for just one of our properties, for just this one use case. In particular if the reason is to workaround bugs in another interface.

BR,
Jani.

Quoted 124 lines

-Daniel

Quoted 122 lines

What happens

Quoted 2 lines

when the display "gets confused"?

The monitor wrongly toggles sharpness if it receives the brightness adjusting​
​ DDC/CI soon after resuming from power saving state.

Quoted 3 lines

My first instinct is that you're proposing a new kernel ABI to solve an issue you shouldn't be solving in userspace to begin with.

Calculating ambient light from pictures acquired via ​ ​v4l​2 in kernel seamed wrong to me.

Or that

Quoted 3 lines

perhaps the userspace should be doing this in cooperation with the drm master, not standalone.

Is there a way to call into the drm-master (xscreensaver/xserver​ here​ ​) ​with the call only returning if a monitor's power state changed?

There is DPMSInfo, but it returns immediately rendering the daemon less efficient.

BR,

Karsten

Quoted 80 lines

BR,
Jani.

Quoted 10 lines

Without the p​atch the daemon would have to actively read the dpms flag every once in a while.

Quoted 2 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but

didn't

Quoted 14 lines

find any.

BR,
Karsten

Quoted 9 lines

BR,
Jani.

Quoted 4 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic.c

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct

Quoted 4 lines

index 2fd383d..b6fa87b 100644

drivers/gpu/drm/drm_atomic.c +0 -0
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_

legacy_modeset_state(struct

Quoted 4 lines
Quoted 4 lines

drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(

crtc->state)))

Quoted 15 lines
Quoted 15 lines

{

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev->kobj,
+                                             NULL, "dpms");
              }
      }
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

--
Jani Nikula, Intel Open Source Technology Center

--
Jani Nikula, Intel Open Source Technology Center

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

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

2017-09-27 14:58 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 58 lines · Daniel Vetter
Quoted 12 lines · Karsten Wiese
Quoted 4 lines

2017-09-27 9:18 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 2 lines · Karsten Wiese
Quoted 1 line

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]

:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is

the

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

problem that this solves?

​
The patch enables cpu cycle less waiting for dpms flag changes.

Here it lets a screen brightness ​setting daemon know which monitor

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

handle. One of the attached screens gets confused if it is set just after being switched on, hence the daemon leaves it untouched until

it

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

has been active for some seconds.

Screen brightness settings daemon?

Running on a laptop lacking an ambient light sensor employing it's

webcam

Quoted 8 lines
Quoted 8 lines

instead to measure ambient light and adjust monitors' brightnesses accordingly.

What exactly do you mean by "if it is

Quoted 1 line

set"? What interface are you using to change brightness?

The external monitor's brightness is adjusted by DDC/CI via the

/dev/i2c-x

Quoted 4 lines
Quoted 2 lines

the monitor is attached to.
I there a saner interface to use?

There's supposed to be a backlight property on the panel, exposed by the

X

Quoted 1 line

driver. If there's not, then that needs to be fixed/adjusted.

For eDP/LVDS in Intel driver yes, for external displays not. For external displays DDC/CI is currently probably the best bet.

However, DDC/CI is overall not very robust. I think we have prior bug reports about it, but it's never really been very high on our list of priorities.

Quoted 1 line

There's also plans to directly link that up on the kernel side, but

that's

Quoted 2 lines

a bit more involved due to how screwed up the backlight driver design on linux is right now.

Quoted 7 lines

It's going to take forever and a half before DDC/CI for external displays get that treatment, if ever.

It still feels wrong to add sysfs notify support for just one of our properties, for just this one use case. In particular if the reason is to workaround bugs in another interface.

​Would you accept a patch supporting​ all relevant attributes?

BR,
Karsten

Quoted 129 lines

BR,
Jani.

Quoted 12 lines

-Daniel

Quoted 10 lines

What happens

Quoted 2 lines

when the display "gets confused"?

The monitor wrongly toggles sharpness if it receives the brightness adjusting​
​ DDC/CI soon after resuming from power saving state.

Quoted 2 lines

My first instinct is that you're proposing a new kernel ABI to solve

an

Quoted 18 lines
Quoted 18 lines
Quoted 1 line

issue you shouldn't be solving in userspace to begin with.

Calculating ambient light from pictures acquired via ​ ​v4l​2 in kernel seamed wrong to me.

Or that

Quoted 3 lines

perhaps the userspace should be doing this in cooperation with the drm master, not standalone.

Is there a way to call into the drm-master (xscreensaver/xserver​ here​ ​) ​with the call only returning if a monitor's power state changed?

There is DPMSInfo, but it returns immediately rendering the daemon less efficient.

BR,

Quoted 8 lines
Quoted 8 lines

Karsten

Quoted 6 lines

BR,
Jani.

Quoted 2 lines

Without the p​atch the daemon would have to actively read the dpms

flag

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 8 lines

every once in a while.

Quoted 2 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but

didn't

Quoted 20 lines

find any.

BR,
Karsten

Quoted 15 lines

BR,
Jani.

Quoted 10 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic.c

Quoted 4 lines
Quoted 4 lines

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_

Quoted 4 lines

index 2fd383d..b6fa87b 100644

drivers/gpu/drm/drm_atomic.c +0 -0
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_

dpms(struct

Quoted 48 lines
Quoted 28 lines
Quoted 28 lines
Quoted 12 lines
Quoted 12 lines

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_ · line 1885

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_

legacy_modeset_state(struct

Quoted 4 lines
Quoted 4 lines

drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(

crtc->state)))

Quoted 4 lines
Quoted 4 lines

{

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_ · line 932

Quoted 7 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -0
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev-

kobj,

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_ · line 935

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +1 -0
+                                             NULL, "dpms");
              }
      }

--
Jani Nikula, Intel Open Source Technology Center

--
Jani Nikula, Intel Open Source Technology Center

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

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

--
Jani Nikula, Intel Open Source Technology Center

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

#8 lore raw
Quoted 7 lines · Karsten Wiese

2017-09-27 14:58 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 4 lines

It still feels wrong to add sysfs notify support for just one of our properties, for just this one use case. In particular if the reason is to workaround bugs in another interface.

​Would you accept a patch supporting​ all relevant attributes?

It's not my call alone, but personally I'd be hesitant about taking on the burden of maintaining that ABI.

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
#9 lore raw
In reply to Karsten Wiese
Quoted 12 lines · Karsten Wiese

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 7 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

​
The patch enables cpu cycle less waiting for dpms flag changes.

Quoted 6 lines

Here it lets a screen brightness ​setting daemon know which monitor to handle.
One of the attached screens gets confused if it is set just after being switched on,
hence the daemon leaves it untouched until it has been active for some seconds.

Without knowing more details, but a brightness deamon in userspace sounds rather wrong. The driver is supposed to take care of this and shut down the backlight when we disable the output for a panel.

Quoted 2 lines

Without the p​atch the daemon would have to actively read the dpms flag every once in a while.

On top of that, any uabi changes need open source userspace. -Daniel

Quoted 77 lines
Quoted 4 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but didn't find any.

BR,
Karsten

Quoted 57 lines

BR,
Jani.

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct

Quoted 15 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +0 -0
index 2fd383d..b6fa87b 100644
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Review

Quoted 5 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_legacy_modeset_state(struct

drm_device *dev,

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(crtc->state)))

{

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, · line 935

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev->kobj,
+                                             NULL, "dpms");
              }
      }
Quoted 3 lines

--
Jani Nikula, Intel Open Source Technology Center

_______________________________________________
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
#10 lore raw

2017-09-27 10:45 GMT+02:00 Daniel Vetter <[email protected]>:

Quoted 20 lines · Karsten Wiese
Quoted 12 lines

2017-09-25 15:48 GMT+02:00 Jani Nikula <[email protected]>:

Quoted 7 lines · Karsten Wiese
Quoted 2 lines

This makes poll work for the
/sys/class/drm/cardX/connectorY/dpms attributes.

I guess the question is, what are you trying to achieve? What is the problem that this solves?

​
The patch enables cpu cycle less waiting for dpms flag changes.

Quoted 6 lines

Here it lets a screen brightness ​setting daemon know which monitor to handle.
One of the attached screens gets confused if it is set just after being switched on,
hence the daemon leaves it untouched until it has been active for some seconds.

Quoted 9 lines

Without knowing more details, but a brightness deamon in userspace sounds rather wrong. The driver is supposed to take care of this and shut down the backlight when we disable the output for a panel.

Quoted 2 lines

Without the p​atch the daemon would have to actively read the dpms flag every once in a while.

On top of that, any uabi changes need open source userspace.

​Will put publishing userspace on my list, if proposed uabi change​ is agreed upon to be accepted once userspace is open sourced.
Or if I find another way of knowing monitors' power states using cpu cycles only if said states have changed. Anybody?

BR,
Karsten

-Daniel

Quoted 84 lines
Quoted 8 lines
Quoted 5 lines

We have zero sysfs_notify in all of drm AFAICT.

Yes I noticed too and looked for some dbus signal to listen to​ but

didn't

Quoted 14 lines

find any.

BR,
Karsten

Quoted 9 lines

BR,
Jani.

Quoted 4 lines

Tested with i915 suspended by XScreenServer and
suspend to RAM.

Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines
---
 drivers/gpu/drm/drm_atomic.c        | 4 ++++
 drivers/gpu/drm/drm_atomic_helper.c | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic.c

Quoted 16 lines
Quoted 16 lines

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct

Quoted 4 lines

index 2fd383d..b6fa87b 100644

drivers/gpu/drm/drm_atomic.c +0 -0
@@ -1880,6 +1880,10 @@ int drm_atomic_connector_commit_dpms(struct

drm_atomic_state *state,

drivers/gpu/drm/drm_atomic.c int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,

Quoted 6 lines
drivers/gpu/drm/drm_atomic.c +3 -0
 out:
      if (ret != 0)
              connector->dpms = old_mode;
+     else
+             if (connector->dpms != old_mode)
+                     sysfs_notify(&connector->kdev->kobj, NULL,

"dpms");

Quoted 4 lines
drivers/gpu/drm/drm_atomic.c +1 -0
+
      return ret;
 }
 
Quoted 6 lines
Quoted 6 lines

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c drm_atomic_helper_update_

Quoted 4 lines

index 4e53aae..6198772 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -921,12 +921,16 @@ drm_atomic_helper_update_

legacy_modeset_state(struct

Quoted 4 lines
Quoted 4 lines

drm_device *dev,

Quoted 3 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -0
              crtc = new_conn_state->crtc;
              if ((!crtc && old_conn_state->crtc) ||
                  (crtc && drm_atomic_crtc_needs_modeset(

crtc->state)))

Quoted 15 lines
Quoted 15 lines

{

Quoted 13 lines
drivers/gpu/drm/drm_atomic_helper.c +5 -1
-                     int mode = DRM_MODE_DPMS_OFF;
+                     int old_mode, mode = DRM_MODE_DPMS_OFF;
 
                      if (crtc && crtc->state->active)
                              mode = DRM_MODE_DPMS_ON;
 
+                     old_mode = connector->dpms;
                      connector->dpms = mode;
+                     if (old_mode != mode)
+                             sysfs_notify(&connector->kdev->kobj,
+                                             NULL, "dpms");
              }
      }
Quoted 8 lines
Quoted 3 lines

--
Jani Nikula, Intel Open Source Technology Center

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

Quoted 5 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