From f373c97c90e816404c00ab48b2e36b18fd5e6c49 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 30 Sep 2022 10:25:28 +0100 Subject: Define LCD_STRIDEFORMAT unconditionally Instead of putting "#ifdef LCD_STRIDEFORMAT" at every usage of the macro it's simpler to have config.h define LCD_STRIDEFORMAT to the default of horizontal stride when the target leaves it unspecified. Change-Id: Ib187012aad65ac678dbd837b1464a83bad722411 --- firmware/SOURCES | 2 +- firmware/drivers/lcd-1bit-vert.c | 2 +- firmware/drivers/lcd-2bit-horz.c | 2 +- firmware/drivers/lcd-2bit-vert.c | 2 +- firmware/drivers/lcd-2bit-vi.c | 2 +- firmware/drivers/lcd-color-common.c | 2 +- firmware/export/config.h | 8 ++++++-- firmware/export/lcd.h | 4 ++-- firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c | 4 ++-- firmware/target/hosted/sdl/lcd-sdl.c | 6 +++--- 10 files changed, 19 insertions(+), 15 deletions(-) (limited to 'firmware') diff --git a/firmware/SOURCES b/firmware/SOURCES index 49d1d9ac95..abce59fe04 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -300,7 +300,7 @@ drivers/lcd-2bit-vert.c drivers/lcd-2bit-vi.c #endif /* LCD_PIXELFORMAT */ #elif LCD_DEPTH == 16 -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE drivers/lcd-16bit-vert.c #else drivers/lcd-16bit.c diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index ff95eacdbc..e574d4c191 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c @@ -83,7 +83,7 @@ static void *LCDFN(frameaddress_default)(int x, int y) { /* the default expects a buffer the same size as the screen */ struct frame_buffer_t *fb = CURRENT_VP->buffer; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE size_t element = (x * LCDM(NATIVE_STRIDE)(fb->stride)) + y; #else size_t element = (y * LCDM(NATIVE_STRIDE)(fb->stride)) + x; diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index 66313d624b..1bc489247c 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c @@ -81,7 +81,7 @@ static void *lcd_frameaddress_default(int x, int y) /* the default expects a buffer the same size as the screen */ struct frame_buffer_t *fb = lcd_current_viewport->buffer; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE size_t element = (x * LCD_NATIVE_STRIDE(fb->stride)) + y; #else size_t element = (y * LCD_NATIVE_STRIDE(fb->stride)) + x; diff --git a/firmware/drivers/lcd-2bit-vert.c b/firmware/drivers/lcd-2bit-vert.c index 4ce9960419..b206a2d816 100644 --- a/firmware/drivers/lcd-2bit-vert.c +++ b/firmware/drivers/lcd-2bit-vert.c @@ -83,7 +83,7 @@ static void *lcd_frameaddress_default(int x, int y) /* the default expects a buffer the same size as the screen */ struct frame_buffer_t *fb = lcd_current_viewport->buffer; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE size_t element = (x * LCD_NATIVE_STRIDE(fb->stride)) + y; #else size_t element = (y * LCD_NATIVE_STRIDE(fb->stride)) + x; diff --git a/firmware/drivers/lcd-2bit-vi.c b/firmware/drivers/lcd-2bit-vi.c index b969c93216..0bcf60767e 100644 --- a/firmware/drivers/lcd-2bit-vi.c +++ b/firmware/drivers/lcd-2bit-vi.c @@ -95,7 +95,7 @@ static void *LCDFN(frameaddress_default)(int x, int y) { /* the default expects a buffer the same size as the screen */ struct frame_buffer_t *fb = CURRENT_VP->buffer; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE size_t element = (x * LCDM(NATIVE_STRIDE)(fb->stride)) + y; #else size_t element = (y * LCDM(NATIVE_STRIDE)(fb->stride)) + x; diff --git a/firmware/drivers/lcd-color-common.c b/firmware/drivers/lcd-color-common.c index 36144b574c..9feba9f894 100644 --- a/firmware/drivers/lcd-color-common.c +++ b/firmware/drivers/lcd-color-common.c @@ -76,7 +76,7 @@ static void *lcd_frameaddress_default(int x, int y) /* the default expects a buffer the same size as the screen */ struct frame_buffer_t *fb = lcd_current_viewport->buffer; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE size_t element = (x * LCD_NATIVE_STRIDE(fb->stride)) + y; #else size_t element = (y * LCD_NATIVE_STRIDE(fb->stride)) + x; diff --git a/firmware/export/config.h b/firmware/export/config.h index 2519b87f0d..e83194e0f4 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -772,6 +772,11 @@ Lyre prototype 1 */ #define LCD_SPLIT_LINES 0 #endif +/* Most displays have a horizontal stride */ +#ifndef LCD_STRIDEFORMAT +# define LCD_STRIDEFORMAT HORIZONTAL_STRIDE +#endif + /* Simulator LCD dimensions. Set to standard dimensions if undefined */ #ifndef SIM_LCD_WIDTH #define SIM_LCD_WIDTH LCD_WIDTH @@ -978,8 +983,7 @@ Lyre prototype 1 */ || defined(CPU_S5L870X) || (CONFIG_CPU == S3C2440) \ || defined(APPLICATION) || (CONFIG_CPU == PP5002) \ || (CONFIG_CPU == RK27XX) || (CONFIG_CPU == IMX233) || \ - (defined(HAVE_LCD_COLOR) && \ - (!defined(LCD_STRIDEFORMAT) || (LCD_STRIDEFORMAT != VERTICAL_STRIDE))) + (defined(HAVE_LCD_COLOR) && (LCD_STRIDEFORMAT == HORIZONTAL_STRIDE)) #define HAVE_SEMAPHORE_OBJECTS #endif diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 0edef7b866..67b22190ad 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -82,7 +82,7 @@ enum screen_type { struct scrollinfo; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE #define STRIDE_MAIN(w, h) (h) #else #define STRIDE_MAIN(w, h) (w) @@ -496,7 +496,7 @@ typedef void lcd_blockfunc_type(fb_data *address, unsigned mask, unsigned bits); #endif #ifndef LCD_NBELEMS -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE #define LCD_NBELEMS(w, h) (((w-1)*STRIDE_MAIN(w, h)) + h) #else #define LCD_NBELEMS(w, h) (((h-1)*STRIDE_MAIN(w, h)) + w) diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c index d952d3d40d..8620c672e1 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c @@ -38,7 +38,7 @@ #if CONFIG_ORIENTATION == SCREEN_PORTRAIT #define LCD_USE_DMA -#elif defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#elif LCD_STRIDEFORMAT == VERTICAL_STRIDE #define LCD_USE_DMA #endif @@ -511,7 +511,7 @@ void lcd_update_rect(int x, int y, int width, int height) #else -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE #if defined(LCD_USE_DMA) dma_start_transfer16( (char *)FBADDR(0,0), x, y, LCD_HEIGHT, diff --git a/firmware/target/hosted/sdl/lcd-sdl.c b/firmware/target/hosted/sdl/lcd-sdl.c index de19de365a..8cbb6c5651 100644 --- a/firmware/target/hosted/sdl/lcd-sdl.c +++ b/firmware/target/hosted/sdl/lcd-sdl.c @@ -31,9 +31,9 @@ void sdl_update_rect(SDL_Surface *surface, int x_start, int y_start, int width, unsigned long (*getpixel)(int, int)) { SDL_Rect dest; -#if LCD_DEPTH >= 8 && (LCD_PIXELFORMAT == RGB565) \ - && !defined(LCD_STRIDEFORMAT) && !defined(HAVE_LCD_SPLIT) \ - && !defined(HAVE_REMOTE_LCD) +#if LCD_DEPTH >= 8 && (LCD_PIXELFORMAT == RGB565) && \ + (LCD_STRIDEFORMAT == HORIZONTAL_STRIDE) && \ + !defined(HAVE_LCD_SPLIT) && !defined(HAVE_REMOTE_LCD) SDL_Rect src; (void)max_x; (void)max_y; -- cgit v1.2.3