xref: /freebsd/sys/dev/videomode/vesagtf.h (revision d0b2dbfa)
1 /*	$NetBSD$	*/
2 
3 /*-
4  * Copyright (c) 2006 Itronix Inc.
5  * All rights reserved.
6  *
7  * Written by Garrett D'Amore for Itronix Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of Itronix Inc. may not be used to endorse
18  *    or promote products derived from this software without specific
19  *    prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND ANY EXPRESS
22  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef _DEV_VIDEOMODE_VESAGTF_H
35 #define _DEV_VIDEOMODE_VESAGTF_H
36 
37 /*
38  * Use VESA GTF formula to generate a monitor mode, given resolution and
39  * refresh rates.
40  */
41 
42 struct vesagtf_params {
43 	unsigned	margin_ppt;	/* vertical margin size, percent * 10
44 					 * think parts-per-thousand */
45 	unsigned	min_porch;	/* minimum front porch */
46 	unsigned	vsync_rqd;	/* width of vsync in lines */
47 	unsigned	hsync_pct;	/* hsync as % of total width */
48 	unsigned	min_vsbp;	/* minimum vsync + back porch (usec) */
49 	unsigned	M;		/* blanking formula gradient */
50 	unsigned	C;		/* blanking formula offset */
51 	unsigned	K;		/* blanking formula scaling factor */
52 	unsigned	J;		/* blanking formula scaling factor */
53 };
54 
55 /*
56  * Default values to use for params.
57  */
58 #define	VESAGTF_MARGIN_PPT	18	/* 1.8% */
59 #define	VESAGTF_MIN_PORCH	1	/* minimum front porch */
60 #define	VESAGTF_VSYNC_RQD	3	/* vsync width in lines */
61 #define	VESAGTF_HSYNC_PCT	8	/* width of hsync % of total line */
62 #define	VESAGTF_MIN_VSBP	550	/* min vsync + back porch (usec) */
63 #define	VESAGTF_M		600	/* blanking formula gradient */
64 #define	VESAGTF_C		40	/* blanking formula offset */
65 #define	VESAGTF_K		128	/* blanking formula scaling factor */
66 #define	VESAGTF_J		20	/* blanking formula scaling factor */
67 
68 /*
69  * Use VESA GTF formula to generate monitor timings.  Assumes default
70  * GTF parameters, non-interlaced, and no margins.
71  */
72 void vesagtf_mode(unsigned x, unsigned y, unsigned refresh,
73     struct videomode *);
74 
75 /*
76  * A more complete version, in case we ever want to use alternate GTF
77  * parameters.  EDID 1.3 allows for "secondary GTF parameters".
78  */
79 void vesagtf_mode_params(unsigned x, unsigned y, unsigned refresh,
80     struct vesagtf_params *, int flags, struct videomode *);
81 
82 #define	VESAGTF_FLAG_ILACE	0x0001		/* use interlace */
83 #define	VESAGTF_FLAG_MARGINS	0x0002		/* use margins */
84 
85 #endif /* _DEV_VIDEOMODE_VESAGTF_H */
86