xref: /haiku/src/add-ons/accelerants/intel_extreme/Ports.h (revision d8ffdea39e122821c22bb610e965a2823bbd4480)
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 enum port_index {
36 	INTEL_PORT_ANY,				// wildcard for lookup functions
37 	INTEL_PORT_A,
38 	INTEL_PORT_B,
39 	INTEL_PORT_C,
40 	INTEL_PORT_D,
41 	INTEL_PORT_E
42 };
43 
44 
45 class Port {
46 public:
47 									Port(port_index index,
48 										const char* baseName);
49 virtual								~Port();
50 
51 virtual	uint32						Type() const = 0;
52 		const char*					PortName() const
53 										{ return fPortName; }
54 
55 		port_index					PortIndex() const
56 										{ return fPortIndex; }
57 
58 virtual	bool						IsConnected() = 0;
59 
60 		status_t					SetPipe(Pipe* pipe);
61 		::Pipe*						GetPipe()
62 										{ return fPipe; };
63 
64 virtual	status_t					Power(bool enabled);
65 
66 		bool						HasEDID();
67 virtual	status_t					GetEDID(edid1_info* edid,
68 										bool forceRead = false);
69 
70 virtual	status_t					GetPLLLimits(pll_limits& limits);
71 
72 virtual status_t					SetDisplayMode(display_mode* mode,
73 										uint32 colorMode) { return B_ERROR; };
74 
75 virtual pipe_index					PipePreference();
76 //										{ return INTEL_PIPE_ANY; };
77 
78 protected:
79 		void						_SetName(const char* name);
80 
81 static	status_t					_GetI2CSignals(void* cookie, int* _clock,
82 										int* _data);
83 static	status_t					_SetI2CSignals(void* cookie, int clock,
84 										int data);
85 
86 		display_mode				fCurrentMode;
87 		Pipe*						fPipe;
88 
89 		status_t					fEDIDState;
90 		edid1_info					fEDIDInfo;
91 
92 private:
93 virtual	addr_t						_DDCRegister() = 0;
94 virtual addr_t						_PortRegister() = 0;
95 
96 		port_index					fPortIndex;
97 		char*						fPortName;
98 };
99 
100 
101 class AnalogPort : public Port {
102 public:
103 									AnalogPort();
104 
105 virtual	uint32						Type() const
106 										{ return INTEL_PORT_TYPE_ANALOG; }
107 
108 virtual	bool						IsConnected();
109 
110 virtual status_t					SetDisplayMode(display_mode* mode,
111 										uint32 colorMode);
112 
113 protected:
114 virtual	addr_t						_DDCRegister();
115 virtual addr_t						_PortRegister();
116 };
117 
118 
119 class LVDSPort : public Port {
120 public:
121 									LVDSPort();
122 
123 virtual	uint32						Type() const
124 										{ return INTEL_PORT_TYPE_LVDS; }
125 
126 virtual	bool						IsConnected();
127 
128 virtual status_t					SetDisplayMode(display_mode* mode,
129 										uint32 colorMode);
130 
131 virtual pipe_index					PipePreference();
132 
133 protected:
134 virtual	addr_t						_DDCRegister();
135 virtual addr_t						_PortRegister();
136 };
137 
138 
139 class DigitalPort : public Port {
140 public:
141 									DigitalPort(
142 										port_index index = INTEL_PORT_B,
143 										const char* baseName = "DVI");
144 
145 virtual	uint32						Type() const
146 										{ return INTEL_PORT_TYPE_DVI; }
147 
148 virtual	bool						IsConnected();
149 
150 virtual status_t					SetDisplayMode(display_mode* mode,
151 										uint32 colorMode);
152 
153 protected:
154 virtual	addr_t						_DDCRegister();
155 virtual addr_t						_PortRegister();
156 };
157 
158 
159 class HDMIPort : public DigitalPort {
160 public:
161 									HDMIPort(port_index index);
162 
163 virtual	uint32						Type() const
164 										{ return INTEL_PORT_TYPE_HDMI; }
165 
166 virtual	bool						IsConnected();
167 
168 protected:
169 virtual addr_t						_PortRegister();
170 };
171 
172 
173 class DisplayPort : public Port {
174 public:
175 									DisplayPort(port_index index,
176 										const char* baseName = "DisplayPort");
177 
178 virtual	uint32						Type() const
179 										{ return INTEL_PORT_TYPE_DP; }
180 
181 virtual	bool						IsConnected();
182 
183 virtual status_t					SetDisplayMode(display_mode* mode,
184 										uint32 colorMode);
185 
186 virtual pipe_index					PipePreference();
187 
188 protected:
189 virtual	addr_t						_DDCRegister();
190 virtual	addr_t						_PortRegister();
191 
192 private:
193 		status_t					_SetPortLinkGen4(display_mode* target);
194 };
195 
196 
197 class EmbeddedDisplayPort : public DisplayPort {
198 public:
199 									EmbeddedDisplayPort();
200 
201 virtual	uint32						Type() const
202 										{ return INTEL_PORT_TYPE_eDP; }
203 
204 virtual	bool						IsConnected();
205 };
206 
207 
208 class DigitalDisplayInterface : public Port {
209 public:
210 									DigitalDisplayInterface(
211 										port_index index = INTEL_PORT_A,
212 										const char* baseName = "Digital Display Interface");
213 
214 virtual	uint32						Type() const
215 										{ return INTEL_PORT_TYPE_DVI; }
216 
217 virtual	status_t					Power(bool enabled);
218 
219 virtual	bool						IsConnected();
220 
221 virtual status_t					SetDisplayMode(display_mode* mode,
222 										uint32 colorMode);
223 
224 protected:
225 virtual	addr_t						_DDCRegister();
226 virtual addr_t						_PortRegister();
227 private:
228 		uint8						fMaxLanes;
229 };
230 
231 
232 #endif // INTEL_PORTS_H
233