dsp_loader.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 2021 Alibaba Group. All rights reserved.
  3. * License-Identifier: Apache-2.0
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. * not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #include "csi_dsp_post_process_defs.h"
  19. #include "ialgo.h"
  20. #include "dsp_ps_debug.h"
  21. #include "algo.h"
  22. #include <xt_library_loader.h>
  23. #include "lib_loader.h"
  24. //#define USE_SUBFUNC_OBJ
  25. #if defined ( USE_FL_OBJ )
  26. #define _loader csi_dsp_load_flo
  27. #define _unloader csi_dsp_unload_flo
  28. #elif defined ( USE_PI_OBJ)
  29. #define _loader csi_dsp_load_pilsl
  30. #define _unloader csi_dsp_unload_pilsl
  31. #endif
  32. #if (defined ( USE_FL_OBJ ) || defined ( USE_PI_OBJ)) && (!defined (LOAD_LIB_OTF))
  33. /* This library will be provided by the object created by the
  34. * xt-pkg-loadlib tool. Observe that the name declared here must
  35. * match the name used with the "-e" option to the tool.
  36. */
  37. //extern xtlib_packaged_library Overlay_kernel;
  38. extern xtlib_packaged_library dsp_dummy_algo_lib;
  39. #endif
  40. algo_func dsp_algo_load(uint16_t algo_id,uint64_t algo_ptr,csi_dsp_algo_param_t *info)
  41. {
  42. wrapper_func func = NULL;
  43. #if defined ( USE_SUBFUNC_OBJ )
  44. switch((csi_dsp_algo_lib_id_e)algo_id)
  45. {
  46. case CSI_DSP_ALGO_LIB_COPY:
  47. func = dsp_dummy_algo_wrapper;
  48. break;
  49. default:
  50. ps_err("No valid algo to load\n");
  51. return NULL;
  52. }
  53. #else
  54. xtlib_packaged_library *library=NULL;
  55. lib_loader_info_t lib_info;
  56. #if defined (LOAD_LIB_OTF)
  57. library = (xtlib_packaged_library *)algo_ptr;
  58. #else
  59. switch((csi_dsp_algo_lib_id_e)algo_id)
  60. {
  61. case CSI_DSP_ALGO_LIB_COPY:
  62. library = &dsp_dummy_algo_lib;
  63. break;
  64. default:
  65. ps_err("No valid algo to load\n");
  66. return NULL;
  67. }
  68. #endif
  69. func = _loader(library,&lib_info);
  70. if(func == NULL)
  71. {
  72. return NULL;
  73. }
  74. #endif
  75. return func(info);
  76. }