This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit bcd979b2d3db5e6467def5b85dd291366231ea86
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Mon Sep 11 09:34:20 2023 +0200

    lvgl/lcd_itf: Pass coordinate to lcd_itf_write_color_data
    
    Previously lcd_itf_write_color_data() only received pixel data and
    number of bytes to write.
    Now size is change to x-y coordinates that is needed for some drivers.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/drivers/display/lcd_itf/include/lcd_itf.h       | 2 +-
 hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c | 3 ++-
 hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c   | 3 ++-
 hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c    | 9 +--------
 hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c  | 9 +--------
 hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c  | 9 +--------
 hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c  | 9 +--------
 hw/drivers/display/lvgl/tft/st7789/src/st7789.c    | 9 +--------
 8 files changed, 10 insertions(+), 43 deletions(-)

diff --git a/hw/drivers/display/lcd_itf/include/lcd_itf.h 
b/hw/drivers/display/lcd_itf/include/lcd_itf.h
index dfa7f0256..b720f0055 100644
--- a/hw/drivers/display/lcd_itf/include/lcd_itf.h
+++ b/hw/drivers/display/lcd_itf/include/lcd_itf.h
@@ -96,6 +96,6 @@ void lcd_itf_init(void);
 
 /* Function implemented by LCD interface driver */
 void lcd_ift_write_cmd(const uint8_t *cmd, int cmd_length);
-void lcd_itf_write_color_data(const void *data, size_t size);
+void lcd_itf_write_color_data(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t 
y2, const void *pixels);
 
 #endif /* LCD_ITF_H */
diff --git a/hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c 
b/hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c
index 2df025c6b..6400331c3 100644
--- a/hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c
+++ b/hw/drivers/display/lcd_itf/itf_8080/src/itf_8080.c
@@ -91,9 +91,10 @@ lcd_itf_write_bytes(const uint8_t *bytes, size_t size)
 }
 
 void
-lcd_itf_write_color_data(const void *pixels, size_t size)
+lcd_itf_write_color_data(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, 
const void *pixels)
 {
     const uint16_t *data = (const uint16_t *)pixels;
+    size_t size = (x2 - x1 + 1) * (y2 - y1 + 1) * 2;
 
     LCD_DC_PIN_DATA();
     LCD_CS_PIN_ACTIVE();
diff --git a/hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c 
b/hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c
index a8b44c5e8..294d678d7 100644
--- a/hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c
+++ b/hw/drivers/display/lcd_itf/itf_spi/src/itf_spi.c
@@ -38,10 +38,11 @@ static uint8_t *lv_color_16_swap_buffer;
 static size_t lv_color_16_swap_buffer_size;
 
 void
-lcd_itf_write_color_data(const void *pixels, size_t size)
+lcd_itf_write_color_data(uint16_t x1, uint16_t x2, uint16_t y1, uint16_t y2, 
const void *pixels)
 {
     const void *color_data = pixels;
     size_t i;
+    size_t size = (x2 - x1 + 1) * (y2 - y1 + 1) * 2;
 
     LCD_DC_PIN_DATA();
     LCD_CS_PIN_ACTIVE();
diff --git a/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c 
b/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
index 87a8c8a5d..5e1988389 100644
--- a/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
+++ b/hw/drivers/display/lvgl/tft/gc9a01/src/gc9a01.c
@@ -204,8 +204,6 @@ gc9a01_drv_update(struct _lv_disp_drv_t *drv)
 void
 gc9a01_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
 {
-    int32_t y;
-    lv_coord_t w;
     uint8_t cmd[5];
 
     if (area->x2 < 0 || area->y2 < 0 || area->x1 >= GC9A01_HOR_RES || area->y1 
>= GC9A01_VER_RES) {
@@ -219,8 +217,6 @@ gc9a01_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     int32_t act_x2 = area->x2 >= GC9A01_HOR_RES ? GC9A01_HOR_RES - 1 : 
area->x2;
     int32_t act_y2 = area->y2 >= GC9A01_VER_RES ? GC9A01_VER_RES - 1 : 
area->y2;
 
-    w = lv_area_get_width(area);
-
     /* Column address */
     cmd[0] = GC9A01_CASET;
     cmd[1] = (uint8_t)(act_x1 >> 8);
@@ -240,10 +236,7 @@ gc9a01_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     cmd[0] = GC9A01_RAMWR;
     lcd_ift_write_cmd(cmd, 1);
 
-    for (y = act_y1; y <= act_y2; y++) {
-        lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
-        color_p += w;
-    }
+    lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);
 
     lv_disp_flush_ready(drv);
 }
diff --git a/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c 
b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
index 5f3a3e293..e6e8a0f0d 100644
--- a/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
+++ b/hw/drivers/display/lvgl/tft/ili9341/src/ili9341.c
@@ -206,9 +206,7 @@ ili9341_drv_update(struct _lv_disp_drv_t *drv)
 void
 ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
 {
-    int32_t y;
     uint8_t cmd[5];
-    lv_coord_t w;
 
     if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9341_HOR_RES || 
area->y1 >= ILI9341_VER_RES) {
         lv_disp_flush_ready(drv);
@@ -221,8 +219,6 @@ ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     int32_t act_x2 = area->x2 >= ILI9341_HOR_RES ? ILI9341_HOR_RES - 1 : 
area->x2;
     int32_t act_y2 = area->y2 >= ILI9341_VER_RES ? ILI9341_VER_RES - 1 : 
area->y2;
 
-    w = lv_area_get_width(area);
-
     /* Column address */
     cmd[0] = ILI9341_CASET;
     cmd[1] = (uint8_t)(act_x1 >> 8);
@@ -242,10 +238,7 @@ ili9341_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     cmd[0] = ILI9341_RAMWR;
     lcd_ift_write_cmd(cmd, 1);
 
-    for (y = act_y1; y <= act_y2; y++) {
-        lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
-        color_p += w;
-    }
+    lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);
 
     lv_disp_flush_ready(drv);
 }
diff --git a/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c 
b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
index 73eabb4eb..01cc42244 100644
--- a/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
+++ b/hw/drivers/display/lvgl/tft/ili9486/src/ili9486.c
@@ -189,8 +189,6 @@ ili9486_drv_update(struct _lv_disp_drv_t *drv)
 void
 ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
 {
-    int32_t y;
-    lv_coord_t w;
     uint8_t cmd[5];
 
     if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ILI9486_HOR_RES || 
area->y1 >= ILI9486_VER_RES) {
@@ -204,8 +202,6 @@ ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     int32_t act_x2 = area->x2 >= ILI9486_HOR_RES ? ILI9486_HOR_RES - 1 : 
area->x2;
     int32_t act_y2 = area->y2 >= ILI9486_VER_RES ? ILI9486_VER_RES - 1 : 
area->y2;
 
-    w = lv_area_get_width(area);
-
     /* Column address */
     cmd[0] = ILI9486_CASET;
     cmd[1] = (uint8_t)(act_x1 >> 8);
@@ -225,10 +221,7 @@ ili9486_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     cmd[0] = ILI9486_RAMWR;
     lcd_ift_write_cmd(cmd, 1);
 
-    for (y = act_y1; y <= act_y2; y++) {
-        lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
-        color_p += w;
-    }
+    lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);
 
     lv_disp_flush_ready(drv);
 }
diff --git a/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c 
b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
index c7b79d1d9..ae4f7cca6 100644
--- a/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
+++ b/hw/drivers/display/lvgl/tft/st7735s/src/st7735s.c
@@ -182,8 +182,6 @@ st7735s_drv_update(struct _lv_disp_drv_t *drv)
 void
 st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
 {
-    int32_t y;
-    lv_coord_t w;
     uint8_t cmd[5];
 
     if (area->x2 < 0 || area->y2 < 0 || area->x1 >= ST7735S_HOR_RES || 
area->y1 >= ST7735S_VER_RES) {
@@ -197,8 +195,6 @@ st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     int32_t act_x2 = area->x2 >= ST7735S_HOR_RES ? ST7735S_HOR_RES - 1 : 
area->x2;
     int32_t act_y2 = area->y2 >= ST7735S_VER_RES ? ST7735S_VER_RES - 1 : 
area->y2;
 
-    w = lv_area_get_width(area);
-
     /* Column address */
     cmd[0] = ST7735S_CASET;
     cmd[1] = (uint8_t)(act_x1 >> 8);
@@ -218,10 +214,7 @@ st7735s_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     cmd[0] = ST7735S_RAMWR;
     lcd_ift_write_cmd(cmd, 1);
 
-    for (y = act_y1; y <= act_y2; y++) {
-        lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
-        color_p += w;
-    }
+    lcd_itf_write_color_data(act_x1, act_x2, act_y1, act_y2, color_p);
 
     lv_disp_flush_ready(drv);
 }
diff --git a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c 
b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
index 54ddefef7..cbdb99d32 100644
--- a/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
+++ b/hw/drivers/display/lvgl/tft/st7789/src/st7789.c
@@ -208,8 +208,6 @@ st7789_drv_update(struct _lv_disp_drv_t *drv)
 void
 st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_p)
 {
-    int32_t y;
-    lv_coord_t w;
     uint8_t cmd[5];
 
     /* Truncate the area to the screen */
@@ -250,8 +248,6 @@ st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
 #endif
 #endif
 
-    w = lv_area_get_width(area);
-
     /* Column addresses */
     cmd[0] = ST7789_CASET;
     cmd[1] = (uint8_t)(offsetx1 >> 8);
@@ -271,10 +267,7 @@ st7789_flush(lv_disp_drv_t *drv, const lv_area_t *area, 
lv_color_t *color_p)
     cmd[0] = ST7789_RAMWR;
     lcd_ift_write_cmd(cmd, 1);
 
-    for (y = offsety1; y <= offsety2; y++) {
-        lcd_itf_write_color_data(color_p, w * sizeof(*color_p));
-        color_p += w;
-    }
+    lcd_itf_write_color_data(offsetx1, offsetx2, offsety1, offsety2, color_p);
 
     lv_disp_flush_ready(drv);
 }

Reply via email to