From 4136d425963617dfe53b782c784bf732c231e759 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 23 Jul 2020 12:27:14 +0800 Subject: [PATCH] Change FBIO_UPDATE argument from nxgl_rect_s to fb_area_s Signed-off-by: Xiang Xiao Change-Id: Ibaf4b0180afecdcd3248693a3092c8a23e22a2fa --- examples/fb/fb_main.c | 94 +++++++++++++++--------------- examples/lvgldemo/fbdev.c | 50 ++++++++-------- graphics/pdcurs34/nuttx/pdcdisp.c | 96 +++++++++++++++---------------- 3 files changed, 119 insertions(+), 121 deletions(-) diff --git a/examples/fb/fb_main.c b/examples/fb/fb_main.c index 96edbcff4..86a6b1390 100644 --- a/examples/fb/fb_main.c +++ b/examples/fb/fb_main.c @@ -47,8 +47,6 @@ #include #include -#include -#include #include #include @@ -83,17 +81,20 @@ static const char g_default_fbdev[] = CONFIG_EXAMPLES_FB_DEFAULTFB; static const uint32_t g_rgb24[NCOLORS] = { - RGB24_VIOLET, RGB24_BLUE, RGB24_GREEN, RGB24_YELLOW, RGB24_ORANGE, RGB24_RED + RGB24_VIOLET, RGB24_BLUE, RGB24_GREEN, + RGB24_YELLOW, RGB24_ORANGE, RGB24_RED }; static const uint16_t g_rgb16[NCOLORS] = { - RGB16_VIOLET, RGB16_BLUE, RGB16_GREEN, RGB16_YELLOW, RGB16_ORANGE, RGB16_RED + RGB16_VIOLET, RGB16_BLUE, RGB16_GREEN, + RGB16_YELLOW, RGB16_ORANGE, RGB16_RED }; static const uint8_t g_rgb8[NCOLORS] = { - RGB8_VIOLET, RGB8_BLUE, RGB8_GREEN, RGB8_YELLOW, RGB8_ORANGE, RGB8_RED + RGB8_VIOLET, RGB8_BLUE, RGB8_GREEN, + RGB8_YELLOW, RGB8_ORANGE, RGB8_RED }; /**************************************************************************** @@ -105,18 +106,18 @@ static const uint8_t g_rgb8[NCOLORS] = ****************************************************************************/ static void draw_rect32(FAR struct fb_state_s *state, - FAR struct nxgl_rect_s *rect, int color) + FAR struct fb_area_s *area, int color) { FAR uint32_t *dest; FAR uint8_t *row; int x; int y; - row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * rect->pt1.y; - for (y = rect->pt1.y; y <= rect->pt2.y; y++) + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; + for (y = 0; y < area->h; y++) { - dest = ((FAR uint32_t *)row) + rect->pt1.x; - for (x = rect->pt1.x; x <= rect->pt2.x; x++) + dest = ((FAR uint32_t *)row) + area->x; + for (x = 0; x < area->w; x++) { *dest++ = g_rgb24[color]; } @@ -126,18 +127,18 @@ static void draw_rect32(FAR struct fb_state_s *state, } static void draw_rect16(FAR struct fb_state_s *state, - FAR struct nxgl_rect_s *rect, int color) + FAR struct fb_area_s *area, int color) { FAR uint16_t *dest; FAR uint8_t *row; int x; int y; - row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * rect->pt1.y; - for (y = rect->pt1.y; y <= rect->pt2.y; y++) + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; + for (y = 0; y < area->h; y++) { - dest = ((FAR uint16_t *)row) + rect->pt1.x; - for (x = rect->pt1.x; x <= rect->pt2.x; x++) + dest = ((FAR uint16_t *)row) + area->x; + for (x = 0; x < area->w; x++) { *dest++ = g_rgb16[color]; } @@ -147,18 +148,18 @@ static void draw_rect16(FAR struct fb_state_s *state, } static void draw_rect8(FAR struct fb_state_s *state, - FAR struct nxgl_rect_s *rect, int color) + FAR struct fb_area_s *area, int color) { FAR uint8_t *dest; FAR uint8_t *row; int x; int y; - row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * rect->pt1.y; - for (y = rect->pt1.y; y <= rect->pt2.y; y++) + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; + for (y = 0; y < area->h; y++) { - dest = row + rect->pt1.x; - for (x = rect->pt1.x; x <= rect->pt2.x; x++) + dest = row + area->x; + for (x = 0; x < area->w; x++) { *dest++ = g_rgb8[color]; } @@ -168,7 +169,7 @@ static void draw_rect8(FAR struct fb_state_s *state, } static void draw_rect1(FAR struct fb_state_s *state, - FAR struct nxgl_rect_s *rect, int color) + FAR struct fb_area_s *area, int color) { FAR uint8_t *pixel; FAR uint8_t *row; @@ -182,7 +183,7 @@ static void draw_rect1(FAR struct fb_state_s *state, /* Calculate the framebuffer address of the first row to draw on */ - row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * rect->pt1.y; + row = (FAR uint8_t *)state->fbmem + state->pinfo.stride * area->y; /* Calculate the start byte position rounding down so that we get the * first byte containing any part of the pixel sequence. Then calculate @@ -190,19 +191,19 @@ static void draw_rect1(FAR struct fb_state_s *state, * final pixels of the sequence. */ - startx = (rect->pt1.x >> 3); - endx = ((rect->pt2.x + 7) >> 3); + startx = (area->x >> 3); + endx = ((area->x + area->w + 6) >> 3); /* Calculate a mask on the first and last bytes of the sequence that may * not be completely filled with pixel. */ - lmask = 0xff << (8 - (rect->pt1.x & 7)); - rmask = 0xff >> (rect->pt2.x & 7); + lmask = 0xff << (8 - (area->x & 7)); + rmask = 0xff >> ((area->x + area->w - 1) & 7); /* Now draw each row, one-at-a-time */ - for (y = rect->pt1.y; y <= rect->pt2.y; y++) + for (y = 0; y < area->h; y++) { /* 'pixel' points to the 1st pixel the next row */ @@ -218,7 +219,6 @@ static void draw_rect1(FAR struct fb_state_s *state, } else { - /* Special case the first byte of the row */ *pixel = (*pixel & lmask) | (color8 & ~lmask); @@ -234,42 +234,42 @@ static void draw_rect1(FAR struct fb_state_s *state, /* Handle the final byte of the row */ *pixel = (*pixel & rmask) | (color8 & ~rmask); - } + } row += state->pinfo.stride; } } static void draw_rect(FAR struct fb_state_s *state, - FAR struct nxgl_rect_s *rect, int color) + FAR struct fb_area_s *area, int color) { -#ifdef CONFIG_LCD_UPDATE +#ifdef CONFIG_FB_UPDATE int ret; #endif switch (state->pinfo.bpp) { case 32: - draw_rect32(state, rect, color); + draw_rect32(state, area, color); break; case 16: - draw_rect16(state, rect, color); + draw_rect16(state, area, color); break; case 8: default: - draw_rect8(state, rect, color); + draw_rect8(state, area, color); break; case 1: - draw_rect1(state, rect, color); + draw_rect1(state, area, color); break; } -#ifdef CONFIG_LCD_UPDATE +#ifdef CONFIG_FB_UPDATE ret = ioctl(state->fd, FBIO_UPDATE, - (unsigned long)((uintptr_t)rect)); + (unsigned long)((uintptr_t)area)); if (ret < 0) { int errcode = errno; @@ -291,7 +291,7 @@ int main(int argc, FAR char *argv[]) { FAR const char *fbdev = g_default_fbdev; struct fb_state_s state; - struct nxgl_rect_s rect; + struct fb_area_s area; int nsteps; int xstep; int ystep; @@ -429,8 +429,8 @@ int main(int argc, FAR char *argv[]) * address mapping to make the memory accessible to the application. */ - state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ|PROT_WRITE, - MAP_SHARED|MAP_FILE, state.fd, 0); + state.fbmem = mmap(NULL, state.pinfo.fblen, PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FILE, state.fd, 0); if (state.fbmem == MAP_FAILED) { int errcode = errno; @@ -454,16 +454,16 @@ int main(int argc, FAR char *argv[]) color < NCOLORS; x += xstep, y += ystep, color++) { - rect.pt1.x = x; - rect.pt1.y = y; - rect.pt2.x = x + width - 1; - rect.pt2.y = y + height - 1; + area.x = x; + area.y = y; + area.w = width; + area.h = height; printf("%2d: (%3d,%3d) (%3d,%3d)\n", - color, rect.pt1.x, rect.pt1.y, rect.pt2.x, rect.pt2.y); + color, area.x, area.y, area.w, area.h); - draw_rect(&state, &rect, color); - usleep(500*1000); + draw_rect(&state, &area, color); + usleep(500 * 1000); width -= (2 * xstep); height -= (2 * ystep); diff --git a/examples/lvgldemo/fbdev.c b/examples/lvgldemo/fbdev.c index e462c60ad..c7f59e7f9 100644 --- a/examples/lvgldemo/fbdev.c +++ b/examples/lvgldemo/fbdev.c @@ -49,8 +49,6 @@ #include #include -#include -#include #include #include @@ -208,8 +206,8 @@ int fbdev_init(void) void fbdev_flush(struct _disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p) { -#ifdef CONFIG_LCD_UPDATE - struct nxgl_rect_s rect; +#ifdef CONFIG_FB_UPDATE + struct fb_area_s area; #endif int32_t x1 = area->x1; int32_t y1 = area->y1; @@ -312,12 +310,12 @@ void fbdev_flush(struct _disp_drv_t *disp_drv, const lv_area_t *area, } } -#ifdef CONFIG_LCD_UPDATE - rect.pt1.x = act_x1; - rect.pt1.y = act_y1; - rect.pt2.x = act_x2; - rect.pt2.y = act_y2; - ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&rect)); +#ifdef CONFIG_FB_UPDATE + area.x = act_x1; + area.y = act_y1; + area.w = act_x2 - act_x1 + 1; + area.h = act_y2 - cat_y1 + 1; + ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&area)); #endif /* Tell the flushing is ready */ @@ -346,8 +344,8 @@ void fbdev_flush(struct _disp_drv_t *disp_drv, const lv_area_t *area, void fbdev_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) { -#ifdef CONFIG_LCD_UPDATE - struct nxgl_rect_s rect; +#ifdef CONFIG_FB_UPDATE + struct fb_area_s area; #endif int32_t act_x1; int32_t act_y1; @@ -437,12 +435,12 @@ void fbdev_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, } } -#ifdef CONFIG_LCD_UPDATE - rect.pt1.x = act_x1; - rect.pt1.y = act_y1; - rect.pt2.x = act_x2; - rect.pt2.y = act_y2; - ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&rect)); +#ifdef CONFIG_FB_UPDATE + area.x = act_x1; + area.y = act_y1; + area.w = act_x2 - act_x1 + 1; + area.h = act_y2 - act_y1 + 1; + ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&area)); #endif } @@ -467,8 +465,8 @@ void fbdev_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, void fbdev_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, FAR const lv_color_t *color_p) { -#ifdef CONFIG_LCD_UPDATE - struct nxgl_rect_s rect; +#ifdef CONFIG_FB_UPDATE + struct fb_area_s area; #endif int32_t act_x1; int32_t act_y1; @@ -567,11 +565,11 @@ void fbdev_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, } } -#ifdef CONFIG_LCD_UPDATE - rect.pt1.x = act_x1; - rect.pt1.y = act_y1; - rect.pt2.x = act_x2; - rect.pt2.y = act_y2; - ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&rect)); +#ifdef CONFIG_FB_UPDATE + area.x = act_x1; + area.y = act_y1; + area.w = act_x2 - act_x1 + 1; + area.h = act_y2 - act_y1 + 1; + ioctl(state.fd, FBIO_UPDATE, (unsigned long)((uintptr_t)&area)); #endif } diff --git a/graphics/pdcurs34/nuttx/pdcdisp.c b/graphics/pdcurs34/nuttx/pdcdisp.c index 01a1ea244..d711bd6dd 100644 --- a/graphics/pdcurs34/nuttx/pdcdisp.c +++ b/graphics/pdcurs34/nuttx/pdcdisp.c @@ -508,26 +508,26 @@ static inline void PDC_copy_glyph(FAR struct pdc_fbstate_s *fbstate, * ****************************************************************************/ -#ifdef CONFIG_LCD_UPDATE +#ifdef CONFIG_FB_UPDATE static void PDC_update(FAR struct pdc_fbstate_s *fbstate, int row, int col, int nchars) { - struct nxgl_rect_s rect; + struct fb_area_s area; int ret; if (nchars > 0) { /* Setup the bounding rectangle */ - rect.pt1.x = PDC_pixel_x(fbstate, col); - rect.pt1.y = PDC_pixel_y(fbstate, row); - rect.pt2.x = rect.pt1.x + nchars * fbstate->fwidth - 1; - rect.pt2.y = rect.pt1.y + fbstate->fheight - 1; + area.x = PDC_pixel_x(fbstate, col); + area.y = PDC_pixel_y(fbstate, row); + area.w = nchars * fbstate->fwidth; + area.h = fbstate->fheight; /* Then perform the update via IOCTL */ ret = ioctl(fbstate->fbfd, FBIO_UPDATE, - (unsigned long)((uintptr_t)&rect)); + (unsigned long)((uintptr_t)&area)); if (ret < 0) { PDC_LOG(("ERROR: ioctl(FBIO_UPDATE) failed: %d\n", errno)); @@ -569,20 +569,20 @@ static void PDC_putc(FAR struct pdc_fbstate_s *fbstate, int row, int col, return; } - /* Get the foreground and background colors of the character */ + /* Get the foreground and background colors of the character */ - PDC_pair_content(PAIR_NUMBER(ch), &fg, &bg); + PDC_pair_content(PAIR_NUMBER(ch), &fg, &bg); - /* Handle the A_REVERSE attribute. */ + /* Handle the A_REVERSE attribute. */ - if ((ch & A_REVERSE) != 0) - { - /* Swap the foreground and background colors if reversed */ + if ((ch & A_REVERSE) != 0) + { + /* Swap the foreground and background colors if reversed */ - short tmp = fg; - fg = bg; - bg = tmp; - } + short tmp = fg; + fg = bg; + bg = tmp; + } #ifdef CONFIG_PDCURSES_CHTYPE_LONG /* Translate characters 0-127 via acs_map[], if they're flagged with @@ -668,9 +668,9 @@ static void PDC_putc(FAR struct pdc_fbstate_s *fbstate, int row, int col, ****************************************************************************/ #ifdef CONFIG_SYSTEM_TERMCURSES -static void PDC_gotoyx_term(FAR SCREEN *sp, int row, int col) +static void PDC_gotoyx_term(FAR SCREEN *s, int row, int col) { - FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp; + FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)s; FAR struct pdc_termstate_s *termstate; termstate = &termscreen->termstate; @@ -741,16 +741,16 @@ static void PDC_set_char_attrib_term(FAR struct pdc_termscreen_s *termscreen, PDC_pair_content(PAIR_NUMBER(ch), &fg, &bg); - /* Handle the A_REVERSE attribute. */ + /* Handle the A_REVERSE attribute. */ - if ((ch & A_REVERSE) != 0) - { - /* Swap the foreground and background colors if reversed */ + if ((ch & A_REVERSE) != 0) + { + /* Swap the foreground and background colors if reversed */ - short tmp = fg; - fg = bg; - bg = tmp; - } + short tmp = fg; + fg = bg; + bg = tmp; + } /* Set the color */ @@ -809,7 +809,6 @@ static void PDC_set_char_attrib_term(FAR struct pdc_termscreen_s *termscreen, termstate->bg_green = termstate->rgbcolor[bg].green; termstate->bg_blue = termstate->rgbcolor[bg].blue; } - } #endif /* CONFIG_SYSTEM_TERMCURSES */ @@ -819,17 +818,17 @@ static void PDC_set_char_attrib_term(FAR struct pdc_termscreen_s *termscreen, * Description: * The core output routine. It takes len chtype entities from srcp (a * pointer into curscr) and renders them to the physical screen at line - * lineno, column x. It must also translate characters 0-127 via acs_map[], + * lineno, column x. It must also translate characters 0-127 via acs_map[], * if they're flagged with A_ALTCHARSET in the attribute portion of the * chtype. * ****************************************************************************/ #ifdef CONFIG_SYSTEM_TERMCURSES -static void PDC_transform_line_term(FAR SCREEN *sp, int lineno, int x, +static void PDC_transform_line_term(FAR SCREEN *s, int lineno, int x, int len, FAR const chtype *srcp) { - FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)sp; + FAR struct pdc_termscreen_s *termscreen = (FAR struct pdc_termscreen_s *)s; FAR struct pdc_termstate_s *termstate = &termscreen->termstate; int c; int i; @@ -842,7 +841,7 @@ static void PDC_transform_line_term(FAR SCREEN *sp, int lineno, int x, /* Loop through all characters to be displayed */ - for (c = 0; c < len;) + for (c = 0; c < len; ) { /* Get the foreground and background colors of the character */ @@ -850,10 +849,10 @@ static void PDC_transform_line_term(FAR SCREEN *sp, int lineno, int x, /* Write next character(s) */ - ch = *srcp & 0x7F; + ch = *srcp & 0x7f; buffer[0] = ch; - for (i = 1; i < sizeof(buffer) && c+i < len; i++) + for (i = 1; i < sizeof(buffer) && c + i < len; i++) { /* Break if the attributes change */ @@ -862,7 +861,7 @@ static void PDC_transform_line_term(FAR SCREEN *sp, int lineno, int x, break; } - ch = *(srcp + i) & 0x7F; + ch = *(srcp + i) & 0x7f; buffer[i] = ch; } @@ -950,7 +949,7 @@ void PDC_gotoyx(int row, int col) * Description: * The core output routine. It takes len chtype entities from srcp (a * pointer into curscr) and renders them to the physical screen at line - * lineno, column x. It must also translate characters 0-127 via acs_map[], + * lineno, column x. It must also translate characters 0-127 via acs_map[], * if they're flagged with A_ALTCHARSET in the attribute portion of the * chtype. * @@ -1019,8 +1018,8 @@ void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate) int row; int col; -#ifdef CONFIG_LCD_UPDATE - struct nxgl_rect_s rect; +#ifdef CONFIG_FB_UPDATE + struct fb_area_s area; int ret; #endif @@ -1057,26 +1056,27 @@ void PDC_clear_screen(FAR struct pdc_fbstate_s *fbstate) row < fbstate->yres; row++, line += fbstate->stride) { - for (col = 0, dest = (FAR pdc_color_t *)line; + for (col = 0, dest = (FAR pdc_color_t *)line; col < width; col++) - { - *dest++ = bgcolor; - } + { + *dest++ = bgcolor; + } } -#ifdef CONFIG_LCD_UPDATE +#ifdef CONFIG_FB_UPDATE /* Update the entire display */ + /* Setup the bounding rectangle */ - rect.pt1.x = 0; - rect.pt1.y = 0; - rect.pt2.x = fbstate->xres - 1; - rect.pt2.y = fbstate->yres - 1; + area.x = 0; + area.y = 0; + area.w = fbstate->xres; + area.h = fbstate->yres; /* Then perform the update via IOCTL */ - ret = ioctl(fbstate->fbfd, FBIO_UPDATE, (unsigned long)((uintptr_t)&rect)); + ret = ioctl(fbstate->fbfd, FBIO_UPDATE, (unsigned long)((uintptr_t)&area)); if (ret < 0) { PDC_LOG(("ERROR: ioctl(FBIO_UPDATE) failed: %d\n", errno));