diff --git a/.github/workflows/build-tests.yml b/.github/workflows/build-tests.yml index eb8c9d84..74cc76c9 100644 --- a/.github/workflows/build-tests.yml +++ b/.github/workflows/build-tests.yml @@ -11,7 +11,7 @@ jobs: build: strategy: matrix: - version: [ipu6] + version: [ipu6epmtl, ipu6ep, ipu6, hal] os: ["ubuntu:24.04", "ubuntu:22.04", "ubuntu:20.04"] runs-on: ubuntu-latest container: ${{ matrix.os }} @@ -19,7 +19,7 @@ jobs: - uses: actions/checkout@v4 with: repository: intel/ipu6-camera-bins - ref: main + ref: dfsg path: bins - name: Install from intel/ipu6-camera-bins @@ -53,35 +53,36 @@ jobs: apt-get update -q export TZ=Asia/Shanghai echo "" | apt-get install -qy tzdata - echo "" | apt-get install git build-essential cmake libexpat-dev automake libtool rpm libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev libdrm-dev libva-dev libunwind-dev libdrm-dev --yes - - - uses: actions/checkout@v4 - with: - repository: intel/icamerasrc - ref: icamerasrc_slim_api - path: icamerasrc - + echo "" | apt-get install git build-essential cmake libexpat-dev automake libtool libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev --yes - name: Build test for ${{ matrix.version }} on ${{ matrix.os }} timeout-minutes: 10 run: | + case "${{ matrix.os }}" in + ("ubuntu:24.04") + fortify_level=3 + ;; + ("ubuntu:22.04"|"ubuntu:20.04") + fortify_level=2 + ;; + (*) + echo "${{ matrix.os }} is unsupported yet. Please find the default fortify_level in /usr/share/perl5/Dpkg/Vendor/Ubuntu.pm or /usr/share/perl5/Dpkg/Vendor/Debian.pm." + exit 1 + ;; + esac cd "${GITHUB_WORKSPACE}/hal" mkdir build && cd build - cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DBUILD_CAMHAL_ADAPTOR=ON \ - -DBUILD_CAMHAL_PLUGIN=ON \ - -DIPU_VERSIONS="ipu6;ipu6ep;ipu6epmtl" \ - -DUSE_PG_LITE_PIPE=ON \ - .. - VERBOSE=1 make -j16 - make install - - cd "${GITHUB_WORKSPACE}/icamerasrc" - export CHROME_SLIM_CAMHAL=ON - ./autogen.sh - ./configure --prefix=/usr - make -j16 - make rpm + if [ "${{ matrix.version }}" = "hal" ]; then + cmake -DCMAKE_BUILD_TYPE=Release \ + "-DCMAKE_CXX_FLAGS=-D_FORTIFY_SOURCE=$fortify_level" \ + ../src/hal/hal_adaptor; + else + cmake -DCMAKE_BUILD_TYPE=Release \ + "-DCMAKE_CXX_FLAGS=-D_FORTIFY_SOURCE=$fortify_level" \ + -DIPU_VER="${{ matrix.version }}" \ + -DUSE_PG_LITE_PIPE=ON \ + -DUSE_HAL_ADAPTOR=ON \ + .. + fi + VERBOSE=1 make make install diff --git a/CMakeLists.txt b/CMakeLists.txt index f7b515aa..1a885520 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2017-2024 Intel Corporation +# Copyright (C) 2017-2023 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,12 +18,8 @@ cmake_minimum_required(VERSION 2.8) project(libcamhal) -option(BUILD_CAMHAL_PLUGIN "Build libcamhal as plugins" OFF) -option(BUILD_CAMHAL_ADAPTOR "Build hal_adaptor as libcamhal" OFF) -#------------------------- Global settings ------------------------- - -#------------------------- folder settings ------------------------- +#---------------------------- Fold settings ---------------------------- # Source directories set(SRC_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/src) @@ -56,8 +52,8 @@ endif() #SUPPORT_LIVE_TUNING # ia_cipr is only used by psysprocessor if (USE_PG_LITE_PIPE) - set(IA_CIPR_DIR ${MODULES_DIR}/ia_cipr) - set(MODULE_IA_CSS_DIR ${MODULES_DIR}/ia_css) +set(IA_CIPR_DIR ${MODULES_DIR}/ia_cipr) +set(MODULE_IA_CSS_DIR ${MODULES_DIR}/ia_css) endif() #USE_PG_LITE_PIPE # CMake module directory @@ -69,25 +65,14 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}" CACHE PATH "Target location for install command." FORCE) endif() -#------------------------- compile and link options ------------------------- +message(STATUS "install prefix: " ${CMAKE_INSTALL_PREFIX}) -include(GNUInstallDirs) -# code coverage. -include(code-coverage) +#------------------------- Compilation settings ------------------------- -message(STATUS "install prefix: " ${CMAKE_INSTALL_PREFIX}) +include(GNUInstallDirs) -set (CMAKE_CXX_STANDARD 11) -add_compile_options( - -Wall - -Werror - -fstack-protector - -fPIE - -fPIC - -DDCHECK_ALWAYS_ON - -Wformat - -Wformat-security -) +# -fPIC in xos way +set(CMAKE_POSITION_INDEPENDENT_CODE ON) include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG(-faligned-new COMPILER_SUPPORTS_ALIGNED_NEW) @@ -95,106 +80,84 @@ if (COMPILER_SUPPORTS_ALIGNED_NEW) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new") endif() -set (THREADS_PREFER_PTHREAD_FLAG ON) -find_package (Threads REQUIRED) +set (CMAKE_CXX_STANDARD 11) +add_compile_options(-Wall -Werror + -fstack-protector + -fPIE -fPIC + -DDCHECK_ALWAYS_ON + -Wformat -Wformat-security + ) +# code coverage. +include(code-coverage) + +add_definitions(-D__STDC_FORMAT_MACROS + -DHAVE_PTHREADS + -DHAVE_LINUX_OS + -DHAVE_IA_TYPES + -DHAVE_PRCTL + ) + +if (USE_PG_LITE_PIPE) + add_definitions(-DUSE_PG_LITE_PIPE) +endif() #USE_PG_LITE_PIPE -# check if _FORTIFY_SOURCE is default defined with -O -include(CheckFortifyLevel) -set(FORTIFY_SOURCE_VALUE) -check_fortify_source(FORTIFY_SOURCE_VALUE) -if(FORTIFY_SOURCE_VALUE) - message(STATUS "compiler default _FORTIFY_SOURCE=${FORTIFY_SOURCE_VALUE}") +if (CAL_BUILD) + message("Chrome enabled ") + add_definitions(-DCAL_BUILD) + add_definitions(-DDUMP_IMAGE) else() - message(STATUS "_FORTIFY_SOURCE is not defined or could not be determined.") - add_compile_options(-D_FORTIFY_SOURCE=2) - message(STATUS "define _FORTIFY_SOURCE=2") -endif() + add_definitions(-DSUPPORT_MULTI_PROCESS) + add_definitions(-DLINUX_BUILD) +endif() #CAL_BUILD -add_link_options( - -fPIE - -fPIC - -Wformat - -Wformat-security - -Wl,-z,relro - -Wl,-z,now - -Wl,--no-as-needed - -Wl,--no-undefined -) +if (FACE_DETECTION) + add_definitions(-DFACE_DETECTION) +endif() #FACE_DETECTION -# -fPIC in xos way -set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# IPU6_FEATURE_S +if (IPU_VER MATCHES "ipu6") + add_definitions(-DIPU_SYSVER_IPU6) +endif() +# IPU6_FEATURE_E -#------------------- common definitions, includes and link -------------------- +# IPU6_SE_FEATURE_S +if ("${IPU_VER}" STREQUAL "ipu6sepla") + add_definitions(-DIPU_SYSVER_ipu6v3) +endif() +# IPU6_SE_FEATURE_E -add_definitions(-D__STDC_FORMAT_MACROS -DHAVE_PTHREADS -DHAVE_LINUX_OS -DHAVE_IA_TYPES -DHAVE_PRCTL) +if ("${IPU_VER}" STREQUAL "ipu6ep") + message(INFO "add definition -DIPU_SYSVER_ipu6v5 for ipu6ep") + add_definitions(-DIPU_SYSVER_ipu6v5) +endif() -include_directories( - include - include/api include/utils - ${CMAKE_INSTALL_PREFIX}/include/ia_camera - ${CMAKE_INSTALL_PREFIX}/include/ - ${CMAKE_CURRENT_LIST_DIR} - src - src/v4l2 src/core src/metadata - src/platformdata src/platformdata/gc - src/3a src/3a/intel3a src/3a/external - src/fd src/scheduler - src/core/psysprocessor - src/image_process -) +if ("${IPU_VER}" STREQUAL "ipu6epmtl") + message(INFO "add definition -DIPU_SYSVER_ipu6v6 for ipu6ep") + add_definitions(-DIPU_SYSVER_ipu6v6) +endif() -set(LIBCAMHAL_LINK_LIBS ${LIBCAMHAL_LINK_LIBS} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT} expat rt) +include_directories(include + include/api include/utils + ${CMAKE_INSTALL_PREFIX}/include/ia_camera + ${CMAKE_INSTALL_PREFIX}/include/ + ${CMAKE_CURRENT_LIST_DIR} + src + src/v4l2 src/core src/metadata + src/platformdata src/platformdata/gc + src/3a src/3a/intel3a src/3a/external + src/fd src/scheduler + src/core/psysprocessor + src/image_process + ) + +set(LIBCAMHAL_LD_FLAGS "-fPIE -fPIC -Wformat -Wformat-security -Wl,-z,relro -Wl,-z,now") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LIBCAMHAL_LD_FLAGS}") add_subdirectory(src) add_subdirectory(modules) -if (USE_PG_LITE_PIPE) - add_definitions(-DUSE_PG_LITE_PIPE) -endif() #USE_PG_LITE_PIPE - - set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} ${IIO_SRCS}) - -if (SUPPORT_LIVE_TUNING) - include_directories(modules/livetune) - set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} ${LIVE_TUNING_SRCS}) -endif() #SUPPORT_LIVE_TUNING - -if(FACE_DETECTION) - add_definitions(-DFACE_DETECTION) - set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} ${FACE_DETECTION_SRCS}) - set(LIBCAMHAL_LINK_LIBS - ${LIBCAMHAL_LINK_LIBS} - pvl_eye_detection - pvl_face_detection - pvl_mouth_detection - ${WORK_DIR_TMP}/src/fd/libface_detection.a - ) -endif() #FACE_DETECTION - -if(ENABLE_SANDBOXING) - find_package(LIBMOJO) - find_package(LIBCAMERA_IPC) - find_package(LIBCAB) - add_definitions(-DENABLE_SANDBOXING) - set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} ${SANDBOXING_CLIENT_SRCS}) - include_directories( - ${USR_INCLUDE_HEADER}/base-${BASEVER} - ${LIBMOJO_INCLUDE_DIRS} - ${LIBCAMERA_IPC_INCLUDE_DIRS} - ${LIBCAB_INCLUDE_DIRS} - ) - link_directories( - ${CMAKE_PREFIX_PATH} - ${LIBMOJO_LIBS} - ${LIBCAMERA_IPC_LIBS} - ${LIBCAB_LIBS} - ) - set(LIBCAMHAL_LINK_LIBS ${LIBCAMHAL_LINK_LIBS} ${LIBCAB_LIBS} ${LIBMOJO_LIBS} ${LIBCAMERA_IPC_LIBS} ${CMAKE_PREFIX_PATH}/librt.a) -endif() #ENABLE_SANDBOXING - +# Set source files if (CAL_BUILD) - message("Chrome enabled ") - add_definitions(-DCAL_BUILD -DDUMP_IMAGE) if (SW_JPEG_ENCODE) add_definitions(-DSW_JPEG_ENCODE) include_directories(src/jpeg/sw) @@ -210,51 +173,40 @@ if (CAL_BUILD) add_subdirectory(aal) - set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} ${MEMORY_SRCS} ${AAL_SRCS} ${JPEG_SRCS}) + set(LIBCAMHAL_SRCS + ${LIBCAMHAL_SRCS} + ${MEMORY_SRCS} + ${AAL_SRCS} + ${JPEG_SRCS} + ) include_directories(include include/api include/utils include/linux - ${USR_INCLUDE_HEADER}/android/system/core/include/ - ${USR_INCLUDE_HEADER}/ia_imaging - ${USR_INCLUDE_HEADER}/usr/lib${IPU_VER} - ${USR_INCLUDE_HEADER}/android/hardware/libhardware/include/ - aal aal/chrome src/iutils src/jpeg - modules/memory modules/memory/chrome - ) - find_package(LIBCAMERA_CLIENT) - find_package(LIBCAMERA_COMMON) - find_package(LIBCAMERA_METADATA) - find_package(LIBCAMERA_V4L2_DEVICE) - find_package(LIBSYNC) - find_package(LIBCBM) - - include_directories(${LIBCAMERA_CLIENT_INCLUDE_DIRS} ${LIBCAMERA_COMMON_INCLUDE_DIRS} - ${LIBCAMERA_METADATA_INCLUDE_DIRS} ${LIBCAMERA_V4L2_DEVICE_INCLUDE_DIRS} - ${LIBSYNC_INCLUDE_DIRS} - ${LIBCBM_INCLUDE_DIRS} + ${USR_INCLUDE_HEADER}/android/system/core/include/ + ${USR_INCLUDE_HEADER}/ia_imaging + ${USR_INCLUDE_HEADER}/lib${IPU_VER} + ${USR_INCLUDE_HEADER}/android/hardware/libhardware/include/ + aal aal/chrome src/iutils src/jpeg + modules/memory modules/memory/chrome ) - link_directories(${CMAKE_PREFIX_PATH} ${LIBCAMERA_CLIENT_LIBS} ${LIBCAMERA_METADATA_LIBS} - ${LIBCAMERA_COMMON_LIBS} ${LIBSYNC_LIBS} - ${LIBCBM_LIBS} - ) - - set(LIBCAMHAL_LINK_LIBS ${LIBCAMHAL_LINK_LIBS} ${LIBCAMERA_CLIENT_LIBS} ${LIBCAMERA_COMMON_LIBS} - ${LIBCAMERA_METADATA_LIBS} ${LIBCAMERA_V4L2_DEVICE_LIBS} - ${LIBSYNC_LIBS} jpeg ${CMAKE_PREFIX_PATH}/libyuv.pic.a - ${LIBCBM_LIBS} camera_v4l2_device - ) endif() #CAL_BUILD -if (NOT CAL_BUILD) - message("Linux build") - add_definitions(-DSUPPORT_MULTI_PROCESS) - add_definitions(-DLINUX_BUILD) - include_directories(${MODULES_DIR}/v4l2) - find_package(LIBDRM) - if(LIBDRM_FOUND AND ("${LIBDRM_VERSION}" VERSION_GREATER_EQUAL 2.4.114)) - include_directories(${LIBDRM_INCLUDE_DIRS}) - set(LIBCAMHAL_LINK_LIBS ${LIBCAMHAL_LINK_LIBS} ${LIBDRM_LIBS}) - add_definitions(-DLIBDRM_SUPPORT_MMAP_OFFSET) - endif() +if (SUPPORT_LIVE_TUNING) + set(LIBCAMHAL_SRCS ${LIVE_TUNING_SRCS}) + include_directories(modules/livetune) +endif() #SUPPORT_LIVE_TUNING + +if (USE_PG_LITE_PIPE) +add_subdirectory(${MODULE_IA_CSS_DIR}) +include_directories(${MODULE_IA_CSS_HEADER_INCLUDE_DIR}) +set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} ${MODULE_IA_CSS_SRC}) + +# suppress modules/ia_css .c code compiling error +include(CheckCCompilerFlag) +CHECK_C_COMPILER_FLAG("-Wno-error=unused-but-set-variable" COMPILER_SUPPORTS_NO_UNUSED_BUT_SET_VAR) +if (COMPILER_SUPPORTS_NO_UNUSED_BUT_SET_VAR) + set_source_files_properties(${MODULE_IA_CSS_SRC} PROPERTIES COMPILE_FLAGS + "-Wno-error=unused-but-set-variable ${CMAKE_C_FLAGS}") endif() +endif() #USE_PG_LITE_PIPE set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} @@ -274,157 +226,216 @@ set(LIBCAMHAL_SRCS ${MODULES_DIR}/ia_cipr/src/Event.cpp ${MODULES_DIR}/ia_cipr/src/Command.cpp ${MODULES_DIR}/ia_cipr/src/Utils.cpp -) + ) + +if(FACE_DETECTION) +set(LIBCAMHAL_SRCS + ${LIBCAMHAL_SRCS} + ${FACE_DETECTION_SRCS} + ) +endif() #FACE_DETECTION -#------------------------- Target settings ------------------------- +if(ENABLE_SANDBOXING) +set(LIBCAMHAL_SRCS + ${LIBCAMHAL_SRCS} + ${SANDBOXING_CLIENT_SRCS} + ) +endif() #ENABLE_SANDBOXING -if (NOT IPU_VERSIONS) - set(IPU_VERSIONS ${IPU_VER}) -endif() + set(LIBCAMHAL_SRCS ${LIBCAMHAL_SRCS} ${IIO_SRCS}) -if (BUILD_CAMHAL_ADAPTOR) - add_subdirectory(src/hal/hal_adaptor) - if (NOT BUILD_CAMHAL_PLUGIN) - message(NOTICE "Will not build libcamhal plugins") - set(IPU_VERSIONS "") - endif() +# Add libcamhal using the specified sources +if (${CMAKE_VERSION} VERSION_LESS 3.11) + add_library(camhal SHARED ${LIBCAMHAL_SRCS}) +else() + add_library(camhal SHARED $) +endif() +if(NOT USE_HAL_ADAPTOR) + set_target_properties(camhal PROPERTIES SOVERSION 0) + set_target_properties(camhal PROPERTIES VERSION "0.0.0") endif() -# Add different targets according to array IPU_VERSIONS -foreach(IPU_VER ${IPU_VERSIONS}) +add_library(camhal_static STATIC ${LIBCAMHAL_SRCS}) -if (BUILD_CAMHAL_PLUGIN) - set(TARGET_SUFFIX "-${IPU_VER}") +if(NOT DEFINED IPU_VER) + set(CAMHAL_NAME_SUFFIX "-ipu4") +elseif(${IPU_VER} STREQUAL ipu6) + set(CAMHAL_NAME_SUFFIX "") +else() + set(CAMHAL_NAME_SUFFIX "-${IPU_VER}") endif() +set_target_properties(camhal_static PROPERTIES OUTPUT_NAME camhal${CAMHAL_NAME_SUFFIX}) -set(TARGET_INCLUDE "") -set(TARGET_DEFINITIONS "") -set(TARGET_SRCS "") -set(TARGET_LINK_LIBS "") +#---------------------------- Link settings ---------------------------- +target_link_libraries(camhal ${CMAKE_DL_LIBS}) +target_link_libraries(camhal_static ${CMAKE_DL_LIBS}) -if (USE_PG_LITE_PIPE) - add_subdirectory(modules/ia_css modules/ia_css${TARGET_SUFFIX}) - set(TARGET_INCLUDE ${TARGET_INCLUDE} ${MODULE_IA_CSS_HEADER_INCLUDE_DIR}) - set(TARGET_SRCS ${TARGET_SRCS} ${MODULE_IA_CSS_SRC}) -endif() #USE_PG_LITE_PIPE +set (THREADS_PREFER_PTHREAD_FLAG ON) +find_package (Threads REQUIRED) +target_link_libraries(camhal ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(camhal_static ${CMAKE_THREAD_LIBS_INIT}) -if (IPU_VER MATCHES "ipu6") - message(STATUS "add definition -DIPU_SYSVER_IPU6 for ${IPU_VER}") - set(TARGET_DEFINITIONS ${TARGET_DEFINITIONS} -DIPU_SYSVER_IPU6) - if (IPU_VER STREQUAL "ipu6sepla") - message(STATUS "add definition -DIPU_SYSVER_ipu6v3 for ${IPU_VER}") - set(TARGET_DEFINITIONS ${TARGET_DEFINITIONS} -DIPU_SYSVER_ipu6v3) - elseif (IPU_VER STREQUAL "ipu6ep") - message(STATUS "add definition -DIPU_SYSVER_ipu6v5 for ${IPU_VER}") - set(TARGET_DEFINITIONS ${TARGET_DEFINITIONS} -DIPU_SYSVER_ipu6v5) - elseif (IPU_VER STREQUAL "ipu6epmtl") - message(STATUS "add definition -DIPU_SYSVER_ipu6v6 for ${IPU_VER}") - set(TARGET_DEFINITIONS ${TARGET_DEFINITIONS} -DIPU_SYSVER_ipu6v6) - endif() -endif() +target_link_libraries(camhal expat rt) +target_link_libraries(camhal_static expat rt) -if (NOT CAL_BUILD) - set(TARGET_DEFINITIONS ${TARGET_DEFINITIONS} "-DCAMERA_DEFAULT_CFG_PATH=\"${CMAKE_INSTALL_FULL_SYSCONFDIR}/camera/${IPU_VER}/\"") +if (CAL_BUILD) + target_link_libraries(camhal camera_v4l2_device) + target_link_libraries(camhal_static camera_v4l2_device) endif() # Link libraries, the building will be interrupted if libs/includes not found + # Link ia_imaging find_package(IA_IMAGING) - set(TARGET_INCLUDE ${TARGET_INCLUDE} ${IA_IMAGING${TARGET_SUFFIX}_INCLUDE_DIRS}) - set(TARGET_LINK_LIBS ${TARGET_LINK_LIBS} ${IA_IMAGING${TARGET_SUFFIX}_LIBS}) - - if(USE_PG_LITE_PIPE) - find_package(LIBGCSS) - set(TARGET_INCLUDE ${TARGET_INCLUDE} ${LIBGCSS${TARGET_SUFFIX}_INCLUDE_DIRS}) - set(TARGET_LINK_LIBS ${TARGET_LINK_LIBS} ${LIBGCSS${TARGET_SUFFIX}_LIBS}) - # Include libipu(4) headers - find_package(LIBIPU) - set(TARGET_INCLUDE ${TARGET_INCLUDE} ${LIBIPU${TARGET_SUFFIX}_INCLUDE_DIRS}) - set(TARGET_LINK_LIBS ${TARGET_LINK_LIBS} ${LIBIPU${TARGET_SUFFIX}_LIBS}) - else() - # Link libiacss - find_package(LIBIACSS) - set(TARGET_INCLUDE ${TARGET_INCLUDE} ${LIBIACSS${TARGET_SUFFIX}_INCLUDE_DIRS}) - set(TARGET_LINK_LIBS ${TARGET_LINK_LIBS} ${LIBIACSS${TARGET_SUFFIX}_LIBS}) - endif() + include_directories(${IA_IMAGING_INCLUDE_DIRS}) + target_link_libraries(camhal ${IA_IMAGING_LIBS}) + target_link_libraries(camhal_static ${IA_IMAGING_LIBS}) + +if(USE_PG_LITE_PIPE) + find_package(LIBGCSS) + include_directories(${LIBGCSS_INCLUDE_DIRS}) + target_link_libraries(camhal ${LIBGCSS_LIBS}) + target_link_libraries(camhal_static ${LIBGCSS_LIBS}) +else() + # Link libiacss + find_package(LIBIACSS) + include_directories(${LIBIACSS_INCLUDE_DIRS}) + target_link_libraries(camhal ${LIBIACSS_LIBS}) + target_link_libraries(camhal_static ${LIBIACSS_LIBS}) +endif() -#--------------------------- Add libcamhal target --------------------------- +# Include libipu(4) headers +find_package(LIBIPU) +include_directories(${LIBIPU_INCLUDE_DIRS}) -if (BUILD_CAMHAL_PLUGIN) - set(CAMHAL_TARGET ${IPU_VER}) - set(CAMHAL_STATIC_TARGET ${IPU_VER}_static) -else() - set(CAMHAL_TARGET camhal) - set(CAMHAL_STATIC_TARGET camhal_static) +if (USE_PG_LITE_PIPE) + target_link_libraries(camhal ${IPU_LIB}) + target_link_libraries(camhal_static ${IPU_LIB}) endif() -# Add libcamhal using the specified sources -add_library(${CAMHAL_STATIC_TARGET} STATIC ${LIBCAMHAL_SRCS} ${TARGET_SRCS}) +if (CAL_BUILD) + find_package(LIBCAMERA_CLIENT) + find_package(LIBCAMERA_COMMON) + find_package(LIBCAMERA_METADATA) + find_package(LIBCAMERA_V4L2_DEVICE) + find_package(LIBSYNC) + find_package(LIBCBM) -if (${CMAKE_VERSION} VERSION_LESS 3.11) - add_library(${CAMHAL_TARGET} SHARED ${LIBCAMHAL_SRCS} ${TARGET_SRCS}) -else() - add_library(${CAMHAL_TARGET} SHARED $) + include_directories(${LIBCAMERA_CLIENT_INCLUDE_DIRS} ${LIBCAMERA_COMMON_INCLUDE_DIRS} + ${LIBCAMERA_METADATA_INCLUDE_DIRS} ${LIBCAMERA_V4L2_DEVICE_INCLUDE_DIRS} + ${LIBSYNC_INCLUDE_DIRS} + ${LIBCBM_INCLUDE_DIRS} + ) + link_directories(${CMAKE_PREFIX_PATH} ${LIBCAMERA_CLIENT_LIBS} ${LIBCAMERA_METADATA_LIBS} + ${LIBCAMERA_COMMON_LIBS} ${LIBSYNC_LIBS} + ${LIBCBM_LIBS} + ) + + target_link_libraries(camhal ${LIBCAMERA_CLIENT_LIBS} ${LIBCAMERA_COMMON_LIBS} + ${LIBCAMERA_METADATA_LIBS} ${LIBCAMERA_V4L2_DEVICE_LIBS} + ${LIBSYNC_LIBS} jpeg ${CMAKE_PREFIX_PATH}/libyuv.pic.a + ${LIBCBM_LIBS} + ) + target_link_libraries(camhal_static ${LIBCAMERA_CLIENT_LIBS} ${LIBCAMERA_COMMON_LIBS} + ${LIBCAMERA_METADATA_LIBS} ${LIBCAMERA_V4L2_DEVICE_LIBS} + ${LIBSYNC_LIBS} jpeg ${CMAKE_PREFIX_PATH}/libyuv.pic.a + ${LIBCBM_LIBS} + ) +endif() #CAL_BUILD + +if (NOT CAL_BUILD) + include_directories(${MODULES_DIR}/v4l2) endif() -target_include_directories(${CAMHAL_STATIC_TARGET} PRIVATE ${TARGET_INCLUDE}) -target_include_directories(${CAMHAL_TARGET} PRIVATE ${TARGET_INCLUDE}) -target_compile_definitions(${CAMHAL_STATIC_TARGET} PRIVATE ${TARGET_DEFINITIONS}) -target_compile_definitions(${CAMHAL_TARGET} PRIVATE ${TARGET_DEFINITIONS}) -target_link_libraries(${CAMHAL_STATIC_TARGET} PRIVATE ${LIBCAMHAL_LINK_LIBS} ${TARGET_LINK_LIBS}) -target_link_libraries(${CAMHAL_TARGET} PRIVATE ${LIBCAMHAL_LINK_LIBS} ${TARGET_LINK_LIBS}) - -if (BUILD_CAMHAL_PLUGIN) - set_target_properties(${CAMHAL_STATIC_TARGET} PROPERTIES PREFIX "") - set_target_properties(${CAMHAL_TARGET} PROPERTIES PREFIX "") - set_target_properties(${CAMHAL_STATIC_TARGET} PROPERTIES OUTPUT_NAME ${IPU_VER}) - set_target_properties(${CAMHAL_TARGET} PROPERTIES OUTPUT_NAME ${IPU_VER}) -else() - set_target_properties(${CAMHAL_STATIC_TARGET} PROPERTIES OUTPUT_NAME ${CAMHAL_TARGET}) - set_target_properties(${CAMHAL_TARGET} PROPERTIES SOVERSION 0) - set_target_properties(${CAMHAL_TARGET} PROPERTIES VERSION "0.0.0") - set_target_properties(${CAMHAL_TARGET} PROPERTIES OUTPUT_NAME ${CAMHAL_TARGET}) +if (FACE_DETECTION) + target_link_libraries(camhal pvl_eye_detection pvl_face_detection pvl_mouth_detection) + target_link_libraries(camhal_static pvl_eye_detection pvl_face_detection pvl_mouth_detection) + target_link_libraries(camhal ${WORK_DIR_TMP}/src/fd/libface_detection.a) + target_link_libraries(camhal_static ${WORK_DIR_TMP}/src/fd/libface_detection.a) endif() +if (ENABLE_SANDBOXING) + add_definitions(-DENABLE_SANDBOXING) + + find_package(LIBMOJO) + find_package(LIBCAMERA_IPC) + find_package(LIBCAB) + + include_directories(${USR_INCLUDE_HEADER}/base-${BASEVER}) + include_directories(${LIBMOJO_INCLUDE_DIRS}) + include_directories(${LIBCAMERA_IPC_INCLUDE_DIRS}) + include_directories(${LIBCAB_INCLUDE_DIRS}) + + link_directories(${CMAKE_PREFIX_PATH} + ${LIBMOJO_LIBS} + ${LIBCAMERA_IPC_LIBS} + ${LIBCAB_LIBS} + ) + + target_link_libraries(camhal ${LIBCAB_LIBS}) + target_link_libraries(camhal ${LIBMOJO_LIBS}) + target_link_libraries(camhal ${LIBCAMERA_IPC_LIBS}) + target_link_libraries(camhal ${CMAKE_PREFIX_PATH}/librt.a) + + target_link_libraries(camhal_static ${LIBCAB_LIBS}) + target_link_libraries(camhal_static ${LIBMOJO_LIBS}) + target_link_libraries(camhal_static ${LIBCAMERA_IPC_LIBS}) + target_link_libraries(camhal_static ${CMAKE_PREFIX_PATH}/librt.a) +endif() #ENABLE_SANDBOXING #--------------------------- Install settings --------------------------- if (NOT CAL_BUILD) - if (NOT BUILD_CAMHAL_PLUGIN) - # Install headers - install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libcamhal) - if (SUPPORT_LIVE_TUNING) - install(FILES modules/livetune/LiveTuning.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libcamhal/api) - endif() #SUPPORT_LIVE_TUNING - endif() - - # Install configure files, by default ipu4 is used - message("Install camera configure files for ${IPU_VER}") - install(DIRECTORY config/linux/${IPU_VER}/ DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/camera/${IPU_VER}) +# Install headers +install(DIRECTORY include/ DESTINATION include/libcamhal) +if (SUPPORT_LIVE_TUNING) + install(FILES modules/livetune/LiveTuning.h DESTINATION include/libcamhal/api) +endif() #SUPPORT_LIVE_TUNING - # Install libraries - set(CAMHAL_TARGETS ${CAMHAL_TARGET} ${CAMHAL_STATIC_TARGET}) - if (BUILD_CAMHAL_PLUGIN) - set(CAMHAL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/libcamhal/plugins) - else() - set(CAMHAL_DESTINATION ${CMAKE_INSTALL_LIBDIR}) - endif() - if (${CMAKE_VERSION} VERSION_LESS 3.11) - install(TARGETS ${CAMHAL_TARGETS} - LIBRARY DESTINATION ${CAMHAL_DESTINATION} - ARCHIVE DESTINATION ${CAMHAL_DESTINATION}) +# Install configure files, by default ipu4 is used +if("${IPU_VER}" STREQUAL "") + set(CAMHAL_CFG_VARIANT ipu4) +else() + set(CAMHAL_CFG_VARIANT ${IPU_VER}) +endif() +message("Install camera configure files for ${CAMHAL_CFG_VARIANT}") +install(DIRECTORY config/linux/${CAMHAL_CFG_VARIANT}/ DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/camera/${CAMHAL_CFG_VARIANT}) +add_definitions("-DCAMERA_DEFAULT_CFG_PATH=\"${CMAKE_INSTALL_SYSCONFDIR}/camera/${CAMHAL_CFG_VARIANT}/\"") + +# Install libraries +set(CAMHAL_TARGETS camhal) +if (USE_HAL_ADAPTOR) + set(CAMHAL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/libcamhal/plugins) +else() + set(CAMHAL_DESTINATION ${CMAKE_INSTALL_LIBDIR}) + set(CAMHAL_TARGETS "${CAMHAL_TARGETS} camhal_static") +endif() +if (${CMAKE_VERSION} VERSION_LESS 3.11) + install(TARGETS ${CAMHAL_TARGETS} + LIBRARY DESTINATION ${CAMHAL_DESTINATION} + ARCHIVE DESTINATION ${CAMHAL_DESTINATION}) +else() + install(TARGETS ${CAMHAL_TARGETS} DESTINATION ${CAMHAL_DESTINATION}) +endif() +if (USE_HAL_ADAPTOR) + set_target_properties(camhal PROPERTIES PREFIX "") + if("${IPU_VER}" STREQUAL "") + set_target_properties(camhal PROPERTIES OUTPUT_NAME ipu4) else() - install(TARGETS ${CAMHAL_TARGETS} DESTINATION ${CAMHAL_DESTINATION}) - endif() - if (NOT BUILD_CAMHAL_PLUGIN) - # Install package config file - configure_file(${PROJECT_SOURCE_DIR}/cmake/libcamhal.pc.cmakein - ${PROJECT_SOURCE_DIR}/libcamhal.pc @ONLY) - install(FILES libcamhal.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + set_target_properties(camhal PROPERTIES OUTPUT_NAME ${IPU_VER}) endif() +else() + set_target_properties(camhal PROPERTIES OUTPUT_NAME camhal${CAMHAL_NAME_SUFFIX}) +endif() -endif() #NOT CAL_BUILD +if(NOT USE_HAL_ADAPTOR) +# Install package config file +configure_file(${PROJECT_SOURCE_DIR}/cmake/libcamhal.pc.cmakein + ${PROJECT_SOURCE_DIR}/libcamhal${CAMHAL_NAME_SUFFIX}.pc @ONLY) +install(FILES libcamhal${CAMHAL_NAME_SUFFIX}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() -endforeach() #IPU_VERSIONS +endif() #NOT CAL_BUILD set(CPACK_GENERATOR "RPM") include(CPack) diff --git a/README.md b/README.md index bb68b3f4..b78cc785 100644 --- a/README.md +++ b/README.md @@ -15,18 +15,27 @@ There are 4 repositories that provide the complete setup: - Dependencies: ipu6-camera-bins Please follow https://github.com/intel/ipu6-camera-bins README to install. -- Dependencies: libexpat-dev automake libtool libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libdrm-dev -```sh -# Please follow common cmake, make & make install flow -cd ipu6-camera-hal -mkdir build && cd build -cmake -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DBUILD_CAMHAL_ADAPTOR=ON \ - -DBUILD_CAMHAL_PLUGIN=ON \ - -DIPU_VERSIONS="ipu6;ipu6ep;ipu6epmtl" \ - -DUSE_PG_LITE_PIPE=ON \ - .. -make && sudo make install -``` +- Dependencies: libexpat-dev automake libtool libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + +- Build and install: + Recommend to build together with icamerasrc and using `build.sh` in this repo. +1. Put ipu6-camera-hal, icameasrc and build.sh parallel as below: + ``` + cp build.sh .. && cd .. + # work + # ├── build.sh + # ├── icamerasrc + # ├── ipu6-camera-hal + # └── out + ``` + +2. In `work` folder, run `./build.sh`. Output binaries will be in `out/install`. (RPM build is not implemented yet) + +3. Install contents in `out/install` to your `/usr`: + ```sh + sudo cp -r ./out/install/include/* /usr/include + sudo cp -r ./out/install/lib/* /usr/lib + sudo cp -r ./out/install/share/* /usr/share + ``` + +For more building details please reference the `build.sh`. \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 373608b6..00000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security Policy -Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. - -## Reporting a Vulnerability -Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..4fe2d629 --- /dev/null +++ b/build.sh @@ -0,0 +1,159 @@ +#!/bin/bash + +function check_result() { + local res=$1 + local func=$2 + + if [ $res -eq 0 ] ; then + echo "###############" " $func OK " "#############" + else + echo "###############" " $func FAIL " "#############" + exit 1 + fi +} + +function parse_argument() { + export SOURCE_DIR=${PWD} + export INSTALL_DIR=${PWD}/out + export BOARD_LIST="ipu_tgl ipu_adl ipu_mtl" + export BUILD_RPM=ON + + while true; do + case $1 in + -s|--source) + export SOURCE_DIR=$2 + echo "$2" + shift + ;; + -i|--install) + export INSTALL_DIR=$2 + echo "$2" + shift + ;; + --no-rpm) + export BUILD_RPM=OFF + ;; + --board) + shift + export BOARD_LIST=$@ + echo "$$" + break + ;; + -?*) + echo "WARNING: not supported option: $1" + ;; + *) + break + esac + + shift + done + + echo "=========================== Build Config ============================" + echo "SOURCE_DIR: $SOURCE_DIR" + echo "INSTALL_DIR: $INSTALL_DIR" + echo "BUILD_RPM: $BUILD_RPM" + echo "BOARD_LIST: $BOARD_LIST" + echo "=====================================================================" +} + +function print_helper() { + echo + echo "========================= Command Helper ============================" + echo "./build_release.sh -s source_dir -i install_dir --board target1 targert2 ..." + echo "=====================================================================" + echo +} + +function build_target() { + rm -fr build && mkdir -p build && cd build + + local target=$1 + export IPU_VERSION= + if [ "$target" = "ipu_tgl" ]; then + IPU_VERSION=ipu6 + elif [ "$target" = "ipu_adl" ]; then + IPU_VERSION=ipu6ep + elif [ "$target" = "ipu_mtl" ]; then + IPU_VERSION=ipu6epmtl + else + echo "Error: unsupport the target name : $target" + exit -1 + fi + + command cmake -DCMAKE_BUILD_TYPE=Release \ + -DIPU_VER=$IPU_VERSION \ + -DBUILD_CAMHAL_TESTS=OFF \ + -DUSE_PG_LITE_PIPE=ON \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DUSE_HAL_ADAPTOR=ON \ + .. + + # make and install + make -j`nproc` + check_result $? "$FUNCNAME: $target" + + make DESTDIR=${INSTALL_DIR}/install install + check_result $? "$FUNCNAME: $target" + cd .. +} + +function build_hal() { + cd $SOURCE_DIR/ipu6-camera-hal + + for target in $BOARD_LIST + do + build_target $target + done +} + +function build_hal_adaptor() { + cd $SOURCE_DIR/ipu6-camera-hal/src/hal/hal_adaptor + rm -fr build && mkdir -p build && cd build + + command cmake -DCMAKE_INSTALL_PREFIX=/usr ../ + + # make and install + make -j + check_result $? $FUNCNAME + + make DESTDIR=${INSTALL_DIR}/install install + check_result $? $FUNCNAME +} + +function build_icamerasrc() { + cd $SOURCE_DIR/icamerasrc/ + + export CHROME_SLIM_CAMHAL=ON + export PKG_CONFIG_PATH="${INSTALL_DIR}/install/lib/pkgconfig" + + rm -fr config.h.in autom4te.cache/ aclocal.m4 *-libtool config.guess compile \ + config.sub configure depcomp install-sh ltmain.sh m4 + autoreconf --install + CFLAGS="-O2" CXXFLAGS="-O2" ./configure ${CONFIGURE_FLAGS} \ + --prefix=$INSTALL_DIR/install DEFAULT_CAMERA=0 + check_result $? $FUNCNAME + + make clean + make -j + check_result $? $FUNCNAME + + make install + check_result $? $FUNCNAME +} + +function main () { + parse_argument $@ + if [ -z "$SOURCE_DIR" ] || [ -z "$INSTALL_DIR" ] || [ -z "$BOARD_LIST" ]; then + print_helper + exit 1 + fi + rm -fr $INSTALL_DIR/install $INSTALL_DIR/rpm && mkdir -p $INSTALL_DIR/install $INSTALL_DIR/rpm + build_hal + build_hal_adaptor + build_icamerasrc + + # TODO: Generate the RPM for hal, hal_adaptor and icamerasrc together +} + +main $@ diff --git a/cmake/CheckFortifyLevel.cmake b/cmake/CheckFortifyLevel.cmake deleted file mode 100644 index a27498cf..00000000 --- a/cmake/CheckFortifyLevel.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# CheckFortifySource.cmake -function(check_fortify_source output_variable) - # Create a simple C++ source file to check _FORTIFY_SOURCE - set(CHECK_SOURCE_CODE "#include -#ifndef _FORTIFY_SOURCE -#define _FORTIFY_SOURCE 0 -#endif -int main(){printf(\"%d\", _FORTIFY_SOURCE);return 0;}") - - # Set the full path for the source file - set(SOURCE_FILE_NAME "${CMAKE_BINARY_DIR}/check_fortify_source.c") - file(WRITE "${SOURCE_FILE_NAME}" "${CHECK_SOURCE_CODE}") - - # Try to compile the source file - try_compile(FORTIFY_SOURCE_COMPILED - "${CMAKE_BINARY_DIR}/temp" "${SOURCE_FILE_NAME}" - COMPILE_DEFINITIONS "-O2" - COPY_FILE "${CMAKE_BINARY_DIR}/check_fortify_source.out" - OUTPUT_VARIABLE COMPILE_OUTPUT - ) - - # Check if compilation was successful - if(FORTIFY_SOURCE_COMPILED) - # Run the compiled program to get the value of _FORTIFY_SOURCE - execute_process(COMMAND "${CMAKE_BINARY_DIR}/check_fortify_source.out" - RESULT_VARIABLE RUN_RESULT - OUTPUT_VARIABLE FORTIFY_SOURCE_VALUE - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(RUN_RESULT EQUAL 0) - # Set the variable outside the function - set(${output_variable} "${FORTIFY_SOURCE_VALUE}" PARENT_SCOPE) - else() - message(STATUS "Failed to run the compiled test program.") - set(${output_variable} "" PARENT_SCOPE) - endif() - else() - message(STATUS "Compilation failed; _FORTIFY_SOURCE is not defined.") - message(STATUS "Compiler output: ${COMPILE_OUTPUT}") - set(${output_variable} "" PARENT_SCOPE) - endif() -endfunction() diff --git a/cmake/FindIA_IMAGING.cmake b/cmake/FindIA_IMAGING.cmake index 26cbce5e..1d161d45 100644 --- a/cmake/FindIA_IMAGING.cmake +++ b/cmake/FindIA_IMAGING.cmake @@ -22,70 +22,83 @@ endif() # Get include and lib paths for IA_IMAGING from pkgconfig include(FindPackageHandleStandardArgs) +if(NOT DEFINED IPU_VER) + set(IA_IMAGING_PKG_SUFFIX "-ipu4") +else() + set(IA_IMAGING_PKG_SUFFIX "-${IPU_VER}") +endif() + find_package(PkgConfig) -pkg_check_modules(IA_IMAGING${TARGET_SUFFIX} ia_imaging${TARGET_SUFFIX}) -if(NOT IA_IMAGING${TARGET_SUFFIX}_FOUND) - message(FATAL_ERROR "IA_IMAGING${TARGET_SUFFIX} not found") +pkg_check_modules(IA_IMAGING ia_imaging${IA_IMAGING_PKG_SUFFIX}) +if(NOT IA_IMAGING_FOUND) + message(FATAL_ERROR "IA_IMAGING not found") endif() -set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${IA_IMAGING${TARGET_SUFFIX}_LIBRARY_DIRS}) +set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${IA_IMAGING_LIBRARY_DIRS}) # Libraries -find_library(IA_CCA${TARGET_SUFFIX}_LIB ia_cca${TARGET_SUFFIX}) -find_library(IA_AIQ${TARGET_SUFFIX}_LIB ia_aiq${TARGET_SUFFIX}) -find_library(IA_AIQB_PARSER${TARGET_SUFFIX}_LIB ia_aiqb_parser${TARGET_SUFFIX}) -find_library(IA_CMC_PARSER${TARGET_SUFFIX}_LIB ia_cmc_parser${TARGET_SUFFIX}) -find_library(IA_EXC${TARGET_SUFFIX}_LIB ia_exc${TARGET_SUFFIX}) -find_library(IA_MKN${TARGET_SUFFIX}_LIB ia_mkn${TARGET_SUFFIX}) +find_library(IA_CCA_LIB ia_cca${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_AIQ_LIB ia_aiq${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_AIQB_PARSER_LIB ia_aiqb_parser${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_CMC_PARSER_LIB ia_cmc_parser${IA_IMAGING_PKG_SUFFIX}) +if (NOT ENABLE_SANDBOXING) +find_library(IA_LARD_LIB ia_lard${IA_IMAGING_PKG_SUFFIX}) +endif() #ENABLE_SANDBOXING +find_library(IA_EXC_LIB ia_exc${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_MKN_LIB ia_mkn${IA_IMAGING_PKG_SUFFIX}) # SENSOR_EMD_DECODER -find_library(IA_EMD${TARGET_SUFFIX}_LIB ia_emd_decoder${TARGET_SUFFIX}) +find_library(IA_EMD_LIB ia_emd_decoder${IA_IMAGING_PKG_SUFFIX}) # DOL_FEATURE_S -find_library(IA_BCOMP${TARGET_SUFFIX}_LIB ia_bcomp${TARGET_SUFFIX}) +find_library(IA_BCOMP_LIB ia_bcomp${IA_IMAGING_PKG_SUFFIX}) # DOL_FEATURE_E -find_library(IA_NVM${TARGET_SUFFIX}_LIB ia_nvm${TARGET_SUFFIX}) -find_library(IA_LOG${TARGET_SUFFIX}_LIB ia_log${TARGET_SUFFIX}) -find_library(IA_DVS${TARGET_SUFFIX}_LIB ia_dvs${TARGET_SUFFIX}) -find_library(IA_COORDINATE${TARGET_SUFFIX}_LIB ia_coordinate${TARGET_SUFFIX}) -find_library(IA_LTM${TARGET_SUFFIX}_LIB ia_ltm${TARGET_SUFFIX}) -find_library(IA_DVS${TARGET_SUFFIX}_LIB ia_dvs${TARGET_SUFFIX}) -find_library(IA_ISP_BXT${TARGET_SUFFIX}_LIB ia_isp_bxt${TARGET_SUFFIX}) -find_library(BXT_IA_PAL${TARGET_SUFFIX}_LIB broxton_ia_pal${TARGET_SUFFIX}) +find_library(IA_NVM_LIB ia_nvm${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_LOG_LIB ia_log${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_DVS_LIB ia_dvs${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_COORDINATE_LIB ia_coordinate${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_LTM_LIB ia_ltm${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_DVS_LIB ia_dvs${IA_IMAGING_PKG_SUFFIX}) +find_library(IA_ISP_BXT_LIB ia_isp_bxt${IA_IMAGING_PKG_SUFFIX}) +find_library(BXT_IA_PAL_LIB broxton_ia_pal${IA_IMAGING_PKG_SUFFIX}) +if (USE_PG_LITE_PIPE) +find_library(P2P_LIB_NAME ia_p2p_${IPU_VER}) +endif() -set(IA_IMAGING${TARGET_SUFFIX}_LIBS - ${IA_CCA${TARGET_SUFFIX}_LIB} - ${IA_AIQ${TARGET_SUFFIX}_LIB} - ${IA_AIQB_PARSER${TARGET_SUFFIX}_LIB} - ${IA_CMC_PARSER${TARGET_SUFFIX}_LIB} - ${IA_EXC${TARGET_SUFFIX}_LIB} - ${IA_MKN${TARGET_SUFFIX}_LIB} - ${IA_EMD${TARGET_SUFFIX}_LIB} - ${IA_BCOMP${TARGET_SUFFIX}_LIB} - ${IA_NVM${TARGET_SUFFIX}_LIB} - ${IA_LOG${TARGET_SUFFIX}_LIB} - ${IA_DVS${TARGET_SUFFIX}_LIB} - ${IA_COORDINATE${TARGET_SUFFIX}_LIB} - ${IA_LTM${TARGET_SUFFIX}_LIB} - ${IA_DVS${TARGET_SUFFIX}_LIB} - ${IA_OB${TARGET_SUFFIX}_LIB} - ${IA_ISP_BXT${TARGET_SUFFIX}_LIB} - ${BXT_IA_PAL${TARGET_SUFFIX}_LIB} +set(IA_IMAGING_LIBS + ${IA_CCA_LIB} + ${IA_AIQ_LIB} + ${IA_AIQB_PARSER_LIB} + ${IA_CMC_PARSER_LIB} + ${IA_EXC_LIB} + ${IA_MKN_LIB} + ${IA_EMD_LIB} + ${IA_BCOMP_LIB} + ${IA_NVM_LIB} + ${IA_LOG_LIB} + ${IA_DVS_LIB} + ${IA_COORDINATE_LIB} + ${IA_LTM_LIB} + ${IA_DVS_LIB} + ${IA_OB_LIB} ) if (NOT ENABLE_SANDBOXING) - find_library(IA_LARD${TARGET_SUFFIX}_LIB ia_lard${TARGET_SUFFIX}) - set(IA_IMAGING${TARGET_SUFFIX}_LIBS ${IA_IMAGING${TARGET_SUFFIX}_LIBS} ${IA_LARD${TARGET_SUFFIX}_LIB}) +set(IA_IMAGING_LIBS + ${IA_IMAGING_LIBS} + ${IA_LARD_LIB} + ) endif() #ENABLE_SANDBOXING if (USE_PG_LITE_PIPE) - find_library(IA_P2P${TARGET_SUFFIX}_LIB ia_p2p${TARGET_SUFFIX}) - set(IA_IMAGING${TARGET_SUFFIX}_LIBS ${IA_IMAGING${TARGET_SUFFIX}_LIBS} ${IA_P2P${TARGET_SUFFIX}_LIB}) +set(IA_IMAGING_LIBS ${IA_IMAGING_LIBS} ${P2P_LIB_NAME}) endif() +set(IA_IMAGING_LIBS ${IA_IMAGING_LIBS} ${IA_ISP_BXT_LIB} ${BXT_IA_PAL_LIB}) + # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if # all listed variables are TRUE -find_package_handle_standard_args(IA_IMAGING${TARGET_SUFFIX} - REQUIRED_VARS IA_IMAGING${TARGET_SUFFIX}_INCLUDE_DIRS IA_IMAGING${TARGET_SUFFIX}_LIBS) +find_package_handle_standard_args(IA_IMAGING + REQUIRED_VARS IA_IMAGING_INCLUDE_DIRS IA_IMAGING_LIBS) -if(NOT IA_IMAGING${TARGET_SUFFIX}_FOUND) - message(FATAL_ERROR "IA_IMAGING${TARGET_SUFFIX} not found") +if(NOT IA_IMAGING_FOUND) + message(FATAL_ERROR "IA_IMAGING not found") endif() diff --git a/cmake/FindLIBDRM.cmake b/cmake/FindLIBDRM.cmake deleted file mode 100644 index c71b9ae0..00000000 --- a/cmake/FindLIBDRM.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (C) 2024 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Get include and lib paths for LIBDRM from pkgconfig -include(FindPackageHandleStandardArgs) - -find_package(PkgConfig) -pkg_check_modules(LIBDRM libdrm) -if(NOT LIBDRM_FOUND) - message(SEND_ERROR "LIBDRM not found") -endif() - -set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${LIBDRM_LIBRARY_DIRS}) - -# Libraries -find_library(DRM_LIB drm) -set(LIBDRM_LIBS ${DRM_LIB}) - -# handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if -# all listed variables are TRUE -find_package_handle_standard_args(LIBDRM REQUIRED_VARS LIBDRM_INCLUDE_DIRS LIBDRM_LIBS) - -if(NOT LIBDRM_FOUND) - message(SEND_ERROR "LIBDRM not found") -endif() - diff --git a/cmake/FindLIBGCSS.cmake b/cmake/FindLIBGCSS.cmake index dd0ff799..cffb8803 100644 --- a/cmake/FindLIBGCSS.cmake +++ b/cmake/FindLIBGCSS.cmake @@ -17,23 +17,29 @@ # Get include and lib paths for LIBGCSS from pkgconfig include(FindPackageHandleStandardArgs) +if(NOT DEFINED IPU_VER) + set(LIBGCSS_PKG_SUFFIX "-ipu4") +else() + set(LIBGCSS_PKG_SUFFIX "-${IPU_VER}") +endif() + find_package(PkgConfig) -pkg_check_modules(LIBGCSS${TARGET_SUFFIX} libgcss${TARGET_SUFFIX}) -if(NOT LIBGCSS${TARGET_SUFFIX}_FOUND) - message(FATAL_ERROR "LIBGCSS${TARGET_SUFFIX} not found") +pkg_check_modules(LIBGCSS libgcss${LIBGCSS_PKG_SUFFIX}) +if(NOT LIBGCSS_FOUND) + message(FATAL_ERROR "LIBGCSS not found") endif() -set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${LIBGCSS${TARGET_SUFFIX}_LIBRARY_DIRS}) +set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${LIBGCSS_LIBRARY_DIRS}) # Libraries -find_library(GCSS${TARGET_SUFFIX}_LIB gcss${TARGET_SUFFIX}) -set(LIBGCSS${TARGET_SUFFIX}_LIBS ${GCSS${TARGET_SUFFIX}_LIB}) +find_library(GCSS_LIB gcss${LIBGCSS_PKG_SUFFIX}) +set(LIBGCSS_LIBS ${GCSS_LIB}) # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if # all listed variables are TRUE -find_package_handle_standard_args(LIBGCSS${TARGET_SUFFIX} REQUIRED_VARS LIBGCSS${TARGET_SUFFIX}_INCLUDE_DIRS LIBGCSS${TARGET_SUFFIX}_LIBS) +find_package_handle_standard_args(LIBGCSS REQUIRED_VARS LIBGCSS_INCLUDE_DIRS LIBGCSS_LIBS) -if(NOT LIBGCSS${TARGET_SUFFIX}_FOUND) - message(FATAL_ERROR "LIBGCSS${TARGET_SUFFIX} not found") +if(NOT LIBGCSS_FOUND) + message(FATAL_ERROR "LIBGCSS not found") endif() diff --git a/cmake/FindLIBIACSS.cmake b/cmake/FindLIBIACSS.cmake index c2485e14..ebba61b1 100644 --- a/cmake/FindLIBIACSS.cmake +++ b/cmake/FindLIBIACSS.cmake @@ -17,8 +17,14 @@ # Get include and lib paths for LIBIACSS from pkgconfig include(FindPackageHandleStandardArgs) +if(NOT DEFINED IPU_VER) + set(IACSS_PKG_SUFFIX "-ipu4") +else() + set(IACSS_PKG_SUFFIX "-${IPU_VER}") +endif() + find_package(PkgConfig) -pkg_check_modules(LIBIACSS libiacss) +pkg_check_modules(LIBIACSS libiacss${IACSS_PKG_SUFFIX}) if(NOT LIBIACSS_FOUND) message(FATAL_ERROR "LIBIACSS not found") endif() @@ -26,9 +32,9 @@ endif() set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${LIBIACSS_LIBRARY_DIRS}) # Libraries -find_library(GCSS_LIB gcss) -find_library(IA_CAMERA_LIB ia_camera) -find_library(IA_CIPF_LIB ia_cipf) +find_library(GCSS_LIB gcss${IACSS_PKG_SUFFIX}) +find_library(IA_CAMERA_LIB ia_camera${IACSS_PKG_SUFFIX}) +find_library(IA_CIPF_LIB ia_cipf${IACSS_PKG_SUFFIX}) set(LIBIACSS_LIBS ${GCSS_LIB} ${IA_CAMERA_LIB} diff --git a/cmake/FindLIBIPU.cmake b/cmake/FindLIBIPU.cmake index 9f8d9fc6..44c26459 100644 --- a/cmake/FindLIBIPU.cmake +++ b/cmake/FindLIBIPU.cmake @@ -15,16 +15,8 @@ # if (TARGET ${IPU_VER}) - if (NOT BUILD_CAMHAL_PLUGIN) - message("libcamhal found lib${IPU_VER} target") - return() - endif() -endif() - -if(NOT DEFINED IPU_VER) - set(libipu_ver libipu4) -else() - set(libipu_ver lib${IPU_VER}) + message("libcamhal found lib${IPU_VER} target") + return() endif() # Get include and lib paths for LIBIPU from pkgconfig @@ -32,22 +24,28 @@ include(FindPackageHandleStandardArgs) # Include directory find_package(PkgConfig) -pkg_check_modules(LIBIPU${TARGET_SUFFIX} ${libipu_ver}) -if(NOT LIBIPU${TARGET_SUFFIX}_FOUND) - message(FATAL_ERROR "LIBIPU${TARGET_SUFFIX} not found") +if(NOT DEFINED IPU_VER) +set(libipu_ver libipu4) +else() +set(libipu_ver lib${IPU_VER}) +endif() +pkg_check_modules(LIBIPU ${libipu_ver}) +if(NOT LIBIPU_FOUND) + message(FATAL_ERROR "LIBIPU not found") endif() -set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${LIBIPU${TARGET_SUFFIX}_LIBRARY_DIRS}) +set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${LIBIPU_LIBRARY_DIRS}) # Libraries -find_library(IPU${TARGET_SUFFIX}_LIB NAMES ${libipu_ver}.a) -set(LIBIPU${TARGET_SUFFIX}_LIBS ${IPU${TARGET_SUFFIX}_LIB}) +find_library(IPU_LIB NAMES ${libipu_ver}.a) + +set(LIBIPU_LIBS ${IPU_LIB}) # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if # all listed variables are TRUE -find_package_handle_standard_args(LIBIPU${TARGET_SUFFIX} - REQUIRED_VARS LIBIPU${TARGET_SUFFIX}_INCLUDE_DIRS LIBIPU${TARGET_SUFFIX}_LIBS) +find_package_handle_standard_args(LIBIPU + REQUIRED_VARS LIBIPU_INCLUDE_DIRS LIBIPU_LIBS) -if(NOT LIBIPU${TARGET_SUFFIX}_FOUND) - message(FATAL_ERROR "LIBIPU${TARGET_SUFFIX} not found") +if(NOT LIBIPU_FOUND) + message(FATAL_ERROR "LIBIPU not found") endif() diff --git a/cmake/libcamhal.pc.cmakein b/cmake/libcamhal.pc.cmakein index e08ab497..b072eee6 100644 --- a/cmake/libcamhal.pc.cmakein +++ b/cmake/libcamhal.pc.cmakein @@ -1,11 +1,11 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +libdir=${exec_prefix}/lib includedir=${prefix}/include/libcamhal Name: libcamhal Description: Camera HAL Library URL: Version: @VERSION@ -Libs: -L${libdir} -lcamhal +Libs: -L${libdir} -lcamhal@CAMHAL_NAME_SUFFIX@ Cflags: -I${includedir} -I${includedir}/api -I${includedir}/utils diff --git a/config/linux/ipu6/AR0234_TGL_10bits.aiqb b/config/linux/ipu6/AR0234_TGL_10bits.aiqb index a469723c..51c3409a 100644 Binary files a/config/linux/ipu6/AR0234_TGL_10bits.aiqb and b/config/linux/ipu6/AR0234_TGL_10bits.aiqb differ diff --git a/config/linux/ipu6/gcss/graph_settings_hm11b1.xml b/config/linux/ipu6/gcss/graph_settings_hm11b1.xml index 97063548..289e0668 100644 --- a/config/linux/ipu6/gcss/graph_settings_hm11b1.xml +++ b/config/linux/ipu6/gcss/graph_settings_hm11b1.xml @@ -262,7 +262,7 @@ limitations under the License. - + @@ -1131,7 +1131,7 @@ limitations under the License. - + diff --git a/config/linux/ipu6/sensors/ar0234.xml b/config/linux/ipu6/sensors/ar0234.xml index 2ef4eaf9..c9555464 100644 --- a/config/linux/ipu6/sensors/ar0234.xml +++ b/config/linux/ipu6/sensors/ar0234.xml @@ -25,6 +25,7 @@ + @@ -41,6 +42,7 @@ + @@ -84,7 +86,7 @@ - + @@ -104,6 +106,7 @@ + @@ -120,6 +123,7 @@ + @@ -162,7 +166,7 @@ - + @@ -183,6 +187,7 @@ + @@ -199,6 +204,7 @@ + @@ -241,7 +247,7 @@ - + @@ -261,6 +267,7 @@ + @@ -277,6 +284,7 @@ + @@ -319,7 +327,7 @@ - + diff --git a/config/linux/ipu6/sensors/ar0234_usb.xml b/config/linux/ipu6/sensors/ar0234_usb.xml index b41b97d4..02a10f0a 100755 --- a/config/linux/ipu6/sensors/ar0234_usb.xml +++ b/config/linux/ipu6/sensors/ar0234_usb.xml @@ -38,7 +38,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -106,7 +106,7 @@ - + @@ -140,7 +140,7 @@ - + diff --git a/config/linux/ipu6/sensors/hm11b1-uf.xml b/config/linux/ipu6/sensors/hm11b1-uf.xml index 12d3038a..a5a418b3 100644 --- a/config/linux/ipu6/sensors/hm11b1-uf.xml +++ b/config/linux/ipu6/sensors/hm11b1-uf.xml @@ -16,12 +16,12 @@ - + - - + + @@ -31,17 +31,6 @@ - - - - - - - - - - - @@ -74,7 +63,7 @@ - + diff --git a/config/linux/ipu6/sensors/imx390.xml b/config/linux/ipu6/sensors/imx390.xml index 2afed977..4bd6dbb7 100644 --- a/config/linux/ipu6/sensors/imx390.xml +++ b/config/linux/ipu6/sensors/imx390.xml @@ -109,7 +109,6 @@ - @@ -204,7 +203,6 @@ - @@ -299,7 +297,6 @@ - @@ -394,388 +391,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -871,8 +487,7 @@ - - + @@ -968,8 +583,7 @@ - - + @@ -1065,8 +679,7 @@ - - + @@ -1162,395 +775,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1612,7 +836,6 @@ - diff --git a/config/linux/ipu6/sensors/isx031.xml b/config/linux/ipu6/sensors/isx031.xml deleted file mode 100644 index f1ba28e3..00000000 --- a/config/linux/ipu6/sensors/isx031.xml +++ /dev/null @@ -1,545 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6/sensors/ov01a1s-uf.xml b/config/linux/ipu6/sensors/ov01a1s-uf.xml index ebb22baa..77404a59 100644 --- a/config/linux/ipu6/sensors/ov01a1s-uf.xml +++ b/config/linux/ipu6/sensors/ov01a1s-uf.xml @@ -33,17 +33,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/AR0234_TGL_10bits.aiqb b/config/linux/ipu6ep/AR0234_TGL_10bits.aiqb index a469723c..51c3409a 100644 Binary files a/config/linux/ipu6ep/AR0234_TGL_10bits.aiqb and b/config/linux/ipu6ep/AR0234_TGL_10bits.aiqb differ diff --git a/config/linux/ipu6ep/HM2170_1SG205N3_MB_ADL.aiqb b/config/linux/ipu6ep/HM2170_1SG205N3_MB_ADL.aiqb new file mode 100644 index 00000000..f6cc9e5d Binary files /dev/null and b/config/linux/ipu6ep/HM2170_1SG205N3_MB_ADL.aiqb differ diff --git a/config/linux/ipu6ep/HM2170_1SG205N3_OS_ADL.aiqb b/config/linux/ipu6ep/HM2170_1SG205N3_OS_ADL.aiqb new file mode 100644 index 00000000..f6cc9e5d Binary files /dev/null and b/config/linux/ipu6ep/HM2170_1SG205N3_OS_ADL.aiqb differ diff --git a/config/linux/ipu6ep/IMX390_HDR_ADL.aiqb b/config/linux/ipu6ep/IMX390_HDR_TGL.aiqb similarity index 82% rename from config/linux/ipu6ep/IMX390_HDR_ADL.aiqb rename to config/linux/ipu6ep/IMX390_HDR_TGL.aiqb index a61ef56b..2df11318 100644 Binary files a/config/linux/ipu6ep/IMX390_HDR_ADL.aiqb and b/config/linux/ipu6ep/IMX390_HDR_TGL.aiqb differ diff --git a/config/linux/ipu6epmtl/IMX390_HDR_ADL.aiqb b/config/linux/ipu6ep/IMX390_HDR_TGL_2.aiqb similarity index 82% rename from config/linux/ipu6epmtl/IMX390_HDR_ADL.aiqb rename to config/linux/ipu6ep/IMX390_HDR_TGL_2.aiqb index a61ef56b..2df11318 100644 Binary files a/config/linux/ipu6epmtl/IMX390_HDR_ADL.aiqb and b/config/linux/ipu6ep/IMX390_HDR_TGL_2.aiqb differ diff --git a/config/linux/ipu6ep/gcss/graph_descriptor.xml b/config/linux/ipu6ep/gcss/graph_descriptor.xml index d7e9617f..c0c2656a 100644 --- a/config/linux/ipu6ep/gcss/graph_descriptor.xml +++ b/config/linux/ipu6ep/gcss/graph_descriptor.xml @@ -12354,6 +12354,7 @@ + @@ -12378,6 +12379,7 @@ + @@ -12408,6 +12410,7 @@ + @@ -12428,6 +12431,7 @@ + @@ -12450,6 +12454,7 @@ + @@ -12487,6 +12492,7 @@ + @@ -12509,6 +12515,7 @@ + @@ -12542,6 +12549,7 @@ + @@ -12565,6 +12573,7 @@ + @@ -12585,6 +12594,7 @@ + @@ -12610,6 +12620,7 @@ + @@ -12631,6 +12642,7 @@ + @@ -12656,6 +12668,7 @@ + @@ -12675,6 +12688,7 @@ + @@ -12700,6 +12714,7 @@ + @@ -12722,6 +12737,7 @@ + @@ -12771,6 +12787,7 @@ + @@ -12792,6 +12809,7 @@ + @@ -12845,6 +12863,7 @@ + @@ -12866,6 +12885,7 @@ + @@ -12912,6 +12932,7 @@ + @@ -13542,6 +13563,7 @@ + @@ -14107,6 +14129,7 @@ + @@ -14136,6 +14159,7 @@ + @@ -14283,6 +14307,7 @@ + @@ -14305,6 +14330,7 @@ + @@ -14358,6 +14384,7 @@ + @@ -14380,6 +14407,7 @@ + @@ -14423,6 +14451,7 @@ + @@ -14444,6 +14473,7 @@ + @@ -14481,6 +14511,7 @@ + @@ -14501,6 +14532,7 @@ + @@ -14557,6 +14589,7 @@ + @@ -14577,6 +14610,7 @@ + @@ -14607,6 +14641,7 @@ + @@ -14630,6 +14665,7 @@ + @@ -14650,6 +14686,7 @@ + @@ -14672,6 +14709,7 @@ + @@ -14693,6 +14731,7 @@ + @@ -14718,6 +14757,7 @@ + @@ -14739,6 +14779,7 @@ + @@ -14781,6 +14822,7 @@ + @@ -15241,6 +15283,7 @@ + @@ -15262,6 +15305,7 @@ + @@ -15304,6 +15348,7 @@ + @@ -15383,6 +15428,7 @@ + @@ -15407,6 +15453,7 @@ + @@ -15583,6 +15630,7 @@ + @@ -15603,6 +15651,7 @@ + @@ -15624,6 +15673,7 @@ + @@ -15645,6 +15695,7 @@ + @@ -15666,6 +15717,7 @@ + @@ -15685,6 +15737,7 @@ + @@ -15706,6 +15759,7 @@ + @@ -15728,6 +15782,7 @@ + @@ -15770,6 +15825,7 @@ + @@ -15791,6 +15847,7 @@ + @@ -15836,6 +15893,7 @@ + @@ -15857,6 +15915,7 @@ + @@ -15903,6 +15962,7 @@ + diff --git a/config/linux/ipu6ep/gcss/graph_settings_hm2170_1SG205N3_ADL.xml b/config/linux/ipu6ep/gcss/graph_settings_hm2170_1SG205N3_ADL.xml new file mode 100644 index 00000000..c24aab0b --- /dev/null +++ b/config/linux/ipu6ep/gcss/graph_settings_hm2170_1SG205N3_ADL.xml @@ -0,0 +1,2507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/linux/ipu6ep/hi556.aiqb b/config/linux/ipu6ep/hi556.aiqb new file mode 100644 index 00000000..fa457e46 Binary files /dev/null and b/config/linux/ipu6ep/hi556.aiqb differ diff --git a/config/linux/ipu6ep/libcamhal_profile.xml b/config/linux/ipu6ep/libcamhal_profile.xml index f167d84f..3bc4ff67 100644 --- a/config/linux/ipu6ep/libcamhal_profile.xml +++ b/config/linux/ipu6ep/libcamhal_profile.xml @@ -21,6 +21,6 @@ + imx390,ar0234,external_source,ar0234_usb,lt6911uxc,lt6911uxe"/> diff --git a/config/linux/ipu6ep/psys_policy_profiles.xml b/config/linux/ipu6ep/psys_policy_profiles.xml index eb6fb30f..a75ecf88 100644 --- a/config/linux/ipu6ep/psys_policy_profiles.xml +++ b/config/linux/ipu6ep/psys_policy_profiles.xml @@ -26,11 +26,7 @@ limitations under the License. - - - - - + diff --git a/config/linux/ipu6ep/sensors/ar0234.xml b/config/linux/ipu6ep/sensors/ar0234.xml index df0a2475..52c444ff 100644 --- a/config/linux/ipu6ep/sensors/ar0234.xml +++ b/config/linux/ipu6ep/sensors/ar0234.xml @@ -25,6 +25,7 @@ + @@ -41,6 +42,7 @@ + @@ -84,7 +86,7 @@ - + @@ -105,6 +107,7 @@ + @@ -121,6 +124,7 @@ + @@ -163,7 +167,7 @@ - + @@ -185,6 +189,7 @@ + @@ -201,6 +206,7 @@ + @@ -243,7 +249,7 @@ - + @@ -264,6 +270,7 @@ + @@ -280,6 +287,7 @@ + @@ -322,7 +330,7 @@ - + diff --git a/config/linux/ipu6ep/sensors/ar0234_usb.xml b/config/linux/ipu6ep/sensors/ar0234_usb.xml index 07a7f851..26f5068d 100755 --- a/config/linux/ipu6ep/sensors/ar0234_usb.xml +++ b/config/linux/ipu6ep/sensors/ar0234_usb.xml @@ -37,7 +37,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/config/linux/ipu6ep/sensors/hi556-uf.xml b/config/linux/ipu6ep/sensors/hi556-uf.xml index 338952cd..648bb55a 100644 --- a/config/linux/ipu6ep/sensors/hi556-uf.xml +++ b/config/linux/ipu6ep/sensors/hi556-uf.xml @@ -31,17 +31,6 @@ - - - - - - - - - - - @@ -277,17 +266,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/hm2170-uf.xml b/config/linux/ipu6ep/sensors/hm2170-uf.xml index 4e72419d..d3337a69 100644 --- a/config/linux/ipu6ep/sensors/hm2170-uf.xml +++ b/config/linux/ipu6ep/sensors/hm2170-uf.xml @@ -29,17 +29,6 @@ - - - - - - - - - - - @@ -108,17 +97,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/imx390.xml b/config/linux/ipu6ep/sensors/imx390.xml index 2e104dfb..ceb8cac0 100644 --- a/config/linux/ipu6ep/sensors/imx390.xml +++ b/config/linux/ipu6ep/sensors/imx390.xml @@ -1,5 +1,5 @@ - @@ -161,8 +161,8 @@ - + @@ -249,8 +249,8 @@ - + @@ -337,8 +337,8 @@ - + @@ -374,15 +374,15 @@ - - + + - - + + - + @@ -392,15 +392,15 @@ - - + + - - + + - + @@ -425,8 +425,8 @@ - + @@ -462,15 +462,15 @@ - - + + - - + + - + @@ -480,15 +480,15 @@ - - + + - - + + - + @@ -513,8 +513,8 @@ - + @@ -544,182 +544,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -779,8 +603,8 @@ - + @@ -809,7 +633,7 @@ - + @@ -869,8 +693,8 @@ - + @@ -899,7 +723,7 @@ - + @@ -959,8 +783,8 @@ - + @@ -989,7 +813,7 @@ - + @@ -1049,8 +873,8 @@ - + @@ -1079,7 +903,7 @@ - + @@ -1087,15 +911,15 @@ - - + + - - + + - + @@ -1106,15 +930,15 @@ - - + + - - + + - + @@ -1139,8 +963,8 @@ - + @@ -1169,7 +993,7 @@ - + @@ -1177,15 +1001,15 @@ - - + + - - + + - + @@ -1196,15 +1020,15 @@ - - + + - - + + - + @@ -1229,8 +1053,8 @@ - + @@ -1258,184 +1082,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/isx031.xml b/config/linux/ipu6ep/sensors/isx031.xml deleted file mode 100644 index d7525f52..00000000 --- a/config/linux/ipu6ep/sensors/isx031.xml +++ /dev/null @@ -1,545 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/config/linux/ipu6ep/sensors/ov01a10-uf.xml b/config/linux/ipu6ep/sensors/ov01a10-uf.xml index 9691ad6e..84122f90 100644 --- a/config/linux/ipu6ep/sensors/ov01a10-uf.xml +++ b/config/linux/ipu6ep/sensors/ov01a10-uf.xml @@ -33,17 +33,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/ov01a1s-uf.xml b/config/linux/ipu6ep/sensors/ov01a1s-uf.xml index 333db94a..38918069 100644 --- a/config/linux/ipu6ep/sensors/ov01a1s-uf.xml +++ b/config/linux/ipu6ep/sensors/ov01a1s-uf.xml @@ -33,17 +33,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/ov02c10-uf.xml b/config/linux/ipu6ep/sensors/ov02c10-uf.xml index 200cb19b..bd7604f8 100644 --- a/config/linux/ipu6ep/sensors/ov02c10-uf.xml +++ b/config/linux/ipu6ep/sensors/ov02c10-uf.xml @@ -29,17 +29,6 @@ - - - - - - - - - - - @@ -107,17 +96,6 @@ - - - - - - - - - - - @@ -185,17 +163,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/ov08a10-uf.xml b/config/linux/ipu6ep/sensors/ov08a10-uf.xml index f4a1727c..3cd03672 100644 --- a/config/linux/ipu6ep/sensors/ov08a10-uf.xml +++ b/config/linux/ipu6ep/sensors/ov08a10-uf.xml @@ -29,17 +29,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/ov13b10-uf.xml b/config/linux/ipu6ep/sensors/ov13b10-uf.xml index 13f579b3..d638c487 100644 --- a/config/linux/ipu6ep/sensors/ov13b10-uf.xml +++ b/config/linux/ipu6ep/sensors/ov13b10-uf.xml @@ -31,39 +31,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/ov8856-uf.xml b/config/linux/ipu6ep/sensors/ov8856-uf.xml index 92cc817c..c0aca646 100644 --- a/config/linux/ipu6ep/sensors/ov8856-uf.xml +++ b/config/linux/ipu6ep/sensors/ov8856-uf.xml @@ -31,17 +31,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6ep/sensors/ov8856-wf.xml b/config/linux/ipu6ep/sensors/ov8856-wf.xml index 7c636c31..65cc1c0e 100644 --- a/config/linux/ipu6ep/sensors/ov8856-wf.xml +++ b/config/linux/ipu6ep/sensors/ov8856-wf.xml @@ -31,17 +31,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/AR0234_TGL_10bits.aiqb b/config/linux/ipu6epmtl/AR0234_TGL_10bits.aiqb index a469723c..51c3409a 100644 Binary files a/config/linux/ipu6epmtl/AR0234_TGL_10bits.aiqb and b/config/linux/ipu6epmtl/AR0234_TGL_10bits.aiqb differ diff --git a/config/linux/ipu6epmtl/HM2170_1SG205N3_MB_ADL.aiqb b/config/linux/ipu6epmtl/HM2170_1SG205N3_MB_ADL.aiqb new file mode 100644 index 00000000..f6cc9e5d Binary files /dev/null and b/config/linux/ipu6epmtl/HM2170_1SG205N3_MB_ADL.aiqb differ diff --git a/config/linux/ipu6epmtl/HM2170_1SG205N3_OS_ADL.aiqb b/config/linux/ipu6epmtl/HM2170_1SG205N3_OS_ADL.aiqb new file mode 100644 index 00000000..f6cc9e5d Binary files /dev/null and b/config/linux/ipu6epmtl/HM2170_1SG205N3_OS_ADL.aiqb differ diff --git a/config/linux/ipu6epmtl/IMX390_HDR_TGL.aiqb b/config/linux/ipu6epmtl/IMX390_HDR_TGL.aiqb new file mode 100644 index 00000000..2df11318 Binary files /dev/null and b/config/linux/ipu6epmtl/IMX390_HDR_TGL.aiqb differ diff --git a/config/linux/ipu6epmtl/gcss/graph_settings_OV05C10_BBG501N3_MTL.xml b/config/linux/ipu6epmtl/gcss/graph_settings_OV05C10_BBG501N3_MTL.xml deleted file mode 100644 index 1a55fd7e..00000000 --- a/config/linux/ipu6epmtl/gcss/graph_settings_OV05C10_BBG501N3_MTL.xml +++ /dev/null @@ -1,8406 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/gcss/graph_settings_hm2170_1SG205N3_ADL.xml b/config/linux/ipu6epmtl/gcss/graph_settings_hm2170_1SG205N3_ADL.xml new file mode 100644 index 00000000..c24aab0b --- /dev/null +++ b/config/linux/ipu6epmtl/gcss/graph_settings_hm2170_1SG205N3_ADL.xml @@ -0,0 +1,2507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/linux/ipu6epmtl/gcss/graph_settings_ov01a_1BG101N3_MTL.xml b/config/linux/ipu6epmtl/gcss/graph_settings_ov01a10.xml similarity index 53% rename from config/linux/ipu6epmtl/gcss/graph_settings_ov01a_1BG101N3_MTL.xml rename to config/linux/ipu6epmtl/gcss/graph_settings_ov01a10.xml index 3bf10539..9d71bb42 100644 --- a/config/linux/ipu6epmtl/gcss/graph_settings_ov01a_1BG101N3_MTL.xml +++ b/config/linux/ipu6epmtl/gcss/graph_settings_ov01a10.xml @@ -1,5 +1,6 @@ - - - + + - + @@ -46,28 +47,30 @@ See the License for the specific language governing permissions and + + - - - - - + + + + @@ -79,49 +82,133 @@ See the License for the specific language governing permissions and -
- - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + - - + + + + + + - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - @@ -132,26 +219,26 @@ See the License for the specific language governing permissions and - - - - - - - - + + + + + + + + - + - - + + @@ -164,48 +251,48 @@ See the License for the specific language governing permissions and
- + - - + + + + + + + + + + - + - - - - - - + + - + + + + + + + + + - - - - + + + + - - - - - - - - - - - - @@ -216,22 +303,22 @@ See the License for the specific language governing permissions and - - - - + + + + - - - - - + + + + + @@ -243,79 +330,163 @@ See the License for the specific language governing permissions and -
- - - - - - - - - - - - - - +
+ + - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - - + + + + + + + + + + + + + + + + - - - + + + - - + + - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + @@ -328,48 +499,48 @@ See the License for the specific language governing permissions and
- + - - + + + + + + + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - @@ -380,20 +551,20 @@ See the License for the specific language governing permissions and - - - - + + + + - + - + @@ -405,12 +576,12 @@ See the License for the specific language governing permissions and - - - - - - + + + + + + @@ -422,89 +593,89 @@ See the License for the specific language governing permissions and -
- - - - - - - - - - - - - - +
+ + - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + - - + + + + + + + + + + - - + + - - + + - - - - - - - - + + + + - - - + + + - - + + @@ -517,48 +688,326 @@ See the License for the specific language governing permissions and
- + - - + + + + + + + + + + - + - - - - - - + + - + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -570,10 +1019,10 @@ See the License for the specific language governing permissions and - - - - + + + + @@ -582,19 +1031,203 @@ See the License for the specific language governing permissions and - - - - + + + + - + - - + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -606,85 +1239,89 @@ See the License for the specific language governing permissions and -
- - - - - - - - - - - - - - +
+ + - - + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - - + + + + + + + + + + + + + + + + -
- - - + + + + - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - + + @@ -697,48 +1334,48 @@ See the License for the specific language governing permissions and
- + - - + + + + + + + + + + - + - - - - - - + + - + + + + + + + + + - - - - + + + + - - - - - - - - - - - - @@ -746,14 +1383,18 @@ See the License for the specific language governing permissions and - - - - + + + + + + + + @@ -762,23 +1403,19 @@ See the License for the specific language governing permissions and - + - - - - - + - - + + - - + + @@ -791,48 +1428,138 @@ See the License for the specific language governing permissions and
- + - - + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + - + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - @@ -844,10 +1571,10 @@ See the License for the specific language governing permissions and - - - - + + + + @@ -856,19 +1583,19 @@ See the License for the specific language governing permissions and - - - - + + + + - + - - + + @@ -881,48 +1608,48 @@ See the License for the specific language governing permissions and
- + - - + + + + + + + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - @@ -934,10 +1661,10 @@ See the License for the specific language governing permissions and - - + + - + @@ -946,18 +1673,18 @@ See the License for the specific language governing permissions and - - + + - + - + - + @@ -971,6 +1698,18 @@ See the License for the specific language governing permissions and
+ + + + + + + + + + + + @@ -983,22 +1722,10 @@ See the License for the specific language governing permissions and - - - - - - - - - - - - @@ -1006,14 +1733,18 @@ See the License for the specific language governing permissions and - - - - + + + + + + + + @@ -1022,22 +1753,94 @@ See the License for the specific language governing permissions and - - - - + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + - + + + + + + + + + + + + + - + - + @@ -1051,34 +1854,34 @@ See the License for the specific language governing permissions and
- - + + + + + + - + + + + + + + + + - - - - - - - - - - - - @@ -1090,10 +1893,10 @@ See the License for the specific language governing permissions and - - - - + + + + @@ -1102,10 +1905,10 @@ See the License for the specific language governing permissions and - - - - + + + + diff --git a/config/linux/ipu6epmtl/gcss/graph_settings_ov01a_CJFLE21_MTL.xml b/config/linux/ipu6epmtl/gcss/graph_settings_ov01a_CJFLE21_MTL.xml deleted file mode 100644 index 3bf10539..00000000 --- a/config/linux/ipu6epmtl/gcss/graph_settings_ov01a_CJFLE21_MTL.xml +++ /dev/null @@ -1,1112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/hi556.aiqb b/config/linux/ipu6epmtl/hi556.aiqb new file mode 100644 index 00000000..fa457e46 Binary files /dev/null and b/config/linux/ipu6epmtl/hi556.aiqb differ diff --git a/config/linux/ipu6epmtl/libcamhal_profile.xml b/config/linux/ipu6epmtl/libcamhal_profile.xml index e51ac861..9b702c3b 100644 --- a/config/linux/ipu6epmtl/libcamhal_profile.xml +++ b/config/linux/ipu6epmtl/libcamhal_profile.xml @@ -1,5 +1,5 @@ - - + imx390,ar0234,external_source,ar0234_usb,lt6911uxc,lt6911uxe"/> diff --git a/config/linux/ipu6epmtl/ov01a_1BG101N3_MTL.aiqb b/config/linux/ipu6epmtl/ov01a10.aiqb similarity index 56% rename from config/linux/ipu6epmtl/ov01a_1BG101N3_MTL.aiqb rename to config/linux/ipu6epmtl/ov01a10.aiqb index 89634ca9..479a608a 100644 Binary files a/config/linux/ipu6epmtl/ov01a_1BG101N3_MTL.aiqb and b/config/linux/ipu6epmtl/ov01a10.aiqb differ diff --git a/config/linux/ipu6epmtl/ov01a1s.aiqb b/config/linux/ipu6epmtl/ov01a1s.aiqb new file mode 100644 index 00000000..f175ecd9 Binary files /dev/null and b/config/linux/ipu6epmtl/ov01a1s.aiqb differ diff --git a/config/linux/ipu6epmtl/ov01a_CJFLE21_MTL.aiqb b/config/linux/ipu6epmtl/ov01a_CJFLE21_MTL.aiqb deleted file mode 100644 index 89634ca9..00000000 Binary files a/config/linux/ipu6epmtl/ov01a_CJFLE21_MTL.aiqb and /dev/null differ diff --git a/config/linux/ipu6epmtl/ov05c10_BBG501N3_MTL.aiqb b/config/linux/ipu6epmtl/ov05c10_BBG501N3_MTL.aiqb deleted file mode 100644 index 149c53d1..00000000 Binary files a/config/linux/ipu6epmtl/ov05c10_BBG501N3_MTL.aiqb and /dev/null differ diff --git a/config/linux/ipu6epmtl/sensors/ar0234-1.xml b/config/linux/ipu6epmtl/sensors/ar0234-1.xml deleted file mode 100644 index 3f5e377b..00000000 --- a/config/linux/ipu6epmtl/sensors/ar0234-1.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/ar0234-2.xml b/config/linux/ipu6epmtl/sensors/ar0234-2.xml deleted file mode 100644 index 2e329251..00000000 --- a/config/linux/ipu6epmtl/sensors/ar0234-2.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/ar0234.xml b/config/linux/ipu6epmtl/sensors/ar0234.xml new file mode 100644 index 00000000..52c444ff --- /dev/null +++ b/config/linux/ipu6epmtl/sensors/ar0234.xml @@ -0,0 +1,345 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/linux/ipu6epmtl/sensors/ar0234_usb.xml b/config/linux/ipu6epmtl/sensors/ar0234_usb.xml old mode 100755 new mode 100644 index 07a7f851..26f5068d --- a/config/linux/ipu6epmtl/sensors/ar0234_usb.xml +++ b/config/linux/ipu6epmtl/sensors/ar0234_usb.xml @@ -37,7 +37,7 @@ - + @@ -71,7 +71,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/config/linux/ipu6epmtl/sensors/hi556-uf.xml b/config/linux/ipu6epmtl/sensors/hi556-uf.xml index 338952cd..648bb55a 100644 --- a/config/linux/ipu6epmtl/sensors/hi556-uf.xml +++ b/config/linux/ipu6epmtl/sensors/hi556-uf.xml @@ -31,17 +31,6 @@ - - - - - - - - - - - @@ -277,17 +266,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/hm2170-uf.xml b/config/linux/ipu6epmtl/sensors/hm2170-uf.xml index 4e72419d..d3337a69 100644 --- a/config/linux/ipu6epmtl/sensors/hm2170-uf.xml +++ b/config/linux/ipu6epmtl/sensors/hm2170-uf.xml @@ -29,17 +29,6 @@ - - - - - - - - - - - @@ -108,17 +97,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/hm2172-uf.xml b/config/linux/ipu6epmtl/sensors/hm2172-uf.xml index fb210c3b..f21dfcf4 100644 --- a/config/linux/ipu6epmtl/sensors/hm2172-uf.xml +++ b/config/linux/ipu6epmtl/sensors/hm2172-uf.xml @@ -29,17 +29,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/imx390.xml b/config/linux/ipu6epmtl/sensors/imx390.xml index e400a2be..ceb8cac0 100644 --- a/config/linux/ipu6epmtl/sensors/imx390.xml +++ b/config/linux/ipu6epmtl/sensors/imx390.xml @@ -20,36 +20,36 @@ - - + + - - + + - + - - + + - - + + - + @@ -73,8 +73,8 @@ - + @@ -108,36 +108,36 @@ - - + + - - + + - + - - + + - - + + - + @@ -161,8 +161,8 @@ - + @@ -196,36 +196,36 @@ - - + + - - + + - + - - + + - - + + - + @@ -249,8 +249,8 @@ - + @@ -284,36 +284,36 @@ - - + + - - + + - + - - + + - - + + - + @@ -337,8 +337,8 @@ - + @@ -372,36 +372,36 @@ - - + + - - + + - + - - + + - - + + - + @@ -425,8 +425,8 @@ - + @@ -460,36 +460,36 @@ - - + + - - + + - + - - + + - - + + - + @@ -513,8 +513,8 @@ - + @@ -603,8 +603,8 @@ - + @@ -693,8 +693,8 @@ - + @@ -783,8 +783,8 @@ - + @@ -873,8 +873,8 @@ - + @@ -963,8 +963,8 @@ - + @@ -1053,8 +1053,8 @@ - + diff --git a/config/linux/ipu6epmtl/sensors/isx031.xml b/config/linux/ipu6epmtl/sensors/isx031.xml deleted file mode 100644 index 199ba441..00000000 --- a/config/linux/ipu6epmtl/sensors/isx031.xml +++ /dev/null @@ -1,545 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/lt6911uxe-1.xml b/config/linux/ipu6epmtl/sensors/lt6911uxe-1.xml deleted file mode 100644 index 7e9f28fd..00000000 --- a/config/linux/ipu6epmtl/sensors/lt6911uxe-1.xml +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/lt6911uxe-2.xml b/config/linux/ipu6epmtl/sensors/lt6911uxe.xml similarity index 53% rename from config/linux/ipu6epmtl/sensors/lt6911uxe-2.xml rename to config/linux/ipu6epmtl/sensors/lt6911uxe.xml index c8ec91b7..d0ce0dfc 100644 --- a/config/linux/ipu6epmtl/sensors/lt6911uxe-2.xml +++ b/config/linux/ipu6epmtl/sensors/lt6911uxe.xml @@ -1,5 +1,5 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + s + + + + + + + + + + + @@ -87,67 +176,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -337,8 +150,7 @@ - + @@ -356,7 +168,7 @@ - + diff --git a/config/linux/ipu6epmtl/sensors/ov01a1s-uf.xml b/config/linux/ipu6epmtl/sensors/ov01a1s-uf.xml index 23d243c9..02de85e1 100644 --- a/config/linux/ipu6epmtl/sensors/ov01a1s-uf.xml +++ b/config/linux/ipu6epmtl/sensors/ov01a1s-uf.xml @@ -33,17 +33,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/ov02c10-uf.xml b/config/linux/ipu6epmtl/sensors/ov02c10-uf.xml index eb456069..72a7703c 100644 --- a/config/linux/ipu6epmtl/sensors/ov02c10-uf.xml +++ b/config/linux/ipu6epmtl/sensors/ov02c10-uf.xml @@ -29,17 +29,6 @@ - - - - - - - - - - - @@ -107,17 +96,6 @@ - - - - - - - - - - - @@ -185,17 +163,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/ov02e10-uf.xml b/config/linux/ipu6epmtl/sensors/ov02e10-uf.xml index 6a5be509..1e1784a3 100644 --- a/config/linux/ipu6epmtl/sensors/ov02e10-uf.xml +++ b/config/linux/ipu6epmtl/sensors/ov02e10-uf.xml @@ -29,17 +29,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/ov05c10-uf.xml b/config/linux/ipu6epmtl/sensors/ov05c10-uf.xml deleted file mode 100644 index 9cefa580..00000000 --- a/config/linux/ipu6epmtl/sensors/ov05c10-uf.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/ov08x40-uf.xml b/config/linux/ipu6epmtl/sensors/ov08x40-uf.xml index 51b9d320..77cdf649 100644 --- a/config/linux/ipu6epmtl/sensors/ov08x40-uf.xml +++ b/config/linux/ipu6epmtl/sensors/ov08x40-uf.xml @@ -26,17 +26,6 @@ - - - - - - - - - - - diff --git a/config/linux/ipu6epmtl/sensors/ov13b10-uf.xml b/config/linux/ipu6epmtl/sensors/ov13b10-uf.xml index 8d7cbf11..a5187a7c 100644 --- a/config/linux/ipu6epmtl/sensors/ov13b10-uf.xml +++ b/config/linux/ipu6epmtl/sensors/ov13b10-uf.xml @@ -59,39 +59,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/config/linux/ipu6epmtl/sensors/ov13b10-wf.xml b/config/linux/ipu6epmtl/sensors/ov13b10-wf.xml index 4fc52108..4a632390 100644 --- a/config/linux/ipu6epmtl/sensors/ov13b10-wf.xml +++ b/config/linux/ipu6epmtl/sensors/ov13b10-wf.xml @@ -59,39 +59,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/include/api/Parameters.h b/include/api/Parameters.h index c696d064..9edbc879 100644 --- a/include/api/Parameters.h +++ b/include/api/Parameters.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2013 The Android Open Source Project - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,7 +94,6 @@ typedef struct { } vc_info_t; // VIRTUAL_CHANNEL_E -// IPU7_FEATURE_S /** * \struct device_info_t: Define each camera basic information */ @@ -105,7 +104,6 @@ typedef struct { const char* name; /**< Sensor name */ const char* description; /**< Sensor description */ } device_info_t; -// IPU7_FEATURE_E /** * Basic definition will be inherited by more complicated structure. @@ -259,7 +257,6 @@ typedef enum { BUFFER_FLAG_INTERNAL = 1 << 1, BUFFER_FLAG_SW_READ = 1 << 2, BUFFER_FLAG_SW_WRITE = 1 << 3, - BUFFER_FLAG_NO_FLUSH = 1 << 4, } camera_buffer_flags_t; /** @@ -279,7 +276,7 @@ typedef struct { properties */ uint64_t timestamp; /**< buffer timestamp, it's a time reference measured in nanosecond */ uint32_t frameNumber; /**< buffer frameNumber, it's an id of buffer */ - uint64_t privateHandle; /**< used to pass private data */ + void *priv; /**< used to pass private data */ uint64_t reserved; /**< reserved for future */ } camera_buffer_t; @@ -1091,13 +1088,11 @@ typedef enum { LENS_SHADING_MAP_MODE_ON } camera_lens_shading_map_mode_type_t; -// IPU7_FEATURE_S typedef enum { CAMERA_STATISTICS_FACE_DETECT_MODE_OFF, CAMERA_STATISTICS_FACE_DETECT_MODE_SIMPLE, CAMERA_STATISTICS_FACE_DETECT_MODE_FULL, } camera_statistics_face_detect_mode_t; -// IPU7_FEATURE_E typedef enum { ROTATE_NONE, diff --git a/include/api/intel_vendor_metadata_tags.h b/include/api/intel_vendor_metadata_tags.h index 5e71b7d9..d5e6502b 100644 --- a/include/api/intel_vendor_metadata_tags.h +++ b/include/api/intel_vendor_metadata_tags.h @@ -77,14 +77,6 @@ typedef enum vendor_metadata_tag { INTEL_VENDOR_CAMERA_TOTAL_EXPOSURE_TARGET_RANGE, // int64[] | public INTEL_VENDOR_CAMERA_RAW_DATA_OUTPUT, // enum | public INTEL_VENDOR_CAMERA_HDR_RATIO, // float | public - INTEL_VENDOR_CAMERA_MODULE_ID, // byte[] | public - INTEL_VENDOR_CAMERA_SENSOR_ID, // byte[] | public - INTEL_VENDOR_CAMERA_SENSOR_MODE, // enum | public - INTEL_VENDOR_CAMERA_ANALOG_GAIN_RANGE, // float[] | public - INTEL_VENDOR_CAMERA_DIGITAL_GAIN_RANGE, // float[] | public - INTEL_VENDOR_CAMERA_ANALOG_GAIN, // float | public - INTEL_VENDOR_CAMERA_DIGITAL_GAIN, // float | public - INTEL_VENDOR_CAMERA_SENSITIVITY_RANGE, // int32[] | public INTEL_VENDOR_CAMERA_END, } vendor_metadata_tag_t; @@ -147,9 +139,3 @@ typedef enum vendor_metadata_enum_intel_vendor_camera_raw_data_output { INTEL_VENDOR_CAMERA_RAW_DATA_OUTPUT_ON, } vendor_metadata_enum_intel_vendor_camera_raw_data_output_t; -// INTEL_VENDOR_CAMERA_SENSOR_MODE -typedef enum vendor_metadata_enum_intel_vendor_camera_sensor_mode { - INTEL_VENDOR_CAMERA_SENSOR_MODE_FULL, - INTEL_VENDOR_CAMERA_SENSOR_MODE_BINNING, -} vendor_metadata_enum_intel_vendor_camera_sensor_mode_t; - diff --git a/include/linux/ipu-isys.h b/include/linux/ipu-isys.h index b90f3427..d96e95e1 100644 --- a/include/linux/ipu-isys.h +++ b/include/linux/ipu-isys.h @@ -22,6 +22,7 @@ #define V4L2_CID_IPU_BASE (V4L2_CID_USER_BASE + 0x1080) #define V4L2_CID_IPU_ISA_EN (V4L2_CID_IPU_BASE + 1) /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ +#define V4L2_CID_IPU_STORE_CSI2_HEADER (V4L2_CID_IPU_BASE + 2) #define V4L2_CID_IPU_ISYS_COMPRESSION (V4L2_CID_IPU_BASE + 3) #define V4L2_CID_IPU_QUERY_SUB_STREAM (V4L2_CID_IPU_BASE + 4) #define V4L2_IPU_ISA_EN_BLC (1 << 0) diff --git a/modules/algowrapper/IntelCca.cpp b/modules/algowrapper/IntelCca.cpp index 0ea578d6..5db4715a 100644 --- a/modules/algowrapper/IntelCca.cpp +++ b/modules/algowrapper/IntelCca.cpp @@ -42,13 +42,6 @@ IntelCca* IntelCca::getInstance(int cameraId, TuningMode mode) { } } -#ifndef ENABLE_SANDBOXING - if (sCcaInstance.empty()) { - ia_env env = {&Log::ccaPrintInfo, &Log::ccaPrintError, &Log::ccaPrintInfo}; - ia_log_init(&env); - } -#endif - IntelCca::CCAHandle handle = {}; handle.cameraId = cameraId; handle.ccaHandle[mode] = new IntelCca(cameraId, mode); @@ -119,7 +112,7 @@ ia_err IntelCca::setStatsParams(const cca::cca_stats_params& params) { } ia_err IntelCca::runAEC(uint64_t frameId, const cca::cca_ae_input_params& params, - cca::cca_ae_results* results, bool lowPower) { + cca::cca_ae_results* results) { CheckAndLogError(!results, ia_err_argument, "@%s, results is nullptr", __func__); ia_err ret = getIntelCCA()->runAEC(frameId, params, results); @@ -140,7 +133,7 @@ ia_err IntelCca::runAIQ(uint64_t frameId, const cca::cca_aiq_params& params, ia_err IntelCca::runLTM(uint64_t frameId, const cca::cca_ltm_input_params& params) { ia_err ret = getIntelCCA()->runLTM(frameId, params); - LOG2("@%s, frameId: %lu, ret:%d", __func__, frameId, ret); + LOG2("@%s, frameId: %u, ret:%d", __func__, frameId, ret); return ret; } diff --git a/modules/algowrapper/IntelCca.h b/modules/algowrapper/IntelCca.h index 4d3eaf5f..429236b2 100644 --- a/modules/algowrapper/IntelCca.h +++ b/modules/algowrapper/IntelCca.h @@ -42,7 +42,7 @@ class IntelCca { ia_err setStatsParams(const cca::cca_stats_params& params); ia_err runAEC(uint64_t frameId, const cca::cca_ae_input_params& params, - cca::cca_ae_results* results, bool lowPower); + cca::cca_ae_results* results); ia_err runAIQ(uint64_t frameId, const cca::cca_aiq_params& params, cca::cca_aiq_results* results, camera_makernote_mode_t mode = MAKERNOTE_MODE_OFF); diff --git a/modules/algowrapper/IntelEvcp.cpp b/modules/algowrapper/IntelEvcp.cpp new file mode 100644 index 00000000..bcc3d5f2 --- /dev/null +++ b/modules/algowrapper/IntelEvcp.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelEvcp + +#include "modules/algowrapper/IntelEvcp.h" + +#include + +#include + +#include "igfxcmrt/cm_rt.h" +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { +IntelEvcp::IntelEvcp() : mWidth(0), mHeight(0) {} + +int IntelEvcp::init(int width, int height) { + mWidth = width; + mHeight = height; + mEvcpDLL = std::unique_ptr(new UltraManEvcp(width, height)); + + return mEvcpDLL->init() ? OK : UNKNOWN_ERROR; +} + +bool IntelEvcp::runEvcpFrame(void* inBufAddr, int size) { + auto flushCacheBlock = [](void* start, size_t sz) { + const int CACHE_LINE_SIZE_FOR_ADL = 64; + const int CACHE_LINE_MASK_FOR_ADL = CACHE_LINE_SIZE_FOR_ADL - 1; + + char* p = + reinterpret_cast(reinterpret_cast(start) & ~CACHE_LINE_MASK_FOR_ADL); + char* end = reinterpret_cast(start) + sz; + + asm volatile("mfence" ::: "memory"); + while (p < end) { + asm volatile("clflush (%0)" ::"r"(p)); + p += CACHE_LINE_SIZE_FOR_ADL; + } + asm volatile("mfence" ::: "memory"); + return true; + }; + + return runEvcpFrameNoncopy(inBufAddr) && flushCacheBlock(inBufAddr, size); +} + +bool IntelEvcp::runEvcpFrameNoncopy(void* inBufAddr) { + CmSurface2DUP* inSurface = createCMSurface(reinterpret_cast(inBufAddr)); + + bool r = mEvcpDLL->processFrame(inSurface); + + return destroyCMSurface(inSurface) && r; +} + +CmSurface2DUP* IntelEvcp::createCMSurface(void* bufAddr) { + CmSurface2DUP* cmSurface = nullptr; + + mEvcpDLL->createCMSurface2DUP(mWidth, mHeight, CM_SURFACE_FORMAT_NV12, bufAddr, cmSurface); + + return cmSurface; +} + +bool IntelEvcp::destroyCMSurface(CmSurface2DUP* surface) { + return mEvcpDLL->destroyCMSurface2DUP(surface); +} + +bool IntelEvcp::updateEvcpParam(const EvcpParam* evcpParam) { + return mEvcpDLL->updateEvcpInfo(evcpParam); +} + +void IntelEvcp::getEvcpParam(EvcpParam* evcpParam) const { + evcpParam->evcpEccEnabled = mEvcpDLL->isEccEnabled(); + evcpParam->evcpBdEnabled = mEvcpDLL->isDimmerEnabled(); + evcpParam->evcpEnableTurbo = mEvcpDLL->isTurboOn(); + evcpParam->evcpPowerSave = mEvcpDLL->isLowPowerMode(); + evcpParam->evcpBGConcealment = mEvcpDLL->isBGConcelment(); + evcpParam->evcpBGReplacement = mEvcpDLL->isBGReplacement(); + evcpParam->evcpFaceBea = mEvcpDLL->isFaceBeaEnable(); + evcpParam->evcpFaceFra = mEvcpDLL->isFaceFraEnable(); +} + +} // namespace icamera diff --git a/modules/algowrapper/IntelEvcp.h b/modules/algowrapper/IntelEvcp.h new file mode 100644 index 00000000..66d39a62 --- /dev/null +++ b/modules/algowrapper/IntelEvcp.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wbitfield-constant-conversion" +#pragma clang diagnostic ignored "-Wunused-private-field" +// HANDLE is redefined in cm_rt.h, avoid the redefinition build error +#define HANDLE cancel_fw_pre_define +#include "igfxcmrt/cm_rt.h" +#pragma clang diagnostic pop + +#include "PlatformData.h" +#include "evcp/UltraManEvcp.h" +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" +#include "src/evcp/EvcpCommon.h" + +namespace icamera { + +class IntelEvcp { + public: + IntelEvcp(); + ~IntelEvcp() {} + int init(int width, int height); + + bool runEvcpFrame(void* inBufAddr, int size); + bool updateEvcpParam(const EvcpParam* evcpParam); + void getEvcpParam(EvcpParam* evcpParam) const; // caller to ensure not nullptr + + private: + bool runEvcpFrameNoncopy(void* inBufAddr); + + CmSurface2DUP* createCMSurface(void* bufAddr); + bool destroyCMSurface(CmSurface2DUP* surface); + + private: + int mWidth; + int mHeight; + + std::unique_ptr mEvcpDLL; + + DISALLOW_COPY_AND_ASSIGN(IntelEvcp); +}; + +} // namespace icamera diff --git a/modules/algowrapper/IntelICBM.cpp b/modules/algowrapper/IntelICBM.cpp index df2b743a..acca8c2b 100644 --- a/modules/algowrapper/IntelICBM.cpp +++ b/modules/algowrapper/IntelICBM.cpp @@ -45,11 +45,9 @@ int IntelICBM::shutdown(const ICBMReqInfo& request) { int IntelICBM::processFrame(const ICBMReqInfo& reqInfo) { CheckAndLogError(mIntelOPIC2 == nullptr, UNKNOWN_ERROR, "@%s, no active ICBM session", __func__); - // LEVEL0_ICBM_S if (reqInfo.reqType & (icamera::ICBMFeatureType::USER_FRAMING | icamera::ICBMFeatureType::BC_MODE_BB)) return mIntelOPIC2->processFrame(reqInfo); - // LEVEL0_ICBM_E if (reqInfo.reqType & icamera::ICBMFeatureType::LEVEL0_TNR) return mIntelOPIC2->runTnrFrame(reqInfo); return 0; diff --git a/modules/algowrapper/IntelPGParam.cpp b/modules/algowrapper/IntelPGParam.cpp index 2528015c..5a221bd8 100644 --- a/modules/algowrapper/IntelPGParam.cpp +++ b/modules/algowrapper/IntelPGParam.cpp @@ -566,10 +566,6 @@ int IntelPGParam::encodeTerminal(ia_css_terminal_t* terminal, ia_binary_data pay } } else { kernelId = getKernelIdByBitmap(kernelBitmap); - if (kernelId >= PSYS_MAX_KERNELS_PER_PG) { - /* All the kernels have now been encoded. */ - break; - } } /* Sanity check sections sizes and return the size to be used */ @@ -701,12 +697,13 @@ int IntelPGParam::decodeTerminal(ia_css_terminal_t* terminal, ia_binary_data pay /* Use specific ordering of kernels when available */ if (mPgReqs.terminals[terminalIndex].kernelOrder) { kernelId = mPgReqs.terminals[terminalIndex].kernelOrder[kernelIndex++].id; + CheckAndLogError( + kernelId >= PSYS_MAX_KERNELS_PER_PG, css_err_internal, + "%s: Kernel bitmap for terminal %d covers more kernels than in manifest", __func__, + terminalIndex); } else { kernelId = getKernelIdByBitmap(kernelBitmap); } - CheckAndLogError(kernelId >= PSYS_MAX_KERNELS_PER_PG, css_err_internal, - "%s: Kernel bitmap for terminal %d covers more kernels than in manifest", - __func__, terminalIndex); switch (mPgReqs.terminals[terminalIndex].type) { case IA_CSS_TERMINAL_TYPE_PARAM_CACHED_OUT: diff --git a/modules/algowrapper/graph/GraphConfigImpl.cpp b/modules/algowrapper/graph/GraphConfigImpl.cpp index 56f2584a..ce599f40 100644 --- a/modules/algowrapper/graph/GraphConfigImpl.cpp +++ b/modules/algowrapper/graph/GraphConfigImpl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation + * Copyright (C) 2015-2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -410,42 +410,16 @@ bool GraphConfigImpl::queryGraphSettings(const std::vector& activeSt return ret == OK ? true : false; } -void GraphConfigImpl::reorderQueryResults(std::map>& queryRes, - SensorMode sensorMode) { - if (sensorMode == SENSOR_MODE_UNKNOWN) return; - - for (auto& result : queryRes) { - auto& settingVector = result.second; - if (settingVector.size() < 2) continue; - - std::sort(settingVector.begin(), settingVector.end(), - [&](GCSS::IGraphConfig* a, GCSS::IGraphConfig* b) { - camera_resolution_t aRes, bRes; - if (getRawInputSize(a, &aRes) == OK && getRawInputSize(b, &bRes) == OK) { - if (aRes.width >= bRes.width && aRes.height >= bRes.height) { - if (sensorMode == SENSOR_MODE_FULL) return true; - } else { - if (sensorMode == SENSOR_MODE_BINNING) return true; - } - } - return false; - }); - } -} - /* * According to the stream list to query graph setting and create GraphConfigPipe */ status_t GraphConfigImpl::configStreams(const vector& activeStreams, - bool dummyStillSink, SensorMode sensorMode) { + bool dummyStillSink) { HAL_TRACE_CALL(CAMERA_DEBUG_LOG_LEVEL1); map> useCaseToQueryResults; status_t ret = queryAllMatchedResults(activeStreams, dummyStillSink, &useCaseToQueryResults); CheckAndLogError(ret != OK, UNKNOWN_ERROR, "%s, Faild to queryAllMatchedResults", __func__); - - reorderQueryResults(useCaseToQueryResults, sensorMode); - // Filter the results with same isys output if there are // multiple items in useCaseToQueryResults map if (useCaseToQueryResults.size() > 1) { @@ -489,8 +463,7 @@ status_t GraphConfigImpl::configStreams(const vector& activeStreams, } else { // Use the query result with smallest isys output if there is only video pipe int resultIdx = 0; - if (useCaseToQueryResults.begin()->first == USE_CASE_VIDEO && - sensorMode == SENSOR_MODE_UNKNOWN) { + if (useCaseToQueryResults.begin()->first == USE_CASE_VIDEO) { camera_resolution_t resultReso; getRawInputSize((useCaseToQueryResults.begin()->second)[0], &resultReso); for (size_t idx = 0; idx < (useCaseToQueryResults.begin()->second).size(); idx++) { @@ -667,13 +640,7 @@ status_t GraphConfigImpl::selectSetting( status_t GraphConfigImpl::getGraphConfigData(IGraphType::GraphConfigData* data) { // The graph id, csi output and sensor mode must be same if there are two graph config pipes - LOG1("Query graphs, count %lu, 1st graph id %d", mGraphConfigPipe.size(), - mGraphConfigPipe.begin()->second->getGraphId()); - for (auto& item : mGraphConfigPipe) { - LOG1(" Graph usage %d, graph id %d", item.first, item.second->getGraphId()); - data->graphIds.insert(item.second->getGraphId()); - } - + data->graphId = mGraphConfigPipe.begin()->second->getGraphId(); mGraphConfigPipe.begin()->second->getCSIOutputResolution(&(data->csiReso)); // DOL_FEATURE_S mGraphConfigPipe.begin()->second->getDolInfo(&(data->dolInfo.conversionGain), diff --git a/modules/algowrapper/graph/GraphConfigImpl.h b/modules/algowrapper/graph/GraphConfigImpl.h index b63eb63c..eb202717 100644 --- a/modules/algowrapper/graph/GraphConfigImpl.h +++ b/modules/algowrapper/graph/GraphConfigImpl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation + * Copyright (C) 2015-2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -99,10 +99,7 @@ class GraphConfigImpl { // These public methods called by GraphConfig bool queryGraphSettings(const std::vector& activeStreams); - void reorderQueryResults(std::map>& queryResults, - SensorMode sensorMode); - status_t configStreams(const std::vector& activeStreams, bool dummyStillSink, - SensorMode sensorMode); + status_t configStreams(const std::vector& activeStreams, bool dummyStillSink); status_t getGraphConfigData(IGraphType::GraphConfigData* data); status_t getPgIdForKernel(const uint32_t streamId, const int32_t kernelId, int32_t* pgId); diff --git a/modules/algowrapper/graph/GraphConfigPipe.cpp b/modules/algowrapper/graph/GraphConfigPipe.cpp index 2f0e466a..4ec2e03a 100644 --- a/modules/algowrapper/graph/GraphConfigPipe.cpp +++ b/modules/algowrapper/graph/GraphConfigPipe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2023 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1322,7 +1322,7 @@ status_t GraphConfigPipe::portGetFormat(Node* port, IGraphType::PortFormatSettin status_t status = GCSS::GraphCameraUtil::portGetFourCCInfo(tmpNode, stageId, format->terminalId); - CheckAndLogError(status != OK, INVALID_OPERATION, "%s, Could not get port uid", __func__); + CheckAndLogError(status != OK, INVALID_OPERATION, "Could not get port uid", __func__); // if disabled there is no need to query the format if (format->enabled == 0) { @@ -1339,19 +1339,19 @@ status_t GraphConfigPipe::portGetFormat(Node* port, IGraphType::PortFormatSettin * it means that we need to ask the format from the peer. */ status = portGetPeer(port, &peerNode); - CheckAndLogError(status != OK, BAD_VALUE, "%s, Could not find peer port", __func__); + CheckAndLogError(status != OK, BAD_VALUE, "Could not find peer port", __func__); tmpNode = peerNode; ret = tmpNode->getValue(GCSS_KEY_WIDTH, format->width); - CheckAndLogError(ret != css_err_none, BAD_VALUE, "%s, Could not find port width", __func__); + CheckAndLogError(ret != css_err_none, BAD_VALUE, "Could not find port width", __func__); } ret = tmpNode->getValue(GCSS_KEY_HEIGHT, format->height); - CheckAndLogError(ret != css_err_none, BAD_VALUE, "%s, Could not find port height", __func__); + CheckAndLogError(ret != css_err_none, BAD_VALUE, "Could not find port height", __func__); string fourccFormat; ret = tmpNode->getValue(GCSS_KEY_FORMAT, fourccFormat); - CheckAndLogError(ret != css_err_none, BAD_VALUE, "%s, Could not find port fourcc", __func__); + CheckAndLogError(ret != css_err_none, BAD_VALUE, "Could not find port fourcc", __func__); const char* pFormat = fourccFormat.c_str(); format->fourcc = CameraUtils::string2IaFourccCode(pFormat); diff --git a/modules/ia_cipr/src/Context.cpp b/modules/ia_cipr/src/Context.cpp index fb223a67..1896491c 100644 --- a/modules/ia_cipr/src/Context.cpp +++ b/modules/ia_cipr/src/Context.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2023 Intel Corporation. + * Copyright (C) 2020-2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -229,9 +229,8 @@ Result Context::registerBuffer(MemoryDesc* mem) { mem->sysBuff = ioc_buffer; mem->flags |= MemoryFlag::Migrated; - LOG2("registered buffer:%p -> fd:%d len:%lu offset:%u bytes_used:%u, flags:%x", mem->cpuPtr, - ioc_buffer->base.fd, ioc_buffer->len, ioc_buffer->data_offset, ioc_buffer->bytes_used, - ioc_buffer->flags); + LOG2("registered buffer:%p -> fd:%d len:%lu offset:%u bytes_used:%u", mem->cpuPtr, + ioc_buffer->base.fd, ioc_buffer->len, ioc_buffer->data_offset, ioc_buffer->bytes_used); return res; } diff --git a/modules/ia_css/ipu6/include/assert_support.h b/modules/ia_css/ipu6/include/assert_support.h index 947fc5f0..b7d5bdc1 100644 --- a/modules/ia_css/ipu6/include/assert_support.h +++ b/modules/ia_css/ipu6/include/assert_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/cpu_mem_support.h b/modules/ia_css/ipu6/include/cpu_mem_support.h index d0f1b0f1..802436de 100644 --- a/modules/ia_css/ipu6/include/cpu_mem_support.h +++ b/modules/ia_css/ipu6/include/cpu_mem_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/error_support.h b/modules/ia_css/ipu6/include/error_support.h index 4d43f296..a402a4be 100644 --- a/modules/ia_css/ipu6/include/error_support.h +++ b/modules/ia_css/ipu6/include/error_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/frame_support.h b/modules/ia_css/ipu6/include/frame_support.h index 5243a860..bdde4270 100644 --- a/modules/ia_css/ipu6/include/frame_support.h +++ b/modules/ia_css/ipu6/include/frame_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_base_types.h b/modules/ia_css/ipu6/include/ia_css_base_types.h index 3883e8f1..e5ad986c 100644 --- a/modules/ia_css/ipu6/include/ia_css_base_types.h +++ b/modules/ia_css/ipu6/include/ia_css_base_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs.h b/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs.h index 689c8995..69c96052 100644 --- a/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs.h +++ b/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs_dep.h b/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs_dep.h index 106409e6..339e695f 100644 --- a/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs_dep.h +++ b/modules/ia_css/ipu6/include/ia_css_isa_parameter_defs_dep.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_kernel_bitmap.h b/modules/ia_css/ipu6/include/ia_css_kernel_bitmap.h index 4881fdd5..f0499256 100644 --- a/modules/ia_css/ipu6/include/ia_css_kernel_bitmap.h +++ b/modules/ia_css/ipu6/include/ia_css_kernel_bitmap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_kernel_bitmap_impl.h b/modules/ia_css/ipu6/include/ia_css_kernel_bitmap_impl.h index 5b1974b7..beaedc9e 100644 --- a/modules/ia_css/ipu6/include/ia_css_kernel_bitmap_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_kernel_bitmap_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_kernel_user_param_types.h b/modules/ia_css/ipu6/include/ia_css_kernel_user_param_types.h index c4c0ef52..cd6223b5 100644 --- a/modules/ia_css/ipu6/include/ia_css_kernel_user_param_types.h +++ b/modules/ia_css/ipu6/include/ia_css_kernel_user_param_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_program_group_data.h b/modules/ia_css/ipu6/include/ia_css_program_group_data.h index e3be7548..fa014dba 100644 --- a/modules/ia_css/ipu6/include/ia_css_program_group_data.h +++ b/modules/ia_css/ipu6/include/ia_css_program_group_data.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_program_group_data_defs.h b/modules/ia_css/ipu6/include/ia_css_program_group_data_defs.h index aaad08e9..39a4970a 100644 --- a/modules/ia_css/ipu6/include/ia_css_program_group_data_defs.h +++ b/modules/ia_css/ipu6/include/ia_css_program_group_data_defs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_program_group_data_impl.h b/modules/ia_css/ipu6/include/ia_css_program_group_data_impl.h index 91e54f12..84f1be04 100644 --- a/modules/ia_css/ipu6/include/ia_css_program_group_data_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_program_group_data_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_program_group_param.h b/modules/ia_css/ipu6/include/ia_css_program_group_param.h index d45c769a..e95e1f76 100644 --- a/modules/ia_css/ipu6/include/ia_css_program_group_param.h +++ b/modules/ia_css/ipu6/include/ia_css_program_group_param.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_program_group_param.sim.h b/modules/ia_css/ipu6/include/ia_css_program_group_param.sim.h index ffe3faa0..4e0f8265 100644 --- a/modules/ia_css/ipu6/include/ia_css_program_group_param.sim.h +++ b/modules/ia_css/ipu6/include/ia_css_program_group_param.sim.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_program_group_param_private.h b/modules/ia_css/ipu6/include/ia_css_program_group_param_private.h index 3e13c71c..cfc4fa73 100644 --- a/modules/ia_css/ipu6/include/ia_css_program_group_param_private.h +++ b/modules/ia_css/ipu6/include/ia_css_program_group_param_private.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_program_group_param_types.h b/modules/ia_css/ipu6/include/ia_css_program_group_param_types.h index 26755f44..2e404c40 100644 --- a/modules/ia_css/ipu6/include/ia_css_program_group_param_types.h +++ b/modules/ia_css/ipu6/include/ia_css_program_group_param_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_buffer_set.h b/modules/ia_css/ipu6/include/ia_css_psys_buffer_set.h index c7b208e7..40b4c341 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_buffer_set.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_buffer_set.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_data_trace.h b/modules/ia_css/ipu6/include/ia_css_psys_data_trace.h index 5e20f3ae..c2f35fbb 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_data_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_data_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_dynamic_trace.h b/modules/ia_css/ipu6/include/ia_css_psys_dynamic_trace.h index c8179c51..e79c9469 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_dynamic_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_dynamic_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_kernel_trace.h b/modules/ia_css/ipu6/include/ia_css_psys_kernel_trace.h index 07ff8446..9c0e6488 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_kernel_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_kernel_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_manifest_types.h b/modules/ia_css/ipu6/include/ia_css_psys_manifest_types.h index baebf5ec..3c5ee11d 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_manifest_types.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_manifest_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_param_trace.h b/modules/ia_css/ipu6/include/ia_css_psys_param_trace.h index 87110165..36939b1d 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_param_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_param_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_private_pg_data.h b/modules/ia_css/ipu6/include/ia_css_psys_private_pg_data.h index 29ceb655..a2d4aebd 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_private_pg_data.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_private_pg_data.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process.h b/modules/ia_css/ipu6/include/ia_css_psys_process.h index 6e57cef6..480c70f4 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.kernel.h b/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.kernel.h index 02a66ee5..05b6f1f8 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.kernel.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.kernel.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.user.h b/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.user.h index ccddfd6c..881f6f08 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.user.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process.hsys.user.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process.psys.h b/modules/ia_css/ipu6/include/ia_css_psys_process.psys.h index 212331bc..28b08140 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process.psys.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process.psys.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_group.h b/modules/ia_css/ipu6/include/ia_css_psys_process_group.h index c35bb30f..17a5a008 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_group.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_group.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.kernel.h b/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.kernel.h index 5c300322..73167fa2 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.kernel.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.kernel.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.user.h b/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.user.h index f25c0a30..3dc6f61b 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.user.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_group.hsys.user.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_group.psys.h b/modules/ia_css/ipu6/include/ia_css_psys_process_group.psys.h index de2e4dd9..e42eadf7 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_group.psys.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_group.psys.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_group_cmd_impl.h b/modules/ia_css/ipu6/include/ia_css_psys_process_group_cmd_impl.h index 2e60e001..ff9a70e7 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_group_cmd_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_group_cmd_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_group_impl.h b/modules/ia_css/ipu6/include/ia_css_psys_process_group_impl.h index 38e36c64..c3d704ce 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_group_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_group_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -535,7 +535,6 @@ int ia_css_process_group_print( ia_css_rbm_t routing_bitmap; NOT_USED(fid); - NOT_USED(routing_bitmap); IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, VERBOSE, "ia_css_process_group_print(): enter:\n"); @@ -692,7 +691,6 @@ bool ia_css_can_process_group_submit( int retval = -1; uint8_t terminal_count = ia_css_process_group_get_terminal_count(process_group); - NOT_USED(retval); IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, INFO, "ia_css_can_process_group_submit(): enter:\n"); @@ -703,7 +701,6 @@ bool ia_css_can_process_group_submit( ia_css_terminal_t *terminal = ia_css_process_group_get_terminal(process_group, i); vied_vaddress_t buffer; - NOT_USED(buffer); ia_css_buffer_state_t buffer_state; verifexitval(terminal != NULL, EINVAL); @@ -776,7 +773,6 @@ bool ia_css_can_enqueue_buffer_set( bool can_enqueue = false; int retval = -1; uint8_t terminal_count; - NOT_USED(retval); IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, INFO, "ia_css_can_enqueue_buffer_set(): enter:\n"); @@ -800,7 +796,6 @@ bool ia_css_can_enqueue_buffer_set( ia_css_process_group_get_terminal(process_group, i); vied_vaddress_t buffer; ia_css_buffer_state_t buffer_state; - NOT_USED(buffer); verifexitval(terminal != NULL, EINVAL); @@ -860,7 +855,6 @@ bool ia_css_can_process_group_start( bool can_start = false; int retval = -1; uint8_t terminal_count; - NOT_USED(retval); IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, INFO, "ia_css_can_process_group_start(): enter:\n"); diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_impl.h b/modules/ia_css/ipu6/include/ia_css_psys_process_impl.h index 55c0c19f..0c835f7f 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_private_types.h b/modules/ia_css/ipu6/include/ia_css_psys_process_private_types.h index d7804fe4..85ae3ea8 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_private_types.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_private_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_process_types.h b/modules/ia_css/ipu6/include/ia_css_psys_process_types.h index 9c7a9dc8..e83b760d 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_process_types.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_process_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.h b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.h index afac8563..88740a99 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.hsys.user.h b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.hsys.user.h index 093f7f0e..c85ccc66 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.hsys.user.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.hsys.user.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.sim.h b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.sim.h index 1ed3f796..74511440 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.sim.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest.sim.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest_impl.h b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest_impl.h index 5ffec7e6..0403700a 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_group_manifest_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_group_private.h b/modules/ia_css/ipu6/include/ia_css_psys_program_group_private.h index 4424050f..61f3023f 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_group_private.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_group_private.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.h b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.h index 99b6d9ab..7fa8e791 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.kernel.h b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.kernel.h index 6708a653..93fb1392 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.kernel.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.kernel.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.user.h b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.user.h index aa2bb79e..cc9b13bd 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.user.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.hsys.user.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.sim.h b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.sim.h index 2843b62c..34d742dc 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.sim.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest.sim.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest_impl.h b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest_impl.h index 1e84f22a..04803a38 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_program_manifest_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_program_manifest_impl.h @@ -1,26 +1,18 @@ /* -* INTEL CONFIDENTIAL -* -* Copyright (C) 2018 - 2019 Intel Corporation. -* All Rights Reserved. -* -* The source code contained or described herein and all documents -* related to the source code ("Material") are owned by Intel Corporation -* or licensors. Title to the Material remains with Intel -* Corporation or its licensors. The Material contains trade -* secrets and proprietary and confidential information of Intel or its -* licensors. The Material is protected by worldwide copyright -* and trade secret laws and treaty provisions. No part of the Material may -* be used, copied, reproduced, modified, published, uploaded, posted, -* transmitted, distributed, or disclosed in any way without Intel's prior -* express written permission. -* -* No License under any patent, copyright, trade secret or other intellectual -* property right is granted to or conferred upon you by disclosure or -* delivery of the Materials, either expressly, by implication, inducement, -* estoppel or otherwise. Any license under such intellectual property rights -* must be express and approved by Intel in writing. -*/ + * Copyright (C) 2020 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef __IA_CSS_PSYS_PROGRAM_MANIFEST_IMPL_H #define __IA_CSS_PSYS_PROGRAM_MANIFEST_IMPL_H @@ -43,543 +35,543 @@ IA_CSS_PSYS_STATIC_STORAGE_CLASS_C ia_css_program_manifest_ext_t *ia_css_program_manifest_get_extension(const ia_css_program_manifest_t *program) { - DECLARE_ERRVAL - verifexitval(program != NULL, EFAULT); - if (program->program_extension_offset != 0) { - return (ia_css_program_manifest_ext_t *)((uint8_t *)program + program->program_extension_offset); - } + DECLARE_ERRVAL + verifexitval(program != NULL, EFAULT); + if (program->program_extension_offset != 0) { + return (ia_css_program_manifest_ext_t *)((uint8_t *)program + program->program_extension_offset); + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_extension invalid argument\n"); - } - return NULL; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_extension invalid argument\n"); + } + return NULL; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_resource_size_t ia_css_program_manifest_get_int_mem_size( - const ia_css_program_manifest_t *manifest, - const vied_nci_mem_type_ID_t mem_type_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_mem_type_ID_t mem_type_id) { - (void)manifest; - (void)mem_type_id; - IA_CSS_TRACE_0(PSYSAPI_STATIC, INFO, - "ia_css_program_manifest_get_int_mem_size always returns 0" - "(internally memory feature not used).\n"); - return 0; + (void)manifest; + (void)mem_type_id; + IA_CSS_TRACE_0(PSYSAPI_STATIC, INFO, + "ia_css_program_manifest_get_int_mem_size always returns 0" + "(internally memory feature not used).\n"); + return 0; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_input_terminal_id( - ia_css_program_manifest_t *manifest, - unsigned char idx) + ia_css_program_manifest_t *manifest, + unsigned char idx) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_input_stream_id(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(idx < IA_CSS_MAX_INPUT_DEC_RESOURCES, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_input_stream_id(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(idx < IA_CSS_MAX_INPUT_DEC_RESOURCES, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } EXIT: - if (!noerror()) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + if (!noerror()) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } #if IA_CSS_MAX_INPUT_DEC_RESOURCES > 0 - return manifest_ext->dec_resources_input_terminal[idx]; + return manifest_ext->dec_resources_input_terminal[idx]; #else - (void) idx; - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + (void) idx; + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; #endif } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_output_terminal_id( - ia_css_program_manifest_t *manifest, - unsigned char idx) + ia_css_program_manifest_t *manifest, + unsigned char idx) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_output_terminal_id(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(idx < IA_CSS_MAX_OUTPUT_DEC_RESOURCES, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_output_terminal_id(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(idx < IA_CSS_MAX_OUTPUT_DEC_RESOURCES, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } EXIT: - if (!noerror()) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + if (!noerror()) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } #if IA_CSS_MAX_OUTPUT_DEC_RESOURCES > 0 - return manifest_ext->dec_resources_output_terminal[idx]; + return manifest_ext->dec_resources_output_terminal[idx]; #else - (void) idx; - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + (void) idx; + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; #endif } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_input_stream_id( - ia_css_program_manifest_t *manifest, - unsigned char idx) + ia_css_program_manifest_t *manifest, + unsigned char idx) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_input_stream_id(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(idx < IA_CSS_MAX_INPUT_DEC_RESOURCES, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_input_stream_id(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(idx < IA_CSS_MAX_INPUT_DEC_RESOURCES, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } EXIT: - if (!noerror()) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + if (!noerror()) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } #if IA_CSS_MAX_INPUT_DEC_RESOURCES > 0 - return manifest_ext->dec_resources_input[idx]; + return manifest_ext->dec_resources_input[idx]; #else - (void) idx; - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + (void) idx; + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; #endif } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_output_stream_id( - ia_css_program_manifest_t *manifest, - unsigned char idx) + ia_css_program_manifest_t *manifest, + unsigned char idx) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_output_stream_id(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(idx < IA_CSS_MAX_OUTPUT_DEC_RESOURCES, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_output_stream_id(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(idx < IA_CSS_MAX_OUTPUT_DEC_RESOURCES, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } EXIT: - if (!noerror()) { - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; - } + if (!noerror()) { + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + } #if IA_CSS_MAX_OUTPUT_DEC_RESOURCES > 0 - return manifest_ext->dec_resources_output[idx]; + return manifest_ext->dec_resources_output[idx]; #else - (void) idx; - return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; + (void) idx; + return IA_CSS_PROGRAM_INVALID_DEC_CONFIG; #endif } #if HAS_DFM IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_is_dfm_relocatable( - const ia_css_program_manifest_t *manifest, - const vied_nci_dev_dfm_id_t dfm_type_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_dev_dfm_id_t dfm_type_id) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_is_dfm_relocatable(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(dfm_type_id < VIED_NCI_N_DEV_DFM_ID, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return 0; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_is_dfm_relocatable(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(dfm_type_id < VIED_NCI_N_DEV_DFM_ID, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return 0; + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_is_dfm_relocatable invalid argument\n"); - return 0; - } - return manifest_ext->is_dfm_relocatable[dfm_type_id]; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_is_dfm_relocatable invalid argument\n"); + return 0; + } + return manifest_ext->is_dfm_relocatable[dfm_type_id]; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_resource_bitmap_t ia_css_program_manifest_get_dfm_port_bitmap( - const ia_css_program_manifest_t *manifest, - const vied_nci_dev_dfm_id_t dfm_type_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_dev_dfm_id_t dfm_type_id) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_dfm_port_bitmap(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(dfm_type_id < VIED_NCI_N_DEV_DFM_ID, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return 0; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_dfm_port_bitmap(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(dfm_type_id < VIED_NCI_N_DEV_DFM_ID, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return 0; + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_dfm_port_bitmap invalid argument\n"); - return 0; - } - return manifest_ext->dfm_port_bitmap[dfm_type_id]; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_dfm_port_bitmap invalid argument\n"); + return 0; + } + return manifest_ext->dfm_port_bitmap[dfm_type_id]; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_resource_bitmap_t ia_css_program_manifest_get_dfm_active_port_bitmap( - const ia_css_program_manifest_t *manifest, - const vied_nci_dev_dfm_id_t dfm_type_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_dev_dfm_id_t dfm_type_id) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_dfm_active_port_bitmap(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(dfm_type_id < VIED_NCI_N_DEV_DFM_ID, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return 0; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_dfm_active_port_bitmap(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(dfm_type_id < VIED_NCI_N_DEV_DFM_ID, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return 0; + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_dfm_active_port_bitmap invalid argument\n"); - return 0; - } - return manifest_ext->dfm_active_port_bitmap[dfm_type_id]; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_dfm_active_port_bitmap invalid argument\n"); + return 0; + } + return manifest_ext->dfm_active_port_bitmap[dfm_type_id]; } #endif /* HAS_DFM */ IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_resource_size_t ia_css_program_manifest_get_ext_mem_size( - const ia_css_program_manifest_t *manifest, - const vied_nci_mem_type_ID_t mem_type_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_mem_type_ID_t mem_type_id) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_ext_mem_size(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(mem_type_id < VIED_NCI_N_DATA_MEM_TYPE_ID, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return 0; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_ext_mem_size(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(mem_type_id < VIED_NCI_N_DATA_MEM_TYPE_ID, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return 0; + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_ext_mem_size invalid argument\n"); - return 0; - } - return manifest_ext->ext_mem_size[mem_type_id]; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_ext_mem_size invalid argument\n"); + return 0; + } + return manifest_ext->ext_mem_size[mem_type_id]; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_resource_size_t ia_css_program_manifest_get_ext_mem_offset( - const ia_css_program_manifest_t *manifest, - const vied_nci_mem_type_ID_t mem_type_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_mem_type_ID_t mem_type_id) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_ext_mem_offset(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(mem_type_id < VIED_NCI_N_DATA_MEM_TYPE_ID, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return 0; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_ext_mem_offset(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(mem_type_id < VIED_NCI_N_DATA_MEM_TYPE_ID, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return 0; + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_ext_mem_offset invalid argument\n"); - return 0; - } - return manifest_ext->ext_mem_offset[mem_type_id]; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_ext_mem_offset invalid argument\n"); + return 0; + } + return manifest_ext->ext_mem_offset[mem_type_id]; } #if HAS_DFM IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_resource_size_t ia_css_program_manifest_get_dev_chn_size( - const ia_css_program_manifest_t *manifest, - const vied_nci_dev_chn_ID_t dev_chn_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_dev_chn_ID_t dev_chn_id) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_dev_chn_size(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(dev_chn_id < VIED_NCI_N_DEV_CHN_ID, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return 0; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_dev_chn_size(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(dev_chn_id < VIED_NCI_N_DEV_CHN_ID, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return 0; + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_dev_chn_size invalid argument\n"); - return 0; - } - return manifest_ext->dev_chn_size[dev_chn_id]; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_dev_chn_size invalid argument\n"); + return 0; + } + return manifest_ext->dev_chn_size[dev_chn_id]; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_resource_size_t ia_css_program_manifest_get_dev_chn_offset( - const ia_css_program_manifest_t *manifest, - const vied_nci_dev_chn_ID_t dev_chn_id) + const ia_css_program_manifest_t *manifest, + const vied_nci_dev_chn_ID_t dev_chn_id) { - DECLARE_ERRVAL - ia_css_program_manifest_ext_t *manifest_ext = NULL; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_dev_chn_offset(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - verifexitval(dev_chn_id < VIED_NCI_N_DEV_CHN_ID, EFAULT); - manifest_ext = ia_css_program_manifest_get_extension(manifest); - if (manifest_ext == NULL) { - return 0; - } + DECLARE_ERRVAL + ia_css_program_manifest_ext_t *manifest_ext = NULL; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_dev_chn_offset(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + verifexitval(dev_chn_id < VIED_NCI_N_DEV_CHN_ID, EFAULT); + manifest_ext = ia_css_program_manifest_get_extension(manifest); + if (manifest_ext == NULL) { + return 0; + } EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_dev_chn_offset invalid argument\n"); - return 0; - } - return manifest_ext->dev_chn_offset[dev_chn_id]; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_dev_chn_offset invalid argument\n"); + return 0; + } + return manifest_ext->dev_chn_offset[dev_chn_id]; } #endif /* HAS_DFM */ IA_CSS_PSYS_STATIC_STORAGE_CLASS_C size_t ia_css_program_manifest_get_size( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL + DECLARE_ERRVAL - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_size(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_size(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_size invalid argument\n"); - return 0; - } + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_size invalid argument\n"); + return 0; + } - return manifest->size; + return manifest->size; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C ia_css_program_ID_t ia_css_program_manifest_get_program_ID( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL + DECLARE_ERRVAL - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_program_ID(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_program_ID(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_program_ID invalid argument\n"); - return IA_CSS_PROGRAM_INVALID_ID; - } - return manifest->ID; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_program_ID invalid argument\n"); + return IA_CSS_PROGRAM_INVALID_ID; + } + return manifest->ID; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C ia_css_program_group_manifest_t *ia_css_program_manifest_get_parent( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL - char *base = NULL; + DECLARE_ERRVAL + char *base = NULL; - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_parent(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_parent(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); - base = (char *)((char *)manifest + manifest->parent_offset); + base = (char *)((char *)manifest + manifest->parent_offset); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_parent invalid argument\n"); - return NULL; - } - return (ia_css_program_group_manifest_t *)(base); + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_parent invalid argument\n"); + return NULL; + } + return (ia_css_program_group_manifest_t *)(base); } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C vied_nci_cell_type_ID_t ia_css_program_manifest_get_cell_type_ID( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL + DECLARE_ERRVAL - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_cell_type_ID(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_cell_type_ID(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_cell_type_ID invalid argument\n"); - return VIED_NCI_N_CELL_TYPE_ID; - } - return manifest->cell_type_id; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_cell_type_ID invalid argument\n"); + return VIED_NCI_N_CELL_TYPE_ID; + } + return manifest->cell_type_id; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C ia_css_program_type_t ia_css_program_manifest_get_type( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL + DECLARE_ERRVAL - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_type(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_type(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_type invalid argument\n"); - return IA_CSS_N_PROGRAM_TYPES; - } - return manifest->program_type; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_type invalid argument\n"); + return IA_CSS_N_PROGRAM_TYPES; + } + return manifest->program_type; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_terminal_dependency_count( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL + DECLARE_ERRVAL - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_terminal_dependency_count(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_terminal_dependency_count(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_terminal_dependency_count invalid argument\n"); - return 0; - } - return manifest->terminal_dependency_count; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_terminal_dependency_count invalid argument\n"); + return 0; + } + return manifest->terminal_dependency_count; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_terminal_dependency( - const ia_css_program_manifest_t *manifest, - const unsigned int index) + const ia_css_program_manifest_t *manifest, + const unsigned int index) { - DECLARE_ERRVAL - uint8_t *terminal_dep_ptr = NULL; - uint8_t terminal_dependency_count; - - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_terminal_dependency(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); - terminal_dependency_count = - ia_css_program_manifest_get_terminal_dependency_count(manifest); - verifexitval(index < terminal_dependency_count, EFAULT); - - terminal_dep_ptr = (uint8_t *)((uint8_t *)manifest + - manifest->terminal_dependency_offset + index); + DECLARE_ERRVAL + uint8_t *terminal_dep_ptr = NULL; + uint8_t terminal_dependency_count; + + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_terminal_dependency(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); + terminal_dependency_count = + ia_css_program_manifest_get_terminal_dependency_count(manifest); + verifexitval(index < terminal_dependency_count, EFAULT); + + terminal_dep_ptr = (uint8_t *)((uint8_t *)manifest + + manifest->terminal_dependency_offset + index); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_terminal_dependency invalid argument\n"); - return IA_CSS_PROGRAM_INVALID_DEPENDENCY; - } - return *terminal_dep_ptr; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_terminal_dependency invalid argument\n"); + return IA_CSS_PROGRAM_INVALID_DEPENDENCY; + } + return *terminal_dep_ptr; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C bool ia_css_is_program_manifest_singular_program_type( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - ia_css_program_type_t program_type; + ia_css_program_type_t program_type; - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_is_program_manifest_singular_program_type(): enter:\n"); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_is_program_manifest_singular_program_type(): enter:\n"); - program_type = ia_css_program_manifest_get_type(manifest); + program_type = ia_css_program_manifest_get_type(manifest); /* The error return is the limit value, so no need to check on the manifest * pointer */ - return (program_type == IA_CSS_PROGRAM_TYPE_SINGULAR); + return (program_type == IA_CSS_PROGRAM_TYPE_SINGULAR); } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_program_dependency_count( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL + DECLARE_ERRVAL - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_program_dependency_count(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_program_dependency_count(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_program_dependency_count invalid argument\n"); - return 0; - } - return manifest->program_dependency_count; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_program_dependency_count invalid argument\n"); + return 0; + } + return manifest->program_dependency_count; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C uint8_t ia_css_program_manifest_get_program_dependency( - const ia_css_program_manifest_t *manifest, - const unsigned int index) + const ia_css_program_manifest_t *manifest, + const unsigned int index) { - DECLARE_ERRVAL - uint8_t *program_dep_ptr = NULL; - uint8_t program_dependency_count; + DECLARE_ERRVAL + uint8_t *program_dep_ptr = NULL; + uint8_t program_dependency_count; - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_program_dependency(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_program_dependency(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); - program_dependency_count = - ia_css_program_manifest_get_program_dependency_count(manifest); + program_dependency_count = + ia_css_program_manifest_get_program_dependency_count(manifest); - verifexitval(index < program_dependency_count, EFAULT); - program_dep_ptr = (uint8_t *)((uint8_t *)manifest + - manifest->program_dependency_offset + - index * sizeof(uint8_t)); + verifexitval(index < program_dependency_count, EFAULT); + program_dep_ptr = (uint8_t *)((uint8_t *)manifest + + manifest->program_dependency_offset + + index * sizeof(uint8_t)); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_program_dependency invalid argument\n"); - return IA_CSS_PROGRAM_INVALID_DEPENDENCY; - } - return *program_dep_ptr; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_program_dependency invalid argument\n"); + return IA_CSS_PROGRAM_INVALID_DEPENDENCY; + } + return *program_dep_ptr; } IA_CSS_PSYS_STATIC_STORAGE_CLASS_C ia_css_kernel_bitmap_t ia_css_program_manifest_get_kernel_bitmap( - const ia_css_program_manifest_t *manifest) + const ia_css_program_manifest_t *manifest) { - DECLARE_ERRVAL + DECLARE_ERRVAL - IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, - "ia_css_program_manifest_get_kernel_bitmap(): enter:\n"); - verifexitval(manifest != NULL, EFAULT); + IA_CSS_TRACE_0(PSYSAPI_STATIC, VERBOSE, + "ia_css_program_manifest_get_kernel_bitmap(): enter:\n"); + verifexitval(manifest != NULL, EFAULT); EXIT: - if (!noerror()) { - IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, - "ia_css_program_manifest_get_kernel_bitmap invalid argument\n"); - return ia_css_kernel_bitmap_clear(); - } - return manifest->kernel_bitmap; + if (!noerror()) { + IA_CSS_TRACE_0(PSYSAPI_STATIC, WARNING, + "ia_css_program_manifest_get_kernel_bitmap invalid argument\n"); + return ia_css_kernel_bitmap_clear(); + } + return manifest->kernel_bitmap; } #endif /* __IA_CSS_PSYS_PROGRAM_MANIFEST_IMPL_H */ diff --git a/modules/ia_css/ipu6/include/ia_css_psys_sim_trace.h b/modules/ia_css/ipu6/include/ia_css_psys_sim_trace.h index 75f07d5c..af2a4345 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_sim_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_sim_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_static_trace.h b/modules/ia_css/ipu6/include/ia_css_psys_static_trace.h index 5f0f5a30..8b7a833f 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_static_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_static_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal.h index 1794009a..e960bb9a 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal.hsys.user.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal.hsys.user.h index 7970906e..c18d3fea 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal.hsys.user.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal.hsys.user.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal_impl.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal_impl.h index 9b044fc9..cd944eee 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.h index 5a0ee23c..2bb95044 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.hsys.user.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.hsys.user.h index 7bc46b3d..387afe1b 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.hsys.user.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.hsys.user.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.sim.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.sim.h index a38336b2..a981a34c 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.sim.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest.sim.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest_impl.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest_impl.h index e7d54ffc..ee198361 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal_manifest_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_terminal_private_types.h b/modules/ia_css/ipu6/include/ia_css_psys_terminal_private_types.h index def3bdbf..547d2f68 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_terminal_private_types.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_terminal_private_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_transport.h b/modules/ia_css/ipu6/include/ia_css_psys_transport.h index cfba5b0c..708486f1 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_transport.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_transport.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psys_transport_dep.h b/modules/ia_css/ipu6/include/ia_css_psys_transport_dep.h index ffd88ead..8d51d9fe 100644 --- a/modules/ia_css/ipu6/include/ia_css_psys_transport_dep.h +++ b/modules/ia_css/ipu6/include/ia_css_psys_transport_dep.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psysapi_fw_version.h b/modules/ia_css/ipu6/include/ia_css_psysapi_fw_version.h index 724870d8..c59192b8 100644 --- a/modules/ia_css/ipu6/include/ia_css_psysapi_fw_version.h +++ b/modules/ia_css/ipu6/include/ia_css_psysapi_fw_version.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_psysapi_trace.h b/modules/ia_css/ipu6/include/ia_css_psysapi_trace.h index 4ac6cc01..e4d4f091 100644 --- a/modules/ia_css/ipu6/include/ia_css_psysapi_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_psysapi_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_rbm.h b/modules/ia_css/ipu6/include/ia_css_rbm.h index 915407e0..d724acc6 100644 --- a/modules/ia_css/ipu6/include/ia_css_rbm.h +++ b/modules/ia_css/ipu6/include/ia_css_rbm.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_rbm_impl.h b/modules/ia_css/ipu6/include/ia_css_rbm_impl.h index aaa095ab..673d2368 100644 --- a/modules/ia_css/ipu6/include/ia_css_rbm_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_rbm_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_rbm_manifest.h b/modules/ia_css/ipu6/include/ia_css_rbm_manifest.h index 76568c39..bde63724 100644 --- a/modules/ia_css/ipu6/include/ia_css_rbm_manifest.h +++ b/modules/ia_css/ipu6/include/ia_css_rbm_manifest.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_rbm_manifest_types.h b/modules/ia_css/ipu6/include/ia_css_rbm_manifest_types.h index 35bbf36e..8e1d9153 100644 --- a/modules/ia_css/ipu6/include/ia_css_rbm_manifest_types.h +++ b/modules/ia_css/ipu6/include/ia_css_rbm_manifest_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_rbm_trace.h b/modules/ia_css/ipu6/include/ia_css_rbm_trace.h index 3f45f1cd..9b538305 100644 --- a/modules/ia_css/ipu6/include/ia_css_rbm_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_rbm_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal.h b/modules/ia_css/ipu6/include/ia_css_terminal.h index ac53e25e..2bbaf46d 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_base_types.h b/modules/ia_css/ipu6/include/ia_css_terminal_base_types.h index e2d60553..a8fe8d1b 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_base_types.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_base_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_defs.h b/modules/ia_css/ipu6/include/ia_css_terminal_defs.h index 7e235086..3de05b68 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_defs.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_defs.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_impl.h b/modules/ia_css/ipu6/include/ia_css_terminal_impl.h index b7e79b9c..0f040da0 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_manifest.h b/modules/ia_css/ipu6/include/ia_css_terminal_manifest.h index 1dc90554..15437e09 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_manifest.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_manifest.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_manifest_base_types.h b/modules/ia_css/ipu6/include/ia_css_terminal_manifest_base_types.h index 63d91c3b..bac5b767 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_manifest_base_types.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_manifest_base_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_manifest_impl.h b/modules/ia_css/ipu6/include/ia_css_terminal_manifest_impl.h index a44fe0ef..105d6c0f 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_manifest_impl.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_manifest_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_manifest_types.h b/modules/ia_css/ipu6/include/ia_css_terminal_manifest_types.h index c63c1752..d9c8e1b9 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_manifest_types.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_manifest_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_terminal_types.h b/modules/ia_css/ipu6/include/ia_css_terminal_types.h index ad611e94..b1e9618d 100644 --- a/modules/ia_css/ipu6/include/ia_css_terminal_types.h +++ b/modules/ia_css/ipu6/include/ia_css_terminal_types.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ia_css_trace.h b/modules/ia_css/ipu6/include/ia_css_trace.h index bd8212a9..14d79db6 100644 --- a/modules/ia_css/ipu6/include/ia_css_trace.h +++ b/modules/ia_css/ipu6/include/ia_css_trace.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ipu_device_acb_devices.h b/modules/ia_css/ipu6/include/ipu_device_acb_devices.h index d91dc04a..c29233e4 100644 --- a/modules/ia_css/ipu6/include/ipu_device_acb_devices.h +++ b/modules/ia_css/ipu6/include/ipu_device_acb_devices.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/ipu_device_gp_devices.h b/modules/ia_css/ipu6/include/ipu_device_gp_devices.h index 631646e1..3e678715 100644 --- a/modules/ia_css/ipu6/include/ipu_device_gp_devices.h +++ b/modules/ia_css/ipu6/include/ipu_device_gp_devices.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/math_support.h b/modules/ia_css/ipu6/include/math_support.h index 6682d4d0..1fa191c7 100644 --- a/modules/ia_css/ipu6/include/math_support.h +++ b/modules/ia_css/ipu6/include/math_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/misc_support.h b/modules/ia_css/ipu6/include/misc_support.h index 1265a37d..c2b6a517 100644 --- a/modules/ia_css/ipu6/include/misc_support.h +++ b/modules/ia_css/ipu6/include/misc_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/pg_control_init_framework.h b/modules/ia_css/ipu6/include/pg_control_init_framework.h index 8cd88b88..649eb2c3 100644 --- a/modules/ia_css/ipu6/include/pg_control_init_framework.h +++ b/modules/ia_css/ipu6/include/pg_control_init_framework.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/platform_support.h b/modules/ia_css/ipu6/include/platform_support.h index 058e71ec..1dffa4ba 100644 --- a/modules/ia_css/ipu6/include/platform_support.h +++ b/modules/ia_css/ipu6/include/platform_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/print_support.h b/modules/ia_css/ipu6/include/print_support.h index b48eecce..c0ea8765 100644 --- a/modules/ia_css/ipu6/include/print_support.h +++ b/modules/ia_css/ipu6/include/print_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/psys_system_global_impl.h b/modules/ia_css/ipu6/include/psys_system_global_impl.h index 75c62439..512b0f5d 100644 --- a/modules/ia_css/ipu6/include/psys_system_global_impl.h +++ b/modules/ia_css/ipu6/include/psys_system_global_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/type_support.h b/modules/ia_css/ipu6/include/type_support.h index 29539886..81b00539 100644 --- a/modules/ia_css/ipu6/include/type_support.h +++ b/modules/ia_css/ipu6/include/type_support.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/vied_nci_acb_route_type.h b/modules/ia_css/ipu6/include/vied_nci_acb_route_type.h index edbe8984..66d79fbc 100644 --- a/modules/ia_css/ipu6/include/vied_nci_acb_route_type.h +++ b/modules/ia_css/ipu6/include/vied_nci_acb_route_type.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/vied_nci_psys_resource_model.h b/modules/ia_css/ipu6/include/vied_nci_psys_resource_model.h index e6efb884..3f0359d0 100644 --- a/modules/ia_css/ipu6/include/vied_nci_psys_resource_model.h +++ b/modules/ia_css/ipu6/include/vied_nci_psys_resource_model.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/vied_nci_psys_resource_model_common.h b/modules/ia_css/ipu6/include/vied_nci_psys_resource_model_common.h index 40bf8964..bb90c2e1 100644 --- a/modules/ia_css/ipu6/include/vied_nci_psys_resource_model_common.h +++ b/modules/ia_css/ipu6/include/vied_nci_psys_resource_model_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/include/vied_nci_psys_system_global.h b/modules/ia_css/ipu6/include/vied_nci_psys_system_global.h index 76b511c2..2daf6b39 100644 --- a/modules/ia_css/ipu6/include/vied_nci_psys_system_global.h +++ b/modules/ia_css/ipu6/include/vied_nci_psys_system_global.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_kernel_bitmap.c b/modules/ia_css/ipu6/src/ia_css_kernel_bitmap.c index a7747032..11dd097e 100644 --- a/modules/ia_css/ipu6/src/ia_css_kernel_bitmap.c +++ b/modules/ia_css/ipu6/src/ia_css_kernel_bitmap.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_program_group_param.c b/modules/ia_css/ipu6/src/ia_css_program_group_param.c index 90883754..e6fa6e49 100644 --- a/modules/ia_css/ipu6/src/ia_css_program_group_param.c +++ b/modules/ia_css/ipu6/src/ia_css_program_group_param.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_psys_process.c b/modules/ia_css/ipu6/src/ia_css_psys_process.c index 6184ac87..6d737760 100644 --- a/modules/ia_css/ipu6/src/ia_css_psys_process.c +++ b/modules/ia_css/ipu6/src/ia_css_psys_process.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_psys_process_group.c b/modules/ia_css/ipu6/src/ia_css_psys_process_group.c index bf1bd22f..036a1499 100644 --- a/modules/ia_css/ipu6/src/ia_css_psys_process_group.c +++ b/modules/ia_css/ipu6/src/ia_css_psys_process_group.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_psys_process_group_cmd_impl.c b/modules/ia_css/ipu6/src/ia_css_psys_process_group_cmd_impl.c index ad458c40..f5850036 100644 --- a/modules/ia_css/ipu6/src/ia_css_psys_process_group_cmd_impl.c +++ b/modules/ia_css/ipu6/src/ia_css_psys_process_group_cmd_impl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_psys_program_group_manifest.c b/modules/ia_css/ipu6/src/ia_css_psys_program_group_manifest.c index 9eda49ff..b528fa4a 100644 --- a/modules/ia_css/ipu6/src/ia_css_psys_program_group_manifest.c +++ b/modules/ia_css/ipu6/src/ia_css_psys_program_group_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_psys_program_manifest.c b/modules/ia_css/ipu6/src/ia_css_psys_program_manifest.c index d49ddad9..73635435 100644 --- a/modules/ia_css/ipu6/src/ia_css_psys_program_manifest.c +++ b/modules/ia_css/ipu6/src/ia_css_psys_program_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_psys_terminal.c b/modules/ia_css/ipu6/src/ia_css_psys_terminal.c index 2809050a..17f69207 100644 --- a/modules/ia_css/ipu6/src/ia_css_psys_terminal.c +++ b/modules/ia_css/ipu6/src/ia_css_psys_terminal.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6/src/ia_css_psys_terminal_manifest.c b/modules/ia_css/ipu6/src/ia_css_psys_terminal_manifest.c index 99a1b3b9..380613be 100644 --- a/modules/ia_css/ipu6/src/ia_css_psys_terminal_manifest.c +++ b/modules/ia_css/ipu6/src/ia_css_psys_terminal_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Intel Corporation. + * Copyright (C) 2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/modules/ia_css/ipu6ep/include/ia_css_psys_process_group_impl.h b/modules/ia_css/ipu6ep/include/ia_css_psys_process_group_impl.h index 6a515cc4..614eaad3 100644 --- a/modules/ia_css/ipu6ep/include/ia_css_psys_process_group_impl.h +++ b/modules/ia_css/ipu6ep/include/ia_css_psys_process_group_impl.h @@ -535,7 +535,6 @@ int ia_css_process_group_print( ia_css_rbm_t routing_bitmap; NOT_USED(fid); - NOT_USED(routing_bitmap); IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, VERBOSE, "ia_css_process_group_print(): enter:\n"); @@ -690,7 +689,6 @@ bool ia_css_can_process_group_submit( int i; bool can_submit = false; int retval = -1; - NOT_USED(retval); uint8_t terminal_count = ia_css_process_group_get_terminal_count(process_group); @@ -703,7 +701,6 @@ bool ia_css_can_process_group_submit( ia_css_terminal_t *terminal = ia_css_process_group_get_terminal(process_group, i); vied_vaddress_t buffer; - NOT_USED(buffer); ia_css_buffer_state_t buffer_state; verifexitval(terminal != NULL, EINVAL); @@ -775,7 +772,6 @@ bool ia_css_can_enqueue_buffer_set( int i; bool can_enqueue = false; int retval = -1; - NOT_USED(retval); uint8_t terminal_count; IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, INFO, @@ -799,7 +795,6 @@ bool ia_css_can_enqueue_buffer_set( ia_css_terminal_t *terminal = ia_css_process_group_get_terminal(process_group, i); vied_vaddress_t buffer; - NOT_USED(buffer); ia_css_buffer_state_t buffer_state; verifexitval(terminal != NULL, EINVAL); @@ -859,7 +854,6 @@ bool ia_css_can_process_group_start( int i; bool can_start = false; int retval = -1; - NOT_USED(retval); uint8_t terminal_count; IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, INFO, diff --git a/modules/ia_css/ipu6se/include/ia_css_psys_process_group_impl.h b/modules/ia_css/ipu6se/include/ia_css_psys_process_group_impl.h index fa76827c..5e074b71 100644 --- a/modules/ia_css/ipu6se/include/ia_css_psys_process_group_impl.h +++ b/modules/ia_css/ipu6se/include/ia_css_psys_process_group_impl.h @@ -535,7 +535,6 @@ int ia_css_process_group_print( ia_css_rbm_t routing_bitmap; NOT_USED(fid); - NOT_USED(routing_bitmap); IA_CSS_TRACE_0(PSYSAPI_DYNAMIC, VERBOSE, "ia_css_process_group_print(): enter:\n"); @@ -702,7 +701,6 @@ bool ia_css_can_process_group_submit( ia_css_terminal_t *terminal = ia_css_process_group_get_terminal(process_group, i); vied_vaddress_t buffer; - NOT_USED(buffer); ia_css_buffer_state_t buffer_state; verifexitval(terminal != NULL, EINVAL); @@ -797,7 +795,6 @@ bool ia_css_can_enqueue_buffer_set( ia_css_terminal_t *terminal = ia_css_process_group_get_terminal(process_group, i); vied_vaddress_t buffer; - NOT_USED(buffer); ia_css_buffer_state_t buffer_state; verifexitval(terminal != NULL, EINVAL); diff --git a/modules/sandboxing/CMakeLists.txt b/modules/sandboxing/CMakeLists.txt new file mode 100644 index 00000000..4a03d27b --- /dev/null +++ b/modules/sandboxing/CMakeLists.txt @@ -0,0 +1,20 @@ +# +# Copyright (C) 2019 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +add_subdirectory(client) + +#--------------------------- build libcam_algo.so --------------------------- +add_subdirectory(server) diff --git a/modules/sandboxing/IPCCommon.cpp b/modules/sandboxing/IPCCommon.cpp new file mode 100644 index 00000000..59447a70 --- /dev/null +++ b/modules/sandboxing/IPCCommon.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "modules/sandboxing/IPCCommon.h" + +#include +#include + +namespace icamera { +const char* IntelAlgoIpcCmdToString(IPC_CMD cmd) { + static const char* gIpcCmdMapping[] = { + "IPC_FD_INIT", "IPC_FD_RUN", "IPC_FD_DEINIT", "IPC_GRAPH_ADD_KEY", "IPC_GRAPH_PARSE", + "IPC_GRAPH_RELEASE_NODES", "IPC_GRAPH_QUERY_GRAPH_SETTINGS", "IPC_GRAPH_CONFIG_STREAMS", + "IPC_GRAPH_GET_CONFIG_DATA", "IPC_GRAPH_GET_CONNECTION", "IPC_GRAPH_GET_PG_ID", + "IPC_CCA_CONSTRUCT", "IPC_CCA_DESTRUCT", "IPC_CCA_INIT", + "IPC_CCA_RUN_AEC", "IPC_CCA_RUN_AIQ", "IPC_CCA_RUN_LTM", "IPC_CCA_UPDATE_ZOOM", + "IPC_CCA_RUN_DVS", "IPC_CCA_GET_CMC", "IPC_CCA_GET_AIQD", + "IPC_CCA_UPDATE_TUNING", "IPC_CCA_DEINIT", "IPC_CCA_RUN_AIC", "IPC_CCA_GET_PAL_SIZE", + "IPC_PG_PARAM_INIT", "IPC_PG_PARAM_PREPARE", + "IPC_PG_PARAM_ALLOCATE_PG", "IPC_PG_PARAM_GET_FRAG_DESCS", "IPC_PG_PARAM_PREPARE_PROGRAM", + "IPC_PG_PARAM_REGISTER_PAYLOADS", "IPC_PG_PARAM_ENCODE", "IPC_PG_PARAM_DECODE", + "IPC_PG_PARAM_DEINIT", "IPC_GPU_TNR_INIT", "IPC_GPU_TNR_GET_SURFACE_INFO", + "IPC_GPU_TNR_PREPARE_SURFACE", "IPC_GPU_TNR_RUN_FRAME", "IPC_GPU_TNR_PARAM_UPDATE", + "IPC_GPU_TNR_DEINIT", + // LEVEL0_ICBM_S + "IPC_ICBM_INIT", "IPC_ICBM_RUN_FRAME", "IPC_ICBM_DEINIT", + // LEVEL0_ICBM_E + "IPC_GPU_TNR_THREAD2_RUN_FRAME", + "IPC_GPU_TNR_THREAD2_PARAM_UPDATE"}; + + unsigned int num = sizeof(gIpcCmdMapping) / sizeof(gIpcCmdMapping[0]); + return cmd < num ? gIpcCmdMapping[cmd] : gIpcCmdMapping[0]; +} + +IPC_GROUP IntelAlgoIpcCmdToGroup(IPC_CMD cmd) { + IPC_GROUP group = IPC_GROUP_CPU_OTHER; + if (cmd >= IPC_CCA_CONSTRUCT && cmd <= IPC_CCA_DEINIT) { + group = IPC_GROUP_AIQ; + } else if (cmd >= IPC_CCA_RUN_AIC && cmd <= IPC_CCA_GET_PAL_SIZE) { + group = IPC_GROUP_PAL; + } else if (cmd >= IPC_PG_PARAM_INIT && cmd <= IPC_PG_PARAM_DEINIT) { + group = IPC_GROUP_PSYS; + } else if (cmd >= IPC_FD_INIT && cmd <= IPC_FD_DEINIT) { + group = IPC_GROUP_FD; + } else if (cmd >= IPC_GPU_TNR_INIT && cmd <= IPC_GPU_TNR_DEINIT) { + group = IPC_GROUP_GPU; + } else if (cmd >= IPC_GPU_TNR_THREAD2_RUN_FRAME && cmd <= IPC_GPU_TNR_THREAD2_PARAM_UPDATE) { + group = IPC_GROUP_GPU_THREAD2; + // LEVEL0_ICBM_S + } else if (cmd >= IPC_ICBM_INIT && cmd <= IPC_ICBM_DEINIT) { + group = IPC_GROUP_GPU_ICBM; + // LEVEL0_ICBM_E + } else { + group = IPC_GROUP_CPU_OTHER; + } + + return group; +} + +const char* IntelAlgoServerThreadName(int index) { + int count = 0; +#ifndef GPU_ALGO_SERVER + static const char* gIpcCmdMapping[IPC_CPU_GROUP_NUM] = { + "AiqCPUAlgoServer", "PalCPUAlgoServer", "PsysCPUAlgoServer", + "FdCPUAlgoServer", "OtherCPUAlgoServer"}; + count = IPC_CPU_GROUP_NUM; +#else + static const char* gIpcCmdMapping[IPC_GPU_GROUP_NUM] = {"GPUAlgoServer", + // LEVEL0_ICBM_S + "GPUICBMServer", + // LEVEL0_ICBM_E + "GPUAlgoServer2"}; + count = IPC_GPU_GROUP_NUM; +#endif + + return index < count ? gIpcCmdMapping[index] : "unknown"; +} +} /* namespace icamera */ diff --git a/modules/sandboxing/IPCCommon.h b/modules/sandboxing/IPCCommon.h new file mode 100644 index 00000000..4c73ad3b --- /dev/null +++ b/modules/sandboxing/IPCCommon.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +#include "iutils/Errors.h" + +namespace icamera { +#define IPC_MATCHING_KEY 0x56 // the value is randomly chosen +#define IPC_REQUEST_HEADER_USED_NUM 1 +#define SHM_NAME "shm" + +enum IPC_CMD { + // CPU IPC COMMANDS + IPC_FD_INIT, + IPC_FD_RUN, + IPC_FD_DEINIT, + IPC_GRAPH_ADD_KEY, + IPC_GRAPH_PARSE, + IPC_GRAPH_RELEASE_NODES, + IPC_GRAPH_QUERY_GRAPH_SETTINGS, + IPC_GRAPH_CONFIG_STREAMS, + IPC_GRAPH_GET_CONFIG_DATA, + IPC_GRAPH_GET_CONNECTION, + IPC_GRAPH_GET_PG_ID, + IPC_CCA_CONSTRUCT, + IPC_CCA_DESTRUCT, + IPC_CCA_INIT, + IPC_CCA_RUN_AEC, + IPC_CCA_RUN_AIQ, + IPC_CCA_RUN_LTM, + IPC_CCA_UPDATE_ZOOM, + IPC_CCA_RUN_DVS, + IPC_CCA_GET_CMC, + IPC_CCA_GET_AIQD, + IPC_CCA_UPDATE_TUNING, + IPC_CCA_DEINIT, + IPC_CCA_RUN_AIC, + IPC_CCA_GET_PAL_SIZE, + IPC_PG_PARAM_INIT, + IPC_PG_PARAM_PREPARE, + IPC_PG_PARAM_ALLOCATE_PG, + IPC_PG_PARAM_GET_FRAG_DESCS, + IPC_PG_PARAM_PREPARE_PROGRAM, + IPC_PG_PARAM_REGISTER_PAYLOADS, + IPC_PG_PARAM_ENCODE, + IPC_PG_PARAM_DECODE, + IPC_PG_PARAM_DEINIT, + // GPU IPC COMMANDS + IPC_GPU_TNR_INIT, + IPC_GPU_TNR_GET_SURFACE_INFO, + IPC_GPU_TNR_PREPARE_SURFACE, + IPC_GPU_TNR_RUN_FRAME, + IPC_GPU_TNR_PARAM_UPDATE, + IPC_GPU_TNR_DEINIT, + // LEVEL0_ICBM_S + IPC_ICBM_INIT, + IPC_ICBM_RUN_FRAME, + IPC_ICBM_DEINIT, + // LEVEL0_ICBM_E + IPC_GPU_TNR_THREAD2_RUN_FRAME, + IPC_GPU_TNR_THREAD2_PARAM_UPDATE, +}; + +#define MAX_IA_BINARY_DATA_SIZE 800000 +struct ia_binary_data_mod { + unsigned int size; + char data[MAX_IA_BINARY_DATA_SIZE]; +}; + +const char* IntelAlgoIpcCmdToString(IPC_CMD cmd); + +enum IPC_GROUP { + // IPC command group for cpu + IPC_GROUP_AIQ, + IPC_GROUP_PAL, + IPC_GROUP_PSYS, + IPC_GROUP_FD, + IPC_GROUP_CPU_OTHER, + // IPU command group for gpu + IPC_GROUP_GPU, + // LEVEL0_ICBM_S + IPC_GROUP_GPU_ICBM, + // LEVEL0_ICBM_E + IPC_GROUP_GPU_THREAD2, +}; +#define IPC_GROUP_NUM (IPC_GROUP_GPU_THREAD2 + 1) +#define IPC_CPU_GROUP_NUM (IPC_GROUP_CPU_OTHER + 1) +#define IPC_GPU_GROUP_NUM (IPC_GROUP_GPU_THREAD2 - IPC_GROUP_GPU + 1) + +IPC_GROUP IntelAlgoIpcCmdToGroup(IPC_CMD cmd); +const char* IntelAlgoServerThreadName(int index); +} /* namespace icamera */ diff --git a/modules/sandboxing/IPCGraphConfig.cpp b/modules/sandboxing/IPCGraphConfig.cpp new file mode 100644 index 00000000..b929f9cc --- /dev/null +++ b/modules/sandboxing/IPCGraphConfig.cpp @@ -0,0 +1,484 @@ +/* + * Copyright (C) 2019-2022 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IPC_GRAPH_CONFIG + +#include "modules/sandboxing/IPCGraphConfig.h" + +#include + +#include + +#include "iutils/CameraLog.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" + +namespace icamera { + +status_t IPCGraphConfig::readDataFromXml(const char* fileName, char* dataPtr, size_t* dataSize, + int maxSize) { + CheckAndLogError(!dataSize || !fileName || !dataPtr, UNKNOWN_ERROR, + "%s, Wrong parameters, dataSize: %p, fileName: %p, dataPtr: %p", __func__, + dataSize, fileName, dataPtr); + + struct stat statBuf; + int ret = stat(fileName, &statBuf); + CheckAndLogError((ret != 0), UNKNOWN_ERROR, "Failed to query the size of file: %s!", fileName); + CheckAndLogError(statBuf.st_size > maxSize, BAD_VALUE, + "The memory size: %d less than file size: %d", maxSize, statBuf.st_size); + + *dataSize = static_cast(statBuf.st_size); + LOG1("%s, fileName: %s, size: %zu", __func__, fileName, *dataSize); + + FILE* file = fopen(fileName, "rb"); + CheckAndLogError(!file, NAME_NOT_FOUND, "%s, Failed to open file: %s", __func__, fileName); + + size_t len = fread(dataPtr, 1, *dataSize, file); + fclose(file); + + CheckAndLogError((len != *dataSize), UNKNOWN_ERROR, "%s, Failed to read data from file: %s", + __func__, fileName); + + return OK; +} + +bool IPCGraphConfig::clientFlattenParse(void* pData, uint32_t size, int cameraId, + const char* graphDescFile, const char* settingsFile) { + CheckAndLogError(!pData || !graphDescFile || !settingsFile || size < sizeof(GraphParseParams), + false, "@%s, wrong parameters, pData: %p, GD: %p, settings: %p, size: %u", + __func__, pData, graphDescFile, settingsFile, size); + + GraphParseParams* params = static_cast(pData); + CLEAR(*params); + + params->cameraId = cameraId; + int ret = + readDataFromXml(graphDescFile, params->GD, &(params->gdSize), MAX_GRAPH_DESCRIPTOR_SIZE); + CheckAndLogError(ret != OK, false, "Failed to read the graph descriptor file: %s", + graphDescFile); + + ret = readDataFromXml(settingsFile, params->GS, &(params->gsSize), MAX_GRAPH_SETTINGS_SIZE); + CheckAndLogError(ret != OK, false, "Failed to read the graph settings file: %s", settingsFile); + + return true; +} + +bool IPCGraphConfig::serverUnflattenParse(void* pData, uint32_t size, + GraphParseParams** parseParam) { + CheckAndLogError(!pData || !parseParam || size < sizeof(GraphParseParams), false, + "@%s, Wrong parameters, pData: %p, parseParam: %p, size: %u", __func__, pData, + parseParam, size); + + GraphParseParams* params = static_cast(pData); + *parseParam = params; + + return true; +} + +bool IPCGraphConfig::clientFlattenConfigStreams(void* pData, uint32_t size, GraphBaseInfo info, + GraphSettingType type, bool dummyStillSink, + const std::vector& streams) { + LOG1("@%s, pData: %p, configMode: %d, dummyStillSink: %d", info.cameraId, __func__, pData, + info.configMode, dummyStillSink); + + CheckAndLogError(!pData || size < sizeof(GraphConfigStreamParams) || streams.empty(), false, + "@%s, Wrong parameters, pData: %p, size: %u, streams count: %d", __func__, + pData, size, streams.size()); + + GraphConfigStreamParams* params = static_cast(pData); + CLEAR(*params); + + params->baseInfo = info; + params->type = type; + for (size_t i = 0; i < streams.size(); ++i) { + params->streamCfg[i] = *(streams[i]); + params->streamPriv[i] = *(static_cast(streams[i]->mPrivate)); + params->streamNum++; + } + params->dummyStillSink = dummyStillSink; + return true; +} + +bool IPCGraphConfig::serverUnflattenConfigStreams(void* pData, uint32_t size, GraphBaseInfo* info, + GraphSettingType* type, bool* dummyStillSink, + std::vector* streams) { + CheckAndLogError(!pData || size < sizeof(GraphConfigStreamParams) || !info || !type || + !streams || !dummyStillSink, + false, + "@%s, Wrong parameters, pData: %p, size: %u, info: %p, type: %p, streams: %p, " + "dummyStillSink: %p", + __func__, pData, size, info, type, streams, dummyStillSink); + + GraphConfigStreamParams* params = static_cast(pData); + + *info = params->baseInfo; + *type = params->type; + *dummyStillSink = params->dummyStillSink; + for (uint32_t i = 0; i < params->streamNum; ++i) { + params->streamCfg[i].mPrivate = static_cast(&(params->streamPriv[i])); + streams->push_back(&(params->streamCfg[i])); + } + + return true; +} + +bool IPCGraphConfig::clientFlattenGetGraphData(void* pData, uint32_t size, GraphBaseInfo info) { + CheckAndLogError(!pData || size < sizeof(GraphGetDataParams), false, + "@%s, Wrong parameters, pData: %p, size: %u", __func__, pData, size); + + GraphGetDataParams* params = static_cast(pData); + CLEAR(*params); + + params->baseInfo = info; + + return true; +} + +bool IPCGraphConfig::serverUnflattenGetGraphData(void* pData, uint32_t size, GraphBaseInfo* info) { + CheckAndLogError(!pData || !info || size < sizeof(GraphGetDataParams), false, + "@%s, Wrong parameters, pData: %p, info: %p, size: %u", __func__, pData, info, + size); + + GraphGetDataParams* params = static_cast(pData); + *info = params->baseInfo; + + return true; +} + +bool IPCGraphConfig::serverFlattenGetGraphData(void* pData, uint32_t size, + IGraphType::GraphConfigData graphData) { + CheckAndLogError(!pData || size < sizeof(GraphGetDataParams), false, + "@%s, Wrong parameters, pData: %p, size: %u", __func__, pData, size); + + GraphGetDataParams* params = static_cast(pData); + + params->mcId = graphData.mcId; + params->graphId = graphData.graphId; + + params->csiReso = graphData.csiReso; + + LOG1("@%s, mcId: %d, graphId: %d", __func__, params->mcId, params->graphId); + + params->gdcInfoNum = graphData.gdcInfos.size(); + for (size_t i = 0; i < graphData.gdcInfos.size(); ++i) { + params->mGdcInfo[i] = graphData.gdcInfos[i]; + } + + params->streamIdNum = graphData.streamIds.size(); + for (size_t i = 0; i < graphData.streamIds.size(); ++i) { + params->streamIdData[i] = graphData.streamIds[i]; + } + + params->tuningModeNum = graphData.tuningModes.size(); + for (size_t i = 0; i < graphData.tuningModes.size(); ++i) { + params->tuningModes[i] = graphData.tuningModes[i]; + } + + params->pgInfoNum = graphData.pgInfo.size(); + for (size_t i = 0; i < graphData.pgInfo.size(); ++i) { + size_t len = graphData.pgInfo[i].pgName.copy(params->pgInfoData[i].pgName, MAX_NAME_LENGTH); + params->pgInfoData[i].pgName[len] = '\0'; + params->pgInfoData[i].pgId = graphData.pgInfo[i].pgId; + params->pgInfoData[i].streamId = graphData.pgInfo[i].streamId; + params->pgInfoData[i].rbmByte = graphData.pgInfo[i].rbmValue.rbm_bytes; + + if (params->pgInfoData[i].rbmByte > 0) { + MEMCPY_S(params->pgInfoData[i].rbmData, MAX_RBM_STR_SIZE, + graphData.pgInfo[i].rbmValue.rbm, graphData.pgInfo[i].rbmValue.rbm_bytes); + } + } + + params->mBrInfoNum = graphData.mbrInfo.size(); + for (size_t i = 0; i < graphData.mbrInfo.size(); ++i) { + params->mBrInfoData[i].streamId = graphData.mbrInfo[i].streamId; + params->mBrInfoData[i].mBrData = graphData.mbrInfo[i].data; + } + + params->pgNamesNum = graphData.pgNames.size(); + for (size_t i = 0; i < params->pgNamesNum; ++i) { + size_t len = graphData.pgNames[i].copy(params->pgNames[i], MAX_NAME_LENGTH); + params->pgNames[i][len] = '\0'; + } + + params->kernelArrayNum = graphData.programGroup.size(); + for (size_t i = 0; i < params->kernelArrayNum; ++i) { + params->kernelArray[i].streamId = graphData.programGroup[i].streamId; + ia_isp_bxt_program_group* pgPtr = graphData.programGroup[i].pgPtr; + params->kernelArray[i].group = *pgPtr; + + for (unsigned int j = 0; j < params->kernelArray[i].group.kernel_count; ++j) { + params->kernelArray[i].runKernels[j] = pgPtr->run_kernels[j]; + if (pgPtr->run_kernels[j].resolution_info) { + params->kernelArray[i].resoInfo[j] = *(pgPtr->run_kernels[j].resolution_info); + params->kernelArray[i].runKernels[j].resolution_info = + &(params->kernelArray[i].resoInfo[j]); + } else { + params->kernelArray[i].runKernels[j].resolution_info = nullptr; + } + + if (pgPtr->run_kernels[j].resolution_history) { + params->kernelArray[i].resoHistory[j] = *(pgPtr->run_kernels[j].resolution_history); + params->kernelArray[i].runKernels[j].resolution_history = + &(params->kernelArray[i].resoHistory[j]); + } else { + params->kernelArray[i].runKernels[j].resolution_history = nullptr; + } + } + params->kernelArray[i].group.run_kernels = params->kernelArray[i].runKernels; + + if (pgPtr->pipe) { + params->kernelArray[i].pipeInfo = *(pgPtr->pipe); + params->kernelArray[i].group.pipe = &(params->kernelArray[i].pipeInfo); + } else { + params->kernelArray[i].group.pipe = nullptr; + } + } + + return true; +} + +bool IPCGraphConfig::clientUnflattenGetGraphData(void* pData, uint32_t size, + IGraphType::GraphConfigData* graphData) { + CheckAndLogError(!pData || !graphData || size < sizeof(GraphGetDataParams), false, + "@%s, Wrong parameters, pData: %p, graphData: %p, size: %u", __func__, pData, + graphData, size); + + GraphGetDataParams* params = static_cast(pData); + + graphData->mcId = params->mcId; + graphData->graphId = params->graphId; + + graphData->csiReso = params->csiReso; + + LOG1("@%s, mcId: %d, graphId: %d", __func__, params->mcId, params->graphId); + + for (size_t i = 0; i < params->gdcInfoNum; i++) { + graphData->gdcInfos.push_back(params->mGdcInfo[i]); + } + + for (size_t i = 0; i < params->streamIdNum; ++i) { + graphData->streamIds.push_back(params->streamIdData[i]); + } + + for (size_t i = 0; i < params->tuningModeNum; ++i) { + graphData->tuningModes.push_back(params->tuningModes[i]); + } + + for (size_t i = 0; i < params->pgInfoNum; ++i) { + IGraphType::PgInfo info; + info.pgName = params->pgInfoData[i].pgName; + info.pgId = params->pgInfoData[i].pgId; + info.streamId = params->pgInfoData[i].streamId; + info.rbmValue.rbm_bytes = params->pgInfoData[i].rbmByte; + if (params->pgInfoData[i].rbmByte > 0) { + MEMCPY_S(info.rbmValue.rbm, MAX_RBM_STR_SIZE, params->pgInfoData[i].rbmData, + params->pgInfoData[i].rbmByte); + } + graphData->pgInfo.push_back(info); + } + + for (size_t i = 0; i < params->mBrInfoNum; ++i) { + IGraphType::MbrInfo info; + info.streamId = params->mBrInfoData[i].streamId; + info.data = params->mBrInfoData[i].mBrData; + graphData->mbrInfo.push_back(info); + } + + for (size_t i = 0; i < params->pgNamesNum; ++i) { + graphData->pgNames.push_back(params->pgNames[i]); + } + + for (size_t i = 0; i < params->kernelArrayNum; ++i) { + IGraphType::ProgramGroupInfo info; + + info.streamId = params->kernelArray[i].streamId; + info.pgPtr = &(params->kernelArray[i].group); + + info.pgPtr->run_kernels = params->kernelArray[i].runKernels; + for (unsigned j = 0; j < info.pgPtr->kernel_count; ++j) { + if (params->kernelArray[i].runKernels[j].resolution_info) { + info.pgPtr->run_kernels[j].resolution_info = &(params->kernelArray[i].resoInfo[j]); + } else { + info.pgPtr->run_kernels[j].resolution_info = nullptr; + } + + if (params->kernelArray[i].runKernels[j].resolution_history) { + info.pgPtr->run_kernels[j].resolution_history = + &(params->kernelArray[i].resoHistory[j]); + } else { + info.pgPtr->run_kernels[j].resolution_history = nullptr; + } + } + + if (params->kernelArray[i].group.pipe) { + info.pgPtr->pipe = &(params->kernelArray[i].pipeInfo); + } else { + info.pgPtr->pipe = nullptr; + } + + graphData->programGroup.push_back(info); + } + + return true; +} + +bool IPCGraphConfig::clientFlattenGetPgId(void* pData, uint32_t size, GraphBaseInfo info, + const int streamId, const int kernelId) { + CheckAndLogError(!pData || size < sizeof(GraphGetPgIdParams), false, + "@%s, Wrong parameters, pData: %p, size: %u", __func__, pData, size); + + GraphGetPgIdParams* params = static_cast(pData); + CLEAR(*params); + + params->baseInfo = info; + params->streamId = streamId; + params->kernelId = kernelId; + + return true; +} + +bool IPCGraphConfig::serverUnFlattenGetPgId(void* pData, uint32_t size, GraphBaseInfo* info, + uint32_t* streamId, int32_t* kernelId) { + CheckAndLogError(!pData || size < sizeof(GraphGetPgIdParams) || !info || !streamId || !kernelId, + false, + "@%s, Wrong parameters, pData: %p, size: %u, info: %p, streamId: %p, " + "kernelId: %p", + __func__, pData, size, info, streamId, kernelId); + + GraphGetPgIdParams* params = static_cast(pData); + + *info = params->baseInfo; + *streamId = params->streamId; + *kernelId = params->kernelId; + + return true; +} + +bool IPCGraphConfig::serverFlattenGetPgId(void* pData, uint32_t size, int32_t pgId) { + CheckAndLogError(!pData || size < sizeof(GraphGetPgIdParams), false, + "@%s, Wrong parameters, pData: %p, size: %u", __func__, pData, size); + + GraphGetPgIdParams* params = static_cast(pData); + params->pgId = pgId; + + return true; +} + +bool IPCGraphConfig::clientUnFlattenGetPgId(void* pData, uint32_t size, int32_t* pgId) { + CheckAndLogError(!pData || !pgId || size < sizeof(GraphGetPgIdParams), false, + "@%s, Wrong parameters, pData: %p, pgId: %p, size: %u", __func__, pData, pgId, + size); + + GraphGetPgIdParams* params = static_cast(pData); + *pgId = params->pgId; + + return true; +} + +bool IPCGraphConfig::clientFlattenGetConnection(void* pData, uint32_t size, GraphBaseInfo info, + const std::vector& pgList) { + CheckAndLogError(!pData || size < sizeof(GraphGetConnectionParams), false, + "@%s, Wrong parameters, pData: %p, size: %u", __func__, pData, size); + GraphGetConnectionParams* params = static_cast(pData); + CLEAR(*params); + + params->baseInfo = info; + params->pgListNum = pgList.size(); + for (size_t i = 0; i < pgList.size(); ++i) { + size_t len = pgList[i].copy(params->pgList[i], MAX_NAME_LENGTH); + params->pgList[i][len] = '\0'; + } + + return true; +} + +bool IPCGraphConfig::serverUnFlattenGetConnection(void* pData, uint32_t size, GraphBaseInfo* info, + std::vector* pgList) { + CheckAndLogError(!pData || size < sizeof(GraphGetConnectionParams) || !info || !pgList, false, + "@%s, Wrong parameters, pData: %p, size: %u, info: %p, pgList: %p", __func__, + pData, size, info, pgList); + + GraphGetConnectionParams* params = static_cast(pData); + + *info = params->baseInfo; + for (size_t i = 0; i < params->pgListNum; ++i) { + pgList->push_back(params->pgList[i]); + } + + return true; +} + +bool IPCGraphConfig::serverFlattenGetConnection( + void* pData, uint32_t size, const std::vector& scalerInfo, + const std::vector& confVector, + const std::vector& tnrPortFormat) { + CheckAndLogError(!pData || size < sizeof(GraphGetConnectionParams), false, + "@%s, Wrong parameters, pData: %p, size: %u", __func__, pData, size); + + GraphGetConnectionParams* params = static_cast(pData); + + params->connectionArraySize = confVector.size(); + for (size_t i = 0; i < confVector.size(); ++i) { + params->connectionArray[i].connection = confVector[i]; + if (params->connectionArray[i].connection.stream) { + params->connectionArray[i].stream = *(confVector[i].stream); + } + } + + params->scalerInfoNum = scalerInfo.size(); + for (size_t i = 0; i < scalerInfo.size(); ++i) { + params->scalerInfoArray[i] = scalerInfo[i]; + } + + params->portFormatNum = tnrPortFormat.size(); + for (size_t i = 0; i < tnrPortFormat.size(); ++i) { + params->portFormatArray[i] = tnrPortFormat[i]; + } + + return true; +} + +bool IPCGraphConfig::clientUnFlattenGetConnection( + void* pData, uint32_t size, std::vector* scalerInfo, + std::vector* confVector, + std::vector* tnrPortFormat) { + CheckAndLogError( + !pData || !scalerInfo || !confVector || size < sizeof(GraphGetConnectionParams), false, + "@%s, Wrong parameters, pData: %p, scalerInfo: %p, confVector: %p, size: %u", __func__, + pData, scalerInfo, confVector, size); + + GraphGetConnectionParams* params = static_cast(pData); + + for (size_t i = 0; i < params->connectionArraySize; ++i) { + if (params->connectionArray[i].connection.stream) { + params->connectionArray[i].connection.stream = &(params->connectionArray[i].stream); + } + confVector->push_back(params->connectionArray[i].connection); + } + + for (size_t i = 0; i < params->scalerInfoNum; ++i) { + scalerInfo->push_back(params->scalerInfoArray[i]); + } + + if (tnrPortFormat) { + for (size_t i = 0; i < params->portFormatNum; ++i) { + tnrPortFormat->push_back(params->portFormatArray[i]); + } + } + + return true; +} +} // namespace icamera diff --git a/modules/sandboxing/IPCGraphConfig.h b/modules/sandboxing/IPCGraphConfig.h new file mode 100644 index 00000000..c2a7ebbf --- /dev/null +++ b/modules/sandboxing/IPCGraphConfig.h @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2019-2022 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "modules/sandboxing/IPCCommon.h" +#include "src/platformdata/gc/IGraphConfig.h" + +namespace icamera { + +#define MAX_STREAM (4) // Max stream number +#define MAX_GRAPH_SETTINGS_SIZE (2 * 1024 * 1024) // Max graph settings file size +#define MAX_GRAPH_DESCRIPTOR_SIZE (512 * 1024) // Max graph descriptor file size +#define MAX_PG_NUMBER (10) // Max pg number +#define MAX_NAME_LENGTH (128) // Max length for name +#define MAX_CONNECTION_COUNT (64) // Max connection count +#define MAX_STREAM_KERNEL_COUNT (128) // Max kernels info per one stream + +struct GraphBaseInfo { + int cameraId; + ConfigMode configMode; + + bool operator<(const GraphBaseInfo& b) const { + return (cameraId < b.cameraId) ? true : (configMode < b.configMode ? true : false); + } +}; + +struct GraphPgInfo { + char pgName[MAX_NAME_LENGTH]; + uint32_t pgId; + int streamId; + uint32_t rbmByte; + char rbmData[MAX_RBM_STR_SIZE]; +}; + +struct GraphMbrInfo { + int32_t streamId; + ia_isp_bxt_gdc_limits mBrData; +}; + +struct GraphKernelArray { + int32_t streamId; + ia_isp_bxt_program_group group; + ia_isp_bxt_run_kernels_t runKernels[MAX_STREAM_KERNEL_COUNT]; + ia_isp_bxt_resolution_info_t resoInfo[MAX_STREAM_KERNEL_COUNT]; + ia_isp_bxt_resolution_info_t resoHistory[MAX_STREAM_KERNEL_COUNT]; + ia_isp_bxt_pipe_t pipeInfo; +}; + +struct GraphParseParams { + int cameraId; + size_t gdSize; + char GD[MAX_GRAPH_DESCRIPTOR_SIZE]; + size_t gsSize; + char GS[MAX_GRAPH_SETTINGS_SIZE]; +}; + +struct GraphConfigStreamParams { + GraphBaseInfo baseInfo; + GraphSettingType type; + uint32_t streamNum; + HalStream streamCfg[MAX_STREAM]; + stream_t streamPriv[MAX_STREAM]; + bool dummyStillSink; +}; + +struct GraphQueryGraphParams { + GraphConfigStreamParams configParams; + bool isHasGraphSettings; +}; + +struct GraphGetDataParams { + GraphBaseInfo baseInfo; + + int mcId; + int graphId; + + camera_resolution_t csiReso; + + uint32_t gdcInfoNum; + IGraphType::GdcInfo mGdcInfo[MAX_STREAM]; + + uint32_t streamIdNum; + int32_t streamIdData[MAX_STREAM]; + + uint32_t tuningModeNum; + IGraphType::TuningModeInfo tuningModes[MAX_STREAM]; + + uint32_t pgInfoNum; + GraphPgInfo pgInfoData[MAX_PG_NUMBER]; + + uint32_t mBrInfoNum; + GraphMbrInfo mBrInfoData[MAX_STREAM]; + + uint32_t pgNamesNum; + char pgNames[MAX_PG_NUMBER][MAX_NAME_LENGTH]; + + uint32_t kernelArrayNum; + GraphKernelArray kernelArray[MAX_STREAM]; +}; + +struct GraphGetPgIdParams { + GraphBaseInfo baseInfo; + uint32_t streamId; + int32_t kernelId; + int32_t pgId; +}; + +struct GraphConnection { + IGraphType::PipelineConnection connection; + HalStream stream; +}; + +struct GraphGetConnectionParams { + GraphBaseInfo baseInfo; + uint32_t pgListNum; + char pgList[MAX_PG_NUMBER][MAX_NAME_LENGTH]; + uint32_t connectionArraySize; + GraphConnection connectionArray[MAX_CONNECTION_COUNT]; + uint32_t scalerInfoNum; + IGraphType::ScalerInfo scalerInfoArray[MAX_STREAM]; + uint32_t portFormatNum; + IGraphType::PrivPortFormat portFormatArray[MAX_STREAM]; +}; + +class IPCGraphConfig { + public: + IPCGraphConfig() {} + virtual ~IPCGraphConfig() {} + + bool clientFlattenParse(void* pData, uint32_t size, int cameraId, const char* graphDescFile, + const char* settingsFile); + bool serverUnflattenParse(void* pData, uint32_t size, GraphParseParams** parseParam); + bool clientFlattenConfigStreams(void* pData, uint32_t size, GraphBaseInfo info, + GraphSettingType type, bool dummyStillSink, + const std::vector& streams); + bool serverUnflattenConfigStreams(void* pData, uint32_t size, GraphBaseInfo* info, + GraphSettingType* type, bool* dummyStillSink, + std::vector* streams); + bool clientFlattenGetGraphData(void* pData, uint32_t size, GraphBaseInfo info); + bool serverUnflattenGetGraphData(void* pData, uint32_t size, GraphBaseInfo* info); + bool serverFlattenGetGraphData(void* pData, uint32_t size, + IGraphType::GraphConfigData graphData); + bool clientUnflattenGetGraphData(void* pData, uint32_t size, + IGraphType::GraphConfigData* graphData); + bool clientFlattenGetPgId(void* pData, uint32_t size, GraphBaseInfo info, const int streamId, + const int kernelId); + bool serverUnFlattenGetPgId(void* pData, uint32_t size, GraphBaseInfo* info, uint32_t* streamId, + int32_t* kernelId); + bool serverFlattenGetPgId(void* pData, uint32_t size, int32_t pgId); + bool clientUnFlattenGetPgId(void* pData, uint32_t size, int32_t* pgId); + bool clientFlattenGetConnection(void* pData, uint32_t size, GraphBaseInfo info, + const std::vector& pgList); + bool serverUnFlattenGetConnection(void* pData, uint32_t size, GraphBaseInfo* info, + std::vector* pgList); + bool serverFlattenGetConnection(void* pData, uint32_t size, + const std::vector& scalerInfo, + const std::vector& confVector, + const std::vector& tnrPortFormat); + bool clientUnFlattenGetConnection(void* pData, uint32_t size, + std::vector* scalerInfo, + std::vector* confVector, + std::vector* tnrPortFormat); + + private: + status_t readDataFromXml(const char* fileName, char* dataPtr, size_t* dataSize, int maxSize); + + // Disable copy constructor and assignment operator + DISALLOW_COPY_AND_ASSIGN(IPCGraphConfig); +}; +} // namespace icamera diff --git a/modules/sandboxing/IPCIntelCca.h b/modules/sandboxing/IPCIntelCca.h new file mode 100644 index 00000000..0159ffb7 --- /dev/null +++ b/modules/sandboxing/IPCIntelCca.h @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "IntelCCA.h" + +namespace icamera { + +struct intel_cca_struct_data { + int cameraId; + TuningMode tuningMode; +}; + +struct intel_cca_init_data { + int cameraId; + TuningMode tuningMode; + + cca::cca_init_params inParams; +}; + +struct intel_cca_decode_stats_data { + int cameraId; + TuningMode tuningMode; + + ia_binary_data statsBuffer; + int32_t statsHandle; + uint32_t bitmap; + cca::cca_out_stats outStats; + + ia_isp_bxt_statistics_query_results_t results; +}; + +struct intel_cca_run_aec_data { + int cameraId; + TuningMode tuningMode; + + uint64_t frameId; + cca::cca_ae_input_params inParams; + + bool hasStats; + cca::cca_stats_params inStatsParams; + + bool hasDecodeStats; + intel_cca_decode_stats_data decodeStatsParams; + + cca::cca_ae_results results; +}; + +struct intel_cca_run_aiq_data { + int cameraId; + TuningMode tuningMode; + + uint64_t frameId; + cca::cca_aiq_params inParams; + + cca::cca_aiq_results* results; + int32_t aiqResultHandle; + + ia_mkn_trg type; + + cca::cca_mkn* mknResults; + int32_t mknResultsHandle; +}; + +struct intel_cca_run_ltm_data { + int cameraId; + TuningMode tuningMode; + + uint64_t frameId; + cca::cca_ltm_input_params inParams; +}; + +struct intel_cca_update_zoom_data { + int cameraId; + TuningMode tuningMode; + + cca::cca_dvs_zoom inParams; + uint32_t streamId; +}; + +struct intel_cca_run_dvs_data { + int cameraId; + TuningMode tuningMode; + + uint64_t frameId; + uint32_t streamId; +}; + +struct intel_cca_run_aic_data { + int cameraId; + TuningMode tuningMode; + + uint64_t frameId; + cca::cca_pal_input_params* inParams; + int32_t inParamsHandle; + + ia_binary_data palOutData; + int32_t palDataHandle; +}; + +struct intel_cca_get_cmc_data { + int cameraId; + TuningMode tuningMode; + cca::cca_cpf cpf; + + cca::cca_cmc results; +}; + +struct intel_cca_get_aiqd_data { + int cameraId; + TuningMode tuningMode; + + cca::cca_aiqd results; +}; + +struct intel_cca_update_tuning_data { + int cameraId; + TuningMode tuningMode; + + uint8_t lardTags; + ia_lard_input_params lardParams; + cca::cca_nvm nvmParams; + int32_t streamId; +}; + +struct intel_cca_deinit_data { + int cameraId; + TuningMode tuningMode; +}; + +struct intel_cca_get_pal_data_size { + int cameraId; + TuningMode tuningMode; + + cca::cca_program_group pg; + + uint32_t returnSize; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/IPCIntelFD.cpp b/modules/sandboxing/IPCIntelFD.cpp new file mode 100644 index 00000000..c93a50f4 --- /dev/null +++ b/modules/sandboxing/IPCIntelFD.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IPC_FACE_DETECTION + +#include "modules/sandboxing/IPCIntelFD.h" + +#include "CameraLog.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" + +namespace icamera { + +bool IPCIntelFD::clientFlattenInit(unsigned int max_face_num, int cameraId, + FaceDetectionInitParams* params) { + CheckAndLogError(params == nullptr, false, "@%s, params is nullptr", __func__); + + params->max_face_num = max_face_num; + params->cameraId = cameraId; + + return true; +} + +bool IPCIntelFD::serverUnflattenRun(const FaceDetectionRunParams& inParams, void* imageData, + pvl_image* image, int* cameraId) { + CheckAndLogError(image == nullptr || cameraId == nullptr, false, + "@%s, image or cameraId is nullptr", __func__); + + image->size = inParams.size; + image->width = inParams.width; + image->height = inParams.height; + image->format = inParams.format; + image->stride = inParams.stride; + image->rotation = inParams.rotation; + *cameraId = inParams.cameraId; + + if (imageData) { + image->data = const_cast(static_cast(imageData)); + } else { + image->data = const_cast(inParams.data); + } + + return true; +} +} /* namespace icamera */ diff --git a/modules/sandboxing/IPCIntelFD.h b/modules/sandboxing/IPCIntelFD.h new file mode 100644 index 00000000..b5722d1a --- /dev/null +++ b/modules/sandboxing/IPCIntelFD.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2019-2020 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include "FaceType.h" +#include "modules/sandboxing/IPCCommon.h" + +namespace icamera { +struct FaceDetectionInitParams { + unsigned int max_face_num; + int cameraId; +}; + +struct FaceDetectionDeinitParams { + int cameraId; +}; + +struct FaceDetectionPVLResult { + bool faceUpdated; + int faceNum; + pvl_face_detection_result faceResults[MAX_FACES_DETECTABLE]; + pvl_eye_detection_result eyeResults[MAX_FACES_DETECTABLE]; + pvl_mouth_detection_result mouthResults[MAX_FACES_DETECTABLE]; +}; + +struct FaceDetectionRunParams { + uint8_t data[MAX_FACE_FRAME_SIZE_ASYNC]; + int32_t bufferHandle; + uint32_t size; + int32_t width; + int32_t height; + pvl_image_format format; + int32_t stride; + int32_t rotation; + int cameraId; + + FaceDetectionPVLResult results; +}; + +class IPCIntelFD { + public: + IPCIntelFD() {} + virtual ~IPCIntelFD() {} + + bool clientFlattenInit(unsigned int max_face_num, int cameraId, + FaceDetectionInitParams* params); + bool serverUnflattenRun(const FaceDetectionRunParams& inParams, void* imageData, + pvl_image* image, int* cameraId); +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/IPCIntelPGParam.cpp b/modules/sandboxing/IPCIntelPGParam.cpp new file mode 100644 index 00000000..0d27a091 --- /dev/null +++ b/modules/sandboxing/IPCIntelPGParam.cpp @@ -0,0 +1,534 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IPCIntelPGParam + +#include "modules/sandboxing/IPCIntelPGParam.h" + +#include "iutils/CameraLog.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" + +namespace icamera { + +bool IPCIntelPGParam::clientFlattenInit(void* pData, int dataSize, int pgId, uintptr_t client, + ia_p2p_platform_t platform, + const PgConfiguration& pgConfig) { + CheckAndLogError(!pData || dataSize < sizeof(pg_param_init_params), false, + "@%s, Wrong parameters, pData: %p, dataSize: %d", __func__, pData, dataSize); + + pg_param_init_params* params = static_cast(pData); + CheckAndLogError(pgConfig.pgManifestSize > sizeof(params->pgManifestData), false, + "@%s, manifest buffer size: %d is big", __func__, pgConfig.pgManifestSize); + + params->pgId = pgId; + params->client = client; + params->platform = platform; + + params->pgConfig.fragmentCount = pgConfig.fragmentCount; + params->pgConfig.inputMainFrame = pgConfig.inputMainFrame; + params->pgConfig.outputMainFrame = pgConfig.outputMainFrame; + + params->pgConfig.pgManifestSize = pgConfig.pgManifestSize; + MEMCPY_S(params->pgManifestData, sizeof(params->pgManifestData), pgConfig.pgManifest, + pgConfig.pgManifestSize); + + params->disableDataTermialsCount = pgConfig.disableDataTermials.size(); + CheckAndLogError(params->disableDataTermialsCount > IPU_MAX_TERMINAL_COUNT, false, + "@%s, disableDataTermials cound: %d is big", __func__, + params->disableDataTermialsCount); + memset(params->disableDataTermialsData, -1, sizeof(params->disableDataTermialsData)); + for (int i = 0; i < params->disableDataTermialsCount; i++) { + params->disableDataTermialsData[i] = pgConfig.disableDataTermials[i]; + } + + return true; +} + +bool IPCIntelPGParam::serverUnflattenInit(void* pData, int dataSize, int* pgId, uintptr_t* client, + ia_p2p_platform_t* platform, PgConfiguration* pgConfig) { + CheckAndLogError(!pData || !pgId || !client || !platform || !pgConfig || + dataSize < sizeof(pg_param_init_params), + false, + "@%s, Wrong parameters, pData: %p, pgId: %p, client: %p, platform: %p, " + "pgConfig: %p, dataSize: %d", + __func__, pData, pgId, client, platform, pgConfig, dataSize); + + pg_param_init_params* params = static_cast(pData); + *pgId = params->pgId; + *client = params->client; + *platform = params->platform; + + pgConfig->fragmentCount = params->pgConfig.fragmentCount; + pgConfig->inputMainFrame = params->pgConfig.inputMainFrame; + pgConfig->outputMainFrame = params->pgConfig.outputMainFrame; + pgConfig->pgManifestSize = params->pgConfig.pgManifestSize; + void* dataPtr = static_cast(params->pgManifestData); + pgConfig->pgManifest = static_cast(dataPtr); + + pgConfig->disableDataTermials.clear(); + CheckAndLogError(params->disableDataTermialsCount > IPU_MAX_TERMINAL_COUNT, false, + "@%s, disableDataTermials cound: %d is big", __func__, + params->disableDataTermialsCount); + for (int i = 0; i < params->disableDataTermialsCount; i++) { + pgConfig->disableDataTermials.push_back(params->disableDataTermialsData[i]); + } + + return true; +} + +bool IPCIntelPGParam::clientFlattenPrepare(void* pData, int dataSize, uintptr_t client, + unsigned int ipuParamSize, int32_t ipuParamHandle, + const ia_css_rbm_t* rbm) { + CheckAndLogError(!pData || dataSize < sizeof(pg_param_prepare_params), false, + "@%s, Wrong parameters, pData: %p, dataSize: %d", __func__, pData, dataSize); + + pg_param_prepare_params* params = static_cast(pData); + params->client = client; + params->ipuParamSize = ipuParamSize; + params->ipuParamHandle = ipuParamHandle; + + if (rbm) { + params->rbm = ¶ms->rbmData; + MEMCPY_S(¶ms->rbmData, sizeof(params->rbmData), rbm, sizeof(*rbm)); + } else { + params->rbm = nullptr; + } + + return true; +} + +bool IPCIntelPGParam::serverUnflattenPrepare(void* pData, int dataSize, uintptr_t* client, + void* palDataAddr, ia_binary_data* ipuParameters, + ia_css_rbm_t** rbm, ia_css_kernel_bitmap_t** bitmap, + uint32_t** maxStatsSize) { + CheckAndLogError(!pData || !client || !ipuParameters || !rbm || !bitmap || !palDataAddr || + dataSize < sizeof(pg_param_prepare_params), + false, + "@%s, Wrong parameters, pData: %p, client: %p, ipuParameters: %p, rbm: %p, " + "bitmap: %p, palDataAddr: %p, dataSize: %d", + __func__, pData, client, ipuParameters, rbm, bitmap, palDataAddr, dataSize); + + pg_param_prepare_params* params = static_cast(pData); + *client = params->client; + ipuParameters->size = params->ipuParamSize; + ipuParameters->data = palDataAddr; + *rbm = params->rbm ? ¶ms->rbmData : nullptr; + *bitmap = ¶ms->bitmapData; + if (maxStatsSize) *maxStatsSize = ¶ms->maxStatsSize; + return true; +} + +bool IPCIntelPGParam::clientUnflattenPrepare(const void* pData, int dataSize, + ia_css_kernel_bitmap_t* bitmap, + uint32_t* maxStatsSize) { + CheckAndLogError(!pData || !bitmap || dataSize < sizeof(pg_param_prepare_params), false, + "@%s, Wrong parameters, pData: %p, bitmap: %p, dataSize: %d", __func__, pData, + bitmap, dataSize); + + const pg_param_prepare_params* params = static_cast(pData); + MEMCPY_S(bitmap, sizeof(*bitmap), ¶ms->bitmapData, sizeof(params->bitmapData)); + + if (maxStatsSize) *maxStatsSize = params->maxStatsSize; + return true; +} + +int IPCIntelPGParam::getTotalPGBufferSize(int pgSize) { + int size = sizeof(pg_param_allocate_pg_params); + size += PAGE_ALIGN(pgSize); + return size; +} + +bool IPCIntelPGParam::assignPGBuffer(void* pData, int dataSize, int pgSize, void** pgBuffer) { + CheckAndLogError(!pData || !pgBuffer || dataSize < pgSize, false, + "@%s, Wrong parameters, pData: %p, pgBuffer: %p, dataSize: %d, pgSize: %d", + __func__, pData, pgBuffer, dataSize, pgSize); + + uintptr_t pgAddr = reinterpret_cast(pData); + CheckAndLogError(pgAddr & ((getpagesize() - 1)), false, "@%s, pg addr is not aligned", + __func__); + *pgBuffer = pData; + return true; +} + +bool IPCIntelPGParam::clientFlattenAllocatePGBuffer(void* pData, int dataSize, uintptr_t client, + int pgSize) { + CheckAndLogError(!pData, false, "@%s, pData is nullptr", __func__); + uintptr_t paramAddr = + reinterpret_cast(pData) + dataSize - sizeof(pg_param_allocate_pg_params); + CheckAndLogError(paramAddr < reinterpret_cast(pData) + pgSize, false, + "@%s, dataSize: %d is small", __func__, dataSize); + + pg_param_allocate_pg_params* params = reinterpret_cast(paramAddr); + params->client = client; + params->pgSize = pgSize; + + return true; +} + +bool IPCIntelPGParam::serverUnflattenAllocatePGBuffer(const void* pData, int dataSize, + uintptr_t* client, int* pgSize) { + CheckAndLogError(!pData || !client || !pgSize || dataSize < sizeof(pg_param_allocate_pg_params), + false, + "@%s, Wrong parameters, pData: %p, client: %p, pgSize: %p, dataSize: %d", + __func__, pData, client, pgSize, dataSize); + uintptr_t paramAddr = + reinterpret_cast(pData) + dataSize - sizeof(pg_param_allocate_pg_params); + pg_param_allocate_pg_params* params = reinterpret_cast(paramAddr); + CheckAndLogError(paramAddr < reinterpret_cast(pData) + params->pgSize, false, + "@%s, dataSize is small", __func__); + *client = params->client; + *pgSize = params->pgSize; + + return true; +} + +bool IPCIntelPGParam::clientFlattenGetFragDescs(void* pData, int dataSize, uintptr_t client, + int descCount) { + CheckAndLogError(!pData || dataSize < sizeof(pg_param_get_fragment_desc_params), false, + "@%s, Wrong parameters, pData: %p, dataSize: %d", __func__, pData, dataSize); + + pg_param_get_fragment_desc_params* params = + static_cast(pData); + CheckAndLogError(descCount > sizeof(params->descsData), false, "@%s, descCount: %d is big", + __func__, descCount); + + params->client = client; + params->descCount = descCount; + return true; +} + +bool IPCIntelPGParam::serverUnflattenGetFragDescs(void* pData, int dataSize, uintptr_t* client, + int* descCount, ia_p2p_fragment_desc** descs) { + CheckAndLogError(!pData || !client || !descCount || !descs || + dataSize < sizeof(pg_param_get_fragment_desc_params), + false, + "@%s, Wrong parameters, pData: %p, client: %p, descCount: %p, " + "descs: %p, dataSize: %d", + __func__, pData, client, descCount, descs, dataSize); + + pg_param_get_fragment_desc_params* params = + static_cast(pData); + *client = params->client; + *descCount = params->descCount; + *descs = params->descsData; + return true; +} + +bool IPCIntelPGParam::serverFlattenGetFragDescs(void* pData, int dataSize, int count) { + CheckAndLogError(!pData || dataSize < sizeof(pg_param_get_fragment_desc_params), false, + "@%s, Wrong parameters, pData: %p, dataSize: %d", __func__, pData, dataSize); + + pg_param_get_fragment_desc_params* params = + static_cast(pData); + params->returnCount = count; + return true; +} + +bool IPCIntelPGParam::clientUnflattenGetFragDescs(const void* pData, int dataSize, int* count, + ia_p2p_fragment_desc* descs) { + CheckAndLogError( + !pData || !count || !descs || dataSize < sizeof(pg_param_get_fragment_desc_params), false, + "@%s, Wrong parameters, pData: %p, count: %p, descs: %p, dataSize: %d", __func__, pData, + count, descs, dataSize); + + const pg_param_get_fragment_desc_params* params = + static_cast(pData); + *count = params->returnCount; + MEMCPY_S(descs, sizeof(ia_p2p_fragment_desc) * params->descCount, params->descsData, + sizeof(params->descsData)); + return true; +} + +bool IPCIntelPGParam::clientFlattenPrepareProgram(void* pData, int dataSize, uintptr_t client) { + CheckAndLogError(!pData || dataSize < sizeof(pg_param_prepare_program_params), false, + "@%s, Wrong parameters, pData: %p, dataSize: %d", __func__, pData, dataSize); + + pg_param_prepare_program_params* params = static_cast(pData); + params->client = client; + return true; +} + +bool IPCIntelPGParam::serverUnflattenPrepareProgram(const void* pData, int dataSize, + uintptr_t* client) { + CheckAndLogError(!pData || !client || dataSize < sizeof(pg_param_prepare_program_params), false, + "@%s, Wrong parameters, pData: %p, client: %p, dataSize: %d", __func__, pData, + client, dataSize); + + const pg_param_prepare_program_params* params = + static_cast(pData); + *client = params->client; + return true; +} + +bool IPCIntelPGParam::serverFlattenPrepareProgram(void* pData, int dataSize, int payloadCount, + const ia_binary_data* payloads) { + CheckAndLogError(!pData || !payloads || dataSize < sizeof(pg_param_prepare_program_params) || + payloadCount > IPU_MAX_TERMINAL_COUNT, + false, + "@%s, Wrong parameters, pData: %p, payloads: %p, dataSize: %d, count: %d", + __func__, pData, payloads, dataSize, payloadCount); + + pg_param_prepare_program_params* params = static_cast(pData); + params->payloadCount = payloadCount; + MEMCPY_S(params->payloads, sizeof(ia_binary_data) * payloadCount, payloads, + sizeof(ia_binary_data) * payloadCount); + return true; +} + +bool IPCIntelPGParam::clientUnflattenPrepareProgram(const void* pData, int dataSize, + int* payloadCount, ia_binary_data* payloads) { + CheckAndLogError(!pData || !payloads || dataSize < sizeof(pg_param_prepare_program_params), + false, "@%s, Wrong parameters, pData: %p, payloads: %p, dataSize: %d", + __func__, pData, payloads, dataSize); + + const pg_param_prepare_program_params* params = + static_cast(pData); + + CheckAndLogError(*payloadCount < params->payloadCount, false, "@%s, payloadCount is small", + __func__); + *payloadCount = params->payloadCount; + for (int i = 0; i < params->payloadCount; i++) { + payloads[i].size = params->payloads[i].size; + payloads[i].data = nullptr; + } + return true; +} + +int IPCIntelPGParam::getTotalPayloadSize(int payloadCount, const ia_binary_data* payloads) { + CheckAndLogError(!payloads, 0, "@%s, payloads is nullptr", __func__); + int size = sizeof(pg_param_register_payloads_params); + for (int i = 0; i < payloadCount; i++) { + if (payloads[i].size) { + size += PAGE_ALIGN(payloads[i].size); + } + } + return size; +} + +bool IPCIntelPGParam::assignPayloads(void* pData, int dataSize, int payloadCount, + ia_binary_data* payloads) { + CheckAndLogError(!pData || !payloads, false, "@%s, pData: %p, payloads: %p is nullptr", + __func__, pData, payloads); + + uintptr_t payloadAddr = reinterpret_cast(pData); + CheckAndLogError(payloadAddr & ((getpagesize() - 1)), false, "@%s, payload addr is not aligned", + __func__); + for (int i = 0; i < payloadCount; i++) { + if (payloads[i].size > 0) { + CheckAndLogError(payloadAddr > reinterpret_cast(pData) + dataSize, false, + "@%s, buffer is small", __func__); + payloads[i].data = reinterpret_cast(payloadAddr); + payloadAddr += PAGE_ALIGN(payloads[i].size); + } + } + return true; +} + +bool IPCIntelPGParam::clientFlattenRegisterPayloads(void* pData, int dataSize, uintptr_t client, + int payloadCount, + const ia_binary_data* payloads) { + CheckAndLogError(!pData || !payloads || dataSize < sizeof(pg_param_register_payloads_params) || + payloadCount > IPU_MAX_TERMINAL_COUNT, + false, + "@%s, Wrong parameters, pData: %p, payloads: %p, dataSize: %d, count: %d", + __func__, pData, payloads, dataSize, payloadCount); + + uintptr_t paramAddr = + reinterpret_cast(pData) + dataSize - sizeof(pg_param_register_payloads_params); + pg_param_register_payloads_params* params = + reinterpret_cast(paramAddr); + params->client = client; + params->payloadCount = payloadCount; + MEMCPY_S(params->cPayloads, sizeof(params->cPayloads), payloads, + sizeof(ia_binary_data) * payloadCount); + getPayloadOffsets(pData, dataSize, payloadCount, payloads, params->payloadOffsets); + return true; +} + +bool IPCIntelPGParam::serverUnflattenRegisterPayloads(void* pData, int dataSize, uintptr_t* client, + int* payloadCount, ia_binary_data** cPayloads, + ia_binary_data** sPayloads) { + CheckAndLogError(!pData || !client || !payloadCount || !cPayloads || !sPayloads || + dataSize < sizeof(pg_param_register_payloads_params), + false, + "@%s, Wrong parameters, pData: %p, client: %p, payloadCount: %p, " + "cPayloads: %p, sPayloads: %p, dataSize: %d", + __func__, pData, client, payloadCount, cPayloads, sPayloads, dataSize); + + uintptr_t paramAddr = + reinterpret_cast(pData) + dataSize - sizeof(pg_param_register_payloads_params); + pg_param_register_payloads_params* params = + reinterpret_cast(paramAddr); + *client = params->client; + MEMCPY_S(params->sPayloads, sizeof(params->sPayloads), params->cPayloads, + sizeof(params->cPayloads)); // save size to sPayloads + *payloadCount = params->payloadCount; + getPayloadData(pData, dataSize, *payloadCount, params->payloadOffsets, params->sPayloads); + *cPayloads = params->cPayloads; + *sPayloads = params->sPayloads; + return true; +} + +bool IPCIntelPGParam::getPayloadOffsets(const void* pData, int dataSize, int payloadCount, + const ia_binary_data* payloads, int32_t* payloadOffsets) { + CheckAndLogError(!pData || !payloads || !payloadOffsets, false, + "@%s, pData: %p, payloads: %p, payloadOffsets: %p is nullptr", __func__, pData, + payloads); + + uintptr_t startAddr = reinterpret_cast(pData); + for (int i = 0; i < payloadCount; i++) { + if (payloads[i].size <= 0) continue; + + int32_t offset = reinterpret_cast(payloads[i].data) - startAddr; + CheckAndLogError((offset > (dataSize - payloads[i].size) || offset < 0), false, + "@%s, error offset %d", __func__, offset); + payloadOffsets[i] = offset; + } + return 0; +} + +bool IPCIntelPGParam::getPayloadData(void* pData, int dataSize, int payloadCount, + const int32_t* payloadOffsets, ia_binary_data* payloads) { + CheckAndLogError(!pData || !payloads || !payloadOffsets, false, + "@%s, pData: %p, payloads: %p, payloadOffsets: %p is nullptr", __func__, pData, + payloads, payloadOffsets); + + unsigned char* startAddr = reinterpret_cast(pData); + for (int i = 0; i < payloadCount; i++) { + if (payloads[i].size <= 0) continue; + + CheckAndLogError(payloadOffsets[i] > dataSize - payloads[i].size, false, + "@%s, error offset %d", __func__, payloadOffsets[i]); + payloads[i].data = startAddr + payloadOffsets[i]; + } + return true; +} + +bool IPCIntelPGParam::clientFlattenEncode(void* pData, int dataSize, uintptr_t client, + unsigned int ipuParamSize, int32_t ipuParamHandle, + int32_t payloadCount, const ia_binary_data* payloads) { + CheckAndLogError(!pData || !payloads || dataSize < sizeof(pg_param_encode_params) || + payloadCount > IPU_MAX_TERMINAL_COUNT, + false, + "@%s, Wrong parameters, pData: %p, payloads: %p, dataSize: %d, count: %d", + __func__, pData, payloads, dataSize, payloadCount); + + pg_param_encode_params* params = static_cast(pData); + params->client = client; + params->ipuParamSize = ipuParamSize; + params->ipuParamHandle = ipuParamHandle; + params->payloadCount = payloadCount; + MEMCPY_S(params->payloads, sizeof(params->payloads), payloads, + sizeof(ia_binary_data) * payloadCount); + return true; +} + +bool IPCIntelPGParam::serverUnflattenEncode(void* pData, int dataSize, uintptr_t* client, + void* palDataAddr, ia_binary_data* ipuParameters, + int32_t* payloadCount, ia_binary_data** payloads) { + CheckAndLogError(!pData || !client || !ipuParameters || !palDataAddr || !payloadCount || + !payloads || dataSize < sizeof(pg_param_encode_params), + false, + "@%s, Wrong parameters, pData: %p, client: %p, ipuParameters: %p, " + "palDataAddr: %p, payloadCount: %p, payloads: %p, dataSize: %d", + __func__, pData, client, ipuParameters, palDataAddr, payloadCount, payloads, + dataSize); + + pg_param_encode_params* params = static_cast(pData); + *client = params->client; + ipuParameters->size = params->ipuParamSize; + ipuParameters->data = palDataAddr; + *payloadCount = params->payloadCount; + *payloads = params->payloads; + return true; +} + +bool IPCIntelPGParam::clientFlattenDecode(void* pData, int dataSize, uintptr_t client, + int32_t payloadCount, const ia_binary_data* payloads, + int32_t statsHandle) { + CheckAndLogError(!pData || !payloads || dataSize < sizeof(pg_param_decode_params) || + payloadCount > IPU_MAX_TERMINAL_COUNT, + false, + "@%s, Wrong parameters, pData: %p, payloads: %p, dataSize: %d, count: %d", + __func__, pData, payloads, dataSize, payloadCount); + + pg_param_decode_params* params = static_cast(pData); + params->client = client; + params->payloadCount = payloadCount; + MEMCPY_S(params->payloads, sizeof(params->payloads), payloads, + sizeof(ia_binary_data) * payloadCount); + params->clientStatsHandle = statsHandle; + return true; +} + +bool IPCIntelPGParam::serverUnflattenDecode(void* pData, int dataSize, uintptr_t* client, + int32_t* payloadCount, ia_binary_data** payloads) { + CheckAndLogError(!pData || !client || !payloadCount || !payloads || + dataSize < sizeof(pg_param_decode_params), + false, + "@%s, Wrong parameters, pData: %p, client: %p, payloadCount: %p, " + "payloads: %p, dataSize: %d", + __func__, pData, client, payloadCount, payloads, dataSize); + + pg_param_decode_params* params = static_cast(pData); + *client = params->client; + *payloadCount = params->payloadCount; + *payloads = params->payloads; + return true; +} + +bool IPCIntelPGParam::serverFlattenDecode(void* pData, int dataSize, + const ia_binary_data& statistics) { + CheckAndLogError(!pData || dataSize < sizeof(pg_param_decode_params), false, + "@%s, Wrong parameters, pData: %p, dataSize: %d", __func__, pData, dataSize); + pg_param_decode_params* params = static_cast(pData); + params->statsSize = statistics.size; + return true; +} + +bool IPCIntelPGParam::clientUnflattenDecode(void* pData, int dataSize, ia_binary_data* statistics) { + CheckAndLogError(!pData || !statistics || dataSize < sizeof(pg_param_decode_params), false, + "@%s, Wrong parameters, pData: %p, statistics: %p, dataSize: %d", __func__, + pData, statistics, dataSize); + + pg_param_decode_params* params = static_cast(pData); + statistics->size = params->statsSize; + return true; +} + +bool IPCIntelPGParam::clientFlattenDeinit(void* pData, int dataSize, uintptr_t client) { + CheckAndLogError(!pData || dataSize < sizeof(pg_param_deinit_params), false, + "@%s, Wrong parameters, pData: %p, dataSize: %d", __func__, pData, dataSize); + + pg_param_deinit_params* params = static_cast(pData); + params->client = client; + + return true; +} + +bool IPCIntelPGParam::serverUnflattenDeinit(const void* pData, int dataSize, uintptr_t* client) { + CheckAndLogError(!pData || !client || dataSize < sizeof(pg_param_deinit_params), false, + "@%s, Wrong parameters, pData: %p, client: %p, dataSize: %d", __func__, pData, + client, dataSize); + + const pg_param_deinit_params* params = static_cast(pData); + *client = params->client; + + return true; +} + +} // namespace icamera diff --git a/modules/sandboxing/IPCIntelPGParam.h b/modules/sandboxing/IPCIntelPGParam.h new file mode 100644 index 00000000..c783920c --- /dev/null +++ b/modules/sandboxing/IPCIntelPGParam.h @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "modules/sandboxing/IPCCommon.h" +#include "src/core/psysprocessor/PGUtils.h" + +#include "CameraTypes.h" +#include "modules/sandboxing/IPCIntelCca.h" + +namespace icamera { + +#define MAX_PROCESS_GROUP_SIZE 8192 +#define MAX_PAL_SIZE 0x800000 // 8M +#define MAX_STATISTICS_SIZE MAX_IA_BINARY_DATA_SIZE + +struct pg_param_init_params { + int pgId; + uintptr_t client; + ia_p2p_platform_t platform; + PgConfiguration pgConfig; + unsigned char pgManifestData[MAX_PROCESS_GROUP_SIZE]; + int disableDataTermialsData[IPU_MAX_TERMINAL_COUNT]; + int disableDataTermialsCount; +}; + +struct pg_param_prepare_params { + uintptr_t client; + uint32_t ipuParamSize; + int32_t ipuParamHandle; + ia_css_rbm_t* rbm; + ia_css_rbm_t rbmData; + + // Output + ia_css_kernel_bitmap_t bitmapData; + uint32_t maxStatsSize; +}; + +// Shared memory: pg + struct +// as pg memory addr should be page size aligned +struct pg_param_allocate_pg_params { + uintptr_t client; + int pgSize; +}; + +struct pg_param_get_fragment_desc_params { + uintptr_t client; + int descCount; + + // Output + int returnCount; + ia_p2p_fragment_desc descsData[IPU_MAX_TERMINAL_COUNT * IA_P2P_MAX_FRAGMENTS]; +}; + +struct pg_param_prepare_program_params { + uintptr_t client; + + // Output + int payloadCount; + ia_binary_data payloads[IPU_MAX_TERMINAL_COUNT]; // save size of payloads +}; + +// Shared memory: payloads + struct +// as payload memory addr should be page size aligned +struct pg_param_register_payloads_params { + uintptr_t client; + int payloadCount; + ia_binary_data cPayloads[IPU_MAX_TERMINAL_COUNT]; // save payloads of client + ia_binary_data sPayloads[IPU_MAX_TERMINAL_COUNT]; // save payloads of server + + int32_t payloadOffsets[IPU_MAX_TERMINAL_COUNT]; +}; + +struct pg_param_encode_params { + uintptr_t client; + uint32_t ipuParamSize; + int32_t ipuParamHandle; + int32_t payloadCount; + ia_binary_data payloads[IPU_MAX_TERMINAL_COUNT]; // save payloads of client +}; + +struct pg_param_decode_params { + uintptr_t client; + int32_t payloadCount; + ia_binary_data payloads[IPU_MAX_TERMINAL_COUNT]; // save payloads of client + int32_t clientStatsHandle; + + // Output + uint32_t statsSize; + + // For stats decoding together + intel_cca_decode_stats_data decodeStatsParams; + bool hasStatsDecode; +}; + +struct pg_param_deinit_params { + uintptr_t client; +}; + +class IPCIntelPGParam { + public: + IPCIntelPGParam() {} + virtual ~IPCIntelPGParam() {} + + bool clientFlattenInit(void* pData, int dataSize, int pgId, uintptr_t client, + ia_p2p_platform_t platform, const PgConfiguration& pgConfig); + bool serverUnflattenInit(void* pData, int dataSize, int* pgId, uintptr_t* client, + ia_p2p_platform_t* platform, PgConfiguration* pgConfig); + + bool clientFlattenPrepare(void* pData, int dataSize, uintptr_t client, + unsigned int ipuParamSize, int32_t ipuParamHandle, + const ia_css_rbm_t* rbm); + bool serverUnflattenPrepare(void* pData, int dataSize, uintptr_t* client, void* palDataAddr, + ia_binary_data* ipuParameters, ia_css_rbm_t** rbm, + ia_css_kernel_bitmap_t** bitmap, uint32_t** maxStatsSize); + bool clientUnflattenPrepare(const void* pData, int dataSize, ia_css_kernel_bitmap_t* bitmap, + uint32_t* maxStatsSize = nullptr); + + int getTotalPGBufferSize(int pgSize); + bool assignPGBuffer(void* pData, int dataSize, int pgSize, void** pgBuffer); + bool clientFlattenAllocatePGBuffer(void* pData, int dataSize, uintptr_t client, int pgSize); + bool serverUnflattenAllocatePGBuffer(const void* pData, int dataSize, uintptr_t* client, + int* pgSize); + + bool clientFlattenGetFragDescs(void* pData, int dataSize, uintptr_t client, int descCount); + bool serverUnflattenGetFragDescs(void* pData, int dataSize, uintptr_t* client, int* descCount, + ia_p2p_fragment_desc** descs); + bool serverFlattenGetFragDescs(void* pData, int dataSize, int count); + bool clientUnflattenGetFragDescs(const void* pData, int dataSize, int* count, + ia_p2p_fragment_desc* descs); + + bool clientFlattenPrepareProgram(void* pData, int dataSize, uintptr_t client); + bool serverUnflattenPrepareProgram(const void* pData, int dataSize, uintptr_t* client); + bool serverFlattenPrepareProgram(void* pData, int dataSize, int payloadCount, + const ia_binary_data* payloads); + bool clientUnflattenPrepareProgram(const void* pData, int dataSize, int* payloadCount, + ia_binary_data* payloads); + + int getTotalPayloadSize(int payloadCount, const ia_binary_data* payloads); + bool assignPayloads(void* pData, int dataSize, int payloadCount, ia_binary_data* payloads); + bool clientFlattenRegisterPayloads(void* pData, int dataSize, uintptr_t client, + int payloadCount, const ia_binary_data* payloads); + bool serverUnflattenRegisterPayloads(void* pData, int dataSize, uintptr_t* client, + int* payloadCount, ia_binary_data** cPayloads, + ia_binary_data** sPayloads); + + bool clientFlattenEncode(void* pData, int dataSize, uintptr_t client, unsigned int ipuParamSize, + int32_t ipuParamHandle, int32_t payloadCount, + const ia_binary_data* payloads); + bool serverUnflattenEncode(void* pData, int dataSize, uintptr_t* client, void* palDataAddr, + ia_binary_data* ipuParameters, int32_t* payloadCount, + ia_binary_data** payloads); + + bool clientFlattenDecode(void* pData, int dataSize, uintptr_t client, int32_t payloadCount, + const ia_binary_data* payloads, int32_t statsHandle); + bool serverUnflattenDecode(void* pData, int dataSize, uintptr_t* client, int32_t* payloadCount, + ia_binary_data** payloads); + bool serverFlattenDecode(void* pData, int dataSize, const ia_binary_data& statistics); + bool clientUnflattenDecode(void* pData, int dataSize, ia_binary_data* statistics); + + bool clientFlattenDeinit(void* pData, int dataSize, uintptr_t client); + bool serverUnflattenDeinit(const void* pData, int dataSize, uintptr_t* client); + + private: + bool getPayloadOffsets(const void* pData, int dataSize, int payloadCount, + const ia_binary_data* payloads, int32_t* payloadOffsets); + bool getPayloadData(void* pData, int dataSize, int payloadCount, const int32_t* payloadOffsets, + ia_binary_data* payloads); +}; + +} // namespace icamera diff --git a/modules/sandboxing/client/CMakeLists.txt b/modules/sandboxing/client/CMakeLists.txt new file mode 100644 index 00000000..c4c1c477 --- /dev/null +++ b/modules/sandboxing/client/CMakeLists.txt @@ -0,0 +1,28 @@ +# +# Copyright (C) 2019-2021 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set(SANDBOXING_CLIENT_SRCS + ${SANDBOXING_DIR}/client/IntelAlgoClient.cpp + ${SANDBOXING_DIR}/client/IntelAlgoCommonClient.cpp + ${SANDBOXING_DIR}/client/IntelLard.cpp + ${SANDBOXING_DIR}/client/IntelFaceDetectionClient.cpp + ${SANDBOXING_DIR}/client/GraphConfigImplClient.cpp + ${SANDBOXING_DIR}/IPCCommon.cpp + ${SANDBOXING_DIR}/IPCIntelLard.cpp + ${SANDBOXING_DIR}/IPCIntelFD.cpp + ${SANDBOXING_DIR}/IPCGraphConfig.cpp + CACHE INTERNAL "sandboxing sources" + ) diff --git a/modules/sandboxing/client/GraphConfigImplClient.cpp b/modules/sandboxing/client/GraphConfigImplClient.cpp new file mode 100644 index 00000000..d8878d15 --- /dev/null +++ b/modules/sandboxing/client/GraphConfigImplClient.cpp @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG GraphConfigImplClient + +#include "modules/sandboxing/client/GraphConfigImplClient.h" + +#include "iutils/CameraLog.h" + +using std::map; +using std::string; +using std::vector; + +namespace icamera { + +GraphConfigImpl::GraphConfigImpl() : mCameraId(-1), mInitialized(false) { + uintptr_t personal = reinterpret_cast(this); + std::string parseName = "/graphParse" + std::to_string(personal) + "Shm"; + + mMems = {{parseName.c_str(), sizeof(GraphParseParams), &mMemParse, false}}; + + bool success = mCommon.allocateAllShmMems(&mMems); + if (!success) { + mCommon.releaseAllShmMems(mMems); + return; + } + + mInitialized = true; + LOG1(" %s Construct done", mCameraId, __func__); +} + +GraphConfigImpl::GraphConfigImpl(int32_t camId, ConfigMode mode, GraphSettingType type) + : mCameraId(camId), + mConfigMode(mode), + mType(type), + mInitialized(false) { + uintptr_t personal = reinterpret_cast(this); + std::string queryGraphSettings = "/graphQueryGraph" + std::to_string(personal) + "Shm"; + std::string configStreamsName = "/graphConfigStreams" + std::to_string(personal) + "Shm"; + std::string getGraphDataName = "/graphGetData" + std::to_string(personal) + "Shm"; + std::string getPgIdName = "/graphGetPgId" + std::to_string(personal) + "Shm"; + std::string getConnection = "/graphGetConnection" + std::to_string(personal) + "Shm"; + + mMems = { + {queryGraphSettings.c_str(), sizeof(GraphQueryGraphParams), &mMemQueryGraphSettings, false}, + {configStreamsName.c_str(), sizeof(GraphConfigStreamParams), &mMemConfig, false}, + {getGraphDataName.c_str(), sizeof(GraphGetDataParams), &mMemGetData, false}, + {getPgIdName.c_str(), sizeof(GraphGetPgIdParams), &mMemGetPgId, false}, + {getConnection.c_str(), sizeof(GraphGetConnectionParams), &mMemGetConnection, false}}; + + bool success = mCommon.allocateAllShmMems(&mMems); + if (!success) { + mCommon.releaseAllShmMems(mMems); + return; + } + + mInitialized = true; + LOG1(" %s Construct done, configMode: %d, type %d", mCameraId, __func__, mConfigMode, + mType); +} + +GraphConfigImpl::~GraphConfigImpl() { + LOG1(" %s Destroy, configMode: %d, type %d", mCameraId, __func__, mConfigMode, mType); + + mInitialized = false; + mCommon.releaseAllShmMems(mMems); + mMems.clear(); +} + +void GraphConfigImpl::addCustomKeyMap() { + LOG1(" Add Custom KeyMap", mCameraId); + CheckAndLogError(!mInitialized, VOID_VALUE, "addCustomKeyMap mInitialized is false"); + + bool ret = mCommon.requestSync(IPC_GRAPH_ADD_KEY); + CheckAndLogError(!ret, VOID_VALUE, "addCustomKeyMap requestSync fails"); +} + +status_t GraphConfigImpl::parse(int cameraId, const char* graphDescFile, const char* settingsFile) { + LOG1(" Parse GD file %s and setting file %s", cameraId, graphDescFile, settingsFile); + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "parse mInitialized is false"); + + bool ret = mIpc.clientFlattenParse(mMemParse.mAddr, mMemParse.mSize, cameraId, graphDescFile, + settingsFile); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientFlattenParse fails"); + + status_t rt = mCommon.requestSync(IPC_GRAPH_PARSE, mMemParse.mHandle); + CheckAndLogError(!rt, UNKNOWN_ERROR, "parse requestSync fails"); + + return OK; +} + +void GraphConfigImpl::releaseGraphNodes() { + CheckAndLogError(!mInitialized, VOID_VALUE, "releaseGraphNodes mInitialized is false"); + + bool ret = mCommon.requestSync(IPC_GRAPH_RELEASE_NODES); + CheckAndLogError(!ret, VOID_VALUE, "releaseGraphNodes requestSync fails"); +} + +bool GraphConfigImpl::queryGraphSettings(const vector& activeStreams) { + CheckAndLogError(!mInitialized, false, "queryGraphSettings mInitialized is false"); + + GraphBaseInfo info = {mCameraId, mConfigMode}; + memset(mMemQueryGraphSettings.mAddr, 0, sizeof(GraphQueryGraphParams)); + bool ret = mIpc.clientFlattenConfigStreams(mMemQueryGraphSettings.mAddr, mMemConfig.mSize, info, + mType, false, activeStreams); + CheckAndLogError(!ret, false, "clientFlattenConfigStreams fails"); + + ret = mCommon.requestSync(IPC_GRAPH_QUERY_GRAPH_SETTINGS, mMemQueryGraphSettings.mHandle); + CheckAndLogError(!ret, false, "queryGraphSettings requestSync fails"); + + GraphQueryGraphParams* params = + static_cast(mMemQueryGraphSettings.mAddr); + return params->isHasGraphSettings; +} + +status_t GraphConfigImpl::configStreams(const vector& activeStreams, + bool dummyStillSink) { + LOG1(" %s, dummyStillSink: %d", mCameraId, __func__, dummyStillSink); + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "configStreams mInitialized is false"); + + GraphBaseInfo info = {mCameraId, mConfigMode}; + bool ret = mIpc.clientFlattenConfigStreams(mMemConfig.mAddr, mMemConfig.mSize, info, mType, + dummyStillSink, activeStreams); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientFlattenConfigStreams fails"); + + ret = mCommon.requestSync(IPC_GRAPH_CONFIG_STREAMS, mMemConfig.mHandle); + CheckAndLogError(!ret, UNKNOWN_ERROR, "configStreams requestSync fails"); + + return OK; +} + +status_t GraphConfigImpl::getGraphConfigData(IGraphType::GraphConfigData* data) { + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "getGraphConfigData mInitialized is false"); + + GraphBaseInfo info = {mCameraId, mConfigMode}; + bool ret = mIpc.clientFlattenGetGraphData(mMemGetData.mAddr, mMemGetData.mSize, info); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientFlattenGetGraphData fails"); + + ret = mCommon.requestSync(IPC_GRAPH_GET_CONFIG_DATA, mMemGetData.mHandle); + CheckAndLogError(!ret, UNKNOWN_ERROR, "getGraphConfigData requestSync fails"); + + ret = mIpc.clientUnflattenGetGraphData(mMemGetData.mAddr, mMemGetData.mSize, data); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientUnflattenGetGraphData fails"); + + return OK; +} + +status_t GraphConfigImpl::pipelineGetConnections( + const std::vector& pgList, std::vector* scalerInfo, + std::vector* confVector, + std::vector* tnrPortFormat) { + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "GetConnections mInitialized is false"); + + GraphBaseInfo info = {mCameraId, mConfigMode}; + bool ret = mIpc.clientFlattenGetConnection(mMemGetConnection.mAddr, mMemGetConnection.mSize, + info, pgList); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientFlattenGetConnection fails"); + + ret = mCommon.requestSync(IPC_GRAPH_GET_CONNECTION, mMemGetConnection.mHandle); + CheckAndLogError(!ret, UNKNOWN_ERROR, "GetConnections requestSync fails"); + + ret = mIpc.clientUnFlattenGetConnection(mMemGetConnection.mAddr, mMemGetConnection.mSize, + scalerInfo, confVector, tnrPortFormat); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientUnFlattenGetConnection fails"); + + return OK; +} + +status_t GraphConfigImpl::getPgIdForKernel(const uint32_t streamId, const int32_t kernelId, + int32_t* pgId) { + LOG1(" getPgIdForKernel stream %d, kernel %d", mCameraId, streamId, kernelId); + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "@%s, mInitialized is false", __func__); + + GraphBaseInfo info = {mCameraId, mConfigMode}; + bool ret = + mIpc.clientFlattenGetPgId(mMemGetPgId.mAddr, mMemGetPgId.mSize, info, streamId, kernelId); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientFlattenGetPgId fails"); + + ret = mCommon.requestSync(IPC_GRAPH_GET_PG_ID, mMemGetPgId.mHandle); + CheckAndLogError(!ret, UNKNOWN_ERROR, "getPgId requestSync fails"); + + ret = mIpc.clientUnFlattenGetPgId(mMemGetPgId.mAddr, mMemGetPgId.mSize, pgId); + CheckAndLogError(!ret, UNKNOWN_ERROR, "clientUnFlattenGetPgId fails"); + + return OK; +} +} // namespace icamera diff --git a/modules/sandboxing/client/GraphConfigImplClient.h b/modules/sandboxing/client/GraphConfigImplClient.h new file mode 100644 index 00000000..1ae8df16 --- /dev/null +++ b/modules/sandboxing/client/GraphConfigImplClient.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +#include "IntelAlgoCommonClient.h" +#include "iutils/Errors.h" +#include "iutils/Thread.h" +#include "iutils/Utils.h" +#include "modules/sandboxing/IPCGraphConfig.h" +#include "src/platformdata/CameraTypes.h" +#include "src/platformdata/gc/HalStream.h" +#include "src/platformdata/gc/IGraphConfig.h" + +namespace icamera { + +class GraphConfigImpl { + public: + GraphConfigImpl(); + GraphConfigImpl(int32_t camId, ConfigMode mode, GraphSettingType type); + virtual ~GraphConfigImpl(); + + void addCustomKeyMap(); + status_t parse(int cameraId, const char* graphDescFile, const char* settingsFile); + void releaseGraphNodes(); + + bool queryGraphSettings(const std::vector& activeStreams); + status_t configStreams(const std::vector& activeStreams, bool dummyStillSink); + status_t getGraphConfigData(IGraphType::GraphConfigData* data); + status_t getPgIdForKernel(const uint32_t streamId, const int32_t kernelId, int32_t* pgId); + + status_t pipelineGetConnections(const std::vector& pgList, + std::vector* scalerInfo, + std::vector* confVector, + std::vector* tnrPortFormat); + + private: + IPCGraphConfig mIpc; + IntelAlgoCommon mCommon; + + ShmMemInfo mMemParse; + ShmMemInfo mMemQueryGraphSettings; + ShmMemInfo mMemConfig; + ShmMemInfo mMemGetData; + ShmMemInfo mMemGetPgId; + ShmMemInfo mMemGetConnection; + + std::vector mMems; + + int mCameraId; + ConfigMode mConfigMode; + GraphSettingType mType; + bool mInitialized; + + // Disable copy constructor and assignment operator + DISALLOW_COPY_AND_ASSIGN(GraphConfigImpl); +}; +} // namespace icamera diff --git a/modules/sandboxing/client/IntelAlgoClient.cpp b/modules/sandboxing/client/IntelAlgoClient.cpp new file mode 100644 index 00000000..6257bd8e --- /dev/null +++ b/modules/sandboxing/client/IntelAlgoClient.cpp @@ -0,0 +1,447 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelAlgoClient + +#include "modules/sandboxing/client/IntelAlgoClient.h" + +#include +#include +#include +#include + +#include +#include +#include + +#include "Parameters.h" +#include "PlatformData.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" +#include "modules/sandboxing/client/IntelCcaClient.h" + +namespace icamera { + +IntelAlgoClient* IntelAlgoClient::sInstance = nullptr; +Mutex IntelAlgoClient::sLock; + +IntelAlgoClient* IntelAlgoClient::getInstance() { + AutoMutex lock(sLock); + + if (!sInstance) { + sInstance = new IntelAlgoClient; + } + + return sInstance; +} + +void IntelAlgoClient::releaseInstance() { + AutoMutex lock(sLock); + + icamera::IntelCca::releaseAllInstances(); + + if (sInstance) { + delete sInstance; + sInstance = nullptr; + } +} + +IntelAlgoClient::IntelAlgoClient() + : mErrCb(nullptr), + mGpuBridge(nullptr), + mIPCStatus(true), + mMojoManagerToken(nullptr), + mInitialized(false) { + LOG1("%s, Construct", __func__); +} + +IntelAlgoClient::~IntelAlgoClient() { + LOG1("%s, Destroy", __func__); +} + +int IntelAlgoClient::initialize() { + LOG1("@%s, mMojoManagerToken: %p", __func__, mMojoManagerToken); + CheckAndLogError(!mMojoManagerToken, UNKNOWN_ERROR, "@%s, mMojoManagerToken is nullptr", + __func__); + + mCallback = base::BindRepeating(&IntelAlgoClient::callbackHandler, base::Unretained(this)); + IntelAlgoClient::return_callback = returnCallback; + + mNotifyCallback = base::BindRepeating(&IntelAlgoClient::notifyHandler, base::Unretained(this)); + IntelAlgoClient::notify = notifyCallback; + + mBridge = cros::CameraAlgorithmBridge::CreateInstance(cros::CameraAlgorithmBackend::kVendorCpu, + mMojoManagerToken); + CheckAndLogError(!mBridge, UNKNOWN_ERROR, "@%s, mBridge is nullptr", __func__); + CheckAndLogError(mBridge->Initialize(this) != 0, UNKNOWN_ERROR, "@%s, mBridge init fails", + __func__); + + if (PlatformData::isUsingGpuAlgo()) { + LOG1("GPU algo enabled"); + mGpuBridge = cros::CameraAlgorithmBridge::CreateInstance( + cros::CameraAlgorithmBackend::kVendorGpu, mMojoManagerToken); + CheckAndLogError(!mGpuBridge, UNKNOWN_ERROR, "mGpuBridge is nullptr"); + CheckAndLogError(mGpuBridge->Initialize(this) != 0, UNKNOWN_ERROR, "mGpuBridge init fails"); + } + + for (int i = 0; i < IPC_GROUP_NUM; i++) { + if (static_cast(i) < IPC_GROUP_GPU) { + mRunner[i] = + std::unique_ptr(new Runner(static_cast(i), mBridge.get())); + } else if (mGpuBridge) { + mRunner[i] = + std::unique_ptr(new Runner(static_cast(i), mGpuBridge.get())); + } + } + + mIPCStatus = true; + mInitialized = true; + + return OK; +} + +bool IntelAlgoClient::isIPCFine() { + std::lock_guard l(mIPCStatusMutex); + + return mIPCStatus; +} + +void IntelAlgoClient::registerErrorCallback(const camera_callback_ops_t* errCb) { + LOG1("@%s, errCb:%p", __func__, errCb); + + std::lock_guard l(mIPCStatusMutex); + mErrCb = errCb; + + if (!mIPCStatus && mErrCb) { + camera_msg_data_t data = {CAMERA_IPC_ERROR, {}}; + mErrCb->notify(mErrCb, data); + } +} + +int IntelAlgoClient::allocateShmMem(const std::string& name, int size, int* fd, void** addr) { + *fd = -1; + *addr = nullptr; + int shmFd = -1; + void* shmAddr = nullptr; + + shmFd = shm_open(name.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); + CheckAndLogError((shmFd == -1), UNKNOWN_ERROR, "call shm_open fail"); + + do { + int ret = fcntl(shmFd, F_GETFD); + if (ret == -1) { + LOGE("call fcntl fail, error %s", strerror(errno)); + break; + } + + ret = ftruncate(shmFd, size); + if (ret == -1) { + LOGE("call ftruncate fail, error %s", strerror(errno)); + break; + } + + struct stat sb; + ret = fstat(shmFd, &sb); + if (ret == -1) { + LOGE("call fstat fail, error %s", strerror(errno)); + break; + } + + shmAddr = mmap(0, sb.st_size, PROT_WRITE, MAP_SHARED, shmFd, 0); + if (!shmAddr) { + LOGE("call mmap fail, error %s", strerror(errno)); + break; + } + + *fd = shmFd; + *addr = shmAddr; + + return OK; + } while (0); + + close(shmFd); + return UNKNOWN_ERROR; +} + +void IntelAlgoClient::releaseShmMem(const std::string& name, int size, int fd, void* addr) { + munmap(addr, size); + close(fd); + shm_unlink(name.c_str()); +} + +int IntelAlgoClient::requestSync(IPC_CMD cmd, int32_t bufferHandle) { + LOG2("requestSync cmd:%d:%s, bufferHandle:%d, mInitialized:%d", cmd, + IntelAlgoIpcCmdToString(cmd), bufferHandle, mInitialized); + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, " mInitialized is false"); + CheckAndLogError(!isIPCFine(), UNKNOWN_ERROR, "IPC error happens"); + + IPC_GROUP group = IntelAlgoIpcCmdToGroup(cmd); + + return mRunner[group]->requestSync(cmd, bufferHandle); +} + +int IntelAlgoClient::requestSync(IPC_CMD cmd) { + return requestSync(cmd, -1); +} + +int32_t IntelAlgoClient::registerBuffer(int bufferFd, void* addr, ShmMemUsage usage) { + LOG2("%s bufferFd: %d, mInitialized: %d, addr: %p, usage: %d", __func__, bufferFd, mInitialized, + addr, usage); + CheckAndLogError(!mInitialized, -1, "mInitialized is false"); + CheckAndLogError(usage >= MAX_ALGO_SHM, -1, "usage: %d isn't supported", usage); + CheckAndLogError(!isIPCFine(), -1, "IPC error happens"); + + int32_t handle = -1; + if (usage == CPU_ALGO_SHM) { + handle = mBridge->RegisterBuffer(bufferFd); + } else if (mGpuBridge) { + handle = mGpuBridge->RegisterBuffer(bufferFd); + } + if (handle >= 0) { + std::lock_guard l(mShmMapMutex); + mShmMap[usage][addr] = handle; + } + + return handle; +} + +void IntelAlgoClient::deregisterBuffer(int32_t bufferHandle, ShmMemUsage usage) { + LOG2("%s, bufferHandle: %d, mInitialized: %d, usage: %d", __func__, bufferHandle, mInitialized, + usage); + CheckAndLogError(!mInitialized, VOID_VALUE, "mInitialized is false"); + CheckAndLogError(usage >= MAX_ALGO_SHM, VOID_VALUE, "usage: %d isn't supported", usage); + CheckAndLogError(!isIPCFine(), VOID_VALUE, "IPC error happens"); + + { + std::lock_guard l(mShmMapMutex); + for (auto& item : mShmMap[usage]) { + if (item.second == bufferHandle) { + mShmMap[usage].erase(item.first); + break; + } + } + } + + std::vector handles({bufferHandle}); + if (usage == CPU_ALGO_SHM) { + mBridge->DeregisterBuffers(handles); + } else if (mGpuBridge) { + mGpuBridge->DeregisterBuffers(handles); + } +} + +int32_t IntelAlgoClient::registerGbmBuffer(int bufferFd, ShmMemUsage usage) { + LOG2("%s bufferFd:%d, mInitialized:%d, usage:%d", __func__, bufferFd, mInitialized, usage); + CheckAndLogError(!mInitialized, -1, "mInitialized is false"); + CheckAndLogError(!isIPCFine(), -1, "IPC error happens"); + CheckAndLogError(usage >= MAX_ALGO_SHM, -1, "usage: %d isn't supported", usage); + + if (usage == CPU_ALGO_SHM) { + return mBridge->RegisterBuffer(bufferFd); + } else if (mGpuBridge) { + return mGpuBridge->RegisterBuffer(bufferFd); + } + return OK; +} + +void IntelAlgoClient::deregisterGbmBuffer(int32_t bufferHandle, ShmMemUsage usage) { + LOG1("%s bufferHandle:%d, mInitialized:%d, usage:%d", __func__, bufferHandle, mInitialized, + usage); + CheckAndLogError(!mInitialized, VOID_VALUE, "mInitialized is false"); + CheckAndLogError(!isIPCFine(), VOID_VALUE, "IPC error happens"); + CheckAndLogError(usage >= MAX_ALGO_SHM, VOID_VALUE, "usage: %d isn't supported", usage); + + std::vector handles({bufferHandle}); + if (usage == CPU_ALGO_SHM) { + mBridge->DeregisterBuffers(handles); + } else if (mGpuBridge) { + mGpuBridge->DeregisterBuffers(handles); + } +} + +int32_t IntelAlgoClient::getBufferHandle(void* addr, ShmMemUsage usage) { + CheckAndLogError(!mInitialized, -1, "mInitialized is false"); + CheckAndLogError(usage >= MAX_ALGO_SHM, -1, "usage: %d isn't supported", usage); + if (!addr) return -1; + + LOG2("the buffer addr: %p, usage: %d", addr, usage); + std::lock_guard l(mShmMapMutex); + CheckAndLogError(mShmMap[usage].find(addr) == mShmMap[usage].end(), -1, + "%s, Invalid client addr: %p, usage: %d", __func__, addr, usage); + + return mShmMap[usage][addr]; +} + +void IntelAlgoClient::callbackHandler(uint32_t req_id, uint32_t status, int32_t buffer_handle) { + IPC_GROUP group = IntelAlgoIpcCmdToGroup(static_cast(req_id)); + mRunner[group]->callbackHandler(status, buffer_handle); +} + +void IntelAlgoClient::notifyHandler(uint32_t msg) { + if (msg != CAMERA_ALGORITHM_MSG_IPC_ERROR) { + LOGE("receive msg:%d, not CAMERA_ALGORITHM_MSG_IPC_ERROR", msg); + return; + } + + std::lock_guard l(mIPCStatusMutex); + mIPCStatus = false; + + if (mErrCb) { + camera_msg_data_t data = {CAMERA_IPC_ERROR, {}}; + mErrCb->notify(mErrCb, data); + } else { + LOGE("mErrCb is nullptr, no device error is sent out"); + } + LOGE("receive CAMERA_ALGORITHM_MSG_IPC_ERROR"); +} + +void IntelAlgoClient::returnCallback(const camera_algorithm_callback_ops_t* callback_ops, + uint32_t req_id, uint32_t status, int32_t buffer_handle) { + CheckAndLogError(!callback_ops, VOID_VALUE, "callback_ops is nullptr"); + + auto s = const_cast(static_cast(callback_ops)); + s->callbackHandler(req_id, status, buffer_handle); +} + +void IntelAlgoClient::notifyCallback(const struct camera_algorithm_callback_ops* callback_ops, + camera_algorithm_error_msg_code_t msg) { + CheckAndLogError(!callback_ops, VOID_VALUE, "callback_ops is nullptr"); + + auto s = const_cast(static_cast(callback_ops)); + s->notifyHandler((uint32_t)msg); +} + +IntelAlgoClient::Runner::Runner(IPC_GROUP group, cros::CameraAlgorithmBridge* bridge) + : mGroup(group), + mBridge(bridge), + mIsCallbacked(false), + mCbStatus(OK), + mInitialized(false) { + LOG1("Runner Construct group:%d", mGroup); + + pthread_condattr_t attr; + int ret = pthread_condattr_init(&attr); + if (ret != 0) { + LOGE("call pthread_condattr_init fails, ret:%d", ret); + pthread_condattr_destroy(&attr); + return; + } + + ret = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); + if (ret != 0) { + LOGE("call pthread_condattr_setclock fails, ret:%d", ret); + pthread_condattr_destroy(&attr); + return; + } + + ret = pthread_cond_init(&mCbCond, &attr); + if (ret != 0) { + LOGE("call pthread_cond_init fails, ret:%d", ret); + pthread_condattr_destroy(&attr); + return; + } + + pthread_condattr_destroy(&attr); + + ret = pthread_mutex_init(&mCbLock, nullptr); + CheckAndLogError(ret != 0, VOID_VALUE, "call pthread_mutex_init fails, ret:%d", ret); + + mInitialized = true; +} + +IntelAlgoClient::Runner::~Runner() { + LOG1("Runner Destroy, group:%d", mGroup); + + int ret = pthread_cond_destroy(&mCbCond); + if (ret != 0) { + LOGE("call pthread_cond_destroy fails, ret:%d", ret); + } + + ret = pthread_mutex_destroy(&mCbLock); + if (ret != 0) { + LOGE("call pthread_mutex_destroy fails, ret:%d", ret); + } +} + +int IntelAlgoClient::Runner::requestSync(IPC_CMD cmd, int32_t bufferHandle) { + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "mInitialized is false, cmd:%d:%s", cmd, + IntelAlgoIpcCmdToString(cmd)); + + std::lock_guard lck(mMutex); + + std::vector reqHeader(IPC_REQUEST_HEADER_USED_NUM); + reqHeader[0] = IPC_MATCHING_KEY; + + // cmd is for request id, no duplicate command will be issued at any given time. + mBridge->Request(cmd, reqHeader, bufferHandle); + int ret = waitCallback(); + CheckAndLogError((ret != OK), UNKNOWN_ERROR, "waitCallback fails, cmd:%d:%s", cmd, + IntelAlgoIpcCmdToString(cmd)); + + // check callback result + CheckAndLogError((mCbStatus != OK && mCbStatus != ia_err_not_run), mCbStatus, + "callback fails, cmd:%d:%s, mCbStatus:%d", cmd, IntelAlgoIpcCmdToString(cmd), + mCbStatus); + + return mCbStatus; +} + +void IntelAlgoClient::Runner::callbackHandler(uint32_t status, int32_t buffer_handle) { + if (status != 0 && status != ia_err_not_run) { + LOGE("Runner callbackHandler group:%d, status:%d, buffer_handle:%d", mGroup, status, + buffer_handle); + } + mCbStatus = status; + + pthread_mutex_lock(&mCbLock); + mIsCallbacked = true; + int ret = pthread_cond_signal(&mCbCond); + pthread_mutex_unlock(&mCbLock); + + CheckAndLogError(ret != 0, VOID_VALUE, "group:%d, call pthread_cond_signal fails, ret:%d", + mGroup, ret); +} + +int IntelAlgoClient::Runner::waitCallback() { + nsecs_t startTime = CameraUtils::systemTime(); + + pthread_mutex_lock(&mCbLock); + if (!mIsCallbacked) { + int ret = 0; + struct timespec ts = {0, 0}; + clock_gettime(CLOCK_MONOTONIC, &ts); + ts.tv_sec += 5; // 5s timeout + + while (!mIsCallbacked && !ret) { + ret = pthread_cond_timedwait(&mCbCond, &mCbLock, &ts); + } + if (ret != 0) { + LOGE("%s, group:%d, call pthread_cond_timedwait fail, ret:%d, it takes %" PRId64 " ms", + __func__, mGroup, ret, (CameraUtils::systemTime() - startTime) / 1000000); + pthread_mutex_unlock(&mCbLock); + return UNKNOWN_ERROR; + } + } + mIsCallbacked = false; + pthread_mutex_unlock(&mCbLock); + + LOG2("%s, group:%d IPC call takes %" PRId64 " ms", __func__, mGroup, + (CameraUtils::systemTime() - startTime) / 1000000); + + return OK; +} + +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelAlgoClient.h b/modules/sandboxing/client/IntelAlgoClient.h new file mode 100644 index 00000000..30c57e85 --- /dev/null +++ b/modules/sandboxing/client/IntelAlgoClient.h @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include +#include +#include +#include + +#include "CameraLog.h" +#include "Parameters.h" +#include "base/functional/bind.h" +#include "base/functional/callback.h" +#include "cros-camera/camera_algorithm_bridge.h" +#include "iutils/Thread.h" +#include "modules/sandboxing/IPCCommon.h" + +namespace icamera { + +typedef enum { + CPU_ALGO_SHM, + GPU_ALGO_SHM, + MAX_ALGO_SHM, +} ShmMemUsage; + +class IntelAlgoClient : public camera_algorithm_callback_ops_t { + public: + static IntelAlgoClient* getInstance(); + static void releaseInstance(); + + IntelAlgoClient(); + virtual ~IntelAlgoClient(); + + void setMojoManagerToken(cros::CameraMojoChannelManagerToken* token) { + mMojoManagerToken = token; + } + + // Connect to the algo processes(cpu and gpu) + // It must be called after all preparation are ready in camera service + int initialize(); + + bool isIPCFine(); + + // when IPC error happens, device error + // will be sent out via the camera_callback_ops_t which belongs to CameraHal. + // before the CameraHal be terminated, set nullptr in the function. + void registerErrorCallback(const camera_callback_ops_t* errCb); + + int allocateShmMem(const std::string& name, int size, int* fd, void** addr); + void releaseShmMem(const std::string& name, int size, int fd, void* addr); + + int requestSync(IPC_CMD cmd, int32_t bufferHandle); + int requestSync(IPC_CMD cmd); + + int32_t registerBuffer(int bufferFd, void* addr, ShmMemUsage usage = CPU_ALGO_SHM); + void deregisterBuffer(int32_t bufferHandle, ShmMemUsage usage = CPU_ALGO_SHM); + int32_t registerGbmBuffer(int bufferFd, ShmMemUsage usage = CPU_ALGO_SHM); + void deregisterGbmBuffer(int32_t bufferHandle, ShmMemUsage usage = CPU_ALGO_SHM); + int32_t getBufferHandle(void* addr, ShmMemUsage usage = CPU_ALGO_SHM); + + private: + int waitCallback(); + + void callbackHandler(uint32_t req_id, uint32_t status, int32_t buffer_handle); + void notifyHandler(uint32_t msg); + + // when the request is done, the callback will be received. + static void returnCallback(const camera_algorithm_callback_ops_t* callback_ops, uint32_t req_id, + uint32_t status, int32_t buffer_handle); + // when IPC error happens in the bridge, notifyCallback will be called. + static void notifyCallback(const struct camera_algorithm_callback_ops* callback_ops, + camera_algorithm_error_msg_code_t msg); + + private: + /* + * Get access to the IntelAlgoClient singleton. + */ + static IntelAlgoClient* sInstance; + static Mutex sLock; // Guard for singleton creation. + + const camera_callback_ops_t* mErrCb; + + std::unique_ptr mBridge; + std::unique_ptr mGpuBridge; + + base::RepeatingCallback mCallback; + base::RepeatingCallback mNotifyCallback; + bool mIPCStatus; // true: no error happens, false: error happens + std::mutex mIPCStatusMutex; // the mutex for mIPCStatus + + // + std::unordered_map mShmMap[MAX_ALGO_SHM]; + std::mutex mShmMapMutex; // the mutex for mShmMap + + cros::CameraMojoChannelManagerToken* mMojoManagerToken; + bool mInitialized; + + private: + class Runner { + public: + Runner(IPC_GROUP group, cros::CameraAlgorithmBridge* bridge); + virtual ~Runner(); + int requestSync(IPC_CMD cmd, int32_t bufferHandle); + void callbackHandler(uint32_t status, int32_t buffer_handle); + + private: + int waitCallback(); + + private: + IPC_GROUP mGroup; + cros::CameraAlgorithmBridge* mBridge; + pthread_mutex_t mCbLock; + pthread_cond_t mCbCond; + bool mIsCallbacked; + int mCbStatus; + + bool mInitialized; + + std::mutex mMutex; // the mutex for the public method + }; + + std::unique_ptr mRunner[IPC_GROUP_NUM]; +}; + +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelAlgoCommonClient.cpp b/modules/sandboxing/client/IntelAlgoCommonClient.cpp new file mode 100644 index 00000000..a4e3a46c --- /dev/null +++ b/modules/sandboxing/client/IntelAlgoCommonClient.cpp @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelAlgoCommonClient + +#include "modules/sandboxing/client/IntelAlgoCommonClient.h" + +#include +#include + +#include "CameraLog.h" +#include "PlatformData.h" + +namespace icamera { +IntelAlgoCommon::IntelAlgoCommon() { + mClient = IntelAlgoClient::getInstance(); + LOG1("@%s, Construct, mClient:%p", __func__, mClient); +} + +IntelAlgoCommon::~IntelAlgoCommon() { + LOG1("@%s Destroy", __func__); +} + +bool IntelAlgoCommon::allocShmMem(const std::string& name, int size, ShmMemInfo* shm, + ShmMemUsage usage) { + CheckAndLogError(mClient == nullptr, false, "@%s, mClient is nullptr", __func__); + + shm->mName = name; + shm->mSize = size; + int ret = mClient->allocateShmMem(shm->mName, shm->mSize, &shm->mFd, &shm->mAddr); + CheckAndLogError((ret != OK), false, "@%s, call allocateShmMem fail", __func__); + + shm->mHandle = mClient->registerBuffer(shm->mFd, shm->mAddr, usage); + if (shm->mHandle < 0) { + LOGE("@%s, call mBridge->RegisterBuffer fail", __func__); + mClient->releaseShmMem(shm->mName, shm->mSize, shm->mFd, shm->mAddr); + return false; + } + + return true; +} + +int32_t IntelAlgoCommon::registerGbmBuffer(int bufferFd, ShmMemUsage usage) { + CheckAndLogError(mClient == nullptr, -1, "@%s, mClient is nullptr", __func__); + + return mClient->registerGbmBuffer(bufferFd, usage); +} + +void IntelAlgoCommon::deregisterGbmBuffer(int32_t bufferHandle, ShmMemUsage usage) { + CheckAndLogError(mClient == nullptr, VOID_VALUE, "@%s, mClient is nullptr", __func__); + + mClient->deregisterGbmBuffer(bufferHandle, usage); +} + +bool IntelAlgoCommon::requestSync(IPC_CMD cmd, int32_t handle) { + CheckAndLogError(mClient == nullptr, false, "@%s, mClient is nullptr", __func__); + + return mClient->requestSync(cmd, handle) == OK ? true : false; +} + +bool IntelAlgoCommon::requestSync(IPC_CMD cmd) { + CheckAndLogError(mClient == nullptr, false, "@%s, mClient is nullptr", __func__); + + return mClient->requestSync(cmd) == OK ? true : false; +} + +ia_err IntelAlgoCommon::requestSyncCca(IPC_CMD cmd, int32_t handle) { + CheckAndLogError(mClient == nullptr, ia_err_argument, "@%s, mClient is nullptr", __func__); + + return (ia_err)(mClient->requestSync(cmd, handle)); +} + +ia_err IntelAlgoCommon::requestSyncCca(IPC_CMD cmd) { + CheckAndLogError(mClient == nullptr, ia_err_argument, "@%s, mClient is nullptr", __func__); + + return (ia_err)(mClient->requestSync(cmd)); +} + +void IntelAlgoCommon::freeShmMem(const ShmMemInfo& shm, ShmMemUsage usage) { + CheckAndLogError(mClient == nullptr, VOID_VALUE, "@%s, mClient is nullptr", __func__); + if (shm.mHandle < 0 || shm.mFd < 0) { + LOGE("@%s, mHandle:%d, mFd:%d, one of them < 0", __func__, shm.mHandle, shm.mFd); + return; + } + + mClient->deregisterBuffer(shm.mHandle, usage); + mClient->releaseShmMem(shm.mName, shm.mSize, shm.mFd, shm.mAddr); +} + +bool IntelAlgoCommon::allocateAllShmMems(std::vector* mems) { + for (auto& it : *mems) { + ShmMemInfo* mem = it.mem; + mem->mName = it.name; + mem->mSize = it.size; + bool ret = allocShmMem(mem->mName, mem->mSize, mem); + CheckAndLogError(!ret, false, "@%s, allocShmMem fails, name:%s, size:%d", __func__, + mem->mName.c_str(), mem->mSize); + it.allocated = true; + } + + return true; +} + +void IntelAlgoCommon::releaseAllShmMems(const std::vector& mems) { + for (auto& it : mems) { + if (it.allocated) { + freeShmMem(*it.mem); + } + } +} + +int32_t IntelAlgoCommon::getShmMemHandle(void* addr, ShmMemUsage usage) { + CheckAndLogError(mClient == nullptr, -1, "@%s, mClient is nullptr", __func__); + return mClient->getBufferHandle(addr, usage); +} + +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelAlgoCommonClient.h b/modules/sandboxing/client/IntelAlgoCommonClient.h new file mode 100644 index 00000000..a127352b --- /dev/null +++ b/modules/sandboxing/client/IntelAlgoCommonClient.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "IntelAlgoClient.h" + +namespace icamera { +typedef struct ShmMemInfo { + std::string mName; + int mSize; + int mFd; + void* mAddr; + int32_t mHandle; + ShmMemInfo() : mName(""), mSize(0), mFd(-1), mAddr(nullptr), mHandle(-1) {} +} ShmMemInfo; + +typedef struct ShmMem { + std::string name; + int size; + ShmMemInfo* mem; + bool allocated; +} ShmMem; + +class IntelAlgoCommon { + public: + IntelAlgoCommon(); + virtual ~IntelAlgoCommon(); + + bool allocShmMem(const std::string& name, int size, ShmMemInfo* shm, + ShmMemUsage usage = CPU_ALGO_SHM); + int32_t registerGbmBuffer(int bufferFd, ShmMemUsage usage = CPU_ALGO_SHM); + void deregisterGbmBuffer(int32_t bufferHandle, ShmMemUsage usage = CPU_ALGO_SHM); + bool requestSync(IPC_CMD cmd, int32_t handle); + bool requestSync(IPC_CMD cmd); + ia_err requestSyncCca(IPC_CMD cmd, int32_t handle); + ia_err requestSyncCca(IPC_CMD cmd); + void freeShmMem(const ShmMemInfo& shm, ShmMemUsage usage = CPU_ALGO_SHM); + + bool allocateAllShmMems(std::vector* mems); + void releaseAllShmMems(const std::vector& mems); + + int32_t getShmMemHandle(void* addr, ShmMemUsage usage = CPU_ALGO_SHM); + + private: + IntelAlgoClient* mClient; +}; + +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelCcaClient.cpp b/modules/sandboxing/client/IntelCcaClient.cpp new file mode 100644 index 00000000..31795180 --- /dev/null +++ b/modules/sandboxing/client/IntelCcaClient.cpp @@ -0,0 +1,530 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelCcaClient + +#include "modules/sandboxing/client/IntelCcaClient.h" + +#include + +#include "PlatformData.h" +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +std::vector IntelCca::sCcaInstance; +Mutex IntelCca::sLock; + +IntelCca* IntelCca::getInstance(int cameraId, TuningMode mode) { + AutoMutex lock(sLock); + for (auto& it : sCcaInstance) { + if (cameraId == it.cameraId) { + if (it.ccaHandle.find(mode) == it.ccaHandle.end()) { + it.ccaHandle[mode] = new IntelCca(cameraId, mode); + } + + return it.ccaHandle[mode]; + } + } + + IntelCca::CCAHandle handle = {}; + handle.cameraId = cameraId; + handle.ccaHandle[mode] = new IntelCca(cameraId, mode); + sCcaInstance.push_back(handle); + + return handle.ccaHandle[mode]; +} + +void IntelCca::releaseInstance(int cameraId, TuningMode mode) { + AutoMutex lock(sLock); + for (auto& it : sCcaInstance) { + if (cameraId == it.cameraId && it.ccaHandle.find(mode) != it.ccaHandle.end()) { + IntelCca* cca = it.ccaHandle[mode]; + it.ccaHandle.erase(mode); + delete cca; + } + } +} + +void IntelCca::releaseAllInstances() { + AutoMutex lock(sLock); + + for (auto& it : sCcaInstance) { + for (auto& oneCcaHandle : it.ccaHandle) { + IntelCca* intelCca = oneCcaHandle.second; + delete intelCca; + } + it.ccaHandle.clear(); + } +} + +IntelCca::IntelCca(int cameraId, TuningMode mode) + : mCameraId(cameraId), + mTuningMode(mode), + mHasMknData(false) { + LOG1(" @%s, tuningMode:%d", cameraId, __func__, mode); + + std::string number = std::to_string(cameraId) + std::to_string(mode) + + std::to_string(reinterpret_cast(this)); + std::string structName = "/ccaStruct" + number + SHM_NAME; + std::string initName = "/ccaInit" + number + SHM_NAME; + std::string aecName = "/ccaAec" + number + SHM_NAME; + std::string aiqName = "/ccaAiq" + number + SHM_NAME; + std::string ltmName = "/ccaLtm" + number + SHM_NAME; + std::string zoomName = "/ccaZoom" + number + SHM_NAME; + std::string dvsName = "/ccaDvs" + number + SHM_NAME; + std::string aicName = "/ccaAic" + number + SHM_NAME; + std::string cmcName = "/ccaCmc" + number + SHM_NAME; + std::string aiqdName = "/ccaAiqd" + number + SHM_NAME; + std::string tuningName = "/ccaTuning" + number + SHM_NAME; + std::string deinitName = "/ccaDeinit" + number + SHM_NAME; + std::string decodeStatsName = "/ccaDecodeStats" + number + SHM_NAME; + std::string palSizeName = "/ccaPalSize" + number + SHM_NAME; + + mMems = { + {structName.c_str(), sizeof(intel_cca_struct_data), &mMemStruct, false}, + {initName.c_str(), sizeof(intel_cca_init_data), &mMemInit, false}, + {aecName.c_str(), sizeof(intel_cca_run_aec_data), &mMemAEC, false}, + {aiqName.c_str(), sizeof(intel_cca_run_aiq_data), &mMemAIQ, false}, + {ltmName.c_str(), sizeof(intel_cca_run_ltm_data), &mMemLTM, false}, + {zoomName.c_str(), sizeof(intel_cca_update_zoom_data), &mMemZoom, false}, + {dvsName.c_str(), sizeof(intel_cca_run_dvs_data), &mMemDVS, false}, + {aicName.c_str(), sizeof(intel_cca_run_aic_data), &mMemAIC, false}, + {cmcName.c_str(), sizeof(intel_cca_get_cmc_data), &mMemCMC, false}, + {aiqdName.c_str(), sizeof(intel_cca_get_aiqd_data), &mMemAIQD, false}, + {tuningName.c_str(), sizeof(intel_cca_update_tuning_data), &mMemTuning, false}, + {deinitName.c_str(), sizeof(intel_cca_deinit_data), &mMemDeinit, false}, + {decodeStatsName.c_str(), sizeof(intel_cca_decode_stats_data), &mMemDecodeStats, false}, + {palSizeName.c_str(), sizeof(intel_cca_get_pal_data_size), &mMemPalSize, false}}; + + bool success = mCommon.allocateAllShmMems(&mMems); + if (!success) { + mCommon.releaseAllShmMems(mMems); + return; + } + + // construct the remote CCA + intel_cca_struct_data* params = static_cast(mMemStruct.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + mCommon.requestSyncCca(IPC_CCA_CONSTRUCT, mMemStruct.mHandle); + + LOG1("@%s, Construct done", __func__); +} + +IntelCca::~IntelCca() { + LOG1(" @%s, tuningMode:%d", mCameraId, __func__, mTuningMode); + + // destruct the remote CCA + intel_cca_struct_data* params = static_cast(mMemStruct.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + mCommon.requestSyncCca(IPC_CCA_DESTRUCT, mMemStruct.mHandle); + + mCommon.releaseAllShmMems(mMems); + + for (auto& it : mMemsOuter) { + mCommon.freeShmMem(it.second); + } + mMemsOuter.clear(); + + freeStatsDataMem(); +} + +ia_err IntelCca::init(const cca::cca_init_params& initParams) { + LOG1(" @%s, tuningMode:%d, bitmap:0x%x", mCameraId, __func__, mTuningMode, + initParams.bitmap); + + intel_cca_init_data* params = static_cast(mMemInit.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + params->inParams = initParams; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_INIT, mMemInit.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + return ret; +} + +ia_err IntelCca::decodeStats(uint64_t statsPointer, uint32_t statsSize, uint32_t bitmap, + ia_isp_bxt_statistics_query_results_t* results, + cca::cca_out_stats* outStats) { + LOG2(" @%s, tuningMode:%d, statsPointer:0x%lx, statsSize:%d, bitmap:0x%x", mCameraId, + __func__, mTuningMode, statsPointer, statsSize, bitmap); + + if (results) return ia_err_none; + + intel_cca_run_aec_data* aecParams = static_cast(mMemAEC.mAddr); + intel_cca_decode_stats_data* params = &aecParams->decodeStatsParams; + + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + params->statsHandle = mCommon.getShmMemHandle(reinterpret_cast(statsPointer)); + params->statsBuffer.data = nullptr; + params->statsBuffer.size = statsSize; + params->bitmap = bitmap; + params->outStats.get_rgbs_stats = false; + aecParams->hasDecodeStats = true; + + return ia_err_none; +} + +ia_err IntelCca::setStatsParams(const cca::cca_stats_params& params) { + LOG2(" @%s, tuningMode:%d, in params size:%zu", mCameraId, __func__, mTuningMode, + sizeof(cca::cca_stats_params)); + + // Set stats when running AEC + intel_cca_run_aec_data* aecParams = static_cast(mMemAEC.mAddr); + aecParams->inStatsParams = params; + aecParams->hasStats = true; + + return ia_err_none; +} + +ia_err IntelCca::runAEC(uint64_t frameId, const cca::cca_ae_input_params& params, + cca::cca_ae_results* results) { + LOG2(" @%s, tuningMode:%d, in params size:%zu, results size:%zu", mCameraId, + frameId, __func__, mTuningMode, sizeof(cca::cca_ae_input_params), + sizeof(cca::cca_ae_results)); + + CheckAndLogError(!results, ia_err_argument, "@%s, results is nullptr", __func__); + + intel_cca_run_aec_data* aecParams = static_cast(mMemAEC.mAddr); + aecParams->cameraId = mCameraId; + aecParams->tuningMode = mTuningMode; + aecParams->frameId = frameId; + aecParams->inParams = params; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_RUN_AEC, mMemAEC.mHandle); + aecParams->hasStats = false; + + if (aecParams->hasDecodeStats) { + LOG2("%s, query results: rgbs_grid(%d), af_grid(%d), dvs_stats(%d)", __func__, + aecParams->decodeStatsParams.results.rgbs_grid, + aecParams->decodeStatsParams.results.af_grid, + aecParams->decodeStatsParams.results.dvs_stats); + aecParams->hasDecodeStats = false; + } + + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + *results = aecParams->results; + + return ret; +} + +ia_err IntelCca::runAIQ(uint64_t frameId, const cca::cca_aiq_params& params, + cca::cca_aiq_results* results, camera_makernote_mode_t mode) { + LOG2(" @%s, tuningMode:%d, in params size:%zu, results size:%zu", mCameraId, + frameId, __func__, mTuningMode, sizeof(cca::cca_aiq_params), sizeof(cca::cca_aiq_results)); + CheckAndLogError(!results, ia_err_argument, "@%s, results is nullptr", __func__); + + intel_cca_run_aiq_data* aiqParams = static_cast(mMemAIQ.mAddr); + aiqParams->cameraId = mCameraId; + aiqParams->tuningMode = mTuningMode; + aiqParams->frameId = frameId; + aiqParams->inParams = params; + + aiqParams->mknResultsHandle = -1; + bool dump = false; + void* ptr = PlatformData::getMakernoteBuf(mCameraId, mode, dump); + if (ptr) { + aiqParams->mknResults = static_cast(ptr); + aiqParams->type = + ((mode == MAKERNOTE_MODE_JPEG) || dump ? ia_mkn_trg_section_1 : ia_mkn_trg_section_2); + aiqParams->mknResultsHandle = mCommon.getShmMemHandle(aiqParams->mknResults); + } + + aiqParams->aiqResultHandle = mCommon.getShmMemHandle(results); + CheckAndLogError(aiqParams->aiqResultHandle < 0, ia_err_nomemory, "Failed to get result buf"); + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_RUN_AIQ, mMemAIQ.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + if (aiqParams->mknResultsHandle >= 0) mHasMknData = true; + + return ret; +} + +ia_err IntelCca::runLTM(uint64_t frameId, const cca::cca_ltm_input_params& params) { + LOG2(" @%s, tuningMode:%d, in params size:%zu", mCameraId, frameId, __func__, + mTuningMode, sizeof(cca::cca_ltm_input_params)); + intel_cca_run_ltm_data* ltmParams = static_cast(mMemLTM.mAddr); + ltmParams->cameraId = mCameraId; + ltmParams->tuningMode = mTuningMode; + ltmParams->frameId = frameId; + ltmParams->inParams = params; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_RUN_LTM, mMemLTM.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + return ret; +} + +ia_err IntelCca::updateZoom(uint32_t streamId, const cca::cca_dvs_zoom& params) { + LOG1(" @%s, tuningMode:%d, streamId: %u", mCameraId, __func__, mTuningMode, streamId); + + intel_cca_update_zoom_data* zoomParams = + static_cast(mMemZoom.mAddr); + zoomParams->cameraId = mCameraId; + zoomParams->tuningMode = mTuningMode; + zoomParams->inParams = params; + zoomParams->streamId = streamId; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_UPDATE_ZOOM, mMemZoom.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + return ret; +} + +ia_err IntelCca::runDVS(uint32_t streamId, uint64_t frameId) { + LOG2(" @%s, tuningMode:%d, streamId: %u", mCameraId, frameId, __func__, + mTuningMode, streamId); + + intel_cca_run_dvs_data* params = static_cast(mMemDVS.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + params->frameId = frameId; + params->streamId = streamId; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_RUN_DVS, mMemDVS.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + return ret; +} + +ia_err IntelCca::runAIC(uint64_t frameId, cca::cca_pal_input_params* params, ia_binary_data* pal) { + CheckAndLogError(!params, ia_err_argument, "@%s, params is nullptr", __func__); + CheckAndLogError(!pal, ia_err_argument, "@%s, pal is nullptr", __func__); + + intel_cca_run_aic_data* aicParams = static_cast(mMemAIC.mAddr); + aicParams->cameraId = mCameraId; + aicParams->tuningMode = mTuningMode; + aicParams->frameId = frameId; + aicParams->inParams = params; + aicParams->inParamsHandle = mCommon.getShmMemHandle(params); + aicParams->palOutData = *pal; + + int32_t palDataHandle = mCommon.getShmMemHandle(pal->data); + CheckAndLogError(!palDataHandle, ia_err_general, "%s, pal buf:%p is not in SHM", __func__, + pal->data); + aicParams->palDataHandle = palDataHandle; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_RUN_AIC, mMemAIC.mHandle); + CheckAndLogError(ret != ia_err_none && ret != ia_err_not_run, ia_err_general, + "@%s, requestSyncCca fails", __func__); + pal->size = aicParams->palOutData.size; + LOG2(" @%s, tuningMode:%d, in params size:%zu pal size:%d", mCameraId, frameId, + __func__, mTuningMode, sizeof(cca::cca_pal_input_params), pal->size); + + return ret; +} + +ia_err IntelCca::getCMC(cca::cca_cmc* cmc, const cca::cca_cpf* cpf) { + CheckAndLogError(!cmc, ia_err_argument, "@%s, cmc is nullptr", __func__); + + intel_cca_get_cmc_data* params = static_cast(mMemCMC.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + if (cpf && cpf->size) { + MEMCPY_S(params->cpf.buf, cca::MAX_CPF_LEN, cpf->buf, cpf->size); + params->cpf.size = cpf->size; + } else { + params->cpf.size = 0; + } + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_GET_CMC, mMemCMC.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + *cmc = params->results; + + return ret; +} + +ia_err IntelCca::getMKN(ia_mkn_trg type, cca::cca_mkn* mkn) { + UNUSED(type); + UNUSED(mkn); + + // get MKN when calling runAIQ API + if (!mHasMknData) return ia_err_general; + mHasMknData = false; + + return ia_err_none; +} + +ia_err IntelCca::getAiqd(cca::cca_aiqd* aiqd) { + CheckAndLogError(!aiqd, ia_err_argument, "@%s, aiqd is nullptr", __func__); + + intel_cca_get_aiqd_data* params = static_cast(mMemAIQD.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_GET_AIQD, mMemAIQD.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + *aiqd = params->results; + + return ret; +} + +ia_err IntelCca::updateTuning(uint8_t lardTags, const ia_lard_input_params& lardParams, + const cca::cca_nvm& nvm, int32_t streamId) { + LOG2(" @%s, tuningMode:%d", mCameraId, __func__, mTuningMode); + + intel_cca_update_tuning_data* params = + static_cast(mMemTuning.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + params->lardTags = lardTags; + params->lardParams = lardParams; + params->nvmParams = nvm; + params->streamId = streamId; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_UPDATE_TUNING, mMemTuning.mHandle); + CheckAndLogError(ret != ia_err_none, ia_err_general, "@%s, requestSyncCca fails", __func__); + + return ret; +} + +bool IntelCca::allocStatsDataMem(unsigned int size) { + LOG1(" @%s, tuningMode:%d, size:%d", mCameraId, __func__, mTuningMode, size); + + freeStatsDataMem(); + + AutoMutex l(mMemStatsMLock); + for (int i = 0; i < kMaxQueueSize; i++) { + std::string number = std::to_string(i) + std::to_string(mCameraId) + + std::to_string(mTuningMode) + + std::to_string(reinterpret_cast(this)); + std::string finalName = "statsData" + number + SHM_NAME; + StatsBufInfo info = {}; + bool ret = mCommon.allocShmMem(finalName, size, &info.shmMem); + CheckAndLogError(ret == false, false, "mCommon.allocShmMem failed for stats data"); + info.usedSize = size; + info.bufSize = size; + + LOG1("the buffer handle: %d, address: %p", info.shmMem.mHandle, info.shmMem.mAddr); + int64_t index = i * (-1) - 1; // default index list: -1, -2, -3, ... + mMemStatsInfoMap[index] = info; + } + + return true; +} + +void IntelCca::freeStatsDataMem() { + LOG1(" @%s, tuningMode:%d", mCameraId, __func__, mTuningMode); + + AutoMutex l(mMemStatsMLock); + for (auto it = mMemStatsInfoMap.begin(); it != mMemStatsInfoMap.end(); ++it) { + mCommon.freeShmMem(it->second.shmMem); + } + + mMemStatsInfoMap.clear(); +} + +void* IntelCca::getStatsDataBuffer() { + AutoMutex l(mMemStatsMLock); + if (mMemStatsInfoMap.empty()) return nullptr; + + ShmMemInfo memInfo = mMemStatsInfoMap.begin()->second.shmMem; + + return memInfo.mAddr; +} + +void IntelCca::decodeHwStatsDone(int64_t sequence, unsigned int byteUsed) { + LOG2(" @%s, tuningMode:%d, byteUsed:%d", mCameraId, sequence, __func__, + mTuningMode, byteUsed); + + AutoMutex l(mMemStatsMLock); + if (mMemStatsInfoMap.empty() || mMemStatsInfoMap.count(sequence) > 0) return; + + auto it = mMemStatsInfoMap.begin(); + it->second.usedSize = byteUsed; + mMemStatsInfoMap[sequence] = it->second; + + if (sequence != it->first) mMemStatsInfoMap.erase(it->first); +} + +void* IntelCca::fetchHwStatsData(int64_t sequence, unsigned int* byteUsed) { + CheckAndLogError(!byteUsed, nullptr, "byteUsed is nullptr"); + + AutoMutex l(mMemStatsMLock); + if (mMemStatsInfoMap.find(sequence) != mMemStatsInfoMap.end()) { + *byteUsed = mMemStatsInfoMap[sequence].usedSize; + ShmMemInfo memInfo = mMemStatsInfoMap[sequence].shmMem; + LOG2(" @%s, tuningMode:%d, memInfo.mAddr %p", mCameraId, sequence, __func__, + mTuningMode, memInfo.mAddr); + return memInfo.mAddr; + } + + return nullptr; +} + +void IntelCca::deinit() { + LOG1(" @%s, tuningMode:%d", mCameraId, __func__, mTuningMode); + + intel_cca_deinit_data* params = static_cast(mMemDeinit.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_DEINIT, mMemDeinit.mHandle); + CheckAndLogError(ret != ia_err_none, VOID_VALUE, "@%s, requestSyncCca fails", __func__); +} + +uint32_t IntelCca::getPalDataSize(const cca::cca_program_group& programGroup) { + intel_cca_get_pal_data_size* params = + static_cast(mMemPalSize.mAddr); + params->cameraId = mCameraId; + params->tuningMode = mTuningMode; + params->pg = programGroup; + + ia_err ret = mCommon.requestSyncCca(IPC_CCA_GET_PAL_SIZE, mMemPalSize.mHandle); + CheckAndLogError(ret != ia_err_none, 0, "@%s, requestSyncCca fails", __func__); + LOG2(" @%s, tuningMode:%d, in params size:%zu, returnSize:%d", mCameraId, __func__, + mTuningMode, sizeof(cca::cca_program_group), params->returnSize); + + return params->returnSize; +} + +void* IntelCca::allocMem(int streamId, const std::string& name, int index, int size) { + std::string number = std::to_string(streamId) + std::to_string(index) + + std::to_string(mCameraId) + std::to_string(mTuningMode) + + std::to_string(reinterpret_cast(this)); + std::string finalName = name + number + SHM_NAME; + + ShmMemInfo memInfo = {}; + bool ret = mCommon.allocShmMem(finalName, size, &memInfo); + CheckAndLogError(ret == false, nullptr, "%s, mCommon.allocShmMem fails for pal buf", __func__); + LOG1(" @%s, tuningMode:%d, name:%s, index:%d, streamId:%d, size:%d, handle: %d," + "address: %p", + mCameraId, __func__, mTuningMode, name.c_str(), index, streamId, size, memInfo.mHandle, + memInfo.mAddr); + mMemsOuter[memInfo.mAddr] = memInfo; + + return memInfo.mAddr; +} + +void IntelCca::freeMem(void* addr) { + LOG1(" @%s, tuningMode:%d, addr: %p", mCameraId, __func__, mTuningMode, addr); + + if (mMemsOuter.find(addr) != mMemsOuter.end()) { + mCommon.freeShmMem(mMemsOuter[addr]); + mMemsOuter.erase(addr); + return; + } + LOGW("@%s, there is no addr:%p, in the mMemsOuter", __func__, addr); +} +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelCcaClient.h b/modules/sandboxing/client/IntelCcaClient.h new file mode 100644 index 00000000..b36d0117 --- /dev/null +++ b/modules/sandboxing/client/IntelCcaClient.h @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include + +#include "CameraTypes.h" +#include "IntelAlgoCommonClient.h" +#include "iutils/Thread.h" +#include "modules/sandboxing/IPCIntelCca.h" + +namespace icamera { +class IntelCca { + public: + static IntelCca* getInstance(int cameraId, TuningMode mode); + static void releaseInstance(int cameraId, TuningMode mode); + static void releaseAllInstances(); + + ia_err init(const cca::cca_init_params& initParams); + + ia_err setStatsParams(const cca::cca_stats_params& params); + + ia_err runAEC(uint64_t frameId, const cca::cca_ae_input_params& params, + cca::cca_ae_results* results); + ia_err runAIQ(uint64_t frameId, const cca::cca_aiq_params& params, + cca::cca_aiq_results* results, camera_makernote_mode_t mode = MAKERNOTE_MODE_OFF); + + ia_err runLTM(uint64_t frameId, const cca::cca_ltm_input_params& params); + + ia_err updateZoom(uint32_t streamId, const cca::cca_dvs_zoom& params); + + ia_err runDVS(uint32_t streamId, uint64_t frameId); + + ia_err runAIC(uint64_t frameId, cca::cca_pal_input_params* params, ia_binary_data* pal); + + ia_err getCMC(cca::cca_cmc* cmc, const cca::cca_cpf* cpf = nullptr); + ia_err getMKN(ia_mkn_trg type, cca::cca_mkn* mkn); + ia_err getAiqd(cca::cca_aiqd* aiqd); + ia_err updateTuning(uint8_t lardTags, const ia_lard_input_params& lardParams, + const cca::cca_nvm& nvm, int32_t streamId); + + bool allocStatsDataMem(unsigned int size); + void* getStatsDataBuffer(); + void decodeHwStatsDone(int64_t sequence, unsigned int byteUsed); + void* fetchHwStatsData(int64_t sequence, unsigned int* byteUsed); + + void deinit(); + + // No decoding here because decoding should be done + // in IPC_CCA_RUN_AEC or IPC_PG_PARAM_DECODE if it is required. + ia_err decodeStats(uint64_t statsPointer, uint32_t statsSize, uint32_t bitmap, + ia_isp_bxt_statistics_query_results_t* results = nullptr, + cca::cca_out_stats* outStats = nullptr); + + uint32_t getPalDataSize(const cca::cca_program_group& programGroup); + void* allocMem(int streamId, const std::string& name, int index, int size); + void freeMem(void* addr); + + private: + IntelCca(int cameraId, TuningMode mode); + virtual ~IntelCca(); + void freeStatsDataMem(); + + private: + int mCameraId; + TuningMode mTuningMode; + bool mHasMknData; + + IntelAlgoCommon mCommon; + + ShmMemInfo mMemStruct; + ShmMemInfo mMemInit; + ShmMemInfo mMemAEC; + ShmMemInfo mMemAIQ; + ShmMemInfo mMemLTM; + ShmMemInfo mMemZoom; + ShmMemInfo mMemDVS; + ShmMemInfo mMemAIC; + ShmMemInfo mMemCMC; + ShmMemInfo mMemAIQD; + ShmMemInfo mMemTuning; + ShmMemInfo mMemDeinit; + ShmMemInfo mMemDecodeStats; + ShmMemInfo mMemPalSize; + + std::vector mMems; + + // Only 3 buffers will be held in AiqResultStorage (kAiqResultStorageSize is 3) + // So it is safe to use other 3 buffers. + static const int kMaxQueueSize = 6; + Mutex mMemStatsMLock; // protect mMemStatsInfoMap + struct StatsBufInfo { + unsigned int bufSize; + ShmMemInfo shmMem; + unsigned int usedSize; + }; + // first: sequence id, second: stats buffer info + std::map mMemStatsInfoMap; + + std::unordered_map mMemsOuter; + + private: + struct CCAHandle { + int cameraId; + std::unordered_map ccaHandle; // TuningMode to IntelCca map + }; + static std::vector sCcaInstance; + static Mutex sLock; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelEvcpClient.cpp b/modules/sandboxing/client/IntelEvcpClient.cpp new file mode 100644 index 00000000..ca9da787 --- /dev/null +++ b/modules/sandboxing/client/IntelEvcpClient.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelEVCPClient + +#include "modules/sandboxing/client/IntelEvcpClient.h" + +#include + +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +IntelEvcp::~IntelEvcp() { + bool ret = mCommon.requestSync(IPC_EVCP_DEINIT); + if (!ret) LOGE("@%s, EVCP DEINIT Fails", __func__); + + mCommon.freeShmMem(mParamMems, GPU_ALGO_SHM); + mCommon.freeShmMem(mEvcpRunInfoMem, GPU_ALGO_SHM); +} + +int IntelEvcp::init(int width, int height, EvcpParam* param) { + bool ret = initResolution(width, height); + if (!ret) return UNKNOWN_ERROR; + + ret = initRunInfoBuffer(); + if (!ret) return UNKNOWN_ERROR; + + ret = initParamBuffer(); + if (!ret) return UNKNOWN_ERROR; + + if (param) { + ret = updateEvcpParam(param); + } else { + EvcpParam defParam = {false, false, false, false}; + ret = updateEvcpParam(&defParam); + } + + if (!ret) return UNKNOWN_ERROR; + + return OK; +} + +bool IntelEvcp::initRunInfoBuffer() { + std::string name = + "/evcpRuninfo" + std::to_string(reinterpret_cast(this)) + SHM_NAME; + mEvcpRunInfoMem.mName = name.c_str(); + mEvcpRunInfoMem.mSize = sizeof(EvcpRunInfo); + return mCommon.allocShmMem(mEvcpRunInfoMem.mName, mEvcpRunInfoMem.mSize, &mEvcpRunInfoMem, + GPU_ALGO_SHM); +} + +bool IntelEvcp::initParamBuffer() { + std::string name = "/evcpParam" + std::to_string(reinterpret_cast(this)) + SHM_NAME; + mParamMems.mName = name.c_str(); + mParamMems.mSize = sizeof(EvcpParam); + return mCommon.allocShmMem(mParamMems.mName, mParamMems.mSize, &mParamMems, GPU_ALGO_SHM); +} + +bool IntelEvcp::initResolution(int width, int height) { + ShmMemInfo resolutionMems; + resolutionMems.mName = "/evcpResolutionShm"; + resolutionMems.mSize = sizeof(EvcpResolution); + + bool ret = mCommon.allocShmMem(resolutionMems.mName, resolutionMems.mSize, &resolutionMems, + GPU_ALGO_SHM); + CheckAndLogError(!ret, false, "@%s, Alloc resolution allocShmMem fails", __func__); + + EvcpResolution* res = reinterpret_cast(resolutionMems.mAddr); + res->width = width; + res->height = height; + + ret = mCommon.requestSync(IPC_EVCP_INIT, resolutionMems.mHandle); + mCommon.freeShmMem(resolutionMems, GPU_ALGO_SHM); + + return ret; +} + +bool IntelEvcp::runEvcpFrame(int dmafd, int dataSize) { + EvcpRunInfo* runInfo = reinterpret_cast(mEvcpRunInfoMem.mAddr); + + runInfo->inHandle = mCommon.registerGbmBuffer(dmafd, GPU_ALGO_SHM); + CheckAndLogError(runInfo->inHandle < 0, false, "@%s, Cannot register GBM buffers.", __func__); + + runInfo->bufSize = dataSize; + + auto runInfoHandle = mCommon.getShmMemHandle(reinterpret_cast(runInfo), GPU_ALGO_SHM); + if (runInfoHandle < 0) { + LOGE("@%s, Cannot get shm handle.", __func__); + mCommon.deregisterGbmBuffer(runInfo->inHandle, GPU_ALGO_SHM); + return false; + } + + bool ret = mCommon.requestSync(IPC_EVCP_RUN_FRAME, runInfoHandle); + mCommon.deregisterGbmBuffer(runInfo->inHandle, GPU_ALGO_SHM); + + return ret; +} + +void IntelEvcp::getEvcpParam(EvcpParam* evcpParam) { + EvcpParam* pamem = reinterpret_cast(mParamMems.mAddr); + + mCommon.requestSync(IPC_EVCP_GETCONF, mParamMems.mHandle); + *evcpParam = *pamem; +} + +bool IntelEvcp::updateEvcpParam(EvcpParam* param) { + EvcpParam* pamem = reinterpret_cast(mParamMems.mAddr); + *pamem = *param; + + return mCommon.requestSync(IPC_EVCP_UPDCONF, mParamMems.mHandle); +} + +} // namespace icamera diff --git a/modules/sandboxing/client/IntelEvcpClient.h b/modules/sandboxing/client/IntelEvcpClient.h new file mode 100644 index 00000000..b37f951e --- /dev/null +++ b/modules/sandboxing/client/IntelEvcpClient.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "BufferQueue.h" +#include "CameraBuffer.h" +#include "Parameters.h" +#include "PlatformData.h" +#include "src/evcp/EvcpCommon.h" + +namespace icamera { + +class IntelEvcp { + public: + IntelEvcp() {} + ~IntelEvcp(); + int init(int width, int height, EvcpParam* param = nullptr); + + bool runEvcpFrame(int dmafd, int dataSize); + bool updateEvcpParam(EvcpParam* evcpParam); + void getEvcpParam(EvcpParam* evcpParam); + + private: + bool initResolution(int width, int height); + bool initParamBuffer(); + bool initRunInfoBuffer(); + + IntelAlgoCommon mCommon; + ShmMemInfo mParamMems; + ShmMemInfo mEvcpRunInfoMem; + + DISALLOW_COPY_AND_ASSIGN(IntelEvcp); +}; +} // namespace icamera diff --git a/modules/sandboxing/client/IntelFaceDetectionClient.cpp b/modules/sandboxing/client/IntelFaceDetectionClient.cpp new file mode 100644 index 00000000..6f2bc2ec --- /dev/null +++ b/modules/sandboxing/client/IntelFaceDetectionClient.cpp @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelFaceDetectionClient + +#include "modules/sandboxing/client/IntelFaceDetectionClient.h" + +#include + +#include "FaceType.h" + +namespace icamera { +IntelFaceDetection::IntelFaceDetection() : mInitialized(false) { + uintptr_t personal = reinterpret_cast(this); + mMems = {{("/faceDetectionInit" + std::to_string(personal) + "Shm"), + sizeof(FaceDetectionInitParams), &mMemInit, false}, + {("/faceDetectionDeinit" + std::to_string(personal) + "Shm"), + sizeof(FaceDetectionDeinitParams), &mMemDeinit, false}}; + + for (int i = 0; i < MAX_STORE_FACE_DATA_BUF_NUM; i++) { + mMems.push_back( + {("/faceDetectionRun" + std::to_string(i) + std::to_string(personal) + "Shm"), + sizeof(FaceDetectionRunParams), &mMemRunBufs[i], false}); + } + + bool success = mCommon.allocateAllShmMems(&mMems); + if (!success) { + LOGE("@%s,Failed to call allocateAllShmMems", __func__); + mCommon.releaseAllShmMems(mMems); + return; + } + + LOG1("@%s, Construct done", __func__); + mInitialized = true; +} + +IntelFaceDetection::~IntelFaceDetection() { + LOG1("@%s, Destroy", __func__); + mCommon.releaseAllShmMems(mMems); +} + +status_t IntelFaceDetection::init(FaceDetectionInitParams* initParams, int dataSize) { + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "@%s, mInitialized is false", __func__); + + CheckAndLogError( + initParams == nullptr || dataSize < static_cast(sizeof(FaceDetectionInitParams)), + UNKNOWN_ERROR, "@%s, initParams: %p, dataSize: %d", __func__, initParams, dataSize); + + unsigned int maxFacesNum = + std::min(initParams->max_face_num, static_cast(MAX_FACES_DETECTABLE)); + LOG1(" @%s, maxFacesNum:%d", initParams->cameraId, __func__, maxFacesNum); + + FaceDetectionInitParams* params = static_cast(mMemInit.mAddr); + + bool ret = mIpc.clientFlattenInit(maxFacesNum, initParams->cameraId, params); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenInit fails", __func__); + + ret = mCommon.requestSync(IPC_FD_INIT, mMemInit.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + return OK; +} + +status_t IntelFaceDetection::deinit(FaceDetectionDeinitParams* deinitParams, int dataSize) { + LOG1("@%s", __func__); + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "@%s, mInitialized is false", __func__); + CheckAndLogError( + deinitParams == nullptr || dataSize < static_cast(sizeof(FaceDetectionDeinitParams)), + UNKNOWN_ERROR, "@%s, deinitParams: %p, dataSize: %d", __func__, deinitParams, dataSize); + + FaceDetectionDeinitParams* params = static_cast(mMemDeinit.mAddr); + params->cameraId = deinitParams->cameraId; + bool ret = mCommon.requestSync(IPC_FD_DEINIT, mMemDeinit.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + return OK; +} + +FaceDetectionRunParams* IntelFaceDetection::prepareRunBuffer(unsigned int index) { + CheckAndLogError(!mInitialized, nullptr, "@%s, mInitialized is false", __func__); + CheckAndLogError(index >= MAX_STORE_FACE_DATA_BUF_NUM, nullptr, "@%s, index: %d is error", + __func__, index); + LOG2("%s, index: %d", __func__, index); + + return static_cast(mMemRunBufs[index].mAddr); +} + +status_t IntelFaceDetection::run(FaceDetectionRunParams* runParams, int dataSize, int dmafd) { + CheckAndLogError(!mInitialized, UNKNOWN_ERROR, "@%s, mInitialized is false", __func__); + CheckAndLogError(!runParams || dataSize < static_cast(sizeof(FaceDetectionRunParams)), + UNKNOWN_ERROR, "@%s, runParams: %p dataSize: %d", __func__, runParams, + dataSize); + LOG2("@%s, dmafd: %d", __func__, dmafd); + + if (dmafd >= 0) { + runParams->bufferHandle = mCommon.registerGbmBuffer(dmafd); + CheckAndLogError((runParams->bufferHandle < 0), false, + "@%s, call mCommon.registerGbmBuffer", __func__); + } + + int32_t runBufHandle = mCommon.getShmMemHandle(static_cast(runParams)); + CheckAndLogError(runBufHandle < 0, UNKNOWN_ERROR, "@%s, getShmMemHandle fails", __func__); + + bool ret = mCommon.requestSync(IPC_FD_RUN, runBufHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + if (dmafd >= 0) { + mCommon.deregisterGbmBuffer(runParams->bufferHandle); + } + + return OK; +} +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelFaceDetectionClient.h b/modules/sandboxing/client/IntelFaceDetectionClient.h new file mode 100644 index 00000000..0f65e32a --- /dev/null +++ b/modules/sandboxing/client/IntelFaceDetectionClient.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "FaceType.h" +#include "IntelAlgoCommonClient.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" +#include "modules/sandboxing/IPCIntelFD.h" + +namespace icamera { +class IntelFaceDetection { + public: + IntelFaceDetection(); + virtual ~IntelFaceDetection(); + + status_t init(FaceDetectionInitParams* initData, int dataSize); + status_t deinit(FaceDetectionDeinitParams* deinitParams, int dataSize); + status_t run(FaceDetectionRunParams* runParams, int dataSize, int dmafd = -1); + FaceDetectionRunParams* prepareRunBuffer(unsigned int index); + + private: + IPCIntelFD mIpc; + IntelAlgoCommon mCommon; + + bool mInitialized; + + ShmMemInfo mMemInit; + ShmMemInfo mMemDeinit; + ShmMemInfo mMemRunBufs[MAX_STORE_FACE_DATA_BUF_NUM]; + std::vector mMems; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/client/IntelICBMClient.cpp b/modules/sandboxing/client/IntelICBMClient.cpp new file mode 100644 index 00000000..e63ca1e7 --- /dev/null +++ b/modules/sandboxing/client/IntelICBMClient.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2022-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelICBMClient + +#include "modules/sandboxing/client/IntelICBMClient.h" + +#include + +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +int IntelICBM::shutdown(const ICBMReqInfo& reqInfo) { + ICBMReqInfo* runInfo = reinterpret_cast(mRunInfoMem.mAddr); + *runInfo = reqInfo; + + bool ret = mCommon.requestSync(IPC_ICBM_DEINIT, mRunInfoMem.mHandle); + if (!ret) LOGE("%s, Intel ICBM shutdown failed", __func__); + + mCommon.freeShmMem(mRunInfoMem, GPU_ALGO_SHM); + return ret; +} + +int IntelICBM::setup(ICBMInitInfo* initParam) { + auto ret = initRunInfoBuffer(); + if (ret != OK) return ret; + + ShmMemInfo initMems; + initMems.mName = "/IntelICBMInitMem"; + + ICBMInitInfo dummy{}; + + if (initParam == nullptr) initParam = &dummy; + + initMems.mSize = sizeof(*initParam); + + auto re = mCommon.allocShmMem(initMems.mName, initMems.mSize, &initMems, GPU_ALGO_SHM); + CheckAndLogError(!re, UNKNOWN_ERROR, "%s, Alloc init allocShmMem failed", __func__); + + ICBMInitInfo* im = reinterpret_cast(initMems.mAddr); + *im = *initParam; + + re = mCommon.requestSync(IPC_ICBM_INIT, initMems.mHandle); + mCommon.freeShmMem(initMems, GPU_ALGO_SHM); + + return re ? OK : UNKNOWN_ERROR; +} + +int IntelICBM::initRunInfoBuffer() { + std::string name = + "/IntelICBMRuninfo" + std::to_string(reinterpret_cast(this)) + SHM_NAME; + mRunInfoMem.mName = name.c_str(); + mRunInfoMem.mSize = sizeof(ICBMReqInfo); + + auto ret = + mCommon.allocShmMem(mRunInfoMem.mName, mRunInfoMem.mSize, &mRunInfoMem, GPU_ALGO_SHM); + + CheckAndLogError(!ret, UNKNOWN_ERROR, "%s, RunInfo SHM alloc error!", __func__); + + return OK; +} + +int IntelICBM::processFrame(const ICBMReqInfo& reqInfo) { + ICBMReqInfo* runInfo = reinterpret_cast(mRunInfoMem.mAddr); + + *runInfo = reqInfo; + runInfo->inHandle = mCommon.registerGbmBuffer(reqInfo.inII.gfxHandle, GPU_ALGO_SHM); + CheckAndLogError(runInfo->inHandle < 0, UNKNOWN_ERROR, "%s, Cannot register in GBM buffers.", + __func__); + + runInfo->outHandle = mCommon.registerGbmBuffer(reqInfo.outII.gfxHandle, GPU_ALGO_SHM); + CheckAndLogError(runInfo->outHandle < 0, UNKNOWN_ERROR, "%s, Cannot register out GBM buffers.", + __func__); + + auto runInfoHandle = mCommon.getShmMemHandle(reinterpret_cast(runInfo), GPU_ALGO_SHM); + if (runInfoHandle < 0) { + LOGE("%s, Cannot get GBMSHM handle.", __func__); + mCommon.deregisterGbmBuffer(runInfo->inHandle, GPU_ALGO_SHM); + mCommon.deregisterGbmBuffer(runInfo->outHandle, GPU_ALGO_SHM); + return UNKNOWN_ERROR; + } + + bool ret = mCommon.requestSync(IPC_ICBM_RUN_FRAME, runInfoHandle); + mCommon.deregisterGbmBuffer(runInfo->inHandle, GPU_ALGO_SHM); + mCommon.deregisterGbmBuffer(runInfo->outHandle, GPU_ALGO_SHM); + + CheckAndLogError(!ret, UNKNOWN_ERROR, "%s, Run frame IPC error!", __func__); + return OK; +} + +int IntelICBM::runTnrFrame(const ICBMReqInfo& reqInfo) { + ICBMReqInfo* runInfo = reinterpret_cast(mRunInfoMem.mAddr); + *runInfo = reqInfo; + + runInfo->inHandle = reqInfo.inII.gfxHandle; + runInfo->outHandle = reqInfo.outII.gfxHandle; + return mCommon.requestSync(IPC_ICBM_RUN_FRAME, mRunInfoMem.mHandle); +} + +} // namespace icamera diff --git a/modules/sandboxing/client/IntelICBMClient.h b/modules/sandboxing/client/IntelICBMClient.h new file mode 100644 index 00000000..30e5f078 --- /dev/null +++ b/modules/sandboxing/client/IntelICBMClient.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "CameraBuffer.h" +#include "Parameters.h" +#include "PlatformData.h" +#include "src/icbm/ICBMTypes.h" + +namespace icamera { + +class IntelICBM { + public: + IntelICBM() {} + ~IntelICBM(){}; + + int setup(ICBMInitInfo* initParam); + int shutdown(const ICBMReqInfo& reqInfo); + int processFrame(const ICBMReqInfo& reqInfo); + int runTnrFrame(const ICBMReqInfo& reqInfo); + + private: + int initRunInfoBuffer(); + + IntelAlgoCommon mCommon; + ShmMemInfo mRunInfoMem; + + DISALLOW_COPY_AND_ASSIGN(IntelICBM); +}; +} // namespace icamera diff --git a/modules/sandboxing/client/IntelPGParamClient.cpp b/modules/sandboxing/client/IntelPGParamClient.cpp new file mode 100644 index 00000000..6b5a5de9 --- /dev/null +++ b/modules/sandboxing/client/IntelPGParamClient.cpp @@ -0,0 +1,375 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelPGParamClient + +#include "modules/sandboxing/client/IntelPGParamClient.h" + +#include + +#include "AiqResultStorage.h" +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +IntelPGParam::IntelPGParam(int pgId, int cameraId, TuningMode tuningMode) + : mInitialized(false), + mPgId(pgId), + mClient(reinterpret_cast(this)), + mPayloadCount(0), + mPGBuffer(nullptr), + mCameraId(cameraId), + mTuningMode(tuningMode) { + std::string initName = "/pgParamInit" + std::to_string(mClient) + SHM_NAME; + std::string prepareName = "/pgParamPrepare" + std::to_string(mClient) + SHM_NAME; + std::string getFragDescsName = "/pgParamGetFragDescs" + std::to_string(mClient) + SHM_NAME; + std::string prepareProgramName = "/pgParamPrepareProgram" + std::to_string(mClient) + SHM_NAME; + std::string encodeName = "/pgParamEncode" + std::to_string(mClient) + SHM_NAME; + std::string decodeName = "/pgParamDecode" + std::to_string(mClient) + SHM_NAME; + std::string deinitName = "/pgParamDeinit" + std::to_string(mClient) + SHM_NAME; + + mMems = { + {initName.c_str(), sizeof(pg_param_init_params), &mMemInit, false}, + {prepareName.c_str(), sizeof(pg_param_prepare_params), &mMemPrepare, false}, + {getFragDescsName.c_str(), sizeof(pg_param_get_fragment_desc_params), &mMemGetFragDescs, + false}, + {prepareProgramName.c_str(), sizeof(pg_param_prepare_program_params), &mMemPrepareProgram, + false}, + {encodeName.c_str(), sizeof(pg_param_encode_params), &mMemEncode, false}, + {decodeName.c_str(), sizeof(pg_param_decode_params), &mMemDecode, false}, + {deinitName.c_str(), sizeof(pg_param_deinit_params), &mMemDeinit, false}, + }; + + bool success = mCommon.allocateAllShmMems(&mMems); + if (!success) { + mCommon.releaseAllShmMems(mMems); + return; + } + + // Allocate when use + mMemAllocatePGBuffer.mName = "/pgParamAllocPG" + std::to_string(mClient) + SHM_NAME; + mMemAllocatePGBuffer.mSize = 0; + mMemStatistics.mName = "/pgParamStats" + std::to_string(mClient) + SHM_NAME; + mMemStatistics.mSize = 0; + mMaxStatsSize = 0; + + mIntelCca = IntelCca::getInstance(mCameraId, mTuningMode); + CheckAndLogError(!mIntelCca, VOID_VALUE, "%s: Can't get IntelCca", __func__); + + mInitialized = true; + LOG1("@%s, Construct done", __func__); +} + +IntelPGParam::~IntelPGParam() { + mCommon.releaseAllShmMems(mMems); + while (!mMemAllocatePayloads.empty()) { + mCommon.freeShmMem(mMemAllocatePayloads.back()); + mMemAllocatePayloads.pop_back(); + } + if (mMemAllocatePGBuffer.mSize) { + mCommon.freeShmMem(mMemAllocatePGBuffer); + } + if (mMemStatistics.mSize) { + mCommon.freeShmMem(mMemStatistics); + } + LOG1("@%s", __func__); +} + +int IntelPGParam::init(ia_p2p_platform_t platform, const PgConfiguration& pgConfig) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + + bool ret = + mIpc.clientFlattenInit(mMemInit.mAddr, mMemInit.mSize, mPgId, mClient, platform, pgConfig); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenInit fails", __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_INIT, mMemInit.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + return OK; +} + +int IntelPGParam::prepare(const ia_binary_data* ipuParameters, const ia_css_rbm_t* rbm, + ia_css_kernel_bitmap_t* bitmap, uint32_t* maxStatsSize) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + CheckAndLogError(!ipuParameters, INVALID_OPERATION, "@%s, ipuParams error", __func__); + + int32_t palHandle = mCommon.getShmMemHandle(ipuParameters->data); + bool ret = mIpc.clientFlattenPrepare(mMemPrepare.mAddr, mMemPrepare.mSize, mClient, + ipuParameters->size, palHandle, rbm); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenPrepare fails", __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_PREPARE, mMemPrepare.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + ret = mIpc.clientUnflattenPrepare(mMemPrepare.mAddr, mMemPrepare.mSize, bitmap, &mMaxStatsSize); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientUnflattenPrepare fails", __func__); + + if (mMemStatistics.mAddr && mMemStatistics.mSize <= mMaxStatsSize) { + mCommon.freeShmMem(mMemStatistics); + mMemStatistics.mSize = 0; + mMemStatistics.mAddr = nullptr; + } + if (maxStatsSize) *maxStatsSize = mMaxStatsSize; + return OK; +} + +int IntelPGParam::getFragmentDescriptors(int descCount, ia_p2p_fragment_desc* descs) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + + bool ret = mIpc.clientFlattenGetFragDescs(mMemGetFragDescs.mAddr, mMemGetFragDescs.mSize, + mClient, descCount); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenGetFragDescs fails", __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_GET_FRAG_DESCS, mMemGetFragDescs.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + int count = 0; + ret = mIpc.clientUnflattenGetFragDescs(mMemGetFragDescs.mAddr, mMemGetFragDescs.mSize, &count, + descs); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientUnflattenGetFragDescs fails", + __func__); + return count; +} + +void* IntelPGParam::allocatePGBuffer(int pgSize) { + CheckAndLogError(mInitialized == false, nullptr, "@%s, mInitialized is false", __func__); + + mPGBuffer = nullptr; + int size = mIpc.getTotalPGBufferSize(pgSize); + if (mMemAllocatePGBuffer.mAddr && mMemAllocatePGBuffer.mSize < size) { + mCommon.freeShmMem(mMemAllocatePGBuffer); + mMemAllocatePGBuffer.mSize = 0; + mMemAllocatePGBuffer.mAddr = nullptr; + } + if (!mMemAllocatePGBuffer.mAddr) { + mMemAllocatePGBuffer.mSize = size; + bool ret = mCommon.allocShmMem(mMemAllocatePGBuffer.mName, mMemAllocatePGBuffer.mSize, + &mMemAllocatePGBuffer); + CheckAndLogError(ret == false, nullptr, "@%s, allocShmMem fails", __func__); + } + + void* pgBuffer = nullptr; + bool ret = mIpc.assignPGBuffer(mMemAllocatePGBuffer.mAddr, mMemAllocatePGBuffer.mSize, pgSize, + &pgBuffer); + CheckAndLogError(ret == false, nullptr, "@%s, assignPGBuffer fails", __func__); + + ret = mIpc.clientFlattenAllocatePGBuffer(mMemAllocatePGBuffer.mAddr, mMemAllocatePGBuffer.mSize, + mClient, pgSize); + CheckAndLogError(ret == false, nullptr, "@%s, clientFlattenAllocatePGBuffer fails", __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_ALLOCATE_PG, mMemAllocatePGBuffer.mHandle); + CheckAndLogError(ret == false, nullptr, "@%s, requestSync fails", __func__); + + mPGBuffer = reinterpret_cast(pgBuffer); + return mPGBuffer; +} + +int IntelPGParam::setPGAndPrepareProgram(ia_css_process_group_t* pg) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + CheckAndLogError(mPGBuffer != pg, INVALID_OPERATION, "@%s, pg is not recognized", __func__); + + bool ret = mIpc.clientFlattenPrepareProgram(mMemPrepareProgram.mAddr, mMemPrepareProgram.mSize, + mClient); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenPrepareProgram fails", + __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_PREPARE_PROGRAM, mMemPrepareProgram.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + // Get size of payloads + mPayloadCount = ARRAY_SIZE(mPayloads); + ret = mIpc.clientUnflattenPrepareProgram(mMemPrepareProgram.mAddr, mMemPrepareProgram.mSize, + &mPayloadCount, mPayloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientUnlattenPrepareProgram fails", + __func__); + + return OK; +} + +int IntelPGParam::getPayloadSizes(int payloadCount, ia_binary_data* payloads) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + CheckAndLogError(payloadCount < mPayloadCount, UNKNOWN_ERROR, + "@%s, payloadCount: %d is small than %d", __func__, payloadCount, + mPayloadCount); + CheckAndLogError(!payloads, UNKNOWN_ERROR, "@%s, payloads is nullptr", __func__); + + MEMCPY_S(payloads, sizeof(ia_binary_data) * payloadCount, mPayloads, sizeof(mPayloads)); + return mPayloadCount; +} + +int IntelPGParam::allocatePayloads(int payloadCount, ia_binary_data* payloads) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + CheckAndLogError(payloadCount > IPU_MAX_TERMINAL_COUNT, UNKNOWN_ERROR, + "@%s, payloadCount: %d exceeded max count", __func__, payloadCount); + CheckAndLogError(!payloads, UNKNOWN_ERROR, "@%s, payloads is nullptr", __func__); + + // Allocate memory + int size = mIpc.getTotalPayloadSize(payloadCount, payloads); + CheckAndLogError(size <= 0, UNKNOWN_ERROR, "@%s, payloads size error", __func__); + mMemAllocatePayloads.resize(mMemAllocatePayloads.size() + 1); + + ShmMemInfo& info = mMemAllocatePayloads.back(); + info.mName = "/pgParamAllocPayloads" + std::to_string(mClient) + + std::to_string(mMemAllocatePayloads.size()) + SHM_NAME; + info.mSize = size; + info.mAddr = nullptr; + bool ret = mCommon.allocShmMem(info.mName, info.mSize, &info); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, allocShmMem fails", __func__); + + // Split memory of payloads in client side + ret = mIpc.assignPayloads(info.mAddr, info.mSize, payloadCount, payloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, allocatePayloads fails", __func__); + + ret = + mIpc.clientFlattenRegisterPayloads(info.mAddr, info.mSize, mClient, payloadCount, payloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenRegisterPayloads fails", + __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_REGISTER_PAYLOADS, info.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + return OK; +} + +int IntelPGParam::updatePALAndEncode(const ia_binary_data* ipuParameters, int payloadCount, + ia_binary_data* payloads) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + CheckAndLogError(!ipuParameters, INVALID_OPERATION, "@%s, ipuParams error", __func__); + // Check shared memory of payloads + CheckAndLogError(payloadCount != mPayloadCount, BAD_VALUE, + "@%s, payloadCount :%d should equal to %d", __func__, payloadCount, + mPayloadCount); + + int32_t palHandle = mCommon.getShmMemHandle(ipuParameters->data); + bool ret = mIpc.clientFlattenEncode(mMemEncode.mAddr, mMemEncode.mSize, mClient, + ipuParameters->size, palHandle, payloadCount, payloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenEncode fails", __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_ENCODE, mMemEncode.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + return OK; +} + +int IntelPGParam::decode(int payloadCount, ia_binary_data* payloads, ia_binary_data* statistics, + int64_t sequence) { + CheckAndLogError(mInitialized == false, INVALID_OPERATION, "@%s, mInitialized is false", + __func__); + // Check shared memory of payloads + CheckAndLogError(payloadCount != mPayloadCount, BAD_VALUE, + "@%s, payloadCount :%d should equal to %d", __func__, payloadCount, + mPayloadCount); + + // Check share memory of statistics + CheckAndLogError(!statistics, BAD_VALUE, "@%s, statistics nullptr", __func__); + CheckAndLogError(!mMaxStatsSize, BAD_VALUE, "@%s, bad max stats size", __func__); + bool ret = true; + int32_t statsHandle = -1; + if (!statistics->data) { + // Prepare shared stats memory + if (!mMemStatistics.mAddr) { + mMemStatistics.mSize = mMaxStatsSize; + ret = mCommon.allocShmMem(mMemStatistics.mName, mMemStatistics.mSize, &mMemStatistics); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, alloc statsData fails", __func__); + } + statsHandle = mCommon.getShmMemHandle(mMemStatistics.mAddr); + statistics->data = mMemStatistics.mAddr; + } else { + statsHandle = mCommon.getShmMemHandle(statistics->data); + } + + cca::cca_out_stats* outStats = fetchOutStats(sequence); + pg_param_decode_params* params = static_cast(mMemDecode.mAddr); + intel_cca_decode_stats_data& decodeStatsParams = params->decodeStatsParams; + if (outStats && mIntelCca) { + params->hasStatsDecode = true; + decodeStatsParams.cameraId = mCameraId; + decodeStatsParams.tuningMode = mTuningMode; + decodeStatsParams.statsHandle = statsHandle; + decodeStatsParams.statsBuffer.data = nullptr; + decodeStatsParams.statsBuffer.size = 0; // not decode pg yet + decodeStatsParams.bitmap = cca::CCA_STATS_RGBS | cca::CCA_STATS_HIST | cca::CCA_STATS_AF | + cca::CCA_STATS_YV | cca::CCA_STATS_LTM | cca::CCA_STATS_DVS; + if (PlatformData::isPdafEnabled(mCameraId)) decodeStatsParams.bitmap |= cca::CCA_STATS_PDAF; + decodeStatsParams.outStats.get_rgbs_stats = outStats->get_rgbs_stats; + } else { + params->hasStatsDecode = false; + } + + ret = mIpc.clientFlattenDecode(mMemDecode.mAddr, mMemDecode.mSize, mClient, payloadCount, + payloads, statsHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenDecode fails", __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_DECODE, mMemDecode.mHandle); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, requestSync fails", __func__); + + ret = mIpc.clientUnflattenDecode(mMemDecode.mAddr, mMemDecode.mSize, statistics); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientUnflattenDecode fails", __func__); + + if (outStats && mIntelCca) { + // print query result: params->results + if (outStats && decodeStatsParams.outStats.get_rgbs_stats) { + *outStats = decodeStatsParams.outStats; + for (unsigned int i = 0; i < cca::MAX_NUM_EXPOSURE; ++i) { + outStats->rgbs_grid[i].blocks_ptr = outStats->rgbs_blocks[i]; + } + } + ia_isp_bxt_statistics_query_results_t& queryResults = decodeStatsParams.results; + LOG2("%s, query results: rgbs_grid(%d), af_grid(%d), dvs_stats(%d), paf_grid(%d)", __func__, + queryResults.rgbs_grid, queryResults.af_grid, queryResults.dvs_stats, + queryResults.paf_grid); + } + return OK; +} + +void IntelPGParam::deinit() { + CheckAndLogError(mInitialized == false, VOID_VALUE, "@%s, mInitialized is false", __func__); + + bool ret = mIpc.clientFlattenDeinit(mMemDeinit.mAddr, mMemDeinit.mSize, mClient); + CheckAndLogError(ret == false, VOID_VALUE, "@%s, clientFlattenDeinit fails", __func__); + + ret = mCommon.requestSync(IPC_PG_PARAM_DEINIT, mMemDeinit.mHandle); + CheckAndLogError(ret == false, VOID_VALUE, "@%s, requestSync fails", __func__); +} + +cca::cca_out_stats* IntelPGParam::fetchOutStats(int64_t sequence) { + if (sequence < 0) return nullptr; + + AiqResult* aiqResult = + const_cast(AiqResultStorage::getInstance(mCameraId)->getAiqResult(sequence)); + // Check if the frame needs stats decoding together + if (aiqResult && aiqResult->mAiqParam.callbackRgbs) { + // Request decodeStats together when rgbCallback is enabled + aiqResult->mOutStats.get_rgbs_stats = true; + return &aiqResult->mOutStats; + } else if (aiqResult && !PlatformData::isStatsRunningRateSupport(mCameraId)) { + // Request decodeStats together when running rate is disabled + aiqResult->mOutStats.get_rgbs_stats = false; + return &aiqResult->mOutStats; + } + + return nullptr; +} + +} // namespace icamera diff --git a/modules/sandboxing/client/IntelPGParamClient.h b/modules/sandboxing/client/IntelPGParamClient.h new file mode 100644 index 00000000..f99917a1 --- /dev/null +++ b/modules/sandboxing/client/IntelPGParamClient.h @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "CameraTypes.h" +#include "IntelAlgoCommonClient.h" +#include "modules/sandboxing/IPCIntelPGParam.h" +#include "modules/sandboxing/client/IntelCcaClient.h" + +namespace icamera { + +class IntelPGParam { + public: + explicit IntelPGParam(int pgId, int cameraId = 0, + TuningMode tuningMode = TUNING_MODE_VIDEO); + ~IntelPGParam(); + + int init(ia_p2p_platform_t platform, const PgConfiguration& Pgconfiguration); + int prepare(const ia_binary_data* ipuParameters, const ia_css_rbm_t* rbm, + ia_css_kernel_bitmap_t* bitmap, uint32_t* maxStatsSize = nullptr); + void* allocatePGBuffer(int pgSize); + int getFragmentDescriptors(int terminalIdx, ia_p2p_fragment_desc* desc); + int setPGAndPrepareProgram(ia_css_process_group_t* pg); + int getPayloadSizes(int payloadCount, ia_binary_data* payloads); + int allocatePayloads(int payloadCount, ia_binary_data* payloads); + int updatePALAndEncode(const ia_binary_data* ipuParams, int payloadCount, + ia_binary_data* payloads); + int decode(int payloadCount, ia_binary_data* payload, ia_binary_data* statistics, + int64_t sequence = -1); + void deinit(); + +private: + cca::cca_out_stats* fetchOutStats(int64_t sequence); + + private: + IPCIntelPGParam mIpc; + IntelAlgoCommon mCommon; + bool mInitialized; + + ShmMemInfo mMemInit; + ShmMemInfo mMemPrepare; + ShmMemInfo mMemGetFragDescs; + ShmMemInfo mMemAllocatePGBuffer; + ShmMemInfo mMemPrepareProgram; + ShmMemInfo mMemEncode; + ShmMemInfo mMemDecode; + ShmMemInfo mMemDeinit; + ShmMemInfo mMemStatistics; + std::vector mMems; + + std::vector mMemAllocatePayloads; + + int mPgId; + uintptr_t mClient; + + // Shared memory in client, to avoid memory copy + int mPayloadCount; + ia_binary_data mPayloads[IPU_MAX_TERMINAL_COUNT]; // save sizes + ia_css_process_group_t* mPGBuffer; + uint32_t mMaxStatsSize; + + IntelCca* mIntelCca; + int mCameraId; + TuningMode mTuningMode; +}; + +} // namespace icamera diff --git a/modules/sandboxing/client/IntelTNR7USClient.cpp b/modules/sandboxing/client/IntelTNR7USClient.cpp new file mode 100644 index 00000000..e046ff99 --- /dev/null +++ b/modules/sandboxing/client/IntelTNR7USClient.cpp @@ -0,0 +1,293 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelTNR7USClient + +#include "modules/sandboxing/client/IntelTNR7USClient.h" + +#include +#include + +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" +namespace icamera { + +IntelTNR7US* IntelTNR7US::createIntelTNR(int cameraId) { + if (!PlatformData::isGpuTnrEnabled()) return nullptr; +#ifdef TNR7_CM + return new IntelC4mTNR(cameraId); +#else + return new IntelLevel0TNR(cameraId); +#endif +} + +Tnr7Param* IntelTNR7US::allocTnr7ParamBuf() { + uintptr_t personal = reinterpret_cast(this); + std::string initName = "/TnrParam" + std::to_string(personal) + "Shm"; + + mParamMems.mName = initName.c_str(); + mParamMems.mSize = sizeof(Tnr7Param); + bool ret = mCommon.allocShmMem(mParamMems.mName, mParamMems.mSize, &mParamMems, GPU_ALGO_SHM); + CheckAndLogError(!ret, nullptr, "@%s, allocShmMem fails", __func__); + + return reinterpret_cast(mParamMems.mAddr); +} + +void* IntelTNR7US::allocCamBuf(uint32_t bufSize, int id) { + uintptr_t personal = reinterpret_cast(this); + std::string initName = "/TnrCam" + std::to_string(personal) + std::to_string(id) + "Shm"; + ShmMemInfo shm; + shm.mName = initName.c_str(); + shm.mSize = bufSize; + bool ret = mCommon.allocShmMem(shm.mName, shm.mSize, &shm, GPU_ALGO_SHM); + CheckAndLogError(!ret, nullptr, "@%s, allocShmMem fails", __func__); + + mCamBufMems.push_back(shm); + return shm.mAddr; +} + +void IntelTNR7US::freeAllBufs() { + if (mParamMems.mAddr) { + mCommon.freeShmMem(mParamMems, GPU_ALGO_SHM); + } + for (auto& camBuf : mCamBufMems) { + if (camBuf.mAddr) { + mCommon.freeShmMem(camBuf, GPU_ALGO_SHM); + } + } +} + +#ifdef TNR7_CM +IntelC4mTNR::IntelC4mTNR(int cameraId) + : IntelTNR7US(cameraId), + mTnrType(TNR_INSTANCE_MAX), + mTnrRequestInfo(nullptr) { + LOG1(" %s, Construct", cameraId, __func__); +} + +IntelC4mTNR::~IntelC4mTNR() { + // the instance not initialized, don't need to free + if (mTnrType != TNR_INSTANCE_MAX) { + mTnrRequestInfo->type = mTnrType; + mTnrRequestInfo->cameraId = mCameraId; + + int32_t requestHandle = + mCommon.getShmMemHandle(static_cast(mTnrRequestInfo), GPU_ALGO_SHM); + int ret = mCommon.requestSync(IPC_GPU_TNR_DEINIT, requestHandle); + CheckAndLogError(!ret, VOID_VALUE, "@%s, requestSync fails", __func__); + mCommon.freeShmMem(mTnrRequestInfoMem, GPU_ALGO_SHM); + } + LOG1(" %s, Destroy", mCameraId, __func__); +} + +int IntelC4mTNR::init(int width, int height, TnrType type) { + uintptr_t personal = reinterpret_cast(this); + std::string initName = "/TnrRun" + std::to_string(personal) + "Shm"; + mTnrRequestInfoMem.mName = initName.c_str(); + mTnrRequestInfoMem.mSize = sizeof(TnrRequestInfo); + bool ret = mCommon.allocShmMem(mTnrRequestInfoMem.mName, mTnrRequestInfoMem.mSize, + &mTnrRequestInfoMem, GPU_ALGO_SHM); + CheckAndLogError(!ret, UNKNOWN_ERROR, "@%s, allocShmMem fails", __func__); + mTnrRequestInfo = static_cast(mTnrRequestInfoMem.mAddr); + + initName = "/TnrInit" + std::to_string(personal) + "Shm"; + ShmMemInfo initInfoMems; + initInfoMems.mName = initName.c_str(); + initInfoMems.mSize = sizeof(TnrInitInfo); + ret = mCommon.allocShmMem(initInfoMems.mName, initInfoMems.mSize, &initInfoMems, GPU_ALGO_SHM); + if (!ret) { + LOGE("@%s, alloc initInfo ShmMem fails", __func__); + mCommon.freeShmMem(mTnrRequestInfoMem, GPU_ALGO_SHM); + return UNKNOWN_ERROR; + } + + TnrInitInfo* initInfo = static_cast(initInfoMems.mAddr); + *initInfo = {width, height, mCameraId, type}; + + ret = mCommon.requestSync(IPC_GPU_TNR_INIT, initInfoMems.mHandle); + if (!ret) { + LOGE("@%s, IPC %d failed", __func__, IPC_GPU_TNR_INIT); + mCommon.freeShmMem(mTnrRequestInfoMem, GPU_ALGO_SHM); + } + mCommon.freeShmMem(initInfoMems, GPU_ALGO_SHM); + mTnrType = type; + LOG1("%s, GPU TNR instance size %dx%d, type %d", __func__, width, height, mTnrType); + + return ret ? OK : UNKNOWN_ERROR; +} + +int IntelC4mTNR::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize, + uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd) { + LOG2("%s, type: %d, syncUpdate: %d, fd: %d", __func__, mTnrType, syncUpdate, fd); + CheckAndLogError(!inBufAddr || !outBufAddr || !tnrParam, UNKNOWN_ERROR, + "@%s, invalid data buffer or parameter buffer", __func__); + int32_t inHandle = mCommon.getShmMemHandle(const_cast(inBufAddr), GPU_ALGO_SHM); + CheckAndLogError(inHandle < 0, UNKNOWN_ERROR, "@%s, can't find inBuf handle", __func__); + CheckAndLogError(mParamMems.mAddr != tnrParam, UNKNOWN_ERROR, "@%s, invalid tnr parameter", + __func__); + + if (fd >= 0) { + mTnrRequestInfo->outHandle = mCommon.registerGbmBuffer(fd, GPU_ALGO_SHM); + } else { + mTnrRequestInfo->outHandle = + mCommon.getShmMemHandle(static_cast(outBufAddr), GPU_ALGO_SHM); + } + CheckAndLogError(mTnrRequestInfo->outHandle < 0, UNKNOWN_ERROR, "@%s, can't init outBuf handle", + __func__); + + mTnrRequestInfo->inHandle = inHandle; + mTnrRequestInfo->paramHandle = mParamMems.mHandle; + mTnrRequestInfo->type = mTnrType; + mTnrRequestInfo->cameraId = mCameraId; + mTnrRequestInfo->outBufFd = fd; + mTnrRequestInfo->isForceUpdate = syncUpdate; + + int32_t requestHandle = + mCommon.getShmMemHandle(static_cast(mTnrRequestInfo), GPU_ALGO_SHM); + + IPC_CMD cmd = mTnrType > 0 ? IPC_GPU_TNR_THREAD2_RUN_FRAME : IPC_GPU_TNR_RUN_FRAME; + bool ret = mCommon.requestSync(cmd, requestHandle); + + if (fd >= 0) { + mCommon.deregisterGbmBuffer(mTnrRequestInfo->outHandle, GPU_ALGO_SHM); + } + + CheckAndLogError(!ret, OK, "@%s, run tnr fails", __func__); + + return OK; +} + +void* IntelC4mTNR::allocCamBuf(uint32_t bufSize, int id) { + uintptr_t personal = reinterpret_cast(this); + std::string initName = "/TnrCam" + std::to_string(personal) + std::to_string(id) + "Shm"; + ShmMemInfo shm; + shm.mName = initName.c_str(); + shm.mSize = bufSize; + bool ret = mCommon.allocShmMem(shm.mName, shm.mSize, &shm, GPU_ALGO_SHM); + CheckAndLogError(!ret, nullptr, "@%s, allocShmMem fails", __func__); + mTnrRequestInfo->surfaceHandle = shm.mHandle; + mTnrRequestInfo->type = mTnrType; + mTnrRequestInfo->cameraId = mCameraId; + + int32_t requestHandle = + mCommon.getShmMemHandle(static_cast(mTnrRequestInfo), GPU_ALGO_SHM); + ret = mCommon.requestSync(IPC_GPU_TNR_PREPARE_SURFACE, requestHandle); + if (!ret) { + mCommon.freeShmMem(shm, GPU_ALGO_SHM); + return nullptr; + } + mCamBufMems.push_back(shm); + + return shm.mAddr; +} + +int IntelC4mTNR::asyncParamUpdate(int gain, bool forceUpdate) { + LOG2("%s, type: %d, gain: %d, forceUpdate: %d", __func__, mTnrType, gain, forceUpdate); + mTnrRequestInfo->gain = gain; + mTnrRequestInfo->type = mTnrType; + mTnrRequestInfo->cameraId = mCameraId; + mTnrRequestInfo->isForceUpdate = forceUpdate; + + int32_t requestHandle = + mCommon.getShmMemHandle(static_cast(mTnrRequestInfo), GPU_ALGO_SHM); + + IPC_CMD cmd = mTnrType > 0 ? IPC_GPU_TNR_THREAD2_PARAM_UPDATE : IPC_GPU_TNR_PARAM_UPDATE; + bool ret = mCommon.requestSync(cmd, requestHandle); + + CheckAndLogError(!ret, UNKNOWN_ERROR, "@%s, IPC_GPU_TNR_PARAM_UPDATE requestSync fails", + __func__); + return OK; +} + +int IntelC4mTNR::getTnrBufferSize(int width, int height, uint32_t* size) { + mTnrRequestInfo->width = width; + mTnrRequestInfo->height = height; + mTnrRequestInfo->type = mTnrType; + mTnrRequestInfo->cameraId = mCameraId; + + int32_t requestHandle = + mCommon.getShmMemHandle(static_cast(mTnrRequestInfo), GPU_ALGO_SHM); + + bool ret = mCommon.requestSync(IPC_GPU_TNR_GET_SURFACE_INFO, requestHandle); + CheckAndLogError(!ret, UNKNOWN_ERROR, "@%s, IPC_GPU_TNR_GET_SURFACE_INFO requestSync fails", + __func__); + if (size) *size = mTnrRequestInfo->surfaceSize; + return OK; +} +#elif defined(TNR7_LEVEL0) +IntelLevel0TNR::~IntelLevel0TNR() { + LOG1(" %s", mCameraId, __func__); + if (mIntelICBM) { + icamera::ICBMReqInfo reqInfo; + reqInfo.cameraId = mCameraId; + reqInfo.reqType = icamera::ICBMReqType::LEVEL0_TNR; + mIntelICBM->shutdown(reqInfo); + mIntelICBM = nullptr; + } +} + +int IntelLevel0TNR::init(int width, int height, TnrType type) { + LOG1(" %s %dx%d", mCameraId, __func__, width, height); + mWidth = width; + mHeight = height; + mIntelICBM = std::make_unique(); + icamera::ICBMInitInfo initParam = {.cameraId = mCameraId, + .reqType = icamera::ICBMReqType::LEVEL0_TNR}; + int ret = mIntelICBM->setup(&initParam); + CheckAndLogError(ret != OK, ret, "%s: Init failed", __func__); + + return ret; +} + +int IntelLevel0TNR::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize, + uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd) { + (void)syncUpdate; + ImageInfo input = {}; + input.width = mWidth; + input.height = mHeight; + input.size = inBufSize; + input.stride = mWidth; + input.gfxHandle = mCommon.getShmMemHandle(const_cast(inBufAddr), GPU_ALGO_SHM); + + ImageInfo output = {}; + output.width = mWidth; + output.height = mHeight; + output.size = outBufSize; + output.stride = mWidth; + + if (fd >= 0) { + output.gfxHandle = mCommon.registerGbmBuffer(fd, GPU_ALGO_SHM); + } else { + output.gfxHandle = mCommon.getShmMemHandle(static_cast(outBufAddr), GPU_ALGO_SHM); + } + + ICBMReqInfo reqInfo; + reqInfo.cameraId = mCameraId; + reqInfo.reqType = ICBMReqType::LEVEL0_TNR; + reqInfo.paramHandle = mParamMems.mHandle; + reqInfo.inII = input; + reqInfo.outII = output; + + int ret = mIntelICBM->runTnrFrame(reqInfo); + + if (fd >= 0) { + mCommon.deregisterGbmBuffer(output.gfxHandle, GPU_ALGO_SHM); + } + + return ret; +} +#endif +} // namespace icamera diff --git a/modules/sandboxing/client/IntelTNR7USClient.h b/modules/sandboxing/client/IntelTNR7USClient.h new file mode 100644 index 00000000..88ebe2e8 --- /dev/null +++ b/modules/sandboxing/client/IntelTNR7USClient.h @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "BufferQueue.h" +#include "CameraBuffer.h" +#include "Parameters.h" +#include "PlatformData.h" +#include "TNRCommon.h" +#ifdef TNR7_LEVEL0 +#include "src/icbm/ICBMTypes.h" +#include "modules/sandboxing/client/IntelICBMClient.h" +#endif + +namespace icamera { +class IntelTNR7US { + public: + static IntelTNR7US* createIntelTNR(int cameraId); + virtual ~IntelTNR7US(){}; + virtual int init(int width, int height, TnrType type = TNR_INSTANCE0) = 0; + /** + * call tnr api to calc tnr result + * + * \param inBufAddr: input image buffer + * \param outBufAddr: tnr output + * \param tnrParam: tnr parameters from ISP + * \param fd: user output buffer file handle + */ + virtual int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize, + uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate = true, + int fd = -1) = 0; + virtual Tnr7Param* allocTnr7ParamBuf(); + virtual void* allocCamBuf(uint32_t bufSize, int id); + virtual void freeAllBufs(); + int prepareSurface(void* bufAddr, int size) { return OK; } + virtual int asyncParamUpdate(int gain, bool forceUpdate) { return OK; } + virtual int getTnrBufferSize(int width, int height, uint32_t* size) { return BAD_VALUE; } + + protected: + int mCameraId; + IntelAlgoCommon mCommon; + std::vector mCamBufMems; + ShmMemInfo mParamMems; + explicit IntelTNR7US(int cameraId) : mCameraId(cameraId){}; +}; + +#ifdef TNR7_CM +class IntelC4mTNR : public IntelTNR7US { + public: + explicit IntelC4mTNR(int cameraId); + virtual ~IntelC4mTNR(); + virtual int init(int width, int height, TnrType type = TNR_INSTANCE0); + virtual int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize, + uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate = true, + int fd = -1); + virtual void* allocCamBuf(uint32_t bufSize, int id); + virtual int asyncParamUpdate(int gain, bool forceUpdate); + virtual int getTnrBufferSize(int width, int height, uint32_t* size); + + private: + TnrType mTnrType; + TnrRequestInfo* mTnrRequestInfo; + ShmMemInfo mTnrRequestInfoMem; + DISALLOW_COPY_AND_ASSIGN(IntelC4mTNR); +}; + +#elif defined(TNR7_LEVEL0) +class IntelLevel0TNR : public IntelTNR7US { + public: + explicit IntelLevel0TNR(int cameraId) : IntelTNR7US(cameraId){}; + virtual ~IntelLevel0TNR(); + virtual int init(int width, int height, TnrType type = TNR_INSTANCE0); + virtual int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize, + uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate = true, + int fd = -1); + + private: + std::unique_ptr mIntelICBM; + int mWidth; + int mHeight; + + private: + DISALLOW_COPY_AND_ASSIGN(IntelLevel0TNR); +}; +#endif + +} // namespace icamera diff --git a/modules/sandboxing/server/CMakeLists.txt b/modules/sandboxing/server/CMakeLists.txt new file mode 100644 index 00000000..8aa73668 --- /dev/null +++ b/modules/sandboxing/server/CMakeLists.txt @@ -0,0 +1,75 @@ +# +# Copyright (C) 2019-2021 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 2.8) + +project(libcam_algo) + +include_directories(${USR_INCLUDE_HEADER}/ia_imaging) +include_directories(${IUTILS_DIR}) + +set(LIBCAM_ALGO_SRCS + ${IUTILS_DIR}/Utils.cpp + ${IUTILS_DIR}/Trace.cpp + ${IUTILS_DIR}/ScopedAtrace.cpp + ${IUTILS_DIR}/Thread.cpp + ${IUTILS_DIR}/CameraLog.cpp + ${PLATFORMDATA_DIR}/gc/GraphUtils.cpp + ${SANDBOXING_DIR}/IPCCommon.cpp + ${SANDBOXING_DIR}/IPCIntelLard.cpp + ${SANDBOXING_DIR}/IPCIntelFD.cpp + ${SANDBOXING_DIR}/server/IntelFDServer.cpp + ${SANDBOXING_DIR}/IPCGraphConfig.cpp + ${SANDBOXING_DIR}/server/IntelAlgoServer.cpp + ${SANDBOXING_DIR}/server/IntelLardServer.cpp + ${SANDBOXING_DIR}/server/GraphConfigServer.cpp + ${MODULES_DIR}/algowrapper/IntelLard.cpp + ${MODULES_DIR}/algowrapper/IntelFaceDetection.cpp + ${MODULES_DIR}/algowrapper/graph/GraphConfigImpl.cpp + ${MODULES_DIR}/algowrapper/graph/GraphConfigPipe.cpp + CACHE INTERNAL "libcam_algo sources" + ) + +add_library(libcam_algo SHARED ${LIBCAM_ALGO_SRCS}) + +find_package(LIBCAB) +find_package(LIBMOJO) +find_package(IA_IMAGING) +find_package(LIBIACSS) + +include_directories(${IA_IMAGING_INCLUDE_DIRS}) +include_directories(${LIBCAB_INCLUDE_DIRS}) +include_directories(${LIBMOJO_INCLUDE_DIRS}) +include_directories(${SRC_ROOT_DIR}/fd/FaceBase.h) +include_directories(${LIBIACSS_INCLUDE_DIRS}) + +link_directories(${CMAKE_PREFIX_PATH} + ${LIBMOJO_LIBS} + ${LIBCAB_LIBS} + ) + +target_link_libraries(libcam_algo ${LIBCAB_LIBS}) +target_link_libraries(libcam_algo ${LIBMOJO_LIBS}) +target_link_libraries(libcam_algo ${CMAKE_PREFIX_PATH}/libia_lard.so) +target_link_libraries(libcam_algo ${IA_IMAGING_LIBS}) +target_link_libraries(libcam_algo ${LIBIACSS_LIBS}) + +if (FACE_DETECTION) + target_link_libraries(libcam_algo pvl_eye_detection pvl_face_detection pvl_mouth_detection) +endif() + +install(TARGETS libcam_algo LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +set_target_properties(libcam_algo PROPERTIES OUTPUT_NAME "cam_algo") diff --git a/modules/sandboxing/server/GraphConfigServer.cpp b/modules/sandboxing/server/GraphConfigServer.cpp new file mode 100644 index 00000000..99c55840 --- /dev/null +++ b/modules/sandboxing/server/GraphConfigServer.cpp @@ -0,0 +1,181 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG GraphConfigServer + +#include "modules/sandboxing/server/GraphConfigServer.h" + +#include +#include + +#include "CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { +GraphConfigServer::GraphConfigServer() { + LOG1("@%s", __func__); +} + +GraphConfigServer::~GraphConfigServer() { + LOG1("@%s", __func__); +} + +void GraphConfigServer::addCustomKeyMap() { + std::shared_ptr graphConfigImpl = std::make_shared(); + graphConfigImpl->addCustomKeyMap(); +} + +status_t GraphConfigServer::parse(void* pData, size_t dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + + GraphParseParams* parseParam = nullptr; + bool ret = mIpc.serverUnflattenParse(pData, dataSize, &parseParam); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenParse fails", __func__); + + std::shared_ptr graphConfigImpl = std::make_shared(); + status_t rt = graphConfigImpl->parse(parseParam->cameraId, parseParam->GD, parseParam->gdSize, + parseParam->GS, parseParam->gsSize); + CheckAndLogError(rt != OK, UNKNOWN_ERROR, "@%s, Failed to parse the graph xml data", __func__); + + return OK; +} + +void GraphConfigServer::releaseGraphNodes() { + if (mGraphConfigMap.empty()) return; + mGraphConfigMap.begin()->second->releaseGraphNodes(); +} + +status_t GraphConfigServer::queryGraphSettings(void* pData, size_t dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + + GraphBaseInfo info; + GraphSettingType type; + std::vector streams; + bool dummyStillSink; + bool ret = + mIpc.serverUnflattenConfigStreams(pData, dataSize, &info, &type, &dummyStillSink, &streams); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, clientFlattenConfigStreams fails", + __func__); + + GraphQueryGraphParams* params = static_cast(pData); + std::shared_ptr graphConfigImpl = + std::make_shared(info.cameraId, info.configMode, type); + params->isHasGraphSettings = graphConfigImpl->queryGraphSettings(streams); + + return OK; +} + +status_t GraphConfigServer::configStreams(void* pData, size_t dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + + GraphBaseInfo info; + GraphSettingType type; + std::vector streams; + bool dummyStillSink; + bool ret = + mIpc.serverUnflattenConfigStreams(pData, dataSize, &info, &type, &dummyStillSink, &streams); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenConfigStreams fails", + __func__); + + // release the old item + auto it = mGraphConfigMap.find(info); + if (it != mGraphConfigMap.end()) { + mGraphConfigMap.erase(it); + } + LOG1(" @%s configMode: %d, settingType: %d, dummyStillSink: %d", info.cameraId, __func__, + info.configMode, type, dummyStillSink); + std::shared_ptr graphConfigImpl = + std::make_shared(info.cameraId, info.configMode, type); + status_t rt = graphConfigImpl->configStreams(streams, dummyStillSink); + CheckAndLogError(rt != OK, ret, " @%s, Failed to configStreams, configMode: %d", + info.cameraId, __func__, info.configMode); + + mGraphConfigMap[info] = graphConfigImpl; + + return OK; +} + +status_t GraphConfigServer::getGraphConfigData(void* pData, size_t dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + + GraphBaseInfo info; + bool ret = mIpc.serverUnflattenGetGraphData(pData, dataSize, &info); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenGetGraphData fails", + __func__); + + auto it = mGraphConfigMap.find(info); + CheckAndLogError(it == mGraphConfigMap.end(), UNKNOWN_ERROR, + " @%s, Failed to find the graph config", info.cameraId, __func__); + + IGraphType::GraphConfigData graphData; + status_t rt = it->second->getGraphConfigData(&graphData); + CheckAndLogError(rt != OK, UNKNOWN_ERROR, " @%s, Failed to getGraphConfigData", + info.cameraId, __func__); + + ret = mIpc.serverFlattenGetGraphData(pData, dataSize, graphData); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverFlattenGetGraphData fails", __func__); + + return OK; +} + +status_t GraphConfigServer::getPgIdForKernel(void* pData, size_t dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + + uint32_t streamId = -1; + int32_t kernelId = 0; + GraphBaseInfo info; + bool ret = mIpc.serverUnFlattenGetPgId(pData, dataSize, &info, &streamId, &kernelId); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnFlattenGetPgId fails", __func__); + + auto it = mGraphConfigMap.find(info); + CheckAndLogError(it == mGraphConfigMap.end(), UNKNOWN_ERROR, + " @%s, Failed to find the graph config", info.cameraId, __func__); + + int32_t pgId = -1; + it->second->getPgIdForKernel(streamId, kernelId, &pgId); + + ret = mIpc.serverFlattenGetPgId(pData, dataSize, pgId); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverFlattenGetPgId fails", __func__); + + return OK; +} + +status_t GraphConfigServer::pipelineGetConnections(void* pData, size_t dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + + GraphBaseInfo info; + std::vector pgList; + bool ret = mIpc.serverUnFlattenGetConnection(pData, dataSize, &info, &pgList); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnFlattenGetPgId fails", __func__); + + auto it = mGraphConfigMap.find(info); + CheckAndLogError(it == mGraphConfigMap.end(), UNKNOWN_ERROR, + " @%s, Failed to find the graph config", info.cameraId, __func__); + + std::vector confVector; + std::vector scalerInfo; + std::vector tnrPortFormat; + status_t rt = + it->second->pipelineGetConnections(pgList, &scalerInfo, &confVector, &tnrPortFormat); + CheckAndLogError(rt != OK, UNKNOWN_ERROR, " @%s, Failed to getConnection", info.cameraId, + __func__); + + ret = mIpc.serverFlattenGetConnection(pData, dataSize, scalerInfo, confVector, tnrPortFormat); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverFlattenGetPgId fails", __func__); + + return OK; +} +} // namespace icamera diff --git a/modules/sandboxing/server/GraphConfigServer.h b/modules/sandboxing/server/GraphConfigServer.h new file mode 100644 index 00000000..309fac08 --- /dev/null +++ b/modules/sandboxing/server/GraphConfigServer.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2019-2020 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "iutils/Errors.h" +#include "modules/algowrapper/graph/GraphConfigImpl.h" +#include "modules/sandboxing/IPCGraphConfig.h" + +namespace icamera { +class GraphConfigServer { + public: + GraphConfigServer(); + virtual ~GraphConfigServer(); + + void addCustomKeyMap(); + status_t parse(void* pData, size_t dataSize); + void releaseGraphNodes(); + status_t queryGraphSettings(void* pData, size_t dataSize); + status_t configStreams(void* pData, size_t dataSize); + status_t getGraphConfigData(void* pData, size_t dataSize); + status_t getPgIdForKernel(void* pData, size_t dataSize); + status_t pipelineGetConnections(void* pData, size_t dataSize); + + private: + std::map > mGraphConfigMap; + IPCGraphConfig mIpc; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelAlgoServer.cpp b/modules/sandboxing/server/IntelAlgoServer.cpp new file mode 100644 index 00000000..2ca29d54 --- /dev/null +++ b/modules/sandboxing/server/IntelAlgoServer.cpp @@ -0,0 +1,217 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelAlgoServer + +#include "modules/sandboxing/server/IntelAlgoServer.h" + +#include +#include +#include +#include + +#include +#include + +#include "iutils/Utils.h" +#ifndef GPU_ALGO_SERVER +#include "modules/sandboxing/server/IntelCPUAlgoServer.h" +#else +#include "modules/sandboxing/server/IntelGPUAlgoServer.h" +#endif + +namespace icamera { + +IntelAlgoServer* IntelAlgoServer::mInstance = nullptr; + +void IntelAlgoServer::init() { + if (mInstance == nullptr) { + mInstance = new IntelAlgoServer; + } +} + +void IntelAlgoServer::deInit() { + delete mInstance; + mInstance = nullptr; +} + +IntelAlgoServer::IntelAlgoServer() : mCallback(nullptr) { + ia_env env = {&Log::ccaPrintInfo, &Log::ccaPrintError, &Log::ccaPrintInfo}; + ia_log_init(&env); + + for (int i = 0; i < kThreadNum; i++) { + std::string name = IntelAlgoServerThreadName(i); + mThreads[i] = std::unique_ptr(new base::Thread(name)); + mThreads[i]->Start(); + } +#ifndef GPU_ALGO_SERVER + mRequestHandler = std::unique_ptr(new IntelCPUAlgoServer(this)); +#else + mRequestHandler = std::unique_ptr(new IntelGPUAlgoServer(this)); +#endif + + for (int32_t i = 1; i <= HANDLE_INDEX_MAX_VALUE; i++) { + mHandlesQueue.push(i); + } + + LOG1("@%s Construct done, %d threads started", __func__, kThreadNum); +} + +IntelAlgoServer::~IntelAlgoServer() { + LOG1("@%s Destroy", __func__); + ia_log_deinit(); +} + +int32_t IntelAlgoServer::initialize(const camera_algorithm_callback_ops_t* callback_ops) { + CheckAndLogError((!callback_ops), -EINVAL, "@%s, the callback_ops is nullptr", __func__); + LOG1("@%s, callback_ops:%p", __func__, callback_ops); + + mCallback = callback_ops; + + return 0; +} + +int32_t IntelAlgoServer::registerBuffer(int buffer_fd) { + std::lock_guard l(mRegisterBufMutex); + CheckAndLogError((mHandles.find(buffer_fd) != mHandles.end()), -EINVAL, + "@%s, Buffer already registered", __func__); + CheckAndLogError(mHandlesQueue.empty(), -EBADFD, "@%s, Failed to get buffer handle index", + __func__); + + struct stat sb; + int ret = fstat(buffer_fd, &sb); + CheckAndLogError((ret == -1), -EBADFD, "@%s, Failed to get buffer status", __func__); + + void* addr = mmap(0, sb.st_size, PROT_WRITE, MAP_SHARED, buffer_fd, 0); + CheckAndLogError((!addr), -EBADFD, "@%s, Failed to map buffer", __func__); + + int32_t handle = mHandlesQueue.front(); + mHandlesQueue.pop(); + mHandles[buffer_fd] = handle; + + mShmInfoMap[handle].fd = buffer_fd; + mShmInfoMap[handle].addr = addr; + mShmInfoMap[handle].size = sb.st_size; + + return handle; +} + +int IntelAlgoServer::parseReqHeader(const uint8_t req_header[], uint32_t size) { + CheckAndLogError(size < IPC_REQUEST_HEADER_USED_NUM || req_header[0] != IPC_MATCHING_KEY, -1, + "@%s, fails, req_header[0]:%d, size:%d", __func__, req_header[0], size); + + return 0; +} + +void IntelAlgoServer::returnCallback(uint32_t req_id, status_t status, int32_t buffer_handle) { + (*mCallback->return_callback)(mCallback, req_id, status, buffer_handle); +} + +status_t IntelAlgoServer::getShmInfo(const int32_t buffer_handle, ShmInfo* memInfo) { + CheckAndLogError(!memInfo, UNKNOWN_ERROR, "%s, memInfo is nullptr", __func__); + if (buffer_handle == -1) return OK; + + CheckAndLogError(mShmInfoMap.find(buffer_handle) == mShmInfoMap.end(), UNKNOWN_ERROR, + "%s, Invalid buffer handle", __func__); + *memInfo = mShmInfoMap[buffer_handle]; + + return OK; +} + +void IntelAlgoServer::handleRequest(const MsgReq& msg) { + CheckAndLogError(!mRequestHandler, VOID_VALUE, "@%s, handler is null", __func__); + mRequestHandler->handleRequest(msg); +} + +void IntelAlgoServer::request(uint32_t req_id, const uint8_t req_header[], uint32_t size, + int32_t buffer_handle) { + IPC_GROUP group = IntelAlgoIpcCmdToGroup(static_cast(req_id)); + + int ret = parseReqHeader(req_header, size); + if (ret != 0) { + returnCallback(req_id, UNKNOWN_ERROR, buffer_handle); + return; + } + + MsgReq msg = {req_id, buffer_handle}; + +#ifndef GPU_ALGO_SERVER + int threadId = group; +#else + // GPU server thread id start from IPC_GROUP_GPU + int threadId = group - IPC_GROUP_GPU; +#endif + if (threadId >= 0 && threadId < kThreadNum) { + if (mThreads[threadId] && mThreads[threadId]->task_runner()) { + mThreads[threadId]->task_runner()->PostTask( + FROM_HERE, + base::BindOnce(&IntelAlgoServer::handleRequest, base::Unretained(this), msg)); + } + } +} + +void IntelAlgoServer::deregisterBuffers(const int32_t buffer_handles[], uint32_t size) { + std::lock_guard l(mRegisterBufMutex); + for (uint32_t i = 0; i < size; i++) { + int32_t handle = buffer_handles[i]; + if (mShmInfoMap.find(handle) == mShmInfoMap.end()) { + continue; + } + + mHandles.erase(mShmInfoMap[handle].fd); + + munmap(mShmInfoMap[handle].addr, mShmInfoMap[handle].size); + close(mShmInfoMap[handle].fd); + mShmInfoMap.erase(handle); + mHandlesQueue.push(handle); + } +} + +static int32_t initialize(const camera_algorithm_callback_ops_t* callback_ops) { + return IntelAlgoServer::getInstance()->initialize(callback_ops); +} + +static int32_t registerBuffer(int32_t buffer_fd) { + return IntelAlgoServer::getInstance()->registerBuffer(buffer_fd); +} + +static void request(uint32_t req_id, const uint8_t req_header[], uint32_t size, + int32_t buffer_handle) { + IntelAlgoServer::getInstance()->request(req_id, req_header, size, buffer_handle); +} + +static void deregisterBuffers(const int32_t buffer_handles[], uint32_t size) { + return IntelAlgoServer::getInstance()->deregisterBuffers(buffer_handles, size); +} + +extern "C" { +camera_algorithm_ops_t CAMERA_ALGORITHM_MODULE_INFO_SYM + __attribute__((__visibility__("default"))) = {.initialize = initialize, + .register_buffer = registerBuffer, + .request = request, + .deregister_buffers = deregisterBuffers}; +} + +__attribute__((constructor)) void initIntelAlgoServer() { + icamera::Log::setDebugLevel(); + IntelAlgoServer::init(); +} + +__attribute__((destructor)) void deinitIntelAlgoServer() { + IntelAlgoServer::deInit(); +} + +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelAlgoServer.h b/modules/sandboxing/server/IntelAlgoServer.h new file mode 100644 index 00000000..654689a7 --- /dev/null +++ b/modules/sandboxing/server/IntelAlgoServer.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2019-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include + +#include "CameraLog.h" +#include "cros-camera/camera_algorithm.h" +#include "iutils/Errors.h" +#include "iutils/Thread.h" +#include "iutils/Utils.h" +#include "modules/sandboxing/IPCCommon.h" + +namespace icamera { + +#define HANDLE_INDEX_MAX_VALUE 1024 +struct MsgReq { + uint32_t req_id; + int32_t buffer_handle; +}; + +typedef struct { + int32_t fd; + void* addr; + size_t size; +} ShmInfo; + +class IntelAlgoServer; +class RequestHandler { + public: + explicit RequestHandler(IntelAlgoServer* server) { mIntelAlgoServer = server; } + virtual ~RequestHandler() {} + virtual void handleRequest(const MsgReq& msg) = 0; + IntelAlgoServer* getIntelAlgoServer() { return mIntelAlgoServer; } + + private: + IntelAlgoServer* mIntelAlgoServer; +}; + +class IntelAlgoServer { + public: + static void init(); + static void deInit(); + + static IntelAlgoServer* getInstance() { return mInstance; } + + int32_t initialize(const camera_algorithm_callback_ops_t* callback_ops); + int32_t registerBuffer(int buffer_fd); + void request(uint32_t req_id, const uint8_t req_header[], uint32_t size, int32_t buffer_handle); + void deregisterBuffers(const int32_t buffer_handles[], uint32_t size); + + void handleRequest(const MsgReq& msg); + status_t getShmInfo(const int32_t buffer_handle, ShmInfo* memInfo); + void returnCallback(uint32_t req_id, status_t status, int32_t buffer_handle); + + private: + IntelAlgoServer(); + ~IntelAlgoServer(); + int parseReqHeader(const uint8_t req_header[], uint32_t size); + + private: + static IntelAlgoServer* mInstance; +#ifndef GPU_ALGO_SERVER + static const int kThreadNum = IPC_CPU_GROUP_NUM; +#else + static const int kThreadNum = IPC_GPU_GROUP_NUM; +#endif + std::unique_ptr mThreads[kThreadNum]; + std::unique_ptr mRequestHandler; + + const camera_algorithm_callback_ops_t* mCallback; + + // key: shared memory fd from client + // value: handle that returns from RegisterBuffer() + std::unordered_map mHandles; + + // key: handle that returns from RegisterBuffer() + // value: shared memory fd and mapped address + std::unordered_map mShmInfoMap; + std::queue mHandlesQueue; + std::mutex mRegisterBufMutex; + + DISALLOW_COPY_AND_ASSIGN(IntelAlgoServer); +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelCPUAlgoServer.cpp b/modules/sandboxing/server/IntelCPUAlgoServer.cpp new file mode 100644 index 00000000..c8f112bd --- /dev/null +++ b/modules/sandboxing/server/IntelCPUAlgoServer.cpp @@ -0,0 +1,349 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelCPUAlgoServer + +#include "modules/sandboxing/server/IntelCPUAlgoServer.h" + +#include +#include +#include +#include + +#include +#include + +#include "iutils/Utils.h" + +namespace icamera { + +// Common check before the function call +#define FUNCTION_PREPARED_RETURN \ + uint16_t key = getKey(p->cameraId, p->tuningMode); \ + if (mCcas.find(key) == mCcas.end()) { \ + LOGE("@%s, req_id:%d, it doesn't find the cca", __func__, req_id); \ + status = UNKNOWN_ERROR; \ + break; \ + } + +IntelCPUAlgoServer::~IntelCPUAlgoServer() { + for (auto& it : mCcas) { + delete it.second; + } +} + +void IntelCPUAlgoServer::handleRequest(const MsgReq& msg) { + uint32_t req_id = msg.req_id; + int32_t buffer_handle = msg.buffer_handle; + + ShmInfo info = {}; + status_t status = getIntelAlgoServer()->getShmInfo(buffer_handle, &info); + if (status != OK) { + LOGE("@%s, Invalid buffer handle", __func__); + getIntelAlgoServer()->returnCallback(req_id, UNKNOWN_ERROR, buffer_handle); + return; + } + + size_t requestSize = info.size; + void* addr = info.addr; + + switch (req_id) { + case IPC_FD_INIT: + status = mFaceDetection.init(addr, requestSize); + break; + case IPC_FD_RUN: { + FaceDetectionRunParams* palParams = static_cast(addr); + void* addrImage = nullptr; + if (palParams->bufferHandle >= 0) { + ShmInfo imageDataInfo; + status = getIntelAlgoServer()->getShmInfo(palParams->bufferHandle, &imageDataInfo); + if (status != OK) { + LOGE("%s, the buffer handle for image data is invalid", __func__); + break; + } + addrImage = imageDataInfo.addr; + } + status = mFaceDetection.run(addr, requestSize, addrImage); + break; + } + case IPC_FD_DEINIT: + status = mFaceDetection.deinit(addr, requestSize); + break; + case IPC_GRAPH_ADD_KEY: + mGraph.addCustomKeyMap(); + break; + case IPC_GRAPH_PARSE: + mGraph.parse(addr, requestSize); + break; + case IPC_GRAPH_RELEASE_NODES: + mGraph.releaseGraphNodes(); + break; + case IPC_GRAPH_QUERY_GRAPH_SETTINGS: + status = mGraph.queryGraphSettings(addr, requestSize); + break; + case IPC_GRAPH_CONFIG_STREAMS: + mGraph.configStreams(addr, requestSize); + break; + case IPC_GRAPH_GET_CONFIG_DATA: + mGraph.getGraphConfigData(addr, requestSize); + break; + case IPC_GRAPH_GET_CONNECTION: + mGraph.pipelineGetConnections(addr, requestSize); + break; + case IPC_GRAPH_GET_PG_ID: + mGraph.getPgIdForKernel(addr, requestSize); + break; + case IPC_CCA_CONSTRUCT: { + intel_cca_struct_data* p = static_cast(addr); + uint16_t key = getKey(p->cameraId, p->tuningMode); + if (mCcas.find(key) != mCcas.end()) { + delete mCcas[key]; + mCcas.erase(key); + } + + mCcas[key] = new IntelCcaServer(p->cameraId, p->tuningMode); + + break; + } + case IPC_CCA_DESTRUCT: { + intel_cca_struct_data* p = static_cast(addr); + uint16_t key = getKey(p->cameraId, p->tuningMode); + if (mCcas.find(key) == mCcas.end()) { + LOGE("@%s, req_id:%d, it doesn't find the cca", __func__, req_id); + status = UNKNOWN_ERROR; + break; + } + + delete mCcas[key]; + mCcas.erase(key); + + break; + } + case IPC_CCA_INIT: { + intel_cca_init_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->init(addr, requestSize); + break; + } + case IPC_CCA_RUN_AEC: { + intel_cca_run_aec_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + if (p->hasDecodeStats) { + intel_cca_decode_stats_data* pDecodeStats = &p->decodeStatsParams; + status = decodeStats(pDecodeStats, key); + if (status != OK) { + LOGE("failed to decode stats in sandbox"); + break; + } + } + + status = mCcas[key]->runAEC(addr, requestSize); + break; + } + case IPC_CCA_RUN_AIQ: { + intel_cca_run_aiq_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + if (p->mknResultsHandle >= 0) { + ShmInfo paramsInfo = {}; + status = getIntelAlgoServer()->getShmInfo(p->mknResultsHandle, ¶msInfo); + if (status != OK) { + LOGE("%s, the buffer handle for mknResultsHandle is invalid", __func__); + break; + } + p->mknResults = static_cast(paramsInfo.addr); + } + + if (p->aiqResultHandle >= 0) { + ShmInfo paramsInfo = {}; + status = getIntelAlgoServer()->getShmInfo(p->aiqResultHandle, ¶msInfo); + if (status != OK) { + LOGE("%s, the buffer handle for aiqResultsHandle is invalid", __func__); + break; + } + p->results = static_cast(paramsInfo.addr); + } + + status = mCcas[key]->runAIQ(addr, requestSize); + break; + } + case IPC_CCA_RUN_LTM: { + intel_cca_run_ltm_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->runLTM(addr, requestSize); + break; + } + case IPC_CCA_UPDATE_ZOOM: { + intel_cca_update_zoom_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->updateZoom(addr, requestSize); + break; + } + case IPC_CCA_RUN_DVS: { + intel_cca_run_dvs_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->runDVS(addr, requestSize); + break; + } + case IPC_CCA_RUN_AIC: { + status = UNKNOWN_ERROR; + intel_cca_run_aic_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + if (p->palDataHandle >= 0) { + ShmInfo inParamsInfo = {}; + status = getIntelAlgoServer()->getShmInfo(p->inParamsHandle, &inParamsInfo); + if (status != OK) { + LOGE("%s, the buffer handle for inParamsHandle is invalid", __func__); + break; + } + p->inParams = static_cast(inParamsInfo.addr); + + ShmInfo palDataInfo = {}; + status = getIntelAlgoServer()->getShmInfo(p->palDataHandle, &palDataInfo); + if (status != OK) { + LOGE("%s, the buffer handle for palDataHandle is invalid", __func__); + break; + } + p->palOutData.data = palDataInfo.addr; + + status = mCcas[key]->runAIC(addr, requestSize); + } + break; + } + case IPC_CCA_GET_CMC: { + intel_cca_get_cmc_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->getCMC(addr, requestSize); + break; + } + case IPC_CCA_GET_AIQD: { + intel_cca_get_aiqd_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->getAiqd(addr, requestSize); + break; + } + case IPC_CCA_UPDATE_TUNING: { + intel_cca_update_tuning_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + mCcas[key]->updateTuning(addr, requestSize); + break; + } + case IPC_CCA_DEINIT: { + intel_cca_deinit_data* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->deinit(addr, requestSize); + break; + } + case IPC_CCA_GET_PAL_SIZE: { + intel_cca_get_pal_data_size* p = static_cast(addr); + FUNCTION_PREPARED_RETURN + + status = mCcas[key]->getPalDataSize(addr, requestSize); + break; + } + case IPC_PG_PARAM_INIT: + status = mPGParam.init(addr, requestSize); + break; + case IPC_PG_PARAM_PREPARE: { + pg_param_prepare_params* prepareParams = static_cast(addr); + ShmInfo palDataInfo = {}; + status = getIntelAlgoServer()->getShmInfo(prepareParams->ipuParamHandle, &palDataInfo); + if (status != OK) { + LOGE("%s, the buffer handle for pal data is invalid", __func__); + break; + } + status = mPGParam.prepare(addr, requestSize, palDataInfo.addr); + break; + } + case IPC_PG_PARAM_ALLOCATE_PG: + status = mPGParam.allocatePGBuffer(addr, requestSize); + break; + case IPC_PG_PARAM_GET_FRAG_DESCS: + status = mPGParam.getFragmentDescriptors(addr, requestSize); + break; + case IPC_PG_PARAM_PREPARE_PROGRAM: + status = mPGParam.setPGAndPrepareProgram(addr, requestSize); + break; + case IPC_PG_PARAM_REGISTER_PAYLOADS: + status = mPGParam.registerPayloads(addr, requestSize); + break; + case IPC_PG_PARAM_ENCODE: { + pg_param_encode_params* encodeParams = static_cast(addr); + ShmInfo palDataInfo = {}; + status = getIntelAlgoServer()->getShmInfo(encodeParams->ipuParamHandle, &palDataInfo); + if (status != OK) { + LOGE("%s, the buffer handle for pal data is invalid", __func__); + break; + } + status = mPGParam.updatePALAndEncode(addr, requestSize, palDataInfo.addr); + break; + } + case IPC_PG_PARAM_DECODE: { + pg_param_decode_params* decodeParams = static_cast(addr); + ShmInfo decodeInfo = {}; + status = getIntelAlgoServer()->getShmInfo(decodeParams->clientStatsHandle, &decodeInfo); + if (status == OK) { + status = mPGParam.decode(addr, requestSize, decodeInfo.addr); + } else { + LOGE("%s, the buffer handle for stats data is invalid", __func__); + } + + if (decodeParams->hasStatsDecode) { + // Update stats bin size + intel_cca_decode_stats_data* p = &decodeParams->decodeStatsParams; + p->statsBuffer.size = decodeParams->statsSize; + FUNCTION_PREPARED_RETURN + status = decodeStats(p, key); + } + + break; + } + case IPC_PG_PARAM_DEINIT: + mPGParam.deinit(addr, requestSize); + break; + default: + LOGE("@%s, req_id:%d is not defined", __func__, req_id); + status = UNKNOWN_ERROR; + break; + } + + LOG2("@%s, req_id:%d:%s, status:%d", __func__, req_id, + IntelAlgoIpcCmdToString(static_cast(req_id)), status); + getIntelAlgoServer()->returnCallback(req_id, status, buffer_handle); +} + +status_t IntelCPUAlgoServer::decodeStats(intel_cca_decode_stats_data* p, uint16_t key) { + ShmInfo info = {}; + status_t status = getIntelAlgoServer()->getShmInfo(p->statsHandle, &info); + CheckAndLogError(status != OK, status, "the handle for stats data is invalid"); + + return mCcas[key]->decodeStats(p, info.addr); +} + +uint16_t IntelCPUAlgoServer::getKey(int cameraId, TuningMode mode) { + return ((cameraId & 0xFF) << 8) + (mode & 0xFF); +} +} // namespace icamera diff --git a/modules/sandboxing/server/IntelCPUAlgoServer.h b/modules/sandboxing/server/IntelCPUAlgoServer.h new file mode 100644 index 00000000..30b7fbeb --- /dev/null +++ b/modules/sandboxing/server/IntelCPUAlgoServer.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include +#include +#include + +#include "CameraLog.h" +#include "GraphConfigServer.h" +#include "IntelAlgoServer.h" +#include "IntelCcaServer.h" +#include "IntelFDServer.h" +#include "IntelPGParamServer.h" +#include "cros-camera/camera_algorithm.h" +#include "iutils/Errors.h" +#include "iutils/Thread.h" +#include "modules/sandboxing/IPCCommon.h" + +namespace icamera { + +class IntelCPUAlgoServer : public RequestHandler { + public: + explicit IntelCPUAlgoServer(IntelAlgoServer* server) : RequestHandler(server) {} + virtual ~IntelCPUAlgoServer(); + void handleRequest(const MsgReq& msg); + + private: + uint16_t getKey(int cameraId, TuningMode mode); + status_t decodeStats(intel_cca_decode_stats_data* p, uint16_t key); + + private: + IntelFDServer mFaceDetection; + GraphConfigServer mGraph; + IntelPGParamServer mPGParam; + std::unordered_map mCcas; +}; +} // namespace icamera diff --git a/modules/sandboxing/server/IntelCcaServer.cpp b/modules/sandboxing/server/IntelCcaServer.cpp new file mode 100644 index 00000000..53c721a6 --- /dev/null +++ b/modules/sandboxing/server/IntelCcaServer.cpp @@ -0,0 +1,263 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelCcaServer + +#include "modules/sandboxing/server/IntelCcaServer.h" + +#include +#include +#include + +#include "CameraLog.h" +#include "iutils/Utils.h" +#include "modules/sandboxing/IPCGraphConfig.h" + +namespace icamera { +IntelCcaServer::IntelCcaServer(int cameraId, TuningMode mode) + : mCameraId(cameraId), + mTuningMode(mode), + mCca(nullptr) { + LOG1("@%s, mode:%d", cameraId, __func__, mode); + + mCca = IntelCca::getInstance(cameraId, mode); + CheckAndLogError(!mCca, VOID_VALUE, "%s, IntelCca::getInstance fails, cameraId(%d), mode(%d)", + __func__, mCameraId, mTuningMode); +} + +IntelCcaServer::~IntelCcaServer() { + LOG1("@%s", __func__); + + IntelCca::releaseInstance(mCameraId, mTuningMode); +} + +status_t IntelCcaServer::init(void* pData, int dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_init_data* params = static_cast(pData); + LOG1("@%s, params->bitmap:0x%x", __func__, params->inParams.bitmap); + + ia_err ret = mCca->init(params->inParams); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::runAEC(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_run_aec_data* params = static_cast(pData); + + if (params->hasStats) { + ia_err ret = mCca->setStatsParams(params->inStatsParams); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails to set stats: %d", __func__, + ret); + } + + ia_err ret = mCca->runAEC(params->frameId, params->inParams, ¶ms->results); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::runAIQ(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_run_aiq_data* params = static_cast(pData); + + ia_err ret = mCca->runAIQ(params->frameId, params->inParams, params->results); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + if (params->mknResultsHandle >= 0) { + ret = mCca->getMKN(params->type, params->mknResults); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails to get MKN: %d", __func__, + ret); + } + + return OK; +} + +status_t IntelCcaServer::runLTM(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_run_ltm_data* params = static_cast(pData); + + ia_err ret = mCca->runLTM(params->frameId, params->inParams); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::updateZoom(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_update_zoom_data* params = static_cast(pData); + + ia_err ret = mCca->updateZoom(params->streamId, params->inParams); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::runDVS(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_run_dvs_data* params = static_cast(pData); + + ia_err ret = mCca->runDVS(params->streamId, params->frameId); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::runAIC(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_run_aic_data* params = static_cast(pData); + + bool retVal = unflattenProgramGroup(¶ms->inParams->program_group); + CheckAndLogError(retVal != true, UNKNOWN_ERROR, "@%s, unflattenProgramGroup fails", __func__); + + ia_err ret = mCca->runAIC(params->frameId, params->inParams, ¶ms->palOutData); + CheckAndLogError(ret != ia_err_none && ret != ia_err_not_run, ret, "@%s, fails: %d", __func__, + ret); + + return ret; +} + +status_t IntelCcaServer::getCMC(void* pData, int dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_get_cmc_data* params = static_cast(pData); + + ia_err ret = mCca->getCMC(¶ms->results, params->cpf.size ? ¶ms->cpf : nullptr); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::getAiqd(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_get_aiqd_data* params = static_cast(pData); + + ia_err ret = mCca->getAiqd(¶ms->results); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::updateTuning(void* pData, int dataSize) { + PERF_CAMERA_ATRACE(); + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_update_tuning_data* params = static_cast(pData); + + ia_err ret = mCca->updateTuning(params->lardTags, params->lardParams, params->nvmParams, + params->streamId); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +status_t IntelCcaServer::deinit(void* pData, int dataSize) { + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + mCca->deinit(); + LOG1("@%s", __func__); + + return OK; +} + +status_t IntelCcaServer::decodeStats(void* pData, void* statsAddr) { + PERF_CAMERA_ATRACE(); + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(statsAddr == nullptr, UNKNOWN_ERROR, "@%s, statsAddr is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_decode_stats_data* params = static_cast(pData); + + if (params->statsBuffer.size > 0) { + params->statsBuffer.data = statsAddr; + } + + ia_err ret = mCca->decodeStats(reinterpret_cast(params->statsBuffer.data), + params->statsBuffer.size, params->bitmap, ¶ms->results, + ¶ms->outStats); + CheckAndLogError(ret != ia_err_none, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + return OK; +} + +bool IntelCcaServer::unflattenProgramGroup(cca::cca_program_group* result) { + CheckAndLogError(!result, false, "@%s, result is nullptr", __func__); + CheckAndLogError(result->base.kernel_count > MAX_STREAM_KERNEL_COUNT, false, + "%s, the buffer of kernel array is too small", __func__); + + result->base.run_kernels = result->run_kernels; + for (unsigned j = 0; j < result->base.kernel_count; ++j) { + if (result->run_kernels[j].resolution_info) { + result->run_kernels[j].resolution_info = &result->resolution_info[j]; + } + + if (result->run_kernels[j].resolution_history) { + result->run_kernels[j].resolution_history = &result->resolution_history[j]; + } + } + if (result->base.pipe) { + result->base.pipe = result->pipe; + } + + return true; +} + +status_t IntelCcaServer::getPalDataSize(void* pData, int dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(mCca == nullptr, UNKNOWN_ERROR, "@%s, mCca is nullptr", __func__); + + intel_cca_get_pal_data_size* params = static_cast(pData); + bool ret = unflattenProgramGroup(¶ms->pg); + CheckAndLogError(ret != true, UNKNOWN_ERROR, "@%s, unflattenProgramGroup fails", __func__); + + uint32_t size = mCca->getPalDataSize(params->pg); + CheckAndLogError(size == 0, UNKNOWN_ERROR, "@%s, fails: %d", __func__, ret); + + params->returnSize = size; + + return OK; +} +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelCcaServer.h b/modules/sandboxing/server/IntelCcaServer.h new file mode 100644 index 00000000..4d26d915 --- /dev/null +++ b/modules/sandboxing/server/IntelCcaServer.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "memory" +#include + +#include "iutils/Errors.h" +#include "modules/algowrapper/IntelCca.h" +#include "modules/sandboxing/IPCIntelCca.h" + +namespace icamera { +class IntelCcaServer { + public: + IntelCcaServer(int cameraId, TuningMode mode); + virtual ~IntelCcaServer(); + + status_t init(void* pData, int dataSize); + status_t runAEC(void* pData, int dataSize); + status_t runAIQ(void* pData, int dataSize); + status_t runLTM(void* pData, int dataSize); + status_t updateZoom(void* pData, int dataSize); + status_t runDVS(void* pData, int dataSize); + status_t runAIC(void* pData, int dataSize); + status_t getCMC(void* pData, int dataSize); + status_t getAiqd(void* pData, int dataSize); + status_t updateTuning(void* pData, int dataSize); + status_t deinit(void* pData, int dataSize); + status_t decodeStats(void* pData, void* statsAddr); + status_t getPalDataSize(void* pData, int dataSize); + + private: + bool unflattenProgramGroup(cca::cca_program_group* result); + + private: + int mCameraId; + TuningMode mTuningMode; + + IntelCca* mCca; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelEvcpServer.cpp b/modules/sandboxing/server/IntelEvcpServer.cpp new file mode 100644 index 00000000..602c1edc --- /dev/null +++ b/modules/sandboxing/server/IntelEvcpServer.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelEVCPServer + +#include "modules/sandboxing/server/IntelEvcpServer.h" + +#include "CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { +int IntelEvcpServer::init(void* pData, int dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "%s, pData is nullptr", __func__); + CheckAndLogError(dataSize < static_cast(sizeof(EvcpResolution)), UNKNOWN_ERROR, + "%s, Buffer mismatch", __func__); + + EvcpResolution* res = reinterpret_cast(pData); + mIntelEvcp = std::unique_ptr(new IntelEvcp()); + + return mIntelEvcp->init(res->width, res->height); +} + +int IntelEvcpServer::deInit() { + mIntelEvcp = nullptr; + + return OK; +} + +int IntelEvcpServer::runEvcpFrame(void* bufferAddr, int size) { + CheckAndLogError(bufferAddr == nullptr, UNKNOWN_ERROR, "%s, Buffer is nullptr", __func__); + + return mIntelEvcp->runEvcpFrame(bufferAddr, size) ? OK : UNKNOWN_ERROR; +} + +int IntelEvcpServer::updateEvcpParam(EvcpParam* param) { + CheckAndLogError(param == nullptr, UNKNOWN_ERROR, "%s, new param is nullptr", __func__); + + return mIntelEvcp->updateEvcpParam(param) ? OK : UNKNOWN_ERROR; +} + +int IntelEvcpServer::getEvcpParam(EvcpParam* param) const { + CheckAndLogError(param == nullptr, UNKNOWN_ERROR, "%s, param is nullptr", __func__); + + mIntelEvcp->getEvcpParam(param); + + return OK; +} + +} // namespace icamera diff --git a/modules/sandboxing/server/IntelEvcpServer.h b/modules/sandboxing/server/IntelEvcpServer.h new file mode 100644 index 00000000..3077bade --- /dev/null +++ b/modules/sandboxing/server/IntelEvcpServer.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "evcp/EvcpCommon.h" +#include "iutils/Errors.h" +#include "modules/algowrapper/IntelEvcp.h" + +namespace icamera { + +class IntelEvcpServer { + public: + IntelEvcpServer() {} + ~IntelEvcpServer() {} + + int init(void* pData, int dataSize); + int deInit(); + + int runEvcpFrame(void* bufAddr, int size); + int updateEvcpParam(EvcpParam* param); + int getEvcpParam(EvcpParam* evcpParam) const; + + private: + std::unique_ptr mIntelEvcp; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelFDServer.cpp b/modules/sandboxing/server/IntelFDServer.cpp new file mode 100644 index 00000000..94640d5d --- /dev/null +++ b/modules/sandboxing/server/IntelFDServer.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelFDServer + +#include "modules/sandboxing/server/IntelFDServer.h" + +#include + +#include "CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { +IntelFDServer::IntelFDServer() { + LOG1("@%s Construct", __func__); +} + +IntelFDServer::~IntelFDServer() { + LOG1("@%s Destroy", __func__); +} + +status_t IntelFDServer::init(void* pData, int dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(dataSize < static_cast(sizeof(FaceDetectionInitParams)), UNKNOWN_ERROR, + "@%s, buffer size: %d is small", __func__, dataSize); + + FaceDetectionInitParams* inParams = static_cast(pData); + if (mFaceDetection.find(inParams->cameraId) == mFaceDetection.end()) { + mFaceDetection[inParams->cameraId] = + std::unique_ptr(new IntelFaceDetection()); + } + + return mFaceDetection[inParams->cameraId]->init(inParams, dataSize); +} + +status_t IntelFDServer::run(void* pData, int dataSize, void* imageData) { + PERF_CAMERA_ATRACE(); + TRACE_LOG_PROCESS("IntelFDServer", "runFaceDetection"); + + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(dataSize < static_cast(sizeof(FaceDetectionRunParams)), UNKNOWN_ERROR, + "@%s, buffer size: %d is small", __func__, dataSize); + pvl_image image; + int cameraId; + FaceDetectionRunParams* pFdRunParams = static_cast(pData); + mIpcFD.serverUnflattenRun(*pFdRunParams, imageData, &image, &cameraId); + CheckAndLogError((mFaceDetection.find(cameraId) == mFaceDetection.end()), UNKNOWN_ERROR, + " @%s, mFaceDetection is nullptr", cameraId, __func__); + + return mFaceDetection[cameraId]->run(&image, &pFdRunParams->results); +} + +status_t IntelFDServer::deinit(void* pData, int dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(dataSize < static_cast(sizeof(FaceDetectionDeinitParams)), UNKNOWN_ERROR, + "@%s, buffer size: %d is small", __func__, dataSize); + + FaceDetectionDeinitParams* deinitParams = static_cast(pData); + CheckAndLogError((mFaceDetection.find(deinitParams->cameraId) == mFaceDetection.end()), + UNKNOWN_ERROR, " @%s, mFaceDetection is nullptr", deinitParams->cameraId, + __func__); + + return mFaceDetection[deinitParams->cameraId]->deinit(deinitParams, dataSize); +} +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelFDServer.h b/modules/sandboxing/server/IntelFDServer.h new file mode 100644 index 00000000..e7d28496 --- /dev/null +++ b/modules/sandboxing/server/IntelFDServer.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019-2020 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "iutils/Errors.h" +#include "modules/algowrapper/IntelFaceDetection.h" +#include "modules/sandboxing/IPCIntelFD.h" + +namespace icamera { +class IntelFDServer { + public: + IntelFDServer(); + virtual ~IntelFDServer(); + + status_t init(void* pData, int dataSize); + status_t run(void* pData, int dataSize, void* imageData); + status_t deinit(void* pData, int dataSize); + + private: + std::unordered_map> mFaceDetection; + IPCIntelFD mIpcFD; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelGPUAlgoServer.cpp b/modules/sandboxing/server/IntelGPUAlgoServer.cpp new file mode 100644 index 00000000..15fcd4b9 --- /dev/null +++ b/modules/sandboxing/server/IntelGPUAlgoServer.cpp @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelGPUAlgoServer + +#include "modules/sandboxing/server/IntelGPUAlgoServer.h" + +#include +#include +#include +#include + +#include +#include + +#include "iutils/Utils.h" + +namespace icamera { + +void IntelGPUAlgoServer::handleRequest(const MsgReq& msg) { + uint32_t req_id = msg.req_id; + int32_t buffer_handle = msg.buffer_handle; + + ShmInfo info = {}; + status_t status = getIntelAlgoServer()->getShmInfo(buffer_handle, &info); + if (status != OK) { + LOGE("@%s, Invalid buffer handle", __func__); + getIntelAlgoServer()->returnCallback(req_id, UNKNOWN_ERROR, buffer_handle); + return; + } + + size_t requestSize = info.size; + void* addr = info.addr; + + switch (req_id) { +#ifdef TNR7_CM + case IPC_GPU_TNR_INIT: + status = mTNR.init(addr, requestSize); + break; + case IPC_GPU_TNR_GET_SURFACE_INFO: { + TnrRequestInfo* requestInfo = static_cast(addr); + status = mTNR.getTnrBufferSize(requestInfo); + break; + } + case IPC_GPU_TNR_PREPARE_SURFACE: { + TnrRequestInfo* requestInfo = static_cast(addr); + ShmInfo surfaceBuffer = {}; + if (requestInfo->surfaceHandle >= 0) { + status = + getIntelAlgoServer()->getShmInfo(requestInfo->surfaceHandle, &surfaceBuffer); + if (status != OK) { + LOGE("%s, the buffer handle for surfaceBuffer data is invalid", __func__); + break; + } + } + status = mTNR.prepareSurface(surfaceBuffer.addr, surfaceBuffer.size, requestInfo); + break; + } + case IPC_GPU_TNR_RUN_FRAME: + case IPC_GPU_TNR_THREAD2_RUN_FRAME: { + TnrRequestInfo* requestInfo = static_cast(addr); + ShmInfo inBuffer = {}; + ShmInfo outBuffer = {}; + ShmInfo paramBuffer = {}; + if (requestInfo->inHandle >= 0) { + status = getIntelAlgoServer()->getShmInfo(requestInfo->inHandle, &inBuffer); + if (status != OK) { + LOGE("%s, the buffer handle for inBuffer data is invalid", __func__); + break; + } + } + if (requestInfo->outHandle >= 0) { + status = getIntelAlgoServer()->getShmInfo(requestInfo->outHandle, &outBuffer); + if (status != OK) { + LOGE("%s, the buffer handle for outBuffer data is invalid", __func__); + break; + } + } + if (requestInfo->paramHandle >= 0) { + status = getIntelAlgoServer()->getShmInfo(requestInfo->paramHandle, ¶mBuffer); + if (status != OK) { + LOGE("%s, the buffer handle for parameter is invalid", __func__); + break; + } + } + + status = mTNR.runTnrFrame(inBuffer.addr, outBuffer.addr, inBuffer.size, outBuffer.size, + paramBuffer.addr, requestInfo); + break; + } + case IPC_GPU_TNR_PARAM_UPDATE: + case IPC_GPU_TNR_THREAD2_PARAM_UPDATE: { + TnrRequestInfo* requestInfo = static_cast(addr); + status = mTNR.asyncParamUpdate(requestInfo); + break; + } + case IPC_GPU_TNR_DEINIT: { + TnrRequestInfo* requestInfo = static_cast(addr); + status = mTNR.deInit(requestInfo); + break; + } +#endif + + // LEVEL0_ICBM_S + case IPC_ICBM_INIT: + (void) requestSize; + status = mICBMServer.setup(reinterpret_cast(addr)); + break; + case IPC_ICBM_RUN_FRAME: { + status = UNKNOWN_ERROR; + ICBMReqInfo* runInfo = reinterpret_cast(addr); + ShmInfo inBuffer = {}; + if (runInfo->inHandle < 0) break; + ShmInfo outBuffer = {}; + if (runInfo->inHandle < 0) break; + + status = getIntelAlgoServer()->getShmInfo(runInfo->inHandle, &inBuffer); + if (status != OK) { + LOGE("%s, the buffer handle for ICBM inBuffer data is invalid", __func__); + break; + } + + status = getIntelAlgoServer()->getShmInfo(runInfo->outHandle, &outBuffer); + if (status != OK) { + LOGE("%s, the buffer handle for ICBM outBuffer data is invalid", __func__); + break; + } + if (runInfo->paramHandle >= 0) { + ShmInfo paramBuffer = {}; + status = getIntelAlgoServer()->getShmInfo(runInfo->paramHandle, ¶mBuffer); + if (status != OK) { + LOGE("%s, the buffer handle for parameter is invalid", __func__); + break; + } + runInfo->paramAddr = paramBuffer.addr; + } + runInfo->inII.bufAddr = inBuffer.addr; + runInfo->outII.bufAddr = outBuffer.addr; + + status = mICBMServer.processFrame(*runInfo); + + runInfo->inII.bufAddr = nullptr; + runInfo->outII.bufAddr = nullptr; + runInfo->paramAddr = nullptr; + break; + } + case IPC_ICBM_DEINIT: { + ICBMReqInfo* shutInfo = static_cast(addr); + status = mICBMServer.shutdown(*shutInfo); + break; + } + // LEVEL0_ICBM_E + default: + LOGE("@%s, req_id:%d is not defined", __func__, req_id); + status = UNKNOWN_ERROR; + break; + } + LOG1("@%s, req_id:%d:%s, status:%d", __func__, req_id, + IntelAlgoIpcCmdToString(static_cast(req_id)), status); + + (void)requestSize; + (void)addr; + getIntelAlgoServer()->returnCallback(req_id, status, buffer_handle); +} +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelGPUAlgoServer.h b/modules/sandboxing/server/IntelGPUAlgoServer.h new file mode 100644 index 00000000..98aeed68 --- /dev/null +++ b/modules/sandboxing/server/IntelGPUAlgoServer.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include +#include +#include + +#include "CameraLog.h" +#include "IntelAlgoServer.h" +#include "cros-camera/camera_algorithm.h" +#include "iutils/Errors.h" +#include "iutils/Thread.h" +#include "modules/sandboxing/IPCCommon.h" +#ifdef TNR7_CM +#include "modules/sandboxing/server/IntelTNRServer.h" +#endif + +// LEVEL0_ICBM_S +#include "modules/sandboxing/server/IntelICBMServer.h" +// LEVEL0_ICBM_E + +namespace icamera { + +class IntelGPUAlgoServer : public RequestHandler { + public: + explicit IntelGPUAlgoServer(IntelAlgoServer* server) : RequestHandler(server) {} + virtual ~IntelGPUAlgoServer() {} + void handleRequest(const MsgReq& msg); + +#ifdef TNR7_CM + private: + IntelTNRServer mTNR; +#endif + + // LEVEL0_ICBM_S + private: + IntelICBMServer mICBMServer; + // LEVEL0_ICBM_E +}; + +} // namespace icamera diff --git a/modules/sandboxing/server/IntelICBMServer.cpp b/modules/sandboxing/server/IntelICBMServer.cpp new file mode 100644 index 00000000..cf3c7381 --- /dev/null +++ b/modules/sandboxing/server/IntelICBMServer.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelICBMServer + +#include "modules/sandboxing/server/IntelICBMServer.h" + +#include "CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +int IntelICBMServer::setup(ICBMInitInfo* initParam) { + mIntelICBM = std::unique_ptr(new IntelICBM()); + + return mIntelICBM->setup(initParam); +} + +int IntelICBMServer::shutdown(const ICBMReqInfo& reqInfo) { + int ret = mIntelICBM->shutdown(reqInfo); + + return ret >= 0 ? OK : ret; +} + +int IntelICBMServer::processFrame(const ICBMReqInfo& reqInfo) { + return mIntelICBM->processFrame(reqInfo); +} + +} // namespace icamera diff --git a/modules/sandboxing/server/IntelICBMServer.h b/modules/sandboxing/server/IntelICBMServer.h new file mode 100644 index 00000000..0dbc15d3 --- /dev/null +++ b/modules/sandboxing/server/IntelICBMServer.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2022-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "icbm/ICBMTypes.h" +#include "iutils/Errors.h" +#include "modules/algowrapper/IntelICBM.h" + +namespace icamera { + +class IntelICBMServer { + public: + IntelICBMServer(){}; + ~IntelICBMServer(){}; + + int setup(ICBMInitInfo* initParam); + int shutdown(const ICBMReqInfo& reqInfo); + + int processFrame(const ICBMReqInfo& reqInfo); + + private: + std::unique_ptr mIntelICBM; +}; +} /* namespace icamera */ diff --git a/modules/sandboxing/server/IntelPGParamServer.cpp b/modules/sandboxing/server/IntelPGParamServer.cpp new file mode 100644 index 00000000..9962e98c --- /dev/null +++ b/modules/sandboxing/server/IntelPGParamServer.cpp @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelPGParamS + +#include "modules/sandboxing/server/IntelPGParamServer.h" + +#include "iutils/CameraLog.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" + +namespace icamera { + +IntelPGParamServer::IntelPGParamServer() {} + +IntelPGParamServer::~IntelPGParamServer() {} + +int IntelPGParamServer::init(void* pData, int dataSize) { + int pgId = 0; + uintptr_t client = 0; + ia_p2p_platform_t platform = IA_P2P_PLATFORM_IPU6; + PgConfiguration pgConfig; + + bool ret = mIpc.serverUnflattenInit(pData, dataSize, &pgId, &client, &platform, &pgConfig); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenInit fails", __func__); + + PGParamPackage package; + package.pgId = pgId; + package.mPayloadCount = 0; + CLEAR(package.mPayloads); + package.mPGBuffer = nullptr; + mPGParamPackages[client] = package; + mPGParamPackages[client].mPGParamAdapt = std::shared_ptr(new IntelPGParam(pgId)); + int result = mPGParamPackages[client].mPGParamAdapt->init(platform, pgConfig); + CheckAndLogError(result != OK, result, "@%s, init fails", __func__); + + return OK; +} + +int IntelPGParamServer::prepare(void* pData, int dataSize, void* palDataAddr) { + uintptr_t client = 0; + ia_binary_data ipuParameters = {nullptr, 0}; + ia_css_rbm_t* rbm = nullptr; + ia_css_kernel_bitmap_t* bitmap = nullptr; + uint32_t* maxStatsSize = nullptr; + bool ret = mIpc.serverUnflattenPrepare(pData, dataSize, &client, palDataAddr, &ipuParameters, + &rbm, &bitmap, &maxStatsSize); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenPrepare fails", __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), UNKNOWN_ERROR, + "%s, the pg doesn't exist in the table", __func__); + + int result = + mPGParamPackages[client].mPGParamAdapt->prepare(&ipuParameters, rbm, bitmap, maxStatsSize); + CheckAndLogError(result != OK, result, "@%s, prepare fails", __func__); + + return OK; +} + +int IntelPGParamServer::allocatePGBuffer(void* pData, int dataSize) { + uintptr_t client = 0; + int pgSize = 0; + bool ret = mIpc.serverUnflattenAllocatePGBuffer(pData, dataSize, &client, &pgSize); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenAllocatePGBuffer fails", + __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), UNKNOWN_ERROR, + "%s, the pg doesn't exist in the table", __func__); + + // Get server data pointer of PGBuffer + void* pgBuffer = nullptr; + ret = mIpc.assignPGBuffer(pData, dataSize, pgSize, &pgBuffer); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, assignPGBuffer fails", __func__); + + mPGParamPackages[client].mPGBuffer = reinterpret_cast(pgBuffer); + return OK; +} + +int IntelPGParamServer::getFragmentDescriptors(void* pData, int dataSize) { + uintptr_t client = 0; + int descCount = 0; + ia_p2p_fragment_desc* descs = nullptr; + bool ret = mIpc.serverUnflattenGetFragDescs(pData, dataSize, &client, &descCount, &descs); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenGetFragDescs fails", + __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), UNKNOWN_ERROR, + "%s, the pg doesn't exist in the table", __func__); + + int count = mPGParamPackages[client].mPGParamAdapt->getFragmentDescriptors(descCount, descs); + CheckAndLogError(count <= 0, count, "@%s, getFragmentDescriptors fails", __func__); + + ret = mIpc.serverFlattenGetFragDescs(pData, dataSize, count); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverFlattenGetFragDescs fails", __func__); + + return OK; +} + +int IntelPGParamServer::setPGAndPrepareProgram(void* pData, int dataSize) { + uintptr_t client = 0; + bool ret = mIpc.serverUnflattenPrepareProgram(pData, dataSize, &client); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenPrepareProgram fails", + __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), UNKNOWN_ERROR, + "%s, the pg doesn't exist in the table", __func__); + PGParamPackage& package = mPGParamPackages[client]; + + int result = package.mPGParamAdapt->setPGAndPrepareProgram(package.mPGBuffer); + CheckAndLogError(result != OK, result, "@%s, setPGAndPrepareProgram fails", __func__); + + // Get payload size here + package.mPayloadCount = + package.mPGParamAdapt->getPayloadSizes(ARRAY_SIZE(package.mPayloads), package.mPayloads); + CheckAndLogError(!package.mPayloadCount, UNKNOWN_ERROR, "@%s, getPayloadSizes fails", __func__); + + ret = + mIpc.serverFlattenPrepareProgram(pData, dataSize, package.mPayloadCount, package.mPayloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverFlattenPrepareProgram fails", + __func__); + + return OK; +} + +int IntelPGParamServer::registerPayloads(void* pData, int dataSize) { + uintptr_t client = 0; + int payloadCount = 0; + ia_binary_data* cPayloads = nullptr; + ia_binary_data* sPayloads = nullptr; + bool ret = mIpc.serverUnflattenRegisterPayloads(pData, dataSize, &client, &payloadCount, + &cPayloads, &sPayloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenRegisterPayloads fails", + __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), UNKNOWN_ERROR, + "%s, the pg doesn't exist in the table", __func__); + PGParamPackage& package = mPGParamPackages[client]; + + // Save + for (int i = 0; i < payloadCount; i++) { + if (cPayloads[i].size > 0) { + package.mAllocatedPayloads[cPayloads[i].data] = sPayloads[i]; + } + } + + return OK; +} + +int IntelPGParamServer::updatePALAndEncode(void* pData, int dataSize, void* palDataAddr) { + PERF_CAMERA_ATRACE(); + TRACE_LOG_PROCESS("IntelPGParamServer", "updatePALAndEncode"); + uintptr_t client = 0; + ia_binary_data ipuParameters = {nullptr, 0}; + ia_binary_data* payloads = nullptr; + int32_t payloadCount = 0; + + bool ret = mIpc.serverUnflattenEncode(pData, dataSize, &client, palDataAddr, &ipuParameters, + &payloadCount, &payloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenEncode fails", __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), UNKNOWN_ERROR, + "%s, the pg doesn't exist in the table", __func__); + PGParamPackage& package = mPGParamPackages[client]; + CheckAndLogError(payloadCount != package.mPayloadCount, UNKNOWN_ERROR, + "@%s, wrong payloadCount", __func__); + + int result = findPayloads(package.mPayloadCount, payloads, &package.mAllocatedPayloads, + package.mPayloads); + CheckAndLogError(result != OK, result, "@%s, findPayloads fails", __func__); + + result = package.mPGParamAdapt->updatePALAndEncode(&ipuParameters, package.mPayloadCount, + package.mPayloads); + CheckAndLogError(result != OK, result, "@%s, updatePALAndEncode fails", __func__); + + return OK; +} + +int IntelPGParamServer::decode(void* pData, int dataSize, void* statsAddr) { + PERF_CAMERA_ATRACE(); + TRACE_LOG_PROCESS("IntelPGParamServer", "decode"); + uintptr_t client = 0; + ia_binary_data statistics = {statsAddr, 0}; + ia_binary_data* payloads = nullptr; + int32_t payloadCount = 0; + + bool ret = mIpc.serverUnflattenDecode(pData, dataSize, &client, &payloadCount, &payloads); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverUnflattenDecode fails", __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), UNKNOWN_ERROR, + "%s, the pg doesn't exist in the table", __func__); + PGParamPackage& package = mPGParamPackages[client]; + CheckAndLogError(payloadCount != package.mPayloadCount, UNKNOWN_ERROR, + "@%s, wrong payloadCount", __func__); + + int result = findPayloads(package.mPayloadCount, payloads, &package.mAllocatedPayloads, + package.mPayloads); + CheckAndLogError(result != OK, result, "@%s, findPayloads fails", __func__); + + result = package.mPGParamAdapt->decode(package.mPayloadCount, package.mPayloads, &statistics); + CheckAndLogError(result != OK, result, "@%s, decode fails", __func__); + + ret = mIpc.serverFlattenDecode(pData, dataSize, statistics); + CheckAndLogError(ret == false, UNKNOWN_ERROR, "@%s, serverFlattenDecode fails", __func__); + + return OK; +} + +void IntelPGParamServer::deinit(void* pData, int dataSize) { + uintptr_t client = 0; + + bool ret = mIpc.serverUnflattenDeinit(pData, dataSize, &client); + CheckAndLogError(ret == false, VOID_VALUE, "@%s, serverUnflattenDeinit fails", __func__); + + CheckAndLogError((mPGParamPackages.find(client) == mPGParamPackages.end()), VOID_VALUE, + "%s, the pg doesn't exist in the table", __func__); + + mPGParamPackages[client].mPGParamAdapt->deinit(); + mPGParamPackages.erase(client); +} + +int IntelPGParamServer::findPayloads(int32_t payloadCount, ia_binary_data* clientPayloads, + std::unordered_map* allocated, + ia_binary_data* serverPayloads) { + CheckAndLogError(!clientPayloads, BAD_VALUE, "@%s, payloads is nullptr", __func__); + CLEAR(*serverPayloads); + for (size_t i = 0; i < payloadCount; i++) { + if (!clientPayloads[i].size) continue; + + CheckAndLogError(allocated->find(clientPayloads[i].data) == allocated->end(), UNKNOWN_ERROR, + "%s: can't find client payload %p for term %zu", __func__, + clientPayloads[i].data, i); + ia_binary_data& alloc = allocated->at(clientPayloads[i].data); + CheckAndLogError(alloc.size != clientPayloads[i].size, UNKNOWN_ERROR, + "%s: payload size mismatch for term %zu", __func__, i); + serverPayloads[i] = alloc; + } + return OK; +} + +} // namespace icamera diff --git a/modules/sandboxing/server/IntelPGParamServer.h b/modules/sandboxing/server/IntelPGParamServer.h new file mode 100644 index 00000000..3b27cc1b --- /dev/null +++ b/modules/sandboxing/server/IntelPGParamServer.h @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "modules/algowrapper/IntelPGParam.h" +#include "modules/sandboxing/IPCIntelPGParam.h" + +namespace icamera { + +class IntelPGParamServer { + public: + IntelPGParamServer(); + ~IntelPGParamServer(); + + int init(void* pData, int dataSize); + int prepare(void* pData, int dataSize, void* palDataAddr); + int allocatePGBuffer(void* pData, int dataSize); + int getFragmentDescriptors(void* pData, int dataSize); + int setPGAndPrepareProgram(void* pData, int dataSize); + int registerPayloads(void* pData, int dataSize); + int updatePALAndEncode(void* pData, int dataSize, void* palDataAddr); + int decode(void* pData, int dataSize, void* statsAddr); + void deinit(void* pData, int dataSize); + + private: + struct PGParamPackage { + int pgId; + std::shared_ptr mPGParamAdapt; + ia_binary_data mPayloads[IPU_MAX_TERMINAL_COUNT]; // match terminals for encode/decode + int mPayloadCount; + ia_css_process_group_t* mPGBuffer; + + // + std::unordered_map mAllocatedPayloads; + }; + + private: + int findPayloads(int32_t payloadCount, ia_binary_data* clientPayloads, + std::unordered_map* allocated, + ia_binary_data* serverPayloads); + + IPCIntelPGParam mIpc; + std::unordered_map mPGParamPackages; +}; + +} // namespace icamera diff --git a/modules/sandboxing/server/IntelTNRServer.cpp b/modules/sandboxing/server/IntelTNRServer.cpp new file mode 100644 index 00000000..c111e3cf --- /dev/null +++ b/modules/sandboxing/server/IntelTNRServer.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG IntelTNRServer + +#include "modules/sandboxing/server/IntelTNRServer.h" + +#include + +#include "CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +IntelTNRServer::IntelTNRServer() { + LOG1("@%s Construct", __func__); +} + +IntelTNRServer::~IntelTNRServer() { + mIntelTNRMap.clear(); + mLockMap.clear(); + LOG1("@%s Destroy", __func__); +} + +int IntelTNRServer::init(void* pData, int dataSize) { + CheckAndLogError(pData == nullptr, UNKNOWN_ERROR, "@%s, pData is nullptr", __func__); + CheckAndLogError(dataSize < static_cast(sizeof(TnrInitInfo)), UNKNOWN_ERROR, + "@%s, buffer size %d is small", __func__, dataSize); + TnrInitInfo* initInfo = static_cast(pData); + CheckAndLogError(initInfo->type >= TNR_INSTANCE_MAX || initInfo->type < 0, UNKNOWN_ERROR, + "@%s, invalid tnr type: %d", __func__, static_cast(initInfo->type)); + + CheckAndLogError(mIntelTNRMap.size() == TNR_INSTANCE_MAX, UNKNOWN_ERROR, + "@%s, tnr resource is busy", __func__); + + int tnrInstance; + // choose a free tnr instance + for (tnrInstance = TNR_INSTANCE0; tnrInstance < TNR_INSTANCE_MAX; tnrInstance++) { + bool find = false; + for (auto& ins : mTnrSlotMap) { + if (ins.second == tnrInstance) { + find = true; + break; + } + } + if (!find) break; + } + CheckAndLogError(tnrInstance == TNR_INSTANCE_MAX, UNKNOWN_ERROR, + "@%s, no avaliable tnr instance", __func__); + + int key = getIndex(initInfo->cameraId, initInfo->type); + if (mIntelTNRMap.find(key) == mIntelTNRMap.end()) { + mIntelTNRMap[key] = + std::unique_ptr(IntelTNR7US::createIntelTNR(initInfo->cameraId)); + } + + mLockMap[key] = std::unique_ptr(new std::mutex); + mTnrSlotMap[key] = static_cast(tnrInstance); + std::unique_lock lock(*mLockMap[key]); + + return mIntelTNRMap[key]->init(initInfo->width, initInfo->height, + static_cast(tnrInstance)); +} + +int IntelTNRServer::deInit(TnrRequestInfo* requestInfo) { + CheckAndLogError(requestInfo == nullptr, UNKNOWN_ERROR, "@%s, requestInfo is nullptr", + __func__); + int key = getIndex(requestInfo->cameraId, requestInfo->type); + CheckAndLogError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR, + " @%s, IntelTNR type: %d is invalid", requestInfo->cameraId, __func__, + requestInfo->type); + { + std::unique_lock lock(*mLockMap[key]); + mIntelTNRMap.erase(key); + mTnrSlotMap.erase(key); + } + mLockMap.erase(key); + return OK; +} + +int IntelTNRServer::prepareSurface(void* pData, int dataSize, TnrRequestInfo* requestInfo) { + CheckAndLogError(pData == nullptr || requestInfo == nullptr, UNKNOWN_ERROR, + "@%s, invalid params, pData: %p, requestInfo: %p", __func__, pData, + requestInfo); + int key = getIndex(requestInfo->cameraId, requestInfo->type); + CheckAndLogError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR, + " @%s, IntelTNR type: %d is invalid", requestInfo->cameraId, __func__, + requestInfo->type); + std::unique_lock lock(*mLockMap[key]); + + return mIntelTNRMap[key]->prepareSurface(pData, dataSize); +} + +int IntelTNRServer::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize, + uint32_t outBufSize, void* tnrParam, TnrRequestInfo* requestInfo) { + CheckAndLogError(requestInfo == nullptr, UNKNOWN_ERROR, "@%s, requestInfo is nullptr", + __func__); + int key = getIndex(requestInfo->cameraId, requestInfo->type); + CheckAndLogError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR, + " @%s, IntelTNR type: %d is invalid", requestInfo->cameraId, __func__, + requestInfo->type); + std::unique_lock lock(*mLockMap[key]); + + return mIntelTNRMap[key]->runTnrFrame(inBufAddr, outBufAddr, inBufSize, outBufSize, + static_cast(tnrParam), + requestInfo->isForceUpdate, requestInfo->outBufFd); +} + +int IntelTNRServer::asyncParamUpdate(TnrRequestInfo* requestInfo) { + CheckAndLogError(requestInfo == nullptr, UNKNOWN_ERROR, "@%s, requestInfo is nullptr", + __func__); + int key = getIndex(requestInfo->cameraId, requestInfo->type); + CheckAndLogError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR, + " @%s, IntelTNR type: %d is invalid", requestInfo->cameraId, __func__, + requestInfo->type); + std::unique_lock lock(*mLockMap[key]); + + return mIntelTNRMap[key]->asyncParamUpdate(requestInfo->gain, requestInfo->isForceUpdate); +} + +int IntelTNRServer::getTnrBufferSize(TnrRequestInfo* requestInfo) { + CheckAndLogError(requestInfo == nullptr, UNKNOWN_ERROR, "@%s, requestInfo is nullptr", + __func__); + int key = getIndex(requestInfo->cameraId, requestInfo->type); + CheckAndLogError((mIntelTNRMap.find(key) == mIntelTNRMap.end()), UNKNOWN_ERROR, + " @%s, IntelTNR type: %d is invalid", requestInfo->cameraId, __func__, + requestInfo->type); + std::unique_lock lock(*mLockMap[key]); + + return mIntelTNRMap[key]->getTnrBufferSize(requestInfo->width, requestInfo->height, + &requestInfo->surfaceSize); +} + +} // namespace icamera diff --git a/modules/sandboxing/server/IntelTNRServer.h b/modules/sandboxing/server/IntelTNRServer.h new file mode 100644 index 00000000..6ea1be35 --- /dev/null +++ b/modules/sandboxing/server/IntelTNRServer.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020-2023 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "iutils/Errors.h" +#include "modules/algowrapper/IntelTNR7US.h" + +namespace icamera { + +class IntelTNRServer { + public: + IntelTNRServer(); + virtual ~IntelTNRServer(); + + int init(void* pData, int dataSize); + int deInit(TnrRequestInfo* requestInfo); + int prepareSurface(void* pData, int dataSize, TnrRequestInfo* requestInfo); + int runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize, + uint32_t outBufSize, void* tnrParam, TnrRequestInfo* requestInfo); + int asyncParamUpdate(TnrRequestInfo* requestInfo); + int getTnrBufferSize(TnrRequestInfo* requestInfo); + + private: + // the tnr instance of the id + std::unordered_map mTnrSlotMap; + std::unordered_map> mIntelTNRMap; + std::unordered_map> mLockMap; + // transfer cameraId and type to index of the mTnrSlotMap and mIntelTNRMap + int getIndex(int cameraId, TnrType type) { return (cameraId << TNR_INSTANCE_MAX) + type; } +}; +} /* namespace icamera */ diff --git a/modules/v4l2/v4l2_device.cc b/modules/v4l2/v4l2_device.cc index 43b9ef94..eddd5b6f 100644 --- a/modules/v4l2/v4l2_device.cc +++ b/modules/v4l2/v4l2_device.cc @@ -285,7 +285,7 @@ int V4L2Device::GetControl(struct v4l2_ext_control* ext_control) { int ret = ::ioctl(fd_, VIDIOC_G_EXT_CTRLS, &controls); if (ret != 0) { - LOG1("%s: Device node %s IOCTL VIDIOC_G_EXT_CTRLS error: %s", __func__, name_.c_str(), + LOGE("%s: Device node %s IOCTL VIDIOC_G_EXT_CTRLS error: %s", __func__, name_.c_str(), strerror(errno)); return ret; } diff --git a/modules/v4l2/v4l2_device.h b/modules/v4l2/v4l2_device.h index 94375cdd..87d087ef 100644 --- a/modules/v4l2/v4l2_device.h +++ b/modules/v4l2/v4l2_device.h @@ -351,7 +351,6 @@ class CROS_CAMERA_EXPORT V4L2VideoNode final : public V4L2Device { // V4L2 memory type. enum v4l2_memory GetMemoryType(); - int GetDeviceCaps(); // This method get the buffer type of video device. // // Returns: @@ -468,7 +467,6 @@ class CROS_CAMERA_EXPORT V4L2VideoNode final : public V4L2Device { bool is_buffer_cached_; - int device_caps; enum v4l2_buf_type buffer_type_; enum v4l2_memory memory_type_; diff --git a/modules/v4l2/v4l2_subdevice.cc b/modules/v4l2/v4l2_subdevice.cc index 2d93b1d4..1451dac6 100644 --- a/modules/v4l2/v4l2_subdevice.cc +++ b/modules/v4l2/v4l2_subdevice.cc @@ -102,7 +102,7 @@ int V4L2Subdevice::GetPadFormat(int pad_index, int* width, int* height, int* cod LOG1("@%s", __func__); if (!width || !height || !code) { - LOGE("%s: Device node %s some of parameters is nullptr", __func__, name_.c_str()); + LOGE("%s: Device node %s some of parameters is nullptr: %s", __func__, name_.c_str()); return -EINVAL; } struct v4l2_subdev_format format = {}; @@ -138,7 +138,7 @@ int V4L2Subdevice::SetRouting(v4l2_subdev_route* routes, uint32_t numRoutes) { LOG1("@%s", __func__); if (!routes) { - LOGE("%s: Device node %s routes is nullptr", __func__, name_.c_str()); + LOGE("%s: Device node %s routes is nullptr: %s", __func__, name_.c_str()); return -EINVAL; } @@ -158,7 +158,7 @@ int V4L2Subdevice::GetRouting(v4l2_subdev_route* routes, uint32_t* numRoutes) { LOG1("@%s", __func__); if (!routes || !numRoutes) { - LOGE("%s: Device node %s routes or numRoutes is nullptr", __func__, name_.c_str()); + LOGE("%s: Device node %s routes or numRoutes is nullptr: %s", __func__, name_.c_str()); return -EINVAL; } diff --git a/modules/v4l2/v4l2_video_node.cc b/modules/v4l2/v4l2_video_node.cc index 8c9a913d..a48a922e 100644 --- a/modules/v4l2/v4l2_video_node.cc +++ b/modules/v4l2/v4l2_video_node.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2023 Intel Corporation + * Copyright (C) 2013-2021 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -392,7 +392,6 @@ V4L2VideoNode::V4L2VideoNode(const std::string& name) buffer_type_(V4L2_BUF_TYPE_VIDEO_CAPTURE), memory_type_(V4L2_MEMORY_USERPTR) { LOG1("@%s", __func__); - device_caps = 0; } V4L2VideoNode::~V4L2VideoNode() { @@ -427,14 +426,14 @@ int V4L2VideoNode::Open(int flags) { {V4L2_CAP_VIDEO_OUTPUT_MPLANE, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE}, {V4L2_CAP_META_CAPTURE, V4L2_BUF_TYPE_META_CAPTURE}, {V4L2_CAP_META_OUTPUT, V4L2_BUF_TYPE_META_OUTPUT}}; - size_t i = 0; for (; i < ARRAY_SIZE(buffer_type_mapper); i++) { if (cap.capabilities & buffer_type_mapper[i].first) { - device_caps |= buffer_type_mapper[i].first; + buffer_type_ = buffer_type_mapper[i].second; + break; } } - if (device_caps == 0) { + if (i == ARRAY_SIZE(buffer_type_mapper)) { V4L2Device::Close(); LOGE("%s: ARRAY_SIZE error.", __func__); return -EINVAL; @@ -463,12 +462,6 @@ enum v4l2_memory V4L2VideoNode::GetMemoryType() { return memory_type_; } -int V4L2VideoNode::GetDeviceCaps() { - LOG1("@%s", __func__); - - return device_caps; -} - enum v4l2_buf_type V4L2VideoNode::GetBufferType() { LOG1("@%s", __func__); @@ -537,7 +530,7 @@ int V4L2VideoNode::SetFormat(const V4L2Format& format) { } V4L2Format fmt(format); - buffer_type_ = static_cast(fmt.Type()); + fmt.SetType(buffer_type_); if (V4L2_TYPE_IS_META(buffer_type_)) { fmt.SetSizeImage(0, 0); @@ -601,7 +594,7 @@ int V4L2VideoNode::MapMemory(unsigned int index, int prot, int flags, std::vecto for (uint32_t i = 0; i < num_planes; i++) { void* res = ::mmap(nullptr, buffer.Length(i), prot, flags, fd_, buffer.Offset(i)); if (res == MAP_FAILED) { - LOGE("%s: MMAP error. %s", __func__, strerror(errno)); + LOGE("%s: MMAP error. %d", __func__, strerror(errno)); return -EINVAL; } mapped->push_back(res); @@ -617,7 +610,7 @@ int V4L2VideoNode::GrabFrame(V4L2Buffer* buf) { return -EINVAL; } if (!buf) { - LOGE("%s: Device node %s buf is nullptr", __func__, name_.c_str()); + LOGE("%s: Device node %s buf is nullptr: %s", __func__, name_.c_str()); return -EINVAL; } @@ -648,7 +641,7 @@ int V4L2VideoNode::ExportFrame(unsigned int index, std::vector* fds) { return -EINVAL; } if (!fds) { - LOGE("%s: Device node %s fds is nullptr", __func__, name_.c_str()); + LOGE("%s: Device node %s fds is nullptr: %s", __func__, name_.c_str()); return -EINVAL; } @@ -756,10 +749,10 @@ void V4L2VideoNode::PrintBufferInfo(const std::string& func, const V4L2Buffer& b switch (memory_type_) { case V4L2_MEMORY_USERPTR: - LOG1("%s: idx: %ud, addr: %lu", func.c_str(), buf.Index(), buf.Userptr(0)); + LOG1("%s: idx: %ud, addr: %p", func.c_str(), buf.Index(), buf.Userptr(0)); break; case V4L2_MEMORY_MMAP: - LOG1("%s: idx: %ud, offset: %u", func.c_str(), buf.Index(), buf.Offset(0)); + LOG1("%s: idx: %ud, offset: %p", func.c_str(), buf.Index(), buf.Offset(0)); break; case V4L2_MEMORY_DMABUF: LOG1("%s: idx: %ud, fd: %d", func.c_str(), buf.Index(), buf.Fd(0)); @@ -812,9 +805,9 @@ int V4L2VideoNode::QueryBuffer(int index, enum v4l2_memory memory_type, V4L2Buff LOG1("Device: name: %s, index %ud, type: %ud, bytesused: %ud, flags: 0x%x", name_.c_str(), buf->Index(), buf->Type(), buf->BytesUsed(0), buf->Flags()); if (memory_type == V4L2_MEMORY_MMAP) { - LOG1("memory MMAP: offset %u", buf->Offset(0)); + LOG1("memory MMAP: offset 0x%p", buf->Offset(0)); } else if (memory_type == V4L2_MEMORY_USERPTR) { - LOG1("memory USRPTR: %lu", buf->Userptr(0)); + LOG1("memory USRPTR: %p", buf->Userptr(0)); } LOG1("length: %ud", buf->Length(0)); return 0; @@ -824,7 +817,7 @@ int V4L2VideoNode::GetFormat(V4L2Format* format) { LOG1("@%s", __func__); if (!format) { - LOGE("%s: Device node %s format is nullptr", __func__, name_.c_str()); + LOGE("%s: Device node %s format is nullptr: %s", __func__, name_.c_str()); return -EINVAL; } diff --git a/src/3a/AiqCore.cpp b/src/3a/AiqCore.cpp index 01e91ab0..5cf7b1ad 100644 --- a/src/3a/AiqCore.cpp +++ b/src/3a/AiqCore.cpp @@ -44,7 +44,6 @@ AiqCore::AiqCore(int cameraId) mAiqRunTime(0), mAiqState(AIQ_NOT_INIT), mHyperFocalDistance(0.0f), - mLowPowerMode(false), mTuningMode(TUNING_MODE_MAX), mShadingMode(SHADING_MODE_FAST), mLensShadingMapMode(LENS_SHADING_MAP_MODE_OFF), @@ -120,6 +119,11 @@ int AiqCore::initAiqPlusParams() { int AiqCore::init() { initAiqPlusParams(); +#ifndef ENABLE_SANDBOXING + ia_env env = {&Log::ccaPrintInfo, &Log::ccaPrintError, &Log::ccaPrintInfo}; + ia_log_init(&env); +#endif + mAiqState = AIQ_INIT; int ret = mIntel3AParameter->init(); @@ -135,6 +139,10 @@ int AiqCore::init() { } int AiqCore::deinit() { +#ifndef ENABLE_SANDBOXING + ia_log_deinit(); +#endif + mAiqState = AIQ_NOT_INIT; freeAiqResultMem(); @@ -259,8 +267,6 @@ int AiqCore::updateParameter(const aiq_parameter_t& param) { mLensShadingMapMode = param.lensShadingMapMode; mLensShadingMapSize = param.lensShadingMapSize; - mLowPowerMode = param.powerMode == CAMERA_LOW_POWER ? true : false; - mGbceParams.ev_shift = param.evShift; // In still frame use force update by setting convergence time to 0. @@ -483,10 +489,6 @@ int AiqCore::runAiq(long requestId, AiqResult* aiqResult) { mLastEvShift = mIntel3AParameter->mAeParams.ev_shift; aiqResult->mTimestamp = mTimestamp; - aiqResult->mAnalogGainRange[0] = mIntel3AParameter->mCMC.min_ag; - aiqResult->mAnalogGainRange[1] = mIntel3AParameter->mCMC.max_ag; - aiqResult->mDigitalGainRange[0] = mIntel3AParameter->mCMC.min_dg; - aiqResult->mDigitalGainRange[1] = mIntel3AParameter->mCMC.max_dg; if (PlatformData::isStatsRunningRateSupport(mCameraId)) { bool bothConverged = (mLastAeResult.exposures[0].converged && @@ -521,8 +523,7 @@ int AiqCore::runAEC(long requestId, cca::cca_ae_results* aeResults) { CheckAndLogError(!intelCca, UNKNOWN_ERROR, "%s, intelCca is null, m:%d", __func__, mTuningMode); { PERF_CAMERA_ATRACE_PARAM1_IMAGING("intelCca->runAEC", 1); - ia_err iaErr = intelCca->runAEC(requestId, mIntel3AParameter->mAeParams, newAeResults, - mLowPowerMode); + ia_err iaErr = intelCca->runAEC(requestId, mIntel3AParameter->mAeParams, newAeResults); ret = AiqUtils::convertError(iaErr); CheckAndLogError(ret != OK, ret, "Error running AE, ret: %d", ret); } diff --git a/src/3a/AiqCore.h b/src/3a/AiqCore.h index c1d0784e..2597f4e1 100644 --- a/src/3a/AiqCore.h +++ b/src/3a/AiqCore.h @@ -200,7 +200,6 @@ class AiqCore { float mHyperFocalDistance; // in millimeters - bool mLowPowerMode; TuningMode mTuningMode; camera_shading_mode_t mShadingMode; camera_lens_shading_map_mode_type_t mLensShadingMapMode; diff --git a/src/3a/AiqEngine.cpp b/src/3a/AiqEngine.cpp index 70e72df7..38ab9b79 100644 --- a/src/3a/AiqEngine.cpp +++ b/src/3a/AiqEngine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -271,6 +271,9 @@ int AiqEngine::getSkippingNum(AiqResult* aiqResult) { // Skip 3 frames when pipe switching skipNum = 3; } + } else if (mAiqRunningForPerframe) { + // The 1st result takes effect @ frame (initialSkip) (applied before stream on) + skipNum = PlatformData::getInitialSkipFrame(mCameraId); } return skipNum; diff --git a/src/3a/AiqResult.cpp b/src/3a/AiqResult.cpp index 1c3f7744..01c0b122 100644 --- a/src/3a/AiqResult.cpp +++ b/src/3a/AiqResult.cpp @@ -36,8 +36,6 @@ AiqResult::AiqResult(int cameraId) mLscUpdate(false), mFrameDuration(0), mRollingShutter(0) { - CLEAR(mAnalogGainRange); - CLEAR(mDigitalGainRange); CLEAR(mCustomControls); CLEAR(mCustomControlsParams); CLEAR(mAwbResults); diff --git a/src/3a/AiqResult.h b/src/3a/AiqResult.h index 4b501b2c..61068153 100644 --- a/src/3a/AiqResult.h +++ b/src/3a/AiqResult.h @@ -47,8 +47,6 @@ class AiqResult { int64_t mSequence; int64_t mFrameId; // CCA frame id TuningMode mTuningMode; - float mAnalogGainRange[2]; - float mDigitalGainRange[2]; float mAfDistanceDiopters; bool mSkip; camera_range_t mFocusRange; diff --git a/src/3a/AiqUnit.cpp b/src/3a/AiqUnit.cpp index c5306073..7fe74ea1 100644 --- a/src/3a/AiqUnit.cpp +++ b/src/3a/AiqUnit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -151,7 +151,7 @@ int AiqUnit::configure(const stream_config_t* streamList) { void AiqUnit::resetIntelCcaHandle(const std::vector& configModes) { bool reinit = false; - if ((PlatformData::supportUpdateTuning(mCameraId) || PlatformData::isDvsSupported(mCameraId)) && + if ((PlatformData::supportUpdateTuning() || PlatformData::isDvsSupported(mCameraId)) && !configModes.empty()) { std::shared_ptr graphConfig = IGraphConfigManager::getInstance(mCameraId)->getGraphConfig(configModes[0]); @@ -361,7 +361,7 @@ int AiqUnit::initIntelCcaHandle(const std::vector& configModes) { } // DOL_FEATURE_E - if (PlatformData::supportUpdateTuning(mCameraId)) { + if (PlatformData::supportUpdateTuning()) { if (graphConfig != nullptr) { std::vector streamIds; graphConfig->graphGetStreamIds(streamIds); @@ -420,7 +420,9 @@ void AiqUnit::deinitIntelCcaHandle() { } intelCca->deinit(); +#ifndef ENABLE_SANDBOXING IntelCca::releaseInstance(mCameraId, mode); +#endif } mCcaInitialized = false; diff --git a/src/3a/AiqUtils.cpp b/src/3a/AiqUtils.cpp index 19dda84c..40945759 100644 --- a/src/3a/AiqUtils.cpp +++ b/src/3a/AiqUtils.cpp @@ -109,7 +109,6 @@ void AiqUtils::dumpAwbResults(const cca::cca_awb_results& awbResult) { LOG3("AWB result: accurate_r/g %f, accurate_b/g %f, distance_from_convergence %f", awbResult.accurate_r_per_g, awbResult.accurate_b_per_g, awbResult.distance_from_convergence); - LOG3("AWB result: cct_estimate %d", awbResult.cct_estimate); } void AiqUtils::dumpGbceResults(const cca::cca_gbce_params& gbceResult) { diff --git a/src/3a/MakerNote.h b/src/3a/MakerNote.h index 7001d941..eb3c4141 100644 --- a/src/3a/MakerNote.h +++ b/src/3a/MakerNote.h @@ -125,7 +125,7 @@ class MakerNote { private: // Should > max request number in processing - static const int MAX_MAKER_NOTE_LIST_SIZE = 48; + static const int MAX_MAKER_NOTE_LIST_SIZE = 32; enum MknState { UNINIT, INIT } mMknState; diff --git a/src/3a/SensorManager.cpp b/src/3a/SensorManager.cpp index 2eb27a56..99d89565 100644 --- a/src/3a/SensorManager.cpp +++ b/src/3a/SensorManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,8 +119,8 @@ void SensorManager::handleSensorModeSwitch(int64_t sequence) { if (mWdrModeSetting.sequence <= sequence) { int wdrMode = convertTuningModeToWdrMode(mWdrModeSetting.tuningMode); - LOG2("@%s, tunning mode %d, set wdrMode %d sequence %u", sequence, __func__, - mWdrModeSetting.tuningMode, wdrMode, mWdrModeSetting.sequence); + LOG2("@%s, tunning mode %d, set wdrMode %d sequence %ld", sequence, __func__, + wdrMode, mWdrModeSetting.sequence); if (mSensorHwCtrl->setWdrMode(wdrMode) == OK) { mModeSwitched = false; @@ -195,7 +195,7 @@ int SensorManager::getCurrentExposureAppliedDelay() { uint32_t SensorManager::updateSensorExposure(SensorExpGroup sensorExposures, int64_t applyingSeq) { AutoMutex l(mLock); - int64_t effectSeq = mLastSofSequence < 0 ? 0 + int64_t effectSeq = mLastSofSequence < 0 ? PlatformData::getInitialSkipFrame(mCameraId) : mLastSofSequence + PlatformData::getExposureLag(mCameraId); if (sensorExposures.empty()) { @@ -250,10 +250,6 @@ uint32_t SensorManager::updateSensorExposure(SensorExpGroup sensorExposures, int mSensorHwCtrl->setDigitalGains(digitalGains); } - if (effectSeq == 0) { - effectSeq = PlatformData::getInitialSkipFrame(mCameraId); - } - LOG2("@%s: effectSeq %ld, applyingSeq %ld", mLastSofSequence, __func__, effectSeq, applyingSeq); return ((uint32_t)effectSeq); diff --git a/src/3a/intel3a/Intel3AParameter.cpp b/src/3a/intel3a/Intel3AParameter.cpp index 4803d156..cabaff45 100644 --- a/src/3a/intel3a/Intel3AParameter.cpp +++ b/src/3a/intel3a/Intel3AParameter.cpp @@ -247,10 +247,7 @@ void Intel3AParameter::setAeManualLimits(const aiq_parameter_t& param) { if (gainRange.min >= 0 && gainRange.max >= gainRange.min) { float isoMin = convertdBGainToISO(gainRange.min, mCMC.base_iso); float isoMax = convertdBGainToISO(gainRange.max, mCMC.base_iso); - // Cast these to doubles for this comparison, as float(INT_MAX) produces - // the value 2147483648, which is INT_MAX+1. Clang warns about this. - if (static_cast(isoMin) <= INT_MAX && - static_cast(isoMax) <= INT_MAX) { + if (isoMin <= INT_MAX && isoMax <= INT_MAX) { limit->manual_iso_min = static_cast(isoMin); limit->manual_iso_max = static_cast(isoMax); } @@ -297,16 +294,6 @@ void Intel3AParameter::setManualIso(const aiq_parameter_t& param) { return; } - SensitivityRange range; - if (PlatformData::getSensitivityRangeByTuningMode(mCameraId, param.tuningMode, range) == OK) { - float ratio = - (manualIso - mSensitivityRange.min) / (mSensitivityRange.max - mSensitivityRange.min); - manualIso = range.min + ratio * (range.max - range.min); - manualIso = CLIP(manualIso, range.max, range.min); - - LOG2("%s, param.manualIso %d, manualIso %d", __func__, param.manualIso, manualIso); - } - // Will overwrite manual_analog_gain for (unsigned int i = 0; i < mAeParams.num_exposures; i++) { mAeParams.manual_iso[i] = manualIso; @@ -645,14 +632,11 @@ void Intel3AParameter::updateAfParameter(const aiq_parameter_t& param) { // Current only one AF metering window is supported, so use the latest one camera_window_t window = param.afRegions.back(); if (window.right > window.left && window.bottom > window.top) { - if ((window.right - window.left) != param.resolution.width && - (window.bottom - window.top) != param.resolution.height) { - camera_coordinate_system_t frameCoord = {0, 0, param.resolution.width, - param.resolution.height}; - window = AiqUtils::convertToIaWindow(frameCoord, window); - mAfParams.focus_metering_mode = ia_aiq_af_metering_mode_touch; - mAfParams.focus_rect = {window.left, window.top, window.right, window.bottom}; - } + camera_coordinate_system_t frameCoord = {0, 0, param.resolution.width, + param.resolution.height}; + window = AiqUtils::convertToIaWindow(frameCoord, window); + mAfParams.focus_metering_mode = ia_aiq_af_metering_mode_touch; + mAfParams.focus_rect = {window.left, window.top, window.right, window.bottom}; } } diff --git a/src/core/CameraBuffer.cpp b/src/core/CameraBuffer.cpp index df093f09..03a0b048 100644 --- a/src/core/CameraBuffer.cpp +++ b/src/core/CameraBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,6 @@ #include "CameraBuffer.h" -#ifdef LIBDRM_SUPPORT_MMAP_OFFSET -#include -#include -#endif - #include #include #include @@ -37,12 +32,13 @@ namespace icamera { CameraBuffer::CameraBuffer(int cameraId, int usage, int memory, uint32_t size, int index, - int format, v4l2_buf_type v4l2BufType) + int format) : mNumPlanes(1), mAllocatedMemory(false), mU(nullptr), mBufferUsage(usage), mSettingSequence(-1) { + v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; int num_plane = 1; LOG2("%s: construct buffer with usage:%d, memory:%d, size:%d, format:%d, index:%d", @@ -61,22 +57,28 @@ CameraBuffer::CameraBuffer(int cameraId, int usage, int memory, uint32_t size, i case BUFFER_USAGE_GENERAL: if (PlatformData::isIsysEnabled(cameraId) && PlatformData::isCSIFrontEndCapture(cameraId)) { + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; num_plane = CameraUtils::getNumOfPlanes(format); + } else { + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; } break; + case BUFFER_USAGE_PSYS_STATS: + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + break; case BUFFER_USAGE_MIPI_CAPTURE: case BUFFER_USAGE_METADATA: + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; num_plane = CameraUtils::getNumOfPlanes(format); break; default: LOGE("Not supported Usage"); - break; } CLEAR(mMmapAddrs); CLEAR(mDmaFd); - initBuffer(memory, v4l2BufType, size, index, num_plane); + initBuffer(memory, type, size, index, num_plane); } CameraBuffer::~CameraBuffer() { @@ -97,6 +99,7 @@ void CameraBuffer::initBuffer(int memType, v4l2_buf_type bufType, uint32_t size, if (!V4L2_TYPE_IS_MULTIPLANAR(bufType)) { mV.SetOffset(0, 0); mV.SetLength(size, 0); + LOGE("SINGLE PLANE!"); } else { mV.SetLength(num_plane, 0); mNumPlanes = num_plane; @@ -314,62 +317,11 @@ void CameraBuffer::freeMmap() { } } -#ifdef LIBDRM_SUPPORT_MMAP_OFFSET -CameraBuffer::DeviceRender::DeviceRender() : m_handle(-1) { - m_handle = open("/dev/dri/renderD128", O_RDWR); -} - -CameraBuffer::DeviceRender::DeviceRender(const char* path_file) : m_handle(-1) { - m_handle = open(path_file, O_RDWR); -} - -CameraBuffer::DeviceRender::~DeviceRender() { - close(m_handle); -} - -CameraBuffer::DeviceRender CameraBuffer::mDeviceRender("/dev/dri/renderD128"); - -void* CameraBuffer::DeviceRender::mapDmaBufferAddr(int fd, unsigned int bufferSize) { - if (m_handle == -1) { - LOGE("open device /dev/dri/renderD128 failed!\n"); - return MAP_FAILED; - } - - int ret = 0; - struct drm_prime_handle prime_handle; - memset(&prime_handle, 0, sizeof(prime_handle)); - prime_handle.fd = fd; - ret = drmIoctl(m_handle, DRM_IOCTL_PRIME_FD_TO_HANDLE, &prime_handle); - if (ret != 0) { - LOGE("DRM_IOCTL_PRIME_FD_TO_HANDLE failed (fd=%u)\n", prime_handle.fd); - return MAP_FAILED; - } - - struct drm_i915_gem_mmap_offset gem_map = {0}; - gem_map.handle = prime_handle.handle; - gem_map.flags = I915_MMAP_OFFSET_WB; - /* Get the fake offset back */ - ret = drmIoctl(m_handle, DRM_IOCTL_I915_GEM_MMAP_OFFSET, &gem_map); - void* addr = MAP_FAILED; - if (ret != 0) - LOGE("DRM_IOCTL_I915_GEM_MMAP_OFFSET failed!"); - else - addr = ::mmap(nullptr, bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, m_handle, - gem_map.offset); - - return addr; -} -#endif - void* CameraBuffer::mapDmaBufferAddr(int fd, unsigned int bufferSize) { CheckAndLogError(fd < 0 || !bufferSize, nullptr, "%s, fd:0x%x, bufferSize:%u", __func__, fd, bufferSize); -#ifdef LIBDRM_SUPPORT_MMAP_OFFSET - return mDeviceRender.mapDmaBufferAddr(fd, bufferSize); -#else return ::mmap(nullptr, bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); -#endif } void CameraBuffer::unmapDmaBufferAddr(void* addr, unsigned int bufferSize) { diff --git a/src/core/CameraBuffer.h b/src/core/CameraBuffer.h index e5fc4443..524fca6f 100644 --- a/src/core/CameraBuffer.h +++ b/src/core/CameraBuffer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,8 +54,7 @@ class CameraBuffer { int srcWidth = -1, int srcHeight = -1); public: - CameraBuffer(int cameraId, int usage, int memory, uint32_t size, int index, int format = -1, - v4l2_buf_type v4l2BufType = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + CameraBuffer(int cameraId, int usage, int memory, uint32_t size, int index, int format = -1); virtual ~CameraBuffer(); public: @@ -173,21 +172,6 @@ class CameraBuffer { void* mMmapAddrs[VIDEO_MAX_PLANES]; int mDmaFd[VIDEO_MAX_PLANES]; - -#ifdef LIBDRM_SUPPORT_MMAP_OFFSET - class DeviceRender { - public: - DeviceRender(); - explicit DeviceRender(const char* path_file); - ~DeviceRender(); - void* mapDmaBufferAddr(int fd, unsigned int bufferSize); - - private: - int m_handle; - }; - - static DeviceRender mDeviceRender; -#endif }; typedef std::vector > CameraBufVector; diff --git a/src/core/CameraStream.cpp b/src/core/CameraStream.cpp index e98e8aff..c3d2897f 100644 --- a/src/core/CameraStream.cpp +++ b/src/core/CameraStream.cpp @@ -98,12 +98,10 @@ shared_ptr CameraStream::userBufferToCameraBuffer(camera_buffer_t* } if (!camBuffer) { // Not found in the pool, so create a new CameraBuffer for it. - v4l2_buf_type v4l2BufType = PlatformData::getV4L2BufType(mCameraId); ubuffer->index = mUserBuffersPool.size(); camBuffer = std::make_shared(mCameraId, BUFFER_USAGE_GENERAL, ubuffer->s.memType, - ubuffer->s.size, ubuffer->index, ubuffer->s.format, - v4l2BufType); + ubuffer->s.size, ubuffer->index, ubuffer->s.format); CheckAndLogError(!camBuffer, nullptr, "@%s: fail to alloc CameraBuffer", __func__); mUserBuffersPool.push_back(camBuffer); } diff --git a/src/core/CsiMetaDevice.cpp b/src/core/CsiMetaDevice.cpp index 25fb9f64..495a850d 100644 --- a/src/core/CsiMetaDevice.cpp +++ b/src/core/CsiMetaDevice.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2023 Intel Corporation. + * Copyright (C) 2016-2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -301,7 +301,7 @@ void CsiMetaDevice::handleCsiMetaBuffer() { if (mExitPending) return; CheckAndLogError(index < 0, VOID_VALUE, "grab frame failed. index %d", index); - LOG2("%s: grab meta data buffer sequence %d timestamp %ld", __func__, camBuffer->getSequence(), + LOG2("%s: grab meta data buffer sequence %ld timestamp %ld", __func__, camBuffer->getSequence(), TIMEVAL2USECS(camBuffer->getTimestamp())); PERF_CAMERA_ATRACE_PARAM3("grabFrame SeqID", camBuffer->getSequence(), "csi2_port", camBuffer->getCsi2Port(), "virtual_channel", @@ -377,16 +377,7 @@ int CsiMetaDevice::setFormat() { struct v4l2_format v4l2fmt; CLEAR(v4l2fmt); -#ifdef CAL_BUILD v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; -#else - int dev_caps = mCsiMetaDevice->GetDeviceCaps(); - if (dev_caps & V4L2_CAP_META_CAPTURE) { - v4l2fmt.type = V4L2_BUF_TYPE_META_CAPTURE; - } else { - v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - } -#endif v4l2fmt.fmt.pix_mp.width = mEmbeddedMetaData.width; v4l2fmt.fmt.pix_mp.height = mEmbeddedMetaData.height; v4l2fmt.fmt.pix_mp.num_planes = mEmbeddedMetaData.planesNum; diff --git a/src/core/DeviceBase.cpp b/src/core/DeviceBase.cpp index eab1b962..d10c6adb 100644 --- a/src/core/DeviceBase.cpp +++ b/src/core/DeviceBase.cpp @@ -59,9 +59,6 @@ DeviceBase::DeviceBase(int cameraId, VideoNodeType nodeType, VideoNodeDirection nodeType); mDevice = new V4L2VideoNode(devName); -#ifdef LINUX_BUILD - mBufType = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; -#endif } DeviceBase::~DeviceBase() { @@ -77,24 +74,7 @@ int DeviceBase::openDevice() { SyncManager::getInstance()->updateSyncCamNum(); // FRAME_SYNC_E -#ifdef LINUX_BUILD - int ret = mDevice->Open(O_RDWR); - if (ret) - return ret; - - int dev_caps = mDevice->GetDeviceCaps(); - if (dev_caps & V4L2_CAP_VIDEO_CAPTURE) { - mBufType = V4L2_BUF_TYPE_VIDEO_CAPTURE; - } else { - mBufType = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; - } - - PlatformData::setV4L2BufType(mCameraId, mBufType); - - return OK; -#else return mDevice->Open(O_RDWR); -#endif } void DeviceBase::closeDevice() { @@ -159,10 +139,6 @@ int DeviceBase::queueBuffer(int64_t sequence) { mBufferQueuing = true; } -#ifdef LINUX_BUILD - buffer->getV4L2Buffer().SetType(mBufType); - -#endif int ret = onQueueBuffer(sequence, buffer); if (ret == OK) { ret = mDevice->PutFrame(&buffer->getV4L2Buffer()); @@ -325,6 +301,20 @@ int MainDevice::createBufferPool(const stream_t& config) { csiBEDeviceNodeName.c_str(), ret); } + bool setWithHeaderCtl = true; + std::string subDeviceNodeName; + + if (PlatformData::getDevNameByType(mCameraId, VIDEO_ISYS_RECEIVER, subDeviceNodeName) == OK) { + LOG1("%s: found ISYS receiver subdevice %s", __func__, subDeviceNodeName.c_str()); + if (PlatformData::isTPGReceiver(mCameraId)) { + LOG1("%s: no need to set csi header ctrl for tpg", __func__); + setWithHeaderCtl = false; + } + } else { + setWithHeaderCtl = false; + } + + int withHeader = 1; struct v4l2_format v4l2fmt; v4l2fmt.fmt.pix_mp.field = config.field; @@ -340,6 +330,13 @@ int MainDevice::createBufferPool(const stream_t& config) { v4l2fmt.fmt.pix_mp.plane_fmt[i].bytesperline = config.width; v4l2fmt.fmt.pix_mp.plane_fmt[i].sizeimage = 0; } + // The frame data is without header(MIPI STORE MODE) when + // format is YUV/RGB and frame output from CSI-Front-End entity. + if (!CameraUtils::isRaw(config.format)) { + LOG2("@%s, set frame without header for format: %s", __func__, + CameraUtils::pixelCode2String(config.format)); + withHeader = 0; + } } else { v4l2fmt.fmt.pix.width = config.width; v4l2fmt.fmt.pix.height = config.height; @@ -348,11 +345,13 @@ int MainDevice::createBufferPool(const stream_t& config) { v4l2fmt.fmt.pix.sizeimage = 0; } -#ifdef LINUX_BUILD - v4l2fmt.type = mBufType; -#else + if (setWithHeaderCtl) { + V4L2Subdevice* receiverSubDev = V4l2DeviceFactory::getSubDev(mCameraId, subDeviceNodeName); + int ret = receiverSubDev->SetControl(V4L2_CID_IPU_STORE_CSI2_HEADER, withHeader); + CheckAndLogError(ret != OK, ret, "set v4l2 store csi2 header failed, ret=%d", ret); + } + v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -#endif V4L2Format tmpbuf{v4l2fmt}; int ret = mDevice->SetFormat(tmpbuf); CheckAndLogError(ret != OK, ret, "set v4l2 format failed ret=%d", ret); @@ -386,9 +385,8 @@ int MainDevice::onDequeueBuffer(shared_ptr buffer) { if (mNeedSkipFrame) return OK; - LOG2("camera:%d, stream:%d, @%s, field:%d, timestamp: sec=%ld, usec=%ld", mCameraId, - buffer->getStreamId(), buffer->getSequence(), __func__, buffer->getField(), - buffer->getTimestamp().tv_sec, buffer->getTimestamp().tv_usec); + LOG2("@%s, field:%d, timestamp: sec=%ld, usec=%ld", buffer->getSequence(), __func__, + buffer->getField(), buffer->getTimestamp().tv_sec, buffer->getTimestamp().tv_usec); for (auto& consumer : mConsumers) { consumer->onFrameAvailable(mPort, buffer); @@ -425,7 +423,7 @@ bool MainDevice::needQueueBack(shared_ptr buffer) { sharedCamBufInfo.sof_ts = buffer->getTimestamp(); SyncManager::getInstance()->updateCameraBufInfo(mCameraId, &sharedCamBufInfo); if (skipFrameAfterSyncCheck(buffer->getSequence())) { - LOG1("@%s: dropped due to frame not sync", mCameraId, + LOG1("@%s: dropped due to frame not sync", mCameraId, buffer->getSequence(), __func__); needSkipFrame = true; } @@ -457,11 +455,7 @@ int DolCaptureDevice::createBufferPool(const stream_t& config) { v4l2fmt.fmt.pix.sizeimage = 0; v4l2fmt.fmt.pix_mp.field = 0; -#ifdef LINUX_BUILD - v4l2fmt.type = mBufType; -#else v4l2fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; -#endif V4L2Format tmpbuf{v4l2fmt}; int ret = mDevice->SetFormat(tmpbuf); CheckAndLogError(ret != OK, ret, "set DOL v4l2 format failed ret=%d", ret); diff --git a/src/core/DeviceBase.h b/src/core/DeviceBase.h index 95d60ce6..94774254 100644 --- a/src/core/DeviceBase.h +++ b/src/core/DeviceBase.h @@ -152,9 +152,6 @@ class DeviceBase : public EventSource { uint32_t mMaxBufferNumber; bool mBufferQueuing; -#ifdef LINUX_BUILD - v4l2_buf_type mBufType; -#endif private: DISALLOW_COPY_AND_ASSIGN(DeviceBase); diff --git a/src/core/IspParamAdaptor.cpp b/src/core/IspParamAdaptor.cpp index d4bbe0aa..782331d2 100644 --- a/src/core/IspParamAdaptor.cpp +++ b/src/core/IspParamAdaptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -244,7 +244,7 @@ int IspParamAdaptor::configure(const stream_t& stream, ConfigMode configMode, Tu CheckAndLogError(ret != OK, ret, "%s, Failed to allocate isp parameter buffers", __func__); } - if (PlatformData::supportUpdateTuning(mCameraId)) { + if (PlatformData::supportUpdateTuning()) { for (auto& ispParamIt : mStreamIdToIspParameterMap) { int ispTuningIndex = mGraphConfig->getTuningModeByStreamId(ispParamIt.first); // Use the tuning mode in graph to update the isp tuning data @@ -354,7 +354,6 @@ int IspParamAdaptor::decodeStatsData(TuningMode tuningMode, bParam.mType = M_PSYS; bParam.sequence = statsBuffer->getSequence(); bParam.gParam.appendix = "p2p_decoded_stats"; - bParam.sUsage = (streamId == VIDEO_STREAM_ID) ? 0 : 2; CameraDump::dumpBinary(mCameraId, hwStatsData->data, hwStatsData->size, &bParam); } @@ -880,24 +879,19 @@ int IspParamAdaptor::runIspAdaptL(ia_isp_bxt_program_group* pgPtr, ia_isp_bxt_gd inputParams->stream_id = inputParams->program_group.base.run_kernels[0].stream_id; if (ispSettings) { - if (VIDEO_STREAM_ID == inputParams->stream_id) { - inputParams->nr_setting = ispSettings->nrSetting; - inputParams->ee_setting = ispSettings->eeSetting; - } else { - inputParams->nr_setting = ispSettings->nrStillSetting; - inputParams->ee_setting = ispSettings->eeStillSetting; - } + inputParams->nr_setting = ispSettings->nrSetting; + inputParams->ee_setting = ispSettings->eeSetting; LOG2("%s: ISP NR setting, level: %d, strength: %d", __func__, - static_cast(inputParams->nr_setting.feature_level), - static_cast(inputParams->nr_setting.strength)); - LOG2("%s: ISP EE setting, level: %d, strength: %d", __func__, - inputParams->ee_setting.feature_level, inputParams->ee_setting.strength); + static_cast(ispSettings->nrSetting.feature_level), + static_cast(ispSettings->nrSetting.strength)); inputParams->effects = ispSettings->effects; inputParams->manual_brightness = ispSettings->manualSettings.manualBrightness; inputParams->manual_contrast = ispSettings->manualSettings.manualContrast; inputParams->manual_hue = ispSettings->manualSettings.manualHue; inputParams->manual_saturation = ispSettings->manualSettings.manualSaturation; + LOG2("%s: ISP EE setting, level: %d, strength: %d", __func__, + ispSettings->eeSetting.feature_level, ispSettings->eeSetting.strength); if (ispSettings->palOverride) { CheckAndLogError(ispSettings->palOverride->size > cca::MAX_PAL_TUNING_SIZE, NO_MEMORY, @@ -1019,7 +1013,7 @@ void IspParamAdaptor::updateResultFromAlgo(ia_binary_data* binaryData, int64_t s CheckAndLogError(tmSize < aiqResults->mGbceResults.tone_map_lut_size, VOID_VALUE, "memory is mismatch to store tone map from algo"); - LOG2("%s, Tonemap Curve. enable: %d, prog_shift: %d, table size: %u", __func__, TM->enable, + LOG2("%s, Tonemap Curve. enable: %d, prog_shift: %d, table size: %zu", __func__, TM->enable, TM->prog_shift, tmSize); const int shiftBase = 1 << TM->prog_shift; @@ -1038,7 +1032,6 @@ void IspParamAdaptor::dumpIspParameter(int streamId, int64_t sequence, ia_binary bParam.mType = M_PSYS; bParam.sequence = sequence; bParam.gParam.appendix = ("pal_" + std::to_string(streamId)).c_str(); - bParam.sUsage = (streamId == VIDEO_STREAM_ID) ? 0 : 2; CameraDump::dumpBinary(mCameraId, binaryData.data, binaryData.size, &bParam); } diff --git a/src/core/IspSettings.h b/src/core/IspSettings.h index 8a3f5880..f9ebc649 100644 --- a/src/core/IspSettings.h +++ b/src/core/IspSettings.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2024 Intel Corporation. + * Copyright (C) 2018-2019 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,8 +33,6 @@ struct IspImageEnhancement { struct IspSettings { ia_isp_feature_setting nrSetting; ia_isp_feature_setting eeSetting; - ia_isp_feature_setting nrStillSetting; - ia_isp_feature_setting eeStillSetting; ia_isp_effect effects; bool videoStabilization; IspImageEnhancement manualSettings; diff --git a/src/core/PSysProcessor.cpp b/src/core/PSysProcessor.cpp index db616fd7..92f91746 100644 --- a/src/core/PSysProcessor.cpp +++ b/src/core/PSysProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2024 Intel Corporation. + * Copyright (C) 2017-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,9 +74,7 @@ PSysProcessor::~PSysProcessor() { * before delete PipeExecutor in PSysDAG. */ if (mScheduler) { - if (mPSysDAGs.find(mCurConfigMode) != mPSysDAGs.end()) { - mPSysDAGs[mCurConfigMode]->unregisterNode(); - } + mPSysDAGs[mCurConfigMode]->unregisterNode(); delete mScheduler; } mPSysDAGs.clear(); @@ -320,9 +318,6 @@ int PSysProcessor::setParameters(const Parameters& param) { static_cast(mIspSettings.nrSetting.feature_level), static_cast(mIspSettings.nrSetting.strength)); - mIspSettings.nrStillSetting = mIspSettings.nrSetting; - mIspSettings.eeStillSetting = mIspSettings.eeSetting; - camera_video_stabilization_mode_t stabilizationMode; ret = param.getVideoStabilizationMode(stabilizationMode); if (ret == OK) { @@ -546,7 +541,7 @@ int PSysProcessor::processNewFrame() { ret = prepareTask(&srcBuffers, &dstBuffers); CheckAndLogError(ret != OK, UNKNOWN_ERROR, "%s, Failed to process frame", __func__); } else { - LOG2("@%s, No available buffers, in %lu, out %lu", mCameraId, __func__, + LOG2("@%s, No available buffers, in %u, out %u", mCameraId, __func__, srcBuffers.size(), dstBuffers.size()); } @@ -1070,21 +1065,11 @@ void PSysProcessor::dispatchTask(CameraBufferPortMap& inBuf, CameraBufferPortMap if (res != nullptr) { auto exposure = res->mAeResults.exposures[0].exposure[0]; float totalGain = exposure.analog_gain * exposure.digital_gain; - PlatformData::getEdgeNrSetting(mCameraId, totalGain, hdrRatio, mTuningMode, - edgeNrSetting); + PlatformData::getEdgeNrSetting(mCameraId, totalGain, hdrRatio, edgeNrSetting); mIspSettings.eeSetting.strength += edgeNrSetting.edgeStrength; mIspSettings.nrSetting.strength += edgeNrSetting.nrStrength; LOG2("edgeStrength %d, nrStrength %d", edgeNrSetting.edgeStrength, edgeNrSetting.nrStrength); - - TuningMode stillMode = (mTuningMode == TUNING_MODE_VIDEO) ? - TUNING_MODE_STILL_CAPTURE : TUNING_MODE_VIDEO_ULL; - PlatformData::getEdgeNrSetting(mCameraId, totalGain, hdrRatio, stillMode, - edgeNrSetting); - mIspSettings.eeStillSetting.strength += edgeNrSetting.edgeStrength; - mIspSettings.nrStillSetting.strength += edgeNrSetting.nrStrength; - LOG2("Still edgeStrength %d, nrStrength %d", edgeNrSetting.edgeStrength, - edgeNrSetting.nrStrength); } } diff --git a/src/core/RequestThread.cpp b/src/core/RequestThread.cpp index a2d13da9..07fd212a 100644 --- a/src/core/RequestThread.cpp +++ b/src/core/RequestThread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,8 +144,7 @@ bool RequestThread::blockRequest() { * 2. Too many requests in flight; * 3. if no trigger event is available. */ - return ((mBlockRequest && - (mLastRequestId >= PlatformData::getInitialPendingFrame(mCameraId))) || + return ((mBlockRequest && (mLastRequestId >= 0)) || (mRequestsInProcessing >= PlatformData::getMaxRequestsInflight(mCameraId)) || (mPerframeControlSupport && (mRequestTriggerEvent == NONE_EVENT))); } @@ -177,10 +176,8 @@ int RequestThread::processRequest(int bufferNum, camera_buffer_t** ubuffer, mActive = true; } - if (mRequestsInProcessing == 0) { - mRequestTriggerEvent |= NEW_REQUEST; - mRequestSignal.signal(); - } + mRequestTriggerEvent |= NEW_REQUEST; + mRequestSignal.signal(); return OK; } @@ -247,7 +244,7 @@ void RequestThread::handleEvent(EventData eventData) { mRequestsInProcessing--; } // Just in case too many requests are pending in mPendingRequests. - if (!mPendingRequests.empty() && (mRequestsInProcessing == 0)) { + if (!mPendingRequests.empty()) { mRequestTriggerEvent |= NEW_FRAME; mRequestSignal.signal(); } @@ -264,10 +261,8 @@ void RequestThread::handleEvent(EventData eventData) { case EVENT_ISYS_SOF: { AutoMutex l(mPendingReqLock); mLastSofSeq = eventData.data.sync.sequence; - if (mLastSofSeq > mLastAppliedSeq) { - mRequestTriggerEvent |= NEW_SOF; - mRequestSignal.signal(); - } + mRequestTriggerEvent |= NEW_SOF; + mRequestSignal.signal(); } break; case EVENT_FRAME_AVAILABLE: { if (eventData.buffer->getUserBuffer() != &mFakeReqBuf) { @@ -287,7 +282,7 @@ void RequestThread::handleEvent(EventData eventData) { AutoMutex l(mPendingReqLock); // Insert fake request if no any request in the HAL to keep 3A running if (mGet3AStatWithFakeRequest && eventData.buffer->getSequence() >= mLastEffectSeq && - mPendingRequests.empty() && (mRequestsInProcessing == 0)) { + mPendingRequests.empty()) { LOGW("No request, insert fake req after req %ld to keep 3A stats update", mLastRequestId); CameraRequest fakeRequest; diff --git a/src/core/SensorHwCtrl.cpp b/src/core/SensorHwCtrl.cpp index b6d8ab28..2ebf9cf4 100644 --- a/src/core/SensorHwCtrl.cpp +++ b/src/core/SensorHwCtrl.cpp @@ -660,7 +660,7 @@ int SensorHwCtrl::setAWB(float r_per_g, float b_per_g) { // CRL_MODULE_S int SensorHwCtrl::setFrameRate(float fps) { HAL_TRACE_CALL(CAMERA_DEBUG_LOG_LEVEL2); - CheckAndLog1(!mSensorOutputSubdev, NO_INIT, "sensor output sub device is not set"); + CheckAndLogError(!mSensorOutputSubdev, NO_INIT, "sensor output sub device is not set"); struct v4l2_queryctrl query; CLEAR(query); diff --git a/src/core/SofSource.cpp b/src/core/SofSource.cpp index 97faba1e..823e8142 100644 --- a/src/core/SofSource.cpp +++ b/src/core/SofSource.cpp @@ -103,7 +103,7 @@ int SofSource::initDev() { std::string devName; CameraUtils::getDeviceName(aggregator.mName.c_str(), devName, true); if (!devName.empty()) { - LOG1("%s, found aggregator subdevice %s", __func__, devName.c_str()); + LOG1("%s, found aggregator subdevice %s", __func__, devName); mAggregatorSubDev = V4l2DeviceFactory::getSubDev(mCameraId, devName); struct v4l2_querymenu qm = {.id = V4L2_CID_IPU_QUERY_SUB_STREAM, }; diff --git a/src/core/psysprocessor/GPUExecutor.cpp b/src/core/psysprocessor/GPUExecutor.cpp index 67ebdd92..23cfbe9d 100644 --- a/src/core/psysprocessor/GPUExecutor.cpp +++ b/src/core/psysprocessor/GPUExecutor.cpp @@ -291,7 +291,6 @@ int GPUExecutor::getTnrExtraFrameCount(int64_t seq) { CheckAndLogError(ret, 0, "Failed to get total gain"); if (!mStillTnrTriggerInfo.num_gains) return PlatformData::getTnrExtraFrameCount(mCameraId); - if (totalGain <= mStillTnrTriggerInfo.tnr7us_threshold_gain) return 0; int index = 0; for (int i = 1; i < mStillTnrTriggerInfo.num_gains; i++) { @@ -569,10 +568,10 @@ int GPUExecutor::runTnrFrame(const std::shared_ptr& inBuf, bool paramSyncUpdate = (mStreamId == VIDEO_STREAM_ID) ? false : true; -#ifdef TNR7_LEVEL0 + // LEVEL0_ICBM_S // no async param update in level0 tnr paramSyncUpdate = true; -#endif + // LEVEL0_ICBM_E if (!paramSyncUpdate && mIntelTNR) { // request update tnr parameters before wait diff --git a/src/core/psysprocessor/PGCommon.cpp b/src/core/psysprocessor/PGCommon.cpp index 0bb7df86..88390771 100644 --- a/src/core/psysprocessor/PGCommon.cpp +++ b/src/core/psysprocessor/PGCommon.cpp @@ -27,7 +27,6 @@ #include "iutils/CameraDump.h" #include "iutils/CameraLog.h" #include "iutils/Utils.h" -#include "AiqResultStorage.h" namespace icamera { @@ -85,7 +84,6 @@ PGCommon::PGCommon(int cameraId, int pgId, const std::string& pgName, TuningMode mInputMainTerminal(-1), mOutputMainTerminal(-1), mShareReferPool(nullptr), - mIpuParameters(nullptr), mIntelCca(nullptr) { mTnrTerminalPair.inId = -1; mTnrTerminalPair.outId = -1; @@ -1091,10 +1089,9 @@ int PGCommon::prepareTerminalBuffers(const ia_binary_data* ipuParameters, if (buffer) { bool flush = buffer->getUsage() == BUFFER_USAGE_GENERAL ? true : false; - if (buffer->getMemory() == V4L2_MEMORY_DMABUF && - ((PlatformData::removeCacheFlushOutputBuffer(mCameraId) && - !buffer->isFlagsSet(BUFFER_FLAG_SW_READ)) || - buffer->isFlagsSet(BUFFER_FLAG_NO_FLUSH))) { + if (PlatformData::removeCacheFlushOutputBuffer(mCameraId) && + buffer->getMemory() == V4L2_MEMORY_DMABUF && + !buffer->isFlagsSet(BUFFER_FLAG_SW_READ)) { flush = false; } ciprBuf = @@ -1136,16 +1133,6 @@ int PGCommon::prepareTerminalBuffers(const ia_binary_data* ipuParameters, mTerminalBuffers[pair.outId]->getMemoryCpuPtr(&mParamPayload[pair.outId].data); } - const AiqResult* aiqResult = AiqResultStorage::getInstance(mCameraId)->getAiqResult(sequence); - if (aiqResult && aiqResult->mAiqParam.powerMode == CAMERA_LOW_POWER) { - if (ipuParameters != mIpuParameters) { - mIpuParameters = ipuParameters; - } else if (sequence > MAX_SETTING_COUNT) { - LOG2("don't run P2P if no PAL update, seq %ld", sequence); - return OK; - } - } - return mPGParamAdapt->updatePALAndEncode(ipuParameters, mTerminalCount, mParamPayload); } diff --git a/src/core/psysprocessor/PGCommon.h b/src/core/psysprocessor/PGCommon.h index 80e7a585..36bd4572 100644 --- a/src/core/psysprocessor/PGCommon.h +++ b/src/core/psysprocessor/PGCommon.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2023 Intel Corporation. + * Copyright (C) 2019-2021 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -258,7 +258,6 @@ class PGCommon { std::vector mDvsTerminalPairs; std::vector mTnrSimTerminalPairs; - const ia_binary_data* mIpuParameters; IntelCca* mIntelCca; }; diff --git a/src/core/psysprocessor/PGUtils.cpp b/src/core/psysprocessor/PGUtils.cpp index 4e721f90..3683c57d 100644 --- a/src/core/psysprocessor/PGUtils.cpp +++ b/src/core/psysprocessor/PGUtils.cpp @@ -144,7 +144,7 @@ int getCssStride(int v4l2Fmt, int width, bool compression) { stride = ALIGN(width * 2, PSYS_COMPRESSION_TNR_STRIDE_ALIGNMENT); break; default: - LOG1("%s format %d compress not supported", __func__, v4l2Fmt); + LOGW("%s format %d compress not supported", __func__, v4l2Fmt); break; } } @@ -178,7 +178,7 @@ int getCssBpp(int v4l2Fmt, bool compression) { bpp = 24; break; default: - LOG1("%s format %d compress not supported", __func__, v4l2Fmt); + LOGW("%s format %d compress not supported", __func__, v4l2Fmt); break; } } @@ -216,7 +216,7 @@ int getCssBpe(int v4l2Fmt, bool compression) { bpe = 16; break; default: - LOG1("%s format %d compress not supported", __func__, v4l2Fmt); + LOGW("%s format %d compress not supported", __func__, v4l2Fmt); break; } } diff --git a/src/core/psysprocessor/PSysDAG.cpp b/src/core/psysprocessor/PSysDAG.cpp index dae6f7ce..82f4c08e 100644 --- a/src/core/psysprocessor/PSysDAG.cpp +++ b/src/core/psysprocessor/PSysDAG.cpp @@ -105,14 +105,13 @@ int PSysDAG::createPipeExecutors(bool useTnrOutBuffer) { std::shared_ptr gc = GCM->getGraphConfig(mConfigMode); CheckAndLogError(!gc, UNKNOWN_ERROR, "Failed to get GraphConfig in PSysDAG!"); - std::set graphIds; - gc->getGraphIds(graphIds); - PolicyConfig* cfg = PlatformData::getExecutorPolicyConfig(graphIds); + int graphId = gc->getGraphId(); + PolicyConfig* cfg = PlatformData::getExecutorPolicyConfig(graphId); CheckAndLogError(!cfg, UNKNOWN_ERROR, "Failed to get PolicyConfig in PSysDAG!"); - if (mScheduler) mScheduler->configurate(graphIds); + if (mScheduler) mScheduler->configurate(graphId); #ifdef USE_PG_LITE_PIPE - configShareReferPool(gc, cfg); + configShareReferPool(gc); #endif std::vector pgNames; @@ -503,7 +502,8 @@ int PSysDAG::queueBuffers(const PSysTaskData& task) { } #ifdef USE_PG_LITE_PIPE -void PSysDAG::configShareReferPool(std::shared_ptr gc, PolicyConfig* cfg) { +void PSysDAG::configShareReferPool(std::shared_ptr gc) { + PolicyConfig* cfg = PlatformData::getExecutorPolicyConfig(gc->getGraphId()); if (!cfg || cfg->shareReferPairList.empty()) { return; } diff --git a/src/core/psysprocessor/PSysDAG.h b/src/core/psysprocessor/PSysDAG.h index 75385655..3009a036 100644 --- a/src/core/psysprocessor/PSysDAG.h +++ b/src/core/psysprocessor/PSysDAG.h @@ -121,7 +121,7 @@ class PSysDAG { int bindExternalPortsToExecutor(); void releasePipeExecutors(); #ifdef USE_PG_LITE_PIPE - void configShareReferPool(std::shared_ptr gc, PolicyConfig* cfg); + void configShareReferPool(std::shared_ptr gc); #endif PipeExecutor* findExecutorProducer(PipeExecutor* consumer); status_t searchStreamIdsForOutputPort(PipeExecutor* executor, Port port); diff --git a/src/core/psysprocessor/PipeLiteExecutor.cpp b/src/core/psysprocessor/PipeLiteExecutor.cpp index d9c16947..54dd9f08 100644 --- a/src/core/psysprocessor/PipeLiteExecutor.cpp +++ b/src/core/psysprocessor/PipeLiteExecutor.cpp @@ -64,9 +64,7 @@ PipeLiteExecutor::PipeLiteExecutor(int cameraId, const ExecutorPolicy& policy, mLastStatsSequence(-1), mExclusivePGs(exclusivePGs), mPSysDag(psysDag), - mkernelsCountWithStats(0), - mMsOfPsysAlignWithSystem(0) { - mMsOfPsysAlignWithSystem = PlatformData::getMsOfPsysAlignWithSystem(mCameraId); + mkernelsCountWithStats(0) { } PipeLiteExecutor::~PipeLiteExecutor() { @@ -629,25 +627,6 @@ int PipeLiteExecutor::processNewFrame() { } // HDR_FEATURE_E - // Check if system scheduling -// Allow +/- 3ms delay -#define SYS_TRIGGER_DELTA (3) - if (mMsOfPsysAlignWithSystem) { - timeval curTime; - gettimeofday(&curTime, nullptr); - int64_t ms = (curTime.tv_usec / 1000) % mMsOfPsysAlignWithSystem; - int64_t waitMs = 0; - - if ((ms <= SYS_TRIGGER_DELTA) || ((mMsOfPsysAlignWithSystem - ms) <= SYS_TRIGGER_DELTA)) - waitMs = 0; - else - waitMs = mMsOfPsysAlignWithSystem - ms; - - LOG1("%s: current %ld (%ld), need wait %ld to trigger", mName.c_str(), - curTime.tv_usec / 1000, ms, waitMs); - if (waitMs) usleep(waitMs * 1000); - } - LOG2("%s:Id:%d run pipe start for buffer:%ld", mName.c_str(), mCameraId, inBufSequence); // FRAME_SYNC_S @@ -801,7 +780,7 @@ int PipeLiteExecutor::runPipe(map>& inBuffers, unit.inputBuffers.begin()->second->setSequence(sequence); // Currently PG handles one stats buffer only ret = unit.pg->iterate(unit.inputBuffers, unit.outputBuffers, - pgStatsDatas.empty() ? nullptr : pgStatsDatas[0], ipuParameters); + (statsCount > 0) ? pgStatsDatas[0] : nullptr, ipuParameters); CheckAndLogError((ret != OK), ret, "%s: pipe iteration error %d", mName.c_str(), ret); if (CameraDump::isDumpTypeEnable(DUMP_PSYS_INTERM_BUFFER)) { diff --git a/src/core/psysprocessor/PipeLiteExecutor.h b/src/core/psysprocessor/PipeLiteExecutor.h index 4e0eab02..1596fe3e 100644 --- a/src/core/psysprocessor/PipeLiteExecutor.h +++ b/src/core/psysprocessor/PipeLiteExecutor.h @@ -203,8 +203,6 @@ class PipeLiteExecutor : public BufferQueue, public ISchedulerNode { CameraBufferPortMap mInternalOutputBuffers; int mkernelsCountWithStats; - - int mMsOfPsysAlignWithSystem; }; typedef PipeLiteExecutor PipeExecutor; diff --git a/src/core/psysprocessor/PolicyManager.cpp b/src/core/psysprocessor/PolicyManager.cpp index 88e34427..b87098a7 100644 --- a/src/core/psysprocessor/PolicyManager.cpp +++ b/src/core/psysprocessor/PolicyManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2024 Intel Corporation + * Copyright (C) 2017-2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ #include "PolicyManager.h" -#include "AiqResultStorage.h" #include "iutils/Errors.h" #include "iutils/CameraLog.h" @@ -142,19 +141,14 @@ int PolicyManager::wait(std::string executorName, int64_t sequence) { bundle->mWaitingCount++; - int64_t waitDuration = 66000000; // 66ms - const AiqResult* aiqResult = AiqResultStorage::getInstance(mCameraId)->getAiqResult(sequence); - if (aiqResult && aiqResult->mAiqParam.aeFpsRange.min >= 30.0) { - waitDuration = 33000000; // 33ms - } - /** * If waiting count less than total executor number in the bundle, it means * we need to wait for other executors to run with them together. */ if (bundle->mWaitingCount < bundle->mExecutorNum) { LOG2("%s: need wait for other executors.", executorName.c_str()); - int ret = bundle->mCondition.waitRelative(lock, waitDuration * SLOWLY_MULTIPLIER); + const int64_t kWaitDuration = 66000000; // 66ms + int ret = bundle->mCondition.waitRelative(lock, kWaitDuration * SLOWLY_MULTIPLIER); if (ret == TIMED_OUT) { LOG2("%s: wait executors timeout", executorName.c_str()); return ret; diff --git a/src/evcp/EvcpCommon.h b/src/evcp/EvcpCommon.h new file mode 100644 index 00000000..94215a85 --- /dev/null +++ b/src/evcp/EvcpCommon.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.||g/licenses/LICENSE-2.0 + * + * Unless required by applicable law || agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES || CONDITIONS OF ANY KIND, either express || implied. + * See the License f|| the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#define FNLEN 256 + +struct EvcpParam { + bool evcpEccEnabled; + bool evcpBdEnabled; + bool evcpEnableTurbo; + bool evcpPowerSave; + + bool evcpBGConcealment; + bool evcpBGReplacement; + bool evcpFaceBea; + bool evcpFaceFra; + + uint32_t evcpBGBufferHandle; + char evcpBGFileName[FNLEN]; +}; + +static bool inline evcpParamCmp(const EvcpParam* p1, const EvcpParam* p2) { + if (p1->evcpEccEnabled != p2->evcpEccEnabled || p1->evcpBdEnabled != p2->evcpBdEnabled || + p1->evcpBGConcealment != p2->evcpBGConcealment || + p1->evcpBGReplacement != p2->evcpBGReplacement || p1->evcpFaceFra != p2->evcpFaceFra || + p1->evcpBGBufferHandle != p2->evcpBGBufferHandle) { + return false; + } + return true; +} + +typedef EvcpParam ECCParam; + +struct EvcpRunParam { + void* bufferHandle; +}; + +struct EvcpResolution { + int32_t width; + int32_t height; +}; + +struct EvcpRunInfo { + int32_t inHandle; + uint32_t bufSize; +}; + +#define MAX_STORE_EVCP_DATA_BUF_NUM 10 diff --git a/src/evcp/EvcpManager.cpp b/src/evcp/EvcpManager.cpp new file mode 100644 index 00000000..f056f580 --- /dev/null +++ b/src/evcp/EvcpManager.cpp @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG EvcpManager + +#include "src/evcp/EvcpManager.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "PlatformData.h" +#include "core/CameraBuffer.h" +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { +std::unordered_map EvcpManager::sInstances; +std::unordered_map EvcpManager::mLatestParam; +Mutex EvcpManager::sLock; +Mutex EvcpManager::sParamLock; + +EvcpManager* EvcpManager::getInstance(int cameraId) { + AutoMutex lock(sLock); + + if (sInstances.find(cameraId) == sInstances.end()) { + return nullptr; + } + + return sInstances[cameraId]; +} + +bool EvcpManager::createInstance(int cameraId, int width, int height) { + AutoMutex lock(sLock); + if (sInstances.find(cameraId) == sInstances.end()) { + EvcpManager* thr = new EvcpManager(cameraId, width, height, nullptr); + bool r = thr->init(); + if (!r) { + delete thr; + return false; + } + sInstances[cameraId] = thr; + } + + return true; +} + +void EvcpManager::destoryInstance(int cameraId) { + AutoMutex lock(sLock); + + if (sInstances.find(cameraId) != sInstances.end()) { + delete sInstances[cameraId]; + sInstances.erase(cameraId); + } +} + +EvcpManager::EvcpManager(int cameraId, int width, int height, EvcpParam* evcpParam) + : mCameraId(cameraId), + mWidth(width), + mHeight(height) {} + +bool EvcpManager::init() { + mEvcp = std::unique_ptr(new IntelEvcp()); + int ret = mEvcp->init(mWidth, mHeight); + CheckAndLogError(ret != OK, false, "$%s: mEvcp init fails, ret %d", __func__, ret); + + return mEvcp->updateEvcpParam(&mLatestParam[mCameraId]); +} + +bool EvcpManager::checkingStatus() { + AutoMutex lock(sParamLock); + + if (!mLatestParam[mCameraId].evcpEccEnabled && !mLatestParam[mCameraId].evcpBGConcealment && + !mLatestParam[mCameraId].evcpFaceBea && !mLatestParam[mCameraId].evcpFaceFra) { + return false; + } + + return true; +} + +bool EvcpManager::saveNV12Img(int fd, int width, int height, char* filename) { + std::string fn; + + struct stat sb; + if (::fstat(fd, &sb)) return false; + + int filesize = sb.st_size; + + void* p = ::mmap(nullptr, filesize, PROT_READ, MAP_SHARED, fd, 0); + + if (p == MAP_FAILED) return false; + + fn = "/run/camera/Babun_"; + fn += std::to_string(width); + fn += "x"; + fn += std::to_string(height); + fn += ".NV12"; + + std::fstream ofs; + ofs.open(fn, std::ios::out | std::ios::binary | std::ios::trunc); + if (!ofs.is_open()) { + ::munmap(p, filesize); + return false; + } + + ofs.write(reinterpret_cast(p), filesize); + + ::munmap(p, filesize); + ::strncpy(filename, fn.c_str(), FNLEN); + + return true; +} + +EvcpParam EvcpManager::getParamFromExp(const icamera::Parameters* param) { + EvcpParam earam = {}; + + uint8_t eccEnable, bcMode, ffMode; + int w, h, bgFD; + + param->getEvcpEccMode(&eccEnable); + param->getEvcpBCMode(&bcMode); + param->getEvcpBRParameters(&w, &h, &bgFD); + param->getEvcpFFMode(&ffMode); + + earam.evcpEccEnabled = eccEnable; + if (bcMode == INTEL_VENDOR_CAMERA_IC_BC_MODE_BLUR) { + earam.evcpBGConcealment = true; + } else if (bcMode == INTEL_VENDOR_CAMERA_IC_BC_MODE_REPLACEMENT) { + earam.evcpBGConcealment = true; + earam.evcpBGReplacement = true; + + if (bgFD > 0) { + earam.evcpBGBufferHandle = bgFD; + if (saveNV12Img(bgFD, w, h, earam.evcpBGFileName) == false) { + earam.evcpBGConcealment = false; + earam.evcpBGReplacement = false; + earam.evcpBGBufferHandle = -1; + earam.evcpBGFileName[0] = '\0'; + } + } + } + earam.evcpFaceFra = ffMode == INTEL_VENDOR_CAMERA_IC_FF_MODE_AUTO; + + return earam; +} + +void EvcpManager::prepare4Param(icamera::Parameters* param) { + EvcpParam curParam = getEvcpParam(); + EvcpParam expParam = getParamFromExp(param); + + if (!evcpParamCmp(&curParam, &expParam)) updateEvcpParam(expParam); +} + +void EvcpManager::runEvcp(const camera_buffer_t& buffer, icamera::Parameters* param) { + prepare4Param(param); + if (checkingStatus() == false) return; + + runEvcpL(buffer); +} + +void EvcpManager::runEvcpL(const camera_buffer_t& buffer) { + int size = buffer.s.size; + + nsecs_t startTime = CameraUtils::systemTime(); + +#ifdef ENABLE_SANDBOXING + bool ret = mEvcp->runEvcpFrame(buffer.dmafd, size); +#else + void* pBuf = (buffer.s.memType == V4L2_MEMORY_DMABUF) ? + CameraBuffer::mapDmaBufferAddr(buffer.dmafd, size) : + buffer.addr; + + bool ret = mEvcp->runEvcpFrame(pBuf, size); + + if (buffer.s.memType == V4L2_MEMORY_DMABUF) { + CameraBuffer::unmapDmaBufferAddr(pBuf, size); + } +#endif + + if (ret == false) { + LOGW("@%s Evcp run frame fails", __func__); + } + + LOG2("@%s: ret:%s, Evcp takes %ums", __func__, ret ? "true" : "false", + (unsigned)((CameraUtils::systemTime() - startTime) / 1000000)); +} + +bool EvcpManager::updateEvcpParam(EvcpParam evcpParam) { + if (mEvcp->updateEvcpParam(&evcpParam)) { + AutoMutex lock(sParamLock); + mLatestParam[mCameraId] = evcpParam; + + return true; + } + + return false; +} + +EvcpParam EvcpManager::getEvcpParam() const { + AutoMutex lock(sParamLock); + + return mLatestParam[mCameraId]; +} + +} // namespace icamera diff --git a/src/evcp/EvcpManager.h b/src/evcp/EvcpManager.h new file mode 100644 index 00000000..9e44027e --- /dev/null +++ b/src/evcp/EvcpManager.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#ifdef ENABLE_SANDBOXING +#include "modules/sandboxing/client/IntelEvcpClient.h" +#else +#include "modules/algowrapper/IntelEvcp.h" +#endif + +#include +#include +#include + +#include "EvcpCommon.h" +#include "Parameters.h" +#include "iutils/Errors.h" +#include "iutils/Thread.h" +#include "iutils/Utils.h" + +namespace icamera { +class IntelECC; + +class EvcpManager { + public: + EvcpManager(int cameraId, int width, int height, EvcpParam* evcpParam); + ~EvcpManager() {} + + static bool createInstance(int cameraId, int width, int height); + static EvcpManager* getInstance(int cameraId); + static void destoryInstance(int cameraId); + + void runEvcp(const camera_buffer_t& buffer, icamera::Parameters* param); + bool updateEvcpParam(EvcpParam evcpParam); + EvcpParam getEvcpParam() const; + + private: + void runEvcpL(const camera_buffer_t& buffer); + bool init(); + bool checkingStatus(); + void prepare4Param(icamera::Parameters* param); + EvcpParam getParamFromExp(const icamera::Parameters* param); + bool saveNV12Img(int fd, int width, int height, char* filename); + + static Mutex sLock; + static std::unordered_map sInstances; + + static Mutex sParamLock; + static std::unordered_map mLatestParam; + + int mCameraId; + + std::unique_ptr mEvcp; + + int mWidth; + int mHeight; + + DISALLOW_COPY_AND_ASSIGN(EvcpManager); +}; + +} // namespace icamera diff --git a/src/evcp/UltraManEvcp.cpp b/src/evcp/UltraManEvcp.cpp new file mode 100644 index 00000000..35f2057d --- /dev/null +++ b/src/evcp/UltraManEvcp.cpp @@ -0,0 +1,403 @@ +/* + * Copyright (C) 2021 Intel Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG UltraManEvcp + +#include "src/evcp/UltraManEvcp.h" + +#include +#include + +#include + +#include "iutils/CameraLog.h" +#include "iutils/Thread.h" +#include "iutils/Utils.h" + +#define EVCP_SUCCESS 0 +#define LIBEVCP_NAME "libevcp.so" + +namespace icamera { + +UltraManEvcp::UltraManEvcp(int width, int height) + : mCurrWidth(width), + mCurrHeight(height), + mFrameCount(0), + mEccEnabled(false), + mDimmerEnabled(false), + mLowPowerMode(false), + mMdfTurbo(false), + mEvcpBGConcelment(false), + mEvcpBGReplacement(false), + mFaceBea(false), + mFaceFra(false), + mCtx(nullptr), + mInit(false), + mHandleEvcpLib(nullptr) {} + +bool UltraManEvcp::init() { + setenv("NoJitter", "1", 1); + setenv("EccTaskOverwhelm", "0 1,0 1", 1); + + memset(&mApi, 0, sizeof(mApi)); + + mDevice = getSystemCMDevice(); + CheckAndLogError(mDevice == nullptr, false, "$%s:CMDevice is nullptr", __func__); + + loadEvcpLibrary(); + CheckAndLogError(mApi.EvcpCreate == nullptr, false, "$%s:Cannot call Evcp ctor", __func__); + + mCtx = mApi.EvcpCreate(mCurrWidth, mCurrHeight, mDevice, 1); + CheckAndLogError(mCtx == nullptr, false, "$%s:Evcp context is nullptr", __func__); + + mInit = true; + return true; +} + +UltraManEvcp::~UltraManEvcp() { + if (!mInit) return; + + mInit = false; + if (mCtx && mApi.EvcpDestroy) { + LOG1("@%s EVCP Shutdown ", __func__); + mApi.EvcpDestroy(mCtx); + } + ::DestroyCmDevice(mDevice); + CameraUtils::dlcloseLibrary(mHandleEvcpLib); + mHandleEvcpLib = nullptr; +} + +bool UltraManEvcp::checkEVCPBackgroundURL(const std::string& name) const { + if (name.empty()) { + LOGW("%s, FileName empty ", __func__); + return true; + } + if (access(name.c_str(), R_OK) != 0) { + LOGE("%s, Cannot read file: [%s]", __func__, name.c_str()); + return false; + } + + std::size_t pos; + pos = name.find_last_of("_"); + if (pos == std::string::npos) { + LOGW("%s, Malform filename: %s", __func__, name.c_str()); + return true; + } + + std::size_t extPos; + extPos = name.find(".nv12"); + if (pos == std::string::npos) { + LOGW("%s, Malform filename: %s", __func__, name.c_str()); + return true; + } + + if (extPos - pos <= 3) { + LOGW("%s, Malform filename: %s", __func__, name.c_str()); + return true; + } + + std::string sizeInfo = name.substr(pos + 1, extPos - pos - 1); + + std::size_t xPos = sizeInfo.find('x'); + int width = std::atol(std::string(sizeInfo.begin(), sizeInfo.begin() + xPos).c_str()); + int height = std::atol(sizeInfo.data() + xPos + 1); + + if ((width != mCurrWidth) || (height != mCurrHeight)) { + LOGW("%s Size mismatch, width = %d, height = %, mCurrHeight = %d, mCurrHeight = %d", + __func__, width, height, mCurrWidth, mCurrHeight); + } + + return true; +} + +bool UltraManEvcp::isEvcpEnable() const { + return isEccEnabled() || isBGConcelment() || isFaceBeaEnable() || isFaceFraEnable(); +} + +bool UltraManEvcp::processFrame(CmSurface2DUP* pSample) { + if (!isEvcpEnable()) { + return true; + } + + if (!mApi.EvcpProcessFrame || !mCtx) { + LOGE("%s, Evcp function error.", __func__); + return false; + } + + bool lockStatus = mCritMutexEccObject.try_lock(); + CheckAndLogError(lockStatus == false, false, "%s return as lock is occupied by others", + __func__); + + if (mApi.EvcpProcessFrame(&mCtx, pSample, pSample) == EVCP_SUCCESS) { + mFrameCount++; + mCritMutexEccObject.unlock(); + return true; + } + + // Not a fatal error + LOGW("%s EvcpProcessFrame BAD", __func__); + mCritMutexEccObject.unlock(); + return true; +} + +bool UltraManEvcp::updateEvcpInfo(const EvcpParam* param) { + if (!param->evcpBGConcealment && param->evcpBGReplacement) { + LOGW("%s EvcpBGConcealment and EvcpBGReplacement conflict", __func__); + return false; + } + + if (strlen(param->evcpBGFileName) && + !checkEVCPBackgroundURL(std::string(param->evcpBGFileName))) { + LOGE("%s checkEVCPBackgroundURL FAILED", __func__); + return false; + } + + bool res = flushStatus(param); + if (!res) LOGE("%s flushStatus FAILED", __func__); + + LOG1("@%s ECC [%d], DIM [%d], LP [%d], TURBO [%d] CON [%d] REPL [%d], FB[%d], FF[%d]", __func__, + mEccEnabled, mDimmerEnabled, mLowPowerMode, mMdfTurbo, mEvcpBGConcelment, + mEvcpBGReplacement, mFaceBea, mFaceFra); + + return true; +} + +bool UltraManEvcp::loadEvcpLibrary() { + mHandleEvcpLib = CameraUtils::dlopenLibrary(LIBEVCP_NAME, RTLD_NOW); + CheckAndLogError(!mHandleEvcpLib, false, "mHandleEvcpLib is nullptr"); +#ifndef TIGA +#define TIGA(member, fn_name) \ + do { \ + mApi.member = \ + (EVCP_API_HANDLE::pFn##member)CameraUtils::dlsymLibrary(mHandleEvcpLib, #fn_name); \ + if (mApi.member == nullptr) { \ + LOG1("@%s: LOADING " #fn_name "failed for member", __func__); \ + } \ + LOG1("@%s: " #fn_name "= %x", __func__, mApi.member); \ + } while (0) +#endif + TIGA(EvcpCreate, evcp_create_context); + TIGA(EvcpDestroy, evcp_destroy_context); + TIGA(EvcpToggleEcc, evcp_toggle_ecc); + TIGA(EvcpSetMdfTurbo, evcp_set_mdf_turbo); + TIGA(EvcpSetVerbose, evcp_set_verbose); + TIGA(EvcpSetPowerSavingMode, evcp_set_power_saving_mode); + TIGA(EvcpProcessFrame, evcp_process_frame3); + TIGA(EvcpProcessFrame2D, evcp_process_frame2); + TIGA(EvcpSetBackGroundURL, evcp_set_background_url); + TIGA(EvcpToggleBackgroundConcelment, evcp_toggle_background_concealment); + TIGA(EvcpToggleBackgroundReplacement, evcp_toggle_background_replacement); + TIGA(EvcpSetFaceBea, evcp_toggle_face_beautify); + TIGA(EvcpSetFaceFra, evcp_toggle_face_centering); +#undef TIGA + + return true; +} + +bool UltraManEvcp::setEvcpEnable(bool v) { + bool res = false; + + if (mApi.EvcpToggleEcc) { + LOG1("%s mEccEnabled will setting to %d", __func__, (int)v); + if (mApi.EvcpToggleEcc(mCtx, static_cast(v)) == EVCP_SUCCESS) { + mEccEnabled = v; + res = true; + } + } + return res; +} + +bool UltraManEvcp::setEvcpPowerSavingMode(bool v) { + bool res = false; + + if (mApi.EvcpSetPowerSavingMode) { + LOG1("%s mEvcpSetPowerSavingMode setting to %d", __func__, (int)v); + if (mApi.EvcpSetPowerSavingMode(mCtx, static_cast(v)) == EVCP_SUCCESS) { + mLowPowerMode = v; + res = true; + } + } + return res; +} + +bool UltraManEvcp::setEvcpSetMdfTurbo(bool v) { + bool res = false; + + if (mApi.EvcpSetMdfTurbo) { + LOG1("%s mMdfTurbo setting to %d", __func__, (int)v); + if (mApi.EvcpSetMdfTurbo(mCtx, static_cast(v)) == EVCP_SUCCESS) { + mMdfTurbo = v; + res = true; + } + } + return res; +} + +bool UltraManEvcp::setEvcpFaceBea(bool v) { + bool res = false; + + if (mApi.EvcpSetFaceBea) { + LOG1("%s EvcpSetFaceBea setting to %d", __func__, (int)v); + if (mApi.EvcpSetFaceBea(mCtx, static_cast(v)) == EVCP_SUCCESS) { + mFaceBea = v; + res = true; + } + } + return res; +} + +bool UltraManEvcp::setEvcpFaceFra(bool v) { + bool res = false; + + if (mApi.EvcpSetFaceFra) { + LOG1("%s FF will setting to %d", __func__, (int)v); + if (mApi.EvcpSetFaceFra(mCtx, static_cast(v)) == EVCP_SUCCESS) { + mFaceFra = v; + res = true; + } + } + return res; +} + +bool UltraManEvcp::setEvcpConcelment(bool con, bool replace, const char* filePath) { + bool res = true; + + if (mApi.EvcpToggleBackgroundConcelment) { + if (mApi.EvcpToggleBackgroundConcelment(mCtx, static_cast(con)) == EVCP_SUCCESS) { + LOG1("%s setEvcpConcelment OK", __func__); + mEvcpBGConcelment = con; + if (!mEvcpBGConcelment) mEvcpBGReplacement = false; + } else { + LOGE("%s setEvcpConcelment FAILED", __func__); + res = false; + } + } + + if (res && mApi.EvcpToggleBackgroundReplacement) { + res = setEvcpReplacement(replace, filePath); + if (res == false) { + LOGE("%s setEvcpReplacement FAILED", __func__); + } + } + + return res; +} + +bool UltraManEvcp::setEvcpReplacement(bool replace, const char* filePath) { + bool res = true; + + if (filePath) { + if (mApi.EvcpSetBackGroundURL(mCtx, filePath) == EVCP_SUCCESS) { + LOG1("%s EvcpSetBackGroundURL OK", __func__); + mEvcpBackgroundURL = std::string(filePath); + } else { + LOGE("%s EvcpSetBackGroundURL FAILED", __func__); + res = false; + } + } else { + replace = false; + } + + if (res) { + if (mApi.EvcpToggleBackgroundReplacement(mCtx, static_cast(replace)) == EVCP_SUCCESS) { + LOG1("%s EvcpToggleBackgroundReplacement OK", __func__); + mEvcpBGReplacement = replace; + } else { + LOGE("%s EvcpToggleBackgroundReplacement FAILED", __func__); + res = false; + } + } + + return res; +} + +bool UltraManEvcp::flushStatus(const EvcpParam* param) { + AutoMutex lock(mCritMutexEccObject); + + if (mEccEnabled != param->evcpEccEnabled) { + bool res = setEvcpEnable(param->evcpEccEnabled); + CheckAndLogError(res != true, false, "%s: SetEvcpEnable fails, ret %d", __func__, + static_cast(res)); + } + + if (mLowPowerMode != param->evcpPowerSave) { + bool res = setEvcpPowerSavingMode(param->evcpPowerSave); + CheckAndLogError(res != true, false, "%s: SetEvcpPowerSavingMode fails, ret %d", __func__, + static_cast(res)); + } + + if (mMdfTurbo != param->evcpEnableTurbo) { + bool res = setEvcpSetMdfTurbo(param->evcpEnableTurbo); + CheckAndLogError(res != true, false, "%s: SetEvcpSetMdfTurbo fails, ret %d", __func__, + static_cast(res)); + } + + if (mEvcpBGConcelment != param->evcpBGConcealment || + (mEvcpBGConcelment && param->evcpBGReplacement != mEvcpBGReplacement) || + ((mEvcpBGConcelment && param->evcpBGReplacement == mEvcpBGReplacement && + mEvcpBackgroundURL != param->evcpBGFileName))) { + bool res = setEvcpConcelment(param->evcpBGConcealment, param->evcpBGReplacement, + param->evcpBGFileName); + CheckAndLogError(res != true, false, "%s: SetEvcpConcelment fails, ret %d", __func__, + static_cast(res)); + } + + if (mFaceBea != param->evcpFaceBea) { + bool res = setEvcpFaceBea(param->evcpFaceBea); + CheckAndLogError(res != true, false, "%s: SetFaceBea fails, ret %d", __func__, + static_cast(res)); + } + + if (mFaceFra != param->evcpFaceFra) { + bool res = setEvcpFaceFra(param->evcpFaceFra); + CheckAndLogError(res != true, false, "%s: SetFaceFra fails, ret %d", __func__, + static_cast(res)); + } + + return true; +} + +CmDevice* UltraManEvcp::getSystemCMDevice() { + unsigned int version = 0; + + if (CreateCmDevice(mDevice, version) != CM_SUCCESS) { + LOGE("%s CreateCmDevice Failed", __func__); + return nullptr; + } + + return mDevice; +} + +bool UltraManEvcp::createCMSurface2DUP(uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, + void* sysMem, CmSurface2DUP*& surface) { + if (mDevice->CreateSurface2DUP(width, height, format, sysMem, surface) != CM_SUCCESS) { + LOGE("%s CreateSurface2DUP FAILED", __func__); + return false; + } + + return true; +} + +bool UltraManEvcp::destroyCMSurface2DUP(CmSurface2DUP*& surface) { + if (mDevice->DestroySurface2DUP(surface) != CM_SUCCESS) { + LOGE("%s destroyCMSurface2DUP FAILED", __func__); + return false; + } + + return true; +} + +} // namespace icamera diff --git a/src/evcp/UltraManEvcp.h b/src/evcp/UltraManEvcp.h new file mode 100644 index 00000000..49b68d7e --- /dev/null +++ b/src/evcp/UltraManEvcp.h @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include +#include + +#include "EvcpCommon.h" +#include "iutils/Utils.h" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wbitfield-constant-conversion" +#pragma clang diagnostic ignored "-Wunused-private-field" +#pragma clang diagnostic ignored "-Werror" +// HANDLE is redefined in cm_rt.h, avoid the redefinition build error +#define HANDLE cancel_fw_pre_define +#include "igfxcmrt/cm_rt.h" + +#pragma clang diagnostic pop + +struct evcp_context; + +struct EVCP_API_HANDLE { +#define _DEF_FUNC(ret, name, ...) \ + typedef ret (*pFn##name)(__VA_ARGS__); \ + pFn##name name + + _DEF_FUNC(evcp_context*, EvcpCreate, int w, int h, void* hdl, int bit); + _DEF_FUNC(void, EvcpDestroy, evcp_context* ctx); + _DEF_FUNC(int, EvcpToggleEcc, evcp_context* ctx, int enable); + _DEF_FUNC(int, EvcpSetMdfTurbo, evcp_context* ctx, bool enable); + _DEF_FUNC(int, EvcpSetVerbose, evcp_context* ctx, int verbose); + _DEF_FUNC(int, EvcpSetPowerSavingMode, evcp_context* ctx, bool enable); + _DEF_FUNC(int, EvcpProcessFrame, evcp_context** ctx, CmSurface2DUP* src, CmSurface2DUP* dst); + _DEF_FUNC(int, EvcpProcessFrame2D, evcp_context** ctx, CmSurface2D* src, CmSurface2D* dst); + _DEF_FUNC(int, EvcpSetBackGroundURL, evcp_context* ctx, const char* path); + _DEF_FUNC(int, EvcpToggleBackgroundConcelment, evcp_context* ctx, int enable); + _DEF_FUNC(int, EvcpToggleBackgroundReplacement, evcp_context* ctx, int enable); + _DEF_FUNC(int, EvcpSetFaceBea, evcp_context* ctx, int enable); + _DEF_FUNC(int, EvcpSetFaceFra, evcp_context* ctx, int enable); +#undef _DEF_FUNC +}; + +namespace icamera { + +class UltraManEvcp { + public: + UltraManEvcp(int width, int height); + bool init(); + + virtual ~UltraManEvcp(); + bool updateEvcpInfo(const EvcpParam* param); + bool processFrame(CmSurface2DUP* pSample); + + bool isEccEnabled() const { return mEccEnabled; } + bool isDimmerEnabled() const { return mDimmerEnabled; } + bool isLowPowerMode() const { return mLowPowerMode; } + bool isTurboOn() const { return mMdfTurbo; } + bool isBGConcelment() const { return mEvcpBGConcelment; } + bool isBGReplacement() const { return mEvcpBGReplacement; } + bool isFaceBeaEnable() const { return mFaceBea; } + bool isFaceFraEnable() const { return mFaceFra; } + std::string getBGFilePath() const { return mEvcpBackgroundURL; } + + bool createCMSurface2DUP(uint32_t width, uint32_t height, CM_SURFACE_FORMAT format, + void* sysMem, CmSurface2DUP*& surface); + + bool destroyCMSurface2DUP(CmSurface2DUP*& surface); + + private: + bool flushStatus(const EvcpParam* param); + bool checkEVCPBackgroundURL(const std::string& name) const; + + CmDevice* getSystemCMDevice(); + bool loadEvcpLibrary(); + + bool setEvcpEnable(bool v); + bool setEvcpPowerSavingMode(bool v); + bool setEvcpSetMdfTurbo(bool v); + bool setEvcpConcelment(bool con, bool replace, const char* filePath); + bool setEvcpReplacement(bool replace, const char* filePath); + bool isEvcpEnable() const; + std::string mEvcpBackgroundURL; + + bool setEvcpFaceBea(bool v); + bool setEvcpFaceFra(bool v); + + uint32_t mCurrWidth; + uint32_t mCurrHeight; + uint64_t mFrameCount; + bool mEccEnabled; + bool mDimmerEnabled; + bool mLowPowerMode; + bool mMdfTurbo; + + bool mEvcpBGConcelment; + bool mEvcpBGReplacement; + + bool mFaceBea; + bool mFaceFra; + + std::mutex mCritMutexEccObject; + EVCP_API_HANDLE mApi; + + evcp_context* mCtx; + CmDevice* mDevice; + bool mInit; + void* mHandleEvcpLib; + + DISALLOW_COPY_AND_ASSIGN(UltraManEvcp); +}; +} // namespace icamera diff --git a/src/fd/facessd/FaceSSD.cpp b/src/fd/facessd/FaceSSD.cpp index 1468d174..60cbc72f 100644 --- a/src/fd/facessd/FaceSSD.cpp +++ b/src/fd/facessd/FaceSSD.cpp @@ -152,7 +152,6 @@ void FaceSSD::getResultFor3A(cca::cca_face_state* faceState) { faceState->is_video_conf = true; faceState->updated = mResult.faceUpdated; faceState->num_faces = faceSsdResult->faceNum; - faceState->fd_algo = GOOGLE_FD; mResult.faceUpdated = false; for (int i = 0; i < faceSsdResult->faceNum; i++) { diff --git a/src/fd/pvl/FaceDetectionPVL.cpp b/src/fd/pvl/FaceDetectionPVL.cpp index c9d8b158..1b032890 100644 --- a/src/fd/pvl/FaceDetectionPVL.cpp +++ b/src/fd/pvl/FaceDetectionPVL.cpp @@ -227,7 +227,6 @@ void FaceDetectionPVL::getResultFor3A(cca::cca_face_state* faceState) { faceState->is_video_conf = true; faceState->updated = mResult.faceUpdated; faceState->num_faces = pvlResult->faceNum; - faceState->fd_algo = PVL; mResult.faceUpdated = false; for (int i = 0; i < pvlResult->faceNum; i++) { diff --git a/src/hal/hal_adaptor/CMakeLists.txt b/src/hal/hal_adaptor/CMakeLists.txt index 9de5e13a..0f2f4ad0 100644 --- a/src/hal/hal_adaptor/CMakeLists.txt +++ b/src/hal/hal_adaptor/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2023-2024 Intel Corporation +# Copyright (C) 2023 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,25 +14,62 @@ # limitations under the License. # +cmake_minimum_required(VERSION 2.8) +project(hal_adaptor) + # Source directories set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../) set(METADATA_DIR ${ROOT_DIR}/src/metadata) set(IUTILS_DIR ${ROOT_DIR}/src/iutils) set(HAL_ADAPTOR_DIR ${ROOT_DIR}/src/hal/hal_adaptor) -set(HAL_ADAPTOR_INCLUDEDIRS - ${ROOT_DIR}/include - ${ROOT_DIR}/include/api - ${ROOT_DIR}/include/utils - ${ROOT_DIR}/src/metadata - ${ROOT_DIR}/src/iutils - ${ROOT_DIR}/src/core - ${ROOT_DIR}/src/platformdata - ${ROOT_DIR}/src/isp_control - ${ROOT_DIR}/src - ${ROOT_DIR}/modules/v4l2 - ${ROOT_DIR} - ) +include_directories(${ROOT_DIR}/include + ${ROOT_DIR}/include/api + ${ROOT_DIR}/include/utils + ${ROOT_DIR}/src/metadata + ${ROOT_DIR}/src/iutils + ${ROOT_DIR}/src/core + ${ROOT_DIR}/src/platformdata + ${ROOT_DIR}/src/isp_control + ${ROOT_DIR}/src + ${ROOT_DIR}/modules/v4l2 + ${ROOT_DIR} + ) + +# Install directories +# CMAKE_INSTALL_PREFIX is defined when executing cmake. +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}" CACHE PATH "Target location for install command." FORCE) +endif() +message(STATUS "install prefix: " ${CMAKE_INSTALL_PREFIX}) + +include(GNUInstallDirs) + +# Set the aligned flag +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG(-faligned-new COMPILER_SUPPORTS_ALIGNED_NEW) +if (COMPILER_SUPPORTS_ALIGNED_NEW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new") +endif() + +# Set the CXX to 11 +set (CMAKE_CXX_STANDARD 11) +add_compile_options(-Wall -Werror + -fstack-protector + -fPIE -fPIC + -DDCHECK_ALWAYS_ON + -Wformat -Wformat-security + ) + +add_definitions(-D__STDC_FORMAT_MACROS + -DHAVE_PTHREADS + -DHAVE_LINUX_OS + -DCAMHAL_PLUGIN_DIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libcamhal/plugins/\" + ) + +set(HAL_ADAPTOR_LD_FLAGS "-fPIE -fPIC -Wformat -Wformat-security -Wl,-z,relro -Wl,-z,now") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HAL_ADAPTOR_LD_FLAGS}") set(HAL_ADAPTOR_SRCS ${METADATA_DIR}/icamera_metadata_base.cpp @@ -50,13 +87,6 @@ set(HAL_ADAPTOR_SRCS ) add_library(hal_adaptor SHARED ${HAL_ADAPTOR_SRCS}) -target_include_directories(hal_adaptor PRIVATE ${HAL_ADAPTOR_INCLUDEDIRS}) -target_compile_definitions(hal_adaptor PRIVATE - -D__STDC_FORMAT_MACROS - -DHAVE_PTHREADS - -DHAVE_LINUX_OS - "-DCAMHAL_PLUGIN_DIR=\"${CMAKE_INSTALL_FULL_LIBDIR}/libcamhal/plugins/\"" - ) set_target_properties(hal_adaptor PROPERTIES OUTPUT_NAME camhal) set_target_properties(hal_adaptor PROPERTIES SOVERSION 0) set_target_properties(hal_adaptor PROPERTIES VERSION "0.0.0") @@ -69,9 +99,9 @@ target_link_libraries(hal_adaptor ${CMAKE_DL_LIBS}) target_link_libraries(hal_adaptor rt) # Install headers -install(DIRECTORY ${ROOT_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libcamhal) +install(DIRECTORY ${ROOT_DIR}/include/ DESTINATION include/libcamhal) if (SUPPORT_LIVE_TUNING) - install(FILES ${ROOT_DIR}/modules/livetune/LiveTuning.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libcamhal/api) + install(FILES ${ROOT_DIR}/modules/livetune/LiveTuning.h DESTINATION include/libcamhal/api) endif() # Install libraries @@ -85,7 +115,10 @@ else() endif() # Install package config file -configure_file(${PROJECT_SOURCE_DIR}/cmake/libcamhal.pc.cmakein +configure_file(${PROJECT_SOURCE_DIR}/hal_adaptor.pc.cmakein ${PROJECT_SOURCE_DIR}/libcamhal.pc @ONLY) -install(FILES ${PROJECT_SOURCE_DIR}/libcamhal.pc +install(FILES libcamhal.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +set(CPACK_GENERATOR "RPM") +include(CPack) diff --git a/src/hal/hal_adaptor/HalAdaptor.cpp b/src/hal/hal_adaptor/HalAdaptor.cpp index 4926798a..9e50261f 100644 --- a/src/hal/hal_adaptor/HalAdaptor.cpp +++ b/src/hal/hal_adaptor/HalAdaptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation. + * Copyright (C) 2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ static char gPciId[8]; LOGE("@%s: LOADING: " #fnName "failed: %s", __func__, dlerror()); \ return; \ } \ - LOG2("@%s: LOADING: " #fnName "= %p", __func__, gCameraHalAdaptor.member); \ + LOG2("@%s: LOADING: " #fnName "= %x", __func__, gCameraHalAdaptor.member); \ } while (0) static bool get_ipu_info(const std::string& path) { @@ -97,23 +97,18 @@ static void load_camera_hal_library() { if (strstr(gPciId, "0xa75d") != nullptr /* RPL */ || strstr(gPciId, "0x462e") != nullptr /* ADLN */ || strstr(gPciId, "0x465d") != nullptr /* ADLP */) { - libName += "ipu6ep"; + libName += "ipu6ep.so"; } else if (strstr(gPciId, "0x7d19") != nullptr /* MTL */) { - libName += "ipu6epmtl"; + libName += "ipu6epmtl.so"; } else if (strstr(gPciId, "0x645d") != nullptr /* LNL */) { - libName += "ipu7x"; - } else if (strstr(gPciId, "0xb05d") != nullptr /* PTL */) { - libName += "ipu75xa"; + libName += "ipu7.so"; } else if (strstr(gPciId, "0x9a19") != nullptr /* TGL */) { - libName += "ipu6"; - } else if (strstr(gPciId, "0x4e19") != nullptr /* JSL */) { - libName += "ipu6sepla"; + libName += "ipu6.so"; } else { LOGE("%s, Not support the PCI device %s for hal adaptor API", __func__, gPciId); - return; + return VOID_VALUE; } - libName += ".so"; LOG1("%s, the library name: %s", __func__, libName.c_str()); gCameraHalLib = dlopen(libName.c_str(), RTLD_NOW); diff --git a/src/hal/hal_adaptor/HalAdaptor.h b/src/hal/hal_adaptor/HalAdaptor.h index 3c5c3275..cca1dab0 100644 --- a/src/hal/hal_adaptor/HalAdaptor.h +++ b/src/hal/hal_adaptor/HalAdaptor.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023-2024 Intel Corporation. + * Copyright (C) 2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/hal/hal_adaptor/hal_adaptor.pc.cmakein b/src/hal/hal_adaptor/hal_adaptor.pc.cmakein new file mode 100644 index 00000000..8c66a551 --- /dev/null +++ b/src/hal/hal_adaptor/hal_adaptor.pc.cmakein @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include/libcamhal +plugindir=${libdir}/libcamhal/plugins + +Name: libcamhal +Description: Camera HAL Library +URL: +Version: @VERSION@ +Libs: -L${libdir} -lcamhal +Cflags: -I${includedir} -I${includedir}/api -I${includedir}/utils diff --git a/src/icbm/ICBMBuilder.h b/src/icbm/ICBMBuilder.h new file mode 100644 index 00000000..122e3856 --- /dev/null +++ b/src/icbm/ICBMBuilder.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "IntelICBM.h" +#include "OnePunchIC2.h" + +namespace icamera { + +#define USE_INTEL_OPIC2 + +#ifdef USE_INTEL_OPIC2 +static inline IIntelICBM* createIntelICBM() { + return new IntelOPIC2; +} + +#else +static inline IIntelICBM* createIntelICBM() { + return nullptr; +} +#endif + +} // namespace icamera diff --git a/src/icbm/ICBMTypes.h b/src/icbm/ICBMTypes.h index 50608679..cb64d6a5 100644 --- a/src/icbm/ICBMTypes.h +++ b/src/icbm/ICBMTypes.h @@ -36,10 +36,8 @@ struct ImageInfo { enum ICBMFeatureType { REQUEST_NONE = 0, LEVEL0_TNR = 1 << 1, -// LEVEL0_ICBM_S USER_FRAMING = 1 << 2, BC_MODE_BB = 1 << 3, -// LEVEL0_ICBM_E REQUEST_MAX = 1 << ICBM_REQUEST_MAX_SHIFT }; @@ -48,8 +46,6 @@ struct ICBMInitInfo { uint32_t sessionType; uint32_t height; uint32_t width; - int32_t libPathHandle; - char* libPath; }; struct ICBMReqInfo { diff --git a/src/icbm/IntelICBM.h b/src/icbm/IntelICBM.h new file mode 100644 index 00000000..69a53532 --- /dev/null +++ b/src/icbm/IntelICBM.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "src/icbm/ICBMTypes.h" + +namespace icamera { + +class IIntelICBM { + public: + virtual ~IIntelICBM() {} + + virtual int setup(void* initParams) = 0; + virtual void shutdown() = 0; + virtual int processFrame(const ImageInfo& iii, const ImageInfo& iio, + const ICBMReqInfo& reqInfo) = 0; +}; + +} // namespace icamera diff --git a/src/icbm/OnePunchIC2.cpp b/src/icbm/OnePunchIC2.cpp index 73f10c6f..c20ddb5c 100644 --- a/src/icbm/OnePunchIC2.cpp +++ b/src/icbm/OnePunchIC2.cpp @@ -31,7 +31,6 @@ namespace icamera { IntelOPIC2* IntelOPIC2::sInstance = nullptr; std::mutex IntelOPIC2::sLock; -// LEVEL0_ICBM_S void UserFramingBuilder::linkToMemoryChain(MemoryChainDescription& memoryChain) { memoryChain.linkIn("user_framing", "source:source", "drain:drain"); } @@ -39,14 +38,11 @@ void UserFramingBuilder::linkToMemoryChain(MemoryChainDescription& memoryChain) void BackgroundBlurBuilder::linkToMemoryChain(MemoryChainDescription& memoryChain) { memoryChain.linkIn("background_concealment", "in:source", "out:drain"); } -// LEVEL0_ICBM_E static const std::unordered_map gFeatureStrMapping = { - {ICBMFeatureType::LEVEL0_TNR, "tnr7us_l0"}, - // LEVEL0_ICBM_S {ICBMFeatureType::USER_FRAMING, "user_framing"}, {ICBMFeatureType::BC_MODE_BB, "background_concealment"}, - // LEVEL0_ICBM_E + {ICBMFeatureType::LEVEL0_TNR, "tnr7us_l0"}, }; IntelOPIC2* IntelOPIC2::getInstance() { @@ -98,7 +94,7 @@ int IntelOPIC2::setup(ICBMInitInfo* initParams, std::shared_ptr ha " @%s, request type: %d is already exist", initParams->cameraId, __func__, initParams->sessionType); - for (int feature = LEVEL0_TNR; feature < REQUEST_MAX; feature <<= 1) { + for (int feature = USER_FRAMING; feature < REQUEST_MAX; feature <<= 1) { if (!(initParams->sessionType & feature)) continue; const char* featureStr = gFeatureStrMapping.at(static_cast(feature)); if (strstr(supportedFeatures.c_str(), featureStr) == nullptr) { @@ -113,12 +109,10 @@ int IntelOPIC2::setup(ICBMInitInfo* initParams, std::shared_ptr ha mFeatureMap[key] = std::vector(); // we use the key value as the unique session id mSessionMap[key] = static_cast(key); - // LEVEL0_ICBM_S if (initParams->sessionType & ICBMFeatureType::USER_FRAMING) { iaic_options option{}; option.profiling = false; option.blocked_init = false; - option.external_device = nullptr; const char* featureStr = gFeatureStrMapping.at(ICBMFeatureType::USER_FRAMING); mIC2Api->create_session(mSessionMap[key], featureStr, option); mFeatureMap[key].push_back(featureStr); @@ -128,17 +122,14 @@ int IntelOPIC2::setup(ICBMInitInfo* initParams, std::shared_ptr ha iaic_options option{}; option.profiling = false; option.blocked_init = false; - option.external_device = nullptr; const char* featureStr = gFeatureStrMapping.at(ICBMFeatureType::BC_MODE_BB); mIC2Api->create_session(mSessionMap[key], featureStr, option); mFeatureMap[key].push_back(featureStr); } - // LEVEL0_ICBM_E if (initParams->sessionType & ICBMFeatureType::LEVEL0_TNR) { iaic_options option{}; option.profiling = true; option.blocked_init = true; - option.external_device = nullptr; const char* featureStr = gFeatureStrMapping.at(ICBMFeatureType::LEVEL0_TNR); mIC2Api->create_session(mSessionMap[key], featureStr, option); mFeatureMap[key].push_back(featureStr); @@ -196,8 +187,7 @@ int IntelOPIC2::runTnrFrame(const ICBMReqInfo& reqInfo) { const char* featureName = gFeatureStrMapping.at(ICBMFeatureType::LEVEL0_TNR); iaic_memory inMem, outMem; - - inMem.gfx = iaic_gfx_none; + inMem.has_gfx = false; inMem.size[0] = reqInfo.inII.size; inMem.size[1] = reqInfo.inII.width; inMem.size[2] = reqInfo.inII.height; @@ -266,12 +256,10 @@ int IntelOPIC2::runTnrFrame(const ICBMReqInfo& reqInfo) { sizeof(tnrParam->blend.max_recursive_similarity), featureName, "tnr7us/pal:max_recursive_similarity"); - if (mIC2Api->execute(mSessionMap[key], inMem, outMem)) { - mIC2Api->get_data(mSessionMap[key], outMem); - return OK; - } + int ret = mIC2Api->execute(mSessionMap[key], inMem, outMem); + mIC2Api->get_data(mSessionMap[key], outMem); - return UNKNOWN_ERROR; + return ret; } void IntelOPIC2::setData(iaic_session uid, void* p, size_t size, const char* featureName, @@ -288,7 +276,7 @@ void IntelOPIC2::setData(iaic_session uid, void* p, size_t size, const char* fea MemoryChainDescription IntelOPIC2::createMemoryChain(const ICBMReqInfo& reqInfo) { MemoryChainDescription mCD(reqInfo.inII, reqInfo.outII); - // LEVEL0_ICBM_S + if (reqInfo.reqType & ICBMFeatureType::USER_FRAMING) { UserFramingBuilder().linkToMemoryChain(mCD); } @@ -296,7 +284,6 @@ MemoryChainDescription IntelOPIC2::createMemoryChain(const ICBMReqInfo& reqInfo) if (reqInfo.reqType & ICBMFeatureType::BC_MODE_BB) { BackgroundBlurBuilder().linkToMemoryChain(mCD); } - // LEVEL0_ICBM_E if (reqInfo.reqType & ICBMFeatureType::LEVEL0_TNR) { mCD.linkIn(gFeatureStrMapping.at(ICBMFeatureType::LEVEL0_TNR), "in:source", "out:drain"); } diff --git a/src/icbm/OnePunchIC2.h b/src/icbm/OnePunchIC2.h index 7b43a37f..5fdad6db 100644 --- a/src/icbm/OnePunchIC2.h +++ b/src/icbm/OnePunchIC2.h @@ -29,7 +29,6 @@ namespace icamera { -// LEVEL0_ICBM_S struct IOPIC2Algorithm { virtual ~IOPIC2Algorithm() = default; virtual void linkToMemoryChain(MemoryChainDescription& memoryChain) = 0; @@ -50,7 +49,6 @@ class BackgroundBlurBuilder : public IOPIC2Algorithm { void linkToMemoryChain(MemoryChainDescription& memoryChain) override; }; -// LEVEL0_ICBM_E class IntelOPIC2 { public: diff --git a/src/iutils/CameraDump.cpp b/src/iutils/CameraDump.cpp index 2a9282b5..4376a22d 100644 --- a/src/iutils/CameraDump.cpp +++ b/src/iutils/CameraDump.cpp @@ -54,12 +54,6 @@ uint32_t gDumpRangeMax = 0; int gDumpFrequency = 1; char gDumpPath[50]; bool gDumpRangeEnabled = false; -int gDumpPatternEnabled = 0; -uint32_t gDumpPattern = 0xffffffff; -uint32_t gDumpPatternMask = 0xffffffff; -uint32_t gDumpPatternLineMin = 0; -uint32_t gDumpPatternLineMax = 0; -bool gDumpPatternLineEnabled = false; static const char* ModuleName[] = {"na", // not available "sensor", "isys", "psys", "de-inter", "swip-op", "gpu-tnr", "nvm", "mkn"}; // map to the ModuleType @@ -71,17 +65,6 @@ static const char* StreamUsage[] = { "app", }; // map to the StreamUsage -void CameraDump::parseRange(char* rangeStr, uint32_t* rangeMin, uint32_t* rangeMax) { - if (!rangeStr) return; - - std::string rangeArray(rangeStr); - size_t i = rangeArray.find_first_of(",~-"); - if (i != std::string::npos) { - *rangeMin = std::stoul(rangeArray.substr(0, i - 1)); - *rangeMax = std::stoul(rangeArray.substr(i + 1)); - } -} - void CameraDump::setDumpLevel(void) { const char* PROP_CAMERA_HAL_DUMP = "cameraDump"; const char* PROP_CAMERA_HAL_DUMP_FORMAT = "cameraDumpFormat"; @@ -89,10 +72,6 @@ void CameraDump::setDumpLevel(void) { const char* PROP_CAMERA_HAL_DUMP_SKIP_NUM = "cameraDumpSkipNum"; const char* PROP_CAMERA_HAL_DUMP_RANGE = "cameraDumpRange"; const char* PROP_CAMERA_HAL_DUMP_FREQUENCY = "cameraDumpFrequency"; - const char* PROP_CAMERA_HAL_DUMP_PATTERN_ENABLED = "cameraDumpPatternEnabled"; - const char* PROP_CAMERA_HAL_DUMP_PATTERN = "cameraDumpPattern"; - const char* PROP_CAMERA_HAL_DUMP_PATTERN_MASK = "cameraDumpPatternMask"; - const char* PROP_CAMERA_HAL_DUMP_PATTERN_RANGE = "cameraDumpPatternRange"; // dump, it's used to dump images or some parameters to a file. char* dumpType = getenv(PROP_CAMERA_HAL_DUMP); @@ -125,7 +104,18 @@ void CameraDump::setDumpLevel(void) { char* cameraDumpRange = getenv(PROP_CAMERA_HAL_DUMP_RANGE); if (cameraDumpRange) { - parseRange(cameraDumpRange, &gDumpRangeMin, &gDumpRangeMax); + int sz = strlen(cameraDumpRange); + char dumpRange[sz + 1]; + char *savePtr = nullptr, *tablePtr = nullptr; + MEMCPY_S(dumpRange, sz, cameraDumpRange, sz); + dumpRange[sz] = '\0'; + + tablePtr = strtok_r(dumpRange, ",~-", &savePtr); + if (tablePtr) gDumpRangeMin = strtoul(tablePtr, nullptr, 0); + + tablePtr = strtok_r(nullptr, ",~-", &savePtr); + if (tablePtr) gDumpRangeMax = strtoul(tablePtr, nullptr, 0); + gDumpRangeEnabled = true; LOG1("Dump range is %d-%d", gDumpRangeMin, gDumpRangeMax); } @@ -137,31 +127,6 @@ void CameraDump::setDumpLevel(void) { LOG1("Dump frequency is %d", gDumpFrequency); } - char* cameraDumpPatternEnabled = getenv(PROP_CAMERA_HAL_DUMP_PATTERN_ENABLED); - if (cameraDumpPatternEnabled) { - gDumpPatternEnabled = strtoul(cameraDumpPatternEnabled, nullptr, 0); - LOGI("Dump pattern enabled is %d", gDumpPatternEnabled); - } - - char* cameraDumpPattern = getenv(PROP_CAMERA_HAL_DUMP_PATTERN); - if (cameraDumpPattern) { - gDumpPattern = strtoul(cameraDumpPattern, nullptr, 0); - LOGI("Dump pattern is 0x%08x", gDumpPattern); - } - - char* cameraDumpPatternMask = getenv(PROP_CAMERA_HAL_DUMP_PATTERN_MASK); - if (cameraDumpPatternMask) { - gDumpPatternMask = strtoul(cameraDumpPatternMask, nullptr, 0); - LOGI("Dump pattern mask is 0x%08x", gDumpPatternMask); - } - - char* cameraDumpPatternRange = getenv(PROP_CAMERA_HAL_DUMP_PATTERN_RANGE); - if (cameraDumpPatternRange) { - parseRange(cameraDumpPatternRange, &gDumpPatternLineMin, &gDumpPatternLineMax); - gDumpPatternLineEnabled = true; - LOG1("Dump pattern range is line %d-%d", gDumpPatternLineMin, gDumpPatternLineMax); - } - // the PG dump is implemented in libiacss if (gDumpType & DUMP_PSYS_PG) { const char* PROP_CAMERA_CSS_DEBUG = "camera_css_debug"; @@ -421,26 +386,6 @@ static string formatBinFileName(int cameraId, const char* prefix, BinParam_t* bi return string(fileName); } -int CameraDump::checkPattern(void* data, int bufferSize, int w, int h, int stride) { - uint32_t val; - int lineStart = h - 1; - int lineEnd = h - 1; - - if (gDumpPatternLineEnabled && gDumpPatternLineMin < (uint32_t)h) - lineStart = gDumpPatternLineMin; - - if (gDumpPatternLineEnabled && gDumpPatternLineMax < (uint32_t)h) - lineEnd = gDumpPatternLineMax; - - for (; lineStart <= lineEnd; lineStart++) - for (int col = 0; col < w; col += sizeof(uint32_t)) { - val = *reinterpret_cast((unsigned char*)data + stride * lineStart + col); - if ((val & gDumpPatternMask) ^ gDumpPattern) return 0; - } - - return 1; -} - void CameraDump::dumpImage(int cameraId, const shared_ptr& camBuffer, ModuleType_t type, Port port, const char* desc) { CheckAndLogError(camBuffer == nullptr, VOID_VALUE, "invalid param"); @@ -469,15 +414,6 @@ void CameraDump::dumpImage(int cameraId, const shared_ptr& camBuff ScopeMapping mapper(camBuffer); void* pBuf = mapper.getUserPtr(); - - if (gDumpPatternEnabled) { - if (!checkPattern(pBuf, bufferSize, - camBuffer->getWidth(), - camBuffer->getHeight(), - camBuffer->getStride())) - return; - LOGI("@%s, dump pattern matched frame %d", __func__, camBuffer->getSequence()); - } LOG1("@%s, fd:%d, buffersize:%d, buf:%p, memoryType:%d, fileName:%s", __func__, fd, bufferSize, pBuf, memoryType, fileName.c_str()); writeData(pBuf, bufferSize, fileName.c_str()); diff --git a/src/iutils/CameraDump.h b/src/iutils/CameraDump.h index 08875277..b3679914 100644 --- a/src/iutils/CameraDump.h +++ b/src/iutils/CameraDump.h @@ -151,8 +151,6 @@ bool isDumpTypeEnable(int dumpType); bool isDumpFormatEnable(int dumpFormat); void writeData(const void* data, int size, const char* fileName); const char* getDumpPath(void); -void parseRange(char* rangeStr, uint32_t* rangeMin, uint32_t* rangeMax); -int checkPattern(void* data, int bufferSize, int w, int h, int stride); /** * Dump image according to CameraBuffer properties */ diff --git a/src/iutils/CameraLog.cpp b/src/iutils/CameraLog.cpp index bd3100e7..84e23705 100644 --- a/src/iutils/CameraLog.cpp +++ b/src/iutils/CameraLog.cpp @@ -29,7 +29,9 @@ #include #endif +#ifdef CAMERA_SYS_LOG #include +#endif #include "CameraLog.h" #include "Trace.h" @@ -91,6 +93,7 @@ __attribute__((__format__(__printf__, 3, 0))) static void printLog(const char* m } #endif +#ifdef CAMERA_SYS_LOG __attribute__((__format__(__printf__, 3, 0))) static void printLog(const char* module, int level, const char* fmt, va_list ap) { const char* levelStr = nullptr; @@ -133,6 +136,34 @@ __attribute__((__format__(__printf__, 3, 0))) static void printLog(const char* m vsyslog(priority, format, ap); closelog(); } +#endif + +static void getLogTime(char* timeBuf, int bufLen) { + // The format of time is: 01-22 15:24:53.071 + struct timeval tv; + gettimeofday(&tv, nullptr); + time_t nowtime = tv.tv_sec; + struct tm* nowtm = localtime(&nowtime); + if (nowtm) { // If nowtm is nullptr, simply print nothing for time info + char tmbuf[bufLen]; + CLEAR(tmbuf); + strftime(tmbuf, bufLen, "%m-%d %H:%M:%S", nowtm); + snprintf(timeBuf, bufLen, "%s.%03ld", tmbuf, tv.tv_usec / 1000); + } +} + +__attribute__((__format__(__printf__, 3, 0))) static void printLog(const char* module, int level, + const char* fmt, va_list ap) { + // Add time into beginning of the log. + const int BUF_LEN = 64; + char timeBuf[BUF_LEN] = {'\0'}; + + getLogTime(timeBuf, BUF_LEN); + + fprintf(stdout, "%s: [%s]: CamHAL_%s:", timeBuf, cameraDebugLogToString(level), module); + vfprintf(stdout, fmt, ap); + fprintf(stdout, "\n"); +} void doLogBody(int logTag, int level, int grpPosition, const char* fmt, ...) { if (!(level & globalGroupsDescp[grpPosition].level)) return; @@ -162,7 +193,6 @@ namespace Log { #define DEFAULT_LOG_SINK "GLOG" #define FILELOG_SINK "FILELOG" -#define SYSLOG_SINK "SYSLOG" static void initLogSinks() { #ifdef CAL_BUILD @@ -181,20 +211,23 @@ static void initLogSinks() { } #endif +#ifdef CAMERA_SYS_LOG const char* sinkName = ::getenv("logSink"); if (!sinkName) { sinkName = DEFAULT_LOG_SINK; } - if (!::strcmp(sinkName, SYSLOG_SINK)) { + if (!::strcmp(sinkName, DEFAULT_LOG_SINK)) { globalLogSink = new SysLogSink(); } else if (!::strcmp(sinkName, FILELOG_SINK)) { globalLogSink = new FileLogSink; } else { globalLogSink = new StdconLogSink(); } +#endif + globalLogSink = new StdconLogSink(); } static void setLogTagLevel() { diff --git a/src/iutils/LogSink.cpp b/src/iutils/LogSink.cpp index 3311307b..19dc6e34 100644 --- a/src/iutils/LogSink.cpp +++ b/src/iutils/LogSink.cpp @@ -30,10 +30,12 @@ #include "iutils/LogSink.h" #include "iutils/Utils.h" +#ifdef CAMERA_SYS_LOG #include #include #include #include +#endif namespace icamera { extern const char* cameraDebugLogToString(int level); #define CAMERA_DEBUG_LOG_ERR (1 << 5) @@ -128,8 +130,6 @@ const char* FileLogSink::getName() const { } void FileLogSink::sendOffLog(LogItem logItem) { - if (mFp == nullptr) return; - char timeInfo[TIME_BUF_SIZE]; setLogTime(timeInfo); fprintf(mFp, "[%s] CamHAL[%s] %s:%s\n", timeInfo, @@ -137,10 +137,7 @@ void FileLogSink::sendOffLog(LogItem logItem) { fflush(mFp); } -FileLogSink::~FileLogSink() { - if (mFp) fclose(mFp); -} - +#ifdef CAMERA_SYS_LOG SysLogSink::SysLogSink() {} SysLogSink::~SysLogSink() {} @@ -164,5 +161,6 @@ void SysLogSink::sendOffLog(LogItem logItem) { syslog(levelMap[levelStr], "%s", logMsg); closelog(); } +#endif }; // namespace icamera diff --git a/src/iutils/LogSink.h b/src/iutils/LogSink.h index 67319c91..edf507b4 100644 --- a/src/iutils/LogSink.h +++ b/src/iutils/LogSink.h @@ -62,6 +62,7 @@ class StdconLogSink : public LogOutputSink { void sendOffLog(LogItem logItem) override; }; +#ifdef CAMERA_SYS_LOG class SysLogSink : public LogOutputSink { public: SysLogSink(); @@ -69,11 +70,11 @@ class SysLogSink : public LogOutputSink { const char* getName() const override; void sendOffLog(LogItem logItem) override; }; +#endif class FileLogSink : public LogOutputSink { public: FileLogSink(); - ~FileLogSink(); const char* getName() const override; void sendOffLog(LogItem logItem) override; diff --git a/src/iutils/ModuleTags.cpp b/src/iutils/ModuleTags.cpp index 03d8e528..bba451f5 100644 --- a/src/iutils/ModuleTags.cpp +++ b/src/iutils/ModuleTags.cpp @@ -79,7 +79,6 @@ const char* tagNames[] = { "Customized3A", "CustomizedAic", "CvfPrivacyChecker", - "DLCClient", "DeviceBase", "Dvs", "EXIFMaker", diff --git a/src/iutils/ModuleTags.h b/src/iutils/ModuleTags.h index d783e80d..e7aca700 100644 --- a/src/iutils/ModuleTags.h +++ b/src/iutils/ModuleTags.h @@ -87,144 +87,143 @@ enum ModuleTags { GENERATED_TAGS_Customized3A = 57, GENERATED_TAGS_CustomizedAic = 58, GENERATED_TAGS_CvfPrivacyChecker = 59, - GENERATED_TAGS_DLCClient = 60, - GENERATED_TAGS_DeviceBase = 61, - GENERATED_TAGS_Dvs = 62, - GENERATED_TAGS_EXIFMaker = 63, - GENERATED_TAGS_EXIFMetaData = 64, - GENERATED_TAGS_ExifCreater = 65, - GENERATED_TAGS_FaceDetection = 66, - GENERATED_TAGS_FaceDetectionPVL = 67, - GENERATED_TAGS_FaceDetectionResultCallbackManager = 68, - GENERATED_TAGS_FaceSSD = 69, - GENERATED_TAGS_FileSource = 70, - GENERATED_TAGS_GPUExecutor = 71, - GENERATED_TAGS_GenGfx = 72, - GENERATED_TAGS_GfxGen = 73, - GENERATED_TAGS_GraphConfig = 74, - GENERATED_TAGS_GraphConfigImpl = 75, - GENERATED_TAGS_GraphConfigImplClient = 76, - GENERATED_TAGS_GraphConfigManager = 77, - GENERATED_TAGS_GraphConfigPipe = 78, - GENERATED_TAGS_GraphConfigServer = 79, - GENERATED_TAGS_GraphUtils = 80, - GENERATED_TAGS_HAL_FACE_DETECTION_TEST = 81, - GENERATED_TAGS_HAL_basic = 82, - GENERATED_TAGS_HAL_jpeg = 83, - GENERATED_TAGS_HAL_multi_streams_test = 84, - GENERATED_TAGS_HAL_rotation_test = 85, - GENERATED_TAGS_HAL_yuv = 86, - GENERATED_TAGS_HalAdaptor = 87, - GENERATED_TAGS_HalV3Utils = 88, - GENERATED_TAGS_I3AControlFactory = 89, - GENERATED_TAGS_IA_CIPR_UTILS = 90, - GENERATED_TAGS_ICBMThread = 91, - GENERATED_TAGS_ICamera = 92, - GENERATED_TAGS_IFaceDetection = 93, - GENERATED_TAGS_IPCIntelPGParam = 94, - GENERATED_TAGS_IPC_FACE_DETECTION = 95, - GENERATED_TAGS_IPC_GRAPH_CONFIG = 96, - GENERATED_TAGS_ImageProcessorCore = 97, - GENERATED_TAGS_ImageScalerCore = 98, - GENERATED_TAGS_Intel3AParameter = 99, - GENERATED_TAGS_IntelAEStateMachine = 100, - GENERATED_TAGS_IntelAFStateMachine = 101, - GENERATED_TAGS_IntelAWBStateMachine = 102, - GENERATED_TAGS_IntelAlgoClient = 103, - GENERATED_TAGS_IntelAlgoCommonClient = 104, - GENERATED_TAGS_IntelAlgoServer = 105, - GENERATED_TAGS_IntelCPUAlgoServer = 106, - GENERATED_TAGS_IntelCca = 107, - GENERATED_TAGS_IntelCcaClient = 108, - GENERATED_TAGS_IntelCcaServer = 109, - GENERATED_TAGS_IntelFDServer = 110, - GENERATED_TAGS_IntelFaceDetection = 111, - GENERATED_TAGS_IntelFaceDetectionClient = 112, - GENERATED_TAGS_IntelGPUAlgoServer = 113, - GENERATED_TAGS_IntelICBM = 114, - GENERATED_TAGS_IntelICBMClient = 115, - GENERATED_TAGS_IntelICBMServer = 116, - GENERATED_TAGS_IntelPGParam = 117, - GENERATED_TAGS_IntelPGParamClient = 118, - GENERATED_TAGS_IntelPGParamS = 119, - GENERATED_TAGS_IntelTNR7US = 120, - GENERATED_TAGS_IntelTNR7USClient = 121, - GENERATED_TAGS_IntelTNRServer = 122, - GENERATED_TAGS_IspControlUtils = 123, - GENERATED_TAGS_IspParamAdaptor = 124, - GENERATED_TAGS_JpegEncoderCore = 125, - GENERATED_TAGS_JpegMaker = 126, - GENERATED_TAGS_LensHw = 127, - GENERATED_TAGS_LensManager = 128, - GENERATED_TAGS_LiveTuning = 129, - GENERATED_TAGS_Ltm = 130, - GENERATED_TAGS_MANUAL_POST_PROCESSING = 131, - GENERATED_TAGS_MakerNote = 132, - GENERATED_TAGS_MediaControl = 133, - GENERATED_TAGS_MetadataConvert = 134, - GENERATED_TAGS_MockCamera3HAL = 135, - GENERATED_TAGS_MockCameraHal = 136, - GENERATED_TAGS_MockSysCall = 137, - GENERATED_TAGS_MsgHandler = 138, - GENERATED_TAGS_OnePunchIC2 = 139, - GENERATED_TAGS_OpenSourceGFX = 140, - GENERATED_TAGS_PGCommon = 141, - GENERATED_TAGS_PGUtils = 142, - GENERATED_TAGS_PSysDAG = 143, - GENERATED_TAGS_PSysPipe = 144, - GENERATED_TAGS_PSysProcessor = 145, - GENERATED_TAGS_ParameterGenerator = 146, - GENERATED_TAGS_ParameterHelper = 147, - GENERATED_TAGS_ParameterResult = 148, - GENERATED_TAGS_Parameters = 149, - GENERATED_TAGS_ParserBase = 150, - GENERATED_TAGS_PipeExecutor = 151, - GENERATED_TAGS_PipeLiteExecutor = 152, - GENERATED_TAGS_PlatformData = 153, - GENERATED_TAGS_PnpDebugControl = 154, - GENERATED_TAGS_PolicyParser = 155, - GENERATED_TAGS_PostProcessor = 156, - GENERATED_TAGS_PostProcessorBase = 157, - GENERATED_TAGS_PostProcessorCore = 158, - GENERATED_TAGS_PrivacyControl = 159, - GENERATED_TAGS_PrivateStream = 160, - GENERATED_TAGS_ProcessorManager = 161, - GENERATED_TAGS_RequestManager = 162, - GENERATED_TAGS_RequestThread = 163, - GENERATED_TAGS_ResultProcessor = 164, - GENERATED_TAGS_SWJpegEncoder = 165, - GENERATED_TAGS_SWPostProcessor = 166, - GENERATED_TAGS_SchedPolicy = 167, - GENERATED_TAGS_Scheduler = 168, - GENERATED_TAGS_SensorHwCtrl = 169, - GENERATED_TAGS_SensorManager = 170, - GENERATED_TAGS_SensorOB = 171, - GENERATED_TAGS_ShareRefer = 172, - GENERATED_TAGS_SofSource = 173, - GENERATED_TAGS_StreamBuffer = 174, - GENERATED_TAGS_SwImageConverter = 175, - GENERATED_TAGS_SwImageProcessor = 176, - GENERATED_TAGS_SyncManager = 177, - GENERATED_TAGS_SysCall = 178, - GENERATED_TAGS_TCPServer = 179, - GENERATED_TAGS_Thread = 180, - GENERATED_TAGS_Trace = 181, - GENERATED_TAGS_TunningParser = 182, - GENERATED_TAGS_Utils = 183, - GENERATED_TAGS_V4l2DeviceFactory = 184, - GENERATED_TAGS_V4l2_device_cc = 185, - GENERATED_TAGS_V4l2_subdevice_cc = 186, - GENERATED_TAGS_V4l2_video_node_cc = 187, - GENERATED_TAGS_VendorTags = 188, - GENERATED_TAGS_camera_metadata_tests = 189, - GENERATED_TAGS_icamera_metadata_base = 190, - GENERATED_TAGS_metadata_test = 191, - ST_FPS = 192, - ST_GPU_TNR = 193, - ST_STATS = 194, + GENERATED_TAGS_DeviceBase = 60, + GENERATED_TAGS_Dvs = 61, + GENERATED_TAGS_EXIFMaker = 62, + GENERATED_TAGS_EXIFMetaData = 63, + GENERATED_TAGS_ExifCreater = 64, + GENERATED_TAGS_FaceDetection = 65, + GENERATED_TAGS_FaceDetectionPVL = 66, + GENERATED_TAGS_FaceDetectionResultCallbackManager = 67, + GENERATED_TAGS_FaceSSD = 68, + GENERATED_TAGS_FileSource = 69, + GENERATED_TAGS_GPUExecutor = 70, + GENERATED_TAGS_GenGfx = 71, + GENERATED_TAGS_GfxGen = 72, + GENERATED_TAGS_GraphConfig = 73, + GENERATED_TAGS_GraphConfigImpl = 74, + GENERATED_TAGS_GraphConfigImplClient = 75, + GENERATED_TAGS_GraphConfigManager = 76, + GENERATED_TAGS_GraphConfigPipe = 77, + GENERATED_TAGS_GraphConfigServer = 78, + GENERATED_TAGS_GraphUtils = 79, + GENERATED_TAGS_HAL_FACE_DETECTION_TEST = 80, + GENERATED_TAGS_HAL_basic = 81, + GENERATED_TAGS_HAL_jpeg = 82, + GENERATED_TAGS_HAL_multi_streams_test = 83, + GENERATED_TAGS_HAL_rotation_test = 84, + GENERATED_TAGS_HAL_yuv = 85, + GENERATED_TAGS_HalAdaptor = 86, + GENERATED_TAGS_HalV3Utils = 87, + GENERATED_TAGS_I3AControlFactory = 88, + GENERATED_TAGS_IA_CIPR_UTILS = 89, + GENERATED_TAGS_ICBMThread = 90, + GENERATED_TAGS_ICamera = 91, + GENERATED_TAGS_IFaceDetection = 92, + GENERATED_TAGS_IPCIntelPGParam = 93, + GENERATED_TAGS_IPC_FACE_DETECTION = 94, + GENERATED_TAGS_IPC_GRAPH_CONFIG = 95, + GENERATED_TAGS_ImageProcessorCore = 96, + GENERATED_TAGS_ImageScalerCore = 97, + GENERATED_TAGS_Intel3AParameter = 98, + GENERATED_TAGS_IntelAEStateMachine = 99, + GENERATED_TAGS_IntelAFStateMachine = 100, + GENERATED_TAGS_IntelAWBStateMachine = 101, + GENERATED_TAGS_IntelAlgoClient = 102, + GENERATED_TAGS_IntelAlgoCommonClient = 103, + GENERATED_TAGS_IntelAlgoServer = 104, + GENERATED_TAGS_IntelCPUAlgoServer = 105, + GENERATED_TAGS_IntelCca = 106, + GENERATED_TAGS_IntelCcaClient = 107, + GENERATED_TAGS_IntelCcaServer = 108, + GENERATED_TAGS_IntelFDServer = 109, + GENERATED_TAGS_IntelFaceDetection = 110, + GENERATED_TAGS_IntelFaceDetectionClient = 111, + GENERATED_TAGS_IntelGPUAlgoServer = 112, + GENERATED_TAGS_IntelICBM = 113, + GENERATED_TAGS_IntelICBMClient = 114, + GENERATED_TAGS_IntelICBMServer = 115, + GENERATED_TAGS_IntelPGParam = 116, + GENERATED_TAGS_IntelPGParamClient = 117, + GENERATED_TAGS_IntelPGParamS = 118, + GENERATED_TAGS_IntelTNR7US = 119, + GENERATED_TAGS_IntelTNR7USClient = 120, + GENERATED_TAGS_IntelTNRServer = 121, + GENERATED_TAGS_IspControlUtils = 122, + GENERATED_TAGS_IspParamAdaptor = 123, + GENERATED_TAGS_JpegEncoderCore = 124, + GENERATED_TAGS_JpegMaker = 125, + GENERATED_TAGS_LensHw = 126, + GENERATED_TAGS_LensManager = 127, + GENERATED_TAGS_LiveTuning = 128, + GENERATED_TAGS_Ltm = 129, + GENERATED_TAGS_MANUAL_POST_PROCESSING = 130, + GENERATED_TAGS_MakerNote = 131, + GENERATED_TAGS_MediaControl = 132, + GENERATED_TAGS_MetadataConvert = 133, + GENERATED_TAGS_MockCamera3HAL = 134, + GENERATED_TAGS_MockCameraHal = 135, + GENERATED_TAGS_MockSysCall = 136, + GENERATED_TAGS_MsgHandler = 137, + GENERATED_TAGS_OnePunchIC2 = 138, + GENERATED_TAGS_OpenSourceGFX = 139, + GENERATED_TAGS_PGCommon = 140, + GENERATED_TAGS_PGUtils = 141, + GENERATED_TAGS_PSysDAG = 142, + GENERATED_TAGS_PSysPipe = 143, + GENERATED_TAGS_PSysProcessor = 144, + GENERATED_TAGS_ParameterGenerator = 145, + GENERATED_TAGS_ParameterHelper = 146, + GENERATED_TAGS_ParameterResult = 147, + GENERATED_TAGS_Parameters = 148, + GENERATED_TAGS_ParserBase = 149, + GENERATED_TAGS_PipeExecutor = 150, + GENERATED_TAGS_PipeLiteExecutor = 151, + GENERATED_TAGS_PlatformData = 152, + GENERATED_TAGS_PnpDebugControl = 153, + GENERATED_TAGS_PolicyParser = 154, + GENERATED_TAGS_PostProcessor = 155, + GENERATED_TAGS_PostProcessorBase = 156, + GENERATED_TAGS_PostProcessorCore = 157, + GENERATED_TAGS_PrivacyControl = 158, + GENERATED_TAGS_PrivateStream = 159, + GENERATED_TAGS_ProcessorManager = 160, + GENERATED_TAGS_RequestManager = 161, + GENERATED_TAGS_RequestThread = 162, + GENERATED_TAGS_ResultProcessor = 163, + GENERATED_TAGS_SWJpegEncoder = 164, + GENERATED_TAGS_SWPostProcessor = 165, + GENERATED_TAGS_SchedPolicy = 166, + GENERATED_TAGS_Scheduler = 167, + GENERATED_TAGS_SensorHwCtrl = 168, + GENERATED_TAGS_SensorManager = 169, + GENERATED_TAGS_SensorOB = 170, + GENERATED_TAGS_ShareRefer = 171, + GENERATED_TAGS_SofSource = 172, + GENERATED_TAGS_StreamBuffer = 173, + GENERATED_TAGS_SwImageConverter = 174, + GENERATED_TAGS_SwImageProcessor = 175, + GENERATED_TAGS_SyncManager = 176, + GENERATED_TAGS_SysCall = 177, + GENERATED_TAGS_TCPServer = 178, + GENERATED_TAGS_Thread = 179, + GENERATED_TAGS_Trace = 180, + GENERATED_TAGS_TunningParser = 181, + GENERATED_TAGS_Utils = 182, + GENERATED_TAGS_V4l2DeviceFactory = 183, + GENERATED_TAGS_V4l2_device_cc = 184, + GENERATED_TAGS_V4l2_subdevice_cc = 185, + GENERATED_TAGS_V4l2_video_node_cc = 186, + GENERATED_TAGS_VendorTags = 187, + GENERATED_TAGS_camera_metadata_tests = 188, + GENERATED_TAGS_icamera_metadata_base = 189, + GENERATED_TAGS_metadata_test = 190, + ST_FPS = 191, + ST_GPU_TNR = 192, + ST_STATS = 193, }; -#define TAGS_MAX_NUM 195 +#define TAGS_MAX_NUM 194 #endif // !!! DO NOT EDIT THIS FILE !!! diff --git a/src/iutils/Utils.cpp b/src/iutils/Utils.cpp index 8c60930c..2efa9c10 100644 --- a/src/iutils/Utils.cpp +++ b/src/iutils/Utils.cpp @@ -595,12 +595,8 @@ void CameraUtils::getDeviceName(const char* entityName, string& deviceNodeName, subDeviceName += dirp->d_name; subDeviceName += "/name"; int fd = open(subDeviceName.c_str(), O_RDONLY); - if (fd < 0) { - LOGE("@%s, open file %s failed. err: %s", __func__, subDeviceName.c_str(), - strerror(errno)); - closedir(dp); - return; - } + CheckAndLogError((fd < 0), VOID_VALUE, "@%s, open file %s failed. err: %s", __func__, + subDeviceName.c_str(), strerror(errno)); char buf[128] = {'\0'}; int len = read(fd, buf, sizeof(buf)); @@ -815,10 +811,10 @@ void* CameraUtils::dlopenLibrary(const char* name, int flags) { const char* lError = dlerror(); if (lError) { - LOGW("%s, dlopen Error: %s", __func__, lError); - if (handle) { - dlclose(handle); + if (handle == nullptr) { + LOGW("%s, handle is NULL", __func__); } + LOGW("%s, dlopen Error: %s", __func__, lError); return nullptr; } diff --git a/src/iutils/Utils.h b/src/iutils/Utils.h index 388d017b..37396bf6 100644 --- a/src/iutils/Utils.h +++ b/src/iutils/Utils.h @@ -127,18 +127,6 @@ typedef ::cros::V4L2Format V4L2Format; } \ } while (0) -/** - * Used to check input parameters, if unsuccessful, returns err_code and prints a log1 message, - * which applies to error checking without substance. - */ -#define CheckAndLog1(condition, err_code, err_msg, args...) \ - do { \ - if (condition) { \ - LOG1(err_msg, ##args); \ - return err_code; \ - } \ - } while (0) - // macro delete array and set it to null #define DELETE_ARRAY_AND_NULLIFY(var) \ do { \ diff --git a/src/jpeg/CMakeLists.txt b/src/jpeg/CMakeLists.txt new file mode 100644 index 00000000..409f472e --- /dev/null +++ b/src/jpeg/CMakeLists.txt @@ -0,0 +1,35 @@ +# +# Copyright (C) 2019 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if (SW_JPEG_ENCODE) + set(JPEG_SRCS + ${JPEG_DIR}/sw/SWJpegEncoder.cpp + CACHE INTERNAL "jpeg sources" + ) +else () + set(JPEG_SRCS + ${JPEG_DIR}/chrome/JpegEncoderCore.cpp + CACHE INTERNAL "jpeg sources" + ) +endif() + +set(JPEG_SRCS + ${JPEG_SRCS} + ${JPEG_DIR}/ExifCreater.cpp + ${JPEG_DIR}/EXIFMetaData.cpp + ${JPEG_DIR}/EXIFMaker.cpp + ${JPEG_DIR}/JpegMaker.cpp + CACHE INTERNAL "jpeg sources" + ) diff --git a/src/jpeg/EXIFMaker.cpp b/src/jpeg/EXIFMaker.cpp new file mode 100644 index 00000000..77e6fb95 --- /dev/null +++ b/src/jpeg/EXIFMaker.cpp @@ -0,0 +1,617 @@ +/* + * Copyright (C) 2016-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG EXIFMaker + +#include "EXIFMaker.h" + +#include + +#include +#include +#include + +#include "ParameterHelper.h" +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +#define DEFAULT_ISO_SPEED 100 + +// The property file directory +static const char* CAMERA_CACHE_DIR = "/var/cache/camera/"; +/* + * Property file defines product name and manufactory info + * Used for EXIF header of JPEG. Format: key=value in each line + */ +static const char* CAMERA_PROPERTY_FILE = "camera.prop"; + +EXIFMaker::EXIFMaker() + : mExifSize(-1), + mInitialized(false), + mProductName(""), + mManufacturerName("") { + LOG1("@%s", __func__); + + CLEAR(mExifAttributes); + mMakernoteSection = new unsigned char[MAKERNOTE_SECTION1_SIZE + MAKERNOTE_SECTION2_SIZE]; + readProperty(); +} + +EXIFMaker::~EXIFMaker() { + LOG1("@%s", __func__); + delete[] mMakernoteSection; +} + +void EXIFMaker::readProperty() { + LOG2("@%s", __func__); + std::string cameraPropertyPath = + std::string(CAMERA_CACHE_DIR) + std::string(CAMERA_PROPERTY_FILE); + std::fstream props(cameraPropertyPath.c_str(), std::ios::in); + + if (!props.is_open()) { + LOG2("There isn't camera property file."); + return; + } + + const std::string kModel = "ro.product.model"; + const std::string kManufacturer = "ro.product.manufacturer"; + const std::string kDelimiter = "="; + std::unordered_map properties; + + while (!props.eof()) { + size_t pos; + std::string line, key, value; + + std::getline(props, line); + pos = line.find(kDelimiter); + if (pos != std::string::npos) { + key = line.substr(0, pos); + value = line.substr(pos + 1); + properties[key] = value; + LOG2("%s, new key,value: %s,%s", __func__, key.c_str(), value.c_str()); + } + } + + if (properties.find(kManufacturer) != properties.end()) { + mManufacturerName = properties[kManufacturer]; + } + if (properties.find(kModel) != properties.end()) { + mProductName = properties[kModel]; + } +} + +/** + * Fills EXIF data after a picture has been taken to + * record the active sensor, 3A and ISP state to EXIF metadata. + * + * This function is intented to set EXIF tags belonging + * to the EXIF "Per Picture Camera Setting" group. + * + * @arg params active Android HAL parameters + */ +void EXIFMaker::pictureTaken(ExifMetaData* exifmetadata) { + LOG2("@%s", __func__); + + mExifAttributes.contrast = 0; + mExifAttributes.saturation = 0; + mExifAttributes.sharpness = 0; + LOG2("EXIF: contrast=%d, saturation=%d, sharpness=%d (0:normal 1:low 2:high)", + mExifAttributes.contrast, mExifAttributes.saturation, mExifAttributes.sharpness); + + // set the exposure program mode + icamera::camera_ae_mode_t aeMode = exifmetadata->aeMode; + switch (aeMode) { + case AE_MODE_MANUAL: + mExifAttributes.exposure_program = EXIF_EXPOSURE_PROGRAM_MANUAL; + mExifAttributes.exposure_mode = EXIF_EXPOSURE_MANUAL; + LOG2("EXIF: Exposure Program = Manual, Exposure Mode = Manual"); + break; + case AE_MODE_AUTO: + default: + mExifAttributes.exposure_program = EXIF_EXPOSURE_PROGRAM_NORMAL; + mExifAttributes.exposure_mode = EXIF_EXPOSURE_AUTO; + LOG2("EXIF: Exposure Program = Normal, Exposure Mode = Auto"); + break; + } + + mExifAttributes.metering_mode = EXIF_METERING_AVERAGE; + + // white balance mode. 0: auto; 1: manual + icamera::camera_awb_mode_t awbMode = exifmetadata->awbMode; + LOG2("EXIF: awbMode = %d", awbMode); + switch (awbMode) { + case AWB_MODE_AUTO: + case AWB_MODE_MAX: + mExifAttributes.white_balance = EXIF_WB_AUTO; + break; + default: + mExifAttributes.white_balance = EXIF_WB_MANUAL; + break; + } + + // light source type. Refer to EXIF V2.2 + // TBD. Now light source is only set to UNKNOWN, when WB is auto mode. + std::unordered_map awbModeLightMap = { + {AWB_MODE_AUTO, EXIF_LIGHT_SOURCE_UNKNOWN}, + {AWB_MODE_SUNSET, EXIF_LIGHT_SOURCE_TUNGSTEN}, + {AWB_MODE_DAYLIGHT, EXIF_LIGHT_SOURCE_FINE_WEATHER}, + {AWB_MODE_PARTLY_OVERCAST, EXIF_LIGHT_SOURCE_CLOUDY_WEATHER}, + {AWB_MODE_FLUORESCENT, EXIF_LIGHT_SOURCE_FLUORESCENT}, + {AWB_MODE_INCANDESCENT, EXIF_LIGHT_SOURCE_TUNGSTEN}, + {AWB_MODE_MAX, EXIF_LIGHT_SOURCE_OTHER_LIGHT_SOURCE}, + }; + if (awbModeLightMap.find(awbMode) != awbModeLightMap.end()) { + mExifAttributes.light_source = awbModeLightMap[awbMode]; + } else { + mExifAttributes.light_source = EXIF_LIGHT_SOURCE_UNKNOWN; + } + + mExifAttributes.scene_capture_type = EXIF_SCENE_STANDARD; + + int rotation = exifmetadata->mJpegSetting.orientation; + mExifAttributes.orientation = EXIF_ORIENTATION_UP; + if (0 == rotation) + mExifAttributes.orientation = EXIF_ORIENTATION_UP; + else if (90 == rotation) + mExifAttributes.orientation = EXIF_ORIENTATION_90; + else if (180 == rotation) + mExifAttributes.orientation = EXIF_ORIENTATION_180; + else if (270 == rotation) + mExifAttributes.orientation = EXIF_ORIENTATION_270; + + // Platform has no HW rotation. No swap here + // if (rotation % 180 == 90) + // swap(mExifAttributes.width, mExifAttributes.height); + + mExifAttributes.zoom_ratio.num = exifmetadata->zoomRatio; + mExifAttributes.zoom_ratio.den = 100; + // the unit of subjectDistance is meter, focus distance from 3A is mm. + mExifAttributes.subject_distance.num = + static_cast(exifmetadata->currentFocusDistance); + mExifAttributes.subject_distance.den = 1000; + mExifAttributes.custom_rendered = + exifmetadata->hdr ? EXIF_CUSTOM_RENDERED_HDR : EXIF_DEF_CUSTOM_RENDERED; + LOG2("subject_distance is %d", mExifAttributes.subject_distance.num); +} + +/** + * Called when the the camera static configuration is known. + * + * @arg width: width of the main JPEG picture. + * @arg height: height of the main JPEG picture. + */ +void EXIFMaker::initialize(int width, int height) { + /* We clear the exif attributes, so we won't be using some old values + * from a previous EXIF generation. + */ + clear(); + + // Initialize the mExifAttributes with specific values + // time information + time_t rawtime; + struct tm* timeinfo; + time(&rawtime); + timeinfo = localtime(&rawtime); + if (timeinfo) { + strftime(reinterpret_cast(mExifAttributes.date_time), + sizeof(mExifAttributes.date_time), "%Y:%m:%d %H:%M:%S", timeinfo); + // fields: tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday, tm_yday, tm_isdst, + // tm_gmtoff, tm_zone + } else { + LOGW("nullptr timeinfo from localtime(), using defaults..."); + struct tm tmpTime = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "UTC"}; + strftime(reinterpret_cast(mExifAttributes.date_time), + sizeof(mExifAttributes.date_time), "%Y:%m:%d %H:%M:%S", &tmpTime); + } + + // set default subsec time to 1000 + const char subsecTime[] = "1000"; + MEMCPY_S(reinterpret_cast(mExifAttributes.subsec_time), + sizeof(mExifAttributes.subsec_time), subsecTime, sizeof(subsecTime)); + + // conponents configuration. + // Default = 4 5 6 0(if RGB uncompressed), 1 2 3 0(other cases) + // 0 = does not exist; 1 = Y; 2 = Cb; 3 = Cr; 4 = R; 5 = G; 6 = B; other = reserved + mExifAttributes.components_configuration[0] = 1; + mExifAttributes.components_configuration[1] = 2; + mExifAttributes.components_configuration[2] = 3; + mExifAttributes.components_configuration[3] = 0; + + // set default values for fnumber and focal length + // (see EXIFMaker::setDriverData() how to override these) + mExifAttributes.fnumber.num = EXIF_DEF_FNUMBER_NUM; + mExifAttributes.fnumber.den = EXIF_DEF_FNUMBER_DEN; + mExifAttributes.focal_length.num = EXIF_DEF_FOCAL_LEN_NUM; + mExifAttributes.focal_length.den = EXIF_DEF_FOCAL_LEN_DEN; + + mExifAttributes.iso_speed_rating = DEFAULT_ISO_SPEED; + + mExifAttributes.aperture.den = EXIF_DEF_APEX_DEN; + mExifAttributes.aperture.num = EXIF_DEF_APEX_NUM; + // max aperture. the smallest F number of the lens. unit is APEX value. + mExifAttributes.max_aperture.num = mExifAttributes.aperture.num; + mExifAttributes.max_aperture.den = mExifAttributes.aperture.den; + + // subject distance, 0 means distance unknown; (~0) means infinity. + mExifAttributes.subject_distance.num = EXIF_DEF_SUBJECT_DISTANCE_UNKNOWN; + mExifAttributes.subject_distance.den = 1; + + // light source, 0 means light source unknown + mExifAttributes.light_source = 0; + + // gain control, 0 = none; + // 1 = low gain up; 2 = high gain up; 3 = low gain down; 4 = high gain down + mExifAttributes.gain_control = 0; + + // contrast, 0 = normal; 1 = soft; 2 = hard; other = reserved + mExifAttributes.contrast = EXIF_CONTRAST_NORMAL; + + // saturation, 0 = normal; 1 = Low saturation; 2 = High saturation; other = reserved + mExifAttributes.saturation = EXIF_SATURATION_NORMAL; + + // sharpness, 0 = normal; 1 = soft; 2 = hard; other = reserved + mExifAttributes.sharpness = EXIF_SHARPNESS_NORMAL; + + // the picture's width and height + mExifAttributes.width = width; + mExifAttributes.height = height; + + mExifAttributes.orientation = 1; + + mExifAttributes.custom_rendered = EXIF_DEF_CUSTOM_RENDERED; + + // metering mode, 0 = normal; 1 = soft; 2 = hard; other = reserved + mExifAttributes.metering_mode = EXIF_METERING_UNKNOWN; + mInitialized = true; +} + +void EXIFMaker::initializeLocation(ExifMetaData* metadata) { + // GIS information + bool gpsEnabled = false; + double latitude = metadata->mGpsSetting.latitude; + double longitude = metadata->mGpsSetting.longitude; + double altitude = metadata->mGpsSetting.altitude; + long timestamp = metadata->mGpsSetting.gpsTimeStamp; + char* pprocmethod = metadata->mGpsSetting.gpsProcessingMethod; + + // check whether the GIS Information is valid + if (!(latitude >= -EPSILON && latitude <= EPSILON) || + !(longitude >= -EPSILON && longitude <= EPSILON) || + !(altitude >= -EPSILON && altitude <= EPSILON) || (timestamp != 0) || + (strlen(pprocmethod) != 0)) + gpsEnabled = true; + + mExifAttributes.enableGps = 0; + LOG1("@%s,EXIF: gpsEnabled: %d", __func__, gpsEnabled); + + // the version is given as 2.2.0.0, it is mandatory when GPSInfo tag is present + if (gpsEnabled) { + const unsigned char gpsversion[4] = {0x02, 0x02, 0x00, 0x00}; + MEMCPY_S(mExifAttributes.gps_version_id, sizeof(mExifAttributes.gps_version_id), gpsversion, + sizeof(gpsversion)); + } else { + return; + } + + // latitude, for example, 39.904214 degrees, N + if (latitude > 0) + MEMCPY_S(mExifAttributes.gps_latitude_ref, sizeof(mExifAttributes.gps_latitude_ref), "N", + sizeof(mExifAttributes.gps_latitude_ref)); + else + MEMCPY_S(mExifAttributes.gps_latitude_ref, sizeof(mExifAttributes.gps_latitude_ref), "S", + sizeof(mExifAttributes.gps_latitude_ref)); + + latitude = fabs(latitude); + mExifAttributes.gps_latitude[0].num = (uint32_t)latitude; + mExifAttributes.gps_latitude[0].den = 1; + mExifAttributes.gps_latitude[1].num = + (uint32_t)((latitude - mExifAttributes.gps_latitude[0].num) * 60); + mExifAttributes.gps_latitude[1].den = 1; + mExifAttributes.gps_latitude[2].num = + (uint32_t)(((latitude - mExifAttributes.gps_latitude[0].num) * 60 - + mExifAttributes.gps_latitude[1].num) * + 60 * 100); + mExifAttributes.gps_latitude[2].den = 100; + mExifAttributes.enableGps |= EXIF_GPS_LATITUDE; + LOG1("EXIF: latitude, ref:%s, dd:%d, mm:%d, ss:%d", mExifAttributes.gps_latitude_ref, + mExifAttributes.gps_latitude[0].num, mExifAttributes.gps_latitude[1].num, + mExifAttributes.gps_latitude[2].num); + + // longitude, for example, 116.407413 degrees, E + if (longitude > 0) + MEMCPY_S(mExifAttributes.gps_longitude_ref, sizeof(mExifAttributes.gps_longitude_ref), "E", + sizeof(mExifAttributes.gps_longitude_ref)); + else + MEMCPY_S(mExifAttributes.gps_longitude_ref, sizeof(mExifAttributes.gps_longitude_ref), "W", + sizeof(mExifAttributes.gps_longitude_ref)); + longitude = fabs(longitude); + mExifAttributes.gps_longitude[0].num = (uint32_t)longitude; + mExifAttributes.gps_longitude[0].den = 1; + mExifAttributes.gps_longitude[1].num = + (uint32_t)((longitude - mExifAttributes.gps_longitude[0].num) * 60); + mExifAttributes.gps_longitude[1].den = 1; + mExifAttributes.gps_longitude[2].num = + (uint32_t)(((longitude - mExifAttributes.gps_longitude[0].num) * 60 - + mExifAttributes.gps_longitude[1].num) * + 60 * 100); + mExifAttributes.gps_longitude[2].den = 100; + mExifAttributes.enableGps |= EXIF_GPS_LONGITUDE; + LOG1("EXIF: longitude, ref:%s, dd:%d, mm:%d, ss:%d", mExifAttributes.gps_longitude_ref, + mExifAttributes.gps_longitude[0].num, mExifAttributes.gps_longitude[1].num, + mExifAttributes.gps_longitude[2].num); + + // altitude + // altitude, sea level or above sea level, set it to 0; below sea level, set it to 1 + mExifAttributes.gps_altitude_ref = ((altitude > 0) ? 0 : 1); + altitude = fabs(altitude); + mExifAttributes.gps_altitude.num = (uint32_t)altitude; + mExifAttributes.gps_altitude.den = 1; + mExifAttributes.enableGps |= EXIF_GPS_ALTITUDE; + LOG1("EXIF: altitude, ref:%d, height:%d", mExifAttributes.gps_altitude_ref, + mExifAttributes.gps_altitude.num); + + // timestamp + if (timestamp >= LONG_MAX || timestamp <= LONG_MIN) { + timestamp = 0; + LOGW("invalid timestamp was provided, defaulting to 0 (i.e. 1970)"); + } + struct tm time; + gmtime_r(×tamp, &time); + time.tm_year += 1900; + time.tm_mon += 1; + mExifAttributes.gps_timestamp[0].num = time.tm_hour; + mExifAttributes.gps_timestamp[0].den = 1; + mExifAttributes.gps_timestamp[1].num = time.tm_min; + mExifAttributes.gps_timestamp[1].den = 1; + mExifAttributes.gps_timestamp[2].num = time.tm_sec; + mExifAttributes.gps_timestamp[2].den = 1; + mExifAttributes.enableGps |= EXIF_GPS_TIMESTAMP; + + snprintf(reinterpret_cast(mExifAttributes.gps_datestamp), + sizeof(mExifAttributes.gps_datestamp), "%04d:%02d:%02d", time.tm_year, time.tm_mon, + time.tm_mday); + + LOG1("EXIF: timestamp, year:%d,mon:%d,day:%d,hour:%d,min:%d,sec:%d", time.tm_year, time.tm_mon, + time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec); + + // processing method + MEMCPY_S(mExifAttributes.gps_processing_method, sizeof(mExifAttributes.gps_processing_method), + metadata->mGpsSetting.gpsProcessingMethod, + sizeof(metadata->mGpsSetting.gpsProcessingMethod)); + mExifAttributes.gps_processing_method[sizeof(mExifAttributes.gps_processing_method) - 1] = 0; + + mExifAttributes.enableGps |= EXIF_GPS_PROCMETHOD; + LOG1("EXIF: GPS processing method:%s", mExifAttributes.gps_processing_method); +} + +void EXIFMaker::setSensorAeConfig(const Parameters& params) { + LOG1("@%s", __func__); + + int64_t expTime = 0; + params.getExposureTime(expTime); + + if (expTime > 0) { + // EXIF exposure rational value is in seconds and the unit of exposure time in 3A is usecs + mExifAttributes.exposure_time.num = expTime; + mExifAttributes.exposure_time.den = 1000000; + uint32_t tv = APEX_EXPOSURE_TO_SHUTTER(static_cast(expTime) / + mExifAttributes.exposure_time.den); + mExifAttributes.shutter_speed.num = tv * 65536; + mExifAttributes.shutter_speed.den = 65536; + } else { + mExifAttributes.exposure_time.num = 0; + mExifAttributes.exposure_time.den = 1; + mExifAttributes.shutter_speed.num = 0; + mExifAttributes.shutter_speed.den = 1; + } + + float stepEv = 1 / 3.0f; + icamera::camera_rational_t aeCompensationStep; + if (params.getAeCompensationStep(aeCompensationStep) == 0) { + stepEv = static_cast(aeCompensationStep.numerator) / aeCompensationStep.denominator; + } + + int32_t ev = 0; + float evBias = 0; + if (params.getAeCompensation(ev) == 0) { + evBias = static_cast(ev) * stepEv; + } + + // exposure bias. unit is APEX value. -99.99 to 99.99 + const int evLowerBound = -100, evUpperBound = 100; + if (evBias > evLowerBound && evBias < evUpperBound) { + mExifAttributes.exposure_bias.num = static_cast(evBias) * 100; + mExifAttributes.exposure_bias.den = 100; + LOG2("EXIF: Ev = %.2f", evBias); + } else { + mExifAttributes.exposure_bias.num = 0; + mExifAttributes.exposure_bias.den = 100; + LOG2("EXIF: Invalid Ev!"); + } + + int32_t iso; + mExifAttributes.iso_speed_rating = DEFAULT_ISO_SPEED; + if (params.getSensitivityIso(iso) == 0) { + mExifAttributes.iso_speed_rating = iso; + } + + LOG2("EXIF: ISO=%d", mExifAttributes.iso_speed_rating); + LOG2("EXIF: shutter speed=%u/%u", mExifAttributes.shutter_speed.num, + mExifAttributes.shutter_speed.den); + LOG2("EXIF: exposure time=%u/%u", mExifAttributes.exposure_time.num, + mExifAttributes.exposure_time.den); + + if (mExifAttributes.fnumber.den > 0 && expTime > 0 && mExifAttributes.iso_speed_rating > 0) { + // 'dAv + dTv = dSv + dBv' based on the equation of APEX system + double dAv = APEX_FNUM_TO_APERTURE(static_cast(mExifAttributes.fnumber.num) / + mExifAttributes.fnumber.den); + double dTv = APEX_EXPOSURE_TO_SHUTTER(static_cast(expTime) / 1000000); + double dSv = APEX_ISO_TO_FILMSENSITIVITY(mExifAttributes.iso_speed_rating); + mExifAttributes.brightness.num = (dAv + dTv - dSv) * EXIF_DEF_BRIGHTNESSVALUE_DEN; + mExifAttributes.brightness.den = EXIF_DEF_BRIGHTNESSVALUE_DEN; + LOG2("EXIF: brightness = %d / %d", mExifAttributes.brightness.num, + mExifAttributes.brightness.den); + } +} + +/* + * more secure attribute copy routine. + * \param dst pointer to dst buffer + * \param dstSize dst buffer size + * \param src pointer to src character buffer + * \param srcLength src buffer length in characters, not including null byte + */ +void EXIFMaker::copyAttribute(uint8_t* dst, size_t dstSize, const char* src, size_t srcLength) { + size_t dstMaxLength = dstSize - 1; // leave space for null + MEMCPY_S(dst, dstMaxLength, src, srcLength); // copy chars (not null) + // add null termination + size_t len = std::min(dstMaxLength, srcLength); + dst[len] = '\0'; +} + +void EXIFMaker::clear() { + LOG1("@%s", __func__); + // Reset all the attributes + CLEAR(mExifAttributes); + // Initialize the common values + mExifAttributes.enableThumb = false; + copyAttribute(mExifAttributes.image_description, sizeof(mExifAttributes.image_description), + EXIF_DEF_IMAGE_DESCRIPTION, strlen(EXIF_DEF_IMAGE_DESCRIPTION)); + + copyAttribute(mExifAttributes.maker, sizeof(mExifAttributes.maker), mManufacturerName.c_str(), + strlen(mManufacturerName.c_str())); + + copyAttribute(mExifAttributes.model, sizeof(mExifAttributes.model), mProductName.c_str(), + strlen(mProductName.c_str())); + + copyAttribute(mExifAttributes.software, sizeof(mExifAttributes.software), EXIF_DEF_SOFTWARE, + strlen(EXIF_DEF_SOFTWARE)); + + copyAttribute(mExifAttributes.exif_version, sizeof(mExifAttributes.exif_version), + EXIF_DEF_EXIF_VERSION, strlen(EXIF_DEF_EXIF_VERSION)); + + copyAttribute(mExifAttributes.flashpix_version, sizeof(mExifAttributes.flashpix_version), + EXIF_DEF_FLASHPIXVERSION, strlen(EXIF_DEF_FLASHPIXVERSION)); + + // initially, set default flash + mExifAttributes.flash = EXIF_DEF_FLASH; + + // normally it is sRGB, 1 means sRGB. FFFF.H means uncalibrated + mExifAttributes.color_space = EXIF_DEF_COLOR_SPACE; + + // the number of pixels per ResolutionUnit in the w or h direction + // 72 means the image resolution is unknown + mExifAttributes.x_resolution.num = EXIF_DEF_RESOLUTION_NUM; + mExifAttributes.x_resolution.den = EXIF_DEF_RESOLUTION_DEN; + mExifAttributes.y_resolution.num = mExifAttributes.x_resolution.num; + mExifAttributes.y_resolution.den = mExifAttributes.x_resolution.den; + // resolution unit, 2 means inch + mExifAttributes.resolution_unit = EXIF_DEF_RESOLUTION_UNIT; + // when thumbnail uses JPEG compression, this tag 103H's value is set to 6 + mExifAttributes.compression_scheme = EXIF_DEF_COMPRESSION; + + // the TIFF default is 1 (centered) + mExifAttributes.ycbcr_positioning = EXIF_DEF_YCBCR_POSITIONING; + + // Clear the Intel 3A Makernote information + mExifAttributes.makerNoteData = mMakernoteSection; + mExifAttributes.makerNoteDataSize = 0; + mExifAttributes.makernoteToApp2 = ENABLE_APP2_MARKER; + + mInitialized = false; +} + +void EXIFMaker::enableFlash(bool enable, int8_t aeMode, int8_t flashMode) { + mExifAttributes.flash = EXIF_DEF_FLASH; +} + +void EXIFMaker::setThumbnail(unsigned char* data, size_t size, int width, int height) { + LOG1("@%s: data = %p, size = %zu", __func__, data, size); + mExifAttributes.enableThumb = true; + mExifAttributes.widthThumb = width; + mExifAttributes.heightThumb = height; + if (mEncoder.setThumbData(data, size) != EXIF_SUCCESS) { + LOGE("Error in setting EXIF thumbnail"); + } +} + +bool EXIFMaker::isThumbnailSet() const { + return mEncoder.isThumbDataSet(); +} + +size_t EXIFMaker::makeExif(unsigned char* data) { + LOG2("@%s", __func__); + CheckAndLogError(!data, 0, "nullptr passed for EXIF. Cannot generate EXIF!"); + + if (mEncoder.makeExif(data, &mExifAttributes, &mExifSize) == EXIF_SUCCESS) { + LOG1("Generated EXIF (@%p) of size: %zu", data, mExifSize); + return mExifSize; + } + return 0; +} + +void EXIFMaker::setMaker(const char* data) { + LOG2("@%s: data = %s", __func__, data); + + snprintf((char*)mExifAttributes.maker, sizeof(mExifAttributes.maker), "%s", data); +} + +void EXIFMaker::setModel(const char* data) { + LOG2("@%s: data = %s", __func__, data); + + snprintf((char*)mExifAttributes.model, sizeof(mExifAttributes.model), "%s", data); +} + +void EXIFMaker::setSoftware(const char* data) { + LOG2("@%s: data = %s", __func__, data); + + snprintf((char*)mExifAttributes.software, sizeof(mExifAttributes.software), "%s", data); +} + +void EXIFMaker::saveMakernote(const Parameters& params) { + unsigned int size = sizeof(unsigned char) * (MAKERNOTE_SECTION1_SIZE + MAKERNOTE_SECTION2_SIZE); + if (params.getMakernoteData(mMakernoteSection, &size) == OK) { + mExifAttributes.makerNoteDataSize = size; + } +} + +void EXIFMaker::updateSensorInfo(const Parameters& params) { + float focal = 0.0; + params.getFocalLength(focal); + + if (focal < EPSILON) { + // Focal length is not supported, set to default value + const icamera::CameraMetadata& meta = icamera::ParameterHelper::getMetadata(params); + + icamera_metadata_ro_entry entry = meta.find(CAMERA_LENS_INFO_AVAILABLE_FOCAL_LENGTHS); + if (entry.count >= 1) { + focal = entry.data.f[0]; + } + } + + LOG2("focal length is %f", focal); + mExifAttributes.focal_length.num = focal * mExifAttributes.focal_length.den; + float aperture = 0.0; + params.getAperture(aperture); + mExifAttributes.aperture.num = aperture * mExifAttributes.aperture.den; + + mExifAttributes.fnumber.num = aperture * mExifAttributes.aperture.den; + mExifAttributes.fnumber.den = mExifAttributes.aperture.den; +} + +} // namespace icamera diff --git a/src/jpeg/EXIFMaker.h b/src/jpeg/EXIFMaker.h new file mode 100644 index 00000000..adad8d07 --- /dev/null +++ b/src/jpeg/EXIFMaker.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2016-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "EXIFMetaData.h" +#include "ExifCreater.h" +#include "iutils/Utils.h" + +namespace icamera { + +/** + * \class EXIFMaker + * + */ +class EXIFMaker { + public: + EXIFMaker(); + ~EXIFMaker(); + + void readProperty(); + void initialize(int width, int height); + bool isInitialized() { return mInitialized; } + void initializeLocation(ExifMetaData* metadata); + uint32_t getMakerNoteDataSize() const; + void pictureTaken(ExifMetaData* exifmetadata); + void enableFlash(bool enable, int8_t aeMode, int8_t flashMode); + void setThumbnail(unsigned char* data, size_t size, int width, int height); + bool isThumbnailSet() const; + size_t makeExif(unsigned char* data); + void setMaker(const char* data); + void setModel(const char* data); + void setSoftware(const char* data); + void updateSensorInfo(const Parameters& params); + void saveMakernote(const Parameters& params); + void setSensorAeConfig(const Parameters& params); + + private: // member variables + ExifCreater mEncoder; + exif_attribute_t mExifAttributes; + size_t mExifSize; + bool mInitialized; + unsigned char* mMakernoteSection; + std::string mProductName; + std::string mManufacturerName; + + private: + // prevent copy constructor and assignment operator + DISALLOW_COPY_AND_ASSIGN(EXIFMaker); + + private: // Methods + void copyAttribute(uint8_t* dst, size_t dstSize, const char* src, size_t srcLength); + + void clear(); +}; + +} // namespace icamera diff --git a/src/jpeg/EXIFMetaData.cpp b/src/jpeg/EXIFMetaData.cpp new file mode 100644 index 00000000..dc2fbd8e --- /dev/null +++ b/src/jpeg/EXIFMetaData.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2016-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG EXIFMetaData + +#include "EXIFMetaData.h" + +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +#define DEFAULT_ISO_SPEED 100 + +ExifMetaData::ExifMetaData() + : effectMode(CAM_EFFECT_NONE), + software(nullptr), + hdr(false), + flashFired(false), + v3AeMode(BAD_VALUE), + flashMode(BAD_VALUE), + saveMirrored(false), + cameraOrientation(0), + currentOrientation(0), + zoomRatio(1), + aeMode(AE_MODE_AUTO), + awbMode(AWB_MODE_AUTO), + currentFocusDistance(0.0) { + LOG1("@%s", __func__); + mJpegSetting.jpegQuality = 90; + mJpegSetting.jpegThumbnailQuality = 90; + mJpegSetting.orientation = 0; + mJpegSetting.thumbWidth = 320; + mJpegSetting.thumbHeight = 240; + mGpsSetting.latitude = 0.0; + mGpsSetting.longitude = 0.0; + mGpsSetting.altitude = 0.0; + CLEAR(mGpsSetting.gpsProcessingMethod); + mGpsSetting.gpsTimeStamp = 0; +} + +ExifMetaData::~ExifMetaData() {} + +} // namespace icamera diff --git a/src/jpeg/EXIFMetaData.h b/src/jpeg/EXIFMetaData.h new file mode 100644 index 00000000..7cd37f31 --- /dev/null +++ b/src/jpeg/EXIFMetaData.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2016-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "Parameters.h" +#include "iutils/Errors.h" +namespace icamera { + +#define MAX_NUM_GPS_PROCESSING_METHOD 64 + +/** + * \class ExifMetaData + * + */ +class ExifMetaData { + public: + ExifMetaData(); + virtual ~ExifMetaData(); + + // jpeg info + struct JpegSetting { + uint8_t jpegQuality; + uint8_t jpegThumbnailQuality; + int thumbWidth; + int thumbHeight; + int orientation; + }; + // GPS info + struct GpsSetting { + double latitude; + double longitude; + double altitude; + char gpsProcessingMethod[MAX_NUM_GPS_PROCESSING_METHOD]; + long gpsTimeStamp; + }; + // exif info + JpegSetting mJpegSetting; + GpsSetting mGpsSetting; + camera_effect_mode_t effectMode; + char* software; /*!< software string from HAL */ + bool hdr; /*!< whether hdr was used */ + bool flashFired; /*!< whether flash was fired */ + int8_t v3AeMode; /*!< v3 ae mode (e.g. for flash) */ + int8_t flashMode; /*!< flash mode (e.g. TORCH,SINGLE,OFF) */ + bool saveMirrored; /*!< whether to do mirroring */ + int cameraOrientation; /*!< camera sensor orientation */ + int currentOrientation; /*!< Current orientation of the device */ + int zoomRatio; + icamera::camera_ae_mode_t aeMode; + icamera::camera_awb_mode_t awbMode; + float currentFocusDistance; +}; + +} // namespace icamera diff --git a/src/jpeg/Exif.h b/src/jpeg/Exif.h new file mode 100644 index 00000000..bce7b71e --- /dev/null +++ b/src/jpeg/Exif.h @@ -0,0 +1,345 @@ +/* + * Copyright Samsung Electronics Co.,LTD. + * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2016-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#define EXIF_LOG2(x) (log((double)(x)) / log(2.0)) +#define APEX_FNUM_TO_APERTURE(x) (2.0 * (EXIF_LOG2((double)(x)))) +#define APEX_EXPOSURE_TO_SHUTTER(x) (-1.0 * (EXIF_LOG2((double)(x)))) +#define APEX_ISO_TO_FILMSENSITIVITY(x) (EXIF_LOG2((x) / 3.125)) + +#define NUM_SIZE 2 +#define IFD_SIZE 12 +#define OFFSET_SIZE 4 + +#define NUM_0TH_IFD_TIFF 14 +#define NUM_0TH_IFD_EXIF 36 +#define NUM_0TH_IFD_GPS 12 +#define NUM_1TH_IFD_TIFF 9 +// For QVGA: 320 * 240 * 1.5 +#define EXIF_SIZE_LIMITATION 0x10000 +// Limite the thumbnail size to 32k, to make sure the whole exif size does +// not exceed the exif size limitation. We guess the total size of all the +// other fields is smaller than 32k. (Currently the size is about 26k.) +#define THUMBNAIL_SIZE_LIMITATION 0x8000 + +/* Type */ +#define EXIF_TYPE_BYTE 1 +#define EXIF_TYPE_ASCII 2 +#define EXIF_TYPE_SHORT 3 +#define EXIF_TYPE_LONG 4 +#define EXIF_TYPE_RATIONAL 5 +#define EXIF_TYPE_UNDEFINED 7 +#define EXIF_TYPE_SLONG 9 +#define EXIF_TYPE_SRATIONAL 10 + +#define EXIF_FILE_SIZE 28800 + +/* 0th IFD TIFF Tags */ +#define EXIF_TAG_IMAGE_WIDTH 0x0100 +#define EXIF_TAG_IMAGE_HEIGHT 0x0101 +#define EXIF_TAG_IMAGE_DESCRIPTION 0x010e +#define EXIF_TAG_MAKE 0x010f +#define EXIF_TAG_MODEL 0x0110 +#define EXIF_TAG_ORIENTATION 0x0112 +#define EXIF_TAG_X_RESOLUTION 0x011A +#define EXIF_TAG_Y_RESOLUTION 0x011B +#define EXIF_TAG_RESOLUTION_UNIT 0x0128 +#define EXIF_TAG_SOFTWARE 0x0131 +#define EXIF_TAG_DATE_TIME 0x0132 +#define EXIF_TAG_YCBCR_POSITIONING 0x0213 +#define EXIF_TAG_EXIF_IFD_POINTER 0x8769 +#define EXIF_TAG_GPS_IFD_POINTER 0x8825 + +/* 0th IFD Exif Private Tags */ +#define EXIF_TAG_EXPOSURE_TIME 0x829A +#define EXIF_TAG_FNUMBER 0x829D +#define EXIF_TAG_EXPOSURE_PROGRAM 0x8822 +#define EXIF_TAG_ISO_SPEED_RATING 0x8827 +#define EXIF_TAG_EXIF_VERSION 0x9000 +#define EXIF_TAG_DATE_TIME_ORG 0x9003 +#define EXIF_TAG_DATE_TIME_DIGITIZE 0x9004 +#define EXIF_TAG_COMPONENTS_CONFIGURATION 0x9101 +#define EXIF_TAG_SHUTTER_SPEED 0x9201 +#define EXIF_TAG_APERTURE 0x9202 +#define EXIF_TAG_BRIGHTNESS 0x9203 +#define EXIF_TAG_EXPOSURE_BIAS 0x9204 +#define EXIF_TAG_MAX_APERTURE 0x9205 +#define EXIF_TAG_SUBJECT_DISTANCE 0x9206 +#define EXIF_TAG_METERING_MODE 0x9207 +#define EXIF_TAG_LIGHT_SOURCE 0x9208 +#define EXIF_TAG_FLASH 0x9209 +#define EXIF_TAG_FOCAL_LENGTH 0x920A +#define EXIF_TAG_MAKER_NOTE 0x927C +#define EXIF_TAG_USER_COMMENT 0x9286 +#define EXIF_TAG_SUBSEC_TIME 0x9290 +#define EXIF_TAG_SUBSEC_TIME_ORIG 0x9291 +#define EXIF_TAG_SUBSEC_TIME_DIG 0x9292 +#define EXIF_TAG_FLASH_PIX_VERSION 0xA000 +#define EXIF_TAG_COLOR_SPACE 0xA001 +#define EXIF_TAG_PIXEL_X_DIMENSION 0xA002 +#define EXIF_TAG_PIXEL_Y_DIMENSION 0xA003 +#define EXIF_TAG_CUSTOM_RENDERED 0xA401 +#define EXIF_TAG_EXPOSURE_MODE 0xA402 +#define EXIF_TAG_WHITE_BALANCE 0xA403 +#define EXIF_TAG_JPEG_ZOOM_RATIO 0XA404 +#define EXIF_TAG_SCENCE_CAPTURE_TYPE 0xA406 +#define EXIF_TAG_GAIN_CONTROL 0xA407 +#define EXIF_TAG_CONTRAST 0xA408 +#define EXIF_TAG_SATURATION 0xA409 +#define EXIF_TAG_SHARPNESS 0xA40A + +/* 0th IFD GPS Info Tags */ +#define EXIF_TAG_GPS_VERSION_ID 0x0000 +#define EXIF_TAG_GPS_LATITUDE_REF 0x0001 +#define EXIF_TAG_GPS_LATITUDE 0x0002 +#define EXIF_TAG_GPS_LONGITUDE_REF 0x0003 +#define EXIF_TAG_GPS_LONGITUDE 0x0004 +#define EXIF_TAG_GPS_ALTITUDE_REF 0x0005 +#define EXIF_TAG_GPS_ALTITUDE 0x0006 +#define EXIF_TAG_GPS_TIMESTAMP 0x0007 +#define EXIF_TAG_GPS_IMG_DIRECTION_REF 0x0010 +#define EXIF_TAG_GPS_IMG_DIRECTION 0x0011 +#define EXIF_TAG_GPS_PROCESSING_METHOD 0x001B +#define EXIF_TAG_GPS_DATESTAMP 0x001D + +/* 1th IFD TIFF Tags */ +#define EXIF_TAG_COMPRESSION_SCHEME 0x0103 +/* +#define EXIF_TAG_X_RESOLUTION 0x011A +#define EXIF_TAG_Y_RESOLUTION 0x011B +#define EXIF_TAG_RESOLUTION_UNIT 0x0128 +*/ +#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT 0x0201 +#define EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN 0x0202 + +typedef enum { + EXIF_ORIENTATION_UP = 1, + EXIF_ORIENTATION_90 = 6, + EXIF_ORIENTATION_180 = 3, + EXIF_ORIENTATION_270 = 8, +} ExifOrientationType; + +typedef enum { + EXIF_SCENE_STANDARD, + EXIF_SCENE_LANDSCAPE, + EXIF_SCENE_PORTRAIT, + EXIF_SCENE_NIGHT, +} CamExifSceneCaptureType; + +typedef enum { + EXIF_METERING_UNKNOWN, + EXIF_METERING_AVERAGE, + EXIF_METERING_CENTER, + EXIF_METERING_SPOT, + EXIF_METERING_MULTISPOT, + EXIF_METERING_PATTERN, + EXIF_METERING_PARTIAL, + EXIF_METERING_OTHER = 255, +} CamExifMeteringModeType; + +typedef enum { + EXIF_EXPOSURE_AUTO, + EXIF_EXPOSURE_MANUAL, + EXIF_EXPOSURE_AUTO_BRACKET, +} CamExifExposureModeType; + +typedef enum { + EXIF_WB_AUTO, + EXIF_WB_MANUAL, +} CamExifWhiteBalanceType; + +typedef enum { + EXIF_LIGHT_SOURCE_UNKNOWN, + EXIF_LIGHT_SOURCE_DAYLIGHT, + EXIF_LIGHT_SOURCE_FLUORESCENT, + EXIF_LIGHT_SOURCE_TUNGSTEN, + EXIF_LIGHT_SOURCE_FLASH, + EXIF_LIGHT_SOURCE_FINE_WEATHER = 9, + EXIF_LIGHT_SOURCE_CLOUDY_WEATHER, + EXIF_LIGHT_SOURCE_SHADE, + EXIF_LIGHT_SOURCE_DAYLIGHT_FLUORESCENT, + EXIF_LIGHT_SOURCE_DAY_WHITE_FLUORESCENT, + EXIF_LIGHT_SOURCE_COOL_WHITE_FLUORESCENT, + EXIF_LIGHT_SOURCE_WHITE_FLUORESCENT, + EXIF_LIGHT_SOURCE_WARM_WHITE_FLUORESCENT, // value 16 is used in EXIF V2.3, not for EXIF V2.2 + EXIF_LIGHT_SOURCE_STANDARD_LIGHT_A, + EXIF_LIGHT_SOURCE_STANDARD_LIGHT_B, + EXIF_LIGHT_SOURCE_STANDARD_LIGHT_C, + EXIF_LIGHT_SOURCE_D55, + EXIF_LIGHT_SOURCE_D65, + EXIF_LIGHT_SOURCE_D75, + EXIF_LIGHT_SOURCE_D50, + EXIF_LIGHT_SOURCE_ISO_STUDIO_TUNGSTEN, + EXIF_LIGHT_SOURCE_OTHER_LIGHT_SOURCE = 255, +} CamExifLightSourceType; + +typedef enum { + EXIF_EXPOSURE_PROGRAM_MANUAL = 1, + EXIF_EXPOSURE_PROGRAM_NORMAL = 2, + EXIF_EXPOSURE_PROGRAM_APERTURE_PRIORITY = 3, + EXIF_EXPOSURE_PROGRAM_SHUTTER_PRIORITY = 4 +} CamExifExposureProgramType; + +typedef enum { + EXIF_CONTRAST_NORMAL = 0, + EXIF_CONTRAST_SOFT = 1, + EXIF_CONTRAST_HARD = 2, +} CamExifContrastType; + +typedef enum { + EXIF_SATURATION_NORMAL = 0, + EXIF_SATURATION_LOW = 1, + EXIF_SATURATION_HIGH = 2, +} CamExifSaturationType; + +typedef enum { + EXIF_SHARPNESS_NORMAL = 0, + EXIF_SHARPNESS_SOFT = 1, + EXIF_SHARPNESS_HARD = 2, +} CamExifSharpnessType; + +/* define the flag of enable gps info */ +const uint8_t EXIF_GPS_LATITUDE = 0x01; +const uint8_t EXIF_GPS_LONGITUDE = 0x02; +const uint8_t EXIF_GPS_ALTITUDE = 0x04; +const uint8_t EXIF_GPS_TIMESTAMP = 0x08; +const uint8_t EXIF_GPS_PROCMETHOD = 0x10; +const uint8_t EXIF_GPS_IMG_DIRECTION = 0x20; + +/* Values */ +#define EXIF_DEF_IMAGE_DESCRIPTION "Jpeg" +#define EXIF_DEF_SOFTWARE "Android" +#define EXIF_DEF_EXIF_VERSION "0220" +#define EXIF_DEF_USERCOMMENTS " " +#define EXIF_DEF_FLASHPIXVERSION "0100" /* Flashpix Format Version 1.0 */ + +#define EXIF_DEF_YCBCR_POSITIONING 1 /* centered */ +#define EXIF_DEF_FNUMBER_NUM 26 /* 2.6 */ +#define EXIF_DEF_FNUMBER_DEN 10 +#define EXIF_DEF_EXPOSURE_PROGRAM 3 /* aperture priority */ +#define EXIF_DEF_FOCAL_LEN_NUM 2780 /* 2.78mm */ +#define EXIF_DEF_FOCAL_LEN_DEN 1000 +#define EXIF_DEF_FLASH 0 /* O: off, 1: on*/ +#define EXIF_FLASH_FORCED_ON 1 << 3; /* mode description */ +#define EXIF_FLASH_FORCED_OFF 1 << 4; /* mode description */ +#define EXIF_FLASH_AUTO 1 << 3 | 1 << 4; /* mode description */ +#define EXIF_FLASH_ON 1 /* O: off, 1: on - fired or not*/ +#define EXIF_DEF_COLOR_SPACE 1 +#define EXIF_DEF_CUSTOM_RENDERED 0 +#define EXIF_CUSTOM_RENDERED_HDR 1 +#define EXIF_DEF_EXPOSURE_MODE EXIF_EXPOSURE_AUTO +#define EXIF_DEF_APEX_DEN 10 +#define EXIF_DEF_APEX_NUM 25 +#define EXIF_DEF_SUBJECT_DISTANCE_UNKNOWN 0 + +#define EXIF_DEF_COMPRESSION 6 +#define EXIF_DEF_RESOLUTION_NUM 72 +#define EXIF_DEF_RESOLUTION_DEN 1 +#define EXIF_DEF_RESOLUTION_UNIT 2 /* inches */ + +#define EXIF_DEF_BRIGHTNESSVALUE_DEN 100 + +typedef struct { + uint32_t num; + uint32_t den; +} rational_t; + +typedef struct { + int32_t num; + int32_t den; +} srational_t; + +typedef struct { + bool enableThumb; + + uint8_t image_description[32]; + uint8_t flashpix_version[4]; + uint8_t components_configuration[4]; + uint8_t maker[32]; + uint8_t model[32]; + uint8_t software[32]; + uint8_t exif_version[4]; + uint8_t date_time[20]; + uint8_t subsec_time[8]; + uint8_t user_comment[150]; + + uint32_t width; + uint32_t height; + uint32_t widthThumb; + uint32_t heightThumb; + + uint16_t orientation; + uint16_t ycbcr_positioning; + uint16_t exposure_program; + uint16_t iso_speed_rating; + uint16_t metering_mode; + uint16_t flash; + uint16_t color_space; + uint16_t custom_rendered; + uint16_t exposure_mode; + uint16_t white_balance; + rational_t zoom_ratio; + uint16_t scene_capture_type; + uint16_t light_source; + uint16_t gain_control; + uint16_t contrast; + uint16_t saturation; + uint16_t sharpness; + + rational_t exposure_time; + rational_t fnumber; + rational_t aperture; + rational_t max_aperture; + rational_t focal_length; + rational_t subject_distance; + + srational_t shutter_speed; + srational_t brightness; + srational_t exposure_bias; + + // bit 0~4 indicate whether Gps items latitude, longitude, altitude, timestamp, + // datastamp exist or not. + uint8_t enableGps; + uint8_t gps_latitude_ref[2]; + uint8_t gps_longitude_ref[2]; + + uint8_t gps_version_id[4]; + uint8_t gps_altitude_ref; + + rational_t gps_latitude[3]; + rational_t gps_longitude[3]; + rational_t gps_altitude; + rational_t gps_timestamp[3]; + uint8_t gps_datestamp[11]; + uint8_t gps_processing_method[100]; + + uint8_t gps_img_direction_ref[2]; + rational_t gps_img_direction; + + rational_t x_resolution; + rational_t y_resolution; + uint16_t resolution_unit; + uint16_t compression_scheme; + + uint16_t makerNoteDataSize; + unsigned char* makerNoteData; + bool makernoteToApp2; +} exif_attribute_t; diff --git a/src/jpeg/ExifCreater.cpp b/src/jpeg/ExifCreater.cpp new file mode 100644 index 00000000..70c01917 --- /dev/null +++ b/src/jpeg/ExifCreater.cpp @@ -0,0 +1,538 @@ +/* + * Copyright Samsung Electronics Co.,LTD. + * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2016-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * JPEG DRIVER MODULE (ExifCreater.cpp) + * Author : ge.lee -- initial version + * Date : 03 June 2010 + * Purpose : This file implements the JPEG encoder APIs as needed by Camera HAL + */ + +#define LOG_TAG ExifCreater + +#include "ExifCreater.h" + +#include +#include + +#include "iutils/CameraLog.h" + +static const char ExifAsciiPrefix[] = {0x41, 0x53, 0x43, 0x49, 0x49, 0x0, 0x0, 0x0}; + +// the exif size without thumbnail is less than 2k +#define EXIF_SIZE_WITHOUT_THUMBNAIL 0x800 + +namespace icamera { + +ExifCreater::ExifCreater() { + m_thumbBuf = nullptr; + m_thumbSize = 0; +} + +ExifCreater::~ExifCreater() {} + +exif_status ExifCreater::setThumbData(const void* thumbBuf, unsigned int thumbSize) { + if ((thumbSize + EXIF_SIZE_WITHOUT_THUMBNAIL) >= EXIF_SIZE_LIMITATION) { + LOGE("ERROR: Too big thumb size %d (limit: %d)", thumbSize, EXIF_SIZE_LIMITATION); + m_thumbBuf = nullptr; + m_thumbSize = 0; + return EXIF_FAIL; + } + + m_thumbBuf = static_cast(const_cast(thumbBuf)); + m_thumbSize = thumbSize; + return EXIF_SUCCESS; +} + +bool ExifCreater::isThumbDataSet() const { + return m_thumbBuf != nullptr; +} + +// if exif tags size + thumbnail size is > 64K, it will disable thumbnail +exif_status ExifCreater::makeExif(void* exifOut, exif_attribute_t* exifInfo, size_t* size) { + LOG1("makeExif start"); + + unsigned char *pCur, *pApp1Start, *pIfdStart, *pGpsIfdPtr, *pNextIfdOffset; + unsigned int tmp, LongerTagOffset = 0; + pApp1Start = pCur = static_cast(exifOut); + + // 2 Exif Identifier Code & TIFF Header + pCur += 4; // Skip 4 Byte for APP1 marker and length + + unsigned char ExifIdentifierCode[6] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}; + MEMCPY_S(pCur, sizeof(ExifIdentifierCode), ExifIdentifierCode, sizeof(ExifIdentifierCode)); + pCur += 6; + + /* Byte Order - little endian, Offset of IFD - 0x00000008.H */ + unsigned char TiffHeader[8] = {0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00}; + MEMCPY_S(pCur, sizeof(TiffHeader), TiffHeader, sizeof(TiffHeader)); + pIfdStart = pCur; + pCur += 8; + + // 2 0th IFD TIFF Tags + if (exifInfo->enableGps) + tmp = NUM_0TH_IFD_TIFF; + else + tmp = NUM_0TH_IFD_TIFF - 1; + + MEMCPY_S(pCur, NUM_SIZE, (int8_t*)&tmp, NUM_SIZE); + pCur += NUM_SIZE; + + LongerTagOffset += 8 + NUM_SIZE + tmp * IFD_SIZE + OFFSET_SIZE; + + writeExifIfd(&pCur, EXIF_TAG_IMAGE_WIDTH, EXIF_TYPE_LONG, 1, exifInfo->width); + writeExifIfd(&pCur, EXIF_TAG_IMAGE_HEIGHT, EXIF_TYPE_LONG, 1, exifInfo->height); + writeExifIfd(&pCur, EXIF_TAG_IMAGE_DESCRIPTION, EXIF_TYPE_ASCII, + strlen(reinterpret_cast(exifInfo->image_description)) + 1, + exifInfo->image_description, &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_MAKE, EXIF_TYPE_ASCII, strlen((char*)exifInfo->maker) + 1, + exifInfo->maker, &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_MODEL, EXIF_TYPE_ASCII, strlen((char*)exifInfo->model) + 1, + exifInfo->model, &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_ORIENTATION, EXIF_TYPE_SHORT, 1, exifInfo->orientation); + writeExifIfd(&pCur, EXIF_TAG_X_RESOLUTION, EXIF_TYPE_RATIONAL, 1, &exifInfo->x_resolution, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_Y_RESOLUTION, EXIF_TYPE_RATIONAL, 1, &exifInfo->y_resolution, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_RESOLUTION_UNIT, EXIF_TYPE_SHORT, 1, exifInfo->resolution_unit); + writeExifIfd(&pCur, EXIF_TAG_SOFTWARE, EXIF_TYPE_ASCII, strlen((char*)exifInfo->software) + 1, + exifInfo->software, &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_DATE_TIME, EXIF_TYPE_ASCII, 20, exifInfo->date_time, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_YCBCR_POSITIONING, EXIF_TYPE_SHORT, 1, + exifInfo->ycbcr_positioning); + writeExifIfd(&pCur, EXIF_TAG_EXIF_IFD_POINTER, EXIF_TYPE_LONG, 1, LongerTagOffset); + + pGpsIfdPtr = pCur; + if (exifInfo->enableGps) { + pCur += IFD_SIZE; // Skip a ifd size for gps IFD pointer + } + + pNextIfdOffset = pCur; // Skip a offset size for next IFD offset + pCur += OFFSET_SIZE; + + // 2 0th IFD Exif Private Tags + pCur = pIfdStart + LongerTagOffset; + + int drop_num = 0; + if (exifInfo->exposure_time.den == 0) drop_num++; + if (exifInfo->shutter_speed.den == 0) drop_num++; + if (exifInfo->makerNoteDataSize == 0 || exifInfo->makernoteToApp2) { + // skip the makernote IFD in APP1, when we don't have any, + // or if we want it to APP2 + drop_num++; + } + tmp = NUM_0TH_IFD_EXIF - drop_num; + MEMCPY_S(pCur, NUM_SIZE, &tmp, NUM_SIZE); + pCur += NUM_SIZE; + + LongerTagOffset += NUM_SIZE + tmp * IFD_SIZE + OFFSET_SIZE; + if (exifInfo->exposure_time.den != 0) { + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_TIME, EXIF_TYPE_RATIONAL, 1, &exifInfo->exposure_time, + &LongerTagOffset, pIfdStart); + } + writeExifIfd(&pCur, EXIF_TAG_FNUMBER, EXIF_TYPE_RATIONAL, 1, &exifInfo->fnumber, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_PROGRAM, EXIF_TYPE_SHORT, 1, exifInfo->exposure_program); + writeExifIfd(&pCur, EXIF_TAG_ISO_SPEED_RATING, EXIF_TYPE_SHORT, 1, exifInfo->iso_speed_rating); + writeExifIfd(&pCur, EXIF_TAG_EXIF_VERSION, EXIF_TYPE_UNDEFINED, 4, exifInfo->exif_version); + writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_ORG, EXIF_TYPE_ASCII, 20, exifInfo->date_time, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_DATE_TIME_DIGITIZE, EXIF_TYPE_ASCII, 20, exifInfo->date_time, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_COMPONENTS_CONFIGURATION, EXIF_TYPE_UNDEFINED, 4, + exifInfo->components_configuration); + if (exifInfo->shutter_speed.den != 0) { + writeExifIfd(&pCur, EXIF_TAG_SHUTTER_SPEED, EXIF_TYPE_SRATIONAL, 1, + reinterpret_cast(&exifInfo->shutter_speed), &LongerTagOffset, + pIfdStart); + } + writeExifIfd(&pCur, EXIF_TAG_APERTURE, EXIF_TYPE_RATIONAL, 1, &exifInfo->aperture, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_BRIGHTNESS, EXIF_TYPE_SRATIONAL, 1, + reinterpret_cast(&exifInfo->brightness), &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_BIAS, EXIF_TYPE_SRATIONAL, 1, + reinterpret_cast(&exifInfo->exposure_bias), &LongerTagOffset, + pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_MAX_APERTURE, EXIF_TYPE_RATIONAL, 1, &exifInfo->max_aperture, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SUBJECT_DISTANCE, EXIF_TYPE_RATIONAL, 1, + &exifInfo->subject_distance, &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_METERING_MODE, EXIF_TYPE_SHORT, 1, exifInfo->metering_mode); + writeExifIfd(&pCur, EXIF_TAG_LIGHT_SOURCE, EXIF_TYPE_SHORT, 1, exifInfo->light_source); + writeExifIfd(&pCur, EXIF_TAG_FLASH, EXIF_TYPE_SHORT, 1, exifInfo->flash); + writeExifIfd(&pCur, EXIF_TAG_FOCAL_LENGTH, EXIF_TYPE_RATIONAL, 1, &exifInfo->focal_length, + &LongerTagOffset, pIfdStart); + char code[8] = {0x41, 0x53, 0x43, 0x49, 0x49, 0x00, 0x00, 0x00}; + size_t commentsLen = strlen((char*)exifInfo->user_comment) + 1; + if (commentsLen > (sizeof(exifInfo->user_comment) - sizeof(code))) return EXIF_FAIL; + memmove(exifInfo->user_comment + sizeof(code), exifInfo->user_comment, commentsLen); + MEMCPY_S(exifInfo->user_comment, sizeof(exifInfo->user_comment), code, sizeof(code)); + writeExifIfd(&pCur, EXIF_TAG_USER_COMMENT, EXIF_TYPE_UNDEFINED, commentsLen + sizeof(code), + exifInfo->user_comment, &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SUBSEC_TIME, EXIF_TYPE_ASCII, + strlen((char*)exifInfo->subsec_time) + 1, exifInfo->subsec_time, &LongerTagOffset, + pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SUBSEC_TIME_ORIG, EXIF_TYPE_ASCII, + strlen((char*)exifInfo->subsec_time) + 1, exifInfo->subsec_time, &LongerTagOffset, + pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SUBSEC_TIME_DIG, EXIF_TYPE_ASCII, + strlen((char*)exifInfo->subsec_time) + 1, exifInfo->subsec_time, &LongerTagOffset, + pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_FLASH_PIX_VERSION, EXIF_TYPE_UNDEFINED, 4, + exifInfo->flashpix_version); + writeExifIfd(&pCur, EXIF_TAG_COLOR_SPACE, EXIF_TYPE_SHORT, 1, exifInfo->color_space); + writeExifIfd(&pCur, EXIF_TAG_PIXEL_X_DIMENSION, EXIF_TYPE_LONG, 1, exifInfo->width); + writeExifIfd(&pCur, EXIF_TAG_PIXEL_Y_DIMENSION, EXIF_TYPE_LONG, 1, exifInfo->height); + writeExifIfd(&pCur, EXIF_TAG_CUSTOM_RENDERED, EXIF_TYPE_SHORT, 1, exifInfo->custom_rendered); + writeExifIfd(&pCur, EXIF_TAG_EXPOSURE_MODE, EXIF_TYPE_SHORT, 1, exifInfo->exposure_mode); + writeExifIfd(&pCur, EXIF_TAG_WHITE_BALANCE, EXIF_TYPE_SHORT, 1, exifInfo->white_balance); + writeExifIfd(&pCur, EXIF_TAG_JPEG_ZOOM_RATIO, EXIF_TYPE_RATIONAL, 1, &exifInfo->zoom_ratio, + &LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_SCENCE_CAPTURE_TYPE, EXIF_TYPE_SHORT, 1, + exifInfo->scene_capture_type); + writeExifIfd(&pCur, EXIF_TAG_GAIN_CONTROL, EXIF_TYPE_SHORT, 1, exifInfo->gain_control); + writeExifIfd(&pCur, EXIF_TAG_CONTRAST, EXIF_TYPE_SHORT, 1, exifInfo->contrast); + writeExifIfd(&pCur, EXIF_TAG_SATURATION, EXIF_TYPE_SHORT, 1, exifInfo->saturation); + writeExifIfd(&pCur, EXIF_TAG_SHARPNESS, EXIF_TYPE_SHORT, 1, exifInfo->sharpness); + + // Save MakerNote data to APP1, unless we want it APP2 + if (exifInfo->makerNoteDataSize > 0 && !exifInfo->makernoteToApp2) { + writeExifIfd(&pCur, EXIF_TAG_MAKER_NOTE, EXIF_TYPE_UNDEFINED, exifInfo->makerNoteDataSize, + (unsigned char*)exifInfo->makerNoteData, &LongerTagOffset, pIfdStart); + } + + tmp = 0; + MEMCPY_S(pCur, OFFSET_SIZE, (int8_t*)&tmp, OFFSET_SIZE); // next IFD offset + pCur += OFFSET_SIZE; + + // 2 0th IFD GPS Info Tags + if (exifInfo->enableGps) { + writeExifIfd(&pGpsIfdPtr, EXIF_TAG_GPS_IFD_POINTER, EXIF_TYPE_LONG, 1, + LongerTagOffset); // GPS IFD pointer skipped on 0th IFD + + pCur = pIfdStart + LongerTagOffset; + + tmp = NUM_0TH_IFD_GPS; + if ((exifInfo->enableGps & EXIF_GPS_LATITUDE) == 0) tmp -= 2; + if ((exifInfo->enableGps & EXIF_GPS_LONGITUDE) == 0) tmp -= 2; + if ((exifInfo->enableGps & EXIF_GPS_ALTITUDE) == 0) tmp -= 2; + if ((exifInfo->enableGps & EXIF_GPS_TIMESTAMP) == 0) tmp -= 1; + if ((exifInfo->enableGps & EXIF_GPS_PROCMETHOD) == 0) tmp -= 1; + if ((exifInfo->enableGps & EXIF_GPS_IMG_DIRECTION) == 0) tmp -= 2; + + MEMCPY_S(pCur, NUM_SIZE, (int8_t*)&tmp, NUM_SIZE); + pCur += NUM_SIZE; + + LongerTagOffset += NUM_SIZE + tmp * IFD_SIZE + OFFSET_SIZE; + + writeExifIfd(&pCur, EXIF_TAG_GPS_VERSION_ID, EXIF_TYPE_BYTE, 4, exifInfo->gps_version_id); + if (exifInfo->enableGps & EXIF_GPS_LATITUDE) { + writeExifIfd(&pCur, EXIF_TAG_GPS_LATITUDE_REF, EXIF_TYPE_ASCII, 2, + exifInfo->gps_latitude_ref); + writeExifIfd(&pCur, EXIF_TAG_GPS_LATITUDE, EXIF_TYPE_RATIONAL, 3, + exifInfo->gps_latitude, &LongerTagOffset, pIfdStart); + } + + if (exifInfo->enableGps & EXIF_GPS_LONGITUDE) { + writeExifIfd(&pCur, EXIF_TAG_GPS_LONGITUDE_REF, EXIF_TYPE_ASCII, 2, + exifInfo->gps_longitude_ref); + writeExifIfd(&pCur, EXIF_TAG_GPS_LONGITUDE, EXIF_TYPE_RATIONAL, 3, + exifInfo->gps_longitude, &LongerTagOffset, pIfdStart); + } + + if (exifInfo->enableGps & EXIF_GPS_ALTITUDE) { + writeExifIfd(&pCur, EXIF_TAG_GPS_ALTITUDE_REF, EXIF_TYPE_BYTE, 1, + exifInfo->gps_altitude_ref); + writeExifIfd(&pCur, EXIF_TAG_GPS_ALTITUDE, EXIF_TYPE_RATIONAL, 1, + &exifInfo->gps_altitude, &LongerTagOffset, pIfdStart); + } + + if (exifInfo->enableGps & EXIF_GPS_TIMESTAMP) { + writeExifIfd(&pCur, EXIF_TAG_GPS_TIMESTAMP, EXIF_TYPE_RATIONAL, 3, + exifInfo->gps_timestamp, &LongerTagOffset, pIfdStart); + } + + if (exifInfo->enableGps & EXIF_GPS_IMG_DIRECTION) { + writeExifIfd(&pCur, EXIF_TAG_GPS_IMG_DIRECTION_REF, EXIF_TYPE_ASCII, 2, + exifInfo->gps_img_direction_ref); + writeExifIfd(&pCur, EXIF_TAG_GPS_IMG_DIRECTION, EXIF_TYPE_RATIONAL, 1, + &exifInfo->gps_img_direction, &LongerTagOffset, pIfdStart); + } + + if (exifInfo->enableGps & EXIF_GPS_PROCMETHOD) { + tmp = strlen((char*)exifInfo->gps_processing_method); + if (tmp > 0) { + if (tmp > 100) { + tmp = 100; + } + unsigned char tmp_buf[100 + sizeof(ExifAsciiPrefix)]; + MEMCPY_S(tmp_buf, sizeof(tmp_buf), ExifAsciiPrefix, sizeof(ExifAsciiPrefix)); + MEMCPY_S(&tmp_buf[sizeof(ExifAsciiPrefix)], 100, exifInfo->gps_processing_method, + tmp); + writeExifIfd(&pCur, EXIF_TAG_GPS_PROCESSING_METHOD, EXIF_TYPE_UNDEFINED, + tmp + sizeof(ExifAsciiPrefix), tmp_buf, &LongerTagOffset, pIfdStart); + } + } + writeExifIfd(&pCur, EXIF_TAG_GPS_DATESTAMP, EXIF_TYPE_ASCII, 11, exifInfo->gps_datestamp, + &LongerTagOffset, pIfdStart); + tmp = 0; + MEMCPY_S(pCur, OFFSET_SIZE, (int8_t*)&tmp, OFFSET_SIZE); // next IFD offset + pCur += OFFSET_SIZE; + } + + CheckAndLogError(LongerTagOffset >= EXIF_SIZE_LIMITATION, EXIF_FAIL, + "%s, the size exceeds 64K, line:%d", __func__, __LINE__); + + // 2 1th IFD TIFF Tags + if (exifInfo->enableThumb && (m_thumbBuf != nullptr) && (m_thumbSize > 0)) { + writeThumbData(pIfdStart, pNextIfdOffset, &LongerTagOffset, exifInfo); + } else { + tmp = 0; + MEMCPY_S(pNextIfdOffset, OFFSET_SIZE, (int8_t*)&tmp, + OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD + } + + // fill APP1 maker + unsigned char App1Marker[2] = {0xff, 0xe1}; + MEMCPY_S(pApp1Start, 2, App1Marker, 2); + pApp1Start += 2; + + // calc and fill the APP1 segment total size, 2 is length; 6 is ExifIdentifierCode + *size = 2 + 6 + LongerTagOffset; + + writeMarkerSizeToBuf(pApp1Start, *size); + + unsigned app2StartOffset = *size; + *size += 2; // APP1 marker size + + exif_status status = EXIF_SUCCESS; + + if (exifInfo->makernoteToApp2) { + LOG1("Makernote goes to APP2 segment."); + status = makeApp2((pApp1Start + app2StartOffset), *size, exifInfo); + } + + if (status != EXIF_SUCCESS) LOGW("Failed to create EXIF APP2 section"); + + LOG1("makeExif End"); + + return status; +} + +void ExifCreater::writeMarkerSizeToBuf(unsigned char* ptrTo, unsigned int size) { + unsigned char size_mm[2] = {static_cast((size >> 8) & 0xFF), + static_cast(size & 0xFF)}; + + MEMCPY_S(ptrTo, 2, size_mm, 2); +} + +/** + * makeApp2 + * + * Write the makernote to APP2 segment. Use multiple APP2 segments if makernote + * size is more than one segment (64 kb) + * + * \param pStartApp2 [IN] APP2 start address + * \param exifInfo [IN] Data to be written + * \param writeId [IN] Whether to write the Intel Makernote ID string. + * \param size [OUT] Total size after APP2 is written + */ +exif_status ExifCreater::makeApp2(void* pStartApp2, size_t& size, exif_attribute_t* exifInfo, + bool writeId) { + // APP2 marker will be written starting from the pos pointed to by + // pStartApp2 + + if (exifInfo->makerNoteDataSize <= 0) return EXIF_SUCCESS; + + int bytesLeftForSegment = EXIF_SIZE_LIMITATION; + int bytesToWrite = exifInfo->makerNoteDataSize; + + unsigned char *pCur = nullptr, *pApp2Start = nullptr; + unsigned char App2Marker[SIZEOF_APP2_MARKER] = {0xff, 0xe2}; + int writeCount = 0; + unsigned char* toWrite = exifInfo->makerNoteData; + + pCur = static_cast(pStartApp2); + + // Write Makernote up to ~64kB, then split to a new + // APP2 segment, if needed + while (bytesToWrite > 0) { + pApp2Start = pCur; + pCur += 4; // Skip 4 bytes for APP2 marker and length + + if (writeId) { + MEMCPY_S(pCur, sizeof(MAKERNOTE_ID), MAKERNOTE_ID, sizeof(MAKERNOTE_ID)); + pCur += sizeof(MAKERNOTE_ID); + size += sizeof(MAKERNOTE_ID); + // ID overhead for one APP2 segment + bytesLeftForSegment -= sizeof(MAKERNOTE_ID); + } + + // Overhead for one APP2 segment: + bytesLeftForSegment -= (sizeof(App2Marker) + SIZEOF_LENGTH_FIELD); + + if (bytesToWrite > bytesLeftForSegment) { + // More data to write than what fits to one APP2 marker + writeCount = bytesLeftForSegment; + } else { + // All data fits to one APP2 segment + writeCount = bytesToWrite; + } + + bytesToWrite -= writeCount; + + MEMCPY_S(pCur, writeCount, toWrite, writeCount); + pCur += writeCount; + toWrite += writeCount; + size += writeCount; + + // Last, put the APP2 marker to the beginning of the segment + MEMCPY_S(pApp2Start, sizeof(App2Marker), App2Marker, sizeof(App2Marker)); + pApp2Start += sizeof(App2Marker); + + // Length field goes after the APP2 marker + int app2SegmentSize = writeCount + SIZEOF_LENGTH_FIELD; // Raw data written + overhead + if (writeId) app2SegmentSize += sizeof(MAKERNOTE_ID); + + writeMarkerSizeToBuf(pApp2Start, app2SegmentSize); + + // add the 2 bytes for both length field and APP2 marker, the caller has to know the total + // size + size += sizeof(App2Marker) + SIZEOF_LENGTH_FIELD; + + // Reset byte counts for another APP2 segment, if needed + bytesLeftForSegment = EXIF_SIZE_LIMITATION; + } + + return EXIF_SUCCESS; +} + +void ExifCreater::writeThumbData(unsigned char* pIfdStart, unsigned char* pNextIfdOffset, + unsigned int* LongerTagOffset, exif_attribute_t* exifInfo) { + unsigned char* pCur; + unsigned int tmp; + + // firstly calc the exif total size, if it's > 64K, we'll disable the thumbnail + tmp = 4 + 6 + *LongerTagOffset; // 4 is APP1 marker and length; 6 is ExifIdentifierCode + tmp += NUM_SIZE + NUM_1TH_IFD_TIFF * IFD_SIZE + OFFSET_SIZE; + tmp += sizeof(exifInfo->x_resolution) + sizeof(exifInfo->y_resolution); + tmp += m_thumbSize; + + if (tmp > EXIF_SIZE_LIMITATION) { + LOG1("line:%d, in makeExif, exif total size(%d) > 64K, we'll disable thumbnail.", __LINE__, + tmp); + m_thumbSize = 0; + m_thumbBuf = nullptr; + tmp = 0; + MEMCPY_S(pNextIfdOffset, OFFSET_SIZE, (int8_t*)&tmp, + OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD + } else { + tmp = *LongerTagOffset; + MEMCPY_S(pNextIfdOffset, OFFSET_SIZE, (int8_t*)&tmp, + OFFSET_SIZE); // NEXT IFD offset skipped on 0th IFD + + pCur = pIfdStart + *LongerTagOffset; + + tmp = NUM_1TH_IFD_TIFF; + MEMCPY_S(pCur, NUM_SIZE, (int8_t*)&tmp, NUM_SIZE); + pCur += NUM_SIZE; + + *LongerTagOffset += NUM_SIZE + NUM_1TH_IFD_TIFF * IFD_SIZE + OFFSET_SIZE; + + writeExifIfd(&pCur, EXIF_TAG_IMAGE_WIDTH, EXIF_TYPE_LONG, 1, exifInfo->widthThumb); + writeExifIfd(&pCur, EXIF_TAG_IMAGE_HEIGHT, EXIF_TYPE_LONG, 1, exifInfo->heightThumb); + writeExifIfd(&pCur, EXIF_TAG_COMPRESSION_SCHEME, EXIF_TYPE_SHORT, 1, + exifInfo->compression_scheme); + writeExifIfd(&pCur, EXIF_TAG_ORIENTATION, EXIF_TYPE_SHORT, 1, exifInfo->orientation); + writeExifIfd(&pCur, EXIF_TAG_X_RESOLUTION, EXIF_TYPE_RATIONAL, 1, &exifInfo->x_resolution, + LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_Y_RESOLUTION, EXIF_TYPE_RATIONAL, 1, &exifInfo->y_resolution, + LongerTagOffset, pIfdStart); + writeExifIfd(&pCur, EXIF_TAG_RESOLUTION_UNIT, EXIF_TYPE_SHORT, 1, + exifInfo->resolution_unit); + writeExifIfd(&pCur, EXIF_TAG_JPEG_INTERCHANGE_FORMAT, EXIF_TYPE_LONG, 1, *LongerTagOffset); + writeExifIfd(&pCur, EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN, EXIF_TYPE_LONG, 1, m_thumbSize); + + tmp = 0; + MEMCPY_S(pCur, OFFSET_SIZE, (int8_t*)&tmp, OFFSET_SIZE); // next IFD offset + // pCur += OFFSET_SIZE; + + MEMCPY_S(pIfdStart + *LongerTagOffset, m_thumbSize, m_thumbBuf, m_thumbSize); + *LongerTagOffset += m_thumbSize; + } +} + +void ExifCreater::writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, uint32_t value) { + MEMCPY_S(*pCur, 2, (int8_t*)&tag, 2); + *pCur += 2; + MEMCPY_S(*pCur, 2, (int8_t*)&type, 2); + *pCur += 2; + MEMCPY_S(*pCur, 4, (int8_t*)&count, 4); + *pCur += 4; + MEMCPY_S(*pCur, 4, (int8_t*)&value, 4); + *pCur += 4; +} + +void ExifCreater::writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, unsigned char* pValue) { + char buf[4] = { + 0, + }; + + MEMCPY_S(buf, count, pValue, count); + MEMCPY_S(*pCur, 2, (int8_t*)&tag, 2); + *pCur += 2; + MEMCPY_S(*pCur, 2, (int8_t*)&type, 2); + *pCur += 2; + MEMCPY_S(*pCur, 4, (int8_t*)&count, 4); + *pCur += 4; + MEMCPY_S(*pCur, 4, (int8_t*)buf, 4); + *pCur += 4; +} + +void ExifCreater::writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, unsigned char* pValue, unsigned int* offset, + unsigned char* start) { + MEMCPY_S(*pCur, 2, (int8_t*)&tag, 2); + *pCur += 2; + MEMCPY_S(*pCur, 2, (int8_t*)&type, 2); + *pCur += 2; + MEMCPY_S(*pCur, 4, (int8_t*)&count, 4); + *pCur += 4; + MEMCPY_S(*pCur, 4, (int8_t*)offset, 4); + *pCur += 4; + MEMCPY_S(start + *offset, count, pValue, count); + *offset += count; +} + +void ExifCreater::writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, rational_t* pValue, unsigned int* offset, + unsigned char* start) { + MEMCPY_S(*pCur, 2, (int8_t*)&tag, 2); + *pCur += 2; + MEMCPY_S(*pCur, 2, (int8_t*)&type, 2); + *pCur += 2; + MEMCPY_S(*pCur, 4, (int8_t*)&count, 4); + *pCur += 4; + MEMCPY_S(*pCur, 4, (int8_t*)offset, 4); + *pCur += 4; + MEMCPY_S(start + *offset, 8 * count, (int8_t*)pValue, 8 * count); + *offset += 8 * count; +} + +} // namespace icamera diff --git a/src/jpeg/ExifCreater.h b/src/jpeg/ExifCreater.h new file mode 100644 index 00000000..bf90e260 --- /dev/null +++ b/src/jpeg/ExifCreater.h @@ -0,0 +1,114 @@ +/* + * Copyright Samsung Electronics Co.,LTD. + * Copyright (C) 2010 The Android Open Source Project + * Copyright (C) 2016-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * JPEG DRIVER MODULE (JpegEncoder.h) + * Author : ge.lee -- initial version + * Date : 03 June 2010 + * Purpose : This file implements the JPEG encoder APIs as needed by Camera HAL + */ + +#pragma once + +#include +#include + +#include "Exif.h" +#include "iutils/Utils.h" + +namespace icamera { + +#define MAX_JPG_WIDTH 4352 +#define MAX_JPG_HEIGHT 3264 +#define MAX_JPG_RESOLUTION (MAX_JPG_WIDTH * MAX_JPG_HEIGHT) + +#define MAX_JPG_THUMBNAIL_WIDTH 640 +#define MAX_JPG_THUMBNAIL_HEIGHT 480 +#define MAX_JPG_THUMBNAIL_RESOLUTION (MAX_JPG_THUMBNAIL_WIDTH * MAX_JPG_THUMBNAIL_HEIGHT) + +#define MAX_RGB_WIDTH 800 +#define MAX_RGB_HEIGHT 480 +#define MAX_RGB_RESOLUTION (MAX_RGB_WIDTH * MAX_RGB_HEIGHT) + +/*******************************************************************************/ +/* define JPG & image memory */ +/* memory area is 4k(PAGE_SIZE) aligned because of VirtualCopyEx() */ +#define JPG_STREAM_BUF_SIZE ((MAX_JPG_RESOLUTION / PAGE_SIZE + 1) * PAGE_SIZE) +#define JPG_STREAM_THUMB_BUF_SIZE ((MAX_JPG_THUMBNAIL_RESOLUTION / PAGE_SIZE + 1) * PAGE_SIZE) +#define JPG_FRAME_BUF_SIZE (((MAX_JPG_RESOLUTION * 3) / PAGE_SIZE + 1) * PAGE_SIZE) +#define JPG_FRAME_THUMB_BUF_SIZE (((MAX_JPG_THUMBNAIL_RESOLUTION * 3) / PAGE_SIZE + 1) * PAGE_SIZE) +#define JPG_RGB_BUF_SIZE (((MAX_RGB_RESOLUTION * 4) / PAGE_SIZE + 1) * PAGE_SIZE) + +#define JPG_TOTAL_BUF_SIZE \ + (JPG_STREAM_BUF_SIZE + JPG_STREAM_THUMB_BUF_SIZE + JPG_FRAME_BUF_SIZE + \ + JPG_FRAME_THUMB_BUF_SIZE + JPG_RGB_BUF_SIZE) + +#define JPG_MAIN_START 0x00 +#define JPG_THUMB_START JPG_STREAM_BUF_SIZE +#define IMG_MAIN_START (JPG_STREAM_BUF_SIZE + JPG_STREAM_THUMB_BUF_SIZE) +#define IMG_THUMB_START (IMG_MAIN_START + JPG_FRAME_BUF_SIZE) +/*******************************************************************************/ + +const char MAKERNOTE_ID[] = {0x49, 0x6e, 0x74, 0x65, 0x6c, 0x4d, + 0x6b, 0x6e, 0x6f, 0x74, 0x65, 0x0 /* "IntelMknote\0" */}; + +const unsigned SIZEOF_LENGTH_FIELD = 2; +const unsigned SIZEOF_APP2_MARKER = 2; +const unsigned SIZEOF_APP2_OVERHEAD = + sizeof(MAKERNOTE_ID) + SIZEOF_APP2_MARKER + SIZEOF_LENGTH_FIELD; +const bool ENABLE_APP2_MARKER = true; +typedef enum { EXIF_FAIL = -1, EXIF_SUCCESS = 0 } exif_status; + +class ExifCreater { + public: + ExifCreater(); + virtual ~ExifCreater(); + + exif_status setThumbData(const void* thumbBuf, unsigned int thumbSize); + + bool isThumbDataSet() const; + + exif_status makeExif(void* exifOut, exif_attribute_t* exifInfo, size_t* size); + + private: + exif_status makeApp2(void* pStartApp2, size_t& size, exif_attribute_t* exifInfo, + bool writeId = true); + void writeMarkerSizeToBuf(unsigned char* ptrTo, unsigned int size); + /* + Every IFD has 12Bytes. + Tag ID, 2B; Type, 2B; Count, 4B; Value/Offset, 4B; + If it is Value, please use the first two functions. + If it is Offset, please use the last two functions + and store the data in the rear. + */ + void writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, uint32_t value); + void writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, unsigned char* pValue); + void writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, rational_t* pValue, unsigned int* offset, + unsigned char* start); + void writeExifIfd(unsigned char** pCur, unsigned short tag, unsigned short type, + unsigned int count, unsigned char* pValue, unsigned int* offset, + unsigned char* start); + void writeThumbData(unsigned char* pIfdStart, unsigned char* pNextIfdOffset, + unsigned int* LongerTagOffset, exif_attribute_t* exifInfo); + + unsigned char* m_thumbBuf; // MAP: Added to set thumbnail from external data + unsigned int m_thumbSize; // MAP: Added to set thumbnail from external data +}; + +} // namespace icamera diff --git a/src/jpeg/IJpegEncoder.h b/src/jpeg/IJpegEncoder.h new file mode 100644 index 00000000..9e810b07 --- /dev/null +++ b/src/jpeg/IJpegEncoder.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2019-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "iutils/Utils.h" + +namespace icamera { + +#define DEFAULT_JPEG_QUALITY 95 +static const unsigned char mJpegMarkerSOI[2] = {0xFF, 0xD8}; + +struct EncodePackage { + EncodePackage() + : inputWidth(0), + inputHeight(0), + inputStride(0), + inputFormat(0), + inputSize(0), + inputBufferHandle(nullptr), + inputData(nullptr), + outputWidth(0), + outputHeight(0), + outputSize(0), + outputBufferHandle(nullptr), + outputData(nullptr), + quality(0), + encodedDataSize(0), + exifData(nullptr), + exifDataSize(0) {} + + /* input buffer info */ + int inputWidth; + int inputHeight; + int inputStride; + int inputFormat; + unsigned int inputSize; + void* inputBufferHandle; + void* inputData; + + /* output buffer info */ + int outputWidth; + int outputHeight; + unsigned int outputSize; + void* outputBufferHandle; + void* outputData; + + int quality; + uint32_t encodedDataSize; + uint8_t* exifData; + uint32_t exifDataSize; +}; + +class IJpegEncoder { + public: + IJpegEncoder(){}; + virtual ~IJpegEncoder(){}; + + static std::unique_ptr createJpegEncoder(); + virtual bool doJpegEncode(EncodePackage* package) = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(IJpegEncoder); +}; +} // namespace icamera diff --git a/src/jpeg/JpegMaker.cpp b/src/jpeg/JpegMaker.cpp new file mode 100644 index 00000000..4e38bbf0 --- /dev/null +++ b/src/jpeg/JpegMaker.cpp @@ -0,0 +1,222 @@ +/* + * Copyright (C) 2016-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG JpegMaker + +#include "JpegMaker.h" + +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +namespace icamera { + +JpegMaker::JpegMaker() { + LOG2("@%s", __func__); + mExifMaker = std::unique_ptr(new EXIFMaker()); +} + +JpegMaker::~JpegMaker() { + LOG2("@%s", __func__); +} + +status_t JpegMaker::setupExifWithMetaData(int bufWidth, int bufHeight, const Parameters& parameter, + ExifMetaData* metaData) { + LOG2("@%s", __func__); + + status_t status = OK; + + status = processJpegSettings(parameter, metaData); + CheckAndLogError(status != OK, status, "@%s: Process settngs for JPEG failed!", __func__); + + mExifMaker->initialize(bufWidth, bufHeight); + mExifMaker->pictureTaken(metaData); + + mExifMaker->enableFlash(metaData->flashFired, metaData->v3AeMode, metaData->flashMode); + mExifMaker->updateSensorInfo(parameter); + mExifMaker->saveMakernote(parameter); + + status = processExifSettings(parameter, metaData); + if (status != OK) { + LOGE("@%s: Process settngs for Exif! %d", __func__, status); + return status; + } + + mExifMaker->initializeLocation(metaData); + mExifMaker->setSensorAeConfig(parameter); + + if (metaData->software) mExifMaker->setSoftware(metaData->software); + + return status; +} + +status_t JpegMaker::getExif(const EncodePackage& thumbnailPackage, uint8_t* exifPtr, + uint32_t* exifSize) { + if (thumbnailPackage.encodedDataSize > 0 && thumbnailPackage.quality > 0) { + mExifMaker->setThumbnail(static_cast(thumbnailPackage.outputData), + thumbnailPackage.encodedDataSize, thumbnailPackage.outputWidth, + thumbnailPackage.outputHeight); + } + *exifSize = mExifMaker->makeExif(exifPtr); + return *exifSize > 0 ? OK : UNKNOWN_ERROR; +} + +status_t JpegMaker::processExifSettings(const Parameters& params, ExifMetaData* metaData) { + LOG2("@%s:", __func__); + status_t status = OK; + + status = processGpsSettings(params, metaData); + status |= processColoreffectSettings(params, metaData); + status |= processScalerCropSettings(params, metaData); + + return status; +} + +/* copy exif data into output buffer */ +void JpegMaker::writeExifData(EncodePackage* package) { + CheckAndLogError(package == nullptr, VOID_VALUE, "@%s, package is nullptr", __func__); + + if (package->exifDataSize == 0) return; + + CheckAndLogError(!package->outputData, VOID_VALUE, "@%s, outputData is nullptr", __func__); + CheckAndLogError(!package->exifData, VOID_VALUE, "@%s, exifData is nullptr", __func__); + + unsigned int jSOISize = sizeof(mJpegMarkerSOI); + unsigned char* jpegOut = reinterpret_cast(package->outputData); + MEMCPY_S(jpegOut, jSOISize, mJpegMarkerSOI, jSOISize); + jpegOut += jSOISize; + + MEMCPY_S(jpegOut, package->exifDataSize, reinterpret_cast(package->exifData), + package->exifDataSize); +} + +/** + * processJpegSettings + * + * Store JPEG settings to the exif metadata + * + * \param [IN] jpeg parameters + * \ metaData [out] metadata of the request + * + */ +status_t JpegMaker::processJpegSettings(const Parameters& params, ExifMetaData* metaData) { + LOG2("@%s:", __func__); + status_t status = OK; + + CheckAndLogError(!metaData, UNKNOWN_ERROR, "MetaData struct not intialized"); + + // make jpeg with thumbnail or not + camera_resolution_t thumbSize = {0}; + params.getJpegThumbnailSize(thumbSize); + LOG2("%s request thumbname size %dx%d", __func__, thumbSize.width, thumbSize.height); + + uint8_t new_jpeg_quality = DEFAULT_JPEG_QUALITY; + int ret = params.getJpegQuality(&new_jpeg_quality); + if (ret != icamera::OK) { + LOGW("cannot find jpeg quality, use default"); + } + metaData->mJpegSetting.jpegQuality = new_jpeg_quality; + + uint8_t new_jpeg_thumb_quality = DEFAULT_JPEG_QUALITY; + params.getJpegThumbnailQuality(&new_jpeg_thumb_quality); + metaData->mJpegSetting.jpegThumbnailQuality = new_jpeg_thumb_quality; + metaData->mJpegSetting.thumbWidth = thumbSize.width; + metaData->mJpegSetting.thumbHeight = thumbSize.height; + + int new_rotation = 0; + params.getJpegRotation(new_rotation); + metaData->mJpegSetting.orientation = new_rotation; + + LOG1("jpegQuality=%d,thumbQuality=%d,thumbW=%d,thumbH=%d,orientation=%d", + metaData->mJpegSetting.jpegQuality, metaData->mJpegSetting.jpegThumbnailQuality, + metaData->mJpegSetting.thumbWidth, metaData->mJpegSetting.thumbHeight, + metaData->mJpegSetting.orientation); + + params.getAeMode(metaData->aeMode); + params.getAwbMode(metaData->awbMode); + + metaData->currentFocusDistance = 0.0; + float focusDistance = 0.0; + params.getFocusDistance(focusDistance); + if (focusDistance != 0) { + metaData->currentFocusDistance = ceil(1000.0 / focusDistance); + } + LOG2("aeMode=%d, awbMode=%d, currentFocusDistance=%f", metaData->aeMode, metaData->awbMode, + metaData->currentFocusDistance); + + return status; +} + +/** + * This function will get GPS metadata from request setting + * + * \param[in] settings The Anroid metadata to process GPS settings from + * \param[out] metadata The EXIF data where the GPS setting are written to + */ +status_t JpegMaker::processGpsSettings(const Parameters& param, ExifMetaData* metadata) { + LOG2("@%s:", __func__); + status_t status = OK; + + // gps latitude + double new_gps_latitude = 0.0; + param.getJpegGpsLatitude(new_gps_latitude); + metadata->mGpsSetting.latitude = new_gps_latitude; + + double new_gps_longitude = 0.0; + param.getJpegGpsLongitude(new_gps_longitude); + metadata->mGpsSetting.longitude = new_gps_longitude; + + double new_gps_altitude = 0.0; + param.getJpegGpsAltitude(new_gps_altitude); + metadata->mGpsSetting.altitude = new_gps_altitude; + + // gps timestamp + int64_t new_gps_timestamp = 0; + param.getJpegGpsTimeStamp(new_gps_timestamp); + metadata->mGpsSetting.gpsTimeStamp = new_gps_timestamp; + + // gps processing method + char new_gps_processing_method[MAX_NUM_GPS_PROCESSING_METHOD + 1]; + CLEAR(new_gps_processing_method); + param.getJpegGpsProcessingMethod(MAX_NUM_GPS_PROCESSING_METHOD, new_gps_processing_method); + if (strlen(new_gps_processing_method) != 0) { + snprintf(metadata->mGpsSetting.gpsProcessingMethod, + sizeof(metadata->mGpsSetting.gpsProcessingMethod), "%s", + new_gps_processing_method); + } + + return status; +} + +status_t JpegMaker::processColoreffectSettings(const Parameters& param, ExifMetaData* metaData) { + LOG2("@%s:", __func__); + status_t status = OK; + + camera_effect_mode_t new_image_effect = CAM_EFFECT_NONE; + param.getImageEffect(new_image_effect); + metaData->effectMode = new_image_effect; + LOG2("effect mode=%d", metaData->effectMode); + + return status; +} + +status_t JpegMaker::processScalerCropSettings(const Parameters& param, ExifMetaData* metaData) { + LOG2("@%s:", __func__); + status_t status = OK; + + return status; +} + +} // namespace icamera diff --git a/src/jpeg/JpegMaker.h b/src/jpeg/JpegMaker.h new file mode 100644 index 00000000..8f503621 --- /dev/null +++ b/src/jpeg/JpegMaker.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2016-2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "EXIFMaker.h" +#include "EXIFMetaData.h" +#include "IJpegEncoder.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" + +namespace icamera { + +/** + * \class JpegMaker + * Does the EXIF header creation and appending to the provided jpeg buffer + * + */ +class JpegMaker { + public: /* Methods */ + explicit JpegMaker(); + virtual ~JpegMaker(); + status_t setupExifWithMetaData(int bufWidth, int bufHeight, const Parameters& parameter, + ExifMetaData* metaData); + status_t getExif(const EncodePackage& thumbnailPackage, uint8_t* exifPtr, uint32_t* exifSize); + void writeExifData(EncodePackage* package); + + private: /* Methods */ + // prevent copy constructor and assignment operator + DISALLOW_COPY_AND_ASSIGN(JpegMaker); + + status_t processExifSettings(const Parameters& params, ExifMetaData* metaData); + status_t processJpegSettings(const Parameters& params, ExifMetaData* metaData); + status_t processGpsSettings(const Parameters& params, ExifMetaData* metadata); + status_t processColoreffectSettings(const Parameters& params, ExifMetaData* metaData); + status_t processScalerCropSettings(const Parameters& params, ExifMetaData* metaData); + + private: /* Members */ + std::unique_ptr mExifMaker; +}; +} // namespace icamera diff --git a/src/jpeg/chrome/JpegEncoderCore.cpp b/src/jpeg/chrome/JpegEncoderCore.cpp new file mode 100644 index 00000000..1e4d4d63 --- /dev/null +++ b/src/jpeg/chrome/JpegEncoderCore.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2019-2022 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG JpegEncoderCore + +#include "JpegEncoderCore.h" + +#include +#include + +#include "iutils/CameraLog.h" +#include "iutils/Errors.h" +#include "iutils/Utils.h" +#include "PlatformData.h" + +namespace icamera { + +JpegEncoderCore::JpegEncoderCore() : mJpegCompressor(cros::JpegCompressor::GetInstance()) {} + +JpegEncoderCore::~JpegEncoderCore() {} + +std::unique_ptr IJpegEncoder::createJpegEncoder() { + return std::unique_ptr(new JpegEncoderCore()); +} + +/** + * doJpegEncode + * + * Do HW / SW JPEG encoding for the main buffer + * Do SW JPEG encoding for the thumbnail buffer + * + * \param pa [IN/OUT] Information that should be encoded + */ +bool JpegEncoderCore::doJpegEncode(EncodePackage* pa) { + HAL_TRACE_CALL(CAMERA_DEBUG_LOG_LEVEL1); + CheckAndLogError(pa == nullptr, false, "@%s, pa is nullptr", __func__); + + CheckAndLogError(pa->inputWidth != pa->outputWidth || pa->inputHeight != pa->outputHeight, + false, "@%s, input size != output size", __func__); + CheckAndLogError(pa->inputWidth <= 0 || pa->outputWidth <= 0, false, + "@%s, inputWidth:%d, outputWidth:%d", __func__, pa->inputWidth, + pa->outputWidth); + CheckAndLogError(pa->inputHeight <= 0 || pa->outputHeight <= 0, false, + "@%s, inputHeight:%d, outputHeight:%d", __func__, pa->inputHeight, + pa->outputHeight); + + LOG1("@%s: Using Google encoding...", __func__); + + nsecs_t startTime = CameraUtils::systemTime(); + + bool ret = false; + if (pa->inputBufferHandle && pa->outputBufferHandle && PlatformData::supportHwJpegEncode()) { + LOG1("%s, use buffer handle to do jpeg encode input: %p, output: %p", __func__, + pa->inputBufferHandle, pa->outputBufferHandle); + ret = mJpegCompressor->CompressImageFromHandle( + *reinterpret_cast(pa->inputBufferHandle), + *reinterpret_cast(pa->outputBufferHandle), pa->inputWidth, + pa->inputHeight, pa->quality, pa->exifData, pa->exifDataSize, &pa->encodedDataSize); + } else if (pa->inputData && pa->outputData) { + LOG1("%s, use buffer address to do jpeg encode input: %p, output: %p", __func__, + pa->inputData, pa->outputData); + ret = mJpegCompressor->CompressImageFromMemory( + pa->inputData, V4L2_PIX_FMT_NV12, pa->outputData, pa->outputSize, pa->inputWidth, + pa->inputHeight, pa->quality, pa->exifData, pa->exifDataSize, &pa->encodedDataSize); + } else { + LOGE("%s: Google encode input type and output type does not match", __func__); + } + + LOG1("@%s: Google encoding ret:%d, %dx%d need %ld ms, jpeg size %u, quality %d)", __func__, ret, + pa->outputWidth, pa->outputHeight, (CameraUtils::systemTime() - startTime) / 1000000, + pa->encodedDataSize, pa->quality); + return ret && pa->encodedDataSize > 0; +} +} // namespace icamera diff --git a/src/jpeg/chrome/JpegEncoderCore.h b/src/jpeg/chrome/JpegEncoderCore.h new file mode 100644 index 00000000..1c391724 --- /dev/null +++ b/src/jpeg/chrome/JpegEncoderCore.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2019-2021 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include "IJpegEncoder.h" +#include "cros-camera/jpeg_compressor.h" +#include "iutils/Utils.h" + +namespace icamera { + +class JpegEncoderCore : public IJpegEncoder { + public: + JpegEncoderCore(); + ~JpegEncoderCore(); + + virtual bool doJpegEncode(EncodePackage* pa); + + private: + DISALLOW_COPY_AND_ASSIGN(JpegEncoderCore); + + std::unique_ptr mJpegCompressor; +}; +} // namespace icamera diff --git a/src/jpeg/sw/SWJpegEncoder.cpp b/src/jpeg/sw/SWJpegEncoder.cpp new file mode 100644 index 00000000..c8d42254 --- /dev/null +++ b/src/jpeg/sw/SWJpegEncoder.cpp @@ -0,0 +1,740 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * Copyright (C) 2016-2021 Intel Corporation. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define LOG_TAG SWJpegEncoder + +#include "SWJpegEncoder.h" + +#include + +#include "ImageConverter.h" +#include "iutils/CameraLog.h" +#include "iutils/Utils.h" + +#define RESOLUTION_1_3MP_WIDTH 1280 +#define RESOLUTION_1_3MP_HEIGHT 960 + +namespace icamera { + +SWJpegEncoder::SWJpegEncoder() + : mJpegSize(-1), + mTotalWidth(0), + mTotalHeight(0), + mDstBuf(nullptr), + mCPUCoresNum(1) { + LOG2("@%s, line:%d", __func__, __LINE__); +} + +SWJpegEncoder::~SWJpegEncoder() { + LOG2("@%s, line:%d", __func__, __LINE__); +} + +std::unique_ptr IJpegEncoder::createJpegEncoder() { + return std::unique_ptr(new SWJpegEncoder()); +} + +/** + * \param package: encode package for either thumbnail or main image + * \return true if encoding succeeds + * \return false if encoding fails + */ +bool SWJpegEncoder::doJpegEncode(EncodePackage* package) { + CheckAndLogError(package == nullptr, false, "@%s, package is nullptr", __func__); + + int status = 0; + nsecs_t startTime = CameraUtils::systemTime(); + + LOG2("@%s: IN = {buf:%p, w:%u, h:%u, sz:%u, stride:%d, fmt:%s}", __func__, package->inputData, + package->inputWidth, package->inputHeight, package->inputSize, package->inputStride, + icamera::CameraUtils::format2string(package->inputFormat).c_str()); + + LOG2("@%s: OUT = {buf:%p, w:%u, h:%u, sz:%u, q:%d}", __func__, package->outputData, + package->outputWidth, package->outputHeight, package->outputSize, package->quality); + + if (package->inputWidth == 0 || package->inputHeight == 0 || package->inputFormat == 0) { + ALOGE("Invalid input received!"); + mJpegSize = -1; + goto exit; + } + + mTotalWidth = package->inputWidth; + mTotalHeight = package->inputHeight; + + /* + * For encoding main buffer, need to skip the exif data and SOI header. + * Because the SOI(jpeg maker) is written in the beginning of jpeg data when + * do encode, so only skip the exif data size here, and the SOI will be moved + * to the head of output buffer + */ + mDstBuf = reinterpret_cast(package->outputData) + package->exifDataSize; + + if (useMultiThreadEncoding(package->inputWidth, package->inputHeight)) + status = swEncodeMultiThread(*package); + else + status = swEncode(*package); + + if (status < 0) goto exit; + + package->encodedDataSize = mJpegSize; + + LOG2("@%s encode, total consume:%ums, encoded jpeg size: %d", __func__, + (unsigned)((CameraUtils::systemTime() - startTime) / 1000000), mJpegSize); + + return mJpegSize > 0 ? true : false; +exit: + return false; +} + +/** + * This function will decide if we need to enable the multi thread jpeg encoding. + * currently, we have two conditions to use the old single jpeg encoding. + * one is that the resolution is smaller than the 1.3M + * the other is that the CPU number is 1 + * + * \param width: the Jpeg width + * \param height: the Jpeg height + * + * \return false if we don't need multi thread Jpeg encoding + * \return true if we need multi thread Jpeg encoding + */ +bool SWJpegEncoder::useMultiThreadEncoding(int width, int height) { + LOG2("@%s, line:%d, width:%d, height:%d", __func__, __LINE__, width, height); + bool ret = false; + + /* more conditions could be added to here by according to the request */ + if ((width < RESOLUTION_1_3MP_WIDTH && height < RESOLUTION_1_3MP_HEIGHT)) + ret = false; + else if (width & 0xf) + ret = false; + else + ret = true; + + LOG2("@%s, line:%d, ret:%d", __func__, __LINE__, ret); + return ret; +} + +/** + * encode jpeg by calling the SWJpegEncoder which is the libjpeg wrapper + * single thread. + * + * \param package: jpeg encode package + * \return 0 if encoding was successful + * \return -1 if encoding failed + */ +int SWJpegEncoder::swEncode(const EncodePackage& package) { + LOG2("@%s, line:%d, use the libjpeg to do sw jpeg encoding", __func__, __LINE__); + int status = 0; + Codec encoder; + + encoder.init(); + encoder.setJpegQuality(package.quality); + status = encoder.configEncoding(package.inputWidth, package.inputHeight, package.inputStride, + static_cast(mDstBuf), + (package.outputSize - package.exifDataSize)); + const void* uv_buf = + static_cast(package.inputData) + package.inputStride * package.inputHeight; + + if (status) goto exit; + + status = encoder.doJpegEncoding(package.inputData, uv_buf, package.inputFormat); + if (status) goto exit; + +exit: + if (status) + mJpegSize = -1; + else + encoder.getJpegSize(&mJpegSize); + + encoder.deInit(); + + return (status ? -1 : 0); +} + +/** + * encode jpeg by calling the SWJpegEncoder which is the libjpeg wrapper + * multi thread. + * the thread number depends on the CPU number. + * + * \param package: jpeg encode package + * \return 0 if encoding was successful + * \return -1 if encoding failed + */ +int SWJpegEncoder::swEncodeMultiThread(const EncodePackage& package) { + LOG2("@%s, line:%d, use the libjpeg to do sw jpeg encoding", __func__, __LINE__); + int status = 0; + + init(mCPUCoresNum); + config(package); + + status = doJpegEncodingMultiThread(); + if (status) goto exit; + +exit: + mJpegSize = status ? -1 : mergeJpeg(); + deInit(); + + return (status ? -1 : 0); +} + +/** + * Initialize for the multi thread jpeg encoding + * + * it will create n CodecWorkerThread by according to the thread number. + */ +void SWJpegEncoder::init(unsigned int threadNum) { + unsigned int num = CLIP(threadNum, MAX_THREAD_NUM, MIN_THREAD_NUM); + LOG2("@%s, line:%d, thread number, pass:%d, real:%d", __func__, __LINE__, threadNum, num); + + for (unsigned int i = 0; i < num; i++) { + std::shared_ptr codecWorkerThread(new CodecWorkerThread); + mSwJpegEncoder.push_back(codecWorkerThread); + } +} + +/** + * deInit for the multi thread jpeg encoding + * + * it will release all n CodecWorkerThread + */ +void SWJpegEncoder::deInit(void) { + LOG2("@%s, line:%d", __func__, __LINE__); + for (auto& encoder : mSwJpegEncoder) { + encoder.reset(); + } + + mSwJpegEncoder.clear(); +} + +/** + * configue every thread for multi thread jpeg + * + * \param package: jpeg encode package + */ +void SWJpegEncoder::config(const EncodePackage& package) { + LOG2("@%s, line:%d", __func__, __LINE__); + std::shared_ptr encThread; + CodecWorkerThread::CodecConfig cfg; + + for (unsigned int i = 0; i < mSwJpegEncoder.size(); i++) { + cfg.width = package.inputWidth; + /* + for example, there are 4 threads. + the first 3 threads must align to 16 which is NV12_MCU_SIZE + but for the last thread, it doesn't have this request. + */ + cfg.height = ALIGN_16(package.inputHeight / mSwJpegEncoder.size()); + cfg.stride = package.inputStride; + /* + * For NV12 format, Y and UV data are independent, total size is width*height*1.5; + * For YUYV format, Y and UV data are crossing, total size is width*height*2; + * So the inBufY and inBufUV should be distinguished base on format. + */ + cfg.fourcc = package.inputFormat; + cfg.inBufY = + (cfg.fourcc == V4L2_PIX_FMT_YUYV) ? + static_cast(package.inputData) + cfg.stride * cfg.height * 2 * i : + static_cast(package.inputData) + cfg.stride * cfg.height * i; + cfg.inBufUV = + (cfg.fourcc == V4L2_PIX_FMT_NV12 || cfg.fourcc == V4L2_PIX_FMT_NV21) ? + (static_cast(package.inputData) + + package.inputStride * package.inputHeight + cfg.stride * cfg.height * i / 2) : + nullptr; + cfg.quality = package.quality; + cfg.outBufSize = (package.outputSize - package.exifDataSize - DEST_BUF_OFFSET) / + package.inputHeight * cfg.height; + cfg.outBuf = static_cast(mDstBuf) + DEST_BUF_OFFSET + cfg.outBufSize * i; + /* update the last thread's height */ + if (i == mSwJpegEncoder.size() - 1) { + cfg.height = package.inputHeight - cfg.height * (mSwJpegEncoder.size() - 1); + cfg.outBufSize = package.outputSize - package.exifDataSize - DEST_BUF_OFFSET - + cfg.outBufSize * (mSwJpegEncoder.size() - 1); + } + + encThread = mSwJpegEncoder[i]; + encThread->setConfig(cfg); + LOG2("@%s, line:%d, the %d picture thread cfg", __func__, __LINE__, i); + LOG2("@%s, line:%d, cfg.width:%d, cfg.height:%d", __func__, __LINE__, cfg.width, + cfg.height); + LOG2("@%s, line:%d, cfg.fourcc:%d, cfg.quality:%d", __func__, __LINE__, cfg.fourcc, + cfg.quality); + LOG2("@%s, line:%d, cfg.inBufY:%p, cfg.inBufUV:%p", __func__, __LINE__, cfg.inBufY, + cfg.inBufUV); + LOG2("@%s, line:%d, cfg.outBuf:%p, cfg.outBufSize:%d", __func__, __LINE__, cfg.outBuf, + cfg.outBufSize); + } +} + +/** + * the function will trigger the multi jpeg encoding + * + * \return 0 if encoding was successful + * \return -1 if encoding failed + */ +int SWJpegEncoder::doJpegEncodingMultiThread(void) { + LOG2("@%s, line:%d", __func__, __LINE__); + std::shared_ptr encThread; + status_t status = OK; + std::string threadName("CamHAL_SWEncodeMultiThread"); + + /* run all threads */ + for (unsigned int i = 0; i < mSwJpegEncoder.size(); i++) { + threadName = threadName + ":" + std::to_string(i); + LOG2("@%s, new sw jpeg thread name:%s", __func__, threadName.c_str()); + encThread = mSwJpegEncoder[i]; + status = encThread->runThread(threadName.c_str()); + if (status != OK) { + ALOGE("@%s, line:%d, start jpeg thread fail, thread name:%s", __func__, __LINE__, + threadName.c_str()); + return status; + } + } + + /* wait all threads to finish */ + for (unsigned int i = 0; i < mSwJpegEncoder.size(); i++) { + LOG2("@%s, the %d sw jpeg encoder thread before join!", __func__, i); + encThread = mSwJpegEncoder[i]; + encThread->waitThreadFinish(); + if (encThread->getJpegDataSize() == -1) status = UNKNOWN_ERROR; + } + + return status; +} + +/** + * the function will merge all jpeg pictures which are generated in multi threads + * to one jpeg picture + * + * \return int the merged jpeg size + */ +int SWJpegEncoder::mergeJpeg(void) { +#define HEADER_TOTAL_LEN 623 +#define HEADER_SOS_LEN 14 +#define HEADER_EOI_LEN 2 +#define HEADER_HEIGHT_POS 163 +#define HEADER_WIDTH_POS 165 +#define NV12_MCU_SIZE 16 + LOG2("@%s, line:%d", __func__, __LINE__); + int size = HEADER_TOTAL_LEN - HEADER_SOS_LEN; + CodecWorkerThread::CodecConfig cfg; + nsecs_t startTime; + std::shared_ptr encThread = mSwJpegEncoder.at(0); + if (encThread == nullptr) { + ALOGE("encThread is nullptr"); + return -1; + } + encThread->getConfig(&cfg); + + /* Write the JPEG header */ + MEMCPY_S(mDstBuf, size, cfg.outBuf, size); + + /* Update the width and height info */ + mDstBuf[HEADER_HEIGHT_POS] = (mTotalHeight >> 8) & 0xFF; + mDstBuf[HEADER_HEIGHT_POS + 1] = mTotalHeight & 0xFF; + mDstBuf[HEADER_WIDTH_POS] = (mTotalWidth >> 8) & 0xFF; + mDstBuf[HEADER_WIDTH_POS + 1] = mTotalWidth & 0xFF; + + /* Write the restarting interval */ + if (mSwJpegEncoder.size() > 1) { + unsigned int MCUs = (cfg.height / NV12_MCU_SIZE) * (cfg.width / NV12_MCU_SIZE); + mDstBuf[size++] = 0xFF; + mDstBuf[size++] = 0xDD; + mDstBuf[size++] = 0; + mDstBuf[size++] = 4; + mDstBuf[size++] = (MCUs >> 8) & 0xFF; + mDstBuf[size++] = MCUs & 0xFF; + } + + /* Write the SOS */ + MEMCPY_S(reinterpret_cast((unsigned long)mDstBuf + size), HEADER_SOS_LEN, + reinterpret_cast((unsigned long)cfg.outBuf + HEADER_TOTAL_LEN - HEADER_SOS_LEN), + HEADER_SOS_LEN); + size += HEADER_SOS_LEN; + + /* Write coded segments */ + for (unsigned int i = 0; i < mSwJpegEncoder.size(); i++) { + encThread = mSwJpegEncoder[i]; + startTime = CameraUtils::systemTime(); + encThread->getConfig(&cfg); + memmove(reinterpret_cast((unsigned long)mDstBuf + size), + reinterpret_cast((unsigned long)cfg.outBuf + HEADER_TOTAL_LEN), + (encThread->getJpegDataSize() - HEADER_TOTAL_LEN - HEADER_EOI_LEN)); + LOG2("@%s, wr %d segments, size:%d, consume:%ums", __func__, i, + (encThread->getJpegDataSize() - HEADER_TOTAL_LEN - HEADER_EOI_LEN), + (unsigned)((CameraUtils::systemTime() - startTime) / 1000000)); + size += (encThread->getJpegDataSize() - HEADER_TOTAL_LEN - HEADER_EOI_LEN); + + if (i != (mSwJpegEncoder.size() - 1)) { + mDstBuf[size++] = 0xFF; + mDstBuf[size++] = (i & 0x7) | 0xD0; + } + } + + /* Write EOI */ + mDstBuf[size++] = 0xFF; + mDstBuf[size++] = 0xD9; + + return size; +} + +SWJpegEncoder::CodecWorkerThread::CodecWorkerThread() : mDataSize(-1) { + LOG2("@%s, line:%d", __func__, __LINE__); + CLEAR(mCfg); +} + +SWJpegEncoder::CodecWorkerThread::~CodecWorkerThread() { + LOG2("@%s, line:%d", __func__, __LINE__); +} + +/** + * run one thread for multi thread jpeg encoding + * + * \param name: the thread name + */ +status_t SWJpegEncoder::CodecWorkerThread::runThread(const char* name) { + LOG2("@%s, line:%d", __func__, __LINE__); + return this->run(name); +} + +/** + * wait one thread until it has finished + * + */ +void SWJpegEncoder::CodecWorkerThread::waitThreadFinish(void) { + LOG2("@%s, line:%d", __func__, __LINE__); + this->join(); + this->requestExitAndWait(); +} + +/** + * get jpeg size which is done in one thread + * + * \return int the coded jpeg size + */ +int SWJpegEncoder::CodecWorkerThread::getJpegDataSize(void) { + LOG2("@%s, line:%d", __func__, __LINE__); + return mDataSize; +} + +/** + * the thread exe function for one jpeg thread + * when the encoding has been done, it will return false to terminate the thread + * + * \return false + */ +bool SWJpegEncoder::CodecWorkerThread::threadLoop() { + LOG2("@%s, line:%d, in CodecWorkerThread", __func__, __LINE__); + nsecs_t startTime = CameraUtils::systemTime(); + int ret = swEncode(); + LOG2("@%s one swEncode done!, consume:%ums, ret:%d", __func__, + (unsigned)((CameraUtils::systemTime() - startTime) / 1000000), ret); + + return false; +} + +/** + * this function will call the SWJpegEncoder to encode one jpeg. + * it's the main function of the threadLoop + * + * \return 0 if encoding was successful + * \return -1 if encoding failed + */ +int SWJpegEncoder::CodecWorkerThread::swEncode(void) { + LOG2("@%s, line:%d, in CodecWorkerThread", __func__, __LINE__); + int status = 0; + Codec encoder; + + encoder.init(); + encoder.setJpegQuality(mCfg.quality); + status = encoder.configEncoding(mCfg.width, mCfg.height, mCfg.stride, + static_cast(mCfg.outBuf), mCfg.outBufSize); + if (status) goto exit; + + status = encoder.doJpegEncoding(mCfg.inBufY, mCfg.inBufUV, mCfg.fourcc); + if (status) goto exit; + +exit: + if (status) + mDataSize = -1; + else + encoder.getJpegSize(&mDataSize); + + encoder.deInit(); + + return (status ? -1 : 0); +} + +SWJpegEncoder::Codec::Codec() : mStride(-1), mJpegQuality(DEFAULT_JPEG_QUALITY) { + LOG2("@%s", __func__); + CLEAR(mCInfo); + CLEAR(mJErr); +} + +SWJpegEncoder::Codec::~Codec() { + LOG2("@%s", __func__); +} + +/** + * Init the SW jpeg encoder + * + * It will init the libjpeg library + */ +void SWJpegEncoder::Codec::init(void) { + LOG2("@%s", __func__); + CLEAR(mCInfo); + mCInfo.err = jpeg_std_error(&mJErr); + jpeg_create_compress(&mCInfo); +} + +/** + * deInit the SW jpeg encoder + * + * It will deinit the libjpeg library + */ +void SWJpegEncoder::Codec::deInit(void) { + LOG2("@%s", __func__); + jpeg_destroy_compress(&mCInfo); +} + +/** + * Set the jpeg quality + * + * \param quality: one value from 0 to 100 + * + */ +void SWJpegEncoder::Codec::setJpegQuality(int quality) { + LOG2("@%s, quality:%d", __func__, quality); + mJpegQuality = CLIP(quality, 100, 1); +} + +/** + * Config the SW jpeg encoder. + * + * mainly, it will set the destination buffer manager, color space, quality. + * + * \param width: the width of the jpeg dimentions. + * \param height: the height of the jpeg dimentions. + * \param jpegBuf: the dest buffer to store the jpeg data + * \param jpegBufSize: the size of jpegBuf buffer + * + * \return 0 if the configuration is right. + * \return -1 if the configuration fails. + */ +int SWJpegEncoder::Codec::configEncoding(int width, int height, int stride, void* jpegBuf, + int jpegBufSize) { + LOG2("@%s", __func__); + + mStride = stride; + mCInfo.input_components = 3; + mCInfo.in_color_space = (J_COLOR_SPACE)SUPPORTED_FORMAT; + mCInfo.image_width = width; + mCInfo.image_height = height; + + if (setupJpegDestMgr(&mCInfo, static_cast(jpegBuf), jpegBufSize) < 0) { + ALOGE("@%s, line:%d, setupJpegDestMgr fail", __func__, __LINE__); + return -1; + } + + jpeg_set_defaults(&mCInfo); + jpeg_set_colorspace(&mCInfo, (J_COLOR_SPACE)SUPPORTED_FORMAT); + jpeg_set_quality(&mCInfo, mJpegQuality, TRUE); + mCInfo.raw_data_in = TRUE; + mCInfo.dct_method = JDCT_ISLOW; + mCInfo.comp_info[0].h_samp_factor = 2; + mCInfo.comp_info[0].v_samp_factor = 2; + mCInfo.comp_info[1].h_samp_factor = 1; + mCInfo.comp_info[1].v_samp_factor = 1; + mCInfo.comp_info[2].h_samp_factor = 1; + mCInfo.comp_info[2].v_samp_factor = 1; + jpeg_start_compress(&mCInfo, TRUE); + + return 0; +} + +/** + * Do the SW jpeg encoding. + * + * it will convert the YUV data to P411 and then do jpeg encoding. + * + * \param y_buf: the source buffer for Y data + * \param uv_buf: the source buffer for UV data, + * \it could be nullptr if fourcc is V4L2_PIX_FMT_YUYV + * \return 0 if the encoding is successful. + * \return -1 if the encoding fails. + */ +int SWJpegEncoder::Codec::doJpegEncoding(const void* y_buf, const void* uv_buf, int fourcc) { + LOG2("@%s", __func__); + + unsigned char* srcY = nullptr; + unsigned char* srcUV = nullptr; + unsigned char* p411 = nullptr; + JSAMPROW y[16], u[16], v[16]; + JSAMPARRAY data[3]; + int i, j, width, height; + + width = mCInfo.image_width; + height = mCInfo.image_height; + srcY = (unsigned char*)y_buf; + srcUV = (unsigned char*)uv_buf; + p411 = new unsigned char[width * height * 3 / 2]; + + switch (fourcc) { + case V4L2_PIX_FMT_YUYV: + ImageConverter::YUY2ToP411(width, height, mStride, srcY, p411); + break; + case V4L2_PIX_FMT_NV12: + ImageConverter::NV12ToP411Separate(width, height, mStride, srcY, srcUV, p411); + break; + case V4L2_PIX_FMT_NV21: + ImageConverter::NV21ToP411Separate(width, height, mStride, srcY, srcUV, p411); + break; + default: + ALOGE("%s Unsupported fourcc %d", __func__, fourcc); + delete[] p411; + return -1; + } + + data[0] = y; + data[1] = u; + data[2] = v; + for (i = 0; i < height; i += 16) { + for (j = 0; j < 16 && (i + j) < height; j++) { + y[j] = p411 + width * (j + i); + if (j % 2 == 0) { + u[j / 2] = p411 + width * height + width / 2 * ((j + i) / 2); + v[j / 2] = p411 + width * height + width * height / 4 + width / 2 * ((j + i) / 2); + } + } + jpeg_write_raw_data(&mCInfo, data, 16); + } + + jpeg_finish_compress(&mCInfo); + + delete[] p411; + p411 = nullptr; + + return 0; +} + +/** + * Get the jpeg size. + * + * \param jpegSize: get the real jpeg size, it will be -1, if encoding fails + */ +void SWJpegEncoder::Codec::getJpegSize(int* jpegSize) { + LOG2("@%s", __func__); + + JpegDestMgrPtr dest = (JpegDestMgrPtr)mCInfo.dest; + + *jpegSize = (false == dest->encodeSuccess) ? -1 : dest->codedSize; +} + +/** + * Setup the jpeg destination buffer manager + * + * it will convert the YUV data to P411 and then do jpeg encoding. + * + * \param cInfo: the compress pointer + * \param jpegBuf: the buffer pointer for jpeg data + * \param jpegBufSize: the jpegBuf buffer's size + * \return 0 if it's successful. + * \return -1 if it fails. + */ +int SWJpegEncoder::Codec::setupJpegDestMgr(j_compress_ptr cInfo, JSAMPLE* jpegBuf, + int jpegBufSize) { + LOG2("@%s", __func__); + JpegDestMgrPtr dest; + + if (nullptr == jpegBuf || jpegBufSize <= 0) { + ALOGE("@%s, line:%d, jpegBuf:%p, jpegBufSize:%d", __func__, __LINE__, jpegBuf, jpegBufSize); + return -1; + } + + if (cInfo->dest == nullptr) { + cInfo->dest = (struct jpeg_destination_mgr*)(*cInfo->mem->alloc_small)( + (j_common_ptr)cInfo, JPOOL_PERMANENT, sizeof(JpegDestMgr)); + CLEAR(*cInfo->dest); + } + dest = (JpegDestMgrPtr)cInfo->dest; + + dest->pub.init_destination = initDestination; + dest->pub.empty_output_buffer = emptyOutputBuffer; + dest->pub.term_destination = termDestination; + dest->outJpegBuf = jpegBuf; + dest->outJpegBufSize = jpegBufSize; + + return 0; +} + +/** + * Init the destination + * + * It's the first function which be called + * among initDestination, emptyOutputBuffer and termDestination + * + * \param cInfo: the compress pointer + */ +void SWJpegEncoder::Codec::initDestination(j_compress_ptr cInfo) { + LOG2("@%s", __func__); + JpegDestMgrPtr dest = (JpegDestMgrPtr)cInfo->dest; + + dest->pub.next_output_byte = dest->outJpegBuf; + dest->pub.free_in_buffer = dest->outJpegBufSize; + dest->encodeSuccess = true; +} + +/** + * Empty the output buffer + * + * The function should not be called, + * because we should allocate enough memory for the jpeg destination buffer + * If we return FALSE, the libjpeg will terminate, so return TRUE always. + * But when the function is called, the encoding failing will be recorded. + * + * \param cInfo: the compress pointer + * \return TRUE if it is successful. + * \return FALSE if something is wrong + */ +boolean SWJpegEncoder::Codec::emptyOutputBuffer(j_compress_ptr cInfo) { + LOG2("@%s", __func__); + ALOGE("@%s, line:%d, buffer overflow!", __func__, __LINE__); + JpegDestMgrPtr dest = (JpegDestMgrPtr)cInfo->dest; + + /* re-cfg the buffer info */ + dest->pub.next_output_byte = dest->outJpegBuf; + dest->pub.free_in_buffer = dest->outJpegBufSize; + dest->encodeSuccess = false; + + return TRUE; /* if return FALSE, the total taking picture will fail */ +} + +/** + * Terminate the destination + * + * The function will be called as the last function, + * among initDestination, emptyOutputBuffer and termDestination. + * We can get the encoded jpeg size from it. + * + * \param cInfo: the compress pointer + */ +void SWJpegEncoder::Codec::termDestination(j_compress_ptr cInfo) { + LOG2("@%s", __func__); + JpegDestMgrPtr dest = (JpegDestMgrPtr)cInfo->dest; + + dest->codedSize = dest->outJpegBufSize - dest->pub.free_in_buffer; + LOG2("@%s, line:%d, codedSize:%d", __func__, __LINE__, dest->codedSize); +} + +} // namespace icamera diff --git a/src/jpeg/sw/SWJpegEncoder.h b/src/jpeg/sw/SWJpegEncoder.h new file mode 100644 index 00000000..170dfdbb --- /dev/null +++ b/src/jpeg/sw/SWJpegEncoder.h @@ -0,0 +1,186 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * Copyright (C) 2016-2020 Intel Corporation. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + *\file SWJpegEncoder.h + * + * Abstracts the SW jpeg encoder + * + * This class calls the libjpeg ditectly. And libskia's performance is poor. + * The SW jpeg encoder is used for the thumbnail encoding mainly. + * But When the HW jpeg encoding fails, it will use the SW jpeg encoder also. + * + */ + +#pragma once + +#include +#include + +#include + +#include "IJpegEncoder.h" +#include "iutils/Errors.h" +#include "iutils/Thread.h" +#include "iutils/Utils.h" + +#ifdef __cplusplus +extern "C" { +#endif +#include "jpeglib.h" +#ifdef __cplusplus +} +#endif + +namespace icamera { + +/** + * \class SWJpegEncoder + * + * This class is used for sw jpeg encoder. + * It will use single or multi thread to do the sw jpeg encoding + * It just support NV12 input currently. + */ +class SWJpegEncoder : public IJpegEncoder { + public: + SWJpegEncoder(); + ~SWJpegEncoder(); + + virtual bool doJpegEncode(EncodePackage* package); + + private: + // prevent copy constructor and assignment operator + DISALLOW_COPY_AND_ASSIGN(SWJpegEncoder); + + private: + bool useMultiThreadEncoding(int width, int height); + int swEncode(const EncodePackage& package); + int swEncodeMultiThread(const EncodePackage& package); + + int mJpegSize; /*!< it's used to store jpeg size */ + int mTotalWidth; /*!< the final jpeg width */ + int mTotalHeight; /*!< the final jpeg height */ + unsigned char* mDstBuf; /*!< the dest buffer to store the final jpeg */ + unsigned int mCPUCoresNum; /*!< use to remember the CPU Cores number */ + + private: + /** + * \class CodecWorkerThread + * + * This class will create one thread to do one sw jpeg encoder. + * It will call the SWJpegEncoderWrapper directly. + */ + class CodecWorkerThread : public Thread { + public: + struct CodecConfig { + // input buffer configuration + int width; + int height; + int stride; + int fourcc; + void* inBufY; + void* inBufUV; + // output buffer configuration + int quality; + void* outBuf; + int outBufSize; + }; + + CodecWorkerThread(); + ~CodecWorkerThread(); + + void setConfig(const CodecConfig& cfg) { mCfg = cfg; } + void getConfig(CodecConfig* cfg) const { *cfg = mCfg; } + status_t runThread(const char* name); + void waitThreadFinish(void); + int getJpegDataSize(void); + + private: + int mDataSize; /*!< the jpeg data size in one thread */ + CodecConfig mCfg; /*!< the cfg in one thread */ + private: + virtual bool threadLoop(); + int swEncode(void); + }; + + private: + void init(unsigned int threadNum = 1); + void deInit(void); + void config(const EncodePackage& package); + int doJpegEncodingMultiThread(void); + int mergeJpeg(void); + + std::vector > mSwJpegEncoder; + static const unsigned int MAX_THREAD_NUM = 8; /*!< the same as max jpeg restart time */ + static const unsigned int MIN_THREAD_NUM = 1; + + /*!< it's used to use one buffer to merge the multi jpeg data to one jpeg data */ + static const unsigned int DEST_BUF_OFFSET = 1024; + + private: + /** + * \class Codec + * + * This class is used for sw jpeg encoder. + * It will call the libjpeg directly. + * It just support NV12 input currently. + */ + class Codec { + public: + Codec(); + ~Codec(); + + void init(void); + void deInit(void); + void setJpegQuality(int quality); + int configEncoding(int width, int height, int stride, void* jpegBuf, int jpegBufSize); + /* + if fourcc is V4L2_PIX_FMT_NV12, y_buf and uv_buf must be passed + if fourcc is V4L2_PIX_FMT_YUYV, y_buf must be passed, uv_buf could be nullptr + */ + int doJpegEncoding(const void* y_buf, const void* uv_buf = nullptr, + int fourcc = V4L2_PIX_FMT_NV12); + void getJpegSize(int* jpegSize); + + private: + // prevent copy constructor and assignment operator + DISALLOW_COPY_AND_ASSIGN(Codec); + + private: + typedef struct { + struct jpeg_destination_mgr pub; + JSAMPLE* outJpegBuf; /*!< jpeg output buffer */ + int outJpegBufSize; /*!< jpeg output buffer size */ + int codedSize; /*!< the final encoded out jpeg size */ + bool encodeSuccess; /*!< if buffer overflow, it will be set to false */ + } JpegDestMgr, *JpegDestMgrPtr; + + int mStride; + struct jpeg_compress_struct mCInfo; + struct jpeg_error_mgr mJErr; + int mJpegQuality; + static const unsigned int SUPPORTED_FORMAT = JCS_YCbCr; + + int setupJpegDestMgr(j_compress_ptr cInfo, JSAMPLE* jpegBuf, int jpegBufSize); + // the below three functions are for the dest buffer manager. + static void initDestination(j_compress_ptr cInfo); + static boolean emptyOutputBuffer(j_compress_ptr cInfo); + static void termDestination(j_compress_ptr cInfo); + }; +}; + +} // namespace icamera diff --git a/src/metadata/ParameterGenerator.cpp b/src/metadata/ParameterGenerator.cpp index 3b9dc87a..696af3b5 100644 --- a/src/metadata/ParameterGenerator.cpp +++ b/src/metadata/ParameterGenerator.cpp @@ -68,8 +68,6 @@ ParameterGenerator::ParameterGenerator(int cameraId) mTonemapCurveGreen[i * 2 + 1] = index / (mTonemapMaxCurvePoints - 1); } } - CLEAR(mSensitivityRange); - info.capability->getSupportedSensorSensitivityRange(mSensitivityRange); } ParameterGenerator::~ParameterGenerator() {} @@ -327,19 +325,7 @@ int ParameterGenerator::updateWithAiqResultsL(int64_t sequence, Parameters* para } else { params->setExposureTime(aiqResult->mAeResults.exposures[0].exposure[0].exposure_time_us); } - - int iso = aiqResult->mAeResults.exposures[0].exposure[0].iso; - SensitivityRange range; - if (PlatformData::getSensitivityRangeByTuningMode(mCameraId, aiqResult->mTuningMode, - range) == OK) { - float ratio = static_cast(iso - range.min) / (range.max - range.min); - iso = mSensitivityRange.min + ratio * (mSensitivityRange.max - mSensitivityRange.min); - iso = CLIP(iso, mSensitivityRange.max, mSensitivityRange.min); - LOG2("%s, exposure[0].iso %d, iso %d", __func__, - aiqResult->mAeResults.exposures[0].exposure[0].iso, iso); - } - params->setSensitivityIso(iso); - + params->setSensitivityIso(aiqResult->mAeResults.exposures[0].exposure[0].iso); float fps = 1000000.0 / aiqResult->mFrameDuration; params->setFrameRate(fps); @@ -480,31 +466,6 @@ int ParameterGenerator::updateCommonMetadata(Parameters* params, const AiqResult entry.data.i64 = &frameDuration; ParameterHelper::mergeTag(entry, params); - uint8_t sensorMode = (aiqResult->mTuningMode == TUNING_MODE_VIDEO_BINNING) ? - INTEL_VENDOR_CAMERA_SENSOR_MODE_BINNING : INTEL_VENDOR_CAMERA_SENSOR_MODE_FULL; - entry.tag = INTEL_VENDOR_CAMERA_SENSOR_MODE; - entry.type = ICAMERA_TYPE_BYTE; - entry.count = 1; - entry.data.u8 = &sensorMode; - ParameterHelper::mergeTag(entry, params); - - int32_t isoRange[2]; - SensitivityRange range; - if (PlatformData::getSensitivityRangeByTuningMode(mCameraId, aiqResult->mTuningMode, - range) == OK) { - isoRange[0] = range.min; - isoRange[1] = range.max; - } else { - isoRange[0] = static_cast(mSensitivityRange.min); - isoRange[1] = static_cast(mSensitivityRange.max); - } - LOG2("%s, sensitivity range [%d-%d]", __func__, isoRange[0], isoRange[1]); - entry.tag = INTEL_VENDOR_CAMERA_SENSITIVITY_RANGE; - entry.type = ICAMERA_TYPE_INT32; - entry.count = 2; - entry.data.i32 = isoRange; - ParameterHelper::mergeTag(entry, params); - int32_t userRequestId = 0; params->getUserRequestId(userRequestId); camera_msg_data_t data = {CAMERA_METADATA_ENTRY, {}}; @@ -565,7 +526,7 @@ int ParameterGenerator::updateCommonMetadata(Parameters* params, const AiqResult if (aiqResult->mAiqParam.manualExpTimeUs <= 0 && aiqResult->mAiqParam.manualIso <= 0) { int64_t range[] = {aiqResult->mAeResults.exposures[0].exposure[0].low_limit_total_exposure, aiqResult->mAeResults.exposures[0].exposure[0].up_limit_total_exposure}; - LOG2("total et limits [%ld-%ld]", range[0], range[1]); + LOG2("total et limits [%ldx%ld]", range[0], range[1]); entry.tag = INTEL_VENDOR_CAMERA_TOTAL_EXPOSURE_TARGET_RANGE; entry.type = ICAMERA_TYPE_INT64; entry.count = 2; @@ -573,38 +534,6 @@ int ParameterGenerator::updateCommonMetadata(Parameters* params, const AiqResult ParameterHelper::mergeTag(entry, params); } - if (aiqResult->mAnalogGainRange[0] > 0.0 && aiqResult->mAnalogGainRange[1] > 0.0) { - LOG2("analog gain range is [%f-%f]", aiqResult->mAnalogGainRange[0], - aiqResult->mAnalogGainRange[1]); - entry.tag = INTEL_VENDOR_CAMERA_ANALOG_GAIN_RANGE; - entry.type = ICAMERA_TYPE_FLOAT; - entry.count = 2; - entry.data.f = aiqResult->mAnalogGainRange; - ParameterHelper::mergeTag(entry, params); - } - - if (aiqResult->mDigitalGainRange[0] > 0.0 && aiqResult->mDigitalGainRange[1] > 0.0) { - LOG2("digital gain range is [%f-%f]", aiqResult->mDigitalGainRange[0], - aiqResult->mDigitalGainRange[1]); - entry.tag = INTEL_VENDOR_CAMERA_DIGITAL_GAIN_RANGE; - entry.type = ICAMERA_TYPE_FLOAT; - entry.count = 2; - entry.data.f = aiqResult->mDigitalGainRange; - ParameterHelper::mergeTag(entry, params); - } - - entry.tag = INTEL_VENDOR_CAMERA_ANALOG_GAIN; - entry.type = ICAMERA_TYPE_FLOAT; - entry.count = 1; - entry.data.f = &aiqResult->mAeResults.exposures[0].exposure[0].analog_gain; - ParameterHelper::mergeTag(entry, params); - - entry.tag = INTEL_VENDOR_CAMERA_DIGITAL_GAIN; - entry.type = ICAMERA_TYPE_FLOAT; - entry.count = 1; - entry.data.f = &aiqResult->mAeResults.exposures[0].exposure[0].digital_gain;; - ParameterHelper::mergeTag(entry, params); - bool callbackTmCurve = false; params->getCallbackTmCurve(&callbackTmCurve); diff --git a/src/metadata/ParameterGenerator.h b/src/metadata/ParameterGenerator.h index 41e41a39..47bcb6bf 100644 --- a/src/metadata/ParameterGenerator.h +++ b/src/metadata/ParameterGenerator.h @@ -108,7 +108,6 @@ class ParameterGenerator { int32_t mTonemapMaxCurvePoints; camera_color_transform_t mPaCcm; - camera_range_t mSensitivityRange; }; } /* namespace icamera */ diff --git a/src/metadata/vendor_metadata_tag_info.c b/src/metadata/vendor_metadata_tag_info.c index d134e0f9..e85a4b7f 100644 --- a/src/metadata/vendor_metadata_tag_info.c +++ b/src/metadata/vendor_metadata_tag_info.c @@ -60,14 +60,6 @@ static tag_info_t intel_vendor_camera[INTEL_VENDOR_CAMERA_END - INTEL_VENDOR_CAM {"totalExposureTargetRange", ICAMERA_TYPE_INT64}, {"rawDataOutput", ICAMERA_TYPE_BYTE}, {"hdrRatio", ICAMERA_TYPE_FLOAT}, - {"moduleId", ICAMERA_TYPE_BYTE}, - {"sensorId", ICAMERA_TYPE_BYTE}, - {"sensorMode", ICAMERA_TYPE_BYTE}, - {"analogGainRange", ICAMERA_TYPE_FLOAT}, - {"digitalGainRange", ICAMERA_TYPE_FLOAT}, - {"analogGain", ICAMERA_TYPE_FLOAT}, - {"digitalGain", ICAMERA_TYPE_FLOAT}, - {"sensitivityRange", ICAMERA_TYPE_INT32}, }; tag_info_t* vendor_tag_info[INTEL_VENDOR_SECTION_COUNT] = { @@ -242,42 +234,6 @@ int vendor_metadata_enum_snprint(uint32_t tag, int32_t value, char* dst, size_t case INTEL_VENDOR_CAMERA_HDR_RATIO: { break; } - case INTEL_VENDOR_CAMERA_MODULE_ID: { - break; - } - case INTEL_VENDOR_CAMERA_SENSOR_ID: { - break; - } - case INTEL_VENDOR_CAMERA_SENSOR_MODE: { - switch (value) { - case INTEL_VENDOR_CAMERA_SENSOR_MODE_FULL: - msg = "FULL"; - ret = 0; - break; - case INTEL_VENDOR_CAMERA_SENSOR_MODE_BINNING: - msg = "BINNING"; - ret = 0; - break; - default: - msg = "error: enum value out of range"; - } - break; - } - case INTEL_VENDOR_CAMERA_ANALOG_GAIN_RANGE: { - break; - } - case INTEL_VENDOR_CAMERA_DIGITAL_GAIN_RANGE: { - break; - } - case INTEL_VENDOR_CAMERA_ANALOG_GAIN: { - break; - } - case INTEL_VENDOR_CAMERA_DIGITAL_GAIN: { - break; - } - case INTEL_VENDOR_CAMERA_SENSITIVITY_RANGE: { - break; - } } snprintf(dst, size, "%s", msg); diff --git a/src/opic2/OPIC2Api.h b/src/opic2/OPIC2Api.h new file mode 100644 index 00000000..10c132ba --- /dev/null +++ b/src/opic2/OPIC2Api.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef IC2API_FOR_CHROME_H +#define IC2API_FOR_CHROME_H + +#define EVCP_SUCCESS 0 + +extern "C" { + +#define KEYPOINTSCOUNT 40 +struct FaceResult { + int x; + int y; + int width; + int height; + float keypoints[KEYPOINTSCOUNT][2]; + bool valid; +}; + +enum iaic_media_format { iaic_nv12 }; +enum iaic_log_level { trace = 0, debug, info, warning, error, fatal }; + +enum class iaic_session_status { + uninitialized, + opening, + opened, + shutdown, + critical +}; + +struct iaic_memory { + const char* port_name; + const char* feature_name; + + union { + void* p; + void* r; + }; + + unsigned long long size[4]; + iaic_media_format media_type; + bool has_gfx; + struct iaic_memory* next; +}; + +struct iaic_options { + bool profiling = false; + bool blocked_init = false; + unsigned int threads = 1; + void* external_device = nullptr; +}; + +struct iaic_join_desc { + iaic_join_desc* next = nullptr; + const char* src_feature_name = nullptr; + const char* src_port_name = nullptr; + const char* dst_feature_name = nullptr; + const char* dst_port_name = nullptr; +}; + +typedef unsigned int iaic_session; + +extern void iaic_query_version(int* major, int* minor, int* patch); +extern void iaic_startup(); +extern void iaic_shutdown(); + +extern void iaic_query_features(char* future_d, size_t* fsize); +extern void iaic_startup(); +extern void iaic_shutdown(); + +extern void iaic_set_loglevel(iaic_log_level level); +extern void iaic_create_session(iaic_session uid, const char* feature, iaic_options opt); +extern void iaic_close_session(iaic_session uid, const char* feature); +extern void iaic_join_session(iaic_session uid, iaic_join_desc desc); +extern void iaic_disjoin_session(iaic_session uid, iaic_join_desc desc); +extern void iaic_pause_feature(iaic_session uid, const char* feature); +extern void iaic_resume_feature(iaic_session uid, const char* feature); +extern bool iaic_execute(iaic_session uid, iaic_memory in, iaic_memory out); +extern void iaic_set_data(iaic_session uid, iaic_memory& data); +extern void iaic_get_data(iaic_session uid, iaic_memory& data); +extern iaic_session_status iaic_get_status(iaic_session uid, const char* feature); + +struct evcp_context { + std::unique_ptr obj; + iaic_session sessionid; + short width; + short height; + void* hdl; + int sync; +}; + +extern evcp_context* evcp_create_context(int w, int h, void* hdl, int bit); +extern void evcp_destroy_context(evcp_context* ctx); +extern int evcp_toggle_ecc(evcp_context* ctx, int enable); +extern int evcp_toggle_background_concealment(evcp_context* ctx, int enable); +extern int evcp_toggle_background_replacement(evcp_context* ctx, int enable); +extern int evcp_set_background_url(evcp_context* ctx, const char* path); +extern int evcp_toggle_face_centering(evcp_context* ctx, int enable); +extern int evcp_toggle_face_detection(evcp_context* ctx, int enable); +extern int evcp_get_face_result(evcp_context* ctx, FaceResult* result); + +} + +#endif diff --git a/src/platformdata/AiqInitData.cpp b/src/platformdata/AiqInitData.cpp index 1a07cfac..cd3f3c7c 100644 --- a/src/platformdata/AiqInitData.cpp +++ b/src/platformdata/AiqInitData.cpp @@ -125,7 +125,7 @@ void AiqData::saveDataToFile(const std::string& fileName, const ia_binary_data* AiqInitData::AiqInitData(const std::string& sensorName, const std::string& camCfgDir, const std::vector& tuningCfg, const std::string& nvmDir, - int maxNvmSize, const std::string& camModuleName, int cameraId) + int maxNvmSize, const std::string& camModuleName) : mSensorName(sensorName), mMaxNvmSize(maxNvmSize), mTuningCfg(tuningCfg), @@ -143,18 +143,9 @@ AiqInitData::AiqInitData(const std::string& sensorName, const std::string& camCf std::string postfix(".aiqb"); aiqbName.append(camModuleName); struct dirent* direntPtr = nullptr; - bool boardConfig = false; - bool HDRnetUsed = PlatformData::isHDRnetTuningUsed(cameraId, boardConfig); while ((direntPtr = readdir(dir)) != nullptr) { if ((strncmp(direntPtr->d_name, aiqbName.c_str(), aiqbName.length()) == 0) && (strstr(direntPtr->d_name, postfix.c_str()) != nullptr)) { - if (boardConfig) { - if (HDRnetUsed && (strstr(direntPtr->d_name, "hdrnet") == nullptr)) - continue; - else if (!HDRnetUsed && - (strstr(direntPtr->d_name, "hdrnet") != nullptr)) - continue; - } aiqbNameFromModuleInfo.insert(direntPtr->d_name); } } diff --git a/src/platformdata/AiqInitData.h b/src/platformdata/AiqInitData.h index 70e7aa64..898dd359 100644 --- a/src/platformdata/AiqInitData.h +++ b/src/platformdata/AiqInitData.h @@ -56,7 +56,7 @@ class AiqInitData { public: AiqInitData(const std::string& sensorName, const std::string& camCfgDir, const std::vector& tuningCfg, const std::string& nvmDir, - int maxNvmSize, const std::string& camModuleName, int cameraId); + int maxNvmSize, const std::string& camModuleName); ~AiqInitData(); // cpf diff --git a/src/platformdata/CameraParser.cpp b/src/platformdata/CameraParser.cpp index 507a46f6..258eead5 100644 --- a/src/platformdata/CameraParser.cpp +++ b/src/platformdata/CameraParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation + * Copyright (C) 2015-2023 Intel Corporation * Copyright 2008-2017, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,11 +49,8 @@ CameraParser::CameraParser(MediaControl* mc, PlatformData::StaticCfg* cfg) mCurrentDataField(FIELD_INVALID), mSensorNum(0), mCurrentSensor(0), - mCaptureIdLinkIndex(0), - mCaptureIdIndex(0), pCurrentCam(nullptr), mInMediaCtlCfg(false), - mSkipMediaCtlCfg(false), mInStaticMetadata(false), mMC(mc), mMetadataCache(nullptr), @@ -61,8 +58,6 @@ CameraParser::CameraParser(MediaControl* mc, PlatformData::StaticCfg* cfg) LOG1("@%s", __func__); CheckAndLogError(cfg == nullptr, VOID_VALUE, "@%s, cfg is nullptr", __func__); - memset(mCaptureId, 0, sizeof(mCaptureId)); - // Get common data from libcamhal_profile.xml int ret = getDataFromXmlFile(LIBCAMHAL_PROFILE_NAME); CheckAndLogError(ret != OK, VOID_VALUE, "Failed to get libcamhal profile data from %s", @@ -136,15 +131,13 @@ CameraParser::~CameraParser() { * Replacing $I2CBUS with the real mI2CBus if the value contains the string "$I2CBUS" * one example: "imx319 $I2CBUS" * Replacing $CSI_PORT with the real mCsiPort if the value contains the string "$CSI_PORT" - * one example: "Intel IPU6 CSI-2 $CSI_PORT" or "Intel IPU6 CSI2 $CSI_PORT" - * Replacing $CAPTURE_ID with the real mCaptureId if the value contains the string "$CAPTURE_ID" + * one example: "Intel IPU6 CSI-2 $CSI_PORT" * * \param profiles: the pointer of the CameraParser. * \param value: camera information. * \return: if the value contains the string, it will be replaced. */ -string CameraParser::replaceStringInXml(CameraParser* profiles, const char* value, - const char* name) { +string CameraParser::replaceStringInXml(CameraParser* profiles, const char* value) { string valueTmp; CheckAndLogError(value == nullptr, valueTmp, "value is nullptr"); @@ -154,20 +147,6 @@ string CameraParser::replaceStringInXml(CameraParser* profiles, const char* valu valueTmp.replace(found, sizeof("$I2CBUS"), profiles->mI2CBus); } else if ((found = valueTmp.find("$CSI_PORT")) != string::npos) { valueTmp.replace(found, sizeof("$CSI_PORT"), profiles->mCsiPort); - } else if ((found = valueTmp.find("$CAPTURE_ID")) != string::npos) { - if (strcmp(name, "link") == 0 && profiles->mCaptureIdLinkIndex < IPU_ISYS_CAPTURE_ID_MAX) { - int captureId = std::stoi(profiles->mCsiPort) * 8 + profiles->mCaptureIdLinkIndex; - valueTmp.replace(found, sizeof("$CAPTURE_ID"), std::to_string(captureId)); - profiles->mCaptureId[profiles->mCaptureIdLinkIndex] = captureId; - profiles->mCaptureIdLinkIndex++; - profiles->mCaptureIdIndex = 0; - } else if (strcmp(name, "videonode") == 0 && - profiles->mCaptureIdIndex < IPU_ISYS_CAPTURE_ID_MAX) { - valueTmp.replace(found, sizeof("$CAPTURE_ID"), - std::to_string(profiles->mCaptureId[profiles->mCaptureIdIndex])); - profiles->mCaptureIdIndex++; - profiles->mCaptureIdLinkIndex = 0; - } } return valueTmp; @@ -190,7 +169,7 @@ void CameraParser::getCsiPortAndI2CBus(CameraParser* profiles) { if ((availableSensorTmp.first.find(fullSensorName) != string::npos) && (sensorInfo->sensorFlag != true)) { /* parameters information format example: - sinkEntityName is "Intel IPU6 CSI-2 1" or "Intel IPU6 CSI2 1" + sinkEntityName is "Intel IPU6 CSI-2 1" profiles->pCurrentCam->sensorName is "ov8856-wf" or "ov8856" sensorName is "ov8856" */ @@ -279,8 +258,6 @@ void CameraParser::checkField(CameraParser* profiles, const char* name, const ch return; } - if (profiles->mIsAvailableSensor) return; - LOGE("@%s, name:%s, atts[0]:%s, xml format wrong", __func__, name, atts[0]); return; } @@ -324,10 +301,10 @@ void CameraParser::handleCommon(CameraParser* profiles, const char* name, const cfg->supportHwJpegEncode = strcmp(atts[1], "true") == 0; } else if (strcmp(name, "maxIsysTimeoutValue") == 0) { cfg->maxIsysTimeoutValue = atoi(atts[1]); - // LEVEL0_ICBM_S + // LEVEL0_ICBM_S } else if (strcmp(name, "useGPUICBM") == 0) { cfg->isGPUICBMEnabled = strcmp(atts[1], "true") == 0; - // LEVEL0_ICBM_E + // LEVEL0_ICBM_E } } @@ -354,8 +331,8 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const getSupportedFormat(atts[1], pCurrentCam->mSupportedISysFormat); } else if (strcmp(name, "iSysRawFormat") == 0) { pCurrentCam->mISysRawFormat = CameraUtils::string2PixelCode(atts[1]); - } else if (strcmp(name, "preferredOutput") == 0) { - parseSizesList(atts[1], pCurrentCam->mPreferOutput); + } else if (strcmp(name, "preferredStillOutput") == 0) { + parseSizesList(atts[1], pCurrentCam->mPreferStillOutput); } else if (strcmp(name, "configModeToStreamId") == 0) { char* srcDup = strdup(atts[1]); CheckAndLogError(!srcDup, VOID_VALUE, "Create a copy of source string failed."); @@ -374,8 +351,6 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const pCurrentCam->mEnableAIQ = strcmp(atts[1], "true") == 0; } else if (strcmp(name, "enableMkn") == 0) { pCurrentCam->mEnableMkn = strcmp(atts[1], "true") == 0; - } else if (strcmp(name, "ispTuningUpdate") == 0) { - pCurrentCam->mIspTuningUpdate = strcmp(atts[1], "true") == 0; } else if (strcmp(name, "AiqRunningInterval") == 0) { pCurrentCam->mAiqRunningInterval = atoi(atts[1]); } else if (strcmp(name, "AlgoRunningRate") == 0) { @@ -416,17 +391,6 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const // if same runnning rate of AE and AWB, stats running rate is supported pCurrentCam->mStatsRunningRate = true; } - } else if (strcmp(name, "disableHDRnetBoards") == 0) { - int size = strlen(atts[1]); - char src[size + 1]; - MEMCPY_S(src, size, atts[1], size); - src[size] = '\0'; - char* savePtr = nullptr; - char* tablePtr = strtok_r(src, ",", &savePtr); - while (tablePtr) { - pCurrentCam->mDisableHDRnetBoards.push_back(tablePtr); - tablePtr = strtok_r(nullptr, ",", &savePtr); - } } else if (strcmp(name, "useCrlModule") == 0) { pCurrentCam->mUseCrlModule = strcmp(atts[1], "true") == 0; // DOL_FEATURE_S @@ -462,33 +426,6 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const LOGE("unknown Lens HW type %s, set to LENS_NONE_HW", atts[1]); pCurrentCam->mLensHwType = LENS_NONE_HW; } - } else if (strcmp(name, "tuningModeToSensitivityMap") == 0) { - int size = strlen(atts[1]); - char src[size + 1]; - MEMCPY_S(src, size, atts[1], size); - src[size] = '\0'; - - char* savePtr = nullptr; - char* tuningMode = strtok_r(src, ",", &savePtr); - while (tuningMode) { - SensitivityRange range; - char* min = strtok_r(nullptr, ",", &savePtr); - char* max = strtok_r(nullptr, ",", &savePtr); - CheckAndLogError(!tuningMode || !min || !max, VOID_VALUE, "Wrong sensitivity map"); - - TuningMode mode = CameraUtils::string2TuningMode(tuningMode); - range.min = atoi(min); - range.max = atoi(max); - pCurrentCam->mTuningModeToSensitivityMap[mode] = range; - - tuningMode = strtok_r(nullptr, ",", &savePtr); - } - } else if (strcmp(name, "sensorMode") == 0) { - if (strcmp(atts[1], "binning") == 0) { - pCurrentCam->mSensorMode = SENSOR_MODE_BINNING; - } else if (strcmp(atts[1], "full") == 0) { - pCurrentCam->mSensorMode = SENSOR_MODE_FULL; - } } else if (strcmp(name, "enablePdaf") == 0) { pCurrentCam->mEnablePdaf = strcmp(atts[1], "true") == 0; } else if (strcmp(name, "sensorAwb") == 0) { @@ -583,8 +520,6 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const } } else if (strcmp(name, "initialSkipFrame") == 0) { pCurrentCam->mInitialSkipFrame = atoi(atts[1]); - } else if (strcmp(name, "initialPendingFrame") == 0) { - pCurrentCam->mInitialPendingFrame = atoi(atts[1]); } else if (strcmp(name, "maxRawDataNum") == 0) { pCurrentCam->mMaxRawDataNum = atoi(atts[1]); } else if (strcmp(name, "topBottomReverse") == 0) { @@ -700,9 +635,6 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const pCurrentCam->mFaceAeEnabled = strcmp(atts[1], "true") == 0; } else if (strcmp(name, "psysAlignWithSof") == 0) { pCurrentCam->mPsysAlignWithSof = strcmp(atts[1], "true") == 0; - } else if (strcmp(name, "psysAlignWithSystem") == 0) { - int val = atoi(atts[1]); - pCurrentCam->mMsPsysAlignWithSystem = val > 0 ? val : 0; } else if (strcmp(name, "psysBundleWithAic") == 0) { pCurrentCam->mPsysBundleWithAic = strcmp(atts[1], "true") == 0; } else if (strcmp(name, "swProcessingAlignWithIsp") == 0) { @@ -728,20 +660,16 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const val > 0 ? std::min(val, MAX_FACES_DETECTABLE) : MAX_FACES_DETECTABLE; } else if (strcmp(name, "tnrExtraFrameNum") == 0) { int val = atoi(atts[1]); - pCurrentCam->mTnrExtraFrameNum = val > 0 ? val : 0; + pCurrentCam->mTnrExtraFrameNum = val > 0 ? val : DEFAULT_TNR_EXTRA_FRAME_NUM; } else if (strcmp(name, "dummyStillSink") == 0) { pCurrentCam->mDummyStillSink = strcmp(atts[1], "true") == 0; - } else if (strcmp(name, "tnrThresholdSizes") == 0) { - parseSizesList(atts[1], pCurrentCam->mTnrThresholdSizes); - for (const auto& s : pCurrentCam->mTnrThresholdSizes) - LOG2("@%s, mTnrThresholdSizes: width:%d, height:%d", __func__, s.width, s.height); } else if (strcmp(name, "useGpuTnr") == 0) { pCurrentCam->mGpuTnrEnabled = strcmp(atts[1], "true") == 0; } else if (!strcmp(name, "removeCacheFlushOutputBuffer")) { pCurrentCam->mRemoveCacheFlushOutputBuffer = strcmp(atts[1], "true") == 0; } else if (!strcmp(name, "isPLCEnable")) { pCurrentCam->mPLCEnable = strcmp(atts[1], "true") == 0; - // PRIVACY_MODE_S + // PRIVACY_MODE_S } else if (strcmp(name, "supportPrivacy") == 0) { int val = atoi(atts[1]); if (val > 0 && val <= 2) { @@ -757,10 +685,10 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const if (val >= 0) { pCurrentCam->mPrivacyModeFrameDelay = val; } - // PRIVACY_MODE_E + // PRIVACY_MODE_E } else if (strcmp(name, "stillOnlyPipe") == 0) { pCurrentCam->mStillOnlyPipe = strcmp(atts[1], "true") == 0; - // VIRTUAL_CHANNEL_S + // VIRTUAL_CHANNEL_S } else if (strcmp(name, "vcAggregator") == 0) { int size = strlen(atts[1]); char src[size + 1]; @@ -771,7 +699,7 @@ void CameraParser::handleSensor(CameraParser* profiles, const char* name, const if (tablePtr) pCurrentCam->mVcAggregator.mName = tablePtr; tablePtr = strtok_r(nullptr, ",", &savePtr); if (tablePtr) pCurrentCam->mVcAggregator.mIndex = atoi(tablePtr); - // VIRTUAL_CHANNEL_E + // VIRTUAL_CHANNEL_E } else if (strcmp(name, "disableBLCByAGain") == 0) { int size = strlen(atts[1]); char src[size + 1]; @@ -859,7 +787,6 @@ int CameraParser::parseLardTags(const char* str, vector& lardTags void CameraParser::parseMediaCtlConfigElement(CameraParser* profiles, const char* name, const char** atts) { MediaCtlConf mc; - bool skipMediaCtlCfg = true; int idx = 0; while (atts[idx]) { @@ -879,22 +806,10 @@ void CameraParser::parseMediaCtlConfigElement(CameraParser* profiles, const char } else if (strcmp(key, "vbp") == 0) { mc.vbp = strtoul(atts[idx + 1], nullptr, 10); // DOL_FEATURE_E - } else if (strcmp(key, "mediaCfg") == 0) { - skipMediaCtlCfg = false; - if (strtol(atts[idx + 1], nullptr, 10) != profiles->mStaticCfg->mMediaCfgId) { - profiles->mSkipMediaCtlCfg = true; - return; - } } idx += 2; } - if (profiles->mSkipMediaCtlCfg || - (skipMediaCtlCfg && profiles->mStaticCfg->mMediaCfgId == IPU6_UPSTREAM_MEDIA_CFG)) { - profiles->mSkipMediaCtlCfg = true; - return; - } - LOG2("@%s, name:%s, atts[0]:%s, id: %d", __func__, name, atts[0], mc.mcId); // Add a new empty MediaControl Configuration profiles->pCurrentCam->mMediaCtlConfs.push_back(mc); @@ -913,7 +828,7 @@ void CameraParser::parseControlElement(CameraParser* profiles, const char* name, const char* val = atts[idx + 1]; LOG2("@%s, name:%s, atts[%d]:%s, atts[%d]:%s", __func__, name, idx, key, idx + 1, val); if (strcmp(key, "name") == 0) { - ctl.entityName = replaceStringInXml(profiles, val, name); + ctl.entityName = replaceStringInXml(profiles, val); if (profiles->mMC) { ctl.entity = profiles->mMC->getEntityIdByName(ctl.entityName.c_str()); } @@ -990,7 +905,7 @@ void CameraParser::parseSelectionElement(CameraParser* profiles, const char* nam const char* val = atts[idx + 1]; LOG2("@%s, name:%s, atts[%d]:%s, atts[%d]:%s", __func__, name, idx, key, idx + 1, val); if (strcmp(key, "name") == 0) { - sel.entityName = replaceStringInXml(profiles, val, name); + sel.entityName = replaceStringInXml(profiles, val); if (profiles->mMC) { sel.entity = profiles->mMC->getEntityIdByName(sel.entityName.c_str()); } @@ -1333,7 +1248,7 @@ void CameraParser::parseFormatElement(CameraParser* profiles, const char* name, const char* val = atts[idx + 1]; LOG2("@%s, name:%s, atts[%d]:%s, atts[%d]:%s", __func__, name, idx, key, idx + 1, val); if (strcmp(key, "name") == 0) { - fmt.entityName = replaceStringInXml(profiles, val, name); + fmt.entityName = replaceStringInXml(profiles, val); if (profiles->mMC) { fmt.entity = profiles->mMC->getEntityIdByName(fmt.entityName.c_str()); } @@ -1379,14 +1294,14 @@ void CameraParser::parseLinkElement(CameraParser* profiles, const char* name, co const char* val = atts[idx + 1]; LOG2("@%s, name:%s, atts[%d]:%s, atts[%d]:%s", __func__, name, idx, key, idx + 1, val); if (strcmp(key, "srcName") == 0) { - link.srcEntityName = replaceStringInXml(profiles, val, name); + link.srcEntityName = replaceStringInXml(profiles, val); if (profiles->mMC) { link.srcEntity = profiles->mMC->getEntityIdByName(link.srcEntityName.c_str()); } } else if (strcmp(key, "srcPad") == 0) { link.srcPad = strtoul(val, nullptr, 10); } else if (strcmp(key, "sinkName") == 0) { - link.sinkEntityName = replaceStringInXml(profiles, val, name); + link.sinkEntityName = replaceStringInXml(profiles, val); if (profiles->mMC) { link.sinkEntity = profiles->mMC->getEntityIdByName(link.sinkEntityName.c_str()); } @@ -1413,7 +1328,7 @@ void CameraParser::parseRouteElement(CameraParser* profiles, const char* name, c const char* val = atts[idx + 1]; LOG2("@%s, name:%s, atts[%d]:%s, atts[%d]:%s", __func__, name, idx, key, idx + 1, val); if (strcmp(key, "name") == 0) { - route.entityName = replaceStringInXml(profiles, val, name); + route.entityName = replaceStringInXml(profiles, val); if (profiles->mMC) { route.entity = profiles->mMC->getEntityIdByName(route.entityName.c_str()); } @@ -1434,12 +1349,12 @@ void CameraParser::parseRouteElement(CameraParser* profiles, const char* name, c mc.routes.push_back(route); } -void CameraParser::parseVideoElement(CameraParser* profiles, const char* name, +void CameraParser::parseVideoElement(CameraParser* profiles, const char* /*name*/, const char** atts) { McVideoNode videoNode; MediaCtlConf& mc = profiles->pCurrentCam->mMediaCtlConfs.back(); - videoNode.name = replaceStringInXml(profiles, atts[1], name); + videoNode.name = replaceStringInXml(profiles, atts[1]); videoNode.videoNodeType = GetNodeType(atts[3]); LOG2("@%s, name:%s, videoNodeType:%d", __func__, videoNode.name.c_str(), videoNode.videoNodeType); @@ -1750,10 +1665,6 @@ int CameraParser::getSupportedFormat(const char* str, vector& supportedForm void CameraParser::handleMediaCtlCfg(CameraParser* profiles, const char* name, const char** atts) { LOG2("@%s, name:%s, atts[0]:%s, profiles->mCurrentSensor:%d", __func__, name, atts[0], profiles->mCurrentSensor); - - if (profiles->mSkipMediaCtlCfg) - return; - if (strcmp(name, "MediaCtlConfig") == 0) { parseMediaCtlConfigElement(profiles, name, atts); } else if (strcmp(name, "link") == 0) { @@ -2138,8 +2049,8 @@ void CameraParser::endParseElement(void* userData, const char* name) { for (size_t i = 0; i < profiles->pCurrentCam->mSupportModuleNames.size(); i++) { if ((strcmp(pCurrentCam->mSupportModuleNames[i].c_str(), profiles->pCurrentCam->mCamModuleName.c_str()) == 0) || - (strcmp(pCurrentCam->mSupportModuleNames[i].c_str(), DEFAULT_MODULE_NAME) == - 0)) { + (strcmp(pCurrentCam->mSupportModuleNames[i].c_str(), + DEFAULT_MODULE_NAME) == 0)) { isCameraAvailable = true; // If find an available sensor, it will not search other sensors profiles->mIsAvailableSensor = true; @@ -2170,7 +2081,6 @@ void CameraParser::endParseElement(void* userData, const char* name) { if (strcmp(name, "MediaCtlConfig") == 0) { LOG2("@%s %s, mInMediaCtlCfg is set to false", __func__, name); profiles->mInMediaCtlCfg = false; - profiles->mSkipMediaCtlCfg = false; } if (strcmp(name, "StaticMetadata") == 0) { @@ -2196,11 +2106,12 @@ void CameraParser::endParseElement(void* userData, const char* name) { } } -int CameraParser::getCameraModuleNameFromEEPROM(PlatformData::StaticCfg::CameraInfo* cam) { +int CameraParser::getCameraModuleNameFromEEPROM(const std::string& nvmDir, + std::string* cameraModule) { const int moduleInfoOffset = CAMERA_MODULE_INFO_OFFSET; - FILE* eepromFile = fopen(cam->mNvmDirectory.c_str(), "rb"); + FILE* eepromFile = fopen(nvmDir.c_str(), "rb"); CheckAndLogError(!eepromFile, UNKNOWN_ERROR, "Failed to open EEPROM file in %s", - cam->mNvmDirectory.c_str()); + nvmDir.c_str()); // file size should be larger than CAMERA_MODULE_INFO_OFFSET fseek(eepromFile, 0, SEEK_END); @@ -2229,20 +2140,8 @@ int CameraParser::getCameraModuleNameFromEEPROM(PlatformData::StaticCfg::CameraI snprintf(tmpName, CAMERA_MODULE_INFO_SIZE, "%c%c_%04x", cameraModuleInfo.mModuleVendor[0], cameraModuleInfo.mModuleVendor[1], cameraModuleInfo.mModuleProduct); - cam->mCamModuleName.assign(tmpName); - LOG1("%s, aiqb name %s", __func__, cam->mCamModuleName.c_str()); - - char moduleId[CAMERA_MODULE_INFO_SIZE]; - snprintf(moduleId, CAMERA_MODULE_INFO_SIZE, "%c%c%04x", cameraModuleInfo.mModuleVendor[0], - cameraModuleInfo.mModuleVendor[1], cameraModuleInfo.mModuleProduct); - cam->mModuleId.assign(moduleId); - - char sensorId[CAMERA_MODULE_INFO_SIZE]; - snprintf(sensorId, CAMERA_MODULE_INFO_SIZE, "%c%c%04x", cameraModuleInfo.mSensorVendor[0], - cameraModuleInfo.mSensorVendor[1], cameraModuleInfo.mSensorModel); - cam->mSensorId.assign(sensorId); - - LOG1("module id %s, sensor id %s", cam->mModuleId.c_str(), cam->mSensorId.c_str()); + cameraModule->assign(tmpName); + LOG1("%s, aiqb name %s", __func__, cameraModule->c_str()); return OK; } @@ -2274,8 +2173,8 @@ void CameraParser::getNVMDirectory(CameraParser* profiles) { int size = static_cast(ftell(fp)); fseek(fp, 0, SEEK_SET); std::unique_ptr ptr(new char[size + 1]); + ptr[size] = 0; size_t readSize = fread(ptr.get(), sizeof(char), size, fp); - ptr[readSize] = 0; fclose(fp); if (readSize > 0) { @@ -2318,7 +2217,8 @@ void CameraParser::getNVMDirectory(CameraParser* profiles) { LOG2("NVM data is located in %s", nvmPath.c_str()); profiles->pCurrentCam->mNvmDirectory = nvmPath; profiles->pCurrentCam->mMaxNvmDataSize = nvm.dataSize; - int ret = getCameraModuleNameFromEEPROM(profiles->pCurrentCam); + int ret = getCameraModuleNameFromEEPROM(profiles->pCurrentCam->mNvmDirectory, + &profiles->pCurrentCam->mCamModuleName); LOG2("NVM dir %s, ret %d", profiles->pCurrentCam->mNvmDirectory.c_str(), ret); break; } else { @@ -2337,51 +2237,39 @@ void CameraParser::getNVMDirectory(CameraParser* profiles) { * 1. * The value is "'camera name'-wf/uf-'CSI port number'". * For example: camera name is "ov8856". Sensor's sink entity name is - * "Intel IPU6 CSI-2 2" or "Intel IPU6 CSI2 2" and it is world-facing. - * The value is ov8856-wf-2. + * "Intel IPU6 CSI-2 2" and it is word facing. The value is ov8856-wf-2. * 2. the platform value must be uppercase letter. * */ std::vector CameraParser::getAvailableSensors( - const std::string& ipuName, const std::vector& sensorsList, int mediaCfgId) { + const std::string& ipuName, const std::vector& sensorsList) { LOG2("@%s, ipuName:%s", __func__, ipuName.c_str()); - // sensor's sink entity name prefix:"Intel IPU6 CSI-2 2" or "Intel IPU6 CSI2 2" + /* if the string doesn't contain -wf- or -uf-, it needn't be parsed */ + if ((sensorsList[0].find("-wf-") == string::npos) && + (sensorsList[0].find("-uf-") == string::npos)) { + return sensorsList; + } + + // sensor's sink entity name prefix:Intel IPU6 CSI-2 2 std::string sensorSinkName = "Intel "; sensorSinkName.append(ipuName); - - if (mediaCfgId == IPU6_UPSTREAM_MEDIA_CFG) - sensorSinkName.append(" CSI2 "); - else - sensorSinkName.append(" CSI-2 "); + sensorSinkName.append(" CSI-2 "); std::vector availableSensors; for (auto& sensor : sensorsList) { - if (sensor.find("-") == string::npos) { - // sensors without suffix port number - if (mMC && mMC->checkAvailableSensor(sensor)) { - availableSensors.push_back(sensor); - LOG2("@%s, available sensor name: %s", __func__, sensor.c_str()); -#ifdef LINUX_BUILD - } else if (sensor.find("_usb") != string::npos) { - availableSensors.push_back(sensor); - LOG2("@%s, available usb sensor name: %s", __func__, sensor.c_str()); -#endif - } - } else { - // sensors with suffix port number - std::string portNum = sensor.substr(sensor.find_last_of('-') + 1); - std::string sensorSinkNameTmp = sensorSinkName + portNum; - std::string sensorName = sensor.substr(0, sensor.find_first_of('-')); - std::string sensorOutName = sensor.substr(0, sensor.find_last_of('-')); - - if (mMC && mMC->checkAvailableSensor(sensorName, sensorSinkNameTmp)) { - AvailableSensorInfo sensorInfo = {sensorSinkNameTmp, false}; - availableSensors.push_back(sensorOutName); - mAvailableSensor[sensor] = sensorInfo; - LOG2("@%s, available sensor name: %s, sensorSinkNameTmp:%s", __func__, - sensor.c_str(), sensorSinkNameTmp.c_str()); - } + std::string srcSensor = sensor; + std::string portNum = srcSensor.substr(srcSensor.find_last_of('-') + 1); + std::string sensorSinkNameTmp = sensorSinkName; + sensorSinkNameTmp.append(portNum); + std::string sensorName = srcSensor.substr(0, srcSensor.find_first_of('-')); + + if (mMC && mMC->checkAvailableSensor(sensorName, sensorSinkNameTmp)) { + AvailableSensorInfo sensorInfo = {sensorSinkNameTmp, false}; + availableSensors.push_back(srcSensor); + mAvailableSensor[srcSensor] = sensorInfo; + LOG2("@%s, The availabel sensor name:%s, sensorSinkNameTmp:%s", __func__, + srcSensor.c_str(), sensorSinkNameTmp.c_str()); } } @@ -2409,8 +2297,7 @@ void CameraParser::getSensorDataFromXmlFile(void) { // According to sensor name to get sensor data LOG1("%s, available sensors: %zu", __func__, mStaticCfg->mCommonConfig.availableSensors.size()); vector allSensors = getAvailableSensors(mStaticCfg->mCommonConfig.ipuName, - mStaticCfg->mCommonConfig.availableSensors, - mStaticCfg->mMediaCfgId); + mStaticCfg->mCommonConfig.availableSensors); if (allSensors.size() == 0) { LOGW("The style of libcamhal_profile is too old, please switch it as soon as possible !!!"); @@ -2418,7 +2305,13 @@ void CameraParser::getSensorDataFromXmlFile(void) { } for (auto sensor : allSensors) { - string sensorName = "sensors/" + sensor + ".xml"; + string sensorName = "sensors/"; + if ((sensor.find("-wf-") != string::npos) || (sensor.find("-uf-") != string::npos)) { + sensorName.append(sensor.substr(0, sensor.find_last_of('-'))); + } else { + sensorName.append(sensor); + } + sensorName.append(".xml"); LOG1("%s: parse sensor name %s", __func__, sensorName.c_str()); int ret = getDataFromXmlFile(sensorName); CheckAndLogError(ret != OK, VOID_VALUE, "Failed to get sensor profile data from %s", diff --git a/src/platformdata/CameraParser.h b/src/platformdata/CameraParser.h index 025c424e..467b1e01 100644 --- a/src/platformdata/CameraParser.h +++ b/src/platformdata/CameraParser.h @@ -74,7 +74,6 @@ struct CameraModuleInfo { #define CAMERA_MODULE_INFO_OFFSET 32 #define CAMERA_MODULE_INFO_SIZE 32 #define DEFAULT_MODULE_NAME "default" -#define IPU_ISYS_CAPTURE_ID_MAX 8 /** * \class CameraParser * @@ -97,15 +96,6 @@ class CameraParser : public ParserBase { int mCurrentSensor; std::string mI2CBus; std::string mCsiPort; - - /** - * mCaptureId is used to store Intel IPU6 ISYS Capture Id for each sensor. - * When parse Link, if it has video capture, mCaptureIdLinkIndex will add, and put value - * into mCaptureId. Otherwise, mCaptureIdIndex will add and get value from mCaptureId. - */ - int mCaptureId[IPU_ISYS_CAPTURE_ID_MAX]; - int mCaptureIdLinkIndex; - int mCaptureIdIndex; struct AvailableSensorInfo { std::string sinkEntityName; bool sensorFlag; @@ -113,7 +103,6 @@ class CameraParser : public ParserBase { std::unordered_map mAvailableSensor; PlatformData::StaticCfg::CameraInfo* pCurrentCam; bool mInMediaCtlCfg; - bool mSkipMediaCtlCfg; bool mInStaticMetadata; MediaControl* mMC; CameraMetadata mMetadata; @@ -142,8 +131,7 @@ class CameraParser : public ParserBase { char** endptr = nullptr); std::vector getAvailableSensors(const std::string& ipuName, - const std::vector& sensorsList, - int mediaCfgId); + const std::vector& sensorsList); void getSensorDataFromXmlFile(void); void getCsiPortAndI2CBus(CameraParser* profiles); void checkField(CameraParser* profiles, const char* name, const char** atts); @@ -186,9 +174,9 @@ class CameraParser : public ParserBase { void parseOutputMap(const char* str, std::vector& outputMap); - std::string replaceStringInXml(CameraParser* profiles, const char* value, const char* name); + std::string replaceStringInXml(CameraParser* profiles, const char* value); void getNVMDirectory(CameraParser* profiles); - int getCameraModuleNameFromEEPROM(PlatformData::StaticCfg::CameraInfo* cam); + int getCameraModuleNameFromEEPROM(const std::string& nvmDir, std::string* cameraModule); private: DISALLOW_COPY_AND_ASSIGN(CameraParser); diff --git a/src/platformdata/CameraTypes.h b/src/platformdata/CameraTypes.h index 8b146fe3..b239d7df 100644 --- a/src/platformdata/CameraTypes.h +++ b/src/platformdata/CameraTypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,12 +43,6 @@ enum { enum { LENS_VCM_HW = 0, LENS_NONE_HW }; -typedef enum { - SENSOR_MODE_UNKNOWN = 0, - SENSOR_MODE_FULL, - SENSOR_MODE_BINNING -} SensorMode; - enum { SENSOR_EXPOSURE_SINGLE = 0, /* sensor is single exposure */ SENSOR_FIX_EXPOSURE_RATIO, /* Fix exposure ratio between long and short exposure */ @@ -170,7 +164,7 @@ struct ExecutorDepth { typedef std::pair ShareReferIdDesc; struct PolicyConfig { - std::set graphIds; + int graphId; std::string policyDescription; std::vector pipeExecutorVec; std::vector exclusivePgs; @@ -179,6 +173,7 @@ struct PolicyConfig { bool enableBundleInSdv; PolicyConfig() { + graphId = -1; enableBundleInSdv = true; } }; @@ -245,11 +240,6 @@ struct MultiExpRange { ExpRange SHS3; }; -struct SensitivityRange { - int32_t min; - int32_t max; -}; - struct UserToPslOutputMap { camera_resolution_t User; camera_resolution_t Psl; diff --git a/src/platformdata/PlatformData.cpp b/src/platformdata/PlatformData.cpp index 37db7486..c4179fa7 100644 --- a/src/platformdata/PlatformData.cpp +++ b/src/platformdata/PlatformData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ #include #include -#include #include "CameraParser.h" #include "iutils/CameraLog.h" @@ -62,7 +61,6 @@ PlatformData::PlatformData() { MediaControl* mc = MediaControl::getInstance(); if (mc) { mc->initEntities(); - mStaticCfg.mMediaCfgId = mc->getMediaCfgId(); } CameraParser CameraParser(mc, &mStaticCfg); @@ -98,7 +96,7 @@ int PlatformData::init() { AiqInitData* aiqInitData = new AiqInitData( staticCfg->mCameras[i].sensorName, getCameraCfgPath(), staticCfg->mCameras[i].mSupportedTuningConfig, staticCfg->mCameras[i].mNvmDirectory, - staticCfg->mCameras[i].mMaxNvmDataSize, camModuleName, i); + staticCfg->mCameras[i].mMaxNvmDataSize, camModuleName); getInstance()->mAiqInitData.push_back(aiqInitData); staticCfg->getModuleInfoFromCmc(i); @@ -222,68 +220,21 @@ int PlatformData::queryGraphSettings(int cameraId, const stream_config_t* stream } int PlatformData::getEdgeNrSetting(int cameraId, float totalGain, float hdrRatio, - TuningMode mode, EdgeNrSetting& setting) { - LOG2("%s, tuningmode %d, totalGain %f, hdrRatio %f", __func__, mode, totalGain, hdrRatio); + EdgeNrSetting& setting) { const StaticCfg::CameraInfo& pCam = getInstance()->mStaticCfg.mCameras[cameraId]; - - auto totalMap = pCam.mTotalGainHdrRatioToEdgeNrMap.find(mode); - if (totalMap == pCam.mTotalGainHdrRatioToEdgeNrMap.end()) return NAME_NOT_FOUND; - - std::map> l1SettingMap; - // found the l1 value - auto l1Map = totalMap->second.equal_range(totalGain); - if (l1Map.second == totalMap->second.begin()) { - l1SettingMap[l1Map.second->first] = l1Map.second->second; - } else if (l1Map.first == totalMap->second.end()) { - --l1Map.first; - l1SettingMap[l1Map.first->first] = l1Map.first->second; - } else if (l1Map.first != l1Map.second) { - l1SettingMap[l1Map.first->first] = l1Map.first->second; - } else { - --l1Map.first; - l1SettingMap[l1Map.first->first] = l1Map.first->second; - l1SettingMap[l1Map.second->first] = l1Map.second->second; - } - - auto interpolation = [](float v, float low, float up, const EdgeNrSetting& l, - const EdgeNrSetting& u) { - EdgeNrSetting result = l; - result.edgeStrength += - static_cast((u.edgeStrength - l.edgeStrength) * (v - low) / (up - low) + 0.5); - result.nrStrength += - static_cast((u.nrStrength - l.nrStrength) * (v - low) / (up - low) + 0.5); - return result; - }; - - for (auto& it : l1SettingMap) { - std::map l2SettingMap; - // found the l2 values - auto l2Map = it.second.equal_range(hdrRatio); - if (l2Map.second == it.second.begin()) { - l2SettingMap[l2Map.second->first] = l2Map.second->second; - } else if (l2Map.first == it.second.end()) { - --l2Map.first; - l2SettingMap[l2Map.first->first] = l2Map.first->second; - } else if (l2Map.first != l2Map.second) { - l2SettingMap[l2Map.first->first] = l2Map.first->second; - } else { - --l2Map.first; - l2SettingMap[l2Map.first->first] = interpolation(hdrRatio, l2Map.first->first, - l2Map.second->first, l2Map.first->second, l2Map.second->second); + LOG2("%s, totalGain %f, hdrRatio %f", __func__, totalGain, hdrRatio); + + if (!pCam.mTotalGainHdrRatioToEdgeNrMap.empty()) { + // found the lower value in map + auto subMap = pCam.mTotalGainHdrRatioToEdgeNrMap.upper_bound(totalGain); + if (subMap != pCam.mTotalGainHdrRatioToEdgeNrMap.begin()) { + auto sub = (--subMap)->second; + auto it = sub.upper_bound(hdrRatio); + if (it != sub.begin()) { + setting = (--it)->second; + return OK; + } } - - it.second = l2SettingMap; - } - - if (l1SettingMap.size() == 1) { - setting = l1SettingMap.begin()->second.begin()->second; - return OK; - } else if (l1SettingMap.size() == 2) { - auto it = l1SettingMap.end(); - --it; - setting = interpolation(totalGain, l1SettingMap.begin()->first, it->first, - l1SettingMap.begin()->second.begin()->second, it->second.begin()->second); - return OK; } return NAME_NOT_FOUND; @@ -297,43 +248,10 @@ void PlatformData::releaseGraphConfigNodes() { } } -int PlatformData::getModuleInfo(int cameraId, std::string& moduleId, std::string& sensorId) { - const StaticCfg::CameraInfo& pCam = getInstance()->mStaticCfg.mCameras[cameraId]; - - if (pCam.mModuleId.empty() || pCam.mSensorId.empty()) return NAME_NOT_FOUND; - - moduleId = pCam.mModuleId; - sensorId = pCam.mSensorId; - - return OK; -} - const char* PlatformData::getSensorName(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].sensorName.c_str(); } -void PlatformData::setBoardName(const std::string& boardName) { - getInstance()->mStaticCfg.mBoardName = boardName; -} - -bool PlatformData::isHDRnetTuningUsed(int cameraId, bool& boardConfig) { - auto& boards = getInstance()->mStaticCfg.mCameras[cameraId].mDisableHDRnetBoards; - auto& boardName = getInstance()->mStaticCfg.mBoardName; - - if (!boards.empty()) boardConfig = true; - - if (boardName.empty()) return true; - - for (auto& board : boards) { - LOG2("mBoardName %s, board %s", boardName.c_str(), board.c_str()); - if (board == boardName) { - return false; - } - } - - return true; -} - const char* PlatformData::getSensorDescription(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].sensorDescription.c_str(); } @@ -346,38 +264,6 @@ int PlatformData::getLensHwType(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mLensHwType; } -void PlatformData::setSensorMode(int cameraId, SensorMode sensorMode) { - // Only change sensor mode when binning mode supported - if (!PlatformData::isBinningModeSupport(cameraId)) return; - getInstance()->mStaticCfg.mCameras[cameraId].mSensorMode = sensorMode; -} - -SensorMode PlatformData::getSensorMode(int cameraId) { - return getInstance()->mStaticCfg.mCameras[cameraId].mSensorMode; -} - -bool PlatformData::isBinningModeSupport(int cameraId) { - auto pCam = &getInstance()->mStaticCfg.mCameras[cameraId]; - for (auto& cfg : pCam->mSupportedTuningConfig) { - if (cfg.tuningMode == TUNING_MODE_VIDEO_BINNING) { - return true; - } - } - - return false; -} - -int PlatformData::getSensitivityRangeByTuningMode(int cameraId, TuningMode mode, - SensitivityRange& range) { - auto& map = getInstance()->mStaticCfg.mCameras[cameraId].mTuningModeToSensitivityMap; - if (map.find(mode) != map.end()) { - range = map[mode]; - return OK; - } - - return NAME_NOT_FOUND; -} - bool PlatformData::isPdafEnabled(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mEnablePdaf; } @@ -512,10 +398,6 @@ bool PlatformData::psysAlignWithSof(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mPsysAlignWithSof; } -int PlatformData::getMsOfPsysAlignWithSystem(int cameraId) { - return getInstance()->mStaticCfg.mCameras[cameraId].mMsPsysAlignWithSystem; -} - bool PlatformData::psysBundleWithAic(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mPsysBundleWithAic; } @@ -621,10 +503,11 @@ bool PlatformData::updateMediaFormat(int cameraId, bool isNarrow) { media_format = isNarrow ? media_format_bt2100_12b_cl_narrow : media_format_bt2100_12b_cl; break; default: - LOG1("invalid media format, default value used."); + LOGE("invalid media format, default value used."); return false; + break; } - LOG1("%s, media format in tuning: %d, media format for aic %d.", __func__, tuning_media_format, + LOGI("%s, media format in tuning: %d, media format for aic %d.", tuning_media_format, media_format); getInstance()->mStaticCfg.mCameras[cameraId].mMediaFormat = media_format; return true; @@ -677,10 +560,6 @@ unsigned int PlatformData::getInitialSkipFrame(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mInitialSkipFrame; } -unsigned int PlatformData::getInitialPendingFrame(int cameraId) { - return getInstance()->mStaticCfg.mCameras[cameraId].mInitialPendingFrame; -} - unsigned int PlatformData::getMaxRawDataNum(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mMaxRawDataNum; } @@ -721,37 +600,18 @@ int PlatformData::getAnalogGainLag(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mAnalogGainLag; } -PolicyConfig* PlatformData::getExecutorPolicyConfig(const std::set& graphIds) { +PolicyConfig* PlatformData::getExecutorPolicyConfig(int graphId) { + size_t i = 0; PlatformData::StaticCfg* cfg = &getInstance()->mStaticCfg; - size_t i = 0; - size_t graphCount = graphIds.size(); - PolicyConfig* pCfg = nullptr; for (i = 0; i < cfg->mPolicyConfig.size(); i++) { - PolicyConfig& policy = cfg->mPolicyConfig[i]; - // Previous platforms only support cfg with one graph id. - // Find cfg according to the first graphId for them - if (!graphIds.empty() && (*policy.graphIds.begin() == *graphIds.begin())) pCfg = &policy; - - if (policy.graphIds.size() != graphCount) continue; - bool match = true; - for (auto it = graphIds.cbegin(); it != graphIds.cend(); ++it) { - if (policy.graphIds.find(*it) == policy.graphIds.end()) { - match = false; - break; - } - } - if (match) { - return &policy; + if (graphId == cfg->mPolicyConfig[i].graphId) { + return &(cfg->mPolicyConfig[i]); } } - LOGW("Couldn't find the executor policy in xml, need %lu graphs:", graphIds.size()); - for (auto it = graphIds.begin(); it != graphIds.end(); ++it) { - LOGW(" graph id %d", *it); - } - if (pCfg) LOGW("%s: use cfg with graph id %d", __func__, *pCfg->graphIds.begin()); - return pCfg; + LOGW("Couldn't find the executor policy for graphId(%d), please check xml file", graphId); + return nullptr; } int PlatformData::numberOfCameras() { @@ -1390,7 +1250,7 @@ int PlatformData::getConfigModesByOperationMode(int cameraId, uint32_t operation return INVALID_OPERATION; } - CheckAndLog1(getInstance()->mStaticCfg.mCameras[cameraId].mSupportedTuningConfig.empty(), + CheckAndLogError(getInstance()->mStaticCfg.mCameras[cameraId].mSupportedTuningConfig.empty(), INVALID_OPERATION, "@%s, the tuning config in xml does not exist", __func__); if (operationMode == CAMERA_STREAM_CONFIGURATION_MODE_AUTO) { @@ -1559,8 +1419,7 @@ bool PlatformData::isCSIBackEndCapture(int cameraId) { for (const auto& node : mc->videoNodes) { if (node.videoNodeType == VIDEO_GENERIC && (node.name.find("BE capture") != string::npos || - node.name.find("BE SOC capture") != string::npos || - node.name.find("ISYS capture") != string::npos)) { + node.name.find("BE SOC capture") != string::npos)) { isCsiBECapture = true; break; } @@ -1576,9 +1435,7 @@ bool PlatformData::isCSIFrontEndCapture(int cameraId) { for (const auto& node : mc->videoNodes) { if (node.videoNodeType == VIDEO_GENERIC && - (node.name.find("CSI-2") != string::npos || - node.name.find("TPG") != string::npos || - node.name.find("CSI2") != string::npos)) { + (node.name.find("CSI-2") != string::npos || node.name.find("TPG") != string::npos)) { isCsiFeCapture = true; break; } @@ -1692,13 +1549,14 @@ camera_resolution_t* PlatformData::getPslOutputForRotation(int width, int height return nullptr; } -const camera_resolution_t* PlatformData::getPreferOutput(int width, int height, int cameraId) { - if (getInstance()->mStaticCfg.mCameras[cameraId].mPreferOutput.empty()) return nullptr; +const camera_resolution_t* PlatformData::getPreferStillOutput(int width, int height, + int cameraId) { + if (getInstance()->mStaticCfg.mCameras[cameraId].mPreferStillOutput.empty()) return nullptr; const std::vector& preferOutput = - getInstance()->mStaticCfg.mCameras[cameraId].mPreferOutput; + getInstance()->mStaticCfg.mCameras[cameraId].mPreferStillOutput; for (const auto& output : preferOutput) { - // get preferred output for small size + // get preferred still output for small size if ((width < output.width || height < output.height) && (width * output.height == height * output.width)) { LOG2(" the psl output: (%dx%d) for user: %dx%d", cameraId, output.width, @@ -1882,12 +1740,8 @@ int PlatformData::getVideoStreamNum() { return getInstance()->mStaticCfg.mCommonConfig.videoStreamNum; } -bool PlatformData::supportUpdateTuning(int cameraId) { - // Check if support UpdateTuning per platform config - if (getInstance()->mStaticCfg.mCommonConfig.supportIspTuningUpdate) return true; - - // check if support UpdateTuning per sensor config - return getInstance()->mStaticCfg.mCameras[cameraId].mIspTuningUpdate; +bool PlatformData::supportUpdateTuning() { + return getInstance()->mStaticCfg.mCommonConfig.supportIspTuningUpdate; } bool PlatformData::supportHwJpegEncode() { @@ -1937,11 +1791,6 @@ bool PlatformData::isDummyStillSink(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mDummyStillSink; } -void PlatformData::getTnrThresholdSizes(int cameraId, - std::vector& resolutions) { - resolutions = getInstance()->mStaticCfg.mCameras[cameraId].mTnrThresholdSizes; -} - bool PlatformData::isGpuTnrEnabled(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mGpuTnrEnabled; } @@ -1986,18 +1835,6 @@ int64_t PlatformData::getReqWaitTimeout(int cameraId) { return getInstance()->mStaticCfg.mCameras[cameraId].mReqWaitTimeout; } -v4l2_buf_type PlatformData::getV4L2BufType(int cameraId) { - return getInstance()->mStaticCfg.mCameras[cameraId].mV4l2BufType; -} - -void PlatformData::setV4L2BufType(int cameraId, v4l2_buf_type v4l2BufType) { - getInstance()->mStaticCfg.mCameras[cameraId].mV4l2BufType = v4l2BufType; -} - -int PlatformData::getMediaCfgId() { - return getInstance()->mStaticCfg.mMediaCfgId; -} - // LEVEL0_ICBM_S bool PlatformData::isGPUICBMEnabled() { return getInstance()->mStaticCfg.mCommonConfig.isGPUICBMEnabled; diff --git a/src/platformdata/PlatformData.h b/src/platformdata/PlatformData.h index 59699f6d..2adcb7ec 100644 --- a/src/platformdata/PlatformData.h +++ b/src/platformdata/PlatformData.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2024 Intel Corporation. + * Copyright (C) 2015-2023 Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,11 +63,14 @@ namespace icamera { #define FACE_ENGINE_INTEL_PVL 0 #define FACE_ENGINE_GOOGLE_FACESSD 1 +#define DEFAULT_TNR_EXTRA_FRAME_NUM 2 + /* Max number of the RAW buffer number is 32. * Max number size of the pipeline depth is 6. * Max setting count should be larger than raw buffer number + pipeline depth. */ #define MAX_SETTING_COUNT 40 +#define CAMERA_PORT_NAME "CSI-2" #ifdef CAL_BUILD #define MAX_CAMERA_NUMBER 2 @@ -89,14 +92,13 @@ namespace icamera { #define MAX_CAMERA_NUMBER 100 // Temporarily using current path to save aiqd file for none CAL platforms. #define CAMERA_CACHE_DIR "./" +#if !defined(CAMERA_DEFAULT_CFG_PATH) +#error CAMERA_DEFAULT_CFG_PATH not defined. +#endif #define CAMERA_GRAPH_DESCRIPTOR_FILE "gcss/graph_descriptor.xml" #define CAMERA_GRAPH_SETTINGS_DIR "gcss/" #endif -#ifndef CAMERA_DEFAULT_CFG_PATH -#error CAMERA_DEFAULT_CFG_PATH not defined -#endif - #define NVM_DATA_PATH "/sys/bus/i2c/devices/" #define TNR7US_RESTART_THRESHOLD 5 @@ -111,8 +113,7 @@ class PlatformData { public: class StaticCfg { public: - StaticCfg() - : mMediaCfgId(IPU6_DOWNSTREAM_MEDIA_CFG) { mCameras.clear(); } + StaticCfg() { mCameras.clear(); } ~StaticCfg() {} // not release resource by design /** @@ -131,7 +132,6 @@ class PlatformData { mVCGroupId(-1), // VIRTUAL_CHANNEL_E mLensHwType(LENS_NONE_HW), - mSensorMode(SENSOR_MODE_UNKNOWN), mEnablePdaf(false), mSensorAwb(false), mSensorAe(false), @@ -150,12 +150,10 @@ class PlatformData { mAiqRunningInterval(1), mStatsRunningRate(false), mEnableMkn(true), - mIspTuningUpdate(false), mSkipFrameV4L2Error(false), mCITMaxMargin(0), mYuvColorRangeMode(CAMERA_FULL_MODE_YUV_COLOR_RANGE), mInitialSkipFrame(0), - mInitialPendingFrame(0), mMaxRawDataNum(MAX_BUFFER_COUNT), mTopBottomReverse(false), mPsysContinueStats(false), @@ -197,12 +195,11 @@ class PlatformData { mFaceEngineByIPU(false), mMaxFaceDetectionNumber(MAX_FACES_DETECTABLE), mPsysAlignWithSof(false), - mMsPsysAlignWithSystem(0), mPsysBundleWithAic(false), mSwProcessingAlignWithIsp(false), mMaxNvmDataSize(0), mNvmOverwrittenFileSize(0), - mTnrExtraFrameNum(0), + mTnrExtraFrameNum(DEFAULT_TNR_EXTRA_FRAME_NUM), mDummyStillSink(false), mGpuTnrEnabled(false), mRemoveCacheFlushOutputBuffer(false), @@ -217,8 +214,7 @@ class PlatformData { mDisableBLCAGainLow(-1), mDisableBLCAGainHigh(-1), mResetLinkRoute(true), - mReqWaitTimeout(0), - mV4l2BufType(V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {} + mReqWaitTimeout(0) {} std::vector mMediaCtlConfs; @@ -233,8 +229,6 @@ class PlatformData { VcAggregator mVcAggregator; // VIRTUAL_CHANNEL_E int mLensHwType; - std::map mTuningModeToSensitivityMap; - SensorMode mSensorMode; bool mEnablePdaf; bool mSensorAwb; bool mSensorAe; @@ -253,7 +247,6 @@ class PlatformData { int mAiqRunningInterval; bool mStatsRunningRate; bool mEnableMkn; - bool mIspTuningUpdate; // first: one algo type in imaging_algorithm_t, second: running rate std::unordered_map mAlgoRunningRateMap; // DOL_FEATURE_S @@ -263,7 +256,6 @@ class PlatformData { int mCITMaxMargin; camera_yuv_color_range_mode_t mYuvColorRangeMode; unsigned int mInitialSkipFrame; - unsigned int mInitialPendingFrame; unsigned int mMaxRawDataNum; bool mTopBottomReverse; bool mPsysContinueStats; @@ -289,7 +281,6 @@ class PlatformData { std::vector mLardTagsConfig; std::vector mConfigModesForAuto; - std::vector mDisableHDRnetBoards; bool mUseCrlModule; int mOrientation; int mSensorOrientation; @@ -305,12 +296,8 @@ class PlatformData { std::map mStreamToMcMap; Parameters mCapability; - /* key: TuningMode, - value: map (key: total gain, - value: map (key: hdr ratio, - value: edge and noise settings)) */ - std::map>> mTotalGainHdrRatioToEdgeNrMap; + /* key: total gain, value: a map (key: hdr ratio, value: edge and noise settings) */ + std::map> mTotalGainHdrRatioToEdgeNrMap; std::string mGraphSettingsFile; GraphSettingType mGraphSettingsType; std::vector mMultiExpRanges; @@ -328,7 +315,6 @@ class PlatformData { bool mFaceEngineByIPU; unsigned int mMaxFaceDetectionNumber; bool mPsysAlignWithSof; - int mMsPsysAlignWithSystem; // Aligned with system time bool mPsysBundleWithAic; bool mSwProcessingAlignWithIsp; @@ -339,21 +325,18 @@ class PlatformData { // a PG might be incorrect. To be removed after stream id mismatch issue fixed. std::map mConfigModeToStreamId; std::vector mOutputMap; - std::vector mPreferOutput; + std::vector mPreferStillOutput; int mMaxNvmDataSize; std::string mNvmDirectory; int mNvmOverwrittenFileSize; std::string mNvmOverwrittenFile; // overwrite NVM data std::string mCamModuleName; - std::string mModuleId; - std::string mSensorId; std::vector mSupportModuleNames; /* key: camera module name, value: camera module info */ std::unordered_map mCameraModuleInfoMap; std::vector mScalerInfo; int mTnrExtraFrameNum; bool mDummyStillSink; - std::vector mTnrThresholdSizes; bool mGpuTnrEnabled; bool mRemoveCacheFlushOutputBuffer; bool mPLCEnable; @@ -370,7 +353,6 @@ class PlatformData { bool mResetLinkRoute; /* mReqWaitTimeout is used to override dqbuf timeout (ns) */ int64_t mReqWaitTimeout; - v4l2_buf_type mV4l2BufType; }; /** @@ -381,8 +363,6 @@ class PlatformData { std::vector mCameras; std::vector mPolicyConfig; CommonConfig mCommonConfig; - std::string mBoardName; - int mMediaCfgId; }; private: @@ -465,17 +445,6 @@ class PlatformData { */ static int getXmlCameraNumber(); - /** - * get module info of sensor - * - * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \param moduleId: the module id of sensor - * \param sensorId: the sensor id of sensor - * - * \return int: return OK if has module info. - */ - static int getModuleInfo(int cameraId, std::string& moduleId, std::string& sensorId); - /** * get the sensor name * @@ -484,22 +453,6 @@ class PlatformData { */ static const char* getSensorName(int cameraId); - /** - * set board name - * - * \param[in] boardName - */ - static void setBoardName(const std::string& boardName); - - /** - * get status if HDRnet tuning used - * - * \param[in] cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \param[out] boardConfig: set true if configured - * \return true if HDRnet tuning used, otherwise return false. - */ - static bool isHDRnetTuningUsed(int cameraId, bool& boardConfig); - /** * get the sensor description * @@ -524,40 +477,6 @@ class PlatformData { */ static int getLensHwType(int cameraId); - /** - * get sensor mode - * - * \param[in] cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \return SensorMode. - */ - static SensorMode getSensorMode(int cameraId); - - /** - * set sensor mode - * - * \param[in] cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \param[in] sensorMode: SensorMode - */ - static void setSensorMode(int cameraId, SensorMode sensorMode); - - /** - * check if binning mode supported - * - * \param[in] cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \return true if binning mode supported, otherwise return false. - */ - static bool isBinningModeSupport(int cameraId); - - /** - * get sensitivity range by TuningMode - * - * \param[in] cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \param[out] range: SensitivityRange - * \return OK if found, otherwise return NAME_NOT_FOUND. - */ - static int getSensitivityRangeByTuningMode(int cameraId, TuningMode mode, - SensitivityRange& range); - /** * check if PDAF is supported or not * @@ -814,14 +733,6 @@ class PlatformData { */ static unsigned int getInitialSkipFrame(int cameraId); - /** - * Get initial pending frame number - * - * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \return the value of initial pending frame number - */ - static unsigned int getInitialPendingFrame(int cameraId); - /** * Get max raw data number * @@ -958,14 +869,6 @@ class PlatformData { */ static bool psysAlignWithSof(int cameraId); - /** - * Get time interval to align psys processing - * - * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \return time interval. - */ - static int getMsOfPsysAlignWithSystem(int cameraId); - /** * Check running psys bundle with aic is enabled or not * @@ -1027,22 +930,21 @@ class PlatformData { * \param[in] cameraId: [0, MAX_CAMERA_NUMBER - 1] * \param[in] totalGain: total gain * \param[in] hdrRatio: hdr ratio - * \param[in] mode: TuningMode * \param[out] setting: EdgeNrSetting setting * * \return OK if setting is available, otherwise return NAME_NOT_FOUND. */ static int getEdgeNrSetting(int cameraId, float totalGain, float hdrRatio, - TuningMode mode, EdgeNrSetting& setting); + EdgeNrSetting& setting); /** * Get the executor policy config. * - * \param[in] graphIds: the graph ids + * \param[in] graphId: the graph id * * \return PolicyConfig* object if found, otherwise return nullptr. */ - static PolicyConfig* getExecutorPolicyConfig(const std::set& graphIds); + static PolicyConfig* getExecutorPolicyConfig(int graphId); /** * According to stream info to select MC @@ -1509,14 +1411,14 @@ class PlatformData { static camera_resolution_t* getPslOutputForRotation(int width, int height, int cameraId); /** - * Get preferred output size + * Get preferred output size for still * * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] * \param width: The width of user requirement * \param height: The height of user requirement * \return the output resolution if provides it in xml file, otherwise return nullptr. */ - const static camera_resolution_t* getPreferOutput(int width, int height, int cameraId); + const static camera_resolution_t* getPreferStillOutput(int width, int height, int cameraId); /** * Check if test pattern is supported or not @@ -1701,10 +1603,8 @@ class PlatformData { /** * Check if support to update tuning data or not - * - * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] */ - static bool supportUpdateTuning(int cameraId); + static bool supportUpdateTuning(); /** * Check if support hardware jpeg encode or not @@ -1767,12 +1667,6 @@ class PlatformData { */ static bool isDummyStillSink(int cameraId); - /** - * get the tnr resolution list - * - * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] - */ - static void getTnrThresholdSizes(int cameraId, std::vector& resolutions); /* * check if removing cache flush output buffer * @@ -1842,29 +1736,6 @@ class PlatformData { */ static int64_t getReqWaitTimeout(int cameraId); - /** - * Get V4L2 buffer type - * - * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \return V4L2 buffer type - */ - static v4l2_buf_type getV4L2BufType(int cameraId); - - /** - * Set V4L2 buffer type - * - * \param cameraId: [0, MAX_CAMERA_NUMBER - 1] - * \param v4l2BufType:V4L2 buffer type - */ - static void setV4L2BufType(int cameraId, v4l2_buf_type v4l2BufType); - - /** - * Get media configuration ID - * - * \return media configuration ID - */ - static int getMediaCfgId(); - // LEVEL0_ICBM_S /** * Check GPU ICBM is enabled or not diff --git a/src/platformdata/PolicyParser.cpp b/src/platformdata/PolicyParser.cpp index 97498fe5..5fd8835e 100644 --- a/src/platformdata/PolicyParser.cpp +++ b/src/platformdata/PolicyParser.cpp @@ -59,8 +59,8 @@ void PolicyParser::checkField(PolicyParser* profiles, const char* name, const ch const char* key = atts[idx]; const char* val = atts[idx + 1]; LOG2("@%s, name:%s, atts[%d]:%s, atts[%d]:%s", __func__, name, idx, key, idx + 1, val); - if (strcmp(key, "id") == 0 || strcmp(key, "video") == 0 || strcmp(key, "still") == 0) { - profiles->pCurrentConf->graphIds.insert(atoi(val)); + if (strcmp(key, "id") == 0) { + profiles->pCurrentConf->graphId = atoi(val); } else if (strcmp(key, "description") == 0) { profiles->pCurrentConf->policyDescription = val; } @@ -272,7 +272,7 @@ void PolicyParser::endParseElement(void* userData, const char* name) { PolicyParser* profiles = reinterpret_cast(userData); if (strcmp(name, "graph") == 0) { - LOG2("@%s, add policyConf", __func__); + LOG2("@%s, add policyConf, graphId: %d", __func__, profiles->pCurrentConf->graphId); profiles->mStaticCfg->mPolicyConfig.push_back(*(profiles->pCurrentConf)); delete profiles->pCurrentConf; profiles->pCurrentConf = nullptr; diff --git a/src/platformdata/gc/GraphConfig.cpp b/src/platformdata/gc/GraphConfig.cpp index 266b67f6..3850ab53 100644 --- a/src/platformdata/gc/GraphConfig.cpp +++ b/src/platformdata/gc/GraphConfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2024 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ #include "src/platformdata/gc/GraphConfig.h" -#include - #include "PlatformData.h" #include "iutils/CameraLog.h" @@ -66,29 +64,8 @@ status_t GraphConfig::queryGraphSettings(const std::vector& activeSt status_t GraphConfig::configStreams(const vector& activeStreams) { LOG1("@%s", __func__); - vector res; - PlatformData::getTnrThresholdSizes(mCameraId, res); - - // enable tnr dummy sink on resolution size larger than threshold - bool highResolution = res.size() > 0 ? false : true; - if (res.size() > 0) { - for (auto& stream : activeStreams) { - if (static_cast(stream->mHeight) * static_cast(stream->mWidth) > - res.begin()->height * res.begin()->width) { - highResolution = true; - break; - } - } - } - - SensorMode sensorMode = SENSOR_MODE_UNKNOWN; - if (PlatformData::isBinningModeSupport(mCameraId)) { - sensorMode = PlatformData::getSensorMode(mCameraId); - } - bool dummyStillSink = PlatformData::isDummyStillSink(mCameraId); - int ret = mGraphConfigImpl->configStreams(activeStreams, dummyStillSink && highResolution, - sensorMode); + int ret = mGraphConfigImpl->configStreams(activeStreams, dummyStillSink); CheckAndLogError(ret != OK, UNKNOWN_ERROR, "%s, Failed to config streams", __func__); ret = mGraphConfigImpl->getGraphConfigData(&mGraphData); diff --git a/src/platformdata/gc/GraphConfig.h b/src/platformdata/gc/GraphConfig.h index 2d07176b..9ffe8615 100644 --- a/src/platformdata/gc/GraphConfig.h +++ b/src/platformdata/gc/GraphConfig.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2023 Intel Corporation + * Copyright (C) 2019-2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ #include #include #include -#include #include "HalStream.h" #include "iutils/Errors.h" @@ -57,11 +56,7 @@ class GraphConfig : public IGraphConfig { status_t queryGraphSettings(const std::vector& activeStreams); status_t configStreams(const std::vector& activeStreams); int getSelectedMcId() { return mGraphData.mcId; } - virtual int getGraphIds(std::set& graphIds) { - graphIds = mGraphData.graphIds; - return OK; - } - + virtual int getGraphId(void) { return mGraphData.graphId; } virtual void getCSIOutputResolution(camera_resolution_t& reso) { reso = mGraphData.csiReso; } virtual status_t getGdcKernelSetting(uint32_t* kernelId, diff --git a/src/platformdata/gc/IGraphConfig.h b/src/platformdata/gc/IGraphConfig.h index bf490da2..608f1399 100644 --- a/src/platformdata/gc/IGraphConfig.h +++ b/src/platformdata/gc/IGraphConfig.h @@ -16,7 +16,6 @@ #pragma once #include -#include #include "HalStream.h" #include "Parameters.h" #include "iutils/CameraLog.h" @@ -185,7 +184,7 @@ struct GdcInfo { struct GraphConfigData { int mcId; - std::set graphIds; + int graphId; // DOL_FEATURE_S DolInfo dolInfo; // DOL_FEATURE_E @@ -197,7 +196,7 @@ struct GraphConfigData { std::vector pgNames; std::vector programGroup; std::vector tuningModes; - GraphConfigData() : mcId(-1) { + GraphConfigData() : mcId(-1), graphId(-1) { CLEAR(csiReso); } }; @@ -223,7 +222,7 @@ class IGraphConfig { ia_isp_bxt_resolution_info_t* resolution, int32_t streamId = VIDEO_STREAM_ID) = 0; virtual status_t graphGetStreamIds(std::vector& streamIds) = 0; - virtual int getGraphIds(std::set& graphIds) = 0; + virtual int getGraphId(void) = 0; virtual int getStreamIdByPgName(std::string pgName) = 0; virtual int getTuningModeByStreamId(const int32_t streamId) = 0; virtual int getPgIdByPgName(std::string pgName) = 0; diff --git a/src/scheduler/CameraScheduler.cpp b/src/scheduler/CameraScheduler.cpp index df543a45..7166d199 100644 --- a/src/scheduler/CameraScheduler.cpp +++ b/src/scheduler/CameraScheduler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,9 +35,9 @@ CameraScheduler::~CameraScheduler() { destoryExecutors(); } -int32_t CameraScheduler::configurate(const std::set& graphIds) { - int ret = mPolicy->setConfig(graphIds); - CheckAndLogError(ret != OK, ret, "configurate error"); +int32_t CameraScheduler::configurate(int32_t graphId) { + int ret = mPolicy->setConfig(graphId); + CheckAndLogError(ret != OK, ret, "configurate %d error", graphId); mTriggerCount = 0; destoryExecutors(); @@ -174,7 +174,7 @@ bool CameraScheduler::Executor::threadLoop() { if (!mActive) return false; for (auto& node : mNodes) { - LOG2("%s process %ld", getName(), tick); + LOG2("%s process %d", getName(), tick); bool ret = node->process(tick); CheckAndLogError(!ret, true, "%s: node %s process error", getName(), node->getName()); } diff --git a/src/scheduler/CameraScheduler.h b/src/scheduler/CameraScheduler.h index 2bc6ccce..43519f96 100644 --- a/src/scheduler/CameraScheduler.h +++ b/src/scheduler/CameraScheduler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ #include #include #include -#include #include "CameraEvent.h" #include "CameraSchedulerPolicy.h" @@ -43,7 +42,7 @@ class CameraScheduler { CameraScheduler(); ~CameraScheduler(); - int32_t configurate(const std::set& graphIds); + int32_t configurate(int32_t graphId); int32_t registerNode(ISchedulerNode* node); void unregisterNode(ISchedulerNode* node); diff --git a/src/scheduler/CameraSchedulerPolicy.cpp b/src/scheduler/CameraSchedulerPolicy.cpp index 212bc307..a64974f3 100644 --- a/src/scheduler/CameraSchedulerPolicy.cpp +++ b/src/scheduler/CameraSchedulerPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,28 +61,16 @@ CameraSchedulerPolicy::~CameraSchedulerPolicy() { LOG1("%s", __func__); } -int32_t CameraSchedulerPolicy::setConfig(const std::set& graphIds) { - size_t graphCount = graphIds.size(); - for (auto& item : mPolicyConfigs) { - if (graphCount != item.graphIds.size()) continue; - - bool match = true; - for (auto it = graphIds.cbegin(); it != graphIds.cend(); ++it) { - if (item.graphIds.find(*it) == item.graphIds.end()) { - match = false; - break; - } - } - if (match) { - mActiveConfig = &item; +int32_t CameraSchedulerPolicy::setConfig(uint32_t graphId) { + for (auto& iter : mPolicyConfigs) { + if (iter.graphId == graphId) { + mActiveConfig = &iter; + LOG1("%s: config id %u, graphId %u", __func__, iter.configId, graphId); return OK; } } - LOGE("%s: no config for the following graphs %lu: )", __func__, graphCount); - for (auto it = graphIds.cbegin(); it != graphIds.cend(); ++it) { - LOGE(" graph id %d", *it); - } + LOGE("%s: no config for graphId %u", __func__, graphId); return BAD_VALUE; } @@ -129,9 +117,8 @@ void CameraSchedulerPolicy::checkField(CameraSchedulerPolicy* profiles, const ch LOG2("@%s, name:%s, atts[%d]:%s, atts[%d]:%s", __func__, name, idx, key, idx + 1, val); if (strcmp(key, "id") == 0) { profiles->mPolicyConfigs[profiles->mCurrentConfig].configId = atoi(val); - } else if (strcmp(key, "graphId") == 0 || - strcmp(key, "video") == 0 || strcmp(key, "still") == 0) { - profiles->mPolicyConfigs[profiles->mCurrentConfig].graphIds.insert(atoi(val)); + } else if (strcmp(key, "graphId") == 0) { + profiles->mPolicyConfigs[profiles->mCurrentConfig].graphId = atoi(val); } idx += 2; } diff --git a/src/scheduler/CameraSchedulerPolicy.h b/src/scheduler/CameraSchedulerPolicy.h index 3ff148ce..a3c7d1e6 100644 --- a/src/scheduler/CameraSchedulerPolicy.h +++ b/src/scheduler/CameraSchedulerPolicy.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022-2023 Intel Corporation + * Copyright (C) 2022 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ #include #include #include -#include #include "ParserBase.h" @@ -37,7 +36,7 @@ class CameraSchedulerPolicy : public ParserBase { ~CameraSchedulerPolicy(); public: - int32_t setConfig(const std::set& graphIds); + int32_t setConfig(uint32_t graphId); // Return int32_t getExecutors(std::map* executors) const; int32_t getNodeList(const char* exeName, std::vector* nodeList) const; @@ -55,11 +54,12 @@ class CameraSchedulerPolicy : public ParserBase { struct PolicyConfigDesc { // static data uint32_t configId; - std::set graphIds; + uint32_t graphId; std::vector exeList; PolicyConfigDesc() { configId = 0; + graphId = 0; } }; diff --git a/src/v4l2/MediaControl.cpp b/src/v4l2/MediaControl.cpp index 54158cc3..2ce75f34 100644 --- a/src/v4l2/MediaControl.cpp +++ b/src/v4l2/MediaControl.cpp @@ -127,9 +127,7 @@ void MediaControl::releaseInstance() { } } -MediaControl::MediaControl(const char* devName) - : mDevName(devName), - mMediaCfgId(IPU6_DOWNSTREAM_MEDIA_CFG) { +MediaControl::MediaControl(const char* devName) : mDevName(devName) { LOG1("@%s device: %s", __func__, devName); } @@ -427,7 +425,6 @@ void MediaControl::dumpEntityDesc(media_entity_desc& desc, media_device_info& de } int MediaControl::enumEntities(int fd, media_device_info& devInfo) { - int mediaCfgId = IPU6_MEDIA_CFG_MAX; MediaEntity entity; uint32_t id; int ret; @@ -443,14 +440,6 @@ int MediaControl::enumEntities(int fd, media_device_info& devInfo) { break; } - if (mediaCfgId == IPU6_MEDIA_CFG_MAX) { - if (!strncmp(entity.info.name, IPU6_DOWNSTREAM_ENTITY, strlen(IPU6_DOWNSTREAM_ENTITY))) - mediaCfgId = IPU6_DOWNSTREAM_MEDIA_CFG; - else if (!strncmp(entity.info.name, IPU6_UPSTREAM_ENTITY, - strlen(IPU6_UPSTREAM_ENTITY))) - mediaCfgId = IPU6_UPSTREAM_MEDIA_CFG; - } - if (Log::isDumpMediaInfo()) dumpEntityDesc(entity.info, devInfo); /* Number of links (for outbound links) plus number of pads (for @@ -476,21 +465,7 @@ int MediaControl::enumEntities(int fd, media_device_info& devInfo) { } } - if (ret != 0) - return ret; - - if (mediaCfgId != IPU6_MEDIA_CFG_MAX) - mMediaCfgId = mediaCfgId; - - if ((!strcmp(devInfo.model, IPU6_DOWNSTREAM_DEV_MODEL) && - mMediaCfgId != IPU6_DOWNSTREAM_MEDIA_CFG) || - (!strcmp(devInfo.model, IPU6_UPSTREAM_DEV_MODEL) && - mMediaCfgId != IPU6_UPSTREAM_MEDIA_CFG)) { - LOGE("Invalid media configuration id %d for %s", mMediaCfgId, devInfo.model); - return -EINVAL; - } - - return OK; + return ret; } int MediaControl::getDevnameFromSysfs(MediaEntity* entity) { @@ -576,9 +551,7 @@ int MediaControl::enumLinks(int fd) { links.entity = entity.info.id; links.pads = new media_pad_desc[entity.info.pads]; - memset(links.pads, 0, sizeof(struct media_pad_desc) * entity.info.pads); links.links = new media_link_desc[entity.info.links]; - memset(links.links, 0, sizeof(struct media_link_desc) * entity.info.links); if (sc->ioctl(fd, MEDIA_IOC_ENUM_LINKS, &links) < 0) { ret = -errno; @@ -1012,17 +985,6 @@ bool MediaControl::checkHasSource(const MediaEntity* sink, const std::string& so return false; } -// This function must be called after enumEntities(). -bool MediaControl::checkAvailableSensor(const std::string& sensorEntityName) { - LOG1("@%s, sensorEntityName:%s", __func__, sensorEntityName.c_str()); - for (auto& entity : mEntities) { - if (strncmp(sensorEntityName.c_str(), entity.info.name, sensorEntityName.length()) == 0) { - return true; - } - } - return false; -} - // This function must be called after enumEntities(). bool MediaControl::checkAvailableSensor(const std::string& sensorEntityName, const std::string& sinkEntityName) { diff --git a/src/v4l2/MediaControl.h b/src/v4l2/MediaControl.h index 39174c5f..b3d47dec 100644 --- a/src/v4l2/MediaControl.h +++ b/src/v4l2/MediaControl.h @@ -51,16 +51,6 @@ struct MediaLink; #define MEDIA_CTL_DEV_NAME "/dev/media" #define MEDIA_DRIVER_NAME "intel-ipu" #define MEDIA_DEVICE_MAX_NUM 256 -#define IPU6_DOWNSTREAM_ENTITY "Intel IPU6 CSI-2" -#define IPU6_UPSTREAM_ENTITY "Intel IPU6 CSI2" -#define IPU6_DOWNSTREAM_DEV_MODEL "ipu6-downstream" -#define IPU6_UPSTREAM_DEV_MODEL "ipu6" - -enum { - IPU6_DOWNSTREAM_MEDIA_CFG = 0, - IPU6_UPSTREAM_MEDIA_CFG = 1, - IPU6_MEDIA_CFG_MAX, -}; enum { FC_FORMAT = 0, @@ -296,7 +286,6 @@ class MediaControl { // VIRTUAL_CHANNEL_E int getLensName(std::string* lensName); - bool checkAvailableSensor(const std::string& sensorEntityName); bool checkAvailableSensor(const std::string& sensorEntityName, const std::string& sinkEntityName); /** @@ -310,8 +299,6 @@ class MediaControl { int getI2CBusAddress(const std::string& sensorEntityName, const std::string& sinkEntityName, std::string* i2cBus); - int getMediaCfgId() { return mMediaCfgId; } - private: MediaControl& operator=(const MediaControl&); MediaControl(const char* devName); @@ -365,8 +352,6 @@ class MediaControl { static MediaControl* sInstance; static Mutex sLock; - - int mMediaCfgId; }; } // namespace icamera