• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <common/bk_include.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define    PARAM_JPEG_SRC_ADDR_BASE       0X60100000 /**< LCD DISPLAY Define jpeg dec src addr*/
24 #define    PARAM_JPEG_DEC_DST_ADDR_BASE   0X60300000 /**< LCD DISPLAY Define jpeg dec dst addr*/
25 #define    PARAM_LCD_DISPLAY_ADDR_BASE    0X60500000 /**< if lcd display data is jpegdec data,the display addr = PARAM_JPEG_DEC_DST_ADDR_BASE*/
26 #define    PARAM_LCD_ROTATE_BASE          0X60700000 /**< if ENABLE rotate function*/
27 
28 /**
29  * @brief camera image resolution type
30  */
31 typedef enum {
32 	QVGA_320_240    = 0,  /**< 320*240 */
33 	VGA_480_272,          /**< 480*272 */
34 	VGA_320_480,          /**< 640*480 */
35 	VGA_480_320,          /**< 480*320 */
36 	VGA_640_480,          /**< 640*480 */
37 	VGA_800_600,          /**< 800*600 */
38 	VGA_1280_720,         /**< 1280*720 */
39 	VGA_1600_1200,        /**< 1600*1200 */
40 	PPI_MAX
41 } ppi_type_t; // Pixel per inch
42 
43 /**
44  * @brief camera frame rate type
45  */
46 typedef enum {
47 	TYPE_5FPS     = 0,     /**< 5fps */
48 	TYPE_10FPS,            /**< 10fps */
49 	TYPE_15FPS,            /**< 15fps */
50 	TYPE_20FPS,            /**< 20fps */
51 	TYPE_25FPS,            /**< 25fps */
52 	TYPE_30FPS,            /**< 30fps */
53 	FPS_MAX
54 } fps_type_t; // frame per second
55 
56 #define PPI_POSI        0        /**< replace ppi bit position, start bit 0 */
57 #define PPI_MASK        0xFF     /**< ppi occupy 8bits, bit[7-0] */
58 #define FPS_POSI        8        /**< replace fps bit position, start bit 8 */
59 #define FPS_MASK        0xFF     /**< fps occupy 8bits, bit[15-8] */
60 
61 /**
62  * @brief set ppi type to camera sensor
63  */
64 #define CMPARAM_SET_PPI(p, x)   (p = ((p & ~(PPI_MASK << PPI_POSI)) | ((x & PPI_MASK) << PPI_POSI)))
65 
66 /**
67  * @brief get ppi type from camera sensor param
68  */
69 #define CMPARAM_GET_PPI(p)      ((p >> PPI_POSI) & PPI_MASK)
70 
71 /**
72  * @brief set fps type to camera sensor
73  */
74 #define CMPARAM_SET_FPS(p, x)   (p = ((p & ~(FPS_MASK << FPS_POSI)) | ((x & FPS_MASK) << FPS_POSI)))
75 
76 /**
77  * @brief get fps type from camera sensor param
78  */
79 #define CMPARAM_GET_FPS(p)      ((p >> FPS_POSI) & FPS_MASK)
80 
81 /**
82  * @brief video sample module protocol type
83  */
84 typedef enum {
85 	TVIDEO_OPEN_NONE         = 0, /**< not sample module */
86 	TVIDEO_OPEN_SCCB,             /**< sample module follow sccb protocol */
87 	TVIDEO_OPEN_SPIDMA,           /**< sample module follow spidma protocol */
88 } video_open_type_t;
89 
90 /**
91  * @brief video transfer network comunication protocol type
92  */
93 typedef enum {
94 	TVIDEO_SND_NONE         = 0,  /**< not transfer */
95 	TVIDEO_SND_UDP,               /**< follow udp protocol */
96 	TVIDEO_SND_TCP,               /**< follow tcp protocol */
97 	TVIDEO_SND_INTF,              /**< transfer to inter frame */
98 	TVIDEO_SND_BUFFER,            /**< transfer to buffer */
99 } video_send_type_t;
100 
101 typedef struct {
102 	uint8_t *rxbuf; /**< the buffer save camera data */
103 
104 	/**
105 	 * @brief node full handler
106 	 *
107 	 * This is a transfer camera data to uplayer api, when transfer node_len jpeg data finish , this function will be called
108 	 *
109 	 * @param curptr: the start address of transfer data.
110 	 * @param newlen: the transfer data length
111 	 * @param is_eof: 0/1: whether this packet data is the last packet of this frame, will called in jpeg_end_frame isr
112 	 * @param frame_len: the complete jpeg frame size, if is_eof=1, the frame_len is the true value of jpeg frame size,
113 	 * is_eof=0, the frame_len=0, in other words, only when transfer really frame_len at the last packet in jpeg_end_frame isr
114 	 *
115 	**/
116 	void (*node_full_handler)(void *curptr, uint32_t newlen, uint32_t is_eof, uint32_t frame_len);
117 
118 	/**
119 	 * brief data_end_handler
120 	 *
121 	 * This api use to inforamte video transfer thread to deal transfer camera data
122 	 *
123 	**/
124 	void (*data_end_handler)(void);
125 
126 	uint16_t rxbuf_len;  /**< The length  of receiving camera data buff */
127 	uint16_t rx_read_len;/**< manage the node_full_handler callback function input params */
128 	uint32_t node_len;   /**< video transfer network comunication protocol length a time */
129 	uint32_t sener_cfg; /**< camera config, ppi[15-8], fps[7-0] */
130 } video_config_t;
131 
132 typedef struct {
133 	uint8_t *ptk_ptr;
134 	uint32_t ptklen;     /**< The current packet length */
135 	uint32_t frame_id;   /**< The current packet frame id */
136 	uint32_t is_eof;     /**< The current packet is the last packet */
137 	uint32_t frame_len;  /**< The frame length */
138 } video_packet_t;
139 
140 typedef void (*tvideo_add_pkt_header)(video_packet_t *param);
141 typedef int (*video_transfer_send_func)(uint8_t *data, uint32_t len);
142 typedef void (*video_transfer_start_cb)(void);
143 typedef void (*video_transfer_end_cb)(void);
144 
145 typedef struct {
146 	uint16_t open_type;                  /**< video transfer network comunication protocol type, video_open_type_t */
147 	uint16_t send_type;                  /**< video transfer network comunication protocol type, video_send_type_t */
148 	video_transfer_send_func send_func;  /**< function ptr for send to uplayer */
149 	video_transfer_start_cb start_cb;    /**< function ptr for start to send to uplayer */
150 	video_transfer_start_cb end_cb;      /**< function ptr for end to send to uplayer */
151 
152 	uint32_t pkt_header_size;            /**< packet header size */
153 	tvideo_add_pkt_header add_pkt_header;/**< function ptr for add packet header */
154 } video_setup_t;
155 
156 #ifdef __cplusplus
157 }
158 #endif
159