diff mbox

[U-Boot,V2,06/12] lcd: replace CONSOLE_(ROWS|COLS) with variables

Message ID 1417350585-22669-7-git-send-email-nikita@compulab.co.il
State Superseded
Delegated to: Anatolij Gustschin
Headers show

Commit Message

Nikita Kiryanov Nov. 30, 2014, 12:29 p.m. UTC
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 <nikita@compulab.co.il>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Simon Glass <sjg@chromium.org>
---
Changes in V2:
	- New patch.

 common/lcd.c | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

Comments

Nikita Kiryanov Dec. 2, 2014, 11:34 a.m. UTC | #1
Hi Simon,

On 11/30/2014 09:25 PM, Simon Glass wrote:
> On 30 November 2014 at 05:29, Nikita Kiryanov <nikita@compulab.co.il> wrote:
>> 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 <nikita@compulab.co.il>
>> Cc: Anatolij Gustschin <agust@denx.de>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>> Changes in V2:
>>          - New patch.
>
> 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.

>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> Tested on pit, LCD works fine.
>
> Tested-by: Simon Glass <sjg@chromium.org>
>

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?
Simon Glass Dec. 2, 2014, 5:38 p.m. UTC | #2
On 30 November 2014 at 05:29, Nikita Kiryanov <nikita@compulab.co.il> wrote:
> 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 <nikita@compulab.co.il>
> Cc: Anatolij Gustschin <agust@denx.de>
> Cc: Simon Glass <sjg@chromium.org>

Acked-by: Simon Glass <sjg@chromium.org>

Tested on pit, LCD works fine.

Tested-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/common/lcd.c b/common/lcd.c
index 371f4a2..f8fff90 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -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)