xref: /haiku/src/add-ons/accelerants/intel_extreme/Ports.h (revision 9e25244c5e9051f6cd333820d6332397361abd6c)
1 /*
2  * Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Lotz, mmlr@mlotz.ch
7  *		Alexander von Gluck IV, kallisti5@unixzen.com
8  */
9 #ifndef INTEL_PORTS_H
10 #define INTEL_PORTS_H
11 
12 
13 #include <edid.h>
14 
15 #include "intel_extreme.h"
16 
17 #include "Pipes.h"
18 #include "pll.h"
19 
20 
21 #define MAX_PORTS	20	// a generous upper bound
22 
23 struct pll_limits;
24 
25 enum port_type {
26 	INTEL_PORT_TYPE_ANY,		// wildcard for lookup functions
27 	INTEL_PORT_TYPE_ANALOG,
28 	INTEL_PORT_TYPE_DVI,
29 	INTEL_PORT_TYPE_LVDS,
30 	INTEL_PORT_TYPE_DP,
31 	INTEL_PORT_TYPE_eDP,
32 	INTEL_PORT_TYPE_HDMI
33 };
34 
35 
36 class Port {
37 public:
38 									Port(port_index index,
39 										const char* baseName);
40 virtual								~Port();
41 
42 virtual	uint32						Type() const = 0;
43 		const char*					PortName() const
44 										{ return fPortName; }
45 
46 		port_index					PortIndex() const
47 										{ return fPortIndex; }
48 
49 virtual	bool						IsConnected() = 0;
50 
51 virtual	status_t					SetPipe(Pipe* pipe);
52 		::Pipe*						GetPipe()
53 										{ return fPipe; };
54 
55 virtual	status_t					Power(bool enabled);
56 
57 		bool						HasEDID();
58 virtual	status_t					GetEDID(edid1_info* edid,
59 										bool forceRead = false);
60 
61 virtual	status_t					GetPLLLimits(pll_limits& limits);
62 
63 virtual status_t					SetDisplayMode(display_mode* mode,
64 										uint32 colorMode) { return B_ERROR; };
65 
66 virtual pipe_index					PipePreference();
67 
68 protected:
69 		void						_SetName(const char* name);
70 
71 static	status_t					_GetI2CSignals(void* cookie, int* _clock,
72 										int* _data);
73 static	status_t					_SetI2CSignals(void* cookie, int clock,
74 										int data);
75 
76 		display_mode				fCurrentMode;
77 		Pipe*						fPipe;
78 
79 		status_t					fEDIDState;
80 		edid1_info					fEDIDInfo;
81 
82 private:
83 virtual	addr_t						_DDCRegister() = 0;
84 virtual addr_t						_PortRegister() = 0;
85 
86 		port_index					fPortIndex;
87 		char*						fPortName;
88 };
89 
90 
91 class AnalogPort : public Port {
92 public:
93 									AnalogPort();
94 
95 virtual	uint32						Type() const
96 										{ return INTEL_PORT_TYPE_ANALOG; }
97 
98 virtual	bool						IsConnected();
99 
100 virtual status_t					SetDisplayMode(display_mode* mode,
101 										uint32 colorMode);
102 
103 protected:
104 virtual	addr_t						_DDCRegister();
105 virtual addr_t						_PortRegister();
106 };
107 
108 
109 class LVDSPort : public Port {
110 public:
111 									LVDSPort();
112 
113 virtual	uint32						Type() const
114 										{ return INTEL_PORT_TYPE_LVDS; }
115 
116 virtual	bool						IsConnected();
117 
118 virtual status_t					SetDisplayMode(display_mode* mode,
119 										uint32 colorMode);
120 
121 virtual pipe_index					PipePreference();
122 
123 protected:
124 virtual	addr_t						_DDCRegister();
125 virtual addr_t						_PortRegister();
126 };
127 
128 
129 class DigitalPort : public Port {
130 public:
131 									DigitalPort(
132 										port_index index = INTEL_PORT_B,
133 										const char* baseName = "DVI");
134 
135 virtual	uint32						Type() const
136 										{ return INTEL_PORT_TYPE_DVI; }
137 
138 virtual	bool						IsConnected();
139 
140 virtual status_t					SetDisplayMode(display_mode* mode,
141 										uint32 colorMode);
142 
143 protected:
144 virtual	addr_t						_DDCRegister();
145 virtual addr_t						_PortRegister();
146 };
147 
148 
149 class HDMIPort : public DigitalPort {
150 public:
151 									HDMIPort(port_index index);
152 
153 virtual	uint32						Type() const
154 										{ return INTEL_PORT_TYPE_HDMI; }
155 
156 virtual	bool						IsConnected();
157 
158 protected:
159 virtual addr_t						_PortRegister();
160 };
161 
162 
163 class DisplayPort : public Port {
164 public:
165 									DisplayPort(port_index index,
166 										const char* baseName = "DisplayPort");
167 
168 virtual	uint32						Type() const
169 										{ return INTEL_PORT_TYPE_DP; }
170 
171 virtual	status_t					SetPipe(Pipe* pipe);
172 
173 virtual	bool						IsConnected();
174 
175 virtual status_t					SetDisplayMode(display_mode* mode,
176 										uint32 colorMode);
177 
178 virtual pipe_index					PipePreference();
179 
180 protected:
181 virtual	addr_t						_DDCRegister();
182 virtual	addr_t						_PortRegister();
183 
184 private:
185 		status_t					_SetPortLinkGen4(const display_timing& timing);
186 		status_t					_SetPortLinkGen6(const display_timing& timing);
187 };
188 
189 
190 class EmbeddedDisplayPort : public DisplayPort {
191 public:
192 									EmbeddedDisplayPort();
193 
194 virtual	uint32						Type() const
195 										{ return INTEL_PORT_TYPE_eDP; }
196 
197 virtual	bool						IsConnected();
198 };
199 
200 
201 class DigitalDisplayInterface : public Port {
202 public:
203 									DigitalDisplayInterface(
204 										port_index index = INTEL_PORT_A,
205 										const char* baseName = "Digital Display Interface");
206 
207 virtual	uint32						Type() const
208 										{ return INTEL_PORT_TYPE_DVI; }
209 
210 virtual	status_t					Power(bool enabled);
211 
212 virtual	status_t					SetPipe(Pipe* pipe);
213 
214 virtual	bool						IsConnected();
215 
216 virtual status_t					SetDisplayMode(display_mode* mode,
217 										uint32 colorMode);
218 
219 protected:
220 virtual	addr_t						_DDCRegister();
221 virtual addr_t						_PortRegister();
222 private:
223 		uint8						fMaxLanes;
224 
225 		status_t					_SetPortLinkGen8(const display_timing& timing,
226 										uint32 pllSel);
227 };
228 
229 
230 #endif // INTEL_PORTS_H
231