2 * linux/drivers/video/fbmon.c
4 * Copyright (C) 1999 James Simmons
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
11 * This code handles the different types of monitors that are out their.
12 * Most video cards for example can support a mode like 800x600 but fix
13 * frequency monitors can't. So the code here checks if the monitor can
14 * support the mode as well as the card can. Fbmonospecs takes on
15 * different meaning with different types of monitors. For multifrequency
16 * monitors fbmonospecs represents the range of frequencies the monitor
17 * can support. Only one fbmonospec needs to be allocated. The fbmonospecs
18 * pointer in fb_info points to this one. If you specific a mode that has
19 * timing greater than the allowed range then setting the video mode will
20 * fail. With multifrequency monitors you can set any mode you like as long
21 * as you have a programmable clock on the video card.
22 * With fixed frequency monitors you have only a SET of very narrow
23 * allowed frequency ranges. So for a fixed fequency monitor you have a
24 * array of fbmonospecs. The fbmonospecs in fb_info represents the
25 * monitor frequency for the CURRENT mode. If you change the mode and ask
26 * for fbmonospecs you will NOT get the same values as before. Note this
27 * is not true for multifrequency monitors where you do get the same
28 * fbmonospecs each time. Also the values in each fbmonospecs represent the
29 * very narrow frequency band for range. Well you can't have exactly the
30 * same frequencies from fixed monitor. So some tolerance is excepted.
31 * By DEFAULT all monitors are assumed fixed frequency since they are so
32 * easy to fry or screw up a mode with. Just try setting a 800x600 mode on
33 * one. After you boot you can run a simple program the tells what kind of
34 * monitor you have. If you have a multifrequency monitor then you can set
35 * any mode size you like as long as your video card has a programmable clock.
36 * By default also besides assuming you have a fixed frequency monitor it
37 * assumes the monitor only supports lower modes. This way for example you
38 * can't set a 1280x1024 mode on a fixed frequency monitor that can only
39 * support up to 1024x768.
42 #include <linux/tty.h>
44 #include <linux/module.h>
46 int fbmon_valid_timings(u_int pixclock, u_int htotal, u_int vtotal,
47 const struct fb_info *fb_info)
51 * long long divisions .... $#%%#$
53 unsigned long long hpicos, vpicos;
54 const unsigned long long _1e12 = 1000000000000ULL;
55 const struct fb_monspecs *monspecs = &fb_info->monspecs;
57 hpicos = (unsigned long long)htotal*(unsigned long long)pixclock;
58 vpicos = (unsigned long long)vtotal*(unsigned long long)hpicos;
62 if (monspecs->hfmin == 0)
65 if (hpicos*monspecs->hfmin > _1e12 || hpicos*monspecs->hfmax < _1e12 ||
66 vpicos*monspecs->vfmin > _1e12 || vpicos*monspecs->vfmax < _1e12)
72 int fbmon_dpms(const struct fb_info *fb_info)
74 return fb_info->monspecs.dpms;
77 EXPORT_SYMBOL(fbmon_valid_timings);