]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drm/connector: Pull out common create_colorspace_property code
authorHarry Wentland <harry.wentland@amd.com>
Wed, 30 Nov 2022 19:42:03 +0000 (14:42 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 16:46:28 +0000 (12:46 -0400)
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>
drivers/gpu/drm/drm_connector.c

index 48df7a5ea503fbce0033f1daa2dcab46c716dd4b..614dd9fd4d3f7a23feb9ff02e870bb96e6529a8e 100644 (file)
@@ -2135,33 +2135,44 @@ EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
  * drm_mode_create_dp_colorspace_property() is used for DP connector.
  */
 
-/**
- * drm_mode_create_hdmi_colorspace_property - create hdmi colorspace property
- * @connector: connector to create the Colorspace property on.
- *
- * Called by a driver the first time it's needed, must be attached to desired
- * HDMI connectors.
- *
- * Returns:
- * Zero on success, negative errno on failure.
- */
-int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector)
+static int drm_mode_create_colorspace_property(struct drm_connector *connector,
+                                       const struct drm_prop_enum_list *colorspaces,
+                                       int size)
 {
        struct drm_device *dev = connector->dev;
 
        if (connector->colorspace_property)
                return 0;
 
+       if (!colorspaces)
+               return 0;
+
        connector->colorspace_property =
                drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, "Colorspace",
-                                        hdmi_colorspaces,
-                                        ARRAY_SIZE(hdmi_colorspaces));
+                                       colorspaces,
+                                       size);
 
        if (!connector->colorspace_property)
                return -ENOMEM;
 
        return 0;
 }
+/**
+ * drm_mode_create_hdmi_colorspace_property - create hdmi colorspace property
+ * @connector: connector to create the Colorspace property on.
+ *
+ * Called by a driver the first time it's needed, must be attached to desired
+ * HDMI connectors.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector)
+{
+       return drm_mode_create_colorspace_property(connector,
+                                                  hdmi_colorspaces,
+                                                  ARRAY_SIZE(hdmi_colorspaces));
+}
 EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property);
 
 /**
@@ -2176,20 +2187,9 @@ EXPORT_SYMBOL(drm_mode_create_hdmi_colorspace_property);
  */
 int drm_mode_create_dp_colorspace_property(struct drm_connector *connector)
 {
-       struct drm_device *dev = connector->dev;
-
-       if (connector->colorspace_property)
-               return 0;
-
-       connector->colorspace_property =
-               drm_property_create_enum(dev, DRM_MODE_PROP_ENUM, "Colorspace",
-                                        dp_colorspaces,
-                                        ARRAY_SIZE(dp_colorspaces));
-
-       if (!connector->colorspace_property)
-               return -ENOMEM;
-
-       return 0;
+       return drm_mode_create_colorspace_property(connector,
+                                                  dp_colorspaces,
+                                                  ARRAY_SIZE(dp_colorspaces));
 }
 EXPORT_SYMBOL(drm_mode_create_dp_colorspace_property);