[mutter/gbsneto/underscan: 4/4] monitor-manager: only support underscan when mode allows it



commit 9709b93d02abffd0b94db970a2a21a8e5b17bb14
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Tue Jun 28 13:46:21 2016 -0700

    monitor-manager: only support underscan when mode allows it
    
    Underscan should only be available for certain modes; in particular, it
    should only be available for HDMI displays with a compatible resolution.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767804
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/549

 src/backends/meta-monitor-manager.c   | 29 +----------------------------
 src/backends/meta-output.c            | 27 +++++++++++++++++++++++++++
 src/backends/meta-output.h            |  3 +++
 src/backends/x11/meta-output-xrandr.c | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 28 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 6f2460f27..391ae3d60 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -1032,33 +1032,6 @@ make_display_name (MetaMonitorManager *manager,
     }
 }
 
-static const char *
-get_connector_type_name (MetaConnectorType connector_type)
-{
-  switch (connector_type)
-    {
-    case META_CONNECTOR_TYPE_Unknown: return "Unknown";
-    case META_CONNECTOR_TYPE_VGA: return "VGA";
-    case META_CONNECTOR_TYPE_DVII: return "DVII";
-    case META_CONNECTOR_TYPE_DVID: return "DVID";
-    case META_CONNECTOR_TYPE_DVIA: return "DVIA";
-    case META_CONNECTOR_TYPE_Composite: return "Composite";
-    case META_CONNECTOR_TYPE_SVIDEO: return "SVIDEO";
-    case META_CONNECTOR_TYPE_LVDS: return "LVDS";
-    case META_CONNECTOR_TYPE_Component: return "Component";
-    case META_CONNECTOR_TYPE_9PinDIN: return "9PinDIN";
-    case META_CONNECTOR_TYPE_DisplayPort: return "DisplayPort";
-    case META_CONNECTOR_TYPE_HDMIA: return "HDMIA";
-    case META_CONNECTOR_TYPE_HDMIB: return "HDMIB";
-    case META_CONNECTOR_TYPE_TV: return "TV";
-    case META_CONNECTOR_TYPE_eDP: return "eDP";
-    case META_CONNECTOR_TYPE_VIRTUAL: return "VIRTUAL";
-    case META_CONNECTOR_TYPE_DSI: return "DSI";
-    default: g_assert_not_reached ();
-    }
-  return NULL;
-}
-
 static GList *
 combine_gpu_lists (MetaMonitorManager    *manager,
                    GList              * (*list_getter) (MetaGpu *gpu))
@@ -1187,7 +1160,7 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
       g_variant_builder_add (&properties, "{sv}", "presentation",
                              g_variant_new_boolean (output->is_presentation));
       g_variant_builder_add (&properties, "{sv}", "connector-type",
-                             g_variant_new_string (get_connector_type_name (output->connector_type)));
+                             g_variant_new_string (meta_output_get_connector_type_name (output)));
       g_variant_builder_add (&properties, "{sv}", "underscanning",
                              g_variant_new_boolean (output->is_underscanning));
       g_variant_builder_add (&properties, "{sv}", "supports-underscanning",
diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c
index 2139a17a3..632e0a6dd 100644
--- a/src/backends/meta-output.c
+++ b/src/backends/meta-output.c
@@ -29,6 +29,33 @@ typedef struct _MetaOutputPrivate
 
 G_DEFINE_TYPE_WITH_PRIVATE (MetaOutput, meta_output, G_TYPE_OBJECT)
 
+const char *
+meta_output_get_connector_type_name (MetaOutput *output)
+{
+  switch (output->connector_type)
+    {
+    case META_CONNECTOR_TYPE_Unknown: return "Unknown";
+    case META_CONNECTOR_TYPE_VGA: return "VGA";
+    case META_CONNECTOR_TYPE_DVII: return "DVII";
+    case META_CONNECTOR_TYPE_DVID: return "DVID";
+    case META_CONNECTOR_TYPE_DVIA: return "DVIA";
+    case META_CONNECTOR_TYPE_Composite: return "Composite";
+    case META_CONNECTOR_TYPE_SVIDEO: return "SVIDEO";
+    case META_CONNECTOR_TYPE_LVDS: return "LVDS";
+    case META_CONNECTOR_TYPE_Component: return "Component";
+    case META_CONNECTOR_TYPE_9PinDIN: return "9PinDIN";
+    case META_CONNECTOR_TYPE_DisplayPort: return "DisplayPort";
+    case META_CONNECTOR_TYPE_HDMIA: return "HDMIA";
+    case META_CONNECTOR_TYPE_HDMIB: return "HDMIB";
+    case META_CONNECTOR_TYPE_TV: return "TV";
+    case META_CONNECTOR_TYPE_eDP: return "eDP";
+    case META_CONNECTOR_TYPE_VIRTUAL: return "VIRTUAL";
+    case META_CONNECTOR_TYPE_DSI: return "DSI";
+    default: g_assert_not_reached ();
+    }
+  return NULL;
+}
+
 MetaGpu *
 meta_output_get_gpu (MetaOutput *output)
 {
diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h
index 95f66af74..4b5ae0008 100644
--- a/src/backends/meta-output.h
+++ b/src/backends/meta-output.h
@@ -138,4 +138,7 @@ void meta_output_unassign_crtc (MetaOutput *output);
 META_EXPORT_TEST
 MetaCrtc * meta_output_get_assigned_crtc (MetaOutput *output);
 
+META_EXPORT_TEST
+const char *       meta_output_get_connector_type_name (MetaOutput *output);
+
 #endif /* META_OUTPUT_H */
diff --git a/src/backends/x11/meta-output-xrandr.c b/src/backends/x11/meta-output-xrandr.c
index e97890a49..74704341c 100644
--- a/src/backends/x11/meta-output-xrandr.c
+++ b/src/backends/x11/meta-output-xrandr.c
@@ -52,6 +52,32 @@ typedef struct
   int underscan_vborder;
 } MetaOutputXrandr;
 
+static gboolean
+output_is_hdtv (MetaOutput *output)
+{
+  MetaCrtc *crtc;
+  guint width, height;
+
+  crtc = meta_output_get_assigned_crtc (output);
+
+  if (!crtc || !crtc->current_mode)
+    return FALSE;
+
+  /* We must have an HDTV is underscan is already enabled */
+  if (output->is_underscanning)
+    return TRUE;
+
+  if (!g_str_has_prefix (meta_output_get_connector_type_name (output), "HDMI"))
+    return FALSE;
+
+  width = crtc->current_mode->width;
+  height = crtc->current_mode->height;
+
+  return ((width == 1920 && height == 1080) ||
+          (width == 1440 && height == 1080) ||
+          (width == 1280 && height == 720));
+}
+
 static void
 meta_output_xrandr_destroy_notify (MetaOutput *output)
 {
@@ -877,6 +903,12 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
   output_get_backlight_limits_xrandr (output);
   output_get_underscanning_borders_xrandr (output);
 
+  /* Override the 'supports underscanning' property for non HDTV sets.
+   * Note that we need to do this after checking if underscanning is on, so
+   * that we now the exact values for width and height to be checked. */
+  if (output->supports_underscanning && !output_is_hdtv (output))
+    output->supports_underscanning = FALSE;
+
   if (!(output->backlight_min == 0 && output->backlight_max == 0))
     output->backlight = output_get_backlight_xrandr (output);
   else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]