monitor-config-manager: Allow backends to assign extra data

When we're configuring monitors, allow backends to add backend specific
assignments during resource assignment (mapping connectors and CRTCs
etc).

This will later allow the native backend's KMS monitor resources to
assign a primary plane and optionally a cursor plane during
configuration. This will then dictate what plane will be used for
primary plane updates, as well as cursor updates, until reconfigured
again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3428>
This commit is contained in:
Jonas Ådahl 2023-11-28 09:25:59 +01:00 committed by Marge Bot
parent 2bb75a3c97
commit 429e65b993
9 changed files with 57 additions and 7 deletions

View File

@ -112,11 +112,17 @@ meta_crtc_get_all_transforms (MetaCrtc *crtc)
void void
meta_crtc_set_config (MetaCrtc *crtc, meta_crtc_set_config (MetaCrtc *crtc,
MetaCrtcConfig *config) MetaCrtcConfig *config,
gpointer backend_private)
{ {
MetaCrtcPrivate *priv = meta_crtc_get_instance_private (crtc); MetaCrtcPrivate *priv = meta_crtc_get_instance_private (crtc);
MetaCrtcClass *klass = META_CRTC_GET_CLASS (crtc);
meta_crtc_unset_config (crtc); meta_crtc_unset_config (crtc);
if (klass->set_config)
klass->set_config (crtc, config, backend_private);
priv->config = config; priv->config = config;
} }
@ -136,6 +142,20 @@ meta_crtc_get_config (MetaCrtc *crtc)
return priv->config; return priv->config;
} }
gboolean
meta_crtc_assign_extra (MetaCrtc *crtc,
MetaCrtcAssignment *crtc_assignment,
GPtrArray *crtc_assignments,
GError **error)
{
MetaCrtcClass *klass = META_CRTC_GET_CLASS (crtc);
if (klass->assign_extra)
return klass->assign_extra (crtc, crtc_assignment, crtc_assignments, error);
else
return TRUE;
}
size_t size_t
meta_crtc_get_gamma_lut_size (MetaCrtc *crtc) meta_crtc_get_gamma_lut_size (MetaCrtc *crtc)
{ {

View File

@ -46,6 +46,15 @@ struct _MetaCrtcClass
void (* set_gamma_lut) (MetaCrtc *crtc, void (* set_gamma_lut) (MetaCrtc *crtc,
const MetaGammaLut *lut); const MetaGammaLut *lut);
gboolean (* assign_extra) (MetaCrtc *crtc,
MetaCrtcAssignment *crtc_assignment,
GPtrArray *crtc_assignments,
GError **error);
void (* set_config) (MetaCrtc *crtc,
const MetaCrtcConfig *config,
gpointer backend_private);
}; };
META_EXPORT_TEST META_EXPORT_TEST
@ -71,7 +80,8 @@ MetaMonitorTransform meta_crtc_get_all_transforms (MetaCrtc *crtc);
META_EXPORT_TEST META_EXPORT_TEST
void meta_crtc_set_config (MetaCrtc *crtc, void meta_crtc_set_config (MetaCrtc *crtc,
MetaCrtcConfig *config); MetaCrtcConfig *config,
gpointer backend_private);
META_EXPORT_TEST META_EXPORT_TEST
void meta_crtc_unset_config (MetaCrtc *crtc); void meta_crtc_unset_config (MetaCrtc *crtc);
@ -79,6 +89,11 @@ void meta_crtc_unset_config (MetaCrtc *crtc);
META_EXPORT_TEST META_EXPORT_TEST
const MetaCrtcConfig * meta_crtc_get_config (MetaCrtc *crtc); const MetaCrtcConfig * meta_crtc_get_config (MetaCrtc *crtc);
gboolean meta_crtc_assign_extra (MetaCrtc *crtc,
MetaCrtcAssignment *crtc_assignment,
GPtrArray *crtc_assignments,
GError **error);
size_t meta_crtc_get_gamma_lut_size (MetaCrtc *crtc); size_t meta_crtc_get_gamma_lut_size (MetaCrtc *crtc);
MetaGammaLut * meta_crtc_get_gamma_lut (MetaCrtc *crtc); MetaGammaLut * meta_crtc_get_gamma_lut (MetaCrtc *crtc);

View File

@ -261,6 +261,12 @@ assign_monitor_crtc (MetaMonitor *monitor,
}; };
g_ptr_array_add (crtc_assignment->outputs, output); g_ptr_array_add (crtc_assignment->outputs, output);
if (!meta_crtc_assign_extra (crtc,
crtc_assignment,
data->crtc_assignments,
error))
return FALSE;
/* /*
* Only one output can be marked as primary (due to Xrandr limitation), * Only one output can be marked as primary (due to Xrandr limitation),
* so only mark the main output of the first monitor in the logical monitor * so only mark the main output of the first monitor in the logical monitor
@ -1748,6 +1754,8 @@ meta_monitors_config_class_init (MetaMonitorsConfigClass *klass)
static void static void
meta_crtc_assignment_free (MetaCrtcAssignment *assignment) meta_crtc_assignment_free (MetaCrtcAssignment *assignment)
{ {
g_clear_pointer (&assignment->backend_private,
assignment->backend_private_destroy);
g_ptr_array_free (assignment->outputs, TRUE); g_ptr_array_free (assignment->outputs, TRUE);
g_free (assignment); g_free (assignment);
} }

View File

@ -522,7 +522,8 @@ apply_crtc_assignments (MetaMonitorManager *manager,
crtc_config = meta_crtc_config_new (&crtc_assignment->layout, crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_assignment->mode, crtc_assignment->mode,
crtc_assignment->transform); crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config); meta_crtc_set_config (crtc, crtc_config,
crtc_assignment->backend_private);
for (j = 0; j < crtc_assignment->outputs->len; j++) for (j = 0; j < crtc_assignment->outputs->len; j++)
{ {

View File

@ -87,6 +87,9 @@ struct _MetaCrtcAssignment
graphene_rect_t layout; graphene_rect_t layout;
MetaMonitorTransform transform; MetaMonitorTransform transform;
GPtrArray *outputs; GPtrArray *outputs;
gpointer backend_private;
GDestroyNotify backend_private_destroy;
}; };
/* /*

View File

@ -220,7 +220,8 @@ apply_crtc_assignments (MetaMonitorManager *manager,
crtc_config = meta_crtc_config_new (&crtc_assignment->layout, crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_assignment->mode, crtc_assignment->mode,
crtc_assignment->transform); crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config); meta_crtc_set_config (crtc, crtc_config,
crtc_assignment->backend_private);
for (j = 0; j < crtc_assignment->outputs->len; j++) for (j = 0; j < crtc_assignment->outputs->len; j++)
{ {

View File

@ -293,7 +293,7 @@ meta_crtc_xrandr_new (MetaGpuXrandr *gpu_xrandr,
crtc_xrandr->rect.height), crtc_xrandr->rect.height),
crtc_xrandr->current_mode, crtc_xrandr->current_mode,
crtc_xrandr->transform); crtc_xrandr->transform);
meta_crtc_set_config (META_CRTC (crtc_xrandr), crtc_config); meta_crtc_set_config (META_CRTC (crtc_xrandr), crtc_config, NULL);
} }
return crtc_xrandr; return crtc_xrandr;

View File

@ -560,7 +560,8 @@ apply_crtc_assignments (MetaMonitorManager *manager,
crtc_config = meta_crtc_config_new (&crtc_assignment->layout, crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_mode, crtc_mode,
crtc_assignment->transform); crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config); meta_crtc_set_config (crtc, crtc_config,
crtc_assignment->backend_private);
} }
} }

View File

@ -184,7 +184,8 @@ apply_crtc_assignments (MetaMonitorManager *manager,
crtc_config = meta_crtc_config_new (&crtc_assignment->layout, crtc_config = meta_crtc_config_new (&crtc_assignment->layout,
crtc_assignment->mode, crtc_assignment->mode,
crtc_assignment->transform); crtc_assignment->transform);
meta_crtc_set_config (crtc, crtc_config); meta_crtc_set_config (crtc, crtc_config,
crtc_assignment->backend_private);
for (j = 0; j < crtc_assignment->outputs->len; j++) for (j = 0; j < crtc_assignment->outputs->len; j++)
{ {