• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 
19 #ifndef __HIFB_MAIN_H__
20 #define __HIFB_MAIN_H__
21 
22 #include "hifb_vou_drv.h"
23 #include "drv_tde_type.h"
24 
25 /* define the value of default set of each layer */
26 #define HIFB_4K_DEF_WIDTH 3840
27 #define HIFB_4K_DEF_HEIGHT 2160
28 
29 #define HIFB_HD_DEF_WIDTH 1920 /* 1280 */                           /* unit: pixel */
30 #define HIFB_HD_DEF_HEIGHT 1080 /* 720 */                           /* unit: pixel */
31 #define HIFB_HD_DEF_STRIDE (HIFB_HD_DEF_WIDTH * 4)                  /* unit: byte */
32 #define HIFB_HD_DEF_VRAM 16200 /* 7200, unit:KB 1280*720*4*2, unit:KB 1920*1080*4*2 */
33 
34 #define HIFB_SD_DEF_WIDTH 720
35 #define HIFB_SD_DEF_HEIGHT 576
36 #define HIFB_SD_DEF_STRIDE 1440
37 #define HIFB_SD_DEF_VRAM 3240 /* unit:KB 720*576*4 */
38 
39 #define HIFB_AD_DEF_WIDTH 720
40 #define HIFB_AD_DEF_HEIGHT 576
41 #define HIFB_AD_DEF_STRIDE 1440
42 #define HIFB_AD_DEF_VRAM 3240 /* unit:KB 720*576*4 */
43 
44 #define HIFB_CURSOR_DEF_WIDTH 256
45 #define HIFB_CURSOR_DEF_HEIGHT 256
46 #define HIFB_CURSOR_DEF_STRIDE 512
47 #define HIFB_CURSOR_DEF_VRAM 512 /* unit:KB for doudble buffer mode, we need 2 memory buffer, save cursor */
48 
49 #define HIFB_SOFTCURSOR_STRIDE 512
50 
51 #define HIFB_DEF_DEPTH 16 /* unit: bits */
52 #define HIFB_DEF_XSTART 0
53 #define HIFB_DEF_YSTART 0
54 #define HIFB_DEF_ALPHA 0xff
55 
56 #define HIFB_MAX_ZOOMIN 15
57 
58 #if (HICHIP == HI3519A_V100)
59 #define HIFB_TDE_DISTINCT_WIDTH 1920
60 #define HIFB_TDE_DISTINCT_HEIGHT 1080
61 #else
62 #define HIFB_TDE_DISTINCT_WIDTH 3840
63 #define HIFB_TDE_DISTINCT_HEIGHT 2160
64 #endif
65 
66 #define HIFB_CMAP_SIZE 0 /* unit:KB 256*4 */
67 #define MMB_ADDR_INVALID 0
68 
69 #define hifb_is_clutfmt(fmt) (((fmt) >= HIFB_FMT_1BPP) && ((fmt) <= HIFB_FMT_ACLUT88))
70 #define HIFB_ALPHA_OPAQUE 0xff
71 #define HIFB_ALPHA_TRANSPARENT 0x00
72 
73 #define HIFB_DEFLICKER_LEVEL_MAX 5 /* support level 5 deflicker most */
74 
75 #define HIFB_MAX_CURSOR_WIDTH 128
76 #define HIFB_MAX_CURSOR_HEIGHT 128
77 
78 #define HIFB_SPIN_LOCK_S spinlock_t
79 #define hifb_spin_lock_init(lock) spin_lock_init(lock)
80 #define hifb_spin_lock_irqsave(lock, flag) spin_lock_irqsave(lock, flag)
81 #define hifb_spin_unlock_irqrestore(lock, flag) spin_unlock_irqrestore(lock, flag)
82 
83 typedef enum {
84     HIFB_ANTIFLICKER_NONE, /* no antiflicker.If scan mode is progressive, hifb will set antiflicker mode to none */
85     HIFB_ANTIFLICKER_TDE,  /* tde antiflicker mode, it's effect for 1buf or 2buf only */
86     HIFB_ANTIFLICKER_VO,   /* vo antiflicker mode, need hardware support */
87     HIFB_ANTIFLICKER_BUTT
88 } hifb_layer_antiflicker_mode;
89 
90 typedef struct {
91     HIFB_POINT_S pos;
92     hi_u32 display_width;
93     hi_u32 display_height;
94     hi_u32 screen_width;
95     hi_u32 screen_height;
96     hi_bool premul;
97     hi_bool need_antiflicker;
98     HIFB_LAYER_ANTIFLICKER_LEVEL_E antiflicker_level; /* antiflicker level */
99     hifb_layer_antiflicker_mode antiflicker_mode;   /* antiflicker mode */
100     hi_u32 vir_x_res;
101     hi_u32 vir_y_res;
102     hi_u32 x_res;
103     hi_u32 y_res;
104     hi_u32 max_screen_width;
105     hi_u32 max_screen_height;
106     HIFB_MIRROR_MODE_E mirror_mode;
107     HIFB_ROTATE_MODE_E rotate_mode;
108     HIFB_DYNAMIC_RANGE_E dynamic_range; /* which dynamic range */
109 } hifb_display_info;
110 
111 typedef struct {
112     hi_u64 phy_addr[2]; /* 2 buf address */
113     hi_u32 stride;     /* buf stride */
114     hi_bool need_flip;
115     hi_bool fliped;
116     hi_u32 index_for_int;
117     hi_u32 int_pic_num;
118     HIFB_RECT union_rect;
119     hi_s32 refresh_handle;
120     hi_bool compress; /* Identifies whether the frame to be displayed is compressed */
121 } hifb_dispbuf_info;
122 
123 typedef struct {
124     HIFB_LAYER_BUF_E buf_mode; /* buffer mode */
125     HIFB_BUFFER_S user_buffer;
126     hi_u64 screen_addr;   /* screen buf addr */
127     hi_u64 gb_screen_addr; /* new GB screen buf addr */
128     hifb_dispbuf_info disp_buf_info;
129     hi_u32 refresh_num; /* refresh request num in 2 buf mode */
130     hi_bool do_refresh_job;
131 } hifb_refresh_info;
132 
133 typedef struct {
134     /*
135      * For cursor layer, stCursor means cursor buffer, it is allocated and freed
136      * both by user;for general layer,stCursor means back buf
137      */
138     HIFB_CURSOR_S cursor;
139 
140     /*
141      * For cursor layer,you can query whether cursor attach to a certain layer
142      * for general layer, you can query whether cursor attach to it
143      */
144     hi_u32 attached;
145 
146     /* valid area:overlap region between attached layer and cursor layer */
147     HIFB_RECT rect_in_disp_buf;
148 
149     /* the original position of cursor, usually is (0,0) but also has different when at margin */
150     HIFB_POINT_S pos_in_cursor;
151 
152     hi_u32 attached_cursor_id;
153 } hifb_cursor_info;
154 
155 typedef struct {
156     hi_bool compress_open;
157     hi_bool decompress_open;
158     hi_bool update_finished;
159 
160     HIFB_RECT update_rect;
161 
162     HIFB_RECT compress_rect;
163 
164     hi_bool delay;
165 
166     hi_u64 ar_buf_phy_addr;
167     hi_u64 gb_buf_phy_addr;
168     hi_u32 frame_size0;
169     hi_u32 frame_size1;
170     hi_u32 header_size;
171     hi_u32 stride;
172 
173     hi_bool layer_addr_update;
174 
175     hi_u32 start_section;
176     hi_u32 zone_nums;
177     hi_bool clear_zone;
178 
179     hi_u32 new_start_section;
180     hi_u32 new_zone_nums;
181 } hifb_compress_info;
182 
183 typedef struct {
184     hi_u32 layer_id;                 /* layer id */
185     atomic_t ref_count;              /* framebuffer reference count */
186     hi_bool show;                    /* show status */
187     HIFB_COLOR_FMT_E color_format;   /* color format */
188     HIFB_ALPHA_S alpha;              /* alpha attribution */
189     hifb_colorkeyex ckey;            /* colorkey attribution */
190     hifb_display_info display_info;  /* display info */
191     hifb_refresh_info refresh_info;
192     hifb_cursor_info cursor_info;
193     volatile hifb_compress_info compress_info;
194     hi_u32 param_modify_mask;
195     volatile hi_bool modifying;
196     HIFB_SURFACE_S canvas_sur;                      /* canvas surface */
197     hi_u32 h_dflevel;                               /* horizontal deflicker level */
198     hi_u32 v_dflevel;                               /* vertical deflicker level */
199     hi_u8 h_dfcoef[HIFB_DEFLICKER_LEVEL_MAX - 1];   /* horizontal deflicker coefficients */
200     hi_u8 v_dfcoef[HIFB_DEFLICKER_LEVEL_MAX - 1];   /* vertical deflicker coefficients */
201     volatile hi_u32 vblflag;
202     wait_queue_head_t vbl_event;
203     wait_queue_head_t do_refresh_job;
204     spinlock_t lock;
205     hi_bool layer_open;
206     hi_u64 rotate_vb;
207 } hifb_par;
208 
209 typedef enum {
210     HIFB_LAYER_TYPE_HD,
211     HIFB_LAYER_TYPE_SD,
212     HIFB_LAYER_TYPE_AD,
213     HIFB_LAYER_TYPE_CURSOR,
214     HIFB_LAYER_TYPE_BUTT,
215 } hifb_layer_type;
216 
217 typedef struct {
218     struct fb_bitfield red;   /* bitfield in fb mem if true color, */
219     struct fb_bitfield green; /* else only length is significant */
220     struct fb_bitfield blue;
221     struct fb_bitfield transp; /* transparency   */
222 } hifb_argb_bitinfo;
223 
224 typedef struct {
225     hi_u32 layer_id;
226     hi_bool soft_cursor_update;
227     hi_bool compress; /* if this tde task is compress output */
228 } hifb_tde_callback_param;
229 
230 bool hifb_update_rotate_rect(hi_void);
231 extern hi_void *hifb_buf_map(hi_u64 phy_addr, hi_u32 size);
232 extern hi_s32 tde_cal_scale_rect_hifb(const hi_tde_rect *src_rect, const hi_tde_rect *dst_rect,
233                                       hi_tde_rect *rect_in_src, hi_tde_rect *rect_in_dst);
234 
235 typedef enum {
236     HIFB_MAIN_INTF_VO,
237     HIFB_MAIN_INTF_MAX
238 } hifb_main_intf_type;
239 
240 typedef int (*hifb_main_gfx_cb)(hi_u32 layer_id, hifb_main_intf_type type, void *para);
241 
242 int hifb_main_reg_callback(hi_u32 layer_id, hifb_main_intf_type type, hifb_main_gfx_cb cb);
243 
244 #endif /* __HIFB_MAIN_H__ */
245