Skip to content

Commit

Permalink
Merge pull request #53 from zouxiaoh/iotg_ipu6
Browse files Browse the repository at this point in the history
iotg rpl mr1 release
  • Loading branch information
zouxiaoh authored Apr 17, 2023
2 parents c385ed2 + a0d34dc commit 919f58c
Show file tree
Hide file tree
Showing 21 changed files with 251 additions and 272 deletions.
8 changes: 3 additions & 5 deletions include/api/ICamera.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 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.
Expand Down Expand Up @@ -68,6 +68,8 @@
* Version 0.61 Add API camera_callback_register() to notify event to AAL
*******************************************************************************
* Version 0.62 Add sequence in camera_get_parameters to fetch settings
*******************************************************************************
* Version 0.63 Merge camera_device_open API with/without vc_num together
* ------------------------------------------------------------------------------
*
*/
Expand Down Expand Up @@ -231,11 +233,7 @@ void camera_callback_register(int camera_id, const camera_callback_ops_t* callba
* int ret = camera_device_open(camera_id);
* \endcode
**/
#ifdef NO_VIRTUAL_CHANNEL
int camera_device_open(int camera_id);
#else
int camera_device_open(int camera_id, int vc_num = 0);
#endif

/**
* \brief
Expand Down
3 changes: 2 additions & 1 deletion modules/algowrapper/IntelTNR7US.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ int IntelTNR7US::asyncParamUpdate(int gain, bool forceUpdate) {
if (mThread->task_runner()) {
mThread->task_runner()->PostTask(
FROM_HERE,
base::Bind(&IntelTNR7US::handleParamUpdate, base::Unretained(this), gain, forceUpdate));
base::BindOnce(&IntelTNR7US::handleParamUpdate,
base::Unretained(this), gain, forceUpdate));
}
return OK;
}
Expand Down
4 changes: 2 additions & 2 deletions src/3a/AiqUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ int AiqUnit::initIntelCcaHandle(const std::vector<ConfigMode>& configModes) {
if (graphConfig != nullptr) {
graphConfig->graphGetStreamIds(streamIds);
}
params.dvs_ids.count = streamIds.size();
params.gdcConfigs.count = streamIds.size();
for (size_t i = 0; i < streamIds.size(); ++i) {
params.dvs_ids.ids[i] = streamIds[i];
params.gdcConfigs.ids[i] = streamIds[i];
}
ret = mDvs->configure(cfg, &params);
CheckAndLogError(ret != OK, UNKNOWN_ERROR, "%s, configure DVS error", __func__);
Expand Down
122 changes: 54 additions & 68 deletions src/3a/Dvs.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2022 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.
Expand Down Expand Up @@ -47,8 +47,8 @@ int Dvs::configure(const ConfigMode configMode, cca::cca_init_params* params) {
CheckAndLogError(!params, BAD_VALUE, "params is nullptr");
LOG2("@%s", __func__);

for (uint8_t i = 0; i < params->dvs_ids.count; i++) {
int ret = configCcaDvsData(params->dvs_ids.ids[i], configMode, params);
for (uint8_t i = 0; i < params->gdcConfigs.count; i++) {
auto ret = configCcaDvsData(params->gdcConfigs.ids[i], configMode, params);
CheckAndLogError(ret != OK, UNKNOWN_ERROR, "%s, configure DVS data error", __func__);
}

Expand All @@ -58,6 +58,7 @@ int Dvs::configure(const ConfigMode configMode, cca::cca_init_params* params) {
}
mTuningMode = tuningMode;

dumpDvsConfiguration(*params);
return OK;
}

Expand All @@ -82,7 +83,16 @@ int Dvs::configCcaDvsData(int32_t streamId, const ConfigMode configMode,
resolution.input_width, resolution.input_height, resolution.output_width,
resolution.output_height);

cca::cca_gdc_configuration* gdcConfig = &params->gdcConfig;
cca::cca_gdc_configuration* gdcConfig = nullptr;
for (size_t i = 0; i < params->gdcConfigs.count; ++i) {
if (params->gdcConfigs.ids[i] == static_cast<uint32_t>(streamId)) {
gdcConfig = &params->gdcConfigs.configs[i];
}
}

CheckAndLogError(gdcConfig == nullptr, UNKNOWN_ERROR,
"%s, Cannot find correspond DVS GDC Config!", __func__);

CLEAR(*gdcConfig);
gdcConfig->gdc_filter_width = DVS_MIN_ENVELOPE / 2;
gdcConfig->gdc_filter_height = DVS_MIN_ENVELOPE / 2;
Expand Down Expand Up @@ -151,7 +161,6 @@ int Dvs::configCcaDvsData(int32_t streamId, const ConfigMode configMode,
mZoomParamMap[streamId] = zoomParam;
}

dumpDvsConfiguration(*params);
return OK;
}

Expand Down Expand Up @@ -215,36 +224,7 @@ void Dvs::handleEvent(EventData eventData) {
if (!ptzRegion.left && !ptzRegion.top && !ptzRegion.right && !ptzRegion.bottom) {
zp.zoom_region = {gdcRegion.left, gdcRegion.top, gdcRegion.right, gdcRegion.bottom};
} else {
/*
SCALER_CROP_REGION can adjust to a small crop region if the aspect of active
pixel array is not same as the crop region aspect. Crop can only on either
horizontally or veritacl but never both.
If active pixel array's aspect ratio is wider than the crop region, the region
should be further cropped vertically.
*/
auto coord = PlatformData::getActivePixelArray(mCameraId);
int wpa = coord.right - coord.left;
int hpa = coord.bottom - coord.top;

int width = ptzRegion.right - ptzRegion.left;
int height = ptzRegion.bottom - ptzRegion.top;

float aspect0 = static_cast<float>(wpa) / hpa;
float aspect1 = static_cast<float>(width) / height;

if (std::fabs(aspect0 - aspect1) < 0.00001) {
zp.zoom_region = {ptzRegion.left, ptzRegion.top, ptzRegion.right, ptzRegion.bottom};
} else if (aspect0 > aspect1) {
auto croppedHeight = width / aspect0;
int diff = std::abs(height - croppedHeight) / 2;
zp.zoom_region = {ptzRegion.left, ptzRegion.top + diff, ptzRegion.right,
ptzRegion.bottom - diff};
} else {
auto croppedWidth = height * aspect0;
int diff = std::abs(width - croppedWidth) / 2;
zp.zoom_region = {ptzRegion.left + diff, ptzRegion.top, ptzRegion.right - diff,
ptzRegion.bottom};
}
zp.zoom_region = {ptzRegion.left, ptzRegion.top, ptzRegion.right, ptzRegion.bottom};
}
intelCcaHandle->updateZoom(streamId, zp);

Expand All @@ -257,39 +237,45 @@ void Dvs::handleEvent(EventData eventData) {
void Dvs::dumpDvsConfiguration(const cca::cca_init_params& config) {
if (!Log::isLogTagEnabled(GET_FILE_SHIFT(Dvs), CAMERA_DEBUG_LOG_LEVEL3)) return;

LOG3("config.dvsOutputType %d", config.dvsOutputType);
LOG3("config.enableVideoStablization %d", config.enableVideoStablization);
LOG3("config.dvsZoomRatio %f", config.dvsZoomRatio);
LOG3("config.gdcConfig.pre_gdc_top_padding %d", config.gdcConfig.pre_gdc_top_padding);
LOG3("config.gdcConfig.pre_gdc_bottom_padding %d", config.gdcConfig.pre_gdc_bottom_padding);
LOG3("config.gdcConfig.gdc_filter_width %d", config.gdcConfig.gdc_filter_width);
LOG3("config.gdcConfig.gdc_filter_height %d", config.gdcConfig.gdc_filter_height);
LOG3("config.gdcConfig.splitMetadata[0](oydim_uv) %d", config.gdcConfig.splitMetadata[0]);
LOG3("config.gdcConfig.splitMetadata[1](oxdim_uv) %d", config.gdcConfig.splitMetadata[1]);
LOG3("config.gdcConfig.splitMetadata[2](oydim_y) %d", config.gdcConfig.splitMetadata[2]);
LOG3("config.gdcConfig.splitMetadata[3](oxdim_y) %d", config.gdcConfig.splitMetadata[3]);
LOG3("config.gdcConfig.gdc_resolution_info.input_width %d, input_height %d",
config.gdcConfig.gdc_resolution_info.input_width,
config.gdcConfig.gdc_resolution_info.input_height);
LOG3("config.gdcConfig.gdc_resolution_info.output_width %d, output_height %d",
config.gdcConfig.gdc_resolution_info.output_width,
config.gdcConfig.gdc_resolution_info.output_height);
LOG3("config.gdcConfig.gdc_resolution_info.input_crop.left %d, top %d, right %d, bottom %d",
config.gdcConfig.gdc_resolution_info.input_crop.left,
config.gdcConfig.gdc_resolution_info.input_crop.top,
config.gdcConfig.gdc_resolution_info.input_crop.right,
config.gdcConfig.gdc_resolution_info.input_crop.bottom);
LOG3("config.gdcConfig.gdc_resolution_history.input_width %d, input_height %d",
config.gdcConfig.gdc_resolution_history.input_width,
config.gdcConfig.gdc_resolution_history.input_height);
LOG3("config.gdcConfig.gdc_resolution_history.output_width %d, output_height %d",
config.gdcConfig.gdc_resolution_history.output_width,
config.gdcConfig.gdc_resolution_history.output_height);
LOG3("config.gdcConfig.gdc_resolution_history.input_crop.left %d, top %d, right %d, bottom %d",
config.gdcConfig.gdc_resolution_history.input_crop.left,
config.gdcConfig.gdc_resolution_history.input_crop.top,
config.gdcConfig.gdc_resolution_history.input_crop.right,
config.gdcConfig.gdc_resolution_history.input_crop.bottom);
LOG3("config: config.dvsOutputType %d", config.dvsOutputType);
LOG3("config: config.enableVideoStablization %d", config.enableVideoStablization);
LOG3("config: config.dvsZoomRatio %f", config.dvsZoomRatio);

for (size_t i = 0; i < config.gdcConfigs.count; ++i) {
LOG3("GDC Config for steeam: %d", config.gdcConfigs.ids[i]);

auto gdcConfig = config.gdcConfigs.configs[i];
LOG3("gdcConfig.pre_gdc_top_padding %d", gdcConfig.pre_gdc_top_padding);
LOG3("gdcConfig.pre_gdc_bottom_padding %d", gdcConfig.pre_gdc_bottom_padding);
LOG3("gdcConfig.gdc_filter_width %d", gdcConfig.gdc_filter_width);
LOG3("gdcConfig.gdc_filter_height %d", gdcConfig.gdc_filter_height);
LOG3("gdcConfig.splitMetadata[0](oydim_uv) %d", gdcConfig.splitMetadata[0]);
LOG3("gdcConfig.splitMetadata[1](oxdim_uv) %d", gdcConfig.splitMetadata[1]);
LOG3("gdcConfig.splitMetadata[2](oydim_y) %d", gdcConfig.splitMetadata[2]);
LOG3("gdcConfig.splitMetadata[3](oxdim_y) %d", gdcConfig.splitMetadata[3]);
LOG3("gdcConfig.gdc_resolution_info.input_width %d, input_height %d",
gdcConfig.gdc_resolution_info.input_width,
gdcConfig.gdc_resolution_info.input_height);
LOG3("gdcConfig.gdc_resolution_info.output_width %d, output_height %d",
gdcConfig.gdc_resolution_info.output_width,
gdcConfig.gdc_resolution_info.output_height);
LOG3("gdcConfig.gdc_resolution_info.input_crop.left %d, top %d, right %d, bottom %d",
gdcConfig.gdc_resolution_info.input_crop.left,
gdcConfig.gdc_resolution_info.input_crop.top,
gdcConfig.gdc_resolution_info.input_crop.right,
gdcConfig.gdc_resolution_info.input_crop.bottom);
LOG3("gdcConfig.gdc_resolution_history.input_width %d, input_height %d",
gdcConfig.gdc_resolution_history.input_width,
gdcConfig.gdc_resolution_history.input_height);
LOG3("gdcConfig.gdc_resolution_history.output_width %d, output_height %d",
gdcConfig.gdc_resolution_history.output_width,
gdcConfig.gdc_resolution_history.output_height);
LOG3("gdcConfig.gdc_resolution_history.input_crop.left %d, top %d, right %d, bottom %d",
gdcConfig.gdc_resolution_history.input_crop.left,
gdcConfig.gdc_resolution_history.input_crop.top,
gdcConfig.gdc_resolution_history.input_crop.right,
gdcConfig.gdc_resolution_history.input_crop.bottom);
}
}

} // namespace icamera
9 changes: 5 additions & 4 deletions src/core/CameraDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ int CameraDevice::init() {
ret = m3AControl->init();
CheckAndLogError((ret != OK), ret, "%s: Init 3A Unit falied", __func__);

ret = mLensCtrl->init();
CheckAndLogError((ret != OK), ret, "%s: Init Lens falied", __func__);

mRequestThread->run("RequestThread", PRIORITY_NORMAL);

mState = DEVICE_INIT;
Expand Down Expand Up @@ -753,6 +750,7 @@ int CameraDevice::stop() {
mRequestThread->clearRequests();

m3AControl->stop();
mLensCtrl->stop();

if (mState == DEVICE_START) stopLocked();

Expand Down Expand Up @@ -873,7 +871,10 @@ int CameraDevice::qbuf(camera_buffer_t** ubuffer, int bufferNum, const Parameter
AutoMutex m(mDeviceLock);
if (mState == DEVICE_CONFIGURE || mState == DEVICE_STOP) {
// Start 3A here then the HAL can run 3A for request
int ret = m3AControl->start();
int ret = mLensCtrl->start();
CheckAndLogError((ret != OK), ret, "%s: Start Lens falied", __func__);

ret = m3AControl->start();
CheckAndLogError((ret != OK), BAD_VALUE, "Start 3a unit failed with ret:%d.", ret);

mState = DEVICE_BUFFER_READY;
Expand Down
11 changes: 8 additions & 3 deletions src/core/IspParamAdaptor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2022 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.
Expand Down Expand Up @@ -250,8 +250,12 @@ int IspParamAdaptor::configure(const stream_t& stream, ConfigMode configMode, Tu
// Use the tuning mode in graph to update the isp tuning data
if (ispTuningIndex != -1) {
uint8_t lardTag = cca::CCA_LARD_ISP;
ia_lard_input_params lardParam = {};
lardParam.isp_mode_index = ispTuningIndex;
ia_lard_input_params lardParam = {
IA_MKN_CHTOUL('D', 'F', 'L', 'T'),
IA_MKN_CHTOUL('D', 'F', 'L', 'T'),
static_cast<uint32_t>(ispTuningIndex),
IA_MKN_CHTOUL('D', 'F', 'L', 'T')
};
cca::cca_nvm tmpNvm = {};

ia_err iaErr =
Expand All @@ -274,6 +278,7 @@ int IspParamAdaptor::configure(const stream_t& stream, ConfigMode configMode, Tu
inputParams->seq_id = -1;
initInputParams(inputParams);
inputParams->stream_id = ispParamIt.first;
inputParams->dvs_id = inputParams->stream_id;

ia_isp_bxt_program_group* pgPtr = mGraphConfig->getProgramGroup(ispParamIt.first);
CheckAndLogError(!pgPtr, UNKNOWN_ERROR,
Expand Down
21 changes: 18 additions & 3 deletions src/core/LensHw.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2021 Intel Corporation
* Copyright (C) 2016-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 @@ -16,7 +16,10 @@

#define LOG_TAG LensHw

#include "LensHw.h"
#include "src/core/LensHw.h"

#include <string>

#include "iutils/CameraLog.h"
#include "V4l2DeviceFactory.h"
#include "PlatformData.h"
Expand All @@ -31,7 +34,7 @@ LensHw::LensHw(int cameraId)

LensHw::~LensHw() {}

int LensHw::init() {
int LensHw::start() {
std::string lensName = PlatformData::getLensName(mCameraId);
if (lensName.empty()) {
LOG1("<id%d>@%s No HW Lens", mCameraId, __func__);
Expand All @@ -51,6 +54,18 @@ int LensHw::init() {
return OK;
}

void LensHw::stop() {
if (!mLensSubdev) return;

// close the lens sub device
std::string subDevName;
CameraUtils::getSubDeviceName(mLensName.c_str(), subDevName);
if (!subDevName.empty()) {
V4l2DeviceFactory::releaseSubDev(mCameraId, subDevName);
mLensSubdev = nullptr;
}
}

/**
* focus with absolute value
*/
Expand Down
5 changes: 3 additions & 2 deletions src/core/LensHw.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2021 Intel Corporation
* Copyright (C) 2016-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 Down Expand Up @@ -39,7 +39,8 @@ class LensHw {
LensHw(int cameraId);
~LensHw();

int init();
int start();
void stop();

const char* getLensName(void);

Expand Down
8 changes: 5 additions & 3 deletions src/core/RequestThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,11 @@ bool RequestThread::threadLoop() {

if (blockRequest()) {
int ret = mRequestSignal.waitRelative(lock, kWaitDuration * SLOWLY_MULTIPLIER);
CheckWarning(ret == TIMED_OUT, true,
"wait event time out, %d requests processing, %zu requests in HAL",
mRequestsInProcessing, mPendingRequests.size());
if (ret == TIMED_OUT) {
LOG2("wait event time out, %d requests processing, %zu requests in HAL",
mRequestsInProcessing, mPendingRequests.size());
return true;
}

if (blockRequest()) {
LOG2("Pending request processing, mBlockRequest %d, Req in processing %d",
Expand Down
5 changes: 4 additions & 1 deletion src/core/psysprocessor/PolicyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ int PolicyManager::wait(std::string executorName, int64_t sequence) {
LOG2("%s: need wait for other executors.", executorName.c_str());
const int64_t kWaitDuration = 66000000; // 66ms
int ret = bundle->mCondition.waitRelative(lock, kWaitDuration * SLOWLY_MULTIPLIER);
CheckWarning(ret == TIMED_OUT, ret, "%s: wait executors timeout", executorName.c_str());
if (ret == TIMED_OUT) {
LOG2("%s: wait executors timeout", executorName.c_str());
return ret;
}
} else {
bundle->mWaitingCount = 0;
bundle->mCondition.broadcast();
Expand Down
Loading

0 comments on commit 919f58c

Please sign in to comment.