void vc_hostfs_exit(void) { vcos_log_unregister(&hostfs_log_cat); if (p_file_info_table) { free(p_file_info_table); p_file_info_table = NULL; } }
void mmal_vc_deinit(void) { int count; vcos_mutex_lock(&client.lock); count = --client.refcount; if (count != 0) { /* Still in use so don't do anything */ vcos_mutex_unlock(&client.lock); return; } vcos_mutex_delete(&client.bulk_lock); destroy_waitpool(&client.waitpool); vchiq_close_service(client.service); vchiq_shutdown(mmal_vchiq_instance); vcos_log_unregister(VCOS_LOG_CATEGORY); client.service = VCHIQ_SERVICE_HANDLE_INVALID; client.inited = 0; vcos_mutex_unlock(&client.lock); }
MMAL_STATUS_T mmal_vc_init(void) { VCHIQ_SERVICE_PARAMS_T vchiq_params; MMAL_BOOL_T vchiq_initialised = 0, waitpool_initialised = 0; MMAL_BOOL_T service_initialised = 0; MMAL_STATUS_T status = MMAL_EIO; VCHIQ_STATUS_T vchiq_status; int count; vcos_once(&once, init_once); vcos_mutex_lock(&client.lock); count = client.refcount++; if (count > 0) { /* Already initialised so nothing to do */ vcos_mutex_unlock(&client.lock); return MMAL_SUCCESS; } vcos_log_register("mmalipc", VCOS_LOG_CATEGORY); /* Initialise a VCHIQ instance */ vchiq_status = vchiq_initialise(&mmal_vchiq_instance); if (vchiq_status != VCHIQ_SUCCESS) { LOG_ERROR("failed to initialise vchiq"); status = MMAL_EIO; goto error; } vchiq_initialised = 1; vchiq_status = vchiq_connect(mmal_vchiq_instance); if (vchiq_status != VCHIQ_SUCCESS) { LOG_ERROR("failed to connect to vchiq"); status = MMAL_EIO; goto error; } memset(&vchiq_params,0,sizeof(vchiq_params)); vchiq_params.fourcc = MMAL_CONTROL_FOURCC(); vchiq_params.callback = mmal_vc_vchiq_callback; vchiq_params.userdata = &client; vchiq_params.version = WORKER_VER_MAJOR; vchiq_params.version_min = WORKER_VER_MINIMUM; vchiq_status = vchiq_open_service(mmal_vchiq_instance, &vchiq_params, &client.service); if (vchiq_status != VCHIQ_SUCCESS) { LOG_ERROR("could not open vchiq service"); status = MMAL_EIO; goto error; } client.usecount = 1; /* usecount set to 1 by the open call. */ service_initialised = 1; status = create_waitpool(&client.waitpool); if (status != MMAL_SUCCESS) { LOG_ERROR("could not create wait pool"); goto error; } waitpool_initialised = 1; if (vcos_mutex_create(&client.bulk_lock, "mmal client bulk lock") != VCOS_SUCCESS) { LOG_ERROR("could not create bulk lock"); status = MMAL_ENOSPC; goto error; } client.inited = 1; vcos_mutex_unlock(&client.lock); /* assume we're not using VC immediately. Do this outside the lock */ mmal_vc_release(); return MMAL_SUCCESS; error: if (waitpool_initialised) destroy_waitpool(&client.waitpool); if (service_initialised) { client.usecount = 0; vchiq_close_service(client.service); } if (vchiq_initialised) vchiq_shutdown(mmal_vchiq_instance); vcos_log_unregister(VCOS_LOG_CATEGORY); client.refcount--; vcos_mutex_unlock(&client.lock); return status; }