1278798Shselasky/*	$NetBSD$	*/
2278798Shselasky/*	$FreeBSD: releng/11.0/sys/dev/videomode/vesagtf.h 278798 2015-02-15 11:37:40Z hselasky $	*/
3278798Shselasky
4278798Shselasky/*-
5278798Shselasky * Copyright (c) 2006 Itronix Inc.
6278798Shselasky * All rights reserved.
7278798Shselasky *
8278798Shselasky * Written by Garrett D'Amore for Itronix Inc.
9278798Shselasky *
10278798Shselasky * Redistribution and use in source and binary forms, with or without
11278798Shselasky * modification, are permitted provided that the following conditions
12278798Shselasky * are met:
13278798Shselasky * 1. Redistributions of source code must retain the above copyright
14278798Shselasky *    notice, this list of conditions and the following disclaimer.
15278798Shselasky * 2. Redistributions in binary form must reproduce the above copyright
16278798Shselasky *    notice, this list of conditions and the following disclaimer in the
17278798Shselasky *    documentation and/or other materials provided with the distribution.
18278798Shselasky * 3. The name of Itronix Inc. may not be used to endorse
19278798Shselasky *    or promote products derived from this software without specific
20278798Shselasky *    prior written permission.
21278798Shselasky *
22278798Shselasky * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND ANY EXPRESS
23278798Shselasky * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24278798Shselasky * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25278798Shselasky * ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
26278798Shselasky * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27278798Shselasky * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28278798Shselasky * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29278798Shselasky * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30278798Shselasky * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31278798Shselasky * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32278798Shselasky * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33278798Shselasky */
34278798Shselasky
35278798Shselasky#ifndef _DEV_VIDEOMODE_VESAGTF_H
36278798Shselasky#define _DEV_VIDEOMODE_VESAGTF_H
37278798Shselasky
38278798Shselasky/*
39278798Shselasky * Use VESA GTF formula to generate a monitor mode, given resolution and
40278798Shselasky * refresh rates.
41278798Shselasky */
42278798Shselasky
43278798Shselaskystruct vesagtf_params {
44278798Shselasky	unsigned	margin_ppt;	/* vertical margin size, percent * 10
45278798Shselasky					 * think parts-per-thousand */
46278798Shselasky	unsigned	min_porch;	/* minimum front porch */
47278798Shselasky	unsigned	vsync_rqd;	/* width of vsync in lines */
48278798Shselasky	unsigned	hsync_pct;	/* hsync as % of total width */
49278798Shselasky	unsigned	min_vsbp;	/* minimum vsync + back porch (usec) */
50278798Shselasky	unsigned	M;		/* blanking formula gradient */
51278798Shselasky	unsigned	C;		/* blanking formula offset */
52278798Shselasky	unsigned	K;		/* blanking formula scaling factor */
53278798Shselasky	unsigned	J;		/* blanking formula scaling factor */
54278798Shselasky};
55278798Shselasky
56278798Shselasky/*
57278798Shselasky * Default values to use for params.
58278798Shselasky */
59278798Shselasky#define	VESAGTF_MARGIN_PPT	18	/* 1.8% */
60278798Shselasky#define	VESAGTF_MIN_PORCH	1	/* minimum front porch */
61278798Shselasky#define	VESAGTF_VSYNC_RQD	3	/* vsync width in lines */
62278798Shselasky#define	VESAGTF_HSYNC_PCT	8	/* width of hsync % of total line */
63278798Shselasky#define	VESAGTF_MIN_VSBP	550	/* min vsync + back porch (usec) */
64278798Shselasky#define	VESAGTF_M		600	/* blanking formula gradient */
65278798Shselasky#define	VESAGTF_C		40	/* blanking formula offset */
66278798Shselasky#define	VESAGTF_K		128	/* blanking formula scaling factor */
67278798Shselasky#define	VESAGTF_J		20	/* blanking formula scaling factor */
68278798Shselasky
69278798Shselasky/*
70278798Shselasky * Use VESA GTF formula to generate monitor timings.  Assumes default
71278798Shselasky * GTF parameters, non-interlaced, and no margins.
72278798Shselasky */
73278798Shselaskyvoid vesagtf_mode(unsigned x, unsigned y, unsigned refresh,
74278798Shselasky    struct videomode *);
75278798Shselasky
76278798Shselasky/*
77278798Shselasky * A more complete version, in case we ever want to use alternate GTF
78278798Shselasky * parameters.  EDID 1.3 allows for "secondary GTF parameters".
79278798Shselasky */
80278798Shselaskyvoid vesagtf_mode_params(unsigned x, unsigned y, unsigned refresh,
81278798Shselasky    struct vesagtf_params *, int flags, struct videomode *);
82278798Shselasky
83278798Shselasky#define	VESAGTF_FLAG_ILACE	0x0001		/* use interlace */
84278798Shselasky#define	VESAGTF_FLAG_MARGINS	0x0002		/* use margins */
85278798Shselasky
86278798Shselasky#endif /* _DEV_VIDEOMODE_VESAGTF_H */
87