Loading drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +89 −18 Original line number Diff line number Diff line Loading @@ -480,6 +480,53 @@ static int cam_fd_mgr_util_parse_generic_cmd_buffer( return rc; } static int cam_fd_mgr_util_get_buf_map_requirement(uint32_t direction, uint32_t resource_type, bool *need_io_map, bool *need_cpu_map) { if (!need_io_map || !need_cpu_map) { CAM_ERR(CAM_FD, "Invalid input pointers %pK %pK", need_io_map, need_cpu_map); return -EINVAL; } if (direction == CAM_BUF_INPUT) { switch (resource_type) { case CAM_FD_INPUT_PORT_ID_IMAGE: *need_io_map = true; *need_cpu_map = false; break; default: CAM_WARN(CAM_FD, "Invalid port: dir %d, id %d", direction, resource_type); return -EINVAL; } } else if (direction == CAM_BUF_OUTPUT) { switch (resource_type) { case CAM_FD_OUTPUT_PORT_ID_RESULTS: *need_io_map = true; *need_cpu_map = true; break; case CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS: *need_io_map = true; *need_cpu_map = true; break; case CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER: *need_io_map = true; *need_cpu_map = false; break; default: CAM_WARN(CAM_FD, "Invalid port: dir %d, id %d", direction, resource_type); return -EINVAL; } } else { CAM_WARN(CAM_FD, "Invalid direction %d", direction); return -EINVAL; } return 0; } static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, struct cam_hw_prepare_update_args *prepare, struct cam_fd_hw_io_buffer *input_buf, Loading @@ -491,6 +538,7 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, uint64_t io_addr[CAM_PACKET_MAX_PLANES]; uint64_t cpu_addr[CAM_PACKET_MAX_PLANES]; size_t size; bool need_io_map, need_cpu_map; /* Get IO Buf information */ num_out_buf = 0; Loading @@ -512,32 +560,55 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, return -EINVAL; } rc = cam_fd_mgr_util_get_buf_map_requirement( io_cfg[i].direction, io_cfg[i].resource_type, &need_io_map, &need_cpu_map); if (rc) { CAM_WARN(CAM_FD, "Invalid io buff [%d] : %d %d %d", i, io_cfg[i].direction, io_cfg[i].resource_type, rc); continue; } memset(io_addr, 0x0, sizeof(io_addr)); for (plane = 0; plane < CAM_PACKET_MAX_PLANES; plane++) { if (!io_cfg[i].mem_handle[plane]) break; rc = cam_mem_get_io_buf(io_cfg[i].mem_handle[plane], io_addr[plane] = 0x0; cpu_addr[plane] = 0x0; if (need_io_map) { rc = cam_mem_get_io_buf( io_cfg[i].mem_handle[plane], iommu_hdl, &io_addr[plane], &size); if ((rc) || (io_addr[plane] >> 32)) { CAM_ERR(CAM_FD, "Invalid io addr for %d %d", plane, rc); CAM_ERR(CAM_FD, "Invalid io buf %d %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane, rc); return -ENOMEM; } /* * Buffers may be accessed by CPU as well, we do not * know at this point, so get both and send to HW layer */ rc = cam_mem_get_cpu_buf(io_cfg[i].mem_handle[plane], io_addr[plane] += io_cfg[i].offsets[plane]; } if (need_cpu_map) { rc = cam_mem_get_cpu_buf( io_cfg[i].mem_handle[plane], &cpu_addr[plane], &size); if (rc) { CAM_ERR(CAM_FD, "unable to get buf address"); CAM_ERR(CAM_FD, "Invalid cpu buf %d %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane, rc); return rc; } io_addr[plane] += io_cfg[i].offsets[plane]; cpu_addr[plane] += io_cfg[i].offsets[plane]; } CAM_DBG(CAM_FD, "IO Address[%d][%d] : %pK, %pK", io_cfg[i].direction, plane, io_addr[plane], Loading Loading
drivers/media/platform/msm/camera/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +89 −18 Original line number Diff line number Diff line Loading @@ -480,6 +480,53 @@ static int cam_fd_mgr_util_parse_generic_cmd_buffer( return rc; } static int cam_fd_mgr_util_get_buf_map_requirement(uint32_t direction, uint32_t resource_type, bool *need_io_map, bool *need_cpu_map) { if (!need_io_map || !need_cpu_map) { CAM_ERR(CAM_FD, "Invalid input pointers %pK %pK", need_io_map, need_cpu_map); return -EINVAL; } if (direction == CAM_BUF_INPUT) { switch (resource_type) { case CAM_FD_INPUT_PORT_ID_IMAGE: *need_io_map = true; *need_cpu_map = false; break; default: CAM_WARN(CAM_FD, "Invalid port: dir %d, id %d", direction, resource_type); return -EINVAL; } } else if (direction == CAM_BUF_OUTPUT) { switch (resource_type) { case CAM_FD_OUTPUT_PORT_ID_RESULTS: *need_io_map = true; *need_cpu_map = true; break; case CAM_FD_OUTPUT_PORT_ID_RAW_RESULTS: *need_io_map = true; *need_cpu_map = true; break; case CAM_FD_OUTPUT_PORT_ID_WORK_BUFFER: *need_io_map = true; *need_cpu_map = false; break; default: CAM_WARN(CAM_FD, "Invalid port: dir %d, id %d", direction, resource_type); return -EINVAL; } } else { CAM_WARN(CAM_FD, "Invalid direction %d", direction); return -EINVAL; } return 0; } static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, struct cam_hw_prepare_update_args *prepare, struct cam_fd_hw_io_buffer *input_buf, Loading @@ -491,6 +538,7 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, uint64_t io_addr[CAM_PACKET_MAX_PLANES]; uint64_t cpu_addr[CAM_PACKET_MAX_PLANES]; size_t size; bool need_io_map, need_cpu_map; /* Get IO Buf information */ num_out_buf = 0; Loading @@ -512,32 +560,55 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, return -EINVAL; } rc = cam_fd_mgr_util_get_buf_map_requirement( io_cfg[i].direction, io_cfg[i].resource_type, &need_io_map, &need_cpu_map); if (rc) { CAM_WARN(CAM_FD, "Invalid io buff [%d] : %d %d %d", i, io_cfg[i].direction, io_cfg[i].resource_type, rc); continue; } memset(io_addr, 0x0, sizeof(io_addr)); for (plane = 0; plane < CAM_PACKET_MAX_PLANES; plane++) { if (!io_cfg[i].mem_handle[plane]) break; rc = cam_mem_get_io_buf(io_cfg[i].mem_handle[plane], io_addr[plane] = 0x0; cpu_addr[plane] = 0x0; if (need_io_map) { rc = cam_mem_get_io_buf( io_cfg[i].mem_handle[plane], iommu_hdl, &io_addr[plane], &size); if ((rc) || (io_addr[plane] >> 32)) { CAM_ERR(CAM_FD, "Invalid io addr for %d %d", plane, rc); CAM_ERR(CAM_FD, "Invalid io buf %d %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane, rc); return -ENOMEM; } /* * Buffers may be accessed by CPU as well, we do not * know at this point, so get both and send to HW layer */ rc = cam_mem_get_cpu_buf(io_cfg[i].mem_handle[plane], io_addr[plane] += io_cfg[i].offsets[plane]; } if (need_cpu_map) { rc = cam_mem_get_cpu_buf( io_cfg[i].mem_handle[plane], &cpu_addr[plane], &size); if (rc) { CAM_ERR(CAM_FD, "unable to get buf address"); CAM_ERR(CAM_FD, "Invalid cpu buf %d %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane, rc); return rc; } io_addr[plane] += io_cfg[i].offsets[plane]; cpu_addr[plane] += io_cfg[i].offsets[plane]; } CAM_DBG(CAM_FD, "IO Address[%d][%d] : %pK, %pK", io_cfg[i].direction, plane, io_addr[plane], Loading