kms/update: Support merging updates with mode sets
Will be helpful to allow constructing each initial mode set update per CRTC, merging them later on-demand. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2854>
This commit is contained in:
parent
9dcb28ffd1
commit
37db905ff9
@ -671,6 +671,56 @@ meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip)
|
|||||||
g_free (custom_page_flip);
|
g_free (custom_page_flip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GList *
|
||||||
|
find_mode_set_link_for (MetaKmsUpdate *update,
|
||||||
|
MetaKmsCrtc *crtc)
|
||||||
|
{
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = update->mode_sets; l; l = l->next)
|
||||||
|
{
|
||||||
|
MetaKmsModeSet *mode_set = l->data;
|
||||||
|
|
||||||
|
if (mode_set->crtc == crtc)
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
merge_mode_sets (MetaKmsUpdate *update,
|
||||||
|
MetaKmsUpdate *other_update)
|
||||||
|
{
|
||||||
|
while (other_update->mode_sets)
|
||||||
|
{
|
||||||
|
GList *l = other_update->mode_sets;
|
||||||
|
MetaKmsModeSet *other_mode_set = l->data;
|
||||||
|
MetaKmsCrtc *crtc = other_mode_set->crtc;
|
||||||
|
GList *el;
|
||||||
|
|
||||||
|
other_update->mode_sets =
|
||||||
|
g_list_remove_link (other_update->mode_sets, l);
|
||||||
|
|
||||||
|
el = find_mode_set_link_for (update, crtc);
|
||||||
|
if (el)
|
||||||
|
{
|
||||||
|
meta_kms_mode_set_free (el->data);
|
||||||
|
update->mode_sets =
|
||||||
|
g_list_insert_before_link (update->mode_sets, el, l);
|
||||||
|
update->mode_sets =
|
||||||
|
g_list_delete_link (update->mode_sets, el);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
update->mode_sets =
|
||||||
|
g_list_insert_before_link (update->mode_sets,
|
||||||
|
update->mode_sets,
|
||||||
|
l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
find_plane_assignment_link_for (MetaKmsUpdate *update,
|
find_plane_assignment_link_for (MetaKmsUpdate *update,
|
||||||
MetaKmsPlane *plane)
|
MetaKmsPlane *plane)
|
||||||
@ -808,10 +858,10 @@ meta_kms_update_merge_from (MetaKmsUpdate *update,
|
|||||||
MetaKmsUpdate *other_update)
|
MetaKmsUpdate *other_update)
|
||||||
{
|
{
|
||||||
g_return_if_fail (update->device == other_update->device);
|
g_return_if_fail (update->device == other_update->device);
|
||||||
g_return_if_fail (!update->mode_sets && !other_update->mode_sets);
|
|
||||||
g_return_if_fail (!update->connector_updates &&
|
g_return_if_fail (!update->connector_updates &&
|
||||||
!other_update->connector_updates);
|
!other_update->connector_updates);
|
||||||
|
|
||||||
|
merge_mode_sets (update, other_update);
|
||||||
merge_plane_assignments_from (update, other_update);
|
merge_plane_assignments_from (update, other_update);
|
||||||
merge_crtc_color_updates_from (update, other_update);
|
merge_crtc_color_updates_from (update, other_update);
|
||||||
merge_custom_page_flip_from (update, other_update);
|
merge_custom_page_flip_from (update, other_update);
|
||||||
|
@ -408,6 +408,8 @@ meta_test_kms_update_merge (void)
|
|||||||
MetaKmsUpdate *update2;
|
MetaKmsUpdate *update2;
|
||||||
g_autoptr (MetaGammaLut) lut = NULL;
|
g_autoptr (MetaGammaLut) lut = NULL;
|
||||||
g_autoptr (MetaDrmBuffer) cursor_buffer2 = NULL;
|
g_autoptr (MetaDrmBuffer) cursor_buffer2 = NULL;
|
||||||
|
GList *mode_sets;
|
||||||
|
MetaKmsModeSet *mode_set;
|
||||||
GList *plane_assignments;
|
GList *plane_assignments;
|
||||||
MetaKmsPlaneAssignment *plane_assignment;
|
MetaKmsPlaneAssignment *plane_assignment;
|
||||||
GList *crtc_color_updates;
|
GList *crtc_color_updates;
|
||||||
@ -456,12 +458,17 @@ meta_test_kms_update_merge (void)
|
|||||||
10, 11);
|
10, 11);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create an update2 with with cursor buffer 2
|
* Create an update2 with a mode set and a cursor buffer 2
|
||||||
* on the cursor plane at at (32, 56), and a new CRTC gamma.
|
* on the cursor plane at at (32, 56), and a new CRTC gamma.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
update2 = meta_kms_update_new (device);
|
update2 = meta_kms_update_new (device);
|
||||||
|
|
||||||
|
meta_kms_update_mode_set (update2,
|
||||||
|
crtc,
|
||||||
|
g_list_append (NULL, connector),
|
||||||
|
mode);
|
||||||
|
|
||||||
lut = meta_gamma_lut_new (3,
|
lut = meta_gamma_lut_new (3,
|
||||||
(uint16_t[]) { 1, 2, 3 },
|
(uint16_t[]) { 1, 2, 3 },
|
||||||
(uint16_t[]) { 4, 5, 6 },
|
(uint16_t[]) { 4, 5, 6 },
|
||||||
@ -488,6 +495,14 @@ meta_test_kms_update_merge (void)
|
|||||||
meta_kms_update_merge_from (update1, update2);
|
meta_kms_update_merge_from (update1, update2);
|
||||||
meta_kms_update_free (update2);
|
meta_kms_update_free (update2);
|
||||||
|
|
||||||
|
mode_sets = meta_kms_update_get_mode_sets (update1);
|
||||||
|
g_assert_cmpuint (g_list_length (mode_sets), ==, 1);
|
||||||
|
mode_set = mode_sets->data;
|
||||||
|
g_assert (mode_set->crtc == crtc);
|
||||||
|
g_assert (mode_set->mode == mode);
|
||||||
|
g_assert_cmpuint (g_list_length (mode_set->connectors), ==, 1);
|
||||||
|
g_assert (mode_set->connectors->data == connector);
|
||||||
|
|
||||||
plane_assignments = meta_kms_update_get_plane_assignments (update1);
|
plane_assignments = meta_kms_update_get_plane_assignments (update1);
|
||||||
g_assert_cmpuint (g_list_length (plane_assignments), ==, 2);
|
g_assert_cmpuint (g_list_length (plane_assignments), ==, 2);
|
||||||
plane_assignment = meta_kms_update_get_primary_plane_assignment (update1,
|
plane_assignment = meta_kms_update_get_primary_plane_assignment (update1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user