* [PATCH 1/2] OMAP: DSS2: OMAPFB: implement OMAPFB_RESERVE_BUFFER
@ 2010-02-04 15:31 Tomi Valkeinen
2010-02-04 15:31 ` [PATCH 2/2] OMAP: DSS2: OMAPFB: implement OMAPFB_GET_DISPLAY_INFO Tomi Valkeinen
0 siblings, 1 reply; 4+ messages in thread
From: Tomi Valkeinen @ 2010-02-04 15:31 UTC (permalink / raw)
To: linux-omap, linux-fbdev; +Cc: Tomi Valkeinen
Currently applications can reserve fb memory with OMAPFB_SETUP_MEM
ioctl, which takes the size in bytes as an argument. This falls apart
when using VRFB, as the memory need for VRFB is not trivial
This patch implements OMAPFB_RESERVE_BUFFER ioctl, which reserves memory
just like SETUP_MEM, but takes width, height and bytes per pixel as
arguments. This will let omapfb driver allocate the memory more
intelligently.
The "size" entry in sysfs now also supports writing the size in
"width,height,bytespp" format.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
---
drivers/video/omap2/omapfb/omapfb-ioctl.c | 51 +++++++++++++++++++++++++++++
drivers/video/omap2/omapfb/omapfb-sysfs.c | 13 +++++++-
include/linux/omapfb.h | 10 ++++++
3 files changed, 73 insertions(+), 1 deletions(-)
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index 4c4bafd..5562a76 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -155,6 +155,47 @@ static int omapfb_query_mem(struct fb_info *fbi, struct omapfb_mem_info *mi)
return 0;
}
+static int omapfb_reserve_buffer(struct fb_info *fbi,
+ struct omapfb_res_buf_info *bi)
+{
+ struct omapfb_info *ofbi = FB2OFB(fbi);
+ struct omapfb2_device *fbdev = ofbi->fbdev;
+ struct omapfb2_mem_region *rg;
+ int r, i;
+ size_t size;
+ unsigned w = bi->width;
+ unsigned h = bi->height;
+
+ if (bi->type > OMAPFB_MEMTYPE_MAX)
+ return -EINVAL;
+
+ if (ofbi->rotation_type = OMAP_DSS_ROT_VRFB) {
+ size = max(omap_vrfb_min_phys_size(w, h, bi->bytespp),
+ omap_vrfb_min_phys_size(h, w, bi->bytespp));
+ } else {
+ size = w * h * bi->bytespp;
+ }
+
+ size = PAGE_ALIGN(size);
+
+ rg = &ofbi->region;
+
+ for (i = 0; i < ofbi->num_overlays; i++) {
+ if (ofbi->overlays[i]->info.enabled)
+ return -EBUSY;
+ }
+
+ if (rg->size != size || rg->type != bi->type) {
+ r = omapfb_realloc_fbmem(fbi, size, bi->type);
+ if (r) {
+ dev_err(fbdev->dev, "realloc fbmem failed\n");
+ return r;
+ }
+ }
+
+ return 0;
+}
+
static int omapfb_update_window_nolock(struct fb_info *fbi,
u32 x, u32 y, u32 w, u32 h)
{
@@ -476,6 +517,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
struct omapfb_plane_info plane_info;
struct omapfb_caps caps;
struct omapfb_mem_info mem_info;
+ struct omapfb_res_buf_info res_buf_info;
struct omapfb_color_key color_key;
struct omapfb_ovl_colormode ovl_colormode;
enum omapfb_update_mode update_mode;
@@ -572,6 +614,15 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
r = -EFAULT;
break;
+ case OMAPFB_RESERVE_BUFFER:
+ DBG("ioctl RESERVE_BUFFER\n");
+ if (copy_from_user(&p.res_buf_info, (void __user *)arg,
+ sizeof(p.res_buf_info)))
+ r = -EFAULT;
+ else
+ r = omapfb_reserve_buffer(fbi, &p.res_buf_info);
+ break;
+
case OMAPFB_GET_CAPS:
DBG("ioctl GET_CAPS\n");
if (!display) {
diff --git a/drivers/video/omap2/omapfb/omapfb-sysfs.c b/drivers/video/omap2/omapfb/omapfb-sysfs.c
index 62bb88f..9cd7957 100644
--- a/drivers/video/omap2/omapfb/omapfb-sysfs.c
+++ b/drivers/video/omap2/omapfb/omapfb-sysfs.c
@@ -413,8 +413,19 @@ static ssize_t store_size(struct device *dev, struct device_attribute *attr,
unsigned long size;
int r;
int i;
+ unsigned w, h, bytespp;
+
+ if (sscanf(buf, "%u,%u,%u", &w, &h, &bytespp) = 3) {
+ if (ofbi->rotation_type = OMAP_DSS_ROT_VRFB)
+ size = max(omap_vrfb_min_phys_size(w, h, bytespp),
+ omap_vrfb_min_phys_size(h, w, bytespp));
+ else
+ size = w * h * bytespp;
+ } else {
+ size = simple_strtoul(buf, NULL, 0);
+ }
- size = PAGE_ALIGN(simple_strtoul(buf, NULL, 0));
+ size = PAGE_ALIGN(size);
lock_fb_info(fbi);
diff --git a/include/linux/omapfb.h b/include/linux/omapfb.h
index f46c40a..ef4c2cf 100644
--- a/include/linux/omapfb.h
+++ b/include/linux/omapfb.h
@@ -57,6 +57,7 @@
#define OMAPFB_WAITFORGO OMAP_IO(60)
#define OMAPFB_GET_VRAM_INFO OMAP_IOR(61, struct omapfb_vram_info)
#define OMAPFB_SET_TEARSYNC OMAP_IOW(62, struct omapfb_tearsync_info)
+#define OMAPFB_RESERVE_BUFFER OMAP_IOW(63, struct omapfb_res_buf_info)
#define OMAPFB_CAPS_GENERIC_MASK 0x00000fff
#define OMAPFB_CAPS_LCDC_MASK 0x00fff000
@@ -147,6 +148,15 @@ struct omapfb_mem_info {
__u8 reserved[3];
};
+struct omapfb_res_buf_info {
+ __u16 width;
+ __u16 height;
+ __u8 bytespp;
+ __u8 type;
+ __u8 reserved[2];
+ __u32 reserved2[6];
+};
+
struct omapfb_caps {
__u32 ctrl;
__u32 plane_color;
--
1.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] OMAP: DSS2: OMAPFB: implement OMAPFB_GET_DISPLAY_INFO
2010-02-04 15:31 [PATCH 1/2] OMAP: DSS2: OMAPFB: implement OMAPFB_RESERVE_BUFFER Tomi Valkeinen
@ 2010-02-04 15:31 ` Tomi Valkeinen
2010-02-04 23:05 ` [PATCH 2/2] OMAP: DSS2: OMAPFB: implement Ville Syrjälä
0 siblings, 1 reply; 4+ messages in thread
From: Tomi Valkeinen @ 2010-02-04 15:31 UTC (permalink / raw)
To: linux-omap, linux-fbdev; +Cc: Tomi Valkeinen
Previously the only place to get the size of the display was from the
DSS's sysfs interface, making, for example, configuring overlays and doing
updates on manual displays more difficult.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
---
drivers/video/omap2/omapfb/omapfb-ioctl.c | 18 ++++++++++++++++++
include/linux/omapfb.h | 7 +++++++
2 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index 5562a76..c97aaf1 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -525,6 +525,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
struct omapfb_memory_read memory_read;
struct omapfb_vram_info vram_info;
struct omapfb_tearsync_info tearsync_info;
+ struct omapfb_display_info display_info;
} p;
int r = 0;
@@ -792,6 +793,23 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
break;
}
+ case OMAPFB_GET_DISPLAY_INFO: {
+ DBG("ioctl GET_DISPLAY_INFO\n");
+
+ if (display = NULL) {
+ r = -ENODEV;
+ break;
+ }
+
+ p.display_info.width = display->panel.timings.x_res;
+ p.display_info.height = display->panel.timings.y_res;
+
+ if (copy_to_user((void __user *)arg, &p.display_info,
+ sizeof(p.display_info)))
+ r = -EFAULT;
+ break;
+ }
+
default:
dev_err(fbdev->dev, "Unknown ioctl 0x%x\n", cmd);
r = -EINVAL;
diff --git a/include/linux/omapfb.h b/include/linux/omapfb.h
index ef4c2cf..4a88cbe 100644
--- a/include/linux/omapfb.h
+++ b/include/linux/omapfb.h
@@ -58,6 +58,7 @@
#define OMAPFB_GET_VRAM_INFO OMAP_IOR(61, struct omapfb_vram_info)
#define OMAPFB_SET_TEARSYNC OMAP_IOW(62, struct omapfb_tearsync_info)
#define OMAPFB_RESERVE_BUFFER OMAP_IOW(63, struct omapfb_res_buf_info)
+#define OMAPFB_GET_DISPLAY_INFO OMAP_IOR(64, struct omapfb_display_info)
#define OMAPFB_CAPS_GENERIC_MASK 0x00000fff
#define OMAPFB_CAPS_LCDC_MASK 0x00fff000
@@ -216,6 +217,12 @@ struct omapfb_tearsync_info {
__u16 reserved2;
};
+struct omapfb_display_info {
+ __u16 width;
+ __u16 height;
+ __u32 reserved[5];
+};
+
#ifdef __KERNEL__
#include <plat/board.h>
--
1.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] OMAP: DSS2: OMAPFB: implement
2010-02-04 15:31 ` [PATCH 2/2] OMAP: DSS2: OMAPFB: implement OMAPFB_GET_DISPLAY_INFO Tomi Valkeinen
@ 2010-02-04 23:05 ` Ville Syrjälä
2010-02-05 9:28 ` Tomi Valkeinen
0 siblings, 1 reply; 4+ messages in thread
From: Ville Syrjälä @ 2010-02-04 23:05 UTC (permalink / raw)
To: Tomi Valkeinen; +Cc: linux-omap, linux-fbdev
On Thu, Feb 04, 2010 at 05:31:26PM +0200, Tomi Valkeinen wrote:
> Previously the only place to get the size of the display was from the
> DSS's sysfs interface, making, for example, configuring overlays and doing
> updates on manual displays more difficult.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
> ---
> drivers/video/omap2/omapfb/omapfb-ioctl.c | 18 ++++++++++++++++++
> include/linux/omapfb.h | 7 +++++++
> 2 files changed, 25 insertions(+), 0 deletions(-)
>
<snip>
> @@ -216,6 +217,12 @@ struct omapfb_tearsync_info {
> __u16 reserved2;
> };
>
> +struct omapfb_display_info {
> + __u16 width;
> + __u16 height;
How about adding the physical display size here as well? I suppose
mm is the standard unit for such things but for small displays more
accuracy might be nice.
--
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] OMAP: DSS2: OMAPFB: implement
2010-02-04 23:05 ` [PATCH 2/2] OMAP: DSS2: OMAPFB: implement Ville Syrjälä
@ 2010-02-05 9:28 ` Tomi Valkeinen
0 siblings, 0 replies; 4+ messages in thread
From: Tomi Valkeinen @ 2010-02-05 9:28 UTC (permalink / raw)
To: ext Ville Syrjälä
Cc: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org
On Fri, 2010-02-05 at 00:05 +0100, ext Ville Syrjälä wrote:
> On Thu, Feb 04, 2010 at 05:31:26PM +0200, Tomi Valkeinen wrote:
> > Previously the only place to get the size of the display was from the
> > DSS's sysfs interface, making, for example, configuring overlays and doing
> > updates on manual displays more difficult.
> >
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
> > ---
> > drivers/video/omap2/omapfb/omapfb-ioctl.c | 18 ++++++++++++++++++
> > include/linux/omapfb.h | 7 +++++++
> > 2 files changed, 25 insertions(+), 0 deletions(-)
> >
> <snip>
> > @@ -216,6 +217,12 @@ struct omapfb_tearsync_info {
> > __u16 reserved2;
> > };
> >
> > +struct omapfb_display_info {
> > + __u16 width;
> > + __u16 height;
>
> How about adding the physical display size here as well? I suppose
> mm is the standard unit for such things but for small displays more
> accuracy might be nice.
That can be read from framebuffer's var struct. But I could add it here
also for completeness. Perhaps also some other display related info,
like capabilities.
Tomi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-02-05 9:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-04 15:31 [PATCH 1/2] OMAP: DSS2: OMAPFB: implement OMAPFB_RESERVE_BUFFER Tomi Valkeinen
2010-02-04 15:31 ` [PATCH 2/2] OMAP: DSS2: OMAPFB: implement OMAPFB_GET_DISPLAY_INFO Tomi Valkeinen
2010-02-04 23:05 ` [PATCH 2/2] OMAP: DSS2: OMAPFB: implement Ville Syrjälä
2010-02-05 9:28 ` Tomi Valkeinen
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).