feat(isp): added isp dvp driver

This commit is contained in:
Armando
2024-05-15 18:53:04 +08:00
parent 7425154472
commit 70d2ed5ee8
45 changed files with 1172 additions and 123 deletions
+131
View File
@@ -76,6 +76,13 @@ extern "C" {
---------------------------------------------------------------*/
#define ISP_LL_BF_DEFAULT_TEMPLATE_VAL 15
/*---------------------------------------------------------------
DVP
---------------------------------------------------------------*/
#define ISP_LL_DVP_DATA_TYPE_RAW8 0x2A
#define ISP_LL_DVP_DATA_TYPE_RAW10 0x2B
#define ISP_LL_DVP_DATA_TYPE_RAW12 0x2C
/**
* @brief Env monitor mode
*/
@@ -791,6 +798,130 @@ static inline void isp_ll_color_enable(isp_dev_t *hw, bool enable)
hw->cntl.color_en = enable;
}
/*---------------------------------------------------------------
DVP Camera
---------------------------------------------------------------*/
/**
* @brief Set dvp data color format
*
* @param[in] hw Hardware instance address
* @param[in] format color format, see `color_space_pixel_format_t`
*
* @return true for valid format, false for invalid format
*/
static inline bool isp_ll_dvp_set_data_type(isp_dev_t *hw, color_space_pixel_format_t format)
{
bool valid = false;
if (format.color_space == COLOR_SPACE_RAW) {
switch(format.pixel_format) {
case COLOR_PIXEL_RAW8:
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW8;
valid = true;
break;
case COLOR_PIXEL_RAW10:
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW10;
valid = true;
break;
case COLOR_PIXEL_RAW12:
hw->cam_conf.cam_data_type = ISP_LL_DVP_DATA_TYPE_RAW12;
valid = true;
break;
default:
break;
}
}
return valid;
}
/**
* @brief Enable / Disable 2B mode
*
* @param[in] hw Hardware instance address
* @param[in] enable Enable / Disable
*/
static inline void isp_ll_dvp_enable_2byte_mode(isp_dev_t *hw, bool enable)
{
if (enable) {
HAL_ASSERT(hw->cam_conf.cam_data_type == ISP_LL_DVP_DATA_TYPE_RAW8);
hw->cam_conf.cam_2byte_mode = 1;
} else {
hw->cam_conf.cam_2byte_mode = 0;
}
}
/**
* @brief Reset DVP CAM module
*
* @param[in] hw Hardware instance address
*/
static inline void isp_ll_dvp_cam_reset(isp_dev_t *hw)
{
hw->cam_cntl.cam_reset = 1;
hw->cam_cntl.cam_reset = 0;
}
/**
* @brief Enable DVP CAM pclk invert
*
* @param[in] hw Hardware instance address
* @param[in] enable Enable / Disable
*/
static inline void isp_ll_cam_enable_pclk_invert(isp_dev_t *hw, bool enable)
{
hw->cam_cntl.cam_clk_inv = enable;
}
/**
* @brief Enable DVP CAM de invert
*
* @param[in] hw Hardware instance address
* @param[in] enable Enable / Disable
*/
static inline void isp_ll_cam_enable_de_invert(isp_dev_t *hw, bool enable)
{
hw->cam_conf.cam_de_inv = enable;
}
/**
* @brief Enable DVP CAM hsync invert
*
* @param[in] hw Hardware instance address
* @param[in] enable Enable / Disable
*/
static inline void isp_ll_cam_enable_hsync_invert(isp_dev_t *hw, bool enable)
{
hw->cam_conf.cam_hsync_inv = enable;
}
/**
* @brief Enable DVP CAM vsync invert
*
* @param[in] hw Hardware instance address
* @param[in] enable Enable / Disable
*/
static inline void isp_ll_cam_enable_vsync_invert(isp_dev_t *hw, bool enable)
{
hw->cam_conf.cam_vsync_inv = enable;
}
/**
* @brief Enable DVP CAM
*
* @param[in] hw Hardware instance address
* @param[in] enable Enable / Disable
*/
static inline void isp_ll_cam_enable(isp_dev_t *hw, bool enable)
{
if (enable) {
hw->cam_cntl.cam_update_reg = 1;
hw->cam_cntl.cam_en = 1;
while (hw->cam_cntl.cam_update_reg);
} else {
hw->cam_cntl.cam_en = 0;
}
}
/*---------------------------------------------------------------
INTR
---------------------------------------------------------------*/
@@ -0,0 +1,42 @@
/*
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "soc/soc_caps.h"
#include "hal/color_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Camera Controller Color Type
*/
typedef enum {
CAM_CTLR_COLOR_RAW8 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW8), ///< RAW8
CAM_CTLR_COLOR_RAW10 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW10), ///< RAW10
CAM_CTLR_COLOR_RAW12 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW12), ///< RAW12
CAM_CTLR_COLOR_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), ///< RGB565
CAM_CTLR_COLOR_RGB666 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB666), ///< RGB666
CAM_CTLR_COLOR_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), ///< RGB888
CAM_CTLR_COLOR_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), ///< YUV420
CAM_CTLR_COLOR_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), ///< YUV422
} cam_ctlr_color_t;
/**
* @brief Camera Controller Data Width
*/
typedef enum {
CAM_CTLR_DATA_WIDTH_8 = 8, ///< 8-bit data width
CAM_CTLR_DATA_WIDTH_10 = 10, ///< 10-bit data width
CAM_CTLR_DATA_WIDTH_12 = 12, ////< 12-bit data width
CAM_CTLR_DATA_WIDTH_16 = 16, ///< 16-bit data width
} cam_ctlr_data_width_t;
#ifdef __cplusplus
}
#endif
+9
View File
@@ -45,6 +45,15 @@ typedef enum {
ISP_COLOR_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), ///< YUV420
} isp_color_t;
/*---------------------------------------------------------------
DVP
---------------------------------------------------------------*/
#if SOC_ISP_AF_WINDOW_NUMS
#define ISP_DVP_DATA_SIG_NUM SOC_ISP_DVP_DATA_WIDTH_MAX // The ISP DVP data signal number
#else
#define ISP_DVP_DATA_SIG_NUM 0
#endif
/*---------------------------------------------------------------
AF
---------------------------------------------------------------*/
+1 -14
View File
@@ -10,6 +10,7 @@
#include "soc/soc_caps.h"
#include "soc/clk_tree_defs.h"
#include "hal/color_types.h"
#include "hal/cam_ctlr_types.h"
#ifdef __cplusplus
extern "C" {
@@ -24,20 +25,6 @@ typedef soc_periph_mipi_csi_phy_clk_src_t mipi_csi_phy_clock_source_t;
typedef int mipi_csi_phy_clock_source_t;
#endif // SOC_MIPI_CSI_SUPPORTED
/**
* @brief MIPI CSI Color Type
*/
typedef enum {
MIPI_CSI_COLOR_RAW8 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW8), ///< RAW8
MIPI_CSI_COLOR_RAW10 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW10), ///< RAW10
MIPI_CSI_COLOR_RAW12 = COLOR_TYPE_ID(COLOR_SPACE_RAW, COLOR_PIXEL_RAW12), ///< RAW12
MIPI_CSI_COLOR_RGB565 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB565), ///< RGB565
MIPI_CSI_COLOR_RGB666 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB666), ///< RGB666
MIPI_CSI_COLOR_RGB888 = COLOR_TYPE_ID(COLOR_SPACE_RGB, COLOR_PIXEL_RGB888), ///< RGB888
MIPI_CSI_COLOR_YUV420 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV420), ///< YUV420
MIPI_CSI_COLOR_YUV422 = COLOR_TYPE_ID(COLOR_SPACE_YUV, COLOR_PIXEL_YUV422), ///< YUV422
} mipi_csi_color_t;
#ifdef __cplusplus
}
#endif