static u32 vcd_stop_in_run(struct vcd_clnt_ctxt_type_t *p_cctxt) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_stop_in_run:"); rc = vcd_stop_cmn(p_cctxt); if (!VCD_FAILED(rc) && p_cctxt->status.b_first_ip_frame_recvd) { rc = vcd_power_event(p_cctxt->p_dev_ctxt, p_cctxt, VCD_EVT_PWR_CLNT_LAST_FRAME); } return rc; }
static u32 vcd_stop_in_eos(struct vcd_clnt_ctxt *cctxt) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_stop_in_eos:"); if (cctxt->status.mask & VCD_EOS_WAIT_OP_BUF) { rc = vcd_stop_cmn(cctxt); if (!VCD_FAILED(rc)) { rc = vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_LAST_FRAME); cctxt->status.mask &= ~VCD_EOS_WAIT_OP_BUF; } } else cctxt->status.mask |= VCD_STOP_PENDING; return rc; }
static u32 vcd_flush_in_invalid(struct vcd_clnt_ctxt *cctxt, u32 mode) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_flush_in_invalid:"); if (!(cctxt->status.mask & VCD_CLEANING_UP)) { rc = vcd_flush_buffers(cctxt, mode); if (!VCD_FAILED(rc)) { VCD_MSG_HIGH("All buffers are flushed"); cctxt->status.mask |= (mode & VCD_FLUSH_ALL); vcd_send_flush_done(cctxt, VCD_S_SUCCESS); } } return rc; }
static u32 vcd_flush_in_invalid(struct vcd_clnt_ctxt_type_t *p_cctxt, u32 mode) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_flush_in_invalid:"); if (!p_cctxt->status.b_cleaning_up) { rc = vcd_flush_buffers(p_cctxt, mode); if (!VCD_FAILED(rc)) { VCD_MSG_HIGH("All buffers are flushed"); p_cctxt->status.n_flush_mode = mode; vcd_send_flush_done(p_cctxt, VCD_S_SUCCESS); } } return rc; }
static u32 vcd_term_in_not_init (struct vcd_drv_ctxt *drv_ctxt, s32 driver_handle) { struct vcd_dev_ctxt *dev_ctxt = &drv_ctxt->dev_ctxt; u32 rc; VCD_MSG_LOW("vcd_term_in_dev_not_init:"); rc = vcd_term_cmn(drv_ctxt, driver_handle); if (!VCD_FAILED(rc) && !dev_ctxt->refs) vcd_term_driver_context(drv_ctxt); return rc; }
u32 vcd_power_event( struct vcd_dev_ctxt *dev_ctxt, struct vcd_clnt_ctxt *cctxt, u32 event) { u32 rc = VCD_S_SUCCESS; VCD_MSG_MED("Device power state = %d", dev_ctxt->pwr_clk_state); VCD_MSG_MED("event = 0x%x", event); switch (event) { case VCD_EVT_PWR_DEV_INIT_BEGIN: case VCD_EVT_PWR_DEV_INIT_END: case VCD_EVT_PWR_DEV_INIT_FAIL: case VCD_EVT_PWR_DEV_TERM_BEGIN: case VCD_EVT_PWR_DEV_TERM_END: case VCD_EVT_PWR_DEV_TERM_FAIL: case VCD_EVT_PWR_DEV_SLEEP_BEGIN: case VCD_EVT_PWR_DEV_SLEEP_END: case VCD_EVT_PWR_DEV_SET_PERFLVL: case VCD_EVT_PWR_DEV_HWTIMEOUT: { rc = vcd_device_power_event(dev_ctxt, event, cctxt); break; } case VCD_EVT_PWR_CLNT_CMD_BEGIN: case VCD_EVT_PWR_CLNT_CMD_END: case VCD_EVT_PWR_CLNT_CMD_FAIL: case VCD_EVT_PWR_CLNT_PAUSE: case VCD_EVT_PWR_CLNT_RESUME: case VCD_EVT_PWR_CLNT_FIRST_FRAME: case VCD_EVT_PWR_CLNT_LAST_FRAME: case VCD_EVT_PWR_CLNT_ERRFATAL: { rc = vcd_client_power_event(dev_ctxt, cctxt, event); break; } } if (VCD_FAILED(rc)) VCD_MSG_ERROR("vcd_power_event: event 0x%x failed", event); return rc; }
static u32 vcd_stop_in_run(struct vcd_clnt_ctxt *cctxt) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_stop_in_run:"); rc = vcd_stop_cmn(cctxt); if (!VCD_FAILED(rc) && (cctxt->status.mask & VCD_FIRST_IP_RCVD)) { rc = vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_LAST_FRAME); } return rc; }
static void vcd_resume_all_sessions(struct vcd_dev_ctxt_type *p_dev_ctxt) { struct vcd_clnt_ctxt_type_t *p_cctxt = p_dev_ctxt->p_cctxt_list_head; u32 rc; while (p_cctxt) { if (p_cctxt->clnt_state.p_state_table->ev_hdlr.pf_resume) { rc = p_cctxt->clnt_state.p_state_table->ev_hdlr. pf_resume(p_cctxt); if (VCD_FAILED(rc)) VCD_MSG_ERROR("Client resume failed"); } p_cctxt = p_cctxt->p_next; } }
static void vcd_resume_all_sessions(struct vcd_dev_ctxt *dev_ctxt) { struct vcd_clnt_ctxt *cctxt = dev_ctxt->cctxt_list_head; u32 rc; while (cctxt) { if (cctxt->clnt_state.state_table->ev_hdlr.resume) { rc = cctxt->clnt_state.state_table->ev_hdlr. resume(cctxt); if (VCD_FAILED(rc)) VCD_MSG_ERROR("Client resume failed"); } cctxt = cctxt->next; } }
static u32 vcd_fill_output_buffer_cmn (struct vcd_clnt_ctxt_type_t *p_cctxt, struct vcd_frame_data_type *p_buffer) { u32 rc = VCD_S_SUCCESS; struct vcd_buffer_entry_type *p_buf_entry; u32 b_q_result = TRUE; u32 b_handled = TRUE; VCD_MSG_LOW("vcd_fill_output_buffer_cmn in %d:", p_cctxt->clnt_state.e_state); p_buf_entry = vcd_check_fill_output_buffer(p_cctxt, p_buffer); if (!p_buf_entry) return VCD_ERR_BAD_POINTER; if (!p_cctxt->status.b_first_op_frame_recvd) { rc = vcd_handle_first_fill_output_buffer(p_cctxt, p_buffer, &b_handled); VCD_FAILED_RETURN(rc, "Failed: VCD_HandleFirstFillOutputBuffer"); p_cctxt->status.b_first_op_frame_recvd = TRUE; if (b_handled) return rc ; } b_q_result = vcd_buffer_pool_entry_en_q(&p_cctxt->out_buf_pool, p_buf_entry); if (!b_q_result && !p_cctxt->b_decoding) { VCD_MSG_ERROR("Failed: vcd_buffer_pool_entry_en_q"); return VCD_ERR_FAIL; } p_buf_entry->frame = *p_buffer; rc = vcd_return_op_buffer_to_hw(p_cctxt, p_buf_entry); if (!VCD_FAILED(rc) && p_cctxt->sched_clnt_hdl) { vcd_try_submit_frame(p_cctxt->p_dev_ctxt); p_cctxt->sched_clnt_hdl->n_o_tkns++; } return rc; }
static u32 vcd_set_buffer_cmn (struct vcd_clnt_ctxt_type_t *p_cctxt, enum vcd_buffer_type e_buffer, u8 *p_buffer, u32 n_buf_size) { u32 rc; struct vcd_buffer_pool_type *p_buf_pool; VCD_MSG_LOW("vcd_set_buffer_cmn in %d:", p_cctxt->clnt_state.e_state); rc = vcd_common_allocate_set_buffer(p_cctxt, e_buffer, n_buf_size, &p_buf_pool); if (!VCD_FAILED(rc)) { rc = vcd_set_buffer_internal(p_cctxt, p_buf_pool, p_buffer, n_buf_size); } return rc; }
static u32 vcd_set_buffer_cmn (struct vcd_clnt_ctxt *cctxt, enum vcd_buffer_type buffer_type, u8 *buffer, u32 buf_size) { u32 rc; struct vcd_buffer_pool *buf_pool; VCD_MSG_LOW("vcd_set_buffer_cmn in %d:", cctxt->clnt_state.state); rc = vcd_common_allocate_set_buffer(cctxt, buffer_type, buf_size, &buf_pool); if (!VCD_FAILED(rc)) { rc = vcd_set_buffer_internal(cctxt, buf_pool, buffer, buf_size); } return rc; }
static u32 vcd_pause_in_run(struct vcd_clnt_ctxt_type_t *p_cctxt) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_pause_in_run:"); if (p_cctxt->b_sched_clnt_valid) { rc = vcd_map_sched_status(sched_suspend_resume_client (p_cctxt->p_dev_ctxt->sched_hdl, p_cctxt->sched_clnt_hdl, FALSE)); } VCD_FAILED_RETURN(rc, "Failed: sched_suspend_resume_client"); if (p_cctxt->status.n_frame_submitted > 0) { vcd_do_client_state_transition(p_cctxt, VCD_CLIENT_STATE_PAUSING, CLIENT_STATE_EVENT_NUMBER (pf_pause)); } else { VCD_MSG_HIGH("No client frames are currently being processed"); vcd_do_client_state_transition(p_cctxt, VCD_CLIENT_STATE_PAUSED, CLIENT_STATE_EVENT_NUMBER (pf_pause)); p_cctxt->callback(VCD_EVT_RESP_PAUSE, VCD_S_SUCCESS, NULL, 0, p_cctxt, p_cctxt->p_client_data); rc = vcd_power_event(p_cctxt->p_dev_ctxt, p_cctxt, VCD_EVT_PWR_CLNT_PAUSE); if (VCD_FAILED(rc)) VCD_MSG_ERROR("VCD_EVT_PWR_CLNT_PAUSE_END failed"); } return VCD_S_SUCCESS; }
static u32 vcd_fill_output_buffer_cmn (struct vcd_clnt_ctxt *cctxt, struct vcd_frame_data *buffer) { u32 rc = VCD_S_SUCCESS; struct vcd_buffer_entry *buf_entry; u32 result = true; u32 handled = true; VCD_MSG_LOW("vcd_fill_output_buffer_cmn in %d:", cctxt->clnt_state.state); buf_entry = vcd_check_fill_output_buffer(cctxt, buffer); if (!buf_entry) return VCD_ERR_BAD_POINTER; if (!(cctxt->status.mask & VCD_FIRST_OP_RCVD)) { rc = vcd_handle_first_fill_output_buffer(cctxt, buffer, &handled); VCD_FAILED_RETURN(rc, "Failed: vcd_handle_first_fill_output_buffer"); if (handled) return rc ; } result = vcd_buffer_pool_entry_en_q(&cctxt->out_buf_pool, buf_entry); if (!result && !cctxt->decoding) { VCD_MSG_ERROR("Failed: vcd_buffer_pool_entry_en_q"); return VCD_ERR_FAIL; } buf_entry->frame = *buffer; rc = vcd_return_op_buffer_to_hw(cctxt, buf_entry); if (!VCD_FAILED(rc) && cctxt->sched_clnt_hdl) { cctxt->sched_clnt_hdl->tkns++; vcd_try_submit_frame(cctxt->dev_ctxt); } return rc; }
//LGE_S NEXTi dongkyu31.lee //static u32 vcd_pause_in_run(struct vcd_clnt_ctxt *cctxt) static u32 vcd_pause_cmn(struct vcd_clnt_ctxt *cctxt) { u32 rc = VCD_S_SUCCESS; //VCD_MSG_LOW("vcd_pause_in_run:"); VCD_MSG_LOW("vcd_pause_cmn:"); if (cctxt->sched_clnt_hdl) { rc = vcd_sched_suspend_resume_clnt(cctxt, false); VCD_FAILED_RETURN(rc, "Failed: vcd_sched_suspend_resume_clnt"); } if (cctxt->status.frame_submitted > 0) { vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_PAUSING, CLIENT_STATE_EVENT_NUMBER (pause)); } else { VCD_MSG_HIGH("No client frames are currently being processed"); vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_PAUSED, CLIENT_STATE_EVENT_NUMBER (pause)); cctxt->callback(VCD_EVT_RESP_PAUSE, VCD_S_SUCCESS, NULL, 0, cctxt, cctxt->client_data); rc = vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_PAUSE); if (VCD_FAILED(rc)) VCD_MSG_ERROR("VCD_EVT_PWR_CLNT_PAUSE_END failed"); } return VCD_S_SUCCESS; }
static u32 vcd_decode_start_in_open (struct vcd_clnt_ctxt *cctxt, struct vcd_sequence_hdr *seq_hdr) { u32 rc = VCD_S_SUCCESS; VCD_MSG_LOW("vcd_decode_start_in_open:"); if (!cctxt->decoding) { VCD_MSG_ERROR("vcd_decode_init for encoder client"); return VCD_ERR_ILLEGAL_OP; } if (seq_hdr) { VCD_MSG_HIGH("Seq hdr supplied. len = %d", seq_hdr->sequence_header_len); rc = vcd_store_seq_hdr(cctxt, seq_hdr); } else { VCD_MSG_HIGH("Seq hdr not supplied"); cctxt->seq_hdr.sequence_header_len = 0; cctxt->seq_hdr.sequence_header = NULL; } VCD_FAILED_RETURN(rc, "Err processing seq hdr"); rc = vcd_process_cmd_sess_start(cctxt); if (!VCD_FAILED(rc)) { vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_STARTING, CLIENT_STATE_EVENT_NUMBER (decode_start)); } return rc; }
static u32 vcd_close_in_dev_invalid(struct vcd_drv_ctxt *drv_ctxt, struct vcd_clnt_ctxt *cctxt) { u32 rc; VCD_MSG_LOW("vcd_close_in_dev_invalid:"); if (cctxt->clnt_state.state_table->ev_hdlr.close) { rc = cctxt->clnt_state.state_table-> ev_hdlr.close(cctxt); } else { VCD_MSG_ERROR("Unsupported API in client state %d", cctxt->clnt_state.state); rc = VCD_ERR_BAD_STATE; } if (!VCD_FAILED(rc) && !drv_ctxt->dev_ctxt. cctxt_list_head) { VCD_MSG_HIGH("All INVALID clients are closed"); vcd_do_device_state_transition(drv_ctxt, VCD_DEVICE_STATE_NOT_INIT, DEVICE_STATE_EVENT_NUMBER(close)); } return rc; }
static u32 vcd_close_in_ready (struct vcd_drv_ctxt *drv_ctxt, struct vcd_clnt_ctxt *cctxt) { u32 rc; VCD_MSG_LOW("vcd_close_in_dev_ready:"); if (cctxt->clnt_state.state_table->ev_hdlr.close) { rc = cctxt->clnt_state.state_table->ev_hdlr. close(cctxt); } else { VCD_MSG_ERROR("Unsupported API in client state %d", cctxt->clnt_state.state); rc = VCD_ERR_BAD_STATE; } if (!VCD_FAILED(rc)) vcd_handle_for_last_clnt_close(&drv_ctxt->dev_ctxt, true); return rc; }
static u32 vcd_close_in_ready (struct vcd_drv_ctxt_type_t *p_drv_ctxt, struct vcd_clnt_ctxt_type_t *p_cctxt) { u32 rc; VCD_MSG_LOW("vcd_close_in_dev_ready:"); if (p_cctxt->clnt_state.p_state_table->ev_hdlr.pf_close) { rc = p_cctxt->clnt_state.p_state_table->ev_hdlr. pf_close(p_cctxt); } else { VCD_MSG_ERROR("Unsupported API in client state %d", p_cctxt->clnt_state.e_state); rc = VCD_ERR_BAD_STATE; } if (!VCD_FAILED(rc)) vcd_handle_for_last_clnt_close(&p_drv_ctxt->dev_ctxt, TRUE); return rc; }
static u32 vcd_open_in_ready (struct vcd_drv_ctxt *drv_ctxt, s32 driver_handle, u32 decoding, void (*callback) (u32 event, u32 status, void *info, size_t sz, void *handle, void *const client_data), void *client_data) { struct vcd_clnt_ctxt *cctxt; struct vcd_handle_container container; u32 rc; VCD_MSG_LOW("vcd_open_in_dev_ready:"); rc = vcd_open_cmn(drv_ctxt, driver_handle, decoding, callback, client_data, &cctxt); VCD_FAILED_RETURN(rc, "Failed: vcd_open_cmn"); rc = vcd_init_client_context(cctxt); if (!VCD_FAILED(rc)) { container.handle = (void *)cctxt; callback(VCD_EVT_RESP_OPEN, VCD_S_SUCCESS, &container, sizeof(container), container.handle, client_data); } else { VCD_MSG_ERROR("rc = 0x%x. Failed: vcd_init_client_context", rc); vcd_destroy_client_context(cctxt); } return rc; }
u32 vcd_device_power_event(struct vcd_dev_ctxt *dev_ctxt, u32 event, struct vcd_clnt_ctxt *cctxt) { u32 rc = VCD_ERR_FAIL; u32 set_perf_lvl; switch (event) { case VCD_EVT_PWR_DEV_INIT_BEGIN: { if (dev_ctxt->pwr_clk_state == VCD_PWRCLK_STATE_OFF) { if (res_trk_get_max_perf_level(&dev_ctxt-> max_perf_lvl)) { if (res_trk_power_up()) { dev_ctxt->pwr_clk_state = VCD_PWRCLK_STATE_ON_NOTCLOCKED; dev_ctxt->curr_perf_lvl = 0; dev_ctxt->reqd_perf_lvl = 0; dev_ctxt->active_clnts = 0; dev_ctxt-> set_perf_lvl_pending = false; rc = vcd_enable_clock(dev_ctxt, cctxt); if (VCD_FAILED(rc)) { (void)res_trk_power_down(); dev_ctxt->pwr_clk_state = VCD_PWRCLK_STATE_OFF; } } } } break; } case VCD_EVT_PWR_DEV_INIT_END: case VCD_EVT_PWR_DEV_TERM_FAIL: case VCD_EVT_PWR_DEV_SLEEP_BEGIN: case VCD_EVT_PWR_DEV_HWTIMEOUT: { rc = vcd_gate_clock(dev_ctxt); break; } case VCD_EVT_PWR_DEV_INIT_FAIL: case VCD_EVT_PWR_DEV_TERM_END: { if (dev_ctxt->pwr_clk_state != VCD_PWRCLK_STATE_OFF) { (void)vcd_disable_clock(dev_ctxt); (void)res_trk_power_down(); dev_ctxt->pwr_clk_state = VCD_PWRCLK_STATE_OFF; dev_ctxt->curr_perf_lvl = 0; dev_ctxt->reqd_perf_lvl = 0; dev_ctxt->active_clnts = 0; dev_ctxt->set_perf_lvl_pending = false; rc = VCD_S_SUCCESS; } break; } case VCD_EVT_PWR_DEV_TERM_BEGIN: case VCD_EVT_PWR_DEV_SLEEP_END: { rc = vcd_un_gate_clock(dev_ctxt); break; } case VCD_EVT_PWR_DEV_SET_PERFLVL: { set_perf_lvl = dev_ctxt->reqd_perf_lvl > 0 ? dev_ctxt-> reqd_perf_lvl : VCD_MIN_PERF_LEVEL; rc = vcd_set_perf_level(dev_ctxt, set_perf_lvl); break; } } return rc; }
static void vcd_clnt_cb_in_eos (struct vcd_clnt_ctxt *cctxt, u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; struct vcd_transc *transc = NULL; u32 frm_trans_end = false, rc = VCD_S_SUCCESS; if (cctxt->ddl_handle != ddl_handle) { VCD_MSG_ERROR("ddl_handle mismatch"); return; } switch (event) { case VCD_EVT_RESP_INPUT_DONE: { rc = vcd_handle_input_done_in_eos(cctxt, payload, status); break; } case VCD_EVT_RESP_OUTPUT_DONE: { rc = vcd_handle_frame_done_in_eos(cctxt, payload, status); break; } case VCD_EVT_RESP_OUTPUT_REQ: { rc = vcd_handle_output_required(cctxt, payload, status); break; } case VCD_EVT_RESP_EOS_DONE: { transc = (struct vcd_transc *)client_data; vcd_handle_eos_done(cctxt, transc, status); vcd_mark_frame_channel(cctxt->dev_ctxt); break; } case VCD_EVT_IND_OUTPUT_RECONFIG: { rc = vcd_handle_ind_output_reconfig(cctxt, payload, status); if (!VCD_FAILED(rc)) { frm_trans_end = true; payload = NULL; vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_RUN, CLIENT_STATE_EVENT_NUMBER (clnt_cb)); VCD_MSG_LOW ("RECONFIGinEOS:Suspending Client"); rc = vcd_sched_suspend_resume_clnt(cctxt, false); if (VCD_FAILED(rc)) { VCD_MSG_ERROR ("Failed: suspend_resume_clnt. rc=0x%x", rc); } } break; } case VCD_EVT_IND_HWERRFATAL: { vcd_handle_ind_hw_err_fatal(cctxt, VCD_EVT_IND_HWERRFATAL, status); break; } case VCD_EVT_IND_INFO_OUTPUT_RECONFIG: { vcd_handle_ind_info_output_reconfig(cctxt, status); break; } default: { VCD_MSG_ERROR ("Unexpected callback event=%d status=%d from DDL", event, status); dev_ctxt->command_continue = false; break; } } if (!VCD_FAILED(rc) && (event == VCD_EVT_RESP_INPUT_DONE || event == VCD_EVT_RESP_OUTPUT_DONE || event == VCD_EVT_RESP_OUTPUT_REQ || event == VCD_EVT_IND_OUTPUT_RECONFIG)) { if (payload && ((struct ddl_frame_data_tag *) payload)->frm_trans_end) { vcd_mark_frame_channel(cctxt->dev_ctxt); frm_trans_end = true; } if (frm_trans_end && !cctxt->status.frame_submitted) vcd_handle_eos_trans_end(cctxt); } }
void vcd_continue(void) { struct vcd_drv_ctxt *drv_ctxt; struct vcd_dev_ctxt *dev_ctxt; u32 command_continue; struct vcd_transc *transc; u32 rc; VCD_MSG_LOW("vcd_continue:"); drv_ctxt = vcd_get_drv_context(); dev_ctxt = &drv_ctxt->dev_ctxt; dev_ctxt->command_continue = false; if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_INIT) { VCD_MSG_HIGH("VCD_CMD_DEVICE_INIT is pending"); dev_ctxt->pending_cmd = VCD_CMD_NONE; (void)vcd_init_device_context(drv_ctxt, DEVICE_STATE_EVENT_NUMBER(open)); } else if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_TERM) { VCD_MSG_HIGH("VCD_CMD_DEVICE_TERM is pending"); dev_ctxt->pending_cmd = VCD_CMD_NONE; (void)vcd_deinit_device_context(drv_ctxt, DEVICE_STATE_EVENT_NUMBER(close)); } else if (dev_ctxt->pending_cmd == VCD_CMD_DEVICE_RESET) { VCD_MSG_HIGH("VCD_CMD_DEVICE_RESET is pending"); dev_ctxt->pending_cmd = VCD_CMD_NONE; (void)vcd_reset_device_context(drv_ctxt, DEVICE_STATE_EVENT_NUMBER(dev_cb)); } else { if (dev_ctxt->set_perf_lvl_pending) { rc = vcd_power_event(dev_ctxt, NULL, VCD_EVT_PWR_DEV_SET_PERFLVL); if (VCD_FAILED(rc)) { VCD_MSG_ERROR ("VCD_EVT_PWR_CLNT_SET_PERFLVL failed"); VCD_MSG_HIGH ("Not running at desired perf level." "curr=%d, reqd=%d", dev_ctxt->curr_perf_lvl, dev_ctxt->reqd_perf_lvl); } else { dev_ctxt->set_perf_lvl_pending = false; } } do { command_continue = false; if (vcd_get_command_channel_in_loop (dev_ctxt, &transc)) { if (vcd_submit_command_in_continue(dev_ctxt, transc)) command_continue = true; else { VCD_MSG_MED ("No more commands to submit"); vcd_release_command_channel(dev_ctxt, transc); vcd_release_interim_command_channels (dev_ctxt); } } } while (command_continue); do { command_continue = false; if (vcd_get_frame_channel_in_loop (dev_ctxt, &transc)) { if (vcd_try_submit_frame_in_continue(dev_ctxt, transc)) { command_continue = true; } else { VCD_MSG_MED("No more frames to submit"); vcd_release_frame_channel(dev_ctxt, transc); vcd_release_interim_frame_channels (dev_ctxt); } } } while (command_continue); if (!vcd_core_is_busy(dev_ctxt)) { rc = vcd_power_event(dev_ctxt, NULL, VCD_EVT_PWR_CLNT_CMD_END); if (VCD_FAILED(rc)) VCD_MSG_ERROR("Failed:" "VCD_EVT_PWR_CLNT_CMD_END"); } } }
void vcd_ddl_callback(u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_drv_ctxt *drv_ctxt; struct vcd_dev_ctxt *dev_ctxt; struct vcd_dev_state_ctxt *dev_state; struct vcd_clnt_ctxt *cctxt; struct vcd_transc *transc; VCD_MSG_LOW("vcd_ddl_callback:"); VCD_MSG_LOW("event=0x%x status=0x%x", event, status); drv_ctxt = vcd_get_drv_context(); dev_ctxt = &drv_ctxt->dev_ctxt; dev_state = &drv_ctxt->dev_state; dev_ctxt->command_continue = true; vcd_device_timer_stop(dev_ctxt); switch (dev_state->state) { case VCD_DEVICE_STATE_NULL: { VCD_MSG_HIGH("Callback unexpected in NULL state"); break; } case VCD_DEVICE_STATE_NOT_INIT: { VCD_MSG_HIGH("Callback unexpected in NOT_INIT state"); break; } case VCD_DEVICE_STATE_INITING: { if (dev_state->state_table->ev_hdlr.dev_cb) { dev_state->state_table->ev_hdlr. dev_cb(drv_ctxt, event, status, payload, sz, ddl_handle, client_data); } else { VCD_MSG_HIGH("No device handler in %d state", dev_state->state); } break; } case VCD_DEVICE_STATE_READY: { transc = (struct vcd_transc *)client_data; if (!transc || !transc->in_use || !transc->cctxt) { VCD_MSG_ERROR("Invalid clientdata " "received from DDL "); } else { cctxt = transc->cctxt; if (cctxt->clnt_state.state_table->ev_hdlr. clnt_cb) { cctxt->clnt_state.state_table-> ev_hdlr.clnt_cb(cctxt, event, status, payload, sz, ddl_handle, client_data); } else { VCD_MSG_HIGH ("No client handler in" " (dsm:READY, csm:%d) state", (int)cctxt->clnt_state.state); if (VCD_FAILED(status)) { VCD_MSG_FATAL("DDL callback" " returned failure 0x%x", status); } } } break; } default: { VCD_MSG_ERROR("Unknown state"); break; } } }
static void vcd_clnt_cb_in_run (struct vcd_clnt_ctxt *cctxt, u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u32 rc = VCD_S_SUCCESS; if (cctxt->ddl_handle != ddl_handle) { VCD_MSG_ERROR("ddl_handle mismatch"); return; } switch (event) { case VCD_EVT_RESP_INPUT_DONE: { rc = vcd_handle_input_done(cctxt, payload, event, status); break; } case VCD_EVT_RESP_OUTPUT_DONE: { rc = vcd_handle_frame_done(cctxt, payload, event, status); break; } case VCD_EVT_RESP_OUTPUT_REQ: { rc = vcd_handle_output_required(cctxt, payload, status); break; } case VCD_EVT_IND_OUTPUT_RECONFIG: { rc = vcd_handle_ind_output_reconfig(cctxt, payload, status); break; } case VCD_EVT_RESP_TRANSACTION_PENDING: { vcd_handle_trans_pending(cctxt); break; } case VCD_EVT_IND_HWERRFATAL: { vcd_handle_ind_hw_err_fatal(cctxt, VCD_EVT_IND_HWERRFATAL, status); break; } case VCD_EVT_IND_INFO_OUTPUT_RECONFIG: { vcd_handle_ind_info_output_reconfig(cctxt, status); break; } default: { VCD_MSG_ERROR ("Unexpected callback event=%d status=%d from DDL", event, status); dev_ctxt->command_continue = false; break; } } if (!VCD_FAILED(rc) && (event == VCD_EVT_RESP_INPUT_DONE || event == VCD_EVT_RESP_OUTPUT_DONE || event == VCD_EVT_RESP_OUTPUT_REQ)) { if (((struct ddl_frame_data_tag *) payload)->frm_trans_end) vcd_mark_frame_channel(cctxt->dev_ctxt); } }
static void vcd_dev_cb_in_initing (struct vcd_drv_ctxt *drv_ctxt, u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_dev_ctxt *dev_ctxt; struct vcd_clnt_ctxt *client; struct vcd_clnt_ctxt *tmp_client; struct vcd_handle_container container; u32 rc = VCD_S_SUCCESS; u32 client_inited = false; u32 fail_all_open = false; VCD_MSG_LOW("vcd_dev_cb_in_initing:"); if (event != VCD_EVT_RESP_DEVICE_INIT) { VCD_MSG_ERROR("vcd_dev_cb_in_initing: Unexpected event %d", (int)event); return; } dev_ctxt = &drv_ctxt->dev_ctxt; dev_ctxt->command_continue = false; if (VCD_FAILED(status)) { vcd_handle_device_init_failed(drv_ctxt, status); return; } vcd_do_device_state_transition(drv_ctxt, VCD_DEVICE_STATE_READY, DEVICE_STATE_EVENT_NUMBER(open)); if (!dev_ctxt->cctxt_list_head) { VCD_MSG_HIGH("All clients are closed"); dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM; return; } if (!dev_ctxt->ddl_cmd_ch_depth || !dev_ctxt->trans_tbl) rc = vcd_setup_with_ddl_capabilities(dev_ctxt); if (VCD_FAILED(rc)) { VCD_MSG_ERROR ("rc = 0x%x: Failed vcd_setup_with_ddl_capabilities", rc); fail_all_open = true; } client = dev_ctxt->cctxt_list_head; while (client) { if (!fail_all_open) rc = vcd_init_client_context(client); if (!VCD_FAILED(rc)) { container.handle = (void *)client; client->callback(VCD_EVT_RESP_OPEN, VCD_S_SUCCESS, &container, sizeof(container), container.handle, client->client_data); client = client->next; client_inited = true; } else { VCD_MSG_ERROR ("rc = 0x%x, Failed: vcd_init_client_context", rc); client->callback(VCD_EVT_RESP_OPEN, rc, NULL, 0, 0, client->client_data); tmp_client = client; client = client->next; vcd_destroy_client_context(tmp_client); } } if (!client_inited || fail_all_open) { VCD_MSG_ERROR("All client open requests failed"); dev_ctxt->pending_cmd = VCD_CMD_DEVICE_TERM; } else { if (vcd_power_event(dev_ctxt, NULL, VCD_EVT_PWR_DEV_INIT_END)) { VCD_MSG_ERROR("VCD_EVT_PWR_DEV_INIT_END failed"); } } }
static void vcd_clnt_cb_in_pausing (struct vcd_clnt_ctxt *cctxt, u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u32 rc = VCD_S_SUCCESS; u32 frm_trans_end = false; VCD_MSG_LOW("vcd_clnt_cb_in_pausing:"); if (cctxt->ddl_handle != ddl_handle) { VCD_MSG_ERROR("ddl_handle mismatch"); return; } switch (event) { case VCD_EVT_RESP_INPUT_DONE: { rc = vcd_handle_input_done(cctxt, payload, event, status); break; } case VCD_EVT_RESP_OUTPUT_DONE: { rc = vcd_handle_frame_done(cctxt, payload, event, status); break; } case VCD_EVT_RESP_OUTPUT_REQ: { rc = vcd_handle_output_required(cctxt, payload, status); break; } case VCD_EVT_IND_OUTPUT_RECONFIG: { rc = vcd_handle_ind_output_reconfig(cctxt, payload, status); if (!VCD_FAILED(rc)) { frm_trans_end = true; payload = NULL; } break; } case VCD_EVT_IND_HWERRFATAL: { vcd_handle_ind_hw_err_fatal(cctxt, VCD_EVT_RESP_PAUSE, status); rc = VCD_ERR_FAIL; break; } default: { VCD_MSG_ERROR ("Unexpected callback event=%d status=%d from DDL", event, status); dev_ctxt->command_continue = false; break; } } if (!VCD_FAILED(rc)) { if (payload && ((struct ddl_frame_data_tag *)\ payload)->frm_trans_end) { vcd_mark_frame_channel(cctxt->dev_ctxt); frm_trans_end = true; } if (frm_trans_end && !cctxt->status.frame_submitted) { VCD_MSG_HIGH ("All pending frames recvd from DDL"); cctxt->callback(VCD_EVT_RESP_PAUSE, VCD_S_SUCCESS, NULL, 0, cctxt, cctxt->client_data); vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_PAUSED, CLIENT_STATE_EVENT_NUMBER (clnt_cb)); rc = vcd_power_event(cctxt->dev_ctxt, cctxt, VCD_EVT_PWR_CLNT_PAUSE); if (VCD_FAILED(rc)) { VCD_MSG_ERROR ("VCD_EVT_PWR_CLNT_PAUSE_END" "failed"); } } } }
static void vcd_clnt_cb_in_stopping (struct vcd_clnt_ctxt *cctxt, u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u32 rc = VCD_S_SUCCESS; u32 frm_trans_end = false; VCD_MSG_LOW("vcd_clnt_cb_in_stopping:"); if (cctxt->ddl_handle != ddl_handle) { VCD_MSG_ERROR("ddl_handle mismatch"); return; } switch (event) { case VCD_EVT_RESP_INPUT_DONE: { rc = vcd_handle_input_done(cctxt, payload, VCD_EVT_RESP_INPUT_FLUSHED, status); break; } case VCD_EVT_RESP_OUTPUT_DONE: { rc = vcd_handle_frame_done(cctxt, payload, VCD_EVT_RESP_OUTPUT_FLUSHED, status); break; } case VCD_EVT_RESP_OUTPUT_REQ: { rc = vcd_handle_output_required_in_flushing(cctxt, payload); break; } case VCD_EVT_RESP_STOP: { vcd_handle_stop_done(cctxt, (struct vcd_transc *) client_data, status); break; } case VCD_EVT_IND_OUTPUT_RECONFIG: { (void) vcd_handle_ind_output_reconfig(cctxt, payload, status); frm_trans_end = true; payload = NULL; break; } case VCD_EVT_IND_HWERRFATAL: { vcd_handle_ind_hw_err_fatal(cctxt, VCD_EVT_RESP_STOP, status); break; } default: { VCD_MSG_ERROR ("Unexpected callback event=%d status=%d from DDL", event, status); dev_ctxt->command_continue = false; break; } } if (!VCD_FAILED(rc) && ((event == VCD_EVT_RESP_INPUT_DONE || event == VCD_EVT_RESP_OUTPUT_DONE) || event == VCD_EVT_RESP_OUTPUT_REQ || event == VCD_EVT_IND_OUTPUT_RECONFIG)) { if (payload && ((struct ddl_frame_data_tag *)\ payload)->frm_trans_end) { vcd_mark_frame_channel(cctxt->dev_ctxt); frm_trans_end = true; } if (frm_trans_end && !cctxt->status.frame_submitted) { VCD_MSG_HIGH ("All pending frames recvd from DDL"); vcd_flush_bframe_buffers(cctxt, VCD_FLUSH_INPUT); vcd_flush_output_buffers(cctxt); cctxt->status.mask &= ~VCD_FLUSH_ALL; vcd_release_all_clnt_frm_transc(cctxt); VCD_MSG_HIGH ("All buffers flushed. Enqueuing stop cmd"); vcd_client_cmd_flush_and_en_q(cctxt, VCD_CMD_CODEC_STOP); } } }
static void vcd_clnt_cb_in_flushing (struct vcd_clnt_ctxt *cctxt, u32 event, u32 status, void *payload, size_t sz, u32 *ddl_handle, void *const client_data) { struct vcd_dev_ctxt *dev_ctxt = cctxt->dev_ctxt; u32 rc = VCD_S_SUCCESS; u32 frm_trans_end = false; VCD_MSG_LOW("vcd_clnt_cb_in_flushing:"); if (cctxt->ddl_handle != ddl_handle) { VCD_MSG_ERROR("ddl_handle mismatch"); return; } switch (event) { case VCD_EVT_RESP_INPUT_DONE: { rc = vcd_handle_input_done(cctxt, payload, VCD_EVT_RESP_INPUT_FLUSHED, status); break; } case VCD_EVT_RESP_OUTPUT_DONE: { rc = vcd_handle_frame_done(cctxt, payload, VCD_EVT_RESP_OUTPUT_FLUSHED, status); break; } case VCD_EVT_RESP_OUTPUT_REQ: { rc = vcd_handle_output_required_in_flushing(cctxt, payload); break; } case VCD_EVT_IND_OUTPUT_RECONFIG: { rc = vcd_handle_ind_output_reconfig(cctxt, payload, status); if (!VCD_FAILED(rc)) { frm_trans_end = true; payload = NULL; } break; } case VCD_EVT_IND_HWERRFATAL: { vcd_handle_ind_hw_err_fatal(cctxt, VCD_EVT_IND_HWERRFATAL, status); break; } default: { VCD_MSG_ERROR ("Unexpected callback event=%d status=%d from DDL", event, status); dev_ctxt->command_continue = false; break; } } if (!VCD_FAILED(rc) && ((event == VCD_EVT_RESP_INPUT_DONE || event == VCD_EVT_RESP_OUTPUT_DONE || event == VCD_EVT_RESP_OUTPUT_REQ || event == VCD_EVT_IND_OUTPUT_RECONFIG))) { if (payload && ((struct ddl_frame_data_tag *)\ payload)->frm_trans_end) { vcd_mark_frame_channel(cctxt->dev_ctxt); frm_trans_end = true; } if (frm_trans_end && !cctxt->status.frame_submitted) { VCD_MSG_HIGH ("All pending frames recvd from DDL"); if (cctxt->status.mask & VCD_FLUSH_INPUT) vcd_flush_bframe_buffers(cctxt, VCD_FLUSH_INPUT); if (cctxt->status.mask & VCD_FLUSH_OUTPUT) vcd_flush_output_buffers(cctxt); vcd_send_flush_done(cctxt, VCD_S_SUCCESS); vcd_release_interim_frame_channels(dev_ctxt); VCD_MSG_HIGH("Flush complete"); vcd_do_client_state_transition(cctxt, VCD_CLIENT_STATE_RUN, CLIENT_STATE_EVENT_NUMBER (clnt_cb)); } } }
u32 vcd_device_power_event(struct vcd_dev_ctxt_type *p_dev_ctxt, u32 event, struct vcd_clnt_ctxt_type_t *p_cctxt) { u32 rc = VCD_ERR_FAIL; u32 n_set_perf_lvl; switch (event) { case VCD_EVT_PWR_DEV_INIT_BEGIN: { if (p_dev_ctxt->e_pwr_clk_state == VCD_PWRCLK_STATE_OFF) { if (res_trk_get_max_perf_level(&p_dev_ctxt-> n_max_perf_lvl)) { if (res_trk_power_up()) { p_dev_ctxt->e_pwr_clk_state = VCD_PWRCLK_STATE_ON_NOTCLOCKED; p_dev_ctxt->n_curr_perf_lvl = 0; p_dev_ctxt->n_reqd_perf_lvl = 0; p_dev_ctxt->n_active_clnts = 0; p_dev_ctxt-> b_set_perf_lvl_pending = FALSE; rc = vcd_enable_clock(p_dev_ctxt, p_cctxt); if (VCD_FAILED(rc)) { (void)res_trk_power_down(); p_dev_ctxt->e_pwr_clk_state = VCD_PWRCLK_STATE_OFF; } } } } break; } case VCD_EVT_PWR_DEV_INIT_END: case VCD_EVT_PWR_DEV_TERM_FAIL: case VCD_EVT_PWR_DEV_SLEEP_BEGIN: case VCD_EVT_PWR_DEV_HWTIMEOUT: { rc = vcd_gate_clock(p_dev_ctxt); break; } case VCD_EVT_PWR_DEV_INIT_FAIL: case VCD_EVT_PWR_DEV_TERM_END: { if (p_dev_ctxt->e_pwr_clk_state != VCD_PWRCLK_STATE_OFF) { (void)vcd_disable_clock(p_dev_ctxt); (void)res_trk_power_down(); p_dev_ctxt->e_pwr_clk_state = VCD_PWRCLK_STATE_OFF; p_dev_ctxt->n_curr_perf_lvl = 0; p_dev_ctxt->n_reqd_perf_lvl = 0; p_dev_ctxt->n_active_clnts = 0; p_dev_ctxt->b_set_perf_lvl_pending = FALSE; rc = VCD_S_SUCCESS; } break; } case VCD_EVT_PWR_DEV_TERM_BEGIN: case VCD_EVT_PWR_DEV_SLEEP_END: { rc = vcd_un_gate_clock(p_dev_ctxt); break; } case VCD_EVT_PWR_DEV_SET_PERFLVL: { n_set_perf_lvl = p_dev_ctxt->n_reqd_perf_lvl > 0 ? p_dev_ctxt-> n_reqd_perf_lvl : VCD_MIN_PERF_LEVEL; rc = vcd_set_perf_level(p_dev_ctxt, n_set_perf_lvl, p_cctxt); break; } } return rc; }