linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>,
	linux-media@vger.kernel.org
Subject: [PATCH 3/5] auxdisplay: charlcd: add escape sequence for brightness on NEC µPD16314
Date: Mon, 15 Jan 2018 09:58:22 +0000	[thread overview]
Message-ID: <259fa00659be126f371ecfa4d75a7830107c3eea.1516008708.git.sean@mess.org> (raw)
In-Reply-To: <cover.1516008708.git.sean@mess.org>
In-Reply-To: <cover.1516008708.git.sean@mess.org>

The NEC µPD16314 can alter the the brightness of the LCD. Make it possible
to set this via escape sequence Y0 - Y3. B and R were already taken, so
I picked Y for luminance.

Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/auxdisplay/charlcd.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/auxdisplay/charlcd.c b/drivers/auxdisplay/charlcd.c
index a16c72779722..7a671ad959d1 100644
--- a/drivers/auxdisplay/charlcd.c
+++ b/drivers/auxdisplay/charlcd.c
@@ -39,6 +39,8 @@
 #define LCD_FLAG_F		0x0020	/* Large font mode */
 #define LCD_FLAG_N		0x0040	/* 2-rows mode */
 #define LCD_FLAG_L		0x0080	/* Backlight enabled */
+#define LCD_BRIGHTNESS_MASK	0x0300	/* Brightness */
+#define LCD_BRIGHTNESS_SHIFT	8
 
 /* LCD commands */
 #define LCD_CMD_DISPLAY_CLEAR	0x01	/* Clear entire display */
@@ -490,6 +492,17 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
 		charlcd_gotoxy(lcd);
 		processed = 1;
 		break;
+	case 'Y':	/* brightness (luma) */
+		switch (esc[1]) {
+		case '0':	/* 25% */
+		case '1':	/* 50% */
+		case '2':	/* 75% */
+		case '3':	/* 100% */
+			priv->flags = (priv->flags & ~(LCD_BRIGHTNESS_MASK)) |
+				(('3' - esc[1]) << LCD_BRIGHTNESS_SHIFT);
+			processed =  1;
+			break;
+		}
 	}
 
 	/* TODO: This indent party here got ugly, clean it! */
@@ -507,12 +520,15 @@ static inline int handle_lcd_special_code(struct charlcd *lcd)
 			((priv->flags & LCD_FLAG_C) ? LCD_CMD_CURSOR_ON : 0) |
 			((priv->flags & LCD_FLAG_B) ? LCD_CMD_BLINK_ON : 0));
 	/* check whether one of F,N flags was changed */
-	else if ((oldflags ^ priv->flags) & (LCD_FLAG_F | LCD_FLAG_N))
+	else if ((oldflags ^ priv->flags) & (LCD_FLAG_F | LCD_FLAG_N |
+					     LCD_BRIGHTNESS_MASK))
 		lcd->ops->write_cmd(lcd,
 			LCD_CMD_FUNCTION_SET |
 			((lcd->ifwidth == 8) ? LCD_CMD_DATA_LEN_8BITS : 0) |
 			((priv->flags & LCD_FLAG_F) ? LCD_CMD_FONT_5X10_DOTS : 0) |
-			((priv->flags & LCD_FLAG_N) ? LCD_CMD_TWO_LINES : 0));
+			((priv->flags & LCD_FLAG_N) ? LCD_CMD_TWO_LINES : 0) |
+			((priv->flags & LCD_BRIGHTNESS_MASK) >>
+							LCD_BRIGHTNESS_SHIFT));
 	/* check whether L flag was changed */
 	else if ((oldflags ^ priv->flags) & LCD_FLAG_L)
 		charlcd_backlight(lcd, !!(priv->flags & LCD_FLAG_L));
-- 
2.14.3

  parent reply	other threads:[~2018-01-15  9:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  9:58 [PATCH 0/5] new driver for Ahanix D.Vine 5 IR/VFD Sean Young
2018-01-15  9:58 ` [PATCH 1/5] auxdisplay: charlcd: no need to call charlcd_gotoxy() if nothing changes Sean Young
2018-02-12 13:42   ` Miguel Ojeda
2018-02-12 13:59     ` Geert Uytterhoeven
2018-02-12 17:30       ` Miguel Ojeda
2018-01-15  9:58 ` [PATCH 2/5] auxdisplay: charlcd: add flush function Sean Young
2018-02-12 20:44   ` Miguel Ojeda
2018-02-13 13:47     ` Andy Shevchenko
2018-01-15  9:58 ` Sean Young [this message]
2018-02-12 11:56   ` [PATCH 3/5] auxdisplay: charlcd: add escape sequence for brightness on NEC µPD16314 Miguel Ojeda
2018-02-13 17:34     ` Sean Young
2018-01-15  9:58 ` [PATCH 4/5] media: rc: add keymap for Dign Remote Sean Young
2018-01-15  9:58 ` [PATCH 5/5] media: rc: new driver for Sasem Remote Controller VFD/IR Sean Young

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=259fa00659be126f371ecfa4d75a7830107c3eea.1516008708.git.sean@mess.org \
    --to=sean@mess.org \
    --cc=linux-media@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).