• 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 <soc/soc.h>
18 #include "hal_port.h"
19 #include "lcd_disp_hw.h"
20 #include "lcd_disp_types.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #define LCD_LL_REG_BASE    (SOC_LCD_DISP_REG_BASE)
27 
28 #define reg0  (LCD_LL_REG_BASE  + 0x0*4) //REG ADDR :0x48060000
29 #define reg1  (LCD_LL_REG_BASE  + 0x1*4) //REG ADDR :0x48060004
30 #define reg2  (LCD_LL_REG_BASE  + 0x2*4) //REG ADDR :0x47800000
31 #define reg3  (LCD_LL_REG_BASE  + 0x3*4) //REG ADDR :0x47800000
32 #define reg4  (LCD_LL_REG_BASE  + 0x4*4) //REG ADDR :0x47800000
33 #define reg5  (LCD_LL_REG_BASE  + 0x5*4) //REG ADDR :0x47800000
34 #define reg6  (LCD_LL_REG_BASE  + 0x6*4) //REG ADDR :0x47800000
35 #define reg7  (LCD_LL_REG_BASE  + 0x7*4) //REG ADDR :0x47800000
36 
37 
lcd_disp_reg1_get_value(void)38 static inline uint32_t lcd_disp_reg1_get_value(void)
39 {
40     return REG_READ(reg1);
41 }
42 
lcd_disp_reg0_config_value(uint32_t value)43 static inline void lcd_disp_reg0_config_value(uint32_t value)
44 {
45     REG_WRITE(reg0, value);
46 }
47 
lcd_disp_reg1_config_value(uint32_t value)48 static inline void lcd_disp_reg1_config_value(uint32_t value)
49 {
50     REG_WRITE(reg1, value);
51 }
lcd_disp_reg2_config_value(uint32_t value)52 static inline void lcd_disp_reg2_config_value(uint32_t value)
53 {
54     REG_WRITE(reg2, value);
55 }
lcd_disp_reg3_config_value(uint32_t value)56 static inline void lcd_disp_reg3_config_value(uint32_t value)
57 {
58     REG_WRITE(reg3, value);
59 }
lcd_disp_reg4_config_value(uint32_t value)60 static inline void lcd_disp_reg4_config_value(uint32_t value)
61 {
62     REG_WRITE(reg4, value);
63 }
lcd_disp_reg5_config_value(uint32_t value)64 static inline void lcd_disp_reg5_config_value(uint32_t value)
65 {
66     REG_WRITE(reg5, value);
67 }
lcd_disp_reg6_config_value(uint32_t value)68 static inline void lcd_disp_reg6_config_value(uint32_t value)
69 {
70     REG_WRITE(reg6, value);
71 }
lcd_disp_reg7_config_value(uint32_t value)72 static inline void lcd_disp_reg7_config_value(uint32_t value)
73 {
74     REG_WRITE(reg7, value);
75 }
76 
77 
78 /**-------------------------------------------RGB/I8080 common  API----------------------------------------------------*/
79 /**-------------------------------------------RGB/I8080 common  API----------------------------------------------------*/
80 /**-------------------------------------------RGB/I8080 common  API----------------------------------------------------*/
81 
lcd_display_fifo_clr(lcd_disp_hw_t * hw)82 static inline void lcd_display_fifo_clr(lcd_disp_hw_t *hw)
83 {
84 	hw->i8080_config.i8080_fifo_clr = 1;
85 	hw->i8080_config.i8080_cmdfifo_clr = 1;
86 	hw->status.str_fifo_clr = 1;
87 }
88 
lcd_display_ll_int_en(lcd_disp_hw_t * hw,LCD_INT_TYPE int_type,bool en)89 static inline void lcd_display_ll_int_en(lcd_disp_hw_t *hw, LCD_INT_TYPE int_type, bool en)
90 {
91 	if (I8080_OUTPUT_EOF | int_type) {
92 		hw->display_int.i8080_int_en |= (en << 1);
93 	}
94 
95 	if (I8080_OUTPUT_SOF | int_type) {
96 		hw->display_int.i8080_int_en |= (en << 0);
97 	}
98 
99 	if (RGB_OUTPUT_EOF | int_type) {
100 		hw->display_int.rgb_int_en |= (en << 1);
101 	}
102 
103 	if (RGB_OUTPUT_SOF | int_type) {
104 		hw->display_int.rgb_int_en |= (en << 0);
105 	}
106 }
107 
lcd_display_ll_int_status_get(lcd_disp_hw_t * hw)108 static inline uint32_t lcd_display_ll_int_status_get(lcd_disp_hw_t *hw)
109 {
110 	return hw->display_int.v;
111 }
112 
lcd_display_ll_clear_int_status(lcd_disp_hw_t * hw,LCD_INT_TYPE int_type)113 static inline void lcd_display_ll_clear_int_status(lcd_disp_hw_t *hw, LCD_INT_TYPE int_type)
114 {
115 	if (I8080_OUTPUT_EOF | int_type) {
116 		hw->display_int.i8080_eof = 1;
117 	}
118 	if (I8080_OUTPUT_SOF | int_type) {
119 		hw->display_int.i8080_sof = 1;
120 	}
121 	if (RGB_OUTPUT_EOF | int_type) {
122 		hw->display_int.rgb_eof = 1;
123 	}
124 	if (RGB_OUTPUT_SOF | int_type) {
125 		hw->display_int.rgb_sof = 1;
126 	}
127 }
128 
lcd_display_ll_pixel_config(lcd_disp_hw_t * hw,uint16_t x_pixel,uint16_t y_pixel)129 static inline void lcd_display_ll_pixel_config(lcd_disp_hw_t *hw, uint16_t x_pixel, uint16_t y_pixel )
130 {
131 	hw->status.x_pixel = x_pixel;
132 	hw->status.y_pixel = y_pixel;
133 }
134 
135 
lcd_display_ll_status_get(lcd_disp_hw_t * hw)136 static inline uint32_t lcd_display_ll_status_get(lcd_disp_hw_t *hw)
137 {
138 	return hw->status.v & 0xff;
139 }
140 
141 /**-------------------------------------------I8080  API----------------------------------------------------*/
142 /**-------------------------------------------I8080  API----------------------------------------------------*/
143 /**-------------------------------------------I8080  API----------------------------------------------------*/
lcd_display_ll_8080_display_enable(lcd_disp_hw_t * hw,uint8_t disp_en)144 static inline void lcd_display_ll_8080_display_enable(lcd_disp_hw_t *hw, uint8_t disp_en)
145 {
146 	hw->i8080_config.i8080_disp_en = disp_en;
147 }
148 
149 
lcd_display_ll_8080_data_start_transfer(lcd_disp_hw_t * hw,uint8_t data_start_transfer)150 static inline void lcd_display_ll_8080_data_start_transfer(lcd_disp_hw_t *hw, uint8_t data_start_transfer)
151 {
152 	hw->i8080_config.i8080_dat_on = data_start_transfer;  //set after init
153 }
154 
155 /**
156  * date wr: mpu write data to LCD
157  *date rd:  mpu read data from LCD
158  */
lcd_display_ll_8080_thrd_set(lcd_disp_hw_t * hw,uint32_t thrd_type,uint8_t threshold)159 static inline void lcd_display_ll_8080_thrd_set(lcd_disp_hw_t *hw, uint32_t thrd_type, uint8_t threshold)
160 {
161 	if (DAT_WR_THRD | thrd_type) {
162 		hw->i8080thrd.dat_wr_thrd = threshold;
163 	}
164 	if (CMD_WR_THRD | thrd_type) {
165 		hw->i8080thrd.cmd_wr_thrd = threshold;
166 	}
167 	if (DAT_RD_THRD | thrd_type) {
168 		hw->i8080thrd.dat_rd_thrd = threshold;
169 	}
170 	if (CMD_RD_THRD | thrd_type) {
171 		hw->i8080thrd.cmd_rd_thrd = threshold;
172 	}
173 }
174 
lcd_display_ll_8080_cmd_send(lcd_disp_hw_t * hw,uint16_t cmd)175 static inline void lcd_display_ll_8080_cmd_send(lcd_disp_hw_t *hw, uint16_t cmd)
176 {
177 	hw->i8080_cmd_fifo.i8080_cmd_fifo = cmd;
178 }
179 
lcd_display_ll_8080_fifo_mode(lcd_disp_hw_t * hw,uint8_t fifo_mode)180 static inline void lcd_display_ll_8080_fifo_mode(lcd_disp_hw_t *hw, uint8_t fifo_mode)
181 {
182 	hw->i8080_config.i8080_fifo_mode = fifo_mode;
183 }
184 
lcd_display_ll_8080_data_send(lcd_disp_hw_t * hw,uint16_t data)185 static inline void lcd_display_ll_8080_data_send(lcd_disp_hw_t *hw, uint16_t data)
186 {
187 	hw->i8080_dat_fifo.i8080_dat_fifo = data;
188 }
189 
lcd_display_ll_8080_reset_in_sleep(lcd_disp_hw_t * hw,bool reset)190 static inline void lcd_display_ll_8080_reset_in_sleep(lcd_disp_hw_t *hw, bool reset)
191 {
192 	hw->i8080_config.reset_sleep_in = reset;
193 }
194 
lcd_display_ll_8080_tik_set(lcd_disp_hw_t * hw,uint8_t tik_cnt)195 static inline void lcd_display_ll_8080_tik_set(lcd_disp_hw_t *hw, uint8_t tik_cnt)
196 {
197 	hw->i8080_config.tik_cnt = tik_cnt;
198 }
199 
200 
201 /**-------------------------------------------RGB  API----------------------------------------------------*/
202 /**-------------------------------------------RGB  API----------------------------------------------------*/
203 /**-------------------------------------------RGB  API----------------------------------------------------*/
204 
lcd_display_ll_rgb_enable(lcd_disp_hw_t * hw,bool en)205 static inline void lcd_display_ll_rgb_enable(lcd_disp_hw_t *hw, bool en)
206 {
207 	hw->status.rgb_disp_on = en; //rgb display function on
208 }
209 
lcd_display_ll_rgb_display_on(lcd_disp_hw_t * hw,bool en)210 static inline void lcd_display_ll_rgb_display_on(lcd_disp_hw_t *hw, bool en)
211 {
212 	hw->status.rgb_on = en;  //1: enable rgb output, 0: not rgb output
213 	hw->status.lcd_display_on = en;
214 }
215 
216 
217 
lcd_display_ll_rgb_thrd_set(lcd_disp_hw_t * hw,LCD_RGB_THRD_TYPE thrd_type,uint32_t threshold)218 static inline void lcd_display_ll_rgb_thrd_set(lcd_disp_hw_t *hw, LCD_RGB_THRD_TYPE thrd_type, uint32_t threshold)
219 {
220 	if (WR_THRD | thrd_type) {
221 		hw->display_int.wr_thrd = threshold;
222 	}
223 	if (RD_THRD | thrd_type) {
224 		hw->display_int.rd_thrd = threshold;
225 	}
226 }
lcd_display_ll_rgb_dclk_rev(lcd_disp_hw_t * hw,LCD_RGB_OUTPUT_EDGE edge)227 static inline void lcd_display_ll_rgb_dclk_rev(lcd_disp_hw_t *hw, LCD_RGB_OUTPUT_EDGE edge)
228 {
229 	hw->status.dclk_rev = edge;
230 }
231 
lcd_display_ll_rgb_clk_div(lcd_disp_hw_t * hw,uint8_t clk_div)232 static inline void lcd_display_ll_rgb_clk_div(lcd_disp_hw_t *hw, uint8_t clk_div)
233 {
234 	hw->status.rgb_clk_div = clk_div;
235 }
236 
lcd_display_ll_disconti_mode(lcd_disp_hw_t * hw,bool en)237 static inline void lcd_display_ll_disconti_mode (lcd_disp_hw_t *hw, bool en)
238 {
239 	hw->display_int.disconti_mode = en;
240 }
241 
lcd_display_ll_rgb_write_fifo(lcd_disp_hw_t * hw,uint16_t rgb_data)242 static inline void lcd_display_ll_rgb_write_fifo(lcd_disp_hw_t *hw, uint16_t rgb_data)
243 {
244 	hw->rgb_fifo.rgb_dat = rgb_data;
245 }
246 
lcd_display_ll_rgb_hsync(lcd_disp_hw_t * hw,uint8_t hsync_back_porch,uint8_t hsync_front_porch)247 static inline void lcd_display_ll_rgb_hsync(lcd_disp_hw_t *hw, uint8_t hsync_back_porch,uint8_t hsync_front_porch )
248 {
249 	hw->hsync_vsync.hsync_back_porch = hsync_back_porch;
250 	hw->hsync_vsync.hsync_front_porch = hsync_front_porch;
251 }
252 
lcd_display_ll_rgb_vsync(lcd_disp_hw_t * hw,uint8_t vsync_back_porch,uint8_t vsync_front_porch)253 static inline void lcd_display_ll_rgb_vsync(lcd_disp_hw_t *hw, uint8_t vsync_back_porch, uint8_t vsync_front_porch)
254 {
255 	hw->hsync_vsync.vsync_back_porch = vsync_back_porch;
256 	hw->hsync_vsync.vsync_front_porch = vsync_front_porch;
257 }
258 
lcd_display_ll_rgb_yuv_sel(lcd_disp_hw_t * hw,RGB_DATA_FORMAT data_format)259 static inline void lcd_display_ll_rgb_yuv_sel(lcd_disp_hw_t *hw, RGB_DATA_FORMAT data_format)
260 {
261 	hw->hsync_vsync.yuv_sel = data_format;
262 }
263 
264 #ifdef __cplusplus
265 }
266 #endif
267 
268