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