Beispiel #1
0
int os_mem_alloc(struct vfe_mm *mem_man)
{
	void *vaddr = NULL;

	vaddr = sunxi_buf_alloc(mem_man->size, (u32 *)&mem_man->phy_addr);
	if (vaddr) {
		mem_man->vir_addr = vaddr;
 		mem_man->dma_addr = mem_man->phy_addr + HW_DMA_OFFSET- CPU_DRAM_PADDR_ORG;        
	} else {
		vfe_err("os_mem_alloc error, size = %d\n", mem_man->size);
		return -ENOMEM;
	}
	return 0;
}
Beispiel #2
0
void *g2d_malloc(__u32 bytes_num, __u32 *phy_addr)
{
#ifdef __FPGA_DEBUG_G2D__

	__u32 actual_bytes;
	struct g2d_alloc_struct *ptr, *newptr;
	
	if(!bytes_num)return 0;
	actual_bytes = G2D_BYTE_ALIGN(bytes_num);
	ptr = &boot_heap_head;
	while(ptr && ptr->next)
	{
		if(ptr->next->address >= (ptr->address + ptr->size +(8*1024)+ actual_bytes))
		{
			break;
		}
		ptr = ptr->next;
	}

    if (!ptr->next)
    {
        ERR(" it has reached the boot_heap_tail of the heap now\n");
        return 0;                   /* it has reached the boot_heap_tail of the heap now              */
    }

    newptr = (struct g2d_alloc_struct *)(ptr->address + ptr->size);
                                                /* create a new node for the memory block             */
    if (!newptr)
    {
        ERR(" create the node failed, can't manage the block\n");
        return 0;                               /* create the node failed, can't manage the block     */
    }
    
    /* set the memory block chain, insert the node to the chain */
    newptr->address = ptr->address + ptr->size + 4*1024;
    newptr->size    = actual_bytes;
    newptr->u_size  = bytes_num;
    newptr->next    = ptr->next;
    ptr->next       = newptr;

    return (void *)newptr->address;
#else
	__u32 actual_bytes;
	__u32 address;

	if(0!= bytes_num)
	{
		void *vptr;

		actual_bytes = G2D_BYTE_ALIGN(bytes_num);
		vptr = sunxi_buf_alloc(actual_bytes, &address);
		if (!vptr) {
			INFO("%s %d: alloc fail,size=0x%x\n", __func__, __LINE__, bytes_num);
			return 0;
		}
		*phy_addr = address;
		return vptr;
	}
	return 0;
#endif
}