[Intel-gfx] [RFC 1/2] drm: dumb buffer size availability

Ramalingam C ramalingam.c at intel.com
Tue Jan 21 01:53:04 UTC 2020


drm_getcap is added with another parameter called
DRM_CAP_DUMB_SIZE_AVAILABLE to get the available size
for dumb buffer from drm driver.

Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
---
 drivers/gpu/drm/drm_ioctl.c |  5 +++++
 include/drm/drm_drv.h       | 15 +++++++++++++++
 include/uapi/drm/drm.h      |  1 +
 3 files changed, 21 insertions(+)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 5afb39688b55..786d23f8c03a 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -302,6 +302,11 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
 	case DRM_CAP_CRTC_IN_VBLANK_EVENT:
 		req->value = 1;
 		break;
+	case DRM_CAP_DUMB_SIZE_AVAILABLE:
+		if (dev->driver->dumb_size_available)
+			return dev->driver->dumb_size_available(file_priv, dev,
+								&req->value);
+		break;
 	default:
 		return -EINVAL;
 	}
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index cf13470810a5..19404e604c03 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -677,6 +677,21 @@ struct drm_driver {
 	int (*dumb_create)(struct drm_file *file_priv,
 			   struct drm_device *dev,
 			   struct drm_mode_create_dumb *args);
+
+	/**
+	 * @dumb_size_available:
+	 *
+	 * This function calculates the available backin store for the
+	 * dumb buffer that can be created through dumb_create ioctl.
+	 *
+	 * Returns:
+	 *
+	 * Zero on success, negative errno on failure.
+	 */
+	int (*dumb_size_available)(struct drm_file *file_priv,
+				   struct drm_device *dev,
+				   uint64_t *avail_size);
+
 	/**
 	 * @dumb_map_offset:
 	 *
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 868bf7996c0f..4da8ebc5aee2 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -651,6 +651,7 @@ struct drm_gem_open {
 #define DRM_CAP_CRTC_IN_VBLANK_EVENT	0x12
 #define DRM_CAP_SYNCOBJ		0x13
 #define DRM_CAP_SYNCOBJ_TIMELINE	0x14
+#define DRM_CAP_DUMB_SIZE_AVAILABLE	0x15
 
 /** DRM_IOCTL_GET_CAP ioctl argument type */
 struct drm_get_cap {
-- 
2.20.1



More information about the Intel-gfx mailing list