2017-03-24 09:35:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Red Hat
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-08-07 09:50:23 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2017-03-24 09:35:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2020-10-21 05:31:08 +00:00
|
|
|
#include "backends/edid.h"
|
2017-03-24 09:35:51 +00:00
|
|
|
#include "backends/meta-output.h"
|
|
|
|
|
2020-10-08 15:30:47 +00:00
|
|
|
#include "backends/meta-crtc.h"
|
|
|
|
|
2020-02-25 09:54:40 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
2020-02-25 15:13:52 +00:00
|
|
|
PROP_ID,
|
2020-02-25 09:54:40 +00:00
|
|
|
PROP_GPU,
|
2020-02-26 08:45:07 +00:00
|
|
|
PROP_INFO,
|
2022-12-20 11:15:25 +00:00
|
|
|
PROP_IS_PRIVACY_SCREEN_ENABLED,
|
2020-02-25 09:54:40 +00:00
|
|
|
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *obj_props[N_PROPS];
|
|
|
|
|
2023-03-02 00:32:38 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
COLOR_SPACE_CHANGED,
|
|
|
|
HDR_METADATA_CHANGED,
|
|
|
|
|
|
|
|
N_SIGNALS
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[N_SIGNALS];
|
|
|
|
|
2017-11-03 10:25:30 +00:00
|
|
|
typedef struct _MetaOutputPrivate
|
|
|
|
{
|
2020-02-25 15:13:52 +00:00
|
|
|
uint64_t id;
|
|
|
|
|
2020-02-25 09:54:40 +00:00
|
|
|
MetaGpu *gpu;
|
|
|
|
|
2020-02-26 08:45:07 +00:00
|
|
|
MetaOutputInfo *info;
|
|
|
|
|
2020-10-08 15:34:57 +00:00
|
|
|
MetaMonitor *monitor;
|
|
|
|
|
2017-11-03 10:25:30 +00:00
|
|
|
/* The CRTC driving this output, NULL if the output is not enabled */
|
|
|
|
MetaCrtc *crtc;
|
2020-02-25 17:37:21 +00:00
|
|
|
|
|
|
|
gboolean is_primary;
|
|
|
|
gboolean is_presentation;
|
|
|
|
|
|
|
|
gboolean is_underscanning;
|
|
|
|
|
2022-06-09 10:44:46 +00:00
|
|
|
gboolean has_max_bpc;
|
|
|
|
unsigned int max_bpc;
|
|
|
|
|
2020-02-25 17:37:21 +00:00
|
|
|
int backlight;
|
2022-12-20 11:15:25 +00:00
|
|
|
|
|
|
|
MetaPrivacyScreenState privacy_screen_state;
|
|
|
|
gboolean is_privacy_screen_enabled;
|
2023-03-02 00:32:38 +00:00
|
|
|
|
|
|
|
MetaOutputHdrMetadata hdr_metadata;
|
|
|
|
MetaOutputColorspace color_space;
|
2017-11-03 10:25:30 +00:00
|
|
|
} MetaOutputPrivate;
|
|
|
|
|
2020-02-26 15:47:03 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaOutput, meta_output, G_TYPE_OBJECT)
|
2017-03-24 09:35:51 +00:00
|
|
|
|
2020-02-26 08:45:07 +00:00
|
|
|
G_DEFINE_BOXED_TYPE (MetaOutputInfo, meta_output_info,
|
|
|
|
meta_output_info_ref,
|
|
|
|
meta_output_info_unref)
|
|
|
|
|
|
|
|
MetaOutputInfo *
|
|
|
|
meta_output_info_new (void)
|
|
|
|
{
|
|
|
|
MetaOutputInfo *output_info;
|
|
|
|
|
|
|
|
output_info = g_new0 (MetaOutputInfo, 1);
|
|
|
|
g_ref_count_init (&output_info->ref_count);
|
|
|
|
|
|
|
|
return output_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaOutputInfo *
|
|
|
|
meta_output_info_ref (MetaOutputInfo *output_info)
|
|
|
|
{
|
|
|
|
g_ref_count_inc (&output_info->ref_count);
|
|
|
|
return output_info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_output_info_unref (MetaOutputInfo *output_info)
|
|
|
|
{
|
|
|
|
if (g_ref_count_dec (&output_info->ref_count))
|
|
|
|
{
|
|
|
|
g_free (output_info->name);
|
|
|
|
g_free (output_info->vendor);
|
|
|
|
g_free (output_info->product);
|
|
|
|
g_free (output_info->serial);
|
2021-10-26 09:27:56 +00:00
|
|
|
g_free (output_info->edid_checksum_md5);
|
2021-11-08 20:43:04 +00:00
|
|
|
g_free (output_info->edid_info);
|
2020-02-26 08:45:07 +00:00
|
|
|
g_free (output_info->modes);
|
|
|
|
g_free (output_info->possible_crtcs);
|
|
|
|
g_free (output_info->possible_clones);
|
|
|
|
g_free (output_info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 15:13:52 +00:00
|
|
|
uint64_t
|
|
|
|
meta_output_get_id (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->id;
|
|
|
|
}
|
|
|
|
|
2017-07-10 10:19:32 +00:00
|
|
|
MetaGpu *
|
|
|
|
meta_output_get_gpu (MetaOutput *output)
|
2017-07-04 03:56:18 +00:00
|
|
|
{
|
2020-02-25 09:54:40 +00:00
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->gpu;
|
2017-07-04 03:56:18 +00:00
|
|
|
}
|
|
|
|
|
2020-10-08 15:34:57 +00:00
|
|
|
MetaMonitor *
|
|
|
|
meta_output_get_monitor (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
g_warn_if_fail (priv->monitor);
|
|
|
|
|
|
|
|
return priv->monitor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_output_set_monitor (MetaOutput *output,
|
|
|
|
MetaMonitor *monitor)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
g_warn_if_fail (!priv->monitor);
|
|
|
|
|
|
|
|
priv->monitor = monitor;
|
|
|
|
}
|
|
|
|
|
2021-01-27 22:16:05 +00:00
|
|
|
void
|
|
|
|
meta_output_unset_monitor (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
g_warn_if_fail (priv->monitor);
|
|
|
|
|
|
|
|
priv->monitor = NULL;
|
|
|
|
}
|
|
|
|
|
2020-04-30 15:58:17 +00:00
|
|
|
const char *
|
|
|
|
meta_output_get_name (MetaOutput *output)
|
|
|
|
{
|
2020-02-26 08:45:07 +00:00
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->info->name;
|
2020-04-30 15:58:17 +00:00
|
|
|
}
|
|
|
|
|
2020-02-25 17:37:21 +00:00
|
|
|
gboolean
|
|
|
|
meta_output_is_primary (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->is_primary;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_output_is_presentation (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->is_presentation;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_output_is_underscanning (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->is_underscanning;
|
|
|
|
}
|
|
|
|
|
2022-06-09 10:44:46 +00:00
|
|
|
gboolean
|
|
|
|
meta_output_get_max_bpc (MetaOutput *output,
|
|
|
|
unsigned int *max_bpc)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
if (priv->has_max_bpc && max_bpc)
|
|
|
|
*max_bpc = priv->max_bpc;
|
|
|
|
|
|
|
|
return priv->has_max_bpc;
|
|
|
|
}
|
|
|
|
|
2020-02-25 17:37:21 +00:00
|
|
|
void
|
|
|
|
meta_output_set_backlight (MetaOutput *output,
|
|
|
|
int backlight)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
priv->backlight = backlight;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
meta_output_get_backlight (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->backlight;
|
|
|
|
}
|
|
|
|
|
2020-02-26 08:45:07 +00:00
|
|
|
void
|
|
|
|
meta_output_add_possible_clone (MetaOutput *output,
|
|
|
|
MetaOutput *possible_clone)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
MetaOutputInfo *output_info = priv->info;
|
|
|
|
|
|
|
|
output_info->n_possible_clones++;
|
|
|
|
output_info->possible_clones = g_renew (MetaOutput *,
|
|
|
|
output_info->possible_clones,
|
|
|
|
output_info->n_possible_clones);
|
|
|
|
output_info->possible_clones[output_info->n_possible_clones - 1] =
|
|
|
|
possible_clone;
|
|
|
|
}
|
|
|
|
|
|
|
|
const MetaOutputInfo *
|
|
|
|
meta_output_get_info (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->info;
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:25:30 +00:00
|
|
|
void
|
2020-02-25 19:30:46 +00:00
|
|
|
meta_output_assign_crtc (MetaOutput *output,
|
|
|
|
MetaCrtc *crtc,
|
|
|
|
const MetaOutputAssignment *output_assignment)
|
2017-11-03 10:25:30 +00:00
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
g_assert (crtc);
|
|
|
|
|
2020-10-08 15:30:47 +00:00
|
|
|
meta_output_unassign_crtc (output);
|
|
|
|
|
2017-11-03 10:27:57 +00:00
|
|
|
g_set_object (&priv->crtc, crtc);
|
2020-02-25 17:37:21 +00:00
|
|
|
|
2020-10-08 15:30:47 +00:00
|
|
|
meta_crtc_assign_output (crtc, output);
|
|
|
|
|
2020-02-25 19:30:46 +00:00
|
|
|
priv->is_primary = output_assignment->is_primary;
|
|
|
|
priv->is_presentation = output_assignment->is_presentation;
|
|
|
|
priv->is_underscanning = output_assignment->is_underscanning;
|
2022-06-09 10:44:46 +00:00
|
|
|
|
|
|
|
priv->has_max_bpc = output_assignment->has_max_bpc;
|
|
|
|
if (priv->has_max_bpc)
|
|
|
|
priv->max_bpc = output_assignment->max_bpc;
|
2017-11-03 10:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_output_unassign_crtc (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
2020-10-08 15:30:47 +00:00
|
|
|
if (priv->crtc)
|
|
|
|
{
|
|
|
|
meta_crtc_unassign_output (priv->crtc, output);
|
|
|
|
g_clear_object (&priv->crtc);
|
|
|
|
}
|
2020-02-25 17:37:21 +00:00
|
|
|
|
|
|
|
priv->is_primary = FALSE;
|
|
|
|
priv->is_presentation = FALSE;
|
2017-11-03 10:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MetaCrtc *
|
|
|
|
meta_output_get_assigned_crtc (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->crtc;
|
|
|
|
}
|
|
|
|
|
2020-01-14 21:21:38 +00:00
|
|
|
MetaMonitorTransform
|
|
|
|
meta_output_logical_to_crtc_transform (MetaOutput *output,
|
|
|
|
MetaMonitorTransform transform)
|
|
|
|
{
|
2020-02-26 08:45:07 +00:00
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
2020-02-18 10:30:38 +00:00
|
|
|
MetaMonitorTransform panel_orientation_transform;
|
2020-01-14 21:21:38 +00:00
|
|
|
|
2020-02-26 08:45:07 +00:00
|
|
|
panel_orientation_transform = priv->info->panel_orientation_transform;
|
2020-02-18 10:30:38 +00:00
|
|
|
return meta_monitor_transform_transform (transform,
|
|
|
|
panel_orientation_transform);
|
2020-01-14 21:21:38 +00:00
|
|
|
}
|
|
|
|
|
2020-02-18 10:45:26 +00:00
|
|
|
MetaMonitorTransform
|
|
|
|
meta_output_crtc_to_logical_transform (MetaOutput *output,
|
|
|
|
MetaMonitorTransform transform)
|
|
|
|
{
|
2020-02-26 08:45:07 +00:00
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
2020-02-18 10:45:26 +00:00
|
|
|
MetaMonitorTransform inverted_panel_orientation_transform;
|
|
|
|
|
|
|
|
inverted_panel_orientation_transform =
|
2020-02-26 08:45:07 +00:00
|
|
|
meta_monitor_transform_invert (priv->info->panel_orientation_transform);
|
2020-02-18 10:45:26 +00:00
|
|
|
return meta_monitor_transform_transform (transform,
|
|
|
|
inverted_panel_orientation_transform);
|
|
|
|
}
|
|
|
|
|
2021-11-08 20:43:04 +00:00
|
|
|
static void
|
|
|
|
set_output_details_from_edid (MetaOutputInfo *output_info,
|
|
|
|
MetaEdidInfo *edid_info)
|
|
|
|
{
|
2023-07-11 14:27:55 +00:00
|
|
|
output_info->vendor = g_strdup (edid_info->manufacturer_code);
|
2021-11-08 20:43:04 +00:00
|
|
|
if (!g_utf8_validate (output_info->vendor, -1, NULL))
|
|
|
|
g_clear_pointer (&output_info->vendor, g_free);
|
|
|
|
|
2023-07-11 14:27:55 +00:00
|
|
|
output_info->product = g_strdup (edid_info->dsc_product_name);
|
2023-09-12 18:08:10 +00:00
|
|
|
if (!output_info->product ||
|
|
|
|
!g_utf8_validate (output_info->product, -1, NULL) ||
|
2021-11-08 20:43:04 +00:00
|
|
|
output_info->product[0] == '\0')
|
|
|
|
{
|
|
|
|
g_clear_pointer (&output_info->product, g_free);
|
|
|
|
output_info->product =
|
|
|
|
g_strdup_printf ("0x%04x", (unsigned) edid_info->product_code);
|
|
|
|
}
|
|
|
|
|
2023-07-11 14:27:55 +00:00
|
|
|
output_info->serial = g_strdup (edid_info->dsc_serial_number);
|
2023-09-12 18:08:10 +00:00
|
|
|
if (!output_info->serial ||
|
|
|
|
!g_utf8_validate (output_info->serial, -1, NULL) ||
|
2021-11-08 20:43:04 +00:00
|
|
|
output_info->serial[0] == '\0')
|
|
|
|
{
|
|
|
|
g_clear_pointer (&output_info->serial, g_free);
|
|
|
|
output_info->serial =
|
|
|
|
g_strdup_printf ("0x%08x", edid_info->serial_number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 05:31:08 +00:00
|
|
|
void
|
|
|
|
meta_output_info_parse_edid (MetaOutputInfo *output_info,
|
|
|
|
GBytes *edid)
|
|
|
|
{
|
2021-11-08 20:43:04 +00:00
|
|
|
MetaEdidInfo *edid_info;
|
2023-03-07 05:21:19 +00:00
|
|
|
size_t size;
|
2021-10-26 09:27:56 +00:00
|
|
|
gconstpointer data;
|
2020-10-21 05:31:08 +00:00
|
|
|
|
2021-11-08 20:43:04 +00:00
|
|
|
g_return_if_fail (!output_info->edid_info);
|
2021-10-28 13:25:58 +00:00
|
|
|
g_return_if_fail (edid);
|
2020-10-21 05:31:08 +00:00
|
|
|
|
2023-03-07 05:21:19 +00:00
|
|
|
data = g_bytes_get_data (edid, &size);
|
|
|
|
edid_info = meta_edid_info_new_parse (data, size);
|
2021-10-26 09:27:56 +00:00
|
|
|
|
|
|
|
output_info->edid_checksum_md5 = g_compute_checksum_for_data (G_CHECKSUM_MD5,
|
2023-03-07 05:21:19 +00:00
|
|
|
data, size);
|
2020-10-21 05:31:08 +00:00
|
|
|
|
2021-11-08 20:43:04 +00:00
|
|
|
if (edid_info)
|
2020-10-21 05:31:08 +00:00
|
|
|
{
|
2021-11-08 20:43:04 +00:00
|
|
|
output_info->edid_info = edid_info;
|
|
|
|
set_output_details_from_edid (output_info, edid_info);
|
2020-10-21 05:31:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-25 09:54:40 +00:00
|
|
|
static void
|
|
|
|
meta_output_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaOutput *output = META_OUTPUT (object);
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2020-02-25 15:13:52 +00:00
|
|
|
case PROP_ID:
|
|
|
|
priv->id = g_value_get_uint64 (value);
|
|
|
|
break;
|
2020-02-25 09:54:40 +00:00
|
|
|
case PROP_GPU:
|
|
|
|
priv->gpu = g_value_get_object (value);
|
|
|
|
break;
|
2020-02-26 08:45:07 +00:00
|
|
|
case PROP_INFO:
|
|
|
|
priv->info = meta_output_info_ref (g_value_get_boxed (value));
|
|
|
|
break;
|
2022-12-20 11:15:25 +00:00
|
|
|
case PROP_IS_PRIVACY_SCREEN_ENABLED:
|
|
|
|
priv->is_privacy_screen_enabled = g_value_get_boolean (value);
|
|
|
|
break;
|
2020-02-25 09:54:40 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_output_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaOutput *output = META_OUTPUT (object);
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2020-02-25 15:13:52 +00:00
|
|
|
case PROP_ID:
|
|
|
|
g_value_set_uint64 (value, priv->id);
|
|
|
|
break;
|
2020-02-25 09:54:40 +00:00
|
|
|
case PROP_GPU:
|
|
|
|
g_value_set_object (value, priv->gpu);
|
|
|
|
break;
|
2020-02-26 08:45:07 +00:00
|
|
|
case PROP_INFO:
|
|
|
|
g_value_set_boxed (value, priv->info);
|
|
|
|
break;
|
2022-12-20 11:15:25 +00:00
|
|
|
case PROP_IS_PRIVACY_SCREEN_ENABLED:
|
|
|
|
g_value_set_boolean (value, priv->is_privacy_screen_enabled);
|
|
|
|
break;
|
2020-02-25 09:54:40 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-03 10:27:57 +00:00
|
|
|
static void
|
|
|
|
meta_output_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
MetaOutput *output = META_OUTPUT (object);
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
g_clear_object (&priv->crtc);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_output_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2017-03-24 09:35:51 +00:00
|
|
|
static void
|
|
|
|
meta_output_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaOutput *output = META_OUTPUT (object);
|
2020-02-26 08:45:07 +00:00
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
2017-03-24 09:35:51 +00:00
|
|
|
|
2020-02-26 08:45:07 +00:00
|
|
|
g_clear_pointer (&priv->info, meta_output_info_unref);
|
|
|
|
|
2017-03-24 09:35:51 +00:00
|
|
|
G_OBJECT_CLASS (meta_output_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2021-03-22 00:02:19 +00:00
|
|
|
MetaPrivacyScreenState
|
|
|
|
meta_output_get_privacy_screen_state (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output);
|
|
|
|
|
|
|
|
if (!output_class->get_privacy_screen_state)
|
|
|
|
return META_PRIVACY_SCREEN_UNAVAILABLE;
|
|
|
|
|
|
|
|
return output_class->get_privacy_screen_state (output);
|
|
|
|
}
|
|
|
|
|
2022-12-20 11:15:25 +00:00
|
|
|
gboolean
|
|
|
|
meta_output_is_privacy_screen_supported (MetaOutput *output)
|
|
|
|
{
|
|
|
|
return !(meta_output_get_privacy_screen_state (output) ==
|
|
|
|
META_PRIVACY_SCREEN_UNAVAILABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_output_is_privacy_screen_enabled (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->privacy_screen_state;
|
|
|
|
}
|
|
|
|
|
2021-03-22 00:02:19 +00:00
|
|
|
gboolean
|
|
|
|
meta_output_set_privacy_screen_enabled (MetaOutput *output,
|
|
|
|
gboolean enabled,
|
|
|
|
GError **error)
|
|
|
|
{
|
2022-12-20 11:15:25 +00:00
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
2021-03-22 00:02:19 +00:00
|
|
|
MetaPrivacyScreenState state;
|
|
|
|
|
2022-12-20 11:15:25 +00:00
|
|
|
state = priv->privacy_screen_state;
|
2021-03-22 00:02:19 +00:00
|
|
|
|
|
|
|
if (state == META_PRIVACY_SCREEN_UNAVAILABLE)
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
|
|
|
"The privacy screen is not supported by this output");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state & META_PRIVACY_SCREEN_LOCKED)
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
|
|
|
|
"The privacy screen is locked at hardware level, "
|
|
|
|
"impossible to set it");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-12-20 11:15:25 +00:00
|
|
|
if (priv->is_privacy_screen_enabled == enabled)
|
2021-03-22 00:02:19 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2022-12-20 11:15:25 +00:00
|
|
|
priv->is_privacy_screen_enabled = enabled;
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (output),
|
|
|
|
obj_props[PROP_IS_PRIVACY_SCREEN_ENABLED]);
|
|
|
|
return TRUE;
|
2021-03-22 00:02:19 +00:00
|
|
|
}
|
|
|
|
|
2023-03-17 00:17:45 +00:00
|
|
|
gboolean
|
|
|
|
meta_output_info_is_color_space_supported (const MetaOutputInfo *output_info,
|
|
|
|
MetaOutputColorspace color_space)
|
|
|
|
{
|
|
|
|
MetaEdidColorimetry colorimetry;
|
|
|
|
|
|
|
|
if (!output_info->edid_info)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
colorimetry = output_info->edid_info->colorimetry;
|
|
|
|
|
|
|
|
switch (color_space)
|
|
|
|
{
|
|
|
|
case META_OUTPUT_COLORSPACE_DEFAULT:
|
|
|
|
return TRUE;
|
|
|
|
case META_OUTPUT_COLORSPACE_BT2020:
|
|
|
|
return !!(colorimetry & META_EDID_COLORIMETRY_BT2020RGB);
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-02 00:32:38 +00:00
|
|
|
gboolean
|
|
|
|
meta_output_is_color_space_supported (MetaOutput *output,
|
|
|
|
MetaOutputColorspace color_space)
|
|
|
|
{
|
|
|
|
MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output);
|
|
|
|
|
2023-03-17 00:17:45 +00:00
|
|
|
if (!output_class->is_color_space_supported)
|
|
|
|
return FALSE;
|
2023-03-02 00:32:38 +00:00
|
|
|
|
2023-03-17 00:17:45 +00:00
|
|
|
return output_class->is_color_space_supported (output, color_space);
|
2023-03-02 00:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_output_set_color_space (MetaOutput *output,
|
|
|
|
MetaOutputColorspace color_space)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
priv->color_space = color_space;
|
|
|
|
|
|
|
|
g_signal_emit (output, signals[COLOR_SPACE_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaOutputColorspace
|
|
|
|
meta_output_peek_color_space (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return priv->color_space;
|
|
|
|
}
|
|
|
|
|
2023-09-06 15:30:00 +00:00
|
|
|
const char *
|
|
|
|
meta_output_colorspace_get_name (MetaOutputColorspace color_space)
|
|
|
|
{
|
|
|
|
switch (color_space)
|
|
|
|
{
|
|
|
|
case META_OUTPUT_COLORSPACE_UNKNOWN:
|
|
|
|
return "Unknown";
|
|
|
|
case META_OUTPUT_COLORSPACE_DEFAULT:
|
|
|
|
return "Default";
|
|
|
|
case META_OUTPUT_COLORSPACE_BT2020:
|
|
|
|
return "bt.2020";
|
|
|
|
}
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
2023-03-02 00:32:38 +00:00
|
|
|
gboolean
|
2023-03-02 18:49:36 +00:00
|
|
|
meta_output_is_hdr_metadata_supported (MetaOutput *output,
|
|
|
|
MetaOutputHdrMetadataEOTF eotf)
|
2023-03-02 00:32:38 +00:00
|
|
|
{
|
|
|
|
MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output);
|
2023-03-02 18:49:36 +00:00
|
|
|
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
|
|
|
MetaEdidTransferFunction tf = 0;
|
|
|
|
|
|
|
|
g_assert (output_info != NULL);
|
|
|
|
if (!output_info->edid_info)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ((output_info->edid_info->hdr_static_metadata.sm &
|
|
|
|
META_EDID_STATIC_METADATA_TYPE1) == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (eotf)
|
|
|
|
{
|
|
|
|
case META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR:
|
|
|
|
tf = META_EDID_TF_TRADITIONAL_GAMMA_SDR;
|
|
|
|
break;
|
|
|
|
case META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_HDR:
|
|
|
|
tf = META_EDID_TF_TRADITIONAL_GAMMA_HDR;
|
|
|
|
break;
|
|
|
|
case META_OUTPUT_HDR_METADATA_EOTF_PQ:
|
|
|
|
tf = META_EDID_TF_PQ;
|
|
|
|
break;
|
|
|
|
case META_OUTPUT_HDR_METADATA_EOTF_HLG:
|
|
|
|
tf = META_EDID_TF_HLG;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((output_info->edid_info->hdr_static_metadata.tf & tf) == 0)
|
|
|
|
return FALSE;
|
2023-03-02 00:32:38 +00:00
|
|
|
|
|
|
|
if (!output_class->is_hdr_metadata_supported)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return output_class->is_hdr_metadata_supported (output);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_output_set_hdr_metadata (MetaOutput *output,
|
|
|
|
MetaOutputHdrMetadata *metadata)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
priv->hdr_metadata = *metadata;
|
|
|
|
|
|
|
|
g_signal_emit (output, signals[HDR_METADATA_CHANGED], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaOutputHdrMetadata *
|
|
|
|
meta_output_peek_hdr_metadata (MetaOutput *output)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
return &priv->hdr_metadata;
|
|
|
|
}
|
|
|
|
|
2017-03-24 09:35:51 +00:00
|
|
|
static void
|
|
|
|
meta_output_init (MetaOutput *output)
|
|
|
|
{
|
2020-02-25 17:37:21 +00:00
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
|
|
|
|
priv->backlight = -1;
|
2023-03-15 12:28:52 +00:00
|
|
|
priv->color_space = META_OUTPUT_COLORSPACE_DEFAULT;
|
2023-03-02 00:32:38 +00:00
|
|
|
priv->hdr_metadata.active = FALSE;
|
2017-03-24 09:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_output_class_init (MetaOutputClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2020-02-25 09:54:40 +00:00
|
|
|
object_class->set_property = meta_output_set_property;
|
|
|
|
object_class->get_property = meta_output_get_property;
|
2017-11-03 10:27:57 +00:00
|
|
|
object_class->dispose = meta_output_dispose;
|
2017-03-24 09:35:51 +00:00
|
|
|
object_class->finalize = meta_output_finalize;
|
2020-02-25 09:54:40 +00:00
|
|
|
|
2020-02-25 15:13:52 +00:00
|
|
|
obj_props[PROP_ID] =
|
2023-06-28 12:02:43 +00:00
|
|
|
g_param_spec_uint64 ("id", NULL, NULL,
|
2020-02-25 15:13:52 +00:00
|
|
|
0, UINT64_MAX, 0,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2020-02-25 09:54:40 +00:00
|
|
|
obj_props[PROP_GPU] =
|
2023-06-28 12:02:43 +00:00
|
|
|
g_param_spec_object ("gpu", NULL, NULL,
|
2020-02-25 09:54:40 +00:00
|
|
|
META_TYPE_GPU,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2020-02-26 08:45:07 +00:00
|
|
|
obj_props[PROP_INFO] =
|
2023-06-28 12:02:43 +00:00
|
|
|
g_param_spec_boxed ("info", NULL, NULL,
|
2020-02-26 08:45:07 +00:00
|
|
|
META_TYPE_OUTPUT_INFO,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2022-12-20 11:15:25 +00:00
|
|
|
obj_props[PROP_IS_PRIVACY_SCREEN_ENABLED] =
|
2023-06-28 12:02:43 +00:00
|
|
|
g_param_spec_boolean ("is-privacy-screen-enabled", NULL, NULL,
|
2022-12-20 11:15:25 +00:00
|
|
|
FALSE,
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2020-02-25 09:54:40 +00:00
|
|
|
g_object_class_install_properties (object_class, N_PROPS, obj_props);
|
2023-03-02 00:32:38 +00:00
|
|
|
|
|
|
|
signals[COLOR_SPACE_CHANGED] =
|
|
|
|
g_signal_new ("color-space-changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
signals[HDR_METADATA_CHANGED] =
|
|
|
|
g_signal_new ("hdr-metadata-changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 0);
|
2017-03-24 09:35:51 +00:00
|
|
|
}
|
2020-07-31 19:37:17 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_tile_info_equal (MetaTileInfo *a,
|
|
|
|
MetaTileInfo *b)
|
|
|
|
{
|
|
|
|
if (a == b)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (a->group_id != b->group_id)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->flags != b->flags)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->max_h_tiles != b->max_h_tiles)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->max_v_tiles != b->max_v_tiles)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->loc_h_tile != b->loc_h_tile)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->loc_v_tile != b->loc_v_tile)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->tile_w != b->tile_w)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (a->tile_h != b->tile_h)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2021-12-16 10:25:37 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_output_update_modes (MetaOutput *output,
|
|
|
|
MetaCrtcMode *preferred_mode,
|
|
|
|
MetaCrtcMode **modes,
|
|
|
|
int n_modes)
|
|
|
|
{
|
|
|
|
MetaOutputPrivate *priv = meta_output_get_instance_private (output);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < priv->info->n_modes; i++)
|
|
|
|
g_object_unref (priv->info->modes[i]);
|
|
|
|
g_free (priv->info->modes);
|
|
|
|
|
|
|
|
priv->info->preferred_mode = preferred_mode;
|
|
|
|
priv->info->modes = modes;
|
|
|
|
priv->info->n_modes = n_modes;
|
|
|
|
}
|