[U-Boot] [PATCH V2 11/12] lcd: refactor lcd console stuff into its own file
common/lcd.c is a mix of code portions that do different but related things. To improve modularity, the various code portions should be split into their own modules. Separate lcd console code into its own file. Signed-off-by: Nikita Kiryanov nik...@compulab.co.il Cc: Anatolij Gustschin ag...@denx.de Cc: Wolfgang Denk w...@denx.de Cc: Simon Glass s...@chromium.org --- NOTE: I'm resending this cover letter with a shorter Cc list because the original mail got held up. Sorry for the double post. Changes in V2: - New patch. common/Makefile | 2 +- common/lcd.c | 227 -- common/lcd_console.c | 212 ++ include/lcd.h | 1 + include/lcd_console.h | 85 +++ 5 files changed, 299 insertions(+), 228 deletions(-) create mode 100644 common/lcd_console.c create mode 100644 include/lcd_console.h diff --git a/common/Makefile b/common/Makefile index 9c47e20..66584fc 100644 --- a/common/Makefile +++ b/common/Makefile @@ -206,7 +206,7 @@ obj-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o obj-$(CONFIG_I2C_EDID) += edid.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-y += splash.o -obj-$(CONFIG_LCD) += lcd.o +obj-$(CONFIG_LCD) += lcd.o lcd_console.o obj-$(CONFIG_LYNXKDI) += lynxkdi.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_MODEM_SUPPORT) += modem.o diff --git a/common/lcd.c b/common/lcd.c index b55dd4c..2d0380d 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -73,22 +73,6 @@ #define CONFIG_LCD_ALIGNMENT PAGE_SIZE #endif -/* By default we scroll by a single line */ -#ifndef CONFIG_CONSOLE_SCROLL_LINES -#define CONFIG_CONSOLE_SCROLL_LINES 1 -#endif - -// -/* ** CONSOLE DEFINITIONS FUNCTIONS */ -// -#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) -#define CONSOLE_ROW_FIRST lcd_console_address -#define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) -#define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ - - CONSOLE_ROW_SIZE) -#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * console_rows) -#define CONSOLE_SCROLL_SIZE(CONSOLE_SIZE - CONSOLE_ROW_SIZE) - #if (LCD_BPP != LCD_COLOR8) (LCD_BPP != LCD_COLOR16) \ (LCD_BPP != LCD_COLOR32) # error Unsupported LCD BPP. @@ -96,9 +80,6 @@ DECLARE_GLOBAL_DATA_PTR; -static void lcd_drawchars(ushort x, ushort y, uchar *str, int count); -static inline void lcd_putc_xy(ushort x, ushort y, uchar c); - static int lcd_init(void *lcdbase); static void *lcd_logo(void); @@ -112,12 +93,6 @@ int lcd_line_length; char lcd_is_enabled = 0; -static short console_curr_col; -static short console_curr_row; -static short console_cols; -static short console_rows; - -static void *lcd_console_address; static void *lcd_base; /* Start of framebuffer memory */ static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ @@ -153,82 +128,6 @@ void lcd_set_flush_dcache(int flush) lcd_flush_dcache = (flush != 0); } -void lcd_init_console(void *address, int rows, int cols) -{ - console_curr_col = 0; - console_curr_row = 0; - console_cols = cols; - console_rows = rows; - lcd_console_address = address; -} - -void lcd_set_col(short col) -{ - console_curr_col = col; -} - -void lcd_set_row(short row) -{ - console_curr_row = row; -} - -/*--*/ - -static void console_scrollup(void) -{ - const int rows = CONFIG_CONSOLE_SCROLL_LINES; - - /* Copy up rows ignoring those that will be overwritten */ - memcpy(CONSOLE_ROW_FIRST, - lcd_console_address + CONSOLE_ROW_SIZE * rows, - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows); - - /* Clear the last rows */ -#if (LCD_BPP != LCD_COLOR32) - memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows, - lcd_getbgcolor(), - CONSOLE_ROW_SIZE * rows); -#else - u32 *ppix = lcd_console_address + - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows; - u32 i; - for (i = 0; - i (CONSOLE_ROW_SIZE * rows) / NBYTES(panel_info.vl_bpix); - i++) { - *ppix++ = lcd_getbgcolor(); - } -#endif - lcd_sync(); - console_curr_row -= rows; -} - -/*--*/ - -static inline void console_back(void) -{ - if (--console_curr_col 0) { - console_curr_col = console_cols - 1; - if (--console_curr_row 0) - console_curr_row = 0; - } - - lcd_putc_xy(console_curr_col * VIDEO_FONT_WIDTH, - console_curr_row *
[U-Boot] [PATCH V2 11/12] lcd: refactor lcd console stuff into its own file
common/lcd.c is a mix of code portions that do different but related things. To improve modularity, the various code portions should be split into their own modules. Separate lcd console code into its own file. Signed-off-by: Nikita Kiryanov nik...@compulab.co.il Cc: Anatolij Gustschin ag...@denx.de Cc: Wolfgang Denk w...@denx.de Cc: Lukasz Majewski l.majew...@samsung.com Cc: Marek Vasut marek.va...@gmail.com Cc: Stephen Warren swar...@wwwdotorg.org Cc: Josh Wu josh...@atmel.com Cc: Alban Bedel alban.be...@avionic-design.de Cc: Bo Shen voice.s...@atmel.com Cc: Tom Warren twar...@nvidia.com Cc: Alban Bedel alban.be...@avionic-design.de Cc: Jens Scharsig e...@bus-elektronik.de Cc: TsiChung Liew tsi-chung.l...@freescale.com Cc: Przemyslaw Marczak p.marc...@samsung.com Cc: Cliff Brake cliff.br...@gmail.com Cc: Sergey Yanovich ynv...@gmail.com Cc: Akshay Saraswat aksha...@samsung.com Cc: Stephen Warren swar...@nvidia.com Cc: Daniel Gorsulowski daniel.gorsulow...@esd.eu Cc: Stelian Pop stel...@popies.net --- Changes in V2: - New patch. common/Makefile | 2 +- common/lcd.c | 227 -- common/lcd_console.c | 212 ++ include/lcd.h | 1 + include/lcd_console.h | 85 +++ 5 files changed, 299 insertions(+), 228 deletions(-) create mode 100644 common/lcd_console.c create mode 100644 include/lcd_console.h diff --git a/common/Makefile b/common/Makefile index 9c47e20..66584fc 100644 --- a/common/Makefile +++ b/common/Makefile @@ -206,7 +206,7 @@ obj-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o obj-$(CONFIG_I2C_EDID) += edid.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-y += splash.o -obj-$(CONFIG_LCD) += lcd.o +obj-$(CONFIG_LCD) += lcd.o lcd_console.o obj-$(CONFIG_LYNXKDI) += lynxkdi.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_MODEM_SUPPORT) += modem.o diff --git a/common/lcd.c b/common/lcd.c index b55dd4c..2d0380d 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -73,22 +73,6 @@ #define CONFIG_LCD_ALIGNMENT PAGE_SIZE #endif -/* By default we scroll by a single line */ -#ifndef CONFIG_CONSOLE_SCROLL_LINES -#define CONFIG_CONSOLE_SCROLL_LINES 1 -#endif - -// -/* ** CONSOLE DEFINITIONS FUNCTIONS */ -// -#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) -#define CONSOLE_ROW_FIRST lcd_console_address -#define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) -#define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ - - CONSOLE_ROW_SIZE) -#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * console_rows) -#define CONSOLE_SCROLL_SIZE(CONSOLE_SIZE - CONSOLE_ROW_SIZE) - #if (LCD_BPP != LCD_COLOR8) (LCD_BPP != LCD_COLOR16) \ (LCD_BPP != LCD_COLOR32) # error Unsupported LCD BPP. @@ -96,9 +80,6 @@ DECLARE_GLOBAL_DATA_PTR; -static void lcd_drawchars(ushort x, ushort y, uchar *str, int count); -static inline void lcd_putc_xy(ushort x, ushort y, uchar c); - static int lcd_init(void *lcdbase); static void *lcd_logo(void); @@ -112,12 +93,6 @@ int lcd_line_length; char lcd_is_enabled = 0; -static short console_curr_col; -static short console_curr_row; -static short console_cols; -static short console_rows; - -static void *lcd_console_address; static void *lcd_base; /* Start of framebuffer memory */ static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ @@ -153,82 +128,6 @@ void lcd_set_flush_dcache(int flush) lcd_flush_dcache = (flush != 0); } -void lcd_init_console(void *address, int rows, int cols) -{ - console_curr_col = 0; - console_curr_row = 0; - console_cols = cols; - console_rows = rows; - lcd_console_address = address; -} - -void lcd_set_col(short col) -{ - console_curr_col = col; -} - -void lcd_set_row(short row) -{ - console_curr_row = row; -} - -/*--*/ - -static void console_scrollup(void) -{ - const int rows = CONFIG_CONSOLE_SCROLL_LINES; - - /* Copy up rows ignoring those that will be overwritten */ - memcpy(CONSOLE_ROW_FIRST, - lcd_console_address + CONSOLE_ROW_SIZE * rows, - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows); - - /* Clear the last rows */ -#if (LCD_BPP != LCD_COLOR32) - memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows, - lcd_getbgcolor(), - CONSOLE_ROW_SIZE * rows); -#else - u32 *ppix = lcd_console_address + - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows; - u32 i; - for (i = 0; - i (CONSOLE_ROW_SIZE * rows) / NBYTES(panel_info.vl_bpix); - i++) { -
Re: [U-Boot] [PATCH V2 11/12] lcd: refactor lcd console stuff into its own file
Hi Nikita, On 30 November 2014 at 06:22, Nikita Kiryanov nik...@compulab.co.il wrote: common/lcd.c is a mix of code portions that do different but related things. To improve modularity, the various code portions should be split into their own modules. Separate lcd console code into its own file. Signed-off-by: Nikita Kiryanov nik...@compulab.co.il Cc: Anatolij Gustschin ag...@denx.de Cc: Wolfgang Denk w...@denx.de Cc: Simon Glass s...@chromium.org --- NOTE: I'm resending this cover letter with a shorter Cc list because the original mail got held up. Sorry for the double post. One nit below, but otherwise: Acked-by: Simon Glass s...@chromium.org Tested on pit, LCD works fine. Tested-by: Simon Glass s...@chromium.org Changes in V2: - New patch. common/Makefile | 2 +- common/lcd.c | 227 -- common/lcd_console.c | 212 ++ include/lcd.h | 1 + include/lcd_console.h | 85 +++ 5 files changed, 299 insertions(+), 228 deletions(-) create mode 100644 common/lcd_console.c create mode 100644 include/lcd_console.h diff --git a/common/Makefile b/common/Makefile index 9c47e20..66584fc 100644 --- a/common/Makefile +++ b/common/Makefile @@ -206,7 +206,7 @@ obj-$(CONFIG_CMD_KGDB) += kgdb.o kgdb_stubs.o obj-$(CONFIG_I2C_EDID) += edid.o obj-$(CONFIG_KALLSYMS) += kallsyms.o obj-y += splash.o -obj-$(CONFIG_LCD) += lcd.o +obj-$(CONFIG_LCD) += lcd.o lcd_console.o obj-$(CONFIG_LYNXKDI) += lynxkdi.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_MODEM_SUPPORT) += modem.o diff --git a/common/lcd.c b/common/lcd.c index b55dd4c..2d0380d 100644 --- a/common/lcd.c +++ b/common/lcd.c @@ -73,22 +73,6 @@ #define CONFIG_LCD_ALIGNMENT PAGE_SIZE #endif -/* By default we scroll by a single line */ -#ifndef CONFIG_CONSOLE_SCROLL_LINES -#define CONFIG_CONSOLE_SCROLL_LINES 1 -#endif - -// -/* ** CONSOLE DEFINITIONS FUNCTIONS */ -// -#define CONSOLE_ROW_SIZE (VIDEO_FONT_HEIGHT * lcd_line_length) -#define CONSOLE_ROW_FIRST lcd_console_address -#define CONSOLE_ROW_SECOND (lcd_console_address + CONSOLE_ROW_SIZE) -#define CONSOLE_ROW_LAST (lcd_console_address + CONSOLE_SIZE \ - - CONSOLE_ROW_SIZE) -#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * console_rows) -#define CONSOLE_SCROLL_SIZE(CONSOLE_SIZE - CONSOLE_ROW_SIZE) - #if (LCD_BPP != LCD_COLOR8) (LCD_BPP != LCD_COLOR16) \ (LCD_BPP != LCD_COLOR32) # error Unsupported LCD BPP. @@ -96,9 +80,6 @@ DECLARE_GLOBAL_DATA_PTR; -static void lcd_drawchars(ushort x, ushort y, uchar *str, int count); -static inline void lcd_putc_xy(ushort x, ushort y, uchar c); - static int lcd_init(void *lcdbase); static void *lcd_logo(void); @@ -112,12 +93,6 @@ int lcd_line_length; char lcd_is_enabled = 0; -static short console_curr_col; -static short console_curr_row; -static short console_cols; -static short console_rows; - -static void *lcd_console_address; static void *lcd_base; /* Start of framebuffer memory */ static char lcd_flush_dcache; /* 1 to flush dcache after each lcd update */ @@ -153,82 +128,6 @@ void lcd_set_flush_dcache(int flush) lcd_flush_dcache = (flush != 0); } -void lcd_init_console(void *address, int rows, int cols) -{ - console_curr_col = 0; - console_curr_row = 0; - console_cols = cols; - console_rows = rows; - lcd_console_address = address; -} - -void lcd_set_col(short col) -{ - console_curr_col = col; -} - -void lcd_set_row(short row) -{ - console_curr_row = row; -} - -/*--*/ - -static void console_scrollup(void) -{ - const int rows = CONFIG_CONSOLE_SCROLL_LINES; - - /* Copy up rows ignoring those that will be overwritten */ - memcpy(CONSOLE_ROW_FIRST, - lcd_console_address + CONSOLE_ROW_SIZE * rows, - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows); - - /* Clear the last rows */ -#if (LCD_BPP != LCD_COLOR32) - memset(lcd_console_address + CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows, - lcd_getbgcolor(), - CONSOLE_ROW_SIZE * rows); -#else - u32 *ppix = lcd_console_address + - CONSOLE_SIZE - CONSOLE_ROW_SIZE * rows; - u32 i; - for (i = 0; - i (CONSOLE_ROW_SIZE * rows) / NBYTES(panel_info.vl_bpix); - i++) { - *ppix++ = lcd_getbgcolor(); - } -#endif - lcd_sync(); - console_curr_row -= rows; -} -