]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/connector: Add a new 'panel_type' property
authorMario Limonciello (AMD) <superm1@kernel.org>
Tue, 6 Jan 2026 17:00:16 +0000 (11:00 -0600)
committerMario Limonciello (AMD) <superm1@kernel.org>
Tue, 27 Jan 2026 18:57:24 +0000 (12:57 -0600)
If the driver can make an assertion whether a connected panel is an OLED
panel or not then it can attach a property to the connector that userspace
can use as a hint for color schemes.

Reviewed-by: Leo Li <sunpeng.li@amd.com>
Link: https://patch.msgid.link/20260106170017.68158-2-superm1@kernel.org
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
drivers/gpu/drm/drm_connector.c
include/drm/drm_connector.h
include/drm/drm_mode_config.h
include/uapi/drm/drm_mode.h

index 4f5b27fab475c7c733622eb8727927571f3fb8fe..aec05adbc8894bc785d962961c7c4099c8efe414 100644 (file)
@@ -1173,6 +1173,11 @@ static const struct drm_prop_enum_list drm_link_status_enum_list[] = {
        { DRM_MODE_LINK_STATUS_BAD, "Bad" },
 };
 
+static const struct drm_prop_enum_list drm_panel_type_enum_list[] = {
+       { DRM_MODE_PANEL_TYPE_UNKNOWN, "unknown" },
+       { DRM_MODE_PANEL_TYPE_OLED, "OLED" },
+};
+
 /**
  * drm_display_info_set_bus_formats - set the supported bus formats
  * @info: display info to store bus formats in
@@ -1501,6 +1506,9 @@ EXPORT_SYMBOL(drm_hdmi_connector_get_output_format_name);
  *     Summarizing: Only set "DPMS" when the connector is known to be enabled,
  *     assume that a successful SETCONFIG call also sets "DPMS" to on, and
  *     never read back the value of "DPMS" because it can be incorrect.
+ * panel_type:
+ *     Immutable enum property to indicate the type of connected panel.
+ *     Possible values are "unknown" (default) and "OLED".
  * PATH:
  *     Connector path property to identify how this sink is physically
  *     connected. Used by DP MST. This should be set by calling
@@ -1851,6 +1859,13 @@ int drm_connector_create_standard_properties(struct drm_device *dev)
                return -ENOMEM;
        dev->mode_config.link_status_property = prop;
 
+       prop = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE, "panel_type",
+                                       drm_panel_type_enum_list,
+                                       ARRAY_SIZE(drm_panel_type_enum_list));
+       if (!prop)
+               return -ENOMEM;
+       dev->mode_config.panel_type_property = prop;
+
        prop = drm_property_create_bool(dev, DRM_MODE_PROP_IMMUTABLE, "non-desktop");
        if (!prop)
                return -ENOMEM;
@@ -3626,3 +3641,21 @@ struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
        return tg;
 }
 EXPORT_SYMBOL(drm_mode_create_tile_group);
+
+/**
+ * drm_connector_attach_panel_type_property - attaches panel type property
+ * @connector: connector to attach the property on.
+ *
+ * This is used to add support for panel type detection.
+ */
+void drm_connector_attach_panel_type_property(struct drm_connector *connector)
+{
+       struct drm_device *dev = connector->dev;
+       struct drm_property *prop = dev->mode_config.panel_type_property;
+
+       if (!prop)
+               return;
+
+       drm_object_attach_property(&connector->base, prop, DRM_MODE_PANEL_TYPE_UNKNOWN);
+}
+EXPORT_SYMBOL(drm_connector_attach_panel_type_property);
index 7eaec37ae1c735334afa7dad15a38cf0c8b761b8..c18be8c19de0ab1e02e7d7b1fcd9f2ab5ef1dd15 100644 (file)
@@ -2493,6 +2493,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);
+void drm_connector_attach_panel_type_property(struct drm_connector *connector);
 int drm_connector_attach_broadcast_rgb_property(struct drm_connector *connector);
 int drm_connector_attach_colorspace_property(struct drm_connector *connector);
 int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector);
index 895fb820dba0733af5c05d52f53aaa817f115ab6..5e1dd0cfccde2d2bc00a09e98e4adc65833dad08 100644 (file)
@@ -600,6 +600,10 @@ struct drm_mode_config {
         * multiple CRTCs.
         */
        struct drm_property *tile_property;
+       /**
+        * @panel_type_property: Default connector property for panel type
+        */
+       struct drm_property *panel_type_property;
        /**
         * @link_status_property: Default connector property for link status
         * of a connector
index cbbbfc1dfe2b806c641c720b0215e825e350bd03..3693d82b5279f1cf14fc2adb538ea830591cc598 100644 (file)
@@ -166,6 +166,10 @@ extern "C" {
 #define DRM_MODE_LINK_STATUS_GOOD      0
 #define DRM_MODE_LINK_STATUS_BAD       1
 
+/* Panel type property */
+#define DRM_MODE_PANEL_TYPE_UNKNOWN    0
+#define DRM_MODE_PANEL_TYPE_OLED       1
+
 /*
  * DRM_MODE_ROTATE_<degrees>
  *