/** awb_module_deinit: * @mod: awb module * * This function deinits awb module. WIll be called by Stats * module and triggered by MCT. **/ void awb_module_deinit(mct_module_t *module) { if (!module || strcmp(MCT_OBJECT_NAME(module), "awb")) return; /* Remove all ports of this module */ mct_list_traverse(MCT_OBJECT_CHILDREN(module), awb_module_remove_port, module); mct_list_free_list(MCT_OBJECT_CHILDREN(module)); mct_module_destroy(module); }
/** * Function: module_imgbase_deinit * * Description: This function is used to free the imgbase module * * Arguments: * p_mct_mod - MCTL module instance pointer * * Return values: * none * * Notes: none **/ void module_imgbase_deinit(mct_module_t *p_mct_mod) { module_imgbase_t *p_mod = NULL; img_core_ops_t *p_core_ops = NULL; mct_list_t* p_list; int rc = 0; int i = 0; if (NULL == p_mct_mod) { IDBG_ERROR("%s:%d] MCTL module NULL", __func__, __LINE__); return; } p_mod = (module_imgbase_t *)p_mct_mod->module_private; if (NULL == p_mod) { IDBG_ERROR("%s:%d] imgbase module NULL", __func__, __LINE__); return; } do { p_list = mct_list_find_custom(MCT_MODULE_SINKPORTS(p_mct_mod), p_mct_mod, module_imglib_get_next_from_list); if (p_list) module_imgbase_free_port(p_list->data, p_mct_mod); } while (p_list); do { p_list = mct_list_find_custom(MCT_MODULE_SRCPORTS(p_mct_mod), p_mct_mod, module_imglib_get_next_from_list); if (p_list) module_imgbase_free_port(p_list->data, p_mct_mod); } while (p_list); p_core_ops = &p_mod->core_ops; IDBG_MED("%s:%d lib_ref_cnt %d", __func__, __LINE__, p_mod->lib_ref_count); if (p_mod->lib_ref_count) { IMG_COMP_UNLOAD(p_core_ops); } p_mod->imgbase_client_cnt = 0; pthread_mutex_destroy(&p_mod->mutex); pthread_cond_destroy(&p_mod->cond); mct_module_destroy(p_mct_mod); }
/** module_hdr_deinit: * @module: the instance to be deinitialized * * Deinitializes instance of hdr module * * This function executes in Imaging Server context * * Returns nothing **/ void module_hdr_deinit(mct_module_t *module) { module_hdr_context_t* hdr_context; mct_list_t* list; IDBG_MED("%s +", __func__); if (module) { if (MODULE_HDR_VALIDATE_NAME(module)) { MCT_OBJECT_LOCK(module); if (module->module_private) { hdr_context = module->module_private; if (hdr_context->dummy_port) { module_hdr_port_deinit(hdr_context->dummy_port); mct_port_destroy(hdr_context->dummy_port); } if (hdr_context->lib_handle) { module_hdr_lib_unload(hdr_context->lib_handle); } free(module->module_private); } do { list = mct_list_find_custom(MCT_MODULE_SINKPORTS(module), module, module_hdr_get_next_from_list); if (list) module_hdr_remove_port(list->data, module); } while (list); do { list = mct_list_find_custom(MCT_MODULE_SRCPORTS(module), module, module_hdr_get_next_from_list); if (list) module_hdr_remove_port(list->data, module); } while (list); mct_module_destroy(module); } } IDBG_MED("%s -", __func__); }
/** module_imgbase_init: * * Arguments: * @name - name of the module * @comp_role: imaging component role * @comp_name: imaging component name * @mod_private: derived structure pointer * @p_caps: imaging capability * @lib_name: library name * @feature_mask: feature mask of imaging algo * @p_modparams: module parameters * * Description: This function is used to initialize the imgbase * module * * Return values: * MCTL module instance pointer * * Notes: none **/ mct_module_t *module_imgbase_init(const char *name, img_comp_role_t comp_role, char *comp_name, void *mod_private, img_caps_t *p_caps, char *lib_name, uint32_t feature_mask, module_imgbase_params_t *p_modparams) { mct_module_t *p_mct_mod = NULL; module_imgbase_t *p_mod = NULL; img_core_ops_t *p_core_ops = NULL; mct_port_t *p_sinkport = NULL, *p_sourceport = NULL; int rc = 0; int i = 0; if (!name || !comp_name || (comp_role >= IMG_COMP_ROLE_MAX) || !p_caps || !lib_name || (0 == feature_mask)) { IDBG_ERROR("%s:%d invalid input", __func__, __LINE__); return NULL; } IDBG_MED("%s:%d] ", __func__, __LINE__); p_mct_mod = mct_module_create(name); if (NULL == p_mct_mod) { IDBG_ERROR("%s:%d cannot allocate mct module", __func__, __LINE__); return NULL; } p_mod = malloc(sizeof(module_imgbase_t)); if (NULL == p_mod) { IDBG_ERROR("%s:%d failed", __func__, __LINE__); goto error; } p_mct_mod->module_private = (void *)p_mod; memset(p_mod, 0, sizeof(module_imgbase_t)); pthread_mutex_init(&p_mod->mutex, NULL); pthread_cond_init(&p_mod->cond, NULL); p_core_ops = &p_mod->core_ops; IDBG_MED("%s:%d] ", __func__, __LINE__); /* check if the imgbase module is present */ rc = img_core_get_comp(comp_role, comp_name, p_core_ops); if (IMG_ERROR(rc)) { IDBG_ERROR("%s:%d] Error rc %d", __func__, __LINE__, rc); goto error; } /* try to load the component */ rc = IMG_COMP_LOAD(p_core_ops, lib_name); if (IMG_ERROR(rc)) { IDBG_ERROR("%s:%d] Error rc %d", __func__, __LINE__, rc); goto error; } p_mod->lib_ref_count++; p_mod->imgbase_client = NULL; p_mod->mod_private = mod_private; p_mod->caps = *p_caps; p_mod->subdevfd = -1; p_mod->feature_mask = feature_mask; if (p_modparams) p_mod->modparams = *p_modparams; IDBG_MED("%s:%d] ", __func__, __LINE__); /* create static ports */ for (i = 0; i < MAX_IMGLIB_BASE_STATIC_PORTS; i++) { p_sinkport = module_imgbase_create_port(p_mct_mod, MCT_PORT_SINK); if (NULL == p_sinkport) { IDBG_ERROR("%s:%d] create SINK port failed", __func__, __LINE__); goto error; } p_sourceport = module_imgbase_create_port(p_mct_mod, MCT_PORT_SRC); if (NULL == p_sourceport) { IDBG_ERROR("%s:%d] create SINK port failed", __func__, __LINE__); goto error; } } p_mct_mod->start_session = module_imgbase_start_session; p_mct_mod->stop_session = module_imgbase_stop_session; p_mct_mod->query_mod = module_imgbase_query_mod; IDBG_MED("%s:%d] %p", __func__, __LINE__, p_mct_mod); return p_mct_mod; error: if (p_mod) { module_imgbase_deinit(p_mct_mod); } else if (p_mct_mod) { mct_module_destroy(p_mct_mod); p_mct_mod = NULL; } return NULL; }
/** module_cac_init: * * Arguments: * @name - name of the module * * Description: This function is used to initialize the cac * module * * Return values: * MCTL module instance pointer * * Notes: none **/ mct_module_t *module_cac_init(const char *name) { mct_module_t *p_mct_mod = NULL; module_cac_t *p_mod = NULL; img_core_ops_t *p_core_ops = NULL; mct_port_t *p_sinkport = NULL, *p_sourceport = NULL; int rc = 0; int i = 0; IDBG_MED("%s:%d] ", __func__, __LINE__); p_mct_mod = mct_module_create(name); if (NULL == p_mct_mod) { IDBG_ERROR("%s:%d cannot allocate mct module", __func__, __LINE__); return NULL; } p_mod = malloc(sizeof(module_cac_t)); if (NULL == p_mod) { IDBG_ERROR("%s:%d failed", __func__, __LINE__); goto error; } p_mct_mod->module_private = (void *)p_mod; memset(p_mod, 0, sizeof(module_cac_t)); pthread_mutex_init(&p_mod->mutex, NULL); pthread_cond_init(&p_mod->cond, NULL); p_core_ops = &p_mod->core_ops; IDBG_MED("%s:%d] ", __func__, __LINE__); /* check if the cac module is present */ rc = img_core_get_comp(IMG_COMP_CAC, "qcom.cac", p_core_ops); if (IMG_ERROR(rc)) { IDBG_ERROR("%s:%d] Error rc %d", __func__, __LINE__, rc); goto error; } /* try to load the component */ rc = IMG_COMP_LOAD(p_core_ops, NULL); if (IMG_ERROR(rc)) { IDBG_ERROR("%s:%d] Error rc %d", __func__, __LINE__, rc); goto error; } p_mod->lib_ref_count++; p_mod->cac_client = NULL; IDBG_MED("%s:%d] ", __func__, __LINE__); /* create static ports */ for (i = 0; i < MAX_CAC_STATIC_PORTS; i++) { p_sinkport = module_cac_create_port(p_mct_mod, MCT_PORT_SINK); if (NULL == p_sinkport) { IDBG_ERROR("%s:%d] create SINK port failed", __func__, __LINE__); goto error; } p_sourceport = module_cac_create_port(p_mct_mod, MCT_PORT_SRC); if (NULL == p_sourceport) { IDBG_ERROR("%s:%d] create SINK port failed", __func__, __LINE__); goto error; } } p_mct_mod->start_session = module_cac_start_session; p_mct_mod->stop_session = module_cac_stop_session; IDBG_MED("%s:%d] %p", __func__, __LINE__, p_mct_mod); return p_mct_mod; error: if (p_mod) { module_cac_deinit(p_mct_mod); } else if (p_mct_mod) { mct_module_destroy(p_mct_mod); p_mct_mod = NULL; } return NULL; }