[PATCH] drm: add client cap to expose low power modes

Ken Huang kenbshuang at google.com
Wed Oct 21 06:54:04 UTC 2020


From: Adrian Salido <salidoa at google.com>

Some displays may support Low Power modes, however, these modes may
require special handling as they would usually require lower OPR
content on framebuffers. Add a drm mode flag to specify display
capability to support low power mode, and add a drm client cap for
it. If a client doesn't support the capability, that will filter it
out for the client.

Signed-off-by: Adrian Salido <salidoa at google.com>
Signed-off-by: Ken Huang <kenbshuang at google.com>
---
 drivers/gpu/drm/drm_connector.c |  4 ++++
 drivers/gpu/drm/drm_ioctl.c     |  5 +++++
 include/drm/drm_file.h          |  7 +++++++
 include/uapi/drm/drm.h          | 10 ++++++++++
 include/uapi/drm/drm_mode.h     |  3 +++
 5 files changed, 29 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 717c4e7271b0..46a29b156ffa 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2318,6 +2318,10 @@ drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
 		}
 	}
 
+	if (!file_priv->low_power_modes_allowed &&
+	    (mode->flags & DRM_MODE_FLAG_LOW_POWER))
+		return false;
+
 	return true;
 }
 
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 789ee65ac1f5..e7e025698b3b 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -362,6 +362,11 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
 			return -EINVAL;
 		file_priv->writeback_connectors = req->value;
 		break;
+	case DRM_CLIENT_CAP_LOW_POWER_MODES:
+		if (req->value > 1)
+			return -EINVAL;
+		file_priv->low_power_modes_allowed = req->value;
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 716990bace10..2fa66c32f066 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -212,6 +212,13 @@ struct drm_file {
 	 */
 	bool was_master;
 
+	/**
+	 * @low_power_modes_allowed:
+	 *
+	 * True if the client understands how to work with low power modes
+	 */
+	bool low_power_modes_allowed;
+
 	/**
 	 * @is_master:
 	 *
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 808b48a93330..12f39a628bb5 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -698,6 +698,16 @@ struct drm_get_cap {
  */
 #define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS	5
 
+/**
+ * DRM_CLIENT_CAP_LOW_POWER_MODES
+ *
+ * If set to 1, the DRM core will expose modes that support Lower Power at the
+ * potential cost of reduced fidelity. Special care must be taken by clients
+ * that work with these modes, (ex. framebuffer contents are expected to
+ * have reduced OPRs)
+ */
+#define DRM_CLIENT_CAP_LOW_POWER_MODES	6
+
 /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
 struct drm_set_client_cap {
 	__u64 capability;
diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h
index 863eda048265..71137280b1e6 100644
--- a/include/uapi/drm/drm_mode.h
+++ b/include/uapi/drm/drm_mode.h
@@ -124,6 +124,8 @@ extern "C" {
 #define  DRM_MODE_FLAG_PIC_AR_256_135 \
 			(DRM_MODE_PICTURE_ASPECT_256_135<<19)
 
+#define  DRM_MODE_FLAG_LOW_POWER		(1<<23)
+
 #define  DRM_MODE_FLAG_ALL	(DRM_MODE_FLAG_PHSYNC |		\
 				 DRM_MODE_FLAG_NHSYNC |		\
 				 DRM_MODE_FLAG_PVSYNC |		\
@@ -136,6 +138,7 @@ extern "C" {
 				 DRM_MODE_FLAG_HSKEW |		\
 				 DRM_MODE_FLAG_DBLCLK |		\
 				 DRM_MODE_FLAG_CLKDIV2 |	\
+				 DRM_MODE_FLAG_LOW_POWER |	\
 				 DRM_MODE_FLAG_3D_MASK)
 
 /* DPMS flags */
-- 
2.29.0.rc1.297.gfa9743e501-goog



More information about the dri-devel mailing list