Skip to content

Commit

Permalink
Use old camera driver from branch android12-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
liyafe1997 committed Aug 9, 2024
1 parent 765eb44 commit 341766f
Show file tree
Hide file tree
Showing 61 changed files with 925 additions and 2,402 deletions.
13 changes: 12 additions & 1 deletion techpack/camera/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
6 changes: 1 addition & 5 deletions techpack/camera/config/konacamera.conf
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion techpack/camera/config/konacameraconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
*/

#define CONFIG_SPECTRA_CAMERA_KONA 1

#define CONFIG_SPECTRA_CAMERA 1

1 change: 0 additions & 1 deletion techpack/camera/config/litocamera.conf
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion techpack/camera/config/litocameraconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

3 changes: 0 additions & 3 deletions techpack/camera/drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 4 additions & 16 deletions techpack/camera/drivers/cam_cdm/cam_cdm_virtual_core.c
Original file line number Diff line number Diff line change
@@ -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 <linux/delay.h>
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 2 additions & 10 deletions techpack/camera/drivers/cam_core/cam_context_utils.c
Original file line number Diff line number Diff line change
@@ -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 <linux/debugfs.h>
Expand Down Expand Up @@ -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;

}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;

}
Expand Down Expand Up @@ -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--) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <linux/slab.h>
Expand Down Expand Up @@ -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;
}

Expand Down
50 changes: 6 additions & 44 deletions techpack/camera/drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c
Original file line number Diff line number Diff line change
@@ -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 <linux/module.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 */
Expand All @@ -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 */
Expand All @@ -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;
}
Expand Down
Loading

0 comments on commit 341766f

Please sign in to comment.