VCHIQ_STATUS_T vchiq_open_service(VCHIQ_INSTANCE_T instance, int fourcc, VCHIQ_CALLBACK_T callback, void *userdata, VCHIQ_SERVICE_HANDLE_T *pservice)
{
   VCHIQ_STATE_T *state = &instance->state;
   VCHIQ_SERVICE_T *service;
   VCHIQ_STATUS_T status = VCHIQ_ERROR;

   vcos_assert(fourcc != VCHIQ_FOURCC_INVALID);
   vcos_assert(callback != NULL);

   if (!is_valid_instance(instance))
      return VCHIQ_ERROR;

   if (!instance->connected)
      return VCHIQ_ERROR;

   vcos_mutex_lock(&state->mutex);

   service = vchiq_add_service_internal(state, fourcc, callback, userdata, VCHIQ_SRVSTATE_OPENING, instance);

   vcos_mutex_unlock(&state->mutex);

   if (service)
   {
      status = vchiq_open_service_internal(service);
      if (status != VCHIQ_SUCCESS)
      {
         vchiq_remove_service(&service->base);
         service = NULL;
      }
   }
   *pservice = &service->base;
   return status;
}
Beispiel #2
0
int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle)
{
	int32_t ret = -1;
	struct shim_service *service = (struct shim_service *)handle;

	if (service) {
		VCHIQ_STATUS_T status = vchiq_remove_service(service->handle);

		if (status == VCHIQ_SUCCESS) {
			service_free(service);
			service = NULL;
		}

		ret = vchiq_status_to_vchi(status);
	}
	return ret;
}
VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance)
{
   VCHIQ_CHANNEL_T *local = instance->state.local;
   int i;

   if (!is_valid_instance(instance))
      return VCHIQ_ERROR;

   /* Remove all services */

   for (i = 0; i < VCHIQ_MAX_SERVICES; i++)
   {
      if (local->services[i].srvstate != VCHIQ_SRVSTATE_FREE)
      {
         vchiq_remove_service(&local->services[i].base);
      }
   }

   /* Release the state/instance */
   instance->state.initialised = 0;

   return VCHIQ_SUCCESS;
}