MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _lcd_drv_init

Function _lcd_drv_init

bsp/allwinner/libraries/drivers/drv_lcd.c:204–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204static int _lcd_drv_init(lcd_device_t lcd_drv)
205{
206 unsigned long arg[6] = {0};
207 void *framebuffer = RT_NULL;
208 void *frontbuf = RT_NULL;
209 void *backbuf = RT_NULL;
210
211 /*
212 * The event is used for the synchronization between updating the
213 * framebuffer and flushing the screen.
214 */
215 rt_event_init(&lcd_drv->lcd_evt, "lcd_evt", RT_IPC_FLAG_FIFO);
216
217 /* the lcd device information defined by RT-Thread */
218 arg[0] = lcd_drv->use_screen;
219 lcd_drv->lcd_info.width = (rt_uint16_t)disp_ioctl(DISP_GET_SCN_WIDTH, arg);
220 lcd_drv->lcd_info.height = (rt_uint16_t)disp_ioctl(DISP_GET_SCN_HEIGHT, arg);
221 lcd_drv->lcd_info.bits_per_pixel = 32;
222 lcd_drv->lcd_info.pixel_format = RTGRAPHIC_PIXEL_FORMAT_ARGB888; /* should be coherent to adding layers */
223
224 /* allocate the framebuffer, the front buffer and the back buffer */
225 /* framebuffer */
226#ifdef RT_USING_SMART
227 framebuffer = rt_pages_alloc(rt_page_bits(LCD_DRV_FB_SZ));
228#else
229 framebuffer = rt_malloc(LCD_DRV_FB_SZ);
230#endif
231 if (!framebuffer)
232 {
233 rt_kprintf("malloc framebuffer fail\n");
234 goto out;
235 }
236 lcd_drv->lcd_info.framebuffer = framebuffer;
237 lcd_drv->framebuffer = framebuffer;
238 lcd_drv->framebuffer_phy = (void *)((size_t)framebuffer + PV_OFFSET);
239 memset(framebuffer, 0, LCD_DRV_FB_SZ);
240 rt_hw_cpu_dcache_clean(lcd_drv->framebuffer, LCD_DRV_FB_SZ);
241#ifdef RT_USING_SMART
242 frontbuf = rt_pages_alloc(rt_page_bits(LCD_DRV_FB_SZ));
243#else
244 frontbuf = rt_malloc(LCD_DRV_FB_SZ);
245#endif
246 if (!frontbuf)
247 {
248 rt_kprintf("malloc frontbuf fail\n");
249 goto out;
250 }
251 lcd_drv->front_buf_info.buff = frontbuf;
252 lcd_drv->front_buf_info.buff_phy = (void *)((size_t)frontbuf + PV_OFFSET);
253 memset(frontbuf, 0, LCD_DRV_FB_SZ);
254 rt_hw_cpu_dcache_clean(lcd_drv->front_buf_info.buff, LCD_DRV_FB_SZ);
255
256 if ((lcd_drv->panel) && (lcd_drv->panel->swap_flag != 0))
257 {
258 /* backbuf */
259#ifdef RT_USING_SMART
260 backbuf = rt_pages_alloc(rt_page_bits(LCD_DRV_FB_SZ));
261#else

Callers 1

rt_lcd_initFunction · 0.85

Calls 9

rt_event_initFunction · 0.85
disp_ioctlFunction · 0.85
rt_pages_allocFunction · 0.85
rt_page_bitsFunction · 0.85
rt_mallocFunction · 0.85
rt_kprintfFunction · 0.85
rt_free_alignFunction · 0.85
rt_freeFunction · 0.85
rt_hw_cpu_dcache_cleanFunction · 0.50

Tested by

no test coverage detected