JPEG_ENC
JPEG_ENC API Status
API |
BK7258_AP |
|---|---|
Y |
|
Y |
|
Y |
|
Y |
|
Y |
|
Y |
|
N |
|
Y |
|
Y |
|
Y |
|
Y |
|
N |
|
N |
|
N |
|
N |
|
N |
|
Y |
|
N |
|
N |
|
Y |
JPEG_ENC Marco defined and config
Marco name |
illustrate |
|---|---|
CONFIG_JPEGENC_HW |
enable JPEG_ENC module or not |
Note
CONFIG_JPEGENC_HW depends on CONFIG_YUV_BUF, JPEG module can not work alone. Those api only for reference, user can not use them directly. Please referecnce doorbell project.
JPEG_ENC API Reference
Header File
Functions
-
bk_err_t bk_jpeg_enc_driver_init(void)
Init the jpeg encode driver.
This API init the resoure common:
Init jpegenc driver control memory
register jpegenc isr
- Attention
1. This API should be called before any other jpeg APIs.
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_driver_deinit(void)
Deinit the jpegenc driver.
This API free all resource related to jpegenc and disable jpegenc.
- Attention
1. This API will power down video when soc is bk7256XX
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_init(const jpeg_config_t *config)
Init the jpeg encode.
This API init the jpegenc
Configure clock and Power up the jpegenc
Enable Jpegenc interrupt
Map the jpegenc to dedicated GPIO port(MCLK and PCLK)
Set the jpegenc parameters
Enable jpeg encode module
Usage example:
jpeg_config_t init_config = { .rx_buf = xxx, // the address point to mem for receiving jpeg data .yuv_mode = 0, .sys_clk_div = 3, // jpeg_clk = 480 / (1+3) =120MHz .mclk_div = 0, // MCLK=jpeg_clk/4 = 30MHz .rx_buf_len = xxx, // the length of receive jpeg data .node_len = xxx, // dma transfer length .x_pixel = 80, // jpeg image resolution of width: 80 * 8 = 640 .y_pixel = 60, // jpeg image resolution of height: 60 * 8 = 480 .dma_rx_finish_handler = cb, // dma transfer finish callback }; BK_LOG_ON_ERR(bk_jpeg_init(&init_config);
- Attention
1. only work for imaging transfer
- Parameters
config – jpeg encode parameter settings
- Returns
BK_OK: succeed
BK_ERR_NULL_PARAM: jpegenc config paramter is NULL
BK_ERR_JPEG_NOT_INIT: jpegenc driver not init
others: other errors.
-
bk_err_t bk_jpeg_enc_deinit(void)
Deinit the jpeg.
This API stop jpeg encode, close jpeg gpio, power off jpeg module at last.
- Attention
1. only work for imaging transfer
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_start(yuv_mode_t mode)
set jpegenc start
This API will set jpegenc work start.
- Attention
1. if work in jpegenc mode, this api can enable jpegenc mode
- Attention
2. if work in yuv mode, this api can enable yuv_mode.
- Parameters
mode – 0/1:jpeg encode mode/yuv mode
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_stop(yuv_mode_t mode)
set jpegenc stop
This API will set jpegenc work stop.
- Attention
1. if work in jpegenc mode, this api can disable jpegenc mode
- Attention
2. if work in yuv mode, this api can disable yuv_mode.
- Parameters
mode – 0/1:jpeg encode mode/yuv mode
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_yuv_fmt_sel(yuv_format_t fmt)
yuv format select
This API will set yuv output format.
- Attention
1. this function only used when jpeg at yuv mode
- Parameters
value – 0:yuyv, 1:uyvy, 2:yyuv, 3:uvyy
- Returns
BK_OK: succeed
others: other errors.
-
uint32_t bk_jpeg_enc_get_frame_size(void)
get a frame size output from jpegenc module, uint byte
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_register_isr(jpeg_isr_type_t type_id, jpeg_isr_t isr, void *param)
register frame end isr
This API will register jpeg encode isr function, need user defined.The isr function will execute when the isr be triggered.
- Parameters
type_id – the type of the isr
JPEG_EOY: (eoy)when jpeg encode work in yuv mode, once a complete frame have been transfer by jpeg encode module, the isr will trigger.
JPEG_HEAD_OUTPUT: jpeg encode output head the isrt will be triggered, work in jpeg encode mode.
START_OFFRAME: (sof) when jpeg encode module start reveice a frame the isr will be triggered.
JPEG_EOF: (eof) when jpeg encode module receive a complete frame the isr will be triggered, this only effect in jpeg encode mode.
JPEG_VSYNC_NEGEDGE: (vng) when jpeg encode module receive a vsync negedge the isr will be triggered.
isr – isr_func
param – other value(default set NULL)
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_unregister_isr(jpeg_isr_type_t type_id)
unregister frame end isr
This API will unregister jpeg encode isr function, need user unregister, when deinit jpeg module
- Parameters
type_id – the type of the isr
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_get_fifo_addr(uint32_t *fifo_addr)
get jpeg enc fifo addr
This API will get jpeg encode fifo addr in param
- Attention
1. only work in jpeg encode mode is effective
- Parameters
fifo_addr – fifo addr
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_set_auxs(uint32_t cksel, uint32_t ckdiv)
set mclk output
This API will use for camera config
@attenation 1. this api only used for bk7256xx_mp chip, and when use this api, this api ‘bk_jpeg_enc_mclk_enable’ will not useful
- Parameters
cksel – 0-3:0:DCO/1:APLL/2:320M/3:480M,use 2 or 3
ckdiv – 0-15, div = 1/(ckdiv+1)
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_partial_display_init(const jpeg_partial_offset_config_t *offset_config)
partial display init
This API will use for partial display configure of jpeg encode
- Parameters
offset_config – x_pixel left/right offset and y_pixel left/right offset configure
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_partial_display_deinit(void)
partial display deinit
This API will use for partial display deinit
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_set_em_base_addr(uint8_t *address)
jpeg em base set
This API will use for jpeg em base address, 64KB memory align.
- Parameters
address – set a mem used for jpeg encode
- Returns
BK_OK: succeed
others: other errors.
-
uint32_t bk_jpeg_get_em_base_addr(void)
jpeg em base get
This API will use for get jpeg em base address.
- Returns
jpeg em base
-
bk_err_t bk_jpeg_enc_encode_config(uint8_t enable, uint16_t up_size, uint16_t low_size)
jpeg encode enable encode auto contrl
This API will use for enable/disable for auto encode size. only valid in jpeh encode mode
@attenation 1. this api only called in jpeg_eof_isr function, and only bk_jpeg_enc_enable_encode_auto_ctrl have been set enable
- Parameters
up_size – the jpeg image upper limit, unit byte
low_size – the jpeg image lower limit, unit byte
- Returns
BK_OK: succeed
others: other errors.
-
bk_err_t bk_jpeg_enc_mode_switch(jpeg_config_t *config)
jpeg encode mode and yuv mode switch
This API will use for switch jpeg mode
@attenation 1. this api must called in jpeg_eof isr or yuv_eof isr
- Parameters
config – jpeg encode config or jpeg yuv config
- Returns
BK_OK: succeed
others: other errors.
JPEG_ENC API Typedefs
Header File
Macros
-
Y_PIXEL_272
JPEGENC APIs Version 1.0.
image resolution for hight: Y * 8 = 272
-
Y_PIXEL_320
image resolution for hight: Y * 8 = 320
-
X_PIXEL_480
image resolution for width: X * 8 = 480
-
Y_PIXEL_480
image resolution for hight: Y * 8 = 480
-
X_PIXEL_640
image resolution for hight: X * 8 = 640
-
Y_PIXEL_240
image resolution for hight: Y * 8 = 240
-
X_PIXEL_320
image resolution for hight: X * 8 = 320
-
Y_PIXEL_600
image resolution for hight: Y * 8 = 600
-
X_PIXEL_800
image resolution for hight: X * 8 = 800
-
Y_PIXEL_720
image resolution for hight: Y * 8 = 720
-
X_PIXEL_1280
image resolution for hight: X * 8 = 1280
-
X_PIXEL_1600
image resolution for hight: X * 8 = 1600
-
Y_PIXEL_1200
image resolution for hight: Y * 8 = 1200
Type Definitions
-
typedef void (*jpeg_isr_t)(jpeg_unit_t id, void *param)
jpeg isr callback relay jpeg driver
- Param id
only 0 useful, set 0 default
- Param param
NULL default
Header File
Structures
-
struct jpeg_config_t
Public Members
-
uint8_t *rx_buf
the address of receiving jpeg data
-
yuv_mode_t mode
jpeg module work mode:0/1:jpegencoder/yuv
-
mclk_freq_t clk
jpeg module work clk config
-
sync_level_t vsync
sensor vsync active level
-
sync_level_t hsync
sensor hsync active level
-
yuv_format_t sensor_fmt
sensor input data format
-
uint32_t rx_buf_len
the length for receiving jpeg data
-
uint32_t node_len
dma transfer length
-
uint32_t x_pixel
jpeg encode image resolution for width
-
uint32_t y_pixel
jpeg encode image resolution for height
-
uint8_t *rx_buf
-
struct jpeg_partial_offset_config_t
Macros
-
BK_ERR_JPEG_NOT_INIT
JPEG driver not init
Type Definitions
-
typedef uint8_t jpeg_unit_t
jpeg uint id
Enumerations
-
enum jpeg_isr_type_t
Values:
-
enumerator JPEG_EOY
when work at yuv mode, transfer a complete frame will trigger this isr
-
enumerator JPEG_HEAD_OUTPUT
when work at jpeg encode mode, the head output complete will trigger this isr
-
enumerator JPEG_SOF
when work at jpeg encode mode, detect vsync rising edge after few cycle will trigger this isr
-
enumerator JPEG_EOF
when work at jpeg encode mode, transfer a complete frame will trigger this isr
-
enumerator JPEG_VSYNC_NEGEDGE
when detect vsync negedge will trigger this isr
-
enumerator JPEG_LINE_CLEAR
when used encode yuv data by 8line every time will trigger this isr
-
enumerator JPEG_FRAME_ERR
when detect jpeg encode error, will trigger this isr
-
enumerator JPEG_ISR_MAX
-
enumerator JPEG_EOY