From 3b1e72e7debbd90e0335d31a6594c8a168bd160d Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 29 Aug 2012 01:52:30 +0300 Subject: [PATCH] fix vram realloc we don't need to continue trying if we get in already available range --- src/video/omapdss/osdl_video.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/video/omapdss/osdl_video.c b/src/video/omapdss/osdl_video.c index f64f4e1..56c5485 100644 --- a/src/video/omapdss/osdl_video.c +++ b/src/video/omapdss/osdl_video.c @@ -46,6 +46,7 @@ static int osdl_setup_omapfb(struct omapfb_state *ostate, int fd, int enabled, struct omapfb_plane_info pi; struct omapfb_mem_info mi; int mem_blocks = *buffer_count; + unsigned int size_cur; int ret; memset(&pi, 0, sizeof(pi)); @@ -62,6 +63,7 @@ static int osdl_setup_omapfb(struct omapfb_state *ostate, int fd, int enabled, err_perror("QUERY_MEM"); return -1; } + size_cur = mi.size; /* must disable when changing stuff */ if (pi.enabled) { @@ -71,19 +73,20 @@ static int osdl_setup_omapfb(struct omapfb_state *ostate, int fd, int enabled, err_perror("SETUP_PLANE"); } - if (mi.size < mem * mem_blocks) { - for (; mem_blocks > 0; mem_blocks--) { - mi.size = mem * mem_blocks; - ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi); - if (ret == 0) - break; - } - if (ret != 0 || mem_blocks <= 0) { - err("failed to allocate at least %d bytes of vram:\n", mem); - err_perror("SETUP_MEM"); - return -1; - } + /* allocate more mem, if needed */ + for (; size_cur < mem * mem_blocks && mem_blocks > 0; mem_blocks--) { + mi.size = mem * mem_blocks; + ret = ioctl(fd, OMAPFB_SETUP_MEM, &mi); + if (ret == 0) + break; + mi.size = size_cur; } + if (mem_blocks <= 0) { + err("failed to allocate at least %d bytes of vram:\n", mem); + err_perror("SETUP_MEM"); + return -1; + } + *buffer_count = mem_blocks; pi.pos_x = x; -- 2.39.5