Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
msm: camera: Fast-forward to LA.UM.8.1.r1-16000-sm8150.0
Browse files Browse the repository at this point in the history
We've avoided merging upstream CAF updates to camera drivers, as a
result of the fallout that doing so caused me on the OnePlus 6T.
However, it appears that playing it safe like this is no longer
necessary on this device. Thus, reapply all of the patches we've
omitted up to LA.UM.8.1.r1-16000-sm8150.0.

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
0ctobot committed Sep 26, 2020
1 parent 6da5b74 commit 72d8803
Show file tree
Hide file tree
Showing 30 changed files with 325 additions and 219 deletions.
19 changes: 14 additions & 5 deletions drivers/media/platform/msm/ais/cam_core/cam_context_utils.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -459,6 +459,17 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
"[%s][%d] : Moving req[%llu] from free_list to pending_list",
ctx->dev_name, ctx->ctx_id, req->request_id);

for (j = 0; j < req->num_in_map_entries; j++) {
rc = cam_sync_check_valid(
req->in_map_entries[j].sync_id);
if (rc) {
CAM_ERR(CAM_CTXT,
"invalid in map sync object %d",
req->in_map_entries[j].sync_id);
goto put_ref;
}
}

for (j = 0; j < req->num_in_map_entries; j++) {
cam_context_getref(ctx);
rc = cam_sync_register_callback(
Expand All @@ -480,7 +491,8 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
ctx->dev_name, ctx->ctx_id,
req->request_id);

goto put_ctx_ref;
cam_context_putref(ctx);
goto put_ref;
}
CAM_DBG(CAM_CTXT, "register in fence cb: %d ret = %d",
req->in_map_entries[j].sync_id, rc);
Expand All @@ -492,9 +504,6 @@ int32_t cam_context_prepare_dev_to_hw(struct cam_context *ctx,
ctx->dev_name, ctx->ctx_id);

return rc;
put_ctx_ref:
for (j; j >= 0; j--)
cam_context_putref(ctx);
put_ref:
for (--i; i >= 0; i--) {
if (cam_sync_put_obj_ref(req->out_map_entries[i].sync_id))
Expand Down
25 changes: 22 additions & 3 deletions drivers/media/platform/msm/ais/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -1664,18 +1664,36 @@ static int cam_ife_hw_mgr_acquire_res_root(

static int cam_ife_mgr_check_and_update_fe(
struct cam_ife_hw_mgr_ctx *ife_ctx,
struct cam_isp_acquire_hw_info *acquire_hw_info)
struct cam_isp_acquire_hw_info *acquire_hw_info,
uint32_t acquire_info_size)
{
int i;
struct cam_isp_in_port_info *in_port = NULL;
uint32_t in_port_length = 0;
uint32_t total_in_port_length = 0;

if (acquire_hw_info->input_info_offset >=
acquire_hw_info->input_info_size) {
CAM_ERR(CAM_ISP,
"Invalid size offset 0x%x is greater then size 0x%x",
acquire_hw_info->input_info_offset,
acquire_hw_info->input_info_size);
return -EINVAL;
}

in_port = (struct cam_isp_in_port_info *)
((uint8_t *)&acquire_hw_info->data +
acquire_hw_info->input_info_offset);
for (i = 0; i < acquire_hw_info->num_inputs; i++) {

if (((uint8_t *)in_port +
sizeof(struct cam_isp_in_port_info)) >
((uint8_t *)acquire_hw_info +
acquire_info_size)) {
CAM_ERR(CAM_ISP, "Invalid size");
return -EINVAL;
}

if ((in_port->num_out_res > CAM_IFE_HW_OUT_RES_MAX) ||
(in_port->num_out_res <= 0)) {
CAM_ERR(CAM_ISP, "Invalid num output res %u",
Expand Down Expand Up @@ -1935,7 +1953,8 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
acquire_hw_info =
(struct cam_isp_acquire_hw_info *)acquire_args->acquire_info;

rc = cam_ife_mgr_check_and_update_fe(ife_ctx, acquire_hw_info);
rc = cam_ife_mgr_check_and_update_fe(ife_ctx, acquire_hw_info,
acquire_args->acquire_info_size);
if (rc) {
CAM_ERR(CAM_ISP, "buffer size is not enough");
goto free_cdm;
Expand Down
36 changes: 35 additions & 1 deletion drivers/media/platform/msm/ais/cam_sync/cam_sync.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -288,6 +288,7 @@ int cam_sync_merge(int32_t *sync_obj, uint32_t num_objs, int32_t *merged_obj)
int rc;
long idx = 0;
bool bit;
int i = 0;

if (!sync_obj || !merged_obj) {
CAM_ERR(CAM_SYNC, "Invalid pointer(s)");
Expand All @@ -305,6 +306,15 @@ int cam_sync_merge(int32_t *sync_obj, uint32_t num_objs, int32_t *merged_obj)
return -EINVAL;
}

for (i = 0; i < num_objs; i++) {
rc = cam_sync_check_valid(sync_obj[i]);
if (rc) {
CAM_ERR(CAM_SYNC, "Sync_obj[%d] %d valid check fail",
i, sync_obj[i]);
return rc;
}
}

do {
idx = find_first_zero_bit(sync_dev->bitmap, CAM_SYNC_MAX_OBJS);
if (idx >= CAM_SYNC_MAX_OBJS)
Expand Down Expand Up @@ -376,6 +386,30 @@ int cam_sync_destroy(int32_t sync_obj)
return cam_sync_deinit_object(sync_dev->sync_table, sync_obj);
}

int cam_sync_check_valid(int32_t sync_obj)
{
struct sync_table_row *row = NULL;

if (sync_obj >= CAM_SYNC_MAX_OBJS || sync_obj <= 0)
return -EINVAL;

row = sync_dev->sync_table + sync_obj;

if (!test_bit(sync_obj, sync_dev->bitmap)) {
CAM_ERR(CAM_SYNC, "Error: Released sync obj received %d",
sync_obj);
return -EINVAL;
}

if (row->state == CAM_SYNC_STATE_INVALID) {
CAM_ERR(CAM_SYNC,
"Error: accessing an uninitialized sync obj = %d",
sync_obj);
return -EINVAL;
}
return 0;
}

int cam_sync_wait(int32_t sync_obj, uint64_t timeout_ms)
{
unsigned long timeleft;
Expand Down
11 changes: 10 additions & 1 deletion drivers/media/platform/msm/ais/cam_sync/cam_sync_api.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018,2020 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -147,5 +147,14 @@ int cam_sync_destroy(int32_t sync_obj);
*/
int cam_sync_wait(int32_t sync_obj, uint64_t timeout_ms);

/**
* @brief: Check if sync object is valid
*
* @param sync_obj: int referencing the sync object to be checked
*
* @return 0 upon success, -EINVAL if sync object is in bad state or arguments
* are invalid
*/
int cam_sync_check_valid(int32_t sync_obj);

#endif /* __CAM_SYNC_API_H__ */
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -216,10 +216,10 @@ static int cam_cpastop_handle_errlogger(struct cam_cpas *cpas_core,
soc_info->reg_map[camnoc_index].mem_base +
camnoc_info->err_logger->errlog3_high);

CAM_ERR_RATE_LIMIT(CAM_CPAS,
CAM_DBG(CAM_CPAS,
"Possible memory configuration issue, fault at SMMU raised as CAMNOC SLAVE_IRQ");

CAM_ERR_RATE_LIMIT(CAM_CPAS,
CAM_DBG(CAM_CPAS,
"mainctrl[0x%x 0x%x] errvld[0x%x 0x%x] stall_en=%d, fault_en=%d, err_vld=%d",
camnoc_info->err_logger->mainctrl,
slave_err->mainctrl.value,
Expand All @@ -233,7 +233,7 @@ static int cam_cpastop_handle_errlogger(struct cam_cpas *cpas_core,
if (err_code_index > CAMNOC_SLAVE_MAX_ERR_CODE)
err_code_index = CAMNOC_SLAVE_MAX_ERR_CODE;

CAM_ERR_RATE_LIMIT(CAM_CPAS,
CAM_DBG(CAM_CPAS,
"errlog0 low[0x%x 0x%x] high[0x%x 0x%x] loginfo_vld=%d, word_error=%d, non_secure=%d, device=%d, opc=%d, err_code=%d(%s) sizef=%d, addr_space=%d, len1=%d",
camnoc_info->err_logger->errlog0_low,
slave_err->errlog0_low.value,
Expand All @@ -250,7 +250,7 @@ static int cam_cpastop_handle_errlogger(struct cam_cpas *cpas_core,
slave_err->errlog0_low.addr_space,
slave_err->errlog0_high.len1);

CAM_ERR_RATE_LIMIT(CAM_CPAS,
CAM_DBG(CAM_CPAS,
"errlog1_low[0x%x 0x%x] errlog1_high[0x%x 0x%x] errlog2_low[0x%x 0x%x] errlog2_high[0x%x 0x%x] errlog3_low[0x%x 0x%x] errlog3_high[0x%x 0x%x]",
camnoc_info->err_logger->errlog1_low,
slave_err->errlog1_low.value,
Expand Down Expand Up @@ -279,7 +279,7 @@ static int cam_cpastop_handle_ubwc_enc_err(struct cam_cpas *cpas_core,
camnoc_info->irq_err[i].err_status.offset);

/* Let clients handle the UBWC errors */
CAM_DBG(CAM_CPAS,
CAM_ERR_RATE_LIMIT(CAM_CPAS,
"ubwc enc err [%d]: offset[0x%x] value[0x%x]",
i, camnoc_info->irq_err[i].err_status.offset,
enc_err->encerr_status.value);
Expand All @@ -298,7 +298,7 @@ static int cam_cpastop_handle_ubwc_dec_err(struct cam_cpas *cpas_core,
camnoc_info->irq_err[i].err_status.offset);

/* Let clients handle the UBWC errors */
CAM_DBG(CAM_CPAS,
CAM_ERR_RATE_LIMIT(CAM_CPAS,
"ubwc dec err status [%d]: offset[0x%x] value[0x%x] thr_err=%d, fcl_err=%d, len_md_err=%d, format_err=%d",
i, camnoc_info->irq_err[i].err_status.offset,
dec_err->decerr_status.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ int cam_icp_context_init(struct cam_icp_context *ctx,
}

rc = cam_context_init(ctx->base, icp_dev_name, CAM_ICP, ctx_id,
NULL, hw_intf, ctx->req_base, CAM_CTX_REQ_MAX);
NULL, hw_intf, ctx->req_base, CAM_ICP_CTX_REQ_MAX);
if (rc) {
CAM_ERR(CAM_ICP, "Camera Context Base init failed");
goto err;
Expand Down
5 changes: 3 additions & 2 deletions drivers/media/platform/msm/camera/cam_icp/cam_icp_context.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand All @@ -14,6 +14,7 @@
#define _CAM_ICP_CONTEXT_H_

#include "cam_context.h"
#include "cam_icp_hw_mgr_intf.h"

/**
* struct cam_icp_context - icp context
Expand All @@ -26,7 +27,7 @@
struct cam_icp_context {
struct cam_context *base;
struct cam_ctx_ops *state_machine;
struct cam_ctx_request req_base[CAM_CTX_REQ_MAX];
struct cam_ctx_request req_base[CAM_ICP_CTX_REQ_MAX];
uint32_t state;
void *ctxt_to_hw_map;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -382,12 +382,16 @@ int cam_bps_process_cmd(void *device_priv, uint32_t cmd_type,
}
break;
case CAM_ICP_BPS_CMD_DISABLE_CLK:
mutex_lock(&bps_dev->hw_mutex);
if (core_info->clk_enable == true)
cam_bps_toggle_clk(soc_info, false);
core_info->clk_enable = false;
mutex_unlock(&bps_dev->hw_mutex);
break;
case CAM_ICP_BPS_CMD_RESET:
mutex_lock(&bps_dev->hw_mutex);
rc = cam_bps_cmd_reset(soc_info, core_info);
mutex_unlock(&bps_dev->hw_mutex);
break;
default:
CAM_ERR(CAM_ICP, "Invalid Cmd Type:%u", cmd_type);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define CAM_ICP_ROLE_PARENT 1
#define CAM_ICP_ROLE_CHILD 2

#define CAM_FRAME_CMD_MAX 20
#define CAM_FRAME_CMD_MAX CAM_ICP_CTX_REQ_MAX

#define CAM_MAX_OUT_RES 6
#define CAM_MAX_IN_RES 8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#define CAM_ICP_CTX_MAX 54

#define CAM_ICP_CTX_REQ_MAX 40

#define CPAS_IPE1_BIT 0x2000

int cam_icp_hw_mgr_init(struct device_node *of_node,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -377,12 +377,16 @@ int cam_ipe_process_cmd(void *device_priv, uint32_t cmd_type,
}
break;
case CAM_ICP_IPE_CMD_DISABLE_CLK:
mutex_lock(&ipe_dev->hw_mutex);
if (core_info->clk_enable == true)
cam_ipe_toggle_clk(soc_info, false);
core_info->clk_enable = false;
mutex_unlock(&ipe_dev->hw_mutex);
break;
case CAM_ICP_IPE_CMD_RESET:
mutex_lock(&ipe_dev->hw_mutex);
rc = cam_ipe_cmd_reset(soc_info, core_info);
mutex_unlock(&ipe_dev->hw_mutex);
break;
default:
CAM_ERR(CAM_ICP, "Invalid Cmd Type:%u", cmd_type);
Expand Down
Loading

0 comments on commit 72d8803

Please sign in to comment.