static boolean cpp_port_event_func(mct_port_t *port, mct_event_t *event) { int32_t rc = -EINVAL; if(!port || !event) { CDBG_ERROR("%s:%d failed, port=%p, event=%p", __func__, __LINE__, port, event); return FALSE; } mct_module_t *module; mct_list_t *templist = (mct_list_t*)MCT_PORT_PARENT(port); module = (mct_module_t*)(templist->data); switch(port->direction) { case MCT_PORT_SRC: rc = cpp_module_process_upstream_event(module, event); break; case MCT_PORT_SINK: rc = cpp_module_process_downstream_event(module, event); break; default: CDBG_ERROR("%s:%d failed, bad port->direction=%d", __func__, __LINE__, port->direction); } return rc == 0 ? TRUE : FALSE; }
/** * 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; }
/** * 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; }
/** * 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__); }
/** 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; }
/** * 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; }
static boolean cpp_port_check_caps_unreserve(mct_port_t *port, uint32_t identity) { if(!port) { CDBG_ERROR("%s:%d, failed\n", __func__, __LINE__); return FALSE; } CDBG_HIGH("%s:%d, identity=0x%x\n", __func__, __LINE__, identity); cpp_port_data_t *port_data = (cpp_port_data_t *) MCT_OBJECT_PRIVATE(port); int i, rc; for(i=0; i<CPP_MAX_STREAMS_PER_PORT; i++) { if(port_data->stream_data[i].port_state == CPP_PORT_STATE_RESERVED && port_data->stream_data[i].identity == identity) { port_data->stream_data[i].port_state = CPP_PORT_STATE_UNRESERVED; port_data->num_streams--; CDBG_HIGH("%s:%d, identity=0x%x, unreserved\n", __func__, __LINE__, identity); if(port_data->num_streams == 0) { port_data->port_type = CPP_PORT_TYPE_INVALID; port_data->session_id = 0x00; } break; } } if(i == CPP_MAX_STREAMS_PER_PORT) { CDBG_ERROR("%s:%d, can't find matching identity, unexpected !!", __func__, __LINE__); return FALSE; } /* notify the parent module about removal of this stream, once for the sink port */ if(port->direction == MCT_PORT_SINK) { mct_module_t* module = (mct_module_t*)(MCT_PORT_PARENT(port)->data); rc = cpp_module_notify_remove_stream(module, identity); if(rc < 0) { CDBG_ERROR("%s:%d, failed, unexpected error!", __func__, __LINE__); return FALSE; } } return TRUE; }
static boolean cpp_port_check_caps_reserve(mct_port_t *port, void *peer_caps, void *info) { if(!port || !info) { CDBG_ERROR("%s:%d failed, port=%p, info=%p", __func__, __LINE__, port, info); return FALSE; } mct_stream_info_t *stream_info = (mct_stream_info_t *)info; mct_port_caps_t *port_caps = (mct_port_caps_t *)(&(port->caps)); cpp_port_data_t *port_data = MCT_OBJECT_PRIVATE(port); uint32_t identity = stream_info->identity; uint32_t session_id, stream_id; int rc; session_id = CPP_GET_SESSION_ID(identity); stream_id = CPP_GET_STREAM_ID(identity); CDBG_HIGH("%s:%d, identity=0x%x\n", __func__, __LINE__, identity); if(port_data->num_streams >= CPP_MAX_STREAMS_PER_PORT) { CDBG_ERROR("%s:%d, failed. max streams reached, num=%d", __func__, __LINE__, port_data->num_streams); return FALSE; } if(port->direction == MCT_PORT_SINK) { /* TODO: For Offline/peerless this is not true because peer caps is NULL */ #if 0 if(!peer_caps) { CDBG_ERROR("%s:%d failed, peear_caps=%p", __func__, __LINE__, peer_caps); return FALSE; } #endif /* TODO: Add more peer caps checking logic */ mct_port_caps_t *peer_port_caps = (mct_port_caps_t *)peer_caps; if(peer_caps) { if(port_caps->port_caps_type != peer_port_caps->port_caps_type) { return FALSE; } } } switch(port_data->port_type) { case CPP_PORT_TYPE_INVALID: { port_data->num_streams = 0; if(stream_info->streaming_mode == CAM_STREAMING_MODE_CONTINUOUS) { port_data->port_type = CPP_PORT_TYPE_STREAMING; } else { port_data->port_type = CPP_PORT_TYPE_BURST; } port_data->session_id = session_id; break; } case CPP_PORT_TYPE_STREAMING: { if(stream_info->streaming_mode != CAM_STREAMING_MODE_CONTINUOUS) { CDBG("%s:%d, info: streaming mode doesn't match", __func__, __LINE__); return FALSE; } if(port_data->session_id != session_id) { CDBG("%s:%d, info: session id doesn't match", __func__, __LINE__); return FALSE; } break; } case CPP_PORT_TYPE_BURST: { /* allow only one stream on burst port */ CDBG_LOW("%s:%d, info: only one stream allowed on burst port\n", __func__, __LINE__); return FALSE; } default: CDBG_ERROR("%s:%d, failed, bad port_type=%d\n", __func__, __LINE__, port_data->port_type); return FALSE; } int i; /* reserve the port for this stream */ for(i=0; i<CPP_MAX_STREAMS_PER_PORT; i++) { if(port_data->stream_data[i].port_state == CPP_PORT_STATE_UNRESERVED) { port_data->stream_data[i].port_state = CPP_PORT_STATE_RESERVED; port_data->stream_data[i].identity = identity; port_data->stream_data[i].streaming_mode = stream_info->streaming_mode; port_data->num_streams++; CDBG_HIGH("%s:%d, identity=0x%x, reserved\n", __func__, __LINE__, identity); break; } } if(i == CPP_MAX_STREAMS_PER_PORT) { CDBG_ERROR("%s:%d, failed, unexpected error!", __func__, __LINE__); return FALSE; } /* notify the parent module about this new stream, once for the sink port */ if(port->direction == MCT_PORT_SINK) { mct_module_t* module = (mct_module_t*)(MCT_PORT_PARENT(port)->data); rc = cpp_module_notify_add_stream(module, port, stream_info); if(rc < 0) { CDBG_ERROR("%s:%d, failed, unexpected error!", __func__, __LINE__); return FALSE; } } return TRUE; }
/** * 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); }