Commit 11d9e0d4 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

backends: move GfOutput::crtc field into private struct

Based on mutter commit:
mutter@1200182d
parent 3b4c90d4
......@@ -51,7 +51,7 @@ foreach_crtc (GfMonitor *monitor,
ForeachCrtcData *data = user_data;
data->func (data->logical_monitor,
monitor_crtc_mode->output->crtc,
gf_output_get_assigned_crtc (monitor_crtc_mode->output),
data->user_data);
return TRUE;
......@@ -87,10 +87,12 @@ static GfMonitorTransform
derive_monitor_transform (GfMonitor *monitor)
{
GfOutput *main_output;
GfMonitorTransform transform;
main_output = gf_monitor_get_main_output (monitor);
transform = gf_output_get_assigned_crtc (main_output)->transform;
return gf_monitor_crtc_to_logical_transform (monitor, main_output->crtc->transform);
return gf_monitor_crtc_to_logical_transform (monitor, transform);
}
static void
......@@ -206,12 +208,14 @@ gf_logical_monitor_add_monitor (GfLogicalMonitor *logical_monitor,
for (l_output = outputs; l_output; l_output = l_output->next)
{
GfOutput *output;
GfCrtc *crtc;
output = l_output->data;
is_presentation = is_presentation && output->is_presentation;
crtc = gf_output_get_assigned_crtc (output);
if (output->crtc)
output->crtc->logical_monitor = logical_monitor;
if (crtc)
crtc->logical_monitor = logical_monitor;
}
}
......
......@@ -230,9 +230,13 @@ is_crtc_assignment_changed (GfCrtc *crtc,
for (j = 0; j < crtc_info->outputs->len; j++)
{
GfOutput *output = ((GfOutput**) crtc_info->outputs->pdata)[j];
GfOutput *output;
GfCrtc *assigned_crtc;
if (output->crtc != crtc)
output = ((GfOutput**) crtc_info->outputs->pdata)[j];
assigned_crtc = gf_output_get_assigned_crtc (output);
if (assigned_crtc != crtc)
return TRUE;
}
......@@ -249,9 +253,12 @@ is_output_assignment_changed (GfOutput *output,
GfOutputInfo **output_infos,
guint n_output_infos)
{
gboolean output_is_found = FALSE;
gboolean output_is_found;
GfCrtc *assigned_crtc;
guint i;
output_is_found = FALSE;
for (i = 0; i < n_output_infos; i++)
{
GfOutputInfo *output_info = output_infos[i];
......@@ -271,8 +278,10 @@ is_output_assignment_changed (GfOutput *output,
output_is_found = TRUE;
}
assigned_crtc = gf_output_get_assigned_crtc (output);
if (!output_is_found)
return output->crtc != NULL;
return assigned_crtc != NULL;
for (i = 0; i < n_crtc_infos; i++)
{
......@@ -286,7 +295,7 @@ is_output_assignment_changed (GfOutput *output,
crtc_info_output = ((GfOutput**) crtc_info->outputs->pdata)[j];
if (crtc_info_output == output &&
crtc_info->crtc == output->crtc)
crtc_info->crtc == assigned_crtc)
return FALSE;
}
}
......@@ -516,7 +525,7 @@ apply_crtc_assignments (GfMonitorManager *manager,
output = ((GfOutput**) crtc_info->outputs->pdata)[j];
output->is_dirty = TRUE;
output->crtc = crtc;
gf_output_assign_crtc (output, crtc);
output_ids[j] = output->winsys_id;
}
......@@ -586,7 +595,7 @@ apply_crtc_assignments (GfMonitorManager *manager,
continue;
}
output->crtc = NULL;
gf_output_unassign_crtc (output);
output->is_primary = FALSE;
}
......
......@@ -1187,6 +1187,7 @@ gf_monitor_manager_handle_get_resources (GfDBusDisplayConfig *skeleton,
GVariantBuilder crtcs, modes, clones, properties;
GBytes *edid;
gchar *edid_file;
GfCrtc *crtc;
gint crtc_index;
g_variant_builder_init (&crtcs, G_VARIANT_TYPE ("au"));
......@@ -1284,7 +1285,8 @@ gf_monitor_manager_handle_get_resources (GfDBusDisplayConfig *skeleton,
output->tile_info.tile_h));
}
crtc_index = output->crtc ? g_list_index (combined_crtcs, output->crtc) : -1;
crtc = gf_output_get_assigned_crtc (output);
crtc_index = crtc ? g_list_index (combined_crtcs, crtc) : -1;
g_variant_builder_add (&output_builder, "(uxiausauaua{sv})",
i, /* ID */
......@@ -2649,11 +2651,7 @@ gf_monitor_manager_get_monitor_for_connector (GfMonitorManager *manager,
if (gf_monitor_is_active (monitor) &&
g_str_equal (connector, gf_monitor_get_connector (monitor)))
{
GfOutput *main_output = gf_monitor_get_main_output (monitor);
return main_output->crtc->logical_monitor->number;
}
return gf_monitor_get_logical_monitor (monitor)->number;
}
return -1;
......
......@@ -48,6 +48,7 @@ generate_modes (GfMonitorNormal *normal)
GfCrtcMode *crtc_mode;
GfMonitorMode *mode;
gboolean replace;
GfCrtc *crtc;
crtc_mode = output->modes[i];
......@@ -82,7 +83,8 @@ generate_modes (GfMonitorNormal *normal)
if (crtc_mode == output->preferred_mode)
gf_monitor_set_preferred_mode (monitor, mode);
if (output->crtc && crtc_mode == output->crtc->current_mode)
crtc = gf_output_get_assigned_crtc (output);
if (crtc && crtc_mode == crtc->current_mode)
gf_monitor_set_current_mode (monitor, mode);
}
}
......@@ -102,14 +104,16 @@ gf_monitor_normal_derive_layout (GfMonitor *monitor,
GfRectangle *layout)
{
GfOutput *output;
GfCrtc *crtc;
output = gf_monitor_get_main_output (monitor);
crtc = gf_output_get_assigned_crtc (output);
*layout = (GfRectangle) {
.x = output->crtc->rect.x,
.y = output->crtc->rect.y,
.width = output->crtc->rect.width,
.height = output->crtc->rect.height
.x = crtc->rect.x,
.y = crtc->rect.y,
.width = crtc->rect.width,
.height = crtc->rect.height
};
}
......
......@@ -635,15 +635,19 @@ gf_monitor_tiled_derive_layout (GfMonitor *monitor,
for (l = outputs; l; l = l->next)
{
GfOutput *output = l->data;
GfOutput *output;
GfCrtc *crtc;
output = l->data;
crtc = gf_output_get_assigned_crtc (output);
if (!output->crtc)
if (!crtc)
continue;
min_x = MIN (output->crtc->rect.x, min_x);
min_y = MIN (output->crtc->rect.y, min_y);
max_x = MAX (output->crtc->rect.x + output->crtc->rect.width, max_x);
max_y = MAX (output->crtc->rect.y + output->crtc->rect.height, max_y);
min_x = MIN (crtc->rect.x, min_x);
min_y = MIN (crtc->rect.y, min_y);
max_x = MAX (crtc->rect.x + crtc->rect.width, max_x);
max_y = MAX (crtc->rect.y + crtc->rect.height, max_y);
}
*layout = (GfRectangle) {
......
......@@ -375,14 +375,18 @@ gf_monitor_is_mode_assigned (GfMonitor *monitor,
for (l = priv->outputs, i = 0; l; l = l->next, i++)
{
GfOutput *output = l->data;
GfMonitorCrtcMode *monitor_crtc_mode = &mode->crtc_modes[i];
GfOutput *output;
GfMonitorCrtcMode *monitor_crtc_mode;
GfCrtc *crtc;
output = l->data;
monitor_crtc_mode = &mode->crtc_modes[i];
crtc = gf_output_get_assigned_crtc (output);
if (monitor_crtc_mode->crtc_mode &&
(!output->crtc ||
output->crtc->current_mode != monitor_crtc_mode->crtc_mode))
(!crtc || crtc->current_mode != monitor_crtc_mode->crtc_mode))
return FALSE;
else if (!monitor_crtc_mode->crtc_mode && output->crtc)
else if (!monitor_crtc_mode->crtc_mode && crtc)
return FALSE;
}
......@@ -530,10 +534,12 @@ gboolean
gf_monitor_is_active (GfMonitor *monitor)
{
GfOutput *output;
GfCrtc *crtc;
output = gf_monitor_get_main_output (monitor);
crtc = gf_output_get_assigned_crtc (output);
return output->crtc && output->crtc->current_mode;
return crtc && crtc->current_mode;
}
GfOutput *
......@@ -752,10 +758,14 @@ gf_monitor_get_suggested_position (GfMonitor *monitor,
GfLogicalMonitor *
gf_monitor_get_logical_monitor (GfMonitor *monitor)
{
GfOutput *output = gf_monitor_get_main_output (monitor);
GfOutput *output;
GfCrtc *crtc;
output = gf_monitor_get_main_output (monitor);
crtc = gf_output_get_assigned_crtc (output);
if (output->crtc)
return output->crtc->logical_monitor;
if (crtc)
return crtc->logical_monitor;
else
return NULL;
}
......
......@@ -59,9 +59,6 @@ struct _GfOutput
GfGpu *gpu;
/* The CRTC driving this output, NULL if the output is not enabled */
GfCrtc *crtc;
/* The low-level ID of this output, used to apply back configuration */
glong winsys_id;
gchar *name;
......@@ -113,13 +110,19 @@ struct _GfOutput
#define GF_TYPE_OUTPUT (gf_output_get_type ())
G_DECLARE_FINAL_TYPE (GfOutput, gf_output, GF, OUTPUT, GObject)
GfGpu *gf_output_get_gpu (GfOutput *output);
GfGpu *gf_output_get_gpu (GfOutput *output);
void gf_output_assign_crtc (GfOutput *output,
GfCrtc *crtc);
void gf_output_unassign_crtc (GfOutput *output);
GfCrtc *gf_output_get_assigned_crtc (GfOutput *output);
void gf_output_parse_edid (GfOutput *output,
GBytes *edid);
void gf_output_parse_edid (GfOutput *output,
GBytes *edid);
gboolean gf_output_is_laptop (GfOutput *output);
gboolean gf_output_is_laptop (GfOutput *output);
G_END_DECLS
......
......@@ -92,10 +92,13 @@ output_set_underscanning_xrandr (GfOutput *output,
*/
if (underscanning)
{
GfCrtc *crtc;
uint32_t border_value;
crtc = gf_output_get_assigned_crtc (output);
prop = XInternAtom (xdisplay, "underscan hborder", False);
border_value = output->crtc->current_mode->width * 0.05;
border_value = crtc->current_mode->width * 0.05;
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
(XID) output->winsys_id,
......@@ -104,7 +107,7 @@ output_set_underscanning_xrandr (GfOutput *output,
1, &border_value);
prop = XInternAtom (xdisplay, "underscan vborder", False);
border_value = output->crtc->current_mode->height * 0.05;
border_value = crtc->current_mode->height * 0.05;
xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
(XID) output->winsys_id,
......@@ -531,14 +534,14 @@ output_get_crtcs (GfOutput *output,
}
output->n_possible_crtcs = n_actual_crtcs;
output->crtc = NULL;
gf_output_unassign_crtc (output);
for (l = gf_gpu_get_crtcs (gpu); l; l = l->next)
{
GfCrtc *crtc = l->data;
if ((XID) crtc->crtc_id == xrandr_output->crtc)
{
output->crtc = crtc;
gf_output_assign_crtc (output, crtc);
break;
}
}
......
......@@ -30,7 +30,13 @@
#include "gf-edid-private.h"
#include "gf-output-private.h"
G_DEFINE_TYPE (GfOutput, gf_output, G_TYPE_OBJECT)
typedef struct
{
/* The CRTC driving this output, NULL if the output is not enabled */
GfCrtc *crtc;
} GfOutputPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (GfOutput, gf_output, G_TYPE_OBJECT)
static void
gf_output_finalize (GObject *object)
......@@ -74,6 +80,39 @@ gf_output_get_gpu (GfOutput *output)
return output->gpu;
}
void
gf_output_assign_crtc (GfOutput *output,
GfCrtc *crtc)
{
GfOutputPrivate *priv;
priv = gf_output_get_instance_private (output);
g_assert (crtc);
priv->crtc = crtc;
}
void
gf_output_unassign_crtc (GfOutput *output)
{
GfOutputPrivate *priv;
priv = gf_output_get_instance_private (output);
priv->crtc = NULL;
}
GfCrtc *
gf_output_get_assigned_crtc (GfOutput *output)
{
GfOutputPrivate *priv;
priv = gf_output_get_instance_private (output);
return priv->crtc;
}
void
gf_output_parse_edid (GfOutput *output,
GBytes *edid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment