summaryrefslogtreecommitdiff
path: root/bsp/bouffalo_lab/libraries/bl_mcu_sdk/drivers/lhal/include/bflb_csi.h
blob: d430a4e38158a2a7ba095adec5883e8fcedf6f35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef _BFLB_CSI_H
#define _BFLB_CSI_H

#include "bflb_core.h"

/** @addtogroup LHAL
  * @{
  */

/** @addtogroup CSI
  * @{
  */

/** @defgroup CSI_LANE_NUMBER CSI lane number definition
  * @{
  */
#define CSI_LANE_NUMBER_1 0
#define CSI_LANE_NUMBER_2 1
/**
  * @}
  */

/** @defgroup CSI_INTSTS CSI interrupt status definition
  * @{
  */
#define CSI_INTSTS_GENERIC_PACKET        (1 << 0)
#define CSI_INTSTS_LANE_MERGE_ERROR      (1 << 1)
#define CSI_INTSTS_ECC_ERROR             (1 << 2)
#define CSI_INTSTS_CRC_ERROR             (1 << 3)
#define CSI_INTSTS_PHY_HS_SOT_ERROR      (1 << 4)
#define CSI_INTSTS_PHY_HS_SOT_SYNC_ERROR (1 << 5)
/**
  * @}
  */

/** @defgroup CSI_INTMASK CSI interrupt mask definition
  * @{
  */
#define CSI_INTMASK_GENERIC_PACKET        (1 << 0)
#define CSI_INTMASK_LANE_MERGE_ERROR      (1 << 1)
#define CSI_INTMASK_ECC_ERROR             (1 << 2)
#define CSI_INTMASK_CRC_ERROR             (1 << 3)
#define CSI_INTMASK_PHY_HS_SOT_ERROR      (1 << 4)
#define CSI_INTMASK_PHY_HS_SOT_SYNC_ERROR (1 << 5)
/**
  * @}
  */

/** @defgroup CSI_INTCLR CSI interrupt clear definition
  * @{
  */
#define CSI_INTCLR_GENERIC_PACKET        (1 << 0)
#define CSI_INTCLR_LANE_MERGE_ERROR      (1 << 1)
#define CSI_INTCLR_ECC_ERROR             (1 << 2)
#define CSI_INTCLR_CRC_ERROR             (1 << 3)
#define CSI_INTCLR_PHY_HS_SOT_ERROR      (1 << 4)
#define CSI_INTCLR_PHY_HS_SOT_SYNC_ERROR (1 << 5)
/**
  * @}
  */

/**
 * @brief CSI configuration structure
 *
 * @param lane_number   CSI lane number, use @ref CSI_LANE_NUMBER
 * @param tx_clk_escape CSI tx clock in escape mode
 * @param data_rate     CSI data rate
 */
struct bflb_csi_config_s {
    uint8_t lane_number;
    uint32_t tx_clk_escape;
    uint32_t data_rate;
};

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief Initialize csi.
 *
 * @param [in] dev device handle
 * @param [in] config pointer to csi configure structure
 */
void bflb_csi_init(struct bflb_device_s *dev, const struct bflb_csi_config_s *config);

/**
 * @brief Enable csi.
 *
 * @param [in] dev device handle
 */
void bflb_csi_start(struct bflb_device_s *dev);

/**
 * @brief Disable csi.
 *
 * @param [in] dev device handle
 */
void bflb_csi_stop(struct bflb_device_s *dev);

/**
 * @brief Set threshold of line buffer, data will be sent to following module when threshold reached.
 *
 * @param [in] dev device handle
 * @param [in] resolution_x number of columns
 * @param [in] pixel_clock pixel clock
 * @param [in] dsp_clock dsp clock
 */
void bflb_csi_set_line_threshold(struct bflb_device_s *dev, uint16_t resolution_x, uint32_t pixel_clock, uint32_t dsp_clock);

/**
 * @brief Mask or unmask csi interrupt.
 *
 * @param [in] dev device handle
 * @param [in] int_type csi interrupt mask type, use @ref CSI_INTMASK
 * @param [in] mask mask or unmask
 */
void bflb_csi_int_mask(struct bflb_device_s *dev, uint32_t int_type, bool mask);

/**
 * @brief Clear csi interrupt.
 *
 * @param [in] dev device handle
 * @param [in] int_type csi interrupt clear type, use @ref CSI_INTCLR
 */
void bflb_csi_int_clear(struct bflb_device_s *dev, uint32_t int_type);

/**
 * @brief Get csi interrupt status.
 *
 * @param [in] dev device handle
 * @return Interrupt status
 */
uint32_t bflb_csi_get_intstatus(struct bflb_device_s *dev);

/**
 * @brief Control csi feature.
 *
 * @param [in] dev device handle
 * @param [in] cmd feature command
 * @param [in] arg user data
 * @return A negated errno value on failure
 */
int bflb_csi_feature_control(struct bflb_device_s *dev, int cmd, size_t arg);

#ifdef __cplusplus
}
#endif

/**
  * @}
  */

/**
  * @}
  */

#endif