drm/connector: Create a helper to attach the hdr_output_metadata property
authorMaxime Ripard <maxime@cerno.tech>
Fri, 30 Apr 2021 09:44:47 +0000 (11:44 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Fri, 7 May 2021 15:13:04 +0000 (17:13 +0200)
All the drivers that implement HDR output call pretty much the same
function to initialise the hdr_output_metadata property, and while the
creation of that property is in a helper, every driver uses the same
code to attach it.

Provide a helper for it as well

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20210430094451.2145002-1-maxime@cerno.tech
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
drivers/gpu/drm/drm_connector.c
drivers/gpu/drm/i915/display/intel_hdmi.c
include/drm/drm_connector.h

index a0c8c41e4e57ee204cdfb6d629b4a660c2cb273d..c8d7e7dbc05ef9c46875854e40a5ec2d48cf9de7 100644 (file)
@@ -7498,9 +7498,7 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
        if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
            connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
            connector_type == DRM_MODE_CONNECTOR_eDP) {
-               drm_object_attach_property(
-                       &aconnector->base.base,
-                       dm->ddev->mode_config.hdr_output_metadata_property, 0);
+               drm_connector_attach_hdr_output_metadata_property(&aconnector->base);
 
                if (!aconnector->mst_port)
                        drm_connector_attach_vrr_capable_property(&aconnector->base);
index ae97513ef886d879075deae7241abfdae6b92db0..dd7f6eda2ce2f546170409ad72f19b2aef994116 100644 (file)
@@ -2492,8 +2492,7 @@ static int dw_hdmi_connector_create(struct dw_hdmi *hdmi)
        drm_connector_attach_max_bpc_property(connector, 8, 16);
 
        if (hdmi->version >= 0x200a && hdmi->plat_data->use_drm_infoframe)
-               drm_object_attach_property(&connector->base,
-                       connector->dev->mode_config.hdr_output_metadata_property, 0);
+               drm_connector_attach_hdr_output_metadata_property(connector);
 
        drm_connector_attach_encoder(connector, hdmi->bridge.encoder);
 
index 9de145351546d17f7539720f73cb3cb93956d6af..7eb7b6db515fe61ccbb04562fecea8982f55fc32 100644 (file)
@@ -2152,6 +2152,27 @@ int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_connector_attach_max_bpc_property);
 
+/**
+ * drm_connector_attach_hdr_output_metadata_property - attach "HDR_OUTPUT_METADA" property
+ * @connector: connector to attach the property on.
+ *
+ * This is used to allow the userspace to send HDR Metadata to the
+ * driver.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector)
+{
+       struct drm_device *dev = connector->dev;
+       struct drm_property *prop = dev->mode_config.hdr_output_metadata_property;
+
+       drm_object_attach_property(&connector->base, prop, 0);
+
+       return 0;
+}
+EXPORT_SYMBOL(drm_connector_attach_hdr_output_metadata_property);
+
 /**
  * drm_connector_set_vrr_capable_property - sets the variable refresh rate
  * capable property for a connector
index 9c172dd6fb5b69fd2a85c7faff358b8a1dc8a477..3c767bcc47b149c67d3d22e6b213406ce7849013 100644 (file)
@@ -2459,8 +2459,7 @@ intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *c
        drm_connector_attach_content_type_property(connector);
 
        if (DISPLAY_VER(dev_priv) >= 10)
-               drm_object_attach_property(&connector->base,
-                       connector->dev->mode_config.hdr_output_metadata_property, 0);
+               drm_connector_attach_hdr_output_metadata_property(connector);
 
        if (!HAS_GMCH(dev_priv))
                drm_connector_attach_max_bpc_property(connector, 8, 12);
index 1922b278ffadfdb185312b979f617b3f1f328286..32172dab84279fadee6761248acd67c1f234032e 100644 (file)
@@ -1671,6 +1671,7 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
                                               u32 scaling_mode_mask);
 int drm_connector_attach_vrr_capable_property(
                struct drm_connector *connector);
+int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector);
 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
 int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector);
 int drm_mode_create_dp_colorspace_property(struct drm_connector *connector);