[Intel-gfx] [PATCH 2/5] drm/i915: Expose framebuffer parameters

Chris Wilson chris at chris-wilson.co.uk
Thu Jun 20 19:18:29 CEST 2013


Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_dma.c      |  3 ++
 drivers/gpu/drm/i915/intel_display.c | 66 ++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_drv.h     |  4 +++
 include/uapi/drm/i915_drm.h          | 11 ++++++
 4 files changed, 84 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 78939b6..5dcfbbe 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1924,6 +1924,9 @@ struct drm_ioctl_desc i915_ioctls[] = {
 	DRM_IOCTL_DEF_DRV(I915_GEM_CONTEXT_DESTROY, i915_gem_context_destroy_ioctl, DRM_UNLOCKED),
 	DRM_IOCTL_DEF_DRV(I915_REG_READ, i915_reg_read_ioctl, DRM_UNLOCKED),
 	DRM_IOCTL_DEF_DRV(I915_GEM_USERPTR, i915_gem_userptr_ioctl, DRM_UNLOCKED),
+
+	DRM_IOCTL_DEF_DRV(INTEL_FRAMEBUFFER_GETPARAM, intel_user_framebuffer_getparam, DRM_UNLOCKED),
+	DRM_IOCTL_DEF_DRV(INTEL_FRAMEBUFFER_SETPARAM, intel_user_framebuffer_setparam, DRM_UNLOCKED),
 };
 
 int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 586a648..7bb8851 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9198,6 +9198,72 @@ intel_user_framebuffer_create(struct drm_device *dev,
 	return intel_framebuffer_create(dev, mode_cmd, obj);
 }
 
+static int
+__intel_user_framebuffer_getparam(struct intel_framebuffer *fb,
+				  u32 param, u64 *value)
+{
+	switch (param) {
+	default:
+		return -EINVAL;
+	}
+}
+
+int
+intel_user_framebuffer_getparam(struct drm_device *dev,
+				void *data,
+				struct drm_file *file)
+{
+	struct intel_framebuffer_param *args = data;
+	struct drm_framebuffer *fb, *iter;
+	int ret = -ENOENT;
+
+	mutex_lock(&file->fbs_lock);
+	fb = drm_framebuffer_lookup(dev, args->fb_id);
+	list_for_each_entry(iter, &file->fbs, filp_head) {
+		if (fb == iter) {
+			ret = __intel_user_framebuffer_getparam(to_intel_framebuffer(fb),
+								args->param,
+								&args->value);
+			break;
+		}
+	}
+	mutex_unlock(&file->fbs_lock);
+	return ret;
+}
+
+static int
+__intel_user_framebuffer_setparam(struct intel_framebuffer *fb,
+				  u32 param, u64 value)
+{
+	switch (param) {
+	default:
+		return -EINVAL;
+	}
+}
+
+int
+intel_user_framebuffer_setparam(struct drm_device *dev,
+				void *data,
+				struct drm_file *file)
+{
+	struct intel_framebuffer_param *args = data;
+	struct drm_framebuffer *fb, *iter;
+	int ret = -ENOENT;
+
+	mutex_lock(&file->fbs_lock);
+	fb = drm_framebuffer_lookup(dev, args->fb_id);
+	list_for_each_entry(iter, &file->fbs, filp_head) {
+		if (fb == iter) {
+			ret = __intel_user_framebuffer_setparam(to_intel_framebuffer(fb),
+								args->param,
+								args->value);
+			break;
+		}
+	}
+	mutex_unlock(&file->fbs_lock);
+	return ret;
+}
+
 static const struct drm_mode_config_funcs intel_mode_funcs = {
 	.fb_create = intel_user_framebuffer_create,
 	.output_poll_changed = intel_fb_output_poll_changed,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 05d798f..b679adfb 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -732,6 +732,10 @@ extern int intel_framebuffer_init(struct drm_device *dev,
 				  struct intel_framebuffer *ifb,
 				  struct drm_mode_fb_cmd2 *mode_cmd,
 				  struct drm_i915_gem_object *obj);
+extern int intel_user_framebuffer_getparam(struct drm_device *dev,
+					   void *data, struct drm_file *file);
+extern int intel_user_framebuffer_setparam(struct drm_device *dev,
+					   void *data, struct drm_file *file);
 extern int intel_fbdev_init(struct drm_device *dev);
 extern void intel_fbdev_initial_config(struct drm_device *dev);
 extern void intel_fbdev_fini(struct drm_device *dev);
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index b27e6b9..38a9b52 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -199,6 +199,8 @@ typedef struct _drm_i915_sarea {
 #define DRM_I915_GEM_GET_CACHING	0x30
 #define DRM_I915_REG_READ		0x31
 #define DRM_I915_GEM_USERPTR		0x32
+#define DRM_INTEL_FRAMEBUFFER_GETPARAM	0x33
+#define DRM_INTEL_FRAMEBUFFER_SETPARAM	0x34
 
 #define DRM_IOCTL_I915_INIT		DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
 #define DRM_IOCTL_I915_FLUSH		DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -249,6 +251,8 @@ typedef struct _drm_i915_sarea {
 #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY	DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
 #define DRM_IOCTL_I915_REG_READ			DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
 #define DRM_IOCTL_I915_GEM_USERPTR			DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
+#define DRM_IOCTL_INTEL_FRAMEBUFFER_GETPARAM         DRM_IOWR(DRM_COMMAND_BASE + DRM_INTEL_FRAMEBUFFER_GETPARAM, struct intel_framebuffer_param)
+#define DRM_IOCTL_INTEL_FRAMEBUFFER_SETPARAM         DRM_IOW( DRM_COMMAND_BASE + DRM_INTEL_FRAMEBUFFER_SETPARAM, struct intel_framebuffer_param)
 
 /* Allow drivers to submit batchbuffers directly to hardware, relying
  * on the security mechanisms provided by hardware.
@@ -997,4 +1001,11 @@ struct drm_i915_gem_userptr {
 	 */
 	__u32 handle;
 };
+
+struct intel_framebuffer_param {
+	__u32 fb_id;
+	__u32 param;
+	__u64 value;
+};
+
 #endif /* _UAPI_I915_DRM_H_ */
-- 
1.8.3.1




More information about the Intel-gfx mailing list