linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 2.6.28 1/2] fbdev: add damage support
@ 2009-01-25 12:15 Jaya Kumar
  2009-01-25 12:15 ` [RFC 2.6.28 2/2] broadsheetfb: add damage handling Jaya Kumar
  2009-01-30 11:01 ` [RFC 2.6.28 1/2] fbdev: add damage support Magnus Damm
  0 siblings, 2 replies; 4+ messages in thread
From: Jaya Kumar @ 2009-01-25 12:15 UTC (permalink / raw)
  Cc: linux-fbdev-devel, adaplas, Magnus Damm, armbru, lethal,
	Geert Uytterhoeven, Jaya Kumar

Hi Geert, Krzysztof, Magnus, fbdev friends,

This is version 2 of an idea about allowing userspace to provide damage
information to drivers. Thanks to Magnus, Tomi, and others for discussion
and ideas.

This is just a first pass implementation. The primary change from before
is that we no longer do any processing of the damage within fbdev.
Instead, we pass it straight through to the driver for handling. Please
note I have not added a get_damage in order to postpone the question of how
best to expose optimization information to userspace. I felt that this
would be a good way for us to determine if we have consensus on the basic
part of userspace API first. If we agree on that, then later we can work
out how (and if) we should abstract the kernel side further. That is, if
we can abstract some of the processing within fbdev itself and simplify
the driver handlers. Please let me know your thoughts. 

Thanks,
jaya

This patch adds the ability for userspace applications to provide damage
information to the underlying driver. This is useful in scenarios where the
underlying driver can perform transfer optimizations based on knowing
exactly which framebuffer areas that were updated. This functionality is
exposed by using a simple x,y,w,h bounding box structure. Userspace is
expected to perform its damage and then perform the ioctl. The underlying
driver is free to use this information as it sees fit including ignoring it
if it chooses to. An example use case will be provided in the case of
broadsheetfb.c where the damage information is aggregated for deferred use.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Cc: armbru@redhat.com
Cc: lethal@linux-sh.org
Cc: adaplas@gmail.com
Cc: linux-fbdev-devel@lists.sourceforge.net
Signed-off-by: Jaya Kumar <jayakumar.lkml@gmail.com>
---
 drivers/video/fbmem.c |   15 +++++++++++++++
 include/linux/fb.h    |   19 ++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 756efeb..11a0e05 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1006,6 +1006,14 @@ fb_blank(struct fb_info *info, int blank)
  	return ret;
 }
 
+static int fb_set_damage(struct fb_info *info, struct fb_damage_user *udamage)
+{
+	if (info->fbops->fb_set_damage)
+		return info->fbops->fb_set_damage(info, udamage);
+
+	return -ENOTTY;
+}
+
 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 			unsigned long arg)
 {
@@ -1015,6 +1023,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 	struct fb_con2fbmap con2fb;
 	struct fb_cmap_user cmap;
 	struct fb_event event;
+	struct fb_damage_user udamage;
 	void __user *argp = (void __user *)arg;
 	long ret = 0;
 
@@ -1116,6 +1125,12 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 		info->flags &= ~FBINFO_MISC_USEREVENT;
 		release_console_sem();
 		break;;
+	case FBIOPUT_DAMAGE:
+		if (copy_from_user(&udamage, argp, sizeof(udamage)))
+			ret = -EFAULT;
+		else
+			ret = fb_set_damage(info, &udamage);
+		break;
 	default:
 		if (fb->fb_ioctl == NULL)
 			ret = -ENOTTY;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 1ee63df..ac9e224 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -37,7 +37,8 @@ struct dentry;
 #define FBIOGET_HWCINFO         0x4616
 #define FBIOPUT_MODEINFO        0x4617
 #define FBIOGET_DISPINFO        0x4618
-
+/* to allow userspace to provide screen damage information to drivers */
+#define FBIOPUT_DAMAGE          0x4619
 
 #define FB_TYPE_PACKED_PIXELS		0	/* Packed Pixels	*/
 #define FB_TYPE_PLANES			1	/* Non interleaved planes */
@@ -357,6 +358,18 @@ struct fb_image {
 	struct fb_cmap cmap;	/* color map info */
 };
 
+struct fb_damage_rect {
+	__u16 x;
+	__u16 y;
+	__u16 w;
+	__u16 h;
+};
+
+struct fb_damage_user {
+	__u32 len;		/* Number of entries */
+	struct fb_damage_rect __user *rects; /* array of damage rectangles */
+};
+
 /*
  * hardware cursor control
  */
@@ -672,6 +685,10 @@ struct fb_ops {
 	/* get capability given var */
 	void (*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps,
 			    struct fb_var_screeninfo *var);
+
+	/* provide damage information */
+	int (*fb_set_damage)(struct fb_info *info,
+				struct fb_damage_user *damage);
 };
 
 #ifdef CONFIG_FB_TILEBLITTING
-- 
1.5.2.3


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [RFC 2.6.28 1/2] fbdev: add ability to set damage
@ 2009-01-15  0:06 Jaya Kumar
  2009-01-15  0:06 ` [RFC 2.6.28 2/2] broadsheetfb: add damage handling Jaya Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Jaya Kumar @ 2009-01-15  0:06 UTC (permalink / raw)
  Cc: linux-fbdev-devel, adaplas, Magnus Damm, armbru, lethal,
	Geert Uytterhoeven, Jaya Kumar

Hi Geert, Krzysztof, Magnus, fbdev friends,

I would like to propose this idea about allowing userspace to provide damage
information to drivers. This is just a first pass implementation. Please let
me know your thoughts.

Thanks,
jaya

This patch adds the ability for userspace applications to provide damage
information to the underlying driver. This is useful in scenarios where the
underlying driver can perform transfer optimizations based on knowing
exactly which framebuffer areas that were updated. This functionality is
exposed by using a simple x,y,w,h bounding box structure. Userspace is
expected to perform its damage and then perform the ioctl. The underlying
driver is free to use this information as it sees fit including ignoring it
if it chooses to. An example use case will be provided in the case of
broadsheetfb.c where the damage information is aggregated for deferred use.

Signed-off-by: Jaya Kumar <jayakumar.lkml@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: armbru@redhat.com
Cc: lethal@linux-sh.org
Cc: adaplas@gmail.com
Cc: linux-fbdev-devel@lists.sourceforge.net
---
 drivers/video/fbmem.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fb.h    |   24 +++++++++++++++++++
 2 files changed, 85 insertions(+), 0 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 756efeb..f95ec45 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1006,6 +1006,60 @@ fb_blank(struct fb_info *info, int blank)
  	return ret;
 }
 
+static int fb_alloc_damage(struct fb_damage **damagep, int len)
+{
+	struct fb_damage *damage;
+
+	damage = kzalloc(sizeof(struct fb_damage), GFP_KERNEL);
+	if (!damage)
+		return -ENOMEM;
+
+	damage->len = len;
+	damage->rects = kzalloc(sizeof(struct fb_damage_rect) * len,
+				GFP_KERNEL);
+	if (!damage->rects) {
+		kfree(damage);
+		return -ENOMEM;
+	}
+
+	*damagep = damage;
+	return 0;
+}
+
+static void fb_free_damage(struct fb_damage *damage)
+{
+	if (damage)
+		kfree(damage->rects);
+	kfree(damage);
+}
+
+static int fb_set_damage(struct fb_info *info, struct fb_damage_user *udamage)
+{
+	int ret = -EINVAL;
+	int size = udamage->len;
+	struct fb_damage *damage;
+
+	if (size > FB_DAMAGE_COUNT_MAX)
+		goto fail;
+
+	ret = fb_alloc_damage(&damage, size);
+	if (ret)
+		goto fail;
+
+	if (copy_from_user(damage->rects, udamage->rects,
+				sizeof(struct fb_damage_rect)*size)) {
+		ret = -EFAULT;
+		goto fail2;
+	}
+
+	if (info->fbops->fb_set_damage)
+		return info->fbops->fb_set_damage(info, damage);
+fail2:
+	fb_free_damage(damage);
+fail:
+	return ret;
+}
+
 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 			unsigned long arg)
 {
@@ -1015,6 +1069,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 	struct fb_con2fbmap con2fb;
 	struct fb_cmap_user cmap;
 	struct fb_event event;
+	struct fb_damage_user udamage;
 	void __user *argp = (void __user *)arg;
 	long ret = 0;
 
@@ -1116,6 +1171,12 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
 		info->flags &= ~FBINFO_MISC_USEREVENT;
 		release_console_sem();
 		break;;
+	case FBIOPUT_DAMAGE:
+		if (copy_from_user(&udamage, argp, sizeof(udamage)))
+			ret = -EFAULT;
+		else
+			ret = fb_set_damage(info, &udamage);
+		break;
 	default:
 		if (fb->fb_ioctl == NULL)
 			ret = -ENOTTY;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 1ee63df..8ee5f6d 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -37,7 +37,10 @@ struct dentry;
 #define FBIOGET_HWCINFO         0x4616
 #define FBIOPUT_MODEINFO        0x4617
 #define FBIOGET_DISPINFO        0x4618
+/* to allow userspace to provide screen damage information to drivers */
+#define FBIOPUT_DAMAGE          0x4619
 
+#define FB_DAMAGE_COUNT_MAX	32	/* max number of damage rects */
 
 #define FB_TYPE_PACKED_PIXELS		0	/* Packed Pixels	*/
 #define FB_TYPE_PLANES			1	/* Non interleaved planes */
@@ -357,6 +360,24 @@ struct fb_image {
 	struct fb_cmap cmap;	/* color map info */
 };
 
+struct fb_damage_rect {
+	__u16 x;
+	__u16 y;
+	__u16 w;
+	__u16 h;
+};
+
+struct fb_damage {
+	struct list_head list;
+	__u32 len;		/* Number of entries */
+	struct fb_damage_rect *rects; /* array of damage rectangles */
+};
+
+struct fb_damage_user {
+	__u32 len;		/* Number of entries */
+	struct fb_damage_rect __user *rects; /* array of damage rectangles */
+};
+
 /*
  * hardware cursor control
  */
@@ -672,6 +693,9 @@ struct fb_ops {
 	/* get capability given var */
 	void (*fb_get_caps)(struct fb_info *info, struct fb_blit_caps *caps,
 			    struct fb_var_screeninfo *var);
+
+	/* provide damage information */
+	int (*fb_set_damage)(struct fb_info *info, struct fb_damage *damage);
 };
 
 #ifdef CONFIG_FB_TILEBLITTING
-- 
1.5.2.3


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-01-30 11:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-25 12:15 [RFC 2.6.28 1/2] fbdev: add damage support Jaya Kumar
2009-01-25 12:15 ` [RFC 2.6.28 2/2] broadsheetfb: add damage handling Jaya Kumar
2009-01-30 11:01 ` [RFC 2.6.28 1/2] fbdev: add damage support Magnus Damm
  -- strict thread matches above, loose matches on Subject: below --
2009-01-15  0:06 [RFC 2.6.28 1/2] fbdev: add ability to set damage Jaya Kumar
2009-01-15  0:06 ` [RFC 2.6.28 2/2] broadsheetfb: add damage handling Jaya Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).