From: notaz Date: Tue, 28 Aug 2012 22:52:30 +0000 (+0300) Subject: fix vram realloc X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b1e72e7debbd90e0335d31a6594c8a168bd160d;p=sdl_omap.git fix vram realloc we don't need to continue trying if we get in already available range --- 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;