1 /*
2  * Copyright (C) 2017-2019 Alibaba Group Holding Limited
3  */
4 /******************************************************************************
5  * @file     drv_mipi_csi.h
6  * @brief    header file for mipi_csi driver
7  * @version  V1.2
8  * @date     27. May 2019
9  ******************************************************************************/
10 
11 #ifndef _DRV_MIPI_CSI_H_
12 #define _DRV_MIPI_CSI_H_
13 
14 #include <drv/common.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /// definition for mipi csi handle.
21 typedef void *mipi_csi_handle_t;
22 
23 /**** IPI Data Types ****/
24 typedef enum {
25     MIPI_YUV420_8           = 0x18,
26     MIPI_YUV420_10          = 0x19,
27     MIPI_YUV420_8_LEG       = 0x1A,
28     MIPI_YUV420_8_SHIFT     = 0x1C,
29     MIPI_YUV420_10_SHIFT    = 0x1D,
30     MIPI_YUV422_8           = 0x1E,
31     MIPI_YUV422_10          = 0x1F,
32     MIPI_RGB444             = 0x20,
33     MIPI_RGB555             = 0x21,
34     MIPI_RGB565             = 0x22,
35     MIPI_RGB666             = 0x23,
36     MIPI_RGB888             = 0x24,
37     MIPI_RAW6               = 0x28,
38     MIPI_RAW7               = 0x29,
39     MIPI_RAW8               = 0x2A,
40     MIPI_RAW10              = 0x2B,
41     MIPI_RAW12              = 0x2C,
42     MIPI_RAW14              = 0x2D,
43 } mipi_csi_data_format_e;
44 
45 /**
46 \brief mipi config structure
47 */
48 typedef struct {
49     mipi_csi_data_format_e  data_format;   ///< Output format
50     uint16_t                lane_count;    ///< the count of lane
51 } mipi_csi_config_t;
52 
53 /****** MIPI Event *****/
54 typedef enum {
55     MIPI_CSI_EVENT_RECEIVED_ERROR   = 0,  ///< Receive data error.
56 } mipi_csi_event_e;
57 
58 typedef void (*mipi_csi_event_cb_t)(mipi_csi_handle_t handle, mipi_csi_event_e event, void *user_data); //< Pointer to \ref mipi_event_cb_t : MIPI Event call back.
59 
60 /**
61   \brief       Initialize MIPI CSI Interface. 1. Initializes the resources needed for the MIPI interface 2.registers event callback function
62   \param[in]   idx  mipi index
63   \param[in]   cb_event  event call back function \ref mipi_event_cb_t
64   \return      return mipi handle if success
65 */
66 mipi_csi_handle_t csi_mipi_csi_initialize(int32_t idx, mipi_csi_event_cb_t cb_event, void *user_data);
67 
68 /**
69   \brief       De-initialize MIPI CSI Interface. stops operation and releases the software resources used by the interface
70   \param[in]   handle  mipi handle to operate.
71   \return      error code
72 */
73 int32_t csi_mipi_csi_uninitialize(mipi_csi_handle_t handle);
74 
75 /**
76   \brief       Start the mipi csi.
77   \param[in]   handle  mipi csi handle to operate.
78   \param[in]   config  Pointer of mipi_config_t with data to set to MIPI conteroller.
79   \return      error code
80 */
81 int32_t csi_mipi_csi_start(mipi_csi_handle_t handle, mipi_csi_config_t *config);
82 
83 /**
84   \brief       Stop the mipi.
85   \param[in]   handle  mipi handle to operate.
86   \return      error code
87 */
88 int32_t csi_mipi_csi_stop(mipi_csi_handle_t handle);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* _DRV_MIPI_CSI_H_ */
95