Commit c265f340 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

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: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarSebastian Wick <sebastian.wick@redhat.com>
Reviewed-by: default avatarJoshua Ashton <joshua@froggi.es>
Reviewed-by: default avatarSimon 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: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 035d53e0
...@@ -2210,9 +2210,17 @@ static int drm_mode_create_colorspace_property(struct drm_connector *connector, ...@@ -2210,9 +2210,17 @@ static int drm_mode_create_colorspace_property(struct drm_connector *connector,
* Returns: * Returns:
* Zero on success, negative errno on failure. * Zero on success, negative errno on failure.
*/ */
int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector) int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector,
u32 supported_colorspaces)
{ {
return drm_mode_create_colorspace_property(connector, hdmi_colorspaces); u32 colorspaces;
if (supported_colorspaces)
colorspaces = supported_colorspaces & hdmi_colorspaces;
else
colorspaces = hdmi_colorspaces;
return drm_mode_create_colorspace_property(connector, colorspaces);
} }
EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property); EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property);
...@@ -2226,9 +2234,17 @@ EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property); ...@@ -2226,9 +2234,17 @@ EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property);
* Returns: * Returns:
* Zero on success, negative errno on failure. * Zero on success, negative errno on failure.
*/ */
int drm_mode_create_dp_colorspace_property(struct drm_connector *connector) int drm_mode_create_dp_colorspace_property(struct drm_connector *connector,
u32 supported_colorspaces)
{ {
return drm_mode_create_colorspace_property(connector, dp_colorspaces); u32 colorspaces;
if (supported_colorspaces)
colorspaces = supported_colorspaces & dp_colorspaces;
else
colorspaces = dp_colorspaces;
return drm_mode_create_colorspace_property(connector, colorspaces);
} }
EXPORT_SYMBOL(drm_mode_create_dp_colorspace_property); EXPORT_SYMBOL(drm_mode_create_dp_colorspace_property);
......
...@@ -280,14 +280,14 @@ intel_attach_aspect_ratio_property(struct drm_connector *connector) ...@@ -280,14 +280,14 @@ intel_attach_aspect_ratio_property(struct drm_connector *connector)
void void
intel_attach_hdmi_colorspace_property(struct drm_connector *connector) intel_attach_hdmi_colorspace_property(struct drm_connector *connector)
{ {
if (!drm_mode_create_hdmi_colorspace_property(connector)) if (!drm_mode_create_hdmi_colorspace_property(connector, 0))
drm_connector_attach_colorspace_property(connector); drm_connector_attach_colorspace_property(connector);
} }
void void
intel_attach_dp_colorspace_property(struct drm_connector *connector) intel_attach_dp_colorspace_property(struct drm_connector *connector)
{ {
if (!drm_mode_create_dp_colorspace_property(connector)) if (!drm_mode_create_dp_colorspace_property(connector, 0))
drm_connector_attach_colorspace_property(connector); drm_connector_attach_colorspace_property(connector);
} }
......
...@@ -631,7 +631,7 @@ static int vc4_hdmi_connector_init(struct drm_device *dev, ...@@ -631,7 +631,7 @@ static int vc4_hdmi_connector_init(struct drm_device *dev,
if (ret) if (ret)
return ret; return ret;
ret = drm_mode_create_hdmi_colorspace_property(connector); ret = drm_mode_create_hdmi_colorspace_property(connector, 0);
if (ret) if (ret)
return ret; return ret;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/notifier.h> #include <linux/notifier.h>
#include <drm/drm_mode_object.h> #include <drm/drm_mode_object.h>
#include <drm/drm_util.h> #include <drm/drm_util.h>
#include <drm/drm_property.h>
#include <uapi/drm/drm_mode.h> #include <uapi/drm/drm_mode.h>
...@@ -1994,8 +1995,10 @@ int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *conn ...@@ -1994,8 +1995,10 @@ int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *conn
bool drm_connector_atomic_hdr_metadata_equal(struct drm_connector_state *old_state, bool drm_connector_atomic_hdr_metadata_equal(struct drm_connector_state *old_state,
struct drm_connector_state *new_state); struct drm_connector_state *new_state);
int drm_mode_create_aspect_ratio_property(struct drm_device *dev); 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_hdmi_colorspace_property(struct drm_connector *connector,
int drm_mode_create_dp_colorspace_property(struct drm_connector *connector); u32 supported_colorspaces);
int drm_mode_create_dp_colorspace_property(struct drm_connector *connector,
u32 supported_colorspaces);
int drm_mode_create_content_type_property(struct drm_device *dev); int drm_mode_create_content_type_property(struct drm_device *dev);
int drm_mode_create_suggested_offset_properties(struct drm_device *dev); int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment