embox

Форк
0
/
display_port_memcpy.c 
66 строк · 1.8 Кб
1
/**
2
 * @file
3
 * @brief LVGL display interface port
4
 * @defails Based on lv_drivers/display/fbdev.c
5
 *
6
 * @date 15.02.2021
7
 * @author Alexander Kalmuk
8
 */
9

10
#include <unistd.h>
11
#include <util/log.h>
12
#include <drivers/video/fb.h>
13

14
#include "lvgl.h"
15

16
extern uint8_t *lv_fbp;
17
extern struct fb_var_screeninfo lv_vinfo;
18
extern struct fb_fix_screeninfo lv_finfo;
19

20
void lvgl_port_fbdev_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area,
21
	    lv_color_t *color_p) {
22
	int32_t act_x1, act_y1, act_x2, act_y2;
23
	long int location = 0;
24
	lv_coord_t w;
25

26
	if (lv_fbp == NULL ||
27
		    area->x2 < 0 ||
28
		    area->y2 < 0 ||
29
		    area->x1 > (int32_t)lv_vinfo.xres - 1 ||
30
		    area->y1 > (int32_t)lv_vinfo.yres - 1) {
31
		lv_disp_flush_ready(disp_drv);
32
		return;
33
	}
34

35
	/* Truncate the area to the screen */
36
	act_x1 = area->x1 < 0 ? 0 : area->x1;
37
	act_y1 = area->y1 < 0 ? 0 : area->y1;
38
	act_x2 = area->x2 > (int32_t)lv_vinfo.xres - 1 ? (int32_t)lv_vinfo.xres - 1 : area->x2;
39
	act_y2 = area->y2 > (int32_t)lv_vinfo.yres - 1 ? (int32_t)lv_vinfo.yres - 1 : area->y2;
40

41
	w = (act_x2 - act_x1 + 1);
42

43
	if (lv_vinfo.bits_per_pixel == 32 || lv_vinfo.bits_per_pixel == 24) {
44
		uint32_t * lv_fbp32 = (uint32_t *)lv_fbp;
45
		int32_t y;
46

47
		for(y = act_y1; y <= act_y2; y++) {
48
			location = (act_x1 + lv_vinfo.xoffset) + (y + lv_vinfo.yoffset) * lv_finfo.line_length / 4;
49
			memcpy(&lv_fbp32[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 4);
50
			color_p += w;
51
		}
52
	} else if (lv_vinfo.bits_per_pixel == 16) {
53
		uint16_t * lv_fbp16 = (uint16_t *)lv_fbp;
54
		int32_t y;
55

56
		for(y = act_y1; y <= act_y2; y++) {
57
			location = (act_x1 + lv_vinfo.xoffset) + (y + lv_vinfo.yoffset) * lv_finfo.line_length / 2;
58
			memcpy(&lv_fbp16[location], (uint32_t *)color_p, (act_x2 - act_x1 + 1) * 2);
59
			color_p += w;
60
		}
61
	} else {
62
		log_error("Unsupported bits_per_pixel=%d", lv_vinfo.bits_per_pixel);
63
	}
64

65
	lv_disp_flush_ready(disp_drv);
66
}
67

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.