linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fbdev: Fix usage of blank value passed to fb_blank
       [not found]     ` <200601282106.21664.ioe-lkml@rameria.de>
@ 2006-01-29  2:18       ` Antonino A. Daplas
  2006-01-29  8:18         ` Andrew Morton
  2006-01-29 14:42         ` Ville Syrjälä
  0 siblings, 2 replies; 7+ messages in thread
From: Antonino A. Daplas @ 2006-01-29  2:18 UTC (permalink / raw)
  To: Andrew Morton, Linux Fbdev development list
  Cc: Ingo Oeser, linux-kernel, David S. Miller, benh, linux-kernel

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 <adaplas@pol.net>
---

Ingo Oeser wrote:
> > 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] fbdev: Fix usage of blank value passed to fb_blank
  2006-01-29  2:18       ` [PATCH] fbdev: Fix usage of blank value passed to fb_blank Antonino A. Daplas
@ 2006-01-29  8:18         ` Andrew Morton
  2006-01-29 10:40           ` Antonino A. Daplas
  2006-01-29 14:42         ` Ville Syrjälä
  1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2006-01-29  8:18 UTC (permalink / raw)
  To: Antonino A. Daplas
  Cc: linux-fbdev-devel, ioe-lkml, linux-kernel, davem, benh,
	linux-kernel

"Antonino A. Daplas" <adaplas@gmail.com> wrote:
>
> 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.

Would prefer to avoid any userland breakage.  Is this followup patch
happening?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fbdev: Fix usage of blank value passed to fb_blank
  2006-01-29  8:18         ` Andrew Morton
@ 2006-01-29 10:40           ` Antonino A. Daplas
  0 siblings, 0 replies; 7+ messages in thread
From: Antonino A. Daplas @ 2006-01-29 10:40 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-fbdev-devel, ioe-lkml, linux-kernel, davem, benh,
	linux-kernel

Andrew Morton wrote:
> "Antonino A. Daplas" <adaplas@gmail.com> wrote:
>> 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.
> 
> Would prefer to avoid any userland breakage.  Is this followup patch
> happening?

I'm still doing research on which major fb apps depend on the FB_BLANK constants, but
my guess is that the follow up patch is inevitable. We cannot avoid bending over
backwards for X :(

Tony

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fbdev: Fix usage of blank value passed to fb_blank
  2006-01-29  2:18       ` [PATCH] fbdev: Fix usage of blank value passed to fb_blank Antonino A. Daplas
  2006-01-29  8:18         ` Andrew Morton
@ 2006-01-29 14:42         ` Ville Syrjälä
  2006-01-29 22:19           ` Antonino A. Daplas
  2006-01-29 23:34           ` Antonino A. Daplas
  1 sibling, 2 replies; 7+ messages in thread
From: Ville Syrjälä @ 2006-01-29 14:42 UTC (permalink / raw)
  To: linux-fbdev-devel
  Cc: Andrew Morton, Ingo Oeser, linux-kernel, David S. Miller, benh,
	linux-kernel

On Sun, Jan 29, 2006 at 10:18:19AM +0800, Antonino A. Daplas wrote:
> 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.

Since when? X.Org uses numbers 0,2,3,4 which match the FB_BLANK 
constants not the VESA constants.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/


-------------------------------------------------------
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\x103432&bid#0486&dat\x121642

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fbdev: Fix usage of blank value passed to fb_blank
  2006-01-29 14:42         ` Ville Syrjälä
@ 2006-01-29 22:19           ` Antonino A. Daplas
  2006-01-29 23:34           ` Antonino A. Daplas
  1 sibling, 0 replies; 7+ messages in thread
From: Antonino A. Daplas @ 2006-01-29 22:19 UTC (permalink / raw)
  To: linux-fbdev-devel, Andrew Morton, Ingo Oeser, linux-kernel,
	David S. Miller, benh, linux-kernel

Ville Syrjälä wrote:
> On Sun, Jan 29, 2006 at 10:18:19AM +0800, Antonino A. Daplas wrote:
>> 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.
> 
> Since when? X.Org uses numbers 0,2,3,4 which match the FB_BLANK 
> constants not the VESA constants.
> 

Hmm, you're correct... But I do remember that particular error before,
about FBIOBLANK returning -EINVAL. I think it may be coming from 
this particular code


Bool
fbdevHWSaveScreen(ScreenPtr pScreen, int mode)
{
	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
	fbdevHWPtr fPtr = FBDEVHWPTR(pScrn);
	unsigned long unblank;

	TRACE_ENTER("HWSaveScreen");
	if (!pScrn->vtSema)
		return TRUE;

	unblank = xf86IsUnblank(mode);

	if (-1 == ioctl(fPtr->fd, FBIOBLANK, (void *)(1-unblank))) {
		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
			   "FBIOBLANK: %s\n", strerror(errno));
		return FALSE;
	}

	return TRUE;
}

The FBIOBLANK ioctl call passes only 2 possible values, 0 and 1
(1-unblank).

Andrew, 

I think you should drop this patch, Xorg/XFree86's fbdevhw DPMS support
does the correct thing. It's only the above that may be producing the
particular error as reported by David. I'm not sure how to fix that
(kernel or X side).


Tony


-------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fbdev: Fix usage of blank value passed to fb_blank
  2006-01-29 14:42         ` Ville Syrjälä
  2006-01-29 22:19           ` Antonino A. Daplas
@ 2006-01-29 23:34           ` Antonino A. Daplas
  2006-01-30 10:22             ` Geert Uytterhoeven
  1 sibling, 1 reply; 7+ messages in thread
From: Antonino A. Daplas @ 2006-01-29 23:34 UTC (permalink / raw)
  To: linux-fbdev-devel, Andrew Morton, Ingo Oeser, linux-kernel,
	David S. Miller, benh, linux-kernel

Ville Syrjälä wrote:
> On Sun, Jan 29, 2006 at 10:18:19AM +0800, Antonino A. Daplas wrote:
>> 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.
> 
> Since when? X.Org uses numbers 0,2,3,4 which match the FB_BLANK 
> constants not the VESA constants.
> 

How about if we silently convert FB_BLANK_NORMAL requests to
FB_BLANK_VSYNC_SUSPEND, would that work?

Tony

PS: Soft blanking is very difficult, if not impossible, to
implement correctly kernel-side, so we can either fail (current
code), silently fail but return success, or convert to the next
blank level.


-------------------------------------------------------
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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] fbdev: Fix usage of blank value passed to fb_blank
  2006-01-29 23:34           ` Antonino A. Daplas
@ 2006-01-30 10:22             ` Geert Uytterhoeven
  0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2006-01-30 10:22 UTC (permalink / raw)
  To: Linux Frame Buffer Device Development
  Cc: Andrew Morton, Ingo Oeser, Linux Kernel Development,
	David S. Miller, Benjamin Herrenschmidt, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: TEXT/PLAIN; charset=UTF-8, Size: 1390 bytes --]

On Mon, 30 Jan 2006, Antonino A. Daplas wrote:
> Ville Syrjälä wrote:
> > On Sun, Jan 29, 2006 at 10:18:19AM +0800, Antonino A. Daplas wrote:
> >> 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.
> > 
> > Since when? X.Org uses numbers 0,2,3,4 which match the FB_BLANK 
> > constants not the VESA constants.
> > 
> 
> How about if we silently convert FB_BLANK_NORMAL requests to
> FB_BLANK_VSYNC_SUSPEND, would that work?

Do all (old, pre-VESA) monitors like it when vsync goes away?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-01-30 10:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20060127231314.GA28324@hansmi.ch>
     [not found] ` <20060127.204645.96477793.davem@davemloft.net>
     [not found]   ` <43DB0839.6010703@gmail.com>
     [not found]     ` <200601282106.21664.ioe-lkml@rameria.de>
2006-01-29  2:18       ` [PATCH] fbdev: Fix usage of blank value passed to fb_blank Antonino A. Daplas
2006-01-29  8:18         ` Andrew Morton
2006-01-29 10:40           ` Antonino A. Daplas
2006-01-29 14:42         ` Ville Syrjälä
2006-01-29 22:19           ` Antonino A. Daplas
2006-01-29 23:34           ` Antonino A. Daplas
2006-01-30 10:22             ` Geert Uytterhoeven

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).