Currently drm_output_get_writeback_formats() returns the formats
supported by a single writeback connector compatible with output->crtc.
This list is used to populate struct weston_output_capture_source_info
through weston_output_update_capture_info().
Later, when pulling writeback capture tasks, we call
drm_output_get_writeback_formats() again. However, as
drm_output_find_compatible_writeback() skips writeback connectors in
use, the returned format list may now differ.
Also, when selecting a writeback connector we implicitly rely on
drm_output_find_compatible_writeback() returning the same connector as
before, without verifying that the chosen connector supports the format
of the buffer provided by the client.
Make drm_output_get_writeback_formats() return the union of formats
supported by all writeback connectors compatible with output->crtc. This
makes the returned format list deterministic, regardless of whether a
writeback connector is currently in use. Although most hardware probably
supports a single writeback compatible with the CRTC, this is a good
change as it makes the code more generic and robust.
Also, add a new format param to drm_output_find_compatible_writeback(),
so now the the selected writeback can be validated against the requested
format.
The main benefit of this patch (and the reason why I wrote) is enabling
us to fix an issue when a writeback task is already in progress and
additional ones are requested:
1. weston_output_pull_capture_task() depends on the writeback format
list
2. if a writeback is already in progress,
drm_output_get_writeback_formats() returns NULL (assuming there's a
single writeback connector).
3. weston_output_pull_capture_task() crashes Weston, as the list of
writeback formats we pass does not match the one stored in struct
weston_output_capture_source_info.
With the format list now deterministic, we'll be able to safely pull the
capture task and retire it. The next commit implements this behavior.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>