diff options
author | Uday Kiran Pichika <pichika.uday.kiran@intel.com> | 2020-10-21 11:01:08 +0530 |
---|---|---|
committer | Uday Kiran Pichika <pichika.uday.kiran@intel.com> | 2020-10-21 17:04:44 +0530 |
commit | 9d0bac07547f739b22321a03906499275363d58f (patch) | |
tree | 440a3601327131db01047c6984c3d38210f5af42 /src | |
parent | cd52288ddcfd922510cc952437c777221816dc55 (diff) | |
download | mutter-9d0bac07547f739b22321a03906499275363d58f.tar.gz |
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/
Diffstat (limited to 'src')
-rw-r--r-- | src/backends/meta-monitor-manager-private.h | 7 | ||||
-rw-r--r-- | src/backends/meta-monitor-manager.c | 63 | ||||
-rw-r--r-- | src/backends/meta-output.c | 63 | ||||
-rw-r--r-- | src/backends/meta-output.h | 2 |
4 files changed, 66 insertions, 69 deletions
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index ac3bc94d6..b9c68aad4 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -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 diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index e1987abaa..4488ab32a 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -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" @@ -3032,68 +3031,6 @@ meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager, } 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) { meta_monitor_manager_ensure_configured (manager); diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c index 8071e5cb1..8f1131c0e 100644 --- a/src/backends/meta-output.c +++ b/src/backends/meta-output.c @@ -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, diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h index c10b5fec6..4f2d19337 100644 --- a/src/backends/meta-output.h +++ b/src/backends/meta-output.h @@ -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 ()) |