cleanup and refactor lcd.c
v2 cover cleanup and refactor lcd.c
This series is a first step towards an end goal of merging all CONFIG_LCD related functionality into CONFIG_VIDEO code. My plan is to start by refactoring lcd.c into something cleaner (less ifdefs) and more modular (split code into multiple files), then possibly refactor CONFIG_VIDEO code if needed, and then
finally: move CONFIG_LCD related functionality over to CONFIG_VIDEO code, replacing as much CONFIG_LCD related code with CONFIG_VIDEO related code as possible.
This specific step eliminates some unused code and refactors lcd console stuff into its own file.
In V2 I broke the last patch of the original series ("lcd: refactor lcd console stuff into its own file") into multiple patches to make it clear what changes had to be done in order to refactor the lcd console code into its own file. These preparatory patches ("lcd: rename console_(row|col)" to "lcd: make lcd_drawchars() independant of lcd_base") are meant to illustrate exactly what changed and where in the transition from lcd.c to lcd_console.c, and are not necesserily code improvements when viewed out of context.
Additional changes in V2:
- Added documentation for the new functions.
The whole series was rebased over current mainline, and compile tested for arm and powerpc.
Nikita Kiryanov (12):
lcd: remove CONFIG_SYS_INVERT_COLORS
lcd: cleanup lcd_drawchars
mpc8xx_lcd: get rid of CONFIG_EDT32F10
lcd: remove LCD_MONOCHROME
lcd: rename console_(row|col)
lcd: replace CONSOLE_(ROWS|COLS) with variables
lcd: expand console api
lcd: get rid of COLOR_MASK
lcd: introduce getters for bg/fg color
lcd: make lcd_drawchars() independant of lcd_base
lcd: refactor lcd console stuff into its own file
lcd_console: remove unused defines
common/Makefile | 2 +- common/lcd.c | 308 +++++---------------------------------------- common/lcd_console.c | 208 ++++++++++++++++++++++++++++++ drivers/video/mpc8xx_lcd.c | 49 +------- drivers/video/pxa_lcd.c | 15 --- include/configs/R360MPI.h | 1 - include/lcd.h | 25 ++-- include/lcd_console.h | 85 +++++++++++++ 8 files changed, 340 insertions(+), 353 deletions(-) create mode 100644 common/lcd_console.c create mode 100644 include/lcd_console.h
Signature · 1 line
1.9.1
PATCH v2 1/12 lcd: remove CONFIG_SYS_INVERT_COLORS
No one is using CONFIG_SYS_INVERT_COLORS; remove related code.
---
Changes in V2:
- No changes.
common/lcd.c | 8 -------- drivers/video/mpc8xx_lcd.c | 4 +--- 2 files changed, 1 insertion(+), 11 deletions(-)
common/lcd.c +0 -8
@@ -685,11 +685,7 @@ void bitmap_plot(int x, int y) *(cmap +BMP_LOGO_OFFSET ) = lut_entry; cmap++;#else /* !CONFIG_ATMEL_LCD */ -#ifdef CONFIG_SYS_INVERT_COLORS - *cmap++ =0xffff - colreg; -#else *cmap++ = colreg; -#endif #endif /* CONFIG_ATMEL_LCD */ }
@@ -967,11 +963,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y) ( ((cte.red) <<8 ) &0xf800 ) | ( ((cte.green) <<3 ) &0x07e0 ) | ( ((cte.blue) >>3 ) &0x001f ) ; -#ifdef CONFIG_SYS_INVERT_COLORS - *cmap =0xffff - colreg; -#else *cmap = colreg; -#endif #if defined(CONFIG_MPC823 ) cmap--;#else
drivers/video/mpc8xx_lcd.c +1 -3
@@ -373,9 +373,7 @@ lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue) colreg = ((red &0x0F ) <<8 ) | ((green &0x0F ) <<4 ) | (blue &0x0F ) ; -#ifdef CONFIG_SYS_INVERT_COLORS - colreg ^=0x0FFF ; -#endif + *cmap_ptr = colreg; debug ("setcolreg: reg %2d @ %p: R=%02X G=%02X B=%02X => %02X%02X\n",
Signature · 1 line
1.9.1
PATCH v2 2/12 lcd: cleanup lcd_drawchars
In reply to Nikita KiryanovRemove code duplication from lcd_drawchars().
---
Changes in V2:
- No changes.
common/lcd.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
common/lcd.c +1 -13
@@ -346,19 +346,7 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) *d++ = rest | (sym >> off); rest = sym << (8 -off); -#elif LCD_BPP ==LCD_COLOR8 -for (c =0 ; c <8 ; ++c) { - *d++ = (bits &0x80 ) ? - lcd_color_fg : lcd_color_bg; - bits <<=1 ; - } -#elif LCD_BPP ==LCD_COLOR16 -for (c =0 ; c <8 ; ++c) { - *d++ = (bits &0x80 ) ? - lcd_color_fg : lcd_color_bg; - bits <<=1 ; - } -#elif LCD_BPP ==LCD_COLOR32 +#else /* LCD_BPP == LCD_COLOR8 or LCD_COLOR16 or LCD_COLOR32 */ for (c =0 ; c <8 ; ++c) { *d++ = (bits &0x80 ) ? lcd_color_fg : lcd_color_bg;
Signature · 1 line
1.9.1
PATCH v2 3/12 mpc8xx_lcd: get rid of CONFIG_EDT32F10
In reply to Nikita KiryanovNo one is using CONFIG_EDT32F10; remove related code.
---
Changes in V2:
- No changes.
drivers/video/mpc8xx_lcd.c | 28 ---------------------------- include/configs/R360MPI.h | 1 - 2 files changed, 29 deletions(-)
drivers/video/mpc8xx_lcd.c +0 -28
@@ -34,11 +34,6 @@#define CONFIG_LCD_INFO /* Display Logo, (C) and system info */ #endif -#if defined(CONFIG_EDT32F10 ) -#undef CONFIG_LCD_LOGO -#undef CONFIG_LCD_INFO -#endif -/*----------------------------------------------------------------------*/ #ifdef CONFIG_KYOCERA_KCS057QV1AJ /*
@@ -224,20 +219,6 @@ vidinfo_t panel_info = { };#endif /* CONFIG_OPTREX_BW */ -/*-----------------------------------------------------------------*/ -#ifdef CONFIG_EDT32F10 -/* -* Emerging Display Technologies 320x240. Passive, monochrome, single scan. -*/ -#define LCD_BPP LCD_MONOCHROME -#define LCD_DF 10 - -vidinfo_t panel_info = { -320 ,240 ,0 ,0 ,CONFIG_SYS_HIGH ,CONFIG_SYS_HIGH ,CONFIG_SYS_HIGH ,CONFIG_SYS_HIGH ,CONFIG_SYS_LOW , -LCD_BPP ,0 ,0 ,0 ,0 ,33 ,0 ,0 ,0 -}; -#endif -/************************************************************************/ /* ----------------- chipset specific functions ----------------------- */ /************************************************************************/
@@ -305,7 +286,6 @@ void lcd_ctrl_init (void *lcdbase) immr->im_clkrst.car_sccr &= ~0x1F ; immr->im_clkrst.car_sccr |=LCD_DF ;/* was 8 */ -#if !defined(CONFIG_EDT32F10 )/* Enable LCD on port D. */ immr->im_ioport.iop_pdpar |=0x1FFF ;
@@ -315,14 +295,6 @@ void lcd_ctrl_init (void *lcdbase)*/ immr->im_cpm.cp_pbpar |=0x00005001 ; immr->im_cpm.cp_pbdir |=0x00005001 ; -#else -/* Enable LCD on port D. -*/ - immr->im_ioport.iop_pdpar |=0x1DFF ; - immr->im_ioport.iop_pdpar &= ~0x0200 ; - immr->im_ioport.iop_pddir |=0x1FFF ; - immr->im_ioport.iop_pddat |=0x0200 ; -#endif /* Load the physical address of the linear frame buffer * into the LCD controller.
include/configs/R360MPI.h +0 -1
@@ -24,7 +24,6 @@#define CONFIG_LCD #define CONFIG_MPC8XX_LCD -#undef CONFIG_EDT32F10#define CONFIG_SHARP_LQ057Q3DC02 #define CONFIG_SPLASH_SCREEN
Signature · 1 line
1.9.1
PATCH v2 4/12 lcd: remove LCD_MONOCHROME
In reply to Nikita KiryanovNo one is using LCD_MONOCHROME; remove related code.
---
Changes in V2:
- No changes.
common/lcd.c | 30 ++---------------------------- drivers/video/mpc8xx_lcd.c | 17 ----------------- drivers/video/pxa_lcd.c | 15 --------------- include/lcd.h | 10 +--------- 4 files changed, 3 insertions(+), 69 deletions(-)
common/lcd.c +2 -28
@@ -97,10 +97,7 @@#define CONSOLE_SIZE (CONSOLE_ROW_SIZE * CONSOLE_ROWS)#define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) -#if LCD_BPP ==LCD_MONOCHROME -# define COLOR_MASK (c) ((c) | (c) << 1 | (c) << 2 | (c) << 3 | \ - (c) << 4 | (c) << 5 | (c) << 6 | (c) << 7) -#elif (LCD_BPP ==LCD_COLOR8 ) || (LCD_BPP ==LCD_COLOR16 ) || \ +#if (LCD_BPP ==LCD_COLOR8 ) || (LCD_BPP ==LCD_COLOR16 ) || \ (LCD_BPP ==LCD_COLOR32 )# define COLOR_MASK (c) (c)#else
@@ -313,10 +310,6 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) y +=BMP_LOGO_HEIGHT ;#endif -#if LCD_BPP ==LCD_MONOCHROME -ushort off = x * (1 <<LCD_BPP ) %8 ; -#endif - dest = (uchar *)(lcd_base + y * lcd_line_length + x *NBITS (LCD_BPP )/8 );for (row =0 ; row <VIDEO_FONT_HEIGHT ; ++row, dest += lcd_line_length) {
@@ -330,33 +323,18 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)uchar *d = dest;#endif -#if LCD_BPP ==LCD_MONOCHROME -uchar rest = *d & -(1 << (8 - off)); -uchar sym; -#endif for (i =0 ; i < count; ++i) {uchar c, bits; c = *s++; bits = video_fontdata[c *VIDEO_FONT_HEIGHT + row]; -#if LCD_BPP ==LCD_MONOCHROME - sym = (COLOR_MASK (lcd_color_fg) & bits) | - (COLOR_MASK (lcd_color_bg) & ~bits); - - *d++ = rest | (sym >> off); - rest = sym << (8 -off); -#else /* LCD_BPP == LCD_COLOR8 or LCD_COLOR16 or LCD_COLOR32 */ for (c =0 ; c <8 ; ++c) { *d++ = (bits &0x80 ) ? lcd_color_fg : lcd_color_bg; bits <<=1 ; } -#endif } -#if LCD_BPP ==LCD_MONOCHROME - *d = rest | (*d & ((1 << (8 - off)) -1 )); -#endif } }
@@ -443,11 +421,7 @@ int drv_lcd_init(void)/*----------------------------------------------------------------------*/ void lcd_clear (void ) { -#if LCD_BPP ==LCD_MONOCHROME -/* Setting the palette */ -lcd_initcolregs (); - -#elif LCD_BPP ==LCD_COLOR8 +#if LCD_BPP ==LCD_COLOR8 /* Setting the palette */ lcd_setcolreg (CONSOLE_COLOR_BLACK ,0 ,0 ,0 );lcd_setcolreg (CONSOLE_COLOR_RED ,0xFF ,0 ,0 );
drivers/video/mpc8xx_lcd.c +0 -17
@@ -357,23 +357,6 @@ lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)/*----------------------------------------------------------------------*/ -#if LCD_BPP ==LCD_MONOCHROME -static -void lcd_initcolregs (void ) -{ -volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR ; -volatile cpm8xx_t *cp = &(immr->im_cpm); -ushort regno; - -for (regno =0 ; regno <16 ; regno++) { - cp->lcd_cmap[regno *2 ] =0 ; - cp->lcd_cmap[(regno *2 ) +1 ] = regno &0x0f ; - } -} -#endif - -/*----------------------------------------------------------------------*/ -void lcd_enable (void ) {volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR ;
drivers/video/pxa_lcd.c +0 -15
@@ -379,21 +379,6 @@ lcd_setcolreg (ushort regno, ushort red, ushort green, ushort blue)#endif /* LCD_COLOR8 */ /*----------------------------------------------------------------------*/ -#if LCD_BPP ==LCD_MONOCHROME -void lcd_initcolregs (void ) -{ -struct pxafb_info *fbi = &panel_info.pxa; - cmap = (ushort *)fbi->palette; -ushort regno; - -for (regno =0 ; regno <16 ; regno++) { - cmap[regno *2 ] =0 ; - cmap[(regno *2 ) +1 ] = regno &0x0f ; - } -} -#endif /* LCD_MONOCHROME */ - -/*----------------------------------------------------------------------*/ __weak void lcd_enable (void ) { }
include/lcd.h +1 -9
@@ -359,15 +359,7 @@ void lcd_sync(void);/************************************************************************/ /* ** CONSOLE CONSTANTS */ /************************************************************************/ -#if LCD_BPP ==LCD_MONOCHROME - -/* -* Simple black/white definitions -*/ -# define CONSOLE_COLOR_BLACK 0 -# define CONSOLE_COLOR_WHITE 1/* Must remain last / highest */ - -#elif LCD_BPP ==LCD_COLOR8 +#if LCD_BPP ==LCD_COLOR8 /* * 8bpp color definitions
Signature · 1 line
1.9.1
PATCH v2 5/12 lcd: rename console_(row|col)
In reply to Nikita KiryanovRename console_(row|col) to console_curr_(row|col) to make their meaning clearer and distinguish them from CONSOLE_(COLS|ROWS).
This is a preparatory step for extracting lcd console code into its own file.
---
Changes in V2:
- New patch.
common/lcd.c | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
common/lcd.c +27 -27
@@ -122,8 +122,8 @@ int lcd_line_length;char lcd_is_enabled =0 ; -static short console_col; -static short console_row; +static short console_curr_col; +static short console_curr_row;static void *lcd_console_address;static void *lcd_base;/* Start of framebuffer memory */
@@ -188,31 +188,31 @@ static void console_scrollup(void) }#endif lcd_sync (); - console_row -= rows; + console_curr_row -= rows; }/*----------------------------------------------------------------------*/ static inline void console_back (void ) { -if (--console_col <0 ) { - console_col =CONSOLE_COLS -1 ; -if (--console_row <0 ) - console_row =0 ; +if (--console_curr_col <0 ) { + console_curr_col =CONSOLE_COLS -1 ; +if (--console_curr_row <0 ) + console_curr_row =0 ; } -lcd_putc_xy (console_col *VIDEO_FONT_WIDTH , - console_row *VIDEO_FONT_HEIGHT ,' ' ); +lcd_putc_xy (console_curr_col *VIDEO_FONT_WIDTH , + console_curr_row *VIDEO_FONT_HEIGHT ,' ' ); }/*----------------------------------------------------------------------*/ static inline void console_newline (void ) { - console_col =0 ; + console_curr_col =0 ;/* Check if we need to scroll the terminal */ -if (++console_row >=CONSOLE_ROWS ) +if (++console_curr_row >=CONSOLE_ROWS )console_scrollup ();else lcd_sync ();
@@ -235,7 +235,7 @@ void lcd_putc(const char c)switch (c) {case '\r' : - console_col =0 ; + console_curr_col =0 ;return ;case '\n' :
@@ -243,10 +243,10 @@ void lcd_putc(const char c)return ;case '\t' :/* Tab (8 chars alignment) */ - console_col +=8 ; - console_col &= ~7 ; + console_curr_col +=8 ; + console_curr_col &= ~7 ; -if (console_col >=CONSOLE_COLS ) +if (console_curr_col >=CONSOLE_COLS )console_newline ();return ;
@@ -255,9 +255,9 @@ void lcd_putc(const char c)return ;default : -lcd_putc_xy (console_col *VIDEO_FONT_WIDTH , - console_row *VIDEO_FONT_HEIGHT , c); -if (++console_col >=CONSOLE_COLS ) +lcd_putc_xy (console_curr_col *VIDEO_FONT_WIDTH , + console_curr_row *VIDEO_FONT_HEIGHT , c); +if (++console_curr_col >=CONSOLE_COLS )console_newline (); } }
@@ -464,8 +464,8 @@ void lcd_clear(void)debug ("[LCD] Drawing the logo...\n" ); lcd_console_address =lcd_logo (); - console_col =0 ; - console_row =0 ; + console_curr_col =0 ; + console_curr_row =0 ;lcd_sync (); }
@@ -508,11 +508,11 @@ static int lcd_init(void *lcdbase)lcd_enable ();/* Initialize the console */ - console_col =0 ; + console_curr_col =0 ;#ifdef CONFIG_LCD_INFO_BELOW_LOGO - console_row =7 +BMP_LOGO_HEIGHT /VIDEO_FONT_HEIGHT ; + console_curr_row =7 +BMP_LOGO_HEIGHT /VIDEO_FONT_HEIGHT ;#else - console_row =1 ;/* leave 1 blank line below logo */ + console_curr_row =1 ;/* leave 1 blank line below logo */ #endif return 0 ;
@@ -1062,8 +1062,8 @@ static void *lcd_logo(void)bitmap_plot (0 ,0 );#ifdef CONFIG_LCD_INFO - console_col =LCD_INFO_X /VIDEO_FONT_WIDTH ; - console_row =LCD_INFO_Y /VIDEO_FONT_HEIGHT ; + console_curr_col =LCD_INFO_X /VIDEO_FONT_WIDTH ; + console_curr_row =LCD_INFO_Y /VIDEO_FONT_HEIGHT ;lcd_show_board_info ();#endif /* CONFIG_LCD_INFO */
@@ -1100,8 +1100,8 @@ U_BOOT_ENV_CALLBACK(splashimage, on_splashimage);void lcd_position_cursor (unsigned col,unsigned row) { - console_col =min_t (short, col,CONSOLE_COLS -1 ); - console_row =min_t (short, row,CONSOLE_ROWS -1 ); + console_curr_col =min_t (short, col,CONSOLE_COLS -1 ); + console_curr_row =min_t (short, row,CONSOLE_ROWS -1 ); }int lcd_get_pixel_width (void )
Signature · 1 line
1.9.1
PATCH v2 5/12 lcd: rename console_(row|col)
Quoted 11 lines · Nikita Kiryanov
Rename
console_(row|col)toconsole_curr_(row|col)to make their meaning clearer and distinguish them fromCONSOLE_(COLS|ROWS).This is a preparatory step for extracting lcd console code into its own file.
Signed-off-by Nikita Kiryanov <[email protected]>Cc Simon Glass <[email protected]>Cc Anatolij Gustschin <[email protected]>---
Changes in V2:
- New patch.
Tested on pit, LCD works fine.
PATCH v2 6/12 lcd: replace CONSOLE_(ROWS|COLS) with variables
In reply to Nikita KiryanovReplace CONSOLE_(ROWS|COLS) macros with variables, and assign the original macro values.
This is a preparatory step for extracting lcd console code into its own file.
---
Changes in V2:
- New patch.
common/lcd.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-)
common/lcd.c +18 -17
@@ -81,20 +81,12 @@/************************************************************************/ /* ** CONSOLE DEFINITIONS & FUNCTIONS */ /************************************************************************/ -#if defined(CONFIG_LCD_LOGO ) && !defined(CONFIG_LCD_INFO_BELOW_LOGO ) -# define CONSOLE_ROWS ((panel_info.vl_row-BMP_LOGO_HEIGHT) \ - / VIDEO_FONT_HEIGHT) -#else -# define CONSOLE_ROWS (panel_info.vl_row / VIDEO_FONT_HEIGHT) -#endif - -#define CONSOLE_COLS (panel_info.vl_col / VIDEO_FONT_WIDTH)#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_SIZE (CONSOLE_ROW_SIZE * console_rows)#define CONSOLE_SCROLL_SIZE (CONSOLE_SIZE - CONSOLE_ROW_SIZE) #if (LCD_BPP == LCD_COLOR8) || (LCD_BPP == LCD_COLOR16) || \
@@ -124,6 +116,8 @@ 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 */
@@ -196,7 +190,7 @@ static void console_scrollup(void)static inline void console_back (void ) {if (--console_curr_col <0 ) { - console_curr_col =CONSOLE_COLS -1 ; + console_curr_col = console_cols -1 ;if (--console_curr_row <0 ) console_curr_row =0 ; }
@@ -212,7 +206,7 @@ static inline void console_newline(void) console_curr_col =0 ;/* Check if we need to scroll the terminal */ -if (++console_curr_row >=CONSOLE_ROWS ) +if (++console_curr_row >= console_rows)console_scrollup ();else lcd_sync ();
@@ -246,7 +240,7 @@ void lcd_putc(const char c) console_curr_col +=8 ; console_curr_col &= ~7 ; -if (console_curr_col >=CONSOLE_COLS ) +if (console_curr_col >= console_cols)console_newline ();return ;
@@ -257,7 +251,7 @@ void lcd_putc(const char c)default :lcd_putc_xy (console_curr_col *VIDEO_FONT_WIDTH , console_curr_row *VIDEO_FONT_HEIGHT , c); -if (++console_curr_col >=CONSOLE_COLS ) +if (++console_curr_col >= console_cols)console_newline (); } }
@@ -464,6 +458,13 @@ void lcd_clear(void)debug ("[LCD] Drawing the logo...\n" ); lcd_console_address =lcd_logo (); +#if defined(CONFIG_LCD_LOGO ) && !defined(CONFIG_LCD_INFO_BELOW_LOGO ) + console_rows = (panel_info.vl_row -BMP_LOGO_HEIGHT ); + console_rows /=VIDEO_FONT_HEIGHT ; +#else + console_rows = panel_info.vl_row /VIDEO_FONT_HEIGHT ; +#endif + console_cols = panel_info.vl_col /VIDEO_FONT_WIDTH ; console_curr_col =0 ; console_curr_row =0 ;lcd_sync ();
@@ -1100,8 +1101,8 @@ U_BOOT_ENV_CALLBACK(splashimage, on_splashimage);void lcd_position_cursor (unsigned col,unsigned row) { - console_curr_col =min_t (short, col,CONSOLE_COLS -1 ); - console_curr_row =min_t (short, row,CONSOLE_ROWS -1 ); + console_curr_col =min_t (short, col, console_cols -1 ); + console_curr_row =min_t (short, row, console_rows -1 ); }int lcd_get_pixel_width (void )
@@ -1116,12 +1117,12 @@ int lcd_get_pixel_height(void)int lcd_get_screen_rows (void ) { -return CONSOLE_ROWS ; +return console_rows; }int lcd_get_screen_columns (void ) { -return CONSOLE_COLS ; +return console_cols; }#if defined(CONFIG_LCD_DT_SIMPLEFB )
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): CAPnjgZ1wG2WyirHCjKZUXiYHEmu22akN7nLDjpZA9vwOj3vAcA@mail.gmail.com
PATCH v2 6/12 lcd: replace CONSOLE_(ROWS|COLS) with variables
Hi Simon,
Quoted 14 lines · Simon Glass
Quoted 6 lines · Nikita Kiryanov
Replace
CONSOLE_(ROWS|COLS)macros with variables, and assign the original macro values.This is a preparatory step for extracting lcd console code into its own file.
Quoted 6 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Anatolij Gustschin <[email protected]>Cc Simon Glass <[email protected]>---
Changes in V2:
- New patch.
Quoted 2 lines
Are you intended to want to support multiple displays, or just to change the resolution after start?
This did cross my mind as possible future work, but for this patch set the change was driven by the goal of decoupling lcd_console stuff as much as possible from the rest of the code, which meant that I did not want to bring panel_info references into lcd_console.c (there's actually one use of panel_info still remaining in console_scrollup() but I'll get rid of it if/when this series is applied).
In the case of console_cols and console_rows, the idea was that the use of panel_info can be avoided if lcd.c would pass the values as parameters to lcd_init_console() (introduced in a later patch), which meant that the macros had to be replaced with variables.
Quoted 7 lines
Acked-by Simon Glass <[email protected]>Tested on pit, LCD works fine.
Tested-by Simon Glass <[email protected]>
This mail did not reach mainline, so I'm Cc-ing the mailing list. I don't know if patchworks will register the Ack and Tested-by though, can you maybe resend them in a separate reply?
Signature · 2 lines
Regards, Nikita Kiryanov
PATCH v2 6/12 lcd: replace CONSOLE_(ROWS|COLS) with variables
In reply to Nikita KiryanovQuoted 9 lines · Nikita Kiryanov
Replace
CONSOLE_(ROWS|COLS)macros with variables, and assign the original macro values.This is a preparatory step for extracting lcd console code into its own file.
Signed-off-by Nikita Kiryanov <[email protected]>Cc Anatolij Gustschin <[email protected]>Cc Simon Glass <[email protected]>
Tested on pit, LCD works fine.
PATCH v2 7/12 lcd: expand console api
In reply to Nikita KiryanovIntroduce set_console_row(), set_console_col(), and lcd_init_console(). Use these functions in lcd functions: lcd_init(), lcd_clear(), lcd_logo().
This is a preparatory step for extracting lcd console code into its own file.
---
Changes in V2:
- New patch.
common/lcd.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-)
common/lcd.c +26 -9
@@ -155,6 +155,25 @@ 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 )
@@ -415,6 +434,7 @@ int drv_lcd_init(void)/*----------------------------------------------------------------------*/ void lcd_clear (void ) { +short console_rows, console_cols;#if LCD_BPP ==LCD_COLOR8 /* Setting the palette */ lcd_setcolreg (CONSOLE_COLOR_BLACK ,0 ,0 ,0 );
@@ -456,8 +476,6 @@ void lcd_clear(void)#endif /* Paint the logo and retrieve LCD base address */ debug ("[LCD] Drawing the logo...\n" ); - lcd_console_address =lcd_logo (); -#if defined(CONFIG_LCD_LOGO ) && !defined(CONFIG_LCD_INFO_BELOW_LOGO ) console_rows = (panel_info.vl_row -BMP_LOGO_HEIGHT ); console_rows /=VIDEO_FONT_HEIGHT ;
@@ -465,8 +483,7 @@ void lcd_clear(void) console_rows = panel_info.vl_row /VIDEO_FONT_HEIGHT ;#endif console_cols = panel_info.vl_col /VIDEO_FONT_WIDTH ; - console_curr_col =0 ; - console_curr_row =0 ; +lcd_init_console (lcd_logo (), console_rows, console_cols);lcd_sync (); }
@@ -509,11 +526,11 @@ static int lcd_init(void *lcdbase)lcd_enable ();/* Initialize the console */ - console_curr_col =0 ; +lcd_set_col (0 );#ifdef CONFIG_LCD_INFO_BELOW_LOGO - console_curr_row =7 +BMP_LOGO_HEIGHT /VIDEO_FONT_HEIGHT ; +lcd_set_row (7 +BMP_LOGO_HEIGHT /VIDEO_FONT_HEIGHT );#else - console_curr_row =1 ;/* leave 1 blank line below logo */ +lcd_set_row (1 );/* leave 1 blank line below logo */ #endif return 0 ;
@@ -1063,8 +1080,8 @@ static void *lcd_logo(void)bitmap_plot (0 ,0 );#ifdef CONFIG_LCD_INFO - console_curr_col =LCD_INFO_X /VIDEO_FONT_WIDTH ; - console_curr_row =LCD_INFO_Y /VIDEO_FONT_HEIGHT ; +lcd_set_col (LCD_INFO_X /VIDEO_FONT_WIDTH ); +lcd_set_row (LCD_INFO_Y /VIDEO_FONT_HEIGHT );lcd_show_board_info ();#endif /* CONFIG_LCD_INFO */
Signature · 1 line
1.9.1
PATCH v2 7/12 lcd: expand console api
Quoted 6 lines · Nikita Kiryanov
Introduce
set_console_row(),set_console_col(), andlcd_init_console(). Use these functions in lcd functions:lcd_init(),lcd_clear(),lcd_logo().This is a preparatory step for extracting lcd console code into its own file.
Quoted 6 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Anatolij Gustschin <[email protected]>Cc Simon Glass <[email protected]>---
Changes in V2:
- New patch.
Tested on pit, LCD works fine.
PATCH v2 8/12 lcd: get rid of COLOR_MASK
In reply to Nikita KiryanovCOLOR_MASK macro doesn't do anything; Remove it to reduce visual complexity.
This is a preparatory step for extracting lcd console code into its own file.
---
Changes in V2:
- New patch.
common/lcd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
common/lcd.c +6 -8
@@ -89,10 +89,8 @@#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 ) -# define COLOR_MASK (c) (c) -#else +#if (LCD_BPP !=LCD_COLOR8 ) && (LCD_BPP !=LCD_COLOR16 ) && \ + (LCD_BPP !=LCD_COLOR32 )# error Unsupported LCD BPP.#endif
@@ -188,7 +186,7 @@ static void console_scrollup(void)/* Clear the last rows */ #if (LCD_BPP !=LCD_COLOR32 )memset (lcd_console_address +CONSOLE_SIZE -CONSOLE_ROW_SIZE * rows, -COLOR_MASK (lcd_color_bg), + lcd_color_bg,CONSOLE_ROW_SIZE * rows);#else u32 *ppix = lcd_console_address +
@@ -197,7 +195,7 @@ static void console_scrollup(void)for (i =0 ; i < (CONSOLE_ROW_SIZE * rows) /NBYTES (panel_info.vl_bpix); i++) { - *ppix++ =COLOR_MASK (lcd_color_bg); + *ppix++ = lcd_color_bg; }#endif lcd_sync ();
@@ -462,7 +460,7 @@ void lcd_clear(void)/* set framebuffer to background color */ #if (LCD_BPP !=LCD_COLOR32 )memset ((char *)lcd_base, -COLOR_MASK (lcd_color_bg), + lcd_color_bg, lcd_line_length * panel_info.vl_row);#else u32 *ppix = lcd_base;
@@ -470,7 +468,7 @@ void lcd_clear(void)for (i =0 ; i < (lcd_line_length * panel_info.vl_row)/NBYTES (panel_info.vl_bpix); i++) { - *ppix++ =COLOR_MASK (lcd_color_bg); + *ppix++ = lcd_color_bg; }#endif #endif
Signature · 1 line
1.9.1
PATCH v2 8/12 lcd: get rid of COLOR_MASK
Quoted 6 lines · Nikita Kiryanov
COLOR_MASKmacro doesn't do anything; Remove it to reduce visual complexity.This is a preparatory step for extracting lcd console code into its own file.
Quoted 6 lines
Signed-off-by Nikita Kiryanov <[email protected]>Cc Anatolij Gustschin <[email protected]>Cc Simon Glass <[email protected]>---
Changes in V2:
- New patch.
Tested on pit, LCD works fine.
PATCH v2 9/12 lcd: introduce getters for bg/fg color
In reply to Nikita KiryanovIntroduce lcd_getbgcolor() and lcd_getfgcolor(), and use them where applicable.
This is a preparatory step for extracting lcd console code into its own file.
c: Anatolij Gustschin <[email protected]>
Cc: Simon Glass <[email protected]>
---
Changes in V2:
- New patch.
common/lcd.c | 20 +++++++++++++++----- include/lcd.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-)
common/lcd.c +15 -5
@@ -186,7 +186,7 @@ static void console_scrollup(void)/* Clear the last rows */ #if (LCD_BPP !=LCD_COLOR32 )memset (lcd_console_address +CONSOLE_SIZE -CONSOLE_ROW_SIZE * rows, - lcd_color_bg, +lcd_getbgcolor (),CONSOLE_ROW_SIZE * rows);#else u32 *ppix = lcd_console_address +
@@ -195,7 +195,7 @@ static void console_scrollup(void)for (i =0 ; i < (CONSOLE_ROW_SIZE * rows) /NBYTES (panel_info.vl_bpix); i++) { - *ppix++ = lcd_color_bg; + *ppix++ =lcd_getbgcolor (); }#endif lcd_sync ();
@@ -342,7 +342,7 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)for (c =0 ; c <8 ; ++c) { *d++ = (bits &0x80 ) ? - lcd_color_fg : lcd_color_bg; +lcd_getfgcolor () :lcd_getbgcolor (); bits <<=1 ; } }
@@ -460,7 +460,7 @@ void lcd_clear(void)/* set framebuffer to background color */ #if (LCD_BPP !=LCD_COLOR32 )memset ((char *)lcd_base, - lcd_color_bg, +lcd_getbgcolor (), lcd_line_length * panel_info.vl_row);#else u32 *ppix = lcd_base;
@@ -468,7 +468,7 @@ void lcd_clear(void)for (i =0 ; i < (lcd_line_length * panel_info.vl_row)/NBYTES (panel_info.vl_bpix); i++) { - *ppix++ = lcd_color_bg; + *ppix++ =lcd_getbgcolor (); }#endif #endif
@@ -575,6 +575,11 @@ static void lcd_setfgcolor(int color) lcd_color_fg = color; } +int lcd_getfgcolor (void ) +{ +return lcd_color_fg; +} +/*----------------------------------------------------------------------*/ static void lcd_setbgcolor (int color)
@@ -582,6 +587,11 @@ static void lcd_setbgcolor(int color) lcd_color_bg = color; } +int lcd_getbgcolor (void ) +{ +return lcd_color_bg; +} +/************************************************************************/ /* ** Chipset depending Bitmap / Logo stuff... */ /************************************************************************/
include/lcd.h +14 -0
@@ -291,6 +291,20 @@ int lcd_get_screen_rows(void);int lcd_get_screen_columns (void );/** +* Get the background color of the LCD +* +* @return background color value +*/ +int lcd_getbgcolor (void ); + +/** +* Get the foreground color of the LCD +* +* @return foreground color value +*/ +int lcd_getfgcolor (void ); + +/** * Set the position of the text cursor * * @param col Column to place cursor (0 = left side)
Signature · 1 line
1.9.1
PATCH v2 9/12 lcd: introduce getters for bg/fg color
Hi Nikita,
Quoted 40 lines · Nikita Kiryanov
Introduce
lcd_getbgcolor()andlcd_getfgcolor(), and use them where applicable.This is a preparatory step for extracting lcd console code into its own file.
Signed-off-by Nikita Kiryanov <[email protected]>c: Anatolij Gustschin <[email protected]>
Cc: Simon Glass <[email protected]>
---
Changes in V2:
- New patch.common/lcd.c | 20 +++++++++++++++----- include/lcd.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-)common/lcd.c +2
-2@@ -186,7 +186,7 @@ static void console_scrollup(void)/* Clear the last rows */ #if (LCD_BPP !=LCD_COLOR32 )memset (lcd_console_address +CONSOLE_SIZE -CONSOLE_ROW_SIZE * rows, - lcd_color_bg, +lcd_getbgcolor (),CONSOLE_ROW_SIZE * rows);#else u32 *ppix = lcd_console_address +@@ -195,7 +195,7 @@ static void console_scrollup(void)for (i =0 ; i < (CONSOLE_ROW_SIZE * rows) /NBYTES (panel_info.vl_bpix); i++) { - *ppix++ = lcd_color_bg; + *ppix++ =lcd_getbgcolor (); }#endif lcd_sync ();
common/lcd.c static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) · line 345
Quoted 5 lines
common/lcd.c +1
-1@@ -342,7 +342,7 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)for (c =0 ; c <8 ; ++c) { *d++ = (bits &0x80 ) ? - lcd_color_fg : lcd_color_bg; +lcd_getfgcolor () :lcd_getbgcolor ();
Won't this slow things down slightly? Should you cache the values at the top?
Quoted 50 lines
common/lcd.c +12
-2bits <<=1 ; } }@@ -460,7 +460,7 @@ void lcd_clear(void)/* set framebuffer to background color */ #if (LCD_BPP !=LCD_COLOR32 )memset ((char *)lcd_base, - lcd_color_bg, +lcd_getbgcolor (), lcd_line_length * panel_info.vl_row);#else u32 *ppix = lcd_base;@@ -468,7 +468,7 @@ void lcd_clear(void)for (i =0 ; i < (lcd_line_length * panel_info.vl_row)/NBYTES (panel_info.vl_bpix); i++) { - *ppix++ = lcd_color_bg; + *ppix++ =lcd_getbgcolor (); }#endif #endif @@ -575,6 +575,11 @@ static void lcd_setfgcolor(int color) lcd_color_fg = color; } +int lcd_getfgcolor (void ) +{ +return lcd_color_fg; +} +/*----------------------------------------------------------------------*/ static void lcd_setbgcolor (int color)@@ -582,6 +587,11 @@ static void lcd_setbgcolor(int color) lcd_color_bg = color; } +int lcd_getbgcolor (void ) +{ +return lcd_color_bg; +} +/************************************************************************/ /* ** Chipset depending Bitmap / Logo stuff... */ /************************************************************************/ include/lcd.h +0
-0
include/lcd.h int lcd_get_screen_rows(void); · line 296
Quoted 6 lines
include/lcd.h +3
-0@@ -291,6 +291,20 @@ int lcd_get_screen_rows(void);int lcd_get_screen_columns (void );/** +* Get the background color of the LCD +* +* @return background color value
This is just the raw value of the pixel in the display I think.
Quoted 15 lines
include/lcd.h +11
-1+*/ +int lcd_getbgcolor (void ); + +/** +* Get the foreground color of the LCD +* +* @return foreground color value +*/ +int lcd_getfgcolor (void ); + +/** * Set the position of the text cursor * * @param col Column to place cursor (0 = left side) --
Quoted 2 lines
1.9.1
Regards,
Simon
PATCH v2 9/12 lcd: introduce getters for bg/fg color
Hi Simon,
Quoted 44 lines · Simon Glass
Hi Nikita,
Quoted 41 lines · Nikita Kiryanov
Introduce
lcd_getbgcolor()andlcd_getfgcolor(), and use them where applicable.This is a preparatory step for extracting lcd console code into its own file.
Signed-off-by Nikita Kiryanov <[email protected]>c: Anatolij Gustschin <[email protected]>
Cc: Simon Glass <[email protected]>
---
Changes in V2:
- New patch.common/lcd.c | 20 +++++++++++++++----- include/lcd.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-)common/lcd.c +2
-2@@ -186,7 +186,7 @@ static void console_scrollup(void)/* Clear the last rows */ #if (LCD_BPP !=LCD_COLOR32 )memset (lcd_console_address +CONSOLE_SIZE -CONSOLE_ROW_SIZE * rows, - lcd_color_bg, +lcd_getbgcolor (),CONSOLE_ROW_SIZE * rows);#else u32 *ppix = lcd_console_address +@@ -195,7 +195,7 @@ static void console_scrollup(void)for (i =0 ; i < (CONSOLE_ROW_SIZE * rows) /NBYTES (panel_info.vl_bpix); i++) { - *ppix++ = lcd_color_bg; + *ppix++ =lcd_getbgcolor (); }#endif lcd_sync ();@@ -342,7 +342,7 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)
Quoted 6 lines
common/lcd.c static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) · line 345
Quoted 4 lines
common/lcd.c +1
-1for (c =0 ; c <8 ; ++c) { *d++ = (bits &0x80 ) ? - lcd_color_fg : lcd_color_bg; +lcd_getfgcolor () :lcd_getbgcolor ();Won't this slow things down slightly?
I suppose.. Although, perhaps the compiler is smart enough to optimize this?
Should you cache the values at the top?
I don't know if it's necessary, but I don't mind doing that.
Quoted 53 lines
Quoted 53 lines
common/lcd.c +12
-2bits <<=1 ; } }@@ -460,7 +460,7 @@ void lcd_clear(void)/* set framebuffer to background color */ #if (LCD_BPP !=LCD_COLOR32 )memset ((char *)lcd_base, - lcd_color_bg, +lcd_getbgcolor (), lcd_line_length * panel_info.vl_row);#else u32 *ppix = lcd_base;@@ -468,7 +468,7 @@ void lcd_clear(void)for (i =0 ; i < (lcd_line_length * panel_info.vl_row)/NBYTES (panel_info.vl_bpix); i++) { - *ppix++ = lcd_color_bg; + *ppix++ =lcd_getbgcolor (); }#endif #endif @@ -575,6 +575,11 @@ static void lcd_setfgcolor(int color) lcd_color_fg = color; } +int lcd_getfgcolor (void ) +{ +return lcd_color_fg; +} +/*----------------------------------------------------------------------*/ static void lcd_setbgcolor (int color)@@ -582,6 +587,11 @@ static void lcd_setbgcolor(int color) lcd_color_bg = color; } +int lcd_getbgcolor (void ) +{ +return lcd_color_bg; +} +/************************************************************************/ /* ** Chipset depending Bitmap / Logo stuff... */ /************************************************************************/ include/lcd.h +0
-0@@ -291,6 +291,20 @@ int lcd_get_screen_rows(void);int lcd_get_screen_columns (void );
Quoted 6 lines
include/lcd.h int lcd_get_screen_rows(void); · line 296
Quoted 4 lines
include/lcd.h +3
-0/** +* Get the background color of the LCD +* +* @return background color value This is just the raw value of the pixel in the display I think.
I'll rephrase it to include a reference to the pixels.
Quoted 22 lines
Quoted 16 lines
include/lcd.h +11
-1+*/ +int lcd_getbgcolor (void ); + +/** +* Get the foreground color of the LCD +* +* @return foreground color value +*/ +int lcd_getfgcolor (void ); + +/** * Set the position of the text cursor * * @param col Column to place cursor (0 = left side) -- Quoted 2 lines
1.9.1
Regards,
Simon
Signature · 2 lines
Regards, Nikita Kiryanov
PATCH v2 10/12 lcd: make lcd_drawchars() independant of lcd_base
In reply to Nikita Kiryanovlcd_logo() has the following return value:
#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO) return (void *)((ulong)lcd_base + BMP_LOGO_HEIGHT * lcd_line_length); #else return (void *)lcd_base;
#endif
This return value gets assigned to lcd_console_address. lcd_console_address is not assigned or modified anywhere else. Thus:
#if defined(CONFIG_LCD_LOGO) && !defined(CONFIG_LCD_INFO_BELOW_LOGO): y' = BMP_LOGO_HEIGHT + y; lcd_base + y' * lcd_line_length == lcd_base + (BMP_LOGO_HEIGHT + y) * lcd_line_length == lcd_base + BMP_LOGO_HEIGHT * lcd_line_length + y * lcd_line_length == lcd_console_address + y * lcd_line_length #else lcd_base + y * lcd_line_length == lcd_console_address + y * lcd_line_length
#endif
This is a preparatory step for extracting lcd console code into its own file.
---
Changes in V2:
- New patch.
common/lcd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
common/lcd.c +2 -5
@@ -317,11 +317,8 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)uchar *dest;ushort row; -#if defined(CONFIG_LCD_LOGO ) && !defined(CONFIG_LCD_INFO_BELOW_LOGO ) - y +=BMP_LOGO_HEIGHT ; -#endif - - dest = (uchar *)(lcd_base + y * lcd_line_length + x *NBITS (LCD_BPP )/8 ); + dest = (uchar *)(lcd_console_address + + y * lcd_line_length + x *NBITS (LCD_BPP ) /8 );for (row =0 ; row <VIDEO_FONT_HEIGHT ; ++row, dest += lcd_line_length) {uchar *s = str;
Signature · 1 line
1.9.1
PATCH v2 11/12 lcd: refactor lcd console stuff into its own file
In reply to Nikita Kiryanovcommon/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.
---
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
common/Makefile +1 -1
@@ -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
common/lcd.c +0 -227
274 lines not on this page · raw message
common/lcd_console.c new file +212 -0
212 lines not on this page · raw message
include/lcd.h +1 -0
@@ -12,6 +12,7 @@#ifndef _LCD_H_#define _LCD_H_ +#include <lcd_console.h> extern char lcd_is_enabled;
include/lcd_console.h new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 12/12 lcd_console: remove unused defines
In reply to Nikita KiryanovCONSOLE_ROW_SECOND, CONSOLE_ROW_LAST, andCONSOLE_SCROLL_SIZE are unused. Remove them.
---
Changes in V2:
- New patch.
common/lcd_console.c | 4 ---- 1 file changed, 4 deletions(-)
common/lcd_console.c +0 -4
@@ -12,11 +12,7 @@#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)static short console_curr_col;static short console_curr_row;
Signature · 1 line
1.9.1
PATCH v2 12/12 lcd_console: remove unused defines
Quoted 9 lines · Nikita Kiryanov
CONSOLE_ROW_SECOND,CONSOLE_ROW_LAST, andCONSOLE_SCROLL_SIZEare unused. Remove them.Signed-off-by Nikita Kiryanov <[email protected]>Cc Anatolij Gustschin <[email protected]>Cc Simon Glass <[email protected]>---
Changes in V2:
- New patch.
Tested on pit, LCD works fine.
v2 cover cleanup and refactor lcd.c
In reply to Nikita KiryanovNOTE: I'm resending this cover letter with a shorter Cc list because the original mail got held up. Sorry for the double post.
This series is a first step towards an end goal of merging all CONFIG_LCD related functionality into CONFIG_VIDEO code. My plan is to start by refactoring lcd.c into something cleaner (less ifdefs) and more modular (split code into multiple files), then possibly refactor CONFIG_VIDEO code if needed, and then
finally: move CONFIG_LCD related functionality over to CONFIG_VIDEO code, replacing as much CONFIG_LCD related code with CONFIG_VIDEO related code as possible.
This specific step eliminates some unused code and refactors lcd console stuff into its own file.
In V2 I broke the last patch of the original series ("lcd: refactor lcd console stuff into its own file") into multiple patches to make it clear what changes had to be done in order to refactor the lcd console code into its own file. These preparatory patches ("lcd: rename console_(row|col)" to "lcd: make lcd_drawchars() independant of lcd_base") are meant to illustrate exactly what changed and where in the transition from lcd.c to lcd_console.c, and are not necesserily code improvements when viewed out of context.
Additional changes in V2:
- Added documentation for the new functions.
The whole series was rebased over current mainline, and compile tested for arm and powerpc.
Nikita Kiryanov (12):
lcd: remove CONFIG_SYS_INVERT_COLORS
lcd: cleanup lcd_drawchars
mpc8xx_lcd: get rid of CONFIG_EDT32F10
lcd: remove LCD_MONOCHROME
lcd: rename console_(row|col)
lcd: replace CONSOLE_(ROWS|COLS) with variables
lcd: expand console api
lcd: get rid of COLOR_MASK
lcd: introduce getters for bg/fg color
lcd: make lcd_drawchars() independant of lcd_base
lcd: refactor lcd console stuff into its own file
lcd_console: remove unused defines
common/Makefile | 2 +- common/lcd.c | 308 +++++---------------------------------------- common/lcd_console.c | 208 ++++++++++++++++++++++++++++++ drivers/video/mpc8xx_lcd.c | 49 +------- drivers/video/pxa_lcd.c | 15 --- include/configs/R360MPI.h | 1 - include/lcd.h | 25 ++-- include/lcd_console.h | 85 +++++++++++++ 8 files changed, 340 insertions(+), 353 deletions(-) create mode 100644 common/lcd_console.c create mode 100644 include/lcd_console.h
Signature · 1 line
1.9.1
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.
---
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
common/Makefile +1 -1
@@ -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
common/lcd.c +0 -227
274 lines not on this page · raw message
common/lcd_console.c new file +212 -0
212 lines not on this page · raw message
include/lcd.h +1 -0
@@ -12,6 +12,7 @@#ifndef _LCD_H_#define _LCD_H_ +#include <lcd_console.h> extern char lcd_is_enabled;
include/lcd_console.h new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 11/12 lcd: refactor lcd console stuff into its own file
Hi Nikita,
Quoted 11 lines · Nikita Kiryanov
common/lcd.cis 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 <[email protected]>Cc Anatolij Gustschin <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Simon Glass <[email protected]>---
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:
Tested on pit, LCD works fine.
Quoted 620 lines
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.hcommon/Makefile +1
-1@@ -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.ocommon/lcd.c +0
-227@@ -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 *VIDEO_FONT_HEIGHT ,' ' ); -} - -/*----------------------------------------------------------------------*/ - -static inline void console_newline (void ) -{ - console_curr_col =0 ; - -/* Check if we need to scroll the terminal */ -if (++console_curr_row >= console_rows) -console_scrollup (); -else -lcd_sync (); -} -/*----------------------------------------------------------------------*/ static void lcd_stub_putc (struct stdio_dev *dev,const char c)@@ -236,121 +135,11 @@ static void lcd_stub_putc(struct stdio_dev *dev, const char c)lcd_putc (c); } -void lcd_putc (const char c) -{ -if (!lcd_is_enabled) { -serial_putc (c); - -return ; - } - -switch (c) { -case '\r' : - console_curr_col =0 ; - -return ; -case '\n' : -console_newline (); - -return ; -case '\t' :/* Tab (8 chars alignment) */ - console_curr_col +=8 ; - console_curr_col &= ~7 ; - -if (console_curr_col >= console_cols) -console_newline (); - -return ; -case '\b' : -console_back (); - -return ; -default : -lcd_putc_xy (console_curr_col *VIDEO_FONT_WIDTH , - console_curr_row *VIDEO_FONT_HEIGHT , c); -if (++console_curr_col >= console_cols) -console_newline (); - } -} - -/*----------------------------------------------------------------------*/ -static void lcd_stub_puts (struct stdio_dev *dev,const char *s) {lcd_puts (s); } -void lcd_puts (const char *s) -{ -if (!lcd_is_enabled) { -serial_puts (s); - -return ; - } - -while (*s) -lcd_putc (*s++); - -lcd_sync (); -} - -/*----------------------------------------------------------------------*/ - -void lcd_printf (const char *fmt, ...) -{ -va_list args; -char buf[CONFIG_SYS_PBSIZE ]; - -va_start (args, fmt); -vsprintf (buf, fmt, args); -va_end (args); - -lcd_puts (buf); -} - -/************************************************************************/ -/* ** Low-Level Graphics Routines */ -/************************************************************************/ - -static void lcd_drawchars (ushort x,ushort y,uchar *str,int count) -{ -uchar *dest; -ushort row; - - dest = (uchar *)(lcd_console_address + - y * lcd_line_length + x *NBITS (LCD_BPP ) /8 ); - -for (row =0 ; row <VIDEO_FONT_HEIGHT ; ++row, dest += lcd_line_length) { -uchar *s = str; -int i; -#if LCD_BPP ==LCD_COLOR16 -ushort *d = (ushort *)dest; -#elif LCD_BPP ==LCD_COLOR32 -u32 *d = (u32 *)dest; -#else -uchar *d = dest; -#endif - -for (i =0 ; i < count; ++i) { -uchar c, bits; - - c = *s++; - bits = video_fontdata[c *VIDEO_FONT_HEIGHT + row]; - -for (c =0 ; c <8 ; ++c) { - *d++ = (bits &0x80 ) ? -lcd_getfgcolor () :lcd_getbgcolor (); - bits <<=1 ; - } - } - } -} - -static inline void lcd_putc_xy (ushort x,ushort y,uchar c) -{ -lcd_drawchars (x, y, &c,1 ); -} -/************************************************************************/ /** Small utility to check that you got the colours right */ /************************************************************************/ @@ -1121,12 +910,6 @@ static int on_splashimage(const char *name, const char *value, enum env_op op,U_BOOT_ENV_CALLBACK (splashimage, on_splashimage);#endif -void lcd_position_cursor (unsigned col,unsigned row) -{ - console_curr_col =min_t (short, col, console_cols -1 ); - console_curr_row =min_t (short, row, console_rows -1 ); -} -int lcd_get_pixel_width (void ) {return panel_info.vl_col;@@ -1137,16 +920,6 @@ int lcd_get_pixel_height(void)return panel_info.vl_row; } -int lcd_get_screen_rows (void ) -{ -return console_rows; -} - -int lcd_get_screen_columns (void ) -{ -return console_cols; -} -#if defined(CONFIG_LCD_DT_SIMPLEFB )static int lcd_dt_simplefb_configure_node (void *blob,int off) {common/lcd_console.c new file +212
-0@@ -0,0 +1,212 @@ +/* +* (C) Copyright 2001-2014 +* DENX Software Engineering -- wd at denx.de +* Compulab Ltd - http://compulab.co.il/ +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <lcd.h> +#include <video_font.h> /* Get font data, width and height */ + +#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) + +static short console_curr_col; +static short console_curr_row; +static short console_cols; +static short console_rows; +static void *lcd_console_address; + +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; +} + +void lcd_position_cursor (unsigned col,unsigned row) +{ + console_curr_col =min_t (short, col, console_cols -1 ); + console_curr_row =min_t (short, row, console_rows -1 ); +} + +int lcd_get_screen_rows (void ) +{ +return console_rows; +} + +int lcd_get_screen_columns (void ) +{ +return console_cols; +} + +static void lcd_drawchars (ushort x,ushort y,uchar *str,int count) +{ +uchar *dest; +ushort row; + + dest = (uchar *)(lcd_console_address + + y * lcd_line_length + x *NBITS (LCD_BPP ) /8 ); + +for (row =0 ; row <VIDEO_FONT_HEIGHT ; ++row, dest += lcd_line_length) { +uchar *s = str; +int i; +#if LCD_BPP ==LCD_COLOR16 +ushort *d = (ushort *)dest; +#elif LCD_BPP ==LCD_COLOR32 +u32 *d = (u32 *)dest; +#else +uchar *d = dest; +#endif + +for (i =0 ; i < count; ++i) { +uchar c, bits; + + c = *s++; + bits = video_fontdata[c *VIDEO_FONT_HEIGHT + row]; + +for (c =0 ; c <8 ; ++c) { + *d++ = (bits &0x80 ) ? +lcd_getfgcolor () :lcd_getbgcolor (); + bits <<=1 ; + } + } + } +} + +static inline void lcd_putc_xy (ushort x,ushort y,uchar c) +{ +lcd_drawchars (x, y, &c,1 ); +} + +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 *VIDEO_FONT_HEIGHT ,' ' ); +} + +static inline void console_newline (void ) +{ + console_curr_col =0 ; + +/* Check if we need to scroll the terminal */ +if (++console_curr_row >= console_rows) +console_scrollup (); +else +lcd_sync (); +} + +void lcd_putc (const char c) +{ +if (!lcd_is_enabled) { +serial_putc (c); + +return ; + } + +switch (c) { +case '\r' : + console_curr_col =0 ; + +return ; +case '\n' : +console_newline (); + +return ; +case '\t' :/* Tab (8 chars alignment) */ + console_curr_col +=8 ; + console_curr_col &= ~7 ; + +if (console_curr_col >= console_cols) +console_newline (); + +return ; +case '\b' : +console_back (); + +return ; +default : +lcd_putc_xy (console_curr_col *VIDEO_FONT_WIDTH , + console_curr_row *VIDEO_FONT_HEIGHT , c); +if (++console_curr_col >= console_cols) +console_newline (); + } +} + +void lcd_puts (const char *s) +{ +if (!lcd_is_enabled) { +serial_puts (s); + +return ; + } + +while (*s) +lcd_putc (*s++); + +lcd_sync (); +} + +void lcd_printf (const char *fmt, ...) +{ +va_list args; +char buf[CONFIG_SYS_PBSIZE ]; + +va_start (args, fmt); +vsprintf (buf, fmt, args); +va_end (args); + +lcd_puts (buf); +}include/lcd.h +1
-0@@ -12,6 +12,7 @@#ifndef _LCD_H_#define _LCD_H_ +#include <lcd_console.h> extern char lcd_is_enabled;include/lcd_console.h new file +73
-0@@ -0,0 +1,85 @@ +/* +* Copyright (C) 2014, Compulab Ltd - http://compulab.co.il/ +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +/* By default we scroll by a single line */ +#ifndef CONFIG_CONSOLE_SCROLL_LINES +#define CONFIG_CONSOLE_SCROLL_LINES 1 +#endif + +/** +* lcd_init_console() - Initialize lcd console parameters +* +* Setup the address of console base, and the number of rows and columns the +* console has. +* +* @address: Console base address +* @rows: Number of rows in the console +* @cols: Number of columns in the console +*/ +void lcd_init_console (void *address,int rows,int cols); + +/** +* lcd_set_col() - Set the number of the current lcd console column +* +* Set the number of the console column where the cursor is. +* +* @col: Column number +*/ +void lcd_set_col (short col); + +/** +* lcd_set_row() - Set the number of the current lcd console row +* +* Set the number of the console row where the cursor is. +* +* @row: Row number +*/ +void lcd_set_row (short row); + +/** +* lcd_position_cursor() - Position the cursor on the screen +* +* Position the cursor at the given coordinates on the screen. +* +* @col: Column number +* @row: Row number +*/ +void lcd_position_cursor (unsigned col,unsigned row); + +/** +* lcd_get_screen_rows() - Get the total number of screen rows +* +* @return: Number of screen rows +*/ +int lcd_get_screen_rows (void ); + +/** +* lcd_get_screen_columns() - Get the total number of screen columns +* +* @return: Number of screen columns +*/ +int lcd_get_screen_columns (void ); + +/** +* lcd_putc() - Print to screen a single character at the location of the cursor +* +* @c: The character to print +*/ +void lcd_putc (const char c); + +/**
include/lcd_console.h line 83
Quoted 10 lines
include/lcd_console.h new file +10
-0+* lcd_puts() - Print to screen a string at the location of the cursor +* +* @s: The string to print +*/ +void lcd_puts (const char *s); + +/** +* lcd_printf() - Print to screen a formatted string at location of the cursor +* +* @s: The string to print
Update comment...
Quoted 5 lines
include/lcd_console.h new file +2
-1+*/ +void lcd_printf (const char *fmt, ...); --1.9.1
Regards,
Simon
v2 cover cleanup and refactor lcd.c
In reply to Nikita KiryanovQuoted 19 lines · Nikita Kiryanov
This series is a first step towards an end goal of merging all
CONFIG_LCDrelated functionality intoCONFIG_VIDEOcode. My plan is to start by refactoringlcd.cinto something cleaner (less ifdefs) and more modular (split code into multiple files), then possibly refactorCONFIG_VIDEOcode if needed, and then
finally: moveCONFIG_LCDrelated functionality over toCONFIG_VIDEOcode, replacing as muchCONFIG_LCDrelated code withCONFIG_VIDEOrelated code as possible.This specific step eliminates some unused code and refactors lcd console stuff into its own file.
In V2 I broke the last patch of the original series ("lcd: refactor lcd console stuff into its own file") into multiple patches to make it clear what changes had to be done in order to refactor the lcd console code into its own file. These preparatory patches ("lcd: rename
console_(row|col)" to "lcd: makelcd_drawchars()independant oflcd_base") are meant to illustrate exactly what changed and where in the transition fromlcd.ctolcd_console.c, and are not necesserily code improvements when viewed out of context.
Quoted 5 lines
Additional changes in V2:
- Added documentation for the new functions.The whole series was rebased over current mainline, and compile tested for arm and powerpc.
HDMI support still seems to work on Raspberry Pi with this applied, so,