Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a disable method to DrmSurface/DrmCompositor for implementing DPMS #1561

Merged
merged 3 commits into from
Oct 17, 2024

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Oct 10, 2024

As discussed in #1553.

This seems to be working okay, on atomic or legacy DRM. I'm still finishing the cosmic-comp support.

Not sure if DrmCompositor::disable should clear any other state. Or if AtomicDrmSurface::clear_state does anything that is unneeded here. Other compositors appear to vary slightly in which properties their atomic backends set/unset for DPMS.

This field is currently set, but never read.

This logically doesn't need to be part of `state`/`pending` either,
since a full commit is not needed to change the DPMS state.
Copy link
Member

@Drakulix Drakulix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The surface changes look good imo.

.for_each(|(_, state)| *state = Default::default());
self.pending_frame = None;
self.queued_frame = None;
self.next_frame = None;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @cmeissl

Does this look fine to you?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on how it should behave, this should be fine for disabling alone, yes.
We could also reset the element states to drop all framebuffers we imported, this might allow to lower
the memory footprint. Same for the swapchain which could be reset.

@ids1024 ids1024 marked this pull request as ready for review October 11, 2024 00:21
@Drakulix Drakulix requested a review from cmeissl October 11, 2024 14:14
@cmeissl
Copy link
Collaborator

cmeissl commented Oct 11, 2024

I will do a review Sunday, latest Monday when I am back home.

Copy link
Collaborator

@cmeissl cmeissl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole thing looks more like a reset/clear to me. Disable suggests that the surface will be disabled until some non-existing enable imo.
I would expect it to track and handle the disable state internally, potentially returning errors for some functions like render_frame.
In its current state tracking still has to be done externally, which is fine imo, but maybe not expected from the name disable.

@@ -441,6 +441,17 @@ impl DrmSurface {
DrmSurfaceInternal::Legacy(surf) => &surf.span,
}
}

/// Disable the output, setting DPMS state to off.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo the name disable might be misleading, or at lest the comment might be. it does not only set the dpms state, but also clears the whole state including all planes.

.for_each(|(_, state)| *state = Default::default());
self.pending_frame = None;
self.queued_frame = None;
self.next_frame = None;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on how it should behave, this should be fine for disabling alone, yes.
We could also reset the element states to drop all framebuffers we imported, this might allow to lower
the memory footprint. Same for the swapchain which could be reset.

@ids1024
Copy link
Member Author

ids1024 commented Oct 14, 2024

Yeah, I wasn't really sure what to name it. clear() could be better.

For disabling the screen with DPMS when the session is inactive, saving memory isn't particularly the goal (unless something also saves power). Though different implementations seem a little inconsistent in what they set when setting the DPMS ACTIVE property to false. I assume we want to remove planes that reference direct scanout buffers, but don't want to change much more state than we need to.

Perhaps there are other use cases for something like this, but I don't know exactly what function(s) would be useful for them.

This sets DPMS state to off. Submitting a new frame will re-enable the
output.
@ids1024
Copy link
Member Author

ids1024 commented Oct 17, 2024

I've renamed the function to clear and changed the doc comment slightly. Hopefully that's a bit better.

@Drakulix Drakulix requested a review from cmeissl October 17, 2024 02:15
Copy link
Collaborator

@cmeissl cmeissl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@Drakulix Drakulix merged commit 05c49f7 into Smithay:master Oct 17, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants