Thread (7 messages) 7 messages, 4 authors, 2006-01-30

[PATCH] fbdev: Fix usage of blank value passed to fb_blank

STALE7552d

From: "Antonino A. Daplas" <adaplas@gmail.com>
Date: 2006-01-29 02:19:11
Also in: lkml
Subsystem: framebuffer layer, the rest · Maintainers: Helge Deller, Linus Torvalds

The fb_blank() hook accepts 5 blanking levels which include 1 level designed
for console use only.  Userspace is only aware of 4 levels. Thus, it's
possible for userspace to request VESA_VSYNC_SUSPEND which, in turn, is
interpreted by the fb driver as a request for FB_BLANK_NORMAL. A few drivers
return -EINVAL for this, confusing userspace apps that the driver may not
have VESA blanking support.

Fix by incrementing the blank value by one if the request originated from
userspace.

Signed-off-by: Antonino Daplas <redacted>
---

Ingo Oeser wrote:
quoted
May I suggest to hide this implementation detail?
Yes.  The change will be invisible to drivers.

Unfortunately, this may cause some userland breakage.  X should work.
However, some apps may have been developed that uses the FB_BLANK constants
(DirectFB?).  In these cases, they'll get a deeper blank level instead, so it
probably won't affect them significantly.  A follow up patch that hides the 
FB_BLANK constants may be worthwhile.

 drivers/video/fbmem.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index d2dede6..5bed0fb 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -843,6 +843,19 @@ fb_blank(struct fb_info *info, int blank
 {	
  	int ret = -EINVAL;
 
+	/*
+	 * The framebuffer core supports 5 blanking levels (FB_BLANK), whereas
+	 * VESA defined only 4.  The extra level, FB_BLANK_NORMAL, is a
+	 * console invention and is not related to power management.
+	 * Unfortunately, fb_blank callers, especially X, pass VESA constants
+	 * leading to undefined behavior.
+	 *
+	 * To avoid confusion, fb_blank will assume VESA constants if coming
+	 * from userspace, and FB_BLANK constants if coming from the kernel.
+	 */
+	if (info->flags & FBINFO_MISC_USEREVENT && blank)
+		blank++;
+
  	if (blank > FB_BLANK_POWERDOWN)
  		blank = FB_BLANK_POWERDOWN;
 



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help