From: Tomi Valkeinen <tomi.valkeinen@nokia.com>
To: linux-omap@vger.kernel.org, linux-fbdev@vger.kernel.org
Cc: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Subject: [PATCH 04/13] OMAP: DSS2: OMAPFB: implement OMAPFB_RESERVE_BUFFER
Date: Mon, 08 Feb 2010 15:56:03 +0000 [thread overview]
Message-ID: <1265644572-3578-5-git-send-email-tomi.valkeinen@nokia.com> (raw)
In-Reply-To: <1265644572-3578-4-git-send-email-tomi.valkeinen@nokia.com>
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
next prev parent reply other threads:[~2010-02-08 15:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-08 15:55 [PATCH 00/13] OMAP DSS2 patches Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 01/13] OMAP: DSS2: enable VDDS_DSI when using DPI Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 02/13] OMAP: 3430SDP: remove vdvi regulator Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 03/13] OMAP: DSS: Taal: fix error returns in taal_probe() Tomi Valkeinen
2010-02-08 15:56 ` Tomi Valkeinen [this message]
2010-02-08 15:56 ` [PATCH 05/13] OMAP: DSS2: OMAPFB: implement OMAPFB_GET_DISPLAY_INFO Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 06/13] OMAP: DSS2: fix irq-stats compilation Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 07/13] OMAP: DSS2: OMAPFB: Add omapfb_update_window prototype Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 08/13] OMAP: DSS2: improve DSS clk src selection Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 09/13] OMAP: DSS2: DSI: add dsi_bus_is_locked() Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 10/13] OMAP: DSS2: DSI: add helpers for DCS read/write Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 11/13] OMAP: DSS2: DSI: export dsi_vc_enable_hs() Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 12/13] OMAP: DSS2: DSI: configure all DSI VCs Tomi Valkeinen
2010-02-08 15:56 ` [PATCH 13/13] OMAP: DSS2: DSI: remove dsi_vc_print_status() Tomi Valkeinen
2010-02-15 10:34 ` [PATCH 01/13] OMAP: DSS2: enable VDDS_DSI when using DPI Hiremath, Vaibhav
2010-02-15 10:57 ` Tomi Valkeinen
2010-02-15 12:23 ` Hiremath, Vaibhav
2010-02-15 12:32 ` Tomi Valkeinen
2010-02-15 14:02 ` Grazvydas Ignotas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1265644572-3578-5-git-send-email-tomi.valkeinen@nokia.com \
--to=tomi.valkeinen@nokia.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).