PATCH: FrameBuffer Monitor Functions [now with patch attached :-)]
Hi,
this patch is to avoid the cooking of monitors from inside the framebuffer subsystem. Normally this would be made by fbmon_valid_timings function, but actually this function does nothing. So i start writing a new implementation that will make some checks, note that is not the full answer because it requires to user use another data structures normally don't used, but for now it checks the basic stuff. bye
Signature · 2 lines
"Solo me arrepiento de unos * de menos y unos ++ de sobra" Carlos Manuel Duclos Vergara
drivers/video/fbmon.c +39 -16
@@ -46,31 +46,54 @@int fbmon_valid_timings (u_int pixclock,u_int htotal,u_int vtotal,const struct fb_info *fb_info) { -#if 0 /* -* long long divisions .... $#%%#$ +* Ohhh, i discover the Secret of Ramses II tomb! +* _PLEASE_ note that this is only worth if you _FILL_ _UP_ +* a fb_monspecs with your monitor specs! +* If you don't do that, this will only check for vesa compatible +* modes at some "generic" multifrequency monitors! (not done yet) +* I will think in how to auto detect monitors, or maybe how you can tell in +* runtime what kind of monitor do you have. +* If you want to know the progress of that, email me at: [email protected] +* Note 1: I don't assume nothing, so in htotal & vtotal use your values... +* if you want a sugestion use: htotal = hres * 1.2 and vtotal = vres * 1.1 +* Note 2: We only need to calculate one thing to see if your monitor will cook +* (please don't blame me if it cooks anyway, you must be aware that this function +* do its best to check but is not _the_ final answer! */ -unsigned long long hpicos, vpicos; -const unsigned long long _1e12 =1000000000000ULL ; -const struct fb_monspecs *monspecs = &fb_info->monspecs; - hpicos = (unsigned long long )htotal*(unsigned long long )pixclock; - vpicos = (unsigned long long )vtotal*(unsigned long long )hpicos; -if (!vpicos) -return 0 ; - -if (monspecs->hfmin ==0 ) +if ( !fb_info->monspecs ) + { +/* +* Dear God... +*/ +printk (KERN_INFO "fb: We could not check your monitor, due lack of monspecs!\n" );return 1 ; - -if (hpicos*monspecs->hfmin > _1e12 || hpicos*monspecs->hfmax < _1e12 || - vpicos*monspecs->vfmin > _1e12 || vpicos*monspecs->vfmax < _1e12) + } + +if ( pixelclock > (fb_info->monspecs.hfmax * htotal) ) + { +/* +* We will cook this monitor! +*/ +printk (KERN_INFO "fb: To avoid cooking your monitor we won't use this resolution!\n" );return 0 ; -#endif -return 1 ; + } + +/* +* If we get here, we're safe (almost) +*/ + +return 1 ; }int fbmon_dpms (const struct fb_info *fb_info) { +if ( !fb_info->monspecs ) + { +printk (KERN_INFO "fb: No monspecs!\n" ); +return -EINVAL ; + }return fb_info->monspecs.dpms; }