xref: /haiku/src/add-ons/accelerants/intel_extreme/Ports.h (revision 44d19f4d32b8f7e9c01f00294c87ca5cc2e057f7)
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 										{ return INTEL_PIPE_B; };
133 
134 protected:
135 virtual	addr_t						_DDCRegister();
136 virtual addr_t						_PortRegister();
137 };
138 
139 
140 class DigitalPort : public Port {
141 public:
142 									DigitalPort(
143 										port_index index = INTEL_PORT_B,
144 										const char* baseName = "DVI");
145 
146 virtual	uint32						Type() const
147 										{ return INTEL_PORT_TYPE_DVI; }
148 
149 virtual	bool						IsConnected();
150 
151 virtual status_t					SetDisplayMode(display_mode* mode,
152 										uint32 colorMode);
153 
154 protected:
155 virtual	addr_t						_DDCRegister();
156 virtual addr_t						_PortRegister();
157 };
158 
159 
160 class HDMIPort : public DigitalPort {
161 public:
162 									HDMIPort(port_index index);
163 
164 virtual	uint32						Type() const
165 										{ return INTEL_PORT_TYPE_HDMI; }
166 
167 virtual	bool						IsConnected();
168 
169 protected:
170 virtual addr_t						_PortRegister();
171 };
172 
173 
174 class DisplayPort : public Port {
175 public:
176 									DisplayPort(port_index index,
177 										const char* baseName = "DisplayPort");
178 
179 virtual	uint32						Type() const
180 										{ return INTEL_PORT_TYPE_DP; }
181 
182 virtual	bool						IsConnected();
183 
184 virtual status_t					SetDisplayMode(display_mode* mode,
185 										uint32 colorMode);
186 
187 protected:
188 virtual	addr_t						_DDCRegister();
189 virtual	addr_t						_PortRegister();
190 };
191 
192 
193 class EmbeddedDisplayPort : public DisplayPort {
194 public:
195 									EmbeddedDisplayPort();
196 
197 virtual	uint32						Type() const
198 										{ return INTEL_PORT_TYPE_eDP; }
199 
200 virtual	bool						IsConnected();
201 };
202 
203 
204 class DigitalDisplayInterface : public Port {
205 public:
206 									DigitalDisplayInterface(
207 										port_index index = INTEL_PORT_A,
208 										const char* baseName = "Digital Display Interface");
209 
210 virtual	uint32						Type() const
211 										{ return INTEL_PORT_TYPE_DVI; }
212 
213 virtual	status_t					Power(bool enabled);
214 
215 virtual	bool						IsConnected();
216 
217 virtual status_t					SetDisplayMode(display_mode* mode,
218 										uint32 colorMode);
219 
220 protected:
221 virtual	addr_t						_DDCRegister();
222 virtual addr_t						_PortRegister();
223 private:
224 		uint8						fMaxLanes;
225 };
226 
227 
228 #endif // INTEL_PORTS_H
229