[PATCH v3 1/2] drm/connector: add drm_connector_get_cmdline_min_brightness_override()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a helper which can read a overridden minimum backlight value from the
kernel cmdline.
This is useful if the minimum backlight as reported by machines VBT
does not match the user expectations.

As an example, the minimum backlight brightness on the Framework 13
matte panel is too high.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
 drivers/gpu/drm/drm_connector.c | 34 ++++++++++++++++++++++++++++++++++
 include/drm/drm_connector.h     |  2 ++
 2 files changed, 36 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index ab6ab7ff7ea8..d0b3d5d6c7c2 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -34,6 +34,7 @@
 #include <drm/drm_utils.h>
 
 #include <linux/property.h>
+#include <linux/string.h>
 #include <linux/uaccess.h>
 
 #include <video/cmdline.h>
@@ -3399,3 +3400,36 @@ struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
 	return tg;
 }
 EXPORT_SYMBOL(drm_mode_create_tile_group);
+
+/**
+ * drm_connector_get_cmdline_min_brightness_override - read an overridden
+ * minimum brightness value from the cmdline
+ * @connector: connector to query
+ *
+ * Read an minimum brightness override from the kernel cmdline if present.
+ * The parameter takes the form "video=CONNECTOR_NAME:min-brightness=VALUE".
+ *
+ * RETURNS:
+ * negative error or override value in the range [0, 255]
+ */
+int drm_connector_get_cmdline_min_brightness_override(struct drm_connector *connector)
+{
+	const char *option, *value_str;
+	int err;
+	u8 val;
+
+	option = video_get_options(connector->name);
+	if (!option)
+		return -ENOENT;
+
+	value_str = option + str_has_prefix(option, "min-brightness=");
+	if (value_str == option)
+		return -EINVAL;
+
+	err = kstrtou8(value_str, 10, &val);
+	if (err)
+		return err;
+
+	return val;
+}
+EXPORT_SYMBOL_GPL(drm_connector_get_cmdline_min_brightness_override);
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index c754651044d4..64d86604cc6e 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -2357,6 +2357,8 @@ bool drm_connector_has_possible_encoder(struct drm_connector *connector,
 					struct drm_encoder *encoder);
 const char *drm_get_colorspace_name(enum drm_colorspace colorspace);
 
+int drm_connector_get_cmdline_min_brightness_override(struct drm_connector *connector);
+
 /**
  * drm_for_each_connector_iter - connector_list iterator macro
  * @connector: &struct drm_connector pointer used as cursor

-- 
2.46.0




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux