From 341766fe3d709f3113788a1a6ae37c4e2f2a88a0 Mon Sep 17 00:00:00 2001 From: Yanfeng Lee Date: Fri, 9 Aug 2024 03:32:01 +0000 Subject: [PATCH] Use old camera driver from branch android12-stable --- techpack/camera/Makefile | 13 +- techpack/camera/config/konacamera.conf | 6 +- techpack/camera/config/konacameraconf.h | 3 +- techpack/camera/config/litocamera.conf | 1 - techpack/camera/config/litocameraconf.h | 2 +- techpack/camera/drivers/Makefile | 3 - .../drivers/cam_cdm/cam_cdm_virtual_core.c | 20 +- .../drivers/cam_core/cam_context_utils.c | 12 +- .../cam_custom_hw_mgr/cam_custom_hw_mgr.c | 2 - .../drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c | 50 +- .../cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c | 39 + .../camera/drivers/cam_icp/cam_icp_context.c | 4 - .../icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c | 19 +- .../camera/drivers/cam_isp/cam_isp_context.c | 338 +------ .../camera/drivers/cam_isp/cam_isp_context.h | 14 +- .../cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c | 45 +- .../hw_utils/cam_isp_packet_parser.c | 4 - .../isp_hw/ife_csid_hw/cam_ife_csid_core.c | 25 - .../isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c | 10 - .../cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c | 16 +- techpack/camera/drivers/cam_log/cam_log.c | 194 ---- techpack/camera/drivers/cam_log/cam_log.h | 23 - .../cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c | 7 - .../camera/drivers/cam_req_mgr/cam_mem_mgr.c | 133 +-- .../camera/drivers/cam_req_mgr/cam_mem_mgr.h | 33 +- .../drivers/cam_req_mgr/cam_mem_mgr_api.h | 9 - .../drivers/cam_req_mgr/cam_req_mgr_core.c | 207 ++--- .../drivers/cam_req_mgr/cam_req_mgr_core.h | 1 + .../drivers/cam_req_mgr/cam_req_mgr_dev.c | 3 +- .../drivers/cam_req_mgr/cam_req_mgr_util.c | 125 +-- .../drivers/cam_req_mgr/cam_req_mgr_util.h | 55 +- .../cam_actuator/cam_actuator_core.c | 17 +- .../cam_sensor_module/cam_cci/cam_cci_core.c | 285 ++---- .../cam_sensor_module/cam_cci/cam_cci_dev.h | 6 +- .../cam_csiphy/cam_csiphy_core.c | 34 +- .../cam_eeprom/cam_eeprom_core.c | 29 +- .../cam_flash/cam_flash_core.c | 116 +-- .../cam_sensor_module/cam_ois/Lc898128.c | 33 +- .../cam_sensor_module/cam_ois/Lc898128.h | 1 + .../cam_sensor_module/cam_ois/Makefile | 2 +- .../cam_sensor_module/cam_ois/Sem1215.c | 190 ++-- .../cam_sensor_module/cam_ois/Sem1215.h | 78 +- .../cam_sensor_module/cam_ois/cam_ois_core.c | 842 ++++++++---------- .../cam_sensor_module/cam_ois/cam_ois_dev.h | 12 +- .../cam_res_mgr/cam_res_mgr.c | 3 + .../cam_sensor/cam_sensor_core.c | 38 +- .../cam_sensor/cam_sensor_dev.h | 3 - .../cam_sensor/cam_sensor_soc.c | 14 - .../cam_sensor_io/cam_sensor_cci_i2c.c | 17 +- .../cam_sensor_io/cam_sensor_i2c.h | 7 +- .../cam_sensor_io/cam_sensor_io.c | 12 +- .../cam_sensor_io/cam_sensor_io.h | 7 +- .../cam_sensor_utils/cam_sensor_cmn_header.h | 4 - .../cam_sensor_utils/cam_sensor_util.c | 38 +- .../camera/drivers/cam_smmu/cam_smmu_api.c | 31 +- .../drivers/cam_sync/cam_sync_private.h | 2 +- .../drivers/cam_utils/cam_packet_util.c | 33 +- .../drivers/cam_utils/cam_packet_util.h | 1 - .../camera/drivers/cam_utils/cam_soc_util.c | 32 +- .../camera/drivers/cam_utils/cam_soc_util.h | 14 + .../camera/include/uapi/media/cam_sensor.h | 10 +- 61 files changed, 925 insertions(+), 2402 deletions(-) delete mode 100644 techpack/camera/drivers/cam_log/cam_log.c delete mode 100644 techpack/camera/drivers/cam_log/cam_log.h diff --git a/techpack/camera/Makefile b/techpack/camera/Makefile index 6dbae43a4106..9e0b13785b58 100644 --- a/techpack/camera/Makefile +++ b/techpack/camera/Makefile @@ -9,6 +9,10 @@ ifeq ($(CONFIG_ARCH_LITO), y) include $(srctree)/techpack/camera/config/litocamera.conf endif +ifeq ($(CONFIG_ARCH_BENGAL), y) +include $(srctree)/techpack/camera/config/bengalcamera.conf +endif + ifeq ($(CONFIG_ARCH_KONA), y) LINUXINCLUDE += \ -include $(srctree)/techpack/camera/config/konacameraconf.h @@ -19,7 +23,12 @@ LINUXINCLUDE += \ -include $(srctree)/techpack/camera/config/litocameraconf.h endif -ifdef CONFIG_SPECTRA_CAMERA_KONA +ifeq ($(CONFIG_ARCH_BENGAL), y) +LINUXINCLUDE += \ + -include $(srctree)/techpack/camera/config/bengalcameraconf.h +endif + +ifdef CONFIG_SPECTRA_CAMERA # Use USERINCLUDE when you must reference the UAPI directories only. USERINCLUDE += \ -I$(srctree)/techpack/camera/include/uapi @@ -30,4 +39,6 @@ LINUXINCLUDE += \ -I$(srctree)/techpack/camera/include/uapi \ -I$(srctree)/techpack/camera/include obj-y += drivers/ +else +$(info Target not found) endif diff --git a/techpack/camera/config/konacamera.conf b/techpack/camera/config/konacamera.conf index bae5fda7a592..9b08bcb80c2b 100644 --- a/techpack/camera/config/konacamera.conf +++ b/techpack/camera/config/konacamera.conf @@ -1,5 +1 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (c) 2019, The Linux Foundation. All rights reserved. - -export CONFIG_SPECTRA_CAMERA_KONA=y -export CONFIG_SPECTRA_CAMERA=y +export CONFIG_SPECTRA_CAMERA=y \ No newline at end of file diff --git a/techpack/camera/config/konacameraconf.h b/techpack/camera/config/konacameraconf.h index 9f32793df01e..875b95587ab6 100644 --- a/techpack/camera/config/konacameraconf.h +++ b/techpack/camera/config/konacameraconf.h @@ -3,5 +3,6 @@ * Copyright (c) 2019, The Linux Foundation. All rights reserved. */ -#define CONFIG_SPECTRA_CAMERA_KONA 1 + #define CONFIG_SPECTRA_CAMERA 1 + diff --git a/techpack/camera/config/litocamera.conf b/techpack/camera/config/litocamera.conf index a7da032a4c00..f9f033bad333 100644 --- a/techpack/camera/config/litocamera.conf +++ b/techpack/camera/config/litocamera.conf @@ -1,6 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only # Copyright (c) 2019, The Linux Foundation. All rights reserved. -export CONFIG_SPECTRA_CAMERA_KONA=y export CONFIG_SPECTRA_CAMERA=y export CONFIG_MI7250_CAMERA=y diff --git a/techpack/camera/config/litocameraconf.h b/techpack/camera/config/litocameraconf.h index d62fc1c87ef6..bb006b46c060 100644 --- a/techpack/camera/config/litocameraconf.h +++ b/techpack/camera/config/litocameraconf.h @@ -3,6 +3,6 @@ * Copyright (c) 2019, The Linux Foundation. All rights reserved. */ -#define CONFIG_SPECTRA_CAMERA_KONA 1 #define CONFIG_SPECTRA_CAMERA 1 #define CONFIG_MI7250_CAMERA 1 + diff --git a/techpack/camera/drivers/Makefile b/techpack/camera/drivers/Makefile index 1bb8d0ef343a..13edfb587419 100644 --- a/techpack/camera/drivers/Makefile +++ b/techpack/camera/drivers/Makefile @@ -12,6 +12,3 @@ obj-$(CONFIG_SPECTRA_CAMERA) += cam_jpeg/ obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd/ obj-$(CONFIG_SPECTRA_CAMERA) += cam_lrme/ obj-$(CONFIG_SPECTRA_CAMERA) += cam_cust/ - -cameralog-y := cam_log/cam_log.o -obj-$(CONFIG_SPECTRA_CAMERA) += cameralog.o diff --git a/techpack/camera/drivers/cam_cdm/cam_cdm_virtual_core.c b/techpack/camera/drivers/cam_cdm/cam_cdm_virtual_core.c index bd8d86f9462b..5abca3939338 100644 --- a/techpack/camera/drivers/cam_cdm/cam_cdm_virtual_core.c +++ b/techpack/camera/drivers/cam_cdm/cam_cdm_virtual_core.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -116,7 +115,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, cdm_cmd->cmd[i].len) { CAM_ERR(CAM_CDM, "Not enough buffer"); rc = -EINVAL; - goto end; + break; } CAM_DBG(CAM_CDM, "hdl=%x vaddr=%pK offset=%d cmdlen=%d:%zu", @@ -134,7 +133,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, "write failed for cnt=%d:%d len %u", i, req->data->cmd_arrary_count, cdm_cmd->cmd[i].len); - goto end; + break; } } else { CAM_ERR(CAM_CDM, @@ -145,7 +144,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, "Sanity check failed for cmd_count=%d cnt=%d", i, req->data->cmd_arrary_count); rc = -EINVAL; - goto end; + break; } if (!rc) { struct cam_cdm_work_payload *payload; @@ -162,7 +161,7 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, GFP_KERNEL); if (!node) { rc = -ENOMEM; - goto end; + break; } node->request_type = CAM_HW_CDM_BL_CB_CLIENT; node->client_hdl = req->handle; @@ -194,20 +193,9 @@ int cam_virtual_cdm_submit_bl(struct cam_hw_info *cdm_hw, if (!rc && (core->bl_tag == 63)) core->bl_tag = 0; } - - if (req->data->type == CAM_CDM_BL_CMD_TYPE_MEM_HANDLE) - cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle); } mutex_unlock(&client->lock); return rc; - -end: - if (req->data->type == CAM_CDM_BL_CMD_TYPE_MEM_HANDLE) - cam_mem_put_cpu_buf(cdm_cmd->cmd[i].bl_addr.mem_handle); - - mutex_unlock(&client->lock); - return rc; - } int cam_virtual_cdm_probe(struct platform_device *pdev) diff --git a/techpack/camera/drivers/cam_core/cam_context_utils.c b/techpack/camera/drivers/cam_core/cam_context_utils.c index b65cff2be01e..480d66e60606 100644 --- a/techpack/camera/drivers/cam_core/cam_context_utils.c +++ b/techpack/camera/drivers/cam_core/cam_context_utils.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -301,7 +300,6 @@ int32_t cam_context_config_dev_to_hw( (cmd->offset >= (len - sizeof(struct cam_packet)))) { CAM_ERR(CAM_CTXT, "Not enough buf, len : %zu offset = %llu", len, cmd->offset); - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return -EINVAL; } @@ -323,7 +321,6 @@ int32_t cam_context_config_dev_to_hw( rc = -EFAULT; } - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } @@ -385,7 +382,6 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, if ((len < sizeof(struct cam_packet)) || (cmd->offset >= (len - sizeof(struct cam_packet)))) { CAM_ERR(CAM_CTXT, "Not enough buf"); - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return -EINVAL; } @@ -504,7 +500,7 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, req->in_map_entries[j].sync_id, rc); } } - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); + return rc; put_ref: for (--i; i >= 0; i--) { @@ -518,7 +514,6 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx, req->ctx = NULL; spin_unlock(&ctx->lock); - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } @@ -1112,7 +1107,6 @@ static int cam_context_dump_context(struct cam_context *ctx, if (dump_args->offset >= buf_len) { CAM_WARN(CAM_CTXT, "dump buffer overshoot offset %zu len %zu", dump_args->offset, buf_len); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } @@ -1124,7 +1118,6 @@ static int cam_context_dump_context(struct cam_context *ctx, if (remain_len < min_len) { CAM_WARN(CAM_CTXT, "dump buffer exhaust remain %zu min %u", remain_len, min_len); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } dst = (uint8_t *)cpu_addr + dump_args->offset; @@ -1149,8 +1142,7 @@ static int cam_context_dump_context(struct cam_context *ctx, hdr->size = hdr->word_size * (addr - start); dump_args->offset += hdr->size + sizeof(struct cam_context_dump_header); - cam_mem_put_cpu_buf(dump_args->buf_handle); - return 0; + return rc; } int32_t cam_context_dump_dev_to_hw(struct cam_context *ctx, diff --git a/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c b/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c index d9c349f0b7dd..2fed429ad13a 100644 --- a/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c +++ b/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -1130,7 +1129,6 @@ static int cam_custom_mgr_prepare_hw_update(void *hw_mgr_priv, } cam_custom_add_io_buffers(hw_mgr->img_iommu_hdl, prepare); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); return 0; } diff --git a/techpack/camera/drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c b/techpack/camera/drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c index c736d901c8e6..e99ddb2567a9 100644 --- a/techpack/camera/drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c +++ b/techpack/camera/drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -54,9 +53,7 @@ static int cam_fd_mgr_util_packet_validate(struct cam_packet *packet, } /* All buffers must come through io config, do not support patching */ - if (packet->num_patches || - !packet->num_io_configs || - !packet->num_cmd_buf) { + if (packet->num_patches || !packet->num_io_configs) { CAM_ERR(CAM_FD, "wrong number of cmd/patch info: %u %u", packet->num_cmd_buf, packet->num_patches); return -EINVAL; @@ -543,33 +540,6 @@ static int cam_fd_mgr_util_get_buf_map_requirement(uint32_t direction, return 0; } -static int cam_fd_mgr_put_cpu_buf(struct cam_hw_prepare_update_args *prepare) -{ - int i, rc; - uint32_t plane; - bool need_io_map, need_cpu_map; - struct cam_buf_io_cfg *io_cfg; - - io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *) - &prepare->packet->payload + prepare->packet->io_configs_offset); - - if (!io_cfg) - return -EINVAL; - - for (i = 0; i < prepare->packet->num_io_configs; i++) { - 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 || !need_cpu_map) - continue; - - for (plane = 0; plane < CAM_PACKET_MAX_PLANES; plane++) - cam_mem_put_cpu_buf(io_cfg[i].mem_handle[plane]); - } - 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, @@ -666,8 +636,6 @@ static int cam_fd_mgr_util_prepare_io_buf_info(int32_t iommu_hdl, "Invalid cpu buf %d %d %d", io_cfg[i].direction, io_cfg[i].resource_type, plane); - cam_mem_put_cpu_buf( - io_cfg[i].mem_handle[plane]); rc = -EINVAL; return rc; } @@ -901,6 +869,7 @@ static int cam_fd_mgr_util_submit_frame(void *priv, void *data) } mutex_unlock(&hw_device->lock); mutex_unlock(&hw_mgr->frame_req_mutex); + CAM_DBG(CAM_FD, "FrameSubmit : Frame[%lld] HW is busy", frame_req->request_id); return -EBUSY; } @@ -941,6 +910,7 @@ static int cam_fd_mgr_util_submit_frame(void *priv, void *data) hw_device->ready_to_process = false; hw_device->cur_hw_ctx = hw_ctx; hw_device->req_id = frame_req->request_id; + mutex_unlock(&hw_device->lock); mutex_unlock(&hw_mgr->frame_req_mutex); @@ -1496,6 +1466,7 @@ static int cam_fd_mgr_hw_flush_ctx(void *hw_mgr_priv, continue; list_del_init(&frame_req->list); + CAM_DBG(CAM_FD, "Request deleted from frame processing list"); mutex_lock(&hw_device->lock); if ((hw_device->ready_to_process == true) || (hw_device->cur_hw_ctx != hw_ctx)) @@ -1649,7 +1620,6 @@ static int cam_fd_mgr_hw_dump( if (fd_dump_args.buf_len <= dump_args->offset) { CAM_WARN(CAM_FD, "dump offset overshoot len %zu offset %zu", fd_dump_args.buf_len, dump_args->offset); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } remain_len = fd_dump_args.buf_len - dump_args->offset; @@ -1659,7 +1629,6 @@ static int cam_fd_mgr_hw_dump( if (remain_len < min_len) { CAM_WARN(CAM_FD, "dump buffer exhaust remain %zu min %u", remain_len, min_len); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } @@ -1691,14 +1660,12 @@ static int cam_fd_mgr_hw_dump( if (rc) { CAM_ERR(CAM_FD, "Hw Dump cmd fails req %lld rc %d", frame_req->request_id, rc); - cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } } CAM_DBG(CAM_FD, "Offset before %zu after %zu", dump_args->offset, fd_dump_args.offset); dump_args->offset = fd_dump_args.offset; - cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } @@ -1834,7 +1801,7 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, &prestart_args, &kmd_buf); if (rc) { CAM_ERR(CAM_FD, "Error in hw update entries %d", rc); - goto put_cpu_buf; + goto error; } /* get a free frame req from free list */ @@ -1843,8 +1810,7 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, if (rc || !frame_req) { CAM_ERR(CAM_FD, "Get frame_req failed, rc=%d, hw_ctx=%pK", rc, hw_ctx); - rc = -ENOMEM; - goto put_cpu_buf; + return -ENOMEM; } /* Setup frame request info and queue to pending list */ @@ -1859,13 +1825,9 @@ static int cam_fd_mgr_hw_prepare_update(void *hw_mgr_priv, */ prepare->priv = frame_req; - cam_fd_mgr_put_cpu_buf(prepare); CAM_DBG(CAM_FD, "FramePrepare : Frame[%lld]", frame_req->request_id); return 0; - -put_cpu_buf: - cam_fd_mgr_put_cpu_buf(prepare); error: return rc; } diff --git a/techpack/camera/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c b/techpack/camera/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c index c3d5a68c6910..d05530ae4e17 100644 --- a/techpack/camera/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c +++ b/techpack/camera/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.c @@ -71,6 +71,39 @@ static int cam_fd_hw_soc_util_setup_regbase_indices( return 0; } +static int cam_fd_soc_set_clk_flags(struct cam_hw_soc_info *soc_info) +{ + int i, rc = 0; + + if (soc_info->num_clk > CAM_SOC_MAX_CLK) { + CAM_ERR(CAM_FD, "Invalid num clk %d", soc_info->num_clk); + return -EINVAL; + } + + /* set memcore and mem periphery logic flags to 0 */ + for (i = 0; i < soc_info->num_clk; i++) { + if ((strcmp(soc_info->clk_name[i], "fd_core_clk") == 0) || + (strcmp(soc_info->clk_name[i], "fd_core_uar_clk") == + 0)) { + rc = cam_soc_util_set_clk_flags(soc_info, i, + CLKFLAG_NORETAIN_MEM); + if (rc) + CAM_ERR(CAM_FD, + "Failed in NORETAIN_MEM i=%d, rc=%d", + i, rc); + + cam_soc_util_set_clk_flags(soc_info, i, + CLKFLAG_NORETAIN_PERIPH); + if (rc) + CAM_ERR(CAM_FD, + "Failed in NORETAIN_PERIPH i=%d, rc=%d", + i, rc); + } + } + + return rc; +} + void cam_fd_soc_register_write(struct cam_hw_soc_info *soc_info, enum cam_fd_reg_base reg_base, uint32_t reg_offset, uint32_t reg_value) { @@ -195,6 +228,12 @@ int cam_fd_soc_init_resources(struct cam_hw_soc_info *soc_info, return rc; } + rc = cam_fd_soc_set_clk_flags(soc_info); + if (rc) { + CAM_ERR(CAM_FD, "failed in set_clk_flags rc=%d", rc); + goto release_res; + } + soc_private = kzalloc(sizeof(struct cam_fd_soc_private), GFP_KERNEL); if (!soc_private) { rc = -ENOMEM; diff --git a/techpack/camera/drivers/cam_icp/cam_icp_context.c b/techpack/camera/drivers/cam_icp/cam_icp_context.c index 4d6e0ab352a1..6a9f57b65f68 100644 --- a/techpack/camera/drivers/cam_icp/cam_icp_context.c +++ b/techpack/camera/drivers/cam_icp/cam_icp_context.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -157,7 +156,6 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, CAM_ERR(CAM_CTXT, "Invalid offset, len: %zu cmd offset: %llu sizeof packet: %zu", len, cmd->offset, sizeof(struct cam_packet)); - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return -EINVAL; } @@ -169,7 +167,6 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, if (rc) { CAM_ERR(CAM_CTXT, "Invalid packet params, remain length: %zu", remain_len); - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } @@ -184,7 +181,6 @@ static int __cam_icp_config_dev_in_ready(struct cam_context *ctx, if (rc) CAM_ERR(CAM_ICP, "Failed to prepare device"); - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } diff --git a/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c b/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c index 0358deedabfb..40bb64848b39 100644 --- a/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c +++ b/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. - * */ #include @@ -88,7 +86,7 @@ static int cam_icp_dump_io_cfg(struct cam_icp_hw_ctx_data *ctx_data, used = 0; } } - cam_mem_put_cpu_buf(buf_handle); + return rc; } @@ -4217,15 +4215,13 @@ static int cam_icp_mgr_pkt_validation(struct cam_packet *packet) return -EINVAL; } - if (!packet->num_io_configs || - packet->num_io_configs > IPE_IO_IMAGES_MAX) { + if (packet->num_io_configs > IPE_IO_IMAGES_MAX) { CAM_ERR(CAM_ICP, "Invalid number of io configs: %d %d", IPE_IO_IMAGES_MAX, packet->num_io_configs); return -EINVAL; } - if (!packet->num_cmd_buf || - packet->num_cmd_buf > CAM_ICP_CTX_MAX_CMD_BUFFERS) { + if (packet->num_cmd_buf > CAM_ICP_CTX_MAX_CMD_BUFFERS) { CAM_ERR(CAM_ICP, "Invalid number of cmd buffers: %d %d", CAM_ICP_CTX_MAX_CMD_BUFFERS, packet->num_cmd_buf); return -EINVAL; @@ -4288,7 +4284,6 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr, *fw_cmd_buf_iova_addr = (*fw_cmd_buf_iova_addr + cmd_desc[i].offset); - rc = cam_mem_get_cpu_buf(cmd_desc[i].mem_handle, &cpu_addr, &len); if (rc || !cpu_addr) { @@ -4305,12 +4300,9 @@ static int cam_icp_mgr_process_cmd_desc(struct cam_icp_hw_mgr *hw_mgr, ((len - cmd_desc[i].offset) < cmd_desc[i].length)) { CAM_ERR(CAM_ICP, "Invalid offset or length"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); return -EINVAL; } cpu_addr = cpu_addr + cmd_desc[i].offset; - - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } } @@ -5266,7 +5258,6 @@ static int cam_icp_mgr_hw_dump(void *hw_priv, void *hw_dump_args) req_ts.tv_nsec/NSEC_PER_USEC, cur_ts.tv_sec, cur_ts.tv_nsec/NSEC_PER_USEC); - rc = cam_mem_get_cpu_buf(dump_args->buf_handle, &icp_dump_args.cpu_addr, &icp_dump_args.buf_len); if (rc) { @@ -5277,7 +5268,6 @@ static int cam_icp_mgr_hw_dump(void *hw_priv, void *hw_dump_args) if (icp_dump_args.buf_len <= dump_args->offset) { CAM_WARN(CAM_ICP, "dump buffer overshoot len %zu offset %zu", icp_dump_args.buf_len, dump_args->offset); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } @@ -5288,7 +5278,6 @@ static int cam_icp_mgr_hw_dump(void *hw_priv, void *hw_dump_args) if (remain_len < min_len) { CAM_WARN(CAM_ICP, "dump buffer exhaust remain %zu min %u", remain_len, min_len); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } @@ -5315,8 +5304,6 @@ static int cam_icp_mgr_hw_dump(void *hw_priv, void *hw_dump_args) CAM_DBG(CAM_ICP, "Offset before %zu after %zu", dump_args->offset, icp_dump_args.offset); dump_args->offset = icp_dump_args.offset; - - cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } diff --git a/techpack/camera/drivers/cam_isp/cam_isp_context.c b/techpack/camera/drivers/cam_isp/cam_isp_context.c index 44bf27e1c40c..d890af0ba824 100644 --- a/techpack/camera/drivers/cam_isp/cam_isp_context.c +++ b/techpack/camera/drivers/cam_isp/cam_isp_context.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -334,8 +334,7 @@ static int cam_isp_ctx_dump_req( CAM_ERR(CAM_ISP, "Invalid offset exp %u actual %u", req_isp->cfg[i].offset, (uint32_t)len); - cam_mem_put_cpu_buf(req_isp->cfg[i].handle); - return -EINVAL; + return rc; } remain_len = len - req_isp->cfg[i].offset; @@ -345,8 +344,7 @@ static int cam_isp_ctx_dump_req( "Invalid len exp %u remain_len %u", req_isp->cfg[i].len, (uint32_t)remain_len); - cam_mem_put_cpu_buf(req_isp->cfg[i].handle); - return -EINVAL; + return rc; } buf_start = (uint32_t *)((uint8_t *) buf_addr + @@ -370,7 +368,6 @@ static int cam_isp_ctx_dump_req( } else { cam_cdm_util_dump_cmd_buf(buf_start, buf_end); } - cam_mem_put_cpu_buf(req_isp->cfg[i].handle); } } return rc; @@ -757,7 +754,6 @@ static int __cam_isp_ctx_handle_buf_done_for_req_list( if (req_isp->bubble_detected && req_isp->bubble_report) { req_isp->num_acked = 0; - req_isp->num_deferred_acks = 0; req_isp->bubble_detected = false; list_del_init(&req->list); atomic_set(&ctx_isp->process_bubble, 0); @@ -945,112 +941,12 @@ static int __cam_isp_ctx_handle_buf_done_for_request( return rc; } -static int __cam_isp_handle_deferred_buf_done( - struct cam_isp_context *ctx_isp, - struct cam_ctx_request *req, - bool bubble_handling, - uint32_t status) -{ - int i, j; - int rc = 0; - struct cam_isp_ctx_req *req_isp = - (struct cam_isp_ctx_req *) req->req_priv; - struct cam_context *ctx = ctx_isp->base; - - CAM_DBG(CAM_ISP, - "ctx[%d] : Req %llu : Handling %d deferred buf_dones acked=%d, bubble_handling=%d", - ctx->ctx_id, req->request_id, req_isp->num_deferred_acks, - req_isp->num_acked, bubble_handling); - - for (i = 0; i < req_isp->num_deferred_acks; i++) { - j = req_isp->deferred_fence_map_index[i]; - - CAM_DBG(CAM_ISP, - "ctx[%d] : Sync with status=%d, req %lld res 0x%x sync_id 0x%x", - ctx->ctx_id, status, - req->request_id, - req_isp->fence_map_out[j].resource_handle, - req_isp->fence_map_out[j].sync_id); - - if (req_isp->fence_map_out[j].sync_id == -1) { - CAM_WARN(CAM_ISP, - "ctx[%d] Deferred done already signaled, req=%llu, j=%d, res=0x%x", - ctx->ctx_id, req->request_id, j, - req_isp->fence_map_out[j].resource_handle); - continue; - } - - if (!bubble_handling) { - CAM_WARN(CAM_ISP, - "ctx[%d] : Req %llu, status=%d res=0x%x should never happen", - ctx->ctx_id, req->request_id, status, - req_isp->fence_map_out[j].resource_handle); - - rc = cam_sync_signal(req_isp->fence_map_out[j].sync_id, - status); - if (rc) { - CAM_ERR(CAM_ISP, - "ctx[%d] Sync failed Req %llu, sync_id %d status %d rc %d", - ctx->ctx_id, req->request_id, - req_isp->fence_map_out[j].sync_id, - status, rc); - } else { - req_isp->num_acked++; - req_isp->fence_map_out[j].sync_id = -1; - } - } else { - req_isp->num_acked++; - } - } - - CAM_DBG(CAM_ISP, - "ctx[%d] : Req %llu : Handled %d deferred buf_dones num_acked=%d, map_out=%d", - ctx->ctx_id, req->request_id, req_isp->num_deferred_acks, - req_isp->num_acked, req_isp->num_fence_map_out); - - req_isp->num_deferred_acks = 0; - - return rc; -} - -static int __cam_isp_ctx_handle_deferred_buf_done_in_bubble( - struct cam_isp_context *ctx_isp, - struct cam_ctx_request *req) -{ - int rc = 0; - struct cam_context *ctx = ctx_isp->base; - struct cam_isp_ctx_req *req_isp; - - req_isp = (struct cam_isp_ctx_req *)req->req_priv; - - if (req_isp->num_deferred_acks) - rc = __cam_isp_handle_deferred_buf_done(ctx_isp, req, - req_isp->bubble_report, - CAM_SYNC_STATE_SIGNALED_ERROR); - - if (req_isp->num_acked > req_isp->num_fence_map_out) { - /* Should not happen */ - CAM_ERR(CAM_ISP, - "WARNING:req_id %lld num_acked %d > map_out %d, ctx %u", - req->request_id, req_isp->num_acked, - req_isp->num_fence_map_out, ctx->ctx_id); - WARN_ON(req_isp->num_acked > req_isp->num_fence_map_out); - } - - if (req_isp->num_acked == req_isp->num_fence_map_out) - rc = __cam_isp_ctx_handle_buf_done_for_req_list(ctx_isp, req); - - return rc; -} - - static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr( struct cam_isp_context *ctx_isp, struct cam_ctx_request *req, struct cam_isp_hw_done_event_data *done, uint32_t bubble_state, - bool verify_consumed_addr, - bool defer_buf_done) + bool verify_consumed_addr) { int rc = 0; int i, j; @@ -1106,32 +1002,7 @@ static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr( continue; } - if (defer_buf_done) { - uint32_t deferred_indx = req_isp->num_deferred_acks; - - /* - * If we are handling this BUF_DONE event for a request - * that is still in wait_list, do not signal now, - * instead mark it as done and handle it later - - * if this request is going into BUBBLE state later - * it will automatically be re-applied. If this is not - * going into BUBBLE, signal fences later. - * Note - we will come here only if the last consumed - * address matches with this ports buffer. - */ - req_isp->deferred_fence_map_index[deferred_indx] = j; - req_isp->num_deferred_acks++; - CAM_DBG(CAM_ISP, - "ctx[%d] : Deferred buf done for %llu bubble state %d recovery %d", - ctx->ctx_id, req->request_id, bubble_state, - req_isp->bubble_report); - CAM_DBG(CAM_ISP, - "ctx[%d] : Deferred info: def_acks=%d, j=%d, hld=0x%x, sync_id=%d", - ctx->ctx_id, req_isp->num_deferred_acks, j, - req_isp->fence_map_out[j].resource_handle, - req_isp->fence_map_out[j].sync_id); - continue; - } else if (!req_isp->bubble_detected) { + if (!req_isp->bubble_detected) { CAM_DBG(CAM_ISP, "Sync with success: req %lld res 0x%x fd 0x%x, ctx %u", req->request_id, @@ -1144,13 +1015,6 @@ static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr( if (rc) CAM_DBG(CAM_ISP, "Sync failed with rc = %d", rc); - - /* Process deferred buf_done acks */ - if (req_isp->num_deferred_acks) - __cam_isp_handle_deferred_buf_done(ctx_isp, - req, false, - CAM_SYNC_STATE_SIGNALED_SUCCESS); - } else if (!req_isp->bubble_report) { CAM_ERR(CAM_ISP, "Sync with failure: req %lld res 0x%x fd 0x%x, ctx %u", @@ -1164,13 +1028,6 @@ static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr( if (rc) CAM_ERR(CAM_ISP, "Sync failed with rc = %d", rc); - - /* Process deferred buf_done acks */ - if (req_isp->num_deferred_acks) - __cam_isp_handle_deferred_buf_done(ctx_isp, - req, false, - CAM_SYNC_STATE_SIGNALED_ERROR); - } else { /* * Ignore the buffer done if bubble detect is on @@ -1182,12 +1039,6 @@ static int __cam_isp_ctx_handle_buf_done_for_request_verify_addr( CAM_DBG(CAM_ISP, "buf done with bubble state %d recovery %d", bubble_state, req_isp->bubble_report); - /* Process deferred buf_done acks */ - if (req_isp->num_deferred_acks) - __cam_isp_handle_deferred_buf_done(ctx_isp, req, - true, - CAM_SYNC_STATE_SIGNALED_ERROR); - continue; } @@ -1235,8 +1086,7 @@ static int __cam_isp_ctx_handle_buf_done( struct cam_isp_hw_done_event_data done_next_req; if (list_empty(&ctx->active_req_list)) { - CAM_WARN(CAM_ISP, - "Buf done with no active request ctx %u", ctx->ctx_id); + CAM_DBG(CAM_ISP, "Buf done with no active request"); return 0; } @@ -1336,51 +1186,7 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr( struct cam_context *ctx = ctx_isp->base; if (list_empty(&ctx->active_req_list)) { - CAM_WARN(CAM_ISP, - "Buf done with no active request bubble_state=%d", - bubble_state); - - if (!list_empty(&ctx->wait_req_list)) { - struct cam_isp_ctx_req *req_isp; - - req = list_first_entry(&ctx->wait_req_list, - struct cam_ctx_request, list); - CAM_WARN(CAM_ISP, - "Buf done with no active req, but with req in wait list, req %llu", - req->request_id); - req_isp = (struct cam_isp_ctx_req *) req->req_priv; - - /* - * Verify consumed address for this request to make sure - * we are handling the buf_done for the correct - * buffer. Also defer actual buf_done handling, i.e - * do not signal the fence as this request may go into - * Bubble state eventully. - */ - rc = - __cam_isp_ctx_handle_buf_done_for_request_verify_addr( - ctx_isp, req, done, bubble_state, true, true); - } else if (!list_empty(&ctx->pending_req_list)) { - struct cam_isp_ctx_req *req_isp; - - req = list_first_entry(&ctx->pending_req_list, - struct cam_ctx_request, list); - - CAM_WARN(CAM_ISP, - "Buf done with no active req, but req in pending list, req %llu", - req->request_id); - - req_isp = (struct cam_isp_ctx_req *) req->req_priv; - - /* - * We saw the case that the hw config is blocked due - * to some reason, then we get the reg upd and bufdone - * before the req is added to wait req list. - */ - rc = - __cam_isp_ctx_handle_buf_done_for_request_verify_addr( - ctx_isp, req, done, bubble_state, true, true); - } + CAM_DBG(CAM_ISP, "Buf done with no active request"); return 0; } @@ -1408,7 +1214,7 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr( */ rc = __cam_isp_ctx_handle_buf_done_for_request_verify_addr( ctx_isp, req, done, bubble_state, - !irq_delay_detected, false); + !irq_delay_detected); /* * Verify the consumed address for next req all the time, @@ -1418,7 +1224,7 @@ static int __cam_isp_ctx_handle_buf_done_verify_addr( if (!rc && irq_delay_detected) rc = __cam_isp_ctx_handle_buf_done_for_request_verify_addr( ctx_isp, next_req, done, - bubble_state, true, false); + bubble_state, true); return rc; } @@ -1712,16 +1518,6 @@ static int __cam_isp_ctx_notify_sof_in_activated_state( "CDM callback detected for req: %lld, possible buf_done delay, waiting for buf_done", req->request_id); ctx_isp->bubble_frame_cnt = 0; - if (req_isp->num_fence_map_out == - req_isp->num_deferred_acks) { - __cam_isp_handle_deferred_buf_done( - ctx_isp, - req, - true, - CAM_SYNC_STATE_SIGNALED_ERROR); - __cam_isp_ctx_handle_buf_done_for_req_list( - ctx_isp, req); - } } else { CAM_DBG(CAM_ISP, "CDM callback not happened for req: %lld, possible CDM stuck or workqueue delay", @@ -2007,12 +1803,6 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp, ctx_isp->active_req_cnt++; CAM_DBG(CAM_REQ, "move request %lld to active list(cnt = %d), ctx %u", req->request_id, ctx_isp->active_req_cnt, ctx->ctx_id); - /* - * Handle the deferred buf done after moving - * the bubble req to active req list. - */ - __cam_isp_ctx_handle_deferred_buf_done_in_bubble( - ctx_isp, req); if ((req->request_id > ctx_isp->reported_req_id) && !req_isp->bubble_report) { @@ -2066,9 +1856,6 @@ static int __cam_isp_ctx_sof_in_epoch(struct cam_isp_context *ctx_isp, return -EINVAL; } - if (atomic_read(&ctx_isp->apply_in_progress)) - CAM_INFO(CAM_ISP, "Apply is in progress at the time of SOF"); - ctx_isp->frame_id++; ctx_isp->sof_timestamp_val = sof_event_data->timestamp; ctx_isp->boot_timestamp = sof_event_data->boot_time; @@ -3036,8 +2823,6 @@ static int __cam_isp_ctx_apply_req_in_activated_state( cfg.reapply = req_isp->reapply; cfg.cdm_reset_before_apply = req_isp->cdm_reset_before_apply; - atomic_set(&ctx_isp->apply_in_progress, 1); - rc = ctx->hw_mgr_intf->hw_config(ctx->hw_mgr_intf->hw_mgr_priv, &cfg); if (!rc) { spin_lock_bh(&ctx->lock); @@ -3072,7 +2857,6 @@ static int __cam_isp_ctx_apply_req_in_activated_state( "ctx_id:%d ,Can not apply (req %lld) the configuration, rc %d", ctx->ctx_id, apply->request_id, rc); } - atomic_set(&ctx_isp->apply_in_progress, 0); end: return rc; } @@ -3263,7 +3047,6 @@ static int __cam_isp_ctx_dump_in_top_state( spin_unlock_bh(&ctx->lock); CAM_WARN(CAM_ISP, "Dump buffer overshoot len %zu offset %zu", buf_len, dump_info->offset); - cam_mem_put_cpu_buf(dump_info->buf_handle); return -ENOSPC; } @@ -3275,7 +3058,6 @@ static int __cam_isp_ctx_dump_in_top_state( spin_unlock_bh(&ctx->lock); CAM_WARN(CAM_ISP, "Dump buffer exhaust remain %zu min %u", remain_len, min_len); - cam_mem_put_cpu_buf(dump_info->buf_handle); return -ENOSPC; } @@ -3314,17 +3096,20 @@ static int __cam_isp_ctx_dump_in_top_state( if (rc) { CAM_ERR(CAM_ISP, "Dump event fail %lld", req->request_id); - goto end; + spin_unlock_bh(&ctx->lock); + return rc; + } + if (dump_only_event_record) { + spin_unlock_bh(&ctx->lock); + return rc; } - if (dump_only_event_record) - goto end; - rc = __cam_isp_ctx_dump_req_info(ctx, req, cpu_addr, buf_len, &dump_info->offset); if (rc) { CAM_ERR(CAM_ISP, "Dump Req info fail %lld", req->request_id); - goto end; + spin_unlock_bh(&ctx->lock); + return rc; } spin_unlock_bh(&ctx->lock); @@ -3338,12 +3123,6 @@ static int __cam_isp_ctx_dump_in_top_state( &dump_args); dump_info->offset = dump_args.offset; } - cam_mem_put_cpu_buf(dump_info->buf_handle); - return rc; - -end: - spin_unlock_bh(&ctx->lock); - cam_mem_put_cpu_buf(dump_info->buf_handle); return rc; } @@ -3662,8 +3441,8 @@ static int __cam_isp_ctx_rdi_only_sof_in_top_state( ctx_isp->sof_timestamp_val = sof_event_data->timestamp; ctx_isp->boot_timestamp = sof_event_data->boot_time; - CAM_DBG(CAM_ISP, "frame id: %lld time stamp:%lld ctx %u", - ctx_isp->frame_id, ctx_isp->sof_timestamp_val, ctx->ctx_id); + CAM_DBG(CAM_ISP, "frame id: %lld time stamp:0x%llx", + ctx_isp->frame_id, ctx_isp->sof_timestamp_val); /* * notify reqmgr with sof signal. Note, due to scheduling delay @@ -3906,17 +3685,6 @@ static int __cam_isp_ctx_rdi_only_sof_in_bubble_state( CAM_DBG(CAM_ISP, "CDM callback detected for req: %lld, possible buf_done delay, waiting for buf_done", req->request_id); - if (req_isp->num_fence_map_out == - req_isp->num_deferred_acks) { - __cam_isp_handle_deferred_buf_done( - ctx_isp, - req, - true, - CAM_SYNC_STATE_SIGNALED_ERROR); - - __cam_isp_ctx_handle_buf_done_for_req_list( - ctx_isp, req); - } goto end; } else { CAM_DBG(CAM_ISP, @@ -4075,69 +3843,6 @@ static int __cam_isp_ctx_rdi_only_reg_upd_in_bubble_applied_state( return 0; } -static int __cam_isp_ctx_rdi_only_reg_upd_in_applied_state( - struct cam_isp_context *ctx_isp, void *evt_data) -{ - struct cam_ctx_request *req = NULL; - struct cam_context *ctx = ctx_isp->base; - struct cam_isp_ctx_req *req_isp; - uint64_t request_id = 0; - - if (list_empty(&ctx->wait_req_list)) { - CAM_ERR_RATE_LIMIT(CAM_ISP, - "Reg upd ack with no waiting req ctx %u active cnt %d", - ctx->ctx_id, ctx_isp->active_req_cnt); - - /* move the sub state machine to SOF sub state */ - ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF; - goto end; - } - - ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_EPOCH; - - req = list_first_entry(&ctx->wait_req_list, - struct cam_ctx_request, list); - list_del_init(&req->list); - - req_isp = (struct cam_isp_ctx_req *) req->req_priv; - - request_id = (req_isp->hw_update_data.packet_opcode_type == - CAM_ISP_PACKET_INIT_DEV) ? 0 : req->request_id; - - if (req_isp->num_fence_map_out != 0) { - list_add_tail(&req->list, &ctx->active_req_list); - ctx_isp->active_req_cnt++; - request_id = req->request_id; - CAM_DBG(CAM_REQ, - "move request %lld to active list(cnt = %d), ctx %u", - req->request_id, ctx_isp->active_req_cnt, ctx->ctx_id); - } else { - /* no io config, so the request is completed. */ - list_add_tail(&req->list, &ctx->free_req_list); - CAM_DBG(CAM_ISP, - "move active req %lld to free list(cnt = %d), ctx %u", - req->request_id, ctx_isp->active_req_cnt, ctx->ctx_id); - } - - if (request_id) { - ctx_isp->reported_req_id = request_id; - __cam_isp_ctx_send_sof_timestamp(ctx_isp, request_id, - CAM_REQ_MGR_SOF_EVENT_SUCCESS); - } - - CAM_DBG(CAM_ISP, "next Substate[%s] ctx %u", - __cam_isp_ctx_substate_val_to_type(ctx_isp->substate_activated), - ctx->ctx_id); - - __cam_isp_ctx_update_event_record(ctx_isp, CAM_ISP_CTX_EVENT_RUP, req); - - return 0; -end: - __cam_isp_ctx_update_event_record(ctx_isp, CAM_ISP_CTX_EVENT_RUP, NULL); - - return 0; -} - static struct cam_isp_ctx_irq_ops cam_isp_ctx_rdi_only_activated_state_machine_irq [CAM_ISP_CTX_ACTIVATED_MAX] = { @@ -4157,7 +3862,7 @@ static struct cam_isp_ctx_irq_ops .irq_ops = { __cam_isp_ctx_handle_error, __cam_isp_ctx_rdi_only_sof_in_applied_state, - __cam_isp_ctx_rdi_only_reg_upd_in_applied_state, + NULL, NULL, NULL, __cam_isp_ctx_buf_done_in_applied, @@ -4517,7 +4222,6 @@ static int __cam_isp_ctx_config_dev_in_top_state( 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->num_deferred_acks = 0; req_isp->bubble_detected = false; req_isp->cdm_reset_before_apply = false; @@ -4589,7 +4293,6 @@ static int __cam_isp_ctx_config_dev_in_top_state( __cam_isp_ctx_schedule_apply_req_offline(ctx_isp); } - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; put_ref: @@ -4603,7 +4306,6 @@ static int __cam_isp_ctx_config_dev_in_top_state( list_add_tail(&req->list, &ctx->free_req_list); spin_unlock_bh(&ctx->lock); - cam_mem_put_cpu_buf((int32_t) cmd->packet_handle); return rc; } diff --git a/techpack/camera/drivers/cam_isp/cam_isp_context.h b/techpack/camera/drivers/cam_isp/cam_isp_context.h index ab383d617d82..f3e2b3c25f9f 100644 --- a/techpack/camera/drivers/cam_isp/cam_isp_context.h +++ b/techpack/camera/drivers/cam_isp/cam_isp_context.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_ISP_CONTEXT_H_ @@ -144,13 +144,6 @@ struct cam_isp_ctx_irq_ops { * @num_acked: Count to track acked entried for output. * If count equals the number of fence out, it means * the request has been completed. - * @num_deferred_acks: Number of buf_dones/acks that are deferred to - * handle or signalled in special scenarios. - * Increment this count instead of num_acked and - * handle the events later where eventually - * increment num_acked. - * @deferred_fence_map_index Saves the indices of fence_map_out for which - * handling of buf_done is deferred. * @bubble_report: Flag to track if bubble report is active on * current request * @hw_update_data: HW update data for this request @@ -171,9 +164,6 @@ struct cam_isp_ctx_req { struct cam_hw_fence_map_entry fence_map_in[CAM_ISP_CTX_RES_MAX]; uint32_t num_fence_map_in; uint32_t num_acked; - uint32_t num_deferred_acks; - uint32_t deferred_fence_map_index[ - CAM_ISP_CTX_RES_MAX]; int32_t bubble_report; struct cam_isp_prepare_hw_update_data hw_update_data; ktime_t event_timestamp @@ -267,7 +257,6 @@ struct cam_isp_context_event_record { * @custom_enabled: Custom HW enabled for this ctx * @use_frame_header_ts: Use frame header for qtimer ts * @support_consumed_addr: Indicate whether HW has last consumed addr reg - * @apply_in_progress Whether request apply is in progress * @init_timestamp: Timestamp at which this context is initialized * @rxd_epoch: Indicate whether epoch has been received. Used to * decide whether to apply request in offline ctx @@ -313,7 +302,6 @@ struct cam_isp_context { bool custom_enabled; bool use_frame_header_ts; bool support_consumed_addr; - atomic_t apply_in_progress; unsigned int init_timestamp; atomic_t rxd_epoch; struct cam_req_mgr_core_workq *workq; diff --git a/techpack/camera/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/techpack/camera/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c index 45a8a80e8cd8..088ee1a79232 100644 --- a/techpack/camera/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +++ b/techpack/camera/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -4269,10 +4269,6 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args) bool res_rdi_context_set = false; uint32_t primary_rdi_src_res; uint32_t primary_rdi_out_res; -#ifdef CONFIG_CAMERA_CAS - uint32_t last_rdi_src_res, last_rdi_res; - uint32_t last_rdi_out_res; -#endif primary_rdi_src_res = CAM_ISP_HW_VFE_IN_MAX; primary_rdi_out_res = CAM_ISP_IFE_OUT_RES_MAX; @@ -4375,31 +4371,6 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args) goto cdm_streamoff; } -#ifdef CONFIG_CAMERA_CAS - /* Find out last rdi out resource */ - for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) { - hw_mgr_res = &ctx->res_list_ife_out[i]; - switch (hw_mgr_res->res_id) { - case CAM_ISP_IFE_OUT_RES_RDI_0: - case CAM_ISP_IFE_OUT_RES_RDI_1: - case CAM_ISP_IFE_OUT_RES_RDI_2: - case CAM_ISP_IFE_OUT_RES_RDI_3: - if (ctx->is_rdi_only_context) { - last_rdi_res = i; - last_rdi_out_res = hw_mgr_res->res_id; - } - default: - break; - } - } - - if (ctx->is_rdi_only_context) { - hw_mgr_res = &ctx->res_list_ife_out[last_rdi_res]; - hw_mgr_res->hw_res[0]->rdi_only_last_res = - ctx->is_rdi_only_context; - } -#endif - CAM_DBG(CAM_ISP, "START IFE OUT ... in ctx id:%d", ctx->ctx_index); /* start the IFE out devices */ @@ -4433,12 +4404,6 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args) primary_rdi_src_res = cam_convert_rdi_out_res_id_to_src(primary_rdi_out_res); -#ifdef CONFIG_CAMERA_CAS - if (last_rdi_out_res < CAM_ISP_IFE_OUT_RES_MAX) - last_rdi_src_res = - cam_convert_rdi_out_res_id_to_src(last_rdi_out_res); -#endif - CAM_DBG(CAM_ISP, "START IFE SRC ... in ctx id:%d", ctx->ctx_index); /* Start the IFE mux in devices */ @@ -4448,13 +4413,6 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args) ctx->is_rdi_only_context; } -#ifdef CONFIG_CAMERA_CAS - if (last_rdi_src_res == hw_mgr_res->res_id) { - hw_mgr_res->hw_res[0]->rdi_only_last_res = - ctx->is_rdi_only_context; - } -#endif - rc = cam_ife_hw_mgr_start_hw_res(hw_mgr_res, ctx); if (rc) { CAM_ERR(CAM_ISP, "Can not start IFE Mux (%d)", @@ -6770,7 +6728,6 @@ static int cam_ife_mgr_dump(void *hw_mgr_priv, void *args) } } dump_args->offset = isp_hw_dump_args.offset; - cam_mem_put_cpu_buf(dump_args->buf_handle); end: CAM_DBG(CAM_ISP, "offset %u", dump_args->offset); return rc; diff --git a/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c b/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c index c690aea3f4b4..2f1ad4d82f46 100644 --- a/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c +++ b/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -118,7 +117,6 @@ static int cam_isp_update_dual_config( (cmd_desc->offset >= (len - sizeof(struct cam_isp_dual_config)))) { CAM_ERR(CAM_ISP, "not enough buffer provided"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); return -EINVAL; } remain_len = len - cmd_desc->offset; @@ -129,7 +127,6 @@ static int cam_isp_update_dual_config( sizeof(struct cam_isp_dual_stripe_config)) > (remain_len - offsetof(struct cam_isp_dual_config, stripes))) { CAM_ERR(CAM_ISP, "not enough buffer for all the dual configs"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); return -EINVAL; } for (i = 0; i < dual_config->num_ports; i++) { @@ -187,7 +184,6 @@ static int cam_isp_update_dual_config( } end: - cam_mem_put_cpu_buf(cmd_desc->mem_handle); return rc; } diff --git a/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c b/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c index e563268d02b9..483c6e7c60f5 100644 --- a/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c +++ b/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c @@ -694,7 +694,6 @@ static int cam_ife_csid_global_reset(struct cam_ife_csid_hw *csid_hw) cam_io_w_mb(0x2, soc_info->reg_map[0].mem_base + csid_reg->rdi_reg[i]->csid_rdi_cfg0_addr); -#ifdef CONFIG_BOARD_PSYCHE /* reset SW regs first, then HW */ rc = cam_ife_csid_reset_regs(csid_hw, false); if (rc < 0) @@ -702,15 +701,6 @@ static int cam_ife_csid_global_reset(struct cam_ife_csid_hw *csid_hw) rc = cam_ife_csid_reset_regs(csid_hw, true); if (rc < 0) goto end; -#else - /* reset HW regs first, then SW */ - rc = cam_ife_csid_reset_regs(csid_hw, true); - if (rc < 0) - goto end; - rc = cam_ife_csid_reset_regs(csid_hw, false); - if (rc < 0) - goto end; -#endif val = cam_io_r_mb(soc_info->reg_map[0].mem_base + csid_reg->csi2_reg->csid_csi2_rx_irq_mask_addr); @@ -1018,12 +1008,6 @@ int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw, if (csid_hw->csi2_reserve_cnt) { /* current configure res type should match requested res type */ if (csid_hw->res_type != cid_reserv->in_port->res_type) { -#ifdef CONFIG_CAMERA_CAS - CAM_ERR(CAM_ISP, "[wrong res_type], CSID:%d, csid_hw->res_type:%d, cid_reserv->res_type:%d", - csid_hw->hw_intf->hw_idx, - csid_hw->res_type, - cid_reserv->in_port->res_type); -#endif rc = -EINVAL; goto end; } @@ -1052,15 +1036,6 @@ int cam_ife_csid_cid_reserve(struct cam_ife_csid_hw *csid_hw, cid_reserv->in_port->test_pattern)) { rc = -EINVAL; - -#ifdef CONFIG_CAMERA_CAS - CAM_ERR(CAM_ISP, - "[wrong lane configuration]: CSID:%d res_sel:0x%x Lane type:%d lane_num:%d", - csid_hw->hw_intf->hw_idx, - csid_hw->csi2_rx_cfg.lane_cfg, - csid_hw->csi2_rx_cfg.lane_type, - csid_hw->csi2_rx_cfg.lane_num); -#endif goto end; } } diff --git a/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c b/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c index 6ce10713a6a4..6fe77637e037 100644 --- a/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c +++ b/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c @@ -2173,18 +2173,8 @@ static int cam_vfe_bus_ver3_start_vfe_out( return -EFAULT; } -#ifdef CONFIG_CAMERA_CAS - CAM_INFO(CAM_ISP, - "VFE:%d out_type:0x%X RDI context %d for RUP ", - rsrc_data->common_data->core_index, rsrc_data->out_type, vfe_out->rdi_only_last_res); -#endif - if ((common_data->is_lite || source_group > CAM_VFE_BUS_VER3_SRC_GRP_0) -#ifdef CONFIG_CAMERA_CAS - && !vfe_out->rdi_only_last_res) -#else && !vfe_out->rdi_only_ctx) -#endif goto end; if (!common_data->rup_irq_handle[source_group]) { diff --git a/techpack/camera/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c b/techpack/camera/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c index 1474e73a9c17..e30033d1169b 100644 --- a/techpack/camera/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c +++ b/techpack/camera/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -155,7 +154,6 @@ static int cam_jpeg_mgr_process_irq(void *priv, void *data) CAM_ERR(CAM_JPEG, "Invalid offset: %u cmd buf len: %zu", p_cfg_req->hw_cfg_args.hw_update_entries[ CAM_JPEG_PARAM].offset, cmd_buf_len); - cam_mem_put_cpu_buf(mem_hdl); return -EINVAL; } @@ -182,7 +180,6 @@ static int cam_jpeg_mgr_process_irq(void *priv, void *data) mutex_lock(&g_jpeg_hw_mgr.hw_mgr_mutex); list_add_tail(&p_cfg_req->list, &hw_mgr->free_req_list); mutex_unlock(&g_jpeg_hw_mgr.hw_mgr_mutex); - cam_mem_put_cpu_buf(mem_hdl); return rc; } @@ -284,8 +281,6 @@ static int cam_jpeg_insert_cdm_change_base( if (config_args->hw_update_entries[CAM_JPEG_CHBASE].offset >= ch_base_len) { CAM_ERR(CAM_JPEG, "Not enough buf"); - cam_mem_put_cpu_buf( - config_args->hw_update_entries[CAM_JPEG_CHBASE].handle); return -EINVAL; } CAM_DBG(CAM_JPEG, "iova %pK len %zu offset %d", @@ -316,9 +311,6 @@ static int cam_jpeg_insert_cdm_change_base( ch_base_iova_addr += size; *ch_base_iova_addr = 0; - cam_mem_put_cpu_buf( - config_args->hw_update_entries[CAM_JPEG_CHBASE].handle); - return rc; } @@ -735,9 +727,8 @@ static int cam_jpeg_mgr_prepare_hw_update(void *hw_mgr_priv, return rc; } - if (!packet->num_cmd_buf || - (packet->num_cmd_buf > 5) || - !packet->num_patches || !packet->num_io_configs || + if ((packet->num_cmd_buf > 5) || !packet->num_patches || + !packet->num_io_configs || (packet->num_io_configs > CAM_JPEG_IMAGE_MAX)) { CAM_ERR(CAM_JPEG, "wrong number of cmd/patch/io_configs info: %u %u %u", @@ -1602,7 +1593,6 @@ static int cam_jpeg_mgr_hw_dump(void *hw_mgr_priv, void *dump_hw_args) CAM_WARN(CAM_JPEG, "dump offset overshoot len %zu offset %zu", jpeg_dump_args.buf_len, dump_args->offset); mutex_unlock(&hw_mgr->hw_mgr_mutex); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } @@ -1613,7 +1603,6 @@ static int cam_jpeg_mgr_hw_dump(void *hw_mgr_priv, void *dump_hw_args) CAM_WARN(CAM_JPEG, "dump buffer exhaust remain %zu min %u", remain_len, min_len); mutex_unlock(&hw_mgr->hw_mgr_mutex); - cam_mem_put_cpu_buf(dump_args->buf_handle); return -ENOSPC; } @@ -1646,7 +1635,6 @@ static int cam_jpeg_mgr_hw_dump(void *hw_mgr_priv, void *dump_hw_args) CAM_DBG(CAM_JPEG, "Offset before %u after %u", dump_args->offset, jpeg_dump_args.offset); dump_args->offset = jpeg_dump_args.offset; - cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } diff --git a/techpack/camera/drivers/cam_log/cam_log.c b/techpack/camera/drivers/cam_log/cam_log.c deleted file mode 100644 index df83976a1284..000000000000 --- a/techpack/camera/drivers/cam_log/cam_log.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#define DEBUG -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "cam_log.h" - -/*device name after register in charater*/ -#define CAMLOG_DEV_NAME "camlog" - -static struct camlog_dev camlogdev; - -static long cameralog_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - pr_debug(" cameralog_ioctl!\n"); - return 0; -} - -static int cameralog_open(struct inode *inode, struct file *filp) -{ - pr_debug(" cameralog_open!\n"); - return 0; -} - -/** -* -* @return Number of bytes read. -*/ -static ssize_t cameralog_read(struct file *fp, char __user *buff, - size_t length, loff_t *ppos) -{ - ssize_t bytes_read = 0; - int ret = 0; - bool has_message = false; - struct camlog_dev *camlog_dev = &camlogdev; - - if ( strlen(camlog_dev->m_camlog_message) ) - { - sprintf(camlog_dev->m_camlog_message, "%s\n", camlog_dev->m_camlog_message); - has_message = true; - } else { - has_message = false; - strcpy(camlog_dev->m_camlog_message,"\n"); - } - mutex_lock(&camlog_dev->camlog_message_lock); - - ret = copy_to_user(buff, camlog_dev->m_camlog_message, - strlen(camlog_dev->m_camlog_message)); - - mutex_unlock(&camlog_dev->camlog_message_lock); - - if ((ret == 0) && has_message) - { - bytes_read = strlen(camlog_dev->m_camlog_message); - } - - memset(camlog_dev->m_camlog_message, 0 , strlen(camlog_dev->m_camlog_message)); - - return bytes_read; -} - -void camlog_send_message(void){ - - pr_debug (" camlog_send_message ss \n"); -} -EXPORT_SYMBOL(camlog_send_message); - -/** -* -* @return number of bytes actually written -*/ -static ssize_t cameralog_write(struct file *fp, const char *buff, - size_t length, loff_t *ppos) -{ - int ret = 0; - ssize_t bytes_read = 0; - struct camlog_dev *camlog_dev = &camlogdev; - - mutex_lock(&camlog_dev->camlog_message_lock); - - ret = copy_from_user(camlog_dev->m_camlog_message, buff, - length); - if (0 == ret) - { - bytes_read = strlen(camlog_dev->m_camlog_message); - } - - mutex_unlock(&camlog_dev->camlog_message_lock); - - wake_up_interruptible(&camlog_dev->camlog_is_not_empty); - - return bytes_read; -} - -static int cameralog_release(struct inode *inode, struct file *filp) -{ - struct camlog_dev *camlog_dev = &camlogdev; - pr_debug(" cameralog_release!\n"); - wake_up_interruptible(&camlog_dev->camlog_is_not_empty); - return 0; -} - -static unsigned int cameralog_poll(struct file *file, - struct poll_table_struct *poll_table) -{ - unsigned int mask = 0; - struct camlog_dev *camlog_dev = &camlogdev; - poll_wait(file, &camlog_dev->camlog_is_not_empty, poll_table); - - if (strlen(camlog_dev->m_camlog_message)) - { - mask = POLLIN | POLLRDNORM; - } - - return mask; -} - -static const struct file_operations cameralog_fops = -{ - .owner = THIS_MODULE, - .unlocked_ioctl = cameralog_ioctl, - .open = cameralog_open, - .release = cameralog_release, - .poll = cameralog_poll, - .read = cameralog_read, - .write=cameralog_write, -}; - -static struct class *camlog_class; -static unsigned int camlog_major; -static int __init cameralog_init(void) -{ - struct device *device; - struct camlog_dev *camlog_dev = &camlogdev; - camlog_major = register_chrdev(0, CAMLOG_DEV_NAME, &cameralog_fops); - camlog_class=class_create(THIS_MODULE, CAMLOG_DEV_NAME); - if (IS_ERR(camlog_class)) { - unregister_chrdev(camlog_major, CAMLOG_DEV_NAME); - pr_warn("Failed to create class.\n"); - return PTR_ERR(camlog_class); - } - camlog_dev->devt = MKDEV(camlog_major, 0); - device = device_create(camlog_class, NULL, camlog_dev->devt, - NULL, CAMLOG_DEV_NAME); - - if (IS_ERR(device)) { - pr_err("error while trying to create %s\n",CAMLOG_DEV_NAME); - return -EINVAL; - } - mutex_init(&camlog_dev->camlog_message_lock); - init_waitqueue_head(&camlog_dev->camlog_is_not_empty); - - return 0; -} - -module_init(cameralog_init); - -static void __exit cameralog_exit(void) -{ - struct camlog_dev *camlog_dev = &camlogdev; - device_destroy(camlog_class, camlog_dev->devt); - class_destroy(camlog_class); - unregister_chrdev(camlog_major, CAMLOG_DEV_NAME); -} - -module_exit(cameralog_exit); - -MODULE_DESCRIPTION("camera log device driver"); -MODULE_LICENSE("GPL v2"); diff --git a/techpack/camera/drivers/cam_log/cam_log.h b/techpack/camera/drivers/cam_log/cam_log.h deleted file mode 100644 index 55730370a9c1..000000000000 --- a/techpack/camera/drivers/cam_log/cam_log.h +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. - */ -#ifndef _CAM_LOG_H_ -#define _CAM_LOG_H_ - -#include -#include -#include -#include -#include -#include - -struct camlog_dev { - dev_t devt; - uint8_t m_camlog_message[1024]; - struct mutex camlog_message_lock; - wait_queue_head_t camlog_is_not_empty; -}; -void camlog_send_message(void); - -#endif /* _CAM_LOG_H_ */ diff --git a/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c b/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c index cb387bc33130..a054d5f84709 100644 --- a/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c +++ b/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -113,11 +112,6 @@ static int cam_lrme_mgr_util_packet_validate(struct cam_packet *packet, return -EINVAL; } - if (!packet->num_cmd_buf) { - CAM_ERR(CAM_LRME, "no cmd bufs"); - return -EINVAL; - } - cmd_desc = (struct cam_cmd_buf_desc *)((uint8_t *)&packet->payload + packet->cmd_buf_offset); @@ -696,7 +690,6 @@ static int cam_lrme_mgr_hw_dump(void *hw_mgr_priv, void *hw_dump_args) CAM_DBG(CAM_LRME, "Offset before %zu after %zu", dump_args->offset, lrme_dump_args.offset); dump_args->offset = lrme_dump_args.offset; - cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } diff --git a/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.c b/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.c index 528ca9468388..324143a6efe5 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.c +++ b/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -267,37 +267,33 @@ int cam_mem_get_cpu_buf(int32_t buf_handle, uintptr_t *vaddr_ptr, size_t *len) return -EINVAL; } + if (!atomic_read(&cam_mem_mgr_state)) { + CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized"); + return -EINVAL; + } + if (!buf_handle || !vaddr_ptr || !len) return -EINVAL; idx = CAM_MEM_MGR_GET_HDL_IDX(buf_handle); - if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) return -EINVAL; if (!tbl.bufq[idx].active) return -EPERM; - if (buf_handle != tbl.bufq[idx].buf_handle) { - CAM_ERR(CAM_MEM, "idx: %d Invalid buf handle %d", - idx, buf_handle); + if (buf_handle != tbl.bufq[idx].buf_handle) return -EINVAL; - } - if (!(tbl.bufq[idx].flags & CAM_MEM_FLAG_KMD_ACCESS)) { - CAM_ERR(CAM_MEM, "idx: %d Invalid flag 0x%x", - idx, tbl.bufq[idx].flags); + if (!(tbl.bufq[idx].flags & CAM_MEM_FLAG_KMD_ACCESS)) return -EINVAL; - } - if (tbl.bufq[idx].kmdvaddr && - kref_get_unless_zero(&tbl.bufq[idx].krefcount)) { + if (tbl.bufq[idx].kmdvaddr) { *vaddr_ptr = tbl.bufq[idx].kmdvaddr; *len = tbl.bufq[idx].len; } else { - CAM_ERR(CAM_MEM, - "No KMD access request, vaddr= %p, idx= %d, handle= %d", - tbl.bufq[idx].kmdvaddr, idx, buf_handle); + CAM_ERR(CAM_MEM, "No KMD access was requested for 0x%x handle", + buf_handle); return -EINVAL; } @@ -410,6 +406,7 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, struct dma_buf **buf, int *fd) { + struct dma_buf *dmabuf = NULL; int rc = 0; struct timespec64 ts1, ts2; long microsec = 0; @@ -425,12 +422,6 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, *buf = ion_alloc(len, heap_id_mask, flags); if (IS_ERR_OR_NULL(*buf)) return -ENOMEM; - /* - * increment the ref count so that ref count becomes 2 here - * when we close fd, refcount becomes 1 and when we do - * dmap_put_buf, ref count becomes 0 and memory will be freed. - */ - get_dma_buf(*buf); *fd = dma_buf_fd(*buf, O_CLOEXEC); if (*fd < 0) { @@ -439,6 +430,17 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, goto get_fd_fail; } + /* + * increment the ref count so that ref count becomes 2 here + * when we close fd, refcount becomes 1 and when we do + * dmap_put_buf, ref count becomes 0 and memory will be freed. + */ + dmabuf = dma_buf_get(*fd); + if (IS_ERR_OR_NULL(dmabuf)) { + CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d", *fd); + rc = -EINVAL; + } + if (tbl.alloc_profile_enable) { CAM_GET_TIMESTAMP(ts2); CAM_GET_TIMESTAMP_DIFF_IN_MICRO(ts1, ts2, microsec); @@ -602,8 +604,6 @@ static int cam_mem_util_map_hw_va(uint32_t flags, for (--i; i >= 0; i--) cam_smmu_unmap_stage2_iova(mmu_hdls[i], fd); else - // MI change i>0 to i>=0 - // when i = 1 mean mmu_hdls[0] has map, and it need unmap for (--i; i >= 0; i--) cam_smmu_unmap_user_iova(mmu_hdls[i], fd, @@ -718,8 +718,6 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) memcpy(tbl.bufq[idx].hdls, cmd->mmu_hdls, sizeof(int32_t) * cmd->num_hdl); tbl.bufq[idx].is_imported = false; - kref_init(&tbl.bufq[idx].krefcount); - tbl.bufq[idx].smmu_mapping_client = CAM_SMMU_MAPPING_USER; mutex_unlock(&tbl.bufq[idx].q_lock); cmd->out.buf_handle = tbl.bufq[idx].buf_handle; @@ -827,8 +825,6 @@ int cam_mem_mgr_map(struct cam_mem_mgr_map_cmd *cmd) memcpy(tbl.bufq[idx].hdls, cmd->mmu_hdls, sizeof(int32_t) * cmd->num_hdl); tbl.bufq[idx].is_imported = true; - kref_init(&tbl.bufq[idx].krefcount); - tbl.bufq[idx].smmu_mapping_client = CAM_SMMU_MAPPING_USER; mutex_unlock(&tbl.bufq[idx].q_lock); cmd->out.buf_handle = tbl.bufq[idx].buf_handle; @@ -979,23 +975,17 @@ void cam_mem_mgr_deinit(void) mutex_destroy(&tbl.m_lock); } -static void cam_mem_util_unmap(struct kref *kref) +static int cam_mem_util_unmap(int32_t idx, + enum cam_smmu_mapping_client client) { int rc = 0; - int32_t idx; enum cam_smmu_region_id region = CAM_SMMU_REGION_SHARED; - enum cam_smmu_mapping_client client; - struct cam_mem_buf_queue *bufq = - container_of(kref, typeof(*bufq), krefcount); - idx = CAM_MEM_MGR_GET_HDL_IDX(bufq->buf_handle); if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) { CAM_ERR(CAM_MEM, "Incorrect index"); - return; + return -EINVAL; } - client = tbl.bufq[idx].smmu_mapping_client; - CAM_DBG(CAM_MEM, "Flags = %X idx %d", tbl.bufq[idx].flags, idx); mutex_lock(&tbl.m_lock); @@ -1004,7 +994,7 @@ static void cam_mem_util_unmap(struct kref *kref) CAM_WARN(CAM_MEM, "Buffer at idx=%d is already unmapped,", idx); mutex_unlock(&tbl.m_lock); - return; + return 0; } if (tbl.bufq[idx].flags & CAM_MEM_FLAG_KMD_ACCESS) { @@ -1064,50 +1054,13 @@ static void cam_mem_util_unmap(struct kref *kref) clear_bit(idx, tbl.bitmap); mutex_unlock(&tbl.m_lock); + return rc; } -void cam_mem_put_cpu_buf(int32_t buf_handle) -{ - int rc = 0; - int idx; - - if (!buf_handle) { - CAM_ERR(CAM_MEM, "Invalid buf_handle"); - return; - } - - idx = CAM_MEM_MGR_GET_HDL_IDX(buf_handle); - if (idx >= CAM_MEM_BUFQ_MAX || idx <= 0) { - CAM_ERR(CAM_MEM, "idx: %d not valid", idx); - return; - } - - if (!tbl.bufq[idx].active) { - CAM_ERR(CAM_MEM, "idx: %d not active", idx); - rc = -EPERM; - return; - } - - if (buf_handle != tbl.bufq[idx].buf_handle) { - CAM_ERR(CAM_MEM, "idx: %d Invalid buf handle %d", - idx, buf_handle); - rc = -EINVAL; - return; - } - - if (kref_put(&tbl.bufq[idx].krefcount, cam_mem_util_unmap)) - CAM_DBG(CAM_MEM, - "Called unmap from here, buf_handle: %u, idx: %d", - buf_handle, idx); - -} -EXPORT_SYMBOL(cam_mem_put_cpu_buf); - - int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) { int idx; - int rc = 0; + int rc; if (!atomic_read(&cam_mem_mgr_state)) { CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized"); @@ -1139,11 +1092,7 @@ int cam_mem_mgr_release(struct cam_mem_mgr_release_cmd *cmd) } CAM_DBG(CAM_MEM, "Releasing hdl = %x, idx = %d", cmd->buf_handle, idx); - - if (kref_put(&tbl.bufq[idx].krefcount, cam_mem_util_unmap)) - CAM_DBG(CAM_MEM, - "Called unmap from here, buf_handle: %u, idx: %d", - cmd->buf_handle, idx); + rc = cam_mem_util_unmap(idx, CAM_SMMU_MAPPING_USER); return rc; } @@ -1264,8 +1213,6 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp, memcpy(tbl.bufq[idx].hdls, &smmu_hdl, sizeof(int32_t)); tbl.bufq[idx].is_imported = false; - kref_init(&tbl.bufq[idx].krefcount); - tbl.bufq[idx].smmu_mapping_client = CAM_SMMU_MAPPING_KERNEL; mutex_unlock(&tbl.bufq[idx].q_lock); out->kva = kvaddr; @@ -1291,7 +1238,7 @@ EXPORT_SYMBOL(cam_mem_mgr_request_mem); int cam_mem_mgr_release_mem(struct cam_mem_mgr_memory_desc *inp) { int32_t idx; - int rc = 0; + int rc; if (!atomic_read(&cam_mem_mgr_state)) { CAM_ERR(CAM_MEM, "failed. mem_mgr not initialized"); @@ -1325,12 +1272,7 @@ int cam_mem_mgr_release_mem(struct cam_mem_mgr_memory_desc *inp) } CAM_DBG(CAM_MEM, "Releasing hdl = %X", inp->mem_handle); - if (kref_put(&tbl.bufq[idx].krefcount, cam_mem_util_unmap)) - CAM_DBG(CAM_MEM, - "Called unmap from here, buf_handle: %u, idx: %d", - tbl.bufq[idx].buf_handle, idx); - else - rc = -EINVAL; + rc = cam_mem_util_unmap(idx, CAM_SMMU_MAPPING_KERNEL); return rc; } @@ -1419,8 +1361,6 @@ int cam_mem_mgr_reserve_memory_region(struct cam_mem_mgr_request_desc *inp, memcpy(tbl.bufq[idx].hdls, &smmu_hdl, sizeof(int32_t)); tbl.bufq[idx].is_imported = false; - kref_init(&tbl.bufq[idx].krefcount); - tbl.bufq[idx].smmu_mapping_client = CAM_SMMU_MAPPING_KERNEL; mutex_unlock(&tbl.bufq[idx].q_lock); out->kva = 0; @@ -1505,12 +1445,9 @@ int cam_mem_mgr_free_memory_region(struct cam_mem_mgr_memory_desc *inp) } CAM_DBG(CAM_MEM, "Releasing hdl = %X", inp->mem_handle); - if (kref_put(&tbl.bufq[idx].krefcount, cam_mem_util_unmap)) - CAM_DBG(CAM_MEM, - "Called unmap from here, buf_handle: %u, idx: %d", - inp->mem_handle, idx); - else - rc = -EINVAL; + rc = cam_mem_util_unmap(idx, CAM_SMMU_MAPPING_KERNEL); + if (rc) + CAM_ERR(CAM_MEM, "unmapping secondary heap failed"); return rc; } diff --git a/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.h b/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.h index 082d23761bfd..1ad01bae1adb 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.h +++ b/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_MEM_MGR_H_ @@ -29,23 +28,19 @@ enum cam_smmu_mapping_client { /** * struct cam_mem_buf_queue * - * @dma_buf: pointer to the allocated dma_buf in the table - * @q_lock: mutex lock for buffer - * @hdls: list of mapped handles - * @num_hdl: number of handles - * @fd: file descriptor of buffer - * @buf_handle: unique handle for buffer - * @align: alignment for allocation - * @len: size of buffer - * @flags: attributes of buffer - * @vaddr: IOVA of buffer - * @kmdvaddr: Kernel virtual address - * @active: state of the buffer - * @is_imported: Flag indicating if buffer is imported from an FD in user - * space - * @krefcount: Reference counter to track whether the buffer is - * mapped and in use - * @smmu_mapping_client: Client buffer (User or kernel) + * @dma_buf: pointer to the allocated dma_buf in the table + * @q_lock: mutex lock for buffer + * @hdls: list of mapped handles + * @num_hdl: number of handles + * @fd: file descriptor of buffer + * @buf_handle: unique handle for buffer + * @align: alignment for allocation + * @len: size of buffer + * @flags: attributes of buffer + * @vaddr: IOVA of buffer + * @kmdvaddr: Kernel virtual address + * @active: state of the buffer + * @is_imported: Flag indicating if buffer is imported from an FD in user space */ struct cam_mem_buf_queue { struct dma_buf *dma_buf; @@ -61,8 +56,6 @@ struct cam_mem_buf_queue { uintptr_t kmdvaddr; bool active; bool is_imported; - struct kref krefcount; - enum cam_smmu_mapping_client smmu_mapping_client; }; /** diff --git a/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr_api.h b/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr_api.h index ad1d3ef1c051..e216a46a3a6f 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr_api.h +++ b/techpack/camera/drivers/cam_req_mgr/cam_mem_mgr_api.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_MEM_MGR_API_H_ @@ -91,14 +90,6 @@ int cam_mem_get_io_buf(int32_t buf_handle, int32_t mmu_handle, int cam_mem_get_cpu_buf(int32_t buf_handle, uintptr_t *vaddr_ptr, size_t *len); -/** - * @brief: This indicates end of CPU access - * - * @buf_handle: Handle for the buffer - * - */ -void cam_mem_put_cpu_buf(int32_t buf_handle); - static inline bool cam_mem_is_secure_buf(int32_t buf_handle) { return CAM_MEM_MGR_IS_SECURE_HDL(buf_handle); diff --git a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.c b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.c index a0260799654e..8e3ac0ca951b 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.c +++ b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -546,7 +546,6 @@ static void __cam_req_mgr_validate_crm_wd_timer( CAM_DBG(CAM_CRM, "rd_idx: %d idx: %d current_frame_timeout: %d ms", in_q->rd_idx, idx, current_frame_timeout); - spin_lock_bh(&link->link_state_spin_lock); if (link->watchdog) { if ((next_frame_timeout + CAM_REQ_MGR_WATCHDOG_TIMEOUT) > @@ -568,8 +567,8 @@ static void __cam_req_mgr_validate_crm_wd_timer( crm_timer_modify(link->watchdog, current_frame_timeout + CAM_REQ_MGR_WATCHDOG_TIMEOUT); - } else if (!next_frame_timeout && (link->watchdog->expires > - CAM_REQ_MGR_WATCHDOG_TIMEOUT)) { + } else if (link->watchdog->expires > + CAM_REQ_MGR_WATCHDOG_TIMEOUT) { CAM_DBG(CAM_CRM, "Reset wd timer to default from %d ms to %d ms", link->watchdog->expires, @@ -1354,83 +1353,7 @@ static int __cam_req_mgr_check_sync_req_is_ready( return 0; } - /** - * __cam_req_mgr_check_peer_req_is_applied() - * - * @brief : Check whether peer req is applied - * @link : pointer to link whose input queue and req tbl are - * traversed through - * @idx : slot idx - * @return : true means the req is applied, others not applied - * - */ -static bool __cam_req_mgr_check_peer_req_is_applied( - struct cam_req_mgr_core_link *link, - int32_t idx) -{ - bool applied = true; - int64_t req_id; - int sync_slot_idx = 0; - struct cam_req_mgr_core_link *sync_link; - struct cam_req_mgr_slot *slot, *sync_slot; - struct cam_req_mgr_req_queue *in_q; - - if (idx < 0) - return true; - - slot = &link->req.in_q->slot[idx]; - req_id = slot->req_id; - in_q = link->req.in_q; - - CAM_DBG(CAM_REQ, - "Check Req[%lld] idx %d req_status %d link_hdl %x is applied in peer link", - req_id, idx, slot->status, link->link_hdl); - - if (slot->sync_mode == CAM_REQ_MGR_SYNC_MODE_NO_SYNC) { - applied = true; - goto end; - } - - sync_link = link->sync_link; - - if (!sync_link) - applied &= true; - - in_q = sync_link->req.in_q; - if (!in_q) { - CAM_DBG(CAM_CRM, "Link hdl %x in_q is NULL", - sync_link->link_hdl); - applied &= true; - } - sync_slot_idx = __cam_req_mgr_find_slot_for_req( - sync_link->req.in_q, req_id); - - if ((sync_slot_idx < 0) || - (sync_slot_idx >= MAX_REQ_SLOTS)) { - CAM_DBG(CAM_CRM, - "Can't find req:%lld from peer link, idx:%d", - req_id, sync_slot_idx); - applied &= true; - } - - sync_slot = &in_q->slot[sync_slot_idx]; - - if (sync_slot->status == CRM_SLOT_STATUS_REQ_APPLIED) - applied &= true; - else - applied &= false; - CAM_DBG(CAM_CRM, - "link:%x idx:%d status:%d applied:%d", - sync_link->link_hdl, sync_slot_idx, sync_slot->status, applied); - -end: - CAM_DBG(CAM_REQ, - "Check Req[%lld] idx %d applied:%d", - req_id, idx, link->link_hdl, applied); - - return applied; -} /** * __cam_req_mgr_process_req() * @@ -1534,21 +1457,9 @@ static int __cam_req_mgr_process_req(struct cam_req_mgr_core_link *link, rc = __cam_req_mgr_inject_delay(link->req.l_tbl, slot->idx); - if (!rc) { - if (in_q->slot[in_q->rd_idx].req_id != -1){ - rc = __cam_req_mgr_check_peer_req_is_applied( - link, in_q->last_applied_idx); - - if (rc) - rc = __cam_req_mgr_check_link_is_ready( - link, slot->idx, false); - else - rc = -EINVAL; - } - else - rc = __cam_req_mgr_check_link_is_ready(link, - slot->idx, false); - } + if (!rc) + rc = __cam_req_mgr_check_link_is_ready(link, + slot->idx, false); } if (rc < 0) { @@ -2795,7 +2706,9 @@ static int cam_req_mgr_cb_add_req(struct cam_req_mgr_add_request *add_req) return -EINVAL; } - link = cam_get_link_priv(add_req->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(add_req->link_hdl); + if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", add_req->link_hdl); return -EINVAL; @@ -2872,7 +2785,8 @@ static int cam_req_mgr_cb_notify_err( goto end; } - link = cam_get_link_priv(err_info->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(err_info->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", err_info->link_hdl); rc = -EINVAL; @@ -2959,7 +2873,8 @@ static int cam_req_mgr_cb_notify_timer( goto end; } - link = cam_get_link_priv(timer_data->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(timer_data->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", timer_data->link_hdl); rc = -EINVAL; @@ -3005,7 +2920,8 @@ static int cam_req_mgr_cb_notify_stop( goto end; } - link = cam_get_link_priv(stop_info->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(stop_info->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", stop_info->link_hdl); rc = -EINVAL; @@ -3066,7 +2982,8 @@ static int cam_req_mgr_cb_notify_trigger( goto end; } - link = cam_get_link_priv(trigger_data->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(trigger_data->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", trigger_data->link_hdl); rc = -EINVAL; @@ -3421,7 +3338,7 @@ static int __cam_req_mgr_unlink(struct cam_req_mgr_core_link *link) __cam_req_mgr_destroy_subdev(&link->l_dev); /* Destroy the link handle */ - rc = cam_destroy_link_hdl(link->link_hdl); + rc = cam_destroy_device_hdl(link->link_hdl); if (rc < 0) { CAM_ERR(CAM_CRM, "error destroying link hdl %x rc %d", link->link_hdl, rc); @@ -3447,14 +3364,14 @@ int cam_req_mgr_destroy_session( } mutex_lock(&g_crm_core_dev->crm_lock); - cam_session = cam_get_session_priv(ses_info->session_hdl); + cam_session = (struct cam_req_mgr_core_session *) + cam_get_device_priv(ses_info->session_hdl); if (!cam_session || (cam_session->session_hdl != ses_info->session_hdl)) { - CAM_ERR(CAM_CRM, - "ses: %s, ses_info->ses_hdl:%x, session->ses_hdl:%x", + CAM_ERR(CAM_CRM, "ses:%s ses_info->ses_hdl:%x ses->ses_hdl:%x", CAM_IS_NULL_TO_STR(cam_session), ses_info->session_hdl, (!cam_session) ? CAM_REQ_MGR_DEFAULT_HDL_VAL : - cam_session->session_hdl); + cam_session->session_hdl); rc = -ENOENT; goto end; @@ -3517,16 +3434,15 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info) mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - cam_session = - cam_get_session_priv(link_info->u.link_info_v1.session_hdl); + cam_session = (struct cam_req_mgr_core_session *) + cam_get_device_priv(link_info->u.link_info_v1.session_hdl); if (!cam_session || (cam_session->session_hdl != - link_info->u.link_info_v1.session_hdl)) { - CAM_ERR(CAM_CRM, - "ses: %s, link_info->ses_hdl:%x, session->ses_hdl:%x", + link_info->u.link_info_v1.session_hdl)) { + CAM_ERR(CAM_CRM, "ses:%s link_info->ses_hdl:%x ses->ses_hdl:%x", CAM_IS_NULL_TO_STR(cam_session), link_info->u.link_info_v1.session_hdl, (!cam_session) ? CAM_REQ_MGR_DEFAULT_HDL_VAL : - cam_session->session_hdl); + cam_session->session_hdl); mutex_unlock(&g_crm_core_dev->crm_lock); return -EINVAL; } @@ -3545,8 +3461,8 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info) root_dev.priv = (void *)link; mutex_lock(&link->lock); - /* Create unique handle for link */ - link->link_hdl = cam_create_link_hdl(&root_dev); + /* Create unique dev handle for link */ + link->link_hdl = cam_create_device_hdl(&root_dev); if (link->link_hdl < 0) { CAM_ERR(CAM_CRM, "Insufficient memory to create new device handle"); @@ -3601,7 +3517,7 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info) setup_failed: __cam_req_mgr_destroy_subdev(&link->l_dev); create_subdev_failed: - cam_destroy_link_hdl(link->link_hdl); + cam_destroy_device_hdl(link->link_hdl); link_info->u.link_info_v1.link_hdl = -1; link_hdl_fail: mutex_unlock(&link->lock); @@ -3633,16 +3549,15 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info) mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - cam_session = - cam_get_session_priv(link_info->u.link_info_v2.session_hdl); + cam_session = (struct cam_req_mgr_core_session *) + cam_get_device_priv(link_info->u.link_info_v2.session_hdl); if (!cam_session || (cam_session->session_hdl != - link_info->u.link_info_v2.session_hdl)) { - CAM_ERR(CAM_CRM, - "ses: %s, link_info->ses_hdl:%x, session->ses_hdl:%x", + link_info->u.link_info_v2.session_hdl)) { + CAM_ERR(CAM_CRM, "ses:%s link_info->ses_hdl:%x ses->ses_hdl:%x", CAM_IS_NULL_TO_STR(cam_session), link_info->u.link_info_v2.session_hdl, (!cam_session) ? CAM_REQ_MGR_DEFAULT_HDL_VAL : - cam_session->session_hdl); + cam_session->session_hdl); mutex_unlock(&g_crm_core_dev->crm_lock); return -EINVAL; } @@ -3661,8 +3576,8 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info) root_dev.priv = (void *)link; mutex_lock(&link->lock); - /* Create unique handle for link */ - link->link_hdl = cam_create_link_hdl(&root_dev); + /* Create unique dev handle for link */ + link->link_hdl = cam_create_device_hdl(&root_dev); if (link->link_hdl < 0) { CAM_ERR(CAM_CRM, "Insufficient memory to create new device handle"); @@ -3717,7 +3632,7 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info) setup_failed: __cam_req_mgr_destroy_subdev(&link->l_dev); create_subdev_failed: - cam_destroy_link_hdl(link->link_hdl); + cam_destroy_device_hdl(link->link_hdl); link_info->u.link_info_v2.link_hdl = -1; link_hdl_fail: mutex_unlock(&link->lock); @@ -3742,21 +3657,21 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info) CAM_DBG(CAM_CRM, "link_hdl %x", unlink_info->link_hdl); /* session hdl's priv data is cam session struct */ - cam_session = cam_get_session_priv(unlink_info->session_hdl); + cam_session = (struct cam_req_mgr_core_session *) + cam_get_device_priv(unlink_info->session_hdl); if (!cam_session || (cam_session->session_hdl != unlink_info->session_hdl)) { - CAM_ERR(CAM_CRM, - "ses: %s, unlink_info->ses_hdl:%x, cam_ses->ses_hdl:%x", + CAM_ERR(CAM_CRM, "ses:%s unlink->ses_hdl:%x ses->ses_hdl:%x", CAM_IS_NULL_TO_STR(cam_session), unlink_info->session_hdl, (!cam_session) ? CAM_REQ_MGR_DEFAULT_HDL_VAL : - cam_session->session_hdl); + cam_session->session_hdl); mutex_unlock(&g_crm_core_dev->crm_lock); return -EINVAL; } /* link hdl's priv data is core_link struct */ - link = cam_get_link_priv(unlink_info->link_hdl); + link = cam_get_device_priv(unlink_info->link_hdl); if (!link || (link->link_hdl != unlink_info->link_hdl)) { CAM_ERR(CAM_CRM, "link:%s unlink->lnk_hdl:%x link->lnk_hdl:%x", CAM_IS_NULL_TO_STR(link), unlink_info->link_hdl, @@ -3790,7 +3705,8 @@ int cam_req_mgr_schedule_request( } mutex_lock(&g_crm_core_dev->crm_lock); - link = cam_get_link_priv(sched_req->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(sched_req->link_hdl); if (!link || (link->link_hdl != sched_req->link_hdl)) { CAM_ERR(CAM_CRM, "lnk:%s schd_req->lnk_hdl:%x lnk->lnk_hdl:%x", CAM_IS_NULL_TO_STR(link), sched_req->link_hdl, @@ -3903,15 +3819,14 @@ int cam_req_mgr_sync_config( mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - cam_session = cam_get_session_priv(sync_info->session_hdl); + cam_session = (struct cam_req_mgr_core_session *) + cam_get_device_priv(sync_info->session_hdl); if (!cam_session || (cam_session->session_hdl != sync_info->session_hdl)) { - CAM_ERR(CAM_CRM, - "ses: %s, sync_info->session_hdl:%x, ses->ses_hdl:%x", - CAM_IS_NULL_TO_STR(cam_session), - sync_info->session_hdl, - (!cam_session) ? CAM_REQ_MGR_DEFAULT_HDL_VAL : - cam_session->session_hdl); + CAM_ERR(CAM_CRM, "ses:%s sync_info->ses_hdl:%x ses->ses_hdl:%x", + CAM_IS_NULL_TO_STR(cam_session), sync_info->session_hdl, + (!cam_session) ? + CAM_REQ_MGR_DEFAULT_HDL_VAL : cam_session->session_hdl); mutex_unlock(&g_crm_core_dev->crm_lock); return -EINVAL; } @@ -3922,7 +3837,7 @@ int cam_req_mgr_sync_config( sync_info->link_hdls[0], sync_info->link_hdls[1]); /* only two links existing per session in dual cam use case*/ - link1 = cam_get_link_priv(sync_info->link_hdls[0]); + link1 = cam_get_device_priv(sync_info->link_hdls[0]); if (!link1 || (link1->link_hdl != sync_info->link_hdls[0])) { CAM_ERR(CAM_CRM, "lnk:%s sync_info->lnk_hdl[0]:%x lnk1_hdl:%x", CAM_IS_NULL_TO_STR(link1), sync_info->link_hdls[0], @@ -3932,7 +3847,7 @@ int cam_req_mgr_sync_config( goto done; } - link2 = cam_get_link_priv(sync_info->link_hdls[1]); + link2 = cam_get_device_priv(sync_info->link_hdls[1]); if (!link2 || (link2->link_hdl != sync_info->link_hdls[1])) { CAM_ERR(CAM_CRM, "lnk:%s sync_info->lnk_hdl[1]:%x lnk2_hdl:%x", CAM_IS_NULL_TO_STR(link2), sync_info->link_hdls[1], @@ -4004,9 +3919,9 @@ int cam_req_mgr_flush_requests( } mutex_lock(&g_crm_core_dev->crm_lock); - /* session hdl's priv data is cam session struct */ - session = cam_get_session_priv(flush_info->session_hdl); + session = (struct cam_req_mgr_core_session *) + cam_get_device_priv(flush_info->session_hdl); if (!session || (session->session_hdl != flush_info->session_hdl)) { CAM_ERR(CAM_CRM, "ses: %s flush->ses_hdl:%x ses->ses_hdl:%x", CAM_IS_NULL_TO_STR(session), flush_info->session_hdl, @@ -4021,7 +3936,8 @@ int cam_req_mgr_flush_requests( goto end; } - link = cam_get_link_priv(flush_info->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(flush_info->link_hdl); if (!link || (link->link_hdl != flush_info->link_hdl)) { CAM_ERR(CAM_CRM, "link:%s flush->link_hdl:%x link->link_hdl:%x", CAM_IS_NULL_TO_STR(link), flush_info->link_hdl, @@ -4080,7 +3996,8 @@ int cam_req_mgr_link_control(struct cam_req_mgr_link_control *control) mutex_lock(&g_crm_core_dev->crm_lock); for (i = 0; i < control->num_links; i++) { - link = cam_get_link_priv(control->link_hdls[i]); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(control->link_hdls[i]); if (!link || (link->link_hdl != control->link_hdls[i])) { CAM_ERR(CAM_CRM, "link:%s control->lnk_hdl:%x link->lnk_hdl:%x", @@ -4159,7 +4076,8 @@ int cam_req_mgr_dump_request(struct cam_dump_req_cmd *dump_req) mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - session = cam_get_session_priv(dump_req->session_handle); + session = (struct cam_req_mgr_core_session *) + cam_get_device_priv(dump_req->session_handle); if (!session || (session->session_hdl != dump_req->session_handle)) { CAM_ERR(CAM_CRM, "ses:%s dump_req->ses_hdl:%x ses->ses_hdl:%x", CAM_IS_NULL_TO_STR(session), dump_req->session_handle, @@ -4174,7 +4092,8 @@ int cam_req_mgr_dump_request(struct cam_dump_req_cmd *dump_req) goto end; } - link = cam_get_link_priv(dump_req->link_hdl); + link = (struct cam_req_mgr_core_link *) + cam_get_device_priv(dump_req->link_hdl); if (!link || (link->link_hdl != dump_req->link_hdl)) { CAM_ERR(CAM_CRM, "link:%s dump->link_hdl:%x link->link_hdl:%x", CAM_IS_NULL_TO_STR(link), dump_req->link_hdl, diff --git a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.h b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.h index 6e5d3fba55bb..0283033bbf29 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.h +++ b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_core.h @@ -386,6 +386,7 @@ struct cam_req_mgr_core_link { uint64_t prev_sof_timestamp; bool dual_trigger; uint32_t trigger_cnt[CAM_REQ_MGR_MAX_TRIGGERS]; + uint64_t last_applied_jiffies; }; diff --git a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_dev.c b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_dev.c index 2564f427b95d..3b7ab85f6949 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_dev.c +++ b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_dev.c @@ -28,7 +28,8 @@ #include "cam_debug_util.h" #include "cam_common_util.h" -#define CAM_REQ_MGR_EVENT_MAX 240 +/* Xiaomi: enlarge from 60 to 120 */ +#define CAM_REQ_MGR_EVENT_MAX 120 static struct cam_req_mgr_device g_dev; struct kmem_cache *g_cam_req_mgr_timer_cachep; diff --git a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.c b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.c index 697af4f0027b..77c3f69508de 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.c +++ b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #define pr_fmt(fmt) "CAM-REQ-MGR_UTIL %s:%d " fmt, __func__, __LINE__ @@ -38,31 +37,29 @@ int cam_req_mgr_util_init(void) rc = -ENOMEM; goto hdl_tbl_alloc_failed; } - bitmap_size = BITS_TO_LONGS(CAM_REQ_MGR_MAX_HANDLES_V2) * sizeof(long); - hdl_tbl_local->bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!hdl_tbl_local->bitmap) { - rc = -ENOMEM; - goto bitmap_alloc_fail; - } - hdl_tbl_local->bits = bitmap_size * BITS_PER_BYTE; - spin_lock_bh(&hdl_tbl_lock); if (hdl_tbl) { spin_unlock_bh(&hdl_tbl_lock); rc = -EEXIST; - kfree(hdl_tbl_local->bitmap); kfree(hdl_tbl_local); goto hdl_tbl_check_failed; } hdl_tbl = hdl_tbl_local; spin_unlock_bh(&hdl_tbl_lock); - hdl_count = 0; + bitmap_size = BITS_TO_LONGS(CAM_REQ_MGR_MAX_HANDLES_V2) * sizeof(long); + hdl_tbl->bitmap = kzalloc(bitmap_size, GFP_KERNEL); + if (!hdl_tbl->bitmap) { + rc = -ENOMEM; + goto bitmap_alloc_fail; + } + hdl_tbl->bits = bitmap_size * BITS_PER_BYTE; + hdl_count = 0; return rc; bitmap_alloc_fail: - kfree(hdl_tbl_local); + kfree(hdl_tbl); hdl_tbl = NULL; hdl_tbl_alloc_failed: hdl_tbl_check_failed: @@ -132,19 +129,6 @@ static int32_t cam_get_free_handle_index(void) return idx; } -static void cam_dump_tbl_info(void) -{ - int i; - - for (i = 0; i < CAM_REQ_MGR_MAX_HANDLES_V2; i++) - CAM_INFO_RATE_LIMIT_CUSTOM(CAM_CRM, - CAM_RATE_LIMIT_INTERVAL_5SEC, - CAM_REQ_MGR_MAX_HANDLES_V2, - "session_hdl=%x hdl_value=%x type=%d state=%d", - hdl_tbl->hdl[i].session_hdl, hdl_tbl->hdl[i].hdl_value, - hdl_tbl->hdl[i].type, hdl_tbl->hdl[i].state); -} - int32_t cam_create_session_hdl(void *priv) { int idx; @@ -160,9 +144,7 @@ int32_t cam_create_session_hdl(void *priv) idx = cam_get_free_handle_index(); if (idx < 0) { - CAM_ERR(CAM_CRM, "Unable to create session handle(idx = %d)", - idx); - cam_dump_tbl_info(); + CAM_ERR(CAM_CRM, "Unable to create session handle"); spin_unlock_bh(&hdl_tbl_lock); return idx; } @@ -203,9 +185,7 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data) idx = cam_get_free_handle_index(); if (idx < 0) { - CAM_ERR(CAM_CRM, "Unable to create device handle(idx= %d)", - idx); - cam_dump_tbl_info(); + CAM_ERR(CAM_CRM, "Unable to create device handle"); spin_unlock_bh(&hdl_tbl_lock); return idx; } @@ -224,42 +204,7 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data) return handle; } -int32_t cam_create_link_hdl(struct cam_create_dev_hdl *hdl_data) -{ - int idx; - int rand = 0; - int32_t handle; - - spin_lock_bh(&hdl_tbl_lock); - if (!hdl_tbl) { - CAM_ERR(CAM_CRM, "Hdl tbl is NULL"); - spin_unlock_bh(&hdl_tbl_lock); - return -EINVAL; - } - - idx = cam_get_free_handle_index(); - if (idx < 0) { - CAM_ERR(CAM_CRM, "Unable to create link handle(idx = %d)", idx); - cam_dump_tbl_info(); - spin_unlock_bh(&hdl_tbl_lock); - return idx; - } - - get_random_bytes(&rand, CAM_REQ_MGR_RND1_BYTES); - handle = GET_DEV_HANDLE(rand, HDL_TYPE_LINK, idx); - hdl_tbl->hdl[idx].session_hdl = hdl_data->session_hdl; - hdl_tbl->hdl[idx].hdl_value = handle; - hdl_tbl->hdl[idx].type = HDL_TYPE_LINK; - hdl_tbl->hdl[idx].state = HDL_ACTIVE; - hdl_tbl->hdl[idx].priv = hdl_data->priv; - hdl_tbl->hdl[idx].ops = NULL; - spin_unlock_bh(&hdl_tbl_lock); - - CAM_DBG(CAM_CRM, "handle = %x", handle); - return handle; -} - -void *cam_get_priv(int32_t dev_hdl, int handle_type) +void *cam_get_device_priv(int32_t dev_hdl) { int idx; int type; @@ -273,19 +218,18 @@ void *cam_get_priv(int32_t dev_hdl, int handle_type) idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl); if (idx >= CAM_REQ_MGR_MAX_HANDLES_V2) { - CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid idx: %d", idx); + CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid idx"); goto device_priv_fail; } if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) { - CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid state: %d", - hdl_tbl->hdl[idx].state); + CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid state"); goto device_priv_fail; } type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl); - if (type != handle_type) { - CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid type:%d", type); + if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) { + CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid type"); goto device_priv_fail; } @@ -304,34 +248,6 @@ void *cam_get_priv(int32_t dev_hdl, int handle_type) return NULL; } -void *cam_get_device_priv(int32_t dev_hdl) -{ - void *priv; - - priv = cam_get_priv(dev_hdl, HDL_TYPE_DEV); - return priv; -} - -struct cam_req_mgr_core_session *cam_get_session_priv(int32_t dev_hdl) -{ - struct cam_req_mgr_core_session *priv; - - priv = (struct cam_req_mgr_core_session *) - cam_get_priv(dev_hdl, HDL_TYPE_SESSION); - - return priv; -} - -struct cam_req_mgr_core_link *cam_get_link_priv(int32_t dev_hdl) -{ - struct cam_req_mgr_core_link *priv; - - priv = (struct cam_req_mgr_core_link *) - cam_get_priv(dev_hdl, HDL_TYPE_LINK); - - return priv; -} - void *cam_get_device_ops(int32_t dev_hdl) { int idx; @@ -356,8 +272,7 @@ void *cam_get_device_ops(int32_t dev_hdl) } type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl); - if (type != HDL_TYPE_DEV && type != HDL_TYPE_SESSION && - type != HDL_TYPE_LINK) { + if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) { CAM_ERR(CAM_CRM, "Invalid type"); goto device_ops_fail; } @@ -429,12 +344,6 @@ int cam_destroy_device_hdl(int32_t dev_hdl) return cam_destroy_hdl(dev_hdl, HDL_TYPE_DEV); } -int cam_destroy_link_hdl(int32_t dev_hdl) -{ - CAM_DBG(CAM_CRM, "handle = %x", dev_hdl); - return cam_destroy_hdl(dev_hdl, HDL_TYPE_LINK); -} - int cam_destroy_session_hdl(int32_t dev_hdl) { return cam_destroy_hdl(dev_hdl, HDL_TYPE_SESSION); diff --git a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.h b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.h index 2f676ae55997..c0e339eedd9b 100644 --- a/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.h +++ b/techpack/camera/drivers/cam_req_mgr/cam_req_mgr_util.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_REQ_MGR_UTIL_API_H_ @@ -10,9 +9,6 @@ #include #include "cam_req_mgr_util_priv.h" -/* Interval for cam_info_rate_limit_custom() */ -#define CAM_RATE_LIMIT_INTERVAL_5SEC 5 - /** * state of a handle(session/device) * @HDL_FREE: free handle @@ -25,14 +21,12 @@ enum hdl_state { /** * handle type - * @HDL_TYPE_DEV: for device + * @HDL_TYPE_DEV: for device and link * @HDL_TYPE_SESSION: for session - * @HDL_TYPE_LINK: for link */ enum hdl_type { HDL_TYPE_DEV = 1, - HDL_TYPE_SESSION, - HDL_TYPE_LINK + HDL_TYPE_SESSION }; /** @@ -105,19 +99,8 @@ int32_t cam_create_session_hdl(void *priv); int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data); /** - * cam_create_link_hdl() - create a link handle - * @hdl_data: session hdl, flags, ops and priv dara as input - * - * cam_req_mgr_core calls this function to get - * session and link handles - * KMD drivers calls this function to create - * a link handle. Returns a unique link handle - */ -int32_t cam_create_link_hdl(struct cam_create_dev_hdl *hdl_data); - -/** - * cam_get_device_priv() - get private data of a device handle - * @dev_hdl: handle for a device + * cam_get_device_priv() - get private data of a handle + * @dev_hdl: handle for a session/link/device * * cam_req_mgr_core and KMD drivers use this function to * get private data of a handle. Returns a private data @@ -125,26 +108,6 @@ int32_t cam_create_link_hdl(struct cam_create_dev_hdl *hdl_data); */ void *cam_get_device_priv(int32_t dev_hdl); -/** - * cam_get_session_priv() - get private data of a session handle - * @dev_hdl: handle for a session - * - * cam_req_mgr_core and KMD drivers use this function to - * get private data of a handle. Returns a private data - * structure pointer. - */ -struct cam_req_mgr_core_session *cam_get_session_priv(int32_t dev_hdl); - -/** - * cam_get_link_priv() - get private data of a link handle - * @dev_hdl: handle for a link - * - * cam_req_mgr_core and KMD drivers use this function to - * get private data of a handle. Returns a private data - * structure pointer. - */ -struct cam_req_mgr_core_link *cam_get_link_priv(int32_t dev_hdl); - /** * cam_get_device_ops() - get ops of a handle * @dev_hdl: handle for a session/link/device @@ -156,20 +119,12 @@ void *cam_get_device_ops(int32_t dev_hdl); /** * cam_destroy_device_hdl() - destroy device handle - * @dev_hdl: handle for a device. + * @dev_hdl: handle for a link/device. * * Returns success/failure */ int32_t cam_destroy_device_hdl(int32_t dev_hdl); -/** - * cam_destroy_link_hdl() - destroy link handle - * @dev_hdl: handle for a link. - * - * Returns success/failure - */ -int32_t cam_destroy_link_hdl(int32_t dev_hdl); - /** * cam_destroy_session_hdl() - destroy device handle * @dev_hdl: handle for a session diff --git a/techpack/camera/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c b/techpack/camera/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c index 7ed7baa2b272..8ee158472765 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_actuator/cam_actuator_core.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -154,7 +153,7 @@ static int32_t cam_actuator_i2c_modes_util( if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_RANDOM) { rc = camera_io_dev_write(io_master_info, - &(i2c_list->i2c_settings), false); + &(i2c_list->i2c_settings)); if (rc < 0) { CAM_ERR(CAM_ACTUATOR, "Failed to random write I2C settings: %d", @@ -165,7 +164,7 @@ static int32_t cam_actuator_i2c_modes_util( rc = camera_io_dev_write_continuous( io_master_info, &(i2c_list->i2c_settings), - 0, false); + 0); if (rc < 0) { CAM_ERR(CAM_ACTUATOR, "Failed to seq write I2C settings: %d", @@ -176,7 +175,7 @@ static int32_t cam_actuator_i2c_modes_util( rc = camera_io_dev_write_continuous( io_master_info, &(i2c_list->i2c_settings), - 1, false); + 1); if (rc < 0) { CAM_ERR(CAM_ACTUATOR, "Failed to burst write I2C settings: %d", @@ -501,7 +500,6 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl, cmd_buf = (uint32_t *)generic_ptr; if (!cmd_buf) { CAM_ERR(CAM_ACTUATOR, "invalid cmd buf"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); rc = -EINVAL; goto end; } @@ -510,7 +508,6 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl, sizeof(struct common_header)))) { CAM_ERR(CAM_ACTUATOR, "Invalid length for sensor cmd"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); rc = -EINVAL; goto end; } @@ -527,8 +524,6 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl, if (rc < 0) { CAM_ERR(CAM_ACTUATOR, "Failed to parse slave info: %d", rc); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); goto end; } break; @@ -544,8 +539,6 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl, CAM_ERR(CAM_ACTUATOR, "Failed:parse power settings: %d", rc); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); goto end; } break; @@ -566,13 +559,10 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl, CAM_ERR(CAM_ACTUATOR, "Failed:parse init settings: %d", rc); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); goto end; } break; } - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } if (a_ctrl->cam_act_state == CAM_ACTUATOR_ACQUIRE) { @@ -742,7 +732,6 @@ int32_t cam_actuator_i2c_pkt_parse(struct cam_actuator_ctrl_t *a_ctrl, } end: - cam_mem_put_cpu_buf(config.packet_handle); return rc; } diff --git a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c index 144f031e70f5..2e339b8d9534 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_core.c @@ -1,16 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include "cam_cci_core.h" #include "cam_cci_dev.h" -static uint32_t cam_cci_retry(struct cci_device *cci_dev, - enum cci_i2c_master_t master, - enum cci_i2c_queue_t queue); static int disable_optmz; module_param(disable_optmz, int, 0644); @@ -93,31 +89,23 @@ static int32_t cam_cci_validate_queue(struct cci_device *cci_dev, struct cam_hw_soc_info *soc_info = &cci_dev->soc_info; void __iomem *base = soc_info->reg_map[0].mem_base; - struct cam_cci_i2c_queue_info *queue_info = - &cci_dev->cci_i2c_queue_info[master][queue]; unsigned long flags; read_val = cam_io_r_mb(base + CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset); CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR %d len %d max %d", read_val, len, - queue_info->max_queue_size); + cci_dev->cci_i2c_queue_info[master][queue].max_queue_size); if ((read_val + len + 1) > - queue_info->max_queue_size) { + cci_dev->cci_i2c_queue_info[master][queue].max_queue_size) { uint32_t reg_val = 0; - uint32_t report_id = queue_info->report_id; - uint32_t report_val = CCI_I2C_REPORT_CMD | (1 << 8) | - (1 << 9) | (report_id << 4); + uint32_t report_val = CCI_I2C_REPORT_CMD | (1 << 8); CAM_DBG(CAM_CCI, "CCI_I2C_REPORT_CMD"); cam_io_w_mb(report_val, base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR + reg_offset); read_val++; - queue_info->report_id++; - if (queue_info->report_id == REPORT_IDSIZE) - queue_info->report_id = 0; - CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR %d, queue: %d", read_val, queue); @@ -142,13 +130,10 @@ static int32_t cam_cci_validate_queue(struct cci_device *cci_dev, if (rc <= 0) { CAM_ERR(CAM_CCI, "Wait_for_completion_timeout: rc: %d", rc); - rc = cam_cci_retry(cci_dev, master, queue); - if (!rc) - CAM_INFO(CAM_CCI, - "CCI%d_I2C_M%d_Q%d retry success", - soc_info->index, master, queue); - else - return rc; + if (rc == 0) + rc = -ETIMEDOUT; + cam_cci_flush_queue(cci_dev, master); + return rc; } rc = cci_dev->cci_master_info[master].status; if (rc < 0) { @@ -193,37 +178,13 @@ static int32_t cam_cci_lock_queue(struct cci_device *cci_dev, enum cci_i2c_master_t master, enum cci_i2c_queue_t queue, uint32_t en) { - int32_t rc = 0; - uint32_t val = 0; - uint32_t read_val = 0; - struct cam_hw_soc_info *soc_info = - &cci_dev->soc_info; - void __iomem *base = - soc_info->reg_map[0].mem_base; - uint32_t reg_offset = - master * 0x200 + queue * 0x100; + uint32_t val; if (queue != PRIORITY_QUEUE) - goto end; + return 0; val = en ? CCI_I2C_LOCK_CMD : CCI_I2C_UNLOCK_CMD; - rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue); - - if (rc) { - CAM_ERR(CAM_CCI, - "CCI%d_I2C_M%d_Q%d Failed to write i2c data:0x%x rc:%d", - cci_dev->soc_info.index, master, queue, val, rc); - goto end; - } - - read_val = cam_io_r_mb(base + - CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset); - - cam_io_w_mb(read_val, base + - CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR + reg_offset); - -end: - return rc; + return cam_cci_write_i2c_queue(cci_dev, val, master, queue); } #ifdef DUMP_CCI_REGISTERS @@ -282,104 +243,20 @@ static void cam_cci_dump_registers(struct cci_device *cci_dev, } #endif -static uint32_t cam_cci_retry(struct cci_device *cci_dev, - enum cci_i2c_master_t master, - enum cci_i2c_queue_t queue) -{ - int32_t rc = 0; - uint32_t retry = 50; - uint32_t read_val0 = 0, read_val1 = 0; - uint32_t reg_offset = master * 0x200 + queue * 0x100; - struct cam_cci_master_info *cci_master_info = NULL; - struct cam_hw_soc_info *soc_info = &cci_dev->soc_info; - void __iomem *base = soc_info->reg_map[0].mem_base; - - cci_master_info = &cci_dev->cci_master_info[master]; - - while (retry && (cci_master_info->status == 0)) { - read_val0 = cam_io_r_mb(base + - CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset); - CAM_DBG(CAM_CCI, - "CCI%d_I2C_M%d_Q%d_CUR_WORD_CNT_ADDR %d", - soc_info->index, master, queue, read_val0); - - if (read_val0) { - usleep_range(1000, 1010); - read_val1 = cam_io_r_mb(base + - CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset); - CAM_DBG(CAM_CCI, - "CCI%d_I2C_M%d_Q%d_CUR_WORD_CNT_ADDR %d", - soc_info->index, master, queue, read_val1); - - if (read_val1 == 0) - /* No pending cmd in the CCI */ - break; - else if (read_val0 == read_val1) { - /* queue is stable now */ - CAM_DBG(CAM_CCI, - "CCI%d_I2C_M%d_Q%d_EXEC_WORD_CNT_ADDR %d", - soc_info->index, master, - queue, read_val0); - cam_io_w_mb(read_val0, base + - CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR + - reg_offset); - - cam_io_w_mb(1 << ((master * 2) + queue), - base + CCI_QUEUE_START_ADDR); - - CAM_INFO(CAM_CCI, - "CCI%d_I2C_M%d_Q%d restart the queue", - soc_info->index, master, queue); - - rc = wait_for_completion_timeout( - &cci_master_info->report_q[queue], - CCI_TIMEOUT); - - if (rc <= 0) { - rc = -ETIMEDOUT; - cam_cci_flush_queue(cci_dev, master); - break; - } - } else { - retry--; - CAM_INFO(CAM_CCI, - "CCI%d_I2C_M%d_Q%d_CURR_WORD_CNT isn't stable retry:%d", - soc_info->index, master, queue, retry); - continue; - } - } else { - CAM_INFO(CAM_CCI, - "CCI%d_I2C_M%d_Q%d_CURR_WORD_CNT is 0, treat it as normal", - soc_info->index, master, queue); - break; - } - } - - if (retry == 0) { - rc = -ETIMEDOUT; - cam_cci_flush_queue(cci_dev, master); - } - - return rc; -} - static uint32_t cam_cci_wait(struct cci_device *cci_dev, enum cci_i2c_master_t master, enum cci_i2c_queue_t queue) { int32_t rc = 0; - struct cam_hw_soc_info *soc_info = NULL; if (!cci_dev) { CAM_ERR(CAM_CCI, "failed"); return -EINVAL; } - soc_info = &cci_dev->soc_info; - rc = wait_for_completion_timeout( &cci_dev->cci_master_info[master].report_q[queue], CCI_TIMEOUT); - CAM_DBG(CAM_CCI, "wait DONE_for_completion_timeout, rc=%d", rc); + CAM_DBG(CAM_CCI, "wait DONE_for_completion_timeout"); if (rc <= 0) { #ifdef DUMP_CCI_REGISTERS @@ -387,16 +264,11 @@ static uint32_t cam_cci_wait(struct cci_device *cci_dev, #endif CAM_ERR(CAM_CCI, "wait for queue: %d", queue); if (rc == 0) { - rc = cam_cci_retry(cci_dev, master, queue); - if (!rc) - CAM_INFO(CAM_CCI, - "CCI%d_I2C_M%d_Q%d retry success", - soc_info->index, master, queue); - else - return rc; + rc = -ETIMEDOUT; + cam_cci_flush_queue(cci_dev, master); + return rc; } } - rc = cci_dev->cci_master_info[master].status; if (rc < 0) { CAM_ERR(CAM_CCI, "failed rc %d", rc); @@ -418,23 +290,14 @@ static void cam_cci_load_report_cmd(struct cci_device *cci_dev, uint32_t reg_offset = master * 0x200 + queue * 0x100; uint32_t read_val = cam_io_r_mb(base + CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset); - struct cam_cci_i2c_queue_info *queue_info = - &cci_dev->cci_i2c_queue_info[master][queue]; - uint32_t report_id = queue_info->report_id; - uint32_t report_val = CCI_I2C_REPORT_CMD | (1 << 8) | - (1 << 9) | (report_id << 4); - - CAM_DBG(CAM_CCI, "CCI_I2C_REPORT_CMD curr_w_cnt: %d report_id %d", - read_val, report_id); + uint32_t report_val = CCI_I2C_REPORT_CMD | (1 << 8); + + CAM_DBG(CAM_CCI, "CCI_I2C_REPORT_CMD curr_w_cnt: %d", read_val); cam_io_w_mb(report_val, base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR + reg_offset); read_val++; - queue_info->report_id++; - if (queue_info->report_id == REPORT_IDSIZE) - queue_info->report_id = 0; - CAM_DBG(CAM_CCI, "CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR %d", read_val); cam_io_w_mb(read_val, base + CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR + reg_offset); @@ -451,6 +314,7 @@ static int32_t cam_cci_wait_report_cmd(struct cci_device *cci_dev, uint32_t reg_val = 1 << ((master * 2) + queue); + cam_cci_load_report_cmd(cci_dev, master, queue); spin_lock_irqsave( &cci_dev->cci_master_info[master].lock_q[queue], flags); atomic_set(&cci_dev->cci_master_info[master].q_free[queue], 1); @@ -475,13 +339,11 @@ static int32_t cam_cci_transfer_end(struct cci_device *cci_dev, if (atomic_read(&cci_dev->cci_master_info[master].q_free[queue]) == 0) { spin_unlock_irqrestore( &cci_dev->cci_master_info[master].lock_q[queue], flags); - cam_cci_load_report_cmd(cci_dev, master, queue); rc = cam_cci_lock_queue(cci_dev, master, queue, 0); if (rc < 0) { CAM_ERR(CAM_CCI, "failed rc: %d", rc); return rc; } - rc = cam_cci_wait_report_cmd(cci_dev, master, queue); if (rc < 0) { CAM_ERR(CAM_CCI, "failed rc %d", rc); @@ -498,13 +360,11 @@ static int32_t cam_cci_transfer_end(struct cci_device *cci_dev, CAM_ERR(CAM_CCI, "failed rc %d", rc); return rc; } - cam_cci_load_report_cmd(cci_dev, master, queue); rc = cam_cci_lock_queue(cci_dev, master, queue, 0); if (rc < 0) { CAM_ERR(CAM_CCI, "failed rc %d", rc); return rc; } - rc = cam_cci_wait_report_cmd(cci_dev, master, queue); if (rc < 0) { CAM_ERR(CAM_CCI, "Failed rc %d", rc); @@ -579,9 +439,6 @@ static int32_t cam_cci_process_full_q(struct cci_device *cci_dev, } else { spin_unlock_irqrestore( &cci_dev->cci_master_info[master].lock_q[queue], flags); - CAM_DBG(CAM_CCI, "CCI%d_I2C_M%d_Q%d is set to 0", - cci_dev->soc_info.index, master, queue); - cam_cci_load_report_cmd(cci_dev, master, queue); rc = cam_cci_wait_report_cmd(cci_dev, master, queue); if (rc < 0) { CAM_ERR(CAM_CCI, "failed rc %d", rc); @@ -596,18 +453,12 @@ static int32_t cam_cci_calc_cmd_len(struct cci_device *cci_dev, struct cam_cci_ctrl *c_ctrl, uint32_t cmd_size, struct cam_sensor_i2c_reg_array *i2c_cmd, uint32_t *pack) { - // disable I2C writing optimization due to OIS -#ifndef CONFIG_CAMERA_NONEDXO uint8_t i; -#endif uint32_t len = 0; uint8_t data_len = 0, addr_len = 0; uint8_t pack_max_len; struct cam_sensor_i2c_reg_setting *msg; - // disable I2C writing optimization due to OIS -#ifndef CONFIG_CAMERA_NONEDXO struct cam_sensor_i2c_reg_array *cmd = i2c_cmd; -#endif uint32_t size = cmd_size; if (!cci_dev || !c_ctrl) { @@ -629,9 +480,8 @@ static int32_t cam_cci_calc_cmd_len(struct cci_device *cci_dev, len = data_len + addr_len; pack_max_len = size < (cci_dev->payload_size-len) ? size : (cci_dev->payload_size-len); -#ifndef CONFIG_CAMERA_NONEDXO - if ((!c_ctrl->cci_info->disable_optmz) && - (!disable_optmz)) { + if ((!c_ctrl->cci_info->disable_optmz) && (!disable_optmz)) + { CAM_DBG(CAM_CCI, "enable writing optimization for 0x%02X", c_ctrl->cci_info->sid<<1); for (i = 0; i < pack_max_len;) { if (cmd->delay || ((cmd - i2c_cmd) >= (cmd_size - 1))) @@ -651,7 +501,6 @@ static int32_t cam_cci_calc_cmd_len(struct cci_device *cci_dev, cmd++; } } -#endif } if (len > cci_dev->payload_size) { @@ -857,14 +706,6 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev, cci_dev->cci_wait_sync_cfg.csid * CCI_SET_CID_SYNC_TIMER_OFFSET); - rc = cam_cci_lock_queue(cci_dev, master, queue, 1); - if (rc < 0) { - CAM_ERR(CAM_CCI, - "CCI%d_I2C_M%d_Q%d Failed to lock_queue for rc: %d", - cci_dev->soc_info.index, master, queue, rc); - return rc; - } - val = CCI_I2C_SET_PARAM_CMD | c_ctrl->cci_info->sid << 4 | c_ctrl->cci_info->retries << 16 | c_ctrl->cci_info->id_map << 18; @@ -899,6 +740,12 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev, reg_offset); } + rc = cam_cci_lock_queue(cci_dev, master, queue, 1); + if (rc < 0) { + CAM_ERR(CAM_CCI, "failed line %d", rc); + return rc; + } + while (cmd_size) { uint32_t pack = 0; @@ -913,9 +760,9 @@ static int32_t cam_cci_data_queue(struct cci_device *cci_dev, CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset); CAM_DBG(CAM_CCI, "CUR_WORD_CNT_ADDR %d len %d max %d", read_val, len, max_queue_size); - /* + 2 - space alocation for Report and Unlock CMD */ - if ((read_val + len + 2) > queue_size) { - if ((read_val + len + 2) > max_queue_size) { + /* + 1 - space alocation for Report CMD */ + if ((read_val + len + 1) > queue_size) { + if ((read_val + len + 1) > max_queue_size) { rc = cam_cci_process_full_q(cci_dev, master, queue); if (rc < 0) { @@ -1127,22 +974,19 @@ static int32_t cam_cci_burst_read(struct v4l2_subdev *sd, goto rel_mutex_q; } - val = CCI_I2C_LOCK_CMD; + CAM_DBG(CAM_CCI, "set param sid 0x%x retries %d id_map %d", + c_ctrl->cci_info->sid, c_ctrl->cci_info->retries, + c_ctrl->cci_info->id_map); + val = CCI_I2C_SET_PARAM_CMD | c_ctrl->cci_info->sid << 4 | + c_ctrl->cci_info->retries << 16 | + c_ctrl->cci_info->id_map << 18; rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue); if (rc < 0) { - CAM_DBG(CAM_CCI, - "CCI%d_I2C_M%d_Q%d failed to write lock_cmd for rc: %d", - cci_dev->soc_info.index, master, queue, rc); + CAM_DBG(CAM_CCI, "failed rc: %d", rc); goto rel_mutex_q; } - CAM_DBG(CAM_CCI, - "CCI%d_I2C_M%d_Q%d set param sid 0x%x retries %d id_map %d", - cci_dev->soc_info.index, master, queue, c_ctrl->cci_info->sid, - c_ctrl->cci_info->retries, c_ctrl->cci_info->id_map); - val = CCI_I2C_SET_PARAM_CMD | c_ctrl->cci_info->sid << 4 | - c_ctrl->cci_info->retries << 16 | - c_ctrl->cci_info->id_map << 18; + val = CCI_I2C_LOCK_CMD; rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue); if (rc < 0) { CAM_DBG(CAM_CCI, "failed rc: %d", rc); @@ -1367,11 +1211,7 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd, cci_dev->cci_i2c_queue_info[master][queue].max_queue_size - 1, master, queue); if (rc < 0) { - val = cam_io_r_mb(base + CCI_I2C_M0_Q0_CUR_CMD_ADDR + - master * 0x200 + queue * 0x100); - CAM_ERR(CAM_CCI, - "CCI%d_I2C_M%d_Q%d Initial validataion failed rc: %d, CUR_CMD:0x%x", - cci_dev->soc_info.index, master, queue, rc, val); + CAM_ERR(CAM_CCI, "Initial validataion failed rc %d", rc); goto rel_mutex_q; } @@ -1385,16 +1225,6 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd, goto rel_mutex_q; } - val = CCI_I2C_LOCK_CMD; - rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue); - if (rc < 0) { - CAM_DBG(CAM_CCI, - "CCI%d_I2C_M%d_Q%d failed rc: %d", - cci_dev->soc_info.index, master, - queue, rc); - goto rel_mutex_q; - } - CAM_DBG(CAM_CCI, "master %d, queue %d", master, queue); CAM_DBG(CAM_CCI, "set param sid 0x%x retries %d id_map %d", c_ctrl->cci_info->sid, c_ctrl->cci_info->retries, @@ -1408,6 +1238,13 @@ static int32_t cam_cci_read(struct v4l2_subdev *sd, goto rel_mutex_q; } + val = CCI_I2C_LOCK_CMD; + rc = cam_cci_write_i2c_queue(cci_dev, val, master, queue); + if (rc < 0) { + CAM_DBG(CAM_CCI, "failed rc: %d", rc); + goto rel_mutex_q; + } + if (read_cfg->addr_type >= CAMERA_SENSOR_I2C_TYPE_MAX) { CAM_ERR(CAM_CCI, "failed : Invalid addr type: %u", read_cfg->addr_type); @@ -1811,9 +1648,6 @@ static int32_t cam_cci_write(struct v4l2_subdev *sd, cci_master_info = &cci_dev->cci_master_info[master]; - CAM_DBG(CAM_CCI, "CCI%d_I2C_M%d ctrl_cmd = %d", - cci_dev->soc_info.index, master, c_ctrl->cmd); - switch (c_ctrl->cmd) { case MSM_CCI_I2C_WRITE_SYNC_BLOCK: mutex_lock(&cci_master_info->mutex_q[SYNC_QUEUE]); @@ -1828,27 +1662,18 @@ static int32_t cam_cci_write(struct v4l2_subdev *sd, case MSM_CCI_I2C_WRITE: case MSM_CCI_I2C_WRITE_SEQ: case MSM_CCI_I2C_WRITE_BURST: - if (!c_ctrl->force_low_priority) { - for (i = 0; i < NUM_QUEUES; i++) { - if (mutex_trylock( - &cci_master_info->mutex_q[i])) { - rc = cam_cci_i2c_write(sd, c_ctrl, i, - MSM_SYNC_DISABLE); - mutex_unlock( - &cci_master_info->mutex_q[i]); - return rc; - } + for (i = 0; i < NUM_QUEUES; i++) { + if (mutex_trylock(&cci_master_info->mutex_q[i])) { + rc = cam_cci_i2c_write(sd, c_ctrl, i, + MSM_SYNC_DISABLE); + mutex_unlock(&cci_master_info->mutex_q[i]); + return rc; } - mutex_lock(&cci_master_info->mutex_q[PRIORITY_QUEUE]); - rc = cam_cci_i2c_write(sd, c_ctrl, - PRIORITY_QUEUE, MSM_SYNC_DISABLE); - mutex_unlock(&cci_master_info->mutex_q[PRIORITY_QUEUE]); - } else { - mutex_lock(&cci_master_info->mutex_q[SYNC_QUEUE]); - rc = cam_cci_i2c_write(sd, c_ctrl, - SYNC_QUEUE, MSM_SYNC_DISABLE); - mutex_unlock(&cci_master_info->mutex_q[SYNC_QUEUE]); } + mutex_lock(&cci_master_info->mutex_q[PRIORITY_QUEUE]); + rc = cam_cci_i2c_write(sd, c_ctrl, + PRIORITY_QUEUE, MSM_SYNC_DISABLE); + mutex_unlock(&cci_master_info->mutex_q[PRIORITY_QUEUE]); break; case MSM_CCI_I2C_WRITE_ASYNC: rc = cam_cci_i2c_write_async(sd, c_ctrl, diff --git a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h index 7fff56a3fad8..bfefd06bfcaa 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_CCI_DEV_H_ @@ -38,7 +37,7 @@ #define CYCLES_PER_MICRO_SEC_DEFAULT 4915 #define CCI_MAX_DELAY 1000000 -#define CCI_TIMEOUT msecs_to_jiffies(100) +#define CCI_TIMEOUT msecs_to_jiffies(1500) #define NUM_QUEUES 2 @@ -67,8 +66,6 @@ #define PRIORITY_QUEUE (QUEUE_0) #define SYNC_QUEUE (QUEUE_1) -#define REPORT_IDSIZE 16 - enum cci_i2c_sync { MSM_SYNC_DISABLE, MSM_SYNC_ENABLE, @@ -288,7 +285,6 @@ struct cam_cci_ctrl { struct cam_cci_wait_sync_cfg cci_wait_sync_cfg; struct cam_cci_gpio_cfg gpio_cfg; } cfg; - bool force_low_priority; }; struct cci_write_async { diff --git a/techpack/camera/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c b/techpack/camera/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c index b516930e1ad1..0f8da2f6ed91 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -248,7 +247,6 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev, "Inval cam_packet strut size: %zu, len_of_buff: %zu", sizeof(struct cam_packet), len); rc = -EINVAL; - cam_mem_put_cpu_buf(cfg_dev->packet_handle); return rc; } @@ -260,35 +258,18 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev, remain_len)) { CAM_ERR(CAM_CSIPHY, "Invalid packet params"); rc = -EINVAL; - cam_mem_put_cpu_buf(cfg_dev->packet_handle); return rc; } - if (csl_packet->num_cmd_buf) - cmd_desc = (struct cam_cmd_buf_desc *) - ((uint32_t *)&csl_packet->payload + - csl_packet->cmd_buf_offset / 4); - else { - CAM_ERR(CAM_CSIPHY, "num_cmd_buffers = %d", - csl_packet->num_cmd_buf); - rc = -EINVAL; - cam_mem_put_cpu_buf(cfg_dev->packet_handle); - return rc; - } - - rc = cam_packet_util_validate_cmd_desc(cmd_desc); - if (rc) { - CAM_ERR(CAM_CSIPHY, "Invalid cmd desc ret: %d", rc); - cam_mem_put_cpu_buf(cfg_dev->packet_handle); - return rc; - } + cmd_desc = (struct cam_cmd_buf_desc *) + ((uint32_t *)&csl_packet->payload + + csl_packet->cmd_buf_offset / 4); rc = cam_mem_get_cpu_buf(cmd_desc->mem_handle, &generic_ptr, &len); if (rc < 0) { CAM_ERR(CAM_CSIPHY, "Failed to get cmd buf Mem address : %d", rc); - cam_mem_put_cpu_buf(cfg_dev->packet_handle); return rc; } @@ -297,8 +278,6 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev, CAM_ERR(CAM_CSIPHY, "Not enough buffer provided for cam_cisphy_info"); rc = -EINVAL; - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(cfg_dev->packet_handle); return rc; } @@ -309,8 +288,6 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev, index = cam_csiphy_get_instance_offset(csiphy_dev, cfg_dev->dev_handle); if (index < 0 || index >= csiphy_dev->session_max_device_support) { CAM_ERR(CAM_CSIPHY, "index is invalid: %d", index); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(cfg_dev->packet_handle); return -EINVAL; } @@ -373,8 +350,6 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev, csiphy_dev->csiphy_info[index].data_rate, csiphy_dev->csiphy_info[index].mipi_flags); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(cfg_dev->packet_handle); return rc; reset_settings: @@ -386,8 +361,7 @@ int32_t cam_cmd_buf_parser(struct csiphy_device *csiphy_dev, csiphy_dev->csiphy_info[index].mipi_flags = 0; csiphy_dev->csiphy_info[index].secure_mode = 0; csiphy_dev->csiphy_info[index].hdl_data.device_hdl = -1; - cam_mem_put_cpu_buf(cfg_dev->packet_handle); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); + return rc; } diff --git a/techpack/camera/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c b/techpack/camera/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c index 6eff736f4d04..41f3a9538c08 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -65,7 +65,7 @@ static int cam_eeprom_read_memory(struct cam_eeprom_ctrl_t *e_ctrl, i2c_reg_array.delay = emap[j].page.delay; i2c_reg_settings.reg_setting = &i2c_reg_array; rc = camera_io_dev_write(&e_ctrl->io_master_info, - &i2c_reg_settings, false); + &i2c_reg_settings); if (rc) { CAM_ERR(CAM_EEPROM, "page write failed rc %d", rc); @@ -82,7 +82,7 @@ static int cam_eeprom_read_memory(struct cam_eeprom_ctrl_t *e_ctrl, i2c_reg_array.delay = emap[j].pageen.delay; i2c_reg_settings.reg_setting = &i2c_reg_array; rc = camera_io_dev_write(&e_ctrl->io_master_info, - &i2c_reg_settings, false); + &i2c_reg_settings); if (rc) { CAM_ERR(CAM_EEPROM, "page enable failed rc %d", rc); @@ -126,7 +126,7 @@ static int cam_eeprom_read_memory(struct cam_eeprom_ctrl_t *e_ctrl, i2c_reg_array.delay = emap[j].pageen.delay; i2c_reg_settings.reg_setting = &i2c_reg_array; rc = camera_io_dev_write(&e_ctrl->io_master_info, - &i2c_reg_settings, false); + &i2c_reg_settings); if (rc) { CAM_ERR(CAM_EEPROM, "page disable failed rc %d", @@ -891,12 +891,9 @@ static int32_t cam_eeprom_parse_write_memory_packet( break; } } - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } - return rc; end: - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); return rc; } @@ -1053,12 +1050,9 @@ static int32_t cam_eeprom_init_pkt_parser(struct cam_eeprom_ctrl_t *e_ctrl, } } e_ctrl->cal_data.num_map = num_map + 1; - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } - return rc; end: - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); return rc; } @@ -1100,7 +1094,6 @@ static int32_t cam_eeprom_get_cal_data(struct cam_eeprom_ctrl_t *e_ctrl, } if (buf_size <= io_cfg->offsets[0]) { CAM_ERR(CAM_EEPROM, "Not enough buffer"); - cam_mem_put_cpu_buf(io_cfg->mem_handle[0]); rc = -EINVAL; return rc; } @@ -1113,7 +1106,6 @@ static int32_t cam_eeprom_get_cal_data(struct cam_eeprom_ctrl_t *e_ctrl, if (!read_buffer) { CAM_ERR(CAM_EEPROM, "invalid buffer to copy data"); - cam_mem_put_cpu_buf(io_cfg->mem_handle[0]); rc = -EINVAL; return rc; } @@ -1122,7 +1114,6 @@ static int32_t cam_eeprom_get_cal_data(struct cam_eeprom_ctrl_t *e_ctrl, if (remain_len < e_ctrl->cal_data.num_data) { CAM_ERR(CAM_EEPROM, "failed to copy, Invalid size"); - cam_mem_put_cpu_buf(io_cfg->mem_handle[0]); rc = -EINVAL; return rc; } @@ -1131,7 +1122,6 @@ static int32_t cam_eeprom_get_cal_data(struct cam_eeprom_ctrl_t *e_ctrl, e_ctrl->cal_data.num_data); memcpy(read_buffer, e_ctrl->cal_data.mapdata, e_ctrl->cal_data.num_data); - cam_mem_put_cpu_buf(io_cfg->mem_handle[0]); } else { CAM_ERR(CAM_EEPROM, "Invalid direction"); rc = -EINVAL; @@ -1182,7 +1172,7 @@ static int32_t cam_eeprom_write(struct cam_eeprom_ctrl_t *e_ctrl) &(i2c_set->list_head), list) { rc = camera_io_dev_write_continuous( &e_ctrl->io_master_info, - &i2c_list->i2c_settings, 1, false); + &i2c_list->i2c_settings, 1); if (rc < 0) { CAM_ERR(CAM_EEPROM, "Error in EEPROM write"); @@ -1237,7 +1227,6 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) CAM_ERR(CAM_EEPROM, "Inval cam_packet strut size: %zu, len_of_buff: %zu", sizeof(struct cam_packet), pkt_len); - cam_mem_put_cpu_buf(dev_config.packet_handle); rc = -EINVAL; return rc; } @@ -1249,7 +1238,6 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) if (cam_packet_util_validate_packet(csl_packet, remain_len)) { CAM_ERR(CAM_EEPROM, "Invalid packet params"); - cam_mem_put_cpu_buf(dev_config.packet_handle); rc = -EINVAL; return rc; } @@ -1261,7 +1249,6 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) e_ctrl->soc_info.dev->of_node, e_ctrl); if (rc < 0) { CAM_ERR(CAM_EEPROM, "Failed: rc : %d", rc); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } rc = cam_eeprom_get_cal_data(e_ctrl, csl_packet); @@ -1277,7 +1264,6 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) if (rc) { CAM_ERR(CAM_EEPROM, "Failed in parsing the pkt"); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1336,7 +1322,6 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) csl_packet, e_ctrl); if (rc < 0) { CAM_ERR(CAM_EEPROM, "Failed: rc : %d", rc); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1358,7 +1343,6 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) e_ctrl->eebin_info.size); if (rc < 0) { CAM_ERR(CAM_EEPROM, "Failed in erase : %d", rc); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1368,7 +1352,6 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) rc = cam_eeprom_write(e_ctrl); if (rc < 0) { CAM_ERR(CAM_EEPROM, "Failed: rc : %d", rc); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1387,14 +1370,12 @@ static int32_t cam_eeprom_pkt_parse(struct cam_eeprom_ctrl_t *e_ctrl, void *arg) break; } - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; power_down: cam_eeprom_power_down(e_ctrl); memdata_free: vfree(e_ctrl->cal_data.mapdata); error: - cam_mem_put_cpu_buf(dev_config.packet_handle); kfree(power_info->power_setting); kfree(power_info->power_down_setting); power_info->power_setting = NULL; diff --git a/techpack/camera/drivers/cam_sensor_module/cam_flash/cam_flash_core.c b/techpack/camera/drivers/cam_sensor_module/cam_flash/cam_flash_core.c index 3a0e8efe8e07..33eec4676b53 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_flash/cam_flash_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_flash/cam_flash_core.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -1068,7 +1067,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) CAM_ERR(CAM_FLASH, "Inval cam_packet strut size: %zu, len_of_buff: %zu", sizeof(struct cam_packet), len_of_buffer); - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } @@ -1079,7 +1077,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (cam_packet_util_validate_packet(csl_packet, remain_len)) { CAM_ERR(CAM_FLASH, "Invalid packet params"); - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } @@ -1090,7 +1087,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) CAM_DBG(CAM_FLASH, "reject request %lld, last request to flush %lld", csl_packet->header.request_id, fctrl->last_flush_req); - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } @@ -1114,14 +1110,11 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) &generic_ptr, &len_of_buffer); if (rc < 0) { CAM_ERR(CAM_FLASH, "Failed to get cpu buf"); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } cmd_buf = (uint32_t *)generic_ptr; if (!cmd_buf) { CAM_ERR(CAM_FLASH, "invalid cmd buf"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } @@ -1130,8 +1123,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) (len_of_buffer - sizeof(struct common_header)))) { CAM_ERR(CAM_FLASH, "invalid cmd buf length"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } remain_len = len_of_buffer - cmd_desc[i].offset; @@ -1148,10 +1139,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (len_of_buffer < sizeof(struct cam_flash_init)) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - config.packet_handle); return -EINVAL; } @@ -1171,10 +1158,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) CAM_ERR(CAM_FLASH, "Failed parsing slave info: rc: %d", rc); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - config.packet_handle); return rc; } cmd_length_in_bytes = @@ -1201,10 +1184,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (rc) { CAM_ERR(CAM_FLASH, "Failed update power settings"); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - config.packet_handle); return rc; } break; @@ -1224,10 +1203,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_FLASH, "pkt parsing failed: %d", rc); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - config.packet_handle); return rc; } cmd_length_in_bytes = @@ -1239,12 +1214,10 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) break; } - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } power_info = &fctrl->power_info; if (!power_info) { CAM_ERR(CAM_FLASH, "Power_info is NULL"); - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } @@ -1256,7 +1229,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) CAM_ERR(CAM_FLASH, "failed to fill vreg params for power up rc:%d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -1269,7 +1241,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) CAM_ERR(CAM_FLASH, "failed to fill vreg params power down rc:%d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -1277,14 +1248,12 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (rc) { CAM_ERR(CAM_FLASH, "Enable Regulator Failed rc = %d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } rc = fctrl->func_tbl.apply_setting(fctrl, 0); if (rc) { CAM_ERR(CAM_FLASH, "cannot apply settings rc = %d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -1314,7 +1283,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (rc) { CAM_ERR(CAM_FLASH, "Failed in parsing i2c packets"); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } break; @@ -1333,7 +1301,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (rc) { CAM_ERR(CAM_FLASH, "Failed in Deleting the err: %d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } } @@ -1347,14 +1314,12 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) if (rc) { CAM_ERR(CAM_FLASH, "Failed in parsing i2c NRT packets"); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } rc = fctrl->func_tbl.apply_setting(fctrl, 0); if (rc) CAM_ERR(CAM_FLASH, "Apply setting failed: %d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } case CAM_PKT_NOP_OPCODE: { @@ -1366,7 +1331,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) MAX_PER_FRAME_ARRAY; fctrl->i2c_data.per_frame[frm_offset].is_settings_valid = false; - cam_mem_put_cpu_buf(config.packet_handle); return 0; } @@ -1377,7 +1341,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) default: CAM_ERR(CAM_FLASH, "Wrong Opcode : %d", (csl_packet->header.op_code & 0xFFFFFF)); - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } update_req_mgr: @@ -1400,7 +1363,6 @@ int cam_flash_i2c_pkt_parser(struct cam_flash_ctrl *fctrl, void *arg) fctrl->bridge_intf.crm_cb->add_req(&add_req); CAM_DBG(CAM_FLASH, "add req to req_mgr= %lld", add_req.req_id); } - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -1460,7 +1422,6 @@ int cam_flash_pmic_gpio_pkt_parser( CAM_ERR(CAM_FLASH, "Inval cam_packet strut size: %zu, len_of_buff: %zu", sizeof(struct cam_packet), len_of_buffer); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1472,7 +1433,6 @@ int cam_flash_pmic_gpio_pkt_parser( if (cam_packet_util_validate_packet(csl_packet, remain_len)) { CAM_ERR(CAM_FLASH, "Invalid packet params"); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1484,7 +1444,6 @@ int cam_flash_pmic_gpio_pkt_parser( CAM_WARN(CAM_FLASH, "reject request %lld, last request to flush %d", csl_packet->header.request_id, fctrl->last_flush_req); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1502,15 +1461,12 @@ int cam_flash_pmic_gpio_pkt_parser( &cmd_buf_ptr, &len_of_buffer); if (rc) { CAM_ERR(CAM_FLASH, "Fail in get buffer: %d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } if ((len_of_buffer < sizeof(struct cam_flash_init)) || (cmd_desc->offset > (len_of_buffer - sizeof(struct cam_flash_init)))) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1534,8 +1490,6 @@ int cam_flash_pmic_gpio_pkt_parser( if (rc) { CAM_ERR(CAM_FLASH, "Enable Regulator Failed rc = %d", rc); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -1548,8 +1502,6 @@ int cam_flash_pmic_gpio_pkt_parser( if (remain_len < sizeof(struct cam_flash_set_on_off)) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1559,16 +1511,12 @@ int cam_flash_pmic_gpio_pkt_parser( if (!flash_operation_info) { CAM_ERR(CAM_FLASH, "flash_operation_info Null"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } if (flash_operation_info->count > CAM_FLASH_MAX_LED_TRIGGERS) { CAM_ERR(CAM_FLASH, "led count out of limit"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1590,14 +1538,14 @@ int cam_flash_pmic_gpio_pkt_parser( "Apply setting failed: %d", rc); -#ifdef CONFIG_BOARD_PSYCHE - if (rc && CAM_FLASH_STATE_START == fctrl->flash_state) { - CAM_ERR(CAM_FLASH, - "cannot apply settings rc = %d for state %d", - rc, fctrl->flash_state); + //xiaomi add start + if(rc && CAM_FLASH_STATE_START == fctrl->flash_state) + { + CAM_ERR(CAM_FLASH, "cannot apply settings rc = %d for state %d", + rc, fctrl->flash_state); return rc; } -#endif + //xiaomi add end fctrl->flash_state = CAM_FLASH_STATE_CONFIG; break; @@ -1605,13 +1553,9 @@ int cam_flash_pmic_gpio_pkt_parser( default: CAM_ERR(CAM_FLASH, "Wrong cmd_type = %d", cam_flash_info->cmd_type); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } - - cam_mem_put_cpu_buf(cmd_desc->mem_handle); break; } case CAM_FLASH_PACKET_OPCODE_SET_OPS: { @@ -1636,7 +1580,6 @@ int cam_flash_pmic_gpio_pkt_parser( if (rc) { CAM_ERR(CAM_FLASH, "Fail in get buffer: 0x%x", cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -1644,8 +1587,6 @@ int cam_flash_pmic_gpio_pkt_parser( (cmd_desc->offset > (len_of_buffer - sizeof(struct common_header)))) { CAM_ERR(CAM_FLASH, "not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1654,8 +1595,6 @@ int cam_flash_pmic_gpio_pkt_parser( cmd_buf = (uint32_t *)((uint8_t *)cmd_buf_ptr + cmd_desc->offset); if (!cmd_buf) { - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1671,16 +1610,10 @@ int cam_flash_pmic_gpio_pkt_parser( CAM_WARN(CAM_FLASH, "Rxed Flash fire ops without linking"); flash_data->cmn_attr.is_settings_valid = false; - cam_mem_put_cpu_buf( - cmd_desc->mem_handle); - cam_mem_put_cpu_buf( - config.packet_handle); return -EINVAL; } if (remain_len < sizeof(struct cam_flash_set_on_off)) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1690,16 +1623,12 @@ int cam_flash_pmic_gpio_pkt_parser( if (!flash_operation_info) { CAM_ERR(CAM_FLASH, "flash_operation_info Null"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } if (flash_operation_info->count > CAM_FLASH_MAX_LED_TRIGGERS) { CAM_ERR(CAM_FLASH, "led count out of limit"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1720,13 +1649,9 @@ int cam_flash_pmic_gpio_pkt_parser( default: CAM_ERR(CAM_FLASH, "Wrong cmd_type = %d", cmn_hdr->cmd_type); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } - - cam_mem_put_cpu_buf(cmd_desc->mem_handle); break; } case CAM_FLASH_PACKET_OPCODE_NON_REALTIME_SET_OPS: { @@ -1738,7 +1663,6 @@ int cam_flash_pmic_gpio_pkt_parser( &cmd_buf_ptr, &len_of_buffer); if (rc) { CAM_ERR(CAM_FLASH, "Fail in get buffer: %d", rc); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -1746,8 +1670,6 @@ int cam_flash_pmic_gpio_pkt_parser( (cmd_desc->offset > (len_of_buffer - sizeof(struct common_header)))) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1761,8 +1683,6 @@ int cam_flash_pmic_gpio_pkt_parser( CAM_DBG(CAM_FLASH, "Widget Flash Operation"); if (remain_len < sizeof(struct cam_flash_set_on_off)) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1771,16 +1691,12 @@ int cam_flash_pmic_gpio_pkt_parser( if (!flash_operation_info) { CAM_ERR(CAM_FLASH, "flash_operation_info Null"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } if (flash_operation_info->count > CAM_FLASH_MAX_LED_TRIGGERS) { CAM_ERR(CAM_FLASH, "led count out of limit"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1801,8 +1717,6 @@ int cam_flash_pmic_gpio_pkt_parser( if (rc) CAM_ERR(CAM_FLASH, "Apply setting failed: %d", rc); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } case CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR: { @@ -1810,8 +1724,6 @@ int cam_flash_pmic_gpio_pkt_parser( if (remain_len < sizeof(struct cam_flash_query_curr)) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1834,8 +1746,6 @@ int cam_flash_pmic_gpio_pkt_parser( if (rc) { CAM_ERR(CAM_FLASH, "Query current failed with rc=%d", rc); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } flash_query_info->query_current_ma = query_curr_ma; @@ -1845,8 +1755,6 @@ int cam_flash_pmic_gpio_pkt_parser( rc = 0; if (remain_len < sizeof(struct cam_flash_set_rer)) { CAM_ERR(CAM_FLASH, "Not enough buffer"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1854,16 +1762,12 @@ int cam_flash_pmic_gpio_pkt_parser( if (!flash_rer_info) { CAM_ERR(CAM_FLASH, "flash_rer_info Null"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } if (flash_rer_info->count > CAM_FLASH_MAX_LED_TRIGGERS) { CAM_ERR(CAM_FLASH, "led count out of limit"); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1888,20 +1792,15 @@ int cam_flash_pmic_gpio_pkt_parser( if (rc) CAM_ERR(CAM_FLASH, "apply_setting failed: %d", rc); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); return rc; } default: CAM_ERR(CAM_FLASH, "Wrong cmd_type : %d", cmn_hdr->cmd_type); - cam_mem_put_cpu_buf(cmd_desc->mem_handle); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } - cam_mem_put_cpu_buf(cmd_desc->mem_handle); break; } case CAM_PKT_NOP_OPCODE: { @@ -1913,7 +1812,6 @@ int cam_flash_pmic_gpio_pkt_parser( "Rxed NOP packets without linking"); fctrl->per_frame[frm_offset].cmn_attr.is_settings_valid = false; - cam_mem_put_cpu_buf(config.packet_handle); return -EINVAL; } @@ -1927,7 +1825,6 @@ int cam_flash_pmic_gpio_pkt_parser( default: CAM_ERR(CAM_FLASH, "Wrong Opcode : %d", (csl_packet->header.op_code & 0xFFFFFF)); - cam_mem_put_cpu_buf(config.packet_handle); rc = -EINVAL; return rc; } @@ -1952,7 +1849,6 @@ int cam_flash_pmic_gpio_pkt_parser( CAM_DBG(CAM_FLASH, "add req to req_mgr= %lld", add_req.req_id); } - cam_mem_put_cpu_buf(config.packet_handle); return rc; } diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.c b/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.c index d1abf8ad23c1..b69a44c7fe2d 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.c @@ -1,11 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (C) 2020 XiaoMi, Inc. */ #include #include -#include #include #include "cam_ois_core.h" #include "cam_ois_soc.h" @@ -15,6 +15,7 @@ #include "cam_common_util.h" #include "cam_packet_util.h" #include "Lc898128.h" +#include const uint8_t PACT1Tbl[] = { 0x20, 0xDF }; /* [ACT_02][ACT_01][ACT_03] */ @@ -38,7 +39,7 @@ void RamWrite32A(struct cam_ois_ctrl_t *o_ctrl, uint32_t addr, uint32_t data, ui i2c_reg_settings.reg_setting = &i2c_reg_array; rc = camera_io_dev_write(&o_ctrl->io_master_info, - &i2c_reg_settings, false); + &i2c_reg_settings); if (rc) { CAM_ERR(CAM_OIS, "%s : write addr 0x%04x data 0x%x failed rc %d", o_ctrl->ois_name, addr, data, rc); @@ -129,7 +130,7 @@ void CntWrt(struct cam_ois_ctrl_t *o_ctrl, uint8_t *data, uint32_t length, uint3 write_setting.reg_setting = w_data; rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &write_setting, 1, false); + &write_setting, 1); if (rc < 0) { CAM_ERR(CAM_OIS, "OIS CntWrt write failed %d", rc); } @@ -1253,7 +1254,7 @@ uint8_t download_fw( const char *fw_name = NULL; struct device *dev = &(o_ctrl->pdev->dev); struct cam_sensor_i2c_reg_setting i2c_reg_setting; - struct page *page = NULL; + void *vaddr = NULL; fw_addr = addr; fw_name = firmware_name; @@ -1268,18 +1269,18 @@ uint8_t download_fw( i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; i2c_reg_setting.size = total_bytes; i2c_reg_setting.delay = 0; - fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * - total_bytes) >> PAGE_SHIFT; - page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), - fw_size, 0, GFP_KERNEL); - if (!page) { - CAM_ERR(CAM_OIS, "Failed in allocating i2c_array"); + fw_size = sizeof(struct cam_sensor_i2c_reg_array) * total_bytes; + vaddr = vmalloc(fw_size); + + if (!vaddr) { + CAM_ERR(CAM_OIS, + "Failed in allocating i2c_array: fw_size: %u", fw_size); release_firmware(fw); return -ENOMEM; } - i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) ( - page_address(page)); + i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) vaddr; + ptr = (uint8_t *)fw->data; if (read_data) { for (i = 0; i < read_length; i++) { @@ -1298,7 +1299,7 @@ uint8_t download_fw( i2c_reg_setting.size = cnt; rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &i2c_reg_setting, 1, false); + &i2c_reg_setting, 1); if (rc < 0) { CAM_ERR(CAM_OIS, "OIS FW %s download failed %d", fw_name, rc); break; @@ -1312,9 +1313,9 @@ uint8_t download_fw( } } } - cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), - page, fw_size); - page = NULL; + + vfree(vaddr); + vaddr = NULL; fw_size = 0; release_firmware(fw); } diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.h b/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.h index 0b3db35d2a01..b104c03c905f 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/Lc898128.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (C) 2020 XiaoMi, Inc. */ #ifndef _CAM_LC898218_H_ #define _CAM_LC898218_H_ diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/Makefile b/techpack/camera/drivers/cam_sensor_module/cam_ois/Makefile index c4bbe20fb711..daedad5dcb44 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/Makefile +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/Makefile @@ -11,4 +11,4 @@ ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_ois_dev.o cam_ois_core.o cam_ois_soc.o Lc898128.o Sem1215.o +obj-$(CONFIG_SPECTRA_CAMERA) += cam_ois_dev.o cam_ois_core.o cam_ois_soc.o Sem1215.o Lc898128.o diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.c b/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.c index 0a020e2951a5..8898ee6211f7 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.c @@ -1,95 +1,95 @@ -#include -#include -#include -#include -#include "cam_ois_core.h" -#include "cam_ois_soc.h" -#include "cam_sensor_util.h" -#include "cam_debug_util.h" -#include "cam_res_mgr_api.h" -#include "cam_common_util.h" -#include "cam_packet_util.h" -#include "Sem1215.h" - -void I2C_Read_Data(struct cam_ois_ctrl_t *o_ctrl, uint32_t addr, uint32_t length, uint8_t *data) -{ - int32_t rc = 0; - int32_t i = 0; - rc = camera_io_dev_read_seq(&o_ctrl->io_master_info, - addr, data, - CAMERA_SENSOR_I2C_TYPE_WORD, - CAMERA_SENSOR_I2C_TYPE_BYTE, - length); - for (i = 0; i < length; i++) { - CAM_DBG(CAM_OIS, "[OISDEBUG] read addr 0x%04x[%d] = 0x%02x", addr, i, data[i]); - } - if (rc) { - CAM_ERR(CAM_EEPROM, "read failed rc %d", - rc); - } -} - -void I2C_Write_Data(struct cam_ois_ctrl_t *o_ctrl,uint32_t addr, uint32_t length,uint8_t* data, uint32_t delay) -{ - static struct cam_sensor_i2c_reg_array w_data[256] = { {0} }; - struct cam_sensor_i2c_reg_setting write_setting; - uint32_t i = 0; - int32_t rc = 0; - if (!data || !o_ctrl || (length < 1)) { - CAM_ERR(CAM_OIS, "Invalid Args"); - return; - } - - for (i = 0;i < length && i < 256; i++) { - w_data[i].reg_addr = addr; - w_data[i].reg_data = data[i]; - w_data[i].delay = 0; - w_data[i].data_mask = 0; - } - write_setting.size = length; - write_setting.addr_type = CAMERA_SENSOR_I2C_TYPE_WORD; - write_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; - write_setting.delay = delay; - write_setting.reg_setting = w_data; - - rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &write_setting, 0, false); - if (rc < 0) { - CAM_ERR(CAM_OIS, "OIS I2C_Write_Data write failed %d", rc); - } - for (i = 0; i < length && i < 256; i+=4) { - CAM_DBG(CAM_OIS, "[OISDEBUG] write addr 0x%04x = 0x%02x 0x%02x 0x%02x 0x%02x", w_data[i].reg_addr, data[i], data[i+1], data[i+2], data[i+3]); - } -} - -uint8_t load_fw_buff( - struct cam_ois_ctrl_t *o_ctrl, - char* firmware_name, - uint8_t *read_data, - uint32_t read_length) -{ - - uint16_t total_bytes = 0; - uint8_t *ptr = NULL; - int32_t rc = 0, i; - const struct firmware *fw = NULL; - const char *fw_name = NULL; - struct device *dev = &(o_ctrl->pdev->dev); - - fw_name = firmware_name; - - rc = request_firmware(&fw, fw_name, dev); - if (rc) { - CAM_ERR(CAM_OIS, "Failed to locate %s", fw_name); - } else { - total_bytes = fw->size; - ptr = (uint8_t *)fw->data; - if (read_data) { - for (i = 0; i < read_length; i++) { - read_data[i] = *(ptr + i); - } - } - } - release_firmware(fw); - return 0; -} +#include +#include +#include +#include +#include "cam_ois_core.h" +#include "cam_ois_soc.h" +#include "cam_sensor_util.h" +#include "cam_debug_util.h" +#include "cam_res_mgr_api.h" +#include "cam_common_util.h" +#include "cam_packet_util.h" +#include "Sem1215.h" + +void I2C_Read_Data(struct cam_ois_ctrl_t *o_ctrl, uint32_t addr, uint32_t length, uint8_t *data) +{ + int32_t rc = 0; + int32_t i = 0; + rc = camera_io_dev_read_seq(&o_ctrl->io_master_info, + addr, data, + CAMERA_SENSOR_I2C_TYPE_WORD, + CAMERA_SENSOR_I2C_TYPE_BYTE, + length); + for (i = 0; i < length; i++) { + CAM_DBG(CAM_OIS, "[OISDEBUG] read addr 0x%04x[%d] = 0x%02x", addr, i, data[i]); + } + if (rc) { + CAM_ERR(CAM_EEPROM, "read failed rc %d", + rc); + } +} + +void I2C_Write_Data(struct cam_ois_ctrl_t *o_ctrl,uint32_t addr, uint32_t length,uint8_t* data, uint32_t delay) +{ + static struct cam_sensor_i2c_reg_array w_data[256] = { {0} }; + struct cam_sensor_i2c_reg_setting write_setting; + uint32_t i = 0; + int32_t rc = 0; + if (!data || !o_ctrl || (length < 1)) { + CAM_ERR(CAM_OIS, "Invalid Args"); + return; + } + + for (i = 0;i < length && i < 256; i++) { + w_data[i].reg_addr = addr; + w_data[i].reg_data = data[i]; + w_data[i].delay = 0; + w_data[i].data_mask = 0; + } + write_setting.size = length; + write_setting.addr_type = CAMERA_SENSOR_I2C_TYPE_WORD; + write_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; + write_setting.delay = delay; + write_setting.reg_setting = w_data; + + rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), + &write_setting, 0); + if (rc < 0) { + CAM_ERR(CAM_OIS, "OIS I2C_Write_Data write failed %d", rc); + } + for (i = 0; i < length && i < 256; i+=4) { + CAM_DBG(CAM_OIS, "[OISDEBUG] write addr 0x%04x = 0x%02x 0x%02x 0x%02x 0x%02x", w_data[i].reg_addr, data[i], data[i+1], data[i+2], data[i+3]); + } +} + +uint8_t load_fw_buff( + struct cam_ois_ctrl_t *o_ctrl, + char* firmware_name, + uint8_t *read_data, + uint32_t read_length) +{ + + uint16_t total_bytes = 0; + uint8_t *ptr = NULL; + int32_t rc = 0, i; + const struct firmware *fw = NULL; + const char *fw_name = NULL; + struct device *dev = &(o_ctrl->pdev->dev); + + fw_name = firmware_name; + + rc = request_firmware(&fw, fw_name, dev); + if (rc) { + CAM_ERR(CAM_OIS, "Failed to locate %s", fw_name); + } else { + total_bytes = fw->size; + ptr = (uint8_t *)fw->data; + if (read_data) { + for (i = 0; i < read_length; i++) { + read_data[i] = *(ptr + i); + } + } + } + release_firmware(fw); + return 0; +} diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.h b/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.h index 1c11aa782b33..97649ecc0e2d 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/Sem1215.h @@ -1,39 +1,39 @@ -#ifndef _CAM_SEM1215_H_ -#define _CAM_SEM1215_H_ - -/* Default set 256 byte but you can change TX_BUFFER_SIZE between 32 to 256 */ -#define TX_SIZE_32_BYTE 32 -#define TX_SIZE_64_BYTE 64 -#define TX_SIZE_128_BYTE 128 -#define TX_SIZE_256_BYTE 256 -#define TX_BUFFER_SIZE TX_SIZE_256_BYTE -#define RX_BUFFER_SIZE 4 -#define REG_OIS_CTRL 0x0000 -#define REG_OIS_STS 0x0001 -#define REG_AF_CTRL 0x0200 -#define REG_AF_STS 0x0201 -#define REG_FWUP_CTRL 0x1000 -#define REG_FWUP_ERR 0x1001 -#define REG_FWUP_CHKSUM 0x1002 -#define REG_APP_VER 0x1008 -#define REG_DATA_BUF 0x1100 -#define OIS_OFF 0x00 -#define AF_OFF 0x00 -#define STATE_READY 0x01 -#define NO_ERROR 0x00 -#define RESET_REQ 0x80 -#define FWUP_CTRL_32_SET 0x01 -#define FWUP_CTRL_64_SET 0x03 -#define FWUP_CTRL_128_SET 0x05 -#define FWUP_CTRL_256_SET 0x07 -#define APP_FW_SIZE (32*1024) - -void I2C_Read_Data(struct cam_ois_ctrl_t *o_ctrl, uint32_t addr, uint32_t length, uint8_t *data); -void I2C_Write_Data(struct cam_ois_ctrl_t *o_ctrl,uint32_t addr, uint32_t length,uint8_t *data, uint32_t delay); -uint8_t load_fw_buff( - struct cam_ois_ctrl_t *o_ctrl, - char* firmware_name, - uint8_t *read_data, - uint32_t read_length); - -#endif \ No newline at end of file +#ifndef _CAM_SEM1215_H_ +#define _CAM_SEM1215_H_ + +/* Default set 256 byte but you can change TX_BUFFER_SIZE between 32 to 256 */ +#define TX_SIZE_32_BYTE 32 +#define TX_SIZE_64_BYTE 64 +#define TX_SIZE_128_BYTE 128 +#define TX_SIZE_256_BYTE 256 +#define TX_BUFFER_SIZE TX_SIZE_256_BYTE +#define RX_BUFFER_SIZE 4 +#define REG_OIS_CTRL 0x0000 +#define REG_OIS_STS 0x0001 +#define REG_AF_CTRL 0x0200 +#define REG_AF_STS 0x0201 +#define REG_FWUP_CTRL 0x1000 +#define REG_FWUP_ERR 0x1001 +#define REG_FWUP_CHKSUM 0x1002 +#define REG_APP_VER 0x1008 +#define REG_DATA_BUF 0x1100 +#define OIS_OFF 0x00 +#define AF_OFF 0x00 +#define STATE_READY 0x01 +#define NO_ERROR 0x00 +#define RESET_REQ 0x80 +#define FWUP_CTRL_32_SET 0x01 +#define FWUP_CTRL_64_SET 0x03 +#define FWUP_CTRL_128_SET 0x05 +#define FWUP_CTRL_256_SET 0x07 +#define APP_FW_SIZE (32*1024) + +void I2C_Read_Data(struct cam_ois_ctrl_t *o_ctrl, uint32_t addr, uint32_t length, uint8_t *data); +void I2C_Write_Data(struct cam_ois_ctrl_t *o_ctrl,uint32_t addr, uint32_t length,uint8_t *data, uint32_t delay); +uint8_t load_fw_buff( + struct cam_ois_ctrl_t *o_ctrl, + char* firmware_name, + uint8_t *read_data, + uint32_t read_length); + +#endif diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c b/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c index 3d3128ad522b..ad7db9e65423 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_core.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -15,9 +14,9 @@ #include "cam_res_mgr_api.h" #include "cam_common_util.h" #include "cam_packet_util.h" -#include "Lc898128.h" #include #include "Sem1215.h" +#include "Lc898128.h" static int oisfwctrl; module_param(oisfwctrl, int, 0644); @@ -232,7 +231,7 @@ static int cam_ois_apply_settings(struct cam_ois_ctrl_t *o_ctrl, &(i2c_set->list_head), list) { if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_RANDOM) { rc = camera_io_dev_write(&(o_ctrl->io_master_info), - &(i2c_list->i2c_settings), false); + &(i2c_list->i2c_settings)); if (rc < 0) { CAM_ERR(CAM_OIS, "Failed in Applying i2c wrt settings"); @@ -303,7 +302,7 @@ static int cam_ois_slaveInfo_pkt_parser(struct cam_ois_ctrl_t *o_ctrl, return rc; } -static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) +static int cam_default_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) { uint16_t total_bytes = 0; uint8_t *ptr = NULL; @@ -352,7 +351,6 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) fw_name_coeff = name_coeff; fw_name_mem = name_mem; fw_name_ph = name_ph; - /* Load FW */ rc = request_firmware(&fw, fw_name_prog, dev); if (rc) { @@ -390,7 +388,7 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) if (o_ctrl->opcode.is_addr_increase) prog_addr += cnt; rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &i2c_reg_setting, 1, false); + &i2c_reg_setting, 1); if (rc < 0) { CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc); goto release_firmware; @@ -438,7 +436,7 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) if (o_ctrl->opcode.is_addr_increase) coeff_addr += cnt; rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &i2c_reg_setting, 1, false); + &i2c_reg_setting, 1); if (rc < 0) CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc); } @@ -477,53 +475,6 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) i2c_reg_setting.size = cnt; if (o_ctrl->opcode.is_addr_increase) mem_addr += cnt; - rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &i2c_reg_setting, 1, false); - if (rc < 0) - CAM_ERR(CAM_OIS, "OIS FW Memory download failed %d", rc); - } - cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), - page_xm, fw_size_xm); - page_xm = NULL; - fw_size_xm = 0; - release_firmware(fw_xm); - } - - /* - rc = request_firmware(&fw_xm, fw_name_ph, dev); - if (rc) { - CAM_INFO(CAM_OIS, "Failed to locate %s, not error", fw_name_ph); - rc = 0; - } else { - total_bytes = fw_xm->size; - i2c_reg_setting.addr_type = o_ctrl->opcode.fw_addr_type; - i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; - i2c_reg_setting.size = total_bytes; - i2c_reg_setting.delay = 0; - fw_size_xm = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * - total_bytes) >> PAGE_SHIFT; - page_xm = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), - fw_size_xm, 0, GFP_KERNEL); - if (!page_xm) { - CAM_ERR(CAM_OIS, "Failed in allocating i2c_array"); - release_firmware(fw_xm); - return -ENOMEM; - } - - i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) ( - page_address(page_xm)); - - for (i = 0, ptr = (uint8_t *)fw_xm->data; i < total_bytes;) { - for (cnt = 0; cnt < OIS_TRANS_SIZE && i < total_bytes; - cnt++, ptr++, i++) { - i2c_reg_setting.reg_setting[cnt].reg_addr = pheripheral_addr; - i2c_reg_setting.reg_setting[cnt].reg_data = *ptr; - i2c_reg_setting.reg_setting[cnt].delay = 0; - i2c_reg_setting.reg_setting[cnt].data_mask = 0; - } - i2c_reg_setting.size = cnt; - if (o_ctrl->opcode.is_addr_increase) - pheripheral_addr += cnt; rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), &i2c_reg_setting, 1); if (rc < 0) @@ -535,7 +486,6 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) fw_size_xm = 0; release_firmware(fw_xm); } - */ release_firmware: cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), @@ -545,7 +495,6 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) return rc; } - struct cam_sensor_i2c_reg_array ois_pm_add_array[]= { {0x30, 0x00, 0x0, 0x0}, {0x30, 0x10, 0x0, 0x0}, @@ -607,15 +556,14 @@ static int cam_lc898124_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) fw_name_mem = name_mem; /* PM data address write */ - write_setting.size = sizeof(ois_pm_add_array) / - sizeof(struct cam_sensor_i2c_reg_array); - write_setting.addr_type = CAMERA_SENSOR_I2C_TYPE_BYTE; - write_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; - write_setting.delay = 0; - write_setting.reg_setting = ois_pm_add_array; + write_setting.size= sizeof(ois_pm_add_array)/sizeof(struct cam_sensor_i2c_reg_array); + write_setting.addr_type =CAMERA_SENSOR_I2C_TYPE_BYTE; + write_setting.data_type= CAMERA_SENSOR_I2C_TYPE_BYTE; + write_setting.delay=0; + write_setting.reg_setting= ois_pm_add_array; rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &write_setting, 1, false); + &write_setting, 1); if (rc < 0) { CAM_ERR(CAM_OIS, "OIS ois pm add failed %d", rc); } @@ -633,25 +581,22 @@ static int cam_lc898124_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) i2c_reg_setting.size = total_bytes; i2c_reg_setting.delay = 0; fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * - total_bytes) >> - PAGE_SHIFT; - page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), fw_size, 0, - GFP_KERNEL); + total_bytes) >> PAGE_SHIFT; + page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), + fw_size, 0, GFP_KERNEL); if (!page) { CAM_ERR(CAM_OIS, "Failed in allocating i2c_array"); release_firmware(fw); return -ENOMEM; } - i2c_reg_setting.reg_setting = - (struct cam_sensor_i2c_reg_array *)(page_address(page)); + i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) ( + page_address(page)); for (i = 0, ptr = (uint8_t *)fw->data; i < total_bytes;) { - CAM_DBG(CAM_OIS, - "download %s prog_addr =0x%02x total_bytes=%d", - fw_name_prog, prog_addr, total_bytes); + CAM_DBG(CAM_OIS, "download %s prog_addr =0x%02x total_bytes=%d", fw_name_prog, prog_addr,total_bytes); for (cnt = 0; cnt < LC124EP3_OIS_TRANS_SIZE && i < total_bytes; - cnt++, ptr++, i++) { + cnt++, ptr++, i++) { i2c_reg_setting.reg_setting[cnt].reg_addr = prog_addr; i2c_reg_setting.reg_setting[cnt].reg_data = *ptr; i2c_reg_setting.reg_setting[cnt].delay = 0; @@ -659,35 +604,34 @@ static int cam_lc898124_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) } i2c_reg_setting.size = cnt; rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &i2c_reg_setting, 1, false); + &i2c_reg_setting, 1); if (rc < 0) { CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc); goto release_firmware; } } - - cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), page, fw_size); + cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), + page, fw_size); page = NULL; fw_size = 0; release_firmware(fw); - /* write 0xF00A PM size*/ + /* write 0xF00A PM size*/ CAM_DBG(CAM_OIS, "PM size write"); - write_setting.size = sizeof(ois_pm_length_array) / - sizeof(struct cam_sensor_i2c_reg_array); - write_setting.addr_type = CAMERA_SENSOR_I2C_TYPE_BYTE; - write_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; - write_setting.delay = 0; - write_setting.reg_setting = ois_pm_length_array; - - rtc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), - &write_setting, 1, false); - if (rtc < 0) { - CAM_ERR(CAM_OIS, "OIS 0xF00A PM size failed %d", rc); - } + write_setting.size= sizeof(ois_pm_length_array)/sizeof(struct cam_sensor_i2c_reg_array); + write_setting.addr_type =CAMERA_SENSOR_I2C_TYPE_BYTE; + write_setting.data_type= CAMERA_SENSOR_I2C_TYPE_BYTE; + write_setting.delay=0; + write_setting.reg_setting= ois_pm_length_array; + + rtc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), + &write_setting, 1); + if (rtc < 0) { + CAM_ERR(CAM_OIS, "OIS 0xF00A PM size failed %d", rc); + } - /* load coeff download*/ + /* load coeff download*/ rc = request_firmware(&fw, fw_name_coeff, dev); if (rc) { CAM_ERR(CAM_OIS, "Failed to locate %s", fw_name_coeff); @@ -700,75 +644,64 @@ static int cam_lc898124_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) i2c_reg_setting.size = total_bytes; i2c_reg_setting.delay = 0; fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * - total_bytes) >> - PAGE_SHIFT; - page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), fw_size, 0, - GFP_KERNEL); + total_bytes) >> PAGE_SHIFT; + page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), + fw_size, 0, GFP_KERNEL); if (!page) { CAM_ERR(CAM_OIS, "Failed in allocating i2c_array"); release_firmware(fw); return -ENOMEM; } - i2c_reg_setting.reg_setting = - (struct cam_sensor_i2c_reg_array *)(page_address(page)); + i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) ( + page_address(page)); - if (total_bytes == ((DMA_ByteSize + DMB_ByteSize) * 6 / 4)) { + if( total_bytes == ((DMA_ByteSize + DMB_ByteSize) * 6 / 4)) + { ptr = (uint8_t *)fw->data; coeff_addr = ptr[0]; - for (i = 0; i < (DMA_ByteSize * 6 / 4);) { - CAM_DBG(CAM_OIS, "download DMA %s,coeff_addr=0x%04x", - fw_name_coeff, coeff_addr); - for (cnt = 0; cnt < LC124EP3_OIS_TRANS_SIZE && - i < (DMA_ByteSize * 6 / 4); - cnt++, i++) { - i2c_reg_setting.reg_setting[cnt].reg_addr = - coeff_addr; - i2c_reg_setting.reg_setting[cnt].reg_data = - ptr[i + 1]; + for (i = 0 ; i < (DMA_ByteSize *6 /4);) { + CAM_DBG(CAM_OIS, "download DMA %s,coeff_addr=0x%04x", fw_name_coeff,coeff_addr); + for (cnt = 0; cnt < LC124EP3_OIS_TRANS_SIZE && i < (DMA_ByteSize *6 /4); + cnt++, i++) { + i2c_reg_setting.reg_setting[cnt].reg_addr = coeff_addr; + i2c_reg_setting.reg_setting[cnt].reg_data = ptr[i+1]; i2c_reg_setting.reg_setting[cnt].delay = 0; i2c_reg_setting.reg_setting[cnt].data_mask = 0; } i2c_reg_setting.size = cnt; - coeff_addr = ptr[0 + i]; - rc = camera_io_dev_write_continuous( - &(o_ctrl->io_master_info), &i2c_reg_setting, 1, - false); + coeff_addr = ptr[0+i]; + rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), + &i2c_reg_setting, 1); if (rc < 0) { - CAM_ERR(CAM_OIS, "OIS FW download failed %d", - rc); + CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc); goto release_firmware; } } - for (i = (DMA_ByteSize * 6 / 4); i < total_bytes;) { - CAM_DBG(CAM_OIS, "download DMB %s,coeff_addr=0x%04x", - fw_name_coeff, coeff_addr); - for (cnt = 0; - cnt < LC124EP3_OIS_TRANS_SIZE && i < total_bytes; - cnt++, i++) { - i2c_reg_setting.reg_setting[cnt].reg_addr = - coeff_addr; - i2c_reg_setting.reg_setting[cnt].reg_data = - ptr[i + 1]; + for (i = (DMA_ByteSize *6 /4); i < total_bytes;) { + CAM_DBG(CAM_OIS, "download DMB %s,coeff_addr=0x%04x", fw_name_coeff,coeff_addr); + for (cnt = 0; cnt < LC124EP3_OIS_TRANS_SIZE && i < total_bytes; + cnt++, i++) { + i2c_reg_setting.reg_setting[cnt].reg_addr = coeff_addr; + i2c_reg_setting.reg_setting[cnt].reg_data = ptr[i+1]; i2c_reg_setting.reg_setting[cnt].delay = 0; i2c_reg_setting.reg_setting[cnt].data_mask = 0; } i2c_reg_setting.size = cnt; coeff_addr = ptr[i]; - rc = camera_io_dev_write_continuous( - &(o_ctrl->io_master_info), &i2c_reg_setting, 1, - false); + rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), + &i2c_reg_setting, 1); if (rc < 0) { - CAM_ERR(CAM_OIS, "OIS FW download failed %d", - rc); + CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc); goto release_firmware; } } - } else { + }else{ CAM_ERR(CAM_OIS, "OIS FW DM download failed %d", rc); goto release_firmware; } + rc = request_firmware(&fw_xm, fw_name_mem, dev); if (rc) { CAM_INFO(CAM_OIS, "no fw named %s, skip", fw_name_mem); @@ -779,96 +712,208 @@ static int cam_lc898124_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; i2c_reg_setting.size = total_bytes; i2c_reg_setting.delay = 0; - fw_size_xm = - PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * - total_bytes) >> - PAGE_SHIFT; + fw_size_xm = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * + total_bytes) >> PAGE_SHIFT; page_xm = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), - fw_size_xm, 0, GFP_KERNEL); + fw_size_xm, 0, GFP_KERNEL); if (!page_xm) { CAM_ERR(CAM_OIS, "Failed in allocating i2c_array"); release_firmware(fw); return -ENOMEM; } - i2c_reg_setting.reg_setting = - (struct cam_sensor_i2c_reg_array *)(page_address( - page_xm)); + i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) ( + page_address(page_xm)); ptr = (uint8_t *)fw_xm->data; mem_addr = ptr[0]; for (i = 0; i < total_bytes;) { - CAM_DBG(CAM_OIS, "download %s,mem_addr=0x%04x", - fw_name_mem, mem_addr); - for (cnt = 0; - cnt < LC124EP3_OIS_TRANS_SIZE && i < total_bytes; - cnt++, i++) { - i2c_reg_setting.reg_setting[cnt].reg_addr = - mem_addr; - i2c_reg_setting.reg_setting[cnt].reg_data = - ptr[i + 1]; + CAM_DBG(CAM_OIS, "download %s,mem_addr=0x%04x", fw_name_mem,mem_addr); + for (cnt = 0; cnt < LC124EP3_OIS_TRANS_SIZE && i < total_bytes; + cnt++, i++) { + i2c_reg_setting.reg_setting[cnt].reg_addr = mem_addr; + i2c_reg_setting.reg_setting[cnt].reg_data = ptr[i+1]; i2c_reg_setting.reg_setting[cnt].delay = 0; i2c_reg_setting.reg_setting[cnt].data_mask = 0; } i2c_reg_setting.size = cnt; - mem_addr = ptr[i]; - rc = camera_io_dev_write_continuous( - &(o_ctrl->io_master_info), &i2c_reg_setting, 1, - false); + mem_addr = ptr[i]; + rc = camera_io_dev_write_continuous(&(o_ctrl->io_master_info), + &i2c_reg_setting, 1); if (rc < 0) - CAM_ERR(CAM_OIS, - "OIS FW Memory download failed %d", rc); + CAM_ERR(CAM_OIS, "OIS FW Memory download failed %d", rc); } - cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), page_xm, - fw_size_xm); + cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), + page_xm, fw_size_xm); page_xm = NULL; fw_size_xm = 0; release_firmware(fw_xm); } release_firmware: - cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), page, fw_size); + cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), + page, fw_size); release_firmware(fw); return rc; } -static int cam_lc898128_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl, - uint32_t FwChecksum, - uint32_t FwChecksumSize, - uint8_t FwVersion) +static int cam_sem1215_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) { + uint8_t txdata[TX_BUFFER_SIZE]; + uint8_t rxdata[RX_BUFFER_SIZE]; + uint16_t txBuffSize; + uint16_t i,chkIdx,idx = 0; + uint16_t check_sum; + uint32_t updated_ver,new_fw_ver,current_fw_ver; + char *fw_name_prog = NULL; + char name_prog[32] = {0}; + uint8_t *chkBuff = vmalloc(APP_FW_SIZE); + uint8_t *fw_data = vmalloc(APP_FW_SIZE); int32_t rc = 0; - uint8_t ans = 0; +// uint8_t FwVersion = o_ctrl->opcode.fwversion; + + /* Get FW Ver from Binary File */ + snprintf(name_prog, 32, "%s.prog", o_ctrl->ois_name); + fw_name_prog = name_prog; + load_fw_buff(o_ctrl, fw_name_prog,fw_data, APP_FW_SIZE); + new_fw_ver = *(uint32_t *)&fw_data[APP_FW_SIZE - 12]; /* 0x7FF4 ~ 0x7FF7 */ + + I2C_Read_Data(o_ctrl,REG_APP_VER, 4, rxdata); + current_fw_ver = *(uint32_t *)rxdata; + CAM_DBG(CAM_OIS, "[current_fw_ver] = %d,[new_fw_ver] = %d",current_fw_ver,new_fw_ver); + + if((current_fw_ver == new_fw_ver) && (oisfwctrl == 0)){ + vfree(chkBuff); + vfree(fw_data); + return rc; + }else{ + /* If have FW app, Turnoff OIS and AF */ + if (current_fw_ver != 0) + { + I2C_Read_Data(o_ctrl,REG_OIS_STS, 1, rxdata); /* Read REG_OIS_STS */ + if (rxdata[0] != STATE_READY) + { + txdata[0] = OIS_OFF; /* Set OIS_OFF */ + I2C_Write_Data(o_ctrl,REG_OIS_CTRL, 1, txdata,0); /* Write 1 Byte to REG_OIS_CTRL */ + } + I2C_Read_Data(o_ctrl,REG_AF_STS, 1, rxdata); /* Read REG_AF_STS */ + if (rxdata[0] != STATE_READY) + { + txdata[0] = AF_OFF; /* Set AF_OFF */ + I2C_Write_Data(o_ctrl,REG_AF_CTRL, 1, txdata,0); /* Write 1 Byte to REG_AF_CTRL */ + } + } + + /* PAYLOAD_LEN = Size Bytes, FW_UPEN = TRUE */ + txBuffSize = TX_SIZE_256_BYTE; + switch (txBuffSize) + { + case TX_SIZE_32_BYTE: + txdata[0] = FWUP_CTRL_32_SET; + break; + case TX_SIZE_64_BYTE: + txdata[0] = FWUP_CTRL_64_SET; + break; + case TX_SIZE_128_BYTE: + txdata[0] = FWUP_CTRL_128_SET; + break; + case TX_SIZE_256_BYTE: + txdata[0] = FWUP_CTRL_256_SET; + break; + default: + /* Does not setting Tx data size, Alert Message */ + break; + } + /* Set FW Update Ctrl Reg */ + I2C_Write_Data(o_ctrl,REG_FWUP_CTRL, 1, txdata,0); + + msleep(60); + check_sum = 0; + + for (i = 0; i < (APP_FW_SIZE / txBuffSize); i++) + { + CAM_DBG(CAM_OIS, "Write [REG_DATA_BUF] i = %d",i); + memcpy(&chkBuff[txBuffSize * i], &fw_data[idx], txBuffSize); + for (chkIdx = 0; chkIdx < txBuffSize; chkIdx += 2) + { + check_sum += ((chkBuff[chkIdx + 1 + (txBuffSize * i)] << 8) | + chkBuff[chkIdx + (txBuffSize * i)]); + } + memcpy(txdata, &fw_data[idx], txBuffSize); + I2C_Write_Data(o_ctrl,REG_DATA_BUF, txBuffSize, txdata,0); + idx += txBuffSize; + msleep(20); + } + + vfree(chkBuff); + vfree(fw_data); + + *(uint16_t *)txdata = check_sum; + I2C_Write_Data(o_ctrl,REG_FWUP_CHKSUM, 2, txdata,0); + msleep(200); + + I2C_Read_Data(o_ctrl,REG_FWUP_CHKSUM, 2, rxdata); + CAM_DBG(CAM_OIS, "[REG_FWUP_CHKSUM] = 0x%x,0x%x",rxdata[0],rxdata[1]); + + I2C_Read_Data(o_ctrl,REG_FWUP_ERR, 1, rxdata); + CAM_DBG(CAM_OIS, "[REG_FWUP_ERR] = 0x%x",rxdata[0]); + + if (rxdata[0] != NO_ERROR) + { + CAM_ERR(CAM_OIS, "[Error] : FW Update != NO_ERROR"); + return rc; + } + + txdata[0] = RESET_REQ; + I2C_Write_Data(o_ctrl,REG_FWUP_CTRL, 1, txdata,0); + msleep(200); + + I2C_Read_Data(o_ctrl,REG_APP_VER, 4, rxdata); + updated_ver = *(uint32_t *)rxdata; + CAM_DBG(CAM_OIS, "[updated_ver] = %d,[new_fw_ver] = %d",updated_ver,new_fw_ver); + + if (updated_ver != new_fw_ver) + { + CAM_ERR(CAM_OIS, "[Error]: updated_ver != new_fw_ver"); + return rc; + } + CAM_DBG(CAM_OIS, "FW Update Success."); + } + return rc; +} +static int cam_lc898128_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl, uint32_t FwChecksum, uint32_t FwChecksumSize, uint8_t FwVersion) +{ + int32_t rc = 0; + uint8_t ans = 0; if (!o_ctrl) { CAM_ERR(CAM_OIS, "Invalid Args"); return -EINVAL; } - - if (!CheckFwValid(o_ctrl, FwVersion)) { + if ( !CheckFwValid(o_ctrl,FwVersion) ) { CAM_ERR(CAM_OIS, "firmware is invalid, updating"); - //-------------------------------------------------------------------------------- - // 0. Driver Offset - //-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +// 0. Driver Offset +//-------------------------------------------------------------------------------- ans = DrvOffAdj(o_ctrl); if (ans != 0) - return ans; + return ans; ans = CoreResetwithoutMC128(o_ctrl); if (ans != 0) return ans; - ans = Mat2ReWrite(o_ctrl); // MAT2 re-write process + ans = Mat2ReWrite(o_ctrl); // MAT2 re-write process if (ans != 0 && ans != 1) return ans; ans = PmemUpdate128(o_ctrl, 1); if (ans != 0) return ans; - //-------------------------------------------------------------------------------- - // Erase - //-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +// Erase +//-------------------------------------------------------------------------------- if (0 != UnlockCodeSet(o_ctrl)) return 0x33; @@ -891,19 +936,19 @@ static int cam_lc898128_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl, #else ans = ProgramFlash128_Standard(o_ctrl); #endif - if (ans != 0) { - if (UnlockCodeClear(o_ctrl) != 0) - return (0x43); // unlock code clear ng + if ( ans != 0) { + if ( UnlockCodeClear(o_ctrl) != 0 ) + return (0x43); // unlock code clear ng else - return (ans); + return( ans ); } - if (UnlockCodeClear(o_ctrl) != 0) + if ( UnlockCodeClear(o_ctrl) != 0 ) return (0x43); - //-------------------------------------------------------------------------------- - // 5. Verify - //-------------------------------------------------------------------------------- - ans = MatVerify(o_ctrl, FwChecksum, FwChecksumSize); +//-------------------------------------------------------------------------------- +// 5. Verify +//-------------------------------------------------------------------------------- + ans = MatVerify(o_ctrl,FwChecksum,FwChecksumSize); if (ans != 0) { CAM_ERR(CAM_OIS, "MatVerify fail %d", ans); } @@ -914,134 +959,27 @@ static int cam_lc898128_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl, return rc; } -static int cam_sem1215_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) +static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) { - uint8_t txdata[TX_BUFFER_SIZE]; - uint8_t rxdata[RX_BUFFER_SIZE]; - uint16_t txBuffSize; - uint16_t i, chkIdx, idx = 0; - uint16_t check_sum; - uint32_t updated_ver, new_fw_ver, current_fw_ver; - char *fw_name_prog = NULL; - char name_prog[32] = { 0 }; - uint8_t *chkBuff = vmalloc(APP_FW_SIZE); - uint8_t *fw_data = vmalloc(APP_FW_SIZE); int32_t rc = 0; - // uint8_t FwVersion = o_ctrl->opcode.fwversion; - - /* Get FW Ver from Binary File */ - snprintf(name_prog, 32, "%s.prog", o_ctrl->ois_name); - fw_name_prog = name_prog; - load_fw_buff(o_ctrl, fw_name_prog, fw_data, APP_FW_SIZE); - new_fw_ver = - *(uint32_t *)&fw_data[APP_FW_SIZE - 12]; /* 0x7FF4 ~ 0x7FF7 */ - - I2C_Read_Data(o_ctrl, REG_APP_VER, 4, rxdata); - current_fw_ver = *(uint32_t *)rxdata; - CAM_DBG(CAM_OIS, "[current_fw_ver] = %d,[new_fw_ver] = %d", - current_fw_ver, new_fw_ver); - - if ((current_fw_ver == new_fw_ver) && (oisfwctrl == 0)) { - vfree(chkBuff); - vfree(fw_data); - return rc; + uint32_t FwChecksum =0; + uint32_t FwChecksumSize = 0; + uint8_t FwVersion = 0; + + if (121 == o_ctrl->opcode.is_addr_indata) { + CAM_DBG(CAM_OIS, "apply Sem1215 ois_fw settings"); + rc = cam_sem1215_ois_fw_download(o_ctrl); + } else if (128 == o_ctrl->opcode.is_addr_indata) { + FwChecksum = o_ctrl->opcode.fwchecksum; + FwChecksumSize = o_ctrl->opcode.fwchecksumsize; + FwVersion = o_ctrl->opcode.fwversion; + CAM_DBG(CAM_OIS, "apply lc898128 ois_fw settings"); + rc = cam_lc898128_ois_fw_download(o_ctrl, FwChecksum, FwChecksumSize, FwVersion); } else { - /* If have FW app, Turnoff OIS and AF */ - if (current_fw_ver != 0) { - I2C_Read_Data(o_ctrl, REG_OIS_STS, 1, - rxdata); /* Read REG_OIS_STS */ - if (rxdata[0] != STATE_READY) { - txdata[0] = OIS_OFF; /* Set OIS_OFF */ - I2C_Write_Data( - o_ctrl, REG_OIS_CTRL, 1, txdata, - 0); /* Write 1 Byte to REG_OIS_CTRL */ - } - I2C_Read_Data(o_ctrl, REG_AF_STS, 1, - rxdata); /* Read REG_AF_STS */ - if (rxdata[0] != STATE_READY) { - txdata[0] = AF_OFF; /* Set AF_OFF */ - I2C_Write_Data( - o_ctrl, REG_AF_CTRL, 1, txdata, - 0); /* Write 1 Byte to REG_AF_CTRL */ - } - } - - /* PAYLOAD_LEN = Size Bytes, FW_UPEN = TRUE */ - txBuffSize = TX_SIZE_256_BYTE; - switch (txBuffSize) { - case TX_SIZE_32_BYTE: - txdata[0] = FWUP_CTRL_32_SET; - break; - case TX_SIZE_64_BYTE: - txdata[0] = FWUP_CTRL_64_SET; - break; - case TX_SIZE_128_BYTE: - txdata[0] = FWUP_CTRL_128_SET; - break; - case TX_SIZE_256_BYTE: - txdata[0] = FWUP_CTRL_256_SET; - break; - default: - /* Does not setting Tx data size, Alert Message */ - break; - } - /* Set FW Update Ctrl Reg */ - I2C_Write_Data(o_ctrl, REG_FWUP_CTRL, 1, txdata, 0); - - msleep(60); - check_sum = 0; - - for (i = 0; i < (APP_FW_SIZE / txBuffSize); i++) { - CAM_DBG(CAM_OIS, "Write [REG_DATA_BUF] i = %d", i); - memcpy(&chkBuff[txBuffSize * i], &fw_data[idx], - txBuffSize); - for (chkIdx = 0; chkIdx < txBuffSize; chkIdx += 2) { - check_sum += - ((chkBuff[chkIdx + 1 + (txBuffSize * i)] - << 8) | - chkBuff[chkIdx + (txBuffSize * i)]); - } - memcpy(txdata, &fw_data[idx], txBuffSize); - I2C_Write_Data(o_ctrl, REG_DATA_BUF, txBuffSize, txdata, - 0); - idx += txBuffSize; - msleep(20); - } - - vfree(chkBuff); - vfree(fw_data); - - *(uint16_t *)txdata = check_sum; - I2C_Write_Data(o_ctrl, REG_FWUP_CHKSUM, 2, txdata, 0); - msleep(200); - - I2C_Read_Data(o_ctrl, REG_FWUP_CHKSUM, 2, rxdata); - CAM_DBG(CAM_OIS, "[REG_FWUP_CHKSUM] = 0x%x,0x%x", rxdata[0], - rxdata[1]); - - I2C_Read_Data(o_ctrl, REG_FWUP_ERR, 1, rxdata); - CAM_DBG(CAM_OIS, "[REG_FWUP_ERR] = 0x%x", rxdata[0]); - - if (rxdata[0] != NO_ERROR) { - CAM_ERR(CAM_OIS, "[Error] : FW Update != NO_ERROR"); - return rc; - } - - txdata[0] = RESET_REQ; - I2C_Write_Data(o_ctrl, REG_FWUP_CTRL, 1, txdata, 0); - msleep(200); - - I2C_Read_Data(o_ctrl, REG_APP_VER, 4, rxdata); - updated_ver = *(uint32_t *)rxdata; - CAM_DBG(CAM_OIS, "[updated_ver] = %d,[new_fw_ver] = %d", - updated_ver, new_fw_ver); - - if (updated_ver != new_fw_ver) { - CAM_ERR(CAM_OIS, "[Error]: updated_ver != new_fw_ver"); - return rc; - } - CAM_DBG(CAM_OIS, "FW Update Success."); + CAM_DBG(CAM_OIS, "apply default ois_fw settings"); + rc = cam_default_ois_fw_download(o_ctrl); } + return rc; } @@ -1065,62 +1003,53 @@ static int cam_ois_get_data(struct cam_ois_ctrl_t *o_ctrl, t_now = get_cycles(); boottime64 = (uint64_t)((ts64.tv_sec * 1000000000) + ts64.tv_nsec); -#ifdef CONFIG_BOARD_PSYCHE if (o_ctrl->opcode.ois_get_data != 0) { - uint32_t ois_addr = - (o_ctrl->opcode.ois_get_data & 0xFFFF0000) >> 16; + uint32_t ois_addr = (o_ctrl->opcode.ois_get_data & 0xFFFF0000) >> 16; uint32_t ois_addr_type = o_ctrl->opcode.ois_get_data & 0xFFFF; - rc = camera_io_dev_read_seq(&(o_ctrl->io_master_info), ois_addr, - o_ctrl->ois_data.data, - ois_addr_type, - CAMERA_SENSOR_I2C_TYPE_BYTE, - num_data); + rc = camera_io_dev_read_seq(&(o_ctrl->io_master_info), + ois_addr, o_ctrl->ois_data.data, + ois_addr_type, CAMERA_SENSOR_I2C_TYPE_BYTE, + num_data); } else { - rc = camera_io_dev_read_seq( - &(o_ctrl->io_master_info), OIS_DATA_ADDR, - o_ctrl->ois_data.data, CAMERA_SENSOR_I2C_TYPE_BYTE, - CAMERA_SENSOR_I2C_TYPE_BYTE, num_data); + rc = camera_io_dev_read_seq(&(o_ctrl->io_master_info), + OIS_DATA_ADDR, o_ctrl->ois_data.data, + CAMERA_SENSOR_I2C_TYPE_BYTE, CAMERA_SENSOR_I2C_TYPE_BYTE, + num_data); } -#else - rc = camera_io_dev_read_seq(&(o_ctrl->io_master_info), OIS_DATA_ADDR, - o_ctrl->ois_data.data, - CAMERA_SENSOR_I2C_TYPE_BYTE, - CAMERA_SENSOR_I2C_TYPE_BYTE, num_data); -#endif - o_ctrl->ois_data.data_timestamp = - (uint64_t)(t_now * 10000 / 192); //< QTimer Freq = 19.2 MHz + o_ctrl->ois_data.data_timestamp = (uint64_t)(t_now*10000/192);//< QTimer Freq = 19.2 MHz if (rc < 0) { CAM_ERR(CAM_OIS, "read failed"); } else { - CAM_DBG(CAM_OIS, - "ois_data count=%d,data_timestamp=%llu,boottime64=%llu,t_now=%llu", - o_ctrl->ois_data.data[0], - o_ctrl->ois_data.data_timestamp, boottime64, t_now); + CAM_DBG(CAM_OIS, "ois_data count=%d,data_timestamp=%llu,boottime64=%llu,t_now=%llu", + o_ctrl->ois_data.data[0], o_ctrl->ois_data.data_timestamp, boottime64, t_now); } - io_cfg = (struct cam_buf_io_cfg *)((uint8_t *)&csl_packet->payload + - csl_packet->io_configs_offset); + io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *) + &csl_packet->payload + + csl_packet->io_configs_offset); - CAM_DBG(CAM_OIS, - "number of IO configs: %d:", csl_packet->num_io_configs); + CAM_DBG(CAM_OIS, "number of IO configs: %d:", + csl_packet->num_io_configs); for (i = 0; i < csl_packet->num_io_configs; i++) { CAM_DBG(CAM_OIS, "Direction: %d:", io_cfg->direction); if (io_cfg->direction == CAM_BUF_OUTPUT) { rc = cam_mem_get_cpu_buf(io_cfg->mem_handle[0], - &buf_addr, &buf_size); + &buf_addr, &buf_size); if (rc) { - CAM_ERR(CAM_OIS, "Fail in get buffer: %d", rc); + CAM_ERR(CAM_OIS, "Fail in get buffer: %d", + rc); return rc; } CAM_DBG(CAM_OIS, "buf_addr : %pK, buf_size : %zu\n", - (void *)buf_addr, buf_size); + (void *)buf_addr, buf_size); read_buffer = (uint8_t *)buf_addr; if (!read_buffer) { - CAM_ERR(CAM_OIS, "invalid buffer to copy data"); + CAM_ERR(CAM_OIS, + "invalid buffer to copy data"); rc = -EINVAL; return rc; } @@ -1128,14 +1057,14 @@ static int cam_ois_get_data(struct cam_ois_ctrl_t *o_ctrl, if (buf_size != sizeof(struct ois_data_eis_t)) { CAM_ERR(CAM_OIS, - "failed to copy, Invalid size"); + "failed to copy, Invalid size"); rc = -EINVAL; return rc; } - CAM_DBG(CAM_OIS, "copy the data, len:%d", num_data); - memcpy(read_buffer, &o_ctrl->ois_data, - sizeof(struct ois_data_eis_t)); + CAM_DBG(CAM_OIS, "copy the data, len:%d", + num_data); + memcpy(read_buffer, &o_ctrl->ois_data, sizeof(struct ois_data_eis_t)); } else { CAM_ERR(CAM_OIS, "Invalid direction"); @@ -1146,90 +1075,87 @@ static int cam_ois_get_data(struct cam_ois_ctrl_t *o_ctrl, return rc; } -#ifdef CONFIG_CAMERA_CAS static int cam_tele_ois_get_data(struct cam_ois_ctrl_t *o_ctrl, - struct cam_packet *csl_packet) + struct cam_packet *csl_packet) { - struct cam_buf_io_cfg *io_cfg; - uint32_t i = 0; - int rc = 0; - uintptr_t buf_addr; - size_t buf_size; - uint8_t *read_buffer; - uint32_t num_data = sizeof(o_ctrl->ois_tele_data.data); - struct timespec64 ts64; - cycles_t t_now; - uint64_t boottime64; - - memset(&o_ctrl->ois_tele_data, 0, sizeof(struct ois_tele_data_eis_t)); - get_monotonic_boottime64(&ts64); - t_now = get_cycles(); - boottime64 = (uint64_t)((ts64.tv_sec * 1000000000) + ts64.tv_nsec); - - rc = camera_io_dev_read_seq(&(o_ctrl->io_master_info), - OIS_TELE_DATA_ADDR, - o_ctrl->ois_tele_data.data, - CAMERA_SENSOR_I2C_TYPE_WORD, - CAMERA_SENSOR_I2C_TYPE_BYTE, num_data); - o_ctrl->ois_tele_data.data_timestamp = - (uint64_t)(t_now * 10000 / 192); //< QTimer Freq = 19.2 MHz - - if (rc < 0) { - CAM_ERR(CAM_OIS, "read failed"); - } else { - CAM_DBG(CAM_OIS, - "ois_data count=%d,data_timestamp=%llu,boottime64=%llu,t_now=%llu", - o_ctrl->ois_tele_data.data[0], - o_ctrl->ois_tele_data.data_timestamp, boottime64, - t_now); - } - - io_cfg = (struct cam_buf_io_cfg *)((uint8_t *)&csl_packet->payload + - csl_packet->io_configs_offset); - - CAM_DBG(CAM_OIS, - "number of IO configs: %d:", csl_packet->num_io_configs); - - for (i = 0; i < csl_packet->num_io_configs; i++) { - CAM_DBG(CAM_OIS, "Direction: %d:", io_cfg->direction); - if (io_cfg->direction == CAM_BUF_OUTPUT) { - rc = cam_mem_get_cpu_buf(io_cfg->mem_handle[0], - &buf_addr, &buf_size); - if (rc) { - CAM_ERR(CAM_OIS, "Fail in get buffer: %d", rc); - return rc; - } - - CAM_DBG(CAM_OIS, "buf_addr : %pK, buf_size : %zu\n", - (void *)buf_addr, buf_size); - - read_buffer = (uint8_t *)buf_addr; - if (!read_buffer) { - CAM_ERR(CAM_OIS, "invalid buffer to copy data"); - rc = -EINVAL; - return rc; - } - read_buffer += io_cfg->offsets[0]; - - if (buf_size != sizeof(struct ois_tele_data_eis_t)) { - CAM_ERR(CAM_OIS, - "failed to copy, Invalid size"); - rc = -EINVAL; - return rc; - } - - CAM_DBG(CAM_OIS, "copy the data, len:%d", num_data); - memcpy(read_buffer, &o_ctrl->ois_tele_data, - sizeof(struct ois_tele_data_eis_t)); - } else { - CAM_ERR(CAM_OIS, "Invalid direction"); - rc = -EINVAL; - } - } - - return rc; + struct cam_buf_io_cfg *io_cfg; + uint32_t i = 0; + int rc = 0; + uintptr_t buf_addr; + size_t buf_size; + uint8_t *read_buffer; + uint32_t num_data = sizeof(o_ctrl->ois_tele_data.data); + struct timespec64 ts64; + cycles_t t_now; + uint64_t boottime64; + + memset(&o_ctrl->ois_tele_data, 0, sizeof(struct ois_tele_data_eis_t)); + get_monotonic_boottime64(&ts64); + t_now = get_cycles(); + boottime64 = (uint64_t)((ts64.tv_sec * 1000000000) + ts64.tv_nsec); + + rc = camera_io_dev_read_seq(&(o_ctrl->io_master_info), + OIS_TELE_DATA_ADDR, o_ctrl->ois_tele_data.data, + CAMERA_SENSOR_I2C_TYPE_WORD, CAMERA_SENSOR_I2C_TYPE_BYTE, + num_data); + o_ctrl->ois_tele_data.data_timestamp = (uint64_t)(t_now*10000/192);//< QTimer Freq = 19.2 MHz + + if (rc < 0) { + CAM_ERR(CAM_OIS, "read failed"); + } else { + CAM_DBG(CAM_OIS, "ois_data count=%d,data_timestamp=%llu,boottime64=%llu,t_now=%llu", + o_ctrl->ois_tele_data.data[0], o_ctrl->ois_tele_data.data_timestamp, boottime64, t_now); + } + + io_cfg = (struct cam_buf_io_cfg *) ((uint8_t *) + &csl_packet->payload + + csl_packet->io_configs_offset); + + CAM_DBG(CAM_OIS, "number of IO configs: %d:", + csl_packet->num_io_configs); + + for (i = 0; i < csl_packet->num_io_configs; i++) { + CAM_DBG(CAM_OIS, "Direction: %d:", io_cfg->direction); + if (io_cfg->direction == CAM_BUF_OUTPUT) { + rc = cam_mem_get_cpu_buf(io_cfg->mem_handle[0], + &buf_addr, &buf_size); + if (rc) { + CAM_ERR(CAM_OIS, "Fail in get buffer: %d", + rc); + return rc; + } + + CAM_DBG(CAM_OIS, "buf_addr : %pK, buf_size : %zu\n", + (void *)buf_addr, buf_size); + + read_buffer = (uint8_t *)buf_addr; + if (!read_buffer) { + CAM_ERR(CAM_OIS, + "invalid buffer to copy data"); + rc = -EINVAL; + return rc; + } + read_buffer += io_cfg->offsets[0]; + + if (buf_size != sizeof(struct ois_tele_data_eis_t)) { + CAM_ERR(CAM_OIS, + "failed to copy, Invalid size"); + rc = -EINVAL; + return rc; + } + + CAM_DBG(CAM_OIS, "copy the data, len:%d", + num_data); + memcpy(read_buffer, &o_ctrl->ois_tele_data, sizeof(struct ois_tele_data_eis_t)); + } else { + CAM_ERR(CAM_OIS, "Invalid direction"); + rc = -EINVAL; + } + } + + return rc; } -#endif // CONFIG_CAMERA_CAS + #endif /** @@ -1259,9 +1185,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) struct cam_ois_soc_private *soc_private = (struct cam_ois_soc_private *)o_ctrl->soc_info.soc_private; struct cam_sensor_power_ctrl_t *power_info = &soc_private->power_info; - uint32_t FwChecksum = o_ctrl->opcode.fwchecksum; - uint32_t FwChecksumSize = o_ctrl->opcode.fwchecksumsize; - uint8_t FwVersion = o_ctrl->opcode.fwversion; ioctl_ctrl = (struct cam_control *)arg; if (copy_from_user(&dev_config, @@ -1283,7 +1206,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) CAM_ERR(CAM_OIS, "Inval cam_packet strut size: %zu, len_of_buff: %zu", sizeof(struct cam_packet), pkt_len); - cam_mem_put_cpu_buf(dev_config.packet_handle); return -EINVAL; } @@ -1294,7 +1216,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (cam_packet_util_validate_packet(csl_packet, remain_len)) { CAM_ERR(CAM_OIS, "Invalid packet params"); - cam_mem_put_cpu_buf(dev_config.packet_handle); return -EINVAL; } @@ -1316,14 +1237,11 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_OIS, "Failed to get cpu buf : 0x%x", cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } cmd_buf = (uint32_t *)generic_ptr; if (!cmd_buf) { CAM_ERR(CAM_OIS, "invalid cmd buf"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf(dev_config.packet_handle); return -EINVAL; } @@ -1332,8 +1250,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) sizeof(struct common_header)))) { CAM_ERR(CAM_OIS, "Invalid length for sensor cmd"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf(dev_config.packet_handle); return -EINVAL; } remain_len = len_of_buff - cmd_desc[i].offset; @@ -1347,10 +1263,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_OIS, "Failed in parsing slave info"); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - dev_config.packet_handle); return rc; } break; @@ -1365,10 +1277,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc) { CAM_ERR(CAM_OIS, "Failed: parse power settings"); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - dev_config.packet_handle); return rc; } break; @@ -1387,10 +1295,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_OIS, "init parsing failed: %d", rc); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - dev_config.packet_handle); return rc; } } else if ((o_ctrl->is_ois_calib != 0) && @@ -1408,10 +1312,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_OIS, "Calib parsing failed: %d", rc); - cam_mem_put_cpu_buf( - cmd_desc[i].mem_handle); - cam_mem_put_cpu_buf( - dev_config.packet_handle); return rc; } } else if ((o_ctrl->is_ois_pre_init != 0) && @@ -1434,14 +1334,12 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) } break; } - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } if (o_ctrl->cam_ois_state != CAM_OIS_CONFIG) { rc = cam_ois_power_up(o_ctrl); if (rc) { CAM_ERR(CAM_OIS, " OIS Power up failed"); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } o_ctrl->cam_ois_state = CAM_OIS_CONFIG; @@ -1458,32 +1356,18 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) } if (o_ctrl->ois_fw_flag) { - CAM_DBG(CAM_OIS, "is_addr_indata = %d", - o_ctrl->opcode.is_addr_indata); - if (121 == o_ctrl->opcode.is_addr_indata) { - CAM_DBG(CAM_OIS, - "apply sem1215 ois_fw settings begin."); + CAM_DBG(CAM_OIS, "is_addr_indata = %d", o_ctrl->opcode.is_addr_indata); + if(o_ctrl->opcode.is_addr_indata == 121){ + CAM_DBG(CAM_OIS, "apply sem1215 ois_fw settings begin."); rc = cam_sem1215_ois_fw_download(o_ctrl); - CAM_DBG(CAM_OIS, - "apply sem1215 ois_fw settings done."); - } else if (128 == o_ctrl->opcode.is_addr_indata) { - FwChecksum = o_ctrl->opcode.fwchecksum; - FwChecksumSize = o_ctrl->opcode.fwchecksumsize; - FwVersion = o_ctrl->opcode.fwversion; - CAM_DBG(CAM_OIS, - "apply lc898128 ois_fw settings"); - rc = cam_lc898128_ois_fw_download( - o_ctrl, FwChecksum, FwChecksumSize, - FwVersion); - } else if (1 == o_ctrl->opcode.is_addr_indata) { - CAM_DBG(CAM_OIS, - "apply lc898124 ois_fw settings"); + CAM_DBG(CAM_OIS, "apply sem1215 ois_fw settings done."); + }else if(o_ctrl->opcode.is_addr_indata) { + CAM_DBG(CAM_OIS, "apply lc898124 ois_fw settings"); rc = cam_lc898124_ois_fw_download(o_ctrl); } else { CAM_DBG(CAM_OIS, "apply ois_fw settings"); rc = cam_ois_fw_download(o_ctrl); } - if (rc) { CAM_ERR(CAM_OIS, "Failed OIS FW Download"); goto pwr_dwn; @@ -1516,7 +1400,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) } } - rc = delete_request(&o_ctrl->i2c_pre_init_data); if (rc < 0) { CAM_WARN(CAM_OIS, @@ -1543,7 +1426,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) CAM_WARN(CAM_OIS, "Not in right state to control OIS: %d", o_ctrl->cam_ois_state); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } offset = (uint32_t *)&csl_packet->payload; @@ -1557,14 +1439,12 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) cmd_desc, 1, NULL); if (rc < 0) { CAM_ERR(CAM_OIS, "OIS pkt parsing failed: %d", rc); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } rc = cam_ois_apply_settings(o_ctrl, i2c_reg_settings); if (rc < 0) { CAM_ERR(CAM_OIS, "Cannot apply mode settings"); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1572,7 +1452,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_OIS, "Fail deleting Mode data: rc: %d", rc); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } break; @@ -1585,7 +1464,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) CAM_WARN(CAM_OIS, "Not in right state to read OIS: %d", o_ctrl->cam_ois_state); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } CAM_DBG(CAM_OIS, "number of I/O configs: %d:", @@ -1593,7 +1471,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (csl_packet->num_io_configs == 0) { CAM_ERR(CAM_OIS, "No I/O configs to process"); rc = -EINVAL; - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1606,7 +1483,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (io_cfg == NULL) { CAM_ERR(CAM_OIS, "I/O config is invalid(NULL)"); rc = -EINVAL; - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1620,7 +1496,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) cmd_desc, 1, io_cfg); if (rc < 0) { CAM_ERR(CAM_OIS, "OIS read pkt parsing failed: %d", rc); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1630,7 +1505,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_OIS, "cannot read data rc: %d", rc); delete_request(&i2c_read_settings); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } @@ -1638,7 +1512,6 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) if (rc < 0) { CAM_ERR(CAM_OIS, "Failed in deleting the read settings"); - cam_mem_put_cpu_buf(dev_config.packet_handle); return rc; } break; @@ -1659,9 +1532,7 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) return rc; } break; - -#ifdef CONFIG_CAMERA_CAS - case CAM_OIS_PACKET_OPCODE_TELEOIS_GETDATA: + case CAM_OIS_PACKET_OPCODE_TELEOIS_GETDATA: if (o_ctrl->cam_ois_state < CAM_OIS_CONFIG) { rc = -EINVAL; CAM_ERR(CAM_OIS, @@ -1676,21 +1547,16 @@ static int cam_ois_pkt_parse(struct cam_ois_ctrl_t *o_ctrl, void *arg) return rc; } break; -#endif // CONFIG_CAMERA_CAS #endif default: CAM_ERR(CAM_OIS, "Invalid Opcode: %d", (csl_packet->header.op_code & 0xFFFFFF)); - cam_mem_put_cpu_buf(dev_config.packet_handle); return -EINVAL; } - if (!rc) { - cam_mem_put_cpu_buf(dev_config.packet_handle); + if (!rc) return rc; - } pwr_dwn: - cam_mem_put_cpu_buf(dev_config.packet_handle); cam_ois_power_down(o_ctrl); return rc; } diff --git a/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h b/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h index b94943d9e90f..e42b7048637c 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h @@ -27,9 +27,7 @@ #define ENABLE_OIS_EIS #define OIS_DATA_ADDR 0x8A -#ifdef CONFIG_CAMERA_CAS #define OIS_TELE_DATA_ADDR 0x1100 -#endif enum cam_ois_state { CAM_OIS_INIT, @@ -90,8 +88,12 @@ struct cam_ois_intf_params { #ifdef ENABLE_OIS_EIS struct ois_data_eis_t { - uint64_t data_timestamp; - uint8_t data[52]; + uint64_t data_timestamp; + uint8_t data[52]; +}; +struct ois_tele_data_eis_t { + uint64_t data_timestamp; + uint8_t data[48]; }; #endif @@ -142,10 +144,8 @@ struct cam_ois_ctrl_t { uint8_t is_ois_pre_init; #ifdef ENABLE_OIS_EIS struct ois_data_eis_t ois_data; -#ifdef CONFIG_CAMERA_CAS struct ois_tele_data_eis_t ois_tele_data; #endif -#endif }; #endif /*_CAM_OIS_DEV_H_ */ diff --git a/techpack/camera/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c b/techpack/camera/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c index 34055db2863e..43b5032b95d0 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c @@ -665,6 +665,9 @@ static int cam_res_mgr_probe(struct platform_device *pdev) { int rc = 0; + if (cam_res) + return 0; + cam_res = kzalloc(sizeof(*cam_res), GFP_KERNEL); if (!cam_res) return -ENOMEM; diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c b/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c index af194a68bc93..0206060b86c1 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_core.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -13,6 +12,7 @@ #include "cam_common_util.h" #include "cam_packet_util.h" + static void cam_sensor_update_req_mgr( struct cam_sensor_ctrl_t *s_ctrl, struct cam_packet *csl_packet) @@ -300,7 +300,6 @@ static int32_t cam_sensor_i2c_pkt_parse(struct cam_sensor_ctrl_t *s_ctrl, } end: - cam_mem_put_cpu_buf(config.packet_handle); return rc; } @@ -385,8 +384,7 @@ static int32_t cam_sensor_update_i2c_info(struct cam_cmd_i2c_info *i2c_info, static int32_t cam_sensor_i2c_modes_util( struct cam_sensor_ctrl_t *s_ctrl, - struct i2c_settings_list *i2c_list, - bool force_low_priority) + struct i2c_settings_list *i2c_list) { int32_t rc = 0; uint32_t i, size; @@ -401,16 +399,14 @@ static int32_t cam_sensor_i2c_modes_util( if (i2c_list->op_code == CAM_SENSOR_I2C_WRITE_RANDOM) { rc = camera_io_dev_write(io_master_info, - &(i2c_list->i2c_settings), - force_low_priority); + &(i2c_list->i2c_settings)); if ((rc == -ETIMEDOUT) && (io_master_info->master_type == CCI_MASTER)) { CAM_WARN(CAM_SENSOR, "CCI HW is restting: Reapplying request settings"); usleep_range(2000, 2010); rc = camera_io_dev_write(io_master_info, - &(i2c_list->i2c_settings), - force_low_priority); + &(i2c_list->i2c_settings)); } if (rc < 0) { CAM_ERR(CAM_SENSOR, @@ -422,7 +418,7 @@ static int32_t cam_sensor_i2c_modes_util( rc = camera_io_dev_write_continuous( io_master_info, &(i2c_list->i2c_settings), - 0, force_low_priority); + 0); if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to seq write I2C settings: %d", @@ -433,7 +429,7 @@ static int32_t cam_sensor_i2c_modes_util( rc = camera_io_dev_write_continuous( io_master_info, &(i2c_list->i2c_settings), - 1, force_low_priority); + 1); if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to burst write I2C settings: %d", @@ -646,7 +642,6 @@ int32_t cam_handle_mem_ptr(uint64_t handle, struct cam_sensor_ctrl_t *s_ctrl) if (cmd_desc[i].offset >= len) { CAM_ERR(CAM_SENSOR, "offset past length of buffer"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); rc = -EINVAL; goto end; } @@ -654,7 +649,6 @@ int32_t cam_handle_mem_ptr(uint64_t handle, struct cam_sensor_ctrl_t *s_ctrl) if (cmd_desc[i].length > remain_len) { CAM_ERR(CAM_SENSOR, "Not enough buffer provided for cmd"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); rc = -EINVAL; goto end; } @@ -667,14 +661,11 @@ int32_t cam_handle_mem_ptr(uint64_t handle, struct cam_sensor_ctrl_t *s_ctrl) if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to parse the command Buffer Header"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); goto end; } - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } end: - cam_mem_put_cpu_buf(handle); return rc; } @@ -975,8 +966,10 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl, } break; case CAM_RELEASE_DEV: { + /*STOP DEV when sensor is START DEV and RELEASE called*/ - if (s_ctrl->sensor_state == CAM_SENSOR_START) { + if (s_ctrl->sensor_state == CAM_SENSOR_START) + { CAM_WARN(CAM_SENSOR, "Unbalance Release called with out STOP: %d", s_ctrl->sensor_state); @@ -1206,7 +1199,6 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl, struct cam_sensor_i2c_reg_setting user_reg_setting; struct cam_sensor_i2c_reg_array *i2c_reg_setting = NULL; int i = 0; - bool force_low_priority = false; rc = copy_from_user(&user_reg_setting, (void __user *)(cmd->handle), sizeof(user_reg_setting)); if (rc < 0) { @@ -1237,10 +1229,7 @@ int32_t cam_sensor_driver_cmd(struct cam_sensor_ctrl_t *s_ctrl, i2c_reg_setting[i].reg_addr, i2c_reg_setting[i].reg_data); } - force_low_priority = - s_ctrl->force_low_priority_for_init_setting; - rc = camera_io_dev_write(&s_ctrl->io_master_info, - &user_reg_setting, force_low_priority); + rc = camera_io_dev_write(&s_ctrl->io_master_info, &user_reg_setting); if (rc < 0) CAM_ERR(CAM_SENSOR, "Write setting failed, rc = %d\n", rc); @@ -1479,7 +1468,6 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl, uint64_t top = 0, del_req_id = 0; struct i2c_settings_array *i2c_set = NULL; struct i2c_settings_list *i2c_list; - bool force_low_priority = false; if (req_id == 0) { switch (opcode) { @@ -1489,8 +1477,6 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl, } case CAM_SENSOR_PACKET_OPCODE_SENSOR_INITIAL_CONFIG: { i2c_set = &s_ctrl->i2c_data.init_settings; - force_low_priority = - s_ctrl->force_low_priority_for_init_setting; break; } case CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG: { @@ -1522,7 +1508,7 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl, list_for_each_entry(i2c_list, &(i2c_set->list_head), list) { rc = cam_sensor_i2c_modes_util(s_ctrl, - i2c_list, force_low_priority); + i2c_list); if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to apply settings: %d", @@ -1539,7 +1525,7 @@ int cam_sensor_apply_settings(struct cam_sensor_ctrl_t *s_ctrl, list_for_each_entry(i2c_list, &(i2c_set->list_head), list) { rc = cam_sensor_i2c_modes_util(s_ctrl, - i2c_list, force_low_priority); + i2c_list); if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to apply settings: %d", diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h b/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h index d38a4f1a186c..d9e8eaaeb129 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h @@ -85,8 +85,6 @@ struct intf_params { * @bob_pwm_switch: Boolean flag to switch into PWM mode for BoB regulator * @last_flush_req: Last request to flush * @pipeline_delay: Sensor pipeline delay - * @force_low_priority_for_init_setting: Using low priority queue to send - * init setting */ struct cam_sensor_ctrl_t { char device_name[CAM_CTX_DEV_NAME_MAX_LENGTH]; @@ -114,7 +112,6 @@ struct cam_sensor_ctrl_t { uint32_t last_flush_req; uint16_t pipeline_delay; int32_t open_cnt; - bool force_low_priority_for_init_setting; }; #endif /* _CAM_SENSOR_DEV_H_ */ diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c b/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c index 3f45685cb786..2c25ee0aa6f0 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.c @@ -98,7 +98,6 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl) { int32_t rc = 0; int i = 0; - uint32_t concurrency_sensors = 0; struct cam_sensor_board_info *sensordata = NULL; struct device_node *of_node = s_ctrl->of_node; struct device_node *of_parent = NULL; @@ -186,19 +185,6 @@ static int32_t cam_sensor_driver_get_dt_data(struct cam_sensor_ctrl_t *s_ctrl) s_ctrl->cci_num = CCI_DEVICE_0; CAM_DBG(CAM_SENSOR, "cci-index %d", s_ctrl->cci_num); - - rc = of_property_read_u32(of_node, - "concurrency-sensors-on-same-cci", - &concurrency_sensors); - CAM_DBG(CAM_SENSOR, - "sensor %d concurrency_sensors %d, rc %d", - soc_info->index, concurrency_sensors, rc); - if (rc < 0 || concurrency_sensors < 2) { - s_ctrl->force_low_priority_for_init_setting = false; - rc = 0; - } else - s_ctrl->force_low_priority_for_init_setting = true; - } if (of_property_read_u32(of_node, "sensor-position-pitch", diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c index 313b1ff782e9..b85fbadbd23a 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include "cam_sensor_cmn_header.h" @@ -97,8 +96,7 @@ int32_t cam_camera_cci_i2c_read_seq(struct cam_sensor_cci_client *cci_client, static int32_t cam_cci_i2c_write_table_cmd( struct camera_io_master *client, struct cam_sensor_i2c_reg_setting *write_setting, - enum cam_cci_cmd_type cmd, - bool force_low_priority) + enum cam_cci_cmd_type cmd) { int32_t rc = -EINVAL; struct cam_cci_ctrl cci_ctrl; @@ -119,7 +117,6 @@ static int32_t cam_cci_i2c_write_table_cmd( cci_ctrl.cfg.cci_i2c_write_cfg.data_type = write_setting->data_type; cci_ctrl.cfg.cci_i2c_write_cfg.addr_type = write_setting->addr_type; cci_ctrl.cfg.cci_i2c_write_cfg.size = write_setting->size; - cci_ctrl.force_low_priority = force_low_priority; rc = v4l2_subdev_call(client->cci_client->cci_subdev, core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl); if (rc < 0) { @@ -139,27 +136,25 @@ static int32_t cam_cci_i2c_write_table_cmd( int32_t cam_cci_i2c_write_table( struct camera_io_master *client, - struct cam_sensor_i2c_reg_setting *write_setting, - bool force_low_priority) + struct cam_sensor_i2c_reg_setting *write_setting) { return cam_cci_i2c_write_table_cmd(client, write_setting, - MSM_CCI_I2C_WRITE, force_low_priority); + MSM_CCI_I2C_WRITE); } int32_t cam_cci_i2c_write_continuous_table( struct camera_io_master *client, struct cam_sensor_i2c_reg_setting *write_setting, - uint8_t cam_sensor_i2c_write_flag, - bool force_low_priority) + uint8_t cam_sensor_i2c_write_flag) { int32_t rc = 0; if (cam_sensor_i2c_write_flag == 1) rc = cam_cci_i2c_write_table_cmd(client, write_setting, - MSM_CCI_I2C_WRITE_BURST, force_low_priority); + MSM_CCI_I2C_WRITE_BURST); else if (cam_sensor_i2c_write_flag == 0) rc = cam_cci_i2c_write_table_cmd(client, write_setting, - MSM_CCI_I2C_WRITE_SEQ, force_low_priority); + MSM_CCI_I2C_WRITE_SEQ); return rc; } diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h index be65d4ab113e..4f29aca59718 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_i2c.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_SENSOR_I2C_H_ @@ -58,8 +57,7 @@ int32_t cam_camera_cci_i2c_read_seq(struct cam_sensor_cci_client *client, */ int32_t cam_cci_i2c_write_table( struct camera_io_master *client, - struct cam_sensor_i2c_reg_setting *write_setting, - bool force_low_priority); + struct cam_sensor_i2c_reg_setting *write_setting); /** * @client: CCI client structure @@ -71,8 +69,7 @@ int32_t cam_cci_i2c_write_table( int32_t cam_cci_i2c_write_continuous_table( struct camera_io_master *client, struct cam_sensor_i2c_reg_setting *write_setting, - uint8_t cam_sensor_i2c_write_flag, - bool force_low_priority); + uint8_t cam_sensor_i2c_write_flag); /** * @cci_client: CCI client structure diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.c b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.c index 47242942206f..6abf5c3a4f1b 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include "cam_sensor_io.h" @@ -117,8 +116,7 @@ int32_t camera_io_dev_read_seq(struct camera_io_master *io_master_info, } int32_t camera_io_dev_write(struct camera_io_master *io_master_info, - struct cam_sensor_i2c_reg_setting *write_setting, - bool force_low_priority) + struct cam_sensor_i2c_reg_setting *write_setting) { if (!write_setting || !io_master_info) { CAM_ERR(CAM_SENSOR, @@ -134,7 +132,7 @@ int32_t camera_io_dev_write(struct camera_io_master *io_master_info, if (io_master_info->master_type == CCI_MASTER) { return cam_cci_i2c_write_table(io_master_info, - write_setting, force_low_priority); + write_setting); } else if (io_master_info->master_type == I2C_MASTER) { return cam_qup_i2c_write_table(io_master_info, write_setting); @@ -150,8 +148,7 @@ int32_t camera_io_dev_write(struct camera_io_master *io_master_info, int32_t camera_io_dev_write_continuous(struct camera_io_master *io_master_info, struct cam_sensor_i2c_reg_setting *write_setting, - uint8_t cam_sensor_i2c_write_flag, - bool force_low_priority) + uint8_t cam_sensor_i2c_write_flag) { if (!write_setting || !io_master_info) { CAM_ERR(CAM_SENSOR, @@ -167,8 +164,7 @@ int32_t camera_io_dev_write_continuous(struct camera_io_master *io_master_info, if (io_master_info->master_type == CCI_MASTER) { return cam_cci_i2c_write_continuous_table(io_master_info, - write_setting, cam_sensor_i2c_write_flag, - force_low_priority); + write_setting, cam_sensor_i2c_write_flag); } else if (io_master_info->master_type == I2C_MASTER) { return cam_qup_i2c_write_continuous_table(io_master_info, write_setting, cam_sensor_i2c_write_flag); diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.h b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.h index 88b8fd562577..b1482f08aafa 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_SENSOR_IO_H_ @@ -79,8 +78,7 @@ int32_t camera_io_release(struct camera_io_master *io_master_info); * This API abstracts write functionality based on master type */ int32_t camera_io_dev_write(struct camera_io_master *io_master_info, - struct cam_sensor_i2c_reg_setting *write_setting, - bool force_low_priority); + struct cam_sensor_i2c_reg_setting *write_setting); /** * @io_master_info: I2C/SPI master information @@ -92,8 +90,7 @@ int32_t camera_io_dev_write(struct camera_io_master *io_master_info, */ int32_t camera_io_dev_write_continuous(struct camera_io_master *io_master_info, struct cam_sensor_i2c_reg_setting *write_setting, - uint8_t cam_sensor_i2c_write_flag, - bool force_low_priority); + uint8_t cam_sensor_i2c_write_flag); int32_t camera_io_dev_erase(struct camera_io_master *io_master_info, uint32_t addr, uint32_t size); diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h b/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h index 646b70282d27..aa64874bca04 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_cmn_header.h @@ -175,12 +175,8 @@ enum cam_ois_packet_opcodes { CAM_OIS_PACKET_OPCODE_INIT, CAM_OIS_PACKET_OPCODE_OIS_CONTROL, CAM_OIS_PACKET_OPCODE_READ, -#ifdef CONFIG_CAMERA_CAS CAM_OIS_PACKET_OPCODE_OIS_GETDATA, CAM_OIS_PACKET_OPCODE_TELEOIS_GETDATA -#else - CAM_OIS_PACKET_OPCODE_OIS_GETDATA -#endif }; enum msm_bus_perf_setting { diff --git a/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c b/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c index b9efd9ebd304..b38d0cc7494d 100644 --- a/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c +++ b/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -264,7 +263,6 @@ static int32_t cam_sensor_get_io_buffer( CAM_ERR(CAM_SENSOR, "invalid size:io_cfg->offsets[0]: %d, buf_size: %d", io_cfg->offsets[0], buf_size); - cam_mem_put_cpu_buf(io_cfg->mem_handle[0]); return -EINVAL; } i2c_settings->read_buff = @@ -276,7 +274,6 @@ static int32_t cam_sensor_get_io_buffer( io_cfg->direction); rc = -EINVAL; } - cam_mem_put_cpu_buf(io_cfg->mem_handle[0]); return rc; } @@ -460,7 +457,6 @@ int cam_sensor_i2c_command_parser( remain_len -= cmd_desc[i].offset; if (remain_len < cmd_desc[i].length) { CAM_ERR(CAM_SENSOR, "buffer provided too small"); - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); return -EINVAL; } @@ -712,12 +708,9 @@ int cam_sensor_i2c_command_parser( } } i2c_reg_settings->is_settings_valid = 1; - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); } - return rc; end: - cam_mem_put_cpu_buf(cmd_desc[i].mem_handle); return rc; } @@ -731,7 +724,7 @@ int cam_sensor_util_i2c_apply_setting( switch (i2c_list->op_code) { case CAM_SENSOR_I2C_WRITE_RANDOM: { rc = camera_io_dev_write(io_master_info, - &(i2c_list->i2c_settings), false); + &(i2c_list->i2c_settings)); if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to random write I2C settings: %d", @@ -742,8 +735,7 @@ int cam_sensor_util_i2c_apply_setting( } case CAM_SENSOR_I2C_WRITE_SEQ: { rc = camera_io_dev_write_continuous( - io_master_info, &(i2c_list->i2c_settings), - 0, false); + io_master_info, &(i2c_list->i2c_settings), 0); if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to seq write I2C settings: %d", @@ -754,8 +746,7 @@ int cam_sensor_util_i2c_apply_setting( } case CAM_SENSOR_I2C_WRITE_BURST: { rc = camera_io_dev_write_continuous( - io_master_info, &(i2c_list->i2c_settings), - 1, false); + io_master_info, &(i2c_list->i2c_settings), 1); if (rc < 0) { CAM_ERR(CAM_SENSOR, "Failed to burst write I2C settings: %d", @@ -1178,29 +1169,22 @@ int32_t cam_sensor_update_power_settings(void *cmd_buf, int32_t i = 0, pwr_up = 0, pwr_down = 0; struct cam_sensor_power_setting *pwr_settings; void *ptr = cmd_buf, *scr; + struct cam_cmd_power *pwr_cmd = (struct cam_cmd_power *)cmd_buf; struct common_header *cmm_hdr = (struct common_header *)cmd_buf; - struct cam_cmd_power *pwr_cmd = - kzalloc(sizeof(struct cam_cmd_power), GFP_KERNEL); - if (!pwr_cmd) - return -ENOMEM; - memcpy(pwr_cmd, cmd_buf, sizeof(struct cam_cmd_power)); if (!pwr_cmd || !cmd_length || cmd_buf_len < (size_t)cmd_length || cam_sensor_validate(cmd_buf, cmd_buf_len)) { CAM_ERR(CAM_SENSOR, "Invalid Args: pwr_cmd %pK, cmd_length: %d", pwr_cmd, cmd_length); - rc = -EINVAL; - goto free_power_command; + return -EINVAL; } power_info->power_setting_size = 0; power_info->power_setting = kzalloc(sizeof(struct cam_sensor_power_setting) * MAX_POWER_CONFIG, GFP_KERNEL); - if (!power_info->power_setting) { - rc = -ENOMEM; - goto free_power_command; - } + if (!power_info->power_setting) + return -ENOMEM; power_info->power_down_setting_size = 0; power_info->power_down_setting = @@ -1210,8 +1194,7 @@ int32_t cam_sensor_update_power_settings(void *cmd_buf, kfree(power_info->power_setting); power_info->power_setting = NULL; power_info->power_setting_size = 0; - rc = -ENOMEM; - goto free_power_command; + return -ENOMEM; } while (tot_size < cmd_length) { @@ -1395,7 +1378,7 @@ int32_t cam_sensor_update_power_settings(void *cmd_buf, } } - goto free_power_command; + return rc; free_power_settings: kfree(power_info->power_down_setting); kfree(power_info->power_setting); @@ -1403,9 +1386,6 @@ int32_t cam_sensor_update_power_settings(void *cmd_buf, power_info->power_setting = NULL; power_info->power_down_setting_size = 0; power_info->power_setting_size = 0; -free_power_command: - kfree(pwr_cmd); - pwr_cmd = NULL; return rc; } diff --git a/techpack/camera/drivers/cam_smmu/cam_smmu_api.c b/techpack/camera/drivers/cam_smmu/cam_smmu_api.c index 28fb2a76eab2..4f6b9337da9a 100644 --- a/techpack/camera/drivers/cam_smmu/cam_smmu_api.c +++ b/techpack/camera/drivers/cam_smmu/cam_smmu_api.c @@ -200,6 +200,8 @@ struct cam_dma_buff_info { struct cam_sec_buff_info { struct dma_buf *buf; + struct dma_buf_attachment *attach; + struct sg_table *table; enum dma_data_direction dir; int ref_count; dma_addr_t paddr; @@ -2640,6 +2642,8 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, mapping_info->dir = dma_dir; mapping_info->ref_count = 1; mapping_info->buf = dmabuf; + mapping_info->attach = attach; + mapping_info->table = table; CAM_DBG(CAM_SMMU, "idx=%d, ion_fd=%d, dev=%pK, paddr=%pK, len=%u", idx, ion_fd, @@ -2649,14 +2653,13 @@ static int cam_smmu_map_stage2_buffer_and_add_to_list(int idx, int ion_fd, /* add to the list */ list_add(&mapping_info->list, &iommu_cb_set.cb_info[idx].smmu_buf_list); - return 0; - err_unmap_sg: dma_buf_unmap_attachment(attach, table, dma_dir); err_detach: dma_buf_detach(dmabuf, attach); err_put: - dma_buf_put(dmabuf); + if (rc) + dma_buf_put(dmabuf); err_out: return rc; } @@ -2744,7 +2747,28 @@ static int cam_smmu_secure_unmap_buf_and_remove_from_list( CAM_ERR(CAM_SMMU, "Error: List doesn't exist"); return -EINVAL; } + if ((!mapping_info->buf) || (!mapping_info->table) || + (!mapping_info->attach)) { + CAM_ERR(CAM_SMMU, + "Error: Invalid params dev = %pK, table = %pK", + (void *)iommu_cb_set.cb_info[idx].dev, + (void *)mapping_info->table); + CAM_ERR(CAM_SMMU, "Error: buf = %pK, attach = %pK\n", + (void *)mapping_info->buf, + (void *)mapping_info->attach); + return -EINVAL; + } + + /* skip cache operations */ + mapping_info->attach->dma_map_attrs |= DMA_ATTR_SKIP_CPU_SYNC; + + /* iommu buffer clean up */ + dma_buf_unmap_attachment(mapping_info->attach, mapping_info->table, + mapping_info->dir); + dma_buf_detach(mapping_info->buf, mapping_info->attach); dma_buf_put(mapping_info->buf); + mapping_info->buf = NULL; + list_del_init(&mapping_info->list); CAM_DBG(CAM_SMMU, "unmap fd: %d, idx : %d", mapping_info->ion_fd, idx); @@ -3431,6 +3455,7 @@ static int cam_smmu_setup_cb(struct cam_context_bank_info *cb, if (cb->discard_iova_start) iommu_dma_reserve_iova(dev, cb->discard_iova_start, cb->discard_iova_len); + cb->state = CAM_SMMU_ATTACH; } else { CAM_ERR(CAM_SMMU, "Context bank does not have IO region"); diff --git a/techpack/camera/drivers/cam_sync/cam_sync_private.h b/techpack/camera/drivers/cam_sync/cam_sync_private.h index 81256d08556a..ee5c09e6adf1 100644 --- a/techpack/camera/drivers/cam_sync/cam_sync_private.h +++ b/techpack/camera/drivers/cam_sync/cam_sync_private.h @@ -25,7 +25,7 @@ #define CAM_SYNC_OBJ_NAME_LEN 64 #define CAM_SYNC_MAX_OBJS 1792 // 1536=1024+768 -#define CAM_SYNC_MAX_V4L2_EVENTS 300 +#define CAM_SYNC_MAX_V4L2_EVENTS 200 #define CAM_SYNC_DEBUG_FILENAME "cam_debug" #define CAM_SYNC_DEBUG_BASEDIR "cam" #define CAM_SYNC_DEBUG_BUF_SIZE 32 diff --git a/techpack/camera/drivers/cam_utils/cam_packet_util.c b/techpack/camera/drivers/cam_utils/cam_packet_util.c index 53b3d3d4e205..1569d5dbafa6 100644 --- a/techpack/camera/drivers/cam_utils/cam_packet_util.c +++ b/techpack/camera/drivers/cam_utils/cam_packet_util.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -33,12 +32,6 @@ int cam_packet_util_get_cmd_mem_addr(int handle, uint32_t **buf_addr, int cam_packet_util_validate_cmd_desc(struct cam_cmd_buf_desc *cmd_desc) { - - if (!cmd_desc) { - CAM_ERR(CAM_UTIL, "Invalid cmd desc"); - return -EINVAL; - } - if ((cmd_desc->length > cmd_desc->size) || (cmd_desc->mem_handle <= 0)) { CAM_ERR(CAM_UTIL, "invalid cmd arg %d %d %d %d", @@ -79,7 +72,6 @@ int cam_packet_util_validate_packet(struct cam_packet *packet, pkt_wo_payload = offsetof(struct cam_packet, payload); if ((!packet->header.size) || - ((size_t)packet->header.size <= pkt_wo_payload) || ((pkt_wo_payload + (size_t)packet->cmd_buf_offset + sum_cmd_desc) > (size_t)packet->header.size) || ((pkt_wo_payload + (size_t)packet->io_configs_offset + @@ -109,12 +101,6 @@ int cam_packet_util_get_kmd_buffer(struct cam_packet *packet, return -EINVAL; } - if (!packet->num_cmd_buf) { - CAM_ERR(CAM_UTIL, "Invalid num_cmd_buf = %d", - packet->num_cmd_buf); - return -EINVAL; - } - if ((packet->kmd_cmd_buf_index < 0) || (packet->kmd_cmd_buf_index >= packet->num_cmd_buf)) { CAM_ERR(CAM_UTIL, "Invalid kmd buf index: %d", @@ -141,16 +127,14 @@ int cam_packet_util_get_kmd_buffer(struct cam_packet *packet, ((size_t)cmd_desc->size > (len - (size_t)cmd_desc->offset))) { CAM_ERR(CAM_UTIL, "invalid memory len:%zd and cmd desc size:%d", len, cmd_desc->size); - rc = -EINVAL; - goto rel_kmd_buf; + return -EINVAL; } remain_len -= (size_t)cmd_desc->offset; if ((size_t)packet->kmd_cmd_buf_offset >= remain_len) { CAM_ERR(CAM_UTIL, "Invalid kmd cmd buf offset: %zu", (size_t)packet->kmd_cmd_buf_offset); - rc = -EINVAL; - goto rel_kmd_buf; + return -EINVAL; } cpu_addr += (cmd_desc->offset / 4) + (packet->kmd_cmd_buf_offset / 4); @@ -167,8 +151,6 @@ int cam_packet_util_get_kmd_buffer(struct cam_packet *packet, kmd_buf->size = cmd_desc->size - cmd_desc->length; kmd_buf->used_bytes = 0; -rel_kmd_buf: - cam_mem_put_cpu_buf(cmd_desc->mem_handle); return rc; } @@ -222,8 +204,6 @@ void cam_packet_dump_patch_info(struct cam_packet *packet, if (!(*dst_cpu_addr)) CAM_ERR(CAM_ICP, "Null at dst addr %p", dst_cpu_addr); - - cam_mem_put_cpu_buf(patch_desc[i].dst_buf_hdl); } } @@ -285,7 +265,6 @@ int cam_packet_util_process_patches(struct cam_packet *packet, (size_t)patch_desc[i].dst_offset)) { CAM_ERR(CAM_UTIL, "Invalid dst buf patch offset"); - cam_mem_put_cpu_buf((int32_t)patch_desc[i].dst_buf_hdl); return -EINVAL; } @@ -299,7 +278,6 @@ int cam_packet_util_process_patches(struct cam_packet *packet, "patch is done for dst %pK with src %pK value %llx", dst_cpu_addr, src_buf_iova_addr, *((uint64_t *)dst_cpu_addr)); - cam_mem_put_cpu_buf((int32_t)patch_desc[i].dst_buf_hdl); } return rc; @@ -340,16 +318,14 @@ int cam_packet_util_process_generic_cmd_buffer( ((size_t)cmd_buf->offset > (buf_size - sizeof(uint32_t)))) { CAM_ERR(CAM_UTIL, "Invalid offset for cmd buf: %zu", (size_t)cmd_buf->offset); - rc = -EINVAL; - goto end; + return -EINVAL; } remain_len -= (size_t)cmd_buf->offset; if (remain_len < (size_t)cmd_buf->length) { CAM_ERR(CAM_UTIL, "Invalid length for cmd buf: %zu", (size_t)cmd_buf->length); - rc = -EINVAL; - goto end; + return -EINVAL; } blob_ptr = (uint32_t *)(((uint8_t *)cpu_addr) + @@ -399,6 +375,5 @@ int cam_packet_util_process_generic_cmd_buffer( } end: - cam_mem_put_cpu_buf(cmd_buf->mem_handle); return rc; } diff --git a/techpack/camera/drivers/cam_utils/cam_packet_util.h b/techpack/camera/drivers/cam_utils/cam_packet_util.h index 94e8fd5529ee..62866a962cc6 100644 --- a/techpack/camera/drivers/cam_utils/cam_packet_util.h +++ b/techpack/camera/drivers/cam_utils/cam_packet_util.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_PACKET_UTIL_H_ diff --git a/techpack/camera/drivers/cam_utils/cam_soc_util.c b/techpack/camera/drivers/cam_utils/cam_soc_util.c index 3c72fd6b2d81..cc2d310dbbf0 100644 --- a/techpack/camera/drivers/cam_utils/cam_soc_util.c +++ b/techpack/camera/drivers/cam_utils/cam_soc_util.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. - * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -369,6 +368,18 @@ long cam_soc_util_get_clk_round_rate(struct cam_hw_soc_info *soc_info, return clk_round_rate(soc_info->clk[clk_index], clk_rate); } +int cam_soc_util_set_clk_flags(struct cam_hw_soc_info *soc_info, + uint32_t clk_index, unsigned long flags) +{ + if (!soc_info || (clk_index >= soc_info->num_clk)) { + CAM_ERR(CAM_UTIL, "Invalid input params %pK, %d", + soc_info, clk_index); + return -EINVAL; + } + + return clk_set_flags(soc_info->clk[clk_index], flags); +} + /** * cam_soc_util_set_clk_rate() * @@ -2065,7 +2076,8 @@ static int cam_soc_util_dump_dmi_reg_range_user_buf( CAM_ERR(CAM_UTIL, "Invalid input args soc_info: %pK, dump_args: %pK", soc_info, dump_args); - return -EINVAL; + rc = -EINVAL; + goto end; } if (dmi_read->num_pre_writes > CAM_REG_DUMP_DMI_CONFIG_MAX || @@ -2073,14 +2085,15 @@ static int cam_soc_util_dump_dmi_reg_range_user_buf( CAM_ERR(CAM_UTIL, "Invalid number of requested writes, pre: %d post: %d", dmi_read->num_pre_writes, dmi_read->num_post_writes); - return -EINVAL; + rc = -EINVAL; + goto end; } rc = cam_mem_get_cpu_buf(dump_args->buf_handle, &cpu_addr, &buf_len); if (rc) { CAM_ERR(CAM_UTIL, "Invalid handle %u rc %d", dump_args->buf_handle, rc); - return -EINVAL; + goto end; } if (buf_len <= dump_args->offset) { @@ -2166,8 +2179,6 @@ static int cam_soc_util_dump_dmi_reg_range_user_buf( sizeof(struct cam_hw_soc_dump_header); end: - if (dump_args) - cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } @@ -2192,13 +2203,13 @@ static int cam_soc_util_dump_cont_reg_range_user_buf( "Invalid input args soc_info: %pK, dump_out_buffer: %pK reg_read: %pK", soc_info, dump_args, reg_read); rc = -EINVAL; - return rc; + goto end; } rc = cam_mem_get_cpu_buf(dump_args->buf_handle, &cpu_addr, &buf_len); if (rc) { CAM_ERR(CAM_UTIL, "Invalid handle %u rc %d", dump_args->buf_handle, rc); - return rc; + goto end; } if (buf_len <= dump_args->offset) { CAM_WARN(CAM_UTIL, "Dump offset overshoot %zu %zu", @@ -2248,8 +2259,6 @@ static int cam_soc_util_dump_cont_reg_range_user_buf( dump_args->offset += hdr->size + sizeof(struct cam_hw_soc_dump_header); end: - if (dump_args) - cam_mem_put_cpu_buf(dump_args->buf_handle); return rc; } @@ -2341,8 +2350,6 @@ int cam_soc_util_reg_dump_to_cmd_buf(void *ctx, if (rc || !cpu_addr || (buf_size == 0)) { CAM_ERR(CAM_UTIL, "Failed in Get cpu addr, rc=%d, cpu_addr=%pK", rc, (void *)cpu_addr); - if (rc) - return rc; goto end; } @@ -2544,6 +2551,5 @@ int cam_soc_util_reg_dump_to_cmd_buf(void *ctx, } end: - cam_mem_put_cpu_buf(cmd_desc->mem_handle); return rc; } diff --git a/techpack/camera/drivers/cam_utils/cam_soc_util.h b/techpack/camera/drivers/cam_utils/cam_soc_util.h index 3272390c118d..e0500c3cbdba 100644 --- a/techpack/camera/drivers/cam_utils/cam_soc_util.h +++ b/techpack/camera/drivers/cam_utils/cam_soc_util.h @@ -406,6 +406,20 @@ int cam_soc_util_disable_platform_resource(struct cam_hw_soc_info *soc_info, long cam_soc_util_get_clk_round_rate(struct cam_hw_soc_info *soc_info, uint32_t clk_index, unsigned long clk_rate); +/** + * cam_soc_util_set_clk_flags() + * + * @brief: Camera SOC util to set the flags for a specified clock + * + * @soc_info: Device soc information + * @clk_index: Clock index in soc_info for which flags are to be set + * @flags: Flags to set + * + * @return: Success or Failure + */ +int cam_soc_util_set_clk_flags(struct cam_hw_soc_info *soc_info, + uint32_t clk_index, unsigned long flags); + /** * cam_soc_util_set_src_clk_rate() * diff --git a/techpack/camera/include/uapi/media/cam_sensor.h b/techpack/camera/include/uapi/media/cam_sensor.h index faf30c6b87ba..6e7d1c14ccc6 100644 --- a/techpack/camera/include/uapi/media/cam_sensor.h +++ b/techpack/camera/include/uapi/media/cam_sensor.h @@ -118,13 +118,11 @@ struct cam_ois_opcode { uint32_t coeff; uint32_t pheripheral; uint32_t memory; -#ifdef CONFIG_BOARD_PSYCHE uint32_t ois_get_data; -#endif - uint8_t fw_addr_type; - uint8_t is_addr_increase; - uint8_t is_addr_indata; - uint8_t fwversion; + uint8_t fw_addr_type; + uint8_t is_addr_increase; + uint8_t is_addr_indata; + uint8_t fwversion; uint32_t fwchecksumsize; uint32_t fwchecksum; } __attribute__((packed));