• 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 "hal_config.h"
18 #include "jpeg_hw.h"
19 #include "jpeg_ll.h"
20 #include <driver/hal/hal_jpeg_types.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define PSRAM_BASEADDR                    0x60000000
27 
28 
29 typedef struct {
30 	jpeg_hw_t *hw;
31 	jpeg_unit_t id;
32 } jpeg_hal_t;
33 
34 typedef struct {
35 	gpio_id_t gpio_id;
36 	gpio_dev_t dev;
37 } jpeg_gpio_map_t;
38 
39 #define jpeg_hal_enable_end_yuv_int(hal) jpeg_ll_enable_end_yuv_int((hal)->hw)
40 #define jpeg_hal_disable_end_yuv_int(hal) jpeg_ll_disable_end_yuv_int((hal)->hw)
41 #define jpeg_hal_enable_head_output_int(hal) jpeg_ll_enable_head_output_int((hal)->hw)
42 #define jpeg_hal_disable_head_output_int(hal) jpeg_ll_disable_head_output_int((hal)->hw)
43 #define jpeg_hal_enable_start_frame_int(hal) jpeg_ll_enable_start_frame_int((hal)->hw)
44 #define jpeg_hal_disable_start_frame_int(hal) jpeg_ll_disable_start_frame_int((hal)->hw)
45 #define jpeg_hal_enable_end_frame_int(hal) jpeg_ll_enable_end_frame_int((hal)->hw)
46 #define jpeg_hal_disable_end_frame_int(hal) jpeg_ll_disable_end_frame_int((hal)->hw)
47 #define jpeg_hal_enable_vsync_negedge_int(hal) jpeg_ll_enable_vsync_negedge_int((hal)->hw)
48 #define jpeg_hal_disable_vsync_negedge_int(hal) jpeg_ll_disable_vsync_negedge_int((hal)->hw)
49 #define jpeg_hal_reset_config_to_default(hal) jpeg_ll_reset_config_to_default((hal)->hw)
50 #define jpeg_hal_set_x_pixel(hal, x_pixel) jpeg_ll_set_x_pixel((hal)->hw, x_pixel)
51 #define jpeg_hal_set_y_pixel(hal, x_pixel) jpeg_ll_set_y_pixel((hal)->hw, x_pixel)
52 #define jpeg_hal_set_yuv_mode(hal, mode) jpeg_ll_set_yuv_mode((hal)->hw, mode)
53 
54 #define jpeg_hal_get_frame_byte_number(hal) jpeg_ll_get_frame_byte_number((hal)->hw)
55 
56 #define jpeg_hal_get_interrupt_status(hal) jpeg_ll_get_interrupt_status((hal)->hw)
57 #define jpeg_hal_clear_interrupt_status(hal, int_status) jpeg_ll_clear_interrupt_status((hal)->hw, int_status)
58 #define jpeg_hal_is_frame_start_int_triggered(hal, int_status) jpeg_ll_is_frame_start_int_triggered((hal)->hw, int_status)
59 #define jpeg_hal_is_frame_end_int_triggered(hal, int_status) jpeg_ll_is_frame_end_int_triggered((hal)->hw, int_status)
60 #define jpeg_hal_is_yuv_end_int_triggered(hal, int_status) jpeg_ll_is_yuv_end_int_triggered((hal)->hw, int_status)
61 #define jpeg_hal_is_head_output_int_triggered(hal, int_status) jpeg_ll_is_head_output_int_triggered((hal)->hw, int_status)
62 #define jpeg_hal_is_sync_negedge_int_triggered(hal, int_status) jpeg_ll_is_vsync_negedge_int_triggered((hal)->hw, int_status)
63 
64 bk_err_t jpeg_hal_init(jpeg_hal_t *hal);
65 bk_err_t jpeg_hal_configure(jpeg_hal_t *hal, const jpeg_config_t *config);
66 bk_err_t jpeg_hal_yuv_fmt_sel(jpeg_hal_t *hal, uint32_t value);
67 bk_err_t jpeg_hal_start_common(jpeg_hal_t *hal, uint8_t mode);
68 bk_err_t jpeg_hal_stop_common(jpeg_hal_t *hal, uint8_t mode);
69 bk_err_t jpeg_hal_enable_clk(jpeg_hal_t *hal, uint32_t value);
70 bk_err_t jpeg_hal_enable_partial_display(jpeg_hal_t *hal, uint32_t enable);
71 bk_err_t jpeg_hal_partial_display_offset_config(jpeg_hal_t *hal, const jpeg_partial_offset_config_t *offset_config);
72 bk_err_t jpeg_hal_set_em_base_addr(jpeg_hal_t *hal, uint8_t *address);
73 bk_err_t jpeg_hal_set_yuv_config(jpeg_hal_t *hal, const jpeg_config_t *config);
74 bk_err_t jpeg_hal_set_encode_config(jpeg_hal_t *hal, const jpeg_config_t *config);
75 bk_err_t jpeg_hal_enable_bitrate_ctrl(jpeg_hal_t *hal, uint8_t enable);
76 bk_err_t jpeg_hal_set_target_size(jpeg_hal_t *hal, uint32_t up_size, uint32_t low_size);
77 
78 
79 #if CFG_HAL_DEBUG_JPEG
80 void jpeg_struct_dump(void);
81 #else
82 #define jpeg_struct_dump()
83 #endif
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89