auxdisplay: charlcd: make backlight initial state configurable
authorMans Rullgard <mans@mansr.com>
Fri, 1 Mar 2019 18:48:16 +0000 (18:48 +0000)
committerMiguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Sun, 17 Mar 2019 07:48:45 +0000 (08:48 +0100)
The charlcd driver currently flashes the backlight once on init.
This may not be desirable.  Thus, add options for turning the
backlight off or on as well.

Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
drivers/auxdisplay/Kconfig
drivers/auxdisplay/charlcd.c

index 7d3fe27d6868c72b8989c45dc74ff28629148e77..c52c738e554a2dfe8e660973ce8a2685d9a1934b 100644 (file)
@@ -445,6 +445,27 @@ config PANEL_BOOT_MESSAGE
          An empty message will only clear the display at driver init time. Any other
          printf()-formatted message is valid with newline and escape codes.
 
+choice
+       prompt "Backlight initial state"
+       default CHARLCD_BL_FLASH
+
+       config CHARLCD_BL_OFF
+               bool "Off"
+               help
+                 Backlight is initially turned off
+
+       config CHARLCD_BL_ON
+               bool "On"
+               help
+                 Backlight is initially turned on
+
+       config CHARLCD_BL_FLASH
+               bool "Flash"
+               help
+                 Backlight is flashed briefly on init
+
+endchoice
+
 endif # AUXDISPLAY
 
 config PANEL
index 5212675564d783f37b2c3b6f344594dadd94ce84..92745efefb540e5d723f5bbaa3aefd11735b0f29 100644 (file)
@@ -769,6 +769,14 @@ static void charlcd_puts(struct charlcd *lcd, const char *s)
 #define LCD_INIT_TEXT "Linux-" UTS_RELEASE "\n"
 #endif
 
+#ifdef CONFIG_CHARLCD_BL_ON
+#define LCD_INIT_BL "\x1b[L+"
+#elif defined(CONFIG_CHARLCD_BL_FLASH)
+#define LCD_INIT_BL "\x1b[L*"
+#else
+#define LCD_INIT_BL "\x1b[L-"
+#endif
+
 /* initialize the LCD driver */
 static int charlcd_init(struct charlcd *lcd)
 {
@@ -790,7 +798,7 @@ static int charlcd_init(struct charlcd *lcd)
                return ret;
 
        /* display a short message */
-       charlcd_puts(lcd, "\x1b[Lc\x1b[Lb\x1b[L*" LCD_INIT_TEXT);
+       charlcd_puts(lcd, "\x1b[Lc\x1b[Lb" LCD_INIT_BL LCD_INIT_TEXT);
 
        /* clear the display on the next device opening */
        priv->must_clear = true;