Exemple #1
0
/** awb_module_init:
 *    @name: name of this stats interface module("awb").
 *
 *  Return this stats interface module if succes, otherwise
 *  return NULL.
 **/
mct_module_t* awb_module_init(const char *name)
{
  int i;
  mct_module_t *awb = NULL;

  if (strcmp(name, "awb"))
    return NULL;

  awb = mct_module_create("awb");
  if (!awb)
    return NULL;

  mct_module_set_set_mod_func(awb, awb_module_set_mod);
  mct_module_set_query_mod_func(awb, awb_module_query_mod);
  mct_module_set_start_session_func(awb, awb_module_start_session);
  mct_module_set_stop_session_func(awb, awb_module_stop_session);

  return awb;
}
Exemple #2
0
/** af_module_init:
 *    @name: The name of this stats interface module ("af").
 *
 * This function will create the AF module and will set the API function
 * pointers with the AF module's functions.
 *
 * Return this stats interface module on success, otherwise return NULL.
 **/
mct_module_t* af_module_init(const char *name)
{
  int i;
  mct_module_t *af;

  if (strcmp(name, "af")) {
    return NULL;
  }

  af = mct_module_create("af");
  if (!af) {
    return NULL;
  }

  mct_module_set_set_mod_func(af, af_module_set_mod);
  mct_module_set_query_mod_func(af, af_module_query_mod);
  mct_module_set_start_session_func(af, af_module_start_session);
  mct_module_set_stop_session_func(af, af_module_stop_session);

  return af;
}
/** 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;

}
Exemple #4
0
/** 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;
}
Exemple #5
0
/** module_hdr_init:
 *    @name: name of this hdr interface module ("hdr")
 *
 * Initializes new instance of hdr module
 *
 * This function executes in Imaging Server context
 *
 * Returns new instance on success or NULL on fail
 **/
mct_module_t *
module_hdr_init(const char *name)
{
  boolean status = FALSE;
  mct_module_t* module_hdr = NULL;
  module_hdr_context_t* hdr_context;
  uint32_t sessionid = 0;

  IDBG_MED("%s +", __func__);

  if (name) {
    if (!strncmp(name, MODULE_HDR_NAME, sizeof(MODULE_HDR_NAME))) {

      module_hdr = mct_module_create(name);
      if (module_hdr) {

        hdr_context = malloc(sizeof(module_hdr_context_t));
        if (hdr_context) {
          module_hdr->module_private = hdr_context;

          hdr_context->lib_handle = module_hdr_lib_load();
          if (hdr_context->lib_handle) {
            hdr_context->dummy_port = mct_port_create(
              MODULE_HDR_PORT_DUMMY_NAME);
            if (hdr_context->dummy_port) {
              if (module_hdr_port_init(hdr_context->dummy_port, MCT_PORT_SRC,
                &sessionid, hdr_context->lib_handle)) {

                mct_module_set_process_event_func(module_hdr,
                  module_hdr_process_event);
                mct_module_set_set_mod_func(module_hdr, module_hdr_set_mod);
                mct_module_set_query_mod_func(module_hdr,
                  module_hdr_query_mod);
                mct_module_set_start_session_func(module_hdr,
                  module_hdr_start_session);
                mct_module_set_stop_session_func(module_hdr,
                  module_hdr_stop_session);
                mct_module_set_request_new_port_func(module_hdr,
                  module_hdr_request_new_port);

                status = TRUE;
              } else
                IDBG_ERROR("Cannot init dummy port in %s module\n", name);
            } else
              IDBG_ERROR("Cannot create dummy port in %s module\n", name);
          } else
            IDBG_ERROR("Cannot load library in %s module\n", name);
        } else
          IDBG_ERROR("Cannot allocate private data for %s module\n", name);
        if (!status)
          module_hdr_deinit(module_hdr);
      } else
        IDBG_ERROR("Cannot create %s module\n", name);
    } else {
      IDBG_ERROR("Requested module name is %s\n", name);
      IDBG_ERROR("Module name needs to be %s\n", MODULE_HDR_NAME);
    }
  } else
    IDBG_ERROR("Null pointer detected in %s\n", __func__);

  IDBG_MED("%s -", __func__);

  return module_hdr;
}