1
0
Fork 0

crtc: Move CRTC id field into instance private

Set during construction, retrieved using helper.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1287
This commit is contained in:
Jonas Ådahl 2020-02-25 11:34:43 +01:00 committed by Georges Basile Stavracas Neto
parent f4fd92d8e8
commit a42eed0231
14 changed files with 66 additions and 26 deletions

View file

@ -27,6 +27,7 @@ enum
{
PROP_0,
PROP_ID,
PROP_GPU,
N_PROPS
@ -36,6 +37,8 @@ static GParamSpec *obj_props[N_PROPS];
typedef struct _MetaCrtcPrivate
{
uint64_t id;
MetaGpu *gpu;
} MetaCrtcPrivate;
@ -43,6 +46,14 @@ G_DEFINE_TYPE_WITH_PRIVATE (MetaCrtc, meta_crtc, G_TYPE_OBJECT)
G_DEFINE_TYPE (MetaCrtcMode, meta_crtc_mode, G_TYPE_OBJECT)
uint64_t
meta_crtc_get_id (MetaCrtc *crtc)
{
MetaCrtcPrivate *priv = meta_crtc_get_instance_private (crtc);
return priv->id;
}
MetaGpu *
meta_crtc_get_gpu (MetaCrtc *crtc)
{
@ -86,6 +97,9 @@ meta_crtc_set_property (GObject *object,
switch (prop_id)
{
case PROP_ID:
priv->id = g_value_get_uint64 (value);
break;
case PROP_GPU:
priv->gpu = g_value_get_object (value);
break;
@ -105,6 +119,9 @@ meta_crtc_get_property (GObject *object,
switch (prop_id)
{
case PROP_ID:
g_value_set_uint64 (value, priv->id);
break;
case PROP_GPU:
g_value_set_object (value, priv->gpu);
break;
@ -140,6 +157,14 @@ meta_crtc_class_init (MetaCrtcClass *klass)
object_class->get_property = meta_crtc_get_property;
object_class->finalize = meta_crtc_finalize;
obj_props[PROP_ID] =
g_param_spec_uint64 ("id",
"id",
"CRTC id",
0, UINT64_MAX, 0,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_props[PROP_GPU] =
g_param_spec_object ("gpu",
"gpu",

View file

@ -60,7 +60,6 @@ struct _MetaCrtc
{
GObject parent;
glong crtc_id;
unsigned int all_transforms;
MetaCrtcConfig *config;
@ -95,6 +94,9 @@ META_EXPORT_TEST G_DECLARE_FINAL_TYPE (MetaCrtc, meta_crtc, META, CRTC, GObject)
#define META_TYPE_CRTC_MODE (meta_crtc_mode_get_type ())
META_EXPORT_TEST G_DECLARE_FINAL_TYPE (MetaCrtcMode, meta_crtc_mode, META, CRTC_MODE, GObject)
META_EXPORT_TEST
uint64_t meta_crtc_get_id (MetaCrtc *crtc);
META_EXPORT_TEST
MetaGpu * meta_crtc_get_gpu (MetaCrtc *crtc);

View file

@ -84,8 +84,10 @@ is_crtc_reserved (MetaCrtc *crtc,
for (i = 0; i < reserved_crtcs->len; i++)
{
glong id = g_array_index (reserved_crtcs, glong, i);
if (id == crtc->crtc_id)
uint64_t id;
id = g_array_index (reserved_crtcs, uint64_t, i);
if (id == meta_crtc_get_id (crtc))
return TRUE;
}
@ -381,7 +383,7 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_crtc_info_free);
output_infos =
g_ptr_array_new_with_free_func ((GDestroyNotify) meta_output_info_free);
reserved_crtcs = g_array_new (FALSE, FALSE, sizeof (glong));
reserved_crtcs = g_array_new (FALSE, FALSE, sizeof (uint64_t));
for (l = config->logical_monitor_configs; l; l = l->next)
{
@ -404,7 +406,11 @@ meta_monitor_config_manager_assign (MetaMonitorManager *manager,
crtc = meta_output_get_assigned_crtc (output);
if (crtc)
g_array_append_val (reserved_crtcs, crtc->crtc_id);
{
uint64_t crtc_id = meta_crtc_get_id (crtc);
g_array_append_val (reserved_crtcs, crtc_id);
}
}
}
}

View file

@ -199,9 +199,9 @@ append_monitor (MetaMonitorManager *manager,
*modes = g_list_concat (*modes, new_modes);
crtc = g_object_new (META_TYPE_CRTC,
"id", g_list_length (*crtcs) + 1,
"gpu", gpu,
NULL);
crtc->crtc_id = g_list_length (*crtcs) + 1;
crtc->all_transforms = ALL_TRANSFORMS;
*crtcs = g_list_append (*crtcs, crtc);
@ -293,9 +293,9 @@ append_tiled_monitor (MetaMonitorManager *manager,
MetaCrtc *crtc;
crtc = g_object_new (META_TYPE_CRTC,
"id", g_list_length (*crtcs) + i + 1,
"gpu", gpu,
NULL);
crtc->crtc_id = g_list_length (*crtcs) + i + 1;
crtc->all_transforms = ALL_TRANSFORMS;
new_crtcs = g_list_append (new_crtcs, crtc);
}

View file

@ -1030,7 +1030,7 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
current_mode_index = g_list_index (combined_modes, crtc_config->mode);
g_variant_builder_add (&crtc_builder, "(uxiiiiiuaua{sv})",
i, /* ID */
(int64_t) crtc->crtc_id,
(int64_t) meta_crtc_get_id (crtc),
(int) roundf (crtc_config->layout.origin.x),
(int) roundf (crtc_config->layout.origin.y),
(int) roundf (crtc_config->layout.size.width),
@ -1044,7 +1044,7 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
{
g_variant_builder_add (&crtc_builder, "(uxiiiiiuaua{sv})",
i, /* ID */
(int64_t) crtc->crtc_id,
(int64_t) meta_crtc_get_id (crtc),
0,
0,
0,

View file

@ -179,13 +179,15 @@ meta_crtc_kms_set_mode (MetaCrtc *crtc,
{
mode = crtc_config->mode->driver_private;
g_debug ("Setting CRTC (%ld) mode to %s", crtc->crtc_id, mode->name);
g_debug ("Setting CRTC (%ld) mode to %s",
meta_crtc_get_id (crtc), mode->name);
}
else
{
mode = NULL;
g_debug ("Unsetting CRTC (%ld) mode", crtc->crtc_id);
g_debug ("Unsetting CRTC (%ld) mode",
meta_crtc_get_id (crtc));
}
meta_kms_update_mode_set (kms_update,
@ -297,9 +299,9 @@ meta_create_kms_crtc (MetaGpuKms *gpu_kms,
primary_plane = meta_kms_device_get_primary_plane_for (kms_device,
kms_crtc);
crtc = g_object_new (META_TYPE_CRTC,
"id", meta_kms_crtc_get_id (kms_crtc),
"gpu", gpu,
NULL);
crtc->crtc_id = meta_kms_crtc_get_id (kms_crtc);
crtc->is_dirty = FALSE;
crtc->all_transforms = ALL_TRANSFORMS_MASK;

View file

@ -435,7 +435,8 @@ meta_monitor_manager_kms_set_crtc_gamma (MetaMonitorManager *manager,
g_autoptr (MetaKmsFeedback) kms_feedback = NULL;
gamma_ramp_string = generate_gamma_ramp_string (size, red, green, blue);
g_debug ("Setting CRTC (%ld) gamma to %s", crtc->crtc_id, gamma_ramp_string);
g_debug ("Setting CRTC (%ld) gamma to %s",
meta_crtc_get_id (crtc), gamma_ramp_string);
kms_update = meta_kms_ensure_pending_update (kms);

View file

@ -361,7 +361,7 @@ meta_create_kms_output (MetaGpuKms *gpu_kms,
{
MetaCrtc *crtc = l->data;
if (crtc->crtc_id == connector_state->current_crtc_id)
if (meta_crtc_get_id (crtc) == connector_state->current_crtc_id)
{
meta_output_assign_crtc (output, crtc);
break;

View file

@ -2500,7 +2500,7 @@ meta_renderer_native_create_surface_egl_device (CoglOnscreen *onscreen,
return FALSE;
output_attribs[0] = EGL_DRM_CRTC_EXT;
output_attribs[1] = onscreen_native->crtc->crtc_id;
output_attribs[1] = meta_crtc_get_id (onscreen_native->crtc);
output_attribs[2] = EGL_NONE;
if (!meta_egl_get_output_layers (egl, egl_display,

View file

@ -249,6 +249,7 @@ meta_create_xrandr_crtc (MetaGpuXrandr *gpu_xrandr,
GList *modes;
crtc = g_object_new (META_TYPE_CRTC,
"id", crtc_id,
"gpu", gpu,
NULL);
@ -258,7 +259,6 @@ meta_create_xrandr_crtc (MetaGpuXrandr *gpu_xrandr,
crtc->driver_private = crtc_xrandr;
crtc->driver_notify = (GDestroyNotify) meta_crtc_destroy_notify;
crtc->crtc_id = crtc_id;
panning = XRRGetPanning (xdisplay, resources, crtc_id);
if (panning && panning->width > 0 && panning->height > 0)

View file

@ -417,7 +417,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
xrandr_set_crtc_config (manager_xrandr,
crtc,
save_timestamp,
(xcb_randr_crtc_t) crtc->crtc_id,
(xcb_randr_crtc_t) meta_crtc_get_id (crtc),
XCB_CURRENT_TIME,
0, 0, XCB_NONE,
XCB_RANDR_ROTATION_ROTATE_0,
@ -444,7 +444,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
xrandr_set_crtc_config (manager_xrandr,
crtc,
save_timestamp,
(xcb_randr_crtc_t) crtc->crtc_id,
(xcb_randr_crtc_t) meta_crtc_get_id (crtc),
XCB_CURRENT_TIME,
0, 0, XCB_NONE,
XCB_RANDR_ROTATION_ROTATE_0,
@ -498,7 +498,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
if (!xrandr_set_crtc_config (manager_xrandr,
crtc,
save_timestamp,
(xcb_randr_crtc_t) crtc->crtc_id,
(xcb_randr_crtc_t) meta_crtc_get_id (crtc),
XCB_CURRENT_TIME,
(int) roundf (crtc_info->layout.origin.x),
(int) roundf (crtc_info->layout.origin.y),
@ -507,7 +507,8 @@ apply_crtc_assignments (MetaMonitorManager *manager,
output_ids, n_output_ids))
{
meta_warning ("Configuring CRTC %d with mode %d (%d x %d @ %f) at position %d, %d and transform %u failed\n",
(unsigned)(crtc->crtc_id), (unsigned)(mode->mode_id),
(unsigned) meta_crtc_get_id (crtc),
(unsigned) mode->mode_id,
mode->width, mode->height, (float)mode->refresh_rate,
(int) roundf (crtc_info->layout.origin.x),
(int) roundf (crtc_info->layout.origin.y),
@ -658,7 +659,8 @@ meta_monitor_manager_xrandr_get_crtc_gamma (MetaMonitorManager *manager,
MetaMonitorManagerXrandr *manager_xrandr = META_MONITOR_MANAGER_XRANDR (manager);
XRRCrtcGamma *gamma;
gamma = XRRGetCrtcGamma (manager_xrandr->xdisplay, (XID)crtc->crtc_id);
gamma = XRRGetCrtcGamma (manager_xrandr->xdisplay,
(XID) meta_crtc_get_id (crtc));
*size = gamma->size;
*red = g_memdup (gamma->red, sizeof (unsigned short) * gamma->size);
@ -684,7 +686,9 @@ meta_monitor_manager_xrandr_set_crtc_gamma (MetaMonitorManager *manager,
memcpy (gamma->green, green, sizeof (unsigned short) * size);
memcpy (gamma->blue, blue, sizeof (unsigned short) * size);
XRRSetCrtcGamma (manager_xrandr->xdisplay, (XID)crtc->crtc_id, gamma);
XRRSetCrtcGamma (manager_xrandr->xdisplay,
(XID) meta_crtc_get_id (crtc),
gamma);
XRRFreeGamma (gamma);
}

View file

@ -737,7 +737,7 @@ output_get_crtcs (MetaOutput *output,
{
MetaCrtc *crtc = l->data;
if ((XID) crtc->crtc_id == xrandr_output->crtcs[i])
if ((XID) meta_crtc_get_id (crtc) == xrandr_output->crtcs[i])
{
output->possible_crtcs[n_actual_crtcs] = crtc;
n_actual_crtcs += 1;
@ -752,7 +752,7 @@ output_get_crtcs (MetaOutput *output,
{
MetaCrtc *crtc = l->data;
if ((XID) crtc->crtc_id == xrandr_output->crtc)
if ((XID) meta_crtc_get_id (crtc) == xrandr_output->crtc)
{
meta_output_assign_crtc (output, crtc);
break;

View file

@ -139,9 +139,9 @@ meta_test_headless_monitor_connect (void)
gpu = META_GPU (meta_backend_get_gpus (meta_get_backend ())->data);
crtc = g_object_new (META_TYPE_CRTC,
"id", 1,
"gpu", gpu,
NULL);
crtc->crtc_id = 1;
crtc->all_transforms = ALL_TRANSFORMS;
test_setup->crtcs = g_list_append (NULL, crtc);

View file

@ -573,9 +573,9 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
MetaCrtc *crtc;
crtc = g_object_new (META_TYPE_CRTC,
"id", i + 1,
"gpu", test_get_gpu (),
NULL);
crtc->crtc_id = i + 1;
crtc->all_transforms = ALL_TRANSFORMS;
test_setup->crtcs = g_list_append (test_setup->crtcs, crtc);