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 #include <driver/hal/hal_jpeg_types.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /* @brief Overview about this API header 25 * 26 */ 27 28 /** 29 * @brief JPEGENC APIs Version 1.0 30 * @{ 31 */ 32 33 #define Y_PIXEL_272 (34) /**< image resolution for hight: Y * 8 = 272 */ 34 #define Y_PIXEL_320 (40) /**< image resolution for hight: Y * 8 = 320 */ 35 #define X_PIXEL_480 (60) /**< image resolution for width: X * 8 = 480 */ 36 #define Y_PIXEL_480 (60) /**< image resolution for hight: Y * 8 = 480 */ 37 #define X_PIXEL_640 (80) /**< image resolution for hight: X * 8 = 640 */ 38 #define Y_PIXEL_240 (30) /**< image resolution for hight: Y * 8 = 240 */ 39 #define X_PIXEL_320 (40) /**< image resolution for hight: X * 8 = 320 */ 40 #define Y_PIXEL_600 (75) /**< image resolution for hight: Y * 8 = 600 */ 41 #define X_PIXEL_800 (100) /**< image resolution for hight: X * 8 = 800 */ 42 #define Y_PIXEL_720 (90) /**< image resolution for hight: Y * 8 = 720 */ 43 #define X_PIXEL_1280 (160) /**< image resolution for hight: X * 8 = 1280 */ 44 #define X_PIXEL_1600 (200) /**< image resolution for hight: X * 8 = 1600 */ 45 #define Y_PIXEL_1200 (150) /**< image resolution for hight: Y * 8 = 1200 */ 46 47 typedef enum { 48 JPEG_ENC_MODE = 0, 49 JPEG_YUV_MODE, 50 }jpeg_mode_t; 51 52 /** 53 * @brief jpeg_yuv_format_t when jpeg encode at yuv mode, the output yuv format type 54 */ 55 typedef enum { 56 JPEG_YUYV = 0, /**< YUYV, bit[31-0]=[YUYV] */ 57 JPEG_UYVY = 1, /**< UYVY, bit[31-0]=[UYVY] */ 58 JPEG_YYUV = 2, /**< YYUV, bit[31-0]=[YYUV] */ 59 JPEG_UVYY = 3, /**< UVYY, bit[31-0]=[UVYY] */ 60 }jpeg_yuv_format_t; 61 62 typedef enum { 63 END_OF_YUV = 0, /**< when work at yuv mode, transfer a complete frame will trigger this isr */ 64 HEAD_OUTPUT, /**< when work at jpeg encode mode, the head output complete will trigger this isr */ 65 START_OF_FRAME, /**< when work at jpeg encode mode, detect vsync rising edge after few cycle will trigger this isr */ 66 END_OF_FRAME, /**< when work at jpeg encode mode, transfer a complete frame will trigger this isr */ 67 VSYNC_NEGEDGE, /**< when detect vsync negedge will trigger this isr */ 68 ISR_MAX, 69 }jpeg_isr_type_t; 70 71 /** 72 * @brief jpeg int type 73 */ 74 typedef enum { 75 JPEG_END_YUV_INT = (1 << 0), 76 JPEG_HEAD_OUTPUT_INT = (1 << 1), 77 JPEG_START_FRAME_INT = (1 << 2), 78 JPEG_END_FRAME_INT = (1 << 3), 79 JPEG_VSYNC_NEGEDGE_INT = (1 << 6), 80 } jpeg_int_type_t; 81 82 /** 83 * @brief jpeg isr callback relay jpeg driver 84 * 85 * @param id: only 0 useful, set 0 default 86 * @param param: NULL default 87 */ 88 typedef void (*jpeg_isr_t)(jpeg_unit_t id, void *param); 89 90 typedef struct { 91 uint8_t *rxbuf; /**< the address of receiving jpeg data */ 92 93 /** 94 * @brief node full handler 95 * 96 * This is a transfer jpeg data to uplayer api, when transfer node_len jpeg data finish , this function will be called 97 * 98 * @param curptr: the start address of transfer data. 99 * @param newlen: the transfer data length 100 * @param is_eof: 0/1: whether this packet data is the last packet of this frame, will called in jpeg_end_frame isr 101 * @param frame_len: the complete jpeg frame size, if is_eof=1, the frame_len is the true value of jpeg frame size, 102 * 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 103 * 104 **/ 105 void (*node_full_handler)(void *curptr, uint32_t newlen, uint32_t is_eof, uint32_t frame_len); 106 107 /** 108 * brief data_end_handler 109 * 110 * This api use to inforamte video transfer thread to deal transfer jpegenc data 111 * 112 **/ 113 void (*data_end_handler)(void); 114 115 uint16_t rxbuf_len; /**< The length of receiving jpegenc data buff */ 116 uint16_t rx_read_len; /**< manage the node_full_handler callback function input params */ 117 uint32_t node_len; /**< dma transfer length */ 118 uint32_t sener_cfg; /**< The sensor config:[0-15]:image_resolution, [16-31]:image rate */ 119 uint16_t x_pixel; /**< jpeg encoder image resolution for width */ 120 uint16_t y_pixel; /**< jpeg encoder image resolution for height */ 121 122 #if CONFIG_GENERAL_DMA 123 dma_isr_t dma_rx_handler; /**< dma transfer finish isr callbck */ 124 uint8_t dma_channel; /**< dma channel used for transfer jpeg encoder data */ 125 #endif 126 127 #if CONFIG_VIDEO_DVP_LCD 128 uint8_t dma_lcd_channel; /**< dma channel used for lcd display */ 129 uint8_t *jpeg_dec_src_addr; /**< jepg data, and jpeg dec arc addr */ 130 uint8_t *jpeg_dec_dst_addr; /**< jepg dec data dst addr */ 131 uint8_t *lcd_display_addr; /**< lcd diaplay data base addr */ 132 uint16_t jpeg_dec_pixel_x; /**< jepg dec x_pixel */ 133 uint8_t dma_lcd_int_cnt; /**< lcd disaply dma transfer cnt */ 134 uint8_t lcd_blend_frame_cnt; 135 void (*jpeg_dec_callback)(void * src, void * dst); /**< jpeg dec callback */ 136 #endif 137 } jpegenc_desc_t; 138 139 typedef enum { 140 READY = 0, /**< jpeg deca and display ready */ 141 MEMCPYING, /**< jepg data mem cpying */ 142 JPEGDE_START, /**< jepg dec start */ 143 JPEGDECING, /**< jepg decing */ 144 DISPLAYING, /**< jepg dec complete, lcd display */ 145 JPEGDED, 146 }lcd_satus_t; 147 148 149 150 151 /** 152 * @} 153 */ 154 155 #ifdef __cplusplus 156 } 157 #endif 158 159