drm: rename drm_writeback_should_wait_completion() to try_complete()

This function does more than just checking if it should wait for
completion: it completes the screenshot if possible. So rename to avoid
confusion.

This also adds documentation to the function.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
This commit is contained in:
Leandro Ribeiro 2026-03-11 18:04:31 -03:00
parent 1152c53e58
commit b71b347ac6
3 changed files with 19 additions and 8 deletions

View file

@ -685,7 +685,7 @@ void
drm_writeback_reference_planes(struct drm_writeback_state *state,
struct wl_list *plane_state_list);
bool
drm_writeback_should_wait_completion(struct drm_writeback_state *state);
drm_writeback_try_complete(struct drm_writeback_state *state);
void
drm_writeback_fail_screenshot(struct drm_writeback_state *state,
const char *err_msg);

View file

@ -3570,18 +3570,29 @@ drm_writeback_has_finished(struct drm_writeback_state *state)
return false;
}
/**
* Try to complete writeback screenshot
*
* After submitting a writeback task with an atomic commit, call this function
* to complete the screenshot. If the writeback result is already available, the
* screenshot is completed immediately. Otherwise, drm_writeback_save_callback()
* is scheduled to finish it later.
*
* @param state The writeback task state.
* @return true if the screenshot was completed immediately, false if deferred.
*/
bool
drm_writeback_should_wait_completion(struct drm_writeback_state *state)
drm_writeback_try_complete(struct drm_writeback_state *state)
{
struct weston_compositor *ec = state->output->base.compositor;
struct wl_event_loop *event_loop;
if (state->state == DRM_OUTPUT_WB_SCREENSHOT_WAITING_SIGNAL)
return true;
return false;
if (state->state == DRM_OUTPUT_WB_SCREENSHOT_CHECK_FENCE) {
if (drm_writeback_has_finished(state))
return false;
return true;
/* The writeback has not finished yet. So add callback that gets
* called when the sync fd of the writeback job gets signalled.
@ -3593,15 +3604,15 @@ drm_writeback_should_wait_completion(struct drm_writeback_state *state)
drm_writeback_save_callback, state);
if (!state->wb_source) {
drm_writeback_fail_screenshot(state, "drm: out of memory");
return false;
return true;
}
state->state = DRM_OUTPUT_WB_SCREENSHOT_WAITING_SIGNAL;
return true;
return false;
}
return false;
weston_assert_not_reached(ec, "drm_writeback_try_complete() called without a wb task submitted");
}
void

View file

@ -1988,7 +1988,7 @@ on_drm_input(int fd, uint32_t mask, void *data)
* uses the KMS objects (CRTC, planes, etc) in use by the writeback. */
wl_list_for_each(crtc, &device->crtc_list, link) {
state = crtc->output ? crtc->output->wb_state : NULL;
if (state && drm_writeback_should_wait_completion(state))
if (state && !drm_writeback_try_complete(state))
wait_wb_completion = true;
}
if (wait_wb_completion)