5ccff1866ac31ff8b48156e57b138f9a5ac2355b
[openwrt/staging/stintel.git] /
1 From c65eada45c578cfb558ee9a92ce5048a367692d7 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Fri, 19 Mar 2021 11:21:41 +0100
4 Subject: [PATCH] drm/connector: Create a helper to attach the
5 hdr_output_metadata property
6
7 All the drivers that implement HDR output call pretty much the same
8 function to initialise the hdr_output_metadata property, and while the
9 creation of that property is in a helper, every driver uses the same
10 code to attach it.
11
12 Provide a helper for it as well
13
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 ---
16 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 +---
17 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 3 +--
18 drivers/gpu/drm/drm_connector.c | 21 +++++++++++++++++++
19 drivers/gpu/drm/i915/display/intel_hdmi.c | 3 +--
20 include/drm/drm_connector.h | 1 +
21 5 files changed, 25 insertions(+), 7 deletions(-)
22
23 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
24 +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
25 @@ -6532,9 +6532,7 @@ void amdgpu_dm_connector_init_helper(str
26 if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
27 connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
28 connector_type == DRM_MODE_CONNECTOR_eDP) {
29 - drm_object_attach_property(
30 - &aconnector->base.base,
31 - dm->ddev->mode_config.hdr_output_metadata_property, 0);
32 + drm_connector_attach_hdr_output_metadata_property(&aconnector->base);
33
34 if (!aconnector->mst_port)
35 drm_connector_attach_vrr_capable_property(&aconnector->base);
36 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
37 +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
38 @@ -2500,8 +2500,7 @@ static int dw_hdmi_connector_create(stru
39 drm_connector_attach_max_bpc_property(connector, 8, 16);
40
41 if (hdmi->version >= 0x200a && hdmi->plat_data->use_drm_infoframe)
42 - drm_object_attach_property(&connector->base,
43 - connector->dev->mode_config.hdr_output_metadata_property, 0);
44 + drm_connector_attach_hdr_output_metadata_property(connector);
45
46 drm_connector_attach_encoder(connector, hdmi->bridge.encoder);
47
48 --- a/drivers/gpu/drm/drm_connector.c
49 +++ b/drivers/gpu/drm/drm_connector.c
50 @@ -2144,6 +2144,27 @@ int drm_connector_attach_max_bpc_propert
51 EXPORT_SYMBOL(drm_connector_attach_max_bpc_property);
52
53 /**
54 + * drm_connector_attach_hdr_output_metadata_property - attach "HDR_OUTPUT_METADA" property
55 + * @connector: connector to attach the property on.
56 + *
57 + * This is used to allow the userspace to send HDR Metadata to the
58 + * driver.
59 + *
60 + * Returns:
61 + * Zero on success, negative errno on failure.
62 + */
63 +int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector)
64 +{
65 + struct drm_device *dev = connector->dev;
66 + struct drm_property *prop = dev->mode_config.hdr_output_metadata_property;
67 +
68 + drm_object_attach_property(&connector->base, prop, 0);
69 +
70 + return 0;
71 +}
72 +EXPORT_SYMBOL(drm_connector_attach_hdr_output_metadata_property);
73 +
74 +/**
75 * drm_connector_set_vrr_capable_property - sets the variable refresh rate
76 * capable property for a connector
77 * @connector: drm connector
78 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
79 +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
80 @@ -2971,8 +2971,7 @@ intel_hdmi_add_properties(struct intel_h
81 drm_connector_attach_content_type_property(connector);
82
83 if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv))
84 - drm_object_attach_property(&connector->base,
85 - connector->dev->mode_config.hdr_output_metadata_property, 0);
86 + drm_connector_attach_hdr_output_metadata_property(connector);
87
88 if (!HAS_GMCH(dev_priv))
89 drm_connector_attach_max_bpc_property(connector, 8, 12);
90 --- a/include/drm/drm_connector.h
91 +++ b/include/drm/drm_connector.h
92 @@ -1622,6 +1622,7 @@ int drm_connector_attach_scaling_mode_pr
93 u32 scaling_mode_mask);
94 int drm_connector_attach_vrr_capable_property(
95 struct drm_connector *connector);
96 +int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector);
97 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
98 int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector);
99 int drm_mode_create_dp_colorspace_property(struct drm_connector *connector);