Exemple #1
0
/**
 * Function: module_imgbase_port_check_caps_unreserve
 *
 * Description: This method is used to unreserve the port
 *
 * Arguments:
 *   @identity: identitity for the session and stream
 *   @port: mct port pointer
 *   @peer: peer mct port pointer
 *
 * Return values:
 *     error/success
 *
 * Notes: none
 **/
boolean module_imgbase_port_check_caps_unreserve(mct_port_t *port,
  unsigned int identity)
{
  int rc = IMG_SUCCESS;
  mct_module_t *p_mct_mod = NULL;
  module_imgbase_t *p_mod = NULL;
  imgbase_client_t *p_client = NULL;
  uint32_t *p_identity = NULL;

  if (!port) {
    IDBG_ERROR("%s:%d invalid input", __func__, __LINE__);
    return FALSE;
  }

  IDBG_MED("%s:%d] E %d", __func__, __LINE__, MCT_PORT_DIRECTION(port));

  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(port))->data);
  if (!p_mct_mod) {
    IDBG_ERROR("%s:%d invalid module", __func__, __LINE__);
    return FALSE;
  }

  p_mod = (module_imgbase_t *)p_mct_mod->module_private;
  if (NULL == p_mod) {
    IDBG_ERROR("%s:%d] imgbase module NULL", __func__, __LINE__);
    return FALSE;
  }

  p_client = (imgbase_client_t *)port->port_private;
  if (NULL == p_client) {
    IDBG_ERROR("%s:%d] imgbase client NULL", __func__, __LINE__);
    return FALSE;
  }

  /* lock the module */
  pthread_mutex_lock(&p_mod->mutex);

  if (MCT_PORT_IS_SRC(port)) {
    port->port_private = NULL;
  } else {
    module_imgbase_port_release_client(p_mod, port, p_client, identity);
    port->port_private = NULL;
    if (p_mod->subdevfd >= 0) {
      close(p_mod->subdevfd);
      p_mod->subdevfd = -1;
    }
  }
  pthread_mutex_unlock(&p_mod->mutex);

  /*Todo: free port??*/
  IDBG_MED("%s:%d] X", __func__, __LINE__);
  return GET_STATUS(rc);

error:
  pthread_mutex_unlock(&p_mod->mutex);
  IDBG_MED("%s:%d] Error rc = %d X", __func__, __LINE__, rc);
  return FALSE;

}
Exemple #2
0
/**
 * Function: module_imgbase_port_ext_link
 *
 * Description: This method is called when the user establishes
 *              link.
 *
 * Arguments:
 *   @identity: identitity for the session and stream
 *   @port: mct port pointer
 *   @peer: peer mct port pointer
 *
 * Return values:
 *     error/success
 *
 * Notes: none
 **/
boolean module_imgbase_port_ext_link(unsigned int identity,
  mct_port_t* port, mct_port_t *peer)
{
  int rc = IMG_SUCCESS;
  unsigned int *p_identity = NULL;
  mct_list_t *p_temp_list = NULL;
  mct_module_t *p_mct_mod = NULL;
  module_imgbase_t *p_mod = NULL;
  imgbase_client_t *p_client = NULL;

  if (!port || !peer) {
    IDBG_ERROR("%s:%d invalid input", __func__, __LINE__);
    return FALSE;
  }

  IDBG_MED("%s:%d] port %p E", __func__, __LINE__, port);
  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(port))->data);
  if (!p_mct_mod) {
    IDBG_ERROR("%s:%d invalid module", __func__, __LINE__);
    return FALSE;
  }

  p_mod = (module_imgbase_t *)p_mct_mod->module_private;
  if (NULL == p_mod) {
    IDBG_ERROR("%s:%d] imgbase module NULL", __func__, __LINE__);
    return FALSE;
  }

  p_client = (imgbase_client_t *)port->port_private;
  if (NULL == p_client) {
    IDBG_ERROR("%s:%d] invalid client", __func__, __LINE__);
    return FALSE;
  }

  if (MCT_PORT_PEER(port)) {
    IDBG_ERROR("%s:%d] link already established", __func__, __LINE__);
    return FALSE;
  }

  MCT_PORT_PEER(port) = peer;

  /* check if its sink port*/
  if (MCT_PORT_IS_SINK(port)) {
    /* start imgbase client in case of dynamic module */
  } else {
    /* do nothing for source port */
  }
  IDBG_MED("%s:%d] X", __func__, __LINE__);
  return GET_STATUS(rc);

error:
  IDBG_MED("%s:%d] Error X", __func__, __LINE__);
  return FALSE;

}
Exemple #3
0
/**
 * Function: module_imgbase_port_unlink
 *
 * Description: This method is called when the user disconnects
 *              the link.
 *
 * Arguments:
 *   @identity: identitity for the session and stream
 *   @port: mct port pointer
 *   @peer: peer mct port pointer
 *
 * Return values:
 *     none
 *
 * Notes: none
 **/
void module_imgbase_port_unlink(unsigned int identity,
  mct_port_t *port, mct_port_t *peer)
{
  int rc = IMG_SUCCESS;
  mct_list_t *p_temp_list = NULL;
  mct_module_t *p_mct_mod = NULL;
  module_imgbase_t *p_mod = NULL;
  imgbase_client_t *p_client = NULL;
  uint32_t *p_identity = NULL;

  if (!port || !peer) {
    IDBG_ERROR("%s:%d invalid input", __func__, __LINE__);
    return;
  }

  IDBG_MED("%s:%d] E", __func__, __LINE__);
  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(port))->data);
  if (!p_mct_mod) {
    IDBG_ERROR("%s:%d invalid module", __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;
  }

  p_client = (imgbase_client_t *)port->port_private;
  if (NULL == p_client) {
    IDBG_ERROR("%s:%d] imgbase client NULL", __func__, __LINE__);
    return;
  }

  if (MCT_PORT_IS_SINK(port)) {
    /* stop the client in case of dynamic module */
  } else {
    /* do nothing for source port*/
  }

  MCT_PORT_PEER(port) = NULL;

  IDBG_MED("%s:%d] X", __func__, __LINE__);
  return;

error:
  IDBG_MED("%s:%d] Error X", __func__, __LINE__);

}
Exemple #4
0
/**
 * Function: module_imgbase_port_check_caps_reserve
 *
 * Description: This function is used to reserve the port
 *
 * Arguments:
 *   @port: mct port pointer
 *   @peer_caps: pointer to peer capabilities
 *   @stream_info: stream information
 *
 * Return values:
 *     error/success
 *
 * Notes: none
 **/
boolean module_imgbase_port_check_caps_reserve(mct_port_t *port,
  void *peer_caps,
  void *vstream_info)
{
  boolean rc = FALSE;
  mct_module_t *p_mct_mod = NULL;
  module_imgbase_t *p_mod = NULL;
  mct_stream_info_t *stream_info = (mct_stream_info_t *)vstream_info;

  if (!port || !stream_info) {
    CDBG_ERROR("%s:%d invalid input", __func__, __LINE__);
    return FALSE;
  }

  IDBG_MED("%s:%d] E %s", __func__, __LINE__, MCT_PORT_NAME(port));
  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(port))->data);
  if (!p_mct_mod) {
    CDBG_ERROR("%s:%d invalid module", __func__, __LINE__);
    return FALSE;
  }

  p_mod = (module_imgbase_t *)p_mct_mod->module_private;
  if (NULL == p_mod) {
    CDBG_ERROR("%s:%d] imgbase module NULL", __func__, __LINE__);
    return FALSE;
  }

  /* lock the module */
  pthread_mutex_lock(&p_mod->mutex);
  if (port->port_private) {
    /* port is already reserved */
    IDBG_MED("%s:%d] Error port is already reserved", __func__, __LINE__);
    pthread_mutex_unlock(&p_mod->mutex);
    return FALSE;
  }
  rc = module_imgbase_port_acquire(p_mct_mod, port, stream_info);
  if (FALSE == rc) {
    CDBG_ERROR("%s:%d] Error acquiring port", __func__, __LINE__);
    pthread_mutex_unlock(&p_mod->mutex);
    return FALSE;
  }

  pthread_mutex_unlock(&p_mod->mutex);
  IDBG_MED("%s:%d] X", __func__, __LINE__);
  return TRUE;

}
Exemple #5
0
/** module_hdr_check_reserve_port
 *    @data1: mct_port_t object
 *    @data2: stream info
 *
 *  Checks if this port has can be reserved
 *
 *  Return TRUE if the port has the same identity and is linked
 **/
static boolean module_hdr_check_reserve_port(void *data1, void *data2)
{
  boolean ret_val = FALSE;
  mct_module_t *module;
  mct_port_t *port = (mct_port_t *)data1;
  mct_stream_info_t *info = (mct_stream_info_t *)data2;
  module_hdr_context_t* hdr_context;

  IDBG_MED("%s +", __func__);

  if (port && info && MCT_PORT_PARENT(port) && (MCT_PORT_PARENT(port) )->data) {
    module = MCT_MODULE_CAST((MCT_PORT_PARENT(port))->data);
    hdr_context = module->module_private;
    if (hdr_context && hdr_context->dummy_port) {
      ret_val = port->check_caps_reserve(port, &hdr_context->dummy_port->caps,
        info);
    }
  } else
    IDBG_ERROR("Null pointer detected in %s\n", __func__);

  IDBG_MED("%s -", __func__);

  return ret_val;
}
Exemple #6
0
/**
 * Function: module_imgbase_port_event_func
 *
 * Description: Event handler function for the imgbase port
 *
 * Arguments:
 *   @port: mct port pointer
 *   @event: mct event
 *
 * Return values:
 *     true/false
 *
 * Notes: none
 **/
boolean module_imgbase_port_event_func(mct_port_t *port,
  mct_event_t *event)
{
  int rc = IMG_SUCCESS;
  mct_module_t *p_mct_mod = NULL;
  module_imgbase_t *p_mod = NULL;
  imgbase_client_t *p_client;
  boolean fwd_event = TRUE;

  if (!port || !event) {
    IDBG_ERROR("%s:%d invalid input", __func__, __LINE__);
    return FALSE;
  }
  IDBG_LOW("%s:%d] port %p E", __func__, __LINE__, port);
  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(port))->data);
  if (!p_mct_mod) {
    IDBG_ERROR("%s:%d invalid module", __func__, __LINE__);
    return FALSE;
  }

  p_mod = (module_imgbase_t *)p_mct_mod->module_private;
  if (NULL == p_mod) {
    IDBG_ERROR("%s:%d] imgbase module NULL", __func__, __LINE__);
    return FALSE;
  }

  p_client = (imgbase_client_t *)port->port_private;
  if (NULL == p_client) {
    IDBG_ERROR("%s:%d] imgbase client NULL", __func__, __LINE__);
    return FALSE;
  }

  IDBG_LOW("%s:%d] type %d", __func__, __LINE__, event->type);
  switch (event->type) {
  case MCT_EVENT_CONTROL_CMD: {
    mct_event_control_t *p_ctrl_event = &event->u.ctrl_event;
    IDBG_MED("%s:%d] Ctrl type %d", __func__, __LINE__, p_ctrl_event->type);
    switch (p_ctrl_event->type) {
    case MCT_EVENT_CONTROL_STREAMON: {
      IDBG_HIGH("%s:%d] IMGLIB_BASE STREAMON", __func__, __LINE__);
      module_imgbase_client_start(p_client);
      break;
    }
    case MCT_EVENT_CONTROL_STREAMOFF: {
      module_imgbase_t *p_mod = (module_imgbase_t *)p_client->p_mod;
      IDBG_MED("%s:%d] imgbase STREAMOFF", __func__, __LINE__);
      module_imgbase_client_stop(p_client);
      img_q_flush_and_destroy(&p_mod->msg_thread.msg_q);
      img_q_flush_and_destroy(&p_client->stream_parm_q);
      break;
    }
    case MCT_EVENT_CONTROL_PARM_STREAM_BUF: {
      cam_stream_parm_buffer_t *parm_buf =
        event->u.ctrl_event.control_event_data;
      IDBG_HIGH("%s:%d] MCT_EVENT_CONTROL_PARM_STREAM_BUF %d",
        __func__, __LINE__, parm_buf ? parm_buf->type : 0xffff);
      if (parm_buf &&
        (parm_buf->type == CAM_STREAM_PARAM_TYPE_GET_IMG_PROP)) {
        cam_stream_parm_buffer_t *out_buf;
        out_buf = img_q_dequeue(&p_client->stream_parm_q);
        if (out_buf) {
          *parm_buf = *out_buf;
          free(out_buf);
        }
      }
      break;
    }
    default:
      break;
    }
    break;
  }
  case MCT_EVENT_MODULE_EVENT: {
    mct_event_module_t *p_mod_event = &event->u.module_event;
    img_component_ops_t *p_comp = &p_client->comp;
    IDBG_MED("%s:%d] Mod type %d", __func__, __LINE__, p_mod_event->type);
    switch (p_mod_event->type) {
    case MCT_EVENT_MODULE_BUF_DIVERT: {
      mod_img_msg_t msg;
      isp_buf_divert_t *p_buf_divert =
        (isp_buf_divert_t *)p_mod_event->module_event_data;

      IDBG_ERROR("%s:%d] identity %x", __func__, __LINE__,
        event->identity);

      module_imgbase_client_handle_buffer(p_client, p_buf_divert);

      /* indicate that the buffer is consumed */
      p_buf_divert->is_locked = FALSE;
      p_buf_divert->ack_flag = FALSE;
      fwd_event = FALSE;

      break;
    }
    case MCT_EVENT_MODULE_STATS_AWB_UPDATE: {
      stats_update_t *stats_update = (stats_update_t *)
        p_mod_event->module_event_data;
      break;
    }
    case MCT_EVENT_MODULE_QUERY_DIVERT_TYPE: {
      uint32_t *divert_mask = (uint32_t *)p_mod_event->module_event_data;
      *divert_mask |= PPROC_DIVERT_PROCESSED;
      break;
    }
    case MCT_EVENT_MODULE_SET_CHROMATIX_PTR:
      break;
    default:
      break;
    }
    break;
  }
  default:
   break;
  }

  if (fwd_event) {
    boolean brc = module_imgbase_forward_port_event(p_client, port, event);
    rc = (brc) ? IMG_SUCCESS : IMG_ERR_GENERAL;
  }

  return GET_STATUS(rc);
}
/**
 * Function: module_imgbase_client_get_outputbuf
 *
 * Description: This function is to fetching the output buffer
 *           based in buffer info
 * Arguments:
 *   @p_client: imgbase client
 *   @pframe: frame pointer
 *
 * Return values:
 *     imaging error values
 *
 * Notes: none
 **/
int module_imgbase_client_get_outputbuf(imgbase_client_t *p_client,
  img_frame_t *pframe)
{
  int rc = IMG_SUCCESS;
  int i = 0;
  int buf_idx;
  uint32_t size;
  uint8_t *p_addr;
  mct_module_t *p_mct_mod;
  uint32_t padded_size;
  int fd = -1;
  int stride, scanline;
  module_imgbase_t *p_mod = (module_imgbase_t *)p_client->p_mod;
  int out_idx;

  /* get output buffer */
  out_idx = module_imglib_common_get_buffer(p_mod->subdevfd,
    p_client->identity);
  if (out_idx < 0) {
    IDBG_ERROR("%s:%d] rc %d", __func__, __LINE__, rc);
    rc = IMG_ERR_GENERAL;
    goto error;
  }

  pframe->frame_cnt = 1;
  pframe->info.width = p_client->stream_info->dim.width;
  pframe->info.height = p_client->stream_info->dim.height;
  size = pframe->info.width * pframe->info.height;
  pframe->frame[0].plane_cnt = 2;
  stride = p_client->stream_info->buf_planes.plane_info.mp[0].stride;
  scanline = p_client->stream_info->buf_planes.plane_info.mp[0].scanline;
  pframe->idx = buf_idx = out_idx;
  padded_size = stride * scanline;

  if (NULL == p_client->p_sinkport) {
    IDBG_ERROR("%s:%d] NULL Sink port", __func__, __LINE__);
    rc = IMG_ERR_INVALID_INPUT;
    goto error;
  }

  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(p_client->p_sinkport))->data);
  IDBG_MED("%s:%d] Dimension %dx%d buf_idx %d %x mod %p port %p pproc %p"
    " pad %dx%d",
    __func__, __LINE__,
    pframe->info.width, pframe->info.height, buf_idx,
    p_client->identity,
    p_mct_mod,
    p_client->p_sinkport,
    p_client->parent_mod,
    stride,
    scanline);

  p_addr = mct_module_get_buffer_ptr(buf_idx,
    p_mct_mod,
    IMGLIB_SESSIONID(p_client->identity),
    IMGLIB_STREAMID(p_client->identity));

  if (NULL == p_addr) {
    IDBG_ERROR("%s:%d] NULL address", __func__, __LINE__);
    rc = IMG_ERR_INVALID_INPUT;
    goto error;
  }

  for (i = 0; i < pframe->frame[0].plane_cnt; i++) {
    pframe->frame[0].plane[i].fd = fd;
    pframe->frame[0].plane[i].offset = 0;
    if (i == 0) { /* Y plane */
      pframe->frame[0].plane[i].addr = p_addr;
      pframe->frame[0].plane[i].width = pframe->info.width;
      pframe->frame[0].plane[i].height = pframe->info.height;
      pframe->frame[0].plane[i].stride = stride;
      pframe->frame[0].plane[i].scanline = scanline;
      pframe->frame[0].plane[i].length =
       IMG_LENGTH(pframe->frame[0].plane[i]);
    } else { /* Chroma plane */
      pframe->frame[0].plane[i].addr = p_addr + padded_size;
      pframe->frame[0].plane[i].width = pframe->info.width;
      pframe->frame[0].plane[i].height = pframe->info.height/2;
      pframe->frame[0].plane[i].stride = stride;
      pframe->frame[0].plane[i].scanline = scanline/2;
      pframe->frame[0].plane[i].length =
       IMG_LENGTH(pframe->frame[0].plane[i]);
    }
  }

  return rc;

error:
  IDBG_ERROR("%s:%d] Cannot get output buffer", __func__, __LINE__);
  return rc;
}
/**
 * Function: module_imgbase_client_getbuf
 *
 * Description: This function is to fetching the input buffer
 *           based in buffer info
 * Arguments:
 *   @p_client: imgbase client
 *   @p_buf_divert: ISP buffer divert event structure
 *   @pframe: frame pointer
 *   @native_buf: flag to indicate if its a native buffer
 *
 * Return values:
 *     imaging error values
 *
 * Notes: none
 **/
static int module_imgbase_client_getbuf(imgbase_client_t *p_client,
  isp_buf_divert_t *p_buf_divert,
  img_frame_t *pframe,
  int native_buf)
{
  int rc = IMG_SUCCESS;
  int i = 0;
  int buf_idx;
  uint32_t size;
  uint8_t *p_addr;
  mct_module_t *p_mct_mod;
  uint32_t padded_size;
  int fd = -1;
  int stride, scanline;

  pframe->frame_cnt = 1;
  pframe->info.width = p_client->stream_info->dim.width;
  pframe->info.height = p_client->stream_info->dim.height;
  size = pframe->info.width * pframe->info.height;
  pframe->frame[0].plane_cnt = 2;
  stride = p_client->stream_info->buf_planes.plane_info.mp[0].stride;
  scanline = p_client->stream_info->buf_planes.plane_info.mp[0].scanline;
  pframe->idx = buf_idx = p_buf_divert->buffer.index;
  padded_size = stride * scanline;

  if (NULL == p_client->p_sinkport) {
    IDBG_ERROR("%s:%d] NULL Sink port", __func__, __LINE__);
    return IMG_ERR_INVALID_INPUT;
  }

  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(p_client->p_sinkport))->data);
  IDBG_MED("%s:%d] Dimension %dx%d buf_idx %d %x mod %p port %p pproc %p"
    " pad %dx%d frame_id %d",
    __func__, __LINE__,
    pframe->info.width, pframe->info.height, buf_idx,
    p_client->identity,
    p_mct_mod,
    p_client->p_sinkport,
    p_client->parent_mod,
    stride,
    scanline,
    p_buf_divert->buffer.sequence);

  if (!native_buf) {
    p_addr = mct_module_get_buffer_ptr(buf_idx,
      p_mct_mod,
      IMGLIB_SESSIONID(p_client->identity),
      IMGLIB_STREAMID(p_client->identity));
  } else {
    p_addr = p_buf_divert->vaddr;
    fd = p_buf_divert->fd;
    IDBG_MED("%s:%d] Native Buffer addr = %p, fd = %d",
     __func__, __LINE__, p_addr, fd);
  }

  if (NULL == p_addr) {
    IDBG_ERROR("%s:%d] NULL address", __func__, __LINE__);
    return IMG_ERR_INVALID_INPUT;
  }

  for (i = 0; i < pframe->frame[0].plane_cnt; i++) {
    pframe->frame[0].plane[i].fd = fd;
    pframe->frame[0].plane[i].offset = 0;
    if (i == 0) { /* Y plane */
      pframe->frame[0].plane[i].addr = p_addr;
      pframe->frame[0].plane[i].width = pframe->info.width;
      pframe->frame[0].plane[i].height = pframe->info.height;
      pframe->frame[0].plane[i].stride = stride;
      pframe->frame[0].plane[i].scanline = scanline;
      pframe->frame[0].plane[i].length =
       IMG_LENGTH(pframe->frame[0].plane[i]);
    } else { /* Chroma plane */
      pframe->frame[0].plane[i].addr = p_addr + padded_size;
      pframe->frame[0].plane[i].width = pframe->info.width;
      pframe->frame[0].plane[i].height = pframe->info.height/2;
      pframe->frame[0].plane[i].stride = stride;
      pframe->frame[0].plane[i].scanline = scanline/2;
      pframe->frame[0].plane[i].length =
       IMG_LENGTH(pframe->frame[0].plane[i]);
    }
  }

  return rc;
}
/**
 * Function: module_cac_port_event_func
 *
 * Description: Event handler function for the dummy port
 *
 * Arguments:
 *   @port: mct port pointer
 *   @event: mct event
 *
 * Return values:
 *     error/success
 *
 * Notes: none
 **/
boolean module_cac_port_event_func(mct_port_t *port,
  mct_event_t *event)
{
  int rc = IMG_SUCCESS;
  mct_module_t *p_mct_mod = NULL;
  module_cac_t *p_mod = NULL;
  cac_client_t *p_client;
  boolean fwd_event = TRUE;

  if (!port || !event) {
    IDBG_ERROR("%s:%d invalid input", __func__, __LINE__);
    return FALSE;
  }
  IDBG_LOW("%s:%d] port %p E", __func__, __LINE__, port);
  p_mct_mod = MCT_MODULE_CAST((MCT_PORT_PARENT(port))->data);
  if (!p_mct_mod) {
    IDBG_ERROR("%s:%d invalid module", __func__, __LINE__);
    return FALSE;
  }

  p_mod = (module_cac_t *)p_mct_mod->module_private;
  if (NULL == p_mod) {
    IDBG_ERROR("%s:%d] CAC module NULL", __func__, __LINE__);
    return FALSE;
  }

  p_client = (cac_client_t *)port->port_private;
  if (NULL == p_client) {
    IDBG_ERROR("%s:%d] CAC client NULL", __func__, __LINE__);
    return FALSE;
  }

  IDBG_LOW("%s:%d] type %d", __func__, __LINE__, event->type);
  switch (event->type) {
  case MCT_EVENT_CONTROL_CMD: {
    mct_event_control_t *p_ctrl_event = &event->u.ctrl_event;
    IDBG_MED("%s:%d] Ctrl type %d", __func__, __LINE__, p_ctrl_event->type);
    switch (p_ctrl_event->type) {
    case MCT_EVENT_CONTROL_STREAMON: {
      IDBG_HIGH("%s:%d] CAC STREAMON", __func__, __LINE__);
      pthread_mutex_lock(&p_client->mutex);
      p_client->stream_off = FALSE;
      pthread_mutex_unlock(&p_client->mutex);
      break;
    }
    case MCT_EVENT_CONTROL_STREAMOFF: {
      module_cac_t *p_mod = (module_cac_t *)p_client->p_mod;
      IDBG_MED("%s:%d] CAC STREAMOFF", __func__, __LINE__);
      pthread_mutex_lock(&p_client->mutex);
      p_client->stream_off = TRUE;
      pthread_mutex_unlock(&p_client->mutex);
      img_q_flush(&p_mod->msg_thread.msg_q);
    }
    default:
      break;
    }
    break;
  }
  case MCT_EVENT_MODULE_EVENT: {
    mct_event_module_t *p_mod_event = &event->u.module_event;
    img_component_ops_t *p_comp = &p_client->comp;
    IDBG_MED("%s:%d] Mod type %d", __func__, __LINE__, p_mod_event->type);
    switch (p_mod_event->type) {
    case MCT_EVENT_MODULE_BUF_DIVERT: {
      mod_img_msg_t msg;
      isp_buf_divert_t *p_buf_divert =
        (isp_buf_divert_t *)p_mod_event->module_event_data;

      IDBG_ERROR("%s:%d] identity %x", __func__, __LINE__,
        event->identity);

      memset(&msg, 0x0, sizeof(mod_img_msg_t));
      msg.port = port;
      msg.type = MOD_IMG_MSG_DIVERT_BUF;
      msg.data.buf_divert.buf_divert = *p_buf_divert;
      msg.data.buf_divert.identity = p_client->identity;
      msg.data.buf_divert.p_exec = module_cac_client_divert_exec;
      msg.data.buf_divert.userdata = (void *)p_client;
      module_imglib_send_msg(&p_mod->msg_thread, &msg);

      /* indicate that the buffer is consumed */
      p_buf_divert->is_locked = FALSE;
      p_buf_divert->ack_flag = FALSE;
      fwd_event = FALSE;

      break;
    }
    case MCT_EVENT_MODULE_STATS_AWB_UPDATE: {
      stats_update_t *stats_update = (stats_update_t *)
        p_mod_event->module_event_data;
      p_client->cac_cfg_info.cac_3a_data.awb_gr_gain =
        FLOAT_TO_Q(7, stats_update->awb_update.gain.g_gain);
      p_client->cac_cfg_info.cac_3a_data.awb_gb_gain =
        FLOAT_TO_Q(7, stats_update->awb_update.gain.g_gain);
      IDBG_HIGH("%s: abw gr = %f, awb gb = %f", __func__,
        p_client->cac_cfg_info.cac_3a_data.awb_gr_gain,
        p_client->cac_cfg_info.cac_3a_data.awb_gb_gain);
    }
    break;
    case MCT_EVENT_MODULE_SET_CHROMATIX_PTR:
      //Todo: Update chromatix params with Chromatix version 303
    default:
      break;
    }
    break;
  }
  default:
   break;
  }

  if (fwd_event) {
    boolean brc = module_cac_forward_port_event(p_client, port, event);
    rc = (brc) ? IMG_SUCCESS : IMG_ERR_GENERAL;
  }

  return GET_STATUS(rc);
}