/* User cannot free physical share memory, this is done in driver */ int IOGetPhyShareMem(vpu_mem_desc * buff) { return _IOGetPhyMem(VPU_IOC_GET_SHARE_MEM, buff); }
int IOGetPhyMem(vpu_mem_desc * buff) { return _IOGetPhyMem(VPU_IOC_PHYMEM_ALLOC, buff); }
/*! * @brief IO system initialization. * When user wants to start up the codec system, * this function call is needed, to open the codec device, * map the register into user space, * get the working buffer/code buffer/parameter buffer, * download the firmware, and then set up the interrupt signal path. * * @param callback vpu interrupt callback. * * @return * @li 0 System initialization success. * @li -1 System initialization failure. */ int IOSystemInit(void *callback) { int ret; /* Exit directly if already initialized */ if (vpu_fd > 0) { vpu_active_num++; return 0; } ret = get_system_rev(); if (ret == -1) { err_msg("Error: Unable to obtain system rev information\n"); return -1; } vpu_fd = open("/dev/mxc_vpu", O_RDWR); if (vpu_fd < 0) { err_msg("Can't open /dev/mxc_vpu: %s\n", strerror(errno)); return -1; } vpu_shared_mem = vpu_semaphore_open(); if (vpu_shared_mem == NULL) { err_msg("Error: Unable to open vpu shared memory file\n"); close(vpu_fd); vpu_fd = -1; return -1; } if (!semaphore_wait(vpu_semap, API_MUTEX)) { err_msg("Error: Unable to get mutex\n"); close (vpu_fd); vpu_fd = -1; return -1; } vpu_reg_base = (unsigned long)mmap(NULL, BIT_REG_MARGIN, PROT_READ | PROT_WRITE, MAP_SHARED, vpu_fd, 0); if ((void *)vpu_reg_base == MAP_FAILED) { err_msg("Can't map register\n"); close(vpu_fd); vpu_fd = -1; semaphore_post(vpu_semap, API_MUTEX); return -1; } vpu_active_num++; IOClkGateSet(true); #ifdef BUILD_FOR_ANDROID unsigned long va_addr; /* Special handle the bit work buffer, which reserved in vpu driver probe */ bit_work_addr.size = TEMP_BUF_SIZE + PARA_BUF_SIZE + CODE_BUF_SIZE + PARA_BUF2_SIZE; if (_IOGetPhyMem(VPU_IOC_GET_WORK_ADDR, &bit_work_addr) < 0) { err_msg("Get bitwork address failed!\n"); goto err; } va_addr = (unsigned long)mmap(NULL, bit_work_addr.size, PROT_READ | PROT_WRITE, MAP_SHARED, vpu_fd, bit_work_addr.phy_addr); if ((void *)va_addr == MAP_FAILED) { bit_work_addr.virt_uaddr = 0; goto err; } bit_work_addr.virt_uaddr = va_addr; #else bit_work_addr.size = TEMP_BUF_SIZE + PARA_BUF_SIZE + CODE_BUF_SIZE + PARA_BUF2_SIZE; if (_IOGetPhyMem(VPU_IOC_GET_WORK_ADDR, &bit_work_addr) < 0) { err_msg("Get bitwork address failed!\n"); goto err; } if (IOGetVirtMem(&bit_work_addr) == -1) goto err; #endif UnlockVpu(vpu_semap); return 0; err: err_msg("Error in IOSystemInit()"); UnlockVpu(vpu_semap); IOSystemShutdown(); return -1; }
/*! * @brief IO system initialization. * When user wants to start up the codec system, * this function call is needed, to open the codec device, * map the register into user space, * get the working buffer/code buffer/parameter buffer, * download the firmware, and then set up the interrupt signal path. * * @param callback vpu interrupt callback. * * @return * @li 0 System initialization success. * @li -1 System initialization failure. */ int IOSystemInit(void *callback) { int ret; /* Exit directly if already initialized */ if (vpu_fd > 0) { vpu_active_num++; return 0; } ret = get_system_rev(); if (ret == -1) { err_msg("Error: Unable to obtain system rev information\n"); return -1; } vpu_fd = open("/dev/mxc_vpu", O_RDWR); if (vpu_fd < 0) { err_msg("Can't open /dev/mxc_vpu\n"); return -1; } vpu_semap = vpu_semaphore_open(); if (vpu_semap == NULL) { err_msg("Error: Unable to open vpu shared memory file\n"); close(vpu_fd); vpu_fd = -1; return -1; } if (!semaphore_wait(vpu_semap, API_MUTEX)) { err_msg("Error: Unable to get mutex\n"); close (vpu_fd); vpu_fd = -1; return -1; } vpu_reg_base = (unsigned long)mmap(NULL, BIT_REG_MARGIN, PROT_READ | PROT_WRITE, MAP_SHARED, vpu_fd, 0); if ((void *)vpu_reg_base == MAP_FAILED) { err_msg("Can't map register\n"); close(vpu_fd); vpu_fd = -1; semaphore_post(vpu_semap, API_MUTEX); return -1; } vpu_active_num++; IOClkGateSet(true); bit_work_addr.size = TEMP_BUF_SIZE + PARA_BUF_SIZE + CODE_BUF_SIZE + PARA_BUF2_SIZE; if (_IOGetPhyMem(VPU_IOC_GET_WORK_ADDR, &bit_work_addr) < 0) { err_msg("Get bitwork address failed!\n"); goto err; } if (IOGetVirtMem(&bit_work_addr) <= 0) goto err; UnlockVpu(vpu_semap); return 0; err: err_msg("Error in IOSystemInit()"); UnlockVpu(vpu_semap); IOSystemShutdown(); return -1; }
int IOGetPhyUserDataMem(vpu_mem_desc * buff) { return _IOGetPhyMem(VPU_IOC_GET_USER_DATA_ADDR, buff); }
int IOGetPhyPicParaMem(vpu_mem_desc * buff) { return _IOGetPhyMem(VPU_IOC_GET_PIC_PARA_ADDR, buff); }