[mutter] kms-connector: Add "max bpc" property



commit 33ee155630da652b8bbe319f89f976b5da5b9476
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Fri May 13 16:20:57 2022 +0800

    kms-connector: Add "max bpc" property
    
    This limits the bits-per-channel colour depth of the signal that
    the connector is allowed to output.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>

 src/backends/native/meta-kms-connector-private.h |  1 +
 src/backends/native/meta-kms-connector.c         | 31 ++++++++++++++++++++++++
 src/backends/native/meta-kms-connector.h         |  4 +++
 3 files changed, 36 insertions(+)
---
diff --git a/src/backends/native/meta-kms-connector-private.h 
b/src/backends/native/meta-kms-connector-private.h
index e1d9b44cd5..73757a8fca 100644
--- a/src/backends/native/meta-kms-connector-private.h
+++ b/src/backends/native/meta-kms-connector-private.h
@@ -39,6 +39,7 @@ typedef enum _MetaKmsConnectorProp
   META_KMS_CONNECTOR_PROP_SCALING_MODE,
   META_KMS_CONNECTOR_PROP_PANEL_ORIENTATION,
   META_KMS_CONNECTOR_PROP_NON_DESKTOP,
+  META_KMS_CONNECTOR_PROP_MAX_BPC,
   META_KMS_CONNECTOR_N_PROPS
 } MetaKmsConnectorProp;
 
diff --git a/src/backends/native/meta-kms-connector.c b/src/backends/native/meta-kms-connector.c
index 724f96e36f..2bc3372917 100644
--- a/src/backends/native/meta-kms-connector.c
+++ b/src/backends/native/meta-kms-connector.c
@@ -190,6 +190,19 @@ has_privacy_screen_software_toggle (MetaKmsConnector *connector)
     META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_SW_STATE) != 0;
 }
 
+const MetaKmsRange *
+meta_kms_connector_get_max_bpc (MetaKmsConnector *connector)
+{
+  const MetaKmsRange *range = NULL;
+
+  if (connector->current_state &&
+      meta_kms_connector_get_prop_id (connector,
+                                      META_KMS_CONNECTOR_PROP_MAX_BPC))
+    range = &connector->current_state->max_bpc;
+
+  return range;
+}
+
 static void
 sync_fd_held (MetaKmsConnector  *connector,
               MetaKmsImplDevice *impl_device)
@@ -308,6 +321,14 @@ state_set_properties (MetaKmsConnectorState *state,
   prop = &props[META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_HW_STATE];
   if (prop->prop_id)
     set_privacy_screen (state, connector, prop);
+
+  prop = &props[META_KMS_CONNECTOR_PROP_MAX_BPC];
+  if (prop->prop_id)
+    {
+      state->max_bpc.value = prop->value;
+      state->max_bpc.min_value = prop->range_min;
+      state->max_bpc.max_value = prop->range_max;
+    }
 }
 
 static CoglSubpixelOrder
@@ -622,6 +643,11 @@ meta_kms_connector_state_changes (MetaKmsConnectorState *state,
   if (!kms_modes_equal (state->modes, new_state->modes))
     return META_KMS_RESOURCE_CHANGE_FULL;
 
+  if (state->max_bpc.value != new_state->max_bpc.value ||
+      state->max_bpc.min_value != new_state->max_bpc.min_value ||
+      state->max_bpc.max_value != new_state->max_bpc.max_value)
+    return META_KMS_RESOURCE_CHANGE_FULL;
+
   if (state->privacy_screen_state != new_state->privacy_screen_state)
     return META_KMS_RESOURCE_CHANGE_PRIVACY_SCREEN;
 
@@ -940,6 +966,11 @@ init_properties (MetaKmsConnector  *connector,
           .name = "non-desktop",
           .type = DRM_MODE_PROP_RANGE,
         },
+      [META_KMS_CONNECTOR_PROP_MAX_BPC] =
+        {
+          .name = "max bpc",
+          .type = DRM_MODE_PROP_RANGE,
+        },
     },
     .dpms_enum = {
       [META_KMS_CONNECTOR_DPMS_ON] =
diff --git a/src/backends/native/meta-kms-connector.h b/src/backends/native/meta-kms-connector.h
index c2b763548e..bbd59d3423 100644
--- a/src/backends/native/meta-kms-connector.h
+++ b/src/backends/native/meta-kms-connector.h
@@ -59,6 +59,8 @@ typedef struct _MetaKmsConnectorState
   gboolean hotplug_mode_update;
 
   MetaMonitorTransform panel_orientation_transform;
+
+  MetaKmsRange max_bpc;
 } MetaKmsConnectorState;
 
 META_EXPORT_TEST
@@ -83,4 +85,6 @@ gboolean meta_kms_connector_is_underscanning_supported (MetaKmsConnector *connec
 
 gboolean meta_kms_connector_is_privacy_screen_supported (MetaKmsConnector *connector);
 
+const MetaKmsRange * meta_kms_connector_get_max_bpc (MetaKmsConnector *connector);
+
 #endif /* META_KMS_CONNECTOR_H */


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