diff --git a/drivers/cam_isp/cam_isp_context.c b/drivers/cam_isp/cam_isp_context.c index 5d2c46aa6a..00993e35d4 100644 --- a/drivers/cam_isp/cam_isp_context.c +++ b/drivers/cam_isp/cam_isp_context.c @@ -314,71 +314,62 @@ static int cam_isp_ctx_dump_req( size_t *offset, bool dump_to_buff) { - int i, j, rc = 0; + int i, rc = 0; size_t len = 0; uint32_t *buf_addr; uint32_t *buf_start, *buf_end; size_t remain_len = 0; struct cam_cdm_cmd_buf_dump_info dump_info; - uint32_t num_cfg; - struct cam_hw_update_entry *cfg; - for (j = 0; j < CAM_IFE_HW_NUM_MAX; j++) { - num_cfg = req_isp->cfg_info[j].num_hw_entries; - cfg = req_isp->cfg_info[j].hw_entries; - for (i = 0; i < num_cfg; i++) { - rc = cam_packet_util_get_cmd_mem_addr( - cfg[i].handle, &buf_addr, &len); - if (rc) { - CAM_ERR_RATE_LIMIT(CAM_ISP, - "Failed to get_cmd_mem_addr, rc=%d", - rc); - } else { - if (cfg[i].offset >= ((uint32_t)len)) { - CAM_ERR(CAM_ISP, - "Invalid offset exp %u actual %u", - cfg[i].offset, (uint32_t)len); - return -EINVAL; - } - remain_len = len - cfg[i].offset; - - if (req_isp->cfg_info[j].hw_entries[i].len > - ((uint32_t)remain_len)) { - CAM_ERR(CAM_ISP, - "Invalid len exp %u remain_len %u", - cfg[i].len, - (uint32_t)remain_len); - return -EINVAL; - } - - buf_start = (uint32_t *)((uint8_t *) buf_addr + - cfg[i].offset); - buf_end = (uint32_t *)((uint8_t *) buf_start + - cfg[i].len - 1); - - if (dump_to_buff) { - if (!cpu_addr || !offset || !buf_len) { - CAM_ERR(CAM_ISP, - "Invalid args"); - break; - } - dump_info.src_start = buf_start; - dump_info.src_end = buf_end; - dump_info.dst_start = cpu_addr; - dump_info.dst_offset = *offset; - dump_info.dst_max_size = buf_len; - rc = cam_cdm_util_dump_cmd_bufs_v2( - &dump_info); - *offset = dump_info.dst_offset; - if (rc) - return rc; - } else - cam_cdm_util_dump_cmd_buf(buf_start, - buf_end); + for (i = 0; i < req_isp->num_cfg; i++) { + rc = cam_packet_util_get_cmd_mem_addr( + req_isp->cfg[i].handle, &buf_addr, &len); + if (rc) { + CAM_ERR_RATE_LIMIT(CAM_ISP, + "Failed to get_cmd_mem_addr, rc=%d", + rc); + } else { + if (req_isp->cfg[i].offset >= ((uint32_t)len)) { + CAM_ERR(CAM_ISP, + "Invalid offset exp %u actual %u", + req_isp->cfg[i].offset, (uint32_t)len); + return -EINVAL; } + remain_len = len - req_isp->cfg[i].offset; + + if (req_isp->cfg[i].len > + ((uint32_t)remain_len)) { + CAM_ERR(CAM_ISP, + "Invalid len exp %u remain_len %u", + req_isp->cfg[i].len, + (uint32_t)remain_len); + return -EINVAL; + } + + buf_start = (uint32_t *)((uint8_t *) buf_addr + + req_isp->cfg[i].offset); + buf_end = (uint32_t *)((uint8_t *) buf_start + + req_isp->cfg[i].len - 1); + + if (dump_to_buff) { + if (!cpu_addr || !offset || !buf_len) { + CAM_ERR(CAM_ISP, "Invalid args"); + break; + } + dump_info.src_start = buf_start; + dump_info.src_end = buf_end; + dump_info.dst_start = cpu_addr; + dump_info.dst_offset = *offset; + dump_info.dst_max_size = buf_len; + rc = cam_cdm_util_dump_cmd_bufs_v2( + &dump_info); + *offset = dump_info.dst_offset; + if (rc) + return rc; + } else + cam_cdm_util_dump_cmd_buf(buf_start, buf_end); } } - return rc; } @@ -429,17 +420,13 @@ static int __cam_isp_ctx_enqueue_request_in_order( static int __cam_isp_ctx_enqueue_init_request( struct cam_context *ctx, struct cam_ctx_request *req) { - int rc = 0, i = 0; + int rc = 0; struct cam_ctx_request *req_old; struct cam_isp_ctx_req *req_isp_old; struct cam_isp_ctx_req *req_isp_new; struct cam_isp_prepare_hw_update_data *req_update_old; struct cam_isp_prepare_hw_update_data *req_update_new; struct cam_isp_prepare_hw_update_data *hw_update_data; - struct cam_hw_update_entry *cfg_old; - struct cam_hw_update_entry *cfg_new; - uint32_t num_cfg_old; - uint32_t num_cfg_new; spin_lock_bh(&ctx->lock); if (list_empty(&ctx->pending_req_list)) { @@ -455,12 +442,12 @@ static int __cam_isp_ctx_enqueue_init_request( req_isp_new = (struct cam_isp_ctx_req *) req->req_priv; if (req_isp_old->hw_update_data.packet_opcode_type == CAM_ISP_PACKET_INIT_DEV) { - if ((req_isp_old->total_num_cfg + req_isp_new->total_num_cfg) >= + if ((req_isp_old->num_cfg + req_isp_new->num_cfg) >= CAM_ISP_CTX_CFG_MAX) { CAM_WARN(CAM_ISP, - "Can not merge INIT pkt total_num_cfgs = %d", - (req_isp_old->total_num_cfg + - req_isp_new->total_num_cfg)); + "Can not merge INIT pkt num_cfgs = %d", + (req_isp_old->num_cfg + + req_isp_new->num_cfg)); rc = -ENOMEM; } @@ -485,19 +472,11 @@ static int __cam_isp_ctx_enqueue_init_request( req_isp_old->num_fence_map_in = req_isp_new->num_fence_map_in; - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - cfg_old = req_isp_old->cfg_info[i].hw_entries; - cfg_new = req_isp_new->cfg_info[i].hw_entries; - num_cfg_old = - req_isp_old->cfg_info[i].num_hw_entries; - num_cfg_new = - req_isp_new->cfg_info[i].num_hw_entries; - memcpy(&cfg_old[num_cfg_old], - cfg_new, - sizeof(cfg_new[0]) * num_cfg_new); - req_isp_old->cfg_info[i].num_hw_entries - += num_cfg_new; - } + memcpy(&req_isp_old->cfg[req_isp_old->num_cfg], + req_isp_new->cfg, + sizeof(req_isp_new->cfg[0]) * + req_isp_new->num_cfg); + req_isp_old->num_cfg += req_isp_new->num_cfg; memcpy(&req_old->pf_data, &req->pf_data, sizeof(struct cam_hw_mgr_dump_pf_data)); @@ -1088,12 +1067,12 @@ static int __cam_isp_ctx_handle_buf_done_in_activated_state( static int __cam_isp_ctx_apply_req_offline( void *priv, void *data) { - int rc = 0, i = 0; + int rc = 0; struct cam_context *ctx = NULL; struct cam_isp_context *ctx_isp = priv; struct cam_ctx_request *req; struct cam_isp_ctx_req *req_isp; - struct cam_isp_hw_config_args cfg; + struct cam_hw_config_args cfg; if (!ctx_isp) { CAM_ERR(CAM_ISP, "Invalid ctx_isp:%pK", ctx); @@ -1129,12 +1108,8 @@ static int __cam_isp_ctx_apply_req_offline( cfg.ctxt_to_hw_map = ctx_isp->hw_ctx; cfg.request_id = req->request_id; - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - cfg.hw_update_info[i].num_hw_entries = - req_isp->cfg_info[i].num_hw_entries; - cfg.hw_update_info[i].hw_entries = - req_isp->cfg_info[i].hw_entries; - } + cfg.hw_update_entries = req_isp->cfg; + cfg.num_hw_update_entries = req_isp->num_cfg; cfg.priv = &req_isp->hw_update_data; cfg.init_packet = 0; @@ -2505,13 +2480,13 @@ static int __cam_isp_ctx_apply_req_in_activated_state( struct cam_context *ctx, struct cam_req_mgr_apply_request *apply, enum cam_isp_ctx_activated_substate next_state) { - int rc = 0, i; + int rc = 0; struct cam_ctx_request *req; struct cam_ctx_request *active_req = NULL; struct cam_isp_ctx_req *req_isp; struct cam_isp_ctx_req *active_req_isp; struct cam_isp_context *ctx_isp = NULL; - struct cam_isp_hw_config_args isp_cfg; + struct cam_hw_config_args cfg = {0}; if (list_empty(&ctx->pending_req_list)) { CAM_ERR(CAM_ISP, "No available request for Apply id %lld", @@ -2597,22 +2572,16 @@ static int __cam_isp_ctx_apply_req_in_activated_state( } req_isp->bubble_report = apply->report_if_bubble; - memset(&isp_cfg, 0, sizeof(isp_cfg)); - - isp_cfg.ctxt_to_hw_map = ctx_isp->hw_ctx; - isp_cfg.request_id = req->request_id; - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - isp_cfg.hw_update_info[i].num_hw_entries = - req_isp->cfg_info[i].num_hw_entries; - isp_cfg.hw_update_info[i].hw_entries = - req_isp->cfg_info[i].hw_entries; - } - isp_cfg.priv = &req_isp->hw_update_data; - isp_cfg.init_packet = 0; - isp_cfg.reapply = req_isp->reapply; + cfg.ctxt_to_hw_map = ctx_isp->hw_ctx; + cfg.request_id = req->request_id; + cfg.hw_update_entries = req_isp->cfg; + cfg.num_hw_update_entries = req_isp->num_cfg; + cfg.priv = &req_isp->hw_update_data; + cfg.init_packet = 0; + cfg.reapply = req_isp->reapply; rc = ctx->hw_mgr_intf->hw_config(ctx->hw_mgr_intf->hw_mgr_priv, - &isp_cfg); + &cfg); if (rc) { CAM_ERR_RATE_LIMIT(CAM_ISP, "Can not apply the configuration"); } else { @@ -3832,7 +3801,7 @@ static int __cam_isp_ctx_config_dev_in_top_state( struct cam_packet *packet; size_t len = 0; size_t remain_len = 0; - struct cam_isp_hw_update_args isp_cfg; + struct cam_hw_prepare_update_args cfg = {0}; struct cam_req_mgr_add_request add_req; struct cam_isp_context *ctx_isp = (struct cam_isp_context *) ctx->ctx_priv; @@ -3912,44 +3881,31 @@ static int __cam_isp_ctx_config_dev_in_top_state( goto free_req; } - /* preprocess the configuration */ - memset(&isp_cfg, 0, sizeof(isp_cfg)); - - isp_cfg.packet = packet; - isp_cfg.remain_len = remain_len; - isp_cfg.ctxt_to_hw_map = ctx_isp->hw_ctx; - isp_cfg.max_hw_update_entries = CAM_ISP_CTX_CFG_MAX; - isp_cfg.max_out_map_entries = CAM_ISP_CTX_RES_MAX; - isp_cfg.max_in_map_entries = CAM_ISP_CTX_RES_MAX; - isp_cfg.out_map_entries = req_isp->fence_map_out; - isp_cfg.in_map_entries = req_isp->fence_map_in; - isp_cfg.priv = &req_isp->hw_update_data; - isp_cfg.pf_data = &(req->pf_data); - - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) - isp_cfg.hw_update_info[i].hw_entries - = req_isp->cfg_info[i].hw_entries; + cfg.packet = packet; + cfg.remain_len = remain_len; + cfg.ctxt_to_hw_map = ctx_isp->hw_ctx; + cfg.max_hw_update_entries = CAM_ISP_CTX_CFG_MAX; + cfg.hw_update_entries = req_isp->cfg; + cfg.max_out_map_entries = CAM_ISP_CTX_RES_MAX; + cfg.max_in_map_entries = CAM_ISP_CTX_RES_MAX; + cfg.out_map_entries = req_isp->fence_map_out; + cfg.in_map_entries = req_isp->fence_map_in; + cfg.priv = &req_isp->hw_update_data; + cfg.pf_data = &(req->pf_data); CAM_DBG(CAM_ISP, "try to prepare config packet......"); rc = ctx->hw_mgr_intf->hw_prepare_update( - ctx->hw_mgr_intf->hw_mgr_priv, &isp_cfg); + ctx->hw_mgr_intf->hw_mgr_priv, &cfg); if (rc != 0) { CAM_ERR(CAM_ISP, "Prepare config packet failed in HW layer"); rc = -EFAULT; goto free_req; } - req_isp->total_num_cfg = 0; - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - req_isp->cfg_info[i].num_hw_entries - = isp_cfg.hw_update_info[i].num_hw_entries; - req_isp->total_num_cfg += - req_isp->cfg_info[i].num_hw_entries; - } - - req_isp->num_fence_map_out = isp_cfg.num_out_map_entries; - req_isp->num_fence_map_in = isp_cfg.num_in_map_entries; + req_isp->num_cfg = cfg.num_hw_update_entries; + req_isp->num_fence_map_out = cfg.num_out_map_entries; + req_isp->num_fence_map_in = cfg.num_in_map_entries; req_isp->num_acked = 0; req_isp->bubble_detected = false; @@ -3963,7 +3919,7 @@ static int __cam_isp_ctx_config_dev_in_top_state( } CAM_DBG(CAM_ISP, "num_entry: %d, num fence out: %d, num fence in: %d", - req_isp->total_num_cfg, req_isp->num_fence_map_out, + req_isp->num_cfg, req_isp->num_fence_map_out, req_isp->num_fence_map_in); req->request_id = packet->header.request_id; @@ -4698,14 +4654,8 @@ static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx, start_isp.hw_config.ctxt_to_hw_map = ctx_isp->hw_ctx; start_isp.hw_config.request_id = req->request_id; - - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - start_isp.hw_config.hw_update_info[i].hw_entries - = req_isp->cfg_info[i].hw_entries; - start_isp.hw_config.hw_update_info[i].num_hw_entries = - req_isp->cfg_info[i].num_hw_entries; - } - + start_isp.hw_config.hw_update_entries = req_isp->cfg; + start_isp.hw_config.num_hw_update_entries = req_isp->num_cfg; start_isp.hw_config.priv = &req_isp->hw_update_data; start_isp.hw_config.init_packet = 1; start_isp.hw_config.reapply = 0; diff --git a/drivers/cam_isp/cam_isp_context.h b/drivers/cam_isp/cam_isp_context.h index fd5c59fb47..c6f5aa3188 100644 --- a/drivers/cam_isp/cam_isp_context.h +++ b/drivers/cam_isp/cam_isp_context.h @@ -135,8 +135,8 @@ struct cam_isp_ctx_irq_ops { * struct cam_isp_ctx_req - ISP context request object * * @base: Common request object ponter - * @cfg_info: ISP hardware configuration array - * @total_num_cfg: Number of ISP hardware configuration entries + * @cfg: ISP hardware configuration array + * @num_cfg: Number of ISP hardware configuration entries * @fence_map_out: Output fence mapping array * @num_fence_map_out: Number of the output fence map * @fence_map_in: Input fence mapping array @@ -153,8 +153,8 @@ struct cam_isp_ctx_irq_ops { */ struct cam_isp_ctx_req { struct cam_ctx_request *base; - struct cam_isp_hw_update_info cfg_info[CAM_IFE_HW_NUM_MAX]; - uint32_t total_num_cfg; + struct cam_hw_update_entry cfg[CAM_ISP_CTX_CFG_MAX]; + uint32_t num_cfg; struct cam_hw_fence_map_entry fence_map_out [CAM_ISP_CTX_RES_MAX]; uint32_t num_fence_map_out; diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c index 4f07a3a284..9945190e33 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c @@ -653,7 +653,7 @@ static int cam_ife_hw_mgr_free_hw_res( "Release HW:%d resource id %d failed", hw_intf->hw_idx, isp_hw_res->res_id); else - CAM_INFO(CAM_ISP, + CAM_DBG(CAM_ISP, "Released HW:%d resource id %d", hw_intf->hw_idx, isp_hw_res->res_id); @@ -1949,17 +1949,6 @@ static int cam_ife_hw_mgr_acquire_res_ife_csid_pxl( cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_csid, &csid_res); cid_res->num_children++; - if (is_ipp) { - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - if (master_idx == i) - ife_ctx->master_slave[i] = CAM_IFE_RES_MASTER; - else - ife_ctx->master_slave[i] = CAM_IFE_RES_SLAVE; - CAM_DBG(CAM_ISP, "hw %d, slave/master %d", - i, ife_ctx->master_slave[i]); - } - } - CAM_DBG(CAM_ISP, "acquire res %d CID children = %d", csid_acquire.res_id, cid_res->num_children); @@ -2740,8 +2729,6 @@ void cam_ife_cam_cdm_callback(uint32_t handle, void *userdata, { struct cam_isp_prepare_hw_update_data *hw_update_data = NULL; struct cam_ife_hw_mgr_ctx *ctx = NULL; - int i; - uint32_t idx = 0; int reg_dump_done; if (!userdata) { @@ -2752,24 +2739,8 @@ void cam_ife_cam_cdm_callback(uint32_t handle, void *userdata, hw_update_data = (struct cam_isp_prepare_hw_update_data *)userdata; ctx = (struct cam_ife_hw_mgr_ctx *)hw_update_data->isp_mgr_ctx; - if (!ctx->internal_cdm) - idx = 0; - else { - for (i = 0; i < ctx->num_base; i++) { - if (ctx->cdm_handle[ctx->base[i].idx] == handle) { - idx = ctx->base[i].idx; - break; - } - } - - if (i == ctx->num_base) { - CAM_ERR(CAM_ISP, "Incorrect CDM handle=0x%x", handle); - return; - } - } - if (status == CAM_CDM_CB_STATUS_BL_SUCCESS) { - complete_all(&ctx->config_done_complete[idx]); + complete_all(&ctx->config_done_complete); reg_dump_done = atomic_read(&ctx->cdm_done); atomic_set(&ctx->cdm_done, 1); if ((g_ife_hw_mgr.debug_cfg.per_req_reg_dump) && @@ -3019,7 +2990,7 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) struct cam_ife_hw_mgr *ife_hw_mgr = hw_mgr_priv; struct cam_hw_acquire_args *acquire_args = acquire_hw_args; int rc = -1; - int i, j = 0, k; + int i, j; struct cam_ife_hw_mgr_ctx *ife_ctx; struct cam_isp_in_port_generic_info *in_port = NULL; struct cam_cdm_acquire_data cdm_acquire; @@ -3031,7 +3002,7 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) uint32_t total_pd_port = 0; struct cam_isp_acquire_hw_info *acquire_hw_info = NULL; uint32_t input_size = 0; - uint32_t hw_version, idx; + uint32_t hw_version; CAM_DBG(CAM_ISP, "Enter..."); @@ -3049,15 +3020,14 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) ife_ctx->custom_enabled = false; ife_ctx->custom_config = 0; - memset(ife_ctx->cdm_handle, 0, sizeof(ife_ctx->cdm_handle)); - + ife_ctx->cdm_handle = 0; ife_ctx->common.cb_priv = acquire_args->context_data; ife_ctx->internal_cdm = false; for (i = 0; i < CAM_ISP_HW_EVENT_MAX; i++) ife_ctx->common.event_cb[i] = acquire_args->event_cb; ife_ctx->hw_mgr = ife_hw_mgr; - ife_ctx->cdm_ops = cam_cdm_publish_ops(); + ife_ctx->cdm_ops = cam_cdm_publish_ops(); acquire_hw_info = (struct cam_isp_acquire_hw_info *)acquire_args->acquire_info; @@ -3144,36 +3114,36 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) cam_cpas_get_cpas_hw_version(&hw_version); ife_ctx->hw_version = hw_version; - for (k = 0; k < ife_ctx->num_base; k++) { - CAM_DBG(CAM_ISP, "Acquire cdm for ife_hw_idx %d", - ife_ctx->base[k].idx); - + if (ife_ctx->is_dual) + memcpy(cdm_acquire.identifier, "dualife", sizeof("dualife")); + else memcpy(cdm_acquire.identifier, "ife", sizeof("ife")); - cdm_acquire.cell_index = ife_ctx->base[k].idx; - cdm_acquire.handle = 0; - cdm_acquire.userdata = ife_ctx; - if (ife_hw_mgr->cdm_reg_map[ife_ctx->base[k].idx]) - cdm_acquire.base_array[j++] = - ife_hw_mgr->cdm_reg_map[ife_ctx->base[k].idx]; - cdm_acquire.base_array_cnt = j; - cdm_acquire.priority = CAM_CDM_BL_FIFO_0; - cdm_acquire.id = CAM_CDM_VIRTUAL; - cdm_acquire.cam_cdm_callback = cam_ife_cam_cdm_callback; - rc = cam_cdm_acquire(&cdm_acquire); - if (rc) { - CAM_ERR(CAM_ISP, "Failed to acquire the CDM HW"); - goto free_cdm; - } - CAM_DBG(CAM_ISP, - "Successfully acquired CDM id=0%d, handle :0x%x", - cdm_acquire.id, cdm_acquire.handle); - if (cdm_acquire.id == CAM_CDM_IFE) - ife_ctx->internal_cdm = true; - ife_ctx->cdm_handle[ife_ctx->base[k].idx] = cdm_acquire.handle; - ife_ctx->base[k].cdm_id = cdm_acquire.id; + cdm_acquire.cell_index = ife_ctx->base[0].idx; + cdm_acquire.handle = 0; + cdm_acquire.userdata = ife_ctx; + cdm_acquire.base_array_cnt = CAM_IFE_HW_NUM_MAX; + for (i = 0, j = 0; i < CAM_IFE_HW_NUM_MAX; i++) { + if (ife_hw_mgr->cdm_reg_map[i]) + cdm_acquire.base_array[j++] = + ife_hw_mgr->cdm_reg_map[i]; + } + cdm_acquire.base_array_cnt = j; + cdm_acquire.priority = CAM_CDM_BL_FIFO_0; + cdm_acquire.id = CAM_CDM_VIRTUAL; + cdm_acquire.cam_cdm_callback = cam_ife_cam_cdm_callback; + rc = cam_cdm_acquire(&cdm_acquire); + if (rc) { + CAM_ERR(CAM_ISP, "Failed to acquire the CDM HW"); + goto free_ctx; } + CAM_DBG(CAM_ISP, + "Successfully acquired CDM Id: %d, CDM HW hdl=%x, is_dual=%d", + cdm_acquire.id, cdm_acquire.handle, ife_ctx->is_dual); + ife_ctx->cdm_handle = cdm_acquire.handle; + if (cdm_acquire.id == CAM_CDM_IFE) + ife_ctx->internal_cdm = true; atomic_set(&ife_ctx->cdm_done, 1); acquire_args->ctxt_to_hw_map = ife_ctx; @@ -3198,13 +3168,10 @@ free_mem: kfree(in_port->data); kfree(in_port); free_cdm: - for (i = 0; i < ife_ctx->num_base; i++) { - idx = ife_ctx->base[i].idx; - if (ife_ctx->cdm_handle[idx] != 0) - cam_cdm_release(ife_ctx->cdm_handle[idx]); - } + cam_cdm_release(ife_ctx->cdm_handle); free_res: cam_ife_hw_mgr_release_hw_for_ctx(ife_ctx); +free_ctx: cam_ife_hw_mgr_put_ctx(&ife_hw_mgr->free_ctx_list, &ife_ctx); err: CAM_DBG(CAM_ISP, "Exit...(rc=%d)", rc); @@ -3260,7 +3227,7 @@ static int cam_ife_mgr_acquire_dev(void *hw_mgr_priv, void *acquire_hw_args) struct cam_ife_hw_mgr *ife_hw_mgr = hw_mgr_priv; struct cam_hw_acquire_args *acquire_args = acquire_hw_args; int rc = -1; - int i, j = 0, k; + int i, j; struct cam_ife_hw_mgr_ctx *ife_ctx; struct cam_isp_in_port_info *in_port = NULL; struct cam_isp_resource *isp_resource = NULL; @@ -3273,7 +3240,7 @@ static int cam_ife_mgr_acquire_dev(void *hw_mgr_priv, void *acquire_hw_args) uint32_t total_pix_port = 0; uint32_t total_rdi_port = 0; uint32_t in_port_length = 0; - uint32_t hw_version, idx; + uint32_t hw_version; CAM_DBG(CAM_ISP, "Enter..."); @@ -3289,14 +3256,12 @@ static int cam_ife_mgr_acquire_dev(void *hw_mgr_priv, void *acquire_hw_args) goto err; } - memset(ife_ctx->cdm_handle, 0, sizeof(ife_ctx->cdm_handle)); - + ife_ctx->cdm_handle = 0; ife_ctx->common.cb_priv = acquire_args->context_data; for (i = 0; i < CAM_ISP_HW_EVENT_MAX; i++) ife_ctx->common.event_cb[i] = acquire_args->event_cb; ife_ctx->hw_mgr = ife_hw_mgr; - ife_ctx->cdm_ops = cam_cdm_publish_ops(); isp_resource = (struct cam_isp_resource *)acquire_args->acquire_info; @@ -3409,37 +3374,38 @@ static int cam_ife_mgr_acquire_dev(void *hw_mgr_priv, void *acquire_hw_args) } cam_cpas_get_cpas_hw_version(&hw_version); - ife_ctx->hw_version = hw_version; + ife_ctx->internal_cdm = false; - for (k = 0; k < ife_ctx->num_base; k++) { - CAM_DBG(CAM_ISP, "Acquire cdm for ife_hw_idx %d", k); - + if (ife_ctx->is_dual) + memcpy(cdm_acquire.identifier, "dualife", sizeof("dualife")); + else memcpy(cdm_acquire.identifier, "ife", sizeof("ife")); - cdm_acquire.cell_index = ife_ctx->base[k].idx; - cdm_acquire.handle = 0; - cdm_acquire.userdata = ife_ctx; - if (ife_hw_mgr->cdm_reg_map[ife_ctx->base[k].idx]) + cdm_acquire.cell_index = ife_ctx->base[0].idx; + cdm_acquire.handle = 0; + cdm_acquire.userdata = ife_ctx; + cdm_acquire.base_array_cnt = CAM_IFE_HW_NUM_MAX; + for (i = 0, j = 0; i < CAM_IFE_HW_NUM_MAX; i++) { + if (ife_hw_mgr->cdm_reg_map[i]) cdm_acquire.base_array[j++] = - ife_hw_mgr->cdm_reg_map[ife_ctx->base[k].idx]; - cdm_acquire.base_array_cnt = j; - cdm_acquire.priority = CAM_CDM_BL_FIFO_0; - cdm_acquire.id = CAM_CDM_VIRTUAL; - cdm_acquire.cam_cdm_callback = cam_ife_cam_cdm_callback; - rc = cam_cdm_acquire(&cdm_acquire); - if (rc) { - CAM_ERR(CAM_ISP, "Failed to acquire the CDM HW"); - goto free_res; - } - - CAM_DBG(CAM_ISP, "Successfully acquired the CDM HW hdl=0x%x", - cdm_acquire.handle); - - if (cdm_acquire.id == CAM_CDM_IFE) - ife_ctx->internal_cdm = true; - ife_ctx->cdm_handle[ife_ctx->base[k].idx] = cdm_acquire.handle; + ife_hw_mgr->cdm_reg_map[i]; + } + cdm_acquire.base_array_cnt = j; + cdm_acquire.priority = CAM_CDM_BL_FIFO_0; + cdm_acquire.id = CAM_CDM_VIRTUAL; + cdm_acquire.cam_cdm_callback = cam_ife_cam_cdm_callback; + rc = cam_cdm_acquire(&cdm_acquire); + if (rc) { + CAM_ERR(CAM_ISP, "Failed to acquire the CDM HW"); + goto free_res; } + CAM_DBG(CAM_ISP, "Successfully acquired CDM ID:%d, CDM HW hdl=%x", + cdm_acquire.id, cdm_acquire.handle); + + if (cdm_acquire.id == CAM_CDM_IFE) + ife_ctx->internal_cdm = true; + ife_ctx->cdm_handle = cdm_acquire.handle; atomic_set(&ife_ctx->cdm_done, 1); acquire_args->ctxt_to_hw_map = ife_ctx; @@ -3454,11 +3420,7 @@ static int cam_ife_mgr_acquire_dev(void *hw_mgr_priv, void *acquire_hw_args) return 0; free_res: cam_ife_hw_mgr_release_hw_for_ctx(ife_ctx); - for (i = 0; i < ife_ctx->num_base; i++) { - idx = ife_ctx->base[i].idx; - if (ife_ctx->cdm_handle[idx] != 0) - cam_cdm_release(ife_ctx->cdm_handle[idx]); - } + cam_cdm_release(ife_ctx->cdm_handle); cam_ife_hw_mgr_put_ctx(&ife_hw_mgr->free_ctx_list, &ife_ctx); err: CAM_DBG(CAM_ISP, "Exit...(rc=%d)", rc); @@ -3761,199 +3723,17 @@ static int cam_isp_blob_bw_update( return rc; } -static int cam_ife_config_hw_internal_cdm(struct cam_ife_hw_mgr_ctx *ctx, - struct cam_isp_hw_config_args *cfg, - struct cam_isp_prepare_hw_update_data *hw_update_data) -{ - int rc = -1, i, j, skip = 0; - struct cam_hw_update_entry *cmd; - struct cam_cdm_bl_request *cdm_cmd; - uint32_t num_ent; - struct cam_hw_update_entry *cfg_info; - unsigned long rem_jiffies = 0; - uint32_t idx; - - if (ctx->num_base >= CAM_IFE_HW_NUM_MAX) { - CAM_ERR(CAM_ISP, - "Invalid number of IFE acquired = %d", - ctx->num_base); - return -EINVAL; - } - - for (i = 0; i < ctx->num_base; i++) { - idx = ctx->base[i].idx; - num_ent = cfg->hw_update_info[idx].num_hw_entries; - cfg_info = cfg->hw_update_info[idx].hw_entries; - if (num_ent > 0) { - cdm_cmd = ctx->cdm_cmd; - cdm_cmd->type = CAM_CDM_BL_CMD_TYPE_MEM_HANDLE; - cdm_cmd->flag = true; - cdm_cmd->userdata = hw_update_data; - cdm_cmd->cookie = cfg->request_id; - cdm_cmd->gen_irq_arb = false; - skip = 0; - - for (j = 0 ; j < num_ent; j++) { - cmd = (cfg_info + j); - - if (cfg->reapply && - cmd->flags == CAM_ISP_IQ_BL) { - skip++; - continue; - } - - if (cmd->flags == CAM_ISP_UNUSED_BL || - cmd->flags >= CAM_ISP_BL_MAX) - CAM_ERR(CAM_ISP, - "Unexpected BL type %d", - cmd->flags); - - cdm_cmd->cmd[j - skip].bl_addr.mem_handle = - cmd->handle; - cdm_cmd->cmd[j - skip].offset = cmd->offset; - cdm_cmd->cmd[j - skip].len = cmd->len; - cdm_cmd->cmd[j - skip].arbitrate = false; - } - cdm_cmd->cmd_arrary_count = num_ent - skip; - - reinit_completion(&ctx->config_done_complete[idx]); - ctx->applied_req_id = cfg->request_id; - - CAM_DBG(CAM_ISP, "Submit to CDM for IFE idx = %d", - ctx->base[i].idx); - atomic_set(&ctx->cdm_done, 0); - rc = cam_cdm_submit_bls(ctx->cdm_handle[idx], cdm_cmd); - if (rc) { - CAM_ERR(CAM_ISP, - "Failed to apply the configs for req %llu, rc %d", - cfg->request_id, rc); - return rc; - } - } - } - - for (i = 0; i < ctx->num_base; i++) { - idx = ctx->base[i].idx; - if ((cfg->init_packet) || - (ctx->custom_config & CAM_IFE_CUSTOM_CFG_SW_SYNC_ON)) { - rem_jiffies = wait_for_completion_timeout( - &ctx->config_done_complete[idx], - msecs_to_jiffies(30)); - if (rem_jiffies == 0) { - CAM_ERR(CAM_ISP, - "config done completion timeout for req_id=%llu ctx_index %d IFE:%d", - cfg->request_id, - ctx->ctx_index, idx); - rc = -ETIMEDOUT; - } else - CAM_DBG(CAM_ISP, - "config done Success for req_id=%llu ctx_index %d IFE:%d", - cfg->request_id, - ctx->ctx_index, idx); - } - } - - return rc; -} - -static int cam_ife_config_hw_external_cdm(struct cam_ife_hw_mgr_ctx *ctx, - struct cam_isp_hw_config_args *cfg, - struct cam_isp_prepare_hw_update_data *hw_update_data) -{ - int rc = -1, i, j, k = 0, skip = 0; - struct cam_hw_update_entry *cmd; - struct cam_cdm_bl_request *cdm_cmd; - uint32_t num_ent; - struct cam_hw_update_entry *cfg_info; - unsigned long rem_jiffies = 0; - - if (ctx->num_base >= CAM_IFE_HW_NUM_MAX) { - CAM_ERR(CAM_ISP, - "Invalid number of IFE acquired = %d", - ctx->num_base); - return -EINVAL; - } - - cdm_cmd = ctx->cdm_cmd; - cdm_cmd->type = CAM_CDM_BL_CMD_TYPE_MEM_HANDLE; - cdm_cmd->flag = true; - cdm_cmd->userdata = hw_update_data; - cdm_cmd->cookie = cfg->request_id; - cdm_cmd->gen_irq_arb = false; - cdm_cmd->cmd_arrary_count = 0; - - for (i = 0; i < ctx->num_base; i++) { - num_ent = cfg->hw_update_info[ctx->base[i].idx].num_hw_entries; - cfg_info = cfg->hw_update_info[ctx->base[i].idx].hw_entries; - if (num_ent > 0) { - for (j = 0 ; j < num_ent; j++) { - cmd = (cfg_info + j); - - if (cfg->reapply && - cmd->flags == CAM_ISP_IQ_BL) { - skip++; - continue; - } - - if (cmd->flags == CAM_ISP_UNUSED_BL || - cmd->flags >= CAM_ISP_BL_MAX) - CAM_ERR(CAM_ISP, - "Unexpected BL type %d", - cmd->flags); - - cdm_cmd->cmd[j - skip + k].bl_addr.mem_handle = - cmd->handle; - cdm_cmd->cmd[j - skip + k].offset = cmd->offset; - cdm_cmd->cmd[j - skip + k].len = cmd->len; - cdm_cmd->cmd[j - skip + k].arbitrate = false; - } - cdm_cmd->cmd_arrary_count += num_ent - skip; - k = cdm_cmd->cmd_arrary_count; - } - } - - ctx->applied_req_id = cfg->request_id; - CAM_DBG(CAM_ISP, "Submit to CDM for IFE idx = %d", - ctx->base[i].idx); - atomic_set(&ctx->cdm_done, 0); - reinit_completion(&ctx->config_done_complete[0]); - rc = cam_cdm_submit_bls(ctx->cdm_handle[ctx->base[0].idx], cdm_cmd); - if (rc) { - CAM_ERR(CAM_ISP, - "Failed to apply the configs for req %llu, rc %d", - cfg->request_id, rc); - return rc; - } - - if ((cfg->init_packet) || - (ctx->custom_config & CAM_IFE_CUSTOM_CFG_SW_SYNC_ON)) { - rem_jiffies = wait_for_completion_timeout( - &ctx->config_done_complete[0], - msecs_to_jiffies(30)); - if (rem_jiffies == 0) { - CAM_ERR(CAM_ISP, - "config done completion timeout for req_id=%llu ctx_index %d IFE:%d", - cfg->request_id, - ctx->ctx_index, ctx->base[0].idx); - rc = -ETIMEDOUT; - } else - CAM_DBG(CAM_ISP, - "config done Success for req_id=%llu ctx_index %d IFE:%d", - cfg->request_id, - ctx->ctx_index, ctx->base[0].idx); - } - - return rc; -} - /* entry function: config_hw */ static int cam_ife_mgr_config_hw(void *hw_mgr_priv, void *config_hw_args) { - int rc = -1, i; - struct cam_isp_hw_config_args *cfg; + int rc = -1, i, skip = 0; + struct cam_hw_config_args *cfg; + struct cam_hw_update_entry *cmd; + struct cam_cdm_bl_request *cdm_cmd; struct cam_ife_hw_mgr_ctx *ctx; struct cam_isp_prepare_hw_update_data *hw_update_data; + unsigned long rem_jiffies = 0; if (!hw_mgr_priv || !config_hw_args) { CAM_ERR(CAM_ISP, @@ -3990,10 +3770,11 @@ static int cam_ife_mgr_config_hw(void *hw_mgr_priv, ctx, ctx->ctx_index, cfg->request_id, cfg->init_packet); for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - if (hw_update_data->bw_config_valid[i]) { + if (hw_update_data->bw_config_valid[i] == true) { CAM_DBG(CAM_PERF, "idx=%d, bw_config_version=%d", - i, hw_update_data->bw_config_version); + ctx, ctx->ctx_index, i, + hw_update_data->bw_config_version); if (hw_update_data->bw_config_version == CAM_ISP_BW_CONFIG_V1) { @@ -4007,8 +3788,7 @@ static int cam_ife_mgr_config_hw(void *hw_mgr_priv, CAM_ISP_BW_CONFIG_V2) { rc = cam_isp_blob_bw_update_v2( (struct cam_isp_bw_config_v2 *) - &hw_update_data->bw_config_v2[i], - ctx); + &hw_update_data->bw_config_v2[i], ctx); if (rc) CAM_ERR(CAM_PERF, "Bandwidth Update Failed rc: %d", rc); @@ -4022,19 +3802,68 @@ static int cam_ife_mgr_config_hw(void *hw_mgr_priv, } CAM_DBG(CAM_ISP, - "Enter ctx id:%d request id: %llu", ctx->ctx_index, - cfg->request_id); + "Enter ctx id:%d num_hw_upd_entries %d request id: %llu", + ctx->ctx_index, cfg->num_hw_update_entries, cfg->request_id); - if (ctx->internal_cdm) - rc = cam_ife_config_hw_internal_cdm(ctx, cfg, hw_update_data); - else - rc = cam_ife_config_hw_external_cdm(ctx, cfg, hw_update_data); + if (cfg->num_hw_update_entries > 0) { + cdm_cmd = ctx->cdm_cmd; + cdm_cmd->type = CAM_CDM_BL_CMD_TYPE_MEM_HANDLE; + cdm_cmd->flag = true; + cdm_cmd->userdata = hw_update_data; + cdm_cmd->cookie = cfg->request_id; + cdm_cmd->gen_irq_arb = false; - if (rc) { - CAM_ERR(CAM_ISP, "Config HW failure"); - return rc; + for (i = 0 ; i < cfg->num_hw_update_entries; i++) { + cmd = (cfg->hw_update_entries + i); + + if (cfg->reapply && + cmd->flags == CAM_ISP_IQ_BL) { + skip++; + continue; + } + + if (cmd->flags == CAM_ISP_UNUSED_BL || + cmd->flags >= CAM_ISP_BL_MAX) + CAM_ERR(CAM_ISP, "Unexpected BL type %d", + cmd->flags); + + cdm_cmd->cmd[i - skip].bl_addr.mem_handle = cmd->handle; + cdm_cmd->cmd[i - skip].offset = cmd->offset; + cdm_cmd->cmd[i - skip].len = cmd->len; + cdm_cmd->cmd[i - skip].arbitrate = false; + } + cdm_cmd->cmd_arrary_count = cfg->num_hw_update_entries - skip; + + reinit_completion(&ctx->config_done_complete); + ctx->applied_req_id = cfg->request_id; + + CAM_DBG(CAM_ISP, "Submit to CDM"); + atomic_set(&ctx->cdm_done, 0); + rc = cam_cdm_submit_bls(ctx->cdm_handle, cdm_cmd); + if (rc) { + CAM_ERR(CAM_ISP, + "Failed to apply the configs for req %llu, rc %d", + cfg->request_id, rc); + return rc; + } + + if (cfg->init_packet) { + rem_jiffies = wait_for_completion_timeout( + &ctx->config_done_complete, + msecs_to_jiffies(30)); + if (rem_jiffies == 0) { + CAM_ERR(CAM_ISP, + "config done completion timeout for req_id=%llu ctx_index %d", + cfg->request_id, ctx->ctx_index); + rc = -ETIMEDOUT; + } else + CAM_DBG(CAM_ISP, + "config done Success for req_id=%llu ctx_index %d", + cfg->request_id, ctx->ctx_index); + } + } else { + CAM_ERR(CAM_ISP, "No commands to config"); } - CAM_DBG(CAM_ISP, "Exit: Config Done: %llu", cfg->request_id); return rc; @@ -4179,7 +4008,6 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args) enum cam_ife_csid_halt_cmd csid_halt_type; uint32_t i, master_base_idx = 0; unsigned long rem_jiffies = 0; - uint32_t idx; if (!hw_mgr_priv || !stop_hw_args) { CAM_ERR(CAM_ISP, "Invalid arguments"); @@ -4280,40 +4108,19 @@ static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args) cam_ife_mgr_pause_hw(ctx); - if (ctx->internal_cdm) { - for (i = 0; i < ctx->num_base; i++) { - idx = ctx->base[i].idx; - rem_jiffies = wait_for_completion_timeout( - &ctx->config_done_complete[idx], - msecs_to_jiffies(5)); - if (rem_jiffies == 0) - CAM_WARN(CAM_ISP, - "config done completion timeout for last applied req_id=%llu ctx_index %d IFE:%d", - ctx->applied_req_id, ctx->ctx_index, - idx); - } - } else { - rem_jiffies = wait_for_completion_timeout( - &ctx->config_done_complete[0], - msecs_to_jiffies(5)); - if (rem_jiffies == 0) - CAM_WARN(CAM_ISP, - "config done completion timeout for last applied req_id=%llu ctx_index %d IFE:%d", - ctx->applied_req_id, ctx->ctx_index, - ctx->master_hw_idx); - } + rem_jiffies = wait_for_completion_timeout( + &ctx->config_done_complete, + msecs_to_jiffies(10)); + if (rem_jiffies == 0) + CAM_WARN(CAM_ISP, + "config done completion timeout for last applied req_id=%llu ctx_index %", + ctx->applied_req_id, ctx->ctx_index); if (stop_isp->stop_only) goto end; - for (i = 0; i < ctx->num_base; i++) { - idx = ctx->base[i].idx; - if (ctx->cdm_handle[idx] != 0) { - if (cam_cdm_stream_off(ctx->cdm_handle[idx])) - CAM_ERR(CAM_ISP, "CDM stream off failed %d", - ctx->cdm_handle[i]); - } - } + if (cam_cdm_stream_off(ctx->cdm_handle)) + CAM_ERR(CAM_ISP, "CDM stream off failed %d", ctx->cdm_handle); if (ctx->is_tpg) cam_ife_hw_mgr_stop_hw_res(&ctx->res_list_tpg); @@ -4484,7 +4291,7 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args) struct cam_ife_hw_mgr_ctx *ctx; struct cam_isp_hw_mgr_res *hw_mgr_res; struct cam_isp_resource_node *rsrc_node = NULL; - uint32_t i, camif_debug, idx; + uint32_t i, camif_debug; bool res_rdi_context_set = false; uint32_t primary_rdi_src_res; uint32_t primary_rdi_out_res; @@ -4578,16 +4385,10 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args) } mutex_unlock(&g_ife_hw_mgr.ctx_mutex); - for (i = 0; i < ctx->num_base; i++) { - idx = ctx->base[i].idx; - if (ctx->cdm_handle[idx] != 0) { - rc = cam_cdm_stream_on(ctx->cdm_handle[idx]); - if (rc) { - CAM_ERR(CAM_ISP, "Can not start cdm (%d)", - ctx->cdm_handle); - goto safe_disable; - } - } + rc = cam_cdm_stream_on(ctx->cdm_handle); + if (rc) { + CAM_ERR(CAM_ISP, "Can not start cdm (%d)", ctx->cdm_handle); + goto safe_disable; } start_only: @@ -4715,10 +4516,7 @@ err: return rc; cdm_streamoff: - for (i = 0; i < ctx->num_base; i++) { - if (ctx->cdm_handle[ctx->base[i].idx] != 0) - cam_cdm_stream_off(ctx->cdm_handle[ctx->base[i].idx]); - } + cam_cdm_stream_off(ctx->cdm_handle); safe_disable: cam_ife_notify_safe_lut_scm(CAM_IFE_SAFE_DISABLE); @@ -4817,16 +4615,13 @@ static int cam_ife_mgr_release_hw(void *hw_mgr_priv, memset(ctx->base, 0, sizeof(ctx->base)); /* release cdm handle */ - for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) { - if (ctx->cdm_handle[i] != 0) - cam_cdm_release(ctx->cdm_handle[i]); - ctx->cdm_handle[i] = 0; - } + cam_cdm_release(ctx->cdm_handle); /* clean context */ list_del_init(&ctx->list); ctx->ctx_in_use = 0; ctx->is_rdi_only_context = 0; + ctx->cdm_handle = 0; ctx->cdm_ops = NULL; ctx->num_reg_dump_buf = 0; ctx->custom_enabled = false; @@ -4855,7 +4650,7 @@ static int cam_isp_blob_fe_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_fe_config *fe_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -4927,14 +4722,13 @@ static int cam_isp_blob_ubwc_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_ubwc_config *ubwc_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ubwc_plane_cfg_v1 *ubwc_plane_cfg; struct cam_kmd_buf_info *kmd_buf_info; struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; - uint32_t res_id_out, i, slot_idx = 0; + uint32_t res_id_out, i; uint32_t total_used_bytes = 0; uint32_t kmd_buf_remain_size; uint32_t *cmd_buf_addr; @@ -4948,14 +4742,10 @@ static int cam_isp_blob_ubwc_update( goto end; } - slot_idx = blob_info->base_info->idx; - hw_entry = prepare->hw_update_info[slot_idx].hw_entries; - num_ent = prepare->hw_update_info[slot_idx].num_hw_entries; - - if ((num_ent + 1) >= + if ((prepare->num_hw_update_entries + 1) >= prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d max:%d", - num_ent, + prepare->num_hw_update_entries, prepare->max_hw_update_entries); rc = -EINVAL; goto end; @@ -5027,18 +4817,18 @@ static int cam_isp_blob_ubwc_update( if (total_used_bytes) { /* Update the HW entries */ - hw_entry[num_ent].handle = + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = + prepare->hw_update_entries[num_ent].len = total_used_bytes; - hw_entry[num_ent].offset = + prepare->hw_update_entries[num_ent].offset = kmd_buf_info->offset; num_ent++; kmd_buf_info->used_bytes += total_used_bytes; kmd_buf_info->offset += total_used_bytes; - prepare->hw_update_info[slot_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; } break; default: @@ -5103,13 +4893,12 @@ static int cam_isp_blob_ubwc_update_v2( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_ubwc_config_v2 *ubwc_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ubwc_plane_cfg_v2 *ubwc_plane_cfg; struct cam_kmd_buf_info *kmd_buf_info; struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; uint32_t res_id_out, i; uint32_t total_used_bytes = 0; uint32_t kmd_buf_remain_size; @@ -5117,7 +4906,6 @@ static int cam_isp_blob_ubwc_update_v2( uint32_t bytes_used = 0; int num_ent, rc = 0; struct cam_vfe_generic_ubwc_config generic_ubwc_cfg; - uint32_t slot_idx; ctx = prepare->ctxt_to_hw_map; if (!ctx) { @@ -5126,14 +4914,10 @@ static int cam_isp_blob_ubwc_update_v2( goto end; } - slot_idx = blob_info->base_info->idx; - hw_entry = prepare->hw_update_info[slot_idx].hw_entries; - num_ent = prepare->hw_update_info[slot_idx].num_hw_entries; - - if (num_ent + 1 >= + if (prepare->num_hw_update_entries + 1 >= prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d max:%d", - prepare->hw_update_info[slot_idx].num_hw_entries, + prepare->num_hw_update_entries, prepare->max_hw_update_entries); rc = -EINVAL; goto end; @@ -5206,18 +4990,17 @@ static int cam_isp_blob_ubwc_update_v2( if (total_used_bytes) { /* Update the HW entries */ - hw_entry[num_ent].handle = + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = - total_used_bytes; - hw_entry[num_ent].offset = + prepare->hw_update_entries[num_ent].len = total_used_bytes; + prepare->hw_update_entries[num_ent].offset = kmd_buf_info->offset; num_ent++; kmd_buf_info->used_bytes += total_used_bytes; kmd_buf_info->offset += total_used_bytes; - prepare->hw_update_info[slot_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; } end: return rc; @@ -5227,14 +5010,13 @@ static int cam_isp_blob_hfr_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_resource_hfr_config *hfr_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_isp_port_hfr_config *port_hfr_config; struct cam_kmd_buf_info *kmd_buf_info; struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; - uint32_t res_id_out, i, slot_idx = 0; + uint32_t res_id_out, i; uint32_t total_used_bytes = 0; uint32_t kmd_buf_remain_size; uint32_t *cmd_buf_addr; @@ -5245,15 +5027,11 @@ static int cam_isp_blob_hfr_update( CAM_DBG(CAM_ISP, "num_ports= %d", hfr_config->num_ports); - slot_idx = blob_info->base_info->idx; - hw_entry = prepare->hw_update_info[slot_idx].hw_entries; - num_ent = prepare->hw_update_info[slot_idx].num_hw_entries; - /* Max one hw entries required for hfr config update */ - if (prepare->hw_update_info[slot_idx].num_hw_entries + 1 >= + if (prepare->num_hw_update_entries + 1 >= prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d", - prepare->hw_update_info[slot_idx].num_hw_entries, + prepare->num_hw_update_entries, prepare->max_hw_update_entries); return -EINVAL; } @@ -5311,17 +5089,16 @@ static int cam_isp_blob_hfr_update( if (total_used_bytes) { /* Update the HW entries */ - hw_entry[num_ent].handle = + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = - total_used_bytes; - hw_entry[num_ent].offset = + prepare->hw_update_entries[num_ent].len = total_used_bytes; + prepare->hw_update_entries[num_ent].offset = kmd_buf_info->offset; num_ent++; kmd_buf_info->used_bytes += total_used_bytes; kmd_buf_info->offset += total_used_bytes; - prepare->hw_update_info[slot_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; } return rc; @@ -5331,7 +5108,7 @@ static int cam_isp_blob_csid_clock_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_csid_clock_config *clock_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -5378,7 +5155,7 @@ static int cam_isp_blob_csid_qcfa_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_csid_qcfa_config *qcfa_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -5426,7 +5203,7 @@ static int cam_isp_blob_core_cfg_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_core_config *core_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -5481,7 +5258,7 @@ static int cam_isp_blob_clock_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_clock_config *clock_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -5591,7 +5368,7 @@ static int cam_isp_blob_sensor_config( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_sensor_config *dim_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -5661,30 +5438,25 @@ static int cam_isp_blob_vfe_out_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_vfe_out_config *vfe_out_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_isp_vfe_wm_config *wm_config; struct cam_kmd_buf_info *kmd_buf_info; struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *ife_out_res; - struct cam_hw_update_entry *hw_entry; uint32_t res_id_out, i; uint32_t total_used_bytes = 0; uint32_t kmd_buf_remain_size; uint32_t *cmd_buf_addr; uint32_t bytes_used = 0; - uint32_t slot_idx = 0; int num_ent, rc = 0; ctx = prepare->ctxt_to_hw_map; - slot_idx = blob_info->base_info->idx; - hw_entry = prepare->hw_update_info[slot_idx].hw_entries; - num_ent = prepare->hw_update_info[slot_idx].num_hw_entries; - if (num_ent + 1 >= + if (prepare->num_hw_update_entries + 1 >= prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d", - num_ent); + prepare->num_hw_update_entries); return -EINVAL; } @@ -5740,17 +5512,16 @@ static int cam_isp_blob_vfe_out_update( } if (total_used_bytes) { - hw_entry[num_ent].handle = + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = - total_used_bytes; - hw_entry[num_ent].offset = + prepare->hw_update_entries[num_ent].len = total_used_bytes; + prepare->hw_update_entries[num_ent].offset = kmd_buf_info->offset; num_ent++; kmd_buf_info->used_bytes += total_used_bytes; kmd_buf_info->offset += total_used_bytes; - prepare->hw_update_info[slot_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; } return rc; @@ -5760,7 +5531,7 @@ static int cam_isp_blob_csid_config_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_csid_epd_config *epd_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_ife_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -5807,7 +5578,7 @@ static int cam_isp_packet_generic_blob_handler(void *user_data, int rc = 0; struct cam_isp_generic_blob_info *blob_info = user_data; struct cam_ife_hw_mgr_ctx *ife_mgr_ctx = NULL; - struct cam_isp_hw_update_args *prepare = NULL; + struct cam_hw_prepare_update_args *prepare = NULL; if (!blob_data || (blob_size == 0) || !blob_info) { CAM_ERR(CAM_ISP, "Invalid args data %pK size %d info %pK", @@ -6365,13 +6136,13 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, void *prepare_hw_update_args) { int rc = 0; - struct cam_isp_hw_update_args *ife_cfg = - (struct cam_isp_hw_update_args *) prepare_hw_update_args; + struct cam_hw_prepare_update_args *prepare = + (struct cam_hw_prepare_update_args *) prepare_hw_update_args; struct cam_ife_hw_mgr_ctx *ctx; struct cam_ife_hw_mgr *hw_mgr; struct cam_kmd_buf_info kmd_buf; - uint32_t i, idx; + uint32_t i; bool fill_fence = true; bool frame_header_enable = false; struct cam_isp_prepare_hw_update_data *prepare_hw_data; @@ -6383,22 +6154,22 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, } prepare_hw_data = (struct cam_isp_prepare_hw_update_data *) - ife_cfg->priv; + prepare->priv; - ctx = (struct cam_ife_hw_mgr_ctx *) ife_cfg->ctxt_to_hw_map; + ctx = (struct cam_ife_hw_mgr_ctx *) prepare->ctxt_to_hw_map; hw_mgr = (struct cam_ife_hw_mgr *)hw_mgr_priv; CAM_DBG(CAM_REQ, "ctx[%pK][%d] Enter for req_id %lld", - ctx, ctx->ctx_index, ife_cfg->packet->header.request_id); + ctx, ctx->ctx_index, prepare->packet->header.request_id); - rc = cam_packet_util_validate_packet(ife_cfg->packet, - ife_cfg->remain_len); + rc = cam_packet_util_validate_packet(prepare->packet, + prepare->remain_len); if (rc) return rc; /* Pre parse the packet*/ - rc = cam_packet_util_get_kmd_buffer(ife_cfg->packet, &kmd_buf); + rc = cam_packet_util_get_kmd_buffer(prepare->packet, &kmd_buf); if (rc) return rc; @@ -6412,11 +6183,11 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, } if (ctx->internal_cdm) - rc = cam_packet_util_process_patches(ife_cfg->packet, + rc = cam_packet_util_process_patches(prepare->packet, hw_mgr->mgr_common.img_iommu_hdl, hw_mgr->mgr_common.img_iommu_hdl_secure); else - rc = cam_packet_util_process_patches(ife_cfg->packet, + rc = cam_packet_util_process_patches(prepare->packet, hw_mgr->mgr_common.cmd_iommu_hdl, hw_mgr->mgr_common.cmd_iommu_hdl_secure); @@ -6425,14 +6196,10 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, return rc; } - - for (i = 0; i < ctx->num_base; i++) { - idx = ctx->base[i].idx; - ife_cfg->hw_update_info[idx].num_hw_entries = 0; - } - ife_cfg->num_in_map_entries = 0; - ife_cfg->num_out_map_entries = 0; - ife_cfg->num_reg_dump_buf = 0; + prepare->num_hw_update_entries = 0; + prepare->num_in_map_entries = 0; + prepare->num_out_map_entries = 0; + prepare->num_reg_dump_buf = 0; memset(&prepare_hw_data->bw_config[0], 0x0, sizeof(prepare_hw_data->bw_config[0]) * @@ -6441,30 +6208,16 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, sizeof(prepare_hw_data->bw_config_valid[0]) * CAM_IFE_HW_NUM_MAX); - /* Add reset trigger_cdm_event */ - if ((ctx->hw_version >= CAM_CPAS_TITAN_480_V100) && ctx->is_dual - && ctx->internal_cdm) { - for (i = 0; i < ctx->num_base; i++) { - if (ctx->master_slave[ctx->base[i].idx] - == CAM_IFE_RES_SLAVE && - ctx->base[i].cdm_id == CAM_CDM_IFE) - rc = cam_isp_add_wait_trigger(ife_cfg, - &ctx->res_list_ife_src, - ctx->base[i].idx, &kmd_buf, false); - } - } - for (i = 0; i < ctx->num_base; i++) { CAM_DBG(CAM_ISP, "process cmd buffer for device %d", i); CAM_DBG(CAM_ISP, - "change base i=%d, idx=%d, ctx->internal_cdm = %d cdm_id = %d", - i, ctx->base[i].idx, ctx->internal_cdm, - ctx->base[i].cdm_id); + "change base i=%d, idx=%d, ctx->internal_cdm = %d", + i, ctx->base[i].idx, ctx->internal_cdm); /* Add change base */ - if (!ctx->internal_cdm || ctx->base[i].cdm_id == CAM_CDM_CPAS) { - rc = cam_isp_add_change_base(ife_cfg, + if (!ctx->internal_cdm) { + rc = cam_isp_add_change_base(prepare, &ctx->res_list_ife_src, ctx->base[i].idx, &kmd_buf); if (rc) { @@ -6476,7 +6229,7 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, } /* get command buffers */ if (ctx->base[i].split_id != CAM_ISP_HW_SPLIT_MAX) { - rc = cam_isp_add_command_buffers(ife_cfg, &kmd_buf, + rc = cam_isp_add_command_buffers(prepare, &kmd_buf, &ctx->base[i], cam_isp_packet_generic_blob_handler, ctx->res_list_ife_out, CAM_IFE_HW_OUT_RES_MAX); @@ -6500,7 +6253,7 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, rc = cam_isp_add_io_buffers( hw_mgr->mgr_common.img_iommu_hdl, hw_mgr->mgr_common.img_iommu_hdl_secure, - ife_cfg, ctx->base[i].idx, + prepare, ctx->base[i].idx, &kmd_buf, ctx->res_list_ife_out, &ctx->res_list_ife_in_rd, CAM_IFE_HW_OUT_RES_MAX, fill_fence, @@ -6531,9 +6284,9 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, } /* add go_cmd for offline context */ - if (ife_cfg->num_out_map_entries && ife_cfg->num_in_map_entries && + if (prepare->num_out_map_entries && prepare->num_in_map_entries && ctx->is_offline) { - rc = cam_isp_add_go_cmd(ife_cfg, &ctx->res_list_ife_in_rd, + rc = cam_isp_add_go_cmd(prepare, &ctx->res_list_ife_in_rd, ctx->base[i].idx, &kmd_buf); if (rc) CAM_ERR(CAM_ISP, @@ -6547,26 +6300,26 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, * bits to get the type of operation since UMD definition * of op_code has some difference from KMD. */ - if (((ife_cfg->packet->header.op_code + 1) & 0xF) == + if (((prepare->packet->header.op_code + 1) & 0xF) == CAM_ISP_PACKET_INIT_DEV) { prepare_hw_data->packet_opcode_type = CAM_ISP_PACKET_INIT_DEV; - if ((!ife_cfg->num_reg_dump_buf) || (ife_cfg->num_reg_dump_buf > + if ((!prepare->num_reg_dump_buf) || (prepare->num_reg_dump_buf > CAM_REG_DUMP_MAX_BUF_ENTRIES)) goto end; if (!ctx->num_reg_dump_buf) { - ctx->num_reg_dump_buf = ife_cfg->num_reg_dump_buf; + ctx->num_reg_dump_buf = prepare->num_reg_dump_buf; memcpy(ctx->reg_dump_buf_desc, - ife_cfg->reg_dump_buf_desc, + prepare->reg_dump_buf_desc, sizeof(struct cam_cmd_buf_desc) * - ife_cfg->num_reg_dump_buf); + prepare->num_reg_dump_buf); } else { prepare_hw_data->num_reg_dump_buf = - ife_cfg->num_reg_dump_buf; + prepare->num_reg_dump_buf; memcpy(prepare_hw_data->reg_dump_buf_desc, - ife_cfg->reg_dump_buf_desc, + prepare->reg_dump_buf_desc, sizeof(struct cam_cmd_buf_desc) * prepare_hw_data->num_reg_dump_buf); } @@ -6574,35 +6327,22 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, goto end; } else { prepare_hw_data->packet_opcode_type = CAM_ISP_PACKET_UPDATE_DEV; - prepare_hw_data->num_reg_dump_buf = ife_cfg->num_reg_dump_buf; + prepare_hw_data->num_reg_dump_buf = prepare->num_reg_dump_buf; if ((prepare_hw_data->num_reg_dump_buf) && (prepare_hw_data->num_reg_dump_buf < CAM_REG_DUMP_MAX_BUF_ENTRIES)) { memcpy(prepare_hw_data->reg_dump_buf_desc, - ife_cfg->reg_dump_buf_desc, + prepare->reg_dump_buf_desc, sizeof(struct cam_cmd_buf_desc) * prepare_hw_data->num_reg_dump_buf); } } - /* Add wait for comp event */ - if ((ctx->hw_version >= CAM_CPAS_TITAN_480_V100) && ctx->is_dual - && ctx->internal_cdm) { - for (i = 0; i < ctx->num_base; i++) { - if (ctx->master_slave[ctx->base[i].idx] == - CAM_IFE_RES_MASTER && - ctx->base[i].cdm_id == CAM_CDM_IFE) - rc = cam_isp_add_comp_wait(ife_cfg, - &ctx->res_list_ife_src, - ctx->base[i].idx, &kmd_buf); - } - } - /* add reg update commands */ for (i = 0; i < ctx->num_base; i++) { /* Add change base */ - if (!ctx->internal_cdm || ctx->base[i].cdm_id == CAM_CDM_CPAS) { - rc = cam_isp_add_change_base(ife_cfg, + if (!ctx->internal_cdm) { + rc = cam_isp_add_change_base(prepare, &ctx->res_list_ife_src, ctx->base[i].idx, &kmd_buf); @@ -6614,7 +6354,7 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, } } /*Add reg update */ - rc = cam_isp_add_reg_update(ife_cfg, &ctx->res_list_ife_src, + rc = cam_isp_add_reg_update(prepare, &ctx->res_list_ife_src, ctx->base[i].idx, &kmd_buf); if (rc) { @@ -6625,18 +6365,6 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv, } } - /* Add trigger_cdm_event */ - if ((ctx->hw_version >= CAM_CPAS_TITAN_480_V100) && ctx->is_dual - && ctx->internal_cdm) { - for (i = 0; i < ctx->num_base; i++) { - if (ctx->master_slave[ctx->base[i].idx] - == CAM_IFE_RES_SLAVE) - rc = cam_isp_add_wait_trigger(ife_cfg, - &ctx->res_list_ife_src, - ctx->base[i].idx, &kmd_buf, true); - } - } - end: return rc; } @@ -6768,7 +6496,7 @@ static void cam_ife_mgr_print_io_bufs(struct cam_packet *packet, static int cam_ife_mgr_cmd(void *hw_mgr_priv, void *cmd_args) { - int rc = 0, i = 0; + int rc = 0; struct cam_hw_cmd_args *hw_cmd_args = cmd_args; struct cam_ife_hw_mgr *hw_mgr = hw_mgr_priv; struct cam_ife_hw_mgr_ctx *ctx = (struct cam_ife_hw_mgr_ctx *) @@ -6776,7 +6504,6 @@ static int cam_ife_mgr_cmd(void *hw_mgr_priv, void *cmd_args) struct cam_isp_hw_cmd_args *isp_hw_cmd_args = NULL; struct cam_packet *packet; unsigned long rem_jiffies = 0; - uint32_t idx; if (!hw_mgr_priv || !cmd_args) { CAM_ERR(CAM_ISP, "Invalid arguments"); @@ -6850,17 +6577,12 @@ static int cam_ife_mgr_cmd(void *hw_mgr_priv, void *cmd_args) if (ctx->last_dump_flush_req_id == ctx->applied_req_id) return 0; - for (i = 0; i < ctx->num_base; i++) { - idx = ctx->base[i].idx; - rem_jiffies = wait_for_completion_timeout( - &ctx->config_done_complete[idx], - msecs_to_jiffies(5)); - if (rem_jiffies == 0) - CAM_ERR(CAM_ISP, - "config done completion timeout, Reg dump will be unreliable rc=%d ctx_index %d", - rc, ctx->ctx_index); - rc = 0; - } + rem_jiffies = wait_for_completion_timeout( + &ctx->config_done_complete, msecs_to_jiffies(30)); + if (rem_jiffies == 0) + CAM_ERR(CAM_ISP, + "config done completion timeout, Reg dump will be unreliable rc=%d ctx_index %d", + rc, ctx->ctx_index); ctx->last_dump_flush_req_id = ctx->applied_req_id; rc = cam_ife_mgr_handle_reg_dump(ctx, ctx->reg_dump_buf_desc, @@ -8023,10 +7745,7 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl) g_ife_hw_mgr.ctx_pool[i].common.tasklet_info = g_ife_hw_mgr.mgr_common.tasklet_pool[i]; - for (j = 0; j < CAM_IFE_HW_NUM_MAX; j++) - init_completion( - &g_ife_hw_mgr.ctx_pool[i] - .config_done_complete[j]); + init_completion(&g_ife_hw_mgr.ctx_pool[i].config_done_complete); list_add_tail(&g_ife_hw_mgr.ctx_pool[i].list, &g_ife_hw_mgr.free_ctx_list); } diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h index ca1648d616..6afc982ce4 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.h @@ -15,14 +15,6 @@ #include "cam_tasklet_util.h" #include "cam_cdm_intf_api.h" -/* enum cam_ife_res_master_slave - HW resource master/slave */ -enum cam_ife_res_master_slave { - CAM_IFE_RES_NONE, - CAM_IFE_RES_MASTER, - CAM_IFE_RES_SLAVE, - CAM_IFE_RES_MAX, -}; - /* IFE resource constants */ #define CAM_IFE_HW_IN_RES_MAX (CAM_ISP_IFE_IN_RES_MAX & 0xFF) #define CAM_IFE_HW_OUT_RES_MAX (CAM_ISP_IFE_OUT_RES_MAX & 0xFF) @@ -132,7 +124,7 @@ struct cam_ife_hw_mgr_ctx { uint32_t irq_status1_mask[CAM_IFE_HW_NUM_MAX]; struct cam_isp_ctx_base_info base[CAM_IFE_HW_NUM_MAX]; uint32_t num_base; - uint32_t cdm_handle[CAM_IFE_HW_NUM_MAX]; + uint32_t cdm_handle; struct cam_cdm_utils_ops *cdm_ops; struct cam_cdm_bl_request *cdm_cmd; @@ -142,9 +134,7 @@ struct cam_ife_hw_mgr_ctx { atomic_t overflow_pending; atomic_t cdm_done; uint32_t is_rdi_only_context; - struct completion config_done_complete[ - CAM_IFE_HW_NUM_MAX]; - enum cam_ife_res_master_slave master_slave[CAM_IFE_HW_NUM_MAX]; + struct completion config_done_complete; uint32_t hw_version; struct cam_cmd_buf_desc reg_dump_buf_desc[ CAM_REG_DUMP_MAX_BUF_ENTRIES]; diff --git a/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h b/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h index edd1d33be8..021ff70724 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h +++ b/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h @@ -10,7 +10,6 @@ #include "cam_isp_hw_mgr_intf.h" #include "cam_tasklet_util.h" #include "cam_isp_hw.h" -#include "cam_cdm_intf_api.h" #define CAM_ISP_HW_NUM_MAX 7 @@ -91,6 +90,5 @@ struct cam_isp_hw_mgr_res { struct cam_isp_ctx_base_info { uint32_t idx; enum cam_isp_hw_split_id split_id; - enum cam_cdm_id cdm_id; }; #endif /* _CAM_ISP_HW_MGR_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c index 41f2676332..7523c69961 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c @@ -1768,8 +1768,6 @@ static int cam_tfe_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) goto err; } - memset(&tfe_ctx->cdm_handle, 0, sizeof(tfe_ctx->cdm_handle)); - tfe_ctx->common.cb_priv = acquire_args->context_data; for (i = 0; i < CAM_ISP_HW_EVENT_MAX; i++) tfe_ctx->common.event_cb[i] = acquire_args->event_cb; @@ -2003,8 +2001,6 @@ static int cam_tfe_mgr_acquire_dev(void *hw_mgr_priv, void *acquire_hw_args) goto err; } - memset(&tfe_ctx->cdm_handle, 0, sizeof(tfe_ctx->cdm_handle)); - tfe_ctx->common.cb_priv = acquire_args->context_data; for (i = 0; i < CAM_ISP_HW_EVENT_MAX; i++) tfe_ctx->common.event_cb[i] = acquire_args->event_cb; @@ -2335,14 +2331,12 @@ static int cam_isp_tfe_blob_bw_update( static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, void *config_hw_args) { - int rc = -EINVAL, i, j, k = 0, skip = 0; - struct cam_isp_hw_config_args *cfg; + int rc = -EINVAL, i, skip = 0; + struct cam_hw_config_args *cfg; struct cam_hw_update_entry *cmd; struct cam_cdm_bl_request *cdm_cmd; struct cam_tfe_hw_mgr_ctx *ctx; struct cam_isp_prepare_hw_update_data *hw_update_data; - uint32_t num_ent; - struct cam_hw_update_entry *cfg_info; if (!hw_mgr_priv || !config_hw_args) { CAM_ERR(CAM_ISP, "Invalid arguments"); @@ -2387,80 +2381,74 @@ static int cam_tfe_mgr_config_hw(void *hw_mgr_priv, } } - CAM_DBG(CAM_ISP, "Enter ctx id:%d request id: %llu", - ctx->ctx_index, cfg->request_id); + CAM_DBG(CAM_ISP, + "Enter ctx id:%d num_hw_upd_entries %d request id: %llu", + ctx->ctx_index, cfg->num_hw_update_entries, cfg->request_id); - cdm_cmd = ctx->cdm_cmd; - cdm_cmd->type = CAM_CDM_BL_CMD_TYPE_MEM_HANDLE; - cdm_cmd->flag = true; - cdm_cmd->userdata = hw_update_data; - cdm_cmd->cookie = cfg->request_id; - cdm_cmd->gen_irq_arb = false; - cdm_cmd->cmd_arrary_count = 0; + if (cfg->num_hw_update_entries > 0) { + cdm_cmd = ctx->cdm_cmd; + cdm_cmd->cmd_arrary_count = cfg->num_hw_update_entries; + cdm_cmd->type = CAM_CDM_BL_CMD_TYPE_MEM_HANDLE; + cdm_cmd->flag = true; + cdm_cmd->userdata = hw_update_data; + cdm_cmd->cookie = cfg->request_id; + cdm_cmd->gen_irq_arb = false; - for (i = 0; i < ctx->num_base; i++) { - num_ent = cfg->hw_update_info[ctx->base[i].idx].num_hw_entries; - cfg_info = cfg->hw_update_info[ctx->base[i].idx].hw_entries; - if (num_ent > 0) { - for (j = 0 ; j < num_ent; j++) { - cmd = (cfg_info + j); - - if (cfg->reapply && - cmd->flags == CAM_ISP_IQ_BL) { - skip++; - continue; - } - - if (cmd->flags == CAM_ISP_UNUSED_BL || - cmd->flags >= CAM_ISP_BL_MAX) - CAM_ERR(CAM_ISP, - "Unexpected BL type %d", - cmd->flags); - - cdm_cmd->cmd[j - skip + k].bl_addr.mem_handle = - cmd->handle; - cdm_cmd->cmd[j - skip + k].offset = cmd->offset; - cdm_cmd->cmd[j - skip + k].len = cmd->len; - cdm_cmd->cmd[j - skip + k].arbitrate = false; + for (i = 0; i < cfg->num_hw_update_entries; i++) { + cmd = cfg->hw_update_entries + i; + if (cfg->reapply && cmd->flags == CAM_ISP_IQ_BL) { + skip++; + continue; } - cdm_cmd->cmd_arrary_count += num_ent - skip; - k = cdm_cmd->cmd_arrary_count; + + if (cmd->flags == CAM_ISP_UNUSED_BL || + cmd->flags >= CAM_ISP_BL_MAX) + CAM_ERR(CAM_ISP, "Unexpected BL type %d", + cmd->flags); + + cdm_cmd->cmd[i - skip].bl_addr.mem_handle = cmd->handle; + cdm_cmd->cmd[i - skip].offset = cmd->offset; + cdm_cmd->cmd[i - skip].len = cmd->len; + cdm_cmd->cmd[i - skip].arbitrate = false; } - } + cdm_cmd->cmd_arrary_count = cfg->num_hw_update_entries - skip; + reinit_completion(&ctx->config_done_complete); + ctx->applied_req_id = cfg->request_id; + CAM_DBG(CAM_ISP, "Submit to CDM"); - ctx->applied_req_id = cfg->request_id; - CAM_DBG(CAM_ISP, "Submit to CDM"); + atomic_set(&ctx->cdm_done, 0); - atomic_set(&ctx->cdm_done, 0); - reinit_completion(&ctx->config_done_complete); - rc = cam_cdm_submit_bls(ctx->cdm_handle, cdm_cmd); - if (rc) { - CAM_ERR(CAM_ISP, - "Failed to apply the configs for req %llu, rc %d", - cfg->request_id, rc); - return rc; - } - - if (cfg->init_packet) { - rc = wait_for_completion_timeout( - &ctx->config_done_complete, - msecs_to_jiffies( - CAM_TFE_HW_CONFIG_TIMEOUT)); - if (rc <= 0) { + rc = cam_cdm_submit_bls(ctx->cdm_handle, cdm_cmd); + if (rc) { CAM_ERR(CAM_ISP, - "config done completion timeout for req_id=%llu rc=%d ctx_index %d", - cfg->request_id, rc, - ctx->ctx_index); - if (rc == 0) - rc = -ETIMEDOUT; - } else { - rc = 0; - CAM_DBG(CAM_ISP, - "config done Success for req_id=%llu ctx_index %d", - cfg->request_id, - ctx->ctx_index); + "Failed to apply the configs for req %llu, rc %d", + cfg->request_id, rc); + return rc; } + + if (cfg->init_packet) { + rc = wait_for_completion_timeout( + &ctx->config_done_complete, + msecs_to_jiffies(CAM_TFE_HW_CONFIG_TIMEOUT)); + if (rc <= 0) { + CAM_ERR(CAM_ISP, + "config done completion timeout for req_id=%llu rc=%d ctx_index %d", + cfg->request_id, rc, + ctx->ctx_index); + if (rc == 0) + rc = -ETIMEDOUT; + } else { + rc = 0; + CAM_DBG(CAM_ISP, + "config done Success for req_id=%llu ctx_index %d", + cfg->request_id, + ctx->ctx_index); + } + } + } else { + CAM_ERR(CAM_ISP, "No commands to config"); } + CAM_DBG(CAM_ISP, "Exit: Config Done: %llu", cfg->request_id); return rc; @@ -3257,14 +3245,13 @@ static int cam_isp_tfe_blob_hfr_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_tfe_resource_hfr_config *hfr_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_isp_tfe_port_hfr_config *port_hfr_config; struct cam_kmd_buf_info *kmd_buf_info; struct cam_tfe_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; - uint32_t res_id_out, i, slot_idx = 0; + uint32_t res_id_out, i; uint32_t total_used_bytes = 0; uint32_t kmd_buf_remain_size; uint32_t *cmd_buf_addr; @@ -3274,15 +3261,11 @@ static int cam_isp_tfe_blob_hfr_update( ctx = prepare->ctxt_to_hw_map; CAM_DBG(CAM_ISP, "num_ports= %d", hfr_config->num_ports); - slot_idx = blob_info->base_info->idx; - hw_entry = prepare->hw_update_info[slot_idx].hw_entries; - num_ent = prepare->hw_update_info[slot_idx].num_hw_entries; - /* Max one hw entries required for hfr config update */ - if (prepare->hw_update_info[slot_idx].num_hw_entries + 1 >= + if (prepare->num_hw_update_entries + 1 >= prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d", - prepare->hw_update_info[slot_idx].num_hw_entries, + prepare->num_hw_update_entries, prepare->max_hw_update_entries); return -EINVAL; } @@ -3338,17 +3321,16 @@ static int cam_isp_tfe_blob_hfr_update( if (total_used_bytes) { /* Update the HW entries */ - hw_entry[num_ent].handle = + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = - total_used_bytes; - hw_entry[num_ent].offset = + prepare->hw_update_entries[num_ent].len = total_used_bytes; + prepare->hw_update_entries[num_ent].offset = kmd_buf_info->offset; num_ent++; kmd_buf_info->used_bytes += total_used_bytes; kmd_buf_info->offset += total_used_bytes; - prepare->hw_update_info[slot_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; } return rc; @@ -3358,7 +3340,7 @@ static int cam_isp_tfe_blob_csid_clock_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_tfe_csid_clock_config *clock_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_tfe_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -3422,7 +3404,7 @@ static int cam_isp_tfe_blob_clock_update( uint32_t blob_type, struct cam_isp_generic_blob_info *blob_info, struct cam_isp_tfe_clock_config *clock_config, - struct cam_isp_hw_update_args *prepare) + struct cam_hw_prepare_update_args *prepare) { struct cam_tfe_hw_mgr_ctx *ctx = NULL; struct cam_isp_hw_mgr_res *hw_mgr_res; @@ -3511,7 +3493,7 @@ static int cam_isp_tfe_packet_generic_blob_handler(void *user_data, { int rc = 0; struct cam_isp_generic_blob_info *blob_info = user_data; - struct cam_isp_hw_update_args *prepare = NULL; + struct cam_hw_prepare_update_args *prepare = NULL; if (!blob_data || (blob_size == 0) || !blob_info) { CAM_ERR(CAM_ISP, "Invalid args data %pK size %d info %pK", @@ -3713,7 +3695,6 @@ static int cam_isp_tfe_packet_generic_blob_handler(void *user_data, } static int cam_tfe_update_dual_config( - struct cam_isp_hw_update_args *prepare, struct cam_cmd_buf_desc *cmd_desc, uint32_t split_id, uint32_t base_idx, @@ -3822,7 +3803,7 @@ end: } int cam_tfe_add_command_buffers( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct cam_kmd_buf_info *kmd_buf_info, struct cam_isp_ctx_base_info *base_info, cam_packet_generic_blob_handler blob_handler_cb, @@ -3835,12 +3816,10 @@ int cam_tfe_add_command_buffers( enum cam_isp_hw_split_id split_id; struct cam_cmd_buf_desc *cmd_desc = NULL; struct cam_hw_update_entry *hw_entry = NULL; - struct cam_isp_hw_update_entry_info *hw_info; split_id = base_info->split_id; base_idx = base_info->idx; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - hw_info = prepare->hw_update_info; + hw_entry = prepare->hw_update_entries; /* * set the cmd_desc to point the first command descriptor in the * packet @@ -3853,7 +3832,7 @@ int cam_tfe_add_command_buffers( split_id, prepare->packet->num_cmd_buf); for (i = 0; i < prepare->packet->num_cmd_buf; i++) { - num_ent = prepare->hw_update_info[base_idx].num_hw_entries; + num_ent = prepare->num_hw_update_entries; if (!cmd_desc[i].length) continue; @@ -3928,9 +3907,8 @@ int cam_tfe_add_command_buffers( break; case CAM_ISP_TFE_PACKET_META_DUAL_CONFIG: - rc = cam_tfe_update_dual_config(prepare, - &cmd_desc[i], split_id, base_idx, - res_list_isp_out, size_isp_out); + rc = cam_tfe_update_dual_config(&cmd_desc[i], split_id, + base_idx, res_list_isp_out, size_isp_out); if (rc) return rc; @@ -3938,8 +3916,7 @@ int cam_tfe_add_command_buffers( case CAM_ISP_TFE_PACKET_META_GENERIC_BLOB_COMMON: { struct cam_isp_generic_blob_info blob_info; - prepare->hw_update_info[base_idx].num_hw_entries = - num_ent; + prepare->num_hw_update_entries = num_ent; blob_info.prepare = prepare; blob_info.base_info = base_info; blob_info.kmd_buf_info = kmd_buf_info; @@ -3954,7 +3931,7 @@ int cam_tfe_add_command_buffers( return rc; } hw_entry[num_ent].flags = CAM_ISP_IQ_BL; - num_ent = hw_info[base_idx].num_hw_entries; + num_ent = prepare->num_hw_update_entries; } break; case CAM_ISP_TFE_PACKET_META_REG_DUMP_ON_FLUSH: @@ -3983,8 +3960,7 @@ int cam_tfe_add_command_buffers( cmd_meta_data); return -EINVAL; } - prepare->hw_update_info[base_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; } return rc; @@ -3994,8 +3970,8 @@ static int cam_tfe_mgr_prepare_hw_update(void *hw_mgr_priv, void *prepare_hw_update_args) { int rc = 0; - struct cam_isp_hw_update_args *prepare = - (struct cam_isp_hw_update_args *) prepare_hw_update_args; + struct cam_hw_prepare_update_args *prepare = + (struct cam_hw_prepare_update_args *) prepare_hw_update_args; struct cam_tfe_hw_mgr_ctx *ctx; struct cam_tfe_hw_mgr *hw_mgr; struct cam_kmd_buf_info kmd_buf; @@ -4036,6 +4012,7 @@ static int cam_tfe_mgr_prepare_hw_update(void *hw_mgr_priv, return rc; } + prepare->num_hw_update_entries = 0; prepare->num_in_map_entries = 0; prepare->num_out_map_entries = 0; prepare->num_reg_dump_buf = 0; diff --git a/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c b/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c index c4931d85e7..c498233f48 100644 --- a/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c +++ b/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c @@ -13,7 +13,7 @@ #include "cam_isp_hw_mgr_intf.h" int cam_isp_add_change_base( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info) @@ -25,8 +25,8 @@ int cam_isp_add_change_base( struct cam_hw_update_entry *hw_entry; uint32_t num_ent, i; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - num_ent = prepare->hw_update_info[base_idx].num_hw_entries; + hw_entry = prepare->hw_update_entries; + num_ent = prepare->num_hw_update_entries; /* Max one hw entries required for each base */ if (num_ent + 1 >= prepare->max_hw_update_entries) { @@ -77,8 +77,7 @@ int cam_isp_add_change_base( kmd_buf_info->used_bytes += get_base.cmd.used_bytes; kmd_buf_info->offset += get_base.cmd.used_bytes; num_ent++; - prepare->hw_update_info[base_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; /* return success */ return 0; @@ -89,7 +88,6 @@ int cam_isp_add_change_base( } static int cam_isp_update_dual_config( - struct cam_isp_hw_update_args *prepare, struct cam_cmd_buf_desc *cmd_desc, uint32_t split_id, uint32_t base_idx, @@ -243,7 +241,7 @@ int cam_isp_add_cmd_buf_update( } int cam_isp_add_command_buffers( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct cam_kmd_buf_info *kmd_buf_info, struct cam_isp_ctx_base_info *base_info, cam_packet_generic_blob_handler blob_handler_cb, @@ -256,12 +254,11 @@ int cam_isp_add_command_buffers( enum cam_isp_hw_split_id split_id; struct cam_cmd_buf_desc *cmd_desc = NULL; struct cam_hw_update_entry *hw_entry = NULL; - struct cam_isp_hw_update_entry_info *hw_info; split_id = base_info->split_id; base_idx = base_info->idx; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - hw_info = prepare->hw_update_info; + hw_entry = prepare->hw_update_entries; + /* * set the cmd_desc to point the first command descriptor in the * packet @@ -274,8 +271,7 @@ int cam_isp_add_command_buffers( split_id, prepare->packet->num_cmd_buf); for (i = 0; i < prepare->packet->num_cmd_buf; i++) { - num_ent = - prepare->hw_update_info[base_idx].num_hw_entries; + num_ent = prepare->num_hw_update_entries; if (!cmd_desc[i].length) continue; @@ -351,8 +347,8 @@ int cam_isp_add_command_buffers( num_ent++; break; case CAM_ISP_PACKET_META_DUAL_CONFIG: - rc = cam_isp_update_dual_config(prepare, - &cmd_desc[i], split_id, base_idx, + rc = cam_isp_update_dual_config(&cmd_desc[i], + split_id, base_idx, res_list_isp_out, size_isp_out); if (rc) @@ -362,8 +358,7 @@ int cam_isp_add_command_buffers( if (split_id == CAM_ISP_HW_SPLIT_LEFT) { struct cam_isp_generic_blob_info blob_info; - prepare->hw_update_info[base_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; blob_info.prepare = prepare; blob_info.base_info = base_info; blob_info.kmd_buf_info = kmd_buf_info; @@ -379,15 +374,14 @@ int cam_isp_add_command_buffers( return rc; } hw_entry[num_ent].flags = CAM_ISP_IQ_BL; - num_ent = hw_info[base_idx].num_hw_entries; + num_ent = prepare->num_hw_update_entries; } break; case CAM_ISP_PACKET_META_GENERIC_BLOB_RIGHT: if (split_id == CAM_ISP_HW_SPLIT_RIGHT) { struct cam_isp_generic_blob_info blob_info; - prepare->hw_update_info[base_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; blob_info.prepare = prepare; blob_info.base_info = base_info; blob_info.kmd_buf_info = kmd_buf_info; @@ -403,14 +397,13 @@ int cam_isp_add_command_buffers( return rc; } hw_entry[num_ent].flags = CAM_ISP_IQ_BL; - num_ent = hw_info[base_idx].num_hw_entries; + num_ent = prepare->num_hw_update_entries; } break; case CAM_ISP_PACKET_META_GENERIC_BLOB_COMMON: { struct cam_isp_generic_blob_info blob_info; - prepare->hw_update_info[base_idx].num_hw_entries = - num_ent; + prepare->num_hw_update_entries = num_ent; blob_info.prepare = prepare; blob_info.base_info = base_info; blob_info.kmd_buf_info = kmd_buf_info; @@ -425,7 +418,7 @@ int cam_isp_add_command_buffers( return rc; } hw_entry[num_ent].flags = CAM_ISP_IQ_BL; - num_ent = hw_info[base_idx].num_hw_entries; + num_ent = prepare->num_hw_update_entries; } break; case CAM_ISP_PACKET_META_REG_DUMP_ON_FLUSH: @@ -455,8 +448,7 @@ int cam_isp_add_command_buffers( cmd_meta_data); return -EINVAL; } - prepare->hw_update_info[base_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; } return rc; @@ -465,7 +457,7 @@ int cam_isp_add_command_buffers( int cam_isp_add_io_buffers( int iommu_hdl, int sec_iommu_hdl, - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info, struct cam_isp_hw_mgr_res *res_list_isp_out, @@ -481,7 +473,6 @@ int cam_isp_add_io_buffers( struct cam_isp_hw_mgr_res *hw_mgr_res; struct cam_isp_hw_get_cmd_update update_buf; struct cam_isp_hw_get_wm_update wm_update; - struct cam_hw_update_entry *hw_entry; struct cam_isp_hw_get_wm_update bus_rd_update; struct cam_hw_fence_map_entry *out_map_entries; struct cam_hw_fence_map_entry *in_map_entries; @@ -504,14 +495,12 @@ int cam_isp_add_io_buffers( num_in_buf = 0; io_cfg_used_bytes = 0; prepare->pf_data->packet = prepare->packet; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - num_ent = prepare->hw_update_info[base_idx].num_hw_entries; /* Max one hw entries required for each base */ - if (num_ent + 1 >= + if (prepare->num_hw_update_entries + 1 >= prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d", - prepare->hw_update_info[base_idx].num_hw_entries, + prepare->num_hw_update_entries, prepare->max_hw_update_entries); return -EINVAL; } @@ -863,21 +852,25 @@ int cam_isp_add_io_buffers( io_cfg_used_bytes, fill_fence); if (io_cfg_used_bytes) { /* Update the HW entries */ - hw_entry[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = io_cfg_used_bytes; - hw_entry[num_ent].offset = kmd_buf_info->offset; - hw_entry[num_ent].flags = CAM_ISP_IOCFG_BL; + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = + kmd_buf_info->handle; + prepare->hw_update_entries[num_ent].len = + io_cfg_used_bytes; + prepare->hw_update_entries[num_ent].offset = + kmd_buf_info->offset; + prepare->hw_update_entries[num_ent].flags = CAM_ISP_IOCFG_BL; CAM_DBG(CAM_ISP, "num_ent=%d handle=0x%x, len=%u, offset=%u", num_ent, - hw_entry[num_ent].handle, - hw_entry[num_ent].len, - hw_entry[num_ent].offset); + prepare->hw_update_entries[num_ent].handle, + prepare->hw_update_entries[num_ent].len, + prepare->hw_update_entries[num_ent].offset); num_ent++; kmd_buf_info->used_bytes += io_cfg_used_bytes; kmd_buf_info->offset += io_cfg_used_bytes; - prepare->hw_update_info[base_idx].num_hw_entries = num_ent; + prepare->num_hw_update_entries = num_ent; } if (fill_fence) { @@ -889,7 +882,7 @@ int cam_isp_add_io_buffers( } int cam_isp_add_reg_update( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info) @@ -897,17 +890,14 @@ int cam_isp_add_reg_update( int rc = -EINVAL; struct cam_isp_resource_node *res; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; struct cam_isp_hw_get_cmd_update get_regup; uint32_t kmd_buf_remain_size, num_ent, i, reg_update_size; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - num_ent = prepare->hw_update_info[base_idx].num_hw_entries; - /* Max one hw entries required for each base */ - if (num_ent + 1 >= prepare->max_hw_update_entries) { + if (prepare->num_hw_update_entries + 1 >= + prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d", - num_ent, + prepare->num_hw_update_entries, prepare->max_hw_update_entries); return -EINVAL; } @@ -962,23 +952,26 @@ int cam_isp_add_reg_update( if (reg_update_size) { /* Update the HW entries */ - hw_entry[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = reg_update_size; - hw_entry[num_ent].offset = kmd_buf_info->offset; + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = + kmd_buf_info->handle; + prepare->hw_update_entries[num_ent].len = reg_update_size; + prepare->hw_update_entries[num_ent].offset = + kmd_buf_info->offset; /* Marking reg update as IOCFG to reapply on bubble */ - hw_entry[num_ent].flags = CAM_ISP_IOCFG_BL; + prepare->hw_update_entries[num_ent].flags = CAM_ISP_IOCFG_BL; CAM_DBG(CAM_ISP, "num_ent=%d handle=0x%x, len=%u, offset=%u", num_ent, - hw_entry[num_ent].handle, - hw_entry[num_ent].len, - hw_entry[num_ent].offset); + prepare->hw_update_entries[num_ent].handle, + prepare->hw_update_entries[num_ent].len, + prepare->hw_update_entries[num_ent].offset); num_ent++; kmd_buf_info->used_bytes += reg_update_size; kmd_buf_info->offset += reg_update_size; - prepare->hw_update_info[base_idx].num_hw_entries = num_ent; + prepare->num_hw_update_entries = num_ent; /* reg update is success return status 0 */ rc = 0; } @@ -987,7 +980,7 @@ int cam_isp_add_reg_update( } int cam_isp_add_go_cmd( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_rd, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info) @@ -995,17 +988,14 @@ int cam_isp_add_go_cmd( int rc = -EINVAL; struct cam_isp_resource_node *res; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; struct cam_isp_hw_get_cmd_update get_regup; uint32_t kmd_buf_remain_size, num_ent, i, reg_update_size; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - num_ent = prepare->hw_update_info[base_idx].num_hw_entries; - /* Max one hw entries required for each base */ - if (num_ent + 1 >= prepare->max_hw_update_entries) { + if (prepare->num_hw_update_entries + 1 >= + prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d", - num_ent, + prepare->num_hw_update_entries, prepare->max_hw_update_entries); return -EINVAL; } @@ -1058,22 +1048,24 @@ int cam_isp_add_go_cmd( if (reg_update_size) { /* Update the HW entries */ - hw_entry[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = reg_update_size; - hw_entry[num_ent].offset = kmd_buf_info->offset; - - hw_entry[num_ent].flags = CAM_ISP_IOCFG_BL; + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = + kmd_buf_info->handle; + prepare->hw_update_entries[num_ent].len = reg_update_size; + prepare->hw_update_entries[num_ent].offset = + kmd_buf_info->offset; + prepare->hw_update_entries[num_ent].flags = CAM_ISP_IOCFG_BL; CAM_DBG(CAM_ISP, "num_ent=%d handle=0x%x, len=%u, offset=%u", num_ent, - hw_entry[num_ent].handle, - hw_entry[num_ent].len, - hw_entry[num_ent].offset); + prepare->hw_update_entries[num_ent].handle, + prepare->hw_update_entries[num_ent].len, + prepare->hw_update_entries[num_ent].offset); num_ent++; kmd_buf_info->used_bytes += reg_update_size; kmd_buf_info->offset += reg_update_size; - prepare->hw_update_info[base_idx].num_hw_entries = num_ent; + prepare->num_hw_update_entries = num_ent; rc = 0; } @@ -1082,24 +1074,20 @@ int cam_isp_add_go_cmd( } int cam_isp_add_comp_wait( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info) { int rc = -EINVAL; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; struct cam_isp_hw_get_cmd_update add_wait; struct cam_hw_intf *hw_intf; bool hw_res_valid = false; uint32_t kmd_buf_remain_size, num_ent, add_wait_size; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - num_ent = prepare->hw_update_info[base_idx].num_hw_entries; - /* Max one hw entries required for each base */ - if (num_ent >= prepare->max_hw_update_entries) { + if (prepare->num_hw_update_entries >= prepare->max_hw_update_entries) { CAM_ERR(CAM_ISP, "Insufficient HW entries"); return -EINVAL; } @@ -1157,25 +1145,24 @@ int cam_isp_add_comp_wait( add_wait_size += add_wait.cmd.used_bytes; if (add_wait_size) { /* Update the HW entries */ - hw_entry[num_ent].handle = + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = - add_wait_size; - hw_entry[num_ent].offset = + prepare->hw_update_entries[num_ent].len = add_wait_size; + prepare->hw_update_entries[num_ent].offset = kmd_buf_info->offset; - hw_entry[num_ent].flags = CAM_ISP_IOCFG_BL; + prepare->hw_update_entries[num_ent].flags = CAM_ISP_IOCFG_BL; CAM_DBG(CAM_ISP, "num_ent=%d handle=0x%x, len=%u, offset=%u", num_ent, - hw_entry[num_ent].handle, - hw_entry[num_ent].len, - hw_entry[num_ent].offset); + prepare->hw_update_entries[num_ent].handle, + prepare->hw_update_entries[num_ent].len, + prepare->hw_update_entries[num_ent].offset); num_ent++; kmd_buf_info->used_bytes += add_wait_size; kmd_buf_info->offset += add_wait_size; - prepare->hw_update_info[base_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; /* add wait_comp_event is success return status 0 */ rc = 0; } @@ -1184,7 +1171,7 @@ int cam_isp_add_comp_wait( } int cam_isp_add_wait_trigger( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info, @@ -1192,19 +1179,15 @@ int cam_isp_add_wait_trigger( { int rc = -EINVAL; struct cam_isp_hw_mgr_res *hw_mgr_res; - struct cam_hw_update_entry *hw_entry; struct cam_isp_hw_get_cmd_update add_trigger; struct cam_hw_intf *hw_intf; bool hw_res_valid = false; uint32_t kmd_buf_remain_size, num_ent, add_trigger_size; - hw_entry = prepare->hw_update_info[base_idx].hw_entries; - num_ent = prepare->hw_update_info[base_idx].num_hw_entries; - /* Max one hw entries required for each base */ - if (num_ent + 1 >= + if (prepare->num_hw_update_entries + 1 >= prepare->max_hw_update_entries) { - CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d"); + CAM_ERR(CAM_ISP, "Insufficient HW entries"); return -EINVAL; } @@ -1247,11 +1230,6 @@ int cam_isp_add_wait_trigger( add_trigger.cmd_type = CAM_ISP_HW_CMD_ADD_WAIT_TRIGGER; add_trigger.res = hw_mgr_res->hw_res[CAM_ISP_HW_SPLIT_RIGHT]; - if (trigger_cdm_en) - add_trigger.trigger_cdm_en = true; - else - add_trigger.trigger_cdm_en = false; - rc = hw_intf->hw_ops.process_cmd( hw_intf->hw_priv, CAM_ISP_HW_CMD_ADD_WAIT_TRIGGER, @@ -1268,25 +1246,24 @@ int cam_isp_add_wait_trigger( if (add_trigger_size) { /* Update the HW entries */ - hw_entry[num_ent].handle = + num_ent = prepare->num_hw_update_entries; + prepare->hw_update_entries[num_ent].handle = kmd_buf_info->handle; - hw_entry[num_ent].len = - add_trigger_size; - hw_entry[num_ent].offset = + prepare->hw_update_entries[num_ent].len = add_trigger_size; + prepare->hw_update_entries[num_ent].offset = kmd_buf_info->offset; - hw_entry[num_ent].flags = CAM_ISP_IOCFG_BL; + prepare->hw_update_entries[num_ent].flags = CAM_ISP_IOCFG_BL; CAM_DBG(CAM_ISP, "num_ent=%d handle=0x%x, len=%u, offset=%u", num_ent, - hw_entry[num_ent].handle, - hw_entry[num_ent].len, - hw_entry[num_ent].offset); + prepare->hw_update_entries[num_ent].handle, + prepare->hw_update_entries[num_ent].len, + prepare->hw_update_entries[num_ent].offset); num_ent++; kmd_buf_info->used_bytes += add_trigger_size; kmd_buf_info->offset += add_trigger_size; - prepare->hw_update_info[base_idx].num_hw_entries - = num_ent; + prepare->num_hw_update_entries = num_ent; /* add wait trigger is success return status 0 */ rc = 0; } diff --git a/drivers/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h b/drivers/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h index 3c13ee52ae..1be8507e20 100644 --- a/drivers/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h +++ b/drivers/cam_isp/isp_hw_mgr/hw_utils/include/cam_isp_packet_parser.h @@ -29,7 +29,7 @@ enum cam_isp_cdm_bl_type { * @kmd_buf_info: Kmd buffer to store the custom cmd data */ struct cam_isp_generic_blob_info { - struct cam_isp_hw_update_args *prepare; + struct cam_hw_prepare_update_args *prepare; struct cam_isp_ctx_base_info *base_info; struct cam_kmd_buf_info *kmd_buf_info; }; @@ -63,7 +63,7 @@ struct cam_isp_frame_header_info { * -EINVAL for Fail */ int cam_isp_add_change_base( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info); @@ -115,7 +115,7 @@ int cam_isp_add_cmd_buf_update( * Negative for Failure */ int cam_isp_add_command_buffers( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct cam_kmd_buf_info *kmd_buf_info, struct cam_isp_ctx_base_info *base_info, cam_packet_generic_blob_handler blob_handler_cb, @@ -146,7 +146,7 @@ int cam_isp_add_command_buffers( int cam_isp_add_io_buffers( int iommu_hdl, int sec_iommu_hdl, - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info, struct cam_isp_hw_mgr_res *res_list_isp_out, @@ -170,7 +170,7 @@ int cam_isp_add_io_buffers( * -EINVAL for Fail */ int cam_isp_add_reg_update( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info); @@ -191,7 +191,7 @@ int cam_isp_add_reg_update( * -EINVAL for Fail */ int cam_isp_add_comp_wait( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info); @@ -213,7 +213,7 @@ int cam_isp_add_comp_wait( * -EINVAL for Fail */ int cam_isp_add_wait_trigger( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_src, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info, @@ -233,7 +233,7 @@ int cam_isp_add_wait_trigger( * -EINVAL for Fail */ int cam_isp_add_go_cmd( - struct cam_isp_hw_update_args *prepare, + struct cam_hw_prepare_update_args *prepare, struct list_head *res_list_isp_rd, uint32_t base_idx, struct cam_kmd_buf_info *kmd_buf_info); diff --git a/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h b/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h index 2ed1f8b211..36e0b7e1be 100644 --- a/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h +++ b/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h @@ -23,12 +23,6 @@ /* Appliacble vote paths for dual ife, based on no. of UAPI definitions */ #define CAM_ISP_MAX_PER_PATH_VOTES 30 -/* - * Maximum configuration entry size - This is based on the - * worst case DUAL IFE use case plus some margin. - */ - #define CAM_ISP_CTX_CFG_MAX 25 - /** * enum cam_isp_hw_event_type - Collection of the ISP hardware events */ @@ -257,94 +251,6 @@ struct cam_isp_hw_cmd_args { } u; }; -/** - * struct cam_isp_hw_update_entry_info - hardware config info - * - * @hw_update_entries Entry for hardware config - * @num_hw_update_entries: Number of IFE hw - * - */ -struct cam_isp_hw_update_entry_info { - struct cam_hw_update_entry *hw_entries; - uint32_t num_hw_entries; -}; - -/** - * struct cam_isp_hw_update_info - hardware config info - * - * @hw_update_entries Entry for hardware config - * @num_hw_update_entries: number of IFE hw - * - */ - -struct cam_isp_hw_update_info { - struct cam_hw_update_entry hw_entries[CAM_ISP_CTX_CFG_MAX]; - uint32_t num_hw_entries; -}; - -/** - * struct cam_isp_hw_update_args - Payload for prepare command - * - * @packet: CSL packet from user mode driver - * @remain_len Remaining length of CPU buffer after config offset - * @ctxt_to_hw_map: HW context from the acquire - * @max_hw_update_entries: Maximum hardware update entries supported - * @hw_update_info: Actual hardware update configuration (returned) - * @max_out_map_entries: Maximum output fence mapping supported - * @out_map_entries: Actual output fence mapping list (returned) - * @num_out_map_entries: Number of actual output fence mapping (returned) - * @max_in_map_entries: Maximum input fence mapping supported - * @in_map_entries: Actual input fence mapping list (returned) - * @num_in_map_entries: Number of acutal input fence mapping (returned) - * @priv: Private pointer of hw update - * @pf_data: Debug data for page fault - * - */ - -struct cam_isp_hw_update_args { - struct cam_packet *packet; - uint32_t remain_len; - void *ctxt_to_hw_map; - uint32_t max_hw_update_entries; - struct cam_isp_hw_update_entry_info hw_update_info[CAM_IFE_HW_NUM_MAX]; - uint32_t max_out_map_entries; - struct cam_hw_fence_map_entry *out_map_entries; - uint32_t num_out_map_entries; - uint32_t max_in_map_entries; - struct cam_hw_fence_map_entry *in_map_entries; - uint32_t num_in_map_entries; - void *priv; - struct cam_hw_mgr_dump_pf_data *pf_data; - struct cam_cmd_buf_desc reg_dump_buf_desc[ - CAM_REG_DUMP_MAX_BUF_ENTRIES]; - uint32_t num_reg_dump_buf; -}; - -/** - * struct cam_isp_hw_config_args - Payload for config command - * - * @ctxt_to_hw_map: HW context from the acquire - * @hw_update_info: Hardware update info for every IFE - * @out_map_entries: Out map info - * @num_out_map_entries: Number of out map entries - * @priv: Private pointer - * @request_id: Request ID - * @init_packet: check init packet or update packet - * @reapply: check if current req is reapplied - * - */ - -struct cam_isp_hw_config_args { - void *ctxt_to_hw_map; - struct cam_isp_hw_update_entry_info hw_update_info[CAM_IFE_HW_NUM_MAX]; - struct cam_hw_fence_map_entry *out_map_entries; - uint32_t num_out_map_entries; - void *priv; - uint64_t request_id; - bool init_packet; - bool reapply; -}; - /** * struct cam_isp_start_args - isp hardware start arguments * @@ -354,8 +260,8 @@ struct cam_isp_hw_config_args { * */ struct cam_isp_start_args { - struct cam_isp_hw_config_args hw_config; - bool start_only; + struct cam_hw_config_args hw_config; + bool start_only; }; /**