Skip to contentSkip to conversation

DRM planes and new fb creation ioctl

PATCH In review Jesse Barnes 8 participants 42 messages Oct 25, 2011 – Nov 3, 2011

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

I've given up waiting for someone to implement support for these ioctls on another platform before they're merged, but I have received a lot of feedback on the interfaces, and it sounds like they're ok. I've also fixed all the remaining issues I'm aware of on SNB platforms and things are working well, so I'm just going to push them out. (Note IVB support is still missing a few bits for scaling and such; I'll fix those up when I get back home and can test on IVB again.)

One change you may notice from the last set is that I've removed the 'zpos' parameter. Plane blending and z ordering is very chipset specific (it even varies between Intel chipsets), so exposing it through a device specific ioctl is probably a better plan. By default, planes should just overlay the primary plane; a device specific ioctl (none available yet, but I have some planned for i915) can provide more flexibility.

To recap previous posts, this patchset provides a few new interfaces:
- addfb2 - a new FB creation ioctl that lets you specify a surface format, as defined by a fourcc code from the video4linux headers (libdrm will wrap these in DRM_ macros for portability)
- planes - ioctls for fetching plane info and attaching an fb to a plane; note there's no separate flip ioctl for planes, just use setplane to update the fb

The testdisplay.c program in intel-gpu-tools has support for testing these interfaces, and I'll be fixing up and pushing the xf86-video-intel support soon as well, so you can use either as a reference for how the new interfaces work.

Thanks,
Jesse

#1 lore raw

PATCH 1/11 drm: add plane support

Planes are a bit like half-CRTCs. They have a location and fb, but don't drive outputs directly. Add support for handling them to the core KMS code.

---
 drivers/gpu/drm/drm_crtc.c |  236 +++++++++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/drm_drv.c  |    3 +
 include/drm/drm.h          |    3 +
 include/drm/drm_crtc.h     |   71 +++++++++++++-
 include/drm/drm_mode.h     |   33 ++++++
 5 files changed, 343 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +234 -2
index fe738f0..0e129b1 100644
@@ -535,6 +535,48 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
 }
 EXPORT_SYMBOL(drm_encoder_cleanup);
 
+void drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
+		    unsigned long possible_crtcs,
+		    const struct drm_plane_funcs *funcs,
+		    uint32_t *formats, uint32_t format_count)
+{
+	mutex_lock(&dev->mode_config.mutex);
+
+	plane->dev = dev;
+	drm_mode_object_get(dev, &plane->base, DRM_MODE_OBJECT_PLANE);
+	plane->funcs = funcs;
+	plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
+				      GFP_KERNEL);
+	if (!plane->format_types) {
+		DRM_DEBUG_KMS("out of memory when allocating plane\n");
+		drm_mode_object_put(dev, &plane->base);
+		return;
+	}
+
+	memcpy(plane->format_types, formats, format_count);
+	plane->format_count = format_count;
+	plane->possible_crtcs = possible_crtcs;
+
+	list_add_tail(&plane->head, &dev->mode_config.plane_list);
+	dev->mode_config.num_plane++;
+
+	mutex_unlock(&dev->mode_config.mutex);
+}
+EXPORT_SYMBOL(drm_plane_init);
+
+void drm_plane_cleanup(struct drm_plane *plane)
+{
+	struct drm_device *dev = plane->dev;
+
+	mutex_lock(&dev->mode_config.mutex);
+	kfree(plane->format_types);
+	drm_mode_object_put(dev, &plane->base);
+	list_del(&plane->head);
+	dev->mode_config.num_plane--;
+	mutex_unlock(&dev->mode_config.mutex);
+}
+EXPORT_SYMBOL(drm_plane_cleanup);
+
 /**
  * drm_mode_create - create a new display mode
  * @dev: DRM device
@@ -866,6 +908,7 @@ void drm_mode_config_init(struct drm_device *dev)
 	INIT_LIST_HEAD(&dev->mode_config.encoder_list);
 	INIT_LIST_HEAD(&dev->mode_config.property_list);
 	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
+	INIT_LIST_HEAD(&dev->mode_config.plane_list);
 	idr_init(&dev->mode_config.crtc_idr);
 
 	mutex_lock(&dev->mode_config.mutex);
@@ -1466,6 +1509,193 @@ out:
 }
 
 /**
+ * drm_mode_getplane_res - get plane info
+ * @dev: DRM device
+ * @data: ioctl data
+ * @file_priv: DRM file info
+ *
+ * Return an plane count and set of IDs.
+ */
+int drm_mode_getplane_res(struct drm_device *dev, void *data,
+			    struct drm_file *file_priv)
+{
+	struct drm_mode_get_plane_res *plane_resp = data;
+	struct drm_mode_config *config;
+	struct drm_plane *plane;
+	uint32_t __user *plane_ptr;
+	int copied = 0, ret = 0;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	mutex_lock(&dev->mode_config.mutex);
+	config = &dev->mode_config;
+
+	/*
+	 * This ioctl is called twice, once to determine how much space is
+	 * needed, and the 2nd time to fill it.
+	 */
+	if (config->num_plane &&
+	    (plane_resp->count_planes >= config->num_plane)) {
+		plane_ptr = (uint32_t *)(unsigned long)plane_resp->plane_id_ptr;
+
+		list_for_each_entry(plane, &config->plane_list, head) {
+			if (put_user(plane->base.id, plane_ptr + copied)) {
+				ret = -EFAULT;
+				goto out;
+			}
+			copied++;
+		}
+	}
+	plane_resp->count_planes = config->num_plane;
+
+out:
+	mutex_unlock(&dev->mode_config.mutex);
+	return ret;
+}
+
+/**
+ * drm_mode_getplane - get plane info
+ * @dev: DRM device
+ * @data: ioctl data
+ * @file_priv: DRM file info
+ *
+ * Return plane info, including formats supported, gamma size, any
+ * current fb, etc.
+ */
+int drm_mode_getplane(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
+{
+	struct drm_mode_get_plane *plane_resp = data;
+	struct drm_mode_object *obj;
+	struct drm_plane *plane;
+	uint32_t __user *format_ptr;
+	int ret = 0;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	mutex_lock(&dev->mode_config.mutex);
+	obj = drm_mode_object_find(dev, plane_resp->plane_id,
+				   DRM_MODE_OBJECT_PLANE);
+	if (!obj) {
+		ret = -EINVAL;
+		goto out;
+	}
+	plane = obj_to_plane(obj);
+
+	if (plane->crtc)
+		plane_resp->crtc_id = plane->crtc->base.id;
+	else
+		plane_resp->crtc_id = 0;
+
+	if (plane->fb)
+		plane_resp->fb_id = plane->fb->base.id;
+	else
+		plane_resp->fb_id = 0;
+
+	plane_resp->plane_id = plane->base.id;
+	plane_resp->possible_crtcs = plane->possible_crtcs;
+	plane_resp->gamma_size = plane->gamma_size;
+
+	/*
+	 * This ioctl is called twice, once to determine how much space is
+	 * needed, and the 2nd time to fill it.
+	 */
+	if (plane->format_count &&
+	    (plane_resp->count_format_types >= plane->format_count)) {
+		format_ptr = (uint32_t *)(unsigned long)plane_resp->format_type_ptr;
+		if (copy_to_user(format_ptr,
+				 plane->format_types,
+				 sizeof(uint32_t) * plane->format_count)) {
+			ret = -EFAULT;
+			goto out;
+		}
+	}
+	plane_resp->count_format_types = plane->format_count;
+
+out:
+	mutex_unlock(&dev->mode_config.mutex);
+	return ret;
+}
+
+/**
+ * drm_mode_setplane - set up or tear down an plane
+ * @dev: DRM device
+ * @data: ioctl data*
+ * @file_prive: DRM file info
+ *
+ * Set plane info, including placement, fb, scaling, and other factors.
+ * Or pass a NULL fb to disable.
+ */
+int drm_mode_setplane(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
+{
+	struct drm_mode_set_plane *plane_req = data;
+	struct drm_mode_object *obj;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	struct drm_framebuffer *fb;
+	int ret = 0;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	mutex_lock(&dev->mode_config.mutex);
+
+	/*
+	 * First, find the plane, crtc, and fb objects.  If not available,
+	 * we don't bother to call the driver.
+	 */
+	obj = drm_mode_object_find(dev, plane_req->plane_id,
+				   DRM_MODE_OBJECT_PLANE);
+	if (!obj) {
+		DRM_DEBUG_KMS("Unknown plane ID %d\n",
+			      plane_req->plane_id);
+		ret = -EINVAL;
+		goto out;
+	}
+	plane = obj_to_plane(obj);
+
+	/* No fb means shut it down */
+	if (!plane_req->fb_id) {
+		plane->funcs->disable_plane(plane);
+		goto out;
+	}
+
+	obj = drm_mode_object_find(dev, plane_req->crtc_id,
+				   DRM_MODE_OBJECT_CRTC);
+	if (!obj) {
+		DRM_DEBUG_KMS("Unknown crtc ID %d\n",
+			      plane_req->crtc_id);
+		ret = -EINVAL;
+		goto out;
+	}
+	crtc = obj_to_crtc(obj);
+
+	obj = drm_mode_object_find(dev, plane_req->fb_id,
+				   DRM_MODE_OBJECT_FB);
+	if (!obj) {
+		DRM_DEBUG_KMS("Unknown framebuffer ID %d\n",
+			      plane_req->fb_id);
+		ret = -EINVAL;
+		goto out;
+	}
+	fb = obj_to_fb(obj);
+
+	ret = plane->funcs->update_plane(plane, crtc, fb,
+					 plane_req->crtc_x, plane_req->crtc_y,
+					 plane_req->crtc_w, plane_req->crtc_h,
+					 plane_req->src_x, plane_req->src_y,
+					 plane_req->src_h, plane_req->src_w);
+
+out:
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return ret;
+}
+
+/**
  * drm_mode_setcrtc - set CRTC configuration
  * @inode: inode from the ioctl
  * @filp: file * from the ioctl
@@ -1688,11 +1918,13 @@ int drm_mode_addfb(struct drm_device *dev,
 		return -EINVAL;
 
 	if ((config->min_width > r->width) || (r->width > config->max_width)) {
-		DRM_ERROR("mode new framebuffer width not within limits\n");
+		DRM_ERROR("bad framebuffer width %d, should be >= %d && <= %d\n",
+			  r->width, config->min_width, config->max_width);
 		return -EINVAL;
 	}
 	if ((config->min_height > r->height) || (r->height > config->max_height)) {
-		DRM_ERROR("mode new framebuffer height not within limits\n");
+		DRM_ERROR("bad framebuffer height %d, should be >= %d && <= %d\n",
+			  r->height, config->min_height, config->max_height);
 		return -EINVAL;
 	}
 
drivers/gpu/drm/drm_drv.c +3 -0
index 93a112d..15da618 100644
@@ -135,8 +135,11 @@ static struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH|DRM_UNLOCKED),
 
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANE, drm_mode_getplane, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPLANE, drm_mode_setplane, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETGAMMA, drm_mode_gamma_get_ioctl, DRM_MASTER|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER|DRM_UNLOCKED),
include/drm/drm.h +3 -0
index 4be33b4..2897967 100644
@@ -714,6 +714,9 @@ struct drm_get_cap {
 #define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)
 #define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
 #define DRM_IOCTL_MODE_DESTROY_DUMB    DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
+#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
+#define DRM_IOCTL_MODE_GETPLANE	DRM_IOWR(0xB6, struct drm_mode_get_plane)
+#define DRM_IOCTL_MODE_SETPLANE	DRM_IOWR(0xB7, struct drm_mode_set_plane)
 
 /**
  * Device specific ioctls should only be in their respective headers
include/drm/drm_crtc.h +70 -1

119 lines not on this page · raw message

include/drm/drm_mode.h +33 -0
index c4961ea..07711b0 100644
@@ -120,6 +120,39 @@ struct drm_mode_crtc {
 	struct drm_mode_modeinfo mode;
 };
 
+/* Planes blend with or override other bits on the CRTC */
+struct drm_mode_set_plane {
+	__u32 plane_id;
+	__u32 crtc_id;
+	__u32 fb_id; /* fb object contains surface format type */
+
+	/* Signed dest location allows it to be partially off screen */
+	__s32 crtc_x, crtc_y;
+	__u32 crtc_w, crtc_h;
+
+	/* Source values are 16.16 fixed point */
+	__u32 src_x, src_y;
+	__u32 src_h, src_w;
+};
+
+struct drm_mode_get_plane {
+	__u64 format_type_ptr;
+	__u32 plane_id;
+
+	__u32 crtc_id;
+	__u32 fb_id;
+
+	__u32 possible_crtcs;
+	__u32 gamma_size;
+
+	__u32 count_format_types;
+};
+
+struct drm_mode_get_plane_res {
+	__u64 plane_id_ptr;
+	__u32 count_planes;
+};
+
 #define DRM_MODE_ENCODER_NONE	0
 #define DRM_MODE_ENCODER_DAC	1
 #define DRM_MODE_ENCODER_TMDS	2
Signature · 1 line
1.7.4.1
#2 lore raw

Re: [PATCH 01/11] drm: add plane support

10/25/2011 06:46 PM, Jesse Barnes 쓴 글:

Quoted 352 lines

Planes are a bit like half-CRTCs. They have a location and fb, but don't drive outputs directly. Add support for handling them to the core KMS code.

---
  drivers/gpu/drm/drm_crtc.c |  236 +++++++++++++++++++++++++++++++++++++++++++-
  drivers/gpu/drm/drm_drv.c  |    3 +
  include/drm/drm.h          |    3 +
  include/drm/drm_crtc.h     |   71 +++++++++++++-
  include/drm/drm_mode.h     |   33 ++++++
  5 files changed, 343 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +234 -2
index fe738f0..0e129b1 100644
@@ -535,6 +535,48 @@ void drm_encoder_cleanup(struct drm_encoder *encoder)
  }
  EXPORT_SYMBOL(drm_encoder_cleanup);
 
+void drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
+		    unsigned long possible_crtcs,
+		    const struct drm_plane_funcs *funcs,
+		    uint32_t *formats, uint32_t format_count)
+{
+	mutex_lock(&dev->mode_config.mutex);
+
+	plane->dev = dev;
+	drm_mode_object_get(dev,&plane->base, DRM_MODE_OBJECT_PLANE);
+	plane->funcs = funcs;
+	plane->format_types = kmalloc(sizeof(uint32_t) * format_count,
+				      GFP_KERNEL);
+	if (!plane->format_types) {
+		DRM_DEBUG_KMS("out of memory when allocating plane\n");
+		drm_mode_object_put(dev,&plane->base);
+		return;
+	}
+
+	memcpy(plane->format_types, formats, format_count);
+	plane->format_count = format_count;
+	plane->possible_crtcs = possible_crtcs;
+
+	list_add_tail(&plane->head,&dev->mode_config.plane_list);
+	dev->mode_config.num_plane++;
+
+	mutex_unlock(&dev->mode_config.mutex);
+}
+EXPORT_SYMBOL(drm_plane_init);
+
+void drm_plane_cleanup(struct drm_plane *plane)
+{
+	struct drm_device *dev = plane->dev;
+
+	mutex_lock(&dev->mode_config.mutex);
+	kfree(plane->format_types);
+	drm_mode_object_put(dev,&plane->base);
+	list_del(&plane->head);
+	dev->mode_config.num_plane--;
+	mutex_unlock(&dev->mode_config.mutex);
+}
+EXPORT_SYMBOL(drm_plane_cleanup);
+
  /**
   * drm_mode_create - create a new display mode
   * @dev: DRM device
@@ -866,6 +908,7 @@ void drm_mode_config_init(struct drm_device *dev)
  	INIT_LIST_HEAD(&dev->mode_config.encoder_list);
  	INIT_LIST_HEAD(&dev->mode_config.property_list);
  	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
+	INIT_LIST_HEAD(&dev->mode_config.plane_list);
  	idr_init(&dev->mode_config.crtc_idr);
 
  	mutex_lock(&dev->mode_config.mutex);
@@ -1466,6 +1509,193 @@ out:
  }
 
  /**
+ * drm_mode_getplane_res - get plane info
+ * @dev: DRM device
+ * @data: ioctl data
+ * @file_priv: DRM file info
+ *
+ * Return an plane count and set of IDs.
+ */
+int drm_mode_getplane_res(struct drm_device *dev, void *data,
+			    struct drm_file *file_priv)
+{
+	struct drm_mode_get_plane_res *plane_resp = data;
+	struct drm_mode_config *config;
+	struct drm_plane *plane;
+	uint32_t __user *plane_ptr;
+	int copied = 0, ret = 0;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	mutex_lock(&dev->mode_config.mutex);
+	config =&dev->mode_config;
+
+	/*
+	 * This ioctl is called twice, once to determine how much space is
+	 * needed, and the 2nd time to fill it.
+	 */
+	if (config->num_plane&&
+	    (plane_resp->count_planes>= config->num_plane)) {
+		plane_ptr = (uint32_t *)(unsigned long)plane_resp->plane_id_ptr;
+
+		list_for_each_entry(plane,&config->plane_list, head) {
+			if (put_user(plane->base.id, plane_ptr + copied)) {
+				ret = -EFAULT;
+				goto out;
+			}
+			copied++;
+		}
+	}
+	plane_resp->count_planes = config->num_plane;
+
+out:
+	mutex_unlock(&dev->mode_config.mutex);
+	return ret;
+}
+
+/**
+ * drm_mode_getplane - get plane info
+ * @dev: DRM device
+ * @data: ioctl data
+ * @file_priv: DRM file info
+ *
+ * Return plane info, including formats supported, gamma size, any
+ * current fb, etc.
+ */
+int drm_mode_getplane(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
+{
+	struct drm_mode_get_plane *plane_resp = data;
+	struct drm_mode_object *obj;
+	struct drm_plane *plane;
+	uint32_t __user *format_ptr;
+	int ret = 0;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	mutex_lock(&dev->mode_config.mutex);
+	obj = drm_mode_object_find(dev, plane_resp->plane_id,
+				   DRM_MODE_OBJECT_PLANE);
+	if (!obj) {
+		ret = -EINVAL;
+		goto out;
+	}
+	plane = obj_to_plane(obj);
+
+	if (plane->crtc)
+		plane_resp->crtc_id = plane->crtc->base.id;
+	else
+		plane_resp->crtc_id = 0;
+
+	if (plane->fb)
+		plane_resp->fb_id = plane->fb->base.id;
+	else
+		plane_resp->fb_id = 0;
+
+	plane_resp->plane_id = plane->base.id;
+	plane_resp->possible_crtcs = plane->possible_crtcs;
+	plane_resp->gamma_size = plane->gamma_size;
+
+	/*
+	 * This ioctl is called twice, once to determine how much space is
+	 * needed, and the 2nd time to fill it.
+	 */
+	if (plane->format_count&&
+	    (plane_resp->count_format_types>= plane->format_count)) {
+		format_ptr = (uint32_t *)(unsigned long)plane_resp->format_type_ptr;
+		if (copy_to_user(format_ptr,
+				 plane->format_types,
+				 sizeof(uint32_t) * plane->format_count)) {
+			ret = -EFAULT;
+			goto out;
+		}
+	}
+	plane_resp->count_format_types = plane->format_count;
+
+out:
+	mutex_unlock(&dev->mode_config.mutex);
+	return ret;
+}
+
+/**
+ * drm_mode_setplane - set up or tear down an plane
+ * @dev: DRM device
+ * @data: ioctl data*
+ * @file_prive: DRM file info
+ *
+ * Set plane info, including placement, fb, scaling, and other factors.
+ * Or pass a NULL fb to disable.
+ */
+int drm_mode_setplane(struct drm_device *dev, void *data,
+			struct drm_file *file_priv)
+{
+	struct drm_mode_set_plane *plane_req = data;
+	struct drm_mode_object *obj;
+	struct drm_plane *plane;
+	struct drm_crtc *crtc;
+	struct drm_framebuffer *fb;
+	int ret = 0;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	mutex_lock(&dev->mode_config.mutex);
+
+	/*
+	 * First, find the plane, crtc, and fb objects.  If not available,
+	 * we don't bother to call the driver.
+	 */
+	obj = drm_mode_object_find(dev, plane_req->plane_id,
+				   DRM_MODE_OBJECT_PLANE);
+	if (!obj) {
+		DRM_DEBUG_KMS("Unknown plane ID %d\n",
+			      plane_req->plane_id);
+		ret = -EINVAL;
+		goto out;
+	}
+	plane = obj_to_plane(obj);
+
+	/* No fb means shut it down */
+	if (!plane_req->fb_id) {
+		plane->funcs->disable_plane(plane);
+		goto out;
+	}
+
+	obj = drm_mode_object_find(dev, plane_req->crtc_id,
+				   DRM_MODE_OBJECT_CRTC);
+	if (!obj) {
+		DRM_DEBUG_KMS("Unknown crtc ID %d\n",
+			      plane_req->crtc_id);
+		ret = -EINVAL;
+		goto out;
+	}
+	crtc = obj_to_crtc(obj);
+
+	obj = drm_mode_object_find(dev, plane_req->fb_id,
+				   DRM_MODE_OBJECT_FB);
+	if (!obj) {
+		DRM_DEBUG_KMS("Unknown framebuffer ID %d\n",
+			      plane_req->fb_id);
+		ret = -EINVAL;
+		goto out;
+	}
+	fb = obj_to_fb(obj);
+
+	ret = plane->funcs->update_plane(plane, crtc, fb,
+					 plane_req->crtc_x, plane_req->crtc_y,
+					 plane_req->crtc_w, plane_req->crtc_h,
+					 plane_req->src_x, plane_req->src_y,
+					 plane_req->src_h, plane_req->src_w);
+
+out:
+	mutex_unlock(&dev->mode_config.mutex);
+
+	return ret;
+}
+
+/**
   * drm_mode_setcrtc - set CRTC configuration
   * @inode: inode from the ioctl
   * @filp: file * from the ioctl
@@ -1688,11 +1918,13 @@ int drm_mode_addfb(struct drm_device *dev,
  		return -EINVAL;
 
  	if ((config->min_width>  r->width) || (r->width>  config->max_width)) {
-		DRM_ERROR("mode new framebuffer width not within limits\n");
+		DRM_ERROR("bad framebuffer width %d, should be>= %d&&  <= %d\n",
+			  r->width, config->min_width, config->max_width);
  		return -EINVAL;
  	}
  	if ((config->min_height>  r->height) || (r->height>  config->max_height)) {
-		DRM_ERROR("mode new framebuffer height not within limits\n");
+		DRM_ERROR("bad framebuffer height %d, should be>= %d&&  <= %d\n",
+			  r->height, config->min_height, config->max_height);
  		return -EINVAL;
  	}
 
drivers/gpu/drm/drm_drv.c +3 -0
index 93a112d..15da618 100644
@@ -135,8 +135,11 @@ static struct drm_ioctl_desc drm_ioctls[] = {
  	DRM_IOCTL_DEF(DRM_IOCTL_GEM_OPEN, drm_gem_open_ioctl, DRM_AUTH|DRM_UNLOCKED),
 
  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANERESOURCES, drm_mode_getplane_res, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPLANE, drm_mode_getplane, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPLANE, drm_mode_setplane, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETGAMMA, drm_mode_gamma_get_ioctl, DRM_MASTER|DRM_UNLOCKED),
  	DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER|DRM_UNLOCKED),
include/drm/drm.h +3 -0
index 4be33b4..2897967 100644
@@ -714,6 +714,9 @@ struct drm_get_cap {
  #define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)
  #define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
  #define DRM_IOCTL_MODE_DESTROY_DUMB    DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
+#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
+#define DRM_IOCTL_MODE_GETPLANE	DRM_IOWR(0xB6, struct drm_mode_get_plane)
+#define DRM_IOCTL_MODE_SETPLANE	DRM_IOWR(0xB7, struct drm_mode_set_plane)
 
  /**
   * Device specific ioctls should only be in their respective headers
include/drm/drm_crtc.h +16 -0
index 8020798..d7f03aa 100644
@@ -44,6 +44,7 @@ struct drm_framebuffer;
  #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
  #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
  #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
+#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
 
  struct drm_mode_object {
  	uint32_t id;
@@ -278,6 +279,7 @@ struct drm_crtc;
  struct drm_connector;
  struct drm_encoder;
  struct drm_pending_vblank_event;
+struct drm_plane;
 
  /**
   * drm_crtc_funcs - control CRTCs for a given device
@@ -536,6 +538,58 @@ struct drm_connector {
  };
 
  /**
+ * drm_plane_funcs - driver plane control functions
+ * @update_plane: update the plane configuration
+ */
+struct drm_plane_funcs {
+	int (*update_plane)(struct drm_plane *plane,
+			    struct drm_crtc *crtc, struct drm_framebuffer *fb,
+			    int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h);
+	int (*disable_plane)(struct drm_plane *plane);
+};
+
+/**

include/drm/drm_crtc.h struct drm_connector { · line 564

Quoted 10 lines
include/drm/drm_crtc.h +10 -0
+ * drm_plane - central DRM plane control structure
+ * @dev: DRM device this plane belongs to
+ * @kdev: kernel device
+ * @attr: kdev attributes
+ * @head: for list management
+ * @base: base mode object
+ * @crtc_x: x position of plane (relative to pipe base)
+ * @crtc_y: y position of plane
+ * @x: x offset into fb
+ * @y: y offset into fb

Above 4 members don't be used.

Quoted 107 lines
include/drm/drm_crtc.h +44 -1
+ * @crtc: CRTC this plane is feeding
+ */
+struct drm_plane {
+	struct drm_device *dev;
+	struct device kdev;
+	struct device_attribute *attr;
+	struct list_head head;
+
+	struct drm_mode_object base;
+
+	uint32_t possible_crtcs;
+	uint32_t *format_types;
+	uint32_t format_count;
+
+	struct drm_crtc *crtc;
+	struct drm_framebuffer *fb;
+
+	/* CRTC gamma size for reporting to userspace */
+	uint32_t gamma_size;
+	uint16_t *gamma_store;
+
+	bool enabled;
+
+	const struct drm_plane_funcs *funcs;
+	void *helper_private;
+};
+
+/**
   * struct drm_mode_set
   *
   * Represents a single crtc the connectors that it drives with what mode
@@ -589,6 +643,8 @@ struct drm_mode_config {
  	struct list_head connector_list;
  	int num_encoder;
  	struct list_head encoder_list;
+	int num_plane;
+	struct list_head plane_list;
 
  	int num_crtc;
  	struct list_head crtc_list;
@@ -641,6 +697,7 @@ struct drm_mode_config {
  #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
  #define obj_to_property(x) container_of(x, struct drm_property, base)
  #define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
+#define obj_to_plane(x) container_of(x, struct drm_plane, base)
 
 
  extern void drm_crtc_init(struct drm_device *dev,
@@ -660,6 +717,13 @@ extern void drm_encoder_init(struct drm_device *dev,
  			     const struct drm_encoder_funcs *funcs,
  			     int encoder_type);
 
+extern void drm_plane_init(struct drm_device *dev,
+			   struct drm_plane *plane,
+			   unsigned long possible_crtcs,
+			   const struct drm_plane_funcs *funcs,
+			   uint32_t *formats, uint32_t format_count);
+extern void drm_plane_cleanup(struct drm_plane *plane);
+
  extern void drm_encoder_cleanup(struct drm_encoder *encoder);
 
  extern char *drm_get_connector_name(struct drm_connector *connector);
@@ -753,13 +817,18 @@ extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
  /* IOCTLs */
  extern int drm_mode_getresources(struct drm_device *dev,
  				 void *data, struct drm_file *file_priv);
-
+extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
+				   struct drm_file *file_priv);
  extern int drm_mode_getcrtc(struct drm_device *dev,
  			    void *data, struct drm_file *file_priv);
  extern int drm_mode_getconnector(struct drm_device *dev,
  			      void *data, struct drm_file *file_priv);
  extern int drm_mode_setcrtc(struct drm_device *dev,
  			    void *data, struct drm_file *file_priv);
+extern int drm_mode_getplane(struct drm_device *dev,
+			       void *data, struct drm_file *file_priv);
+extern int drm_mode_setplane(struct drm_device *dev,
+			       void *data, struct drm_file *file_priv);
  extern int drm_mode_cursor_ioctl(struct drm_device *dev,
  				void *data, struct drm_file *file_priv);
  extern int drm_mode_addfb(struct drm_device *dev,
include/drm/drm_mode.h +17 -0
index c4961ea..07711b0 100644
@@ -120,6 +120,39 @@ struct drm_mode_crtc {
  	struct drm_mode_modeinfo mode;
  };
 
+/* Planes blend with or override other bits on the CRTC */
+struct drm_mode_set_plane {
+	__u32 plane_id;
+	__u32 crtc_id;
+	__u32 fb_id; /* fb object contains surface format type */
+
+	/* Signed dest location allows it to be partially off screen */
+	__s32 crtc_x, crtc_y;
+	__u32 crtc_w, crtc_h;
+
+	/* Source values are 16.16 fixed point */
+	__u32 src_x, src_y;
+	__u32 src_h, src_w;
+};
+
+struct drm_mode_get_plane {
+	__u64 format_type_ptr;

include/drm/drm_mode.h struct drm_mode_crtc { · line 149

Quoted 10 lines
include/drm/drm_mode.h +10 -0
+	__u32 plane_id;
+
+	__u32 crtc_id;
+	__u32 fb_id;
+
+	__u32 possible_crtcs;
+	__u32 gamma_size;
+
+	__u32 count_format_types;
+};

I wonder why doesn't give to user crtc_x, crtc_y, crtc_w, crtc_h information?

include/drm/drm_mode.h struct drm_mode_crtc { · line 158

Quoted 9 lines
include/drm/drm_mode.h +6 -0
+
+struct drm_mode_get_plane_res {
+	__u64 plane_id_ptr;
+	__u32 count_planes;
+};
+
  #define DRM_MODE_ENCODER_NONE	0
  #define DRM_MODE_ENCODER_DAC	1
  #define DRM_MODE_ENCODER_TMDS	2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 11 lines · On Tue, 25 Oct 2011 19:53:02 +0900 Joonyoung Shim <[email protected]>…
Quoted 11 lines

+/**
+ * drm_plane - central DRM plane control structure
+ * @dev: DRM device this plane belongs to
+ * @kdev: kernel device
+ * @attr: kdev attributes
+ * @head: for list management
+ * @base: base mode object
+ * @crtc_x: x position of plane (relative to pipe base)
+ * @crtc_y: y position of plane
+ * @x: x offset into fb
+ * @y: y offset into fb

Quoted 1 line

Above 4 members don't be used.

Oops yeah, I'll fix up the comments.

Quoted 8 lines
Quoted 8 lines
include/drm/drm_mode.h +8 -0
+
+struct drm_mode_get_plane {
+	__u64 format_type_ptr;
+	__u32 plane_id;
+
+	__u32 crtc_id;
+	__u32 fb_id;
+
Quoted 8 lines

include/drm/drm_mode.h struct drm_mode_crtc { · line 149

Quoted 5 lines
include/drm/drm_mode.h +5 -0
+	__u32 possible_crtcs;
+	__u32 gamma_size;
+
+	__u32 count_format_types;
+};

I wonder why doesn't give to user crtc_x, crtc_y, crtc_w, crtc_h information?

It could, but the caller should already know was my thinking. Would you like those bits returned?

Jesse

#4 lore raw

Re: [PATCH 01/11] drm: add plane support

10/25/2011 08:18 PM, Jesse Barnes 쓴 글:

Quoted 31 lines
Quoted 11 lines · On Tue, 25 Oct 2011 19:53:02 +0900 Joonyoung Shim<[email protected]>…
Quoted 11 lines

+/**
+ * drm_plane - central DRM plane control structure
+ * @dev: DRM device this plane belongs to
+ * @kdev: kernel device
+ * @attr: kdev attributes
+ * @head: for list management
+ * @base: base mode object
+ * @crtc_x: x position of plane (relative to pipe base)
+ * @crtc_y: y position of plane
+ * @x: x offset into fb
+ * @y: y offset into fb

Quoted 1 line

Above 4 members don't be used.

Oops yeah, I'll fix up the comments.

Quoted 7 lines
Quoted 7 lines
include/drm/drm_mode.h +7 -0
+
+struct drm_mode_get_plane {
+	__u64 format_type_ptr;
+	__u32 plane_id;
+
+	__u32 crtc_id;
+	__u32 fb_id;
Quoted 8 lines

include/drm/drm_mode.h struct drm_mode_crtc { · line 149

Quoted 6 lines
include/drm/drm_mode.h +6 -0
+
+	__u32 possible_crtcs;
+	__u32 gamma_size;
+
+	__u32 count_format_types;
+};

I wonder why doesn't give to user crtc_x, crtc_y, crtc_w, crtc_h information?

Quoted 2 lines

It could, but the caller should already know was my thinking. Would you like those bits returned?

I saw such codes in initial your RFC patch version so i just have wondered why it is removed. It can be added later if needs.

Thanks.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw

Re: [PATCH 01/11] drm: add plane support

In reply to Jesse Barnes
Quoted 5 lines · Jesse Barnes

Planes are a bit like half-CRTCs. They have a location and fb, but don't drive outputs directly. Add support for handling them to the core KMS code.

As discussed with Jesse on irc, drm fb handling is fragile. Current rules:
- fbs are not reference counted, hence when destroying we need to disable all crtcs (and now also planes) that use them. drm_framebuffer_cleanup does that atm
- drivers that hold onto fbs after the kms core drops the corresponding pointer needs to hold a ref onto the underlying backing storage (like e.g. for pageflip on the to-be-flipped-out fb as long as it might still be scanned out).

We need proper refcounting for these ... But for now this patch is missing the plane cleanup in drm_framebuffer_cleanup.

Otherwise I think going with just the src and dst rect for set_plane is about the only sensible thing given the crazy hw out there. But I lack the knowledge about that kind of hw (and video stuff in general), so I'll refrain from slapping my r-b on these two.

Cheers, Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#6 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 17 lines · On Tue, 25 Oct 2011 13:58:55 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 5 lines · Jesse Barnes

Planes are a bit like half-CRTCs. They have a location and fb, but don't drive outputs directly. Add support for handling them to the core KMS code.

As discussed with Jesse on irc, drm fb handling is fragile. Current rules:
- fbs are not reference counted, hence when destroying we need to disable all crtcs (and now also planes) that use them. drm_framebuffer_cleanup does that atm
- drivers that hold onto fbs after the kms core drops the corresponding pointer needs to hold a ref onto the underlying backing storage (like e.g. for pageflip on the to-be-flipped-out fb as long as it might still be scanned out).

Quoted 2 lines

We need proper refcounting for these ... But for now this patch is missing the plane cleanup in drm_framebuffer_cleanup.

Ah yeah that's a better place for the disable plane call I currently have in the intel specific code... I'll fix up and test.

Quoted 4 lines

Otherwise I think going with just the src and dst rect for set_plane is about the only sensible thing given the crazy hw out there. But I lack the knowledge about that kind of hw (and video stuff in general), so I'll refrain from slapping my r-b on these two.

Yeah, I think the drivers just need to be able to calculate the scaling level from the params and program them into whatever regs they happen to have (on Intel fortunately the scaling is figured out by hw when we program in the source & dest values, subject to some restrictions).

Thanks,
Jesse

#7 lore raw

Re: [PATCH 01/11] drm: add plane support

In reply to Daniel Vetter
Quoted 17 lines · On Tue, 25 Oct 2011 13:58:55 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 5 lines · Jesse Barnes

Planes are a bit like half-CRTCs. They have a location and fb, but don't drive outputs directly. Add support for handling them to the core KMS code.

As discussed with Jesse on irc, drm fb handling is fragile. Current rules:
- fbs are not reference counted, hence when destroying we need to disable all crtcs (and now also planes) that use them. drm_framebuffer_cleanup does that atm
- drivers that hold onto fbs after the kms core drops the corresponding pointer needs to hold a ref onto the underlying backing storage (like e.g. for pageflip on the to-be-flipped-out fb as long as it might still be scanned out).

Quoted 2 lines

We need proper refcounting for these ... But for now this patch is missing the plane cleanup in drm_framebuffer_cleanup.

Ah yeah that's a better place for the disable plane call I currently have in the intel specific code... I'll fix up and test.

Quoted 4 lines

Otherwise I think going with just the src and dst rect for set_plane is about the only sensible thing given the crazy hw out there. But I lack the knowledge about that kind of hw (and video stuff in general), so I'll refrain from slapping my r-b on these two.

Yeah, I think the drivers just need to be able to calculate the scaling level from the params and program them into whatever regs they happen to have (on Intel fortunately the scaling is figured out by hw when we program in the source & dest values, subject to some restrictions).

Thanks,
Jesse

#8 lore raw

Re: [PATCH 01/11] drm: add plane support

In reply to Daniel Vetter
Quoted 11 lines

As discussed with Jesse on irc, drm fb handling is fragile. Current rules:
- fbs are not reference counted, hence when destroying we need to disable all crtcs (and now also planes) that use them. drm_framebuffer_cleanup does that atm
- drivers that hold onto fbs after the kms core drops the corresponding pointer needs to hold a ref onto the underlying backing storage (like e.g. for pageflip on the to-be-flipped-out fb as long as it might still be scanned out).

We need proper refcounting for these ... But for now this patch is missing the plane cleanup in drm_framebuffer_cleanup.

I'd rather we fixed the framebuffer kref stuff as part of doing this rather than have a poorer API because of something we have to fix anyway.

It shouldn't be *that* hard to fix, at least for this kind of use case. Resize locking, fb moving etc are ugly issues, refcount shouldn't be, and the tty layer also refcounts so we can only have the fb objects themselves to worry about as we can defer fb destruction to tty close or drm last unref even for those with consoles on them.

Alan

#9 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 17 lines · On Tue, 25 Oct 2011 14:26:07 +0100 Alan Cox <[email protected]> wrote:
Quoted 10 lines

As discussed with Jesse on irc, drm fb handling is fragile. Current rules:
- fbs are not reference counted, hence when destroying we need to disable all crtcs (and now also planes) that use them. drm_framebuffer_cleanup does that atm
- drivers that hold onto fbs after the kms core drops the corresponding pointer needs to hold a ref onto the underlying backing storage (like e.g. for pageflip on the to-be-flipped-out fb as long as it might still be scanned out).

Quoted 2 lines

We need proper refcounting for these ... But for now this patch is missing the plane cleanup in drm_framebuffer_cleanup.

I'd rather we fixed the framebuffer kref stuff as part of doing this rather than have a poorer API because of something we have to fix anyway.

Quoted 6 lines

It shouldn't be *that* hard to fix, at least for this kind of use case. Resize locking, fb moving etc are ugly issues, refcount shouldn't be, and the tty layer also refcounts so we can only have the fb objects themselves to worry about as we can defer fb destruction to tty close or drm last unref even for those with consoles on them.

Oh it doesn't affect the userspace API so I don't think it's urgent. But I agree, it would be nice to clean up fb management a bit... Any volunteers? :)

Thanks,
Jesse

#10 lore raw

Re: [PATCH 01/11] drm: add plane support

In reply to Alan Cox
Quoted 9 lines · Alan Cox
Quoted 9 lines

As discussed with Jesse on irc, drm fb handling is fragile. Current rules:
- fbs are not reference counted, hence when destroying we need to disable all crtcs (and now also planes) that use them. drm_framebuffer_cleanup does that atm
- drivers that hold onto fbs after the kms core drops the corresponding pointer needs to hold a ref onto the underlying backing storage (like e.g. for pageflip on the to-be-flipped-out fb as long as it might still be scanned out).

Quoted 5 lines
Quoted 2 lines

We need proper refcounting for these ... But for now this patch is missing the plane cleanup in drm_framebuffer_cleanup.

I'd rather we fixed the framebuffer kref stuff as part of doing this rather than have a poorer API because of something we have to fix anyway.

Imo we should do things piece by piece. Fixing up drm fb refcounting is imo a rather low-prio thing for core drm. And I've already asked Rob Clarke whether he can clean up some of the confiusion in the kms framebuffer->destroy() functions.

Quoted 4 lines

It shouldn't be *that* hard to fix, at least for this kind of use case. Resize locking, fb moving etc are ugly issues, refcount shouldn't be, and the tty layer also refcounts so we can only have the fb objects themselves to worry about as we can defer fb destruction to tty close or

I'm talking solely about kms framebuffers. I.e. completely orthogonal to any issues you're seeing wrt kms<->linux fb subsystem integration. Or I'm completely misunderstanding you here ...
-Daniel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#11 lore raw

Re: [PATCH 01/11] drm: add plane support

In reply to Jesse Barnes

Here's a diff I can roll in if it looks ok. It adds the ability to specify multiple handles for a single fb to better accommodate planar configs. I think Rob has convinced me that this is a good idea... comments appreciated.

Thanks,
Jesse

drivers/gpu/drm/drm_crtc.c +2 -1
index a30b9d4..0cc2077 100644
@@ -1923,7 +1923,8 @@ int drm_mode_addfb(struct drm_device *dev,
 	r.bpp = or->bpp;
 	r.depth = or->depth;
 	r.pixel_format = 0;
-	r.handle = or->handle;
+	r.handle_count = 1;
+	r.handles = (u64)&or->handle;
 
 	if (!drm_core_check_feature(dev, DRIVER_MODESET))
 		return -EINVAL;
drivers/gpu/drm/i915/intel_display.c +2 -1
index cd7e04d..2c7f200 100644
@@ -7619,8 +7619,9 @@ intel_user_framebuffer_create(struct drm_device *dev,
 			      struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct drm_i915_gem_object *obj;
+	u32 *handles = (u32 *)mode_cmd->handles;
 
-	obj = to_intel_bo(drm_gem_object_lookup(dev, filp, mode_cmd->handle));
+	obj = to_intel_bo(drm_gem_object_lookup(dev, filp, handles[0]));
 	if (&obj->base == NULL)
 		return ERR_PTR(-ENOENT);
 
drivers/gpu/drm/nouveau/nouveau_display.c +2 -1
index 7a428a9..cb9b868 100644
@@ -128,9 +128,10 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
 {
 	struct nouveau_framebuffer *nouveau_fb;
 	struct drm_gem_object *gem;
+	u32 *handles = (u32 *)mode_cmd->handles;
 	int ret;
 
-	gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handle);
+	gem = drm_gem_object_lookup(dev, file_priv, handles);
 	if (!gem)
 		return ERR_PTR(-ENOENT);
 
drivers/gpu/drm/radeon/radeon_display.c +3 -2
index ae803f8..63a6d91 100644
@@ -1128,11 +1128,12 @@ radeon_user_framebuffer_create(struct drm_device *dev,
 {
 	struct drm_gem_object *obj;
 	struct radeon_framebuffer *radeon_fb;
+	u32 *handles = (u32 *)mode_cmd->handles;
 
-	obj = drm_gem_object_lookup(dev, file_priv, mode_cmd->handle);
+	obj = drm_gem_object_lookup(dev, file_priv, handles[0]);
 	if (obj ==  NULL) {
 		dev_err(&dev->pdev->dev, "No GEM object associated to handle 0x%08X, "
-			"can't create framebuffer\n", mode_cmd->handle);
+			"can't create framebuffer\n", handles[0]);
 		return ERR_PTR(-ENOENT);
 	}
 
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1 -1
index 2a1b802..0ad7456 100644
@@ -866,7 +866,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
 	 */
 
 	ret = vmw_user_surface_lookup_handle(dev_priv, tfile,
-					     mode_cmd->handle, &surface);
+					     mode_cmd->handles[0], &surface);
 	if (ret)
 		goto try_dmabuf;
 
drivers/staging/gma500/framebuffer.c +1 -1
index 85f47d5..ee91ffe 100644
@@ -496,7 +496,7 @@ static struct drm_framebuffer *psb_user_framebuffer_create
 	 *	Find the GEM object and thus the gtt range object that is
 	 *	to back this space
 	 */
-	obj = drm_gem_object_lookup(dev, filp, cmd->handle);
+	obj = drm_gem_object_lookup(dev, filp, cmd->handles[0]);
 	if (obj == NULL)
 		return ERR_PTR(-ENOENT);
 
include/drm/drm_mode.h +3 -2
index 34a0d22..dafe8df 100644
@@ -272,8 +272,9 @@ struct drm_mode_fb_cmd2 {
 	__u32 bpp;
 	__u32 depth;
 	__u32 pixel_format; /* fourcc code from videodev2.h */
-	/* driver specific handle */
-	__u32 handle;
+	__u32 handle_count;
+	/* driver specific buffer object handle array */
+	__u64 handles;
 };
 
 #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
#12 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 7 lines · Jesse Barnes
include/drm/drm_mode.h +0 -0
index 34a0d22..dafe8df 100644
@@ -272,8 +272,9 @@ struct drm_mode_fb_cmd2 {
        __u32 bpp;
        __u32 depth;
Quoted 7 lines

       __u32 pixel_format; /* fourcc code from videodev2.h */
-       /* driver specific handle */
-       __u32 handle;
+       __u32 handle_count;
+       /* driver specific buffer object handle array */
+       __u64 handles;
 };

Ok, after a bit of discussion with Jakob on IRC, this is what we arrived at:

1) It would be nice to have the option for multi-planar formats to be able to use one single buffer object, or one buffer object per plane. In the case of one buffer per plane, the order is dictated by the fourcc.

2) We do need per-plane stride for some formats, in particular I420 which is a bit ambiguous otherwise (ie. is the stride of the U and V planes half the stride as the Y plane, or the same?)

3) Maybe we need per-plane offsets, but I think this case could be handled by just using one bo per plane, so left it out

4) bpp/depth are redundant w/ the pixel_format. Just in case, as a future placeholder, and inspired by 'struct v4l2_pix_format', add a priv field. Although making the field big enough to hold a pointer if absolutely really needed.

struct drm_mode_fb_cmd2 {
__u32 fb_id;
__u32 width, height;
__u32 pixel_format; /* fourcc code from videodev2.h */ __u64 priv; /* private data, depends on pixelformat */

/* in case of planar formats, either one buffer object,
* or one buffer object per plane, is allowed. In the
* case per-plane bo's, the order is dictated by the
* fourcc.. ie. NV12 (http://fourcc.org/yuv.php#NV12)
* is described as:
*

   *   YUV 4:2:0 image with a plane of 8 bit Y samples
   *   followed by an interleaved U/V plane containing
   *   8 bit 2x2 subsampled colour difference samples.
   *
   * So it would consist of Y as first buffer and UV as
   * second buffer.  In the case that only a single bo
   * is used then buffer[1].handle should be zero.  (But
   * a plane specific pitch could still be specified.)
   */
  struct {
    __u32 pitch;
    /* driver specific handle */
    __u32 handle;

} buffer[16];
};

BR,
-R

#13 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 48 lines · Rob Clark
Quoted 7 lines · Jesse Barnes
include/drm/drm_mode.h +0 -0
index 34a0d22..dafe8df 100644
@@ -272,8 +272,9 @@ struct drm_mode_fb_cmd2 {
        __u32 bpp;
        __u32 depth;
Quoted 7 lines

       __u32 pixel_format; /* fourcc code from videodev2.h */
-       /* driver specific handle */
-       __u32 handle;
+       __u32 handle_count;
+       /* driver specific buffer object handle array */
+       __u64 handles;
 };

Ok, after a bit of discussion with Jakob on IRC, this is what we arrived at:

1) It would be nice to have the option for multi-planar formats to be able to use one single buffer object, or one buffer object per plane. In the case of one buffer per plane, the order is dictated by the fourcc.

2) We do need per-plane stride for some formats, in particular I420 which is a bit ambiguous otherwise (ie. is the stride of the U and V planes half the stride as the Y plane, or the same?)

3) Maybe we need per-plane offsets, but I think this case could be handled by just using one bo per plane, so left it out

4) bpp/depth are redundant w/ the pixel_format. Just in case, as a future placeholder, and inspired by 'struct v4l2_pix_format', add a priv field. Although making the field big enough to hold a pointer if absolutely really needed.

struct drm_mode_fb_cmd2 {
__u32 fb_id;
__u32 width, height;
__u32 pixel_format; /* fourcc code from videodev2.h */ __u64 priv; /* private data, depends on pixelformat */

/* in case of planar formats, either one buffer object,
* or one buffer object per plane, is allowed. In the
* case per-plane bo's, the order is dictated by the
* fourcc.. ie. NV12 (http://fourcc.org/yuv.php#NV12)
* is described as:
*

Quoted 13 lines
   *   YUV 4:2:0 image with a plane of 8 bit Y samples
   *   followed by an interleaved U/V plane containing
   *   8 bit 2x2 subsampled colour difference samples.
   *
   * So it would consist of Y as first buffer and UV as
   * second buffer.  In the case that only a single bo
   * is used then buffer[1].handle should be zero.  (But
   * a plane specific pitch could still be specified.)
   */
  struct {
    __u32 pitch;
    /* driver specific handle */
    __u32 handle;

Why not just add a

	__u32 offset;
	__u32 rsvd;
and call it a day. This thing is pretty big already, so that bloat doesn't
matter that much. Maybe spec that buffer[0].offset must be zero. With that
you can also do I420 with the following layout
+-------+
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
+---+---+
|UUU|VVV|
|UUU|VVV|
+---+---+

i.e. stride_U == stride_V, with their lines meshed into one line. -Daniel

Quoted 10 lines

} buffer[16];
};

BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 3 lines
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
#14 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 79 lines · Daniel Vetter
Quoted 53 lines · Rob Clark
Quoted 7 lines · Jesse Barnes
include/drm/drm_mode.h +0 -0
index 34a0d22..dafe8df 100644
@@ -272,8 +272,9 @@ struct drm_mode_fb_cmd2 {
        __u32 bpp;
        __u32 depth;
Quoted 7 lines

       __u32 pixel_format; /* fourcc code from videodev2.h */
-       /* driver specific handle */
-       __u32 handle;
+       __u32 handle_count;
+       /* driver specific buffer object handle array */
+       __u64 handles;
 };

Ok, after a bit of discussion with Jakob on IRC, this is what we arrived at:

1) It would be nice to have the option for multi-planar formats to be able to use one single buffer object, or one buffer object per plane. In the case of one buffer per plane, the order is dictated by the fourcc.

2) We do need per-plane stride for some formats, in particular I420 which is a bit ambiguous otherwise (ie. is the stride of the U and V planes half the stride as the Y plane, or the same?)

3) Maybe we need per-plane offsets, but I think this case could be handled by just using one bo per plane, so left it out

4) bpp/depth are redundant w/ the pixel_format. Just in case, as a future placeholder, and inspired by 'struct v4l2_pix_format', add a priv field.  Although making the field big enough to hold a pointer if absolutely really needed.

struct drm_mode_fb_cmd2 {
  __u32 fb_id;
  __u32 width, height;
  __u32 pixel_format; /* fourcc code from videodev2.h */ __u64 priv;  /* private data, depends on pixelformat */

  /* in case of planar formats, either one buffer object,
   * or one buffer object per plane, is allowed.  In the
   * case per-plane bo's, the order is dictated by the
   * fourcc.. ie. NV12 (http://fourcc.org/yuv.php#NV12)
   * is described as:
   *
   *   YUV 4:2:0 image with a plane of 8 bit Y samples
   *   followed by an interleaved U/V plane containing
   *   8 bit 2x2 subsampled colour difference samples. *
   * So it would consist of Y as first buffer and UV as

Quoted 8 lines

   * second buffer.  In the case that only a single bo
   * is used then buffer[1].handle should be zero.  (But
   * a plane specific pitch could still be specified.) */
  struct {
    __u32 pitch;
    /* driver specific handle */
    __u32 handle;

Why not just add a
       __u32 offset;
       __u32 rsvd;
and call it a day. This thing is pretty big already, so that bloat doesn't matter that much. Maybe spec that buffer[0].offset must be zero. With that you can also do I420 with the following layout

+-------+
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
+---+---+
|UUU|VVV|
|UUU|VVV|
+---+---+
Quoted 3 lines

i.e. stride_U == stride_V, with their lines meshed into one line. -Daniel

I've no objection to an offset field.. I was mostly just trying to avoid that we keep adding things until we get XvImageFormatValues..

We should either add an offset plus pad field as Daniel suggested, or at least add a u64 reserved field which could be made into made into an offset field later if needed.

OTOH, is the format you described *really* still I420?

BR,
-R

Quoted 20 lines
Quoted 10 lines

  } buffer[16];
 };

BR,
-R
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Mail: [email protected]
Mobile: +41 (0)79 365 57 48
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

Re: [PATCH 01/11] drm: add plane support

In reply to Daniel Vetter

Daniel Vetter <daniel <at> ffwll.ch> writes:

[snip]

Quoted 6 lines
Quoted 6 lines

struct drm_mode_fb_cmd2 {
__u32 fb_id;
__u32 width, height;
__u32 pixel_format; /* fourcc code from videodev2.h */ __u64 priv; /* private data, depends on pixelformat */

[snip]

Quoted 8 lines
Quoted 4 lines
  struct {
    __u32 pitch;
    /* driver specific handle */
    __u32 handle;

Why not just add a

	__u32 offset;
	__u32 rsvd;

For normal NV12 format, I agree that just offset is enough.
But considering more specific format like NV12M, that has two separated memory spaces, IMHO, it needs handle per each plane.

Each plane of NV12M has it own base address and space between these two memory spaces can be used by others.

You can refer following link about NV12M used by V4L2.
http://linuxtv.org/downloads/v4l-dvb-apis/V4L2-PIX-FMT-NV12M.html

Quoted 13 lines

and call it a day. This thing is pretty big already, so that bloat doesn't matter that much. Maybe spec that buffer[0].offset must be zero. With that you can also do I420 with the following layout

+-------+
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
+---+---+
|UUU|VVV|
|UUU|VVV|
+---+---+
Quoted 4 lines

i.e. stride_U == stride_V, with their lines meshed into one line. -Daniel

Quoted 1 line
  } buffer[16];

and just question, is there any meaning about buffer array size 16?

Quoted 1 line
Quoted 1 line

};

[snip]

Thanks and Regards,
- SW Kim

#16 lore raw

Re: [PATCH 01/11] drm: add plane support

Hi, all.

Quoted 19 lines · SW Kim <devusr.opensw <at> gmail.com> writes:

Daniel Vetter <daniel <at> ffwll.ch> writes:

[snip]

Quoted 6 lines
Quoted 6 lines

struct drm_mode_fb_cmd2 {
__u32 fb_id;
__u32 width, height;
__u32 pixel_format; /* fourcc code from videodev2.h */ __u64 priv; /* private data, depends on pixelformat */

[snip]

Quoted 5 lines
Quoted 4 lines
  struct {
    __u32 pitch;
    /* driver specific handle */
    __u32 handle;
Quoted 6 lines
Quoted 3 lines

Why not just add a

	__u32 offset;
	__u32 rsvd;

For normal NV12 format, I agree that just offset is enough. But considering more specific format like NV12M, that has two separated

memory

Quoted 3 lines

spaces, IMHO, it needs handle per each plane.

Each plane of NV12M has it own base address and space between these two

memory

Quoted 23 lines

spaces can be used by others.

You can refer following link about NV12M used by V4L2.
http://linuxtv.org/downloads/v4l-dvb-apis/V4L2-PIX-FMT-NV12M.html

Quoted 13 lines

and call it a day. This thing is pretty big already, so that bloat doesn't matter that much. Maybe spec that buffer[0].offset must be zero. With that you can also do I420 with the following layout

+-------+
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
|YYYYYYY|
+---+---+
|UUU|VVV|
|UUU|VVV|
+---+---+
Quoted 4 lines

i.e. stride_U == stride_V, with their lines meshed into one line. -Daniel

Quoted 1 line
  } buffer[16];
Quoted 9 lines

and just question, is there any meaning about buffer array size 16?

Quoted 1 line
Quoted 1 line

};

[snip]

Thanks and Regards,
- SW Kim

I have a opinion for multi planer. before that, I'd like to mention some considerations.

I think adding any variables such as offset or handle(as plane count) to drm_mode_fb_cmd2 structure could occurs that in application point of view, user could be confused because with the ways above, user needs to allocate buffers as plane count(it depends on pixel format) and also user should know buffer size according to pixel format. so I think it's good way that user sets only pixel format and resolution(width, height) and then specific gem framework allocates buffers according to pixel format as plane count and then user sets the gem handle to drm_mode_fb_cmd2 structure. specific gem framework could get all buffers through only the gem handle.

below is my simple idea.
1. user requests buffer allocation with pixel format and resolution through gem framework.
2. gem framework checks pixel format.
3. specific gem framework allocates buffers as plane count according to the pixel format. (please, know that gem framework provides just interface so acctual implementation would be done at specific gem framework)
4. user gets the gem handle from gem framework.
5. user sets the gem handle to specific drm framebuffer through drm_mode_addfb2 function.
6. user requests setcrtc with fb id and crtc id.
7. drm framework sets framebuffer(corresponding to fb id) to drm_mode_set.
8. crtc calls set_config callbacks to configure hardware.
9. specific crtc framework gets all buffers through framebuffer(actually, it would be specific framebuffer)and sets them to overlay registers of hardware appropriately.

like this, how about using framebuffer and gem framework instead of plane? I'd be glad to give me your opinions.

Thank you,
Inki Dae.

#17 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 18 lines · On Mon, 31 Oct 2011 11:40:57 +0000 (UTC) Inki Dae <[email protected]> wrote:

below is my simple idea.
1. user requests buffer allocation with pixel format and resolution through gem framework.
2. gem framework checks pixel format.
3. specific gem framework allocates buffers as plane count according to the pixel format. (please, know that gem framework provides just interface so acctual implementation would be done at specific gem framework)
4. user gets the gem handle from gem framework.
5. user sets the gem handle to specific drm framebuffer through drm_mode_addfb2 function.
6. user requests setcrtc with fb id and crtc id.
7. drm framework sets framebuffer(corresponding to fb id) to drm_mode_set.
8. crtc calls set_config callbacks to configure hardware.
9. specific crtc framework gets all buffers through framebuffer(actually, it would be specific framebuffer)and sets them to overlay registers of hardware appropriately.

Quoted 2 lines

like this, how about using framebuffer and gem framework instead of plane? I'd be glad to give me your opinions.

I'm not opposed to pushing the multi-object stuff into GEM instead, but I don't think step (9) will be enough to avoid having a separate plane object. Say the user passes in 3 RGB buffers. How do you know which one is the primary and which are overlays? Or are you saying the fb would have that information as well? If so, it would be a little harder to specify things like blending options or colorspace correction on a per-plane basis...

But maybe I'm missing some part of things; do you have any patches to illustrate what you mean? I can see how it might work, but I don't know if it would be any simpler or cleaner than exposing plane objects.

Thanks,

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

Re: [PATCH 01/11] drm: add plane support

Hi, Jesse.

Quoted 5 lines · Jesse Barnes <jbarnes <at> virtuousgeek.org> writes:
Quoted 2 lines · On Mon, 31 Oct 2011 11:40:57 +0000 (UTC) Inki Dae <daeinki <at> gmail.com>…

below is my simple idea.
1. user requests buffer allocation with pixel format and resolution

through

Quoted 3 lines
Quoted 3 lines

gem framework.
2. gem framework checks pixel format.
3. specific gem framework allocates buffers as plane count according to

the

Quoted 9 lines
Quoted 9 lines

pixel format. (please, know that gem framework provides just interface so acctual implementation would be done at specific gem framework)
4. user gets the gem handle from gem framework.
5. user sets the gem handle to specific drm framebuffer through drm_mode_addfb2 function.
6. user requests setcrtc with fb id and crtc id.
7. drm framework sets framebuffer(corresponding to fb id) to drm_mode_set.
8. crtc calls set_config callbacks to configure hardware.
9. specific crtc framework gets all buffers through framebuffer(actually,

it

Quoted 1 line
Quoted 1 line

would be specific framebuffer)and sets them to overlay registers of

hardware

Quoted 4 lines
Quoted 4 lines

appropriately.

like this, how about using framebuffer and gem framework instead of plane?

I'd

Quoted 10 lines
Quoted 1 line

be glad to give me your opinions.

I'm not opposed to pushing the multi-object stuff into GEM instead, but I don't think step (9) will be enough to avoid having a separate plane object. Say the user passes in 3 RGB buffers. How do you know which one is the primary and which are overlays? Or are you saying the fb would have that information as well? If so, it would be a little harder to specify things like blending options or colorspace correction on a per-plane basis...

Quoted 5 lines

But maybe I'm missing some part of things; do you have any patches to illustrate what you mean? I can see how it might work, but I don't know if it would be any simpler or cleaner than exposing plane objects.

Thanks,

Sorry, there is my missing point. please, ignor step 6 ~ 9.
if user requests setplane then drm_mode_setplane function gets fb and crtc object to update the overlay corresponding to plane id. at that time I think we could know which overlay should be set and how many buffers does the overlay has through specific framebuffer object if specific framebuffer has gem object.
in our case, specific framebuffer has gem object. and I would try to implement multi planer the way I mentioned if need and I will post the patch. this work takes about a week. I think the way that user allocates buffers for multi planer only with pixel format and resolution(width, height) would be good. but there could be more good ways then this way.

please give me your opinion and advices.

Thank you,
Inki Dae.

#19 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 6 lines · On Wed, 2 Nov 2011 02:20:58 +0000 (UTC) Inki Dae <[email protected]> wrote:

Sorry, there is my missing point. please, ignor step 6 ~ 9.
if user requests setplane then drm_mode_setplane function gets fb and crtc object to update the overlay corresponding to plane id. at that time I think we could know which overlay should be set and how many buffers does the overlay has through specific framebuffer object if specific framebuffer has gem object.

Right, that's the goal anyway.

Quoted 5 lines

in our case, specific framebuffer has gem object. and I would try to implement multi planer the way I mentioned if need and I will post the patch. this work takes about a week. I think the way that user allocates buffers for multi planer only with pixel format and resolution(width, height) would be good. but there could be more good ways then this way.

Ok, that would help. Rob and Daniel also wanted the addfb2 ioctl to be extended a bit more to handle planar formats and also to specify surface offsets. Now that I have the X driver working well enough to do clipping and multi-pipe, I'll update addfb2 and post an updated patchset today. You can see if it will address what you're trying to do with planar formats.

Thanks,

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#20 lore raw

Re: [PATCH 01/11] drm: add plane support

In reply to Jesse Barnes

10/25/2011 06:46 PM, Jesse Barnes 쓴 글:

[snip]

Quoted 26 lines
include/drm/drm_crtc.h +4 -0
index 8020798..d7f03aa 100644
@@ -44,6 +44,7 @@ struct drm_framebuffer;
  #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
  #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
  #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
+#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
 
  struct drm_mode_object {
  	uint32_t id;
@@ -278,6 +279,7 @@ struct drm_crtc;
  struct drm_connector;
  struct drm_encoder;
  struct drm_pending_vblank_event;
+struct drm_plane;
 
  /**
   * drm_crtc_funcs - control CRTCs for a given device
@@ -536,6 +538,58 @@ struct drm_connector {
  };
 
  /**
+ * drm_plane_funcs - driver plane control functions
+ * @update_plane: update the plane configuration

include/drm/drm_crtc.h struct drm_connector { · line 552

Quoted 10 lines
include/drm/drm_crtc.h +10 -0
+ */
+struct drm_plane_funcs {
+	int (*update_plane)(struct drm_plane *plane,
+			    struct drm_crtc *crtc, struct drm_framebuffer *fb,
+			    int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h);
+	int (*disable_plane)(struct drm_plane *plane);
+};

How about add destroy() function and call it in
drm_mode_config_cleanup()?

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#21 lore raw

Re: [PATCH 01/11] drm: add plane support

Quoted 26 lines · On Wed, 26 Oct 2011 14:40:07 +0900 Joonyoung Shim <[email protected]>…

10/25/2011 06:46 PM, Jesse Barnes 쓴 글:

[snip]

Quoted 23 lines
include/drm/drm_crtc.h +2 -0
index 8020798..d7f03aa 100644
@@ -44,6 +44,7 @@ struct drm_framebuffer;
  #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
  #define DRM_MODE_OBJECT_FB 0xfbfbfbfb
  #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
+#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
 
  struct drm_mode_object {
  	uint32_t id;
@@ -278,6 +279,7 @@ struct drm_crtc;
  struct drm_connector;
  struct drm_encoder;
  struct drm_pending_vblank_event;
+struct drm_plane;
 
  /**
   * drm_crtc_funcs - control CRTCs for a given device
@@ -536,6 +538,58 @@ struct drm_connector {
  };
 
Quoted 16 lines

include/drm/drm_crtc.h struct drm_connector { · line 552

Quoted 13 lines
include/drm/drm_crtc.h +12 -0
  /**
+ * drm_plane_funcs - driver plane control functions
+ * @update_plane: update the plane configuration
+ */
+struct drm_plane_funcs {
+	int (*update_plane)(struct drm_plane *plane,
+			    struct drm_crtc *crtc, struct drm_framebuffer *fb,
+			    int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h);
+	int (*disable_plane)(struct drm_plane *plane);
+};

How about add destroy() function and call it in
drm_mode_config_cleanup()?

Oh good idea; destroy will be needed for hot plug.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#22 lore raw

PATCH 2/11 drm: add an fb creation ioctl that takes a pixel format

In reply to Jesse Barnes

To properly support the various plane formats supported by different hardware, the kernel must know the pixel format of a framebuffer object. So add a new ioctl taking a format argument corresponding to a fourcc name from videodev2.h.

---
 drivers/gpu/drm/drm_crtc.c                |   71 ++++++++++++++++++++++++++++-
 drivers/gpu/drm/drm_crtc_helper.c         |    3 +-
 drivers/gpu/drm/drm_drv.c                 |    1 +
 drivers/gpu/drm/i915/intel_display.c      |    9 ++--
 drivers/gpu/drm/i915/intel_drv.h          |    2 +-
 drivers/gpu/drm/i915/intel_fb.c           |    3 +-
 drivers/gpu/drm/nouveau/nouveau_display.c |    4 +-
 drivers/gpu/drm/radeon/radeon_display.c   |    4 +-
 drivers/gpu/drm/radeon/radeon_fb.c        |    5 +-
 drivers/gpu/drm/radeon/radeon_mode.h      |    2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c       |    2 +-
 drivers/staging/gma500/framebuffer.c      |    2 +-
 include/drm/drm.h                         |    1 +
 include/drm/drm_crtc.h                    |    6 ++-
 include/drm/drm_crtc_helper.h             |    2 +-
 include/drm/drm_mode.h                    |   14 ++++++
 16 files changed, 112 insertions(+), 19 deletions(-)
drivers/gpu/drm/drm_crtc.c +70 -1
index 0e129b1..a30b9d4 100644
@@ -1909,7 +1909,76 @@ out:
 int drm_mode_addfb(struct drm_device *dev,
 		   void *data, struct drm_file *file_priv)
 {
-	struct drm_mode_fb_cmd *r = data;
+	struct drm_mode_fb_cmd *or = data;
+	struct drm_mode_fb_cmd2 r;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_framebuffer *fb;
+	int ret = 0;
+
+	/* Use new struct with format internally */
+	r.fb_id = or->fb_id;
+	r.width = or->width;
+	r.height = or->height;
+	r.pitch = or->pitch;
+	r.bpp = or->bpp;
+	r.depth = or->depth;
+	r.pixel_format = 0;
+	r.handle = or->handle;
+
+	if (!drm_core_check_feature(dev, DRIVER_MODESET))
+		return -EINVAL;
+
+	if ((config->min_width > r.width) || (r.width > config->max_width)) {
+		DRM_ERROR("mode new framebuffer width not within limits\n");
+		return -EINVAL;
+	}
+	if ((config->min_height > r.height) || (r.height > config->max_height)) {
+		DRM_ERROR("mode new framebuffer height not within limits\n");
+		return -EINVAL;
+	}
+
+	mutex_lock(&dev->mode_config.mutex);
+
+	/* TODO check buffer is sufficiently large */
+	/* TODO setup destructor callback */
+
+	fb = dev->mode_config.funcs->fb_create(dev, file_priv, &r);
+	if (IS_ERR(fb)) {
+		DRM_ERROR("could not create framebuffer\n");
+		ret = PTR_ERR(fb);
+		goto out;
+	}
+
+	or->fb_id = fb->base.id;
+	list_add(&fb->filp_head, &file_priv->fbs);
+	DRM_DEBUG_KMS("[FB:%d]\n", fb->base.id);
+
+out:
+	mutex_unlock(&dev->mode_config.mutex);
+	return ret;
+}
+
+/**
+ * drm_mode_addfb2 - add an FB to the graphics configuration
+ * @inode: inode from the ioctl
+ * @filp: file * from the ioctl
+ * @cmd: cmd from ioctl
+ * @arg: arg from ioctl
+ *
+ * LOCKING:
+ * Takes mode config lock.
+ *
+ * Add a new FB to the specified CRTC, given a user request with format.
+ *
+ * Called by the user via ioctl.
+ *
+ * RETURNS:
+ * Zero on success, errno on failure.
+ */
+int drm_mode_addfb2(struct drm_device *dev,
+		    void *data, struct drm_file *file_priv)
+{
+	struct drm_mode_fb_cmd2 *r = data;
 	struct drm_mode_config *config = &dev->mode_config;
 	struct drm_framebuffer *fb;
 	int ret = 0;
drivers/gpu/drm/drm_crtc_helper.c +2 -1
index f88a9b2..77c7293 100644
@@ -806,13 +806,14 @@ void drm_helper_connector_dpms(struct drm_connector *connector, int mode)
 EXPORT_SYMBOL(drm_helper_connector_dpms);
 
 int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
-				   struct drm_mode_fb_cmd *mode_cmd)
+				   struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	fb->width = mode_cmd->width;
 	fb->height = mode_cmd->height;
 	fb->pitch = mode_cmd->pitch;
 	fb->bits_per_pixel = mode_cmd->bpp;
 	fb->depth = mode_cmd->depth;
+	fb->pixel_format = mode_cmd->pixel_format;
 
 	return 0;
 }
drivers/gpu/drm/drm_drv.c +1 -0
index 15da618..f24b9b6 100644
@@ -152,6 +152,7 @@ static struct drm_ioctl_desc drm_ioctls[] = {
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
+	DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB2, drm_mode_addfb2, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_PAGE_FLIP, drm_mode_page_flip_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
 	DRM_IOCTL_DEF(DRM_IOCTL_MODE_DIRTYFB, drm_mode_dirtyfb_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW|DRM_UNLOCKED),
drivers/gpu/drm/i915/intel_display.c +5 -4
index 981b1f1..b1ae70b 100644
@@ -6279,7 +6279,7 @@ static struct drm_display_mode load_detect_mode = {
 
 static struct drm_framebuffer *
 intel_framebuffer_create(struct drm_device *dev,
-			 struct drm_mode_fb_cmd *mode_cmd,
+			 struct drm_mode_fb_cmd2 *mode_cmd,
 			 struct drm_i915_gem_object *obj)
 {
 	struct intel_framebuffer *intel_fb;
@@ -6321,7 +6321,7 @@ intel_framebuffer_create_for_mode(struct drm_device *dev,
 				  int depth, int bpp)
 {
 	struct drm_i915_gem_object *obj;
-	struct drm_mode_fb_cmd mode_cmd;
+	struct drm_mode_fb_cmd2 mode_cmd;
 
 	obj = i915_gem_alloc_object(dev,
 				    intel_framebuffer_size_for_mode(mode, bpp));
@@ -6333,6 +6333,7 @@ intel_framebuffer_create_for_mode(struct drm_device *dev,
 	mode_cmd.depth = depth;
 	mode_cmd.bpp = bpp;
 	mode_cmd.pitch = intel_framebuffer_pitch_for_width(mode_cmd.width, bpp);
+	mode_cmd.pixel_format = 0;
 
 	return intel_framebuffer_create(dev, &mode_cmd, obj);
 }
@@ -7573,7 +7574,7 @@ static const struct drm_framebuffer_funcs intel_fb_funcs = {
 
 int intel_framebuffer_init(struct drm_device *dev,
 			   struct intel_framebuffer *intel_fb,
-			   struct drm_mode_fb_cmd *mode_cmd,
+			   struct drm_mode_fb_cmd2 *mode_cmd,
 			   struct drm_i915_gem_object *obj)
 {
 	int ret;
@@ -7613,7 +7614,7 @@ int intel_framebuffer_init(struct drm_device *dev,
 static struct drm_framebuffer *
 intel_user_framebuffer_create(struct drm_device *dev,
 			      struct drm_file *filp,
-			      struct drm_mode_fb_cmd *mode_cmd)
+			      struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct drm_i915_gem_object *obj;
 
drivers/gpu/drm/i915/intel_drv.h +1 -1
index bd9a604..23c5622 100644
@@ -359,7 +359,7 @@ extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
 
 extern int intel_framebuffer_init(struct drm_device *dev,
 				  struct intel_framebuffer *ifb,
-				  struct drm_mode_fb_cmd *mode_cmd,
+				  struct drm_mode_fb_cmd2 *mode_cmd,
 				  struct drm_i915_gem_object *obj);
 extern int intel_fbdev_init(struct drm_device *dev);
 extern void intel_fbdev_fini(struct drm_device *dev);
drivers/gpu/drm/i915/intel_fb.c +2 -1
index ec49bae..11baa99 100644
@@ -65,7 +65,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct fb_info *info;
 	struct drm_framebuffer *fb;
-	struct drm_mode_fb_cmd mode_cmd;
+	struct drm_mode_fb_cmd2 mode_cmd;
 	struct drm_i915_gem_object *obj;
 	struct device *device = &dev->pdev->dev;
 	int size, ret;
@@ -80,6 +80,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
 	mode_cmd.bpp = sizes->surface_bpp;
 	mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 64);
 	mode_cmd.depth = sizes->surface_depth;
+	mode_cmd.pixel_format = 0;
 
 	size = mode_cmd.pitch * mode_cmd.height;
 	size = ALIGN(size, PAGE_SIZE);
drivers/gpu/drm/nouveau/nouveau_display.c +2 -2
index ddbabef..7a428a9 100644
@@ -64,7 +64,7 @@ static const struct drm_framebuffer_funcs nouveau_framebuffer_funcs = {
 int
 nouveau_framebuffer_init(struct drm_device *dev,
 			 struct nouveau_framebuffer *nv_fb,
-			 struct drm_mode_fb_cmd *mode_cmd,
+			 struct drm_mode_fb_cmd2 *mode_cmd,
 			 struct nouveau_bo *nvbo)
 {
 	struct drm_nouveau_private *dev_priv = dev->dev_private;
@@ -124,7 +124,7 @@ nouveau_framebuffer_init(struct drm_device *dev,
 static struct drm_framebuffer *
 nouveau_user_framebuffer_create(struct drm_device *dev,
 				struct drm_file *file_priv,
-				struct drm_mode_fb_cmd *mode_cmd)
+				struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct nouveau_framebuffer *nouveau_fb;
 	struct drm_gem_object *gem;
drivers/gpu/drm/radeon/radeon_display.c +2 -2
index 6cc17fb..ae803f8 100644
@@ -1113,7 +1113,7 @@ static const struct drm_framebuffer_funcs radeon_fb_funcs = {
 void
 radeon_framebuffer_init(struct drm_device *dev,
 			struct radeon_framebuffer *rfb,
-			struct drm_mode_fb_cmd *mode_cmd,
+			struct drm_mode_fb_cmd2 *mode_cmd,
 			struct drm_gem_object *obj)
 {
 	rfb->obj = obj;
@@ -1124,7 +1124,7 @@ radeon_framebuffer_init(struct drm_device *dev,
 static struct drm_framebuffer *
 radeon_user_framebuffer_create(struct drm_device *dev,
 			       struct drm_file *file_priv,
-			       struct drm_mode_fb_cmd *mode_cmd)
+			       struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct drm_gem_object *obj;
 	struct radeon_framebuffer *radeon_fb;
drivers/gpu/drm/radeon/radeon_fb.c +3 -2
index 0b7b486..06215ac 100644
@@ -103,7 +103,7 @@ static void radeonfb_destroy_pinned_object(struct drm_gem_object *gobj)
 }
 
 static int radeonfb_create_pinned_object(struct radeon_fbdev *rfbdev,
-					 struct drm_mode_fb_cmd *mode_cmd,
+					 struct drm_mode_fb_cmd2 *mode_cmd,
 					 struct drm_gem_object **gobj_p)
 {
 	struct radeon_device *rdev = rfbdev->rdev;
@@ -187,7 +187,7 @@ static int radeonfb_create(struct radeon_fbdev *rfbdev,
 	struct radeon_device *rdev = rfbdev->rdev;
 	struct fb_info *info;
 	struct drm_framebuffer *fb = NULL;
-	struct drm_mode_fb_cmd mode_cmd;
+	struct drm_mode_fb_cmd2 mode_cmd;
 	struct drm_gem_object *gobj = NULL;
 	struct radeon_bo *rbo = NULL;
 	struct device *device = &rdev->pdev->dev;
@@ -203,6 +203,7 @@ static int radeonfb_create(struct radeon_fbdev *rfbdev,
 
 	mode_cmd.bpp = sizes->surface_bpp;
 	mode_cmd.depth = sizes->surface_depth;
+	mode_cmd.pixel_format = 0;
 
 	ret = radeonfb_create_pinned_object(rfbdev, &mode_cmd, &gobj);
 	rbo = gem_to_radeon_bo(gobj);
drivers/gpu/drm/radeon/radeon_mode.h +1 -1
index 68820f5..227f595 100644
@@ -644,7 +644,7 @@ extern void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green
 				     u16 *blue, int regno);
 void radeon_framebuffer_init(struct drm_device *dev,
 			     struct radeon_framebuffer *rfb,
-			     struct drm_mode_fb_cmd *mode_cmd,
+			     struct drm_mode_fb_cmd2 *mode_cmd,
 			     struct drm_gem_object *obj);
 
 int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1 -1
index 1a4c84c..2a1b802 100644
@@ -839,7 +839,7 @@ out_err1:
 
 static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
 						 struct drm_file *file_priv,
-						 struct drm_mode_fb_cmd *mode_cmd)
+						 struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	struct vmw_private *dev_priv = vmw_priv(dev);
 	struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
drivers/staging/gma500/framebuffer.c +1 -1
index ebfde13..85f47d5 100644
@@ -487,7 +487,7 @@ out_err1:
  */
 static struct drm_framebuffer *psb_user_framebuffer_create
 			(struct drm_device *dev, struct drm_file *filp,
-			 struct drm_mode_fb_cmd *cmd)
+			 struct drm_mode_fb_cmd2 *cmd)
 {
 	struct gtt_range *r;
 	struct drm_gem_object *obj;
include/drm/drm.h +1 -0
index 2897967..49d94ed 100644
@@ -717,6 +717,7 @@ struct drm_get_cap {
 #define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
 #define DRM_IOCTL_MODE_GETPLANE	DRM_IOWR(0xB6, struct drm_mode_get_plane)
 #define DRM_IOCTL_MODE_SETPLANE	DRM_IOWR(0xB7, struct drm_mode_set_plane)
+#define DRM_IOCTL_MODE_ADDFB2		DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
 
 /**
  * Device specific ioctls should only be in their respective headers
include/drm/drm_crtc.h +5 -1
index d7f03aa..9a7b2de 100644
@@ -29,6 +29,7 @@
 #include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/idr.h>
+#include <linux/videodev2.h> /* for plane formats */
 
 #include <linux/fb.h>
 
@@ -246,6 +247,7 @@ struct drm_framebuffer {
 	unsigned int depth;
 	int bits_per_pixel;
 	int flags;
+	uint32_t pixel_format; /* fourcc format */
 	struct list_head filp_head;
 	/* if you are using the helper */
 	void *helper_private;
@@ -615,7 +617,7 @@ struct drm_mode_set {
  * struct drm_mode_config_funcs - configure CRTCs for a given screen layout
  */
 struct drm_mode_config_funcs {
-	struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd);
+	struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd);
 	void (*output_poll_changed)(struct drm_device *dev);
 };
 
@@ -833,6 +835,8 @@ extern int drm_mode_cursor_ioctl(struct drm_device *dev,
 				void *data, struct drm_file *file_priv);
 extern int drm_mode_addfb(struct drm_device *dev,
 			  void *data, struct drm_file *file_priv);
+extern int drm_mode_addfb2(struct drm_device *dev,
+			   void *data, struct drm_file *file_priv);
 extern int drm_mode_rmfb(struct drm_device *dev,
 			 void *data, struct drm_file *file_priv);
 extern int drm_mode_getfb(struct drm_device *dev,
include/drm/drm_crtc_helper.h +1 -1
index 73b0712..e88b7d7 100644
@@ -117,7 +117,7 @@ extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
 extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode);
 
 extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
-					  struct drm_mode_fb_cmd *mode_cmd);
+					  struct drm_mode_fb_cmd2 *mode_cmd);
 
 static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
 				       const struct drm_crtc_helper_funcs *funcs)
include/drm/drm_mode.h +14 -0
index 07711b0..34a0d22 100644
@@ -27,6 +27,8 @@
 #ifndef _DRM_MODE_H
 #define _DRM_MODE_H
 
+#include <linux/videodev2.h>
+
 #define DRM_DISPLAY_INFO_LEN	32
 #define DRM_CONNECTOR_NAME_LEN	32
 #define DRM_DISPLAY_MODE_LEN	32
@@ -262,6 +264,18 @@ struct drm_mode_fb_cmd {
 	__u32 handle;
 };
 
+/* For addfb2 ioctl, contains format info */
+struct drm_mode_fb_cmd2 {
+	__u32 fb_id;
+	__u32 width, height;
+	__u32 pitch;
+	__u32 bpp;
+	__u32 depth;
+	__u32 pixel_format; /* fourcc code from videodev2.h */
+	/* driver specific handle */
+	__u32 handle;
+};
+
 #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
 #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02
 #define DRM_MODE_FB_DIRTY_FLAGS         0x03
Signature · 1 line
1.7.4.1
#23 lore raw

PATCH 3/11 drm/i915: rename existing overlay support to "legacy"

In reply to Jesse Barnes

The old overlay block has all sorts of quirks and is very different than ILK+ video sprites. So rename it to legacy to make that clear and clash less with core overlay support.

---
 drivers/gpu/drm/i915/i915_debugfs.c  |    2 +-
 drivers/gpu/drm/i915/i915_drv.h      |   12 ++--
 drivers/gpu/drm/i915/i915_irq.c      |    2 +-
 drivers/gpu/drm/i915/intel_display.c |    2 +-
 drivers/gpu/drm/i915/intel_drv.h     |    4 +-
 drivers/gpu/drm/i915/intel_overlay.c |  126 +++++++++++++++++-----------------
 6 files changed, 74 insertions(+), 74 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 8e95d66..b6d0bbc 100644
@@ -825,7 +825,7 @@ static int i915_error_state(struct seq_file *m, void *unused)
 	}
 
 	if (error->overlay)
-		intel_overlay_print_error_state(m, error->overlay);
+		intel_legacy_overlay_print_error_state(m, error->overlay);
 
 	if (error->display)
 		intel_display_print_error_state(m, dev, error->display);
drivers/gpu/drm/i915/i915_drv.h +6 -6
index 06a37f4..b96c174 100644
@@ -118,8 +118,8 @@ struct intel_opregion {
 };
 #define OPREGION_SIZE            (8*1024)
 
-struct intel_overlay;
-struct intel_overlay_error_state;
+struct intel_legacy_overlay;
+struct intel_legacy_overlay_error_state;
 
 struct drm_i915_master_private {
 	drm_local_map_t *sarea;
@@ -191,7 +191,7 @@ struct drm_i915_error_state {
 		u32 cache_level:2;
 	} *active_bo, *pinned_bo;
 	u32 active_bo_count, pinned_bo_count;
-	struct intel_overlay_error_state *overlay;
+	struct intel_legacy_overlay_error_state *overlay;
 	struct intel_display_error_state *display;
 };
 
@@ -343,7 +343,7 @@ typedef struct drm_i915_private {
 	struct intel_opregion opregion;
 
 	/* overlay */
-	struct intel_overlay *overlay;
+	struct intel_legacy_overlay *overlay;
 
 	/* LVDS info */
 	int backlight_level;  /* restore backlight to this value */
@@ -1309,8 +1309,8 @@ extern int intel_trans_dp_port_sel(struct drm_crtc *crtc);
 
 /* overlay */
 #ifdef CONFIG_DEBUG_FS
-extern struct intel_overlay_error_state *intel_overlay_capture_error_state(struct drm_device *dev);
-extern void intel_overlay_print_error_state(struct seq_file *m, struct intel_overlay_error_state *error);
+extern struct intel_legacy_overlay_error_state *intel_legacy_overlay_capture_error_state(struct drm_device *dev);
+extern void intel_legacy_overlay_print_error_state(struct seq_file *m, struct intel_legacy_overlay_error_state *error);
 
 extern struct intel_display_error_state *intel_display_capture_error_state(struct drm_device *dev);
 extern void intel_display_print_error_state(struct seq_file *m,
drivers/gpu/drm/i915/i915_irq.c +1 -1
index 9ee2729..36f2837 100644
@@ -998,7 +998,7 @@ static void i915_capture_error_state(struct drm_device *dev)
 
 	do_gettimeofday(&error->time);
 
-	error->overlay = intel_overlay_capture_error_state(dev);
+	error->overlay = intel_legacy_overlay_capture_error_state(dev);
 	error->display = intel_display_capture_error_state(dev);
 
 	spin_lock_irqsave(&dev_priv->error_lock, flags);
drivers/gpu/drm/i915/intel_display.c +1 -1
index b1ae70b..e748338 100644
@@ -3180,7 +3180,7 @@ static void intel_crtc_dpms_overlay(struct intel_crtc *intel_crtc, bool enable)
 
 		mutex_lock(&dev->struct_mutex);
 		dev_priv->mm.interruptible = false;
-		(void) intel_overlay_switch_off(intel_crtc->overlay);
+		(void) intel_legacy_overlay_switch_off(intel_crtc->overlay);
 		dev_priv->mm.interruptible = true;
 		mutex_unlock(&dev->struct_mutex);
 	}
drivers/gpu/drm/i915/intel_drv.h +2 -2
index 23c5622..467fb4a 100644
@@ -161,7 +161,7 @@ struct intel_crtc {
 	bool busy; /* is scanout buffer being updated frequently? */
 	struct timer_list idle_timer;
 	bool lowfreq_avail;
-	struct intel_overlay *overlay;
+	struct intel_legacy_overlay *overlay;
 	struct intel_unpin_work *unpin_work;
 	int fdi_lanes;
 
@@ -370,7 +370,7 @@ extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
 
 extern void intel_setup_overlay(struct drm_device *dev);
 extern void intel_cleanup_overlay(struct drm_device *dev);
-extern int intel_overlay_switch_off(struct intel_overlay *overlay);
+extern int intel_legacy_overlay_switch_off(struct intel_legacy_overlay *overlay);
 extern int intel_overlay_put_image(struct drm_device *dev, void *data,
 				   struct drm_file *file_priv);
 extern int intel_overlay_attrs(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/intel_overlay.c +63 -63

425 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#24 lore raw

PATCH 4/11 drm/i915: add SNB video sprite support

In reply to Jesse Barnes

The video sprites support various video surface formats natively and can handle scaling as well. So add support for them using the new DRM core overlay support functions.

---
 drivers/gpu/drm/i915/Makefile         |    1 +
 drivers/gpu/drm/i915/i915_reg.h       |   52 +++++++++
 drivers/gpu/drm/i915/intel_display.c  |   25 +++-
 drivers/gpu/drm/i915/intel_drv.h      |   14 +++
 drivers/gpu/drm/i915/intel_fb.c       |    6 +
 drivers/gpu/drm/i915/intel_overlay2.c |  203 +++++++++++++++++++++++++++++++++
 6 files changed, 294 insertions(+), 7 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_overlay2.c
drivers/gpu/drm/i915/Makefile +1 -0
index 0ae6a7c..6193471 100644
@@ -28,6 +28,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
 	  intel_dvo.o \
 	  intel_ringbuffer.o \
 	  intel_overlay.o \
+	  intel_overlay2.o \
 	  intel_opregion.o \
 	  dvo_ch7xxx.o \
 	  dvo_ch7017.o \
drivers/gpu/drm/i915/i915_reg.h +52 -0

58 lines not on this page · raw message

drivers/gpu/drm/i915/intel_display.c +18 -7
index e748338..4f599ce 100644
@@ -915,8 +915,8 @@ static void assert_panel_unlocked(struct drm_i915_private *dev_priv,
 	     pipe_name(pipe));
 }
 
-static void assert_pipe(struct drm_i915_private *dev_priv,
-			enum pipe pipe, bool state)
+void assert_pipe(struct drm_i915_private *dev_priv,
+		 enum pipe pipe, bool state)
 {
 	int reg;
 	u32 val;
@@ -929,8 +929,6 @@ static void assert_pipe(struct drm_i915_private *dev_priv,
 	     "pipe %c assertion failure (expected %s, current %s)\n",
 	     pipe_name(pipe), state_string(state), state_string(cur_state));
 }
-#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
-#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 static void assert_plane_enabled(struct drm_i915_private *dev_priv,
 				 enum plane plane)
@@ -4439,7 +4437,8 @@ static void ironlake_update_wm(struct drm_device *dev)
 			    ILK_LP0_CURSOR_LATENCY,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
 			      " plane %d, " "cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4453,7 +4452,8 @@ static void ironlake_update_wm(struct drm_device *dev)
 			    ILK_LP0_CURSOR_LATENCY,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
 			      " plane %d, cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4587,6 +4587,11 @@ static void sandybridge_update_wm(struct drm_device *dev)
 		   (plane_wm << WM1_LP_SR_SHIFT) |
 		   cursor_wm);
 
+#if 0
+	I915_WRITE(WM1S_LP_ILK,
+		   WM1S_LP_EN |
+#endif
+
 	/* WM2 */
 	if (!ironlake_compute_srwm(dev, 2, enabled,
 				   SNB_READ_WM2_LATENCY() * 500,
@@ -8692,7 +8697,7 @@ static void i915_disable_vga(struct drm_device *dev)
 void intel_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	int i;
+	int i, ret;
 
 	drm_mode_config_init(dev);
 
@@ -8722,6 +8727,12 @@ void intel_modeset_init(struct drm_device *dev)
 
 	for (i = 0; i < dev_priv->num_pipe; i++) {
 		intel_crtc_init(dev, i);
+		if (HAS_PCH_SPLIT(dev)) {
+			ret = intel_plane_init(dev, i);
+			if (ret)
+				DRM_ERROR("plane %d init failed: %d\n",
+					  i, ret);
+		}
 	}
 
 	/* Just disable it once at startup */
drivers/gpu/drm/i915/intel_drv.h +14 -0
index 467fb4a..50b633b 100644
@@ -176,10 +176,18 @@ struct intel_crtc {
 	bool use_pll_a;
 };
 
+struct intel_plane {
+	struct drm_plane base;
+	enum pipe pipe;
+	struct drm_i915_gem_object *obj;
+	u32 lut_r[1024], lut_g[1024], lut_b[1024];
+};
+
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
+#define to_intel_plane(x) container_of(x, struct intel_plane, base)
 
 #define DIP_HEADER_SIZE	5
 
@@ -289,6 +297,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
 extern bool intel_dpd_is_edp(struct drm_device *dev);
 extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
 extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
+extern int intel_plane_init(struct drm_device *dev, enum pipe pipe);
 
 /* intel_panel.c */
 extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
@@ -379,6 +388,11 @@ extern int intel_overlay_attrs(struct drm_device *dev, void *data,
 extern void intel_fb_output_poll_changed(struct drm_device *dev);
 extern void intel_fb_restore_mode(struct drm_device *dev);
 
+extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
+			bool state);
+#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
+#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
+
 extern void intel_init_clock_gating(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
drivers/gpu/drm/i915/intel_fb.c +6 -0
index 11baa99..513a40c 100644
@@ -270,8 +270,14 @@ void intel_fb_restore_mode(struct drm_device *dev)
 {
 	int ret;
 	drm_i915_private_t *dev_priv = dev->dev_private;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_plane *plane;
 
 	ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
 	if (ret)
 		DRM_DEBUG("failed to restore crtc mode\n");
+
+	/* Be sure to shut off any planes that may be active */
+	list_for_each_entry(plane, &config->plane_list, head)
+		plane->funcs->disable_plane(plane);
 }
drivers/gpu/drm/i915/intel_overlay2.c new file +203 -0

203 lines not on this page · raw message

Signature · 6 lines
1.7.4.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#25 lore raw

Re: [PATCH 04/11] drm/i915: add SNB video sprite support

Hi, Jesse.

drm_plane structure has format_types and format_conunt that they was set at booting time. but they aren't used anywhere. at intel_update_plane(), I guess they could be used to check if the format type(fb->pixel_format) from setplane () is supported or not, comparing to plane->format_types[n]; otherwise, could you please tell me about the purpose that format_types[] and format_count are used?

Thank you,
Inki Dae.

#26 lore raw

Re: [PATCH 04/11] drm/i915: add SNB video sprite support

Quoted 8 lines · On Wed, 2 Nov 2011 05:56:56 +0000 (UTC) Inki Dae <[email protected]> wrote:

Hi, Jesse.

drm_plane structure has format_types and format_conunt that they was set at booting time. but they aren't used anywhere. at intel_update_plane(), I guess they could be used to check if the format type(fb->pixel_format) from setplane () is supported or not, comparing to plane->format_types[n]; otherwise, could you please tell me about the purpose that format_types[] and format_count are used?

They're supposed to be used by application/library code to negotiate a surface format to pass to the kernel.

So for example, libva could query the available surface formats then choose an output format that it can decode to directly if possible, to avoid any format conversion on the CPU.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#27 lore raw

PATCH 5/11 drm/i915: move pin & fence for plane past potential error paths

In reply to Jesse Barnes

This avoids the need to unpin on the error path.

---
 drivers/gpu/drm/i915/intel_overlay2.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_overlay2.c +4 -3
index 2e38b15..e583bd0 100644
@@ -62,9 +62,6 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	old_obj = intel_plane->obj;
 
 	mutex_lock(&dev->struct_mutex);
-	ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
-	if (ret)
-		goto out_unlock;
 
 	dvscntr = I915_READ(reg);
 
@@ -104,6 +101,10 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		goto out_unlock;
 	}
 
+	ret = intel_pin_and_fence_fb_obj(dev, obj, NULL);
+	if (ret)
+		goto out_unlock;
+
 	intel_plane->obj = obj;
 
 	dvscntr |= DVS_TILED;
Signature · 1 line
1.7.4.1
#28 lore raw

PATCH 6/11 drm/i915: plane teardown fixes

In reply to Jesse Barnes

Make sure the object exists (it may not if the plane was previously disabled) and make sure we zero it out in the disable path to avoid trouble later.

---
 drivers/gpu/drm/i915/intel_overlay2.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_overlay2.c +6 -0
index e583bd0..861e09e 100644
@@ -149,12 +149,18 @@ intel_disable_plane(struct drm_plane *plane)
 
 	mutex_lock(&dev->struct_mutex);
 
+	if (!intel_plane->obj)
+		goto out_unlock;
+
 	ret = i915_gem_object_finish_gpu(intel_plane->obj);
 	if (ret)
 		goto out_unlock;
+
 	i915_gem_object_unpin(intel_plane->obj);
 
 out_unlock:
+	intel_plane->obj = NULL;
+
 	I915_WRITE(DVSCNTR(pipe), I915_READ(DVSCNTR(pipe)) & ~DVS_ENABLE);
 	I915_WRITE(DVSSURF(pipe), 0);
 	POSTING_READ(DVSSURF(pipe));
Signature · 1 line
1.7.4.1
#29 lore raw

PATCH 7/11 drm/i915: enable new overlay code on IVB too

In reply to Jesse Barnes

Split things out a little and add the IVB reg definitions.

---
 drivers/gpu/drm/i915/i915_reg.h       |   59 ++++++++++++
 drivers/gpu/drm/i915/intel_overlay2.c |  168 ++++++++++++++++++++++++++++++--
 2 files changed, 216 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +59 -0
index 7b128d4..71496b8 100644
@@ -2718,6 +2718,65 @@
 #define DVSSCALE(pipe) _PIPE(pipe, _DVSASCALE, _DVSBSCALE)
 #define DVSTILEOFF(pipe) _PIPE(pipe, _DVSATILEOFF, _DVSBTILEOFF)
 
+#define _SPRA_CTL		0x70280
+#define   SPRITE_ENABLE			(1<<31)
+#define   SPRITE_GAMMA_ENABLE		(1<<30)
+#define   SPRITE_PIXFORMAT_MASK		(7<<25)
+#define   SPRITE_FORMAT_YUV422		(0<<25)
+#define   SPRITE_FORMAT_RGBX101010	(1<<25)
+#define   SPRITE_FORMAT_RGBX888		(2<<25)
+#define   SPRITE_FORMAT_RGBX161616	(3<<25)
+#define   SPRITE_FORMAT_YUV444		(4<<25)
+#define   SPRITE_FORMAT_XBGR101010	(5<<25)
+#define   SPRITE_CSC_ENABLE		(1<<24)
+#define   SPRITE_SOURCE_KEY		(1<<22)
+#define   SPRITE_RGB_ORDER_RGBX		(1<<20) /* only for 888 and 161616 */
+#define   SPRITE_YUV_TO_RGB_CSC_DISABLE	(1<<19)
+#define   SPRITE_YUV_CSC_FORMAT_BT709	(1<<18) /* 0 is BT601 */
+#define   SPRITE_YUV_BYTE_ORDER_MASK	(3<<16)
+#define   SPRITE_YUV_ORDER_YUYV		(0<<16)
+#define   SPRITE_YUV_ORDER_UYVY		(1<<16)
+#define   SPRITE_YUV_ORDER_YVYU		(2<<16)
+#define   SPRITE_YUV_ORDER_VYUY		(3<<16)
+#define   SPRITE_TRICKLE_FEED_DISABLE	(1<<14)
+#define   SPRITE_INT_GAMMA_ENABLE	(1<<13)
+#define   SPRITE_TILED			(1<<10)
+#define   SPRITE_DEST_KEY		(1<<2)
+#define _SPRA_STRIDE		0x70288
+#define _SPRA_POS		0x7028c
+#define _SPRA_SIZE		0x70290
+#define _SPRA_KEYVAL		0x70294
+#define _SPRA_KEYMSK		0x70298
+#define _SPRA_SURF		0x7029c
+#define _SPRA_KEYMAX		0x702a0
+#define _SPRA_TILEOFF		0x702a4
+#define _SPRA_SCALE		0x70304
+#define _SPRA_GAMC		0x70400
+
+#define _SPRB_CTL		0x70280
+#define _SPRB_STRIDE		0x70288
+#define _SPRB_POS		0x7028c
+#define _SPRB_SIZE		0x70290
+#define _SPRB_KEYVAL		0x70294
+#define _SPRB_KEYMSK		0x70298
+#define _SPRB_SURF		0x7029c
+#define _SPRB_KEYMAX		0x702a0
+#define _SPRB_TILEOFF		0x702a4
+#define _SPRB_SCALE		0x70304
+#define _SPRB_GAMC		0x70400
+
+#define SPRCTL(pipe) _PIPE(pipe, _SPRA_CTL, _SPRB_CTL)
+#define SPRSTRIDE(pipe) _PIPE(pipe, _SPRA_STRIDE, _SPRB_STRIDE)
+#define SPRPOS(pipe) _PIPE(pipe, _SPRA_POS, _SPRB_POS)
+#define SPRSIZE(pipe) _PIPE(pipe, _SPRA_SIZE, _SPRB_SIZE)
+#define SPRKEYVAL(pipe) _PIPE(pipe, _SPRA_KEYVAL, _SPRB_KEYVAL)
+#define SPRKEYMSK(pipe) _PIPE(pipe, _SPRA_KEYMSK, _SPRB_KEYMSK)
+#define SPRSURF(pipe) _PIPE(pipe, _SPRA_SURF, _SPRB_SURF)
+#define SPRKEYMAX(pipe) _PIPE(pipe, _SPRA_KEYMAX, _SPRB_KEYMAX)
+#define SPRTILEOFF(pipe) _PIPE(pipe, _SPRA_TILEOFF, _SPRB_TILEOFF)
+#define SPRSCALE(pipe) _PIPE(pipe, _SPRA_SCALE, _SPRB_SCALE)
+#define SPRGAMC(pipe) _PIPE(pipe, _SPRA_GAMC, _SPRB_GAMC)
+
 /* VBIOS regs */
 #define VGACNTRL		0x71400
 # define VGA_DISP_DISABLE			(1 << 31)
drivers/gpu/drm/i915/intel_overlay2.c +157 -11

220 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#30 lore raw

PATCH 8/11 drm/i915: overlay watermark hack

In reply to Jesse Barnes
---
 drivers/gpu/drm/i915/intel_display.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_display.c +4 -7
index 4f599ce..cd7e04d 100644
@@ -4521,7 +4521,8 @@ static void sandybridge_update_wm(struct drm_device *dev)
 			    &sandybridge_cursor_wm_info, latency,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
 			      " plane %d, " "cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4533,7 +4534,8 @@ static void sandybridge_update_wm(struct drm_device *dev)
 			    &sandybridge_cursor_wm_info, latency,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
 			      " plane %d, cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4587,11 +4589,6 @@ static void sandybridge_update_wm(struct drm_device *dev)
 		   (plane_wm << WM1_LP_SR_SHIFT) |
 		   cursor_wm);
 
-#if 0
-	I915_WRITE(WM1S_LP_ILK,
-		   WM1S_LP_EN |
-#endif
-
 	/* WM2 */
 	if (!ironlake_compute_srwm(dev, 2, enabled,
 				   SNB_READ_WM2_LATENCY() * 500,
Signature · 1 line
1.7.4.1
#31 lore raw

PATCH 9/11 drm/i915: fix overlay fb object handling

In reply to Jesse Barnes

To avoid the object being destroyed before our disable hook is called, take a private reference on it. This will guarantee that we can still access the object at disable time.

---
 drivers/gpu/drm/i915/intel_overlay2.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/intel_overlay2.c +22 -5
index 61b1a2f..8876857 100644
@@ -35,6 +35,18 @@
 #include "i915_drm.h"
 #include "i915_drv.h"
 
+/*
+ * Note on refcounting:
+ * When the user creates an fb for the GEM object to be used for the plane,
+ * a ref is taken on the object.  However, if the application exits before
+ * disabling the plane, the DRM close handling will free all the fbs and
+ * unless we take a ref on the object, it will be destroyed before the
+ * plane disable hook is called, causing obvious trouble with our efforts
+ * to look up and unpin the object.  So we take a ref after we move the
+ * object to the display plane so it won't be destroyed until our disable
+ * hook is called and we drop our private reference.
+ */
+
 static int
 ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		   struct drm_framebuffer *fb, int crtc_x, int crtc_y,
@@ -106,6 +118,8 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (ret)
 		goto out_unlock;
 
+	drm_gem_object_reference(&obj->base);
+
 	intel_plane->obj = obj;
 
 	sprctl |= SPRITE_TILED;
@@ -117,9 +131,6 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	start = obj->gtt_offset;
 	offset = y * fb->pitch + x * (fb->bits_per_pixel / 8);
 
-	DRM_ERROR("enabling sprite, pos %d,%d, size %dx%d\n",
-		  crtc_x, crtc_y, fb->width, fb->height);
-
 	I915_WRITE(SPRSTRIDE(pipe), fb->pitch);
 	I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x);
 	I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x);
@@ -215,6 +226,8 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (ret)
 		goto out_unlock;
 
+	drm_gem_object_reference(&obj->base);
+
 	intel_plane->obj = obj;
 
 	dvscntr |= DVS_TILED;
@@ -260,13 +273,15 @@ ivb_disable_plane(struct drm_plane *plane)
 
 	if (!intel_plane->obj)
 		goto out_unlock;
-#if 0
+
 	ret = i915_gem_object_finish_gpu(intel_plane->obj);
 	if (ret)
 		goto out_unlock;
 
 	i915_gem_object_unpin(intel_plane->obj);
-#endif
+
+	drm_gem_object_reference(&intel_plane->obj->base);
+
 out_unlock:
 	intel_plane->obj = NULL;
 
@@ -299,6 +314,8 @@ snb_disable_plane(struct drm_plane *plane)
 
 	i915_gem_object_unpin(intel_plane->obj);
 
+	drm_gem_object_reference(&intel_plane->obj->base);
+
 out_unlock:
 	intel_plane->obj = NULL;
 
Signature · 1 line
1.7.4.1
#32 lore raw

PATCH 10/11 drm/i915: clamp sprite to viewable area

In reply to Jesse Barnes

If we try to scan a sprite outside of the parent CRTC area, the display engine will underflow and potentially blank the framebuffer. So clamp the position + size to the viewable area.

---
 drivers/gpu/drm/i915/intel_overlay2.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
drivers/gpu/drm/i915/intel_overlay2.c +11 -1
index 8876857..90c4f59 100644
@@ -173,6 +173,7 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	u32 reg = DVSCNTR(pipe);
 	int ret = 0;
 	int x = src_x >> 16, y = src_y >> 16;
+	int active_w = crtc->mode.hdisplay, active_h = crtc->mode.vdisplay;
 
 	assert_pipe_enabled(dev_priv, pipe);
 
@@ -181,6 +182,15 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	old_obj = intel_plane->obj;
 
+	if (crtc_x >= active_w || crtc_y >= active_h)
+		return -EINVAL;
+
+	/* Clamp the width & height into the visible area */
+	if (crtc_x + crtc_w > active_w)
+		crtc_w = active_w - crtc_x - 1;
+	if (crtc_y + crtc_h > active_h)
+		crtc_h = active_h - crtc_y - 1;
+
 	mutex_lock(&dev->struct_mutex);
 
 	dvscntr = I915_READ(reg);
@@ -242,7 +252,7 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	I915_WRITE(DVSSTRIDE(pipe), fb->pitch);
 	I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x);
 	I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x);
-	I915_WRITE(DVSSIZE(pipe), (fb->height << 16) | fb->width);
+	I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w);
 	I915_WRITE(DVSSCALE(pipe), 0);
 	I915_WRITE(reg, dvscntr);
 	I915_WRITE(DVSSURF(pipe), start);
Signature · 1 line
1.7.4.1
#33 lore raw

PATCH 11/11 drm/i915: add sprite scaling support

In reply to Jesse Barnes

If the source and destination size are different, try to scale the sprite on the corresponding CRTC.

---
 drivers/gpu/drm/i915/i915_reg.h       |    5 +++++
 drivers/gpu/drm/i915/intel_overlay2.c |   14 ++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +5 -0
index 71496b8..8cbda0b 100644
@@ -2695,6 +2695,11 @@
 #define _DVSATILEOFF		0x721a4
 #define _DVSASURFLIVE		0x721ac
 #define _DVSASCALE		0x72204
+#define   DVS_SCALE_ENABLE	(1<<31)
+#define   DVS_FILTER_MASK	(3<<29)
+#define   DVS_FILTER_MEDIUM	(0<<29)
+#define   DVS_FILTER_ENHANCING	(1<<29)
+#define   DVS_FILTER_SOFTENING	(2<<29)
 #define _DVSAGAMC		0x72300
 
 #define _DVSBCNTR		0x73180
drivers/gpu/drm/i915/intel_overlay2.c +12 -2
index 90c4f59..61594b6 100644
@@ -169,7 +169,7 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	struct drm_i915_gem_object *obj, *old_obj;
 	int pipe = intel_plane->pipe;
 	unsigned long start, offset;
-	u32 dvscntr;
+	u32 dvscntr, dvsscale = 0;
 	u32 reg = DVSCNTR(pipe);
 	int ret = 0;
 	int x = src_x >> 16, y = src_y >> 16;
@@ -185,6 +185,13 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (crtc_x >= active_w || crtc_y >= active_h)
 		return -EINVAL;
 
+	/*
+	 * We can take a larger source and scale it down, but
+	 * only so much...  16x is the max on SNB.
+	 */
+	if (((src_w * src_h) / (crtc_w * crtc_h)) > 16)
+		return -EINVAL;
+
 	/* Clamp the width & height into the visible area */
 	if (crtc_x + crtc_w > active_w)
 		crtc_w = active_w - crtc_x - 1;
@@ -249,11 +256,14 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	start = obj->gtt_offset;
 	offset = y * fb->pitch + x * (fb->bits_per_pixel / 8);
 
+	if (crtc_w != src_w || crtc_h != src_h)
+		dvsscale = DVS_SCALE_ENABLE | (src_h << 16) | src_w;
+
 	I915_WRITE(DVSSTRIDE(pipe), fb->pitch);
 	I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x);
 	I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x);
 	I915_WRITE(DVSSIZE(pipe), (crtc_h << 16) | crtc_w);
-	I915_WRITE(DVSSCALE(pipe), 0);
+	I915_WRITE(DVSSCALE(pipe), dvsscale);
 	I915_WRITE(reg, dvscntr);
 	I915_WRITE(DVSSURF(pipe), start);
 	POSTING_READ(DVSSURF(pipe));
Signature · 1 line
1.7.4.1
#34 lore raw
In reply to Jesse Barnes

Hi, Jesse.

Thanks for posting.

10/25/2011 06:46 PM, Jesse Barnes 쓴 글:

Quoted 8 lines

I've given up waiting for someone to implement support for these ioctls on another platform before they're merged, but I have received a lot of feedback on the interfaces, and it sounds like they're ok. I've also fixed all the remaining issues I'm aware of on SNB platforms and things are working well, so I'm just going to push them out. (Note IVB support is still missing a few bits for scaling and such; I'll fix those up when I get back home and can test on IVB again.)

Quoted 4 lines

One change you may notice from the last set is that I've removed the 'zpos' parameter. Plane blending and z ordering is very chipset specific (it even varies between Intel chipsets), so exposing it through a device specific ioctl is probably a better plan.

But i think zpos is essential parameter of plane. If plane doesn't support it, drm driver cannot know user wants to use which overlay, so i wonder what it meant DRM_IOCTL_MODE_SETPLANE zpos is absent .

If use device specific ioctl, should implement device specific ioctl for DRM_IOCTL_MODE_SETPLANE?

Quoted 4 lines

By default, planes
should just overlay the primary plane; a device specific ioctl (none available yet, but I have some planned for i915) can provide more flexibility.

Could you explain what is the primary plane? Is it same as the overlay handled by crtc? It confuses a bit when one overlay is handled by crtc and plane at the same time.

Quoted 14 lines

To recap previous posts, this patchset provides a few new interfaces:
- addfb2 - a new FB creation ioctl that lets you specify a surface format, as defined by a fourcc code from the video4linux headers (libdrm will wrap these in DRM_ macros for portability)
- planes - ioctls for fetching plane info and attaching an fb to a plane; note there's no separate flip ioctl for planes, just use setplane to update the fb

The testdisplay.c program in intel-gpu-tools has support for testing these interfaces, and I'll be fixing up and pushing the xf86-video-intel support soon as well, so you can use either as a reference for how the new interfaces work.

Quoted 8 lines

Thanks,
Jesse

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#35 lore raw
Quoted 10 lines · On Tue, 25 Oct 2011 19:47:13 +0900 Joonyoung Shim <[email protected]>…

10/25/2011 06:46 PM, Jesse Barnes 쓴 글:

Quoted 9 lines

I've given up waiting for someone to implement support for these ioctls on another platform before they're merged, but I have received a lot of feedback on the interfaces, and it sounds like they're ok. I've also fixed all the remaining issues I'm aware of on SNB platforms and things are working well, so I'm just going to push them out. (Note IVB support is still missing a few bits for scaling and such; I'll fix those up when I get back home and can test on IVB again.)

Quoted 8 lines
Quoted 4 lines

One change you may notice from the last set is that I've removed the 'zpos' parameter. Plane blending and z ordering is very chipset specific (it even varies between Intel chipsets), so exposing it through a device specific ioctl is probably a better plan.

But i think zpos is essential parameter of plane. If plane doesn't support it, drm driver cannot know user wants to use which overlay, so i wonder what it meant DRM_IOCTL_MODE_SETPLANE zpos is absent .

Setplane is just for attaching a new fb. The order, keying, or whatever else your plane blender can support can be set with a device specific ioctl before or after the setplane call (probably before to avoid any flashing or bad frames).

Quoted 2 lines

If use device specific ioctl, should implement device specific ioctl for DRM_IOCTL_MODE_SETPLANE?

You could if you needed, but I don't think it's strictly necessary.

Quoted 8 lines
Quoted 4 lines

By default, planes
should just overlay the primary plane; a device specific ioctl (none available yet, but I have some planned for i915) can provide more flexibility.

Could you explain what is the primary plane? Is it same as the overlay handled by crtc? It confuses a bit when one overlay is handled by crtc and plane at the same time.

Yeah, it is a little confusing. When I refer to the primary, I'm referring to the plane bound to the CRTC. I'm fine if someone wants to break that out, I think it would make sense. I just didn't want to write the compat code that would be required for that scheme. :) But these patches definitely don't preclude it, and I don't think these interfaces will need changes if we ever move to a pipe/plane split at the userland level.

Thanks,
Jesse
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#36 lore raw

10/25/2011 08:13 PM, Jesse Barnes 쓴 글:

Quoted 16 lines
Quoted 14 lines · On Tue, 25 Oct 2011 19:47:13 +0900 Joonyoung Shim<[email protected]>…

10/25/2011 06:46 PM, Jesse Barnes 쓴 글:

Quoted 13 lines

I've given up waiting for someone to implement support for these ioctls on another platform before they're merged, but I have received a lot of feedback on the interfaces, and it sounds like they're ok. I've also fixed all the remaining issues I'm aware of on SNB platforms and things are working well, so I'm just going to push them out. (Note IVB support is still missing a few bits for scaling and such; I'll fix those up when I get back home and can test on IVB again.)

One change you may notice from the last set is that I've removed the 'zpos' parameter. Plane blending and z ordering is very chipset specific (it even varies between Intel chipsets), so exposing it through a device specific ioctl is probably a better plan.

Quoted 8 lines
Quoted 3 lines

But i think zpos is essential parameter of plane. If plane doesn't support it, drm driver cannot know user wants to use which overlay, so i wonder what it meant DRM_IOCTL_MODE_SETPLANE zpos is absent .

Setplane is just for attaching a new fb. The order, keying, or whatever else your plane blender can support can be set with a device specific ioctl before or after the setplane call (probably before to avoid any flashing or bad frames).

OK, i see.

Thanks.

Quoted 11 lines
Quoted 2 lines

If use device specific ioctl, should implement device specific ioctl for DRM_IOCTL_MODE_SETPLANE?

You could if you needed, but I don't think it's strictly necessary.

Quoted 7 lines
Quoted 4 lines

By default, planes
should just overlay the primary plane; a device specific ioctl (none available yet, but I have some planned for i915) can provide more flexibility.

Could you explain what is the primary plane? Is it same as the overlay handled by crtc? It confuses a bit when one overlay is handled by crtc and plane at the same time.

Quoted 7 lines

Yeah, it is a little confusing. When I refer to the primary, I'm referring to the plane bound to the CRTC. I'm fine if someone wants to break that out, I think it would make sense. I just didn't want to write the compat code that would be required for that scheme. :) But these patches definitely don't preclude it, and I don't think these interfaces will need changes if we ever move to a pipe/plane split at the userland level.

Could you have the policy about fb of overlay? For example, user attaches the fb of plane to the overlay already using by CRTC, then output of overlay will be changed to the fb of plane from fb of CRTC. And if user detaches the fb of plane, the overlay again should output the fb of CRTC? or just be disabled?
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#37 lore raw
In reply to Jesse Barnes
Quoted 8 lines · On Tue, 25 Oct 2011 11:46:55 +0200 Jesse Barnes <[email protected]>…

I've given up waiting for someone to implement support for these ioctls on another platform before they're merged, but I have received a lot of feedback on the interfaces, and it sounds like they're ok. I've also fixed all the remaining issues I'm aware of on SNB platforms and things are working well, so I'm just going to push them out. (Note IVB support is still missing a few bits for scaling and such; I'll fix those up when I get back home and can test on IVB again.)

Btw, ignore 3-11, I forgot to collapse them when I collapsed the core fixes. Updated intel specific patch will be coming shortly (with a fix for the unpin vs disable ordering danvet pointed out).

Jesse

#38 lore raw

PATCH 1/1 drm/i915: add SNB video sprite support

In reply to Jesse Barnes

The video sprites support various video surface formats natively and can handle scaling as well. So add support for them using the new DRM core overlay support functions.

v2: collapse patches and fix plane disable vs unpin ordering bug

---
 drivers/gpu/drm/i915/Makefile         |    1 +
 drivers/gpu/drm/i915/i915_reg.h       |  116 ++++++++++
 drivers/gpu/drm/i915/intel_display.c  |   26 ++-
 drivers/gpu/drm/i915/intel_drv.h      |   14 ++
 drivers/gpu/drm/i915/intel_fb.c       |    6 +
 drivers/gpu/drm/i915/intel_overlay2.c |  393 +++++++++++++++++++++++++++++++++
 6 files changed, 547 insertions(+), 9 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_overlay2.c
drivers/gpu/drm/i915/Makefile +1 -0
index 0ae6a7c..6193471 100644
@@ -28,6 +28,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
 	  intel_dvo.o \
 	  intel_ringbuffer.o \
 	  intel_overlay.o \
+	  intel_overlay2.o \
 	  intel_opregion.o \
 	  dvo_ch7xxx.o \
 	  dvo_ch7017.o \
drivers/gpu/drm/i915/i915_reg.h +116 -0

122 lines not on this page · raw message

drivers/gpu/drm/i915/intel_display.c +17 -9
index e748338..cd7e04d 100644
@@ -915,8 +915,8 @@ static void assert_panel_unlocked(struct drm_i915_private *dev_priv,
 	     pipe_name(pipe));
 }
 
-static void assert_pipe(struct drm_i915_private *dev_priv,
-			enum pipe pipe, bool state)
+void assert_pipe(struct drm_i915_private *dev_priv,
+		 enum pipe pipe, bool state)
 {
 	int reg;
 	u32 val;
@@ -929,8 +929,6 @@ static void assert_pipe(struct drm_i915_private *dev_priv,
 	     "pipe %c assertion failure (expected %s, current %s)\n",
 	     pipe_name(pipe), state_string(state), state_string(cur_state));
 }
-#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
-#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 static void assert_plane_enabled(struct drm_i915_private *dev_priv,
 				 enum plane plane)
@@ -4439,7 +4437,8 @@ static void ironlake_update_wm(struct drm_device *dev)
 			    ILK_LP0_CURSOR_LATENCY,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
 			      " plane %d, " "cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4453,7 +4452,8 @@ static void ironlake_update_wm(struct drm_device *dev)
 			    ILK_LP0_CURSOR_LATENCY,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
 			      " plane %d, cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4521,7 +4521,8 @@ static void sandybridge_update_wm(struct drm_device *dev)
 			    &sandybridge_cursor_wm_info, latency,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
 			      " plane %d, " "cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4533,7 +4534,8 @@ static void sandybridge_update_wm(struct drm_device *dev)
 			    &sandybridge_cursor_wm_info, latency,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
 			      " plane %d, cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -8692,7 +8694,7 @@ static void i915_disable_vga(struct drm_device *dev)
 void intel_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	int i;
+	int i, ret;
 
 	drm_mode_config_init(dev);
 
@@ -8722,6 +8724,12 @@ void intel_modeset_init(struct drm_device *dev)
 
 	for (i = 0; i < dev_priv->num_pipe; i++) {
 		intel_crtc_init(dev, i);
+		if (HAS_PCH_SPLIT(dev)) {
+			ret = intel_plane_init(dev, i);
+			if (ret)
+				DRM_ERROR("plane %d init failed: %d\n",
+					  i, ret);
+		}
 	}
 
 	/* Just disable it once at startup */
drivers/gpu/drm/i915/intel_drv.h +14 -0
index 467fb4a..50b633b 100644
@@ -176,10 +176,18 @@ struct intel_crtc {
 	bool use_pll_a;
 };
 
+struct intel_plane {
+	struct drm_plane base;
+	enum pipe pipe;
+	struct drm_i915_gem_object *obj;
+	u32 lut_r[1024], lut_g[1024], lut_b[1024];
+};
+
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
+#define to_intel_plane(x) container_of(x, struct intel_plane, base)
 
 #define DIP_HEADER_SIZE	5
 
@@ -289,6 +297,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
 extern bool intel_dpd_is_edp(struct drm_device *dev);
 extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
 extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
+extern int intel_plane_init(struct drm_device *dev, enum pipe pipe);
 
 /* intel_panel.c */
 extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
@@ -379,6 +388,11 @@ extern int intel_overlay_attrs(struct drm_device *dev, void *data,
 extern void intel_fb_output_poll_changed(struct drm_device *dev);
 extern void intel_fb_restore_mode(struct drm_device *dev);
 
+extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
+			bool state);
+#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
+#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
+
 extern void intel_init_clock_gating(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
drivers/gpu/drm/i915/intel_fb.c +6 -0
index 11baa99..513a40c 100644
@@ -270,8 +270,14 @@ void intel_fb_restore_mode(struct drm_device *dev)
 {
 	int ret;
 	drm_i915_private_t *dev_priv = dev->dev_private;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_plane *plane;
 
 	ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
 	if (ret)
 		DRM_DEBUG("failed to restore crtc mode\n");
+
+	/* Be sure to shut off any planes that may be active */
+	list_for_each_entry(plane, &config->plane_list, head)
+		plane->funcs->disable_plane(plane);
 }
drivers/gpu/drm/i915/intel_overlay2.c new file +393 -0

393 lines not on this page · raw message

Signature · 7 lines
1.7.4.1


_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#39 lore raw

PATCH 1/1 drm/i915: add SNB video sprite support

From 13efc0a405d522aad8250fce2dbd05fefb8b8ab0 Mon Sep 17 00:00:00 2001
From: Jesse Barnes <[email protected]>
Date: Fri, 22 Apr 2011 14:55:33 -0700
Subject: [PATCH] drm/i915: add SNB video sprite support

The video sprites support various video surface formats natively and can handle scaling as well. So add support for them using the new DRM core overlay support functions.

v2: collapse patches
v3: no really, fix disable ordering

---
 drivers/gpu/drm/i915/Makefile         |    1 +
 drivers/gpu/drm/i915/i915_reg.h       |  116 ++++++++++
 drivers/gpu/drm/i915/intel_display.c  |   26 ++-
 drivers/gpu/drm/i915/intel_drv.h      |   14 ++
 drivers/gpu/drm/i915/intel_fb.c       |    6 +
 drivers/gpu/drm/i915/intel_overlay2.c |  395 +++++++++++++++++++++++++++++++++
 6 files changed, 549 insertions(+), 9 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/intel_overlay2.c
drivers/gpu/drm/i915/Makefile +1 -0
index 0ae6a7c..6193471 100644
@@ -28,6 +28,7 @@ i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
 	  intel_dvo.o \
 	  intel_ringbuffer.o \
 	  intel_overlay.o \
+	  intel_overlay2.o \
 	  intel_opregion.o \
 	  dvo_ch7xxx.o \
 	  dvo_ch7017.o \
drivers/gpu/drm/i915/i915_reg.h +116 -0

122 lines not on this page · raw message

drivers/gpu/drm/i915/intel_display.c +17 -9
index e748338..cd7e04d 100644
@@ -915,8 +915,8 @@ static void assert_panel_unlocked(struct drm_i915_private *dev_priv,
 	     pipe_name(pipe));
 }
 
-static void assert_pipe(struct drm_i915_private *dev_priv,
-			enum pipe pipe, bool state)
+void assert_pipe(struct drm_i915_private *dev_priv,
+		 enum pipe pipe, bool state)
 {
 	int reg;
 	u32 val;
@@ -929,8 +929,6 @@ static void assert_pipe(struct drm_i915_private *dev_priv,
 	     "pipe %c assertion failure (expected %s, current %s)\n",
 	     pipe_name(pipe), state_string(state), state_string(cur_state));
 }
-#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
-#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
 
 static void assert_plane_enabled(struct drm_i915_private *dev_priv,
 				 enum plane plane)
@@ -4439,7 +4437,8 @@ static void ironlake_update_wm(struct drm_device *dev)
 			    ILK_LP0_CURSOR_LATENCY,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
 			      " plane %d, " "cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4453,7 +4452,8 @@ static void ironlake_update_wm(struct drm_device *dev)
 			    ILK_LP0_CURSOR_LATENCY,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
 			      " plane %d, cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4521,7 +4521,8 @@ static void sandybridge_update_wm(struct drm_device *dev)
 			    &sandybridge_cursor_wm_info, latency,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
 			      " plane %d, " "cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -4533,7 +4534,8 @@ static void sandybridge_update_wm(struct drm_device *dev)
 			    &sandybridge_cursor_wm_info, latency,
 			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
-			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
+			   (plane_wm << WM0_PIPE_PLANE_SHIFT) |
+			   (plane_wm << WM0_PIPE_SPRITE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
 			      " plane %d, cursor: %d\n",
 			      plane_wm, cursor_wm);
@@ -8692,7 +8694,7 @@ static void i915_disable_vga(struct drm_device *dev)
 void intel_modeset_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	int i;
+	int i, ret;
 
 	drm_mode_config_init(dev);
 
@@ -8722,6 +8724,12 @@ void intel_modeset_init(struct drm_device *dev)
 
 	for (i = 0; i < dev_priv->num_pipe; i++) {
 		intel_crtc_init(dev, i);
+		if (HAS_PCH_SPLIT(dev)) {
+			ret = intel_plane_init(dev, i);
+			if (ret)
+				DRM_ERROR("plane %d init failed: %d\n",
+					  i, ret);
+		}
 	}
 
 	/* Just disable it once at startup */
drivers/gpu/drm/i915/intel_drv.h +14 -0
index 467fb4a..50b633b 100644
@@ -176,10 +176,18 @@ struct intel_crtc {
 	bool use_pll_a;
 };
 
+struct intel_plane {
+	struct drm_plane base;
+	enum pipe pipe;
+	struct drm_i915_gem_object *obj;
+	u32 lut_r[1024], lut_g[1024], lut_b[1024];
+};
+
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
+#define to_intel_plane(x) container_of(x, struct intel_plane, base)
 
 #define DIP_HEADER_SIZE	5
 
@@ -289,6 +297,7 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
 extern bool intel_dpd_is_edp(struct drm_device *dev);
 extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
 extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
+extern int intel_plane_init(struct drm_device *dev, enum pipe pipe);
 
 /* intel_panel.c */
 extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
@@ -379,6 +388,11 @@ extern int intel_overlay_attrs(struct drm_device *dev, void *data,
 extern void intel_fb_output_poll_changed(struct drm_device *dev);
 extern void intel_fb_restore_mode(struct drm_device *dev);
 
+extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
+			bool state);
+#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
+#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
+
 extern void intel_init_clock_gating(struct drm_device *dev);
 extern void intel_write_eld(struct drm_encoder *encoder,
 			    struct drm_display_mode *mode);
drivers/gpu/drm/i915/intel_fb.c +6 -0
index 11baa99..513a40c 100644
@@ -270,8 +270,14 @@ void intel_fb_restore_mode(struct drm_device *dev)
 {
 	int ret;
 	drm_i915_private_t *dev_priv = dev->dev_private;
+	struct drm_mode_config *config = &dev->mode_config;
+	struct drm_plane *plane;
 
 	ret = drm_fb_helper_restore_fbdev_mode(&dev_priv->fbdev->helper);
 	if (ret)
 		DRM_DEBUG("failed to restore crtc mode\n");
+
+	/* Be sure to shut off any planes that may be active */
+	list_for_each_entry(plane, &config->plane_list, head)
+		plane->funcs->disable_plane(plane);
 }
drivers/gpu/drm/i915/intel_overlay2.c new file +395 -0

395 lines not on this page · raw message

Signature · 6 lines
1.7.4.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#40 lore raw

Re: [PATCH] drm/i915: add SNB video sprite support

In reply to Jesse Barnes

Hi Jesse,
I hope the function of snb_update_plane can handle crtx_x<0 or crtc_y<0 just like my patch. What do you think about it?
Thanks and best regards.

Hai Lan

Quoted 1 line

From 160c899739e7d07f273de889cc889316837d0790 Mon Sep 17 00:00:00 2001

From: Hai Lan <[email protected]>
Date: Tue, 1 Nov 2011 21:30:08 -0400
Subject: [PATCH] drm/i915:add overlay support for crtc_x < 0 or crtc_y < 0

---
 drivers/gpu/drm/i915/intel_overlay2.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/gpu/drm/i915/intel_overlay2.c +16 -0
index ff9f0ea..7eba888 100644
@@ -193,6 +193,22 @@ snb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		return -EINVAL;
 
 	/* Clamp the width & height into the visible area */
+	if ((crtc_x < 0) && ((crtc_x + crtc_w)>0)) {
+		crtc_w += crtc_x;
+		crtc_x = 0;
+	}
+	if ((crtc_y < 0) && ((crtc_y + crtc_h)>0)) {
+		crtc_h += crtc_y;
+		crtc_y = 0;
+	}
+	if ((crtc_x +crtc_w) < 0) {
+		crtc_w = 0;
+		crtc_x = 0;
+	}
+	if ((crtc_y +crtc_h) < 0) {
+		crtc_h = 0;
+		crtc_y = 0;
+	}
 	if (crtc_x + crtc_w > active_w)
 		crtc_w = active_w - crtc_x - 1;
 	if (crtc_y + crtc_h > active_h)
Signature · 1 line
1.7.0.1
#41 lore raw

Re: [Intel-gfx] [PATCH] drm/i915: add SNB video sprite support

Quoted 4 lines · Hai

Hi Jesse,
I hope the function of snb_update_plane can handle crtx_x<0 or crtc_y<0 just like my patch. What do you think about it?
Thanks and best regards.

I don't think this is necessary with the latest code; I clamp things in the top level function now. But take a look and see if I'm missing one of the cases you cover here.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel