diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c index 68564fec7..f15ab3faa 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -844,6 +844,69 @@ merge_crtc_color_updates_from (MetaKmsUpdate *update, } } +static GList * +find_connector_update_link_for (MetaKmsUpdate *update, + MetaKmsConnector *connector) +{ + GList *l; + + for (l = update->connector_updates; l; l = l->next) + { + MetaKmsConnectorUpdate *connector_update = l->data; + + if (connector_update->connector == connector) + return l; + } + + return NULL; +} + +static void +merge_connector_updates_from (MetaKmsUpdate *update, + MetaKmsUpdate *other_update) +{ + while (other_update->connector_updates) + { + GList *l = other_update->connector_updates; + MetaKmsConnectorUpdate *other_connector_update = l->data; + MetaKmsConnector *connector = other_connector_update->connector; + GList *el; + + other_update->connector_updates = + g_list_remove_link (other_update->connector_updates, l); + el = find_connector_update_link_for (update, connector); + if (el) + { + MetaKmsConnectorUpdate *connector_update = el->data; + + if (other_connector_update->underscanning.has_update) + { + connector_update->underscanning = + other_connector_update->underscanning; + } + + if (other_connector_update->privacy_screen.has_update) + { + connector_update->privacy_screen = + other_connector_update->privacy_screen; + } + + if (other_connector_update->max_bpc.has_update) + { + connector_update->max_bpc = + other_connector_update->max_bpc; + } + } + else + { + update->connector_updates = + g_list_insert_before_link (update->connector_updates, + update->connector_updates, + l); + } + } +} + static void merge_custom_page_flip_from (MetaKmsUpdate *update, MetaKmsUpdate *other_update) @@ -880,12 +943,11 @@ meta_kms_update_merge_from (MetaKmsUpdate *update, MetaKmsUpdate *other_update) { g_return_if_fail (update->device == other_update->device); - g_return_if_fail (!update->connector_updates && - !other_update->connector_updates); merge_mode_sets (update, other_update); merge_plane_assignments_from (update, other_update); merge_crtc_color_updates_from (update, other_update); + merge_connector_updates_from (update, other_update); merge_custom_page_flip_from (update, other_update); merge_page_flip_listeners_from (update, other_update); merge_result_listeners_from (update, other_update); diff --git a/src/backends/native/meta-kms-update.h b/src/backends/native/meta-kms-update.h index 885655c42..627d5f274 100644 --- a/src/backends/native/meta-kms-update.h +++ b/src/backends/native/meta-kms-update.h @@ -104,6 +104,7 @@ void meta_kms_update_free (MetaKmsUpdate *update); META_EXPORT_TEST MetaKmsDevice * meta_kms_update_get_device (MetaKmsUpdate *update); +META_EXPORT_TEST void meta_kms_update_set_underscanning (MetaKmsUpdate *update, MetaKmsConnector *connector, uint64_t hborder, @@ -112,10 +113,12 @@ void meta_kms_update_set_underscanning (MetaKmsUpdate *update, void meta_kms_update_unset_underscanning (MetaKmsUpdate *update, MetaKmsConnector *connector); +META_EXPORT_TEST void meta_kms_update_set_privacy_screen (MetaKmsUpdate *update, MetaKmsConnector *connector, gboolean enabled); +META_EXPORT_TEST void meta_kms_update_set_max_bpc (MetaKmsUpdate *update, MetaKmsConnector *connector, uint64_t max_bpc); diff --git a/src/tests/native-kms-updates.c b/src/tests/native-kms-updates.c index c7ed68157..92916aa3c 100644 --- a/src/tests/native-kms-updates.c +++ b/src/tests/native-kms-updates.c @@ -413,6 +413,8 @@ meta_test_kms_update_merge (void) GList *crtc_color_updates; MetaKmsCrtcColorUpdate *crtc_color_update; MetaGammaLut *crtc_gamma; + GList *connector_updates; + MetaKmsConnectorUpdate *connector_update; device = meta_get_test_kms_device (test_context); crtc = meta_get_test_kms_crtc (device); @@ -455,6 +457,11 @@ meta_test_kms_update_merge (void) meta_kms_plane_assignment_set_cursor_hotspot (cursor_plane_assignment, 10, 11); + meta_kms_update_set_underscanning (update1, + connector, + 123, 456); + meta_kms_update_set_privacy_screen (update1, connector, TRUE); + /* * 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. @@ -486,6 +493,9 @@ meta_test_kms_update_merge (void) meta_kms_plane_assignment_set_cursor_hotspot (cursor_plane_assignment, 9, 7); + meta_kms_update_set_privacy_screen (update2, connector, FALSE); + meta_kms_update_set_max_bpc (update2, connector, 8); + /* * Merge and check result. */ @@ -565,6 +575,22 @@ meta_test_kms_update_merge (void) g_assert_cmpuint (crtc_gamma->blue[1], ==, 8); g_assert_cmpuint (crtc_gamma->blue[2], ==, 9); + connector_updates = meta_kms_update_get_connector_updates (update1); + g_assert_cmpuint (g_list_length (connector_updates), ==, 1); + connector_update = connector_updates->data; + g_assert_nonnull (connector_update); + + g_assert_true (connector_update->underscanning.has_update); + g_assert_true (connector_update->underscanning.is_active); + g_assert_cmpuint (connector_update->underscanning.hborder, ==, 123); + g_assert_cmpuint (connector_update->underscanning.vborder, ==, 456); + + g_assert_true (connector_update->privacy_screen.has_update); + g_assert_false (connector_update->privacy_screen.is_enabled); + + g_assert_true (connector_update->max_bpc.has_update); + g_assert_cmpuint (connector_update->max_bpc.value, ==, 8); + meta_kms_update_free (update1); }