提交 5f6729e1 编写于 作者: mysterywolf's avatar mysterywolf

[qemu][lvgl] 优化lvgl显示驱动

上级 1390f7d1
......@@ -36,12 +36,10 @@ config BSP_DRV_MOUSE
if BSP_DRV_CLCD
config BSP_LCD_WIDTH
int "Width of LCD panel"
default 480 if PKG_USING_LV_MUSIC_DEMO
default 640
config BSP_LCD_HEIGHT
int "Height of LCD panel"
default 272 if PKG_USING_LV_MUSIC_DEMO
default 480
endif
......
......@@ -109,7 +109,7 @@ int drv_clcd_hw_init(void)
_lcd.width = CLCD_WIDTH;
_lcd.height = CLCD_HEIGHT;
_lcd.fb = rt_malloc (_lcd.width * _lcd.height * 2);
_lcd.fb = rt_malloc_align(_lcd.width * _lcd.height * 2, 32);
if (_lcd.fb == NULL)
{
rt_kprintf("initialize frame buffer failed!\n");
......
......@@ -13,18 +13,11 @@
/*A static or global variable to store the buffers*/
static lv_disp_draw_buf_t disp_buf;
rt_device_t lcd_device = 0;
static rt_device_t lcd_device = 0;
static struct rt_device_graphic_info info;
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
typedef struct
{
uint8_t blue;
uint8_t green;
uint8_t red;
} lv_color24_t;
static void color_to16_maybe(lv_color16_t *dst, lv_color_t *src)
{
#if (LV_COLOR_DEPTH == 16)
......@@ -36,13 +29,6 @@ static void color_to16_maybe(lv_color16_t *dst, lv_color_t *src)
#endif
}
static void color_to24(lv_color24_t *dst, lv_color_t *src)
{
dst->blue = src->ch.blue;
dst->green = src->ch.green;
dst->red = src->ch.red;
}
/*Flush the content of the internal buffer the specific area on the display
*You can use DMA or any hardware acceleration to do this operation in the background but
*'lv_disp_flush_ready()' has to be called when finished.*/
......@@ -75,76 +61,19 @@ static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_colo
uint32_t y;
long int location = 0;
/* 8 bit per pixel */
if (info.bits_per_pixel == 8)
{
uint8_t *fbp8 = (uint8_t *)info.framebuffer;
//TODO color convert maybe
for (y = act_y1; y <= act_y2; y++)
{
for (x = act_x1; x <= act_x2; x++)
{
location = (x) + (y)*info.width;
fbp8[location] = color_p->full;
color_p++;
}
color_p += x2 - act_x2;
}
}
/* 16 bit per pixel */
else if (info.bits_per_pixel == 16)
{
lv_color16_t *fbp16 = (lv_color16_t *)info.framebuffer;
lv_color16_t *fbp16 = (lv_color16_t *)info.framebuffer;
for (y = act_y1; y <= act_y2; y++)
{
for (x = act_x1; x <= act_x2; x++)
{
location = (x) + (y)*info.width;
color_to16_maybe(&fbp16[location], color_p);
color_p++;
}
color_p += x2 - act_x2;
}
}
/* 24 bit per pixel */
else if (info.bits_per_pixel == 24)
for (y = act_y1; y <= act_y2; y++)
{
lv_color24_t *fbp24 = (lv_color24_t *)info.framebuffer;
for (y = act_y1; y <= act_y2; y++)
for (x = act_x1; x <= act_x2; x++)
{
for (x = act_x1; x <= act_x2; x++)
{
location = (x) + (y)*info.width;
color_to24(&fbp24[location], color_p);
color_p++;
}
color_p += x2 - act_x2;
location = (x) + (y)*info.width;
color_to16_maybe(&fbp16[location], color_p);
color_p++;
}
}
/* 32 bit per pixel */
else if (info.bits_per_pixel == 32)
{
uint32_t *fbp32 = (uint32_t *)info.framebuffer;
//TODO
for (y = act_y1; y <= act_y2; y++)
{
for (x = act_x1; x <= act_x2; x++)
{
location = (x) + (y)*info.width;
fbp32[location] = color_p->full;
color_p++;
}
color_p += x2 - act_x2;
}
color_p += x2 - act_x2;
}
struct rt_device_rect_info rect_info;
......@@ -161,7 +90,7 @@ static void lcd_fb_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_colo
void lv_port_disp_init(void)
{
rt_err_t result;
lv_color_t *fbuf;
lv_color_t *fbuf1, *fbuf2;
lcd_device = rt_device_find("lcd");
if (lcd_device == 0)
......@@ -187,15 +116,23 @@ void lv_port_disp_init(void)
RT_ASSERT(info.bits_per_pixel == 8 || info.bits_per_pixel == 16 ||
info.bits_per_pixel == 24 || info.bits_per_pixel == 32);
fbuf = rt_malloc(info.width * info.height / 10);
if (!fbuf)
fbuf1 = rt_malloc_align(info.width * info.height * sizeof(lv_color_t), 32);
if (fbuf1 == RT_NULL)
{
rt_kprintf("Error: alloc disp buf fail\n");
return;
}
fbuf2 = rt_malloc_align(info.width * info.height * sizeof(lv_color_t), 32);
if (fbuf2 == RT_NULL)
{
rt_kprintf("Error: alloc disp buf fail\n");
rt_free(fbuf1);
return;
}
/*Initialize `disp_buf` with the buffer(s). With only one buffer use NULL instead buf_2 */
lv_disp_draw_buf_init(&disp_buf, fbuf, RT_NULL, info.width * 10);
lv_disp_draw_buf_init(&disp_buf, fbuf1, fbuf2, info.width * info.height);
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册