xref: /haiku/src/add-ons/accelerants/intel_extreme/Ports.h (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
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 		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 //										{ return INTEL_PIPE_ANY; };
68 
69 protected:
70 		void						_SetName(const char* name);
71 
72 static	status_t					_GetI2CSignals(void* cookie, int* _clock,
73 										int* _data);
74 static	status_t					_SetI2CSignals(void* cookie, int clock,
75 										int data);
76 
77 		display_mode				fCurrentMode;
78 		Pipe*						fPipe;
79 
80 		status_t					fEDIDState;
81 		edid1_info					fEDIDInfo;
82 
83 private:
84 virtual	addr_t						_DDCRegister() = 0;
85 virtual addr_t						_PortRegister() = 0;
86 
87 		port_index					fPortIndex;
88 		char*						fPortName;
89 };
90 
91 
92 class AnalogPort : public Port {
93 public:
94 									AnalogPort();
95 
96 virtual	uint32						Type() const
97 										{ return INTEL_PORT_TYPE_ANALOG; }
98 
99 virtual	bool						IsConnected();
100 
101 virtual status_t					SetDisplayMode(display_mode* mode,
102 										uint32 colorMode);
103 
104 protected:
105 virtual	addr_t						_DDCRegister();
106 virtual addr_t						_PortRegister();
107 };
108 
109 
110 class LVDSPort : public Port {
111 public:
112 									LVDSPort();
113 
114 virtual	uint32						Type() const
115 										{ return INTEL_PORT_TYPE_LVDS; }
116 
117 virtual	bool						IsConnected();
118 
119 virtual status_t					SetDisplayMode(display_mode* mode,
120 										uint32 colorMode);
121 
122 virtual pipe_index					PipePreference();
123 
124 protected:
125 virtual	addr_t						_DDCRegister();
126 virtual addr_t						_PortRegister();
127 };
128 
129 
130 class DigitalPort : public Port {
131 public:
132 									DigitalPort(
133 										port_index index = INTEL_PORT_B,
134 										const char* baseName = "DVI");
135 
136 virtual	uint32						Type() const
137 										{ return INTEL_PORT_TYPE_DVI; }
138 
139 virtual	bool						IsConnected();
140 
141 virtual status_t					SetDisplayMode(display_mode* mode,
142 										uint32 colorMode);
143 
144 protected:
145 virtual	addr_t						_DDCRegister();
146 virtual addr_t						_PortRegister();
147 };
148 
149 
150 class HDMIPort : public DigitalPort {
151 public:
152 									HDMIPort(port_index index);
153 
154 virtual	uint32						Type() const
155 										{ return INTEL_PORT_TYPE_HDMI; }
156 
157 virtual	bool						IsConnected();
158 
159 protected:
160 virtual addr_t						_PortRegister();
161 };
162 
163 
164 class DisplayPort : public Port {
165 public:
166 									DisplayPort(port_index index,
167 										const char* baseName = "DisplayPort");
168 
169 virtual	uint32						Type() const
170 										{ return INTEL_PORT_TYPE_DP; }
171 
172 virtual	bool						IsConnected();
173 
174 virtual status_t					SetDisplayMode(display_mode* mode,
175 										uint32 colorMode);
176 
177 virtual pipe_index					PipePreference();
178 
179 protected:
180 virtual	addr_t						_DDCRegister();
181 virtual	addr_t						_PortRegister();
182 
183 private:
184 		status_t					_SetPortLinkGen4(const display_timing& timing);
185 };
186 
187 
188 class EmbeddedDisplayPort : public DisplayPort {
189 public:
190 									EmbeddedDisplayPort();
191 
192 virtual	uint32						Type() const
193 										{ return INTEL_PORT_TYPE_eDP; }
194 
195 virtual	bool						IsConnected();
196 };
197 
198 
199 class DigitalDisplayInterface : public Port {
200 public:
201 									DigitalDisplayInterface(
202 										port_index index = INTEL_PORT_A,
203 										const char* baseName = "Digital Display Interface");
204 
205 virtual	uint32						Type() const
206 										{ return INTEL_PORT_TYPE_DVI; }
207 
208 virtual	status_t					Power(bool enabled);
209 
210 virtual	bool						IsConnected();
211 
212 virtual status_t					SetDisplayMode(display_mode* mode,
213 										uint32 colorMode);
214 
215 protected:
216 virtual	addr_t						_DDCRegister();
217 virtual addr_t						_PortRegister();
218 private:
219 		uint8						fMaxLanes;
220 
221 		status_t					_SetPortLinkGen8(const display_timing& timing,
222 										uint32 pllSel);
223 };
224 
225 
226 #endif // INTEL_PORTS_H
227