Merge branch 'drm-next-4.21' of git://people.freedesktop.org/~agd5f/linux into drm...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / drm_connector.c
index ead26bfc30cade822047c147e9893dccfc2a4581..da8ae80c27506d279fa7fd2419b34eb72a3b292f 100644 (file)
@@ -932,6 +932,13 @@ DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list)
  *       is no longer protected and userspace should take appropriate action
  *       (whatever that might be).
  *
+ * max bpc:
+ *     This range property is used by userspace to limit the bit depth. When
+ *     used the driver would limit the bpc in accordance with the valid range
+ *     supported by the hardware and sink. Drivers to use the function
+ *     drm_connector_attach_max_bpc_property() to create and attach the
+ *     property to the connector during initialization.
+ *
  * Connectors also have one standardized atomic property:
  *
  * CRTC_ID:
@@ -1698,6 +1705,40 @@ void drm_connector_set_link_status_property(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_connector_set_link_status_property);
 
+/**
+ * drm_connector_attach_max_bpc_property - attach "max bpc" property
+ * @connector: connector to attach max bpc property on.
+ * @min: The minimum bit depth supported by the connector.
+ * @max: The maximum bit depth supported by the connector.
+ *
+ * This is used to add support for limiting the bit depth on a connector.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
+                                         int min, int max)
+{
+       struct drm_device *dev = connector->dev;
+       struct drm_property *prop;
+
+       prop = connector->max_bpc_property;
+       if (!prop) {
+               prop = drm_property_create_range(dev, 0, "max bpc", min, max);
+               if (!prop)
+                       return -ENOMEM;
+
+               connector->max_bpc_property = prop;
+       }
+
+       drm_object_attach_property(&connector->base, prop, max);
+       connector->state->max_requested_bpc = max;
+       connector->state->max_bpc = max;
+
+       return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_max_bpc_property);
+
 /**
  * drm_connector_set_vrr_capable_property - sets the variable refresh rate
  * capable property for a connector