output: Move edid parse function to the right file

Move the edid parsing function from MetaMonitorManager to MetaOutput
to read the monitor manufacturer,serial,vendor,etc.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1516/
This commit is contained in:
Uday Kiran Pichika 2020-10-21 11:01:08 +05:30
parent cd52288ddc
commit 9d0bac0754
4 changed files with 66 additions and 69 deletions

View File

@ -144,8 +144,7 @@ struct _MetaMonitorManager
* MetaMonitorManagerClass:
*
* @read_edid: Returns the raw Extended Display Identification Data (EDID)
* for the given #MetaOutput object. Use meta_output_parse_edid() to parse
* afterwards.
* for the given #MetaOutput object.
*
* @ensure_initial_config: Called on setup. Makes sure an initial config
* is loaded.
@ -307,10 +306,6 @@ void meta_monitor_manager_power_save_mode_changed (MetaMonitorMan
void meta_monitor_manager_confirm_configuration (MetaMonitorManager *manager,
gboolean ok);
void meta_output_parse_edid (MetaOutput *output,
GBytes *edid);
gboolean meta_output_is_laptop (MetaOutput *output);
gboolean meta_monitor_manager_has_hotplug_mode_update (MetaMonitorManager *manager);
META_EXPORT_TEST

View File

@ -45,7 +45,6 @@
#include <math.h>
#include <stdlib.h>
#include "backends/edid.h"
#include "backends/meta-backend-private.h"
#include "backends/meta-crtc.h"
#include "backends/meta-logical-monitor.h"
@ -3031,68 +3030,6 @@ meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
g_list_free_full (old_logical_monitors, g_object_unref);
}
void
meta_output_info_parse_edid (MetaOutputInfo *output_info,
GBytes *edid)
{
MonitorInfo *parsed_edid;
gsize len;
if (!edid)
goto out;
parsed_edid = decode_edid (g_bytes_get_data (edid, &len));
if (parsed_edid)
{
output_info->vendor = g_strndup (parsed_edid->manufacturer_code, 4);
if (!g_utf8_validate (output_info->vendor, -1, NULL))
g_clear_pointer (&output_info->vendor, g_free);
output_info->product = g_strndup (parsed_edid->dsc_product_name, 14);
if (!g_utf8_validate (output_info->product, -1, NULL) ||
output_info->product[0] == '\0')
{
g_clear_pointer (&output_info->product, g_free);
output_info->product = g_strdup_printf ("0x%04x", (unsigned) parsed_edid->product_code);
}
output_info->serial = g_strndup (parsed_edid->dsc_serial_number, 14);
if (!g_utf8_validate (output_info->serial, -1, NULL) ||
output_info->serial[0] == '\0')
{
g_clear_pointer (&output_info->serial, g_free);
output_info->serial = g_strdup_printf ("0x%08x", parsed_edid->serial_number);
}
g_free (parsed_edid);
}
out:
if (!output_info->vendor)
output_info->vendor = g_strdup ("unknown");
if (!output_info->product)
output_info->product = g_strdup ("unknown");
if (!output_info->serial)
output_info->serial = g_strdup ("unknown");
}
gboolean
meta_output_is_laptop (MetaOutput *output)
{
const MetaOutputInfo *output_info = meta_output_get_info (output);
switch (output_info->connector_type)
{
case META_CONNECTOR_TYPE_eDP:
case META_CONNECTOR_TYPE_LVDS:
case META_CONNECTOR_TYPE_DSI:
return TRUE;
default:
return FALSE;
}
}
void
meta_monitor_manager_on_hotplug (MetaMonitorManager *manager)
{

View File

@ -19,6 +19,7 @@
#include "config.h"
#include "backends/edid.h"
#include "backends/meta-output.h"
enum
@ -241,6 +242,68 @@ meta_output_crtc_to_logical_transform (MetaOutput *output,
inverted_panel_orientation_transform);
}
void
meta_output_info_parse_edid (MetaOutputInfo *output_info,
GBytes *edid)
{
MonitorInfo *parsed_edid;
size_t len;
if (!edid)
goto out;
parsed_edid = decode_edid (g_bytes_get_data (edid, &len));
if (parsed_edid)
{
output_info->vendor = g_strndup (parsed_edid->manufacturer_code, 4);
if (!g_utf8_validate (output_info->vendor, -1, NULL))
g_clear_pointer (&output_info->vendor, g_free);
output_info->product = g_strndup (parsed_edid->dsc_product_name, 14);
if (!g_utf8_validate (output_info->product, -1, NULL) ||
output_info->product[0] == '\0')
{
g_clear_pointer (&output_info->product, g_free);
output_info->product = g_strdup_printf ("0x%04x", (unsigned) parsed_edid->product_code);
}
output_info->serial = g_strndup (parsed_edid->dsc_serial_number, 14);
if (!g_utf8_validate (output_info->serial, -1, NULL) ||
output_info->serial[0] == '\0')
{
g_clear_pointer (&output_info->serial, g_free);
output_info->serial = g_strdup_printf ("0x%08x", parsed_edid->serial_number);
}
g_free (parsed_edid);
}
out:
if (!output_info->vendor)
output_info->vendor = g_strdup ("unknown");
if (!output_info->product)
output_info->product = g_strdup ("unknown");
if (!output_info->serial)
output_info->serial = g_strdup ("unknown");
}
gboolean
meta_output_is_laptop (MetaOutput *output)
{
const MetaOutputInfo *output_info = meta_output_get_info (output);
switch (output_info->connector_type)
{
case META_CONNECTOR_TYPE_eDP:
case META_CONNECTOR_TYPE_LVDS:
case META_CONNECTOR_TYPE_DSI:
return TRUE;
default:
return FALSE;
}
}
static void
meta_output_set_property (GObject *object,
guint prop_id,

View File

@ -118,6 +118,8 @@ META_EXPORT_TEST
void meta_output_info_parse_edid (MetaOutputInfo *output_info,
GBytes *edid);
gboolean meta_output_is_laptop (MetaOutput *output);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaOutputInfo, meta_output_info_unref)
#define META_TYPE_OUTPUT (meta_output_get_type ())