diff options
Diffstat (limited to 'drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c')
-rw-r--r-- | drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c | 141 |
1 files changed, 73 insertions, 68 deletions
diff --git a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c index 2a23b7c6aeeb..9813014c3fd3 100644 --- a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c +++ b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Support for Intel Camera Imaging ISP subsystem. * Copyright (c) 2015, Intel Corporation. @@ -14,6 +15,9 @@ #include <math_support.h> #include <gdc_device.h> /* HR_GDC_N */ + +#include "hmm.h" + #include "isp.h" /* ISP_VEC_NELEMS */ #include "ia_css_binary.h" @@ -26,6 +30,8 @@ #include "sh_css_defs.h" #include "sh_css_legacy.h" +#include "atomisp_internal.h" + #include "vf/vf_1.0/ia_css_vf.host.h" #include "sc/sc_1.0/ia_css_sc.host.h" #include "sdis/sdis_1.0/ia_css_sdis.host.h" @@ -33,8 +39,6 @@ #include "camera/pipe/interface/ia_css_pipe_binarydesc.h" -#include "memory_access.h" - #include "assert_support.h" #define IMPLIES(a, b) (!(a) || (b)) /* A => B */ @@ -132,7 +136,7 @@ struct sh_css_binary_sc_requirements { }; /* Get the requirements for the shading correction. */ -static enum ia_css_err +static int #ifndef ISP2401 ia_css_binary_compute_shading_table_bayer_origin( const struct ia_css_binary *binary, /* [in] */ @@ -147,7 +151,7 @@ sh_css_binary_get_sc_requirements( struct sh_css_binary_sc_requirements *scr) /* [out] */ #endif { - enum ia_css_err err; + int err; #ifndef ISP2401 /* Numerator and denominator of the fixed bayer downscaling factor. @@ -196,7 +200,7 @@ sh_css_binary_get_sc_requirements( /* Get the numerator and denominator of bayer downscaling factor. */ err = sh_css_bds_factor_get_numerator_denominator (required_bds_factor, &bds_num, &bds_den); - if (err != IA_CSS_SUCCESS) + if (err) #else /* Flags corresponding to NEED_BDS_FACTOR_2_00/NEED_BDS_FACTOR_1_50/NEED_BDS_FACTOR_1_25 macros * defined in isp kernels. */ @@ -226,7 +230,7 @@ sh_css_binary_get_sc_requirements( /* Get the numerator and denominator of the required bayer downscaling factor. */ err = sh_css_bds_factor_get_numerator_denominator(required_bds_factor, &bds_num, &bds_den); - if (err != IA_CSS_SUCCESS) + if (err) { IA_CSS_LEAVE_ERR_PRIVATE(err); #endif @@ -479,7 +483,7 @@ return err; } /* Get the shading information of Shading Correction Type 1. */ -static enum ia_css_err +static int ia_css_binary_get_shading_info_type_1(const struct ia_css_binary *binary, /* [in] */ unsigned int required_bds_factor, /* [in] */ @@ -491,7 +495,7 @@ ia_css_binary_get_shading_info_type_1(const struct ia_css_binary struct ia_css_pipe_config *pipe_config) /* [out] */ #endif { - enum ia_css_err err; + int err; #ifndef ISP2401 struct sh_css_shading_table_bayer_origin_compute_results res; #else @@ -545,12 +549,12 @@ ia_css_binary_get_shading_info_type_1(const struct ia_css_binary required_bds_factor, stream_config, &res); - if (err != IA_CSS_SUCCESS) + if (err) #else *shading_info = DEFAULT_SHADING_INFO_TYPE_1; err = sh_css_binary_get_sc_requirements(binary, required_bds_factor, stream_config, &scr); - if (err != IA_CSS_SUCCESS) + if (err) { IA_CSS_LEAVE_ERR_PRIVATE(err); #endif @@ -639,8 +643,8 @@ IA_CSS_LOG("adjust_width_bqs=%d, adjust_height_bqs=%d", adjust_width_bqs, adjust if (adjust_width_bqs > tbl_width_bqs || adjust_height_bqs > tbl_height_bqs) { - IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_ERR_INTERNAL_ERROR); - return IA_CSS_ERR_INTERNAL_ERROR; + IA_CSS_LEAVE_ERR_PRIVATE(-EINVAL); + return -EINVAL; } /* Origin of the internal frame on the shading table. */ @@ -698,7 +702,7 @@ IA_CSS_LEAVE_ERR_PRIVATE(err); return err; } -enum ia_css_err +int ia_css_binary_get_shading_info(const struct ia_css_binary *binary, /* [in] */ enum ia_css_shading_correction_type type, /* [in] */ unsigned int required_bds_factor, /* [in] */ @@ -706,7 +710,7 @@ ia_css_binary_get_shading_info(const struct ia_css_binary *binary, /* [in] */ struct ia_css_shading_info *shading_info, /* [out] */ struct ia_css_pipe_config *pipe_config) /* [out] */ { - enum ia_css_err err; + int err; assert(binary); assert(shading_info); @@ -726,7 +730,7 @@ ia_css_binary_get_shading_info(const struct ia_css_binary *binary, /* [in] */ /* Other function calls can be added here when other shading correction types will be added in the future. */ else - err = IA_CSS_ERR_NOT_SUPPORTED; + err = -ENOTSUPP; IA_CSS_LEAVE_ERR_PRIVATE(err); return err; @@ -784,12 +788,12 @@ ia_css_binary_dvs_stat_grid_info( return; } -enum ia_css_err +int ia_css_binary_3a_grid_info(const struct ia_css_binary *binary, struct ia_css_grid_info *info, struct ia_css_pipe *pipe) { struct ia_css_3a_grid_info *s3a_info; - enum ia_css_err err = IA_CSS_SUCCESS; + int err = 0; IA_CSS_ENTER_PRIVATE("binary=%p, info=%p, pipe=%p", binary, info, pipe); @@ -857,18 +861,6 @@ binary_supports_output_format(const struct ia_css_binary_xinfo *info, return false; } -#ifdef ISP2401 -static bool -binary_supports_input_format(const struct ia_css_binary_xinfo *info, - enum atomisp_input_format format) -{ - assert(info); - (void)format; - - return true; -} -#endif - static bool binary_supports_vf_format(const struct ia_css_binary_xinfo *info, enum ia_css_frame_format format) @@ -892,52 +884,52 @@ supports_bds_factor(u32 supported_factors, return ((supported_factors & PACK_BDS_FACTOR(bds_factor)) != 0); } -static enum ia_css_err +static int binary_init_info(struct ia_css_binary_xinfo *info, unsigned int i, bool *binary_found) { const unsigned char *blob = sh_css_blob_info[i].blob; unsigned int size = sh_css_blob_info[i].header.blob.size; if ((!info) || (!binary_found)) - return IA_CSS_ERR_INVALID_ARGUMENTS; + return -EINVAL; *info = sh_css_blob_info[i].header.info.isp; *binary_found = blob; info->blob_index = i; /* we don't have this binary, skip it */ if (!size) - return IA_CSS_SUCCESS; + return 0; info->xmem_addr = sh_css_load_blob(blob, size); if (!info->xmem_addr) - return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; - return IA_CSS_SUCCESS; + return -ENOMEM; + return 0; } /* When binaries are put at the beginning, they will only * be selected if no other primary matches. */ -enum ia_css_err +int ia_css_binary_init_infos(void) { unsigned int i; unsigned int num_of_isp_binaries = sh_css_num_binaries - NUM_OF_SPS - NUM_OF_BLS; if (num_of_isp_binaries == 0) - return IA_CSS_SUCCESS; + return 0; - all_binaries = sh_css_malloc(num_of_isp_binaries * - sizeof(*all_binaries)); + all_binaries = kvmalloc(num_of_isp_binaries * sizeof(*all_binaries), + GFP_KERNEL); if (!all_binaries) - return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; + return -ENOMEM; for (i = 0; i < num_of_isp_binaries; i++) { - enum ia_css_err ret; + int ret; struct ia_css_binary_xinfo *binary = &all_binaries[i]; bool binary_found; ret = binary_init_info(binary, i, &binary_found); - if (ret != IA_CSS_SUCCESS) + if (ret) return ret; if (!binary_found) continue; @@ -947,10 +939,10 @@ ia_css_binary_init_infos(void) { binary->blob = &sh_css_blob_info[i]; binary->mem_offsets = sh_css_blob_info[i].mem_offsets; } - return IA_CSS_SUCCESS; + return 0; } -enum ia_css_err +int ia_css_binary_uninit(void) { unsigned int i; struct ia_css_binary_xinfo *b; @@ -964,8 +956,8 @@ ia_css_binary_uninit(void) { } binary_infos[i] = NULL; } - sh_css_free(all_binaries); - return IA_CSS_SUCCESS; + kvfree(all_binaries); + return 0; } /* @brief Compute decimation factor for 3A statistics and shading correction. @@ -1083,7 +1075,7 @@ binary_in_frame_padded_width(int in_frame_width, return rval; } -enum ia_css_err +int ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, bool online, bool two_ppc, @@ -1114,7 +1106,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, bool need_scaling = false; struct ia_css_resolution binary_dvs_env, internal_res; - enum ia_css_err err; + int err; unsigned int i; const struct ia_css_frame_info *bin_out_info = NULL; @@ -1128,7 +1120,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, err = ia_css_isp_param_allocate_isp_parameters( &binary->mem_params, &binary->css_params, &info->mem_initializers); - if (err != IA_CSS_SUCCESS) { + if (err) { return err; } } @@ -1231,7 +1223,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, { err = ia_css_vf_configure(binary, bin_out_info, (struct ia_css_frame_info *)vf_info, &vf_log_ds); - if (err != IA_CSS_SUCCESS) { + if (err) { if (!accelerator) { ia_css_isp_param_destroy_isp_parameters( &binary->mem_params, @@ -1252,7 +1244,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, binary->vf_frame_info.format = vf_info->format; if (!bin_out_info) - return IA_CSS_ERR_INTERNAL_ERROR; + return -EINVAL; vf_out_vecs = __ISP_VF_OUTPUT_WIDTH_VECS(bin_out_info->padded_width, vf_log_ds); vf_out_width = _ISP_VF_OUTPUT_WIDTH(vf_out_vecs); @@ -1350,7 +1342,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, if (info->enable.sc) { - if (!atomisp_hw_is_isp2401) { + if (!IS_ISP2401) { binary->sctbl_width_per_color = _ISP2400_SCTBL_WIDTH_PER_COLOR(sc_3a_dis_padded_width, s3a_log_deci); binary->sctbl_aligned_width_per_color = ISP2400_SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR; binary->sctbl_height = _ISP2400_SCTBL_HEIGHT(sc_3a_dis_height, s3a_log_deci); @@ -1366,7 +1358,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, binary->sctbl_width_per_color = 0; binary->sctbl_aligned_width_per_color = 0; binary->sctbl_height = 0; - if (atomisp_hw_is_isp2401) { + if (IS_ISP2401) { binary->sctbl_legacy_width_per_color = 0; binary->sctbl_legacy_height = 0; } @@ -1382,12 +1374,11 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo, else binary->left_padding = 0; - return IA_CSS_SUCCESS; + return 0; } -enum ia_css_err -ia_css_binary_find(struct ia_css_binary_descr *descr, - struct ia_css_binary *binary) { +static int __ia_css_binary_find(struct ia_css_binary_descr *descr, + struct ia_css_binary *binary) { int mode; bool online; bool two_ppc; @@ -1413,7 +1404,7 @@ ia_css_binary_find(struct ia_css_binary_descr *descr, #ifdef ISP2401 bool enable_luma_only; #endif - enum ia_css_err err = IA_CSS_ERR_INTERNAL_ERROR; + int err = -EINVAL; bool continuous; unsigned int isp_pipe_version; struct ia_css_resolution dvs_env, internal_res; @@ -1441,7 +1432,7 @@ ia_css_binary_find(struct ia_css_binary_descr *descr, req_bin_out_info = req_out_info[i]; } if (!req_bin_out_info) - return IA_CSS_ERR_INTERNAL_ERROR; + return -EINVAL; #ifndef ISP2401 req_vf_info = descr->vf_info; #else @@ -1699,15 +1690,6 @@ ia_css_binary_find(struct ia_css_binary_descr *descr, binary_supports_output_format(xcandidate, req_bin_out_info->format)); continue; } -#ifdef ISP2401 - if (!binary_supports_input_format(xcandidate, descr->stream_format)) { - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, - "ia_css_binary_find() [%d] continue: !%d\n", - __LINE__, - binary_supports_input_format(xcandidate, req_in_info->format)); - continue; - } -#endif if (xcandidate->num_output_pins > 1 && /* in case we have a second output pin, */ req_vf_info && /* and we need vf output. */ @@ -1799,7 +1781,7 @@ ia_css_binary_find(struct ia_css_binary_descr *descr, descr->stream_config_left_padding, false); - if (err != IA_CSS_SUCCESS) + if (err) break; binary_init_metrics(&binary->metrics, &binary->info->sp); break; @@ -1812,9 +1794,32 @@ ia_css_binary_find(struct ia_css_binary_descr *descr, ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_binary_find() leave: return_err=%d\n", err); + if (!err && xcandidate) + dev_dbg(atomisp_dev, + "Using binary %s (id %d), type %d, mode %d, continuous %s\n", + xcandidate->blob->name, + xcandidate->sp.id, + xcandidate->type, + xcandidate->sp.pipeline.mode, + xcandidate->sp.enable.continuous ? "true" : "false"); + + return err; } +int ia_css_binary_find(struct ia_css_binary_descr *descr, + struct ia_css_binary *binary) +{ + int ret = __ia_css_binary_find(descr, binary); + + if (unlikely(ret)) { + dev_dbg(atomisp_dev, "Seeking for binary failed at:"); + dump_stack(); + } + + return ret; +} + unsigned ia_css_binary_max_vf_width(void) { |