Skip to contentSkip to conversation

Updated plane support v3

RFC In review Jesse Barnes 6 participants 23 messages Jun 20, 2011 – Sep 19, 2011

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

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Thanks,
Jesse

#1 lore raw

PATCH 1/4 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 |  235 +++++++++++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/drm_drv.c  |    3 +
 include/drm/drm.h          |    3 +
 include/drm/drm_crtc.h     |   73 ++++++++++++++-
 include/drm/drm_mode.h     |   35 +++++++
 5 files changed, 346 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_crtc.c +233 -2
index 872747c..9be36a5 100644
@@ -533,6 +533,47 @@ 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);
+	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
@@ -864,6 +905,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);
@@ -1467,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
@@ -1689,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 +72 -1

121 lines not on this page · raw message

include/drm/drm_mode.h +35 -0
index c4961ea..fa6d348 100644
@@ -120,6 +120,41 @@ 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;
+
+	__u32 zpos;
+};
+
+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 1/4] drm: add plane support

Hi,

simple questions :)

2011/6/21 Jesse Barnes <[email protected]>:

Quoted 13 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 |  235 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c  |    3 +
 include/drm/drm.h          |    3 +
 include/drm/drm_crtc.h     |   73 ++++++++++++++- include/drm/drm_mode.h     |   35 +++++++

 5 files changed, 346 insertions(+), 3 deletions(-)

snip

Quoted 6 lines
include/drm/drm_mode.h +0 -0
index c4961ea..fa6d348 100644
@@ -120,6 +120,41 @@ struct drm_mode_crtc {
        struct drm_mode_modeinfo mode;

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

Quoted 10 lines
include/drm/drm_mode.h +8 -0
  };
 
+/* 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;

Is this location offset from base(0, 0) of fb for plane, or from base of crtc(mode)?

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

Quoted 1 line
include/drm/drm_mode.h +1 -0
+       __u32 crtc_w, crtc_h;

What is it for? size of plane?

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

Quoted 4 lines
include/drm/drm_mode.h +4 -0
+
+       /* Source values are 16.16 fixed point */
+       __u32 src_x, src_y;
+       __u32 src_h, src_w;

What are these for?

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

Quoted 2 lines
include/drm/drm_mode.h +2 -0
+
+       __u32 zpos;

Is this for order of plane(overlay)?

Quoted 31 lines
include/drm/drm_mode.h +20 -1
+};
+
+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
--

1.7.4.1

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

Signature · 1 line
- Joonyoung Shim
#3 lore raw

Re: [PATCH 1/4] drm: add plane support

Quoted 29 lines · On Thu, 21 Jul 2011 19:30:00 +0900 Joonyoung Shim <[email protected]> wrote:

Hi,

simple questions :)

2011/6/21 Jesse Barnes <[email protected]>:

Quoted 13 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 |  235 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c  |    3 +
 include/drm/drm.h          |    3 +
 include/drm/drm_crtc.h     |   73 ++++++++++++++- include/drm/drm_mode.h     |   35 +++++++

 5 files changed, 346 insertions(+), 3 deletions(-)

snip

Quoted 8 lines
include/drm/drm_mode.h +0 -0
index c4961ea..fa6d348 100644
@@ -120,6 +120,41 @@ struct drm_mode_crtc {
        struct drm_mode_modeinfo mode;
  };
 
Quoted 11 lines

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

Quoted 8 lines
include/drm/drm_mode.h +8 -0
+/* 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;

Is this location offset from base(0, 0) of fb for plane, or from base of crtc(mode)?

This is the offset on the crtc specifically (which could be displaying a nonzero offset of a given fb).

Quoted 4 lines

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

Quoted 2 lines
include/drm/drm_mode.h +1 -0
+       __u32 crtc_w, crtc_h;

What is it for? size of plane?

These are the size of the rect on the crtc. It's possible to have say a small source fb that gets scaled to a different size on the crtc by the plane blender or display hardware.

Quoted 7 lines

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

Quoted 5 lines
include/drm/drm_mode.h +4 -0
+
+       /* Source values are 16.16 fixed point */
+       __u32 src_x, src_y;
+       __u32 src_h, src_w;

What are these for?

These specify the offset and size of the rect used for the source area. This allows the sprite hardware to send a subregion to the plane blender for display on the crtc.

Quoted 4 lines

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

Quoted 2 lines
include/drm/drm_mode.h +2 -0
+
+       __u32 zpos;

Is this for order of plane(overlay)?

Yes.

Hope that helps; most of the above came out of earlier review comments since some display hardware allows a lot of flexibility when displaying overlay planes.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#4 lore raw

Re: [PATCH 1/4] drm: add plane support

2011/7/22 Jesse Barnes <[email protected]>:

Quoted 44 lines
Quoted 29 lines · On Thu, 21 Jul 2011 19:30:00 +0900 Joonyoung Shim <[email protected]> wrote:

Hi,

simple questions :)

2011/6/21 Jesse Barnes <[email protected]>:

Quoted 13 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 |  235 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c  |    3 +
 include/drm/drm.h          |    3 +
 include/drm/drm_crtc.h     |   73 ++++++++++++++- include/drm/drm_mode.h     |   35 +++++++

 5 files changed, 346 insertions(+), 3 deletions(-)

snip

Quoted 8 lines
include/drm/drm_mode.h +0 -0
index c4961ea..fa6d348 100644
@@ -120,6 +120,41 @@ struct drm_mode_crtc {
        struct drm_mode_modeinfo mode;
  };
 
Quoted 11 lines

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

Quoted 8 lines
include/drm/drm_mode.h +8 -0
+/* 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;

Is this location offset from base(0, 0) of fb for plane, or from base of crtc(mode)?

Quoted 3 lines

This is the offset on the crtc specifically (which could be displaying a nonzero offset of a given fb).

Then if i want to use the specific area of a given fb for overlay, how can we know the offset on a given fb?
In other words, can we use the specific offset from fb to origin(base pointer) of plane? or can we use each overlays from each specific offsets of one fb?

Thanks.

Signature · 1 line
- Joonyoung Shim
#5 lore raw

Re: [PATCH 1/4] drm: add plane support

Quoted 49 lines · Joonyoung Shim

2011/7/22 Jesse Barnes <[email protected]>:

Quoted 44 lines
Quoted 29 lines · On Thu, 21 Jul 2011 19:30:00 +0900 Joonyoung Shim <[email protected]> wrote:

Hi,

simple questions :)

2011/6/21 Jesse Barnes <[email protected]>:

Quoted 13 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 |  235 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c  |    3 +
 include/drm/drm.h          |    3 +
 include/drm/drm_crtc.h     |   73 ++++++++++++++- include/drm/drm_mode.h     |   35 +++++++

 5 files changed, 346 insertions(+), 3 deletions(-)

snip

Quoted 8 lines
include/drm/drm_mode.h +0 -0
index c4961ea..fa6d348 100644
@@ -120,6 +120,41 @@ struct drm_mode_crtc {
        struct drm_mode_modeinfo mode;
  };
 
Quoted 11 lines

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

Quoted 8 lines
include/drm/drm_mode.h +8 -0
+/* 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;

Is this location offset from base(0, 0) of fb for plane, or from base of crtc(mode)?

Quoted 3 lines

This is the offset on the crtc specifically (which could be displaying a nonzero offset of a given fb).

Quoted 5 lines

Then if i want to use the specific area of a given fb for overlay, how can we know the offset on a given fb?
In other words, can we use the specific offset from fb to origin(base pointer) of plane? or can we use each overlays from each specific offsets of one fb?

The x,y parameters give the position within the fb, the crtc_x,crtc_y parameters give the position within the crtc (screen)..

So if you had full-screen video spanning two 1280x1024 displays, where the video was 1080p. Say the video was nearly but not completely full-screen (say, 5 pixel border all around.. just to pick some #'s):

display one:
plane: x,y=0,0, crtc_x,crtc_y=5,5, crtc_w=1275, crtc_h=1014

display two: (to right of display one)
plane: x,y=960,0, crtc_x,crtc_y=0,5, crtc_w=1275, crtc_h=1014

(or at least that is my understanding..)

BR,
-R

Quoted 9 lines

Thanks.

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

#6 lore raw

Re: [PATCH 1/4] drm: add plane support

2011/7/25 Rob Clark <[email protected]>:

Quoted 50 lines · Joonyoung Shim
Quoted 49 lines

2011/7/22 Jesse Barnes <[email protected]>:

Quoted 47 lines
Quoted 29 lines · On Thu, 21 Jul 2011 19:30:00 +0900 Joonyoung Shim <[email protected]> wrote:

Hi,

simple questions :)

2011/6/21 Jesse Barnes <[email protected]>:

Quoted 13 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 |  235 +++++++++++++++++++++++++++++++++++++++++++- drivers/gpu/drm/drm_drv.c  |    3 +
 include/drm/drm.h          |    3 +
 include/drm/drm_crtc.h     |   73 ++++++++++++++- include/drm/drm_mode.h     |   35 +++++++

 5 files changed, 346 insertions(+), 3 deletions(-)

snip

Quoted 8 lines
include/drm/drm_mode.h +0 -0
index c4961ea..fa6d348 100644
@@ -120,6 +120,41 @@ struct drm_mode_crtc {
        struct drm_mode_modeinfo mode;
  };
 
Quoted 11 lines

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

Quoted 8 lines
include/drm/drm_mode.h +8 -0
+/* 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;

Is this location offset from base(0, 0) of fb for plane, or from base of crtc(mode)?

This is the offset on the crtc specifically (which could be displaying a nonzero offset of a given fb).

Quoted 9 lines
Quoted 5 lines

Then if i want to use the specific area of a given fb for overlay, how can we know the offset on a given fb?
In other words, can we use the specific offset from fb to origin(base pointer) of plane? or can we use each overlays from each specific offsets of one fb?

The x,y parameters give the position within the fb, the crtc_x,crtc_y parameters give the position within the crtc (screen)..

Hmm, i can't understand well, which x, y parameters? As you know, struct drm_mode_set_plane hasn't x , y parameters for fb, so how can know x, y parameters?

Quoted 25 lines

So if you had full-screen video spanning two 1280x1024 displays, where the video was 1080p.  Say the video was nearly but not completely full-screen (say, 5 pixel border all around.. just to pick some #'s):

display one:
 plane:  x,y=0,0, crtc_x,crtc_y=5,5, crtc_w=1275, crtc_h=1014

display two:  (to right of display one)
 plane: x,y=960,0, crtc_x,crtc_y=0,5, crtc_w=1275, crtc_h=1014

(or at least that is my understanding..)

BR,
-R

Quoted 9 lines

Thanks.

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

Signature · 1 line
- Joonyoung Shim
#7 lore raw

Re: [PATCH 1/4] drm: add plane support

In reply to Jesse Barnes
Quoted 4 lines · Jesse Barnes

 /**
+ * drm_plane_funcs - driver plane control functions
+ * @update_plane: update the plane configuration
+ */

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

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);
+       void (*disable_plane)(struct drm_plane *plane);
+};
+

would it freak anyone out too much to ask about multi-planar formats? Ie. say you have an overlay that could display I420 w/ separate Y, U, & V addresses or NV12 w/ separate Y and UV addresses. Some of the SoC's out there require that chroma and luma is in different memory banks. In omap4xxx case we don't have this requirement, but we do have different tiling for Y and UV (NV12).

Not something that directly affects this patchset.. I'm thinking more along the lines of having a way to create a drm_framebuffer w/ more than one GEM buffer, one per color plane. The other option is to bury this all behind a single GEM buffer.. although that seems like it could get ugly/hacky.

Am I opening a can of worms here? ;-)

BR,
-R

#8 lore raw

Re: [PATCH 1/4] drm: add plane support

Quoted 24 lines · On Fri, 22 Jul 2011 08:52:52 -0500 Rob Clark <[email protected]> wrote:
Quoted 4 lines · Jesse Barnes

 /**
+ * drm_plane_funcs - driver plane control functions
+ * @update_plane: update the plane configuration
+ */

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

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);
+       void (*disable_plane)(struct drm_plane *plane);
+};
+

would it freak anyone out too much to ask about multi-planar formats? Ie. say you have an overlay that could display I420 w/ separate Y, U, & V addresses or NV12 w/ separate Y and UV addresses. Some of the SoC's out there require that chroma and luma is in different memory banks. In omap4xxx case we don't have this requirement, but we do have different tiling for Y and UV (NV12).

Quoted 7 lines

Not something that directly affects this patchset.. I'm thinking more along the lines of having a way to create a drm_framebuffer w/ more than one GEM buffer, one per color plane. The other option is to bury this all behind a single GEM buffer.. although that seems like it could get ugly/hacky.

Am I opening a can of worms here? ;-)

Yes. :)

Given the format constraints for planar, multi-buffer configs, it might be best to expose those as driver specific ioctls. It's a big ugly to have a driver specific addfb (only because we don't have one currently) but should be doable for funkier things like this.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#9 lore raw

Re: [PATCH 1/4] drm: add plane support

Quoted 33 lines · Jesse Barnes
Quoted 30 lines · On Fri, 22 Jul 2011 08:52:52 -0500 Rob Clark <[email protected]> wrote:
Quoted 4 lines · Jesse Barnes

 /**
+ * drm_plane_funcs - driver plane control functions
+ * @update_plane: update the plane configuration
+ */

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

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);
+       void (*disable_plane)(struct drm_plane *plane);
+};
+

would it freak anyone out too much to ask about multi-planar formats? Ie. say you have an overlay that could display I420 w/ separate Y, U, & V addresses or NV12 w/ separate Y and UV addresses.  Some of the SoC's out there require that chroma and luma is in different memory banks.  In omap4xxx case we don't have this requirement, but we do have different tiling for Y and UV  (NV12).

Not something that directly affects this patchset.. I'm thinking more along the lines of having a way to create a drm_framebuffer w/ more than one GEM buffer, one per color plane.  The other option is to bury this all behind a single GEM buffer.. although that seems like it could get ugly/hacky.

Quoted 9 lines
Quoted 1 line

Am I opening a can of worms here?  ;-)

Yes. :)

Given the format constraints for planar, multi-buffer configs, it might be best to expose those as driver specific ioctls.  It's a big ugly to have a driver specific addfb (only because we don't have one currently) but should be doable for funkier things like this.

I'm ok with this.. we can always add a common ioctl later if we end up with multiple drivers doing things the same way

BR,
-R

Quoted 3 lines

--
Jesse Barnes, Intel Open Source Technology Center

#10 lore raw

Re: [PATCH 1/4] drm: add plane support

In reply to Rob Clark
Quoted 5 lines

Not something that directly affects this patchset.. I'm thinking more along the lines of having a way to create a drm_framebuffer w/ more than one GEM buffer, one per color plane. The other option is to bury this all behind a single GEM buffer.. although that seems like it could get ugly/hacky.

My own guess is that it will be best to have a possibly specialist function to allocate the object, but to give it a single GEM handle. For the most part its a list of pinned pages somewhere and while picking the pages to use is special I am thinking that the rest of the behaviour is probably not.

It also then means on the client side that it's a single buffer, a single mmap and can be wrapped easily in things like libkms.

Alan

#11 lore raw

PATCH 2/4 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/psb_fb.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 9be36a5..f963cf5 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 9236965..5adab04 100644
@@ -801,13 +801,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 0b6fd36..8a6e3ab 100644
@@ -5803,7 +5803,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;
@@ -5845,7 +5845,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));
@@ -5857,6 +5857,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);
 }
@@ -6978,7 +6979,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;
@@ -7013,7 +7014,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 0dc9018..3cfc391 100644
@@ -326,7 +326,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 eb514ea..b03df00 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;
@@ -121,7 +121,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 ae247ee..74ffab6 100644
@@ -1122,7 +1122,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;
@@ -1133,7 +1133,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 977a341..121eb56 100644
@@ -637,7 +637,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 dfe32e6..f6566a8 100644
@@ -836,7 +836,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/psb_fb.c +1 -1
index 99c03a2..3cfa632 100644
@@ -481,7 +481,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 caa72ae..6ac4d74 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>
 
@@ -244,6 +245,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;
@@ -604,7 +606,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);
 };
 
@@ -822,6 +824,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 fa6d348..82cd587 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
@@ -264,6 +266,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
#12 lore raw

PATCH 3/4 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 51c2257..c83ed15 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 31e199f..062e80e 100644
@@ -117,8 +117,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;
 };
 
@@ -336,7 +336,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 */
@@ -1329,8 +1329,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 b79619a..7a34167 100644
@@ -991,7 +991,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 8a6e3ab..7901f16 100644
@@ -2936,7 +2936,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 3cfc391..d73e622 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;
 
@@ -337,7 +337,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
#13 lore raw

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

In reply to Jesse Barnes

The video sprites support video surface formats natively and can handle scaling 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  |   19 +++-
 drivers/gpu/drm/i915/intel_drv.h      |   14 +++
 drivers/gpu/drm/i915/intel_fb.c       |    6 +
 drivers/gpu/drm/i915/intel_overlay2.c |  188 +++++++++++++++++++++++++++++++++
 6 files changed, 274 insertions(+), 6 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 +13 -6
index 7901f16..72a570a 100644
@@ -900,8 +900,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;
@@ -914,8 +914,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)
@@ -4319,7 +4317,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);
@@ -4331,7 +4330,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);
@@ -4371,6 +4371,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,
@@ -8013,6 +8018,8 @@ 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))
+			intel_plane_init(dev, i);
 	}
 
 	/* Just disable it once at startup */
drivers/gpu/drm/i915/intel_drv.h +14 -0
index d73e622..232d797 100644
@@ -173,10 +173,18 @@ struct intel_crtc {
 	unsigned int bpp;
 };
 
+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_TYPE_AVI    0x82
 #define DIP_VERSION_AVI 0x2
@@ -255,6 +263,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 void 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,
@@ -346,5 +355,10 @@ 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);
 #endif /* __INTEL_DRV_H__ */
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 +188 -0

188 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
#14 lore raw
In reply to Jesse Barnes
Quoted 7 lines · Jesse Barnes

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

Quoted 9 lines

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Thanks,
Jesse

Is it possible to position a plane above and below the "normal" crtc framebuffer? Plane z-order is unsigned, and I would assume 0 is default z-order. Applications will need to position planes above and below crtc normal framebuffer. Below when using a translucent or color keyed framebuffer, and above if framebuffer is opaque.

So maybe add a one liner comment about z-order meaning and make it signed unless ordering should be solved in another way.

And should it be possible to only define planes with no crtc framebuffer at all? Use case, for example letter boxed video on black background with small UI controls/subtitles. In this case it's not power efficient to have a fullscreen fb with mostly if not all transparent pixels.

/BR
/Marcus

#15 lore raw
Quoted 4 lines · Marcus Lorentzon

And should it be possible to only define planes with no crtc framebuffer at all? Use case, for example letter boxed video on black background with small UI controls/subtitles. In this case it's not power efficient to have a fullscreen fb with mostly if not all transparent pixels.

I think we could shoe-horn this use-case into the current framework by using a special crtc-property "ignore attached fb, use this default color instead". But I think this would be better done in a second step when we tackle atomic vsync flips across multiple planes and the underlying crtc - that might also require us to change certain properties in the same flip command.

-Daniel

Signature · 2 lines
Daniel Vetter
[email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
#16 lore raw
In reply to Marcus Lorentzon
Quoted 17 lines · On Tue, 21 Jun 2011 10:55:39 +0200 Marcus Lorentzon…
Quoted 7 lines · Jesse Barnes

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

Quoted 9 lines

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Thanks,
Jesse

Quoted 6 lines

Is it possible to position a plane above and below the "normal" crtc framebuffer? Plane z-order is unsigned, and I would assume 0 is default z-order.
Applications will need to position planes above and below crtc normal framebuffer. Below when using a translucent or color keyed framebuffer, and above if framebuffer is opaque.

I was thinking 0 would be the bottom layer. But either way we don't have a way of getting the primary plane z position atm, so it'll be hard to position a new plane above or below the main plane... I'm ok with a signed value here, but the real meaning will be defined by a new ioctl we use to get plane blending restrictions, z order, and such.

Quoted 7 lines

So maybe add a one liner comment about z-order meaning and make it signed unless ordering should be solved in another way.

And should it be possible to only define planes with no crtc framebuffer at all? Use case, for example letter boxed video on black background with small UI controls/subtitles. In this case it's not power efficient to have a fullscreen fb with mostly if not all transparent pixels.

A particular driver may be able to expose that somehow, maybe by allowing clients to define a special fb handle that can be used to indicate no plane should be bound to the CRTC as the "primary" plane.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#17 lore raw
In reply to Jesse Barnes
Quoted 11 lines · Jesse Barnes

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Cool, thanks for this

I'm just thinking through how I'd implement the driver part in omap drm driver.. so please bear with me if I'm misunderstanding..

In particular I'm thinking about being able to use a given video pipe (basically like a dma channel) as either framebuffer layer or overlay at various points in time, depending on how many displays are attached. Is the idea to use drm_plane *only* for overlay layer, and still use crtc->fb for the normal framebuffer layer?

Or would/could a drm_plane also be used for main layer instead of crtc->fb? In this case, either userspace would have to know (which doesn't seem like a good idea for things like plymouth which use drm interface a bit generically). Or the driver would have to internally automatically hook up a drm_plane if it sees that userspace hasn't done this.

I was thinking perhaps that if we let userspace DRM_IOCTL_MODE_SETCRTC pass in -1 for fb_id, followed by one or more DRM_IOCTL_MODE_SETPLANE's, to set things up the "new" way (explicitly specify the drm_plane's). Or if _SETCRTC passes in a valid fb_id, we know it is the old way, and driver automatically picks a drm_plane.

BR,
-R

Quoted 8 lines

Thanks,
Jesse

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

#18 lore raw
Quoted 31 lines · Rob Clark
Quoted 11 lines · Jesse Barnes

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Cool, thanks for this

I'm just thinking through how I'd implement the driver part in omap drm driver.. so please bear with me if I'm misunderstanding..

In particular I'm thinking about being able to use a given video pipe (basically like a dma channel) as either framebuffer layer or overlay at various points in time, depending on how many displays are attached.  Is the idea to use drm_plane *only* for overlay layer, and still use crtc->fb for the normal framebuffer layer?

Or would/could a drm_plane also be used for main layer instead of crtc->fb?  In this case, either userspace would have to know (which doesn't seem like a good idea for things like plymouth which use drm interface a bit generically).  Or the driver would have to internally automatically hook up a drm_plane if it sees that userspace hasn't done this.

Quoted 5 lines

I was thinking perhaps that if we let userspace DRM_IOCTL_MODE_SETCRTC pass in -1 for fb_id, followed by one or more DRM_IOCTL_MODE_SETPLANE's, to set things up the "new" way (explicitly specify the drm_plane's).  Or if _SETCRTC passes in a valid fb_id, we know it is the old way, and driver automatically picks a drm_plane.

just thinking through this a bit more.. the idea is that for drivers w/ DRM_SUPPORTS_PLANES[1], there is no fb hooked directly to crtc. And support for userspace that is not aware of planes could be, I think, mostly in the kms core, although I'm just thinking through how disruptive that would be..

I think if we add a crtc->funcs->get_primary_plane() to be implemented by drivers that use planes in cases where userspace does not know about planes. It would be used to get (and if necessary, assign) a drm_plane to a drm_crtc, then we can do things like:

handle _SETCRTC from userspace that doesn't understand planes:
---------
@@ -1580,7 +1580,14 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,

        set.mode = mode;
        set.connectors = connector_set;
        set.num_connectors = crtc_req->count_connectors;

- set.fb = fb;
+ if (fb & (dev->driver->driver_features & DRM_SUPPORTS_PLANES)) {
+ /* pass fb to the primary plane for compatibility */
+ struct drm_plane *plane =
+ crtc->funcs->get_primary_plane(crtc);
+ set.plane = plane;
+ plane->funcs->set_config(&set);
+ } else {
+ set.fb = fb;
+ }

        ret = crtc->funcs->set_config(&set);

out:
---------

or page flip ioctl from userspace that doesn't understand planes:

---------
@@ -2645,7 +2652,14 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,

                        (void (*) (struct drm_pending_event *)) kfree;
        }

- ret = crtc->funcs->page_flip(crtc, fb, e);
+ if (dev->driver->driver_features & DRM_SUPPORTS_PLANES) {
+ struct drm_plane *plane =
+ crtc->funcs->get_primary_plane(crtc);
+ ret = plane->funcs->page_flip(plane, fb, e);
+ } else {
+ ret = crtc->funcs->page_flip(crtc, fb, e);
+ }
+

        if (ret) {
                spin_lock_irqsave(&dev->event_lock, flags);
                file_priv->event_space += sizeof e->event;

---------

It doesn't look like there are *that* many places where crtc->fb is reference, but I've not gone through all of them.. I'm not sure if this sort of change would be too intrusive.

BR,
-R

--
[1] or maybe DRM_MANDATORY_PLANES if there are some drivers that would use a hybrid model of fb either direct to drm_crtc, or indirect via a drm_plane

BR,
-R

#19 lore raw
In reply to Rob Clark
Quoted 15 lines · On Tue, 21 Jun 2011 06:21:11 -0500 Rob Clark <[email protected]> wrote:
Quoted 11 lines · Jesse Barnes

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Cool, thanks for this

Quoted 8 lines

I'm just thinking through how I'd implement the driver part in omap drm driver.. so please bear with me if I'm misunderstanding..

In particular I'm thinking about being able to use a given video pipe (basically like a dma channel) as either framebuffer layer or overlay at various points in time, depending on how many displays are attached. Is the idea to use drm_plane *only* for overlay layer, and still use crtc->fb for the normal framebuffer layer?

Given the structure of the current KMS API, a CRTC implies a plane of some sort, but I don't think the driver is restricted to using the same plane for a given CRTC forever; it could allocate and switch them around depending on usage, with planes beyond what's currently associated with the CRTC exposed through this interface.

Quoted 5 lines

I was thinking perhaps that if we let userspace DRM_IOCTL_MODE_SETCRTC pass in -1 for fb_id, followed by one or more DRM_IOCTL_MODE_SETPLANE's, to set things up the "new" way (explicitly specify the drm_plane's). Or if _SETCRTC passes in a valid fb_id, we know it is the old way, and driver automatically picks a drm_plane.

Yeah that might work; we'd probably want a new GETPARAM flag to indicate support for this... The tough part is doing it in such a way that we don't break existing userspace.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#20 lore raw
Quoted 27 lines · Jesse Barnes
Quoted 15 lines · On Tue, 21 Jun 2011 06:21:11 -0500 Rob Clark <[email protected]> wrote:
Quoted 11 lines · Jesse Barnes

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Cool, thanks for this

Quoted 8 lines

I'm just thinking through how I'd implement the driver part in omap drm driver.. so please bear with me if I'm misunderstanding..

In particular I'm thinking about being able to use a given video pipe (basically like a dma channel) as either framebuffer layer or overlay at various points in time, depending on how many displays are attached.  Is the idea to use drm_plane *only* for overlay layer, and still use crtc->fb for the normal framebuffer layer?

Quoted 5 lines

Given the structure of the current KMS API, a CRTC implies a plane of some sort, but I don't think the driver is restricted to using the same plane for a given CRTC forever; it could allocate and switch them around depending on usage, with planes beyond what's currently associated with the CRTC exposed through this interface.

The awkward thing is how do you express to userspace that if it isn't using some CRTC(s) that it has an extra plane(s) available, if each crtc even though it is not enabled, is assumed to consume a plane (video pipe)..

That said if OMAP is the only hw like this, one possible solution is that you just need to have userspace know.. ie. the main one taking advantage of this feature would be the xorg driver, and it already knows what DRM driver it is talking to. Generic things like splash screen won't need to be using all the video planes.

But I'm at least under the impression that some of the other SoC's have similar flexibility to use video planes as either primary or overlay layers. So I figure it is at least worth trying to handle this in a more generic way if it doesn't cause too much ugliness to KMS core.

Quoted 9 lines
Quoted 5 lines

I was thinking perhaps that if we let userspace DRM_IOCTL_MODE_SETCRTC pass in -1 for fb_id, followed by one or more DRM_IOCTL_MODE_SETPLANE's, to set things up the "new" way (explicitly specify the drm_plane's).  Or if _SETCRTC passes in a valid fb_id, we know it is the old way, and driver automatically picks a drm_plane.

Yeah that might work; we'd probably want a new GETPARAM flag to indicate support for this...  The tough part is doing it in such a way that we don't break existing userspace.

fwiw, Daniel and I discussed a bit on IRC earlier today, and he had an interesting idea about having a simple drm_plane shim+helpers to keep things similar for existing drivers. I think it should be possible to support both old and new userspace semantics this way without too much if(driver_features & SUPPORTS_PLANES) sort of stuff.

BR,
-R

#21 lore raw
Quoted 6 lines · Rob Clark

But I'm at least under the impression that some of the other SoC's have similar flexibility to use video planes as either primary or overlay layers. So I figure it is at least worth trying to handle this in a more generic way if it doesn't cause too much ugliness to KMS core.

Yes, our DSS have similar flexibility. That is, we don't have a special fullscreen framebuffer for the crtc. Instead we have generic "overlays" for all framebuffers that can be positioned anywhere and have any format, all on a background color of choice. So we are happy with a more generic approach where current implementation use a default plane for crtc fb. But it should not hog HW resources when not used. If a plane is used, I think it should be a "normal" plane that the user can control and enumerate.

/BR
/Marcus

#22 lore raw
In reply to Jesse Barnes

2011/6/21 Jesse Barnes <[email protected]>:

Quoted 7 lines

This version adds both source and dest rect params to the set_plane ioctl, and makes the source fixed point to support hardware that needs it.

I haven't changed the name of the SNB implementation yet (per Chris's suggestions) but will before it gets upstream.

Quoted 8 lines

I'd be interested to see whether these interfaces will work for other hardware, so please take a close look at them and ideally implement them on your hardware to make sure (see my userspace example code from earlier posts if you want something to crib from).

Thanks,
Jesse

Hi, Jesse.

Could you have any posting plan for plane?

Thanks.