int dpmgr_path_remove_memout(disp_path_handle dp_handle, void * cmdq_handle) { int ret = 0; ASSERT(dp_handle != NULL); ddp_path_handle handle = (ddp_path_handle)dp_handle; ASSERT(handle->scenario ==DDP_SCENARIO_PRIMARY_DISP || handle->scenario ==DDP_SCENARIO_PRIMARY_ALL || handle->scenario ==DDP_SCENARIO_SUB_DISP || handle->scenario ==DDP_SCENARIO_SUB_ALL); DISP_MODULE_ENUM wdma = ddp_is_scenario_on_primary(handle->scenario) ? DISP_MODULE_WDMA0: DISP_MODULE_WDMA1; // update contxt DDP_MANAGER_CONTEXT * context = _get_context(); context->module_usage_table[wdma]--; context->module_path_table[wdma] = 0; //wdma just need stop if(ddp_modules_driver[wdma] != 0) { if(ddp_modules_driver[wdma]->stop!= 0) { ddp_modules_driver[wdma]->stop(wdma, cmdq_handle); } if(ddp_modules_driver[wdma]->deinit!= 0) { ddp_modules_driver[wdma]->deinit(wdma, cmdq_handle); } } ddp_disconnect_path(DDP_SCENARIO_PRIMARY_OVL_MEMOUT,cmdq_handle); handle->scenario = DDP_SCENARIO_PRIMARY_DISP; // update connected ddp_connect_path(handle->scenario,cmdq_handle); ddp_mutex_set(handle->hwmutexid, handle->scenario, handle->mode, cmdq_handle); return 0; }
int dpmgr_destroy_path(disp_path_handle dp_handle) { int i =0; int module_name ; ASSERT(dp_handle != NULL); ddp_path_handle handle = (ddp_path_handle)dp_handle; int * modules = ddp_get_scenario_list(handle->scenario); int module_num = ddp_get_module_num(handle->scenario); DDP_MANAGER_CONTEXT * content = _get_context(); DISP_LOG_I("destroy path handle 0x%x on scenario %s\n",handle,ddp_get_scenario_name(handle->scenario)); if(handle != NULL) { release_mutex(handle->hwmutexid); ddp_disconnect_path(handle->scenario,handle->cmdqhandle); for( i=0; i< module_num;i++) { module_name = modules[i]; content->module_usage_table[module_name]--; content->module_path_table[module_name] = NULL; } content->handle_cnt --; ASSERT(content->handle_cnt >=0); content->handle_pool[handle->hwmutexid] = NULL; kfree(handle); } return 0; }
int dpmgr_path_add_memout(disp_path_handle dp_handle, ENGINE_DUMP engine,void * cmdq_handle ) { int ret = 0; ASSERT(dp_handle != NULL); ddp_path_handle handle = (ddp_path_handle)dp_handle; ASSERT(handle->scenario ==DDP_SCENARIO_PRIMARY_DISP || handle->scenario ==DDP_SCENARIO_SUB_DISP); DISP_MODULE_ENUM wdma = handle->mem_module; // update contxt DDP_MANAGER_CONTEXT * context = _get_context(); context->module_usage_table[wdma]++; context->module_path_table[wdma] = handle; handle->scenario = DDP_SCENARIO_PRIMARY_ALL; // update connected ddp_connect_path(handle->scenario,cmdq_handle); ddp_mutex_set(handle->hwmutexid, handle->scenario, handle->mode, cmdq_handle); //wdma just need start. if(ddp_modules_driver[wdma] != 0) { if(ddp_modules_driver[wdma]->init!= 0) { ddp_modules_driver[wdma]->init(wdma, cmdq_handle); } if(ddp_modules_driver[wdma]->start!= 0) { ddp_modules_driver[wdma]->start(wdma, cmdq_handle); } } return 0; }
void dpmgr_debug_path_status(int mutex_id) { int i=0; DDP_MANAGER_CONTEXT * content = _get_context(); disp_path_handle handle=NULL; if(mutex_id >=DISP_MUTEX_DDP_FIRST && mutex_id < (DISP_MUTEX_DDP_FIRST+DISP_MUTEX_DDP_COUNT)) { handle = (disp_path_handle)content->handle_pool[mutex_id]; if(handle) { dpmgr_check_status(handle); } } else { for(i=DISP_MUTEX_DDP_FIRST; i<(DISP_MUTEX_DDP_FIRST+DISP_MUTEX_DDP_COUNT);i++) { handle = (disp_path_handle)content->handle_pool[i]; if(handle) { dpmgr_check_status(handle); } } } return ; }
disp_path_handle dpmgr_create_path(DDP_SCENARIO_ENUM scenario, cmdqRecHandle cmdq_handle) { int i =0; int module_name ; ddp_path_handle path_handle = NULL; int * modules = ddp_get_scenario_list(scenario); int module_num = ddp_get_module_num(scenario); DDP_MANAGER_CONTEXT * content = _get_context(); path_handle = kzalloc(sizeof(uint8_t*) * sizeof(ddp_path_handle_t), GFP_KERNEL); if (NULL != path_handle) { path_handle->cmdqhandle = cmdq_handle; path_handle->scenario = scenario; path_handle->hwmutexid = acquire_mutex(scenario); assign_default_irqs_table(scenario,path_handle->irq_event_map); DISP_LOG_I("create handle 0x%x on scenario %s\n",path_handle,ddp_get_scenario_name(scenario)); for( i=0; i< module_num;i++) { module_name = modules[i]; DISP_LOG_I(" scenario %s include module %s\n",ddp_get_scenario_name(scenario),ddp_get_module_name(module_name)); content->module_usage_table[module_name]++; content->module_path_table[module_name] = path_handle; } content->handle_cnt ++; content->handle_pool[path_handle->hwmutexid] = path_handle; } else { DISP_LOG_E("Fail to create handle on scenario %s\n",ddp_get_scenario_name(scenario)); } return path_handle; }
static int release_mutex(int mutex_idx) { DDP_MANAGER_CONTEXT * content = _get_context(); ASSERT(mutex_idx < (DISP_MUTEX_DDP_FIRST+DISP_MUTEX_DDP_COUNT)); content->mutex_idx |= 1<< (mutex_idx-DISP_MUTEX_DDP_FIRST); DISP_LOG_I("release mutex %d , left mutex 0x%x!\n", mutex_idx, content->mutex_idx); return 0; }
static int is_module_in_path(DISP_MODULE_ENUM module,ddp_path_handle handle) { DDP_MANAGER_CONTEXT * context = _get_context(); ASSERT(module <DISP_MODULE_UNKNOWN); if(context->module_path_table[module]==handle) { return 1; } return 0; }
static int path_top_clock_on(void) { DDP_MANAGER_CONTEXT * context = _get_context(); if(!context->power_sate) { context->power_sate = 1; ddp_path_top_clock_on(); } return 0; }
static int path_top_clock_off(void) { int i =0; DDP_MANAGER_CONTEXT * context = _get_context(); if(context->power_sate) { for(i=0; i< DDP_MAX_MANAGER_HANDLE; i++) { if(context->handle_pool[i] != NULL && context->handle_pool[i]->power_sate !=0) { return 0; } } context->power_sate = 0; ddp_path_top_clock_off(); } return 0; }
static int acquire_mutex(DDP_SCENARIO_ENUM scenario) { ///: primay use mutex 0 int mutex_id =0 ; DDP_MANAGER_CONTEXT * content = _get_context(); int mutex_idx_free = content->mutex_idx; ASSERT(scenario >= 0 && scenario < DDP_SCENARIO_MAX); while(mutex_idx_free) { if(mutex_idx_free & 0x1) { content->mutex_idx &= (~(0x1<<mutex_id)); mutex_id += DISP_MUTEX_DDP_FIRST; break; } mutex_idx_free>>=1; ++mutex_id; } ASSERT(mutex_id < (DISP_MUTEX_DDP_FIRST+DISP_MUTEX_DDP_COUNT)); DISP_LOG_I("scenario %s acquire mutex %d , left mutex 0x%x!\n", ddp_get_scenario_name(scenario), mutex_id, content->mutex_idx); return mutex_id; }
void _init_lib() { static const secp256k1_context_t* ctx = _get_context(); static int init_o = init_openssl(); }
static ddp_path_handle find_handle_by_module(DISP_MODULE_ENUM module) { return _get_context()->module_path_table[module]; }