!19 add camera

Merge pull request !19 from yang_hongliang/master
This commit is contained in:
openharmony_sig_ci
2021-11-02 08:58:51 +00:00
committed by Gitee
16 changed files with 1136 additions and 8 deletions
+8 -8
View File
@@ -62,12 +62,12 @@ ohos_prebuilt_shared_library("display_device") {
# output_name = "display_device_drm.z"
}
#ohos_prebuilt_shared_library("display_layer") {
# if (target_cpu == "arm") {
# source = "lib/libdisplay_layer.z.so"
# }
# subsystem_name = "hdf"
# part_name = "hdf"
# install_enable = true
ohos_prebuilt_shared_library("display_layer") {
if (target_cpu == "arm") {
source = "lib/libdisplay_layer.z.so"
}
subsystem_name = "hdf"
part_name = "hdf"
install_enable = true
# output_name = "display_device_drm.z"
#}
}
+111
View File
@@ -0,0 +1,111 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# 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.
import("//build/ohos.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/peripheral/camera/hal/camera.gni")
action("build_camera_host_config") {
script = "$hdf_framework_path/tools/hc-gen/build_hcs.py"
sources = [ rebase_path(
"$camera_product_name_path/hdf_config/uhdf/camera/hdi_impl/camera_host_config.hcs") ]
outputs = [ "$target_gen_dir/config/hdi_impl/camera_host_config.hcb" ]
args = [
"-o",
rebase_path(outputs[0]),
sources[0],
]
}
ohos_prebuilt_etc("camera_host_config.hcb") {
deps = [ ":build_camera_host_config" ]
hcs_outputs = get_target_outputs(":build_camera_host_config")
source = hcs_outputs[0]
relative_install_dir = "hdfconfig"
subsystem_name = "hdf"
part_name = "hdf"
}
ohos_prebuilt_etc("config.c") {
source =
"$camera_path/pipeline_core/pipeline_impl/src/strategy/config/config.c"
exec_script(
"//drivers/framework/tools/hc-gen/build_hcs.py",
[
"-o",
rebase_path(
"$camera_path/pipeline_core/pipeline_impl/src/strategy/config/config.c"),
"-t",
rebase_path(
"$camera_product_name_path/hdf_config/uhdf/camera/pipeline_core/config.hcs"),
],
"")
}
ohos_prebuilt_etc("params.c") {
source =
"$camera_path/pipeline_core/pipeline_impl/src/strategy/config/params.c"
exec_script(
"//drivers/framework/tools/hc-gen/build_hcs.py",
[
"-o",
rebase_path(
"$camera_path/pipeline_core/pipeline_impl/src/strategy/config/params.c"),
"-t",
rebase_path(
"$camera_product_name_path/hdf_config/uhdf/camera/pipeline_core/params.hcs"),
],
"")
}
action("build_ipp_algo_config") {
script = "$hdf_framework_path/tools/hc-gen/build_hcs.py"
sources = [ rebase_path(
"$camera_product_name_path/hdf_config/uhdf/camera/pipeline_core/ipp_algo_config.hcs") ]
outputs = [ "$target_gen_dir/pipeline_core/ipp_algo_config.hcb" ]
args = [
"-o",
rebase_path(outputs[0]),
sources[0],
]
}
ohos_prebuilt_etc("ipp_algo_config.hcb") {
deps = [ ":build_ipp_algo_config" ]
hcs_outputs = get_target_outputs(":build_ipp_algo_config")
source = hcs_outputs[0]
relative_install_dir = "hdfconfig"
subsystem_name = "hdf"
part_name = "hdf"
}
config("example_config") {
visibility = [ ":*" ]
cflags = [
"-Wno-error",
"-Wno-unused-function",
"-Wno-unused-parameter",
]
}
group("chipset_build") {
public_deps = [
":camera_host_config.hcb",
":config.c",
":ipp_algo_config.hcb",
":params.c",
"$camera_device_name_path/camera/src/pipeline_core:camera_ipp_algo_example",
"//drivers/peripheral/camera/hal/adapter/platform/v4l2/src/driver_adapter:camera_v4l2_adapter",
"//drivers/peripheral/camera/hal/adapter/platform/v4l2/src/driver_adapter/main_test:v4l2_main",
]
}
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 HOS_CAMERA_PROJET_CAMERA_DEMO_H
#define HOS_CAMERA_PROJET_CAMERA_DEMO_H
namespace OHOS::Camera {
#define CAMERA_PREVIEW_WIDTH 640
#define CAMERA_PREVIEW_HEIGHT 480
#define CAMERA_CAPTURE_WIDTH 1280
#define CAMERA_CAPTURE_HEIGHT 960
#define CAMERA_VIDEO_WIDTH 1280
#define CAMERA_VIDEO_HEIGHT 960
#define CAMERA_CAPTURE_ENCODE_TYPE ENCODE_TYPE_JPEG
#define CAMERA_VIDEO_ENCODE_TYPE ENCODE_TYPE_H264
#define CAMERA_FORMAT PIXEL_FMT_RGBA_8888
} // namespace OHOS::Camera
#endif
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 HOS_CAMERA_IMX600_H
#define HOS_CAMERA_IMX600_H
#include "isensor.h"
#include "create_sensor_factory.h"
#include "device_manager_adapter.h"
namespace OHOS::Camera {
class Imx600 : public ISensor {
DECLARE_SENSOR(Imx600)
public:
Imx600();
virtual ~Imx600();
void Init(CameraStandard::CameraMetadata& camera_meta_data);
void InitPhysicalSize(CameraStandard::CameraMetadata& camera_meta_data);
void InitAntiBandingModes(CameraStandard::CameraMetadata& camera_meta_data);
void InitAeFpsTarget(CameraStandard::CameraMetadata& camera_meta_data);
void InitCompensationRange(CameraStandard::CameraMetadata& camera_meta_data);
void InitSensitivityRange(CameraStandard::CameraMetadata& camera_meta_data);
};
} // namespace OHOS::Camera
#endif
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 HOS_CAMERA_PROJET_HARDWARE_H
#define HOS_CAMERA_PROJET_HARDWARE_H
namespace OHOS::Camera {
std::vector<HardwareConfiguration> hardware = {
{CAMERA_FIRST, DM_M_SENSOR, DM_C_SENSOR, (std::string) "rkisp_v5"},
{CAMERA_FIRST, DM_M_ISP, DM_C_ISP, (std::string) "isp"},
{CAMERA_FIRST, DM_M_FLASH, DM_C_FLASH, (std::string) "flash"},
{CAMERA_SECOND, DM_M_SENSOR, DM_C_SENSOR, (std::string) "Imx600"},
{CAMERA_SECOND, DM_M_ISP, DM_C_ISP, (std::string) "isp"},
{CAMERA_SECOND, DM_M_FLASH, DM_C_FLASH, (std::string) "flash"}
};
} // namespace OHOS::Camera
#endif
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 HOS_CAMERA_RKISPV5_H
#define HOS_CAMERA_RKISPV5_H
#include "isensor.h"
#include "create_sensor_factory.h"
#include "device_manager_adapter.h"
namespace OHOS::Camera {
class Rkispv5 : public ISensor {
DECLARE_SENSOR(Rkispv5)
public:
Rkispv5();
virtual ~Rkispv5();
void InitSensitivityRange(CameraStandard::CameraMetadata& camera_meta_data);
void InitAwbModes(CameraStandard::CameraMetadata& camera_meta_data);
void InitCompensationRange(CameraStandard::CameraMetadata& camera_meta_data);
void InitFpsTarget(CameraStandard::CameraMetadata& camera_meta_data);
void InitAvailableModes(CameraStandard::CameraMetadata& camera_meta_data);
void InitAntiBandingModes(CameraStandard::CameraMetadata& camera_meta_data);
void InitPhysicalSize(CameraStandard::CameraMetadata& camera_meta_data);
void Init(CameraStandard::CameraMetadata& camera_meta_data);
};
} // namespace OHOS::Camera
#endif
+27
View File
@@ -0,0 +1,27 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# 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.
import("//build/ohos.gni")
if (!defined(defines)) {
defines = []
}
camera_product_name_path = "//vendor/${product_company}/${product_name}"
camera_device_name_path = "//device/${product_company}/${device_name}"
is_support_v4l2 = true
if (is_support_v4l2) {
is_support_mpi = false
defines += [ "SUPPORT_V4L2" ]
chipset_build_deps = "$camera_device_name_path/camera/:chipset_build"
camera_device_manager_deps = "$camera_device_name_path/camera/src/device_manager:camera_device_manager"
camera_pipeline_core_deps = "$camera_device_name_path/camera/src/pipeline_core:camera_pipeline_core"
}
+91
View File
@@ -0,0 +1,91 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# 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.
import("//build/ohos.gni")
import("//drivers/peripheral/camera/hal/camera.gni")
config("device_manager_config") {
visibility = [ ":*" ]
cflags_cc = [
"-Wall",
"-Wextra",
"-Werror",
"-Wno-error",
"-DGST_DISABLE_DEPRECATED",
"-DHAVE_CONFIG_H",
"-DCOLORSPACE=\"videoconvert\"",
"-fno-strict-aliasing",
"-Wno-sign-compare",
"-Wno-builtin-requires-header",
"-Wno-unused-variable",
"-Wno-unused-label",
"-Wno-implicit-function-declaration",
"-Wno-format",
"-Wno-int-conversion",
"-Wno-unused-function",
"-Wno-thread-safety-attributes",
"-Wno-inconsistent-missing-override",
"-fno-rtti",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
]
}
ohos_shared_library("camera_device_manager") {
sources = [
"$camera_device_name_path/camera/src/device_manager/rkispv5.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/enumerator_manager.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/flash_controller.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/flash_manager.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/idevice_manager.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/isp_controller.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/isp_manager.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/sensor_controller.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/sensor_manager.cpp",
"$camera_path/adapter/platform/v4l2/src/device_manager/v4l2_device_manager.cpp",
"$camera_path/device_manager/src/icontroller.cpp",
"$camera_path/device_manager/src/imanager.cpp",
"$camera_path/device_manager/src/isensor.cpp",
]
include_dirs = [
"//base/hiviewdfx/interfaces/innerkits/libhilog/include",
"$camera_path/include",
"$camera_path/utils/event",
"$camera_path/device_manager/include",
"$camera_device_name_path/camera/include/device_manager",
"$camera_path/adapter/platform/v4l2/src/device_manager/include",
"$camera_path/adapter/platform/v4l2/src/driver_adapter/include/",
"//utils/native/base/include",
"//drivers/framework/include/utils",
"//drivers/adapter/uhdf2/osal/include",
"//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata/include",
]
deps = [
"$camera_path/adapter/platform/v4l2/src/driver_adapter:camera_v4l2_adapter",
"//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata:metadata",
"//utils/native/base:utils",
]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
external_deps = [ "hilog:libhilog" ]
}
public_configs = [ ":device_manager_config" ]
subsystem_name = "hdf"
part_name = "hdf"
}
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 "imx600.h"
#include <vector>
namespace OHOS::Camera {
IMPLEMENT_SENSOR(Imx600)
Imx600::Imx600() : ISensor("imx600") {}
Imx600::~Imx600() {}
void Imx600::InitPhysicalSize(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitPhysicalSize(camera_meta_data);
}
void Imx600::InitAntiBandingModes(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitAntiBandingModes(camera_meta_data);
}
void Imx600::InitAeFpsTarget(CameraStandard::CameraMetadata& camera_meta_data)
{
std::vector<int32_t> availableAeFpsTarget = {
15,
30,
};
camera_meta_data.addEntry(OHOS_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, availableAeFpsTarget.data(),
availableAeFpsTarget.size());
}
void Imx600::InitCompensationRange(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitCompensationRange(camera_meta_data);
}
void Imx600::InitSensitivityRange(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitSensitivityRange(camera_meta_data);
}
void Imx600::Init(CameraStandard::CameraMetadata& camera_meta_data)
{
InitPhysicalSize(camera_meta_data);
InitAntiBandingModes(camera_meta_data);
std::vector<uint8_t> aeAvailableModes = {
OHOS_CAMERA_AE_MODE_ON,
};
camera_meta_data.addEntry(OHOS_CONTROL_AE_AVAILABLE_MODES, aeAvailableModes.data(),
aeAvailableModes.size());
InitAeFpsTarget(camera_meta_data);
InitCompensationRange(camera_meta_data);
const camera_rational_t aeCompensationStep[] = {{0, 1}};
camera_meta_data.addEntry(OHOS_CONTROL_AE_COMPENSATION_STEP, aeCompensationStep, 1);
std::vector<uint8_t> availableAwbModes = {
OHOS_CAMERA_AWB_MODE_OFF,
};
camera_meta_data.addEntry(OHOS_CONTROL_AWB_AVAILABLE_MODES, availableAwbModes.data(),
availableAwbModes.size());
InitSensitivityRange(camera_meta_data);
uint8_t faceDetectMode = OHOS_CAMERA_FACE_DETECT_MODE_OFF;
camera_meta_data.addEntry(OHOS_STATISTICS_FACE_DETECT_MODE, &faceDetectMode,
1);
}
} // namespace OHOS::Camera
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 "rkispv5.h"
#include <vector>
namespace OHOS::Camera {
IMPLEMENT_SENSOR(Rkispv5)
Rkispv5::Rkispv5() : ISensor("rkisp_v5") {}
Rkispv5::~Rkispv5() {}
void Rkispv5::InitPhysicalSize(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitPhysicalSize(camera_meta_data);
}
void Rkispv5::InitAntiBandingModes(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitAntiBandingModes(camera_meta_data);
}
void Rkispv5::InitAvailableModes(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitAvailableModes(camera_meta_data);
}
void Rkispv5::InitFpsTarget(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitFpsTarget(camera_meta_data);
}
void Rkispv5::InitCompensationRange(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitCompensationRange(camera_meta_data);
}
void Rkispv5::InitAwbModes(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitAwbModes(camera_meta_data);
}
void Rkispv5::InitSensitivityRange(CameraStandard::CameraMetadata& camera_meta_data)
{
ISensor::InitSensitivityRange(camera_meta_data);
}
void Rkispv5::Init(CameraStandard::CameraMetadata& camera_metaData)
{
InitPhysicalSize(camera_metaData);
InitAntiBandingModes(camera_metaData);
InitAvailableModes(camera_metaData);
InitFpsTarget(camera_metaData);
InitCompensationRange(camera_metaData);
const camera_rational_t aeCompensationStep[] = {{0, 1}};
camera_metaData.addEntry(OHOS_CONTROL_AE_COMPENSATION_STEP, aeCompensationStep, 1);
InitAwbModes(camera_metaData);
InitSensitivityRange(camera_metaData);
uint8_t faceDetectMode = OHOS_CAMERA_FACE_DETECT_MODE_OFF;
camera_metaData.addEntry(OHOS_STATISTICS_FACE_DETECT_MODE, &faceDetectMode, 1);
}
} // namespace OHOS::Camera
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 HOS_CAMERA_PROJET_HARDWARE_H
#define HOS_CAMERA_PROJET_HARDWARE_H
#include <linux/videodev2.h>
namespace OHOS::Camera {
#define PREVIEW_PIXEL_FORMAT V4L2_PIX_FMT_YUV420
#define CAPTURE_PIXEL_FORMAT V4L2_PIX_FMT_YUV420
#define VIDEO_PIXEL_FORMAT V4L2_PIX_FMT_YUV420
#define TEST_SENSOR_NAME "rkisp_v5"
} // namespace OHOS::Camera
#endif
+80
View File
@@ -0,0 +1,80 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# 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.
import("//build/test.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/peripheral/camera/hal/camera.gni")
module_output_path = "hdf/v4l2_adapter_test"
config("v4l2_utest_config") {
visibility = [ ":*" ]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-Wno-error",
"-DGST_DISABLE_DEPRECATED",
"-DHAVE_CONFIG_H",
"-DCOLORSPACE=\"videoconvert\"",
"-fno-strict-aliasing",
"-Wno-sign-compare",
"-Wno-builtin-requires-header",
"-Wno-unused-variable",
"-Wno-unused-label",
"-Wno-implicit-function-declaration",
"-Wno-format",
"-Wno-int-conversion",
"-Wno-unused-function",
"-Wno-thread-safety-attributes",
"-Wno-inconsistent-missing-override",
"-fno-rtti",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
]
}
ohos_unittest("v4l2_adapter_unittest") {
test_type = "unittest"
testonly = true
module_out_path = module_output_path
sources = [ "unittest/utest_v4l2.cpp" ]
include_dirs = [
"$camera_path/include",
"$camera_path/adapter/platform/v4l2/src/driver_adapter/include",
"$camera_device_name_path/camera/src/driver_adapter/test/unittest/include",
"//third_party/googletest/googletest/include/gtest",
"//utils/native/base/include",
]
deps = [
"$camera_path/adapter/platform/v4l2/src/driver_adapter:camera_v4l2_adapter",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
]
defines += [ "V4L2_UTEST" ]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
external_deps = [ "hilog:libhilog" ]
}
public_configs = [ ":v4l2_utest_config" ]
}
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 HOS_CAMERA_UTEST_V4L2_H
#define HOS_CAMERA_UTEST_V4L2_H
#include <stdio.h>
#include <gtest/gtest.h>
#include "v4l2_dev.h"
#include "v4l2_uvc.h"
namespace OHOS::Camera {
class UtestV4L2Dev : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp(void);
void TearDown(void);
static std::shared_ptr<HosV4L2UVC> V4L2UVC_;
static std::shared_ptr<HosV4L2Dev> V4L2Dev_;
static std::vector<std::string> cameraIDs_;
};
std::shared_ptr<HosV4L2UVC> UtestV4L2Dev::V4L2UVC_ = nullptr;
std::shared_ptr<HosV4L2Dev> UtestV4L2Dev::V4L2Dev_ = nullptr;
std::vector<std::string> UtestV4L2Dev::cameraIDs_ = {};
} // namespace OHOS::Camera
#endif
@@ -0,0 +1,190 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 <gtest/gtest.h>
#include <v4l2_dev.h>
#include <v4l2_uvc.h>
#include "utest_v4l2.h"
using namespace testing::ext;
namespace OHOS::Camera {
void V4L2UvcCallback(const std::string cameraId, const std::vector<DeviceControl>& control,
const std::vector<DeviceFormat>& fromat, const bool inOut)
{
std::cout << "V4L2UvcCallback" << std::endl;
}
void V4L2BufferCallback(std::shared_ptr<FrameSpec> buffer)
{
std::cout << "V4L2BufferCallback" << std::endl;
}
void UtestV4L2Dev::SetUpTestCase(void)
{
std::cout << "SetUpTestCase.." << std::endl;
V4L2UVC_ = std::make_shared<HosV4L2UVC>();
EXPECT_EQ(true, V4L2UVC_ != nullptr);
V4L2Dev_ = std::make_shared<HosV4L2Dev>();
EXPECT_EQ(true, V4L2Dev_ != nullptr);
}
void UtestV4L2Dev::TearDownTestCase(void)
{
std::cout << "TearDownTestCase.." << std::endl;
}
void UtestV4L2Dev::SetUp(void)
{
std::cout << "SetUp.." << std::endl;
}
void UtestV4L2Dev::TearDown(void)
{
std::cout << "TearDown.." << std::endl;
}
HWTEST_F(UtestV4L2Dev, InitUvc, TestSize.Level0)
{
V4L2UVC_->V4L2UvcDetectInit(V4L2UvcCallback);
}
HWTEST_F(UtestV4L2Dev, InitCamera, TestSize.Level0)
{
int rc = 0;
cameraIDs_.push_back("rkisp_v5");
rc = HosV4L2Dev::Init(cameraIDs_);
EXPECT_EQ(true, rc != RC_ERROR);
}
HWTEST_F(UtestV4L2Dev, SetFormat, TestSize.Level0)
{
constexpr uint32_t width = 640;
constexpr uint32_t height = 480;
int rc = 0;
std::string devname = "rkisp_v5";
DeviceFormat format = {};
rc = V4L2Dev_->start(devname);
EXPECT_EQ(RC_OK, rc);
rc = V4L2Dev_->ConfigSys(devname, CMD_V4L2_GET_FORMAT, format);
EXPECT_EQ(RC_OK, rc);
format.fmtdesc.pixelformat = V4L2_PIX_FMT_YUYV;
format.fmtdesc.width = width;
format.fmtdesc.height = height;
rc = V4L2Dev_->ConfigSys(devname, CMD_V4L2_SET_FORMAT, format);
EXPECT_EQ(RC_OK, rc);
rc = V4L2Dev_->ConfigSys(devname, CMD_V4L2_GET_FPS, format);
EXPECT_EQ(RC_OK, rc);
}
HWTEST_F(UtestV4L2Dev, SetBuffer, TestSize.Level0)
{
constexpr uint32_t bufferCount = 4;
unsigned char* addr[bufferCount];
std::shared_ptr<FrameSpec> buffptr[bufferCount];
std::string devname = "rkisp_v5";
DeviceFormat format = {};
unsigned int bufSize;
int i;
int rc = 0;
rc = V4L2Dev_->ReqBuffers(devname, bufferCount);
EXPECT_EQ(RC_OK, rc);
rc = V4L2Dev_->ConfigSys(devname, CMD_V4L2_GET_FORMAT, format);
EXPECT_EQ(RC_OK, rc);
bufSize = format.fmtdesc.sizeimage;
for (i = 0; i < bufferCount; ++i) {
buffptr[i] = std::make_shared<FrameSpec>();
buffptr[i]->buffer_ = std::make_shared<IBuffer>();
buffptr[i]->buffer_->SetIndex(i);
buffptr[i]->buffer_->SetSize(bufSize);
buffptr[i]->buffer_->SetUsage(1);
buffptr[i]->bufferPoolId_ = 0;
addr[i] = (unsigned char*)malloc(bufSize);
if (addr == nullptr) {
std::cout << " malloc buffers fail \n" << std::endl;
break;
}
buffptr[i]->buffer_->SetVirAddress(addr[i]);
rc = V4L2Dev_->CreatBuffer(devname, buffptr[i]);
EXPECT_EQ(RC_OK, rc);
}
if (i != bufferCount) {
for (int j = 0; j < i; ++j) {
free(addr[j]);
}
V4L2Dev_->stop(devname);
}
EXPECT_EQ(bufferCount, i);
}
HWTEST_F(UtestV4L2Dev, SetFrameCallback, TestSize.Level0)
{
int rc = 0;
rc = V4L2Dev_->SetCallback(V4L2BufferCallback);
EXPECT_EQ(RC_OK, rc);
}
HWTEST_F(UtestV4L2Dev, StreamStart, TestSize.Level0)
{
int rc = 0;
int value;
std::string devname = "rkisp_v5";
constexpr uint32_t awbValue = 8;
rc = V4L2Dev_->StartStream(devname);
EXPECT_EQ(RC_OK, rc);
rc = V4L2Dev_->QuerySetting(devname, CMD_AWB_MODE, &value);
EXPECT_EQ(RC_OK, rc);
int setValue = awbValue;
rc = V4L2Dev_->UpdateSetting(devname, CMD_AWB_MODE, &setValue);
EXPECT_EQ(RC_OK, rc);
sleep(3);
}
HWTEST_F(UtestV4L2Dev, ReleaseAll, TestSize.Level0)
{
std::string devname = "rkisp_v5";
V4L2Dev_->StopStream(devname);
V4L2Dev_->ReleaseBuffers(devname);
V4L2Dev_->stop(devname);
V4L2UVC_->V4L2UvcDetectUnInit();
}
} // namespace OHOS::Camera
+171
View File
@@ -0,0 +1,171 @@
# Copyright (c) 2021 Huawei Device Co., Ltd.
# 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.
import("//build/ohos.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/peripheral/camera/hal/camera.gni")
config("pipe_config") {
visibility = [ ":*" ]
cflags_cc = [
"-Wall",
"-Wextra",
"-Werror",
"-Wno-error",
"-DGST_DISABLE_DEPRECATED",
"-DHAVE_CONFIG_H",
"-DCOLORSPACE=\"videoconvert\"",
"-fno-strict-aliasing",
"-Wno-sign-compare",
"-Wno-builtin-requires-header",
"-Wno-unused-variable",
"-Wno-unused-label",
"-Wno-implicit-function-declaration",
"-Wno-format",
"-Wno-int-conversion",
"-Wno-unused-function",
"-Wno-thread-safety-attributes",
"-Wno-inconsistent-missing-override",
"-fno-rtti",
"-fno-exceptions",
"-ffunction-sections",
"-fdata-sections",
]
}
ohos_shared_library("camera_pipeline_core") {
sources = [
"$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node/uvc_node.cpp",
"$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node/v4l2_source_node.cpp",
"$camera_path/pipeline_core/host_stream/src/host_stream_impl.cpp",
"$camera_path/pipeline_core/host_stream/src/host_stream_mgr_impl.cpp",
"$camera_path/pipeline_core/ipp/src/algo_plugin.cpp",
"$camera_path/pipeline_core/ipp/src/algo_plugin_manager.cpp",
"$camera_path/pipeline_core/ipp/src/ipp_algo_parser.cpp",
"$camera_path/pipeline_core/ipp/src/ipp_node.cpp",
"$camera_path/pipeline_core/ipp/src/offline_pipeline.cpp",
"$camera_path/pipeline_core/ipp/src/offline_pipeline_manager.cpp",
"$camera_path/pipeline_core/nodes/src/dummy_node/dummy_node.cpp",
"$camera_path/pipeline_core/nodes/src/fork_node/fork_node.cpp",
"$camera_path/pipeline_core/nodes/src/merge_node/merge_node.cpp",
"$camera_path/pipeline_core/nodes/src/node_base/node_base.cpp",
"$camera_path/pipeline_core/nodes/src/sensor_node/sensor_node.cpp",
"$camera_path/pipeline_core/nodes/src/sink_node/sink_node.cpp",
"$camera_path/pipeline_core/nodes/src/source_node/source_node.cpp",
"$camera_path/pipeline_core/pipeline_impl/src/builder/stream_pipeline_builder.cpp",
"$camera_path/pipeline_core/pipeline_impl/src/dispatcher/stream_pipeline_dispatcher.cpp",
"$camera_path/pipeline_core/pipeline_impl/src/parser/config_parser.cpp",
"$camera_path/pipeline_core/pipeline_impl/src/strategy/config/config.c",
"$camera_path/pipeline_core/pipeline_impl/src/strategy/config/params.c",
"$camera_path/pipeline_core/pipeline_impl/src/strategy/stream_pipeline_strategy.cpp",
"$camera_path/pipeline_core/pipeline_impl/src/stream_pipeline_core.cpp",
"$camera_path/pipeline_core/src/pipeline_core.cpp",
]
include_dirs = [
"//utils/native/base/include",
"//base/hiviewdfx/interfaces/innerkits/libhilog/include",
"$camera_path/../interfaces/include",
"$camera_path/../interfaces/hdi_ipc",
"$camera_path/include",
"$camera_path/hdi_impl",
"$camera_path/hdi_impl/camera_host/include",
"$camera_path/hdi_impl/camera_device/include",
"$camera_path/hdi_impl/stream_operator/include",
"$camera_path/hdi_impl/include",
"$camera_path/device_manager",
"$camera_path/device_manager/include",
"$camera_path/pipeline_core",
"$camera_path/pipeline_core/host_stream/include",
"$camera_path/pipeline_core/utils",
"$camera_path/pipeline_core/nodes/include",
"$camera_path/pipeline_core/nodes/src/sensor_node",
"$camera_path/pipeline_core/nodes/src/node_base",
"$camera_path/pipeline_core/nodes/src/sink_node",
"$camera_path/pipeline_core/nodes/src/source_node",
"$camera_path/pipeline_core/nodes/src/merge_node",
"$camera_path/pipeline_core/nodes/src/dummy_node",
"$camera_path/pipeline_core/pipeline_impl/include",
"$camera_path/pipeline_core/pipeline_impl/src",
"$camera_path/pipeline_core/include",
"$camera_path/pipeline_core/pipeline_impl/src/builder",
"$camera_path/pipeline_core/pipeline_impl/src/dispatcher",
"$camera_path/pipeline_core/pipeline_impl/src/parser",
"$camera_path/pipeline_core/pipeline_impl/src/strategy",
"$camera_path/pipeline_core/pipeline_impl/src/strategy/config",
"$camera_path/pipeline_core/ipp/include",
"$camera_path/interfaces/hdi",
"$camera_path/utils/event",
"$camera_path/adapter/platform/v4l2/src/device_manager/include",
"$camera_device_name_path/camera/include/device_manager",
"$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/v4l2_source_node",
"$camera_path/adapter/platform/v4l2/src/pipeline_core/nodes/uvc_node",
"//drivers/peripheral/camera/hal/adapter/platform/v4l2/src/driver_adapter/include/",
"//foundation/communication/ipc/ipc/native/src/core/include",
"//foundation/communication/ipc/interfaces/innerkits/ipc_core/include",
"//utils/native/base/include",
"//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata/include",
"$camera_device_name_path/camera/rk",
# hcs parser
"//drivers/framework/include/osal",
"//drivers/framework/include/utils",
"//drivers/adapter/uhdf2/osal/include",
"//system/core/include/cutils",
"//drivers/framework/utils/include",
"//drivers/adapter/uhdf2/osal/include",
]
deps = [
"$camera_path/buffer_manager:camera_buffer_manager",
"$camera_path/device_manager:camera_device_manager",
"//foundation/multimedia/camera_standard/frameworks/innerkitsimpl/metadata:metadata",
# hcs parser
"$hdf_uhdf_path/utils:libhdf_utils",
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
"//foundation/graphic/standard:libsurface",
]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
external_deps = [ "hilog:libhilog" ]
}
public_configs = [ ":pipe_config" ]
subsystem_name = "hdf"
part_name = "hdf"
}
config("example_config") {
visibility = [ ":*" ]
cflags = [
"-Wno-error",
"-Wno-unused-function",
"-Wno-unused-parameter",
]
}
ohos_shared_library("camera_ipp_algo_example") {
sources = [ "$camera_device_name_path/camera/src/pipeline_core/ipp_algo_example/ipp_algo_example.c" ]
include_dirs = [
"$camera_path/pipeline_core/ipp/include",
"//utils/native/base/include",
]
deps = [ "//utils/native/base:utils" ]
public_configs = [ ":example_config" ]
subsystem_name = "hdf"
part_name = "hdf"
}
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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 "ipp_algo.h"
#include <stdio.h>
#include "securec.h"
#define MAX_BUFFER_COUNT 100
int Init(const IppAlgoMeta *meta)
{
printf("ipp algo example Init ...\n");
return 0;
}
int Start()
{
printf("ipp algo example Start ...\n");
return 0;
}
int Flush()
{
printf("ipp algo example Flush ...\n");
return 0;
}
int Process(IppAlgoBuffer *inBuffer[], int inBufferCount, IppAlgoBuffer *outBuffer, const IppAlgoMeta *meta)
{
printf("ipp algo example Process ...\n");
if (inBuffer == NULL || inBufferCount > MAX_BUFFER_COUNT) {
printf("inBuffer is NULL\n");
return -1;
}
for (int i = 0; i < inBufferCount; i++) {
if (inBuffer[i] != NULL) {
printf("in buffer addr = %p, width = %u, height = %u, stride = %u, size = %u, id = %d\n", inBuffer[i]->addr,
inBuffer[i]->width, inBuffer[i]->height, inBuffer[i]->stride, inBuffer[i]->size, inBuffer[i]->id);
} else {
printf("in buffer %d is NULL\n", i);
}
}
if (outBuffer != NULL && outBuffer->addr != NULL) {
printf("out buffer addr = %p, size = %u, id = %d\n", outBuffer->addr, outBuffer->size, outBuffer->id);
} else {
printf("out buffer is NULL\n");
}
if (inBufferCount == 1) {
if (inBuffer[0] == NULL || outBuffer == NULL || inBuffer[0]->addr == NULL || outBuffer->addr == NULL) {
return 0;
}
char *in = (char*)(inBuffer[0]->addr);
char *out = (char*)(outBuffer->addr);
if (memcpy_s(out, outBuffer->size, in, outBuffer->size) != 0) {
printf("memcpy_s failed.");
}
return 0;
}
if (inBufferCount == 2) {
if (inBuffer[0] == NULL || inBuffer[1] == NULL || inBuffer[0]->addr == NULL || inBuffer[1]->addr == NULL) {
return -1;
}
printf("example algo merge 2 camera images\n");
// format is yuv422
char *startBuffer1 = (char*)(inBuffer[0]->addr) + inBuffer[0]->stride * inBuffer[0]->height;
char *startBuffer2 = (char*)(inBuffer[1]->addr) + inBuffer[1]->stride * inBuffer[1]->height;
if (memcpy_s(startBuffer1, inBuffer[0]->size - inBuffer[0]->stride * inBuffer[0]->height,
startBuffer2, inBuffer[0]->stride * inBuffer[0]->height) != 0) {
printf("memcpy_s failed.");
}
return 0;
}
return 0;
}
int Stop()
{
printf("ipp algo example Stop ...\n");
return 0;
}