Skip to content

Commit

Permalink
Merge pull request #56 from onceforall/ccg_plat_adlp
Browse files Browse the repository at this point in the history
Engineer release 2023-05-18
  • Loading branch information
hao-yao committed May 18, 2023
2 parents 39596de + 988d389 commit ea976df
Show file tree
Hide file tree
Showing 65 changed files with 1,347 additions and 603 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ else()
endif()

add_library(camhal_static STATIC ${LIBCAMHAL_SRCS})

if (NOT CAL_BUILD AND (NOT "${CMAKE_INSTALL_SUB_PATH}" STREQUAL ""))
set(CMAKE_SKIP_RPATH TRUE)
set_target_properties(camhal PROPERTIES LINK_FLAGS
"-Wl,-rpath,/usr/lib/${CMAKE_INSTALL_SUB_PATH}")
add_compile_definitions(SUB_CONFIG_PATH="${CMAKE_INSTALL_SUB_PATH}")
endif()
set_target_properties(camhal_static PROPERTIES OUTPUT_NAME "camhal")

#---------------------------- Link settings ----------------------------
Expand Down Expand Up @@ -375,10 +382,12 @@ endif() #ENABLE_SANDBOXING
#--------------------------- Install settings ---------------------------
if (NOT CAL_BUILD)
# Install headers
install(DIRECTORY include/ DESTINATION include/${CMAKE_INSTALL_SUB_PATH}/libcamhal)
if (SUPPORT_LIVE_TUNING)
install(FILES modules/livetune/LiveTuning.h DESTINATION include/${CMAKE_INSTALL_SUB_PATH}/libcamhal/api)
endif() #SUPPORT_LIVE_TUNING
if ("${CMAKE_INSTALL_SUB_PATH}" STREQUAL "")
install(DIRECTORY include/ DESTINATION include/libcamhal)
if (SUPPORT_LIVE_TUNING)
install(FILES modules/livetune/LiveTuning.h DESTINATION include/libcamhal/api)
endif() #SUPPORT_LIVE_TUNING
endif()

# Install configure files
# By default ipu4 is used
Expand Down
18 changes: 18 additions & 0 deletions include/api/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ typedef enum {
CAMERA_METADATA_READY,
CAMERA_DEVICE_ERROR,
CAMERA_IPC_ERROR,
CAMERA_METADATA_ENTRY,
} camera_msg_type_t;

/**
Expand Down Expand Up @@ -768,6 +769,22 @@ typedef struct {
int64_t sequence;
} metadata_ready_t;

/**
* \struct metadata_entry_t: Use to set metadata entry.
*/
typedef struct {
uint32_t tag;
uint32_t frameNumber;
size_t count;
union {
const uint8_t* u8;
const int32_t* i32;
const float* f;
const int64_t* i64;
const double* d;
} data;
} metadata_entry_t;

/**
* \struct camera_msg_data_t: Use to specify msg data.
*/
Expand All @@ -776,6 +793,7 @@ typedef struct {
union {
isp_buffer_ready_t buffer_ready;
metadata_ready_t metadata_ready;
metadata_entry_t metadata_entry;
} data;
} camera_msg_data_t;

Expand Down
1 change: 1 addition & 0 deletions include/api/intel_vendor_metadata_tags.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ typedef enum vendor_metadata_tag {
INTEL_VENDOR_CAMERA_TOTAL_EXPOSURE_TARGET, // int64 | public
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_END,
} vendor_metadata_tag_t;

Expand Down
3 changes: 2 additions & 1 deletion include/linux/ipu-isys.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright (C) 2019 Intel Corporation.
* Copyright (C) 2019-2023 Intel Corporation.
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
Expand All @@ -24,6 +24,7 @@
/* 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)
#define V4L2_IPU_ISA_EN_LSC (1 << 1)
#define V4L2_IPU_ISA_EN_DPC (1 << 2)
Expand Down
31 changes: 22 additions & 9 deletions modules/algowrapper/IntelICBM.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Intel Corporation
* 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.
Expand All @@ -17,26 +17,39 @@
#define LOG_TAG IntelICBM

#include "modules/algowrapper/IntelICBM.h"
#include "src/icbm/ICBMBuilder.h"

#include "Errors.h"
#include "iutils/CameraLog.h"
#include "iutils/Utils.h"

namespace icamera {

int IntelICBM::setup(ICBMInitInfo* initParam) {
mIIntelICBM = std::unique_ptr<IIntelICBM>(createIntelICBM());
mIntelOPIC2 = IntelOPIC2::getInstance();

return mIIntelICBM->setup(initParam);
return mIntelOPIC2->setup(initParam);
}

void IntelICBM::shutdown() {
mIIntelICBM->shutdown();
int IntelICBM::shutdown(const ICBMReqInfo& request) {
CheckAndLogError(mIntelOPIC2 == nullptr, UNKNOWN_ERROR, "@%s, no active ICBM session",
__func__);
int ret = mIntelOPIC2->shutdown(request);
// ret is the active session count, only release the object when no active session
if (ret == 0) {
IntelOPIC2::releaseInstance();
mIntelOPIC2 = nullptr;
}
return ret;
}

int IntelICBM::processFrame(const ImageInfo& iii, const ImageInfo& iio,
const ICBMReqInfo& reqInfo) {
return mIIntelICBM->processFrame(iii, iio, reqInfo);
int IntelICBM::processFrame(const ICBMReqInfo& reqInfo) {
CheckAndLogError(mIntelOPIC2 == nullptr, UNKNOWN_ERROR, "@%s, no active ICBM session",
__func__);
if (reqInfo.reqType == icamera::ICBMReqType::USER_FRAMING)
return mIntelOPIC2->processFrame(reqInfo);
if (reqInfo.reqType == icamera::ICBMReqType::LEVEL0_TNR)
return mIntelOPIC2->runTnrFrame(reqInfo);
return 0;
}

} // namespace icamera
10 changes: 5 additions & 5 deletions modules/algowrapper/IntelICBM.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 Intel Corporation
* 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.
Expand All @@ -19,19 +19,19 @@
#include <vector>
#include <memory>

#include "src/icbm/IntelICBM.h"
#include "src/icbm/OnePunchIC2.h"
#include "src/icbm/ICBMTypes.h"

namespace icamera {

class IntelICBM {
public:
int setup(ICBMInitInfo* initParam);
void shutdown();
int shutdown(const ICBMReqInfo& reqInfo);

int processFrame(const ImageInfo& iii, const ImageInfo& iio, const ICBMReqInfo& reqInfo);
int processFrame(const ICBMReqInfo& reqInfo);

private:
std::unique_ptr<IIntelICBM> mIIntelICBM;
IntelOPIC2* mIntelOPIC2;
};
} // namespace icamera
68 changes: 34 additions & 34 deletions modules/algowrapper/IntelTNR7US.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,38 @@
namespace icamera {

IntelTNR7US* IntelTNR7US::createIntelTNR(int cameraId) {
return new IntelTNR7US(cameraId);
#ifdef TNR7_CM
return new IntelC4mTNR(cameraId);
#endif
}

IntelTNR7US::IntelTNR7US(int cameraId)
: mCameraId(cameraId),
mWidth(0),
mHeight(0),
mTnrType(TNR_INSTANCE_MAX),
mTnrParam(nullptr) {}
Tnr7Param* IntelTNR7US::allocTnr7ParamBuf() {
LOG1("<id:%d>@%s, type %d", mCameraId, __func__, mTnrType);
mTnrParam = new Tnr7Param;
return mTnrParam;
}

IntelTNR7US::~IntelTNR7US() {
#ifdef TNR7_CM
IntelC4mTNR::~IntelC4mTNR() {
for (auto surface : mCMSurfaceMap) {
destroyCMSurface(surface.second);
}
mCMSurfaceMap.clear();
}

int IntelTNR7US::init(int width, int height, TnrType type) {
int IntelC4mTNR::init(int width, int height, TnrType type) {
LOG1("<id:%d>@%s size %dx%d, type %d", mCameraId, __func__, width, height, type);
mWidth = width;
mHeight = height;
mTnrType = type;

std::string threadName = "IntelTNR7US" + std::to_string(type + (mCameraId << 1));
std::string threadName = "IntelC4mTNR" + std::to_string(type + (mCameraId << 1));
mThread = std::unique_ptr<base::Thread>(new base::Thread(threadName));
mThread->Start();
return OK;
}

Tnr7Param* IntelTNR7US::allocTnr7ParamBuf() {
LOG1("<%d>@%s, type %d", mCameraId, __func__, mTnrType);
mTnrParam = new Tnr7Param;
return mTnrParam;
}

void* IntelTNR7US::allocCamBuf(uint32_t bufSize, int id) {
void* IntelC4mTNR::allocCamBuf(uint32_t bufSize, int id) {
LOG1("<%d>@%s, type %d, id: %d", mCameraId, __func__, mTnrType, id);
void* buffer = nullptr;
int ret = posix_memalign(&buffer, getpagesize(), bufSize);
Expand All @@ -82,7 +78,7 @@ void* IntelTNR7US::allocCamBuf(uint32_t bufSize, int id) {
return buffer;
}

void IntelTNR7US::freeAllBufs() {
void IntelC4mTNR::freeAllBufs() {
LOG1("<%d>@%s, type %d", mCameraId, __func__, mTnrType);
for (auto surface : mCMSurfaceMap) {
::free(surface.first);
Expand All @@ -92,7 +88,7 @@ void IntelTNR7US::freeAllBufs() {
}
}

int IntelTNR7US::prepareSurface(void* bufAddr, int size) {
int IntelC4mTNR::prepareSurface(void* bufAddr, int size) {
CheckAndLogError(size < mWidth * mHeight * 3 / 2, UNKNOWN_ERROR, "%s, invalid buffer size:%d",
__func__, size);
CmSurface2DUP* surface = createCMSurface(bufAddr);
Expand All @@ -102,10 +98,10 @@ int IntelTNR7US::prepareSurface(void* bufAddr, int size) {
return OK;
}

int IntelTNR7US::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
int IntelC4mTNR::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t inBufSize,
uint32_t outBufSize, Tnr7Param* tnrParam, bool syncUpdate, int fd) {
PERF_CAMERA_ATRACE();
TRACE_LOG_PROCESS("IntelTNR7US", "runTnrFrame");
TRACE_LOG_PROCESS("IntelC4mTNR", "runTnrFrame");
LOG2("<%d>@%s type %d", mCameraId, __func__, mTnrType);
CheckAndLogError(inBufAddr == nullptr || outBufAddr == nullptr || tnrParam == nullptr,
UNKNOWN_ERROR, "@%s, buffer is nullptr", __func__);
Expand All @@ -122,7 +118,9 @@ int IntelTNR7US::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t i
CheckAndLogError(outSurface == nullptr, UNKNOWN_ERROR,
"Failed to get CMSurface for output buffer");
struct timespec beginTime = {};
if (Log::isLogTagEnabled(ST_GPU_TNR)) clock_gettime(CLOCK_MONOTONIC, &beginTime);
if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
clock_gettime(CLOCK_MONOTONIC, &beginTime);
}
/* call Tnr api to run tnr for the inSurface and store the result in outSurface */
int ret =
run_tnr7us_frame(mWidth, mHeight, mWidth, inSurface, outSurface, &tnrParam->scale,
Expand All @@ -131,7 +129,7 @@ int IntelTNR7US::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t i
destroyCMSurface(outSurface);
}
CheckAndLogError(ret != OK, UNKNOWN_ERROR, "tnr7us process failed");
if (Log::isLogTagEnabled(ST_GPU_TNR)) {
if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
struct timespec endTime = {};
clock_gettime(CLOCK_MONOTONIC, &endTime);
uint64_t timeUsedUs = (endTime.tv_sec - beginTime.tv_sec) * 1000000 +
Expand All @@ -141,17 +139,16 @@ int IntelTNR7US::runTnrFrame(const void* inBufAddr, void* outBufAddr, uint32_t i
return OK;
}

int IntelTNR7US::asyncParamUpdate(int gain, bool forceUpdate) {
int IntelC4mTNR::asyncParamUpdate(int gain, bool forceUpdate) {
if (mThread->task_runner()) {
mThread->task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&IntelTNR7US::handleParamUpdate,
base::Unretained(this), gain, forceUpdate));
FROM_HERE, base::BindOnce(&IntelC4mTNR::handleParamUpdate, base::Unretained(this), gain,
forceUpdate));
}
return OK;
}

int32_t IntelTNR7US::getTnrBufferSize(int width, int height, uint32_t* size) {
int32_t IntelC4mTNR::getTnrBufferSize(int width, int height, uint32_t* size) {
uint32_t pitch = 0;
uint32_t physicalSize = 0;
int ret = getSurface2DInfo(uint32_t(width), uint32_t(CM_SURFACE_ALIGN_HEIGHT(height)),
Expand All @@ -162,15 +159,17 @@ int32_t IntelTNR7US::getTnrBufferSize(int width, int height, uint32_t* size) {
return OK;
}

void IntelTNR7US::handleParamUpdate(int gain, bool forceUpdate) {
void IntelC4mTNR::handleParamUpdate(int gain, bool forceUpdate) {
PERF_CAMERA_ATRACE();
LOG2("@%s gain: %d", __func__, gain);
// gain value is from AE expore analog_gain * digital_gain
struct timespec beginTime = {};
if (Log::isLogTagEnabled(ST_GPU_TNR)) clock_gettime(CLOCK_MONOTONIC, &beginTime);
if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
clock_gettime(CLOCK_MONOTONIC, &beginTime);
}

tnr7usParamUpdate(gain, forceUpdate, mTnrType);
if (Log::isLogTagEnabled(ST_GPU_TNR)) {
if (Log::isLogTagEnabled(ST_GPU_TNR, CAMERA_DEBUG_LOG_LEVEL2)) {
struct timespec endTime = {};
clock_gettime(CLOCK_MONOTONIC, &endTime);
uint64_t timeUsedUs = (endTime.tv_sec - beginTime.tv_sec) * 1000000 +
Expand All @@ -179,24 +178,25 @@ void IntelTNR7US::handleParamUpdate(int gain, bool forceUpdate) {
}
}

CmSurface2DUP* IntelTNR7US::getBufferCMSurface(void* bufAddr) {
CmSurface2DUP* IntelC4mTNR::getBufferCMSurface(void* bufAddr) {
if (mCMSurfaceMap.find(bufAddr) != mCMSurfaceMap.end()) {
return mCMSurfaceMap[bufAddr];
}

return nullptr;
}

CmSurface2DUP* IntelTNR7US::createCMSurface(void* bufAddr) {
CmSurface2DUP* IntelC4mTNR::createCMSurface(void* bufAddr) {
PERF_CAMERA_ATRACE();
CmSurface2DUP* cmSurface = nullptr;
int32_t ret = createCmSurface2DUP(mWidth, mHeight, CM_SURFACE_FORMAT_NV12, bufAddr, cmSurface);
CheckAndLogError(ret != 0, nullptr, "failed to create CmSurface2DUP object");
return cmSurface;
}

int32_t IntelTNR7US::destroyCMSurface(CmSurface2DUP* surface) {
int32_t IntelC4mTNR::destroyCMSurface(CmSurface2DUP* surface) {
return destroyCMSurface2DUP(surface);
}
#endif

} // namespace icamera
Loading

0 comments on commit ea976df

Please sign in to comment.