cleanup and refactor lcd.c
v3 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.
The patches ("lcd: rename console_(row|col)" to
"lcd: make lcd_drawchars() independant of lcd_base") are preparatory patches 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.
Changes in V3:
- Function documentation
- Cache values of lcd_get(bg|fg)color() instead of calling the functions multiple times.
The whole series was rebased over current mainline, and compile tested for arm and powerpc.
Entire series:
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 | 313 +++++---------------------------------------- common/lcd_console.c | 211 ++++++++++++++++++++++++++++++ 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 | 86 +++++++++++++ 8 files changed, 347 insertions(+), 355 deletions(-) create mode 100644 common/lcd_console.c create mode 100644 include/lcd_console.h
Signature · 1 line
1.9.1
PATCH v3 1/12 lcd: remove CONFIG_SYS_INVERT_COLORS
No one is using CONFIG_SYS_INVERT_COLORS; remove related code.
---
Changes in V3:
- No changes.
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 v3 2/12 lcd: cleanup lcd_drawchars
In reply to Nikita KiryanovRemove code duplication from lcd_drawchars().
---
Changes in V3:
- No changes.
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 v3 3/12 mpc8xx_lcd: get rid of CONFIG_EDT32F10
In reply to Nikita KiryanovNo one is using CONFIG_EDT32F10; remove related code.
---
Changes in V3:
- No changes.
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 v3 4/12 lcd: remove LCD_MONOCHROME
In reply to Nikita KiryanovNo one is using LCD_MONOCHROME; remove related code.
---
Changes in V3:
- No changes.
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 v3 5/12 lcd: rename console_(row|col)
In reply to Nikita KiryanovRename console_(row|col) to console_curr_(row|col) to better distinguish it from console_(rows|cols).
This is a preparatory step for extracting lcd console code into its own file.
---
Changes in V3:
- No changes.
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 v3 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 V3:
- No changes.
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
PATCH v3 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 V3:
- No changes.
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 v3 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 V3:
- No changes.
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 v3 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.
---
Changes in V3:
- Instead of invoking lcd_get(bg|fg)color() each time, do it only once and cache the value. This is done in console_scrollup(), lcd_drawchars(), and drv_lcd_init().
Changes in V2:
- New patch.
common/lcd.c | 31 ++++++++++++++++++++++--------- include/lcd.h | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-)
common/lcd.c +22 -9
@@ -177,6 +177,7 @@ void lcd_set_row(short row)static void console_scrollup (void ) {const int rows =CONFIG_CONSOLE_SCROLL_LINES ; +int bg_color =lcd_getbgcolor ();/* Copy up rows ignoring those that will be overwritten */ memcpy(CONSOLE_ROW_FIRST,
@@ -186,8 +187,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, -CONSOLE_ROW_SIZE * rows); + bg_color,CONSOLE_ROW_SIZE * rows);#else u32 *ppix = lcd_console_address +CONSOLE_SIZE -CONSOLE_ROW_SIZE * rows;
@@ -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++ = bg_color; }#endif lcd_sync ();
@@ -316,6 +316,7 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) {uchar *dest;ushort row; +int fg_color, bg_color;#if defined(CONFIG_LCD_LOGO ) && !defined(CONFIG_LCD_INFO_BELOW_LOGO ) y +=BMP_LOGO_HEIGHT ;
@@ -334,6 +335,8 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)uchar *d = dest;#endif + fg_color =lcd_getfgcolor (); + bg_color =lcd_getbgcolor ();for (i =0 ; i < count; ++i) {uchar c, bits;
@@ -341,8 +344,7 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count) bits = video_fontdata[c *VIDEO_FONT_HEIGHT + row];for (c =0 ; c <8 ; ++c) { - *d++ = (bits &0x80 ) ? - lcd_color_fg : lcd_color_bg; + *d++ = (bits &0x80 ) ? fg_color : bg_color; bits <<=1 ; } }
@@ -433,6 +435,7 @@ int drv_lcd_init(void)void lcd_clear (void ) {short console_rows, console_cols; +int bg_color;#if LCD_BPP ==LCD_COLOR8 /* Setting the palette */ lcd_setcolreg (CONSOLE_COLOR_BLACK ,0 ,0 ,0 );
@@ -449,9 +452,11 @@ void lcd_clear(void)#ifndef CONFIG_SYS_WHITE_ON_BLACK lcd_setfgcolor (CONSOLE_COLOR_BLACK );lcd_setbgcolor (CONSOLE_COLOR_WHITE ); + bg_color =CONSOLE_COLOR_WHITE ;#else lcd_setfgcolor (CONSOLE_COLOR_WHITE );lcd_setbgcolor (CONSOLE_COLOR_BLACK ); + bg_color =CONSOLE_COLOR_BLACK ;#endif /* CONFIG_SYS_WHITE_ON_BLACK */ #ifdef LCD_TEST_PATTERN
@@ -459,16 +464,14 @@ void lcd_clear(void)#else /* set framebuffer to background color */ #if (LCD_BPP !=LCD_COLOR32 ) -memset ((char *)lcd_base, - lcd_color_bg, - lcd_line_length * panel_info.vl_row); +memset ((char *)lcd_base, bg_color, lcd_line_length * panel_info.vl_row);#else u32 *ppix = lcd_base;u32 i;for (i =0 ; i < (lcd_line_length * panel_info.vl_row)/NBYTES (panel_info.vl_bpix); i++) { - *ppix++ = lcd_color_bg; + *ppix++ = bg_color; }#endif #endif
@@ -575,6 +578,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 +590,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 v3 9/12 lcd: introduce getters for bg/fg color
Quoted 9 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]>Cc Anatolij Gustschin <[email protected]>Cc Simon Glass <[email protected]>
Quoted 12 lines
---
Changes in V3:
- Instead of invoking lcd_get(bg|fg)color() each time, do it only once and cache the value. This is done inconsole_scrollup(),lcd_drawchars(), anddrv_lcd_init().Changes in V2:
- New patch.common/lcd.c | 31 ++++++++++++++++++++++--------- include/lcd.h | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-)
PATCH v3 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 V3:
- No changes.
Changes in V2:
- New patch.
common/lcd.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
common/lcd.c +2 -5
@@ -318,11 +318,8 @@ static void lcd_drawchars(ushort x, ushort y, uchar *str, int count)ushort row;int fg_color, bg_color; -#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 v3 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 V3:
- Updated comment for lcd_printf().
Changes in V2:
- New patch.
common/Makefile | 2 +- common/lcd.c | 229 -------------------------------------------------- common/lcd_console.c | 215 +++++++++++++++++++++++++++++++++++++++++++++++ include/lcd.h | 1 + include/lcd_console.h | 86 +++++++++++++++++++ 5 files changed, 303 insertions(+), 230 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 -229
276 lines not on this page · raw message
common/lcd_console.c new file +215 -0
215 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 +86 -0
86 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 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 V3:
- No changes.
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
v3 cover cleanup and refactor lcd.c
In reply to Nikita KiryanovGentle ping.
Quoted 60 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.
The patches ("lcd: rename
console_(row|col)" to
"lcd: makelcd_drawchars()independant oflcd_base") are preparatory patches 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.Changes in V3:
- Function documentation
- Cache values of lcd_get(bg|fg)color() instead of calling the functions multiple times.The whole series was rebased over current mainline, and compile tested for arm and powerpc.
Cc Anatolij Gustschin <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>Entire series:
Tested-by Stephen Warren <[email protected]>Tested-by Simon Glass <[email protected]>Nikita Kiryanov (12):
lcd: removeCONFIG_SYS_INVERT_COLORS
lcd: cleanuplcd_drawchars
mpc8xx_lcd: get rid ofCONFIG_EDT32F10
lcd: removeLCD_MONOCHROME
lcd: renameconsole_(row|col)
lcd: replaceCONSOLE_(ROWS|COLS)with variables
lcd: expand console api
lcd: get rid ofCOLOR_MASK
lcd: introduce getters for bg/fg color
lcd: makelcd_drawchars()independant oflcd_base
lcd: refactor lcd console stuff into its own file
lcd_console: remove unused definescommon/Makefile | 2 +- common/lcd.c | 313 +++++---------------------------------------- common/lcd_console.c | 211 ++++++++++++++++++++++++++++++ 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 | 86 +++++++++++++ 8 files changed, 347 insertions(+), 355 deletions(-)create mode 100644
common/lcd_console.c
create mode 100644include/lcd_console.h
Signature · 2 lines
Regards, Nikita Kiryanov
v3 cover cleanup and refactor lcd.c
Hi Nikita,
Quoted 75 lines · Nikita Kiryanov
Gentle ping.
Quoted 71 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.The patches ("lcd: rename
console_(row|col)" to
"lcd: makelcd_drawchars()independant oflcd_base") are preparatory patches
meant to illustrate exactly what changed and where in the transition fromlcd.c
tolcd_console.c, and are not necesserily code improvements when viewed out of
context.Changes in V3:
- Function documentation
- Cache values of lcd_get(bg|fg)color() instead of calling the
functions
multiple times.The whole series was rebased over current mainline, and compile tested for arm
and powerpc.Cc Anatolij Gustschin <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>Entire series:
Tested-by Stephen Warren <[email protected]>Tested-by Simon Glass <[email protected]>Nikita Kiryanov (12):
lcd: removeCONFIG_SYS_INVERT_COLORS
lcd: cleanuplcd_drawchars
mpc8xx_lcd: get rid ofCONFIG_EDT32F10
lcd: removeLCD_MONOCHROME
lcd: renameconsole_(row|col)
lcd: replaceCONSOLE_(ROWS|COLS)with variables
lcd: expand console api
lcd: get rid ofCOLOR_MASK
lcd: introduce getters for bg/fg color
lcd: makelcd_drawchars()independant oflcd_base
lcd: refactor lcd console stuff into its own file
lcd_console: remove unused definescommon/Makefile | 2 +- common/lcd.c | 313 +++++---------------------------------------- common/lcd_console.c | 211 ++++++++++++++++++++++++++++++ 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 | 86 +++++++++++++ 8 files changed, 347 insertions(+), 355 deletions(-)create mode 100644
common/lcd_console.c
create mode 100644include/lcd_console.h
I think Anatolij will be applying this. Does it go into this release?
Regards,
Simon
v3 cover cleanup and refactor lcd.c
In reply to Nikita KiryanovGentle ping.
Quoted 60 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.
The patches ("lcd: rename
console_(row|col)" to
"lcd: makelcd_drawchars()independant oflcd_base") are preparatory patches 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.Changes in V3:
- Function documentation
- Cache values of lcd_get(bg|fg)color() instead of calling the functions multiple times.The whole series was rebased over current mainline, and compile tested for arm and powerpc.
Cc Anatolij Gustschin <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Simon Glass <[email protected]>Cc Stephen Warren <[email protected]>Entire series:
Tested-by Stephen Warren <[email protected]>Tested-by Simon Glass <[email protected]>Nikita Kiryanov (12):
lcd: removeCONFIG_SYS_INVERT_COLORS
lcd: cleanuplcd_drawchars
mpc8xx_lcd: get rid ofCONFIG_EDT32F10
lcd: removeLCD_MONOCHROME
lcd: renameconsole_(row|col)
lcd: replaceCONSOLE_(ROWS|COLS)with variables
lcd: expand console api
lcd: get rid ofCOLOR_MASK
lcd: introduce getters for bg/fg color
lcd: makelcd_drawchars()independant oflcd_base
lcd: refactor lcd console stuff into its own file
lcd_console: remove unused definescommon/Makefile | 2 +- common/lcd.c | 313 +++++---------------------------------------- common/lcd_console.c | 211 ++++++++++++++++++++++++++++++ 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 | 86 +++++++++++++ 8 files changed, 347 insertions(+), 355 deletions(-)create mode 100644
common/lcd_console.c
create mode 100644include/lcd_console.h
Signature · 2 lines
Regards, Nikita Kiryanov
v3 cover cleanup and refactor lcd.c
Hi Nikita,
Quoted 1 line · On Thu, 08 Jan 2015 14:26:06 +0200 Nikita Kiryanov <[email protected]>…
Gentle ping.
sorry for delay and thanks for your patience. Series now applied to u-boot-video/next.
Thanks,
Anatolij