Skip to content

Commit c265f34

Browse files
Harry Wentlandalexdeucher
authored andcommitted
drm/connector: Allow drivers to pass list of supported colorspaces
Drivers might not support all colorspaces defined in dp_colorspaces and hdmi_colorspaces. This results in undefined behavior when userspace is setting an unsupported colorspace. Allow drivers to pass the list of supported colorspaces when creating the colorspace property. v2: - Use 0 to indicate support for all colorspaces (Jani) - Print drm_dbg_kms message when drivers pass 0 to signal that drivers should specify supported colorspaecs explicity (Jani) v3: - Move changes to create a common colorspace_names array to separate patch v6: - Avoid magic when passing 0 for supported_colorspaces; be explicit in treating it as "all DP/HDMI" Signed-off-by: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com> Reviewed-by: Joshua Ashton <joshua@froggi.es> Reviewed-by: Simon Ser <contact@emersion.fr> Cc: Pekka Paalanen <ppaalanen@gmail.com> Cc: Sebastian Wick <sebastian.wick@redhat.com> Cc: Vitaly.Prosyak@amd.com Cc: Uma Shankar <uma.shankar@intel.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Joshua Ashton <joshua@froggi.es> Cc: Jani Nikula <jani.nikula@linux.intel.com> Cc: Simon Ser <contact@emersion.fr> Cc: Melissa Wen <mwen@igalia.com> Cc: dri-devel@lists.freedesktop.org Cc: amd-gfx@lists.freedesktop.org Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 035d53e commit c265f34

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

drivers/gpu/drm/drm_connector.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,9 +2210,17 @@ static int drm_mode_create_colorspace_property(struct drm_connector *connector,
22102210
* Returns:
22112211
* Zero on success, negative errno on failure.
22122212
*/
2213-
int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector)
2213+
int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector,
2214+
u32 supported_colorspaces)
22142215
{
2215-
return drm_mode_create_colorspace_property(connector, hdmi_colorspaces);
2216+
u32 colorspaces;
2217+
2218+
if (supported_colorspaces)
2219+
colorspaces = supported_colorspaces & hdmi_colorspaces;
2220+
else
2221+
colorspaces = hdmi_colorspaces;
2222+
2223+
return drm_mode_create_colorspace_property(connector, colorspaces);
22162224
}
22172225
EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property);
22182226

@@ -2226,9 +2234,17 @@ EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property);
22262234
* Returns:
22272235
* Zero on success, negative errno on failure.
22282236
*/
2229-
int drm_mode_create_dp_colorspace_property(struct drm_connector *connector)
2237+
int drm_mode_create_dp_colorspace_property(struct drm_connector *connector,
2238+
u32 supported_colorspaces)
22302239
{
2231-
return drm_mode_create_colorspace_property(connector, dp_colorspaces);
2240+
u32 colorspaces;
2241+
2242+
if (supported_colorspaces)
2243+
colorspaces = supported_colorspaces & dp_colorspaces;
2244+
else
2245+
colorspaces = dp_colorspaces;
2246+
2247+
return drm_mode_create_colorspace_property(connector, colorspaces);
22322248
}
22332249
EXPORT_SYMBOL(drm_mode_create_dp_colorspace_property);
22342250

drivers/gpu/drm/i915/display/intel_connector.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,14 @@ intel_attach_aspect_ratio_property(struct drm_connector *connector)
280280
void
281281
intel_attach_hdmi_colorspace_property(struct drm_connector *connector)
282282
{
283-
if (!drm_mode_create_hdmi_colorspace_property(connector))
283+
if (!drm_mode_create_hdmi_colorspace_property(connector, 0))
284284
drm_connector_attach_colorspace_property(connector);
285285
}
286286

287287
void
288288
intel_attach_dp_colorspace_property(struct drm_connector *connector)
289289
{
290-
if (!drm_mode_create_dp_colorspace_property(connector))
290+
if (!drm_mode_create_dp_colorspace_property(connector, 0))
291291
drm_connector_attach_colorspace_property(connector);
292292
}
293293

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,
631631
if (ret)
632632
return ret;
633633

634-
ret = drm_mode_create_hdmi_colorspace_property(connector);
634+
ret = drm_mode_create_hdmi_colorspace_property(connector, 0);
635635
if (ret)
636636
return ret;
637637

include/drm/drm_connector.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/notifier.h>
3131
#include <drm/drm_mode_object.h>
3232
#include <drm/drm_util.h>
33+
#include <drm/drm_property.h>
3334

3435
#include <uapi/drm/drm_mode.h>
3536

@@ -1994,8 +1995,10 @@ int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *conn
19941995
bool drm_connector_atomic_hdr_metadata_equal(struct drm_connector_state *old_state,
19951996
struct drm_connector_state *new_state);
19961997
int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
1997-
int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector);
1998-
int drm_mode_create_dp_colorspace_property(struct drm_connector *connector);
1998+
int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector,
1999+
u32 supported_colorspaces);
2000+
int drm_mode_create_dp_colorspace_property(struct drm_connector *connector,
2001+
u32 supported_colorspaces);
19992002
int drm_mode_create_content_type_property(struct drm_device *dev);
20002003
int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
20012004

0 commit comments

Comments
 (0)