|
@@ -191,27 +191,19 @@ end:
|
|
}
|
|
}
|
|
|
|
|
|
int cam_isp_add_cmd_buf_update(
|
|
int cam_isp_add_cmd_buf_update(
|
|
- struct cam_isp_hw_mgr_res *hw_mgr_res,
|
|
|
|
|
|
+ struct cam_isp_resource_node *res,
|
|
|
|
+ struct cam_hw_intf *hw_intf,
|
|
uint32_t cmd_type,
|
|
uint32_t cmd_type,
|
|
uint32_t hw_cmd_type,
|
|
uint32_t hw_cmd_type,
|
|
- uint32_t base_idx,
|
|
|
|
uint32_t *cmd_buf_addr,
|
|
uint32_t *cmd_buf_addr,
|
|
uint32_t kmd_buf_remain_size,
|
|
uint32_t kmd_buf_remain_size,
|
|
void *cmd_update_data,
|
|
void *cmd_update_data,
|
|
uint32_t *bytes_used)
|
|
uint32_t *bytes_used)
|
|
{
|
|
{
|
|
int rc = 0;
|
|
int rc = 0;
|
|
- struct cam_isp_resource_node *res;
|
|
|
|
struct cam_isp_hw_get_cmd_update cmd_update;
|
|
struct cam_isp_hw_get_cmd_update cmd_update;
|
|
- uint32_t i;
|
|
|
|
uint32_t total_used_bytes = 0;
|
|
uint32_t total_used_bytes = 0;
|
|
|
|
|
|
- if (hw_mgr_res->res_type == CAM_ISP_RESOURCE_UNINT) {
|
|
|
|
- CAM_ERR(CAM_ISP, "VFE out resource:0x%X type:%d not valid",
|
|
|
|
- hw_mgr_res->res_id, hw_mgr_res->res_type);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
cmd_update.cmd_type = hw_cmd_type;
|
|
cmd_update.cmd_type = hw_cmd_type;
|
|
cmd_update.cmd.cmd_buf_addr = cmd_buf_addr;
|
|
cmd_update.cmd.cmd_buf_addr = cmd_buf_addr;
|
|
cmd_update.cmd.size = kmd_buf_remain_size;
|
|
cmd_update.cmd.size = kmd_buf_remain_size;
|
|
@@ -222,30 +214,20 @@ int cam_isp_add_cmd_buf_update(
|
|
cmd_update.cmd.cmd_buf_addr,
|
|
cmd_update.cmd.cmd_buf_addr,
|
|
cmd_update.cmd.size);
|
|
cmd_update.cmd.size);
|
|
|
|
|
|
- for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) {
|
|
|
|
- if (!hw_mgr_res->hw_res[i])
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- if (hw_mgr_res->hw_res[i]->hw_intf->hw_idx != base_idx)
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- res = hw_mgr_res->hw_res[i];
|
|
|
|
- cmd_update.res = res;
|
|
|
|
-
|
|
|
|
- rc = res->hw_intf->hw_ops.process_cmd(
|
|
|
|
- res->hw_intf->hw_priv,
|
|
|
|
- cmd_update.cmd_type, &cmd_update,
|
|
|
|
- sizeof(struct cam_isp_hw_get_cmd_update));
|
|
|
|
-
|
|
|
|
- if (rc) {
|
|
|
|
- CAM_ERR(CAM_ISP, "get buf cmd error:%d",
|
|
|
|
- res->res_id);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
|
|
+ cmd_update.res = res;
|
|
|
|
+ rc = hw_intf->hw_ops.process_cmd(
|
|
|
|
+ hw_intf->hw_priv,
|
|
|
|
+ cmd_update.cmd_type, &cmd_update,
|
|
|
|
+ sizeof(struct cam_isp_hw_get_cmd_update));
|
|
|
|
|
|
- total_used_bytes += cmd_update.cmd.used_bytes;
|
|
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "get buf cmd error:%d cmd %d", hw_intf->hw_idx,
|
|
|
|
+ cmd_update.cmd_type);
|
|
|
|
+ rc = -ENOMEM;
|
|
|
|
+ return rc;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ total_used_bytes += cmd_update.cmd.used_bytes;
|
|
*bytes_used = total_used_bytes;
|
|
*bytes_used = total_used_bytes;
|
|
CAM_DBG(CAM_ISP, "total_used_bytes %u", total_used_bytes);
|
|
CAM_DBG(CAM_ISP, "total_used_bytes %u", total_used_bytes);
|
|
return rc;
|
|
return rc;
|
|
@@ -710,491 +692,388 @@ static void cam_isp_validate_for_ife_scratch(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-int cam_isp_add_io_buffers(
|
|
|
|
- int iommu_hdl,
|
|
|
|
- int sec_iommu_hdl,
|
|
|
|
- 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,
|
|
|
|
- struct list_head *res_list_in_rd,
|
|
|
|
- uint32_t out_base,
|
|
|
|
- uint32_t out_max,
|
|
|
|
- bool fill_fence,
|
|
|
|
- enum cam_isp_hw_type hw_type,
|
|
|
|
- struct cam_isp_frame_header_info *frame_header_info,
|
|
|
|
- struct cam_isp_check_io_cfg_for_scratch *scratch_check_cfg)
|
|
|
|
|
|
+static inline void cam_isp_update_hw_entries_util(
|
|
|
|
+ enum cam_isp_cdm_bl_type cdm_bl_type,
|
|
|
|
+ struct cam_kmd_buf_info *kmd_buf_info,
|
|
|
|
+ uint32_t used_bytes,
|
|
|
|
+ uint32_t offset,
|
|
|
|
+ struct cam_hw_prepare_update_args *prepare)
|
|
{
|
|
{
|
|
|
|
+ uint32_t num_ent;
|
|
|
|
+
|
|
|
|
+ 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 = used_bytes;
|
|
|
|
+ prepare->hw_update_entries[num_ent].offset = offset;
|
|
|
|
+ prepare->hw_update_entries[num_ent].flags = cdm_bl_type;
|
|
|
|
+
|
|
|
|
+ num_ent++;
|
|
|
|
+ prepare->num_hw_update_entries = num_ent;
|
|
|
|
+
|
|
|
|
+ CAM_DBG(CAM_ISP, "Handle: 0x%x len: %u offset: %u flags: %u num_ent: %u",
|
|
|
|
+ prepare->hw_update_entries[num_ent - 1].handle,
|
|
|
|
+ prepare->hw_update_entries[num_ent - 1].len,
|
|
|
|
+ prepare->hw_update_entries[num_ent - 1].offset,
|
|
|
|
+ prepare->hw_update_entries[num_ent - 1].flags,
|
|
|
|
+ num_ent - 1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int cam_isp_io_buf_get_entries_util(
|
|
|
|
+ struct cam_isp_io_buf_info *buf_info,
|
|
|
|
+ struct cam_buf_io_cfg *io_cfg,
|
|
|
|
+ struct cam_isp_hw_mgr_res **hw_mgr_res)
|
|
|
|
+{
|
|
|
|
+ uint32_t res_id;
|
|
|
|
+ uint32_t num_entries;
|
|
|
|
+ struct cam_hw_fence_map_entry *map_entries = NULL;
|
|
|
|
+ struct cam_isp_hw_mgr_res *hw_mgr_res_temp;
|
|
|
|
+ bool found = false;
|
|
|
|
+
|
|
|
|
+ CAM_DBG(CAM_REQ,
|
|
|
|
+ "req_id %llu resource_type:%d fence:%d direction %d format %d",
|
|
|
|
+ buf_info->prepare->packet->header.request_id,
|
|
|
|
+ io_cfg->resource_type, io_cfg->fence,
|
|
|
|
+ io_cfg->direction, io_cfg->format);
|
|
|
|
+
|
|
|
|
+ if (io_cfg->direction == CAM_BUF_OUTPUT) {
|
|
|
|
+ res_id = io_cfg->resource_type & 0xFF;
|
|
|
|
+
|
|
|
|
+ if (io_cfg->resource_type < buf_info->out_base ||
|
|
|
|
+ io_cfg->resource_type >= buf_info->out_max)
|
|
|
|
+ return -ENOMSG;
|
|
|
|
+
|
|
|
|
+ if ((buf_info->base->hw_type == CAM_ISP_HW_TYPE_SFE) &&
|
|
|
|
+ (buf_info->scratch_check_cfg->validate_for_sfe)) {
|
|
|
|
+ cam_isp_validate_for_sfe_scratch(
|
|
|
|
+ &buf_info->scratch_check_cfg->sfe_scratch_res_info,
|
|
|
|
+ io_cfg->resource_type, buf_info->out_base);
|
|
|
|
+ } else if ((buf_info->base->hw_type == CAM_ISP_HW_TYPE_VFE) &&
|
|
|
|
+ (buf_info->scratch_check_cfg->validate_for_ife)) {
|
|
|
|
+ cam_isp_validate_for_ife_scratch(
|
|
|
|
+ &buf_info->scratch_check_cfg->ife_scratch_res_info,
|
|
|
|
+ io_cfg->resource_type);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ *hw_mgr_res = &buf_info->res_list_isp_out[res_id];
|
|
|
|
+ if ((*hw_mgr_res)->res_type == CAM_ISP_RESOURCE_UNINT) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "io res id:%d not valid",
|
|
|
|
+ io_cfg->resource_type);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+ } else if (io_cfg->direction == CAM_BUF_INPUT) {
|
|
|
|
+ found = false;
|
|
|
|
+ res_id = io_cfg->resource_type;
|
|
|
|
+ if (!buf_info->res_list_in_rd) {
|
|
|
|
+ CAM_DBG(CAM_ISP,
|
|
|
|
+ "No BUS Read supported hw_type %d io_cfg %d req:%d type:%d fence:%d",
|
|
|
|
+ buf_info->base->hw_type,
|
|
|
|
+ buf_info->prepare->packet->num_io_configs,
|
|
|
|
+ buf_info->prepare->packet->header.request_id,
|
|
|
|
+ io_cfg->resource_type, io_cfg->fence);
|
|
|
|
+ return -ENOMSG;
|
|
|
|
+ }
|
|
|
|
+ if (buf_info->base->hw_type != CAM_ISP_HW_TYPE_SFE)
|
|
|
|
+ res_id = CAM_ISP_HW_VFE_IN_RD;
|
|
|
|
+
|
|
|
|
+ list_for_each_entry_safe((*hw_mgr_res), hw_mgr_res_temp,
|
|
|
|
+ buf_info->res_list_in_rd, list) {
|
|
|
|
+ if ((*hw_mgr_res)->res_id == res_id) {
|
|
|
|
+ found = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!found) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "No Read resource");
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ CAM_ERR(CAM_ISP, "Invalid io config direction :%d",
|
|
|
|
+ io_cfg->direction);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (buf_info->fill_fence) {
|
|
|
|
+ if (io_cfg->direction == CAM_BUF_OUTPUT &&
|
|
|
|
+ (buf_info->prepare->num_out_map_entries <
|
|
|
|
+ buf_info->prepare->max_out_map_entries)) {
|
|
|
|
+ num_entries = buf_info->prepare->num_out_map_entries;
|
|
|
|
+ map_entries = &buf_info->prepare->out_map_entries[num_entries];
|
|
|
|
+ buf_info->prepare->num_out_map_entries++;
|
|
|
|
+ } else if (io_cfg->direction == CAM_BUF_INPUT &&
|
|
|
|
+ (buf_info->prepare->num_in_map_entries <
|
|
|
|
+ buf_info->prepare->max_in_map_entries)) {
|
|
|
|
+ num_entries = buf_info->prepare->num_in_map_entries;
|
|
|
|
+ map_entries = &buf_info->prepare->in_map_entries[num_entries];
|
|
|
|
+ buf_info->prepare->num_in_map_entries++;
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ CAM_ERR(CAM_ISP, "dir: %d max_ln:%d max_out: %u in: %u out %u",
|
|
|
|
+ io_cfg->direction,
|
|
|
|
+ buf_info->prepare->max_in_map_entries,
|
|
|
|
+ buf_info->prepare->max_out_map_entries,
|
|
|
|
+ buf_info->prepare->num_in_map_entries,
|
|
|
|
+ buf_info->prepare->num_out_map_entries);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
+ map_entries->resource_handle = io_cfg->resource_type;
|
|
|
|
+ map_entries->sync_id = io_cfg->fence;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int cam_isp_add_io_buffers_util(
|
|
|
|
+ struct cam_isp_io_buf_info *buf_info,
|
|
|
|
+ struct cam_buf_io_cfg *io_cfg,
|
|
|
|
+ struct cam_isp_resource_node *res)
|
|
|
|
+{
|
|
|
|
+ uint32_t secure_mode_cmd;
|
|
|
|
+ uint32_t bus_update_cmd;
|
|
int rc = 0;
|
|
int rc = 0;
|
|
dma_addr_t io_addr[CAM_PACKET_MAX_PLANES];
|
|
dma_addr_t io_addr[CAM_PACKET_MAX_PLANES];
|
|
- struct cam_buf_io_cfg *io_cfg;
|
|
|
|
- struct cam_isp_resource_node *res;
|
|
|
|
- struct cam_isp_hw_mgr_res *hw_mgr_res;
|
|
|
|
- struct cam_isp_hw_mgr_res *hw_mgr_res_temp;
|
|
|
|
struct cam_isp_hw_get_cmd_update update_buf;
|
|
struct cam_isp_hw_get_cmd_update update_buf;
|
|
- struct cam_isp_hw_get_wm_update wm_update;
|
|
|
|
- struct cam_isp_hw_get_wm_update bus_rd_update;
|
|
|
|
- struct cam_hw_fence_map_entry *out_map_entries = NULL;
|
|
|
|
- struct cam_hw_fence_map_entry *in_map_entries;
|
|
|
|
- struct cam_isp_hw_get_cmd_update secure_mode;
|
|
|
|
|
|
+ struct cam_isp_hw_get_wm_update bus_port_update;
|
|
|
|
+ struct cam_hw_fence_map_entry *out_map_entry = NULL;
|
|
uint32_t kmd_buf_remain_size;
|
|
uint32_t kmd_buf_remain_size;
|
|
- uint32_t i, j, num_out_buf, num_in_buf;
|
|
|
|
- uint32_t res_id_out, res_id_in, plane_id;
|
|
|
|
- uint32_t io_cfg_used_bytes, num_ent;
|
|
|
|
|
|
+ uint32_t plane_id, num_entries;
|
|
dma_addr_t *image_buf_addr;
|
|
dma_addr_t *image_buf_addr;
|
|
uint32_t *image_buf_offset;
|
|
uint32_t *image_buf_offset;
|
|
- uint64_t iova_addr;
|
|
|
|
size_t size;
|
|
size_t size;
|
|
- int32_t hdl;
|
|
|
|
int mmu_hdl;
|
|
int mmu_hdl;
|
|
- bool is_buf_secure, found = false;
|
|
|
|
- uint32_t mode;
|
|
|
|
|
|
+ bool is_buf_secure;
|
|
|
|
+ struct cam_isp_hw_get_cmd_update secure_mode;
|
|
|
|
+ uint32_t mode = 0;
|
|
|
|
|
|
- io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *)
|
|
|
|
- &prepare->packet->payload +
|
|
|
|
- prepare->packet->io_configs_offset);
|
|
|
|
- num_out_buf = prepare->num_out_map_entries;
|
|
|
|
- num_in_buf = prepare->num_in_map_entries;
|
|
|
|
- io_cfg_used_bytes = 0;
|
|
|
|
|
|
+ if (io_cfg->direction == CAM_BUF_OUTPUT) {
|
|
|
|
+ secure_mode_cmd = CAM_ISP_HW_CMD_GET_WM_SECURE_MODE;
|
|
|
|
+ bus_update_cmd = CAM_ISP_HW_CMD_GET_BUF_UPDATE;
|
|
|
|
+ } else if (io_cfg->direction == CAM_BUF_INPUT) {
|
|
|
|
+ secure_mode_cmd = CAM_ISP_HW_CMD_GET_RM_SECURE_MODE;
|
|
|
|
+ bus_update_cmd = CAM_ISP_HW_CMD_GET_BUF_UPDATE_RM;
|
|
|
|
|
|
- /* Max one hw entries required for each base */
|
|
|
|
- if (prepare->num_hw_update_entries + 1 >=
|
|
|
|
- prepare->max_hw_update_entries) {
|
|
|
|
- CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d",
|
|
|
|
- prepare->num_hw_update_entries,
|
|
|
|
- prepare->max_hw_update_entries);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ CAM_ERR(CAM_ISP, "Invalid dir %d", io_cfg->direction);
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
- for (i = 0; i < prepare->packet->num_io_configs; i++) {
|
|
|
|
- CAM_DBG(CAM_ISP, "======= io config idx %d ============", i);
|
|
|
|
- CAM_DBG(CAM_REQ,
|
|
|
|
- "i %d req_id %llu resource_type:%d fence:%d direction %d",
|
|
|
|
- i, prepare->packet->header.request_id,
|
|
|
|
- io_cfg[i].resource_type, io_cfg[i].fence,
|
|
|
|
- io_cfg[i].direction);
|
|
|
|
- CAM_DBG(CAM_ISP, "format: %d", io_cfg[i].format);
|
|
|
|
-
|
|
|
|
- if (io_cfg[i].direction == CAM_BUF_OUTPUT) {
|
|
|
|
- if (io_cfg[i].resource_type < out_base ||
|
|
|
|
- io_cfg[i].resource_type >= out_max)
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- res_id_out = io_cfg[i].resource_type & 0xFF;
|
|
|
|
- if ((hw_type == CAM_ISP_HW_TYPE_SFE) &&
|
|
|
|
- (scratch_check_cfg->validate_for_sfe)) {
|
|
|
|
- struct cam_isp_sfe_scratch_buf_res_info *sfe_res_info =
|
|
|
|
- &scratch_check_cfg->sfe_scratch_res_info;
|
|
|
|
-
|
|
|
|
- cam_isp_validate_for_sfe_scratch(sfe_res_info,
|
|
|
|
- io_cfg[i].resource_type, out_base);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if ((hw_type == CAM_ISP_HW_TYPE_VFE) &&
|
|
|
|
- (scratch_check_cfg->validate_for_ife)) {
|
|
|
|
- struct cam_isp_ife_scratch_buf_res_info *ife_res_info =
|
|
|
|
- &scratch_check_cfg->ife_scratch_res_info;
|
|
|
|
-
|
|
|
|
- cam_isp_validate_for_ife_scratch(ife_res_info,
|
|
|
|
- io_cfg[i].resource_type);
|
|
|
|
- }
|
|
|
|
|
|
+ if (!res) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "invalid res, io res id:%d split_id :%d",
|
|
|
|
+ io_cfg->resource_type, buf_info->base->split_id);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "configure output io with fill fence %d",
|
|
|
|
- fill_fence);
|
|
|
|
- out_map_entries =
|
|
|
|
- &prepare->out_map_entries[num_out_buf];
|
|
|
|
- if (fill_fence) {
|
|
|
|
- if (num_out_buf <
|
|
|
|
- prepare->max_out_map_entries) {
|
|
|
|
- out_map_entries->resource_handle =
|
|
|
|
- io_cfg[i].resource_type;
|
|
|
|
- out_map_entries->sync_id =
|
|
|
|
- io_cfg[i].fence;
|
|
|
|
- num_out_buf++;
|
|
|
|
- } else {
|
|
|
|
- CAM_ERR(CAM_ISP, "ln_out:%d max_ln:%d",
|
|
|
|
- num_out_buf,
|
|
|
|
- prepare->max_out_map_entries);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (res->res_id != io_cfg->resource_type) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "err res id:%d io res id:%d",
|
|
|
|
+ res->res_id, io_cfg->resource_type);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
|
|
- hw_mgr_res = &res_list_isp_out[res_id_out];
|
|
|
|
- if (hw_mgr_res->res_type == CAM_ISP_RESOURCE_UNINT) {
|
|
|
|
- CAM_ERR(CAM_ISP, "io res id:%d not valid",
|
|
|
|
- io_cfg[i].resource_type);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
- } else if (io_cfg[i].direction == CAM_BUF_INPUT) {
|
|
|
|
- res_id_in = io_cfg[i].resource_type;
|
|
|
|
- found = false;
|
|
|
|
- if (!res_list_in_rd) {
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "No BUS Read supported hw_type %d io_cfg %d %d req:%d type:%d fence:%d",
|
|
|
|
- hw_type,
|
|
|
|
- prepare->packet->num_io_configs, i,
|
|
|
|
- prepare->packet->header.request_id,
|
|
|
|
- io_cfg[i].resource_type, io_cfg[i].fence);
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (hw_type != CAM_ISP_HW_TYPE_SFE)
|
|
|
|
- res_id_in = CAM_ISP_HW_VFE_IN_RD;
|
|
|
|
-
|
|
|
|
- list_for_each_entry_safe(hw_mgr_res, hw_mgr_res_temp,
|
|
|
|
- res_list_in_rd, list) {
|
|
|
|
- if (hw_mgr_res->res_id == res_id_in) {
|
|
|
|
- found = true;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ memset(io_addr, 0, sizeof(io_addr));
|
|
|
|
+ for (plane_id = 0; plane_id < CAM_PACKET_MAX_PLANES; plane_id++) {
|
|
|
|
+ if (!io_cfg->mem_handle[plane_id])
|
|
|
|
+ break;
|
|
|
|
+ secure_mode.cmd_type = secure_mode_cmd;
|
|
|
|
+ secure_mode.res = res;
|
|
|
|
+ secure_mode.data = (void *)&mode;
|
|
|
|
+ rc = res->hw_intf->hw_ops.process_cmd(
|
|
|
|
+ res->hw_intf->hw_priv, secure_mode_cmd,
|
|
|
|
+ &secure_mode, sizeof(struct cam_isp_hw_get_cmd_update));
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "Get secure mode failed cmd_type %d res_id %d",
|
|
|
|
+ secure_mode_cmd, res->res_id);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
|
|
- if (!found) {
|
|
|
|
- CAM_ERR(CAM_ISP, "No Read resource");
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
|
|
+ is_buf_secure = cam_mem_is_secure_buf(io_cfg->mem_handle[plane_id]);
|
|
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "configure input io with fill fence %d",
|
|
|
|
- fill_fence);
|
|
|
|
- in_map_entries =
|
|
|
|
- &prepare->in_map_entries[num_in_buf];
|
|
|
|
- if (fill_fence) {
|
|
|
|
- if (num_in_buf < prepare->max_in_map_entries) {
|
|
|
|
- in_map_entries->resource_handle =
|
|
|
|
- io_cfg[i].resource_type;
|
|
|
|
- in_map_entries->sync_id =
|
|
|
|
- io_cfg[i].fence;
|
|
|
|
- num_in_buf++;
|
|
|
|
- } else {
|
|
|
|
- CAM_ERR(CAM_ISP, "ln_in:%d imax_ln:%d",
|
|
|
|
- num_in_buf,
|
|
|
|
- prepare->max_in_map_entries);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if ((mode == CAM_SECURE_MODE_SECURE) &&
|
|
|
|
+ is_buf_secure) {
|
|
|
|
+ mmu_hdl = buf_info->sec_iommu_hdl;
|
|
|
|
+ } else if ((mode == CAM_SECURE_MODE_NON_SECURE) &&
|
|
|
|
+ !is_buf_secure) {
|
|
|
|
+ mmu_hdl = buf_info->iommu_hdl;
|
|
} else {
|
|
} else {
|
|
- CAM_ERR(CAM_ISP, "Invalid io config direction :%d",
|
|
|
|
- io_cfg[i].direction);
|
|
|
|
|
|
+ CAM_ERR_RATE_LIMIT(CAM_ISP,
|
|
|
|
+ "Invalid hdl: port mode[%u], buf mode[%u]",
|
|
|
|
+ mode, is_buf_secure);
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
- CAM_DBG(CAM_ISP, "setup mem io");
|
|
|
|
- for (j = 0; j < CAM_ISP_HW_SPLIT_MAX &&
|
|
|
|
- io_cfg[i].direction == CAM_BUF_OUTPUT; j++) {
|
|
|
|
- if (!hw_mgr_res->hw_res[j])
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- if (hw_mgr_res->hw_res[j]->hw_intf->hw_idx != base_idx)
|
|
|
|
- continue;
|
|
|
|
-
|
|
|
|
- res = hw_mgr_res->hw_res[j];
|
|
|
|
- if (res->res_id != io_cfg[i].resource_type) {
|
|
|
|
- CAM_ERR(CAM_ISP,
|
|
|
|
- "wm err res id:%d io res id:%d",
|
|
|
|
- res->res_id, io_cfg[i].resource_type);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- memset(io_addr, 0, sizeof(io_addr));
|
|
|
|
-
|
|
|
|
- for (plane_id = 0; plane_id < CAM_PACKET_MAX_PLANES;
|
|
|
|
- plane_id++) {
|
|
|
|
- if (!io_cfg[i].mem_handle[plane_id])
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- hdl = io_cfg[i].mem_handle[plane_id];
|
|
|
|
- secure_mode.cmd_type =
|
|
|
|
- CAM_ISP_HW_CMD_GET_WM_SECURE_MODE;
|
|
|
|
- secure_mode.res = res;
|
|
|
|
- secure_mode.data = (void *)&mode;
|
|
|
|
- rc = res->hw_intf->hw_ops.process_cmd(
|
|
|
|
- res->hw_intf->hw_priv,
|
|
|
|
- CAM_ISP_HW_CMD_GET_WM_SECURE_MODE,
|
|
|
|
- &secure_mode,
|
|
|
|
- sizeof(
|
|
|
|
- struct cam_isp_hw_get_cmd_update));
|
|
|
|
- if (rc)
|
|
|
|
- return -EINVAL;
|
|
|
|
-
|
|
|
|
- is_buf_secure = cam_mem_is_secure_buf(hdl);
|
|
|
|
- if ((mode == CAM_SECURE_MODE_SECURE) &&
|
|
|
|
- is_buf_secure) {
|
|
|
|
- mmu_hdl = sec_iommu_hdl;
|
|
|
|
- } else if (
|
|
|
|
- (mode == CAM_SECURE_MODE_NON_SECURE) &&
|
|
|
|
- (!is_buf_secure)) {
|
|
|
|
- mmu_hdl = iommu_hdl;
|
|
|
|
- } else {
|
|
|
|
- CAM_ERR_RATE_LIMIT(CAM_ISP,
|
|
|
|
- "Invalid hdl: port mode[%u], buf mode[%u]",
|
|
|
|
- mode, is_buf_secure);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
|
|
+ rc = cam_mem_get_io_buf(io_cfg->mem_handle[plane_id],
|
|
|
|
+ mmu_hdl, &io_addr[plane_id], &size, NULL);
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "no io addr for plane%d", plane_id);
|
|
|
|
+ rc = -ENOMEM;
|
|
|
|
+ return rc;
|
|
|
|
+ }
|
|
|
|
|
|
- rc = cam_mem_get_io_buf(
|
|
|
|
- io_cfg[i].mem_handle[plane_id],
|
|
|
|
- mmu_hdl, &io_addr[plane_id], &size, NULL);
|
|
|
|
- if (rc) {
|
|
|
|
- CAM_ERR(CAM_ISP,
|
|
|
|
- "no io addr for plane%d",
|
|
|
|
- plane_id);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
|
|
+ /* need to update with offset */
|
|
|
|
+ io_addr[plane_id] += io_cfg->offsets[plane_id];
|
|
|
|
+ CAM_DBG(CAM_ISP, "get io_addr for plane %d: 0x%llx, mem_hdl=0x%x",
|
|
|
|
+ plane_id, io_addr[plane_id], io_cfg->mem_handle[plane_id]);
|
|
|
|
|
|
- /* need to update with offset */
|
|
|
|
- io_addr[plane_id] +=
|
|
|
|
- io_cfg[i].offsets[plane_id];
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "get io_addr for plane %d: 0x%llx, mem_hdl=0x%x",
|
|
|
|
- plane_id, io_addr[plane_id],
|
|
|
|
- io_cfg[i].mem_handle[plane_id]);
|
|
|
|
|
|
+ CAM_DBG(CAM_ISP, "mmu_hdl=0x%x, size=%d, end=0x%x",
|
|
|
|
+ mmu_hdl, (int)size, io_addr[plane_id]+size);
|
|
|
|
+ }
|
|
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "mmu_hdl=0x%x, size=%d, end=0x%x",
|
|
|
|
- mmu_hdl, (int)size,
|
|
|
|
- io_addr[plane_id]+size);
|
|
|
|
|
|
+ if (!plane_id) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "No valid planes for res%d", res->res_id);
|
|
|
|
+ rc = -ENOMEM;
|
|
|
|
+ return rc;
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- if (!plane_id) {
|
|
|
|
- CAM_ERR(CAM_ISP, "No valid planes for res%d",
|
|
|
|
- res->res_id);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
|
|
+ if ((buf_info->kmd_buf_info->used_bytes) <
|
|
|
|
+ buf_info->kmd_buf_info->size) {
|
|
|
|
+ kmd_buf_remain_size = buf_info->kmd_buf_info->size -
|
|
|
|
+ (buf_info->kmd_buf_info->used_bytes);
|
|
|
|
+ } else {
|
|
|
|
+ CAM_ERR(CAM_ISP, "no free kmd memory for base %d", buf_info->base->idx);
|
|
|
|
+ rc = -ENOMEM;
|
|
|
|
+ return rc;
|
|
|
|
+ }
|
|
|
|
+ update_buf.res = res;
|
|
|
|
+ update_buf.cmd_type = bus_update_cmd;
|
|
|
|
+ update_buf.cmd.cmd_buf_addr = buf_info->kmd_buf_info->cpu_addr +
|
|
|
|
+ buf_info->kmd_buf_info->used_bytes/4;
|
|
|
|
+ bus_port_update.image_buf = io_addr;
|
|
|
|
+ bus_port_update.num_buf = plane_id;
|
|
|
|
+ bus_port_update.io_cfg = io_cfg;
|
|
|
|
+ bus_port_update.frame_header = 0;
|
|
|
|
+ bus_port_update.fh_enabled = false;
|
|
|
|
+
|
|
|
|
+ for (plane_id = 0; plane_id < CAM_PACKET_MAX_PLANES; plane_id++)
|
|
|
|
+ bus_port_update.image_buf_offset[plane_id] = 0;
|
|
|
|
+
|
|
|
|
+ if ((buf_info->frame_hdr->frame_header_enable) &&
|
|
|
|
+ !(buf_info->frame_hdr->frame_header_res_id)) {
|
|
|
|
+ bus_port_update.frame_header =
|
|
|
|
+ buf_info->frame_hdr->frame_header_iova_addr;
|
|
|
|
+ bus_port_update.local_id =
|
|
|
|
+ buf_info->prepare->packet->header.request_id;
|
|
|
|
+ }
|
|
|
|
|
|
- if ((kmd_buf_info->used_bytes + io_cfg_used_bytes) <
|
|
|
|
- kmd_buf_info->size) {
|
|
|
|
- kmd_buf_remain_size = kmd_buf_info->size -
|
|
|
|
- (kmd_buf_info->used_bytes +
|
|
|
|
- io_cfg_used_bytes);
|
|
|
|
- } else {
|
|
|
|
- CAM_ERR(CAM_ISP,
|
|
|
|
- "no free kmd memory for base %d",
|
|
|
|
- base_idx);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
- update_buf.res = res;
|
|
|
|
- update_buf.cmd_type = CAM_ISP_HW_CMD_GET_BUF_UPDATE;
|
|
|
|
- update_buf.cmd.cmd_buf_addr = kmd_buf_info->cpu_addr +
|
|
|
|
- kmd_buf_info->used_bytes/4 +
|
|
|
|
- io_cfg_used_bytes/4;
|
|
|
|
- wm_update.image_buf = io_addr;
|
|
|
|
- wm_update.num_buf = plane_id;
|
|
|
|
- wm_update.io_cfg = &io_cfg[i];
|
|
|
|
- wm_update.frame_header = 0;
|
|
|
|
- wm_update.fh_enabled = false;
|
|
|
|
-
|
|
|
|
- for (plane_id = 0; plane_id < CAM_PACKET_MAX_PLANES;
|
|
|
|
- plane_id++)
|
|
|
|
- wm_update.image_buf_offset[plane_id] = 0;
|
|
|
|
-
|
|
|
|
- iova_addr = frame_header_info->frame_header_iova_addr;
|
|
|
|
- if ((frame_header_info->frame_header_enable) &&
|
|
|
|
- !(frame_header_info->frame_header_res_id)) {
|
|
|
|
- wm_update.frame_header = iova_addr;
|
|
|
|
- wm_update.local_id =
|
|
|
|
- prepare->packet->header.request_id;
|
|
|
|
- }
|
|
|
|
|
|
+ update_buf.cmd.size = kmd_buf_remain_size;
|
|
|
|
+ if (io_cfg->direction == CAM_BUF_OUTPUT)
|
|
|
|
+ update_buf.wm_update = &bus_port_update;
|
|
|
|
+ else if (io_cfg->direction == CAM_BUF_INPUT)
|
|
|
|
+ update_buf.rm_update = &bus_port_update;
|
|
|
|
|
|
- update_buf.cmd.size = kmd_buf_remain_size;
|
|
|
|
- update_buf.wm_update = &wm_update;
|
|
|
|
- update_buf.use_scratch_cfg = false;
|
|
|
|
|
|
+ update_buf.use_scratch_cfg = false;
|
|
|
|
|
|
- CAM_DBG(CAM_ISP, "cmd buffer 0x%pK, size %d",
|
|
|
|
- update_buf.cmd.cmd_buf_addr,
|
|
|
|
- update_buf.cmd.size);
|
|
|
|
- rc = res->hw_intf->hw_ops.process_cmd(
|
|
|
|
- res->hw_intf->hw_priv,
|
|
|
|
- CAM_ISP_HW_CMD_GET_BUF_UPDATE, &update_buf,
|
|
|
|
- sizeof(struct cam_isp_hw_get_cmd_update));
|
|
|
|
|
|
+ CAM_DBG(CAM_ISP, "cmd buffer 0x%pK, size %d",
|
|
|
|
+ update_buf.cmd.cmd_buf_addr, update_buf.cmd.size);
|
|
|
|
+ rc = res->hw_intf->hw_ops.process_cmd(
|
|
|
|
+ res->hw_intf->hw_priv,
|
|
|
|
+ bus_update_cmd, &update_buf,
|
|
|
|
+ sizeof(struct cam_isp_hw_get_cmd_update));
|
|
|
|
|
|
- if (rc) {
|
|
|
|
- CAM_ERR(CAM_ISP, "get buf cmd error:%d",
|
|
|
|
- res->res_id);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "get buf cmd error:%d",
|
|
|
|
+ res->res_id);
|
|
|
|
+ rc = -ENOMEM;
|
|
|
|
+ return rc;
|
|
|
|
+ }
|
|
|
|
|
|
- if (wm_update.fh_enabled) {
|
|
|
|
- frame_header_info->frame_header_res_id =
|
|
|
|
- res->res_id;
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "Frame header enabled for res: 0x%x iova: %pK",
|
|
|
|
- frame_header_info->frame_header_res_id,
|
|
|
|
- wm_update.frame_header);
|
|
|
|
- }
|
|
|
|
|
|
+ if (bus_port_update.fh_enabled) {
|
|
|
|
+ buf_info->frame_hdr->frame_header_res_id = res->res_id;
|
|
|
|
+ CAM_DBG(CAM_ISP,
|
|
|
|
+ "Frame header enabled for res: 0x%x iova: %pK",
|
|
|
|
+ buf_info->frame_hdr->frame_header_res_id,
|
|
|
|
+ bus_port_update.frame_header);
|
|
|
|
+ }
|
|
|
|
|
|
- io_cfg_used_bytes += update_buf.cmd.used_bytes;
|
|
|
|
|
|
+ buf_info->kmd_buf_info->used_bytes += update_buf.cmd.used_bytes;
|
|
|
|
+ buf_info->kmd_buf_info->offset += update_buf.cmd.used_bytes;
|
|
|
|
|
|
- if (!out_map_entries) {
|
|
|
|
- CAM_ERR(CAM_ISP, "out_map_entries is NULL");
|
|
|
|
|
|
+ if (io_cfg->direction == CAM_BUF_OUTPUT) {
|
|
|
|
+ if (buf_info->fill_fence) {
|
|
|
|
+ num_entries = buf_info->prepare->num_out_map_entries - 1;
|
|
|
|
+ out_map_entry =
|
|
|
|
+ &buf_info->prepare->out_map_entries[num_entries];
|
|
|
|
+ if (!out_map_entry) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "out_map_entry is NULL");
|
|
rc = -EINVAL;
|
|
rc = -EINVAL;
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|
|
|
|
|
|
- image_buf_addr = out_map_entries->image_buf_addr;
|
|
|
|
- image_buf_offset = wm_update.image_buf_offset;
|
|
|
|
- if (j == CAM_ISP_HW_SPLIT_LEFT) {
|
|
|
|
- for (plane_id = 0;
|
|
|
|
- plane_id < CAM_PACKET_MAX_PLANES;
|
|
|
|
|
|
+ image_buf_addr = out_map_entry->image_buf_addr;
|
|
|
|
+ image_buf_offset = bus_port_update.image_buf_offset;
|
|
|
|
+ if (buf_info->base->split_id == CAM_ISP_HW_SPLIT_LEFT) {
|
|
|
|
+ for (plane_id = 0; plane_id < CAM_PACKET_MAX_PLANES;
|
|
plane_id++)
|
|
plane_id++)
|
|
- image_buf_addr[plane_id] =
|
|
|
|
- io_addr[plane_id] +
|
|
|
|
|
|
+ image_buf_addr[plane_id] = io_addr[plane_id] +
|
|
image_buf_offset[plane_id];
|
|
image_buf_offset[plane_id];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- for (j = 0; j < CAM_ISP_HW_SPLIT_MAX &&
|
|
|
|
- io_cfg[i].direction == CAM_BUF_INPUT; j++) {
|
|
|
|
- if (!hw_mgr_res->hw_res[j])
|
|
|
|
- continue;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- if (hw_mgr_res->hw_res[j]->hw_intf->hw_idx != base_idx)
|
|
|
|
- continue;
|
|
|
|
|
|
+ return rc;
|
|
|
|
+}
|
|
|
|
|
|
- res = hw_mgr_res->hw_res[j];
|
|
|
|
|
|
+int cam_isp_add_io_buffers(struct cam_isp_io_buf_info *io_info)
|
|
|
|
+{
|
|
|
|
+ int rc = 0;
|
|
|
|
+ struct cam_buf_io_cfg *io_cfg = NULL;
|
|
|
|
+ struct cam_isp_hw_mgr_res *hw_mgr_res = NULL;
|
|
|
|
+ uint32_t i;
|
|
|
|
+ uint32_t curr_used_bytes = 0;
|
|
|
|
+ uint32_t bytes_updated = 0;
|
|
|
|
+ uint32_t curr_offset = 0;
|
|
|
|
+ struct cam_isp_resource_node *res = NULL;
|
|
|
|
|
|
- memset(io_addr, 0, sizeof(io_addr));
|
|
|
|
-
|
|
|
|
- for (plane_id = 0; plane_id < CAM_PACKET_MAX_PLANES;
|
|
|
|
- plane_id++) {
|
|
|
|
- if (!io_cfg[i].mem_handle[plane_id])
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- hdl = io_cfg[i].mem_handle[plane_id];
|
|
|
|
- secure_mode.cmd_type =
|
|
|
|
- CAM_ISP_HW_CMD_GET_RM_SECURE_MODE;
|
|
|
|
- secure_mode.res = res;
|
|
|
|
- secure_mode.data = (void *)&mode;
|
|
|
|
- rc = res->hw_intf->hw_ops.process_cmd(
|
|
|
|
- res->hw_intf->hw_priv,
|
|
|
|
- CAM_ISP_HW_CMD_GET_RM_SECURE_MODE,
|
|
|
|
- &secure_mode,
|
|
|
|
- sizeof(
|
|
|
|
- struct cam_isp_hw_get_cmd_update));
|
|
|
|
- if (rc)
|
|
|
|
- return -EINVAL;
|
|
|
|
|
|
+ io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *)
|
|
|
|
+ &io_info->prepare->packet->payload +
|
|
|
|
+ io_info->prepare->packet->io_configs_offset);
|
|
|
|
+ curr_used_bytes = io_info->kmd_buf_info->used_bytes;
|
|
|
|
+ curr_offset = io_info->kmd_buf_info->offset;
|
|
|
|
|
|
- is_buf_secure = cam_mem_is_secure_buf(hdl);
|
|
|
|
- if ((mode == CAM_SECURE_MODE_SECURE) &&
|
|
|
|
- is_buf_secure) {
|
|
|
|
- mmu_hdl = sec_iommu_hdl;
|
|
|
|
- } else if (
|
|
|
|
- (mode == CAM_SECURE_MODE_NON_SECURE) &&
|
|
|
|
- (!is_buf_secure)) {
|
|
|
|
- mmu_hdl = iommu_hdl;
|
|
|
|
- } else {
|
|
|
|
- CAM_ERR_RATE_LIMIT(CAM_ISP,
|
|
|
|
- "Invalid hdl: port mode[%u], buf mode[%u]",
|
|
|
|
- mode, is_buf_secure);
|
|
|
|
- return -EINVAL;
|
|
|
|
- }
|
|
|
|
|
|
+ /* Max one hw entries required for each base */
|
|
|
|
+ if (io_info->prepare->num_hw_update_entries + 1 >=
|
|
|
|
+ io_info->prepare->max_hw_update_entries) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "Insufficient HW entries :%d %d",
|
|
|
|
+ io_info->prepare->num_hw_update_entries,
|
|
|
|
+ io_info->prepare->max_hw_update_entries);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
|
|
- rc = cam_mem_get_io_buf(
|
|
|
|
- io_cfg[i].mem_handle[plane_id],
|
|
|
|
- mmu_hdl, &io_addr[plane_id], &size, NULL);
|
|
|
|
- if (rc) {
|
|
|
|
- CAM_ERR(CAM_ISP,
|
|
|
|
- "no io addr for plane%d",
|
|
|
|
- plane_id);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
|
|
+ for (i = 0; i < io_info->prepare->packet->num_io_configs; i++) {
|
|
|
|
|
|
- /* need to update with offset */
|
|
|
|
- io_addr[plane_id] +=
|
|
|
|
- io_cfg[i].offsets[plane_id];
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "get io_addr for plane %d: 0x%llx, mem_hdl=0x%x",
|
|
|
|
- plane_id, io_addr[plane_id],
|
|
|
|
- io_cfg[i].mem_handle[plane_id]);
|
|
|
|
|
|
+ rc = cam_isp_io_buf_get_entries_util(io_info, &io_cfg[i], &hw_mgr_res);
|
|
|
|
|
|
- CAM_DBG(CAM_ISP,
|
|
|
|
- "mmu_hdl=0x%x, size=%d, end=0x%x",
|
|
|
|
- mmu_hdl, (int)size,
|
|
|
|
- io_addr[plane_id]+size);
|
|
|
|
|
|
+ if (rc == -ENOMSG) {
|
|
|
|
+ rc = 0;
|
|
|
|
+ continue;
|
|
|
|
+ } else if (rc) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "io_cfg[%d] failed rc %d", i, rc);
|
|
|
|
+ return rc;
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- if (!plane_id) {
|
|
|
|
- CAM_ERR(CAM_ISP, "No valid planes for res%d",
|
|
|
|
- res->res_id);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!hw_mgr_res) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "hw_mgr_res is NULL i:%d", i);
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ }
|
|
|
|
|
|
- if ((kmd_buf_info->used_bytes + io_cfg_used_bytes) <
|
|
|
|
- kmd_buf_info->size) {
|
|
|
|
- kmd_buf_remain_size = kmd_buf_info->size -
|
|
|
|
- (kmd_buf_info->used_bytes +
|
|
|
|
- io_cfg_used_bytes);
|
|
|
|
- } else {
|
|
|
|
- CAM_ERR(CAM_ISP,
|
|
|
|
- "no free kmd memory for base %d",
|
|
|
|
- base_idx);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
- update_buf.res = res;
|
|
|
|
- update_buf.cmd_type = CAM_ISP_HW_CMD_GET_BUF_UPDATE_RM;
|
|
|
|
- update_buf.cmd.cmd_buf_addr = kmd_buf_info->cpu_addr +
|
|
|
|
- kmd_buf_info->used_bytes/4 +
|
|
|
|
- io_cfg_used_bytes/4;
|
|
|
|
- bus_rd_update.image_buf = io_addr;
|
|
|
|
- bus_rd_update.num_buf = plane_id;
|
|
|
|
- bus_rd_update.io_cfg = &io_cfg[i];
|
|
|
|
- update_buf.cmd.size = kmd_buf_remain_size;
|
|
|
|
- update_buf.use_scratch_cfg = false;
|
|
|
|
- update_buf.rm_update = &bus_rd_update;
|
|
|
|
-
|
|
|
|
- CAM_DBG(CAM_ISP, "cmd buffer 0x%pK, size %d",
|
|
|
|
- update_buf.cmd.cmd_buf_addr,
|
|
|
|
- update_buf.cmd.size);
|
|
|
|
- rc = res->hw_intf->hw_ops.process_cmd(
|
|
|
|
- res->hw_intf->hw_priv,
|
|
|
|
- CAM_ISP_HW_CMD_GET_BUF_UPDATE_RM, &update_buf,
|
|
|
|
- sizeof(struct cam_isp_hw_get_cmd_update));
|
|
|
|
|
|
+ res = hw_mgr_res->hw_res[io_info->base->split_id];
|
|
|
|
+ if (!res)
|
|
|
|
+ continue;
|
|
|
|
+ rc = cam_isp_add_io_buffers_util(io_info, &io_cfg[i], res);
|
|
|
|
|
|
- if (rc) {
|
|
|
|
- CAM_ERR(CAM_ISP, "get buf cmd error:%d",
|
|
|
|
- res->res_id);
|
|
|
|
- rc = -ENOMEM;
|
|
|
|
- return rc;
|
|
|
|
- }
|
|
|
|
- io_cfg_used_bytes += update_buf.cmd.used_bytes;
|
|
|
|
|
|
+ if (rc) {
|
|
|
|
+ CAM_ERR(CAM_ISP, "io_cfg[%d] failed rc %d", i, rc);
|
|
|
|
+ return rc;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ bytes_updated = io_info->kmd_buf_info->used_bytes - curr_used_bytes;
|
|
CAM_DBG(CAM_ISP, "io_cfg_used_bytes %d, fill_fence %d",
|
|
CAM_DBG(CAM_ISP, "io_cfg_used_bytes %d, fill_fence %d",
|
|
- io_cfg_used_bytes, fill_fence);
|
|
|
|
- if (io_cfg_used_bytes) {
|
|
|
|
- /* Update the HW entries */
|
|
|
|
- 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,
|
|
|
|
- prepare->hw_update_entries[num_ent].handle,
|
|
|
|
- prepare->hw_update_entries[num_ent].len,
|
|
|
|
- prepare->hw_update_entries[num_ent].offset);
|
|
|
|
- num_ent++;
|
|
|
|
|
|
+ bytes_updated, io_info->fill_fence);
|
|
|
|
|
|
- kmd_buf_info->used_bytes += io_cfg_used_bytes;
|
|
|
|
- kmd_buf_info->offset += io_cfg_used_bytes;
|
|
|
|
- prepare->num_hw_update_entries = num_ent;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (fill_fence) {
|
|
|
|
- prepare->num_out_map_entries = num_out_buf;
|
|
|
|
- prepare->num_in_map_entries = num_in_buf;
|
|
|
|
- }
|
|
|
|
|
|
+ if (bytes_updated)
|
|
|
|
+ cam_isp_update_hw_entries_util(CAM_ISP_IOCFG_BL, io_info->kmd_buf_info,
|
|
|
|
+ bytes_updated, curr_offset, io_info->prepare);
|
|
|
|
|
|
return rc;
|
|
return rc;
|
|
}
|
|
}
|