xref: /linux/drivers/gpu/drm/ast/ast_vbios.h (revision 1260ed77798502de9c98020040d2995008de10cc)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright (c) 2005 ASPEED Technology Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and its
6  * documentation for any purpose is hereby granted without fee, provided that
7  * the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of the authors not be used in
10  * advertising or publicity pertaining to distribution of the software without
11  * specific, written prior permission.  The authors makes no representations
12  * about the suitability of this software for any purpose.  It is provided
13  * "as is" without express or implied warranty.
14  *
15  * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
17  * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
19  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21  * PERFORMANCE OF THIS SOFTWARE.
22  */
23 /* Ported from xf86-video-ast driver */
24 
25 #ifndef AST_VBIOS_H
26 #define AST_VBIOS_H
27 
28 #include <linux/types.h>
29 
30 struct ast_device;
31 struct drm_display_mode;
32 
33 #define Charx8Dot               0x00000001
34 #define HalfDCLK                0x00000002
35 #define DoubleScanMode          0x00000004
36 #define LineCompareOff          0x00000008
37 #define HBorder                 0x00000020
38 #define VBorder                 0x00000010
39 #define WideScreenMode		0x00000100
40 #define NewModeInfo		0x00000200
41 #define NHSync			0x00000400
42 #define PHSync			0x00000800
43 #define NVSync			0x00001000
44 #define PVSync			0x00002000
45 #define SyncPP			(PVSync | PHSync)
46 #define SyncPN			(PVSync | NHSync)
47 #define SyncNP			(NVSync | PHSync)
48 #define SyncNN			(NVSync | NHSync)
49 #define AST2500PreCatchCRT		0x00004000
50 
51 /* DCLK Index */
52 #define VCLK25_175		0x00
53 #define VCLK28_322		0x01
54 #define VCLK31_5		0x02
55 #define VCLK36			0x03
56 #define VCLK40			0x04
57 #define VCLK49_5		0x05
58 #define VCLK50			0x06
59 #define VCLK56_25		0x07
60 #define VCLK65			0x08
61 #define VCLK75			0x09
62 #define VCLK78_75		0x0a
63 #define VCLK94_5		0x0b
64 #define VCLK108			0x0c
65 #define VCLK135			0x0d
66 #define VCLK157_5		0x0e
67 #define VCLK162			0x0f
68 /* #define VCLK193_25		0x10 */
69 #define VCLK154			0x10
70 #define VCLK83_5		0x11
71 #define VCLK106_5		0x12
72 #define VCLK146_25		0x13
73 #define VCLK148_5		0x14
74 #define VCLK71			0x15
75 #define VCLK88_75		0x16
76 #define VCLK119			0x17
77 #define VCLK85_5		0x18
78 #define VCLK97_75		0x19
79 #define VCLK118_25		0x1a
80 
81 struct ast_vbios_enhtable {
82 	u32 ht;
83 	u32 hde;
84 	u32 hfp;
85 	u32 hsync;
86 	u32 vt;
87 	u32 vde;
88 	u32 vfp;
89 	u32 vsync;
90 	u32 dclk_index;
91 	u32 flags;
92 	u32 refresh_rate;
93 	u32 refresh_rate_index;
94 	u32 mode_id;
95 };
96 
97 #define AST_VBIOS_INVALID_MODE \
98 	{0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}
99 
100 static inline bool ast_vbios_mode_is_valid(const struct ast_vbios_enhtable *vmode)
101 {
102 	return vmode->ht && vmode->vt && vmode->refresh_rate;
103 }
104 
105 const struct ast_vbios_enhtable *ast_vbios_find_mode(const struct ast_device *ast,
106 						     const struct drm_display_mode *mode);
107 
108 #endif
109