Browse Source

Add isp_isp8000l headers for vi-sensor build

Change-Id: I0eb7a845568624d008fce3f9fc7b2e9944dd773e
Chuanzhou 1 year ago
parent
commit
f974ec76d8
48 changed files with 11857 additions and 0 deletions
  1. 32 0
      isp_isp8000l/units/cam_device/cam_dct_assert.h
  2. 361 0
      isp_isp8000l/units/cam_device/cam_device_buf_defs.h
  3. 73 0
      isp_isp8000l/units/cam_device/cam_device_buf_defs_common.h
  4. 56 0
      isp_isp8000l/units/cam_device/cam_device_sensor_defs.h
  5. 109 0
      isp_isp8000l/units/cam_device/types.h
  6. 196 0
      isp_isp8000l/units/cameric_drv/cameric_drv_common.h
  7. 36 0
      isp_isp8000l/units/common/align.h
  8. 28 0
      isp_isp8000l/units/common/array_size.h
  9. 932 0
      isp_isp8000l/units/common/cam_types.h
  10. 90 0
      isp_isp8000l/units/common/cea_861.h
  11. 93 0
      isp_isp8000l/units/common/hdmi_3d.h
  12. 98 0
      isp_isp8000l/units/common/hw_version.h
  13. 471 0
      isp_isp8000l/units/common/list.h
  14. 156 0
      isp_isp8000l/units/common/mipi.h
  15. 60 0
      isp_isp8000l/units/common/misc.h
  16. 84 0
      isp_isp8000l/units/common/picture_buffer.h
  17. 52 0
      isp_isp8000l/units/common/return_codes.h
  18. 92 0
      isp_isp8000l/units/common/utl_fixfloat.h
  19. 46 0
      isp_isp8000l/units/ebase/builtins.h
  20. 94 0
      isp_isp8000l/units/ebase/dct_assert.h
  21. 10 0
      isp_isp8000l/units/ebase/ext_types.h
  22. 42 0
      isp_isp8000l/units/ebase/linux_compat.h
  23. 357 0
      isp_isp8000l/units/ebase/list.h
  24. 112 0
      isp_isp8000l/units/ebase/queue.h
  25. 353 0
      isp_isp8000l/units/ebase/slist.h
  26. 187 0
      isp_isp8000l/units/ebase/sort.frag.h
  27. 286 0
      isp_isp8000l/units/ebase/trace.h
  28. 110 0
      isp_isp8000l/units/ebase/types.h
  29. 304 0
      isp_isp8000l/units/fpga/altera_fpga.h
  30. 210 0
      isp_isp8000l/units/hal/adapt.h
  31. 139 0
      isp_isp8000l/units/hal/hal_altera_irq_notifier.h
  32. 465 0
      isp_isp8000l/units/hal/hal_altera_pci.h
  33. 760 0
      isp_isp8000l/units/hal/hal_api.h
  34. 690 0
      isp_isp8000l/units/hal/hal_cmodel.h
  35. 123 0
      isp_isp8000l/units/hal/hal_common.h
  36. 656 0
      isp_isp8000l/units/hal/hal_cosim.h
  37. 188 0
      isp_isp8000l/units/hal/hal_mockup.h
  38. 268 0
      isp_isp8000l/units/i2c_drv/i2c_drv.h
  39. 1114 0
      isp_isp8000l/units/isi/isi.h
  40. 218 0
      isp_isp8000l/units/isi/isi_common.h
  41. 300 0
      isp_isp8000l/units/isi/isi_iss.h
  42. 167 0
      isp_isp8000l/units/isi/isi_priv.h
  43. 1026 0
      isp_isp8000l/units/oslayer/oslayer.h
  44. 162 0
      isp_isp8000l/units/oslayer/oslayer_linux.h
  45. 137 0
      isp_isp8000l/units/oslayer/oslayer_mfs.h
  46. 94 0
      isp_isp8000l/units/oslayer/oslayer_systemc.h
  47. 95 0
      isp_isp8000l/units/oslayer/oslayer_ucosii.h
  48. 125 0
      isp_isp8000l/units/oslayer/oslayer_win32.h

+ 32 - 0
isp_isp8000l/units/cam_device/cam_dct_assert.h

@@ -0,0 +1,32 @@
+/******************************************************************************\
+|* Copyright (c) 2020 by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")       *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+#ifndef _CAM_DCT_ASSERT_H_
+#define _CAM_DCT_ASSERT_H_
+
+/**
+ *          Compile time assert. Use e.g. to check the size of certain data
+ *           types. As this is evaluated at compile time, it will neither cause
+ *           size nor speed overhead, and thus is does not need to be inside
+ *           the NDEBUG.
+ *
+ *****************************************************************************/
+/* we need several levels of indirection to make unique enum names working
+ * we need unique enum names to be able to use DCT_ASSERT_STATIC more than
+ * one time per compilation unit
+ */
+#define UNIQUE_ENUM_NAME(u)     assert_static__ ## u
+#define GET_ENUM_NAME(x)        UNIQUE_ENUM_NAME(x)
+#define DCT_ASSERT_STATIC(e)    enum { GET_ENUM_NAME(__LINE__) = 1/(e) }
+
+
+#endif  // _CAM_DCT_ASSERT_H_

+ 361 - 0
isp_isp8000l/units/cam_device/cam_device_buf_defs.h

@@ -0,0 +1,361 @@
+/******************************************************************************\
+|* Copyright (c) 2020 by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")       *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+#ifndef _CAMERA_DEVICE_BUF_DEFS_H_
+#define _CAMERA_DEVICE_BUF_DEFS_H_
+
+#include "types.h"
+#include "cam_dct_assert.h"
+#include "cam_device_buf_defs_common.h"
+
+#define BUFF_POOL_MAX_INPUT_BUF_NUMBER 8
+#define BUFF_POOL_MAX_OUTPUT_BUF_NUMBER 16
+
+#define PIC_BUFFER_ALIGN            (0x400)
+#define PIC_BUFFER_ALIGN_META       (0x0)
+#define PIC_BUFFER_MEM_SIZE_MAX     (256 * 1024 * 1024)
+
+#define PIC_BUFFER_NUM_INPUT        (1)
+#define PIC_BUFFER_SIZE_INPUT       (8 * 1024 * 1024)    // 21MPixel@12bit => 42MByte
+#define PIC_BUFFER_NUM_LARGE_IMAGE   (3)
+#define PIC_BUFFER_SIZE_LARGE_IMAGE  (8 * 1024 * 1024)    // modify by wuyi to fix alloc memory fail TBD 21MPixel@12bit => 42MByte
+#define PIC_BUFFER_NUM_SMALL_IMAGE   (4)
+#define PIC_BUFFER_SIZE_SMALL_IMAGE  (8 * 1024 * 1024)     // 2MPixel@4:4:4 10bit  => 8MByte
+
+
+#ifdef ISP_DEC
+#define DEC_TILE_BUFFER_SIZE       (172032)    // (pictureSize/(tile size))*tile status bits)/8  tilesize=> 128byte tile status bits=> 4
+#endif
+DCT_ASSERT_STATIC(((PIC_BUFFER_NUM_INPUT*PIC_BUFFER_SIZE_INPUT) + (PIC_BUFFER_NUM_LARGE_IMAGE*PIC_BUFFER_SIZE_LARGE_IMAGE) + (PIC_BUFFER_NUM_SMALL_IMAGE*PIC_BUFFER_SIZE_SMALL_IMAGE)) < PIC_BUFFER_MEM_SIZE_MAX);
+
+#ifdef ISP_SINGLE_DOM_OVER_MP
+#define PIC_BUFFER_NUM_MAIN_SENSOR  (10)
+#define PIC_BUFFER_SIZE_MAIN_SENSOR (16 * 1024 * 1024)    //  2MPixel@4:4:4  => 6MByte
+#define PIC_BUFFER_NUM_SELF1_SENSOR  (0)
+#define PIC_BUFFER_SIZE_SELF1_SENSOR (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte, no buffer for sp
+#define PIC_BUFFER_NUM_SELF2_SENSOR  (0)
+#define PIC_BUFFER_SIZE_SELF2_SENSOR (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte, no buffer for sp
+#define PIC_BUFFER_NUM_PP_PATH_RAW_SENSOR  (0)
+#define PIC_BUFFER_SIZE_PP_PATH_RAW_SENSOR (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte, no buffer for sp
+
+#define PIC_BUFFER_NUM_RDI_SENSOR    (0)
+#define PIC_BUFFER_SIZE_RDI_SENSOR   (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte
+#define PIC_BUFFER_NUM_META_SENSOR    (6)
+#define PIC_BUFFER_SIZE_META_SENSOR   (1 * 1024 * 1024)     // Meta max size  => 1MByte
+#define PIC_BUFFER_NUM_MAIN_SENSOR_IMGSTAB  ( 10 )
+#define PIC_BUFFER_SIZE_MAIN_SENSOR_IMGSTAB ( 6 * 1024 * 1024 )    // ISI_RES_4416_3312 => 14MPixel@12bit => 28MByte
+#define PIC_BUFFER_NUM_SELF_SENSOR_IMGSTAB  ( 10 )
+#define PIC_BUFFER_SIZE_SELF_SENSOR_IMGSTAB ( 6 * 1024 * 1024 )    // ISI_RES_4416_3312 => 14MPixel@12bit => 28MByte
+
+DCT_ASSERT_STATIC(((PIC_BUFFER_NUM_MAIN_SENSOR*PIC_BUFFER_SIZE_MAIN_SENSOR) + (PIC_BUFFER_NUM_SELF1_SENSOR*PIC_BUFFER_SIZE_SELF1_SENSOR) + (PIC_BUFFER_NUM_RDI_SENSOR*PIC_BUFFER_SIZE_RDI_SENSOR) + (PIC_BUFFER_NUM_META_SENSOR*PIC_BUFFER_SIZE_META_SENSOR)) < PIC_BUFFER_MEM_SIZE_MAX);
+#else
+#define PIC_BUFFER_NUM_MAIN_SENSOR  (10)
+#define PIC_BUFFER_SIZE_MAIN_SENSOR (16 * 1024 * 1024)    // ISI_RES_4416_3312 => 14MPixel@12bit => 28MByte
+#define PIC_BUFFER_NUM_SELF1_SENSOR  (8)
+#define PIC_BUFFER_SIZE_SELF1_SENSOR (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte
+#define PIC_BUFFER_NUM_SELF2_SENSOR  (2)
+#define PIC_BUFFER_SIZE_SELF2_SENSOR (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte
+#define PIC_BUFFER_NUM_PP_PATH_RAW_SENSOR  (2)
+#define PIC_BUFFER_SIZE_PP_PATH_RAW_SENSOR (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte
+
+#define PIC_BUFFER_NUM_RDI_SENSOR    (2)
+#define PIC_BUFFER_SIZE_RDI_SENSOR   (6 * 1024 * 1024)     // 2MPixel@4:4:4  => 6MByte
+#define PIC_BUFFER_NUM_META_SENSOR    (6)
+#define PIC_BUFFER_SIZE_META_SENSOR   (1 * 1024 * 1024)     // Meta max size  => 1MByte
+#define PIC_BUFFER_NUM_MAIN_SENSOR_IMGSTAB  ( 10 )
+#define PIC_BUFFER_SIZE_MAIN_SENSOR_IMGSTAB ( 6 * 1024 * 1024 )    // ISI_RES_4416_3312 => 14MPixel@12bit => 28MByte
+#define PIC_BUFFER_NUM_SELF_SENSOR_IMGSTAB  ( 10 )
+#define PIC_BUFFER_SIZE_SELF_SENSOR_IMGSTAB ( 6 * 1024 * 1024 )    // ISI_RES_4416_3312 => 14MPixel@12bit => 28MByte
+
+DCT_ASSERT_STATIC(((PIC_BUFFER_NUM_MAIN_SENSOR*PIC_BUFFER_SIZE_MAIN_SENSOR) + (PIC_BUFFER_NUM_SELF1_SENSOR*PIC_BUFFER_SIZE_SELF1_SENSOR) + (PIC_BUFFER_NUM_RDI_SENSOR*PIC_BUFFER_SIZE_RDI_SENSOR) + (PIC_BUFFER_NUM_META_SENSOR*PIC_BUFFER_SIZE_META_SENSOR)) < PIC_BUFFER_MEM_SIZE_MAX);
+#endif
+
+
+#define PIC_BUFFER_NUM_LARGE_BUF_SENSOR_3D   (10)
+#define PIC_BUFFER_SIZE_LARGE_BUF_SENSOR_3D  (6 * 1024 * 1024)  // allocated twice!
+#define PIC_BUFFER_NUM_SMALL_BUF_SENSOR_3D   (5)
+#define PIC_BUFFER_SIZE_SMALL_BUF_SENSOR_3D  (6 * 1024 * 1024)  // allocated twice!
+
+DCT_ASSERT_STATIC(((PIC_BUFFER_NUM_LARGE_BUF_SENSOR_3D*2*PIC_BUFFER_SIZE_LARGE_BUF_SENSOR_3D) + (PIC_BUFFER_NUM_SMALL_BUF_SENSOR_3D*2*PIC_BUFFER_SIZE_SMALL_BUF_SENSOR_3D)) < PIC_BUFFER_MEM_SIZE_MAX);
+
+#ifdef ISP_MI_HANDSHAKE_NANO
+#define PIC_BUFFER_NUM_MAIN_MP_HANDSHK   (4)                   // virtual sram buffer number
+#endif
+
+
+typedef enum _CAM_DEVICE_ID_ {
+    CAM_ISPCORE_ID_0 = 0,
+    CAM_ISPCORE_ID_1 = 1,
+    CAM_ISPCORE_ID_MAX = 2
+} CAM_DEVICE_ID;
+
+typedef enum __BUFF_MODE__ {
+    BUFF_MODE_PHYLINEAR     = 0,
+    BUFF_MODE_USRPTR        = 1,  // V4l2 mode
+    BUFF_MODE_KERNEL        = 2,
+    BUFF_MODE_DMAHANDSHAKE  = 3,
+    BUFF_MODE_DIRECTLINK    = 4,
+    BUFF_MODE_NAX           = 5,
+    BUFF_MODE_INVALID       = 6,
+} BUFF_MODE;
+
+#define MEDIA_BUF_ALIGN(buf, align) (((buf)+((align)-1U)) & ~((align)-1U))
+
+
+/*Typedef HAL handle*/
+typedef void *HalHandle_t;
+
+/*******************************************************************************
+ * @brief Common SCMI buffer type
+ *
+ * This structure defines a SCMI buffer. In addition to an address pointer to
+ * the actual buffer, this structure also contains the size of the buffer and
+ * an optional (may be null) pointer to some buffer meta data. This meta data
+ * is defined seperately for each specific buffer type. The buffer_flags
+ * variable contains more information about the buffer in the form of
+ * (up to 32) bit flags.
+ * The bit flags and their meaning are defined by each SCMI system separately.
+ * For a list of buffer bit flags, see the respective system's documentation.
+ */
+
+/*Be careful of machine int width bits(32/64)*/
+typedef struct _ScmiBuffer {
+    void        *p_next;        /**< Pointer used by module to chain SCMI-buffers */
+    void        *p_address;     /**< Address of the actual buffer */
+    uint32_t    base_address;   /**< HW address of the actual buffer */
+    BufIdentity buf_id;
+#ifdef ISP_MI_HANDSHAKE_NANO
+    uint32_t    base_addr_sram_cb; /**< HW address of the Nano handshake Sram Cb address */
+    uint32_t    base_addr_sram_cr; /**< HW address of the Nano handshake Sram Cr address */
+#endif
+
+    uint32_t    size;           /**< Size of the buffer in bytes */
+    uint32_t    buffer_flags;   /**< Generic buffer flags */
+    int64_t     time_stamp;     /**< Time stamp of the buffer in ticks with 27 MHz resolution */
+    void        *p_meta_data;   /**< Optional pointer to buffer meta data */
+} ScmiBuffer;
+
+
+/**
+ *
+ * @brief The MediaBufferPool holds elements from type MediaBuffer_t.
+ */
+typedef struct MediaBuffer_s {
+    uint8_t       *pBufAddress;  /**< Base address of system memory buffer(can differ from
+                                     actual buffer start address, set in ScmiBuffer). */
+    uint32_t      baseAddress;  /**< HW address of system memory buffer. */
+
+#ifdef ISP_MI_HANDSHAKE_NANO
+    uint32_t      baseAddrCbSram; /**< HW address of sram Cb memory buffer for Nano Handshake. */
+    uint32_t      baseAddrCrSram; /**< HW address of sram Cr memory buffer for Nano Handshake. */
+#endif
+
+    uint32_t      baseSize;     /**< Base size of buffer(can differ from actual buffer
+                                     size, set in ScmiBuffer). */
+    uint32_t      lockCount;    /**< Counting how many times buffer is used. 0 means
+                                     buffer belongs to pool and is free. */
+    void          *pOwner;
+    uint32_t      duration;     /**< Used to calculate duration */
+    bool_t        syncPoint;    /**< Indicates if buffer contains a reference frame. */
+    bool_t        last;         /**< Media source module signals delivery of last buffer. */
+    bool_t        isFull;       /**< Flag set to TRUE when buffer is put in queue as a full buffer */
+    ScmiBuffer    buf;          /**< Common SCMI buffer type */
+    void          *pNext;        /**< Common next pointer that can be used to create linked lists of media buffers. */
+    void          *pMetaData;    /**< Pointer to optional meta data structure. */
+} MediaBuffer_t;
+
+
+
+// Pic buffers
+
+/*****************************************************************************/
+/**
+ *          PicBufType_t
+ *
+ * @brief   The type of image data a picture buffer holds.
+ *
+ * @note    MVDU_FXQuad requires PIC_BUF_TYPE_YCbCr422 in PIC_BUF_LAYOUT_SEMIPLANAR mode.
+ *
+ *****************************************************************************/
+typedef enum PicBufType_e {
+    PIC_BUF_TYPE_INVALID  = 0x00,
+    PIC_BUF_TYPE_DATA     = 0x08,   // just some sequential data
+    PIC_BUF_TYPE_RAW8     = 0x10,
+    PIC_BUF_TYPE_RAW16    = 0x11,   // includes: 9..16bits, MSBit aligned, LSByte first!
+    PIC_BUF_TYPE_RAW10    = 0x12,   // includes: 10bits, MSBit aligned, LSByte first!
+    PIC_BUF_TYPE_RAW12    = 0x13,   // includes: 12bits, MSBit aligned, LSByte first!
+    PIC_BUF_TYPE_RAW14    = 0x14,   // includes: 14bits, MSBit aligned, LSByte first!
+    PIC_BUF_TYPE_JPEG     = 0x20,
+    PIC_BUF_TYPE_YCbCr444 = 0x30,
+    PIC_BUF_TYPE_YCbCr422 = 0x31,
+    PIC_BUF_TYPE_YCbCr420 = 0x32,
+    PIC_BUF_TYPE_YCbCr400 = 0x33,
+    PIC_BUF_TYPE_YCbCr32  = 0x3f,
+    // PIC_BUF_TYPE_YCbCr400 = 0x33, // "Black&White"
+    PIC_BUF_TYPE_RGB888   = 0x40,
+    PIC_BUF_TYPE_RGB666   = 0x41,  // R, G & B are LSBit aligned!
+    PIC_BUF_TYPE_RGB565   = 0x42,  // TODO: don't know the memory layout right now, investigate!
+    PIC_BUF_TYPE_RGB32    = 0x4f,
+    PIC_BUF_TYPE_META     = 0x50,
+    _PIC_BUF_TYPE_DUMMY_
+} PicBufType_t;
+
+
+/*****************************************************************************/
+/**
+ *          PicBufLayout_t
+ *
+ * @brief   The layout of the image data a picture buffer holds.
+ *
+ * @note    MVDU_FXQuad requires PIC_BUF_TYPE_YCbCr422 in PIC_BUF_LAYOUT_SEMIPLANAR mode.
+ *
+ *****************************************************************************/
+typedef enum PicBufLayout_e {
+    PIC_BUF_LAYOUT_INVALID         = 0,
+
+    PIC_BUF_LAYOUT_COMBINED        = 0x10,  // PIC_BUF_TYPE_DATA:      Data: D0 D1 D2...
+                                            // PIC_BUF_TYPE_RAW8:      Data: D0 D1 D2...
+                                            // PIC_BUF_TYPE_RAW16/10:  Data: D0L D0H D1L D1H...
+                                            // PIC_BUF_TYPE_JPEG:      Data: J0 J1 J2...
+                                            // PIC_BUF_TYPE_YCbCr444:  Data: Y0 Cb0 Cr0 Y1 Cb1Cr1...
+                                            // PIC_BUF_TYPE_YCbCr422:  Data: Y0 Cb0 Y1 Cr0 Y2 Cb1 Y3 Cr1...
+                                            // PIC_BUF_TYPE_YCbCr32:   Data: Cr0 Cb0 Y0 A0 Cr1 Cb1 Y1 A1...
+                                            // PIC_BUF_TYPE_RGB888:    Data: R0 G0 B0 R1 B2 G1...
+                                            // PIC_BUF_TYPE_RGB666:    Data: {00,R0[5:0]} {00,G0[5:0]} {00,B0[5:0]} {00,R1[5:0]} {00,G2[5:0]} {00,B3[5:0]}...
+                                            // PIC_BUF_TYPE_RGB565:    Data: {R0[4:0],G0[5:3]} {G0[2:0],B0[4:0]} {R1[4:0],G1[5:3]} {G1[2:0],B1[4:0]}... (is this correct?)
+                                            // PIC_BUF_TYPE_RGB32:     Data: B0 G0 R0 A0 B1 G1 R1 A1...
+    PIC_BUF_LAYOUT_BAYER_RGRGGBGB  = 0x11,  // 1st line: RGRG... , 2nd line GBGB... , etc.
+    PIC_BUF_LAYOUT_BAYER_GRGRBGBG  = 0x12,  // 1st line: GRGR... , 2nd line BGBG... , etc.
+    PIC_BUF_LAYOUT_BAYER_GBGBRGRG  = 0x13,  // 1st line: GBGB... , 2nd line RGRG... , etc.
+    PIC_BUF_LAYOUT_BAYER_BGBGGRGR  = 0x14,  // 1st line: BGBG... , 2nd line GRGR... , etc.
+
+    PIC_BUF_LAYOUT_SEMIPLANAR      = 0x20,  // PIC_BUF_TYPE_YCbCr422:  Luma:  Y0 Y1 Y2 Y3... ; Chroma: Cb0 Cr0 Cb1 Cr1...
+                                            // PIC_BUF_TYPE_YCbCr420:  Luma:  Y0 Y1 Y2 Y3... ; Chroma: Cb0 Cr0 Cb1 Cr1...
+                                            // PIC_BUF_TYPE_YCbCr400:  Luma:  Y0 Y1 Y2 Y3... ; Chroma: not used
+
+    PIC_BUF_LAYOUT_PLANAR          = 0x30,  // PIC_BUF_TYPE_YCbCr444:  Y: Y0 Y1 Y2 Y3...;  Cb: Cb0 Cb1 Cb2 Cb3...; Cr: Cr0 Cr1 Cr2 Cr3...
+                                            // PIC_BUF_TYPE_YCbCr422:  Y: Y0 Y1 Y2 Y3...;  Cb: Cb0 Cb1 Cb2 Cb3...; Cr: Cr0 Cr1 Cr2 Cr3...
+                                            // PIC_BUF_TYPE_YCbCr420:  Y: Y0 Y1 Y2 Y3...;  Cb: Cb0 Cb1 Cb2 Cb3...; Cr: Cr0 Cr1 Cr2 Cr3...
+                                            // PIC_BUF_TYPE_YCbCr400:  Y: Y0 Y1 Y2 Y3...;  Cb: not used;           Cr: not used...
+                                            // PIC_BUF_TYPE_RGB888:    R: R0 R1 R2 R3...;  G:  G0 G1 G2 G3...;     B:  B0 B1 B2 B3...
+                                            // PIC_BUF_TYPE_RGB666:    R: {00,R0[5:0]}...; G:  {00,G0[5:0]}...;    B:  {00,B0[5:0]}...
+    PIC_BUF_LAYOUT_META_DATA      = 0x40,
+    _PIC_BUF_LAYOUT_DUMMY_
+} PicBufLayout_t;
+
+/*****************************************************************************/
+/**
+ *          PixelDataAlignMode_t
+ *
+ * @brief   The align mode of the image data a picture buffer holds.
+ *
+ *
+ *****************************************************************************/
+
+enum {
+    PIC_BUF_DATA_ALIGN_MODE_INVALID          = -1,
+    PIC_BUF_DATA_UNALIGN_MODE                = 0,  // pixel data not aligned.
+    PIC_BUF_DATA_ALIGN_128BIT_MODE           = 1,  // pixel data  aligned with 128 bit.
+    PIC_BUF_DATA_ALIGN_16BIT_MODE            = 2,  // pixel data  aligned with 16 bit.
+    PIC_BUF_DATA_ALIGN_MODE_MAX
+};
+
+/*****************************************************************************/
+/**
+ *          PicBufPlane_t
+ *
+ * @brief   Common information about a color component plane within an image buffer.
+ *
+ *****************************************************************************/
+typedef struct PicBufPlane_s {
+    uint8_t    *pData;
+    uint32_t    BaseAddress;
+    uint32_t    PicWidthPixel;
+    uint32_t    PicWidthBytes;
+    uint32_t    PicHeightPixel;
+    uint8_t     PixelDataAlignMode;
+} PicBufPlane_t;
+
+/*****************************************************************************/
+/**
+ *          PicBufMetaData_t
+ *
+ * @brief   All the meta data one needs to know about an image buffer.
+ *
+ *****************************************************************************/
+typedef struct PicBufMetaData_s {
+    PicBufType_t            Type;       // type of picture data
+    PicBufLayout_t          Layout;     // kind of data layout
+    uint32_t                Align;      // min. alignment required for color component planes or sub buffer base adresses for this picture buffer
+    int64_t                 TimeStampUs;  // timestamp in us
+    struct PicBufMetaData_s *pNext3D;   // Reference to PicBufMetaData of the subsequent buffer in a 3D descriptor chain, valid only in 3D mode; set to NULL if last in chain or for 2D mode.
+                                        // Note: depending on the 3D format in use, the primary buffer holds left image data while the secondary buffer holds right or depth information.
+                                        //       Certain 3D formats require further buffers, in which case the 3D chain consists of more than two descriptors.
+    BufIdentity             buf_id;
+    union Data_u {                      // the type and layout dependent meta data
+        struct data_s {      // DATA
+            uint8_t    *pData;
+            uint32_t    BaseAddress;
+            uint32_t    DataSize;
+        } data;
+
+        struct data_meta {   // meta
+            uint8_t    *pData;
+            uint32_t    BaseAddress;
+            uint32_t    DataSize;
+        } meta;
+
+        PicBufPlane_t raw;   // RAW8, RAW16
+
+        struct jpeg_s {      // JPEG
+            uint8_t    *pHeader;
+            uint32_t    HeaderSize;
+            uint8_t    *pData;
+            uint32_t    BaseAddress;
+            uint32_t    DataSize;
+        } jpeg;
+
+        union YCbCr_u {     // YCbCr444, YCbCr422, YCbCr420, YCbCr32
+            PicBufPlane_t combined;
+            struct semiplanar_s {
+                PicBufPlane_t Y;
+                PicBufPlane_t CbCr;
+            } semiplanar;
+            struct planar_YUV_s {
+                PicBufPlane_t Y;
+                PicBufPlane_t Cb;
+                PicBufPlane_t Cr;
+            } planar;
+        } YCbCr;
+
+        union RGB_u {        // RGB888, RGB32
+            PicBufPlane_t combined;
+            struct planar_RGB_s {
+                PicBufPlane_t R;
+                PicBufPlane_t G;
+                PicBufPlane_t B;
+            } planar;
+        } RGB;
+#ifdef ISP_MI_BP
+        union BAYER_u {         // rggb bggr
+            struct planar_BAYER_s {
+                PicBufPlane_t R;
+                PicBufPlane_t Gr;
+                PicBufPlane_t Gb;
+                PicBufPlane_t B;
+            } planar;
+        } BAYER;
+#endif
+    } Data;
+} PicBufMetaData_t;
+
+#endif  // _CAMERA_DEVICE_BUF_DEFS_H_

+ 73 - 0
isp_isp8000l/units/cam_device/cam_device_buf_defs_common.h

@@ -0,0 +1,73 @@
+/******************************************************************************\
+|* Copyright (c) 2020 by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")       *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+#ifndef _CAMERA_DEVICE_BUF_DEFS_COMMON_H_
+#define _CAMERA_DEVICE_BUF_DEFS_COMMON_H_
+
+enum {
+    CAMERA_PIX_FMT_YUV422SP = 0,
+    CAMERA_PIX_FMT_YUV422I,
+    CAMERA_PIX_FMT_YUV420SP,
+    CAMERA_PIX_FMT_YUV444,
+    CAMERA_PIX_FMT_RGB888,
+    CAMERA_PIX_FMT_RGB888P,
+    CAMERA_PIX_FMT_RAW8,
+    CAMERA_PIX_FMT_RAW10,
+    CAMERA_PIX_FMT_RAW12,
+    CAMERA_PIX_FMT_MAX,
+};
+
+
+typedef enum _ISPCORE_BUFIO_ID_ {
+    ISPCORE_BUFIO_MP        = 0,
+    ISPCORE_BUFIO_SP1       = 1,
+    ISPCORE_BUFIO_SP2       = 2,
+    ISPCORE_BUFIO_RDI       = 3,  // RAW dump interface
+    ISPCORE_BUFIO_META      = 4,  // meta sw delivery port
+    ISPCORE_BUFIO_WRITEMAX  = 5,
+    ISPCORE_BUFIO_READ      = 6,
+    ISPCORE_BUFIO_MAX       = 7,
+} ISPCORE_BUFIO_ID;
+
+typedef struct __BufIdentity__ {
+    uint64_t address_usr;     // address in V4l2 application space
+    uint64_t address_daemon;  // address in native stack space
+    uint64_t address_kernel;  // address in kernel space
+    uint32_t address_reg;     // address set to ispcore register
+    uint32_t buffer_idx;      // buffer index
+    uint32_t buff_size;       // biffer size
+    uint32_t filled;
+    void     *ctx;            // memory handle
+    int width;
+    int height;
+    int format;
+} BufIdentity;
+
+typedef struct ispcore_meta_kernel_s {
+    unsigned int data_kernel;
+} ispcore_meta_kernel_t;
+
+typedef struct ispcore_meta_kernel_dma_s {
+    unsigned int data_kernel_dma;
+} ispcore_meta_kernel_dma_t;
+
+typedef struct ispcore_meta_user_s {
+    unsigned int data_user;
+} ispcore_meta_user_t;
+
+typedef struct ispcore_meta_s {
+    ispcore_meta_kernel_t     kernel_meta;
+    ispcore_meta_kernel_dma_t kernel_meta_dma;
+    ispcore_meta_user_t       user_meta;
+} ispcore_meta_t;
+
+#endif  // _CAMERA_DEVICE_BUF_DEFS_COMMON_H_

+ 56 - 0
isp_isp8000l/units/cam_device/cam_device_sensor_defs.h

@@ -0,0 +1,56 @@
+/******************************************************************************\
+|* Copyright (c) 2020 by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")       *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+#ifndef _CAMERA_DEVICE_SENSOR_DEFS_H_
+#define _CAMERA_DEVICE_SENSOR_DEFS_H_
+
+#include "types.h"
+
+typedef struct IsiResolution_s
+{
+    uint16_t width;
+    uint16_t height;
+}IsiResolution_t;
+
+/*****************************************************************************/
+/**
+ * @brief   This structure defines the sensor capabilities.
+ */
+/*****************************************************************************/
+typedef struct IsiSensorCaps_s {
+    uint32_t BusWidth;                  /**< supported bus-width */
+    uint32_t Mode;                      /**< supported operating modes */
+    uint32_t FieldSelection;            /**< sample fields */
+    uint32_t YCSequence;
+    uint32_t Conv422;
+    uint32_t BPat;                      /**< bayer pattern */
+    uint32_t HPol;                      /**< horizontal polarity */
+    uint32_t VPol;                      /**< vertical polarity */
+    uint32_t Edge;                      /**< sample edge */
+    IsiResolution_t Resolution;         /**< supported resolutions */
+    uint32_t SmiaMode;
+    uint32_t MipiMode;
+    uint32_t MipiLanes;
+    uint32_t enableHdr;
+} IsiSensorCaps_t;
+
+/*****************************************************************************/
+/**
+ *          IsiSensorConfig_t
+ *
+ * @brief   Sensor configuration struct
+ */
+/*****************************************************************************/
+typedef IsiSensorCaps_t IsiSensorConfig_t;
+
+
+#endif  // _CAMERA_DEVICE_SENSOR_DEFS_H_

+ 109 - 0
isp_isp8000l/units/cam_device/types.h

@@ -0,0 +1,109 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ *   @file types.h
+ *
+ *  This file defines some basic type names like the int types.
+ *
+ *****************************************************************************/
+#ifndef TYPES_H_
+#define TYPES_H_
+
+#include "linux_compat.h"
+#include <limits.h>
+
+#ifndef __cplusplus
+    /* Only C99 compilers know stdbool */
+    #if (__STDC_VERSION__ >= 199901L) || defined(CONFIG_HAVE_STDBOOL)
+        #include <stdbool.h>
+    #else
+        #define bool    unsigned int
+        #define true    (1)
+        #define false   (0)
+    #endif
+#endif
+
+
+#if defined(__GNUC__)
+    #if !defined(INLINE)
+        #define INLINE static inline
+    #endif
+#endif
+
+#include <stddef.h>
+
+#if defined(__cplusplus) || ((__STDC_VERSION__ >= 199901L))
+    #include <stdint.h>
+#else
+
+    /* We only check for __int8_t_defined */
+    /* as this is all that gcc defines. */
+    #if !defined(__int8_t_defined)
+
+        /* In the rare cases that a system does not define
+         * __int8_t_defined (Android p.e.) we check for the
+         * include guard of the stdint header */
+        #if !defined(_STDINT_H)
+
+                typedef unsigned char        uint8_t;
+                typedef signed   char        int8_t;
+                typedef unsigned short       uint16_t;
+                typedef          short       int16_t;
+                typedef unsigned int         uint32_t;
+                typedef          int         int32_t;
+
+            #if !defined(_MSC_VER)
+                        typedef signed   long long  int64_t;
+                        typedef unsigned long long  uint64_t;
+            #else
+                        typedef signed   __int64    int64_t;
+                        typedef unsigned __int64    uint64_t;
+            #endif /* #if !defined(_MSC_VER) */
+
+                typedef unsigned int   uint_least32_t;
+                typedef          int   int_least32_t;
+                typedef unsigned int   uint_least8_t;
+                typedef unsigned int   uint;
+                typedef unsigned char  uchar;
+
+        #endif /* #if !defined(_STDINT_H) */
+    #endif /* #if !defined(__int8_t_defined) */
+#endif /* #if defined(__cplusplus) || ((__STDC_VERSION__ >= 199901L)) */
+
+#ifndef NULL
+    #define NULL ((void *)0)
+#endif
+
+/* make lint happy: */
+typedef char CHAR;
+typedef char char_t;    /* like suggested in  Misra 6.3 (P. 29) */
+
+typedef enum {
+    BOOL_FALSE = 0,
+    BOOL_TRUE = (!BOOL_FALSE)
+} bool_t;
+
+
+#define UNUSED_PARAM(unref_param)  ((void) (unref_param));
+#define CAST_POINTER_TO_UINT32(pointer) ((uint32_t) (pointer))
+#define CAST_POINTER_TO_INT32(pointer) ((int32_t) (pointer))
+#define CAST_UINT32_TO_POINTER(pointerType, value) ((pointerType)(value))
+#define CAST_INT32_TO_POINTER(value) ((int32_t *)(value))
+#define N_ELEMENTS(s)      (sizeof(s) / sizeof ((s)[0]))
+#define ABS(a)         ((a) > 0 ? (a) : -(a))
+
+#endif /*TYPES_H_*/

+ 196 - 0
isp_isp8000l/units/cameric_drv/cameric_drv_common.h

@@ -0,0 +1,196 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file    cameric_drv_common.h
+ *
+ * @brief   This file contains all common definition which are used by the
+ *          internal modules and the upper layer too.
+ *
+ *****************************************************************************/
+/**
+ * @defgroup cameric_drv_common CamerIC driver common API definitions
+ * @{
+ */
+#ifndef __CAMERIC_DRV_COMMON_H__
+#define __CAMERIC_DRV_COMMON_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+#if 1
+/******************************************************************************/
+/**
+ * @brief   A structure to represent a 3x3 matrix.
+ *
+ *          The nine values are laid out as follows (zero based index):
+ *
+ *               | 0 1 2 | \n
+ *               | 3 4 5 | \n
+ *               | 6 7 8 | \n
+ *
+ * @note    The values are represented as float numbers.
+ *
+ *****************************************************************************/
+typedef struct CamerIc3x3FloatMatrix_s
+{
+    float fCoeff[9U];               /**< array of 3x3 float values */
+} CamerIc3x3FloatMatrix_t;
+#endif
+
+
+
+/******************************************************************************/
+/**
+ * @brief   A structure to represent a 5x5 matrix.
+ *
+ *          The 25 values are laid out as follows (zero based index):
+ *
+ *               | 00 01 02 03 04 | \n
+ *               | 05 06 07 08 09 | \n
+ *               | 10 11 12 13 14 | \n
+ *               | 15 16 17 18 19 | \n
+ *               | 20 21 22 23 24 | \n
+ *
+ * @note    The 25 values are represented as float numbers.
+ *
+ *****************************************************************************/
+typedef struct CamerIc5x5FloatMatrix_s
+{
+    float fCoeff[25U];              /**< array of 5x5 float values */
+} CamerIc5x5FloatMatrix_t;
+
+
+
+/******************************************************************************/
+/**
+ * @brief   A structure to represent a 3x3 matrix.
+ *
+ *          The nine values are laid out as follows (zero based index):
+ *
+ *               | 0 1 2 | \n
+ *               | 3 4 5 | \n
+ *               | 6 7 8 | \n
+ *
+ * @note    The values are represented as fix point numbers.
+ *
+ *****************************************************************************/
+typedef struct CamerIc3x3Matrix_s
+{
+    uint32_t    Coeff[9U];               /**< array of 3x3 float values */
+} CamerIc3x3Matrix_t;
+
+
+
+/*******************************************************************************
+ **
+ * @brief   A structure/tupple to represent gain values for four (R,Gr,Gb,B)
+ *          channels.
+ *
+ * @note    The gain values are represented as fix point numbers.
+ *
+ *****************************************************************************/
+typedef struct CamerIcGains_s
+{
+    uint16_t Red;                       /**< gain value for the red channel */
+    uint16_t GreenR;                    /**< gain value for the green-red channel */
+    uint16_t GreenB;                    /**< gain value for the green-blue channel */
+    uint16_t Blue;                      /**< gain value for the blue channel */
+} CamerIcGains_t;
+
+
+
+/******************************************************************************/
+/**
+ * @brief   A structure/tupple to represent offset values for three (R,G,B)
+ *          channels.
+ *
+ * @note    The offset values are represented as 2's complement integer.
+ *          Number ranging from -2048 (0x800) to 2047 (0x7FF).
+ *          0 is represented as 0x000.
+ *
+ *****************************************************************************/
+typedef struct CamerIcXTalkOffset_s
+{
+    uint16_t Red;                       /**< offset value for the red channel */
+    uint16_t Green;                     /**< offset value for the green channel */
+    uint16_t Blue;                      /**< offset value for the blue channel */
+} CamerIcXTalkOffset_t;
+
+
+
+/******************************************************************************/
+/**
+ * @brief   A structure to represent a general purpose window. The window is
+ *          spanned by a horizontal and vertical offset, counting from zero,
+ *          the width and the height.
+ *
+ * @note    The windows points are represented by 16-bit unsigned integer
+ *          numbers.
+ *
+ *****************************************************************************/
+typedef struct CamerIcWindow_s
+{
+    uint16_t    hOffset;
+    uint16_t    vOffset;
+    uint16_t    width;
+    uint16_t    height;
+} CamerIcWindow_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   This function initialize/configures a general purpose window.
+ *
+ * @param   pWnd            pointer to a window to initialize
+ * @param   hOffset         horizontal offset (starting at zero)
+ * @param   vOffset         vertical offset (starting at zero)
+ * @param   height          window height
+ * @param   width           window width
+ *
+ *****************************************************************************/
+static inline void SetCamerIcWindow
+(
+    CamerIcWindow_t *pWnd,
+    const uint16_t  hOffset,
+    const uint16_t  vOffset,
+    const uint16_t  height,
+    const uint16_t  width
+)
+{
+    if ( pWnd != NULL )
+    {
+        pWnd->hOffset   = hOffset;
+        pWnd->vOffset   = vOffset;
+        pWnd->height    = height;
+        pWnd->width     = width;
+    }
+}
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/* @} cameric_drv_common */
+
+#endif /* __CAMERIC_DRV_COMMON_H__ */
+

+ 36 - 0
isp_isp8000l/units/common/align.h

@@ -0,0 +1,36 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file align.h
+ *
+ * @brief
+ *
+ *****************************************************************************/
+#ifndef __ALIGN_H__
+#define __ALIGN_H__
+
+#ifndef ALIGN_UP
+#define ALIGN_UP(addr, align)		( ((addr) + ((align)-1)) & ~(uintptr_t)((align)-1) ) //!< Aligns addr to next higher aligned addr; align must be a power of two.
+#endif
+#define ALIGN_DOWN(addr, align)		( ((addr)              ) & ~(uintptr_t)((align)-1) ) //!< Aligns addr to next lower aligned addr; align must be a power of two.
+
+#define ALIGN_SIZE_1K               ( 0x400 )
+#define ALIGN_UP_1K(addr)			( ALIGN_UP(addr, ALIGN_SIZE_1K) )
+
+#define MAX_ALIGNED_SIZE(size, align) ( ALIGN_UP(size, align) + align ) //!< Calcs max size of memory required to be able to hold a block of size bytes with a start address aligned to align.
+
+#endif /* __ALIGN_H__ */

+ 28 - 0
isp_isp8000l/units/common/array_size.h

@@ -0,0 +1,28 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file misc.h
+ *
+ * @brief   Some often used little helpers; mainly implemented as macros.
+ *
+ *****************************************************************************/
+#ifndef __ARRAY_SIZE_H__
+#define __ARRAY_SIZE_H__
+
+#define ARRAY_SIZE(arr)     ( sizeof(arr) / sizeof((arr)[0]) )
+
+#endif /* __ARRAY_SIZE_H__ */

+ 932 - 0
isp_isp8000l/units/common/cam_types.h

@@ -0,0 +1,932 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file cam_types.h
+ *
+ * @brief Interface description for image sensor specific implementation (iss).
+ *
+ *****************************************************************************/
+/**
+ * @page module_name_page Module Name
+ * Describe here what this module does.
+ *
+ * For a detailed list of functions and implementation detail refer to:
+ * - @ref module_name
+ *
+ * @defgroup cam_types   Common Camera Type Definitions
+ * @{
+ *
+ */
+#ifndef __CAM_TYPES_H__
+#define __CAM_TYPES_H__
+
+#include <common/list.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   doortype of an illumination profile
+ */
+/*****************************************************************************/
+typedef enum  CamDoorType_e
+{
+    CAM_DOOR_TYPE_OUTDOOR = 0,
+    CAM_DOOR_TYPE_INDOOR  = ( !CAM_DOOR_TYPE_OUTDOOR )
+} CamDoorType_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   doortype of an illumination profile
+ */
+/*****************************************************************************/
+typedef enum CamAwbType_e
+{
+    CAM_AWB_TYPE_MANUAL  = 0,
+    CAM_AWB_TYPE_AUTO    = ( !CAM_AWB_TYPE_MANUAL )
+} CamAwbType_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   3 channel color components
+ */
+/*****************************************************************************/
+typedef enum Cam3ChColorComponent_e
+{
+    CAM_3CH_COLOR_COMPONENT_RED     = 0,
+    CAM_3CH_COLOR_COMPONENT_GREEN   = 1,
+    CAM_3CH_COLOR_COMPONENT_BLUE    = 2,
+    CAM_3CH_COLOR_COMPONENT_MAX
+} Cam3ChColorComponent_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   4 channel color components
+ */
+/*****************************************************************************/
+typedef enum Cam4ChColorComponent_e
+{
+    CAM_4CH_COLOR_COMPONENT_RED     = 0,
+    CAM_4CH_COLOR_COMPONENT_GREENR  = 1,
+    CAM_4CH_COLOR_COMPONENT_GREENB  = 2,
+    CAM_4CH_COLOR_COMPONENT_BLUE    = 3,
+    CAM_4CH_COLOR_COMPONENT_MAX
+} Cam4ChColorComponent_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x1FloatMatrix_s
+{
+    float fCoeff[1];
+} Cam1x1FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 | 2 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x3FloatMatrix_s
+{
+    float fCoeff[3];
+} Cam1x3FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 | ... | 4 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x4FloatMatrix_s
+{
+    float fCoeff[4];
+} Cam1x4FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 | ... | 6 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x6FloatMatrix_s
+{
+    float fCoeff[6];
+} Cam1x6FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 | ... | 15 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x16FloatMatrix_s
+{
+    float fCoeff[16];
+} Cam1x16FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam2x1FloatMatrix
+{
+    float fCoeff[2];
+} Cam2x1FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 |
+ *          | 2 | 3 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam2x2FloatMatrix
+{
+    float fCoeff[4];
+} Cam2x2FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 |  2 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam3x1FloatMatrix
+{
+    float fCoeff[3];
+} Cam3x1FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 |  2 |
+ *          | 3 | 4 |  5 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam3x2FloatMatrix_s
+{
+    float fCoeff[6];
+} Cam3x2FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 |  2 |
+ *          | 3 | 4 |  5 |
+ *          | 6 | 7 |  8 |
+ *
+ * @note    Coefficients are represented as float numbers
+ */
+/*****************************************************************************/
+typedef struct Cam3x3FloatMatrix_s
+{
+    float fCoeff[9];
+} Cam3x3FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          |   0 |   1 |   2 |   3 |   4 |   5 |   6 |   7 | ....
+ *          |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  24 | ....
+ *          |  34 |  35 |  36 |  37 |  38 |  39 |  40 |  41 | ....
+ *          ...
+ *          ...
+ *          ...
+ *          | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | .... | 288 |
+ *
+ * @note    Coefficients are represented as short numbers
+ */
+/*****************************************************************************/
+typedef struct Cam17x17FloatMatrix_s
+{
+    float fCoeff[17 * 17];
+} Cam17x17FloatMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 | 2 |
+ *
+ * @note    Coefficients are represented as short numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x3ShortMatrix_s
+{
+    int16_t Coeff[3];
+} Cam1x3ShortMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 | 2 | ... | 4 |
+ *
+ * @note    Coefficients are represented as short numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x4UShortMatrix_s
+{
+    uint16_t uCoeff[4];
+} Cam1x4UShortMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          | 0 | 1 | 2 | ... | 16 |
+ *
+ * @note    Coefficients are represented as short numbers
+ */
+/*****************************************************************************/
+typedef struct Cam1x17UShortMatrix_s
+{
+    uint16_t uCoeff[17];
+} Cam1x17UShortMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Matrix coefficients
+ *
+ *          |   0 |   1 |   2 |   3 |   4 |   5 |   6 |   7 | ....
+ *          |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  24 | ....
+ *          |  34 |  35 |  36 |  37 |  38 |  39 |  40 |  41 | ....
+ *          ...
+ *          ...
+ *          ...
+ *          | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | .... | 288 |
+ *
+ * @note    Coefficients are represented as short numbers
+ */
+/*****************************************************************************/
+typedef struct Cam17x17UShortMatrix_s
+{
+    uint16_t uCoeff[17 * 17];
+} Cam17x17UShortMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of a resolution
+ */
+/*****************************************************************************/
+#define CAM_RESOLUTION_NAME         ( 15U )
+typedef char                        CamResolutionName_t[CAM_RESOLUTION_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of an illumination
+ */
+/*****************************************************************************/
+#define CAM_BLS_PROFILE_NAME        ( 10U )
+typedef char                        CamBlsProfileName_t[CAM_BLS_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of an illumination
+ */
+/*****************************************************************************/
+#define CAM_ILLUMINATION_NAME       ( 20U )
+typedef char                        CamIlluminationName_t[CAM_ILLUMINATION_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of a lense shade correction profile (LscProfile)
+ */
+/*****************************************************************************/
+#define CAM_LSC_PROFILE_NAME        ( 25U )
+typedef char                        CamLscProfileName_t[CAM_LSC_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of a color correction profile (CcProfile)
+ */
+/*****************************************************************************/
+#define CAM_CC_PROFILE_NAME         ( 20U )
+typedef char                        CamCcProfileName_t[CAM_CC_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of a auto white balance profile (AwbProfile)
+ */
+/*****************************************************************************/
+#define CAM_AWB_PROFILE_NAME        ( 20U )
+typedef char                        CamAwbProfileName_t[CAM_AWB_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of an exposure scheme (EcmScheme)
+ */
+/*****************************************************************************/
+#define CAM_ECM_SCHEME_NAME         ( 20U )
+typedef char                        CamEcmSchemeName_t[CAM_ECM_SCHEME_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of an exposure profile (EcmProfile)
+ */
+/*****************************************************************************/
+#define CAM_ECM_PROFILE_NAME        ( 20U )
+typedef char                        CamEcmProfileName_t[CAM_ECM_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of a chromatic abberation correction profile
+ *          (CacProfile)
+ */
+/*****************************************************************************/
+#define CAM_CAC_PROFILE_NAME        ( 20U )
+typedef char                        CamCacProfileName_t[CAM_CAC_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of a denoising prefilter profile (DpfProfile)
+ */
+/*****************************************************************************/
+#define CAM_DPF_PROFILE_NAME        ( 20U )
+typedef char                        CamDpfProfileName_t[CAM_DPF_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   name/identifier of a denoising prefilter profile (DpccProfile)
+ */
+/*****************************************************************************/
+#define CAM_DPCC_PROFILE_NAME       ( 20U )
+typedef char                        CamDpccProfileName_t[CAM_DPCC_PROFILE_NAME];
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   resolution profile
+ */
+/*****************************************************************************/
+typedef struct CamResolution_t
+{
+    void                *p_next;            /**< for adding to a list */
+
+    CamResolutionName_t name;               /**< desctriptor */
+    uint16_t            width;              /**< resolution width */
+    uint16_t            height;             /**< resolution height */
+    uint16_t            framerate;          /**< frames pre second */
+    uint32_t            id;                 /**< bitmask identifier */
+} CamResolution_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   parameters for a sensorgain to saturation interpolation
+ */
+/*****************************************************************************/
+typedef struct CamSaturationCurve_s
+{
+    uint16_t    ArraySize;
+    float       *pSensorGain;
+    float       *pSaturation;
+} CamSaturationCurve_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   parameters for a sensorgain to vignetting (compensation)
+ *          interpolation
+ */
+/*****************************************************************************/
+typedef struct CamVignettingCurve_s
+{
+    uint16_t    ArraySize;
+    float       *pSensorGain;
+    float       *pVignetting;
+} CamVignettingCurve_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   parameters for a sensorgain to vignetting (compensation)
+ *          interpolation
+ *
+ */
+/*****************************************************************************/
+typedef struct CamLscMatrix_s
+{
+    Cam17x17UShortMatrix_t  LscMatrix[CAM_4CH_COLOR_COMPONENT_MAX];
+} CamLscMatrix_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   BLS calibration structure
+ */
+/*****************************************************************************/
+typedef struct CamBlsProfile_s
+{
+    void                        *p_next;                /**< for adding to a list */
+
+    CamBlsProfileName_t         name;                   /**< profile name */
+    CamResolutionName_t         resolution;             /**< resolution link */
+
+    Cam1x4UShortMatrix_t        level;                  /**< black level for all 4 color components */
+} CamBlsProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Illumination specific structure.
+ */
+/*****************************************************************************/
+typedef struct CamIlluProfile_s
+{
+    void                        *p_next;                /**< for adding to a list */
+
+    CamIlluminationName_t       name;                   /**< name of the illumination profile (i.e. "D65", "A", ... )*/
+    uint32_t                    id;                     /**< unique id */
+
+    CamDoorType_t               DoorType;               /**< indoor or outdoor profile */
+    CamAwbType_t                AwbType;                /**< manual or auto profile */
+
+    /* for manual white balance data */
+    Cam3x3FloatMatrix_t         CrossTalkCoeff;         /**< CrossTalk matrix coefficients */
+    Cam1x3FloatMatrix_t         CrossTalkOffset;        /**< CrossTalk offsets */
+    Cam1x4FloatMatrix_t         ComponentGain;          /**< White Balance Gains*/
+
+    /* gaussian mixture modell */
+    Cam2x1FloatMatrix_t         GaussMeanValue;         /**< */
+    Cam2x2FloatMatrix_t         CovarianceMatrix;       /**< */
+    Cam1x1FloatMatrix_t         GaussFactor;            /**< */
+    Cam2x1FloatMatrix_t         Threshold;              /**< */
+
+    /* adaptive color correctio */
+    CamSaturationCurve_t        SaturationCurve;        /**< stauration over gain curve */
+
+    /* adative lense shade correction */
+    CamVignettingCurve_t        VignettingCurve;        /**< vignetting over gain curve */
+
+    #define CAM_NO_CC_PROFILES  ( 10 )                  /**< max number of cc-profiles per illumination */
+    int32_t                     cc_no;
+    CamCcProfileName_t          cc_profiles[CAM_NO_CC_PROFILES];
+
+    #define CAM_NO_LSC_PROFILES ( 5 )
+    #define CAM_NO_RESOLUTIONS  ( 4 )
+    int32_t                     lsc_res_no;
+    int32_t                     lsc_no[CAM_NO_RESOLUTIONS];
+    CamLscProfileName_t         lsc_profiles[CAM_NO_RESOLUTIONS][CAM_NO_LSC_PROFILES];
+} CamIlluProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   LSC profile
+ */
+/*****************************************************************************/
+typedef struct CamLscProfile_s
+{
+    void                    *p_next;                                /**< for adding to a list */
+
+    CamLscProfileName_t     name;                                   /**< profile name */
+    CamResolutionName_t     resolution;                             /**< resolution link */
+    CamIlluminationName_t   illumination;                           /**< illumination link */
+    float                   vignetting;                             /**< vignetting value */
+
+    uint16_t                LscSectors;
+    uint16_t                LscNo;
+    uint16_t                LscXo;
+    uint16_t                LscYo;
+
+    uint16_t                LscXGradTbl[8];
+    uint16_t                LscYGradTbl[8];
+    uint16_t                LscXSizeTbl[8];
+    uint16_t                LscYSizeTbl[8];
+
+    Cam17x17UShortMatrix_t  LscMatrix[CAM_4CH_COLOR_COMPONENT_MAX];     /**< matrix for different color channels */
+} CamLscProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   CC profile
+ *
+ */
+/*****************************************************************************/
+typedef struct CamCcProfile_s
+{
+    void                    *p_next;                /**< for adding to a list */
+
+    CamCcProfileName_t      name;                   /**< profile name */
+    float                   saturation;             /**< saturation value */
+
+    Cam3x3FloatMatrix_t     CrossTalkCoeff;         /**< CrossTalk matrix coefficients */
+    Cam1x3FloatMatrix_t     CrossTalkOffset;        /**< CrossTalk offsets */
+    Cam1x4FloatMatrix_t     ComponentGain;          /**< White Balance Gains*/
+} CamCcProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   CAC calibration structure
+ */
+/*****************************************************************************/
+typedef struct CamCacProfile_s
+{
+    void                    *p_next;            /**< for adding to a list */
+
+    CamCacProfileName_t     name;               /**< profile name */
+    CamResolutionName_t     resolution;         /**< resolution link */
+
+    uint8_t                 x_ns;               /**< horizontal normalization shift */
+    uint8_t                 x_nf;               /**< horizontal normalization factor */
+    uint8_t                 y_ns;               /**< vertical normalization shift */
+    uint8_t                 y_nf;               /**< vertical normalization factor */
+
+    Cam1x3FloatMatrix_t     Red;                /**< coeffciencts A, B and C for red */
+    Cam1x3FloatMatrix_t     Blue;               /**< coeffciencts A, B and C for blue */
+
+    int16_t                 hCenterOffset;
+    int16_t                 vCenterOffset;
+} CamCacProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   DPF calibration structure
+ */
+/*****************************************************************************/
+typedef struct CamDpfProfile_s
+{
+    void                    *p_next;            /**< for adding to a list */
+
+    CamDpfProfileName_t     name;               /**< profile name */
+    CamResolutionName_t     resolution;         /**< resolution link */
+
+    uint16_t                nll_segmentation;
+    Cam1x17UShortMatrix_t   nll_coeff;
+
+    uint16_t                SigmaGreen;         /**< */
+    uint16_t                SigmaRedBlue;       /**< */
+    float                   fGradient;          /**< */
+    float                   fOffset;            /**< */
+    Cam1x4FloatMatrix_t     NfGains;            /**< */
+} CamDpfProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   DPCC calibration structure
+ */
+/*****************************************************************************/
+typedef struct CamDpccProfile_s
+{
+    void                    *p_next;            /**< for adding to a list */
+
+    CamDpccProfileName_t    name;               /**< profile name */
+    CamResolutionName_t     resolution;         /**< resolution link */
+
+    uint32_t                isp_dpcc_mode;
+    uint32_t                isp_dpcc_output_mode;
+    uint32_t                isp_dpcc_set_use;
+    uint32_t                isp_dpcc_methods_set_1;
+    uint32_t                isp_dpcc_methods_set_2;
+    uint32_t                isp_dpcc_methods_set_3;
+    uint32_t                isp_dpcc_line_thresh_1;
+    uint32_t                isp_dpcc_line_mad_fac_1;
+    uint32_t                isp_dpcc_pg_fac_1;
+    uint32_t                isp_dpcc_rnd_thresh_1;
+    uint32_t                isp_dpcc_rg_fac_1;
+    uint32_t                isp_dpcc_line_thresh_2;
+    uint32_t                isp_dpcc_line_mad_fac_2;
+    uint32_t                isp_dpcc_pg_fac_2;
+    uint32_t                isp_dpcc_rnd_thresh_2;
+    uint32_t                isp_dpcc_rg_fac_2;
+    uint32_t                isp_dpcc_line_thresh_3;
+    uint32_t                isp_dpcc_line_mad_fac_3;
+    uint32_t                isp_dpcc_pg_fac_3;
+    uint32_t                isp_dpcc_rnd_thresh_3;
+    uint32_t                isp_dpcc_rg_fac_3;
+    uint32_t                isp_dpcc_ro_limits;
+    uint32_t                isp_dpcc_rnd_offs;
+} CamDpccProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Contains pointers to parameter arrays for Rg/Bg color space
+ *          clipping
+ */
+/*****************************************************************************/
+typedef struct CamAwbClipParm_s
+{
+    float       *pRg1;
+    float       *pMaxDist1;
+    float       *pRg2;
+    float       *pMaxDist2;
+    uint16_t    ArraySize1;
+    uint16_t    ArraySize2;
+} CamAwbClipParm_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Contains pointers to parameter arrays for AWB out of range
+ *          handling
+ *
+ */
+/*****************************************************************************/
+typedef struct CamAwbGlobalFadeParm_s
+{
+    float       *pGlobalFade1;
+    float       *pGlobalGainDistance1;
+    float       *pGlobalFade2;
+    float       *pGlobalGainDistance2;
+    uint16_t    ArraySize1;
+    uint16_t    ArraySize2;
+} CamAwbGlobalFadeParm_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Contains pointers to parameter arrays for near white pixel
+ *          parameter calculations
+ */
+/*****************************************************************************/
+typedef struct CamAwbFade2Parm_s
+{
+    float*      pFade;
+    float*      pCbMinRegionMax;
+    float*      pCrMinRegionMax;
+    float*      pMaxCSumRegionMax;
+    float*      pCbMinRegionMin;
+    float*      pCrMinRegionMin;
+    float*      pMaxCSumRegionMin;
+    uint16_t    ArraySize;
+} CamAwbFade2Parm_t;
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiLine_t
+ *
+ * @brief   Contains parameters for a straight line in Hesse normal form in
+ *          Rg/Bg colorspace
+ *
+ */
+/*****************************************************************************/
+typedef struct CamCenterLine_s
+{
+    float f_N0_Rg;                                  /**< Rg component of normal vector */
+    float f_N0_Bg;                                  /**< Bg component of normal vector */
+    float f_d;                                      /**< Distance of normal vector     */
+} CamCenterLine_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Global AWB IIR Filter
+ */
+/*****************************************************************************/
+typedef struct CamCalibIIR_s
+{
+    float       fIIRDampCoefAdd;                        /**< incrementer of damping coefficient */
+    float       fIIRDampCoefSub;                        /**< decrementer of damping coefficient */
+    float       fIIRDampFilterThreshold;                /**< threshold for incrementing or decrementing of damping coefficient */
+
+    float       fIIRDampingCoefMin;                     /**< minmuim value of damping coefficient */
+    float       fIIRDampingCoefMax;                     /**< maximum value of damping coefficient */
+    float       fIIRDampingCoefInit;                    /**< initial value of damping coefficient */
+
+    uint16_t    IIRFilterSize;                          /**< number of filter items */
+    float       fIIRFilterInitValue;                    /**< initial value of the filter items */
+} CamCalibIIR_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Global AWB calibration structure
+ */
+/*****************************************************************************/
+typedef struct CamCalibAwbGlobal_s
+{
+    void                    *p_next;                    /**< for adding to a list */
+
+    CamAwbProfileName_t     name;                       /**< profile name */
+    CamResolutionName_t     resolution;                 /**< resolution link */
+
+    Cam3x1FloatMatrix_t     SVDMeanValue;
+    Cam3x2FloatMatrix_t     PCAMatrix;
+    CamCenterLine_t         CenterLine;
+    Cam1x1FloatMatrix_t     KFactor;
+
+    CamAwbClipParm_t        AwbClipParam;               /**< clipping parameter in Rg/Bg space */
+    CamAwbGlobalFadeParm_t  AwbGlobalFadeParm;
+    CamAwbFade2Parm_t       AwbFade2Parm;
+
+    float                   fRgProjIndoorMin;
+    float                   fRgProjOutdoorMin;
+    float                   fRgProjMax;
+    float                   fRgProjMaxSky;
+
+    CamIlluminationName_t   outdoor_clipping_profile;
+
+    float                   fRegionSize;
+    float                   fRegionSizeInc;
+    float                   fRegionSizeDec;
+
+    CamCalibIIR_t           IIR;
+} CamCalibAwbGlobal_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   ECM scheme
+ */
+/*****************************************************************************/
+typedef struct CamEcmScheme_s
+{
+    void                    *p_next;                    /**< for adding to a list */
+
+    CamEcmSchemeName_t      name;                       /**< scheme name */
+
+    float                   OffsetT0Fac;                /**< start flicker avoidance above OffsetT0Fac * Tflicker integration time */
+    float                   SlopeA0;                    /**< slope of gain */
+} CamEcmScheme_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   ECM profile
+ */
+/*****************************************************************************/
+typedef struct CamEcmProfile_s
+{
+    void                    *p_next;                    /**< for adding to a list */
+
+    CamEcmProfileName_t     name;                       /**< profile name => serves as resolution link as well */
+
+    List                    ecm_scheme;                 /**< list of ECM schemes; at least one item is expected */
+} CamEcmProfile_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   Global AEC calibration structure
+ */
+/*****************************************************************************/
+typedef struct CamCalibAecGlobal_s
+{
+    float                   SetPoint;                   /**< set point to hit by the ae control system */
+    float                   ClmTolerance;
+    float                   DampOver;
+    float                   DampUnder;
+    float                   AfpsMaxGain;
+} CamCalibAecGlobal_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   System data structure.
+ */
+/*****************************************************************************/
+typedef struct CamCalibSystemData_s
+{
+    bool_t                  AfpsDefault;
+} CamCalibSystemData_t;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/* @} cam_types */
+
+#endif /* __CAM_TYPES_H__ */
+

+ 90 - 0
isp_isp8000l/units/common/cea_861.h

@@ -0,0 +1,90 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file    cea_861.h
+ *
+ * @brief   Defines CEA 861 style video format stuff.
+ *
+ *****************************************************************************/
+#ifndef __CEA_861_H__
+#define __CEA_861_H__
+
+#include <ebase/types.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+typedef enum Cea861VideoFormat_e
+{
+    CEA_861_VIDEOFORMAT_INVALID        = 0,
+
+    // CEA 861 formats below
+    CEA_861_VIDEOFORMAT_640x480p60     = 1,
+    CEA_861_VIDEOFORMAT_1280x720p60    = 4,
+    CEA_861_VIDEOFORMAT_1920x1080p60   = 16,
+    CEA_861_VIDEOFORMAT_1920x1080p50   = 31,
+    CEA_861_VIDEOFORMAT_1920x1080p24   = 32,
+    CEA_861_VIDEOFORMAT_1920x1080p25   = 33,
+    CEA_861_VIDEOFORMAT_1920x1080p30   = 34,
+
+    // user defined formats below
+    CEA_861_VIDEOFORMAT_CUSTOM_BASE    = 256
+} Cea861VideoFormat_t; //!< @note The names and numbers intentionally match the CEA 861 Specification; Version D
+
+typedef struct Cea861VideoFormatDetails_s   //!< All counting in CEA spec starts at 1 (not 0) and so do we!
+{
+    Cea861VideoFormat_t FormatID;           //!< CEA 861 format ID.
+    Cea861VideoFormat_t FormatIDInfoFrame;  //!< Format ID to be used in HDMI info frame; required for 3D support; same as FormatID for all CEA 861 formats and most HDMI 3D formats.
+    char                *szName;            //!< Format description.
+    uint16_t            Hactive;            //!< Active width in pixel.
+    uint16_t            Vactive;            //!< Active height in lines.
+    bool_t              Progressive;        //!< Progressive/Interlaced (true/false) scanning.
+    uint32_t            PixClk;             //!< Pixel clock.
+    uint16_t            PixRep;             //!< Clocks per pixel (used for pixel repetition).
+    uint16_t            Htotal;             //!< Total width in pixel.
+    uint16_t            HsyncStart;         //!< HSync start position.
+    uint16_t            HsyncStop;          //!< HSync stop position.
+    uint16_t            HactStart;          //!< First active pixel.
+    uint16_t            HfieldPos;          //!< Horizontal position of field sync change.
+    uint16_t            Vtotal;             //!< Total height in lines (for interlaced: of full frame).
+    uint16_t            VsyncStart;         //!< VSync start position.
+    uint16_t            VsyncStop;          //!< VSync stop position.
+    uint16_t            VactStart;          //!< First active line.
+    uint16_t            VactStartDelay;     //!< Delay between VactStart and first line containing active image data; required for 3D support only; set to 0 (null) for CEA 861 formats.
+    bool_t              HsyncPolarity;      //!< Hsync polarity high-active/low-active (true/false).
+    bool_t              VsyncPolarity;      //!< Vsync polarity high-active/low-active (true/false).
+    bool_t              FsyncPolarity;      //!< Field sync polarity high-active/low-active (true/false).
+    bool_t              EnPolarity;         //!< Pixel enable polarity high-active/low-active (true/false).
+} Cea861VideoFormatDetails_t;
+
+extern const Cea861VideoFormatDetails_t* Cea861GetVideoFormatDetails
+(
+    Cea861VideoFormat_t FormatID
+);
+
+extern bool_t Cea861AlignVideoFormatDetails
+(
+    Cea861VideoFormatDetails_t *pVideoFormatDetails
+);
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* __CEA_861_H__*/

+ 93 - 0
isp_isp8000l/units/common/hdmi_3d.h

@@ -0,0 +1,93 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file    hdmi_3d.h
+ *
+ * @brief   Defines HDMI 3D style video format stuff.
+ *
+ *****************************************************************************/
+#ifndef __HDMI_3D_H__
+#define __HDMI_3D_H__
+
+#include <ebase/types.h>
+#include <common/return_codes.h>
+#include <common/cea_861.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+typedef enum Hdmi3DVideoFormat_e
+{
+    HDMI_3D_VIDEOFORMAT_FRAME_PACKING       = 0x00, //!< 0000 Frame packing
+    HDMI_3D_VIDEOFORMAT_FIELD_ALTERNATIVE   = 0x01, //!< 0001 Field alternative
+    HDMI_3D_VIDEOFORMAT_LINE_ALTERNATIVE    = 0x02, //!< 0010 Line alternative
+    HDMI_3D_VIDEOFORMAT_SIDE_BY_SIDE_FULL   = 0x03, //!< 0011 Side-by-Side (Full)
+    HDMI_3D_VIDEOFORMAT_L_DEPTH             = 0x04, //!< 0100 L + depth
+    HDMI_3D_VIDEOFORMAT_L_DEPTH_GRFX_DEPTH  = 0x05, //!< 0101 L + depth + graphics + graphics-depth
+    HDMI_3D_VIDEOFORMAT_TOP_AND_BOTTOM      = 0x06, //!< 0110 Top-and-Bottom
+                                                    //   0111 Reserved for future use.
+    HDMI_3D_VIDEOFORMAT_SIDE_BY_SIDE_HALF   = 0x08, //!< 1000 Side-by-Side (Half) (See Table H-3)
+                                                    //   1001 ~ 1110 Reserved for future use.
+    HDMI_3D_VIDEOFORMAT_INVALID             = 0x0f  //!< 1111 Not in use.
+} Hdmi3DVideoFormat_t; //!< @note The names and numbers intentionally match the HDMI Specification; Version 1.4a; March 4, 2010; chapter "Extraction of 3D Signaling Portion".
+
+typedef struct Hdmi3DVideoFormatDetails_s
+{
+    Hdmi3DVideoFormat_t FormatID;       //!< HDMI 3D format ID.
+    char                *szName;        //!< Format description.
+    struct Progressive_s
+    {
+        bool_t              Supported;  //!< Can be used with progressive video.
+        uint16_t            SubImages;  //!< Number of sub images expected per 3D image.
+    } Progressive;
+    struct Interlaced_s
+    {
+        bool_t              Supported;  //!< Can be used with progressive video.
+        uint16_t            SubImages;  //!< Number of sub images expected per 3D image.
+    } Interlaced;
+} Hdmi3DVideoFormatDetails_t;
+
+#define Hdmi3DHasExtData(_format) ((_format&0x8)!=0)
+
+extern const Hdmi3DVideoFormatDetails_t* Hdmi3DGet3DFormatDetails
+(
+    Hdmi3DVideoFormat_t FormatID                                //!< ID of 3D format to get details for.
+);
+
+extern uint16_t Hdmi3DGetNumSubImages
+(
+    const Hdmi3DVideoFormat_t        FormatID,                  //!< ID of 3D format to use.
+    const Cea861VideoFormatDetails_t *pBaseCeaFormatDetails     //!< Reference to base CEA 861 timing details.
+);
+
+extern RESULT Hdmi3DGetVideoFormatDetails
+(
+    const Hdmi3DVideoFormat_t        FormatID,                  //!< ID of 3D format to use.
+    const uint16_t                   SubImageNum,               //!< Number of sub image for which to calc timing details; 0 = first image.
+    const Cea861VideoFormatDetails_t *pBaseCeaFormatDetails,    //!< Reference to base CEA 861 timing details.
+    Cea861VideoFormatDetails_t       *pSubCeaFormatDetails      //!< Reference to storage space for calculated sub image timing details.
+);
+
+// NOTE: The value must match the highest SubImages number in Hdmi3DVideoFormats table in implementation.
+#define HDMI_3D_MAX_NUM_SUBIMAGES 4 //!< Max number of sub images required for supported 3D formats.
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* __HDMI_3D_H__*/

+ 98 - 0
isp_isp8000l/units/common/hw_version.h

@@ -0,0 +1,98 @@
+/******************************************************************************
+ *
+ * Copyright 2010, Dream Chip Technologies GmbH. All rights reserved.
+ * No part of this work may be reproduced, modified, distributed, transmitted,
+ * transcribed, or translated into any language or computer format, in any form
+ * or by any means without written permission of:
+ * Dream Chip Technologies GmbH, Steinriede 10, 30827 Garbsen / Berenbostel,
+ * Germany
+ *
+ *****************************************************************************/
+/**
+ * @file hw_version.h
+ *
+ * @brief
+ *   This header files contains hardware module version define informations.
+ *
+ *****************************************************************************/
+#ifndef __HW_VERSION_H__
+#define __HW_VERSION_H__
+
+
+/*****************************************************************************/
+/**
+ * @brief   HDR module version type
+ */
+/*****************************************************************************/
+#define VSI_ISP_HDR_NOTSUPPORT  0   //!< Not support HDR
+#define VSI_ISP_HDR_V10         1   //!< Version V10
+#define VSI_ISP_HDR_V11         2   //!< Version V11
+#define VSI_ISP_HDR_V12         3   //!< Version V12
+#define VSI_ISP_HDR_V13         4   //!< Version V13
+
+
+
+
+/////////////////////////////////////////
+//add Version defines
+/////////////////////////////////////////
+#ifdef ISP8000NANO_V1801
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_NOTSUPPORT
+
+#elif defined ISP8000NANO_V1802
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V11
+
+#elif defined ISP8000_V1901
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V11
+
+#elif defined ISP8000L_V1901
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_NOTSUPPORT
+
+#elif defined ISP8000L_V1902
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V11
+
+#elif defined ISP8000L_V1903
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V12
+
+#elif defined ISP8000L_V1905
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V12
+
+#elif defined ISP8000L_V2001
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V12
+
+#elif defined ISP8000L_V2002
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V12
+
+#elif defined ISP8000_V2003
+
+#define VSI_ISP_HDR_VERSION VSI_ISP_HDR_V13
+
+#elif defined ISP8000L_V2007
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V12
+
+#elif defined ISP8000L_V2008
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_V12
+
+#elif defined ISP8000NANO_V2012
+
+#define VSI_ISP_HDR_VERSION		VSI_ISP_HDR_NOTSUPPORT
+
+#endif
+
+
+
+
+
+#endif /* __HW_VERSION_H__ */
+

+ 471 - 0
isp_isp8000l/units/common/list.h

@@ -0,0 +1,471 @@
+/******************************************************************************\
+|* Copyright (c) <2010> by Silicon Image, Inc., used with permission by       *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/*!
+ *  @file        list.h
+ *  @version     1.0
+ *  @author      Ulrich Marx
+ *
+ *  @brief       implementation of a single linked list
+ *
+ *  @note        (the tag is omitted if there are no notes) \n
+ */
+
+/**
+ * @file list.h
+ *
+ * <pre>
+ *
+ *   Principal Author: Ulrich Marx <ulrich.marx@siliconimage.com>
+ *   Company: Silicon Image
+ *
+ *   Programming Language: C
+ *   Date:    Tue 22 Apr 2008 07:58:35 PM CEST
+ *   Designed for any OS (conformable to ANSI)
+ *
+ *   Description:
+ *
+ *
+ * </pre>
+ *
+ ******************************************************************************/
+#ifndef __LIST_H__
+#define __LIST_H__
+
+#include <ebase/dct_assert.h>      /* for DCT_ASSERT */
+
+#define ASSERT  DCT_ASSERT
+
+/******************************************************************************/
+/**
+ * @brief  Implementation of single linked list
+ *
+ ******************************************************************************/
+typedef struct _List
+{
+    struct _List* p_next;
+} List;
+
+
+/******************************************************************************/
+/**
+ * @brief   Prepare a list item.
+ *
+ * @note    This function prepares a list item so that it can be added to a list.
+ *
+ * @param   p_item  The list item to be initialized.
+ *
+ ******************************************************************************/
+static inline void ListPrepareItem(void* p_item)
+{
+    ASSERT( p_item != NULL );
+    ((List *)p_item)->p_next = NULL;
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Initialize a list.
+ *
+ * @note    This function initalizes a list. The list will be empty after this
+ *          function has been called.
+ *
+ * @param   p_list  The list to be initialized.
+ *
+ ******************************************************************************/
+static inline void ListInit(List* p_list)
+{
+    ASSERT( p_list != NULL );
+    p_list->p_next = NULL;
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Get a pointer to the first element of a list.
+ *
+ * @note    This function returns a pointer to the first element of the list.
+ *          The element will \b not be removed from the list.
+ *
+ * @param   p_list  The list.
+ *
+ * @return  A pointer to the first element on the list.
+ *
+ ******************************************************************************/
+static inline List *ListHead(const List *p_list)
+{
+    List *p_head;
+
+    ASSERT( p_list != NULL );
+
+    p_head = p_list->p_next;
+
+    return ( p_head );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Get the tail of a list.
+ *
+ * @note    This function returns a pointer to the elements following the first
+ *          element of a list. No elements are removed by this function.
+ *
+ * @param   p_list  The list
+ *
+ * @return  A pointer to the element after the first element on the list.
+ *
+ ******************************************************************************/
+static inline List* ListTail(List* p_list)
+{
+    List* l;
+
+    ASSERT( p_list != NULL );
+
+    if (p_list->p_next == NULL)
+    {
+        return ( NULL );
+    }
+
+    for (l = p_list; l->p_next != NULL; l = l->p_next)
+    {
+        /* make lint happy */
+    }
+
+    return ( l );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief  Tests wheter a list is empty.
+ *
+ * @param  p_list The list
+ *
+ ******************************************************************************/
+static inline int ListEmpty(const List* p_list)
+{
+    ASSERT( p_list != NULL );
+
+    return ( ((p_list->p_next == NULL) ? 1 : 0) );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief  Returns No of Elemtens
+ *
+ * @param  p_list The list
+ *
+ ******************************************************************************/
+static inline int ListNoItems(const List* p_list)
+{
+    int cnt = 0;
+    List* l;
+
+    ASSERT( p_list != NULL );
+
+    l = ListHead( p_list );
+    while ( l != NULL )
+    {
+        ++cnt;
+        l = l->p_next;
+    }
+
+    return ( cnt );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Add an item at the end of a list.
+ *
+ * @note    This function adds an item to the end of the list.
+ *
+ * @param   p_list  The list.
+ * @param   p_item  A pointer to the item to be added.
+ *
+ ******************************************************************************/
+static inline void ListAddTail(List* p_list, void* p_item)
+{
+    List* l;
+
+    ASSERT( p_list != NULL );
+    ASSERT( p_item != NULL );
+
+    ((List *)p_item)->p_next = NULL;
+    l = ListTail(p_list);
+    if ( l == NULL )
+    {
+        p_list->p_next = (List *)p_item;
+    }
+    else
+    {
+        l->p_next = (List *)p_item;
+    }
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Get the first object on a list.
+ *
+ * @note    This function removes the first object on the list and returns a
+ *          pointer to the list.
+ *
+ * @param   p_list  The list.
+ *
+ * @return  The removed head item of the list.
+ *
+ ******************************************************************************/
+static inline List* ListGetHead(List* p_list)
+{
+    List* l;
+
+    ASSERT( p_list != NULL );
+
+    if ( p_list->p_next != NULL )
+    {
+        l = p_list->p_next;
+        return ( l );
+    }
+
+    return ( NULL );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Get the first object on a list.
+ *
+ * @note    This function removes the first object on the list and returns a
+ *          pointer to the list.
+ *
+ * @param   p_list  The list.
+ *
+ * @return  The removed head item of the list.
+ *
+ ******************************************************************************/
+static inline List* ListGetItemByIdx(List* p_list, const int idx)
+{
+    List* l;
+    int cnt = 0;
+
+    ASSERT( p_list != NULL );
+
+    l = ListHead( p_list );
+    while ( (l != NULL) && (cnt < idx) )
+    {
+        ++cnt;
+        l = l->p_next;
+    }
+
+    return ( l );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Remove the first object on a list.
+ *
+ * @note    This function removes the first object on the list and returns a
+ *          pointer to the list.
+ *
+ * @param   p_list  The list.
+ *
+ * @return  The removed head item of the list.
+ *
+ ******************************************************************************/
+static inline List* ListRemoveHead(List* p_list)
+{
+    List* l;
+
+    ASSERT( p_list != NULL );
+
+    if ( p_list->p_next != NULL )
+    {
+        l = p_list->p_next;
+        p_list->p_next = l->p_next;
+        return ( l );
+    }
+
+    return ( NULL );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Search an element in list
+ *
+ * @note    This function searches the first element which matches to the
+ *          given search-function
+ *
+ * @param   p_list  The list.
+ *          func    The search function out side this file
+ *          key     The key that search function matches
+ *
+ * @return  The first element
+ * @retval  NULL    no element matches
+ *
+ ******************************************************************************/
+typedef int (*pSearchFunc)(List *, void *key);
+
+static inline List* ListSearch(List *p_list, pSearchFunc func, void *key)
+{
+    List *l;
+
+    ASSERT ( p_list != NULL );
+    ASSERT ( func != NULL );
+
+    l = ListHead( p_list );
+    while ( l )
+    {
+        if ( func( l, key) )
+        {
+            return ( l );
+        }
+        l = l->p_next;
+    }
+
+    return ( NULL );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Search an element in list
+ *
+ * @note    This function searches the first element which matches to the
+ *          given search-function
+ *
+ * @param   p_list  The list.
+ *          func    The search function out side this file
+ *          key     The key that search function matches
+ *
+ * @return  The first element
+ * @retval  NULL    no element matches
+ *
+ ******************************************************************************/
+typedef void (*pForEachFunc)(List *, void *);
+
+static inline List* ListForEach(List *p_list, pForEachFunc func, void *param)
+{
+    List *l;
+
+    ASSERT ( p_list != NULL );
+    ASSERT ( func != NULL );
+
+    l = ListHead( p_list );
+    while ( l )
+    {
+        func( l, param );
+        l = l->p_next;
+    }
+
+    return ( NULL );
+}
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Get the Index of an Item
+ *
+ * @note    This function removes the first object on the list and returns a
+ *          pointer to the list.
+ *
+ * @param   p_list  The list.
+ *
+ * @return  The removed head item of the list.
+ *
+ ******************************************************************************/
+static inline int ListGetIdxByItem(List *p_list, pSearchFunc func, void *key)
+{
+    List* l;
+    int cnt = 0;
+
+    ASSERT( p_list != NULL );
+
+    l = ListHead( p_list );
+    while ( l )
+    {
+        if ( func( l, key) )
+        {
+            return ( cnt );
+        }
+
+        ++cnt;
+        l = l->p_next;
+    }
+
+    return ( -1 );
+}
+
+
+
+
+/******************************************************************************/
+/**
+ * @brief   Search an element in list
+ *
+ * @note    This function searches the first element which matches to the
+ *          given search-function
+ *
+ * @param   p_list  The list.
+ *          func    The search function out side this file
+ *          key     The key that search function matches
+ *
+ * @return  The first element
+ * @retval  NULL    no element matches
+ *
+ ******************************************************************************/
+static inline List* ListRemoveItem(List *p_list, pSearchFunc func, void *key)
+{
+    List *l, *pre_l;
+
+    ASSERT ( p_list != NULL );
+
+    pre_l = p_list;
+    l = ListHead( p_list );
+    while ( l )
+    {
+        if ( func( l, key) )
+        {
+            /* isolate l from list */
+            pre_l->p_next = l->p_next;
+            l->p_next = NULL;
+            return ( l );
+        }
+        pre_l = l;
+        l = l->p_next;
+    }
+
+    return ( NULL );
+}
+
+
+#endif /* __LIST_H__ */

+ 156 - 0
isp_isp8000l/units/common/mipi.h

@@ -0,0 +1,156 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file    mipi.h
+ *
+ * @brief   Definition of MIPI CSI-2 spec. stuff.
+ *
+ *****************************************************************************/
+#ifndef __MIPI_H__
+#define __MIPI_H__
+
+#include <ebase/types.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/******************************************************************************/
+/**
+ * @brief MIPI virtual channels.
+ *
+ ******************************************************************************/
+typedef enum MipiVirtualChannel_e
+{
+    MIPI_VIRTUAL_CHANNEL_0          = 0x00,     //!< virtual channel 0
+    MIPI_VIRTUAL_CHANNEL_1          = 0x01,     //!< virtual channel 1
+    MIPI_VIRTUAL_CHANNEL_2          = 0x02,     //!< virtual channel 2
+    MIPI_VIRTUAL_CHANNEL_3          = 0x03,     //!< virtual channel 3
+
+    MIPI_VIRTUAL_CHANNEL_MAX
+} MipiVirtualChannel_t;
+
+
+/******************************************************************************/
+/**
+ * @brief MIPI data types.
+ *
+ ******************************************************************************/
+typedef enum MipiDataType_e
+{
+    MIPI_DATA_TYPE_FSC              = 0x00,     //!< frame start code
+    MIPI_DATA_TYPE_FEC              = 0x01,     //!< frame end code
+    MIPI_DATA_TYPE_LSC              = 0x02,     //!< line start code
+    MIPI_DATA_TYPE_LEC              = 0x03,     //!< line end code
+
+                                                //   0x04 .. 0x07 reserved
+
+    MIPI_DATA_TYPE_GSPC1            = 0x08,     //!< gerneric short packet code 1
+    MIPI_DATA_TYPE_GSPC2            = 0x09,     //!< gerneric short packet code 2
+    MIPI_DATA_TYPE_GSPC3            = 0x0A,     //!< gerneric short packet code 3
+    MIPI_DATA_TYPE_GSPC4            = 0x0B,     //!< gerneric short packet code 4
+    MIPI_DATA_TYPE_GSPC5            = 0x0C,     //!< gerneric short packet code 5
+    MIPI_DATA_TYPE_GSPC6            = 0x0D,     //!< gerneric short packet code 6
+    MIPI_DATA_TYPE_GSPC7            = 0x0E,     //!< gerneric short packet code 7
+    MIPI_DATA_TYPE_GSPC8            = 0x0F,     //!< gerneric short packet code 8
+
+    MIPI_DATA_TYPE_NULL             = 0x10,     //!< null
+    MIPI_DATA_TYPE_BLANKING         = 0x11,     //!< blanking data
+    MIPI_DATA_TYPE_EMBEDDED         = 0x12,     //!< embedded 8-bit non image data
+
+                                                //   0x13 .. 0x17 reserved
+
+    MIPI_DATA_TYPE_YUV420_8         = 0x18,     //!< YUV 420 8-Bit
+    MIPI_DATA_TYPE_YUV420_10        = 0x19,     //!< YUV 420 10-Bit
+    MIPI_DATA_TYPE_LEGACY_YUV420_8  = 0x1A,     //!< YUV 420 8-Bit
+                                                //   0x1B reserved
+    MIPI_DATA_TYPE_YUV420_8_CSPS    = 0x1C,     //!< YUV 420 8-Bit (chroma shifted pixel sampling)
+    MIPI_DATA_TYPE_YUV420_10_CSPS   = 0x1D,     //!< YUV 420 10-Bit (chroma shifted pixel sampling)
+    MIPI_DATA_TYPE_YUV422_8         = 0x1E,     //!< YUV 422 8-Bit
+    MIPI_DATA_TYPE_YUV422_10        = 0x1F,     //!< YUV 422 10-Bit
+
+    MIPI_DATA_TYPE_RGB444           = 0x20,     //!< RGB444
+    MIPI_DATA_TYPE_RGB555           = 0x21,     //!< RGB555
+    MIPI_DATA_TYPE_RGB565           = 0x22,     //!< RGB565
+    MIPI_DATA_TYPE_RGB666           = 0x23,     //!< RGB666
+    MIPI_DATA_TYPE_RGB888           = 0x24,     //!< RGB888
+
+                                                //   0x25 .. 0x27 reserved
+
+    MIPI_DATA_TYPE_RAW_6            = 0x28,     //!< RAW6
+    MIPI_DATA_TYPE_RAW_7            = 0x29,     //!< RAW7
+    MIPI_DATA_TYPE_RAW_8            = 0x2A,     //!< RAW8
+    MIPI_DATA_TYPE_RAW_10           = 0x2B,     //!< RAW10
+    MIPI_DATA_TYPE_RAW_12           = 0x2C,     //!< RAW12
+    MIPI_DATA_TYPE_RAW_14           = 0x2D,     //!< RAW14
+
+                                                //   0x2E .. 0x2F reserved
+
+    MIPI_DATA_TYPE_USER_1           = 0x30,     //!< user defined 1
+    MIPI_DATA_TYPE_USER_2           = 0x31,     //!< user defined 2
+    MIPI_DATA_TYPE_USER_3           = 0x32,     //!< user defined 3
+    MIPI_DATA_TYPE_USER_4           = 0x33,     //!< user defined 4
+    MIPI_DATA_TYPE_USER_5           = 0x34,     //!< user defined 5
+    MIPI_DATA_TYPE_USER_6           = 0x35,     //!< user defined 6
+    MIPI_DATA_TYPE_USER_7           = 0x36,     //!< user defined 7
+    MIPI_DATA_TYPE_USER_8           = 0x37,     //!< user defined 8
+
+    MIPI_DATA_TYPE_MAX
+} MipiDataType_t;
+
+
+/******************************************************************************/
+/**
+ * @brief MIPI compression schemes.
+ *
+ ******************************************************************************/
+typedef enum MipiDataCompressionScheme_e
+{
+    MIPI_DATA_COMPRESSION_SCHEME_NONE    = 0,   //!< NONE
+    MIPI_DATA_COMPRESSION_SCHEME_12_8_12 = 1,   //!< 12_8_12
+    MIPI_DATA_COMPRESSION_SCHEME_12_7_12 = 2,   //!< 12_7_12
+    MIPI_DATA_COMPRESSION_SCHEME_12_6_12 = 3,   //!< 12_6_12
+    MIPI_DATA_COMPRESSION_SCHEME_10_8_10 = 4,   //!< 10_8_10
+    MIPI_DATA_COMPRESSION_SCHEME_10_7_10 = 5,   //!< 10_7_10
+    MIPI_DATA_COMPRESSION_SCHEME_10_6_10 = 6,   //!< 10_6_10
+
+    MIPI_DATA_COMPRESSION_SCHEME_MAX
+} MipiDataCompressionScheme_t;
+
+
+/******************************************************************************/
+/**
+ * @brief MIPI predictor blocks.
+ *
+ ******************************************************************************/
+typedef enum MipiPredictorBlock_e
+{
+    MIPI_PREDICTOR_BLOCK_INVALID = 0,   //!< invalid
+
+    MIPI_PREDICTOR_BLOCK_1       = 1,   //!< Predictor1 (simple algorithm)
+    MIPI_PREDICTOR_BLOCK_2       = 2,   //!< Predictor2 (more complex algorithm)
+
+    MIPI_PREDICTOR_BLOCK_MAX
+} MipiPredictorBlock_t;
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* __MIPI_H__*/

+ 60 - 0
isp_isp8000l/units/common/misc.h

@@ -0,0 +1,60 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file misc.h
+ *
+ * @brief   Some often used little helpers; mainly implemented as macros.
+ *
+ *****************************************************************************/
+#ifndef __MISC_H__
+#define __MISC_H__
+
+/* beware of macro side effects! */
+
+#ifndef __FLT_EPSILON__
+#define __FLT_EPSILON__     0.000000119209289550781250000000
+#endif /* __FLT_EPSILON__ */
+
+#ifndef FLT_EPSILON
+#define FLT_EPSILON         __FLT_EPSILON__
+#endif /* FLT_EPSILON */
+
+#ifndef FLT_MAX
+#define FLT_MAX     ((float)3.40282346638528860e+38)
+#endif /* FLT_MAX */
+
+#ifndef MIN
+#define MIN(a, b)   ( ((a)<(b)) ? (a) : (b) )
+#endif /* MIN */
+
+#ifndef MAX
+#define MAX(a, b)   ( ((a)>(b)) ? (a) : (b) )
+#endif /* MAX */
+
+#ifndef ABS
+#define ABS(a)      ( ((a)<0) ? -(a) : (a) )
+#endif /*ABS */
+
+#ifndef SIGN
+#define SIGN(a)     ( ((a)<0) ? -1 : ((a)>0) ? 1 : 0 )
+#endif /* SIGN */
+
+#ifndef ROUND_UP
+#define ROUND_UP(a, b) ((a + b - 1) / b * b)
+#endif
+
+#endif /* __MISC_H__ */

+ 84 - 0
isp_isp8000l/units/common/picture_buffer.h

@@ -0,0 +1,84 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file    picture_buffer.h
+ *
+ * @brief   Defines picture buffer meta data structure including its components
+ *          and helper functions around that structure.
+ *
+ *****************************************************************************/
+/**
+ * @page module_name_page Module Name
+ * Describe here what this module does.
+ *
+ * For a detailed list of functions and implementation detail refer to:
+ * - @ref module_name
+ *
+ * @defgroup picture_buffer Picture buffer descriptor
+ * @{
+ *
+ */
+#ifndef __PICTURE_BUFFER_H__
+#define __PICTURE_BUFFER_H__
+
+#include <ebase/types.h>
+#include <scmi/scmi_types.h>
+#include <common/return_codes.h>
+#include <cam_device/cam_device_buf_defs.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/* input and output buffer macro define, default disable. */
+#define ENABLE_BUFFER_DUMP 0
+
+
+
+/*****************************************************************************/
+/**
+ *          PicBufIsConfigValid()
+ *
+ * @brief   Check the given picture buffer meta data structure for valid
+ *          type & layout combination.
+ *
+ * @param   Reference to picture buffer meta data structure.
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS     type & layout combination is valid
+ * @retval  RET_NOTSUPP     type & layout combination is invalid
+ * @retval  RET_OUTOFRANGE  invalid type and/or layout
+ *
+ *****************************************************************************/
+extern RESULT PicBufIsConfigValid
+(
+    PicBufMetaData_t *pPicBufMetaData
+);
+
+extern RESULT PicBufDump
+(
+    PicBufMetaData_t *pPicBuffer,
+    const uint8_t *logical,
+    bool_t inputSource
+);
+
+/* @} picture_buffer */
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* __PICTURE_BUFFER_H__ */

+ 52 - 0
isp_isp8000l/units/common/return_codes.h

@@ -0,0 +1,52 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file return_codes.h
+ *
+ * @brief
+ *   This header files contains general return codes .
+ *
+ *****************************************************************************/
+#ifndef __RETURN_CODES_H__
+#define __RETURN_CODES_H__
+
+typedef int RESULT;
+
+#define RET_SUCCESS             0   //!< this has to be 0, if clauses rely on it
+#define RET_FAILURE             1   //!< general failure
+#define RET_NOTSUPP             2   //!< feature not supported
+#define RET_BUSY                3   //!< there's already something going on...
+#define RET_CANCELED            4   //!< operation canceled
+#define RET_OUTOFMEM            5   //!< out of memory
+#define RET_OUTOFRANGE          6   //!< parameter/value out of range
+#define RET_IDLE                7   //!< feature/subsystem is in idle state
+#define RET_WRONG_HANDLE        8   //!< handle is wrong
+#define RET_NULL_POINTER        9   //!< the/one/all parameter(s) is a(are) NULL pointer(s)
+#define RET_NOTAVAILABLE       10   //!< profile not available
+#define RET_DIVISION_BY_ZERO   11   //!< a divisor equals ZERO
+#define RET_WRONG_STATE        12   //!< state machine in wrong state
+#define RET_INVALID_PARM       13   //!< invalid parameter
+#define RET_PENDING            14   //!< command pending
+#define RET_WRONG_CONFIG       15   //!< given configuration is invalid
+
+
+#define UPDATE_RESULT( cur_res, new_res ) { RESULT __lres__ = (new_res); if (cur_res == RET_SUCCESS) cur_res = __lres__; } //!< Keeps first non-success result; cur_res must be a modifiable L-value; new_res can be any type of R-value including function call.
+
+#define RETURN_RESULT_IF_DIFFERENT( cur_res, exp_res ) if ( exp_res != cur_res ) { return ( cur_res ); }
+
+#endif /* __RETURN_CODES_H__ */
+

+ 92 - 0
isp_isp8000l/units/common/utl_fixfloat.h

@@ -0,0 +1,92 @@
+/******************************************************************************\
+|* Copyright (c) <2010> by Silicon Image, Inc., used with permission by       *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/*!
+ *  @file        utl_fixfloat.h
+ *  @version     1.0
+ *  @author      Neugebauer
+ *  @brief       Floatingpoint to Fixpoint and vice versa conversion
+ *               routines.
+ */
+
+
+#ifndef __UTL_FIXFLOAT_H__
+#define __UTL_FIXFLOAT_H__
+
+/*****************************************************************************
+ * Prototypes
+ *****************************************************************************/
+
+uint32_t UtlFloatToFix_U0107( float fFloat );
+float  UtlFixToFloat_U0107( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_U0208( float fFloat );
+float  UtlFixToFloat_U0208( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_U0408( float fFloat );
+float  UtlFixToFloat_U0408( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_U0800( float fFloat );
+float  UtlFixToFloat_U0800( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_U1000( float fFloat );
+float  UtlFixToFloat_U1000( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_U1200( float fFloat );
+float  UtlFixToFloat_U1200( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_U0010( float fFloat );
+float  UtlFixToFloat_U0010( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0207( float fFloat );
+float  UtlFixToFloat_S0207( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0307( float fFloat );
+float  UtlFixToFloat_S0307( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0407( float fFloat );
+float  UtlFixToFloat_S0407( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0504( float fFloat );
+float  UtlFixToFloat_S0504( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0808( float fFloat );
+float  UtlFixToFloat_S0808( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0800( float fFloat );
+float  UtlFixToFloat_S0800( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0900( float fFloat );
+float  UtlFixToFloat_S0900( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S1200( float fFloat );
+float  UtlFixToFloat_S1200( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0109( float fFloat );
+float UtlFixToFloat_S0109( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0408( float fFloat );
+float UtlFixToFloat_S0408( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0108( float fFloat );
+float UtlFixToFloat_S0108( uint32_t ulFix );
+
+uint32_t UtlFloatToFix_S0110( float fFloat );
+float UtlFixToFloat_S0110( uint32_t ulFix );
+uint32_t UtlValueMap( uint32_t value, uint32_t sLower, uint32_t sUpper, uint32_t dLower, uint32_t dUpper);
+
+#endif /* __UTL_FIXfloat_H__ */
+

+ 46 - 0
isp_isp8000l/units/ebase/builtins.h

@@ -0,0 +1,46 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ *   @file builtins.h
+ *
+ *	This file defines some macros for standard library functions. Usually we
+ *	dont link against glibc, so we use the builtins. Standard library function
+ *	calls are only permitted in debug mode.
+ *
+ *****************************************************************************/
+#ifndef BUILTINS_H_
+#define BUILTINS_H_
+
+#include "types.h"
+
+#if defined(__GNUC__)
+	#include <stddef.h>
+
+	void* __builtin_memset( void* s, int32_t c, size_t n );
+	#define MEMSET(	TARGET, C, LEN)	__builtin_memset(TARGET, C, LEN)
+
+	void* __builtin_memcpy( void* s1, const void* s2, size_t n);
+	#define MEMCPY( DST, SRC, LEN)	__builtin_memcpy(DST,SRC,LEN)
+#else
+	#include <string.h>
+	#define MEMSET(	TARGET, C, LEN)	memset(TARGET,C,LEN)
+	#define MEMCPY( DST, SRC, LEN)	memcpy(DST,SRC,LEN)
+#endif
+
+#define WIPEOBJ( TARGET ) MEMSET( &TARGET, 0, sizeof( TARGET ) )
+
+#endif /*BUILTINS_H_*/

+ 94 - 0
isp_isp8000l/units/ebase/dct_assert.h

@@ -0,0 +1,94 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ *   @file dct_assert.h
+ *
+ *  This file defines the API for the assertion facility of the embedded lib.
+ *
+ *****************************************************************************/
+/*****************************************************************************/
+/**
+ * @defgroup module_assert Assert macros
+ *
+ * @brief The assertion system used by Dream Chip.
+ *
+ * Example use of the assert system:
+ *
+ *
+ * - In your source file just use the macro
+ *
+ * @code
+ * void foo( uint8_t* pData, size_t size)
+ * {
+ *     DCT_ASSERT(pData != NULL);
+ *     DCT_ASSERT(size > 0);
+ * }
+ * @endcode
+ *
+ * @{
+ *
+ *****************************************************************************/
+#ifndef ASSERT_H_
+#define ASSERT_H_
+#include <cam_device/cam_dct_assert.h>
+
+/**
+ * @brief   The type of the assert handler. @see assert_handler
+ *
+ *****************************************************************************/
+typedef void (*ASSERT_HANDLER)(void) __attribute__((noreturn));
+
+
+/**
+ *          The assert handler is a function that is called in case an
+ *          assertion failed. If no handler is registered, which is the
+ *          default, exit() is called.
+ *
+ *****************************************************************************/
+extern ASSERT_HANDLER   assert_handler;
+
+#if defined(ENABLE_ASSERT) || !defined(NDEBUG)
+    /**
+     *              Dump information on stderr and exit.
+     *
+     *  @param      file  Filename where assertion occured.
+     *  @param      line  Linenumber where assertion occured.
+     *
+     *****************************************************************************/
+#ifdef __cplusplus
+     extern "C"
+#endif
+    void exit_(const char *file, int line) __attribute__((noreturn));
+
+    /**
+     *              The assert macro.
+     *
+     *  @param      exp Expression which assumed to be true.
+     *
+     *****************************************************************************/
+    #define DCT_ASSERT(exp) do { if (!(exp)){ static CHAR filename[] = __FILE__; exit_(&filename[0], __LINE__);}}while(0)
+#else
+    #define DCT_ASSERT(exp)\
+    do {\
+        if ((exp)) {\
+        }\
+    } while(0)
+#endif
+
+/* @} module_tracer*/
+
+#endif /*ASSERT_H_*/

+ 10 - 0
isp_isp8000l/units/ebase/ext_types.h

@@ -0,0 +1,10 @@
+
+
+#ifndef __EXT_TYPES_H__
+#define __EXT_TYPES_H__
+
+typedef void     (*GFunc)          (void* data, void* user_data);
+typedef int32_t     (*GCompareFunc)   (const void* a, const void* b);
+typedef int32_t     (*GCompareDataFunc) (const void* a, const void* b, void* user_data);
+
+#endif /* __EXT_TYPES_H__ */

+ 42 - 0
isp_isp8000l/units/ebase/linux_compat.h

@@ -0,0 +1,42 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file linux_compat.h
+ *
+ * @brief
+ *   Linux compatibility layer.
+ *
+ *****************************************************************************/
+#ifndef LINUX_COMPAT_H_
+#define LINUX_COMPAT_H_
+
+/***** macro definitions *****************************************************/
+
+#   ifdef __cplusplus
+#       include <cstdio>
+#       include <cstdlib>
+#   else
+#       include <stdio.h>
+#       include <stdlib.h>
+#   endif
+
+/***** public type definitions ***********************************************/
+
+/***** public function prototypes ********************************************/
+
+#endif /* LINUX_COMPAT_H_ */
+

+ 357 - 0
isp_isp8000l/units/ebase/list.h

@@ -0,0 +1,357 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file list.h
+ *
+ * @brief
+ *   Extended data types: Linked list
+ *
+ *****************************************************************************/
+/**
+ * @defgroup module_ext_list Double Linked List
+ *
+ * @brief This module implements a "Double Linked List"
+ *
+ * @{
+ *
+ *****************************************************************************/
+#ifndef __LIST_H__
+#define __LIST_H__
+
+#include "types.h"
+#include "ext_types.h"
+
+
+typedef struct _GList GList;
+
+/**
+ * @brief Structure that represents an element in the list.
+ */
+struct _GList {
+  void* data;       /**< Pointer to object using the list for */
+  GList *next;      /**< Pointer to next element in list */
+  GList *prev;      /**< Pointer to prev element in list */
+};
+
+
+#define listNext(list) ((list) ? (((GList *) (list))->next) : NULL)
+#define listPrevious(list) ((list) ? (((GList *) (list))->prev) : NULL)
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listAlloc(void);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listAppend(GList* list, void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listPrepend(GList* list, void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void listFree(GList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void listFree1(GList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listCopy(GList*  list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+uint32_t listLength(GList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+int32_t listIndex(GList* list, const void*  data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listNth(GList * list, uint32_t n);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void* listNthData(GList* list, uint32_t n);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listLast(GList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listConcat(GList* list1, GList* list2);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void listForeach(GList* list, GFunc func, void* user_data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listFirst(GList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listFind(GList* list,const void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listFindCustom(GList* list,const void* data, GCompareFunc func);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listRemove(GList* list,const void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listReverse(GList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listRemoveLink(GList* list, GList* link);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listDeleteLink(GList* list, GList* link);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listInsertSorted(GList* list, void* data, GCompareFunc func);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listInsertBefore(GList* list, GList* sibling, void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GList* listSort(GList* sort, GCompareFunc func);
+
+/* @} module_ext_list */
+
+#endif /* __LIST_H__ */
+
+

+ 112 - 0
isp_isp8000l/units/ebase/queue.h

@@ -0,0 +1,112 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file queue.h
+ *
+ * @brief
+ *   Extended data types: Queue
+ *
+ *****************************************************************************/
+/**
+ * @defgroup module_ext_queue Queue
+ *
+ * @{
+ *
+ *****************************************************************************/
+#ifndef __QUEUE_H__
+#define __QUEUE_H__
+
+#include "types.h"
+#include "ext_types.h"
+#include "list.h"
+
+
+/**
+ * @brief Structure that represents an element in the queue.
+ */
+typedef struct
+{
+    GList *head;        /**< Head element of queue */
+    GList *tail;        /**< Tail  element of queue  */
+    uint32_t length;    /**< Length  of queue  */
+} GQueue;
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void* queuePopHead(GQueue* queue);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void queuePushHead(GQueue* queue, void* data);
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+bool_t queueIsEmpty(GQueue* queue);
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GQueue* queueNew(void);
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void queueFree(GQueue* queue);
+
+/* @} module_ext_queue */
+
+#endif /* __QUEUE_H__ */

+ 353 - 0
isp_isp8000l/units/ebase/slist.h

@@ -0,0 +1,353 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file slist.h
+ *
+ * @brief
+ *   Extended data types: Linked list
+ *
+ *****************************************************************************/
+/**
+ * @defgroup module_ext_slist Linked List
+ *
+ * @brief This module implements a "Single Linked List".
+ *
+ * @{
+ *
+ *****************************************************************************/
+#ifndef __SLIST_H__
+#define __SLIST_H__
+
+#include "types.h"
+#include "ext_types.h"
+
+
+typedef struct _GSList GSList;
+
+/**
+ * @brief Structure that represents an element in the list.
+ */
+struct _GSList {
+    void* data;     /**< Pointer to object using the list for */
+    GSList *next;   /**< Pointer to next element in list */
+};
+
+
+#define slistNext(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistAlloc(void);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistAppend(GSList* list, void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistPrepend(GSList* list, void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void slistFree(GSList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void slistFree1(GSList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistCopy(GSList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistConcat(GSList* list1, GSList* list2);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void slistForeach(GSList* list, GFunc func, void* user_data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistLast(GSList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistFind(GSList* list, const void*  data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistFindCustom(GSList* list, const void*  data, GCompareFunc func);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistRemove(GSList* list, const void*  data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistRemoveAll(GSList* list, const void*  data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistReverse(GSList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+uint32_t slistLength(GSList* list);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistRemoveLink(GSList* list, GSList* link);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistDeleteLink(GSList* list, GSList* link);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistInsertSorted(GSList* list, void* data, GCompareFunc func);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistInsertBefore(GSList* list, GSList* sibling, void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList* slistSort(GSList* list, GCompareFunc func);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+int32_t slistIndex(GSList* list, const void* data);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+GSList *slistNth(GSList* list, uint32_t n);
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ *
+ * @param
+ *
+ * @return
+ * @retval
+ *
+ *****************************************************************************/
+void* slistNthData(GSList* list, uint32_t n);
+
+/* @} module_ext_slist */
+
+#endif /* __SLIST_H__ */

+ 187 - 0
isp_isp8000l/units/ebase/sort.frag.h

@@ -0,0 +1,187 @@
+/*
+ * sort.frag.h: Common implementation of linked-list sorting
+ *
+ * Author:
+ *   Raja R Harinath (rharinath@novell.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * (C) 2006 Novell, Inc.
+ */
+#ifndef __SORT_FRAG_H__
+#define __SORT_FRAG_H__
+
+/*
+ * This code requires a typedef named 'list_node' for the list node.  It
+ * is assumed that the list type is the type of a pointer to a list
+ * node, and that the node has a field named 'next' that implements to
+ * the linked list.  No additional invariant is maintained (e.g. the
+ * 'prev' pointer of a doubly-linked list node is _not_ updated).  Any
+ * invariant would require a post-processing pass to fix matters if
+ * necessary.
+ */
+typedef list_node *digit;
+
+/*
+ * The maximum possible depth of the merge tree
+ *   = ceiling (log2 (maximum number of list nodes))
+ *   = ceiling (log2 (maximum possible memory size/size of each list node))
+ *   = number of bits in 'size_t' - floor (log2 (sizeof digit))
+ * Also, each list in sort_info is at least 2 nodes long: we can reduce the depth by 1
+ */
+#define FLOOR_LOG2(x) (((x)>=2) + ((x)>=4) + ((x)>=8) + ((x)>=16) + ((x)>=32) + ((x)>=64) + ((x)>=128))
+#define MAX_RANKS ((sizeof (size_t) * 8) - FLOOR_LOG2(sizeof (list_node)) - 1)
+
+struct sort_info
+{
+	int min_rank, n_ranks;
+	GCompareFunc func;
+
+	/* Invariant: ranks[i] == NULL || length(ranks[i]) >= 2**(i+1) */
+	list_node *ranks [MAX_RANKS]; /* ~ 128 bytes on 32bit, ~ 512 bytes on 64bit */
+};
+
+static inline void
+init_sort_info (struct sort_info *si, GCompareFunc func)
+{
+	si->min_rank = si->n_ranks = 0;
+	si->func = func;
+	/* we don't need to initialize si->ranks, since we never lookup past si->n_ranks.  */
+}
+
+static inline list_node *
+merge_lists (list_node *first, list_node *second, GCompareFunc func)
+{
+	/* merge the two lists */
+	list_node *list = NULL;
+	list_node **pos = &list;
+	while (first && second) {
+		if (func (first->data, second->data) > 0) {
+			*pos = second;
+			second = second->next;
+		} else {
+			*pos = first;
+			first = first->next;
+		}
+		pos = &((*pos)->next);
+	}
+	*pos = first ? first : second;
+	return list;
+}
+
+/* Pre-condition: upto <= si->n_ranks, list == NULL || length(list) == 1 */
+static inline list_node *
+sweep_up (struct sort_info *si, list_node *list, int upto)
+{
+	int i;
+	for (i = si->min_rank; i < upto; ++i) {
+		list = merge_lists (si->ranks [i], list, si->func);
+		si->ranks [i] = NULL;
+	}
+	return list;
+}
+
+/*
+ * The 'ranks' array essentially captures the recursion stack of a mergesort.
+ * The merge tree is built in a bottom-up manner.  The control loop for
+ * updating the 'ranks' array is analogous to incrementing a binary integer,
+ * and the O(n) time for counting upto n translates to O(n) merges when
+ * inserting rank-0 lists.  When we plug in the sizes of the lists involved in
+ * those merges, we get the O(n log n) time for the sort.
+ *
+ * Inserting higher-ranked lists reduce the height of the merge tree, and also
+ * eliminate a lot of redundant comparisons when merging two lists that would've
+ * been part of the same run.  Adding a rank-i list is analogous to incrementing
+ * a binary integer by 2**i in one operation, thus sharing a similar speedup.
+ *
+ * When inserting higher-ranked lists, we choose to clear out the lower ranks
+ * in the interests of keeping the sort stable, but this makes analysis harder.
+ * Note that clearing the lower-ranked lists is O(length(list))-- thus it
+ * shouldn't affect the O(n log n) behaviour.  IOW, inserting one rank-i list
+ * is equivalent to inserting 2**i rank-0 lists, thus even if we do i additional
+ * merges in the clearing-out (taking at most 2**i time) we are still fine.
+ */
+
+#define stringify2(x) #x
+#define stringify(x) stringify2(x)
+
+/* Pre-condition: 2**(rank+1) <= length(list) < 2**(rank+2) (therefore: length(list) >= 2) */
+static inline void
+insert_list (struct sort_info *si, list_node* list, int rank)
+{
+	int32_t i;
+
+	if (rank > si->n_ranks) {
+		if (rank > (int32_t)MAX_RANKS) {
+			rank = MAX_RANKS;
+		}
+		list = merge_lists (sweep_up (si, NULL, si->n_ranks), list, si->func);
+		for (i = si->n_ranks; i < rank; ++i)
+			si->ranks [i] = NULL;
+	} else {
+		if (rank)
+			list = merge_lists (sweep_up (si, NULL, rank), list, si->func);
+		for (i = rank; i < si->n_ranks && si->ranks [i]; ++i) {
+			list = merge_lists (si->ranks [i], list, si->func);
+			si->ranks [i] = NULL;
+		}
+	}
+
+	if (i == MAX_RANKS) /* Will _never_ happen: so we can just devolve into quadratic ;-) */
+		--i;
+	if (i >= si->n_ranks)
+		si->n_ranks = i + 1;
+	si->min_rank = i;
+	si->ranks [i] = list;
+}
+
+#undef stringify2
+#undef stringify
+#undef MAX_RANKS
+#undef FLOOR_LOG2
+
+/* A non-recursive mergesort */
+static inline digit
+do_sort (list_node* list, GCompareFunc func)
+{
+	struct sort_info si;
+
+	init_sort_info (&si, func);
+
+	while (list && list->next) {
+		list_node* next = list->next;
+		list_node* tail = next->next;
+
+		if (func (list->data, next->data) > 0) {
+			next->next = list;
+			next = list;
+			list = list->next;
+		}
+		next->next = NULL;
+
+		insert_list (&si, list, 0);
+
+		list = tail;
+	}
+
+	return sweep_up (&si, list, si.n_ranks);
+}
+
+#endif /* __SORT_FRAG_H__ */

+ 286 - 0
isp_isp8000l/units/ebase/trace.h

@@ -0,0 +1,286 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ *   @file trace.h
+ *
+ *   This file defines the API for the tracing facility of the embedded lib.
+ *
+ *   WARNING:    Due to use of variadic macros which were introduced into C in
+ *               c99 this can not be used with c++ code in pedantic mode.
+ *
+ *****************************************************************************/
+/**
+ * @defgroup module_tracer Trace System
+ *
+ * @brief The trace system used by Dream Chip.
+ *
+ * Example use of the trace system:
+ *
+ * - Create a file like tracer_cfg.c
+ *
+ * @code
+ * CREATE_TRACER(MODULE_INFO,       "ModInfo:   ", INFO,    1);
+ * CREATE_TRACER(MODULE_WARNING,    "ModWarn:   ", WARNING, 1);
+ * CREATE_TRACER(MODULE_ERROR,      "ModError:  ", ERROR,   1);
+ * @endcode
+ *
+ * - In your source file import the tracer you like to use
+ *
+ * @code
+ * USE_TRACER(MODULE_INFO);
+ * USE_TRACER(MODULE_WARNING);
+ * USE_TRACER(MODULE_ERROR);
+ *
+ * void foo()
+ * {
+ *     TRACE(MODULE_INFO, "enter %s\n", __FUNCTION);
+ *     TRACE(MODULE_INFO, "leave %s\n", __FUNCTION);
+ * }
+ * @endcode
+ *
+ * @{
+ *
+ *****************************************************************************/
+#ifndef TRACE_H_
+#define TRACE_H_
+
+/* must be defined even for release */
+#include "linux_compat.h"
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifdef ERROR
+#undef ERROR
+#endif
+
+enum
+{
+    TRACE_OFF   = 0x00,
+    INFO        = 0x01,
+    DBG     = 0x02,
+    WARNING     = 0x04,
+    ERROR       = 0x08,
+    MAX_LEVEL   = (0x01U | 0x02U | 0x04U | 0x08U)
+};
+
+typedef struct tracer_s
+{
+    FILE*               fp;
+    char_t*             prefix;
+    int16_t             level;
+    int8_t              enabled;
+    int8_t              linked;
+    char_t*             name;
+    struct tracer_s*    next;
+} Tracer;
+
+#ifndef NDEBUG
+	int getTraceLevel(void);
+    void setTraceLevel(int);
+    void enableTracer(Tracer *);
+    void disableTracer(Tracer *);
+    void setTracerFile(Tracer *, FILE *);
+    void flushTracer(const Tracer *);
+    void trace(Tracer*, const CHAR*, ...);
+    Tracer* getTracerList(void);
+
+#if !defined(USE_SDRAM_FOR_TRACE)
+#define TRACER_DATA
+#else
+#define TRACER_DATA  DRAM_DATA
+#endif
+    /**
+     *
+     *          This macro creates a Tracer. Every Tracer has its own output like
+     *          stdout or a file and a trace level associated. A tracer may be
+     *          enabled and disabled. If the global trace level is lower than the
+     *          Tracers level, than output send to an enabled tracer is output to
+     *          its file or stdout. If eg the global trace level is INFO and the
+     *          Tracer has the level WARNING, its output is active. If the global
+     *          trace level were ERROR instead, output of the tracer were
+     *          suppressed.
+     *
+     *          \warning THIS MACRO MUST BE USED IN GLOBAL SCOPE.
+     *
+     *
+     *  @param    name          Name of the tracer.
+     *  @param    arg_prefix    All output of this tracer is preceeded by
+     *                          <arg_prefix>.
+     *  @param    arg_level     Initial trace level.
+     *  @param    arg_enabled   Decide wether the tracer starts in enabled state.
+     *
+     *  @return   No return value.
+     *
+     *****************************************************************************/
+#define CREATE_TRACER(name, arg_prefix, arg_level, arg_enabled) \
+        CHAR tracerName##name[] TRACER_DATA = #name; \
+        CHAR tracerPrefix##name[] TRACER_DATA = arg_prefix; \
+        Tracer instance__##name TRACER_DATA =   \
+        {                                       \
+            0,                                  \
+            &tracerPrefix##name[0],             \
+            arg_level,                          \
+            arg_enabled,                        \
+            0,                                  \
+            &tracerName##name[0],               \
+            NULL                                \
+        };                                      \
+        Tracer *name = &instance__##name
+
+    /**
+     *
+     *              If tracer was created in another compile unit this macro
+     *              makes the named tracer available in the current unit.
+     *
+     *  @param      ...     First parameter is name of tracer.Use variable argument
+     *                      list like printf.
+     *  @return     No return value.
+     *
+     *****************************************************************************/
+#define USE_TRACER(name)\
+        extern Tracer *name
+
+    /**
+     *
+     *              Send output to a tracer.
+     *
+     *  @param      ...     First parameter is name of tracer.Use variable argument
+     *                      list like printf.
+     *  @return             No return value.
+     *
+     *****************************************************************************/
+#define TRACE(...) trace(__VA_ARGS__)
+
+    /**
+     *
+     *              Send output to a tracer, If DEBUG_LEVEL if high enough
+     *
+     *  @param      ...     First parameter is the required DEBUG_LEVEL to get the
+	 *                      output, second parameter is name of tracer. Use variable argument
+     *                      list like printf.
+     *  @return             No return value.
+     *
+     *****************************************************************************/
+#if defined (DEBUG_LEVEL)
+#define DL_TRACE(level, ...) if (DEBUG_LEVEL >= level) { trace(__VA_ARGS__); }
+#else
+#define DL_TRACE(level, ...) (void)0
+#endif
+
+    /**
+     *
+     *              Enable a tracer.
+     *
+     *  @param      T   name of tracer.
+     *  @return     No return value.
+     *
+     *****************************************************************************/
+#define ENABLE_TRACER(T) enableTracer(T)
+
+    /**
+     *
+     *              Disable a tracer.
+     *
+     *  @param      T   name of tracer.
+     *  @return     No return value.
+     *
+     *****************************************************************************/
+#define DISABLE_TRACER(T) disableTracer(T)
+
+    /**
+     *
+     *              Set the global trace level.
+     *
+     *  @param      L   Trace level.
+     *  @return     No return value.
+     *
+     *****************************************************************************/
+#define SET_TRACE_LEVEL(L) setTraceLevel(L)
+
+    /**
+     *
+     *              Init the global trace level.
+     *
+     *  @param      L   Trace level.
+     *  @return     No return value.
+     *
+     *****************************************************************************/
+#define INIT_TRACE_LEVEL() initTraceLevel()
+
+    /**
+     *
+     *              Redirect a tracer to a file.
+     *
+     *  @param      T   name of tracer.
+     *  @param      F   A valid FILE*.
+     *
+     *  @return     No return value.
+     *
+     *****************************************************************************/
+#define SET_TRACER_FILE(T, F) setTracerFile(T, F)
+
+    /**
+     *
+     *              Flush a tracer.
+     *
+     *  @param      T   name of tracer.
+     *
+     *  @return     No return value.
+     *
+     *****************************************************************************/
+#define FLUSH_TRACER(T)		flushTracer(T)
+#define GET_TRACE_LEVEL()   getTraceLevel()
+#define GET_TRACER_LIST()   getTracerList()
+
+/* this macro can be used to define statements or variables which are only
+ * active if NDEBUG is not defined:
+ */
+#define IF_TRACE_ON(x)              x
+#else
+    /* The macro for CREATE_TRACER can not just expand to nothing. Otherwise we
+    * would have a single semicolon which C does not allow outside of function
+    * bodies. For this reason we expand to this extern declaration. As the
+    * external variable is never used linking should not be a problem. */
+#define CREATE_TRACER(name, arg_prefix, arg_level, arg_enabled) extern int32_t name
+#define USE_TRACER(name)            extern int32_t use##name
+#define TRACE(...)                  (void)0
+#define DL_TRACE(level, ...)		(void)0
+#define ENABLE_TRACER(T)            (void)0
+#define DISABLE_TRACER(T)           (void)0
+#define SET_TRACE_LEVEL(L)          (void)0
+#define SET_TRACER_FILE(T, F)       (void)0
+#define FLUSH_TRACER(T)             (void)0
+#define GET_TRACE_LEVEL()           (void)0
+#define GET_TRACER_LIST()           (void)0
+
+/* this macro can be used to define statements or variables which are only
+ * active if NDEBUG is not defined:
+ */
+#define IF_TRACE_ON(x)
+#endif /* NDEBUG */
+
+#ifdef __cplusplus
+}
+#endif
+
+/* @} module_tracer*/
+
+#endif /*TRACE_H_*/

+ 110 - 0
isp_isp8000l/units/ebase/types.h

@@ -0,0 +1,110 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ *   @file types.h
+ *
+ *  This file defines some basic type names like the int types.
+ *
+ *****************************************************************************/
+#ifndef TYPES_H_
+#define TYPES_H_
+
+#include "linux_compat.h"
+#include <limits.h>
+
+#ifndef __cplusplus
+    /* Only C99 compilers know stdbool */
+    #if (__STDC_VERSION__ >= 199901L) || defined(CONFIG_HAVE_STDBOOL)
+        #include <stdbool.h>
+    #else
+        #define bool    unsigned int
+        #define true    (1)
+        #define false   (0)
+    #endif
+#endif
+
+
+#if defined(__GNUC__)
+    #if !defined(INLINE)
+        #define INLINE static inline
+    #endif
+#endif
+
+#include <stddef.h>
+
+#if defined(__cplusplus) || ((__STDC_VERSION__ >= 199901L))
+    #include <stdint.h>
+#else
+
+    /* We only check for __int8_t_defined */
+    /* as this is all that gcc defines. */
+    #if !defined(__int8_t_defined)
+
+        /* In the rare cases that a system does not define
+         * __int8_t_defined (Android p.e.) we check for the
+         * include guard of the stdint header */
+        #if !defined(_STDINT_H)
+
+                typedef unsigned char        uint8_t;
+                typedef signed   char        int8_t;
+                typedef unsigned short       uint16_t;
+                typedef          short       int16_t;
+                typedef unsigned int         uint32_t;
+                typedef          int         int32_t;
+
+            #if !defined(_MSC_VER)
+                        typedef signed   long long  int64_t;
+                        typedef unsigned long long  uint64_t;
+            #else
+                        typedef signed   __int64    int64_t;
+                        typedef unsigned __int64    uint64_t;
+            #endif /* #if !defined(_MSC_VER) */
+
+                typedef unsigned int   uint_least32_t;
+                typedef          int   int_least32_t;
+                typedef unsigned int   uint_least8_t;
+                typedef unsigned int   uint;
+                typedef unsigned char  uchar;
+
+        #endif /* #if !defined(_STDINT_H) */
+    #endif /* #if !defined(__int8_t_defined) */
+#endif /* #if defined(__cplusplus) || ((__STDC_VERSION__ >= 199901L)) */
+
+#ifndef NULL
+    #define NULL ((void*)0)
+#endif
+
+/* make lint happy: */
+typedef char CHAR;
+typedef char char_t;    /* like suggested in  Misra 6.3 (P. 29) */
+
+typedef enum
+{
+    BOOL_FALSE = 0,
+    BOOL_TRUE = (!BOOL_FALSE)
+} bool_t;
+
+
+#define UNUSED_PARAM(unref_param)  ((void) (unref_param));
+#define CAST_POINTER_TO_UINT32( pointer ) ((uint32_t) (pointer))
+#define CAST_POINTER_TO_INT32( pointer ) ((int32_t) (pointer))
+#define CAST_UINT32_TO_POINTER( pointerType, value ) ((pointerType)(value))
+#define CAST_INT32_TO_POINTER( value ) ((int32_t*)(value))
+#define N_ELEMENTS(s)      (sizeof(s) / sizeof ((s) [0]))
+#define ABS(a)         ((a) > 0 ? (a) : -(a))
+
+#endif /*TYPES_H_*/

+ 304 - 0
isp_isp8000l/units/fpga/altera_fpga.h

@@ -0,0 +1,304 @@
+/*******************************************************************************/
+/*! This is an unpublished work, the copyright in which vests in sci-worx GmbH.
+*   The information contained herein is the property of sci-worx GmbH and is
+*   supplied without liability for errors or omissions. No part may be repro-
+*   duced or used except as authorized by contract or other written permission.
+*   Copyright(c) sci-worx GmbH, 2007. All rights reserved.
+*/
+/******************************************************************************/
+/*! Module    : Altera driver
+*
+* Hierarchy :
+*
+* Purpose   : User-level driver for the Altera FPGA board
+*
+* Creator   : Martin Fiedler
+*/
+/******************************************************************************/
+/**
+ *  @file altera_fpga.h
+ *  @brief User-level driver for the Altera FPGA board
+ */
+
+#ifndef _ALTERA_FPGA_H
+#define _ALTERA_FPGA_H
+
+#include <hal/hal_common.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Register access mode switch.
+  * If set to zero (0), each register access will be done with a "DoMem" ioctl()
+  * call to the driver.
+  * If set to one (1), all registers will be memory-mapped and accessed directly. */
+#define FPGA_USE_MMAP  0
+
+#define FPGA_BOARD_NUM           0           /**< board (DMA engine) number */
+
+#define FPGA_REG_BAR_NUM         1           /**< PCI BAR for register access */
+
+#define FPGA_REGISTER_SPACE_SIZE (512*1024)  /**< size of register BAR */
+
+// these mainly influence byte reordering stuff in AlteraFPGABoard_DMARead/Write functions
+// use AlteraFPGABoard_RawDMARead/Write functions to avoid byte reordering & stuff
+#define FPGA_DATA_ITEM_SIZE     8
+#define FPGA_DATA_BLOCK_SIZE    8
+#define FPGA_DATA_BLOCK_STRIDE  8
+
+#define FPGA_DMA_ALIGNMENT       (4*1024)    /**< DMA helper buffer alignment (*must* be a power of two!); used by AlteraFPGABoard_DMARead/Write functions only */
+#define FPGA_DMA_SIZE_ALIGNMENT  32          /**< DMA transfer size alignment (*must* be a power of two!); used by AlteraFPGABoard_DMARead/Write functions only */
+
+#define FPGA_DMA_BLOCK_SIZE      (1024*1024) /**< DMA max block size */
+
+#define FPGA_IRQ_POLL_INTERVAL   1000 //20 //50 //20          /**< interrupt poll interval in microseconds */
+//#define FPGA_IRQ_POLL_INTERVAL   30000 //50 //20          /**< interrupt poll interval in microseconds */
+
+/** Address adjustment macro.
+  * Internally, the driver operates with DWORD (32-bit aligned) adresses. On the
+  * FPGA, however, adresses are 128-bit aligned, creating a gap of 3 unused DWORDs
+  * between each consecutive pair of registers. To compensate for that, register
+  * addresses need to be shifted two bits to the left before using them as FPGA
+  * (PCI BAR) addresses. */
+#if 0
+#define FPGA_REG_ADDRESS_MOD(x) ((x) << 2)
+#else
+#define FPGA_REG_ADDRESS_MOD(x) (x)
+#endif
+
+
+/* PLL config type. */
+typedef struct _AlteraFPGAPLLConfig {
+    uint32_t Fin;
+    uint16_t M;
+    uint16_t N;
+    uint16_t C[10];
+} AlteraFPGAPLLConfig_t;
+
+/* PLL type. */
+typedef struct _AlteraFPGAPLL {
+    uint32_t reg_offset;
+    uint32_t config_pll_reset_mask;
+    uint32_t config_reset_mask;
+} AlteraFPGAPLL_t;
+
+/* Predefined PLL descriptions */
+extern const AlteraFPGAPLL_t AlteraFPGAPLL_1; //vdu
+extern const AlteraFPGAPLL_t AlteraFPGAPLL_2; //msvd, cam1 etc
+
+#if FPGA_USE_MMAP
+    extern volatile uint32_t* fpga_regs_mmap;  /**< memory-mapped registers */
+#endif
+
+/** error codes */
+#define FPGA_RES_OK       0  /**< no error */
+#define FPGA_RES_NODEV    1  /**< device file not open / could not open device */
+#define FPGA_RES_FAIL     2  /**< general HW failure / wrong or missing device */
+#define FPGA_RES_NODMA    3  /**< no DMA engines available */
+#define FPGA_RES_INVAL    4  /**< operation not allowed */
+
+#define FPGA_READ_ERROR 0xDEADBEEF  /**< returned from ReadReg in case of failure */
+
+/** AlteraFPGABoard_Open()
+  * @brief  Open and initialize the FPGA board.
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_INVAL  board already opened
+  * @retval FPGA_RES_NODEV  cannot open device (driver not loaded or wrong permissions)
+  * @retval FPGA_RES_FAIL   hardware failure or unexpected hardware behavior
+  * @retval FPGA_RES_NODMA  operation successful, but no DMA engines found
+  *                         (register access is possible, but DMA access is not) */
+uint32_t AlteraFPGABoard_Open(HalHandle_t HalHandle);
+
+
+void AlteraFPGABoard_Reset(HalHandle_t HalHandle);
+
+/** AlteraFPGABoard_Close()
+  * @brief  Uninitialize and close the FPGA board.
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first) */
+uint32_t AlteraFPGABoard_Close(HalHandle_t HalHandle);
+
+
+/** AlteraFPGABoard_ReadBAR()
+  * @brief  Read a 32-bit DWORD from one of the PCI BARs on the FPGA.
+  * @param  bar             the number of the PCI BAR to access
+  * @param  address         the address (128-bit aligned) to read from
+  * @return the value read from the register, or FPGA_READ_ERROR if any error occured */
+uint32_t AlteraFPGABoard_ReadBAR(int32_t isp_fd, uint32_t address);
+
+
+/** AlteraFPGABoard_WriteBAR()
+  * @brief  Write a 32-bit DWORD to one of the PCI BARs on the FPGA.
+  * @param  bar             the number of the PCI BAR to access
+  * @param  address         the address (128-bit aligned) to write to
+  * @param  data            the data word to write
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   could not write value */
+uint32_t AlteraFPGABoard_WriteBAR(int32_t isp_fd, uint32_t address, uint32_t data);
+
+
+/** AlteraFPGABoard_ReadReg()
+  * @brief  Read a 32-bit DWORD from one of the registers on the predefined PCI BAR.
+  * @param  address         the address (32-bit aligned) to read from
+  * @return the value read from the register, or FPGA_READ_ERROR if any error occured */
+INLINE uint32_t AlteraFPGABoard_ReadReg(int32_t isp_fd, uint32_t address) {
+#if FPGA_USE_MMAP
+    return fpga_regs_mmap[FPGA_REG_ADDRESS_MOD(address) >> 2];
+#else
+    return AlteraFPGABoard_ReadBAR(isp_fd, FPGA_REG_ADDRESS_MOD(address));
+#endif
+}
+
+
+/** AlteraFPGABoard_WriteReg()
+  * @brief  Write a 32-bit DWORD to one of the registers on the predefined PCI BAR.
+  * @param  address         the address (32-bit aligned) to write to
+  * @param  data            the data word to write
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   could not write value */
+INLINE uint32_t AlteraFPGABoard_WriteReg(int32_t isp_fd, uint32_t address, uint32_t data) {
+#if FPGA_USE_MMAP
+    fpga_regs_mmap[FPGA_REG_ADDRESS_MOD(address) >> 2] = data;
+    return FPGA_RES_OK;
+#else
+    return AlteraFPGABoard_WriteBAR(isp_fd, FPGA_REG_ADDRESS_MOD(address), data);
+#endif
+}
+
+/** AlteraFPGABoard_ReadMis()
+  * @brief  Read a 32-bit DWORD from one of the mis array store in kernel.
+  * @param  pAry         pointer to the irq mis src and val array.
+  * @return the value read from the mis, or RET_FAILURE if any error occured */
+uint32_t AlteraFPGABoard_ReadMis(int32_t isp_fd, uint64_t* pAry);
+
+/** AlteraFPGABoard_RawDMARead()
+  * @brief  Transfer a block of memory from the FPGA board's memory into host memory,
+  *         bypassing the 256-to-64-bit memory translation.
+  * @param  data            host memory pointer to write data to
+  * @param  address         board memory address (256-bit aligned) to read data from
+  * @param  size            transfer size in bytes (must be a multiple of 32 bytes)
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   transfer failed
+  * @retval FPGA_RES_NODMA  DMA not available on this board */
+uint32_t AlteraFPGABoard_RawDMARead(HalHandle_t HalHandle, void* data, uint32_t address, uint32_t size);
+
+
+
+/** AlteraFPGABoard_RawDMAWrite()
+  * @brief  Transfer a block of memory from host memory into the FPGA board's memory,
+  *         bypassing the 256-to-64-bit memory translation.
+  * @param  data            host memory pointer to read data from
+  * @param  address         board memory address (256-bit aligned) to write data to
+  * @param  size            transfer size in bytes (must be a multiple of 32 bytes)
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   transfer failed
+  * @retval FPGA_RES_NODMA  DMA not available on this board */
+uint32_t AlteraFPGABoard_RawDMAWrite(HalHandle_t HalHandle, void* data, uint32_t address, uint32_t size);
+
+
+/** AlteraFPGABoard_DMARead()
+  * @brief  Transfer a block of memory from the FPGA board's memory into host memory
+  *         with 256-to-64-bit memory translation.
+  * @param  data            host memory pointer to write data to
+  * @param  address         board memory address (64-bit aligned, MSVD address space) to read data from
+  * @param  size            transfer size in bytes (must be a multiple of 8 bytes)
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   transfer failed
+  * @retval FPGA_RES_NODMA  DMA not available on this board */
+uint32_t AlteraFPGABoard_DMARead(HalHandle_t HalHandle, uint8_t* data, uint32_t address, uint32_t size);
+
+
+/** AlteraFPGABoard_DMAWrite()
+  * @brief  Transfer a block of memory from host memory into the FPGA board's memory
+  *         with 256-to-64-bit memory translation.
+  * @param  data            host memory pointer to read data from
+  * @param  address         board memory address (64-bit aligned, MSVD address space) to write data to
+  * @param  size            transfer size in bytes (must be a multiple of 8 bytes)
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   transfer failed
+  * @retval FPGA_RES_NODMA  DMA not available on this board */
+uint32_t AlteraFPGABoard_DMAWrite(HalHandle_t HalHandle, uint8_t* data, uint32_t address, uint32_t size);
+
+
+/** AlteraFPGABoard_SetupIRQ()
+  * @brief  Set up user interrupt and service routine.
+  * @param  irq             pointer to fpga_irq_handle_t structure to be initialized
+  * @param  mis_addr        address (32-bit aligned) of the interrupt status register in the user design
+  * @param  cis_addr        address (32-bit aligned) of the interrupt clear register in the user design
+  * @param  timeout         timeout, in milliseconds, after which a WaitForIRQ() call shall return
+  *                         if no interrupt occured. If this is zero (0), no timeout will occur.
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   interrupt setup failed */
+uint32_t AlteraFPGABoard_SetupIRQ(fpga_irq_handle_t *irq, uint32_t mis_addr, uint32_t cis_addr, uint32_t timeout);
+
+
+/** AlteraFPGABoard_StopIRQ()
+  * @brief  Deregister interrupt service routine.
+  * @param  irq             pointer to fpga_irq_handle_t structure to be used
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   interrupt setup failed */
+uint32_t AlteraFPGABoard_StopIRQ(fpga_irq_handle_t *irq);
+
+
+/** AlteraFPGABoard_WaitForIRQ()
+  * @brief  Wait for an interrupt.
+  * @param  irq             pointer to fpga_irq_handle_t structure to be used
+  * @param  irq_status      pointer to a variable that receives the contents of the interrupt status register
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   wait for interrupt failed or timed out */
+uint32_t AlteraFPGABoard_WaitForIRQ(HalIrqCtx_t *pIrqCtx, uint64_t irq_src, uint64_t *irq_status);
+
+
+/** AlteraFPGABoard_CancelIRQ()
+  * @brief  Cancel all pending interrupts.
+  * @param  irq             pointer to fpga_irq_handle_t structure to be used
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   cancelling of interrupts failed */
+uint32_t AlteraFPGABoard_CancelIRQ(fpga_irq_handle_t *irq);
+
+
+/** AlteraFPGABoard_SetPLLConfig()
+  * @brief  Update PLL configuration.
+  * @param  pll             one of the predefined PLL object structures
+  * @retval cfg             pointer to the new configuration
+  * @retval FPGA_RES_OK     operation successful
+  * @retval FPGA_RES_NODEV  FPGA board not initialized (need to call AlteraFPGABoard_Open() first)
+  * @retval FPGA_RES_FAIL   reconfiguration failed */
+uint32_t AlteraFPGABoard_SetPLLConfig(const AlteraFPGAPLL_t* pll, const AlteraFPGAPLLConfig_t* cfg);
+
+
+#if FPGA_USE_KERNEL_IRQ_HANDLING
+
+#define AlteraFPGABoard_ForbidIRQPolling(x) do { } while (0)
+#define AlteraFPGABoard_AllowIRQPolling(x)  do { } while (0)
+
+#else
+
+/** AlteraFPGABoard_ForbidIRQPolling()
+  * @brief  Temporally forbid IRQ polling */
+void AlteraFPGABoard_ForbidIRQPolling(fpga_irq_handle_t *irq);
+
+/** AlteraFPGABoard_AllowIRQPolling()
+  * @brief  Re-allow IRQ polling */
+void AlteraFPGABoard_AllowIRQPolling(fpga_irq_handle_t *irq);
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ALTERA_FPGA_H */

+ 210 - 0
isp_isp8000l/units/hal/adapt.h

@@ -0,0 +1,210 @@
+/******************************************************************************\
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/*******************************************************************************
+ * @file adapt.h
+ *
+ * @brief   adapter Layer for isp
+ *
+ *          This header file exports
+ *
+ *
+ * @note
+ *
+ *****************************************************************************/
+
+#ifndef __ADATPT_H__
+#define __ADATPT_H__
+
+#include <ebase/types.h>
+#include <ebase/dct_assert.h>
+//#include <ebase/trace.h>
+#include <common/return_codes.h>
+
+#include "oslayer/oslayer.h"
+
+/* Set this macro to 1 enable register dump. */
+#define ENABLE_REGISTER_DUMP 0
+
+/******************************************************************************
+ * local macro definitions
+ *****************************************************************************/
+#define SEARCH_V4L2_DEV_NUM_MAX      20
+#define SEARCH_V4L2_SUB_DEV_NUM_MAX  20
+#define SENSOR_NAME_SIZE_MAX         16
+#define SENSOR_DRV_NAME_SIZE_MAX     128
+#define SENSOR_CALIB_NAME_SIZE_MAX   128
+
+#define SENSOR_ADAPT_MODE_MAX        20
+
+#define DW_NAME_SIZE_MAX        16
+
+/******************************************************************************
+ * local enum definitions
+ *****************************************************************************/
+typedef enum AdaptModule_s
+{
+    ADAPT_MODULE_VIDEO   = 0x01,//!<video in V4L2
+    ADAPT_MODULE_ISP     = 0x02,//!<ISP
+    ADAPT_MODULE_VIN     = 0x04,//!<VIN:mipi-csi2 dvp bt656 bt601
+    ADAPT_MODULE_SENSOR  = 0x08,//!<Sensor
+    ADAPT_MODULE_SOC     = 0x10,//!<SoC
+    ADAPT_MODULE_DEC400  = 0x20,//!<DEC400
+}AdaptModule_e;
+
+typedef enum AdaptChId_s
+{
+    ADAPT_CH_ID0 = 0, //!<isp channel id 0.
+    ADAPT_CH_ID1 = 1, //!<isp channel id 1.
+    ADAPT_CH_NUM      //!<isp channel numbers.
+}AdaptChId_e;
+
+typedef enum AdaptDrvMode_s
+{
+    ADAPT_DRV_MODE_AUTO   = 0,//!<Automatic detect mode(reserved)
+    ADAPT_DRV_MODE_NATIVE = 1,//!<native driver mode
+    ADAPT_DRV_MODE_V4L2   = 2,//!<v4l2 driver mode
+}AdaptDrvMode_e;
+
+typedef enum AdaptVinType_s
+{
+    ADAPT_VIN_TYPE_MIPI   = 0,//!<connect mipi with vin
+    ADAPT_VIN_TYPE_DVP    = 1,//!<connect dvp with vin
+    ADAPT_VIN_TYPE_BT656  = 2,//!<connect bt656 with vin
+    ADAPT_VIN_TYPE_BT601  = 3,//!<connect bt601 with vin
+}AdaptVinType_e;
+
+/******************************************************************************
+ * local type definitions
+ *****************************************************************************/
+
+
+/******************************************************************************
+ * Contexts for modules in adepter layer
+ *****************************************************************************/
+typedef struct AdaptIspContext_s
+{
+    int32_t        ispFd;  //!< file descriptor of ISP deivce
+    //AdaptChId_e    ispID;  //!< current id/channel index of ISP device
+} AdaptIspContext_t;
+
+typedef struct AdaptSensorInfo_s
+{
+    char  *pSensorName;
+    char  *pSensorDrvName;
+    char  *pSensorCalibXmlName;
+    uint32_t sensorDefaultMode;
+    uint32_t sensorCurrMode;
+}AdaptSensorInfo_t;
+
+typedef struct AdaptSensorModeConfig_s
+{
+    uint32_t      mode;
+    char          sensorCalibXmlName[SENSOR_CALIB_NAME_SIZE_MAX];
+}AdaptSensorModeConfig_t;
+
+typedef struct AdaptSensorContext_s
+{
+    int32_t                 sensorFd;  //!< file descriptor of sensor deivce
+    uint8_t                 i2cBusID;  //!< current i2c dev id which is shown as /dev/i2c-0  /dev/i2c-1...
+    char                    sensorName[SENSOR_NAME_SIZE_MAX];
+    char                    sensorDrvName[SENSOR_DRV_NAME_SIZE_MAX];
+    uint8_t                 modeCount;
+    AdaptSensorModeConfig_t sensorModeConfig[SENSOR_ADAPT_MODE_MAX];
+    uint8_t                 ModeLock;
+    uint32_t                sensorDefaultMode;
+    uint32_t                sensorCurrMode;
+} AdaptSensorContext_t;
+
+typedef struct AdaptVinContext_s
+{
+    int32_t         vinFd;  //!< file descriptor of vin deivce
+    AdaptChId_e     vinID;//!<current channel id of mipi csi which is connectted with isp
+    AdaptVinType_e  vinType;//!< interface type of video input
+} AdaptVinContext_t;
+
+typedef struct AdaptDecContext_s
+{
+    int32_t         decFd;  //!< file descriptor of vin deivce
+    AdaptChId_e     decID;//!<current channel id of mipi csi which is connectted with isp
+} AdaptDecContext_t;
+
+typedef struct AdaptContext_s
+{
+    AdaptDrvMode_e        drvMode; //!< driver mode: native or v4l2
+    AdaptChId_e           currChID;//!< current channel id of adapter<==>isp
+
+    AdaptIspContext_t     ispCtx;
+    AdaptSensorContext_t  sensorCtx;
+    AdaptVinContext_t     vinCtx;
+    AdaptDecContext_t     decCtx;
+    int32_t               socFd;
+    int32_t               v4l2VideoFd; //!< only vaild in v4l2 mode(open /dev/videoX), others as -1
+
+    osMutex               modMutex; //!< common short term mutex; e.g. for read-modify-write accesses
+
+} AdaptContext_t;
+
+/******************************************************************************
+ * open parameters for adepter layer
+ *****************************************************************************/
+typedef struct AdaptOpenParam_s
+{
+    AdaptDrvMode_e        drvMode;  //!< isp driver mode: native or v4l2
+    AdaptChId_e           openChID; //!< adapter channel ID
+    AdaptVinType_e        vinType;  //!< interface type of video input
+    char                 *pSensorCfgFile; //!<path of sensor cfg from isi layer
+    int sensorID;
+} AdaptOpenParam_t;
+/*****************************************************************************/
+/**
+ * @brief   handle to adapt instance
+ *****************************************************************************/
+/*******AdaptContext_t *;   */
+typedef void * AdaptHandle_t;
+
+
+/******************************************************************************
+ * common internal stuff; may be used externally as well
+ *****************************************************************************/
+
+/******************************************************************************
+ * @brief
+ * @return
+ * @note
+ *****************************************************************************/
+
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AdaptHandle_t AdaptOpen(AdaptOpenParam_t *pOpenParams);
+RESULT AdaptClose(AdaptHandle_t adaptHandle);
+int32_t AdaptGetFd(AdaptHandle_t adaptHandle, AdaptModule_e module);
+RESULT AdaptGetDrvMode(AdaptHandle_t adaptHandle, AdaptDrvMode_e  *pDrvMode);
+RESULT AdaptIoctl(AdaptHandle_t adaptHandle, AdaptModule_e module, unsigned int cmd, void *args);
+RESULT AdaptGetSensorInfo(AdaptHandle_t adaptHandle, AdaptSensorInfo_t *pSensorInfo);
+RESULT AdaptSetSensorMode(AdaptHandle_t adaptHandle, uint32_t currMode);
+RESULT AdaptSetSensorDefaultMode(AdaptHandle_t adaptHandle, uint32_t defaultMode);
+RESULT AdaptSetSensorCalibXmlName(AdaptHandle_t adaptHandle, const char * CalibXmlName);
+RESULT AdaptSensorModeLock(AdaptHandle_t adaptHandle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ADATPT_H__ */

+ 139 - 0
isp_isp8000l/units/hal/hal_altera_irq_notifier.h

@@ -0,0 +1,139 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file hal_altera_pci.h
+ *
+ * @brief   Altera PCI variant of Hardware Abstraction Layer
+ *
+ *          This header file exports the register IO interface realized as an Altera
+ *          PCI-Express board access inline function. You should use it for your
+ *          PC implementation in combination with the Altera FPGA board.
+ * @note    Do not include directly! Include hal_api.h instead with HAL_ALTERA defined.
+ *
+ *****************************************************************************/
+
+#ifndef __HAL_ALTERA_IRQ_NOTIFIER_H__
+#define __HAL_ALTERA_IRQ_NOTIFIER_H__
+
+#include <stdio.h>
+#include <ebase/trace.h>
+#include <common/align.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+
+#include "hal_api.h"  // this includes 'hal_altera_pci.h' as well
+
+//#include "hal_altera_pci_mem.h"
+/******************************************************************************
+ * local type definitions
+ *****************************************************************************/
+
+
+typedef enum HalIrqNotifierCmdId_e
+{
+    HAL_IRQ_NORIFIER_CMD_INVALID                   = 0,    /**< invalid command (only for initialization) */
+    HAL_IRQ_NORIFIER_CMD_REGISTER_ISP_IRQ          = 1,    /**< register isp irq command */
+    HAL_IRQ_NORIFIER_CMD_REGISTER_JPE_STATUS_IRQ   = 2,    /**< register jpe status irq command  */
+    HAL_IRQ_NORIFIER_CMD_REGISTER_JPE_ERROR_IRQ    = 3,    /**< register jpe error  irq command  */
+    HAL_IRQ_NORIFIER_CMD_REGISTER_MI_IRQ           = 4,    /**< register mi irq command  */
+    HAL_IRQ_NORIFIER_CMD_REGISTER_MI1_IRQ           ,    /**< register mi1 irq command  */
+    HAL_IRQ_NORIFIER_CMD_REGISTER_MI2_IRQ           ,    /**< register mi2 irq command  */
+
+    HAL_IRQ_NORIFIER_CMD_UNREGISTER_ISP_IRQ          ,
+    HAL_IRQ_NORIFIER_CMD_UNREGISTER_JPE_STATUS_IRQ,
+    HAL_IRQ_NORIFIER_CMD_UNREGISTER_JPE_ERROR_IRQ,
+
+    HAL_IRQ_NORIFIER_CMD_UNREGISTER_MI_IRQ ,    /**< unregister mi irq command  */
+    HAL_IRQ_NORIFIER_CMD_UNREGISTER_MI1_IRQ,
+    HAL_IRQ_NORIFIER_CMD_UNREGISTER_MI2_IRQ,
+    HAL_IRQ_NORIFIER_CMD_MAX
+
+}HalIrqNotifierCmdId_t;
+
+
+/**
+ * @brief Generic command type.
+ *
+ */
+typedef struct HalIrqNotifierCmd_s
+{
+    HalIrqNotifierCmdId_t    cmdId;
+    void                *pCmdCtx;
+} HalIrqNotifierCmd_t;
+
+
+
+typedef struct IrqContext_s
+{
+    uint32_t misRegAddress;
+    uint32_t mis;
+    osEvent      *pIsr_irq_event;        //notify observer interrupt event
+    osQueue      *pIsr_mis_queue;        // mis value queue
+}IrqContext_t;
+
+typedef struct IrqNotifierContext_s
+{
+
+//    IrqContentQueue_t   head;
+    osThread    isr_thread;
+    osEvent      isr_exit_event;
+	osMutex     access_lock;
+
+    osQueue      commandQueue;
+    osEvent      process_cmd_done_event;
+    int          device_file;
+    IrqContext_t  irqSrcCtx[eHalIsrMax];
+
+} IrqNotifierContext_t;
+
+typedef void* IrqNotifierHandle_t;
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/******************************************************************************
+ * createHalIrqNotifierThd()
+ *****************************************************************************/
+RESULT createHalIrqNotifierThd
+(
+    IrqNotifierContext_t * pIrqNotifier
+);
+
+/******************************************************************************
+ * destroyHalIrqNotifierThd()
+ *****************************************************************************/
+RESULT destroyHalIrqNotifierThd
+(
+    IrqNotifierContext_t * pIrqNotifier
+);
+
+/******************************************************************************
+ * HalIrqNotifierSendCommand
+ *****************************************************************************/
+RESULT HalIrqNotifierSendCommand
+(
+    IrqNotifierContext_t     *pIrqNotifier,
+    HalIrqNotifierCmd_t    *pCommand
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HAL_ALTERA_IRQ_NOTIFIER_H__ */

+ 465 - 0
isp_isp8000l/units/hal/hal_altera_pci.h

@@ -0,0 +1,465 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file hal_altera_pci.h
+ *
+ * @brief   Altera PCI variant of Hardware Abstraction Layer
+ *
+ *          This header file exports the register IO interface realized as an Altera
+ *          PCI-Express board access inline function. You should use it for your
+ *          PC implementation in combination with the Altera FPGA board.
+ * @note    Do not include directly! Include hal_api.h instead with HAL_ALTERA defined.
+ *
+ *****************************************************************************/
+
+#ifndef __HAL_ALTERA_PCI_H__
+#define __HAL_ALTERA_PCI_H__
+
+#include <ebase/trace.h>
+#include <fpga/altera_fpga.h>
+#include <i2c_drv/i2c_drv.h>
+
+#include <cam_device/cam_device_buf_defs.h>
+
+#include "adapt.h"
+//#include "hal_altera_irq_notifier.h"
+/* Set this macro to 1 enable register dump. */
+#define ENABLE_REGISTER_DUMP 0
+
+/******************************************************************************
+ * local macro definitions
+ *****************************************************************************/
+#define NUM_I2C 3
+
+#define SYSCTRL_REVID_OFFS  0x00
+#define SYSCTRL_SELECT_OFFS 0x10
+#define SYSCTRL_RESET_OFFS  0x20
+
+#define SYSCTRL_SELECT_CAM_1_NEGEDGE 0x00000100
+#define SYSCTRL_SELECT_CAM_1_RESET   0x00000200
+#define SYSCTRL_SELECT_CAM_1_POWERDN 0x00000400
+
+#define SYSCTRL_SELECT_CAMPHY_1_RESET   0x00001000
+#define SYSCTRL_SELECT_CAMPHY_1_POWERDN 0x00000000  //NOTE: not connected so far
+
+#define EXT_MEM_ALIGN 0x1000 // 4k
+
+#define DMA_STRIDE_BYTES 8 ////FPGA_DMA_SIZE_ALIGNMENT // currently 32
+#define DMA_MEM_ALIGN    512
+
+#define HAL_USE_RAW_DMA // comment out to use dma functions with byte reordering & stuff
+
+
+/*****************************************************************************/
+/**
+ * @brief   different ways of how mapping of data from the memory into local memory is done
+ *****************************************************************************/
+typedef enum HalMapMemType_s
+{
+    HAL_MAPMEM_READWRITE = 0,   //!< Maps memory for read/write access.
+    HAL_MAPMEM_READONLY,        //!< Maps memory for read access only, system action on write access is undefined
+    HAL_MAPMEM_WRITEONLY        //!< Maps memory for write access only, system action on read access is undefined
+} HalMapMemType_t;
+
+
+/******************************************************************************
+ * local type definitions
+ *****************************************************************************/
+typedef enum HalModule_s
+{
+    HAL_MODULE_VIDEO   = 0x01,//!<video in V4L2
+    HAL_MODULE_ISP     = 0x02,//!<ISP
+    HAL_MODULE_VIN     = 0x04,//!<VIN:mipi-csi2 dvp bt656 bt601
+    HAL_MODULE_SENSOR  = 0x08,//!<Sensor
+    HAL_MODULE_SOC     = 0x10,//!<SoC
+}HalModule_e;
+
+typedef struct HalCamConfig_s
+{
+    bool_t configured;      //!< Mark whether this config was set.
+    bool_t power_lowact;    //!< Power on is low-active.
+    bool_t reset_lowact;    //!< Reset is low-active.
+    //bool_t negedge;         //!< Capture data on negedge.
+} HalCamConfig_t;
+
+typedef struct HalCamPhyConfig_s
+{
+    bool_t configured;      //!< Mark whether this config was set.
+    bool_t power_lowact;    //!< Power on is low-active.
+    bool_t reset_lowact;    //!< Reset is low-active.
+} HalCamPhyConfig_t;
+
+typedef struct HalMemMap_s
+{
+    uint32_t        mem_address;    //!< Hardware memory address.
+    uint32_t        byte_size;      //!< Size of mapped buffer.
+    HalMapMemType_t mapping_type;   //!< How the buffer is mapped.
+    void            *p_bufbase;     //!< Base of allocated buffer.
+} HalMemMap_t;
+
+typedef enum HalInterruptType_e{
+    eHAL_INT_MI_DMA_READY    =0x0000,
+    eHAL_INT_MI_FRAME_END_MP,
+    eHAL_INT_MI_FRAME_END_SP,
+	eHAL_INT_MI_FRAME_END_SP2_BP,
+    eHAL_INT_MI_RAW_FRAME_END_SP2_BP,
+    eHAL_INT_MI2_FRAME_END_PPW,
+    eHAL_INT_ISP_OFF,
+    eHal_INT_ISP_HistM,
+    eHal_INT_ISP_ExpM,
+    eHal_INT_ISP_WbM,
+    eHal_INT_ISP_AfmM,
+    eHal_INT_ISP_VsmM,
+
+    eHAL_INTMax,
+}HalInterruptType_t;
+
+typedef struct __HalBuffPoolCtx__
+{
+    BufIdentity bufPoolMp[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolSP1[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolSP2[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolRdi[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolMeta[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolRead[BUFF_POOL_MAX_INPUT_BUF_NUMBER];
+    uint32_t    bufPoolMpNum;
+    uint32_t    bufPoolSP1Num;
+    uint32_t    bufPoolSP2Num;
+    uint32_t    bufPoolRdiNum;
+    uint32_t    bufPoolMetaNum;
+    uint32_t    bufPoolReadNum;
+}HalBuffPoolCtx;
+
+
+
+/******************************************************************************
+ * HalContext_t
+ *****************************************************************************/
+typedef struct HalContext_s
+{
+    osMutex             modMutex;               //!< common short term mutex; e.g. for read-modify-write accesses
+    uint32_t            refCount;               //!< internal ref count
+
+    osMutex             iicMutex[NUM_I2C];      //!< transaction locks for I2C controller 1..NUM_I2C
+    i2c_bus_t           iicConfig[NUM_I2C];     //!< configurations for I2C controller 1..NUM_I2C
+
+    HalCamConfig_t      cam1Config;             //!< configuration for CAM1; set at runtime
+    HalCamPhyConfig_t   camPhy1Config;          //!< configuration for CAMPHY1; set at runtime
+    osDpcFunc           halIsrFunTable[eHalIsrMax];  //!< hal Isr source and function table
+
+#if ENABLE_REGISTER_DUMP
+    FILE*               regDumpFile;
+#endif
+    char*               regDynDumpName;         //!< register dump name.
+    FILE*               regDynDumpFp;           //!< dynamic dump handle
+
+    HalBuffPoolCtx      halBufPool;
+    BUFF_MODE           buf_work_mode;
+    uint32_t            isp_index;
+    uint32_t            sensor_index;
+    int32_t             isp_fd;
+    int32_t             csi_fd;
+    int32_t             sensor_fd;
+    int32_t             soc_fd;
+    int32_t             dec_fd;
+
+    AdaptHandle_t       adaptHandle;
+    void               *pIrqNotifier;
+
+    bool_t              board_using;
+    volatile int        irq_cancel_all;
+    uint8_t*            extern_mem_virtual_base;
+    unsigned long       reservedMemBase;
+    unsigned long       reservedMemSize;
+
+} HalContext_t;
+
+
+/*****************************************************************************/
+/**
+ * @brief   handle to hal instance
+ *****************************************************************************/
+//typedef struct HalContext_s *HalHandle_t;
+typedef void * HalHandle_t;
+
+/******************************************************************************
+ * common internal stuff; may be used externally as well
+ *****************************************************************************/
+
+/******************************************************************************
+ * @brief   reads a value from a specific part of the given variable
+ * @return  masked and shifted data of specific variable part
+ *
+ * @note    It is required to pass a variable (not a register!)
+ *          and the masks (reg_mask and shift_mask) by using constant defines.
+ *          This function is used internally by HalReadMaskedReg() but can also
+ *          be used directly to read values from a (temporary) variable.
+ *****************************************************************************/
+INLINE uint32_t HalGetMaskedValue( uint32_t reg_value, uint32_t reg_mask, uint32_t shift_mask )
+{
+    return ((reg_value & reg_mask) >> shift_mask);
+}
+
+
+/******************************************************************************
+ * @brief   writes a value to specific part of the given variable
+ * @return  new value of variable
+ *
+ * @note    It is required to pass a variable (not a register!)
+ *          and the masks (reg_mask and shift_mask) by using constant defines.
+ *          This function is used internally by HalWriteMaskedReg() but can also
+ *          be used directly to write values into a (temporary) variable.
+ *****************************************************************************/
+INLINE uint32_t HalSetMaskedValue( uint32_t reg_value, uint32_t reg_mask, uint32_t shift_mask, uint32_t value )
+{
+    return (reg_value & ~(reg_mask)) | ((value << shift_mask) & reg_mask);
+}
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+USE_TRACER(HAL_ERROR);
+
+
+RESULT HalKernelAddrMap(HalHandle_t HalHandle , BufIdentity * bufIdentify);
+BufIdentity* HalGetPoolList(HalHandle_t HalHandle, ISPCORE_BUFIO_ID chain);
+uint32_t* HalGetPoolNumHandle(HalHandle_t HalHandle, ISPCORE_BUFIO_ID chain);
+
+int32_t HalGetFdHandle(HalHandle_t HalHandle, HalModule_e module);
+RESULT HalIoctl(HalHandle_t HalHandle, HalModule_e module, unsigned int cmd, void *args);
+RESULT HalGetSensorName(HalHandle_t HalHandle, char pSensorName[], uint16_t arraySize);
+RESULT HalGetSensorDrvName(HalHandle_t HalHandle, char pSensorDrvName[], uint16_t arraySize);
+RESULT HalGetSensorCalibXmlName(HalHandle_t HalHandle, char pSensorCalibXmlName[], uint16_t arraySize);
+RESULT HalGetSensorDefaultMode(HalHandle_t HalHandle, uint32_t *pMode);
+RESULT HalGetSensorCurrMode(HalHandle_t HalHandle, uint32_t *pMode);
+RESULT HalSetSensorMode(HalHandle_t HalHandle, uint32_t mode);
+RESULT HalSetSensorDefaultMode(HalHandle_t HalHandle, uint32_t mode);
+RESULT HalSetSensorCalibXmlName(HalHandle_t HalHandle, const char* CalibXmlName);
+RESULT HaSensorModeLock(HalHandle_t HalHandle);
+
+int32_t HalSetSensorRegister(HalHandle_t HalHandle,uint32_t addr, uint32_t value);
+int32_t HalGetSensorRegister(HalHandle_t HalHandle,uint32_t addr, uint32_t *value);
+int32_t HalSetIspRegister(HalHandle_t HalHandle,uint32_t addr, uint32_t value);
+int32_t HalGetIspRegister(HalHandle_t HalHandle,uint32_t addr, uint32_t *value);
+
+int32_t HalSystemInit(uint32_t id,HalHandle_t HalHandle);
+int32_t HalCsiInit(HalHandle_t HalHandle);
+int32_t HalSensorInit(HalHandle_t HalHandle, const char *registerFileName);
+int32_t HalIspInit(HalHandle_t HalHandle, const char *registerFileName);
+int32_t HalDecInit(HalHandle_t HalHandle);
+
+
+RESULT HalSetBuffMode(HalHandle_t HalHandle, BUFF_MODE buf_work_mode);
+BUFF_MODE HalGetBuffMode(HalHandle_t HalHandle);
+
+/******************************************************************************
+ * HAL device IDs
+ *****************************************************************************/
+#define HAL_DEVID_OCP       0x00000001  //!< HAL internal use only
+#define HAL_DEVID_MARVIN    0x00000002  //!< MARVIN.*
+#define HAL_DEVID_VDU       0x00000004  //!< VDU.clk + VDU.ocpclk
+#define HAL_DEVID_PCLK      0x00000008  //!< VDU.pclk
+#define HAL_DEVID_I2C_0     0x00000010  //!< HAL internal use only
+#define HAL_DEVID_I2C_1     0x00000020  //!< HAL internal use only
+#define HAL_DEVID_I2C_2     0x00000040  //!< HAL internal use only
+#define HAL_DEVID_CAMREC_1  0x00000080  //!< CAMREC1, not neccessarily the REC that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_REC instead
+#define HAL_DEVID_INTERNAL  0x000000ff  //!< just internal devices included
+
+#define HAL_DEVID_CAM_1     0x10000000  //!< CAM1
+#define HAL_DEVID_CAMPHY_1  0x20000000  //!< CAMPHY1, not neccessarily the PHY that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_PHY instead
+#define HAL_DEVID_EXTERNAL  0x30000000  //!< just external devices included
+
+#define HAL_DEVID_ALL       (HAL_DEVID_INTERNAL | HAL_DEVID_EXTERNAL) //!< all devices included
+
+#define HAL_DEVID_HIGHACTIVE_RESET_DEVICES 0x00000000 //!< HAL internal use only; bitwise or of all device masks of devices with high active resets.
+#define HAL_DEVID_HIGHACTIVE_POWER_DEVICES 0x00000000 //!< HAL internal use only; bitwise or of all device masks of devices with high active power on select.
+#define HAL_DEVID_RISING_CLKEDGE_DEVICES   0x00000000 //!< HAL internal use only; bitwise or of all device masks of devices with rising edge active clocks.
+
+/******************************************************************************
+ * HAL device base addresses
+ *****************************************************************************/
+// HalRegs:
+#define HAL_BASEADDR_MARVIN    0x00000000 //!< Base address of MARVIN module.
+#define HAL_BASEADDR_MARVIN_2  0x00010000 //!< Base address of MARVIN module of 2nd channel.
+#define HAL_BASEADDR_MIPI_1    0x00000000 //!< Base address of MIPI module.
+#define HAL_BASEADDR_MIPI_2    0x00010000 //!< Base address of MIPI module of 2nd channel.
+#define HAL_BASEADDR_VDU       0x00008000 //!< Base address of VDU module.
+#define HAL_BASEADDR_MARVIN_DEC 0x00600000 //!< Base address of DEC module.
+
+// HalSysRegs:
+#define HAL_BASEADDR_SYSCTRL   0x00000000 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_0     0x00001000 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_1     0x00001800 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_2     0x00000800 //!< HAL internal use only
+
+
+/******************************************************************************
+ * HAL device base region
+ *****************************************************************************/
+// HalRegs:
+#define HAL_BASEREGION_MARVIN    0 //!< Base region of MARVIN module(s).
+#define HAL_BASEREGION_MIPI      0 //!< Base region of MIPI module(s).
+#define HAL_BASEREGION_VDU       0 //!< Base region of VDU module.
+
+// HalSysRegs:
+#define HAL_BASEREGION_SYSCTRL   2 //!< HAL internal use only
+#define HAL_BASEREGION_I2C       2 //!< HAL internal use only
+
+
+/******************************************************************************
+ * HAL I2C bus location
+ *****************************************************************************/
+#define HAL_I2C_BUS_CAM_1       0 //!< Num of I2C bus CAM1 is connected to
+#define HAL_I2C_BUS_CAM_2       1 //!< Num of I2C bus CAM2 is connected to
+#define HAL_I2C_BUS_HDMI_TX     2 //!< Num of I2C bus HDMI TX is connected to
+#define HAL_I2C_BUS_CAMPHY_1    0 //!< Num of I2C bus CAMPHY1 is connected to
+#define HAL_I2C_BUS_CAMPHY_2    1 //!< Num of I2C bus CAMPHY2 is connected to
+
+
+/******************************************************************************
+ * HAL CAM to PHY/REC mapping
+ *****************************************************************************/
+#define HAL_DEVID_CAM_1_PHY     HAL_DEVID_CAMPHY_1 //!< DEVID of CAMPHY CAM1 is connected to
+#define HAL_DEVID_CAM_2_PHY     HAL_DEVID_CAMPHY_1 //!< DEVID of CAMPHY CAM2 is connected to
+#define HAL_DEVID_CAM_1_REC     HAL_DEVID_CAMREC_1 //!< DEVID of CAMREC CAM1 is connected to
+#define HAL_DEVID_CAM_2_REC     HAL_DEVID_CAMREC_1 //!< DEVID of CAMREC CAM2 is connected to
+
+
+/******************************************************************************
+ * HalReadReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadReg( HalHandle_t HalHandle, uint32_t reg_address )
+{
+    uint32_t read;
+    (void) HalHandle;
+    struct HalContext_s * HalHandleCtx = (struct HalContext_s *)HalHandle;
+    DCT_ASSERT(HalHandleCtx != NULL);
+
+    read = AlteraFPGABoard_ReadReg(HalHandleCtx->isp_fd, reg_address);
+
+#if ENABLE_REGISTER_DUMP
+    if (HalHandleCtx->regDumpFile)
+    {
+        fprintf(HalHandleCtx->regDumpFile, "1 %08x %08x\n", reg_address, read);
+    }
+#endif
+
+    if (HalHandleCtx->regDynDumpFp)
+    {
+        fprintf(HalHandleCtx->regDynDumpFp, "1 %08x %08x\n", (unsigned int)reg_address, (unsigned int)read);
+    }
+
+    //printf("HAL_READ: %08x %08x\n", reg_address, read);
+    return read;
+}
+
+
+/******************************************************************************
+ * HalWriteReg()
+ *****************************************************************************/
+INLINE void HalWriteReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+    struct HalContext_s * HalHandleCtx = (struct HalContext_s *)HalHandle;
+
+#if ENABLE_REGISTER_DUMP
+    if (HalHandleCtx->regDumpFile)
+    {
+        fprintf(HalHandleCtx->regDumpFile, "0 %08x %08x\n", reg_address, value);
+    }
+#endif
+    if (HalHandleCtx->regDynDumpFp)
+    {
+        fprintf(HalHandleCtx->regDynDumpFp, "0 %08x %08x\n", (unsigned int)reg_address, (unsigned int)value);
+    }
+
+    //printf("HAL_WRITE: %08x %08x\n", reg_address, value);
+    (void) AlteraFPGABoard_WriteReg(HalHandleCtx->isp_fd, reg_address, value );
+}
+
+
+/******************************************************************************
+ * HalReadMaskedReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    uint32_t tmp_value = HalReadReg( HalHandle, reg_address );
+    return HalGetMaskedValue( tmp_value, reg_mask, shift_mask );
+}
+
+
+/******************************************************************************
+ * HalWriteMaskedReg()
+ *****************************************************************************/
+INLINE void HalWriteMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask, uint32_t value )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    uint32_t tmp_value = HalReadReg( HalHandle, reg_address );
+    tmp_value = HalSetMaskedValue( tmp_value, reg_mask, shift_mask, value );
+    HalWriteReg( HalHandle, reg_address, tmp_value );
+}
+
+
+/******************************************************************************
+ * HalReadSysReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadSysReg( HalHandle_t HalHandle, uint32_t reg_address )
+{
+    (void) HalHandle;
+   // DCT_ASSERT(HalHandle != NULL);
+    HalContext_t *pHalCtx = (HalContext_t *)HalHandle;
+
+    return AlteraFPGABoard_ReadBAR( pHalCtx->isp_fd, FPGA_REG_ADDRESS_MOD(reg_address) );
+}
+
+
+/******************************************************************************
+ * HalWriteSysReg()
+ *****************************************************************************/
+INLINE void HalWriteSysReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value )
+{
+    (void) HalHandle;
+    //DCT_ASSERT(HalHandle != NULL);
+    HalContext_t *pHalCtx = (HalContext_t *)HalHandle;
+
+    (void) AlteraFPGABoard_WriteBAR( pHalCtx->isp_fd, FPGA_REG_ADDRESS_MOD(reg_address), value );
+}
+
+/******************************************************************************
+ * HalWriteSysReg()
+ *****************************************************************************/
+RESULT HalDynRegDumpOpen( HalHandle_t HalHandle, char* regDynDumpName );
+
+/******************************************************************************
+ * HalDynRegDumpClose()
+ *****************************************************************************/
+RESULT HalDynRegDumpClose( HalHandle_t HalHandle );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HAL_ALTERA_PCI_H__ */

+ 760 - 0
isp_isp8000l/units/hal/hal_api.h

@@ -0,0 +1,760 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file hal_api.h
+ *
+ * @brief   Hardware Abstraction Layer
+ *
+ *          Encapsulates and abstracts services from different hardware platforms.
+ *
+ *****************************************************************************/
+
+#ifndef __HAL_API_H__
+#define __HAL_API_H__
+
+#include <ebase/types.h>
+#include <ebase/dct_assert.h>
+//#include <ebase/trace.h>
+
+#include <common/return_codes.h>
+#include <oslayer/oslayer.h>
+
+/******************************************************************************
+ * inline implementations of API
+ *****************************************************************************/
+ #include "hal_common.h"
+
+#if defined( HAL_ALTERA )
+  #include "hal_altera_pci.h"
+#elif defined( HAL_MOCKUP )
+  #include "hal_mockup.h"
+#elif defined( HAL_COSIM )
+  #include <hal/hal_cosim.h>
+#elif defined (HAL_CMODEL)
+  #include "hal_cmodel.h"
+#else
+  #error "unknow hardware plattform"
+#endif
+
+
+/**
+ * @defgroup HAL_API Hardware Abstraction Layer interface
+ * @{
+ * @brief  Encapsulates and abstracts services from different hardware platforms
+ *         in a hardware platform independent way.
+ *****************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/******************************************************************************
+ * HAL device IDs (defined by underlying layer via included header file)
+ *****************************************************************************/
+//#define HAL_DEVID_OCP         //!< HAL internal use only
+//#define HAL_DEVID_MARVIN      //!< MARVIN.*
+//#define HAL_DEVID_VDU         //!< VDU.clk + VDU.ocpclk
+//#define HAL_DEVID_PCLK        //!< VDU.pclk
+//#define HAL_DEVID_I2C_0       //!< HAL internal use only
+//#define HAL_DEVID_I2C_1       //!< HAL internal use only
+//#define HAL_DEVID_I2C_2       //!< HAL internal use only
+//#define HAL_DEVID_CAMREC_1    //!< CAMREC1, not neccessarily the REC that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_REC instead
+//#define HAL_DEVID_CAM_1       //!< CAM1
+//#define HAL_DEVID_CAMPHY_1    //!< CAMPHY1, not neccessarily the PHY that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_PHY instead
+//#define HAL_DEVID_ALL         //!< just for convenience; all devices included
+
+
+/******************************************************************************
+ * HAL device base addresses (defined by underlying layer via included header file)
+ *****************************************************************************/
+// HalRegs:
+//#define HAL_BASEADDR_MARVIN   //!< Base address of MARVIN module.
+//#define HAL_BASEADDR_MARVIN_2 //!< Base address of MARVIN module of 2nd channel.
+//#define HAL_BASEADDR_MIPI_1   //!< Base address of MIPI module.
+//#define HAL_BASEADDR_MIPI_2   //!< Base address of MIPI module of 2nd channel.
+//#define HAL_BASEADDR_VDU      //!< Base address of VDU module.
+
+// HalSysRegs:
+//#define HAL_BASEADDR_SYSCTRL  //!< HAL internal use only
+//#define HAL_BASEADDR_I2C_0    //!< HAL internal use only
+//#define HAL_BASEADDR_I2C_1    //!< HAL internal use only
+//#define HAL_BASEADDR_I2C_2    //!< HAL internal use only
+
+
+/******************************************************************************
+ * HAL I2C bus locations
+ *****************************************************************************/
+//#define HAL_I2C_BUS_CAM_1     //!< Num of I2C bus CAM1 is connected to
+//#define HAL_I2C_BUS_CAM_2     //!< Num of I2C bus CAM2 is connected to
+//#define HAL_I2C_BUS_HDMI_TX   //!< Num of I2C bus HDMI TX is connected to
+//#define HAL_I2C_BUS_CAMPHY_1  //!< Num of I2C bus CAMPHY1 is connected to
+//#define HAL_I2C_BUS_CAMPHY_2  //!< Num of I2C bus CAMPHY2 is connected to
+
+
+/******************************************************************************
+ * HAL CAM to PHY mapping
+ *****************************************************************************/
+//#define HAL_DEVID_CAM_1_PHY   //!< DEVID of CAMPHY CAM1 is connected to
+//#define HAL_DEVID_CAM_2_PHY   //!< DEVID of CAMPHY CAM2 is connected to
+//#define HAL_DEVID_CAM_1_REC   //!< DEVID of CAMREC CAM1 is connected to
+//#define HAL_DEVID_CAM_2_REC   //!< DEVID of CAMREC CAM2 is connected to
+
+
+/*****************************************************************************/
+/**
+ * @brief   open the low level driver
+ * @return  handle of driver; NULL on failure
+ *
+ * @note    Sets internal ref count to 1.
+ *****************************************************************************/
+HalHandle_t HalOpen( int ispID, int sensorID );
+
+
+/*****************************************************************************/
+/**
+ * @brief   close the low level driver
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @return  Result of operation.
+ *
+ * @note    Decrements internal ref count and closes low level driver if ref count reached zero.
+ *****************************************************************************/
+RESULT HalClose( HalHandle_t HalHandle );
+
+
+/*****************************************************************************/
+/**
+ * @brief   tell HAL about another user of low level driver
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @return  Result of operation.
+ *
+ * @note
+ *****************************************************************************/
+RESULT HalAddRef( HalHandle_t HalHandle );
+
+
+/*****************************************************************************/
+/**
+ * @brief   tell HAL about gone user of low level driver
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @return  Result of operation.
+ *
+ * @note    If the internal ref count is zero, the HAL will be closed as well.
+ *****************************************************************************/
+RESULT HalDelRef( HalHandle_t HalHandle );
+
+
+/*****************************************************************************/
+/**
+ * @brief   Set configuration of given CAM devices so that HAL can take care of
+ *          signal polarities for reset & power. CAMs that aren't configured
+ *          can't be correctly processed by \ref HalSetReset() or @ref HalSetPower()
+ *          and will thus lead to a failure if accessed. Default state after
+ *          successfull configuration is power down & reset active.
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   dev_mask        Mask of CAM devices to set configuration for.
+ * @param   power_lowact    CAM power on signal is low-active.
+ * @param   reset_lowact    CAM reset signal is low-active.
+ * @param   pclk_negedge    Select negative edge of incoming PClk to sample
+ *                          camera data. NOTE: @ref HalSetClock() must be called
+ *                          to activate this new setting!
+ * @return  Result of operation.
+ *
+ * @note    Device mask is bitwise OR (|) of HAL_DEVID_CAM_xxx.
+ *****************************************************************************/
+RESULT HalSetCamConfig( HalHandle_t HalHandle, uint32_t dev_mask, bool_t power_lowact, bool_t reset_lowact, bool_t pclk_negedge );
+
+
+/*****************************************************************************/
+/**
+ * @brief   Set configuration of given CAM PHY devices so that HAL can take care of
+ *          signal polarities for reset & power. CAM PHYs that aren't configured
+ *          can't be correctly processed by \ref HalSetReset() or @ref HalSetPower()
+ *          and will thus lead to a failure if accessed. Default state after
+ *          successfull configuration is power down & reset active.
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   dev_mask        Mask of CAM PHY devices to set configuration for.
+ * @param   power_lowact    CAM PHY power on signal is low-active.
+ * @param   reset_lowact    CAM PHY reset signal is low-active.
+ *
+ * @return  Result of operation.
+ *
+ * @note    Device mask is bitwise OR (|) of HAL_DEVID_CAMPHY_xxx.
+ *****************************************************************************/
+RESULT HalSetCamPhyConfig( HalHandle_t HalHandle, uint32_t dev_mask, bool_t power_lowact, bool_t reset_lowact );
+
+
+/*****************************************************************************/
+/**
+ * @brief   Enables/Disables reset of given devices. HAL takes care of polarity!
+ *          See @ref HalSetCamConfig() for details regarding CAM devices,
+ *          and @ref HalSetCamPhyConfig() for details regarding CAMPHY devices.
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   dev_mask    Mask of devices to change reset state.
+ * @return  Result of operation.
+ *
+ * @note    Device mask is bitwise OR (|) of HAL_DEVID_xxx.
+ *****************************************************************************/
+RESULT HalSetReset( HalHandle_t HalHandle, uint32_t dev_mask, bool_t activate );
+
+
+/*****************************************************************************/
+/**
+ * @brief   Enables/Disables power of given devices. HAL takes care of polarity!
+ *          See @ref HalSetCamConfig() for details regarding CAM devices,
+ *          and @ref HalSetCamPhyConfig() for details regarding CAMPHY devices.
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   dev_mask    Mask of devices to change power state.
+ * @return  Result of operation.
+ *
+ * @note    Device mask is bitwise OR (|) of HAL_DEVID_xxx.
+ *****************************************************************************/
+RESULT HalSetPower( HalHandle_t HalHandle, uint32_t dev_mask, bool_t activate );
+
+
+/*****************************************************************************/
+/**
+ * @brief   Enables+sets/Disables clock of given devices.
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   dev_mask    Mask of devices to change clock settings for.
+ * @param   frequency   Sets frequency of given clocks in Hz steps; the
+ *                      resulting frequency of the clock is implementation
+ *                      dependent, 0 turns clock off.
+ * @return  Result of operation.
+ *
+ * @note    Device mask is bitwise OR (|) of HAL_DEVID_CAM_xxx.
+ *****************************************************************************/
+RESULT HalSetClock( HalHandle_t HalHandle, uint32_t dev_mask, uint32_t frequency );
+
+
+/*****************************************************************************/
+/**
+ * @brief   reads a value from a given address
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   reg_address Address of register to read.
+ * @return  Register value.
+ *
+ * @note    It is required to pass in the full address (base address + offset).
+ *****************************************************************************/
+INLINE uint32_t HalReadReg( HalHandle_t HalHandle, uint32_t reg_address );
+
+
+/*****************************************************************************/
+/**
+ * @brief   writes a value to the given address
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   reg_address Address of register to write.
+ * @param   value       Value to write into register.
+ * @return  none
+ *
+ * @note    It is required to pass in the full address (base address + offset).
+ *****************************************************************************/
+INLINE void HalWriteReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value );
+
+
+/*****************************************************************************/
+/**
+ * @brief   reads a value from a specific part of the given address
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   reg_address Address of register to read.
+ * @param   reg_mask    Mask to apply to register value after being read.
+ * @param   shift_mask  Amount to right shift masked register value prior being returned.
+ * @return  masked and shifted data of specific register part
+ *
+ * @note    It is required to pass in the full address (base address + offset).
+ *****************************************************************************/
+INLINE uint32_t HalReadMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask );
+
+
+/*****************************************************************************/
+/**
+ * @brief   writes a value to specific part of the given address
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   reg_address Address of register to write.
+ * @param   reg_mask    Mask to isolate parts of register that should be written.
+ * @param   shift_mask  Amount to left shift value prior being modified in register.
+ * @param   value       Value to write into specified register position.
+ * @return  none
+ *
+ * @note    It is required to pass in the full address (base address + offset).
+ *****************************************************************************/
+INLINE void HalWriteMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask, uint32_t value );
+
+
+/*****************************************************************************/
+/**
+ * @brief   reads a value from a given given system register
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   reg_address Address of system register to read.
+ * @return  Register value.
+ *
+ * @note    It is required to pass in the full address (base address + offset).
+ *          DEMO SYSTEM & VALIDATION USE ONLY, NOT INDENDED TO BE PORTABLE.
+ *****************************************************************************/
+INLINE uint32_t HalReadSysReg( HalHandle_t HalHandle, uint32_t reg_address );
+
+
+/*****************************************************************************/
+/**
+ * @brief   writes a value to the given system register
+ * @param   HalHandle   Handle to HAL session as returned by @ref HalOpen.
+ * @param   reg_address Address of system register to write.
+ * @param   value       Value to write into register.
+ * @return  none
+ *
+ * @note    It is required to pass in the full address (base address + offset).
+ *          DEMO SYSTEM & VALIDATION USE ONLY, NOT INDENDED TO BE PORTABLE.
+ *****************************************************************************/
+INLINE void HalWriteSysReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value );
+
+
+/*****************************************************************************/
+/**
+ * @brief   allocates the given amount of hardware memory
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   byte_size       Amount of memory to allocate.
+ * @return  mem_address     Memory block start address in hardware memory; 0 on failure.
+ *
+ * @note    Chunks of n*4K byte with addresses aligned to 4K are used internally.
+ *          The allocator behind the scenes may be very simple, but still will recombine
+ *          free'd adjacent blocks. It may perform reasonably well only for at most a
+ *          few dozen allocs active at any time. Allocating/freeing video/audio buffers in
+ *          realtime at framerate should nevertheless be posssible without noticeable
+ *          performance penalties then.
+ *****************************************************************************/
+uint32_t HalAllocMemory( HalHandle_t HalHandle, uint32_t byte_size );
+
+
+/*****************************************************************************/
+/**
+ * @brief   frees the given block of hardware memory
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   mem_address     Start address of memory block in hardware memory.
+ * @return  Result of operation.
+ *
+ * @note    Chunks of n*4K byte with addresses aligned to 4K are used internally.
+ *****************************************************************************/
+RESULT HalFreeMemory( HalHandle_t HalHandle, uint32_t mem_address );
+
+
+/*****************************************************************************/
+/**
+ * @brief   reads a number of data from the memory to a buffer starting a the given address
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   mem_address     Source start address in hardware memory.
+ * @param   p_read_buffer   Pointer to local memory holding the data being read.
+ * @param   byte_size       Amount of data to read.
+ * @return  Result of operation.
+ *
+ * @note    Certain implementation dependent limitations regarding alignment of
+ *          both addresses and transfer size exist!
+ *****************************************************************************/
+RESULT HalReadMemory( HalHandle_t HalHandle, uint32_t mem_address, uint8_t* p_read_buffer, uint32_t byte_size );
+
+
+/*****************************************************************************/
+/**
+ * @brief   writes a number of data from a buffer to the memory starting a the given address
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   mem_address     Target start address in hardware memory.
+ * @param   p_write_buffer  Pointer to local memory holding the data to be written.
+ *                          Undefined on failure.
+ * @param   byte_size       Amount of data to write.
+ * @return  Result of operation.
+ *
+ * @note    Certain implementation dependent limitations regarding alignment of
+ *          both addresses and transfer size exist!
+ *****************************************************************************/
+RESULT HalWriteMemory( HalHandle_t HalHandle, uint32_t mem_address, uint8_t* p_write_buffer, uint32_t byte_size );
+
+
+/*****************************************************************************/
+/**
+ * @brief   maps a number of data from the memory into local memory starting at the given address
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   mem_address     Source start address in hardware memory.
+ * @param   byte_size       Amount of data to map.
+ * @param   mapping_type    The way the mapping is performed.
+ * @param   pp_mapped_buf   Reference to pointer to the mapped local memory.
+ * @return  Result of operation.
+ *
+ * @note    Certain implementation dependent limitations regarding alignment of
+ *          both addresses and transfer size exist!
+ *****************************************************************************/
+RESULT HalMapMemory( HalHandle_t HalHandle, uint32_t mem_address, uint32_t byte_size, HalMapMemType_t mapping_type, void **pp_mapped_buf );
+
+
+/*****************************************************************************/
+/**
+ * @brief   unmaps previously mapped memory from local memory
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   p_mapped_buf    Pointer to local memory to unmap as returned by
+ *                          @ref HalMapMemory().
+ * @return  Result of operation.
+ *
+ * @note    Certain implementation dependent limitations regarding alignment of
+ *          both addresses and transfer size exist!
+ *****************************************************************************/
+RESULT HalUnMapMemory( HalHandle_t HalHandle, void* p_mapped_buf );
+
+
+/*****************************************************************************/
+/**
+ * @brief   reads a number of data from the memory to a buffer starting a the given address
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   bus_num         Number of bus which is to be used.
+ * @param   slave_addr      Address of slave to be accessed (supports auto detection of 10bit adresses).
+ * @param   reg_address     Address of register to read.
+ * @param   reg_addr_size   Size of @ref reg_address in bytes, valid range: 0..4 bytes.
+ * @param   p_read_buffer   Pointer to local memory holding the data being read.
+ * @param   byte_size       Amount of data to read.
+ * @return  Result of operation.
+ *
+ * @note
+ *****************************************************************************/
+RESULT HalReadI2CMem( HalHandle_t HalHandle, uint8_t bus_num, uint16_t slave_addr, uint32_t reg_address, uint8_t reg_addr_size, uint8_t *p_read_buffer, uint32_t byte_size );
+
+
+/*****************************************************************************/
+/**
+ * @brief   writes a number of data from a buffer to the memory starting a the given address
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   bus_num         Number of bus which is to be used.
+ * @param   slave_addr      Address of slave to be accessed (supports auto detection of 10bit adresses).
+ * @param   reg_address     Address of register to write.
+ * @param   reg_addr_size   Size of @ref reg_address in bytes, valid range: 0..4 bytes.
+ * @param   p_write_buffer  Pointer to local memory holding the data to be written.
+ * @param   byte_size       Amount of data to write.
+ * @return  Result of operation.
+ *
+ * @note
+ *****************************************************************************/
+RESULT HalWriteI2CMem( HalHandle_t HalHandle, uint8_t bus_num, uint16_t slave_addr, uint32_t reg_address, uint8_t reg_addr_size, uint8_t *p_write_buffer, uint32_t byte_size );
+
+
+/*****************************************************************************/
+/**
+ * @brief   reads a number of data from the memory to a buffer starting a the given address
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   bus_num         Number of bus which is to be used.
+ * @param   slave_addr      Address of slave to be accessed (supports auto detection of 10bit adresses).
+ * @param   reg_address     Address of register to read.
+ * @param   reg_addr_size   Size of @ref reg_address in bytes, valid range: 0..4 bytes.
+ * @param   preg_value      Pointer to local memory holding the register data being read.
+ * @param   reg_size        Size of register in bytes, valid range: 1..4.
+ * @return  Result of operation.
+ *
+ * @note    The register data gets read starting with the least significant byte!
+ *****************************************************************************/
+INLINE RESULT HalReadI2CReg( HalHandle_t HalHandle, uint8_t bus_num, uint16_t slave_addr, uint32_t reg_address, uint8_t reg_addr_size, void *preg_value, uint8_t reg_size )
+{
+    if ((reg_size < 1) || (reg_size > 4))
+    {
+        return RET_INVALID_PARM;
+    }
+
+    return HalReadI2CMem( HalHandle, bus_num, slave_addr, reg_address, reg_addr_size, (uint8_t*)preg_value, reg_size );
+}
+
+/*****************************************************************************/
+/**
+ * @brief   writes a number of data from a buffer to the memory starting a the given address
+ * @param   HalHandle       Handle to HAL session as returned by @ref HalOpen.
+ * @param   bus_num         Number of bus which is to be used.
+ * @param   slave_addr      Address of slave to be accessed (supports auto detection of 10bit adresses).
+ * @param   reg_address     Address of register to write.
+ * @param   reg_addr_size   Size of @ref reg_address in bytes, valid range: 0..4 bytes.
+ * @param   reg_value       Register data to be written.
+ * @param   reg_size        Size of register in bytes, valid range: 1..4.
+ * @return  Result of operation.
+ *
+ * @note    The register data gets written starting with the least significant byte!
+ *****************************************************************************/
+INLINE RESULT HalWriteI2CReg( HalHandle_t HalHandle, uint8_t bus_num, uint16_t slave_addr, uint32_t reg_address, uint8_t reg_addr_size, uint32_t reg_value, uint8_t reg_size )
+{
+    if ((reg_size < 1) || (reg_size > 4))
+    {
+        return RET_INVALID_PARM;
+    }
+
+    return HalWriteI2CMem( HalHandle, bus_num, slave_addr, reg_address, reg_addr_size, (uint8_t*)&reg_value, reg_size );
+}
+
+
+/*****************************************************************************/
+/**
+ *          HalConnectIrq()
+ *
+ *  @brief  Register interrupt service routine with system software.
+ *
+ *  @param  Handle to HAL session as returned by @ref HalOpen
+ *  @param  Reference of hal irq context structure that represent this connection
+ *  @param  Interrupt object @ref osInterrupt
+ *  @param  Number of the interrupt source, set to 0 if not needed
+ *  @param  First interrupt routine, (first level handler) set to NULL if not needed
+ *  @param  Second interrupt routine (second level handler)
+ *  @param  Context provided when the interrupt routines are called
+ *
+ *  @warning Add platform specific code to connect to your local interrupt source
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         ISR registered successfully
+ *  @retval RET_FAILURE et al.  ISR not registered
+ *
+ *****************************************************************************/
+RESULT HalConnectIrq
+(
+    HalHandle_t HalHandle,
+    HalIrqCtx_t *pIrqCtx,
+    uint32_t    int_src,
+    osIsrFunc   IsrFunction,
+    osDpcFunc   DpcFunction,
+    void*       pContext
+);
+
+/*****************************************************************************/
+/**
+ *          HalDisconnectIrq()
+ *
+ *  @brief  Deregister interrupt service routine from system software.
+ *
+ *  @param  Reference of hal irq context structure that represent this connection
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         ISR deregistered successfully
+ *  @retval RET_FAILURE et al.  ISR not properly deregistered
+ *
+ *****************************************************************************/
+RESULT HalDisconnectIrq
+(
+    HalIrqCtx_t *pIrqCtx
+);
+
+#if defined (HAL_CMODEL)
+/*****************************************************************************/
+/**
+ *          HalCmHwInit()
+ *
+ *  @brief  Cmodel specific interface: Setup register initial value
+ *
+ *  @param  ISP instance type
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         Input set successfully
+ *  @retval RET_FAILURE et al.  Input set fails
+ *
+ *****************************************************************************/
+RESULT HalCmHwInit(HalHandle_t HalHandle, uint32_t isp_type, const char* iniRegFileName);
+
+/*****************************************************************************/
+/**
+ *          HalCmInputInfoSetup()
+ *
+ *  @brief  Cmodel specific interface: Setup input h and v size
+ *
+ *  @param  h_size, v_size: image size of input port.
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         Input set successfully
+ *  @retval RET_FAILURE et al.  Input set fails
+ *
+ *****************************************************************************/
+// Set h and v size for simulation
+RESULT HalCmInputInfoSetup(
+    unsigned int h_size,
+    unsigned int v_size
+);
+
+/*****************************************************************************/
+/**
+ *          HalCmBufTransfer()
+ *
+ *  @brief  Cmodel specific interface: Buffer transfer for DMA
+ *
+ *  @param
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         Input set successfully
+ *  @retval RET_FAILURE et al.  Input set fails
+ *
+ *****************************************************************************/
+RESULT HalCmBufTransfer(    HalHandle_t HalHandle,  uint32_t trans_ctrl);
+
+#ifdef ISP_GCMONO
+/*****************************************************************************/
+/**
+ *          HalCmGcmonoBufFill()
+ *
+ *  @brief  Cmodel specific interface: Buffer transfer for GCMONO
+ *
+ *  @param
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         Input set successfully
+ *  @retval RET_FAILURE et al.  Input set fails
+ *
+ *****************************************************************************/
+RESULT HalCmGcmonoBufFill(HalHandle_t HalHandle, uint8_t* gc_lut, unsigned int lut_length);
+#endif
+
+/******************************************************************************
+ * Cmodel Specific API: HalCmShdRegisterUpdate
+ *****************************************************************************/
+// Cmodel Shd register update process
+RESULT HalCmShdRegisterUpdate(HalHandle_t HalHandle);
+
+
+/*****************************************************************************/
+/**
+ *          HalCmBufConfig()
+ *
+ *  @brief  Cmodel specific interface: Buffer transfer Configuration
+ *
+ *  @param
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         Input set successfully
+ *  @retval RET_FAILURE et al.  Input set fails
+ *
+ *****************************************************************************/
+RESULT HalCmGetBufConfig(    HalHandle_t HalHandle, HalCmodelBufConfig_t** pCmBufCfg);
+
+
+/*****************************************************************************/
+/**
+ *          HalCmISPpipeline()
+ *
+ *  @brief  Cmodel specific interface: Hal ISP8000Process
+ *
+ *  @param  none
+ *
+ *  @return                     Status of operation
+ *    none
+ *
+ *****************************************************************************/
+void HalCmISPpipeline(HalHandle_t HalHandle);
+
+/*****************************************************************************/
+/**
+ *          HalCmDumpBuf()
+ *
+ *  @brief  Cmodel specific interface: memory dump functions
+ *
+ *  @param  buf: base address of memory
+ *          len: length of memory
+ *          str: debug info
+ *
+ *  @return                     None
+ *
+ *****************************************************************************/
+void HalCmDumpBuf(   char *buf, int len, char* str);
+
+/*****************************************************************************/
+/**
+ *          HalCmDumpReFill()
+ *
+ *  @brief  Cmodel specific interface: from Cmodel memory dump
+ *      re-pick up and fill buffer
+ *
+ *  @param  buffer: base address of memory
+ *          file: cmodel dump file
+ *          buf_len: buffer limitation
+ *
+ *  @return                     None
+ *
+ *****************************************************************************/
+RESULT HalCmDumpReFill( unsigned char * buffer, const char* file, unsigned int buf_len);
+
+
+#endif
+
+/*****************************************************************************/
+/**
+ *          HalEventGenerator()
+ *
+ *  @brief  Cmodel specific interface: Hal ISR and Event generator
+ *
+ *  @param
+ *
+ *  @return                     Status of operation
+ *  @retval RET_SUCCESS         Input set successfully
+ *  @retval RET_FAILURE et al.  Input set fails
+ *
+ *****************************************************************************/
+RESULT HalEventGenerator(    HalIrqCtx_t *pIrqCtx, HalIsrSrc_t isr_src, uint32_t misValue);
+
+#if defined ( HAL_ALTERA )
+/*****************************************************************************/
+/**
+ *          HalFpgaDumpBuf()
+ *
+ *  @brief  FPGA online dump function: memory dump functions
+ *
+ *  @param  buf: base address of memory
+ *          len: length of memory
+ *          str: debug info
+ *
+ *  @return                     None
+ *
+ *****************************************************************************/
+void HalFpgaDumpBuf (char *buf, int len, char* str);
+
+
+/*****************************************************************************/
+/**
+ *          HalFpgaReset()
+ *
+ *  @brief  FPGA online set FPGA to reset status
+ *
+ *  @param
+ *
+ *  @return                     None
+ *
+ *****************************************************************************/
+void HalFpgaReset(HalHandle_t HalHandle);
+
+/*****************************************************************************/
+/**
+ *          HalFpgaDereset()
+ *
+ *  @brief  FPGA online set FPGA out of reset mode
+ *
+ *  @param
+ *
+ *  @return                     None
+ *
+ *****************************************************************************/
+void HalFpgaDereset(HalHandle_t HalHandle);
+
+void HalFpgaPreSet(HalHandle_t HalHandle);
+
+#endif
+
+/******************************************************************************
+ * stuff below here requires the inline API implementations being included
+ * as it requires some more hal variant depended header files being loaded
+ *****************************************************************************/
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+//!@} defgroup HAL_API
+
+#endif /* __HAL_API_H__ */

+ 690 - 0
isp_isp8000l/units/hal/hal_cmodel.h

@@ -0,0 +1,690 @@
+/******************************************************************************\
+|* Copyright (c) 2020 by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")       *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+/**
+ * @file hal_cmodel.h
+ *
+ * @brief   MockedUp variant of Hardware Abstraction Layer
+ *
+ *          Exports the cmodel version of the HAL API's inline functions. You could
+ *          use it for your PC implementation to check general interaction of your
+ *          code with the HAL.
+ * @note    Do not include directly! Include hal_api.h instead with HAL_CMODEL defined.
+ *
+ *****************************************************************************/
+
+#ifndef __HAL_CMODEL_H__
+#define __HAL_CMODEL_H__
+#include <ebase/trace.h>
+#include <cmodel_wrapper/cmodel_wrapper.h>
+#include <common/picture_buffer.h>
+
+
+/******************************************************************************
+ * local macro definitions
+ *****************************************************************************/
+#define NUM_I2C 3
+
+/*****************************************************************************/
+/**
+ * @brief   different ways of how mapping of data from the memory into local memory is done
+ *****************************************************************************/
+typedef enum HalMapMemType_s
+{
+    HAL_MAPMEM_READWRITE = 0,   //!< Maps memory for read/write access.
+    HAL_MAPMEM_READONLY,        //!< Maps memory for read access only, system action on write access is undefined
+    HAL_MAPMEM_WRITEONLY        //!< Maps memory for write access only, system action on read access is undefined
+} HalMapMemType_t;
+
+/******************************************************************************
+ * local type definitions
+ *****************************************************************************/
+typedef struct HalCamConfig_s
+{
+    bool_t configured;      //!< Mark whether this config was set.
+    bool_t power_lowact;    //!< Power on is low-active.
+    bool_t reset_lowact;    //!< Reset is low-active.
+    //bool_t negedge;         //!< Capture data on negedge.
+} HalCamConfig_t;
+
+typedef struct HalCamPhyConfig_s
+{
+    bool_t configured;      //!< Mark whether this config was set.
+    bool_t power_lowact;    //!< Power on is low-active.
+    bool_t reset_lowact;    //!< Reset is low-active.
+} HalCamPhyConfig_t;
+
+typedef struct HalMemMap_s
+{
+    uint32_t        mem_address;    //!< Hardware memory address.
+    uint32_t        byte_size;      //!< Size of mapped buffer.
+    HalMapMemType_t mapping_type;   //!< How the buffer is mapped.
+} HalMemMap_t;
+
+#if 0
+/******************************************************************************
+ * HalCmodelBufType_t
+ *****************************************************************************/
+typedef enum HalCmodelBufType_e
+{
+    eHalCmodelBufTypeRAW8     = 0x0000,
+    eHalCmodelBufTypeRAW16,
+    eHalCmodelBufTypeYCbCr444,
+    eHalCmodelBufTypeYCbCr422,
+    eHalCmodelBufTypeYCbCr420,
+    eHalCmodelBufTypeYCbCr400,
+    eHalCmodelBufTypeJPEG,
+    eHalCmodelBufTypeRGB565,
+    eHalCmodelBufTypeRGB666,
+    eHalCmodelBufTypeRGB888,
+    eHalCmodelBufTypeMax,
+}HalCmodelBufType_t;
+
+/******************************************************************************
+ * HalCmodelBufLayout_t
+ *****************************************************************************/
+typedef enum HalCmodelBufLayout_e
+{
+    eHalCmodelBufLayoutBayerRGRGGBGB     = 0x0000,
+    eHalCmodelBufLayoutBayerGRGRBGBG,
+    eHalCmodelBufLayoutBayerGBGBRGRG,
+    eHalCmodelBufLayoutBayerBGBGGRGR,
+    eHalCmodelBufLayoutPlanar,
+    eHalCmodelBufLayoutSemiPlanar,
+    eHalCmodelBufLayoutCombined,
+    eHalCmodelBufLayoutMax,
+}HalCmodelBufLayout_t;
+#endif
+
+#define HAL_CMODEL_BUF_TRANS_DMA   0x0001
+#define HAL_CMODEL_BUF_TRANS_MP    0x0002
+#define HAL_CMODEL_BUF_TRANS_SP    0x0004
+#define HAL_CMODEL_BUF_TRANS_SP2_BP    0x0008
+#define HAL_CMODEL_BUF_TRANS_PP    0x00010
+
+#define HAL_CMODEL_BUF_TRANS_HDR_RET    0x00020
+#define HAL_CMODEL_BUF_TRANS_MASK  0x0003F
+
+
+/******************************************************************************
+ * HalCmodelBufConfig_t
+ *****************************************************************************/
+typedef struct HalCmodelBufConfig_s{
+    //DMA input buffer configurations
+    PicBufType_t cmDmaBufType;
+    PicBufLayout_t cmDmaBufLayout;
+    uint32_t cmDmaBaseY;
+    uint32_t cmDmaWidthY;
+    uint32_t cmDmaHeightY;
+    uint32_t cmDmaBaseCb;
+    uint32_t cmDmaBaseCr;
+    uint32_t cmDmaIntEnabled;
+    //tobe expand later for y_burstlength, c_burstlength
+
+    //Main Path buffer configurations
+    PicBufType_t cmMpBufType;
+    PicBufLayout_t cmMpBufLayout;
+    uint32_t cmMpBaseY;
+    uint32_t cmMpSizeY;
+    uint32_t cmMpOffsY;
+    uint32_t cmMpPicWidthPixelY;
+    uint32_t cmMpPicHeightPixelY;
+
+    uint32_t cmMpBaseCb;
+    uint32_t cmMpSizeCb;
+    uint32_t cmMpOffsCb;
+    uint32_t cmMpPicWidthPixelCb;
+    uint32_t cmMpPicHeightPixelCb;
+
+    uint32_t cmMpBaseCr;
+    uint32_t cmMpSizeCr;
+    uint32_t cmMpOffsCr;
+    uint32_t cmMpPicWidthPixelCr;
+    uint32_t cmMpPicHeightPixelCr;
+    uint32_t cmMpIntEnabled;
+
+    //shd register
+    uint32_t cmMpBaseYShd;
+    uint32_t cmMpSizeYShd;
+    uint32_t cmMpOffsYShd;
+    uint32_t cmMpPicWidthPixelYShd;
+    uint32_t cmMpPicHeightPixelYShd;
+
+    uint32_t cmMpBaseCbShd;
+    uint32_t cmMpSizeCbShd;
+    uint32_t cmMpOffsCbShd;
+    uint32_t cmMpPicWidthPixelCbShd;
+    uint32_t cmMpPicHeightPixelCbShd;
+
+    uint32_t cmMpBaseCrShd;
+    uint32_t cmMpSizeCrShd;
+    uint32_t cmMpOffsCrShd;
+    uint32_t cmMpPicWidthPixelCrShd;
+    uint32_t cmMpPicHeightPixelCrShd;
+
+    //Self Path buffer configurations
+    PicBufType_t cmSpBufType;
+    PicBufLayout_t cmSpBufLayout;
+    uint32_t cmSpBaseY;
+    uint32_t cmSpSizeY;
+    uint32_t cmSpOffsY;
+    uint32_t cmSpPicWidthPixelY;
+    uint32_t cmSpPicHeightPixelY;
+
+    uint32_t cmSpBaseCb;
+    uint32_t cmSpSizeCb;
+    uint32_t cmSpOffsCb;
+    uint32_t cmSpPicWidthPixelCb;
+    uint32_t cmSpPicHeightPixelCb;
+
+    uint32_t cmSpBaseCr;
+    uint32_t cmSpSizeCr;
+    uint32_t cmSpOffsCr;
+    uint32_t cmSpPicWidthPixelCr;
+    uint32_t cmSpPicHeightPixelCr;
+
+    uint32_t cmSpRotEn;
+    uint32_t cmSpVFlip;
+    uint32_t cmSpHFlip;
+
+    uint32_t cmSpIntEnabled;
+
+    //Shd register
+    uint32_t cmSpBaseYShd;
+    uint32_t cmSpSizeYShd;
+    uint32_t cmSpOffsYShd;
+    uint32_t cmSpPicWidthPixelYShd;
+    uint32_t cmSpPicHeightPixelYShd;
+
+    uint32_t cmSpBaseCbShd;
+    uint32_t cmSpSizeCbShd;
+    uint32_t cmSpOffsCbShd;
+    uint32_t cmSpPicWidthPixelCbShd;
+    uint32_t cmSpPicHeightPixelCbShd;
+
+    uint32_t cmSpBaseCrShd;
+    uint32_t cmSpSizeCrShd;
+    uint32_t cmSpOffsCrShd;
+    uint32_t cmSpPicWidthPixelCrShd;
+    uint32_t cmSpPicHeightPixelCrShd;
+
+
+	//Self Path2 buffer configurations
+    PicBufType_t cmSp2BufType;
+    PicBufLayout_t cmSp2BufLayout;
+    uint32_t cmSp2BaseY;
+    uint32_t cmSp2SizeY;
+    uint32_t cmSp2OffsY;
+    uint32_t cmSp2PicWidthPixelY;
+    uint32_t cmSp2PicHeightPixelY;
+
+    uint32_t cmSp2BaseCb;
+    uint32_t cmSp2SizeCb;
+    uint32_t cmSp2OffsCb;
+    uint32_t cmSp2PicWidthPixelCb;
+    uint32_t cmSp2PicHeightPixelCb;
+
+    uint32_t cmSp2BaseCr;
+    uint32_t cmSp2SizeCr;
+    uint32_t cmSp2OffsCr;
+    uint32_t cmSp2PicWidthPixelCr;
+    uint32_t cmSp2PicHeightPixelCr;
+
+    uint32_t cmSp2RotEn;
+    uint32_t cmSp2VFlip;
+    uint32_t cmSp2HFlip;
+
+    uint32_t cmSp2BpIntEnabled;
+
+    //Shd register
+    uint32_t cmSp2BaseYShd;
+    uint32_t cmSp2SizeYShd;
+    uint32_t cmSp2OffsYShd;
+    uint32_t cmSp2PicWidthPixelYShd;
+    uint32_t cmSp2PicHeightPixelYShd;
+
+    uint32_t cmSp2BaseCbShd;
+    uint32_t cmSp2SizeCbShd;
+    uint32_t cmSp2OffsCbShd;
+    uint32_t cmSp2PicWidthPixelCbShd;
+    uint32_t cmSp2PicHeightPixelCbShd;
+
+    uint32_t cmSp2BaseCrShd;
+    uint32_t cmSp2SizeCrShd;
+    uint32_t cmSp2OffsCrShd;
+    uint32_t cmSp2PicWidthPixelCrShd;
+    uint32_t cmSp2PicHeightPixelCrShd;
+
+	//cameric post process buffer configurations
+    PicBufType_t cmPpBufType;
+    PicBufLayout_t cmPpBufLayout;
+    uint32_t cmPpBaseY;
+    uint32_t cmPpSizeY;
+    uint32_t cmPpOffsY;
+    uint32_t cmPpPicWidthPixelY;
+    uint32_t cmPpPicHeightPixelY;
+
+    uint32_t cmPpBaseCb;
+    uint32_t cmPpSizeCb;
+    uint32_t cmPpOffsCb;
+    uint32_t cmPpPicWidthPixelCb;
+    uint32_t cmPpPicHeightPixelCb;
+
+    uint32_t cmPpBaseCr;
+    uint32_t cmPpSizeCr;
+    uint32_t cmPpOffsCr;
+    uint32_t cmPpPicWidthPixelCr;
+    uint32_t cmPpPicHeightPixelCr;
+
+    uint32_t cmPpRotEn;
+    uint32_t cmPpVFlip;
+    uint32_t cmPpHFlip;
+
+    uint32_t cmPpIntEnabled;
+
+    //Shd register
+    uint32_t cmPpBaseYShd;
+    uint32_t cmPpSizeYShd;
+    uint32_t cmPpOffsYShd;
+    uint32_t cmPpPicWidthPixelYShd;
+    uint32_t cmPpPicHeightPixelYShd;
+
+    uint32_t cmPpBaseCbShd;
+    uint32_t cmPpSizeCbShd;
+    uint32_t cmPpOffsCbShd;
+    uint32_t cmPpPicWidthPixelCbShd;
+    uint32_t cmPpPicHeightPixelCbShd;
+
+    uint32_t cmPpBaseCrShd;
+    uint32_t cmPpSizeCrShd;
+    uint32_t cmPpOffsCrShd;
+    uint32_t cmPpPicWidthPixelCrShd;
+    uint32_t cmPpPicHeightPixelCrShd;
+
+#ifdef ISP_MI_BP
+//bayper Pattern buffer configurations
+    PicBufType_t cmBpBufType;
+    PicBufLayout_t cmBpBufLayout;
+    uint32_t cmBpBaseR;
+    uint32_t cmBpSizeR;
+    uint32_t cmBpOffsR;
+
+    uint32_t cmBpBaseGr;
+    uint32_t cmBpSizeGr;
+    uint32_t cmBpOffsGr;
+
+    uint32_t cmBpBaseGb;
+    uint32_t cmBpSizeGb;
+    uint32_t cmBpOffsGb;
+
+
+    uint32_t cmBpBaseB;
+    uint32_t cmBpSizeB;
+    uint32_t cmBpOffsB;
+
+    uint32_t cmBpPicWrOffsCntInit;
+    uint32_t cmBpPicWrIrqOffsInit;
+    uint32_t cmBpPicWrSizeInit;
+
+    uint32_t cmBpPicWrLlength;
+    uint32_t cmBpPicWrWidth;
+    uint32_t cmBpPicWrHeight;
+    uint32_t cmBpPicSize;
+    uint32_t cmBpIntEnabled;
+//Shd register
+    uint32_t cmBpBaseRShd;
+    uint32_t cmBpSizeRShd;
+    uint32_t cmBpOffsRShd;
+
+    uint32_t cmBpBaseGrShd;
+    uint32_t cmBpSizeGrShd;
+    uint32_t cmBpOffsGrShd;
+
+    uint32_t cmBpBaseGbShd;
+    uint32_t cmBpSizeGbShd;
+    uint32_t cmBpOffsGbShd;
+
+    uint32_t cmBpBaseBShd;
+    uint32_t cmBpSizeBShd;
+    uint32_t cmBpOffsBShd;
+
+#endif
+
+    int frame_cnt;
+
+#ifdef ISP_MI_HANDSHAKE_NANO
+    uint32_t cmMiMpHandshkSwitch;
+    uint32_t cmMiMpHandshkStrFmt;
+    uint32_t cmMiMpHandshkDataFmt;
+
+    uint32_t cmMiMpHandshkLinePerSliceMinus1;
+    uint32_t cmMiMpHandshkSlicePerBufferMinus1;
+    uint32_t cmMiMpHandshkAckCount;
+
+    uint32_t cmMiMpHandshkYbaseAdInit;
+    uint32_t cmMiMpHandshkCbbaseAdInit;
+    uint32_t cmMiMpHandshkCrbaseAdInit;
+
+    uint32_t cmMiMpHandshkYLlengthPixel;
+    uint32_t cmMiMpHandshkYSliceOffsetBytes;
+    uint32_t cmMiMpHandshkCSliceOffsetBytes;
+
+    uint32_t cmMiMpHandshkYPicWidthPixel;
+    uint32_t cmMiMpHandshkYPicHeightPixel;
+    uint32_t cmMiMpHandshkYPicSizePixel;    //auto calculation, no need to fill
+
+    uint32_t cmMpYBufSize;          //Y buffer size
+    uint32_t cmMpCBufSize;          //Cb buffer size
+#endif
+}HalCmodelBufConfig_t;
+
+
+typedef enum HalInterruptType_e{
+    eHAL_INT_MI_DMA_READY    =0x0000,
+    eHAL_INT_MI_FRAME_END_MP,
+    eHAL_INT_MI_FRAME_END_SP,
+	eHAL_INT_MI_FRAME_END_SP2_BP,
+    eHAL_INT_MI_RAW_FRAME_END_SP2_BP,
+    eHAL_INT_MI2_FRAME_END_PPW,
+    eHAL_INT_ISP_OFF,
+    eHal_INT_ISP_HistM,
+    eHal_INT_ISP_ExpM,
+    eHal_INT_ISP_WbM,
+    eHal_INT_ISP_AfmM,
+    eHal_INT_ISP_VsmM,
+
+    eHAL_INTMax,
+}HalInterruptType_t;
+
+typedef enum HalModule_s
+{
+    HAL_MODULE_VIDEO   = 0x01,//!<video in V4L2
+    HAL_MODULE_ISP     = 0x02,//!<ISP
+    HAL_MODULE_VIN     = 0x04,//!<VIN:mipi-csi2 dvp bt656 bt601
+    HAL_MODULE_SENSOR  = 0x08,//!<Sensor
+    HAL_MODULE_SOC     = 0x10,//!<SoC
+}HalModule_e;
+
+typedef struct __HalBuffPoolCtx__
+{
+    BufIdentity bufPoolMp[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolSP1[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolSP2[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolRdi[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolMeta[BUFF_POOL_MAX_OUTPUT_BUF_NUMBER];
+    BufIdentity bufPoolRead[BUFF_POOL_MAX_INPUT_BUF_NUMBER];
+    uint32_t    bufPoolMpNum;
+    uint32_t    bufPoolSP1Num;
+    uint32_t    bufPoolSP2Num;
+    uint32_t    bufPoolRdiNum;
+    uint32_t    bufPoolMetaNum;
+    uint32_t    bufPoolReadNum;
+}HalBuffPoolCtx;
+
+/******************************************************************************
+ * HalContext_t
+ *****************************************************************************/
+typedef struct HalContext_s
+{
+    osMutex               modMutex;               //!< common short term mutex; e.g. for read-modify-write accesses
+    uint32_t              refCount;               //!< internal ref count
+
+    osMutex               iicMutex[NUM_I2C];      //!< transaction locks for I2C controller 1..NUM_I2C
+
+    HalCamConfig_t        cam1Config;             //!< configuration for CAM1; set at runtime
+    HalCamPhyConfig_t     camPhy1Config;          //!< configuration for CAMPHY1; set at runtime
+    HalCmodelBufConfig_t  halCmodelbufCfg;        //!< configuration for HalCmodel buffer configurations
+    osDpcFunc             halIsrFunTable[eHalIsrMax];  //!< hal Cmodel Isr source and function table
+
+    char*                 regDynDumpName;         //!< register dump name.
+    FILE*                 regDynDumpFp;           //!< dynamic dump handle
+
+    HalBuffPoolCtx      halBufPool;
+    BUFF_MODE           buf_work_mode;
+    uint32_t            isp_index;
+    uint32_t            sensor_index;
+    int32_t             isp_fd;
+    int32_t             csi_fd;
+    int32_t             sensor_fd;
+    int32_t             soc_fd;
+
+} HalContext_t;
+
+/*****************************************************************************/
+/**
+ * @brief   handle to hal instance
+ *****************************************************************************/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+USE_TRACER(HAL_ERROR);
+
+/******************************************************************************
+ * HAL device IDs
+ *****************************************************************************/
+#define HAL_DEVID_OCP       0x00000001  //!< HAL internal use only
+#define HAL_DEVID_MARVIN    0x00000002  //!< MARVIN.*
+#define HAL_DEVID_VDU       0x00000004  //!< VDU.clk + VDU.ocpclk
+#define HAL_DEVID_PCLK      0x00000008  //!< VDU.pclk
+#define HAL_DEVID_I2C_0     0x00000010  //!< HAL internal use only
+#define HAL_DEVID_I2C_1     0x00000020  //!< HAL internal use only
+#define HAL_DEVID_I2C_2     0x00000040  //!< HAL internal use only
+#define HAL_DEVID_CAMREC_1  0x00000080  //!< CAMREC1, not neccessarily the REC that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_REC instead
+#define HAL_DEVID_INTERNAL  0x000000ff  //!< just internal devices included
+
+#define HAL_DEVID_CAM_1     0x10000000  //!< CAM1
+#define HAL_DEVID_CAMPHY_1  0x20000000  //!< CAMPHY1, not neccessarily the PHY that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_PHY instead
+#define HAL_DEVID_EXTERNAL  0x30000000  //!< just external devices included
+
+#define HAL_DEVID_ALL       (HAL_DEVID_INTERNAL | HAL_DEVID_EXTERNAL) //!< all devices included
+
+
+/******************************************************************************
+ * HAL device base addresses
+ *****************************************************************************/
+// HalRegs:
+#define HAL_BASEADDR_MARVIN    0x00000000 //!< Base address of MARVIN module.
+#define HAL_BASEADDR_MARVIN_2  0x00010000 //!< Base address of MARVIN module of 2nd channel.
+#define HAL_BASEADDR_MIPI_1    0x00000000 //!< Base address of MIPI module.
+#define HAL_BASEADDR_MIPI_2    0x00010000 //!< Base address of MIPI module of 2nd channel.
+#define HAL_BASEADDR_VDU       0x00008000 //!< Base address of VDU module.
+
+// HalSysRegs:
+#define HAL_BASEADDR_SYSCTRL   0x00000000 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_0     0x00001000 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_1     0x00001800 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_2     0x00000800 //!< HAL internal use only
+
+
+/******************************************************************************
+ * HAL device base region
+ *****************************************************************************/
+// HalRegs:
+#define HAL_BASEREGION_MARVIN    0 //!< Base region of MARVIN module(s).
+#define HAL_BASEREGION_MIPI      0 //!< Base region of MIPI module(s).
+#define HAL_BASEREGION_VDU       0 //!< Base region of VDU module.
+
+// HalSysRegs:
+#define HAL_BASEREGION_SYSCTRL   2 //!< HAL internal use only
+#define HAL_BASEREGION_I2C       2 //!< HAL internal use only
+
+
+/******************************************************************************
+ * HAL I2C bus location
+ *****************************************************************************/
+#define HAL_I2C_BUS_CAM_1       0 //!< Num of I2C bus CAM1 is connected to
+#define HAL_I2C_BUS_CAM_2       1 //!< Num of I2C bus CAM2 is connected to
+#define HAL_I2C_BUS_HDMI_TX     2 //!< Num of I2C bus HDMI TX is connected to
+#define HAL_I2C_BUS_CAMPHY_1    0 //!< Num of I2C bus CAMPHY1 is connected to
+#define HAL_I2C_BUS_CAMPHY_2    1 //!< Num of I2C bus CAMPHY1 is connected to
+
+
+/******************************************************************************
+ * HAL CAM to PHY/REC mapping
+ *****************************************************************************/
+#define HAL_DEVID_CAM_1_PHY     HAL_DEVID_CAMPHY_1 //!< DEVID of CAMPHY CAM1 is connected to
+#define HAL_DEVID_CAM_2_PHY     HAL_DEVID_CAMPHY_1 //!< DEVID of CAMPHY CAM2 is connected to
+#define HAL_DEVID_CAM_1_REC     HAL_DEVID_CAMREC_1 //!< DEVID of CAMREC CAM1 is connected to
+#define HAL_DEVID_CAM_2_REC     HAL_DEVID_CAMREC_1 //!< DEVID of CAMREC CAM2 is connected to
+
+
+/******************************************************************************
+ * @brief   writes a value to specific part of the given variable
+ * @return  new value of variable
+ *
+ * @note    It is required to pass a variable (not a register!)
+ *          and the masks (reg_mask and shift_mask) by using constant defines.
+ *          This function is used internally by HalWriteMaskedReg() but can also
+ *          be used directly to write values into a (temporary) variable.
+ *****************************************************************************/
+INLINE uint32_t HalSetMaskedValue( uint32_t reg_value, uint32_t reg_mask, uint32_t shift_mask, uint32_t value )
+{
+    return (reg_value & ~(reg_mask)) | ((value << shift_mask) & reg_mask);
+}
+
+/******************************************************************************
+ * @brief   reads a value from a specific part of the given variable
+ * @return  masked and shifted data of specific variable part
+ *
+ * @note    It is required to pass a variable (not a register!)
+ *          and the masks (reg_mask and shift_mask) by using constant defines.
+ *          This function is used internally by HalReadMaskedReg() but can also
+ *          be used directly to read values from a (temporary) variable.
+ *****************************************************************************/
+INLINE uint32_t HalGetMaskedValue( uint32_t reg_value, uint32_t reg_mask, uint32_t shift_mask )
+{
+    return ((reg_value & reg_mask) >> shift_mask);
+}
+
+/******************************************************************************
+ * HalReadReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadReg( HalHandle_t HalHandle, uint32_t reg_address )
+{
+    unsigned int data;
+    struct HalContext_s * HalHandleCtx = (struct HalContext_s *)HalHandle;
+
+    DCT_ASSERT(HalHandle != NULL);
+
+    readRegister(reg_address, &data);
+
+    if (HalHandleCtx->regDynDumpFp)
+    {
+        fprintf(HalHandleCtx->regDynDumpFp, "1 %08x %08x\n", (unsigned int)reg_address, (unsigned int)data);
+    }
+
+    return data;
+}
+
+/******************************************************************************
+ * HalWriteReg()
+ *****************************************************************************/
+INLINE void HalWriteReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value )
+{
+    struct HalContext_s * HalHandleCtx = (struct HalContext_s *)HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    if (HalHandleCtx->regDynDumpFp)
+    {
+        fprintf(HalHandleCtx->regDynDumpFp, "0 %08x %08x\n", (unsigned int)reg_address, (unsigned int)value);
+    }
+
+    writeRegister(reg_address, value);
+
+}
+
+/******************************************************************************
+ * HalReadMaskedReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask )
+{
+    DCT_ASSERT(HalHandle != NULL);
+
+    uint32_t tmp_value = HalReadReg( HalHandle, reg_address );
+    return HalGetMaskedValue( tmp_value, reg_mask, shift_mask );
+}
+
+/******************************************************************************
+ * HalWriteMaskedReg()
+ *****************************************************************************/
+INLINE void HalWriteMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask, uint32_t value )
+{
+    DCT_ASSERT(HalHandle != NULL);
+
+    uint32_t tmp_value = HalReadReg( HalHandle, reg_address );
+    tmp_value = HalSetMaskedValue( tmp_value, reg_mask, shift_mask, value );
+    HalWriteReg( HalHandle, reg_address, tmp_value );
+}
+
+/******************************************************************************
+ * HalReadSysReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadSysReg( HalHandle_t HalHandle, uint32_t reg_address )
+{
+    return HalReadReg(HalHandle, reg_address);
+}
+
+/******************************************************************************
+ * HalWriteSysReg()
+ *****************************************************************************/
+INLINE void HalWriteSysReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value )
+{
+    HalWriteReg(HalHandle, reg_address, value);
+}
+
+/******************************************************************************
+ * HalWriteSysReg()
+ *****************************************************************************/
+RESULT HalDynRegDumpOpen( HalHandle_t HalHandle, char* regDynDumpName );
+
+/******************************************************************************
+ * HalDynRegDumpClose()
+ *****************************************************************************/
+RESULT HalDynRegDumpClose( HalHandle_t HalHandle );
+
+INLINE RESULT HalKernelAddrMap(HalHandle_t HalHandle , BufIdentity * bufIdentify) {
+	return 0;
+}
+
+INLINE BufIdentity* HalGetPoolList(HalHandle_t HalHandle, ISPCORE_BUFIO_ID chain) {
+	return NULL;
+}
+
+INLINE uint32_t* HalGetPoolNumHandle(HalHandle_t HalHandle, ISPCORE_BUFIO_ID chain) {
+	return NULL;
+}
+
+INLINE RESULT HalSetBuffMode(HalHandle_t HalHandle, BUFF_MODE buf_work_mode) {
+	return 0;
+}
+
+INLINE BUFF_MODE HalGetBuffMode(HalHandle_t HalHandle) {
+	return BUFF_MODE_PHYLINEAR;
+}
+
+int32_t HalGetFdHandle(HalHandle_t HalHandle, HalModule_e module);
+RESULT HalGetSensorName(HalHandle_t HalHandle, char pSensorName[], uint16_t arraySize);
+RESULT HalGetSensorDrvName(HalHandle_t HalHandle, char pSensorDrvName[], uint16_t arraySize);
+RESULT HalGetSensorCalibXmlName(HalHandle_t HalHandle, char pSensorCalibXmlName[], uint16_t arraySize);
+RESULT HalGetSensorDefaultMode(HalHandle_t HalHandle, uint32_t *pMode);
+RESULT HalGetSensorCurrMode(HalHandle_t HalHandle, uint32_t *pMode);
+RESULT HalSetSensorMode(HalHandle_t HalHandle, uint32_t mode);
+RESULT HalSetSensorCalibXmlName(HalHandle_t HalHandle, const char* CalibXmlName);
+RESULT HaSensorModeLock(HalHandle_t HalHandle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HAL_CMODEL_H__ */

+ 123 - 0
isp_isp8000l/units/hal/hal_common.h

@@ -0,0 +1,123 @@
+/******************************************************************************\
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file hal_common.h
+ *
+ * @brief
+ *
+ *
+ * @note
+ *
+ *****************************************************************************/
+
+#ifndef __HAL_COMMON_H__
+#define __HAL_COMMON_H__
+
+#include <ebase/trace.h>
+#include <ebase/dct_assert.h>
+#include <oslayer/oslayer.h>
+
+
+/** Interrupt handling mode switch.
+  * If set to zero (0), the interrupt facilities built into the kernel driver
+  * will not be used. Instead, the user-space application will poll for
+  * interrupts by reading the masked interrupt status register repeatedly.
+  * If set to one (1), the kernel driver will handle the interrupt requests by
+  * the hardware. This is much more efficient, but requires the IRQ logic in the
+  * hardware to work correctly. */
+#define FPGA_USE_KERNEL_IRQ_HANDLING 0
+
+/******************************************************************************
+ * local macro definitions
+ *****************************************************************************/
+typedef enum HalIsrSrc_e
+{
+    eHalIsrSrcIspIrq         = 0x0000,
+    eHalIsrSrcJpeStatusIrq,
+    eHalIsrSrcJpeErrorIrq,
+    eHalIsrSrcCamIcMiIrq,
+    eHalIsrSrcCamIcMi1Irq,
+    eHalIsrSrcCamIcMi2Irq,
+    eHalIsrSrcCamIcMipiIrq,
+    eHalIsrSrcCamIcIspStitchingIrq,
+    eHalIsrMax,
+} HalIsrSrc_t;
+
+
+typedef enum HalChId_s
+{
+    HAL_CH_ID0 = 0, //!<isp channel id 0.
+    HAL_CH_ID1 = 1, //!<isp channel id 1.
+    HAL_CH_NUM      //!<isp channel numbers.
+}HalChId_e;
+
+
+
+/******************************************************************************
+ * local type definitions
+ *****************************************************************************/
+ #if defined ( HAL_ALTERA )
+
+/* IRQ handle type. */
+typedef struct _fpga_irq_handle {
+#if FPGA_USE_KERNEL_IRQ_HANDLING
+        int __dummy;
+#else
+        uint32_t mis_addr;
+        uint32_t cis_addr;
+        uint32_t timeout;
+        volatile int cancel;
+        osMutex poll_mutex;
+#endif
+} fpga_irq_handle_t;
+
+
+#endif
+
+/*****************************************************************************/
+/**
+ * @brief   handle to hal instance
+ *****************************************************************************/
+typedef void * HalHandle_t;
+
+/*****************************************************************************/
+/**
+ * @brief   hal irq context
+ *****************************************************************************/
+struct HalIrqCtx_s                                  // note: a forward declaration was given in this file before!
+{
+    HalHandle_t         HalHandle;                  /**< hal handle this context belongs to; must be set by callee prior connection of irq! */
+    uint32_t            misRegAddress;              /**< address of the masked interrupt status register (MIS); must be set by callee prior connection of irq! */
+    uint32_t            icrRegAddress;              /**< address of the interrupt clear register (ICR); must be set by callee prior connection of irq! */
+
+    osInterrupt         OsIrq;                      /**< os layer abstraction for the interrupt */
+    uint64_t            misValue;                   /**< value of the MIS-Register */
+
+#if defined ( HAL_ALTERA )
+    fpga_irq_handle_t   AlteraIrqHandle;            /**< handle for multiple interrupt handler */
+#endif
+
+    HalIsrSrc_t   irq_src;
+
+};
+
+/*****************************************************************************/
+/**
+ * @brief   hal irq context
+ *****************************************************************************/
+typedef struct HalIrqCtx_s HalIrqCtx_t; // implicit forward declaration of struct HalIrqCtx_s
+
+
+#endif /* __HAL_COMMON_H__ */

+ 656 - 0
isp_isp8000l/units/hal/hal_cosim.h

@@ -0,0 +1,656 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+* @file hal_cosim.h
+*
+* <pre>
+*
+* Description:
+*   This header file exports the register IO interface realized as a direct
+*   memory access inline function. You should use it for your embedded
+*   implementation.\n
+*   Do not include directly! Include hal_api.h instead.
+*
+* </pre>
+*/
+/*****************************************************************************/
+
+#ifndef __HAL_COSIM_H__
+#define __HAL_COSIM_H__
+
+//MEMSET, MEMCPY:
+#include "ebase/builtins.h"
+//bool, INLINE:
+#include "ebase/types.h"
+
+#include "ebase/dct_assert.h"
+#include "ebase/trace.h"
+
+#include <stdio.h>
+//#include "i2c_drv/i2c_drv.h"
+
+//#include "altera_fpga.h"
+
+#if defined(HAL_COSIM)
+#define  SIM_ERROR 2
+#define  SIM_MESSAGE 3
+#define  SIM_VERBINFO 4
+#define  SIM_INFO 5
+//extern void sim_fprintf(int slevel, char* info_string);
+#endif
+
+#undef TRACE
+#undef TEST_ASSERT_EQUAL_INT
+#undef TEST_ASSERT
+
+#if defined(HAL_COSIM)
+
+  extern void sim_fprintf(msg_severity_t slevel, char* info_string);
+
+  #define TRACE(a,...) \
+  {\
+      char info_string[120];            \
+    sprintf(info_string, __VA_ARGS__);      \
+    sim_fprintf(SVE_INFO, info_string);     \
+  }
+
+  #define TEST_ASSERT_EQUAL_INT(a,b) \
+  if ((a)!=(b)) {\
+      char error_string[120];\
+      sprintf(error_string, "expected=0x%08X, received=0x%08X",(a),(b) );  \
+      sim_fprintf(SVE_ERROR, error_string);     \
+  }
+
+  #define TEST_ASSERT(...) \
+  {\
+    if (__VA_ARGS__) {} else {          \
+      sim_fprintf(SVE_ERROR, "TEST_ASSERT");}   \
+  }
+
+
+#else
+  #define TRACE(a,...) (printf(__VA_ARGS__))
+  #define TEST_ASSERT_EQUAL_INT(a,b) if ((a)!=(b)) printf("ERROR: expected=0x%08X, received=0x%08X\n",(a),(b) )
+  #define TEST_ASSERT(...) (printf("ERROR: TEST_ASSERT"))
+#endif
+
+
+
+//#include <string.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef struct _i2c_bus {
+    uint32_t  ulSclRef;                     //!< Clock Divider Value
+    uint8_t   aucVirtualClockDividerEnable; //!< Virtual System Clock Divider 1: divide by 8; 0: no division
+    uint8_t   aucTimingMode;                //!< Timing Mode 1: fast; 0: standard
+    uint8_t   aucSpikeFilter;               //!< Suppressed Spike Width
+    uint8_t   aucIrqDisable;                //!< Interrupt Mask 1: interrupt disabled; 0: interrupt enabled
+} i2c_bus_t;
+
+
+
+
+  //#include <embUnit/embUnit.h>
+
+#define MRV_ALL_BASE (0x0000)
+#define VDU_ALL_BASE (0x8000)
+#define MRV2_ALL_BASE (0x10000)
+
+#define IIC1_BASE (0x800)
+#define IIC2_BASE (0x1000)
+#define IIC3_BASE (0x1800)
+
+
+#include <mrv_all_regs_macro_defs.h>
+
+
+#include <mrv_all_regs_addr_map.h>
+#include <mrv2_all_regs_addr_map.h>
+#include <mrv_all_reg_description.h>
+#include <mrv_all_reg_descr_idx.h>
+  //#include <mrv_all_regs_mask.h>
+#include <mrv_all_regs.h>
+
+#include <vdu_all_regs_addr_map.h>
+#include <vdu_all_reg_description.h>
+#include <vdu_all_reg_descr_idx.h>
+#include <vdu_all_regs_mask.h>
+
+#include <fpga_sys_ctrl_regs_addr_map.h>
+#include <fpga_sys_ctrl_reg_description.h>
+#include <fpga_sys_ctrl_reg_descr_idx.h>
+#include <fpga_sys_ctrl_regs_mask.h>
+
+#include <iic1_regs_addr_map.h>
+#include <iic2_regs_addr_map.h>
+#include <iic3_regs_addr_map.h>
+#include <iic1_reg_description.h>
+#include <iic1_reg_descr_idx.h>
+#include <iic1_regs_mask.h>
+
+
+#define MARVIN_LITE 1
+#define ISP_LITE 1
+
+  //#define MVDU_BASE       0x8000
+  //#define MVDU_REG_ID     0x0004
+  //#define MVDU_REG_MSK    0x0080
+  //#define MVDU_REG_RIS    0x0084
+  //#define MVDU_REG_MIS    0x0088
+  //#define MVDU_REG_ICR    0x008C
+  //#define MVDU_REG_ISR    0x0090
+
+extern sc_testcase* testcase_ptr;
+
+#define writeReg testcase_ptr->writeReg
+#define readReg testcase_ptr->readReg
+#define writeSysReg testcase_ptr->writeSysReg
+#define readSysReg testcase_ptr->readSysReg
+#define wait_clk testcase_ptr->wait_clk
+
+
+#define write_memory testcase_ptr->write_memory
+#define read_memory testcase_ptr->read_memory
+
+  //  HalHandle_t dummyHandle;
+
+
+  //HalContext_s halContext;
+  //HalHandle_t dummyHandle;
+#define HAL_DEVID_PCLK      0x00000008  //!< VDU.pclk
+
+/******************************************************************************
+ * HalReadReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadReg( HalHandle_t handle, uint32_t reg_address )
+{
+    (void) handle;
+    DCT_ASSERT(handle != NULL);
+    //    return *( (volatile uint32_t *) reg_address );
+
+    return (readReg(handle, reg_address));
+}
+
+
+/******************************************************************************
+ * HalWriteSysReg()
+ *****************************************************************************/
+INLINE void HalWriteSysReg( HalHandle_t handle, uint32_t reg_address, uint32_t value )
+{
+    (void) handle;
+    DCT_ASSERT(handle != NULL);
+    //    *( (volatile uint32_t*) reg_address ) = value;
+
+    writeSysReg(handle, reg_address, value);
+}
+
+
+/******************************************************************************
+ * HalReadSysReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadSysReg( HalHandle_t handle, uint32_t reg_address )
+{
+    (void) handle;
+    DCT_ASSERT(handle != NULL);
+    //    return *( (volatile uint32_t *) reg_address );
+
+    return (readSysReg(handle, reg_address));
+}
+
+
+/******************************************************************************
+ * HalWriteReg()
+ *****************************************************************************/
+INLINE void HalWriteReg( HalHandle_t handle, uint32_t reg_address, uint32_t value )
+{
+    (void) handle;
+    DCT_ASSERT(handle != NULL);
+    //    *( (volatile uint32_t*) reg_address ) = value;
+
+    writeReg(handle, reg_address, value);
+}
+
+
+/******************************************************************************
+ * HalReadMaskedReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadMaskedReg( HalHandle_t handle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask )
+{
+    (void) handle;
+    DCT_ASSERT(handle != NULL);
+
+    uint32_t tmp_value = HalReadReg( handle, reg_address );
+    return HalGetMaskedValue( tmp_value, reg_mask, shift_mask );
+}
+
+
+/******************************************************************************
+ * HalWriteMaskedReg()
+ *****************************************************************************/
+INLINE void HalWriteMaskedReg( HalHandle_t handle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask, uint32_t value )
+{
+    (void) handle;
+    DCT_ASSERT(handle != NULL);
+
+    uint32_t tmp_value = HalReadReg( handle, reg_address );
+    tmp_value = HalSetMaskedValue( tmp_value, reg_mask, shift_mask, value );
+    HalWriteReg( handle, reg_address, tmp_value );
+}
+
+
+/******************************************************************************
+ * local macro definitions
+ *****************************************************************************/
+#define NUM_I2C 3
+
+#define SYSCTRL_REVID_OFFS  0x00
+#define SYSCTRL_SELECT_OFFS 0x10
+#define SYSCTRL_RESET_OFFS  0x20
+
+#define SYSCTRL_SELECT_CAM_1_NEGEDGE 0x00000100
+#define SYSCTRL_SELECT_CAM_1_RESET   0x00000200
+#define SYSCTRL_SELECT_CAM_1_POWERDN 0x00000400
+
+#define EXT_MEM_ALIGN    0x1000 // 4k
+#define EXT_MEM_BASE     EXT_MEM_ALIGN // musn't be 0!; will be aligned up to EXT_MEM_ALIGNment
+#define EXT_MEM_SIZE (0x08000000 - EXT_MEM_BASE) // ~128MB
+
+#define DMA_STRIDE_BYTES 8 ////FPGA_DMA_SIZE_ALIGNMENT // currently 32
+
+#define HAL_USE_RAW_DMA // comment out to use dma functions with byte reordering & stuff
+
+
+/******************************************************************************
+ * local type definitions
+ *****************************************************************************/
+typedef struct HalCamConfig_s
+{
+    bool_t configured;      //!< Mark whether this config was set.
+    bool_t power_lowact;    //!< Power on is low-active.
+    bool_t reset_lowact;    //!< Reset is low-active.
+} HalCamConfig_t;
+
+
+/******************************************************************************
+ * HalContext_t
+ *****************************************************************************/
+typedef struct HalContext_s
+{
+  osMutex         modMutex;               //!< common short term mutex; e.g. for read-modify-write accesses
+  uint32_t        refCount;               //!< internal ref count
+
+  osMutex         iicMutex[NUM_I2C];      //!< transaction locks for I2C controller 1..NUM_I2C
+  i2c_bus_t       iicConfig[NUM_I2C];     //!< configurations for I2C controller 1..NUM_I2C
+
+  HalCamConfig_t  cam1Config;             //!< configuration for CAM1; set at runtime
+} HalContext_t;
+
+HalContext_s halContext;
+
+/******************************************************************************
+ * local variable declarations
+ *****************************************************************************/
+//static HalContext_t gHalContext  = { .refCount = 0 };
+//static bool_t       gInitialized = BOOL_FALSE;
+
+/******************************************************************************
+ * local function prototypes
+ *****************************************************************************/
+//static int32_t halIsrHandler( void *pArg );
+
+
+/******************************************************************************
+ * API functions; see header file for detailed comment.
+ *****************************************************************************/
+
+
+/******************************************************************************
+ * HalOpen()
+ *****************************************************************************/
+HalHandle_t HalOpen( void )
+{
+
+  HalHandle_t localDummyHandle;
+
+  localDummyHandle = &halContext;
+  return localDummyHandle;
+}
+
+
+/******************************************************************************
+ * HalClose()
+ *****************************************************************************/
+RESULT HalClose( HalHandle_t HalHandle )
+{
+    RESULT result = RET_SUCCESS;
+    return result;
+}
+
+
+/******************************************************************************
+ * HalAddRef()
+ *****************************************************************************/
+RESULT HalAddRef( HalHandle_t HalHandle )
+{
+    RESULT result = RET_SUCCESS;
+    return result;
+}
+
+
+/******************************************************************************
+ * HalDelRef()
+ *****************************************************************************/
+RESULT HalDelRef( HalHandle_t HalHandle )
+{
+    // just forward to HalClose; it takes care of everything
+    return HalClose( HalHandle );
+}
+
+
+/******************************************************************************
+ * HalSetCamConfig()
+ *****************************************************************************/
+RESULT HalSetCamConfig( HalHandle_t HalHandle, uint32_t dev_mask, bool_t power_lowact, bool_t reset_lowact, bool_t pclk_negedge )
+{
+    RESULT result = RET_NOTSUPP;
+    return result;
+}
+
+/******************************************************************************
+ * HalSetReset()
+ *****************************************************************************/
+RESULT HalSetReset( HalHandle_t HalHandle, uint32_t dev_mask, bool_t activate )
+{
+    RESULT result = RET_NOTSUPP;
+    return result;
+}
+
+
+/******************************************************************************
+ * HalSetPower()
+ *****************************************************************************/
+RESULT HalSetPower( HalHandle_t HalHandle, uint32_t dev_mask, bool_t activate )
+{
+    RESULT result = RET_NOTSUPP;
+    return result;
+}
+
+
+/******************************************************************************
+ * HalSetClock()
+ *****************************************************************************/
+static uint32_t _set_single_pll_counter(HalHandle_t HalHandle, const uint8_t counter_type, const uint16_t value);
+static uint32_t _set_single_pll_param(HalHandle_t HalHandle, const uint8_t counter_type, const uint8_t counter_param, const uint16_t value);
+RESULT HalSetClock( HalHandle_t HalHandle, uint32_t dev_mask, uint32_t frequency )
+{
+  uint32_t reset_val;
+  uint32_t res;
+  RESULT result;
+
+  uint32_t i;
+
+
+  result = RET_SUCCESS;
+
+  // there are problems with reconfiguring the pll during simulation. Thats why this feature is switched off.
+  // use correct pll init settings during compile
+#if 0
+
+  if (dev_mask == HAL_DEVID_PCLK) {
+    reset_val = HalReadSysReg(HalHandle, MRV_FPGA_VEC_SYS_RESETN_REG);
+    HalWriteSysReg(HalHandle, MRV_FPGA_VEC_SYS_RESETN_REG, reset_val & 0xff7f);
+    HalWriteSysReg(HalHandle, MRV_FPGA_VEC_SYS_RESETN_REG, reset_val | 0x0080);
+
+
+    switch (frequency)
+      {
+      case  25200000ul:
+        res = _set_single_pll_counter(HalHandle, 0, 5);
+        res = _set_single_pll_counter(HalHandle, 1, 105);
+
+        res = _set_single_pll_counter(HalHandle, 4, 45);
+        res = _set_single_pll_counter(HalHandle, 5, 14);
+        break;
+      case  74250000ul:
+        res = _set_single_pll_counter(HalHandle, 0, 1); //2);  //N
+        res = _set_single_pll_counter(HalHandle, 1, 33); //33); //M
+
+        res = _set_single_pll_counter(HalHandle, 4, 24); //C0
+        res = _set_single_pll_counter(HalHandle, 5, 22); //C1
+        res = _set_single_pll_counter(HalHandle, 6, 12);
+        res = _set_single_pll_counter(HalHandle, 7, 12);
+        res = _set_single_pll_counter(HalHandle, 8, 12);
+        res = _set_single_pll_counter(HalHandle, 9, 12);
+        res = _set_single_pll_counter(HalHandle, 10, 12);
+        res = _set_single_pll_counter(HalHandle, 11, 12);
+        res = _set_single_pll_counter(HalHandle, 12, 12);
+        res = _set_single_pll_counter(HalHandle, 13, 12);
+        break;
+      case 148500000ul:
+        res = _set_single_pll_counter(HalHandle, 0, 2);
+        res = _set_single_pll_counter(HalHandle, 1, 33);
+
+        res = _set_single_pll_counter(HalHandle, 4, 6);
+        res = _set_single_pll_counter(HalHandle, 5, 11);
+        break;
+      default:
+        return RET_NOTSUPP;
+      }
+
+    for (i=0; i<50;i++) {
+      reset_val = HalReadSysReg(HalHandle, MRV_FPGA_VEC_SYS_RESETN_REG);
+    }
+
+    HalWriteSysReg(HalHandle, MRV_FPGA_RE_RECONFIG_REG, 0x1);
+
+  }
+  else {
+    result = RET_NOTSUPP;
+  }
+
+#endif
+
+    return result;
+}
+
+
+/******************************************************************************
+ * HalAllocMemory()
+ *****************************************************************************/
+uint32_t HalAllocMemory( HalHandle_t HalHandle, uint32_t byte_size )
+{
+  //    if (HalHandle == NULL)
+  //    {
+  //        return RET_NULL_POINTER;
+  //    }
+  return  ((uint32_t) malloc(byte_size));
+}
+
+
+/******************************************************************************
+ * HalFreeMemory()
+ *****************************************************************************/
+RESULT HalFreeMemory( HalHandle_t HalHandle, uint32_t mem_address )
+{
+  //    if (HalHandle == NULL)
+  //    {
+  //        return RET_NULL_POINTER;
+  //    }
+
+  free((void *)mem_address);
+    mem_address = NULL;
+
+    return RET_SUCCESS;
+}
+
+
+/******************************************************************************
+ * HalReadMemory()
+ *****************************************************************************/
+RESULT HalReadMemory( HalHandle_t HalHandle, uint32_t mem_address, uint8_t* p_read_buffer, uint32_t byte_size )
+{
+    if (HalHandle == NULL)
+    {
+        return RET_NULL_POINTER;
+    }
+
+    //DCT_ASSERT((mem_address & (DMA_STRIDE_BYTES-1)) == 0);
+    DCT_ASSERT((byte_size & (DMA_STRIDE_BYTES-1)) == 0);
+    read_memory(mem_address, p_read_buffer, byte_size); // == 0) ? RET_SUCCESS : RET_FAILURE;
+
+    return (RET_SUCCESS);
+}
+
+/******************************************************************************
+ * HalWriteMemory()
+ *****************************************************************************/
+RESULT HalWriteMemory( HalHandle_t HalHandle, uint32_t mem_address, uint8_t* p_write_buffer, uint32_t byte_size )
+{
+  //if (HalHandle == NULL)
+  //    {
+  //        return RET_NULL_POINTER;
+  //    }
+
+    //DCT_ASSERT((mem_address & (DMA_STRIDE_BYTES-1)) == 0);
+    DCT_ASSERT((byte_size & (DMA_STRIDE_BYTES-1)) == 0);
+
+    write_memory(  mem_address, p_write_buffer,byte_size ); // == 0) ? RET_SUCCESS : RET_FAILURE;
+    return ( RET_SUCCESS );
+}
+
+
+/******************************************************************************
+ * HalReadI2CMem()
+ *****************************************************************************/
+RESULT HalReadI2CMem
+(
+    HalHandle_t HalHandle,
+    uint8_t     bus_num,
+    uint16_t    slave_addr,
+    uint32_t    reg_address,
+    uint8_t     reg_addr_size,
+    uint8_t     *p_read_buffer,
+    uint32_t    byte_size
+)
+{
+    RESULT result = RET_NOTSUPP;
+    return result;
+}
+
+
+/******************************************************************************
+ * HalWriteI2CMem()
+ *****************************************************************************/
+RESULT HalWriteI2CMem
+(
+    HalHandle_t HalHandle,
+    uint8_t     bus_num,
+    uint16_t    slave_addr,
+    uint32_t    reg_address,
+    uint8_t     reg_addr_size,
+    uint8_t     *p_write_buffer,
+    uint32_t    byte_size
+)
+{
+    RESULT result = RET_NOTSUPP;
+    return result;
+}
+
+
+
+/******************************************************************************
+ * HalConnectIrq()
+ *****************************************************************************/
+RESULT HalConnectIrq
+(
+    HalHandle_t HalHandle,
+    HalIrqCtx_t *pIrqCtx,
+    uint32_t    int_src,
+    osIsrFunc   IsrFunction,
+    osDpcFunc   DpcFunction,
+    void*       pContext
+)
+{
+    RESULT result = RET_NOTSUPP;
+    return result;
+}
+
+
+/******************************************************************************
+ * HalDisconnectIrq()
+ *****************************************************************************/
+RESULT HalDisconnectIrq
+(
+    HalIrqCtx_t *pIrqCtx
+)
+{
+    RESULT result = RET_NOTSUPP;
+    return result;
+}
+
+/******************************************************************************
+ * Local functions
+ *****************************************************************************/
+/*******************************************************************************/
+
+static uint32_t _set_single_pll_counter(HalHandle_t HalHandle, const uint8_t counter_type, const uint16_t value) {
+  uint32_t res;
+
+  res = _set_single_pll_param(HalHandle, counter_type, 4, value ? 0 : 1);  /* bypass */
+  res = _set_single_pll_param(HalHandle, counter_type, 0, (value + 1) >> 1);  /* high count */
+  res = _set_single_pll_param(HalHandle, counter_type, 5, value & 1);  /* odd/even */
+  res = _set_single_pll_param(HalHandle, counter_type, 1, value >> 1);  /* low count */
+
+  return RET_SUCCESS;
+}
+/*******************************************************************************/
+
+static uint32_t _set_single_pll_param(HalHandle_t HalHandle, const uint8_t counter_type, const uint8_t counter_param, const uint16_t value) {
+
+  HalWriteSysReg(HalHandle, MRV_FPGA_RE_COUNTER_TYPE_PARAM_REG, (counter_param << 4) | counter_type );
+  HalWriteSysReg(HalHandle, MRV_FPGA_RE_WR_RD_DATA_REG, value);
+  HalWriteSysReg(HalHandle, MRV_FPGA_RE_WRITE_PARAM_REG, 0x1);
+
+  return RET_SUCCESS;
+}
+
+/*******************************************************************************/
+
+
+/******************************************************************************
+ * halIsrHandler
+ *****************************************************************************/
+//static int32_t halIsrHandler( void *pArg )
+//{
+//    return ( 0 );
+//}
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HAL_COSIM_H__ */
+
+

+ 188 - 0
isp_isp8000l/units/hal/hal_mockup.h

@@ -0,0 +1,188 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file hal_mockup.h
+ *
+ * @brief   MockedUp variant of Hardware Abstraction Layer
+ *
+ *          Exports the mockup version of the HAL API's inline functions. You could
+ *          use it for your PC implementation to check general interaction of your
+ *          code with the HAL.
+ * @note    Do not include directly! Include hal_api.h instead with HAL_MOCKUP defined.
+ *
+ *****************************************************************************/
+
+#ifndef __HAL_MOCKUP_H__
+#define __HAL_MOCKUP_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/******************************************************************************
+ * HAL device IDs
+ *****************************************************************************/
+#define HAL_DEVID_OCP       0x00000001  //!< HAL internal use only
+#define HAL_DEVID_MARVIN    0x00000002  //!< MARVIN.*
+#define HAL_DEVID_VDU       0x00000004  //!< VDU.clk + VDU.ocpclk
+#define HAL_DEVID_PCLK      0x00000008  //!< VDU.pclk
+#define HAL_DEVID_I2C_0     0x00000010  //!< HAL internal use only
+#define HAL_DEVID_I2C_1     0x00000020  //!< HAL internal use only
+#define HAL_DEVID_I2C_2     0x00000040  //!< HAL internal use only
+#define HAL_DEVID_CAMREC_1  0x00000080  //!< CAMREC1, not neccessarily the REC that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_REC instead
+#define HAL_DEVID_INTERNAL  0x000000ff  //!< just internal devices included
+
+#define HAL_DEVID_CAM_1     0x10000000  //!< CAM1
+#define HAL_DEVID_CAMPHY_1  0x20000000  //!< CAMPHY1, not neccessarily the PHY that CAM1 is hooked up to; see @ref HAL_DEVID_CAM_1_PHY instead
+#define HAL_DEVID_EXTERNAL  0x30000000  //!< just external devices included
+
+#define HAL_DEVID_ALL       (HAL_DEVID_INTERNAL | HAL_DEVID_EXTERNAL) //!< all devices included
+
+
+/******************************************************************************
+ * HAL device base addresses
+ *****************************************************************************/
+// HalRegs:
+#define HAL_BASEADDR_MARVIN    0x00000000 //!< Base address of MARVIN module.
+#define HAL_BASEADDR_MARVIN_2  0x00010000 //!< Base address of MARVIN module of 2nd channel.
+#define HAL_BASEADDR_MIPI_1    0x00000000 //!< Base address of MIPI module.
+#define HAL_BASEADDR_MIPI_2    0x00010000 //!< Base address of MIPI module of 2nd channel.
+#define HAL_BASEADDR_VDU       0x00008000 //!< Base address of VDU module.
+
+// HalSysRegs:
+#define HAL_BASEADDR_SYSCTRL   0x00000000 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_0     0x00001000 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_1     0x00001800 //!< HAL internal use only
+#define HAL_BASEADDR_I2C_2     0x00000800 //!< HAL internal use only
+
+
+/******************************************************************************
+ * HAL device base region
+ *****************************************************************************/
+// HalRegs:
+#define HAL_BASEREGION_MARVIN    0 //!< Base region of MARVIN module(s).
+#define HAL_BASEREGION_MIPI      0 //!< Base region of MIPI module(s).
+#define HAL_BASEREGION_VDU       0 //!< Base region of VDU module.
+
+// HalSysRegs:
+#define HAL_BASEREGION_SYSCTRL   2 //!< HAL internal use only
+#define HAL_BASEREGION_I2C       2 //!< HAL internal use only
+
+
+/******************************************************************************
+ * HAL I2C bus location
+ *****************************************************************************/
+#define HAL_I2C_BUS_CAM_1       0 //!< Num of I2C bus CAM1 is connected to
+#define HAL_I2C_BUS_CAM_2       1 //!< Num of I2C bus CAM2 is connected to
+#define HAL_I2C_BUS_HDMI_TX     2 //!< Num of I2C bus HDMI TX is connected to
+#define HAL_I2C_BUS_CAMPHY_1    0 //!< Num of I2C bus CAMPHY1 is connected to
+#define HAL_I2C_BUS_CAMPHY_2    1 //!< Num of I2C bus CAMPHY1 is connected to
+
+
+/******************************************************************************
+ * HAL CAM to PHY/REC mapping
+ *****************************************************************************/
+#define HAL_DEVID_CAM_1_PHY     HAL_DEVID_CAMPHY_1 //!< DEVID of CAMPHY CAM1 is connected to
+#define HAL_DEVID_CAM_2_PHY     HAL_DEVID_CAMPHY_1 //!< DEVID of CAMPHY CAM2 is connected to
+#define HAL_DEVID_CAM_1_REC     HAL_DEVID_CAMREC_1 //!< DEVID of CAMREC CAM1 is connected to
+#define HAL_DEVID_CAM_2_REC     HAL_DEVID_CAMREC_1 //!< DEVID of CAMREC CAM2 is connected to
+
+
+/******************************************************************************
+ * HalReadReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadReg( HalHandle_t HalHandle, uint32_t reg_address )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    return 0x12345678;
+}
+
+
+/******************************************************************************
+ * HalWriteReg()
+ *****************************************************************************/
+INLINE void HalWriteReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    (void) reg_address;
+    (void) value;
+}
+
+
+/******************************************************************************
+ * HalReadMaskedReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    uint32_t tmp_value = HalReadReg( HalHandle, reg_address );
+    return HalGetMaskedValue( tmp_value, reg_mask, shift_mask );
+}
+
+
+/******************************************************************************
+ * HalWriteMaskedReg()
+ *****************************************************************************/
+INLINE void HalWriteMaskedReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t reg_mask, uint32_t shift_mask, uint32_t value )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    uint32_t tmp_value = HalReadReg( HalHandle, reg_address );
+    tmp_value = HalSetMaskedValue( tmp_value, reg_mask, shift_mask, value );
+    HalWriteReg( HalHandle, reg_address, tmp_value );
+}
+
+
+/******************************************************************************
+ * HalReadSysReg()
+ *****************************************************************************/
+INLINE uint32_t HalReadSysReg( HalHandle_t HalHandle, uint32_t reg_address )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    return 0x12345678;
+}
+
+
+/******************************************************************************
+ * HalWriteSysReg()
+ *****************************************************************************/
+INLINE void HalWriteSysReg( HalHandle_t HalHandle, uint32_t reg_address, uint32_t value )
+{
+    (void) HalHandle;
+    DCT_ASSERT(HalHandle != NULL);
+
+    (void) reg_address;
+    (void) value;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HAL_MOCKUP_H__ */

+ 268 - 0
isp_isp8000l/units/i2c_drv/i2c_drv.h

@@ -0,0 +1,268 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file template_api.h
+ *
+ * @brief
+ *   ADD_DESCRIPTION_HERE
+ *
+ *****************************************************************************/
+/**
+ *
+ * @mainpage Welcome to the Documentation of the i2c driver
+ *
+ *
+ * Doc-Id: xx-xxx-xxx-xxx (NAME Implementation Specification)\n
+ * Author: Ulrich Marx
+ *
+ * DESCRIBE_HERE
+ *
+ *
+ * The manual is divided into the following sections:
+ *
+ * -@subpage module_name_api_page \n
+ * -@subpage module_name_page \n
+ *
+ * @page module_name_api_page Module Name API
+ * This module is the API for the NAME. DESCRIBE IN DETAIL / ADD USECASES...
+ *
+ * for a detailed list of api functions refer to:
+ * - @ref module_name_api
+ *
+ * @defgroup i2c_drv_api I2C Driver API
+ * @{
+ */
+#ifndef __I2C_DRV_H__
+#define __I2C_DRV_H__
+
+#include <ebase/types.h>
+
+/*******************************************************************************
+ * @brief The i2c return value type.
+ *
+ */
+typedef int32_t I2cReturnType;
+
+
+/*******************************************************************************
+ * @brief The i2c return values
+ *
+ * This enumeration lists the possible i2c return values.
+ */
+enum I2C_RESULT
+{
+    I2C_RET_SUCCESS             =   0,      /**< The operation was successfully completed */
+    I2C_RET_FAILURE             =  -1,      /**< Generic error */
+    I2C_RET_PENDING             =  -2,      /**< The operation is ongoing */
+    I2C_RET_NOT_SUPPORTED       =  -3,      /**< The requested function is not supported */
+    I2C_RET_TIMEOUT             =  -4,      /**< Something timed out */
+    I2C_RET_BUSY                =  -5,      /**< The requested operation can't be fulfilled because the resource is busy */
+    I2C_RET_INVALID_PARM        =  -6,      /**< First parameter is invalid */
+    I2C_RET_CANCELLED           =  -7,      /**< The operation was cancelled */
+    I2C_RET_NO_DATA             =  -8,      /**< Insufficient data for the operation to complete */
+    I2C_RET_FULL                =  -9,      /**< Something is full */
+    I2C_RET_OVERFLOW            = -10,      /**< Something was overflowing */
+    I2C_RET_EMPTY               = -11,      /**< Something is empty */
+    I2C_RET_UNDERFLOW           = -12,      /**< Something was underflowing */
+    I2C_RET_NOT_FOUND           = -13,      /**< Unsuccessful find operation */
+    I2C_RET_INVALID_HANDLE      = -14,      /**< The given handle is invalid */
+    I2C_RET_INVALID_CONFIG      = -15,      /**< Configuration is not allowed */
+    I2C_RET_NO_HARDWARE         = -16,      /**< Hardware not present */
+    I2C_RET_WRONG_STATE         = -17,      /**< Module is in wrong state */
+    I2C_RET_WRITE_ERROR         = -18,      /**< Write error */
+    I2C_RET_READ_ERROR          = -19,      /**< Reads error */
+    I2C_RET_PROTOCOLL_ERROR     = -20,      /**< i2c protocoll error */
+    I2C_RET_INVALID_ADDRESS     = -21,      /**< Invalid address */
+    I2C_RET_ONLY_ONE_INSTANCE   = -22,      /**< Only one instance is allowed */
+    I2C_RET_NOT_AVAILABLE       = -23      /**< Something is not available */
+
+};
+
+
+/**
+ * @brief
+ *
+ * @note
+ *
+ */
+typedef struct _i2c_bus
+{
+    uint32_t  ulControllerBaseAddress;      /**< Base Address of the I2C Controller */
+    uint8_t   aucMasterAddrMode;            /**< Master Address Mode 1: 10 bit; 0: 7 bit */
+    uint32_t  ulMasterAddr;                 /**< Master Device Address */
+    uint32_t  ulSclRef;                     /**< Clock Divider Value */
+    uint8_t   aucVirtualClockDividerEnable; /**< Virtual System Clock Divider 1: divide by 8; 0: no division */
+    uint8_t   aucTimingMode;                /**< Timing Mode 1: fast; 0: standard */
+    uint8_t   aucSpikeFilter;               /**< Suppressed Spike Width */
+    uint8_t   aucIrqDisable;                /**< Interrupt Mask 1: interrupt disabled; 0: interrupt enabled */
+    int       handle;
+} i2c_bus_t;
+
+
+
+/**
+ *          i2c_init()
+ *
+ * @brief   Initialize the ic2-bus-master module
+ *
+ * @note
+ *
+ */
+extern I2cReturnType i2c_init
+(
+    i2c_bus_t *i2c
+);
+
+
+
+/**
+ *          i2c_read_reg8()
+ *
+ * @brief   Read an 8-Bit value from an 8-Bit addressable register
+ *
+ * @note
+ *
+ */
+I2cReturnType i2c_read_reg8
+(
+    const i2c_bus_t *i2c,
+    const uint16_t  slave_addr,
+    uint8_t         reg_addr,
+    uint8_t         *value
+);
+
+
+
+/**
+ *          i2c_read_reg16()
+ *
+ * @brief   Read an 8-Bit value from a 16-Bit addressable register
+ *
+ * @note
+ *
+ */
+I2cReturnType i2c_read_reg16
+(
+    const i2c_bus_t *i2c,
+    const uint16_t  slave_addr,
+    uint16_t        reg_addr,
+    uint8_t         *value
+);
+
+
+
+/**
+ *          i2c_read_ex()
+ *
+ * @brief   Read n bytes starting at location which is addressed via 0..3 bytes
+ *
+ * @note
+ *
+ */
+extern I2cReturnType i2c_read_ex
+(
+    i2c_bus_t *i2c,
+    const uint16_t  slave_addr,
+    uint32_t        reg_addr,
+    uint8_t         reg_addr_size,
+    uint8_t         *data,
+    uint8_t         num_data
+);
+
+extern I2cReturnType i2c_read_ex2
+(
+#if 0
+    const i2c_bus_t *i2c,
+#else
+    i2c_bus_t *i2c,
+#endif
+    const uint16_t  slave_addr,
+    uint32_t        reg_addr,
+    uint8_t         reg_addr_size,
+    uint8_t         *p_data,
+    uint8_t         num_data,
+    int16_t         *pdata_read
+);
+
+
+
+/**
+ *          i2c_write_reg8()
+ *
+ * @brief   Write an 8-Bit value to an 8-Bit addressable register
+ *
+ * @note
+ *
+ */
+I2cReturnType i2c_write_reg8
+(
+    const i2c_bus_t *i2c,
+    const uint16_t  slave_addr,
+    uint8_t         reg_addr,
+    uint8_t         value
+);
+
+
+
+/**
+ *          i2c_write_reg8()
+ *
+ * @brief   Write an 8-Bit value to a 16-Bit addressable register
+ *
+ * @note
+ *
+ */
+I2cReturnType i2c_write_reg16
+(
+    const i2c_bus_t *i2c,
+    const uint16_t  slave_addr,
+    uint16_t        reg_addr,
+    uint8_t         value
+);
+
+
+/**
+ *          i2c_write_ex()
+ *
+ * @brief   Write n bytes starting at location which is addressed via 0..3 bytes
+ *
+ * @note
+ *
+ */
+extern I2cReturnType i2c_write_ex
+(
+    i2c_bus_t *i2c,
+    const uint16_t  slave_addr,
+    uint32_t        reg_addr,
+    uint8_t         reg_addr_size,
+    uint8_t         *data,
+    uint8_t         num_data
+);
+
+extern I2cReturnType i2c_write_ex2
+(
+    i2c_bus_t *i2c,
+    const uint16_t  slave_addr,
+    uint32_t        reg_addr,
+    uint8_t         reg_addr_size,
+    uint8_t         *p_data,
+    uint8_t         num_data,
+    int16_t         *pdata_written
+);
+
+
+#endif /* __I2C_DRV_H__ */

+ 1114 - 0
isp_isp8000l/units/isi/isi.h

@@ -0,0 +1,1114 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file isi_iss.h
+ *
+ * @brief Interface description for image sensor specific implementation (iss).
+ *
+ *****************************************************************************/
+/**
+ * @page module_name_page Module Name
+ * Describe here what this module does.
+ *
+ * For a detailed list of functions and implementation detail refer to:
+ * - @ref module_name
+ *
+ * @defgroup isi Independent Sensor Interface
+ * @{
+ *
+ */
+#ifndef __ISI_H__
+#define __ISI_H__
+
+#include <ebase/types.h>
+#include <hal/hal_api.h>
+
+#include <isi/isi_common.h>
+#include <cameric_drv/cameric_drv_common.h>
+#include <cam_device/cam_device_sensor_defs.h>
+#include <vvsensor.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*****************************************************************************/
+/**
+ *          IsiSensorHandle_t
+ *
+ * @brief   Handle to a sensor instance
+ *
+ */
+/*****************************************************************************/
+typedef void *IsiSensorHandle_t; // should be of type 'struct IsiSensorContext_s *'
+
+
+
+/*****************************************************************************/
+/**
+ * @brief
+ */
+/*****************************************************************************/
+typedef struct IsiSensor_s IsiSensor_t;
+
+
+/*****************************************************************************/
+/**
+ *          IsiSensorInstanceConfig_t
+ *
+ * @brief   Config structure to create a new sensor instance
+ *
+ */
+/*****************************************************************************/
+typedef struct IsiSensorInstanceConfig_s
+{
+    HalHandle_t           HalHandle;          /**< Handle of HAL session to use. */
+    uint32_t              HalDevID;           /**< HAL device ID of this sensor. */
+    uint8_t               I2cBusNum;          /**< The I2C bus the sensor is connected to. */
+    uint16_t              SlaveAddr;          /**< The I2C slave addr the sensor is configured to. */
+    uint8_t               I2cAfBusNum;        /**< The I2C bus the ad module is connected to. */
+    uint16_t              SlaveAfAddr;        /**< The I2C slave addr of the af module is configured to */
+
+    uint32_t              SensorModeIndex;
+
+
+    IsiSensor_t         *pSensor;           /**< Sensor driver interface */
+
+    IsiSensorHandle_t   hSensor;            /**< Sensor handle returned by IsiCreateSensorIss */
+    char szSensorNodeName[32];
+    void*             pLib;         /* point to lib${SENSOR_NAME}.so*/
+    char SensorLibName[32];
+} IsiSensorInstanceConfig_t;
+
+
+
+/*****************************************************************************/
+/**
+ * @brief   This structure defines a single Afps resolution's data.
+ */
+/*****************************************************************************/
+typedef struct IsiAfpsResInfo_s
+{
+    uint32_t Resolution;                /**< the corresponding resolution ID */
+    float    MaxIntTime;                /**< the maximum supported integration time */
+} IsiAfpsResInfo_t;
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSetCsiConfig
+ *
+ * @brief   mipi config.
+ *
+ * @param   handle      Sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ * @retval  RET_OUTOFMEM
+ *
+ *****************************************************************************/
+RESULT IsiSetCsiConfig
+(
+    IsiSensorHandle_t   handle,
+    uint32_t            clk
+);
+
+/*****************************************************************************/
+/**
+ *          IsiCreateSensorIss
+ *
+ * @brief   This function creates a new sensor instance.
+ *
+ * @param   pConfig     configuration of the new sensor
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ * @retval  RET_OUTOFMEM
+ *
+ *****************************************************************************/
+RESULT IsiCreateSensorIss
+(
+    IsiSensorInstanceConfig_t   *pConfig
+);
+
+/******************************************************************************
+ *  *          IsiInitSensorIss
+ *^M
+ * @brief   The function Init a sensor register.
+ *^M
+ * @param   handle      sensor Init handle
+ *^M
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NOTSUPP
+******************************************************************************/
+
+
+RESULT IsiInitSensorIss
+(
+   IsiSensorHandle_t   handle
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetSensorModeIss
+ *
+ * @brief   get cuurent sensor mode info.
+ *
+ * @param   handle      Sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ *
+ *****************************************************************************/
+RESULT IsiGetSensorModeIss
+(
+    IsiSensorHandle_t   handle,
+    void *pmode
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiReleaseSensorIss
+ *
+ * @brief   The function destroys/releases a sensor instance.
+ *
+ * @param   handle      sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NOTSUPP
+ *
+ *****************************************************************************/
+RESULT IsiReleaseSensorIss
+(
+    IsiSensorHandle_t   handle
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetCapsIss
+ *
+ * @brief   fills in the correct pointers for the sensor description struct
+ *
+ * @param   handle      Sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetCapsIss
+(
+    IsiSensorHandle_t   handle,
+    IsiSensorCaps_t     *pIsiSensorCaps
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSetupSensorIss
+ *
+ * @brief   Setup of the image sensor considering the given configuration.
+ *
+ * @param   handle      Sensor instance handle
+ * @param   pConfig     pointer to sensor configuration structure
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiSetupSensorIss
+(
+    IsiSensorHandle_t   handle,
+    IsiSensorConfig_t   *pConfig
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiChangeSensorResolutionIss
+ *
+ * @brief   Change image sensor resolution while keeping all other static settings.
+ *          Dynamic settings like current gain & integration time are kept as
+ *          close as possible.
+ *
+ * @note    Re-read current & min/max values as they will probably have changed!
+ *
+ * @param   handle                  Sensor instance handle
+ * @param   width             
+ * @param   height   
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_WRONG_STATE
+ * @retval  RET_OUTOFRANGE
+ *
+ *****************************************************************************/
+RESULT IsiChangeSensorResolutionIss
+(
+    IsiSensorHandle_t   handle,
+    uint16_t            width,
+    uint16_t            height
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSensorSetStreamingIss
+ *
+ * @brief   Enables/disables streaming of sensor data, if possible.
+ *
+ * @param   handle      Sensor instance handle
+ * @param   on          new streaming state (BOOL_TRUE=on, BOOL_FALSE=off)
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ * @retval  RET_WRONG_STATE
+ *
+ *****************************************************************************/
+RESULT IsiSensorSetStreamingIss
+(
+    IsiSensorHandle_t   handle,
+    bool_t              on
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSensorSetPowerIss
+ *
+ * @brief   Performs the power-up/power-down sequence of the camera, if possible.
+ *
+ * @param   handle      Sensor instance handle
+ * @param   on          new power state (BOOL_TRUE=on, BOOL_FALSE=off)
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiSensorSetPowerIss
+(
+    IsiSensorHandle_t   handle,
+    bool_t              on
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiCheckSensorConnectionIss
+ *
+ * @brief   Checks the connection to the camera sensor, if possible.
+ *
+ * @param   handle      Sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiCheckSensorConnectionIss
+(
+    IsiSensorHandle_t   handle
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetSensorRevisionIss
+ *
+ * @brief   This function reads the sensor revision register and returns it.
+ *
+ * @param   handle      sensor instance handle
+ * @param   p_value     pointer to value
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ * @retval  RET_NOTSUPP
+ *
+ *****************************************************************************/
+RESULT IsiGetSensorRevisionIss
+(
+    IsiSensorHandle_t   handle,
+    uint32_t            *p_value
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetGainLimitsIss
+ *
+ * @brief   Returns the gain minimal and maximal values of a sensor
+ *          instance
+ *
+ * @param   handle      sensor instance handle
+ * @param   pMinGain    Pointer to a variable receiving minimal exposure value
+ * @param   pMaxGain    Pointer to a variable receiving maximal exposure value
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetGainLimitsIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pMinGain,
+    float               *pMaxGain
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetIntegrationTimeLimitsIss
+ *
+ * @brief   Returns the integration time minimal and maximal values of a sensor
+ *          instance
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pMinIntegrationTime     Pointer to a variable receiving minimal exposure value
+ * @param   pMaxIntegrationTime     Pointer to a variable receiving maximal exposure value
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetIntegrationTimeLimitsIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pMinIntegrationTime,
+    float               *pMaxIntegrationTime
+);
+
+
+/*****************************************************************************/
+/**
+ *          IsiExposureControlIss
+ *
+ * @brief   Sets the exposure values (gain & integration time) of a sensor
+ *          instance
+ *
+ * @param   handle                  sensor instance handle
+ * @param   NewGain                 newly calculated gain to be set
+ * @param   NewIntegrationTime      newly calculated integration time to be set
+ * @param   pNumberOfFramesToSkip   number of frames to skip until AE is
+ *                                  executed again
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiExposureControlIss
+(
+    IsiSensorHandle_t   handle,
+    float               NewGain,
+    float               NewIntegrationTime,
+    uint8_t             *pNumberOfFramesToSkip,
+    float               *pSetGain,
+    float               *pSetIntegrationTime,
+    float               *hdr_ratio
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetCurrentExposureIss
+ *
+ * @brief   Returns the currently adjusted AE values
+ *
+ * @param   handle       sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetCurrentExposureIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pCurGain,
+    float               *pCurIntegrationTime,
+    float               *pCurHdrRatio
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetGainIss
+ *
+ * @brief   Reads gain values from the image sensor module.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pSetGain                set gain
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetGainIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pGain
+);
+
+RESULT IsiGetVSGainIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pGain
+);
+
+RESULT IsiGetLongGainIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pGain
+);
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetGainIncrementIss
+ *
+ * @brief   Get smalles possible gain increment.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pIncr                   increment
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetGainIncrementIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pIncr
+);
+
+
+/*****************************************************************************/
+/**
+ *          IsiSetGainIss
+ *
+ * @brief   Writes gain values to the image sensor module.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   NewGain                 gain to be set
+ * @param   pSetGain                set gain
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiSetGainIss
+(
+    IsiSensorHandle_t   handle,
+    float               NewGain,
+    float               *pSetGain,
+    float               *hdr_ratio
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetIntegrationTimeIss
+ *
+ * @brief   Reads integration time values from the image sensor module.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pSetIntegrationTime     set integration time
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetIntegrationTimeIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pIntegrationTime
+);
+
+RESULT IsiGetVSIntegrationTimeIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pIntegrationTime
+);
+
+RESULT IsiGetLongIntegrationTimeIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pIntegrationTime
+);
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetIntegrationTimeIncrementIss
+ *
+ * @brief   Get smalles possible integration time increment.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pIncr                   increment
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetIntegrationTimeIncrementIss
+(
+    IsiSensorHandle_t   handle,
+    float               *pIncr
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSetIntegrationTimeIss
+ *
+ * @brief   Writes integration time values to the image sensor module.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   NewIntegrationTime      integration time to be set
+ * @param   pSetIntegrationTime     set integration time
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiSetIntegrationTimeIss
+(
+    IsiSensorHandle_t   handle,
+    float               NewIntegrationTime,
+    float               *pSetIntegrationTime,
+    float               *hdr_ratio
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiQuerySensorIss
+ *
+ * @brief   query sensor info arry.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pSensorInfo             sensor query arry
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiQuerySensorIss
+(
+    IsiSensorHandle_t   handle,
+    vvcam_mode_info_array_t *pSensorInfo
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetSensorFpsIss
+ *
+ * @brief   Get Sensor Fps Config.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pFps                    current fps
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetSensorFpsIss
+(
+    IsiSensorHandle_t   handle,
+    uint32_t            *pFps
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSetSensorFpsIss
+ *
+ * @brief   set Sensor Fps Config.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   Fps                     Setfps
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiSetSensorFpsIss
+(
+    IsiSensorHandle_t   handle,
+    uint32_t            Fps
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetResolutionIss
+ *
+ * @brief   Reads integration time values from the image sensor module.
+ *
+ * @param   handle                  sensor instance handle
+ * @param   pwidth    
+ * @param   pheight      
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiGetResolutionIss
+(
+    IsiSensorHandle_t   handle,
+    uint16_t *pwidth,
+    uint16_t *pheight
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiWriteRegister
+ *
+ * @brief   writes a given number of bytes to the image sensor device by
+ *          calling the corresponding sensor-function
+ *
+ * @param   handle              Handle to image sensor device
+ * @param   RegAddress          register address
+ * @param   RegValue            value to write
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NOTSUPP
+ *
+ *****************************************************************************/
+RESULT IsiWriteRegister
+(
+    IsiSensorHandle_t   handle,
+    const uint32_t      RegAddress,
+    const uint32_t      RegValue
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiReadRegister
+ *
+ * @brief   reads a given number of bytes from the image sensor device
+ *
+ * @param   handle              Handle to image sensor device
+ * @param   RegAddress          register address
+ * @param   RegValue            value to write
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ * @retval  RET_NOTSUPP
+ *
+ *****************************************************************************/
+RESULT IsiReadRegister
+(
+    IsiSensorHandle_t   handle,
+    const uint32_t      RegAddress,
+    uint32_t            *pRegValue
+);
+
+
+
+
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiMdiInitMotoDrive
+ *
+ * @brief   General initialisation tasks like I/O initialisation.
+ *
+ * @param   handle          sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiMdiInitMotoDrive
+(
+    IsiSensorHandle_t   handle
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiMdiSetupMotoDrive
+ *
+ * @brief   Setup of the MotoDrive and return possible max step.
+ *
+ * @param   handle          sensor instance handle
+ *          pMaxStep        pointer to variable to receive the maximum
+ *                          possible focus step
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiMdiSetupMotoDrive
+(
+    IsiSensorHandle_t   handle,
+    uint32_t            *pMaxStep
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiMdiFocusSet
+ *
+ * @brief   Drives the lens system to a certain focus point.
+ *
+ * @param   handle          sensor instance handle
+ *          AbsStep         absolute focus point to apply
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiMdiFocusSet
+(
+    IsiSensorHandle_t   handle,
+    const uint32_t      AbsStep
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiMdiFocusGet
+ *
+ * @brief   Retrieves the currently applied focus point.
+ *
+ * @param   handle          sensor instance handle
+ *          pAbsStep        pointer to a variable to receive the current
+ *                          focus point
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiMdiFocusGet
+(
+    IsiSensorHandle_t   handle,
+    uint32_t            *pAbsStep
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiMdiFocusCalibrate
+ *
+ * @brief   Triggers a forced calibration of the focus hardware.
+ *
+ * @param   handle          sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiMdiFocusCalibrate
+(
+    IsiSensorHandle_t   handle
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiActivateTestPattern
+ *
+ * @brief   Activates or deactivates sensor's test-pattern (normally a defined
+ *          colorbar )
+ *
+ * @param   handle          sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiActivateTestPattern
+(
+    IsiSensorHandle_t   handle,
+    const bool_t        enable
+);
+
+RESULT IsiEnableHdr
+(
+    IsiSensorHandle_t   handle,
+    const bool_t        enable
+);
+
+RESULT IsiSetBayerPattern
+(
+    IsiSensorHandle_t handle,
+    uint8_t pattern
+);
+
+/*****************************************************************************/
+/**
+ *          IsiDumpAllRegisters
+ *
+ * @brief   Activates or deactivates sensor's test-pattern (normally a defined
+ *          colorbar )
+ *
+ * @param   handle          sensor instance handle
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiDumpAllRegisters
+(
+    IsiSensorHandle_t   handle,
+    const uint8_t       *filename
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiTryToSetConfigFromPreferredCaps
+ *
+ * @brief   Tries to set the referenced sensor config parameter to the first of the
+ *          given preferred capabilities that is included in the given capability
+ *          mask. If none of the preferred capabilities is supported, the config
+ *          parameter value remains unchanged.
+ *
+ * @note    Use this function for example to modify the retrieved default sensor
+ *          config parameter for parameter according to some external preferences
+ *          while taking the retrieved sensor capabilities for that config parameter
+ *          into account.
+ *
+ * @param   pConfigParam    reference to parameter of sensor config structure
+ * @param   prefList        reference to 0 (zero) terminated array of preferred
+ *                          capability values in descending order
+ * @param   capsmask        bitmask of supported capabilites for that parameter
+ *
+ * @return  Return the result of the function call.
+ * @retval  BOOL_TRUE       preferred capability set in referenced config parameter
+ * @retval  BOOL_FALSE      preferred capability not supported
+ *
+ *****************************************************************************/
+bool_t IsiTryToSetConfigFromPreferredCaps
+(
+    uint32_t    *pConfigParam,
+    uint32_t    *prefList,
+    uint32_t    capsmask
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiTryToSetConfigFromPreferredCap
+ *
+ * @brief   Tries to set referenced sensor config parameter to the given preferred
+ *          capability while checking that capability against the given capability
+ *          mask. If that capability isn't supported, the config parameter value
+ *          remains unchanged.
+ *
+ * @note    Use this function for example to modify the retrieved default sensor
+ *          config parameter for parameter according to some external preferences
+ *          while taking the retrieved sensor capabilities for that config parameter
+ *          into account.
+ *
+ * @param   pConfigParam    reference to parameter of sensor config structure
+ * @param   prefcap         preferred capability value
+ * @param   capsmask        bitmask of supported capabilites for that parameter
+ *
+ * @return  Return the result of the function call.
+ * @retval  BOOL_TRUE       preferred capability set in referenced config parameter
+ * @retval  BOOL_FALSE      preferred capability not supported
+ *
+ *****************************************************************************/
+bool_t IsiTryToSetConfigFromPreferredCap
+(
+    uint32_t        *pConfigParam,
+    const uint32_t  prefcap,
+    const uint32_t  capsmask
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetSensorAWBMode
+ *
+ * @brief   get sensor awb mode ( workaround )
+ *
+ * Used to modify the AWB control loop handling in case of sensors that require
+ * on-sensor whitebalance gain
+ *
+ * @param        handle          sensor instance handle
+ * @param[out]   pawb_mode       awb mode the sensor is operating in currently
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_FAILURE
+ *
+ *****************************************************************************/
+RESULT IsiGetSensorAWBMode(IsiSensorHandle_t handle, IsiSensorAwbMode_t *pawb_mode);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSensorSetBlc
+ *
+ * @brief   set sensor linear mode black level 
+ *          
+ *
+ * @param   handle          sensor instance handle
+ * @param   pblc            blc params point
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_FAILURE
+ *
+ *****************************************************************************/
+RESULT IsiSensorSetBlc(IsiSensorHandle_t handle, sensor_blc_t * pblc);
+
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSensorSetWB
+ *
+ * @brief   set sensor linear mode white balance 
+ *          or hdr mode normal exp frame white balance
+ *
+ * @param   handle          sensor instance handle
+ * @param   pwb             wb params point
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_FAILURE
+ *
+ *****************************************************************************/
+RESULT IsiSensorSetWB(IsiSensorHandle_t handle, sensor_white_balance_t *pwb);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiSensorGetExpandCure
+ *
+ * @brief   get sensor expand curve 
+ *
+ * @param   handle          sensor instance handle
+ * @param   pexpand_curve   expand cure point
+ *
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_FAILURE
+ *
+ *****************************************************************************/
+RESULT IsiSensorGetExpandCurve(IsiSensorHandle_t handle, sensor_expand_curve_t * pexpand_curve);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* @} isi */
+
+
+#endif /* __ISI_H__ */

+ 218 - 0
isp_isp8000l/units/isi/isi_common.h

@@ -0,0 +1,218 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file isi_iss.h
+ *
+ * @brief Interface description for image sensor specific implementation (iss).
+ *
+ *****************************************************************************/
+/**
+ * @page module_name_page Module Name
+ * Describe here what this module does.
+ *
+ * For a detailed list of functions and implementation detail refer to:
+ * - @ref module_name
+ *
+ * @defgroup isi_iss CamerIc Driver API
+ * @{
+ *
+ */
+#ifndef __ISI_COMMON_H__
+#define __ISI_COMMON_H__
+
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define VI_CONFIG_PATH "/usr/share/vi/config/"
+
+char* get_vi_config_path(void);
+
+/*****************************************************************************/
+/*!
+ * interface version
+ * =================
+ * please increment the version if you add something new to the interface.
+ * This helps upper layer software to deal with different interface versions.
+ */
+/*****************************************************************************/
+#define ISI_INTERFACE_VERSION               6
+
+
+
+/*****************************************************************************/
+/* capabilities / configuration
+ *****************************************************************************/
+
+/**<  BusWidth */
+#define ISI_BUSWIDTH_8BIT_ZZ                0x00000001U     /**< to expand to a (possibly higher) resolution in marvin, the LSBs will be set to zero */
+#define ISI_BUSWIDTH_8BIT_EX                0x00000002U     /**< to expand to a (possibly higher) resolution in marvin, the LSBs will be copied from the MSBs */
+#define ISI_BUSWIDTH_10BIT_EX               0x00000004U     /**< /formerly known as ISI_BUSWIDTH_10BIT (at times no marvin derivative was able to process more than 10 bit) */
+#define ISI_BUSWIDTH_10BIT_ZZ               0x00000008U
+#define ISI_BUSWIDTH_12BIT                  0x00000010U
+
+#define ISI_BUSWIDTH_10BIT      ( ISI_BUSWIDTH_10BIT_EX )
+
+
+/**< Mode, operating mode of the image sensor in terms of output data format and timing data transmission */
+#define ISI_MODE_BT601                      0x00000001      /**< YUV-Data with separate h/v sync lines (ITU-R BT.601) */
+#define ISI_MODE_BT656                      0x00000002      /**< YUV-Data with sync words inside the datastream (ITU-R BT.656) */
+#define ISI_MODE_BAYER                      0x00000004      /**< Bayer data with separate h/v sync lines */
+#define ISI_MODE_DATA                       0x00000008      /**< Any binary data without line/column-structure, (e.g. already JPEG encoded) h/v sync lines act as data valid signals */
+#define ISI_MODE_PICT                       0x00000010      /**< RAW picture data with separate h/v sync lines */
+#define ISI_MODE_RGB565                     0x00000020      /**< RGB565 data with separate h/v sync lines */
+#define ISI_MODE_SMIA                       0x00000040      /**< SMIA conform data stream (see SmiaMode for details) */
+#define ISI_MODE_MIPI                       0x00000080      /**< MIPI conform data stream (see MipiMode for details) */
+#define ISI_MIPI_LANES                      0x00000060
+#define ISI_MODE_BAY_BT656                  0x00000100     /**< Bayer data with sync words inside the datastream (similar to ITU-R BT.656) */
+#define ISI_MODE_RAW_BT656                  0x00000200      /**< Raw picture data with sync words inside the datastream (similar to ITU-R BT.656) */
+
+/**< SmiaMode */
+#define ISI_SMIA_MODE_COMPRESSED            0x00000001      //!< compression mode
+#define ISI_SMIA_MODE_RAW_8_TO_10_DECOMP    0x00000002      //!< 8bit to 10 bit decompression
+#define ISI_SMIA_MODE_RAW_12                0x00000004      //!< 12 bit RAW Bayer Data
+#define ISI_SMIA_MODE_RAW_10                0x00000008      //!< 10 bit RAW Bayer Data
+#define ISI_SMIA_MODE_RAW_8                 0x00000010      //!< 8 bit RAW Bayer Data
+#define ISI_SMIA_MODE_RAW_7                 0x00000020      //!< 7 bit RAW Bayer Data
+#define ISI_SMIA_MODE_RAW_6                 0x00000040      //!< 6 bit RAW Bayer Data
+#define ISI_SMIA_MODE_RGB_888               0x00000080      //!< RGB 888 Display ready Data
+#define ISI_SMIA_MODE_RGB_565               0x00000100      //!< RGB 565 Display ready Data
+#define ISI_SMIA_MODE_RGB_444               0x00000200      //!< RGB 444 Display ready Data
+#define ISI_SMIA_MODE_YUV_420               0x00000400      //!< YUV420 Data
+#define ISI_SMIA_MODE_YUV_422               0x00000800      //!< YUV422 Data
+#define ISI_SMIA_OFF                        0x80000000      //!< SMIA is disabled
+
+/**< MipiMode */
+#define ISI_MIPI_MODE_YUV420_8              0x00000001      //!< YUV 420  8-bit
+#define ISI_MIPI_MODE_YUV420_10             0x00000002      //!< YUV 420 10-bit
+#define ISI_MIPI_MODE_LEGACY_YUV420_8       0x00000004      //!< Legacy YUV 420 8-bit
+#define ISI_MIPI_MODE_YUV420_CSPS_8         0x00000008      //!< YUV 420 8-bit (CSPS)
+#define ISI_MIPI_MODE_YUV420_CSPS_10        0x00000010      //!< YUV 420 10-bit (CSPS)
+#define ISI_MIPI_MODE_YUV422_8              0x00000020      //!< YUV 422 8-bit
+#define ISI_MIPI_MODE_YUV422_10             0x00000040      //!< YUV 422 10-bit
+#define ISI_MIPI_MODE_RGB444                0x00000080      //!< RGB 444
+#define ISI_MIPI_MODE_RGB555                0x00000100      //!< RGB 555
+#define ISI_MIPI_MODE_RGB565                0x00000200      //!< RGB 565
+#define ISI_MIPI_MODE_RGB666                0x00000400      //!< RGB 666
+#define ISI_MIPI_MODE_RGB888                0x00000800      //!< RGB 888
+#define ISI_MIPI_MODE_RAW_6                 0x00001000      //!< RAW_6
+#define ISI_MIPI_MODE_RAW_7                 0x00002000      //!< RAW_7
+#define ISI_MIPI_MODE_RAW_8                 0x00004000      //!< RAW_8
+#define ISI_MIPI_MODE_RAW_10                0x00008000      //!< RAW_10
+#define ISI_MIPI_MODE_RAW_12                0x00010000      //!< RAW_12
+#define ISI_MIPI_OFF                        0x80000000      //!< MIPI is disabled
+#define ISI_MIPI_4LANES                     0x00000004
+#define ISI_MIPI_2LANES                     0x00000002
+
+/**< FieldSelection */
+#define ISI_FIELDSEL_BOTH                   0x00000001      /**< sample all field (don't care about fields */
+#define ISI_FIELDSEL_EVEN                   0x00000002      /**< sample only even fields */
+#define ISI_FIELDSEL_ODD                    0x00000004      /**< sample only odd fields */
+
+/**< YCSeq */
+#define ISI_YCSEQ_YCBYCR                    0x00000001
+#define ISI_YCSEQ_YCRYCB                    0x00000002
+#define ISI_YCSEQ_CBYCRY                    0x00000004
+#define ISI_YCSEQ_CRYCBY                    0x00000008
+
+/**< Conv422 */
+#define ISI_CONV422_COSITED                 0x00000001
+#define ISI_CONV422_INTER                   0x00000002
+#define ISI_CONV422_NOCOSITED               0x00000004
+
+/**< BayerPatttern */
+#define ISI_BPAT_RGRGGBGB                   0x00000001
+#define ISI_BPAT_GRGRBGBG                   0x00000002
+#define ISI_BPAT_GBGBRGRG                   0x00000004
+#define ISI_BPAT_BGBGGRGR                   0x00000008
+
+/**< HPolarity */
+#define ISI_HPOL_SYNCPOS                    0x00000001      /**< sync signal pulses high between lines */
+#define ISI_HPOL_SYNCNEG                    0x00000002      /**< sync signal pulses low between lines */
+#define ISI_HPOL_REFPOS                     0x00000004      /**< reference signal is high as long as sensor puts out line data */
+#define ISI_HPOL_REFNEG                     0x00000008      /**< reference signal is low as long as sensor puts out line data */
+
+/**< VPolarity */
+#define ISI_VPOL_POS                        0x00000001
+#define ISI_VPOL_NEG                        0x00000002
+
+/**< Edge */
+#define ISI_EDGE_RISING                     0x00000001
+#define ISI_EDGE_FALLING                    0x00000002
+
+/**< frame rate **/
+#define ISI_FPS_MAX                         60
+#define ISI_FPS_MIN                         1
+
+
+/**< HDR */
+#define ISI_HDR_DISABLED                    BOOL_FALSE      /**< hdr disabled */
+#define ISI_HDR_ENABLED                     BOOL_TRUE      /**< hdr enabled */
+
+/*****************************************************************************/
+/**
+ *          IsiSensorAwbMode_t
+ *
+ * @brief   mode of awb control to handle whitebalance during integration of AR082x
+ */
+/*****************************************************************************/
+typedef enum IsiSensorAwbMode_e
+{
+    ISI_SENSOR_AWB_MODE_NORMAL  = 0,
+    ISI_SENSOR_AWB_MODE_SENSOR,
+} IsiSensorAwbMode_t;
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiColorComponent_t
+ *
+ * @brief   color components
+ */
+/*****************************************************************************/
+typedef enum IsiColorComponent_e
+{
+    ISI_COLOR_COMPONENT_RED     = 0,
+    ISI_COLOR_COMPONENT_GREENR  = 1,
+    ISI_COLOR_COMPONENT_GREENB  = 2,
+    ISI_COLOR_COMPONENT_BLUE    = 3,
+    ISI_COLOR_COMPONENT_MAX     = 4
+} IsiColorComponent_t;
+
+/*****************************************************************************/
+/*!
+ *  *  Sensor-specific information structure for MIPI. Is filled in by sensor
+ *   *  specific code. Features not supported by the sensor driver code will be
+ *   set
+ *    *  to NULL.
+ *     */
+/*****************************************************************************/
+typedef struct
+{
+    uint8_t  ucMipiLanes;             // number of used MIPI lanes by sensor
+} IsiSensorMipiInfo;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ISI_COMMON_H__ */

+ 300 - 0
isp_isp8000l/units/isi/isi_iss.h

@@ -0,0 +1,300 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file isi_iss.h
+ *
+ * @brief Interface description for image sensor specific implementation (iss).
+ *
+ *****************************************************************************/
+/**
+ * @page module_name_page Module Name
+ * Describe here what this module does.
+ *
+ * For a detailed list of functions and implementation detail refer to:
+ * - @ref module_name
+ *
+ * @defgroup isi_iss CamerIc Driver API
+ * @{
+ *
+ */
+#ifndef __ISI_ISS_H__
+#define __ISI_ISS_H__
+
+#include <ebase/types.h>
+#include <common/return_codes.h>
+#include <hal/hal_api.h>
+
+#include "isi.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiRegisterFlags_t
+ *
+ * @brief   Register permission enumeration type
+ */
+/*****************************************************************************/
+typedef enum IsiRegisterFlags_e
+{
+    // basic features
+    eTableEnd           = 0x00,                                                 /**< special flag for end of register table */
+    eReadable           = 0x01,
+    eWritable           = 0x02,
+    eVolatile           = 0x04,                                                 /**< register can change even if not written by I2C */
+    eDelay              = 0x08,                                                 /**< wait n ms */
+    eReserved           = 0x10,
+    eNoDefault          = 0x20,                                                 /**< no default value specified */
+    eTwoBytes           = 0x40,                                                 /**< SMIA sensors use 8-, 16- and 32-bit registers */
+    eFourBytes          = 0x80,                                                 /**< SMIA sensors use 8-, 16- and 32-bit registers */
+
+    // combined features
+    eReadOnly           = eReadable,
+    eWriteOnly          = eWritable,
+    eReadWrite          = eReadable | eWritable,
+    eReadWriteDel       = eReadable | eWritable | eDelay,
+    eReadWriteVolatile  = eReadable | eWritable | eVolatile,
+    eReadWriteNoDef     = eReadable | eWritable | eNoDefault,
+    eReadWriteVolNoDef  = eReadable | eWritable | eVolatile | eNoDefault,
+    eReadVolNoDef       = eReadable | eVolatile | eNoDefault,
+    eReadOnlyVolNoDef   = eReadOnly | eVolatile | eNoDefault,
+
+    // additional SMIA features
+    eReadOnly_16            = eReadOnly          | eTwoBytes,
+    eReadWrite_16           = eReadWrite         | eTwoBytes,
+    eReadWriteDel_16        = eReadWriteDel      | eTwoBytes,
+    eReadWriteVolatile_16   = eReadWriteVolatile | eTwoBytes,
+    eReadWriteNoDef_16      = eReadWriteNoDef    | eTwoBytes,
+    eReadWriteVolNoDef_16   = eReadWriteVolNoDef | eTwoBytes,
+    eReadOnlyVolNoDef_16    = eReadOnly_16 | eVolatile | eNoDefault,
+    eReadOnly_32            = eReadOnly          | eFourBytes,
+    eReadWrite_32           = eReadWrite         | eFourBytes,
+    eReadWriteVolatile_32   = eReadWriteVolatile | eFourBytes,
+    eReadWriteNoDef_32      = eReadWriteNoDef    | eFourBytes,
+    eReadWriteVolNoDef_32   = eReadWriteVolNoDef | eFourBytes
+} IsiRegisterFlags_t;
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiRegDescription_t
+ *
+ * @brief   Sensor register description struct
+ */
+/*****************************************************************************/
+typedef struct IsiRegisterFlags_s
+{
+    uint32_t    Addr;
+    uint32_t    DefaultValue;
+    const char* pName;
+    uint32_t    Flags;
+} IsiRegDescription_t;
+
+
+typedef RESULT (*IsiCreateSensorIss_t)               ( IsiSensorInstanceConfig_t *pConfig );
+typedef RESULT (*IsiInitSensorIss_t)                 ( IsiSensorHandle_t handle );
+typedef RESULT (*IsiGetSensorModeIss_t)              ( IsiSensorHandle_t handle, void *mode);
+typedef RESULT (*IsiReleaseSensorIss_t)              ( IsiSensorHandle_t handle );
+typedef RESULT (*IsiGetCapsIss_t)                    ( IsiSensorHandle_t handle, IsiSensorCaps_t *pIsiSensorCaps );
+typedef RESULT (*IsiSetupSensorIss_t)                ( IsiSensorHandle_t handle, const IsiSensorCaps_t *pIsiSensorCaps );
+typedef RESULT (*IsiChangeSensorResolutionIss_t)     ( IsiSensorHandle_t handle, uint16_t width, uint16_t height );
+typedef RESULT (*IsiSensorSetStreamingIss_t)         ( IsiSensorHandle_t handle, bool_t on );
+typedef RESULT (*IsiSensorSetPowerIss_t)             ( IsiSensorHandle_t handle, bool_t on );
+typedef RESULT (*IsiCheckSensorConnectionIss_t)      ( IsiSensorHandle_t handle );
+typedef RESULT (*IsiGetSensorRevisionIss_t)          ( IsiSensorHandle_t handle, uint32_t *p_value );
+typedef RESULT (*IsiRegisterReadIss_t)               ( IsiSensorHandle_t handle, const uint32_t address, uint32_t *p_value );
+typedef RESULT (*IsiRegisterWriteIss_t)              ( IsiSensorHandle_t handle, const uint32_t address, const uint32_t value );
+
+/* AEC */
+typedef RESULT (*IsiExposureControlIss_t)            ( IsiSensorHandle_t handle, const float NewGain, const float NewIntegrationTime, uint8_t *pNumberOfFramesToSkip, float *pSetGain, float *pSetIntegrationTime, float* hdr_ratio);
+typedef RESULT (*IsiGetGainLimitsIss_t)              ( IsiSensorHandle_t handle, float *pMinGain, float *pMaxGain);
+typedef RESULT (*IsiGetIntegrationTimeLimitsIss_t)   ( IsiSensorHandle_t handle, float *pMinIntegrationTime, float *pMaxIntegrationTime );
+typedef RESULT (*IsiGetCurrentExposureIss_t)         ( IsiSensorHandle_t handle, float *pSetGain, float *pSetIntegrationTime, float *pCurHdrRatio);
+typedef RESULT (*IsiGetGainIss_t)                    ( IsiSensorHandle_t handle, float *pSetGain );
+typedef RESULT (*IsiGetVSGainIss_t)                  ( IsiSensorHandle_t handle, float *pSetGain );
+typedef RESULT (*IsiGetLongGainIss_t)                ( IsiSensorHandle_t handle, float *pSetGain );
+typedef RESULT (*IsiGetGainIncrementIss_t)           ( IsiSensorHandle_t handle, float *pIncr );
+typedef RESULT (*IsiSetGainIss_t)                    ( IsiSensorHandle_t handle, float NewGain, float *pSetGain, float *hdr_ratio);
+typedef RESULT (*IsiGetIntegrationTimeIss_t)         ( IsiSensorHandle_t handle, float *pSetIntegrationTime );
+typedef RESULT (*IsiGetVSIntegrationTimeIss_t)       ( IsiSensorHandle_t handle, float *pSetIntegrationTime );
+typedef RESULT (*IsiGetLongIntegrationTimeIss_t)     ( IsiSensorHandle_t handle, float *pIntegrationTime );
+typedef RESULT (*IsiGetIntegrationTimeIncrementIss_t)( IsiSensorHandle_t handle, float *pIncr );
+typedef RESULT (*IsiSetIntegrationTimeIss_t)         ( IsiSensorHandle_t handle, float NewIntegrationTime, float *pSetIntegrationTime, uint8_t *pNumberOfFramesToSkip, float *hdr_ratio);
+typedef RESULT (*IsiGetResolutionIss_t)              ( IsiSensorHandle_t handle, uint16_t *pwidth, uint16_t *pheight );
+
+/* AF */
+typedef RESULT (*IsiMdiInitMotoDriveMds_t)           ( IsiSensorHandle_t handle );
+typedef RESULT (*IsiMdiSetupMotoDrive_t)             ( IsiSensorHandle_t handle, uint32_t *pMaxStep );
+typedef RESULT (*IsiMdiFocusSet_t)                   ( IsiSensorHandle_t handle, const uint32_t AbsStep );
+typedef RESULT (*IsiMdiFocusGet_t)                   ( IsiSensorHandle_t handle, uint32_t *pAbsStep );
+typedef RESULT (*IsiMdiFocusCalibrate_t)             ( IsiSensorHandle_t handle );
+
+/*MIPI*/
+typedef RESULT (*IsiGetSensorMipiInfoIss_t)          ( IsiSensorHandle_t handle ,IsiSensorMipiInfo *ptIsiSensorMipiInfo );
+typedef RESULT (*IsiResetSensor_t)                   ( IsiSensorHandle_t handle );
+/* Testpattern */
+typedef RESULT (*IsiActivateTestPattern_t)           ( IsiSensorHandle_t handle, const bool_t enable );
+
+/* BayerPattern */
+typedef RESULT (*IsiSetBayerPattern_t)               ( IsiSensorHandle_t handle, uint8_t pattern );
+
+/* get fps */
+typedef RESULT (*IsiGetSensorFpsIss_t)               ( IsiSensorHandle_t handle, uint32_t *pfps );
+
+/* set fps */
+typedef RESULT (*IsiSetSensorFpsIss_t)               ( IsiSensorHandle_t handle, uint32_t fps );
+
+typedef RESULT (*IsiQuerySensorIss_t)                (IsiSensorHandle_t  handle, vvcam_mode_info_array_t *pSensorInfo);
+
+typedef RESULT (*IsiSensorSetBlcIss_t)               (IsiSensorHandle_t  handle, sensor_blc_t * pblc);
+
+typedef RESULT (*IsiSensorSetWBIss_t)                (IsiSensorHandle_t  handle, sensor_white_balance_t * pwb);
+
+typedef RESULT (*IsiGetSensorAWBModeIss_t)           (IsiSensorHandle_t  handle, IsiSensorAwbMode_t *pawbmode);
+
+typedef RESULT (*IsiSensorGetExpandCurveIss_t)       (IsiSensorHandle_t  handle, sensor_expand_curve_t * pexpand_curve);
+
+/* query sensor support mode */
+typedef RESULT (*IsiQuerySensorSupportIss_t)         (HalHandle_t  HalHandle, vvcam_mode_info_array_t *pSensorSupportInfo);
+
+typedef RESULT (*IsiSensorSetLongExpWBIss_t)         (HalHandle_t  HalHandle, void * pwb);
+
+typedef RESULT (*IsiSensorSetShortExpWBIss_t)        (HalHandle_t  HalHandle, void * pwb);
+
+typedef RESULT (*IsiSensorGetTemperature_t)        (HalHandle_t  HalHandle, int32_t *val);
+
+/*****************************************************************************/
+/**
+ *          IsiSensor_t
+ *
+ * @brief
+ *
+ */
+/*****************************************************************************/
+struct IsiSensor_s
+{
+    const char                          *pszName;                       /**< name of the camera-sensor */
+    const IsiRegDescription_t           *pRegisterTable;                /**< pointer to register table */
+    const IsiSensorCaps_t               *pIsiSensorCaps;                /**< pointer to sensor capabilities */
+
+    IsiCreateSensorIss_t                pIsiCreateSensorIss;     	/**< create a sensor handle */
+    IsiInitSensorIss_t                  pIsiInitSensorIss;		/** init sensor register  */
+    IsiGetSensorModeIss_t               pIsiGetSensorModeIss;
+    IsiReleaseSensorIss_t               pIsiReleaseSensorIss;          /**< release a sensor handle */
+    IsiGetCapsIss_t                     pIsiGetCapsIss;                /**< get sensor capabilities */
+    IsiSetupSensorIss_t                 pIsiSetupSensorIss;            /**< setup sensor capabilities */
+    IsiChangeSensorResolutionIss_t      pIsiChangeSensorResolutionIss; /**< change sensor resolution */
+    IsiSensorSetStreamingIss_t          pIsiSensorSetStreamingIss;     /**< enable/disable streaming of data once sensor is configured */
+    IsiSensorSetPowerIss_t              pIsiSensorSetPowerIss;         /**< turn sensor power on/off */
+    IsiCheckSensorConnectionIss_t       pIsiCheckSensorConnectionIss;
+
+    IsiGetSensorRevisionIss_t           pIsiGetSensorRevisionIss;      /**< read sensor revision register (if available) */
+    IsiRegisterReadIss_t                pIsiRegisterReadIss;           /**< read sensor register */
+    IsiRegisterWriteIss_t               pIsiRegisterWriteIss;          /**< write sensor register */
+
+    /* AEC functions */
+    IsiExposureControlIss_t             pIsiExposureControlIss;
+    IsiGetGainLimitsIss_t               pIsiGetGainLimitsIss;
+    IsiGetIntegrationTimeLimitsIss_t    pIsiGetIntegrationTimeLimitsIss;
+    IsiGetCurrentExposureIss_t          pIsiGetCurrentExposureIss;     /**< get the currenntly adjusted ae values (gain and integration time) */
+    IsiGetGainIss_t                     pIsiGetGainIss;
+    IsiGetVSGainIss_t                   pIsiGetVSGainIss;
+    IsiGetLongGainIss_t                 pIsiGetLongGainIss;
+    IsiGetGainIncrementIss_t            pIsiGetGainIncrementIss;
+    IsiSetGainIss_t                     pIsiSetGainIss;
+    IsiGetIntegrationTimeIss_t          pIsiGetIntegrationTimeIss;
+    IsiGetVSIntegrationTimeIss_t        pIsiGetVSIntegrationTimeIss;
+    IsiGetLongIntegrationTimeIss_t      pIsiGetLongIntegrationTimeIss;
+    IsiGetIntegrationTimeIncrementIss_t pIsiGetIntegrationTimeIncrementIss;
+    IsiSetIntegrationTimeIss_t          pIsiSetIntegrationTimeIss;
+    IsiQuerySensorIss_t                 pIsiQuerySensorIss;
+    IsiGetResolutionIss_t               pIsiGetResolutionIss;
+    IsiGetSensorFpsIss_t                pIsiGetSensorFpsIss;
+    IsiSetSensorFpsIss_t                pIsiSetSensorFpsIss;
+    IsiSensorGetExpandCurveIss_t        pIsiSensorGetExpandCurveIss;
+    /* AF functions */
+    IsiMdiInitMotoDriveMds_t            pIsiMdiInitMotoDriveMds;
+    IsiMdiSetupMotoDrive_t              pIsiMdiSetupMotoDrive;
+    IsiMdiFocusSet_t                    pIsiMdiFocusSet;
+    IsiMdiFocusGet_t                    pIsiMdiFocusGet;
+    IsiMdiFocusCalibrate_t              pIsiMdiFocusCalibrate;
+
+    /*MIPI*/
+    IsiGetSensorMipiInfoIss_t           pIsiGetSensorMipiInfoIss;
+    IsiResetSensor_t                    pIsiResetSensorIss;
+
+    /* Testpattern */
+    IsiActivateTestPattern_t            pIsiActivateTestPattern;       /**< enable/disable test-pattern */
+    IsiSetBayerPattern_t                pIsiSetBayerPattern;
+
+    IsiSensorSetBlcIss_t                pIsiSensorSetBlcIss;
+    IsiSensorSetWBIss_t                 pIsiSensorSetWBIss;
+    IsiGetSensorAWBModeIss_t            pIsiGetSensorAWBModeIss;
+    IsiSensorGetTemperature_t           pIsiGetSensorTemperature;
+};
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetSensorIss_t
+ *
+ * @brief   Only exported function of sensor specific code: fills in
+ *          sensor decription struct
+ *
+ */
+/*****************************************************************************/
+typedef RESULT (*IsiGetSensorIss_t) ( IsiSensor_t *pIsiSensor );
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiCamDrvConfig_t
+ *
+ * @brief   Camera sensor driver specific data
+ *
+ */
+/*****************************************************************************/
+typedef struct IsiCamDrvConfig_s
+{
+    uint32_t                     CameraDriverID;
+    IsiQuerySensorSupportIss_t   pIsiQuerySensorSupportIss;
+    IsiGetSensorIss_t            pfIsiGetSensorIss;
+    IsiSensor_t                  IsiSensor;
+} IsiCamDrvConfig_t;
+
+typedef struct IsiSccbInfo_s
+{
+    uint8_t slave_addr;
+    uint8_t addr_byte;
+    uint8_t data_byte;
+} IsiSccbInfo_t;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ISI_ISS_H__ */
+

+ 167 - 0
isp_isp8000l/units/isi/isi_priv.h

@@ -0,0 +1,167 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file isi_priv.h
+ *
+ * @brief Interface description for image sensor specific implementation (iss).
+ *
+ *****************************************************************************/
+/**
+ * @page module_name_page Module Name
+ * Describe here what this module does.
+ *
+ * For a detailed list of functions and implementation detail refer to:
+ * - @ref module_name
+ *
+ * @defgroup isi_priv
+ * @{
+ *
+ */
+#ifndef __ISI_PRIV_H__
+#define __ISI_PRIV_H__
+
+#include <ebase/types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "isi_iss.h"
+
+/******************************************************************************
+* DEFINES
+******************************************************************************/
+#define MAX_REGISTER_TABLE_ENTRIES 256
+
+#define ISI_I2C_NR_DAT_BYTES_1  (1)                     // sensor has some  8-bit registers
+#define ISI_I2C_NR_DAT_BYTES_2  (2)                     // sensor has some 16-bit registers
+#define ISI_I2C_NR_DAT_BYTES_4  (4)                     // sensor has some 32-bit registers
+
+
+/******************************************************************************
+* TYPEDEFS
+******************************************************************************/
+
+/*****************************************************************************/
+/**
+ *          IsiSensorContext_t
+ *
+ * @brief   abstract class of a sensor context
+ *
+ */
+/*****************************************************************************/
+typedef struct IsiSensorContext_s
+{
+    int            fd;                  /**< /dev/v4l-subdev file description */
+    HalHandle_t    HalHandle;           /**< Handle of HAL session to use. */
+    IsiSensor_t    *pSensor;            /**< points to the sensor device */
+} IsiSensorContext_t;
+
+
+
+
+/******************************************************************************
+* FUNCTIONS
+******************************************************************************/
+//! for the current register tables (tsIsiRegDescription)
+#if 0
+RESULT IsiRegDefaultsApply( const tsIsiRegDescription* patRegDescr );
+RESULT IsiRegDefaultsVerify( const tsIsiRegDescription* patRegDescr );
+#endif
+
+
+/*****************************************************************************/
+/**
+ *          IsiGetNrDatBytesIss
+ *
+ * @brief   Extracts from the register description table the amount of bytes
+ *          the desired register consists of
+ *
+ * @param   address          register address
+ * @param   pRegDesc         register description table
+ *
+ * @return  Return the number of bytes
+ * @retval  ISI_I2C_NR_DAT_BYTES_1
+ * @retval  ISI_I2C_NR_DAT_BYTES_2
+ * @retval  ISI_I2C_NR_DAT_BYTES_4
+ * @retval  0U                      unknown register
+ *
+ *****************************************************************************/
+uint8_t IsiGetNrDatBytesIss
+(
+    const uint32_t            Address,
+    const IsiRegDescription_t *pRegDesc
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiRegDefaultsApply
+ *
+ * @brief   This function applies the default values of the registers specified
+ *          in the given table. Writes to all registers that have been declared
+ *          as writable and do have a default value (appropriate enum in table).
+ *
+ * @param   handle      Handle to image sensor device
+ * @param   pRegDesc    Register description table
+ *
+ * @return  Return the number of bytes
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiRegDefaultsApply
+(
+    IsiSensorHandle_t         handle,
+    const IsiRegDescription_t *pRegDesc
+);
+
+
+
+/*****************************************************************************/
+/**
+ *          IsiRegDefaultsVerify
+ *
+ * @brief   Reads back registers from the image sensor and compares them
+ *          against the register table. Only registers that are readable,
+ *          writable and not volatile will be checked.
+ *
+ * @param   handle      Handle to image sensor device
+ * @param   pRegDesc    Register description table
+ *
+ * @return  Return the number of bytes
+ * @return  Return the result of the function call.
+ * @retval  RET_SUCCESS
+ * @retval  RET_WRONG_HANDLE
+ * @retval  RET_NULL_POINTER
+ *
+ *****************************************************************************/
+RESULT IsiRegDefaultsVerify
+(
+    IsiSensorHandle_t         handle,
+    const IsiRegDescription_t *pRegDesc
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ISI_PRIV_H__ */

+ 1026 - 0
isp_isp8000l/units/oslayer/oslayer.h

@@ -0,0 +1,1026 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file    oslayer.h
+ *
+ * @brief   Operating System Abstraction Layer
+ *
+ *          Encapsulates and abstracts services from different operating
+ *          system, including user-mode as well as kernel-mode services.
+ ******************************************************************************/
+#ifndef OSLAYER_H
+#define OSLAYER_H
+
+/**
+ * @defgroup OS_LAYER_CONFIG OS layer configuration
+ * @{
+ * @brief   Enables/disables the different services provided by the OS layer.
+ *****************************************************************************/
+
+/******************************************************************************/
+/** @brief  Include time-stamp handling in OS Abstraction Layer library */
+#define OSLAYER_TIMESTAMP
+
+/******************************************************************************/
+/** @brief  Include event handling in OS Abstraction Layer library */
+#define OSLAYER_EVENT
+
+/******************************************************************************/
+/** @brief  Include mutex handling in OS Abstraction Layer library */
+#define OSLAYER_MUTEX
+
+/******************************************************************************/
+/** @brief  Include semaphore handling in OS Abstraction Layer library */
+#define OSLAYER_SEMAPHORE
+
+/******************************************************************************/
+/** @brief  Include queue handling in OS Abstraction Layer library */
+#if defined OSLAYER_SEMAPHORE && defined OSLAYER_MUTEX
+#define OSLAYER_QUEUE
+#endif
+
+/******************************************************************************/
+/** @brief  Include atomic operations in OS Abstraction Layer library */
+#define OSLAYER_ATOMIC
+
+/******************************************************************************/
+/** @brief  Include thread handling in OS Abstraction Layer library */
+#if defined OSLAYER_EVENT && defined OSLAYER_MUTEX
+#define OSLAYER_THREAD
+#endif
+
+/******************************************************************************/
+/** @brief  Include IRQ service functionality in OS Abstraction Layer library */
+#if defined OSLAYER_EVENT && defined OSLAYER_MUTEX && defined OSLAYER_THREAD
+#define OSLAYER_IRQ
+#endif
+
+/******************************************************************************/
+/** @brief  Include misc functionality in OS Abstraction Layer library */
+#define OSLAYER_MISC
+
+//!@} defgroup OS_LAYER_CONFIG
+
+/**
+ * @defgroup OS_LAYER OS layer interface
+ * @{
+ * @brief   Encapsulates and abstracts services from different operating
+ *          system, including user-mode as well as kernel-mode services,
+ *          in a operating system independent way.
+ *****************************************************************************/
+
+#ifdef WIN32
+#include "oslayer_win32.h"
+#endif
+#ifdef LINUX
+  #ifdef MSVD_COSIM
+   #include "oslayer_systemc.h"
+  #else
+   #include "oslayer_linux.h"
+  #endif
+#endif
+#ifdef UCOSII
+   #include "oslayer_ucosii.h"
+#endif
+#ifdef MFS
+#include "oslayer_mfs.h"
+#endif
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+/* in debug case, each OS layer implementation
+   shall define the following macros as needed */
+#ifndef OSLAYER_ASSERT
+#define OSLAYER_ASSERT(x)
+#endif /* OSLAYER_DEBUG */
+
+
+/******************************************************************************/
+/** @brief  Status codes of OS Abstraction Layer operation */
+typedef enum _OSLAYER_STATUS
+{
+    OSLAYER_OK                    = 0,   /*< success */
+    OSLAYER_ERROR                 =-1,   /*< general error */
+    OSLAYER_INVALID_PARAM         =-2,   /*< invalid parameter supplied */
+    OSLAYER_OPERATION_FAILED      =-3,   /*< operation failed (i.e. current operation is interrupted) */
+    OSLAYER_NOT_INITIALIZED       =-4,   /*< resource object is not initialized */
+    OSLAYER_TIMEOUT               =-5,   /*< operation failed due to elapsed timeout */
+    OSLAYER_SIGNAL_PENDING        =-6    /*< operation interrupted due to pending signal for waiting thread/process */
+} OSLAYER_STATUS;
+
+
+
+/******************************************************************************/
+/** @brief  Priority of thread created by OS Abstraction Layer */
+typedef enum _OSLAYER_THREAD_PRIO
+{
+    OSLAYER_THREAD_PRIO_HIGHEST,
+    OSLAYER_THREAD_PRIO_HIGH,
+    OSLAYER_THREAD_PRIO_NORMAL,
+    OSLAYER_THREAD_PRIO_LOW,
+    OSLAYER_THREAD_PRIO_LOWEST
+} OSLAYER_THREAD_PRIO;
+
+#ifdef OSLAYER_TIMESTAMP
+/******************************************************************************
+ *  osTimeStampUs()
+ *****************************************************************************/
+/**
+ *  @brief  Returns a 64-bit timestamp [us]
+ *
+ *  @param  pEvent         Reference of the timestamp object
+ *
+ *  @return                Status of operation
+ *  @retval OSLAYER_OK     Event successfully created
+ *
+ ******************************************************************************/
+extern int32_t osTimeStampUs(int64_t *pTimeStamp);
+
+/******************************************************************************
+ *  osTimeStampNs()
+ *****************************************************************************/
+/**
+ *  @brief  Returns a 64-bit timestamp [ns]
+ *
+ *  @param  pEvent         Reference of the timestamp object
+ *
+ *  @return                Status of operation
+ *  @retval OSLAYER_OK     Event successfully created
+ *
+ ******************************************************************************/
+extern int32_t osTimeStampNs(int64_t *pTimeStamp);
+#endif /* OSLAYER_TIMESTAMP */
+
+
+
+#ifdef OSLAYER_EVENT
+/******************************************************************************
+ *  osEventInit()
+ *****************************************************************************/
+/**
+ *  @brief  Initialize an event object.
+ *
+ *  Init an event. Automatic reset flag as well as initial state could be set,
+ *  but event is not signaled. Automatic reset means osEventReset() must
+ *  not be called to set event state to zero. This also implies that all
+ *  waiting threads, otherwise only one thread, will be restarted.
+ *
+ *  @param  pEvent         Reference of the event object
+ *
+ *  @param  Automatic      Automatic Reset flag
+ *
+ *  @param  InitState      Initial state of the event object (true/false)
+ *
+ *  @return                Status of operation
+ *  @retval OSLAYER_OK     Event successfully created
+ *  @retval OSLAYER_ERROR  Event is not created
+ *
+ ******************************************************************************/
+extern int32_t osEventInit(osEvent *pEvent, int32_t Automatic, int32_t InitState);
+
+/******************************************************************************
+ *  osEventSignal()
+ *****************************************************************************/
+/**
+ *  @brief  Set the event state to true.
+ *
+ *  Set the state of the event object to true and signal waiting thread(s).
+ *
+ *  @param  pEvent                    Reference of the event object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Signal send successfully
+ *  @retval OSLAYER_ERROR             Tried to signal a not initialized event
+ *  @retval OSLAYER_OPERATION_FAILED  Signal not send
+ *
+ ******************************************************************************/
+extern int32_t osEventSignal(osEvent *pEvent);
+
+/******************************************************************************
+ *  osEventReset()
+ *****************************************************************************/
+/**
+ *  @brief  Reset the event state to true.
+ *
+ *  Reset the state of the event object to false.
+ *
+ *  @param  pEvent                    Reference of the event object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Event reset successfully
+ *  @retval OSLAYER_ERROR             Tried to reset a not initialized event
+ *  @retval OSLAYER_OPERATION_FAILED  Event not reset
+ *
+ ******************************************************************************/
+extern int32_t osEventReset(osEvent *pEvent);
+
+/******************************************************************************
+ *  osEventPulse()
+ *****************************************************************************/
+/**
+ *  @brief  Pulse the event false -> true -> false.
+ *
+ *  Pulse the state of the event object with the following sequence:
+ *  false -> true -> false and signal waiting thread(s).
+ *
+ *  @param  pEvent                    Reference of the event object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Event pulsed successfully
+ *  @retval OSLAYER_ERROR             Tried to pulse a not initialized event
+ *  @retval OSLAYER_OPERATION_FAILED  Event not pulsed
+ *
+ ******************************************************************************/
+extern int32_t osEventPulse(osEvent *pEvent);
+
+/******************************************************************************
+ *  osEventWait()
+ *****************************************************************************/
+/**
+ *  @brief  Blocking wait for event to be true.
+ *
+ *  Wait for the state of the event object becoming true and block calling
+ *  thread. The function call returns immediatly, if event is already signaled.
+ *
+ *  @param  pEvent                    Reference of the event object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Wait for event succeeded and function
+ *                                    returned due to signal sent
+ +  @retval OSLAYER_ERROR             Tried to wait for a not initialized event
+ *  @retval OSLAYER_OPERATION_FAILED  Wait for event failed
+ *
+ ******************************************************************************/
+extern int32_t osEventWait(osEvent *pEvent);
+
+/******************************************************************************
+ *  osEventTimedWait()
+ *****************************************************************************/
+/**
+ *  @brief  Blocking wait with timeout for event to be true.
+ *
+ *  Wait for the state of the event object becoming true and block calling
+ *  thread. The function call returns immediatly, if event is already signaled.
+ *  If specified timeout elapses, the function returns with apropriate timeout
+ *  error code.
+ *
+ *  @param  pEvent      reference of the event object
+ *
+ *  @param  msec        timeout value in milliseconds
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Wait for event succeeded and function
+ *                                    returned due to signal sent
+ *  @retval OSLAYER_TIMEOUT           Wait for event succeeded and function
+ *                                    returned due to timeout and no signal
+ *                                    was sent
+ *  @retval OSLAYER_OPERATION_FAILED  Wait for event failed
+ *
+ ******************************************************************************/
+extern int32_t osEventTimedWait(osEvent *pEvent, uint32_t msec);
+
+/******************************************************************************
+ *  osEventDestroy()
+ *****************************************************************************/
+/**
+ *  @brief  Destroy the event.
+ *
+ *  Destroy the event and free resources associated with event object.
+ *
+ *  @param  pEvent      Reference of the event object
+ *
+ *  @return             always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osEventDestroy(osEvent *pEvent);
+#endif /* OSLAYER_EVENT */
+
+
+
+#ifdef OSLAYER_MUTEX
+/******************************************************************************
+ *  osMutextInit()
+ *****************************************************************************/
+/**
+ *  @brief  Initialize a mutex object.
+ *
+ *  @param  pMutex         Reference of the mutex object
+ *
+ *  @return                Status of operation
+ *  @retval OSLAYER_OK     Mutex successfully created
+ *  @retval OSLAYER_ERROR  Mutex is not created
+ *
+ ******************************************************************************/
+extern int32_t osMutexInit(osMutex *pMutex);
+
+/******************************************************************************
+ *  osMutexLock()
+ *****************************************************************************/
+/**
+ *  @brief  Lock a mutex object.
+ *
+ *          Lock the mutex. Thread will be blocked if mutex already locked.
+ *
+ *  @param  pMutex         Reference of the mutex object
+ *
+ *  @return                Status of operation
+ *  @retval OSLAYER_OK     Mutex successfully locked
+ *
+ ******************************************************************************/
+extern int32_t osMutexLock(osMutex *pMutex);
+
+/******************************************************************************
+ *   osMutexUnlock()
+ *****************************************************************************/
+/**
+ *  @brief  Unlock a mutex object.
+ *
+ *  @param  pMutex         Reference of the mutex object
+ *
+ *  @return                Status of operation
+ *  @retval OSLAYER_OK     Mutex successfully unlocked
+ *
+ ******************************************************************************/
+extern int32_t osMutexUnlock(osMutex *pMutex);
+
+/******************************************************************************
+ *  osMutexTryLock()
+ *****************************************************************************/
+/**
+ *  @brief  Try to lock a mutex object.
+ *
+ *  Try to lock mutex in Non-Blocking mode. Returns OSLAYER_OK if successful.
+ *
+ *  @param  pMutex                    Reference of the mutex object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Mutex successfully locked
+ *  @retval OSLAYER_OPERATION_FAILED  Mutex not locked (already locked by
+ *                                    someone else)
+ *
+ ******************************************************************************/
+extern int32_t osMutexTryLock(osMutex *pMutex);
+
+/******************************************************************************
+ *  osMutexDestroy()
+ *****************************************************************************/
+/**
+ *  @brief  Destroy a mutex object.
+ *
+ *  @param  pMutex      Reference of the mutex object
+ *
+ *  @return             always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osMutexDestroy(osMutex *pMutex);
+#endif /* OSLAYER_MUTEX */
+
+
+
+#ifdef OSLAYER_SEMAPHORE
+/******************************************************************************
+ *  osSemaphoreInit()
+ *****************************************************************************/
+/**
+ *  @brief  Init a semaphore with init count.
+ *
+ *  @param  pSem           Reference of the semaphore object
+ *
+ *  @return                Status of operation
+ *  @retval OSLAYER_OK     Semaphore successfully created
+ *  @retval OSLAYER_ERROR  Semaphore is not created
+ *
+ ******************************************************************************/
+extern int32_t osSemaphoreInit(osSemaphore *pSem, int32_t init_count);
+
+/******************************************************************************
+ *  osSemaphoreTimedWait()
+ *****************************************************************************/
+/**
+ *  @brief  Decrease the semaphore value in blocking mode, but with timeout.
+ *
+ *  @param  pSem                      Reference of the semaphore object
+ *
+ *  @param  msec                      Timeout value in milliseconds
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Wait for semaphore succeeded and
+ *                                    function returned due to signal sent
+ *  @retval OSLAYER_TIMEOUT           Wait for semaphore succeeded and
+ *                                    function returned due to timeout and
+ *                                    no signal was sent
+ *  @retval OSLAYER_OPERATION_FAILED  Wait for semaphore failed
+ *  @retval OSLAYER_ERROR             Tried to wait for a not initialized
+ *                                    semaphore
+ *
+ ******************************************************************************/
+extern int32_t osSemaphoreTimedWait(osSemaphore *pSem, uint32_t msec);
+
+/******************************************************************************
+ *  osSemaphoreWait()
+ *****************************************************************************/
+/**
+ *  @brief  Decrease the semaphore value in blocking mode.
+ *
+ *  @param  pSem                      Reference of the semaphore object
+ *
+ *  @param  msec                      Timeout value in milliseconds
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Wait for semaphore succeeded and
+ *                                    function returned due to signal sent
+ *  @retval OSLAYER_OPERATION_FAILED  Wait for semaphore failed
+ *  @retval OSLAYER_ERROR             Tried to wait for a not initialized
+ *                                    semaphore
+ *
+ ******************************************************************************/
+extern int32_t osSemaphoreWait(osSemaphore *pSem);
+
+/******************************************************************************
+ *  osSemaphoreTryWait()
+ *****************************************************************************/
+/**
+ *  @brief  Try to wait for a semaphore object.
+ *
+ *          Try to decrease the semaphore value in non-blocking mode. This
+ *          functionality is realized internally with a timed wait called
+ *          with a timeout value of zero.
+ *
+ *  @param  pSem                      Reference of the mutex object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Wait for semaphore succeeded and
+ *                                    function returned due to signal sent
+ *  @retval OSLAYER_TIMEOUT           Wait for semaphore succeeded and
+ *                                    function returned due to timeout and
+ *                                    no signal was sent
+ *  @retval OSLAYER_OPERATION_FAILED  Wait for semaphore failed
+ *  @retval OSLAYER_ERROR             Tried to wait for a not initialized
+ *                                    semaphore
+ *
+ ******************************************************************************/
+extern int32_t osSemaphoreTryWait(osSemaphore *pSem);
+
+/******************************************************************************
+ *  osSemaphorePost()
+ *****************************************************************************/
+/**
+ *  @brief  Increase the semaphore value.
+ *
+ *  @param  pSem                      Reference of the semaphore object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Semaphore value successfully increased
+ *  @retval OSLAYER_ERROR             Tried to increase the value of a not
+ *                                    initialized semaphore object
+ *  @retval OSLAYER_OPERATION_FAILED  Increase of semaphore value failed
+ *
+ ******************************************************************************/
+extern int32_t osSemaphorePost(osSemaphore *pSem);
+
+/******************************************************************************
+ *   osSemaphoreDestroy()
+ *****************************************************************************/
+/**
+ *  @brief  Destroy the semaphore object.
+ *
+ *  @param  pSem        Reference of the semaphore object
+ *
+ *  @return             always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osSemaphoreDestroy(osSemaphore *pSem);
+#endif /* OSLAYER_SEMAPHORE */
+
+
+
+#ifdef OSLAYER_QUEUE
+/*****************************************************************************/
+/** @brief  Queue object (generic Version) of OS Abstraction Layer */
+typedef struct _osQueue
+{
+    void    *p_next;            //!< for storing into a list (multiplexer)
+
+    int32_t ItemSize;           //!< Size of queue item.
+    int32_t ItemNum;            //!< Max number of queue items (just for debugging).
+    int32_t ItemCount;          //!< Current number of queue items (just for debugging).
+
+    char    *pItemBuffer;       //!< Pointer to buffer holding queued items.
+    char    *pItemBufferEnd;    //!< Pointer to end of that buffer, used for wrapping.
+    char    *pItemBufferRead;   //!< Pointer to next item to read.
+    char    *pItemBufferWrite;  //!< Pointer to next item to write.
+
+    osSemaphore ItemsFreeSema;  //!< Counting semaphore increased/decreased for every free/used item in the queue. Used to synchronize concurrent write accesses.
+    osSemaphore ItemsUsedSema;  //!< Counting semaphore increased/decreased for every used/free item in the queue. Used to synchronize concurrent read accesses.
+
+    osMutex AccessMutex;        //!< Must be held to access/modify any of the fields in this struct, but not to get/put the semaphores.
+} osQueue;
+
+/******************************************************************************
+ *  osQueueInit()
+ *****************************************************************************/
+/**
+ *  @brief  Initialize queue object.
+ *
+ *  Init a queue. Item size and item number can be set.
+ *
+ *  @param  pQueue         Reference of the queue object.
+ *
+ *  @param  ItemNum        Number of items this queue can hold.
+ *
+ *  @param  ItemSize       Size of a single queue item.
+ *
+ *  @return                Status of operation.
+ *  @retval OSLAYER_OK     Queue successfully created.
+ *  @retval OSLAYER_ERROR  Queue is not created.
+ *
+ ******************************************************************************/
+extern int32_t osQueueInit(osQueue *pQueue, int32_t ItemNum, int32_t ItemSize);
+
+/******************************************************************************
+ *  osQueueRead()
+ *****************************************************************************/
+/**
+ *  @brief  Blocking read from the queue.
+ *
+ *  Wait for item being available in the queue and block calling thread, then copy item
+ *  from queue. The function call returns immediatly, if an item is already available.
+ *
+ *  @param  pQueue                    Reference of the queue object.
+ *
+ *  @param  pvItem                    Reference to item to read from queue.
+ *
+ *  @return                           Status of operation.
+ *  @retval OSLAYER_OK                Reading from queue succeeded.
+ *  @retval OSLAYER_ERROR             Tried to read from a not initialized queue.
+ *  @retval OSLAYER_OPERATION_FAILED  Reading from queue failed.
+ *
+ ******************************************************************************/
+extern int32_t osQueueRead(osQueue *pQueue, void* pvItem);
+
+/******************************************************************************
+ *  osQueueTimedRead()
+ *****************************************************************************/
+/**
+ *  @brief  Blocking read from the queue with timeout.
+ *
+ *  Wait for item being available in the queue and block calling thread, then copy item
+ *  from queue. The function call returns immediatly, if an item is already available.
+ *
+ *  @param  pQueue                    Reference of the queue object.
+ *
+ *  @param  pvItem                    Reference to item to read from queue.
+ *
+ *  @return                           Status of operation.
+ *  @retval OSLAYER_OK                Reading from queue succeeded.
+ *  @retval OSLAYER_ERROR             Tried to read from a not initialized queue.
+ *  @retval OSLAYER_TIMEOUT           Timeout occurred while waiting for item being
+ *                                    available in the queue.
+ *  @retval OSLAYER_OPERATION_FAILED  Reading from queue failed.
+ *
+ ******************************************************************************/
+extern int32_t osQueueTimedRead(osQueue *pQueue, void* pvItem, uint32_t msec);
+
+/******************************************************************************
+ *  osQueueTryRead()
+ *****************************************************************************/
+/**
+ *  @brief  Non-blocking read from the queue.
+ *
+ *  If an item is available in the queue, then copy item from queue. If no
+ *  item is available, then return with error.
+ *
+ *  @param  pQueue                    Reference of the queue object.
+ *
+ *  @param  pvItem                    Reference to item to read from queue.
+ *
+ *  @return                           Status of operation.
+ *  @retval OSLAYER_OK                Reading from queue succeeded.
+ *  @retval OSLAYER_ERROR             Tried to read from a not initialized queue.
+ *  @retval OSLAYER_TIMEOUT           No item was available in the queue.
+ *  @retval OSLAYER_OPERATION_FAILED  Reading from queue failed.
+ *
+ ******************************************************************************/
+extern int32_t osQueueTryRead(osQueue *pQueue, void* pvItem);
+
+/******************************************************************************
+ *  osQueueWrite()
+ *****************************************************************************/
+/**
+ *  @brief  Blocking write into the queue.
+ *
+ *  Wait for space in queue being available and block calling thread, then copy item
+ *  into queue. The function call returns immediatly, if space is already available.
+ *
+ *  @param  pQueue                    Reference of the queue object.
+ *
+ *  @param  pvItem                    Reference to item to write into queue.
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Writing into queue succeeded.
+ *  @retval OSLAYER_ERROR             Tried to write into a not initialized queue.
+ *  @retval OSLAYER_OPERATION_FAILED  Writing into queue failed.
+ *
+ ******************************************************************************/
+extern int32_t osQueueWrite(osQueue *pQueue, void* pvItem);
+
+/******************************************************************************
+ *  osQueueTimedWrite()
+ *****************************************************************************/
+/**
+ *  @brief  Blocking write into the queue with timeout.
+ *
+ *  Wait for space in queue being available and block calling thread, then copy item
+ *  into queue. The function call returns immediatly, if space is already available.
+ *
+ *  @param  pQueue                    Reference of the queue object.
+ *
+ *  @param  pvItem                    Reference to item to write into queue.
+ *
+ *  @param  msec                      Timeout value in milliseconds.
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Writing into queue succeeded.
+ *  @retval OSLAYER_ERROR             Tried to write into a not initialized queue.
+ *  @retval OSLAYER_TIMEOUT           Timeout occurred while waiting for space being
+ *                                    available in the queue.
+ *  @retval OSLAYER_OPERATION_FAILED  Writing into queue failed.
+ *
+ ******************************************************************************/
+extern int32_t osQueueTimedWrite(osQueue *pQueue, void* pvItem, uint32_t msec);
+
+/******************************************************************************
+ *  osQueueTryWrite()
+ *****************************************************************************/
+/**
+ *  @brief  Non-blocking write into the queue.
+ *
+ *  If a free item is available in the queue, then copy item into queue. If no
+ *  free item is available, then return with error.
+ *
+ *  @param  pQueue                    Reference of the queue object.
+ *
+ *  @param  pvItem                    Reference to item to read from queue.
+ *
+ *  @return                           Status of operation.
+ *  @retval OSLAYER_OK                Writing into queue succeeded.
+ *  @retval OSLAYER_ERROR             Tried to write into a not initialized queue.
+ *  @retval OSLAYER_TIMEOUT           Writing into queue failed, as no free item
+ *                                    was available in the queue.
+ *  @retval OSLAYER_OPERATION_FAILED  Writing into queue failed.
+ *
+ ******************************************************************************/
+extern int32_t osQueueTryWrite(osQueue *pQueue, void* pvItem);
+
+/******************************************************************************
+ *  osQueueDestroy()
+ *****************************************************************************/
+/**
+ *  @brief  Destroy the queue.
+ *
+ *  Destroy the queue and free resources associated with queue object.
+ *
+ *  @param  pQueue      Reference of the queue object
+ *
+ *  @return             always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osQueueDestroy(osQueue *pQueue);
+#endif /* OSLAYER_QUEUE */
+
+
+
+#ifdef OSLAYER_ATOMIC
+/******************************************************************************
+ *  osAtomicInit()
+ *****************************************************************************/
+/**
+ *  @brief  Initialize atomic operation functionality.
+ *
+ *  This function must be called before any other osAtomicXXX call.
+ *
+ ******************************************************************************/
+extern int32_t osAtomicInit();
+
+/******************************************************************************
+ *  osAtomicShutdown()
+ *****************************************************************************/
+/**
+ *  @brief  Shutdown atomic operation functionality.
+ *
+ *  This function must be called before process is terminated
+ *  when osAtomicInit has been called before.
+ *
+ ******************************************************************************/
+extern int32_t osAtomicShutdown();
+
+/******************************************************************************
+ *  osAtomicTestAndClearBit()
+ *****************************************************************************/
+/**
+ *  @brief  Test and set a bit position atomically.
+ *
+ *  Test if a bit position inside a variable is set and clears the bit
+ *  afterwards. The complete operation is atomic (includes IRQ safety).
+ *
+ *  @param  pVar           32-bit unsigned variable to be modified
+ *  @param  bitpos         Bit to be tested and cleared
+ *
+ *  @return                *pVar & (1 << bitpos)
+ *
+ ******************************************************************************/
+extern uint32_t osAtomicTestAndClearBit(uint32_t* pVar, uint32_t bitpos);
+
+/******************************************************************************
+ *  osAtomicIncrement()
+ ******************************************************************************
+ *  @brief  Increments a 32-bit unsigned variable atomically.
+ *
+ *  Increments a 32-bit unsigned variable atomically and returns the value of
+ *  the variable after the increment operation. The complete operation is
+ *  atomic (includes IRQ safety).
+ *
+ *  @param  pVar           32-bit unsigned variable to be modified
+ *
+ *  @return                ++(*pVar)
+ *
+ ******************************************************************************/
+extern uint32_t osAtomicIncrement(uint32_t* pVar);
+
+/******************************************************************************
+ *  osAtomicDecrement()
+ ******************************************************************************
+ *  @brief  Decrements a 32-bit unsigned variable atomically.
+ *
+ *  Decrements a 32-bit unsigned variable atomically and returns the value of
+ *  the variable after the decrement operation. The complete operation is
+ *  atomic (includes IRQ safety).
+ *
+ *  @param  pVar           32-bit unsigned variable to be modified
+ *
+ *  @return                --(*pVar)
+ *
+ ******************************************************************************/
+extern uint32_t osAtomicDecrement(uint32_t* pVar);
+
+/******************************************************************************
+*   osAtomicSetBit()
+ *****************************************************************************/
+/**
+ *  @brief  Set a bit position atomically.
+ *
+ *  Set a bit position inside a variable.
+ *  The operation is atomic (includes IRQ safety).
+ *
+ *  @param  pVar           32-bit unsigned variable to be modified
+ *  @param  bitpos         Bit to be set
+ *
+ *  @return                always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osAtomicSetBit(uint32_t* pVar, uint32_t bitpos);
+
+/******************************************************************************
+ * osAtomicSet()
+ *****************************************************************************/
+/**
+ *  @brief  Set value atomically.
+ *
+ *  Set variable to value. The operation is atomic (includes IRQ safety).
+ *
+ *  @param  pVar           32-bit unsigned variable to be modified
+ *  @param  value          Value to be set
+ *
+ *  @return                always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osAtomicSet(uint32_t* pVar, uint32_t value);
+#endif /* OSLAYER_ATOMIC */
+
+
+
+#ifdef OSLAYER_THREAD
+/******************************************************************************
+ *  osThreadCreate()
+ *****************************************************************************/
+/**
+ *  @brief  Create a thread.
+ *
+ *  @param  pThread                   Reference of the semaphore object
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Thread object created successfully
+ *  @retval OSLAYER_OPERATION_FAILED  Creation of thread object failed
+ +
+ ******************************************************************************/
+extern int32_t osThreadCreate(osThread *pThread, osThreadFunc thread_func, void *arg);
+
+/******************************************************************************
+ *  osThreadSetPriority()
+ *****************************************************************************/
+/**
+ *  @brief  Set thread priority.
+ *
+ *  @param  pThread                   Reference of the semaphore object
+ *
+ *  @param  priority                  New thread priority to be set
+ *
+ *  @return                           Status of operation
+ *  @retval OSLAYER_OK                Thread priority changed successfully
+ *  @retval OSLAYER_ERROR             Invalid thread priority value passed
+ *  @retval OSLAYER_OPERATION_FAILED  Thread priority change failed
+ *
+ ******************************************************************************/
+extern int32_t osThreadSetPriority(osThread *pThread, OSLAYER_THREAD_PRIO priority);
+
+/******************************************************************************
+ *   osThreadWait()
+ *****************************************************************************/
+/**
+ *  @brief  Wait until thread exits.
+ *
+ *          To avoid memory leak, always call @ref osThreadWait and wait
+ *          for the child thread to terminate in the calling thread.
+ *
+ *  @param  pThread        Reference of the semaphore object
+ *
+ *  @return                always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osThreadWait(osThread *pThread);
+
+/******************************************************************************
+ *  osThreadClose()
+ *****************************************************************************/
+/**
+ *  @brief  Destroy thread object.
+ *
+ *  @param  pThread       Reference of the semaphore object
+ *
+ *  @return               always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osThreadClose(osThread *pThread);
+#endif /* OSLAYER_THREAD */
+
+
+
+#ifdef OSLAYER_MISC
+/******************************************************************************
+ *  osSleep()
+ *****************************************************************************/
+/**
+ *  @brief  Yield the execution of current thread for msec miliseconds.
+ *
+ *  @param  msec       Wait time in millisecobds
+ *
+ *  @return            always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osSleep(uint32_t msec);
+
+/******************************************************************************
+ *   osGetTick()
+ *****************************************************************************/
+/**
+ *  @brief  Obtain the clock tick.
+ *
+ *  @return            Current clock tick. The resoultion of clock tick can
+ *                     be requested with @ref osGetFrequency
+ *
+ ******************************************************************************/
+extern uint64_t osGetTick(void);
+
+/******************************************************************************
+ *  osGetFrequency()
+ *****************************************************************************/
+/**
+ *  @brief  Obtain the clock resolution.
+ *
+ *  @return            The resoultion of the clock tick.
+ *
+ ******************************************************************************/
+extern uint64_t osGetFrequency(void);
+
+#if defined LINUX && OSLAYER_KERNEL
+/******************************************************************************
+ *  osMallocEx()
+ *****************************************************************************/
+/**
+ *  @brief  Allocate a continuous block of memory.
+ *
+ *  @param  size       Size of memory block to be allocated
+ *
+ *  @param  type       Type of memory block to be allocated
+ *
+ ******************************************************************************/
+void* osMallocEx(uint32_t size, uint32_t type);
+#endif
+
+/******************************************************************************
+ *  osMalloc()
+ *****************************************************************************/
+/**
+ *  @brief  Allocate a continuous block of memory.
+ *
+ *  @param  size       Size of memory block to be allocated
+ *
+ ******************************************************************************/
+extern void* osMalloc(uint32_t size);
+
+/******************************************************************************
+ *  osFree()
+ *****************************************************************************/
+/**
+ *  @brief  Free a continuous block of memory.
+ *
+ *  @param  p       Pointer to previously allocated memory block
+ *
+ *  @return         always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osFree(void *p);
+
+
+#ifdef OSLAYER_KERNEL
+/******************************************************************************
+ *  osSpinLockInit()
+ *****************************************************************************/
+/**
+ *  @brief  Init a spin lock object.
+ *
+ *  @param  p_spin_lock      Reference of the spin lock object
+ *
+ *  @return                  always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osSpinLockInit(osSpinLock *p_spin_lock);
+
+/******************************************************************************
+ *  osSpinLockAcquire()
+ *****************************************************************************/
+/**
+ *  @brief  Acquire a spin lock object.
+ *
+ *  @param  p_spin_lock      Reference of the spin lock object
+ *
+ *  @param  flags            Interrupt context flags which need to be safed
+ *                           in a local variable
+ *
+ *  @return                  always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osSpinLockAcquire(osSpinLock *p_spin_lock, uint32_t flags);
+
+/******************************************************************************
+ *   osSpinLockRelease()
+ *****************************************************************************/
+/**
+ *  @brief  Release a spin lock object.
+ *
+ *  @param  p_spin_lock      Reference of the spin lock object
+ *
+ *  @param  flags            Interrupt context flags which need to be safed
+ *                           in a local variable
+ *
+ *  @return                  always OSLAYER_OK
+ ******************************************************************************/
+extern int32_t osSpinLockRelease(osSpinLock *p_spin_lock, uint32_t flags);
+#endif /* OSLAYER_KERNEL */
+#endif /* OSLAYER_MISC */
+
+/*****************************************************************************/
+/** @brief  Interrupt object of OS Abstraction Layer */
+typedef struct _osInterrupt
+{
+#ifdef OSLAYER_KERNEL
+#else
+    osThread    isr_thread;
+    osEvent     isr_event;
+    osEvent     isr_exit_event;
+	osMutex     isr_access_lock;
+    osEvent     isr_irq_event;
+    osQueue     isr_mis_queue;
+#endif
+    uint32_t    irq_num;
+    osIsrFunc   IsrFunc;
+    osDpcFunc   DpcFunc;
+    void*       p_context;
+} osInterrupt;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+//!@} defgroup OS_LAYER
+
+#endif /* MSVD_KAL_H */

+ 162 - 0
isp_isp8000l/units/oslayer/oslayer_linux.h

@@ -0,0 +1,162 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * Module    : Operating System Abstraction Layer
+ *
+ * Hierarchy :
+ *
+ * Purpose   : Encapsulates and abstracts services from different operating
+ *             system, including user-mode as well as kernel-mode services.
+ ******************************************************************************/
+#ifdef LINUX
+
+#ifndef __KERNEL__
+#undef _GNU_SOURCE
+#define _GNU_SOURCE        // required for CPU affinity stuff in <sched.h>
+#include <sched.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <semaphore.h>
+#include <sys/time.h>
+#include <errno.h>
+#else
+#include <linux/slab.h>
+#include <linux/time.h>
+#include <linux/wait.h>
+#include <linux/jiffies.h>
+#include <linux/completion.h>
+#include <asm/processor.h>
+#include <asm/semaphore.h>
+#endif
+
+#include <ebase/types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+#ifdef __KERNEL__
+
+#define OSLAYER_KERNEL
+
+/*****************************************************************************/
+/*  @brief Definitions for advanced memory allocation (kernel only) */
+#define OSLAYER_ATOMIC  GFP_ATOMIC   /*< caller will never sleep, can be called from IRQ context */
+#define OSLAYER_KERNEL  GFP_KERNEL   /*< Allocate kernel RAM. Function can sleep if memory is not available */
+#define OSLAYER_USER    GFP_USER     /*< Allocate memory on behalf of user. Attached driver instance can */
+                                     /*< sleep if memory is not available */
+#endif /*  __KERNEL__ */
+
+
+typedef int32_t (*osThreadFunc)(void *);
+typedef int32_t (*osIsrFunc)(void *);
+typedef int32_t (*osDpcFunc)(void *);
+
+
+#ifdef OSLAYER_EVENT
+/*****************************************************************************/
+/*  @brief  Event object (Linux Version) of OS Abstraction Layer */
+typedef struct _osEvent
+{
+#ifndef OSLAYER_KERNEL
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+    int32_t automatic;
+    int32_t state;
+#else
+    struct completion x;
+#endif
+} osEvent;
+#endif /* OSLAYER_EVENT */
+
+
+#ifdef OSLAYER_MUTEX
+/*****************************************************************************/
+/*  @brief  Mutex object (Linux Version) of OS Abstraction Layer */
+typedef struct _osMutex
+{
+#ifndef OSLAYER_KERNEL
+    pthread_mutex_t handle;
+#else
+    struct semaphore *sem;
+#endif
+} osMutex;
+#endif /* OSLAYER_MUTEX */
+
+
+#ifdef OSLAYER_SEMAPHORE
+/*****************************************************************************/
+/*  @brief  Semaphore object (Linux Version) of OS Abstraction Layer */
+typedef struct _osSemaphore
+{
+#ifndef OSLAYER_KERNEL
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+    int32_t count;
+#else
+    struct semaphore *sem;
+#endif
+} osSemaphore;
+#endif /* OSLAYER_SEMAPHORE */
+
+
+#ifdef OSLAYER_THREAD
+/*****************************************************************************/
+/*  @brief  Thread object (Linux Version) of OS Abstraction Layer */
+typedef struct _osThread
+{
+#ifndef OSLAYER_KERNEL
+    pthread_t handle;
+    osMutex access_mut;
+    int32_t wait_count;
+#else
+    int32_t handle;
+#endif
+    osEvent exit_event;
+    int32_t (*pThreadFunc)(void *);
+    void *p_arg;
+} osThread;
+#endif /* OSLAYER_THREAD */
+
+
+#ifdef OSLAYER_MISC
+#ifdef OSLAYER_KERNEL
+/*****************************************************************************/
+/*  @brief  Spin Lock object (Linux Kernel Version only) of OS Abstraction */
+/*          Layer */
+typedef struct _osSpinLock
+{
+    spinlock_t lock;
+} osSpinLock;
+#endif /* OSLAYER_KERNEL */
+#endif /* OSLAYER_MISC */
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* LINUX */

+ 137 - 0
isp_isp8000l/units/oslayer/oslayer_mfs.h

@@ -0,0 +1,137 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * Module    : Operating System Abstraction Layer
+ *
+ * Hierarchy :
+ *
+ * Purpose   : Encapsulates and abstracts services from different operating
+ *             system, including user-mode as well as kernel-mode services.
+ ******************************************************************************/
+#ifndef _OSLAYER_MFS_H
+#define _OSLAYER_MFS_H
+
+#if defined (MFS)
+
+#include <kernel/ctTypes.h>
+#include <kernel/mutexTypes.h>
+#include <kernel/mailboxTypes.h>
+#include <kernel/timerTypes.h>
+#include <kernel/activityTypes.h>
+
+#include <ebase/types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define OSLAYER_ASSERT(x) DCT_ASSERT(x)
+
+
+//typedef int32_t (*osThreadFunc)(void *);
+typedef aid_t osThreadFunc;
+typedef int32_t (*osIsrFunc)(void *);
+typedef int32_t (*osDpcFunc)(void *);
+
+#ifdef OSLAYER_EVENT
+
+#define OS_EVENT_INITIALIZED    0x6469
+
+/*****************************************************************************/
+/*  @brief  Event object (Linux Version) of OS Abstraction Layer */
+typedef struct _osEvent
+{
+    int32_t   state;
+    mbId_t    m_id;
+    aid_t     act_id;
+    void      *cond;
+    int32_t   status;
+    int32_t   automatic_reset;
+    int32_t   initialized;
+} osEvent;
+#endif /* OSLAYER_EVENT */
+
+
+#ifdef OSLAYER_MUTEX
+
+#define OS_MUTEX_INITIALIZED    0x646a
+
+/*****************************************************************************/
+/*  @brief  Mutex object (Linux Version) of OS Abstraction Layer */
+typedef struct _osMutex
+{
+    mutexId_t mutex;
+    int32_t   initialized;
+} osMutex;
+#endif /* OSLAYER_MUTEX */
+
+
+#ifdef OSLAYER_SEMAPHORE
+
+#define OS_SEMAPHORE_INITIALIZED    0x646b
+
+/*****************************************************************************/
+/*  @brief  Semaphore object (Linux Version) of OS Abstraction Layer */
+typedef struct _osSemaphore
+{
+    mutexId_t mutex;
+    aid_t     act_id;
+    mbId_t    m_id;
+    int32_t   count;
+    void      *cond;
+    int32_t   status;
+    int32_t   initialized;
+} osSemaphore;
+#endif /* OSLAYER_SEMAPHORE */
+
+
+#ifdef OSLAYER_THREAD
+/*****************************************************************************/
+/*  @brief  Thread object (Linux Version) of OS Abstraction Layer */
+typedef struct _osThread
+{
+    aid_t   act_id;     /* id of activity assigned to this thread object */
+} osThread;
+#endif /* OSLAYER_THREAD */
+
+
+/*****************************************************************************/
+/*  @brief  Instance records for callers (activities) of OS Abstraction Layer */
+typedef struct _osInstanceRecord
+{
+    aid_t       act_id;           /**< id of activity assigned to this record */
+    ctState_t   ct_state;         /**< state variable used by os layer functions */
+    ctState_t   ct_state_gm;      /**< state variable used by getMailbox function */
+    timerid_t   timer_id;         /**< used for all timer operations of the activity */
+} osInstanceRecord;
+
+
+/*****************************************************************************/
+/*  @brief get result from MFS OS layer function call */
+extern int32_t osGetLastResult (void);
+
+/*****************************************************************************/
+/*  @brief Assign a Mailbox Activity to be woken up upon Receiving (MFS Only) */
+extern void  osAssignMailboxRxWakeUp (mbId_t  mid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MFS */
+#endif /* OSLAYER_MFS_H */

+ 94 - 0
isp_isp8000l/units/oslayer/oslayer_systemc.h

@@ -0,0 +1,94 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * @file oslayer_systemc.h
+ *
+ * Encapsulates and abstracts services of SystemC
+ *
+ *****************************************************************************/
+#ifdef LINUX
+
+#ifdef MSVD_COSIM
+
+#include <ebase/types.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+  typedef int32_t (*osThreadFunc)(void *);
+  typedef int32_t (*osIsrFunc)(void *);
+  typedef int32_t (*osDpcFunc)(void *);
+
+  typedef struct _osScEvent osScEvent;
+  typedef struct _osScMutex osScMutex;
+  typedef struct _osScSemaphore osScSemaphore;
+  typedef struct _osScThreadHandle osScThreadHandle;
+
+
+#ifdef OSLAYER_EVENT
+/*****************************************************************************/
+/*  @brief  Event object (Linux Version) of OS Abstraction Layer */
+typedef struct _osEvent
+{
+  osScEvent* p_event;
+} osEvent;
+#endif /* OSLAYER_EVENT */
+
+
+#ifdef OSLAYER_MUTEX
+/*****************************************************************************/
+/*  @brief  Mutex object (Linux Version) of OS Abstraction Layer */
+typedef struct _osMutex
+{
+  osScMutex* p_mutex;
+} osMutex;
+#endif /* OSLAYER_MUTEX */
+
+
+#ifdef OSLAYER_SEMAPHORE
+/*****************************************************************************/
+/*  @brief  Semaphore object (Linux Version) of OS Abstraction Layer */
+typedef struct _osSemaphore
+{
+  osScSemaphore* p_semaphore;
+} osSemaphore;
+#endif /* OSLAYER_SEMAPHORE */
+
+
+#ifdef OSLAYER_THREAD
+/*****************************************************************************/
+/*  @brief  Thread object (Linux Version) of OS Abstraction Layer */
+
+typedef struct _osThread
+{
+  osScThreadHandle* p_handle;
+  int32_t (*pThreadFunc)(void *);
+  void *p_arg;
+} osThread;
+#endif /* OSLAYER_THREAD */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /*! MSVD_COSIM */
+
+#endif /* LINUX */

+ 95 - 0
isp_isp8000l/units/oslayer/oslayer_ucosii.h

@@ -0,0 +1,95 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * Module    : Operating System Abstraction Layer
+ *
+ * Hierarchy :
+ *
+ * Purpose   : Encapsulates and abstracts services from different operating
+ *             system, including user-mode as well as kernel-mode services.
+ ******************************************************************************/
+#ifdef UCOSII
+
+#include <stdlib.h>
+#include <ucos_ii.h>
+#include <ebase/types.h>
+#include <ebase/dct_assert.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define UCOSII_STACK_SIZE   1024
+#define OSLAYER_ASSERT      DCT_ASSERT
+
+typedef int32_t (*osThreadFunc)(void *);
+typedef int32_t (*osIsrFunc)(void *);
+typedef int32_t (*osDpcFunc)(void *);
+
+
+#ifdef OSLAYER_EVENT
+/*****************************************************************************/
+/*  @brief  Event object (Linux Version) of OS Abstraction Layer */
+typedef struct _osEvent
+{
+    OS_FLAG_GRP*    pFlagGroup;
+    INT8U           wait_type;
+} osEvent;
+#endif /* OSLAYER_EVENT */
+
+
+#ifdef OSLAYER_MUTEX
+/*****************************************************************************/
+/*  @brief  Mutex object (Linux Version) of OS Abstraction Layer */
+typedef struct _osMutex
+{
+    OS_EVENT*   semaphore;
+} osMutex;
+#endif /* OSLAYER_MUTEX */
+
+
+#ifdef OSLAYER_SEMAPHORE
+/*****************************************************************************/
+/*  @brief  Semaphore object (Linux Version) of OS Abstraction Layer */
+typedef struct _osSemaphore
+{
+    OS_EVENT*   semaphore;
+} osSemaphore;
+#endif /* OSLAYER_SEMAPHORE */
+
+
+#ifdef OSLAYER_THREAD
+/*****************************************************************************/
+/*  @brief  Thread object (Linux Version) of OS Abstraction Layer */
+typedef struct _osThread
+{
+    int32_t (*pThreadFunc)(void *);
+    void*   p_arg;
+    OS_STK* stack;
+    INT32U  stackSize;
+    INT8U   prio;
+} osThread;
+#endif /* OSLAYER_THREAD */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* UCOSII */

+ 125 - 0
isp_isp8000l/units/oslayer/oslayer_win32.h

@@ -0,0 +1,125 @@
+/******************************************************************************\
+|* Copyright 2010, Dream Chip Technologies GmbH. used with permission by      *|
+|* VeriSilicon.                                                               *|
+|* Copyright (c) <2020> by VeriSilicon Holdings Co., Ltd. ("VeriSilicon")     *|
+|* All Rights Reserved.                                                       *|
+|*                                                                            *|
+|* The material in this file is confidential and contains trade secrets of    *|
+|* of VeriSilicon.  This is proprietary information owned or licensed by      *|
+|* VeriSilicon.  No part of this work may be disclosed, reproduced, copied,   *|
+|* transmitted, or used in any way for any purpose, without the express       *|
+|* written permission of VeriSilicon.                                         *|
+|*                                                                            *|
+\******************************************************************************/
+
+/* VeriSilicon 2020 */
+
+/**
+ * Module    : Operating System Abstraction Layer
+ *
+ * Hierarchy :
+ *
+ * Purpose   : Encapsulates and abstracts services from different operating
+ *             system, including user-mode as well as kernel-mode services.
+ ******************************************************************************/
+#ifdef WIN32
+
+#include <windows.h>
+#include <ebase/types.h>
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+#ifdef WIN32_KERNEL
+#define OSLAYER_KERNEL
+#endif
+
+
+typedef int32_t (*osThreadFunc)(void *);
+typedef int32_t (*osIsrFunc)(void *);
+typedef int32_t (*osDpcFunc)(void *);
+
+
+#ifdef OSLAYER_EVENT
+/*****************************************************************************/
+/*  @brief  Event object (Win32 Version) of OS Abstraction Layer */
+typedef struct _osEvent
+{
+#ifdef OSLAYER_KERNEL
+    KEVENT event;
+#else
+    HANDLE handle;
+#endif
+} osEvent;
+#endif /* OSLAYER_EVENT */
+
+
+#ifdef OSLAYER_MUTEX
+/*****************************************************************************/
+/*  @brief  Mutex object (Win32 Version) of OS Abstraction Layer */
+typedef struct _osMutex
+{
+#ifdef OSLAYER_KERNEL
+    KMUTEX mutex;
+#else
+    CRITICAL_SECTION sCritSection;
+#endif
+} osMutex;
+#endif /* OSLAYER_MUTEX */
+
+
+#ifdef OSLAYER_SEMAPHORE
+/*****************************************************************************/
+/*  @brief  Semaphore object (Win32 Version) of OS Abstraction Layer */
+typedef struct _osSemaphore
+{
+#ifdef OSLAYER_KERNEL
+    KSEMAPHORE sem;
+#else
+    HANDLE handle;
+#endif
+} osSemaphore;
+#endif /* OSLAYER_SEMAPHORE */
+
+
+#ifdef OSLAYER_THREAD
+/*****************************************************************************/
+/*  @brief  Thread object (Win32 Version) of OS Abstraction Layer */
+typedef struct _osThread
+{
+#ifdef OSLAYER_KERNEL
+    KTHREAD handle;
+#else
+    HANDLE handle;
+    osMutex access_mut;
+    int32_t wait_count;
+#endif
+} osThread;
+#endif /* OSLAYER_THREAD */
+
+
+#ifdef OSLAYER_MISC
+#ifdef OSLAYER_KERNEL
+/*****************************************************************************/
+/*  @brief  Spin Lock object (Win32 Kernel Version only) of OS Abstraction */
+/*          Layer */
+typedef struct _osSpinLock
+{
+    KSPIN_LOCK lock;
+} osSpinLock;
+#endif /* OSLAYER_KERNEL */
+#endif /* OSLAYER_MISC   */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* WIN32 */