From 7264530be28306238c739f9b18e7dcb809638ecf Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Mon, 18 Oct 2021 20:14:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B4=E6=98=8E=EF=BC=9A1.?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0mipi-csi=E6=B5=8B=E8=AF=95=E5=8D=95=E5=85=83?= =?UTF-8?q?=EF=BC=9B2.=E5=B0=86=E5=8D=95=E5=85=83=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=B5=8B=E8=AF=95=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YOUR_NAME --- .../unittest/common/hdf_mipi_csi_test.cpp | 206 +++++++ .../unittest/common/hdf_mipi_dsi_test.cpp | 7 - test/unittest/common/hdf_main_test.c | 6 + test/unittest/common/hdf_main_test.h | 1 + test/unittest/include/hdf_uhdf_test.h | 3 +- test/unittest/platform/common/mipi_csi_test.c | 547 ++++++++++++++++++ test/unittest/platform/common/mipi_csi_test.h | 62 ++ test/unittest/platform/common/mipi_dsi_test.c | 6 +- .../platform/hdf_mipi_csi_entry_test.c | 35 ++ .../platform/hdf_mipi_csi_entry_test.h | 15 + .../platform/hdf_mipi_dsi_entry_test.c | 1 - 11 files changed, 875 insertions(+), 14 deletions(-) create mode 100755 support/platform/test/unittest/common/hdf_mipi_csi_test.cpp create mode 100755 test/unittest/platform/common/mipi_csi_test.c create mode 100755 test/unittest/platform/common/mipi_csi_test.h create mode 100755 test/unittest/platform/hdf_mipi_csi_entry_test.c create mode 100755 test/unittest/platform/hdf_mipi_csi_entry_test.h diff --git a/support/platform/test/unittest/common/hdf_mipi_csi_test.cpp b/support/platform/test/unittest/common/hdf_mipi_csi_test.cpp new file mode 100755 index 000000000..8c661ecff --- /dev/null +++ b/support/platform/test/unittest/common/hdf_mipi_csi_test.cpp @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "hdf_uhdf_test.h" +#include + +using namespace testing::ext; + +/** + * @brief Mipi csi test case number. + * + * The sequence number is related to the test logic, which is different from the actual call. + * 1, 4, 8 and 9 need to be called according to the actual situation. + * + * @since 1.0 + */ +enum MipiCsiTestCmd { + MIPI_CSI_TEST_SET_HS_MODE = 0, + MIPI_CSI_TEST_DISABLE_MIPI_CLOCK = 1, /* for test */ + MIPI_CSI_TEST_ENABLE_MIPI_CLOCK = 2, + MIPI_CSI_TEST_RESET_RX = 3, + MIPI_CSI_TEST_DISABLE_SENSOR_CLOCK = 4, /* for test */ + MIPI_CSI_TEST_ENABLE_SENSOR_CLOCK = 5, + MIPI_CSI_TEST_RESET_SENSOR = 6, + MIPI_CSI_TEST_SET_DEV_ATTR = 7, + MIPI_CSI_TEST_SET_PHY_CMVMODE = 8, /* for test */ + MIPI_CSI_TEST_SET_EXT_DATA_TYPE = 9, /* for test */ + MIPI_CSI_TEST_UNRESET_RX = 10, + MIPI_CSI_TEST_UNRESET_SENSOR = 11, + MIPI_CSI_TEST_MAX = 12 +}; + +class HdfLiteMipiCsiTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; + +void HdfLiteMipiCsiTest::SetUpTestCase() +{ + HdfTestOpenService(); +} + +void HdfLiteMipiCsiTest::TearDownTestCase() +{ + HdfTestCloseService(); +} + +void HdfLiteMipiCsiTest::SetUp() +{ +} + +void HdfLiteMipiCsiTest::TearDown() +{ +} + +/** + * @tc.name: MipiCsiSetHsModeTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiSetHsModeTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_SET_HS_MODE, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiDisableMipiClockTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiDisableMipiClockTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_DISABLE_MIPI_CLOCK, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiEnableMipiClockTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiEnableMipiClockTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_ENABLE_MIPI_CLOCK, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiResetRxTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiResetRxTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_RESET_RX, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiDisableSensorClockTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiDisableSensorClockTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_DISABLE_SENSOR_CLOCK, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiEnableSensorClockTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiEnableSensorClockTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_ENABLE_SENSOR_CLOCK, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiResetSensorTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiResetSensorTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_RESET_SENSOR, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiSetComboDevAttrTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiSetComboDevAttrTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_SET_DEV_ATTR, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiSetPhyCmvmodeTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiSetPhyCmvmodeTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_SET_PHY_CMVMODE, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiSetExtDataTypeTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiSetExtDataTypeTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_SET_EXT_DATA_TYPE, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiUnresetRxTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiUnresetRxTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_UNRESET_RX, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} + +/** + * @tc.name: MipiCsiUnresetSensorTest001 + * @tc.desc: mipi csi function test + * @tc.type: FUNC + * @tc.require: NA + */ +HWTEST_F(HdfLiteMipiCsiTest, MipiCsiUnresetSensorTest001, TestSize.Level1) +{ + struct HdfTestMsg msg = {TEST_PAL_MIPI_CSI_TYPE, MIPI_CSI_TEST_UNRESET_SENSOR, -1}; + EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); +} \ No newline at end of file diff --git a/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp b/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp index 4f394ec38..d0b009e15 100644 --- a/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp +++ b/support/platform/test/unittest/common/hdf_mipi_dsi_test.cpp @@ -7,14 +7,7 @@ */ #include "hdf_uhdf_test.h" -#include -#include -#include -#include #include -#include -#include -#include "hdf_io_service_if.h" using namespace testing::ext; diff --git a/test/unittest/common/hdf_main_test.c b/test/unittest/common/hdf_main_test.c index 205ac2ded..804c8f8c9 100644 --- a/test/unittest/common/hdf_main_test.c +++ b/test/unittest/common/hdf_main_test.c @@ -44,6 +44,9 @@ #if defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_DSI) || defined(CONFIG_DRIVERS_HDF_PLATFORM_MIPI_DSI) #include "hdf_mipi_dsi_entry_test.h" #endif +#if defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_CSI) || defined(CONFIG_DRIVERS_HDF_PLATFORM_MIPI_CSI) +#include "hdf_mipi_csi_entry_test.h" +#endif #if (defined(LOSCFG_STORAGE_EMMC) && defined(LOSCFG_DRIVERS_HDF_PLATFORM_EMMC)) || \ defined(CONFIG_DRIVERS_HDF_PLATFORM_EMMC) #include "hdf_emmc_entry_test.h" @@ -97,6 +100,9 @@ HdfTestFuncList g_hdfTestFuncList[] = { #if defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_DSI) || defined(CONFIG_DRIVERS_HDF_PLATFORM_MIPI_DSI) { TEST_PAL_MIPI_DSI_TYPE, HdfMipiDsiEntry }, #endif +#if defined(LOSCFG_DRIVERS_HDF_PLATFORM_MIPI_CSI) || defined(CONFIG_DRIVERS_HDF_PLATFORM_MIPI_CSI) + { TEST_PAL_MIPI_CSI_TYPE, HdfMipiCsiEntry }, +#endif #if defined(LOSCFG_DRIVERS_HDF_PLATFORM_SDIO) || defined(CONFIG_DRIVERS_HDF_PLATFORM_SDIO) { TEST_PAL_SDIO_TYPE, HdfSdioUnitTestEntry }, #endif diff --git a/test/unittest/common/hdf_main_test.h b/test/unittest/common/hdf_main_test.h index c54969825..3447e3594 100644 --- a/test/unittest/common/hdf_main_test.h +++ b/test/unittest/common/hdf_main_test.h @@ -58,6 +58,7 @@ typedef enum { TEST_PAL_ADC_TYPE = 20, TEST_PAL_WDT_TYPE = 21, TEST_PAL_I3C_TYPE = 22, + TEST_PAL_MIPI_CSI_TYPE = 23, TEST_PAL_END = 200, TEST_OSAL_BEGIN = TEST_PAL_END, #define HDF_OSAL_TEST_ITEM(v) (TEST_OSAL_BEGIN + (v)) diff --git a/test/unittest/include/hdf_uhdf_test.h b/test/unittest/include/hdf_uhdf_test.h index 0c22f0cb9..73a762633 100644 --- a/test/unittest/include/hdf_uhdf_test.h +++ b/test/unittest/include/hdf_uhdf_test.h @@ -54,11 +54,12 @@ enum HdfTestSubModuleCmd { TEST_PAL_ADC_TYPE = 20, TEST_PAL_WDT_TYPE = 21, TEST_PAL_I3C_TYPE = 22, + TEST_PAL_MIPI_CSI_TYPE = 23, TEST_PAL_END = 200, TEST_OSAL_BEGIN = TEST_PAL_END, #define HDF_OSAL_TEST_ITEM(v) (TEST_OSAL_BEGIN + (v)) TEST_OSAL_ITEM = HDF_OSAL_TEST_ITEM(1), - TEST_OSAL_END = 400, + TEST_OSAL_END = 400, TEST_WIFI_BEGIN = TEST_OSAL_END, TEST_WIFI_TYPE = TEST_WIFI_BEGIN + 1, TEST_WIFI_END = 600, diff --git a/test/unittest/platform/common/mipi_csi_test.c b/test/unittest/platform/common/mipi_csi_test.c new file mode 100755 index 000000000..cb028a06d --- /dev/null +++ b/test/unittest/platform/common/mipi_csi_test.c @@ -0,0 +1,547 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "mipi_csi_test.h" +#include "hdf_log.h" +#include "osal_time.h" +#include "securec.h" + +#define HDF_LOG_TAG mipi_csi_test +#define SEQ_OUTPUT_DELAY 100 /* Delay time of sequential output, unit: ms */ + +// Input interface type of RX. +enum InterfaceType { + INTERFACE_MIPI = 0, + INTERFACE_LVDS, + INTERFACE_CMOS, + INTERFACE_BUTT +}; + +static int32_t MipiCsiTestSetUp(struct MipiCsiTest *test) +{ + HDF_LOGI("%s: enter!", __func__); + + if (test == NULL) { + HDF_LOGE("%s: test is NULL.", __func__); + return HDF_ERR_INVALID_OBJECT; + } + + if (test->handle == NULL) { + HDF_LOGE("%s: enter! cntlrId:0x%x", __func__, test->cntlrId); + test->cntlrId = 0; + test->handle = MipiCsiOpen(test->cntlrId); + if (test->handle == NULL) { + HDF_LOGE("%s: failed.", __func__); + return HDF_FAILURE; + } + } + + test->fails = 0; + HDF_LOGD("%s: cntlrId:0x%x", __func__, test->cntlrId); + return HDF_SUCCESS; +} + +static void MipiCsiTestTearDown(struct MipiCsiTest *test) +{ + if (test == NULL) { + return; + } + if (test->handle != NULL) { + MipiCsiClose(test->handle); + test->handle = NULL; + } +} + +/** + * @brief Initialize the device parameters applying LVDS protocol. + * + * This is not fully tested! + * + * @since 1.0 + */ +static void InitLvdsDevAttr(LvdsDevAttr *lvdsAttr) +{ + int i; + int j; + int k; + LvdsDevAttr attr; + + if (lvdsAttr == NULL) { + return; + } + + (void)memset_s(&attr, sizeof(LvdsDevAttr), 0, sizeof(LvdsDevAttr)); + // Hi3516CV500 (DATA_TYPE_RAW_12BIT), Hi3516EV200 (DATA_TYPE_RAW_12BIT) + attr.inputDataType = DATA_TYPE_RAW_12BIT; + attr.wdrMode = HI_WDR_MODE_NONE; + // LVDS synchronization mode. LVDS_SYNC_MODE_SOF, LVDS_SYNC_MODE_SAV + attr.syncMode = LVDS_SYNC_MODE_SOF; + // LVDS Vsync type. LVDS_VSYNC_NORMAL, LVDS_VSYNC_SHARE, LVDS_VSYNC_HCONNECT + attr.vsyncAttr.syncType = LVDS_VSYNC_NORMAL; + // hconnect vsync blanking len, valid when the syncType is LVDS_VSYNC_HCONNECT + // This is not fully tested! + if (attr.vsyncAttr.syncType == LVDS_VSYNC_HCONNECT) { + attr.vsyncAttr.hblank1 = 0; + attr.vsyncAttr.hblank2 = 0; + } + // frame identification code: LVDS_FID_NONE, LVDS_FID_IN_SAV, LVDS_FID_IN_DATA + attr.fidAttr.fidType = LVDS_FID_NONE; + // Sony DOL has the Frame Information Line, in DOL H-Connection mode, should + // configure this flag as false to disable output the Frame Information Line. + // This is not fully tested! + attr.fidAttr.outputFil = 'm'; + // LVDS bit size end mode: LVDS_ENDIAN_LITTLE, LVDS_ENDIAN_BIG + attr.dataEndian = LVDS_ENDIAN_LITTLE; + // sync code endian: little/big, LVDS_ENDIAN_LITTLE, LVDS_ENDIAN_BIG + attr.syncCodeEndian = LVDS_ENDIAN_LITTLE; + // laneId: -1 - disable + attr.laneId[0] = 0; /* 0 -- laneId 0 */ + attr.laneId[1] = 1; /* 1 -- laneId 1 */ + attr.laneId[2] = 2; /* 2 -- laneId 2 */ + attr.laneId[3] = 3; /* 3 -- laneId 3 */ + + /** each vc has 4 params, syncCode[i]: + syncMode is SYNC_MODE_SOF: SOF, EOF, SOL, EOL + syncMode is SYNC_MODE_SAV: invalid sav, invalid eav, valid sav, valid eav */ + // This is not fully tested! + for (i = 0; i < LVDS_LANE_NUM; i++) { + for (j = 0; j < WDR_VC_NUM; j++) { + for (k = 0; k < SYNC_CODE_NUM; k++) { + attr.syncCode[i][j][k] = 0; /* 0 -- frame0 sof */ + } + } + } + + *lvdsAttr = attr; +} + +/** + * @brief Initialize MIPI device attributes. + * + * Data type (DT: data type) + * The data type describes the format and content of load data. Up to 64 data types are supported. + * There are only two data types for short packets, and the others belong to long packets. + * + * @Data type describe + * 0x00 – 0x07 Synchronous short packet data type + * 0x08 – 0x0F General short packet data type + * 0x10 – 0x17 General long packet data type + * 0x18 – 0x1F YUV data + * 0x20 – 0x27 RGB data + * 0x28 – 0x2F Raw data + * 0x30 – 0x37 User defined byte based data type + * 0x38 – 0x3F Reserved + * + * @since 1.0 + */ +static void InitMipiDevAttr(MipiDevAttr *mipiAttr) +{ + MipiDevAttr attr; + if (mipiAttr == NULL) { + return; + } + + HDF_LOGI("%s: enter.", __func__); + (void)memset_s(&attr, sizeof(MipiDevAttr), 0, sizeof(MipiDevAttr)); + // Hi3516CV500 (DATA_TYPE_RAW_12BIT), Hi3516EV200 (DATA_TYPE_RAW_12BIT) + attr.inputDataType = DATA_TYPE_RAW_12BIT; + // Hi3516CV500 (HI_MIPI_WDR_MODE_NONE), Hi3516EV200 (HI_MIPI_WDR_MODE_NONE) + attr.wdrMode = HI_MIPI_WDR_MODE_NONE; + // laneId: -1 - disable + // Hi3516CV500 (0, 1, 2, 3), Hi3516EV200 (0, 1, -1, -1) + attr.laneId[0] = 0; /* 0 -- laneId 0 */ + attr.laneId[1] = 1; /* 1 -- laneId 1 */ + attr.laneId[2] = 2; /* 2 -- laneId 2 */ + attr.laneId[3] = 3; /* 3 -- laneId 3 */ + + // Used by the HI_MIPI_WDR_MODE_DT, This is not fully tested! + if (attr.wdrMode == HI_MIPI_WDR_MODE_DT) { + attr.dataType[0] = 0x39; /* 0x39 -- data type reserved */ + attr.dataType[1] = 0x39; /* 0x39 -- data type reserved */ + attr.dataType[2] = 0x39; /* 0x39 -- data type reserved */ + attr.dataType[3] = 0x39; /* 0x39 -- data type reserved */ + } + + *mipiAttr = attr; +} + +static int MipiGetIntputModeType(InputMode inputMode) +{ + switch (inputMode) { + case INPUT_MODE_SUBLVDS: + case INPUT_MODE_LVDS: + case INPUT_MODE_HISPI: + return INTERFACE_LVDS; + case INPUT_MODE_MIPI: + return INTERFACE_MIPI; + case INPUT_MODE_CMOS: + case INPUT_MODE_BT1120: + case INPUT_MODE_BT656: + case INPUT_MODE_BYPASS: + return INTERFACE_CMOS; + default: + break; + } + + return INTERFACE_BUTT; +} + +static void InitComboDevAttr(struct MipiCsiTest *test) +{ + enum InterfaceType interType; + ComboDevAttr attr; + + (void)memset_s(&attr, sizeof(ComboDevAttr), 0, sizeof(ComboDevAttr)); + // Hi3516CV500(0), Hi3516EV200(0) + attr.devno = 0; + // Hi3516CV500(INPUT_MODE_MIPI), Hi3516EV200(INPUT_MODE_MIPI) + attr.inputMode = INPUT_MODE_MIPI; + // Hi3516CV500(MIPI_DATA_RATE_X1), Hi3516EV200(MIPI_DATA_RATE_X1) + attr.dataRate = MIPI_DATA_RATE_X1; + // Hi3516CV500 (0, 204, 2592, 1944), Hi3516EV200 (0, 204, 2304, 1296), Hi3516DV300-imx335 (0, 0, 2592, 1944) + attr.imgRect.x = 0; /* 0: image sensor left-top positon */ + attr.imgRect.y = 0; /* 0: image sensor right-top position */ + attr.imgRect.width = 2592; /* 2592: image sensor width size */ + attr.imgRect.height = 1944; /* 1944: image sensor height size */ + + interType = MipiGetIntputModeType(attr.inputMode); + if (interType == INTERFACE_MIPI) { + HDF_LOGI("%s: call[InitMipiDevAttr].", __func__); + InitMipiDevAttr(&attr.mipiAttr); + } else if (interType == INTERFACE_LVDS) { + HDF_LOGI("%s: call[InitLvdsDevAttr].", __func__); + InitLvdsDevAttr(&attr.lvdsAttr); + } else { + HDF_LOGE("%s: interType = %d is error!", __func__, attr.inputMode); + } + + test->attr = attr; +} + +static int32_t MipiCsiSetComboDevAttrTest(struct MipiCsiTest *test) +{ + int32_t ret; + + InitComboDevAttr(test); + ret = MipiCsiSetComboDevAttr(test->handle, &(test->attr)); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + + HDF_LOGE("%s: failed.", __func__); + return ret; +} + +static int32_t MipiCsiSetPhyCmvmodeTest(struct MipiCsiTest *test) +{ + int32_t ret; + + test->devno = 0; + // PHY_CMV_GE1200MV or PHY_CMV_LT1200MV + test->cmvMode = PHY_CMV_GE1200MV; + ret = MipiCsiSetPhyCmvmode(test->handle, test->devno, test->cmvMode); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiResetSensorTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // snsResetSource select 0 or 1, and must be less than SNS_MAX_RST_SOURCE_NUM + test->snsResetSource = 0; + ret = MipiCsiResetSensor(test->handle, test->snsResetSource); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiUnresetSensorTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // snsResetSource select 0 or 1, and must be less than SNS_MAX_RST_SOURCE_NUM + test->snsResetSource = 0; + ret = MipiCsiUnresetSensor(test->handle, test->snsResetSource); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiResetRxTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // comboDev select 0 or 1, and must be less than MIPI_RX_MAX_DEV_NUM + test->comboDev = 0; + ret = MipiCsiResetRx(test->handle, test->comboDev); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiUnresetRxTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // comboDev select 0 or 1, and must be less than MIPI_RX_MAX_DEV_NUM + test->comboDev = 0; + ret = MipiCsiUnresetRx(test->handle, test->comboDev); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiSetHsModeTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // laneDivideMode: Hi3516CV500(LANE_DIVIDE_MODE_0), Hi3516EV200(LANE_DIVIDE_MODE_0) + test->laneDivideMode = LANE_DIVIDE_MODE_0; + ret = MipiCsiSetHsMode(test->handle, test->laneDivideMode); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiEnableMipiClockTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // comboDev select 0 or 1, and must be less than MIPI_RX_MAX_DEV_NUM + test->comboDev = 0; + ret = MipiCsiEnableClock(test->handle, test->comboDev); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiDisableMipiClockTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // comboDev select 0 or 1, and must be less than MIPI_RX_MAX_DEV_NUM + test->comboDev = 0; + ret = MipiCsiDisableClock(test->handle, test->comboDev); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiEnableSensorClockTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // snsClkSource select 0 or 1, and must be less than SNS_MAX_CLK_SOURCE_NUM + test->snsClkSource = 0; + ret = MipiCsiEnableSensorClock(test->handle, test->snsClkSource); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiDisableSensorClockTest(struct MipiCsiTest *test) +{ + int32_t ret; + + // snsClkSource select 0 or 1, and must be less than SNS_MAX_CLK_SOURCE_NUM + test->snsClkSource = 0; + ret = MipiCsiDisableSensorClock(test->handle, test->snsClkSource); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiSetExtDataTypeTest(struct MipiCsiTest *test) +{ + int32_t ret; + ExtDataType dataType; + dataType.devno = 0; + dataType.num = 0; + + // extDataBitWidth set 8, 10, 12, 14 or 16. + dataType.extDataBitWidth[0] = 12; /* 12:magic bit width */ + dataType.extDataBitWidth[1] = 12; /* 12:magic bit width */ + dataType.extDataBitWidth[2] = 12; /* 12:magic bit width */ + + dataType.extDataType[0] = 0x39; /* 0x39 -- data type reserved */ + dataType.extDataType[1] = 0x39; /* 0x39 -- data type reserved */ + dataType.extDataType[2] = 0x39; /* 0x39 -- data type reserved */ + test->dataType = dataType; + + ret = MipiCsiSetExtDataType(test->handle, &test->dataType); + if ((ret == HDF_SUCCESS) || (ret == HDF_ERR_NOT_SUPPORT)) { + return HDF_SUCCESS; + } + HDF_LOGE("%s: failed.", __func__); + + return ret; +} + +static int32_t MipiCsiTestByCmd(struct MipiCsiTest *test, uint8_t cmd) +{ + int32_t ret = HDF_FAILURE; + + if (test == NULL) { + HDF_LOGE("%s: test is NULL", __func__); + return ret; + } + + HDF_LOGI("%s: test cmd %u, enter.", __func__, cmd); + switch (cmd) { + case MIPI_CSI_TEST_SET_HS_MODE: + ret = MipiCsiSetHsModeTest(test); + break; + case MIPI_CSI_TEST_DISABLE_MIPI_CLOCK: + ret = MipiCsiDisableMipiClockTest(test); + break; + case MIPI_CSI_TEST_ENABLE_MIPI_CLOCK: + ret = MipiCsiEnableMipiClockTest(test); + break; + case MIPI_CSI_TEST_RESET_RX: + ret = MipiCsiResetRxTest(test); + break; + case MIPI_CSI_TEST_DISABLE_SENSOR_CLOCK: + ret = MipiCsiDisableSensorClockTest(test); + break; + case MIPI_CSI_TEST_ENABLE_SENSOR_CLOCK: + ret = MipiCsiEnableSensorClockTest(test); + break; + case MIPI_CSI_TEST_RESET_SENSOR: + ret = MipiCsiResetSensorTest(test); + break; + case MIPI_CSI_TEST_SET_DEV_ATTR: + ret = MipiCsiSetComboDevAttrTest(test); + break; + case MIPI_CSI_TEST_SET_PHY_CMVMODE: + ret = MipiCsiSetPhyCmvmodeTest(test); + break; + case MIPI_CSI_TEST_SET_EXT_DATA_TYPE: + ret = MipiCsiSetExtDataTypeTest(test); + break; + case MIPI_CSI_TEST_UNRESET_RX: + ret = MipiCsiUnresetRxTest(test); + break; + case MIPI_CSI_TEST_UNRESET_SENSOR: + ret = MipiCsiUnresetSensorTest(test); + break; + default: + HDF_LOGE("%s: not support", __func__); + break; + } + HDF_LOGI("%s: test cmd %u, ret %d done.", __func__, cmd, ret); + + return ret; +} + +static int32_t MipiCsiTestDoTest(struct MipiCsiTest *test, uint8_t cmd) +{ + int32_t ret; + OsalMSleep(SEQ_OUTPUT_DELAY); + + if (test == NULL) { + return HDF_ERR_INVALID_OBJECT; + } + +#ifdef MIPI_CSI_TEST_SELF + int32_t i; + if (cmd != 0) { + return HDF_SUCCESS; + } + ret = MipiCsiTestSetUp(test); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: setup fail!", __func__); + return ret; + } + + for (i = 0; i < test->total; i++) { + if (MipiCsiTestByCmd(test, i) != HDF_SUCCESS) { + test->fails++; + } + } + HDF_LOGI("\n\n%s: **********PASS:%u FAIL:%u**************\n\n", + __func__, test->total - test->fails, test->fails); + ret = (test->fails > 0) ? HDF_FAILURE : HDF_SUCCESS; + MipiCsiTestTearDown(test); +#else + if (cmd == 0) { + ret = MipiCsiTestSetUp(test); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: [MipiCsiTestSetUp] failed!", __func__); + return ret; + } + } + ret = MipiCsiTestByCmd(test, cmd); + if (cmd == (test->total - 1)) { + MipiCsiTestTearDown(test); + } +#endif + OsalMSleep(SEQ_OUTPUT_DELAY); + + return ret; +} + +static int32_t MipiCsiTestBind(struct HdfDeviceObject *device) +{ + static struct MipiCsiTest test; + + test.cntlrId = 0; + test.total = MIPI_CSI_TEST_MAX; + test.doTest = MipiCsiTestDoTest; + device->service = &test.service; +#ifdef MIPI_CSI_TEST_SELF + HDF_LOGI("%s: test on init!", __func__); + test.doTest(&test, -1); +#endif + return HDF_SUCCESS; +} + +static int32_t MipiCsiTestInit(struct HdfDeviceObject *device) +{ + (void)device; + return HDF_SUCCESS; +} + +struct HdfDriverEntry g_mipiCsiTestEntry = { + .moduleVersion = 1, + .Bind = MipiCsiTestBind, + .Init = MipiCsiTestInit, + .moduleName = "PLATFORM_MIPI_CSI_TEST", +}; +HDF_INIT(g_mipiCsiTestEntry); diff --git a/test/unittest/platform/common/mipi_csi_test.h b/test/unittest/platform/common/mipi_csi_test.h new file mode 100755 index 000000000..81324f2c4 --- /dev/null +++ b/test/unittest/platform/common/mipi_csi_test.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef MIPI_CSI_TEST_H +#define MIPI_CSI_TEST_H + +#include "hdf_device_desc.h" +#include "mipi_csi_if.h" + +/** + * @brief Pal mipi csi test case number. + * + * The sequence number is related to the test logic, which is different from the actual call. + * 1, 4, 8 and 9 need to be called according to the actual situation. + * + * @since 1.0 + */ +enum MipiCsiTestCmd { + MIPI_CSI_TEST_SET_HS_MODE = 0, + MIPI_CSI_TEST_DISABLE_MIPI_CLOCK = 1, /* for test */ + MIPI_CSI_TEST_ENABLE_MIPI_CLOCK = 2, + MIPI_CSI_TEST_RESET_RX = 3, + MIPI_CSI_TEST_DISABLE_SENSOR_CLOCK = 4, /* for test */ + MIPI_CSI_TEST_ENABLE_SENSOR_CLOCK = 5, + MIPI_CSI_TEST_RESET_SENSOR = 6, + MIPI_CSI_TEST_SET_DEV_ATTR = 7, + MIPI_CSI_TEST_SET_PHY_CMVMODE = 8, /* for test */ + MIPI_CSI_TEST_SET_EXT_DATA_TYPE = 9, /* for test */ + MIPI_CSI_TEST_UNRESET_RX = 10, + MIPI_CSI_TEST_UNRESET_SENSOR = 11, + MIPI_CSI_TEST_MAX = 12, +}; + +struct MipiCsiTest { + struct IDeviceIoService service; + struct HdfDeviceObject *device; + int32_t (*doTest)(struct MipiCsiTest *test, uint8_t cmd); + DevHandle handle; + uint32_t total; + uint32_t fails; + + uint8_t cntlrId; + ComboDevAttr attr; + uint8_t devno; + PhyCmvMode cmvMode; + ExtDataType dataType; + LaneDivideMode laneDivideMode; + uint8_t comboDev; + uint8_t snsClkSource; + uint8_t snsResetSource; +}; + +static inline struct MipiCsiTest *MipiCsiTestServiceGet(void) +{ + return (struct MipiCsiTest *)DevSvcManagerClntGetService("PLATFORM_MIPI_CSI_TEST"); +} +#endif /* MIPI_CSI_TEST_H */ diff --git a/test/unittest/platform/common/mipi_dsi_test.c b/test/unittest/platform/common/mipi_dsi_test.c index b991e1e41..21319289d 100644 --- a/test/unittest/platform/common/mipi_dsi_test.c +++ b/test/unittest/platform/common/mipi_dsi_test.c @@ -6,12 +6,8 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "osal_mem.h" -#include "device_resource_if.h" -#include "hdf_base.h" -#include "hdf_device_desc.h" -#include "hdf_log.h" #include "mipi_dsi_test.h" +#include "hdf_log.h" #define HDF_LOG_TAG mipi_dsi_test diff --git a/test/unittest/platform/hdf_mipi_csi_entry_test.c b/test/unittest/platform/hdf_mipi_csi_entry_test.c new file mode 100755 index 000000000..780221843 --- /dev/null +++ b/test/unittest/platform/hdf_mipi_csi_entry_test.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#include "hdf_mipi_csi_entry_test.h" +#include "hdf_log.h" +#include "mipi_csi_test.h" + +#define HDF_LOG_TAG hdf_mipi_csi_entry_test + +int32_t HdfMipiCsiEntry(HdfTestMsg *msg) +{ + int32_t ret; + struct MipiCsiTest *test = NULL; + + if (msg == NULL) { + return HDF_FAILURE; + } + + test = MipiCsiTestServiceGet(); + if (test == NULL) { + HDF_LOGE("%s: get service fail!", __func__); + return HDF_FAILURE; + } + + HDF_LOGI("%s: call [doTest]", __func__); + ret = test->doTest(test, msg->subCmd); + msg->result = (int8_t)ret; + + return ret; +} diff --git a/test/unittest/platform/hdf_mipi_csi_entry_test.h b/test/unittest/platform/hdf_mipi_csi_entry_test.h new file mode 100755 index 000000000..c31a73106 --- /dev/null +++ b/test/unittest/platform/hdf_mipi_csi_entry_test.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * + * HDF is dual licensed: you can use it either under the terms of + * the GPL, or the BSD license, at your option. + * See the LICENSE file in the root of this repository for complete details. + */ + +#ifndef HDF_MIPI_CSI_ENTRY_TEST_H +#define HDF_MIPI_CSI_ENTRY_TEST_H + +#include "hdf_main_test.h" + +int32_t HdfMipiCsiEntry(HdfTestMsg *msg); +#endif // HDF_MIPI_CSI_ENTRY_TEST_H \ No newline at end of file diff --git a/test/unittest/platform/hdf_mipi_dsi_entry_test.c b/test/unittest/platform/hdf_mipi_dsi_entry_test.c index c4001c213..ff2a8856b 100644 --- a/test/unittest/platform/hdf_mipi_dsi_entry_test.c +++ b/test/unittest/platform/hdf_mipi_dsi_entry_test.c @@ -8,7 +8,6 @@ #include "hdf_mipi_dsi_entry_test.h" #include "hdf_log.h" -#include "mipi_dsi_if.h" #include "mipi_dsi_test.h" #define HDF_LOG_TAG hdf_mipi_dsi_entry_test -- Gitee