Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Christian Trefzer <ctrefzer@gmx.de>
To: linux-fbdev-devel@lists.sourceforge.net,
	lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] neofb: fix unblank logic interfering with lid toggled backlight
Date: Sat, 3 Jun 2006 15:52:58 +0200	[thread overview]
Message-ID: <20060603135258.GB16012@zeus.uziel.local> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 3329 bytes --]

This is a fix for the most annoying problem that remained with neofb:

After "setterm -powersave powerdown" the console blanker will disable
the backlight after the given timeout expires. If this happens after the
lid has been shut, we read "LCD off" from the register and store that in
the driver. Once the lid is opened, the backlight turns on, but any key
press that would awaken the blanked console will switch the backlight
off again.

The workaround so far was to use the "display config toggle" Fn key
combo - once if no external display is attached, otherwise as often as
required to restore the desired display setup.

The following patch fixes the issue at least for the LCD-only case, with
no external monitor attached. Other display setup permutations are
pending further testing, but so far I can guarantee at least no negative
change in behaviour, if any at all.


Signed-off-by: Christian Trefzer <ctrefzer@gmx.de>
---

diff --git a/drivers/video/neofb.c b/drivers/video/neofb.c
index 24b12f7..1a06229 100644
--- a/drivers/video/neofb.c
+++ b/drivers/video/neofb.c
@@ -1333,17 +1333,22 @@ static int neofb_blank(int blank_mode, s
 	 *  run "setterm -powersave powerdown" to take advantage
 	 */
 	struct neofb_par *par = info->par;
-	int seqflags, lcdflags, dpmsflags, reg;
+	int seqflags, lcdflags, dpmsflags, reg, tmpdisp;
 
-
-	/*
-	 * Reload the value stored in the register, if sensible. It might have
-	 * been changed via FN keystroke.
+	/* 
+	 * Read back the register bits related to display configuration. They might
+	 * have been changed underneath the driver via Fn key stroke.
+	 */
+	neoUnlock();
+	tmpdisp = vga_rgfx(NULL, 0x20) & 0x03;
+	neoLock(&par->state);
+	
+	/* In case we blank the screen, we want to store the possibly new
+	 * configuration in the driver. During un-blank, we re-apply this setting,
+	 * since the LCD bit will be cleared in order to switch off the backlight.
 	 */
 	if (par->PanelDispCntlRegRead) {
-		neoUnlock();
-		par->PanelDispCntlReg1 = vga_rgfx(NULL, 0x20) & 0x03;
-		neoLock(&par->state);
+		par->PanelDispCntlReg1 = tmpdisp;
 	}
 	par->PanelDispCntlRegRead = !blank_mode;
 
@@ -1378,12 +1383,21 @@ #endif
 		break;
 	case FB_BLANK_NORMAL:		/* just blank screen (backlight stays on) */
 		seqflags = VGA_SR01_SCREEN_OFF;	/* Disable sequencer */
-		lcdflags = par->PanelDispCntlReg1 & 0x02; /* LCD normal */
+		/*
+		 * During a blank operation with the LID shut, we might store "LCD off"
+		 * by mistake. Due to timing issues, the BIOS may switch the lights
+		 * back on, and we turn it back off once we "unblank".
+		 *
+		 * So here is an attempt to implement ">=" - if we are in the process
+		 * of unblanking, and the LCD bit is unset in the driver but set in the
+		 * register, we must keep it.
+		 */
+		lcdflags = ((par->PanelDispCntlReg1 | tmpdisp) & 0x02); /* LCD normal */
 		dpmsflags = 0x00;	/* no hsync/vsync suppression */
 		break;
 	case FB_BLANK_UNBLANK:		/* unblank */
 		seqflags = 0;			/* Enable sequencer */
-		lcdflags = par->PanelDispCntlReg1 & 0x02; /* LCD normal */
+		lcdflags = ((par->PanelDispCntlReg1 | tmpdisp) & 0x02); /* LCD normal */
 		dpmsflags = 0x00;	/* no hsync/vsync suppression */
 #ifdef CONFIG_TOSHIBA
 		/* Do we still need this ? */

[-- Attachment #1.2: Type: application/pgp-signature, Size: 829 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 182 bytes --]

_______________________________________________
Linux-fbdev-devel mailing list
Linux-fbdev-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel

                 reply	other threads:[~2006-06-03 13:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20060603135258.GB16012@zeus.uziel.local \
    --to=ctrefzer@gmx.de \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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