diff options
-rw-r--r-- | vmeta_lib.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/vmeta_lib.c b/vmeta_lib.c index 8d5bb96..81a8abc 100644 --- a/vmeta_lib.c +++ b/vmeta_lib.c @@ -163,39 +163,26 @@ void *vdec_os_api_vmalloc(UNSG32 size, UNSG32 align) void vdec_os_api_dma_free(void *ptr) { - unsigned int offset; - unsigned int *paddr; - - paddr = ptr; - offset = *(paddr - 1); - paddr = (unsigned int *)((unsigned int)paddr - offset); - bmm_free((void *)paddr); + bmm_free(ptr); } static void *vmeta_bmm_malloc_aligned(UNSG32 size, UNSG32 align, UNSG32 *phys, int attr) { - unsigned int tmp, *ptr; + void *ptr; if (size == 0) return NULL; - dbg_printf(VDEC_DEBUG_MEM, "%s: size 0x%x attr %u\n", - __FUNCTION__, size, attr); + dbg_printf(VDEC_DEBUG_MEM, "%s: size 0x%x attr %u align %u\n", + __FUNCTION__, size, attr, align); - align = ALIGN(align, sizeof(int)); - size += align; - ptr = bmm_malloc(size, attr); + ptr = bmm_malloc_aligned(size, attr, align); if (!ptr) { dbg_printf(VDEC_DEBUG_MEM, "%s: not enough memory\n", __FUNCTION__); return NULL; } - tmp = (unsigned int)((unsigned int)(ptr) & (align - 1)); - tmp = (unsigned int)(align - tmp); - ptr = (unsigned int *)((unsigned int)ptr + tmp); - *(ptr - 1) = tmp; - *phys = (UNSG32)bmm_get_paddr(ptr); dbg_printf(VDEC_DEBUG_MEM, "%s: ptr: 0x%x\n", __FUNCTION__, ptr); |