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 <dp.h> 14 #include <edid.h> 15 16 #include "intel_extreme.h" 17 18 #include "Pipes.h" 19 #include "pll.h" 20 21 22 #define MAX_PORTS 20 // a generous upper bound 23 24 struct pll_limits; 25 struct i2c_bus; 26 27 enum port_type { 28 INTEL_PORT_TYPE_ANY, // wildcard for lookup functions 29 INTEL_PORT_TYPE_ANALOG, 30 INTEL_PORT_TYPE_DVI, 31 INTEL_PORT_TYPE_LVDS, 32 INTEL_PORT_TYPE_DP, 33 INTEL_PORT_TYPE_eDP, 34 INTEL_PORT_TYPE_HDMI 35 }; 36 37 38 class Port { 39 public: 40 Port(port_index index, 41 const char* baseName); 42 virtual ~Port(); 43 44 virtual uint32 Type() const = 0; 45 const char* PortName() const 46 { return fPortName; } 47 48 port_index PortIndex() const 49 { return fPortIndex; } 50 51 virtual bool IsConnected() = 0; 52 53 virtual status_t SetPipe(Pipe* pipe); 54 ::Pipe* GetPipe() 55 { return fPipe; }; 56 57 virtual status_t Power(bool enabled); 58 59 bool HasEDID(); 60 virtual status_t GetEDID(edid1_info* edid, 61 bool forceRead = false); 62 virtual status_t SetupI2c(struct i2c_bus *bus); 63 64 virtual status_t GetPLLLimits(pll_limits& limits); 65 66 virtual status_t SetDisplayMode(display_mode* mode, 67 uint32 colorMode) { return B_ERROR; }; 68 69 virtual pipe_index PipePreference(); 70 71 protected: 72 void _SetName(const char* name); 73 74 static status_t _GetI2CSignals(void* cookie, int* _clock, 75 int* _data); 76 static status_t _SetI2CSignals(void* cookie, int clock, 77 int data); 78 bool _IsPortInVBT(uint32* foundIndex = NULL); 79 bool _IsDisplayPortInVBT(); 80 bool _IsEDPPort(); 81 status_t _SetupDpAuxI2c(struct i2c_bus *bus); 82 83 ssize_t _DpAuxTransfer(dp_aux_msg* message); 84 ssize_t _DpAuxTransfer(uint8* transmitBuffer, uint8 transmitSize, 85 uint8* receiveBuffer, uint8 receiveSize); 86 status_t _DpAuxSendReceive(uint32 slave_address, 87 const uint8 *writeBuffer, size_t writeLength, 88 uint8 *readBuffer, size_t readLength); 89 static status_t _DpAuxSendReceiveHook(const struct i2c_bus *bus, 90 uint32 slave_address, const uint8 *writeBuffer, 91 size_t writeLength, uint8 *readBuffer, 92 size_t readLength); 93 aux_channel _DpAuxChannel(); 94 95 display_mode fCurrentMode; 96 Pipe* fPipe; 97 98 status_t fEDIDState; 99 edid1_info fEDIDInfo; 100 101 private: 102 virtual addr_t _DDCRegister() = 0; 103 virtual addr_t _PortRegister() = 0; 104 105 port_index fPortIndex; 106 char* fPortName; 107 }; 108 109 110 class AnalogPort : public Port { 111 public: 112 AnalogPort(); 113 114 virtual uint32 Type() const 115 { return INTEL_PORT_TYPE_ANALOG; } 116 117 virtual bool IsConnected(); 118 119 virtual status_t SetDisplayMode(display_mode* mode, 120 uint32 colorMode); 121 122 protected: 123 virtual addr_t _DDCRegister(); 124 virtual addr_t _PortRegister(); 125 }; 126 127 128 class LVDSPort : public Port { 129 public: 130 LVDSPort(); 131 132 virtual uint32 Type() const 133 { return INTEL_PORT_TYPE_LVDS; } 134 135 virtual bool IsConnected(); 136 137 virtual status_t SetDisplayMode(display_mode* mode, 138 uint32 colorMode); 139 140 virtual pipe_index PipePreference(); 141 142 protected: 143 virtual addr_t _DDCRegister(); 144 virtual addr_t _PortRegister(); 145 }; 146 147 148 class DigitalPort : public Port { 149 public: 150 DigitalPort( 151 port_index index = INTEL_PORT_B, 152 const char* baseName = "DVI"); 153 154 virtual uint32 Type() const 155 { return INTEL_PORT_TYPE_DVI; } 156 157 virtual bool IsConnected(); 158 159 virtual status_t SetDisplayMode(display_mode* mode, 160 uint32 colorMode); 161 162 protected: 163 virtual addr_t _DDCRegister(); 164 virtual addr_t _PortRegister(); 165 }; 166 167 168 class HDMIPort : public DigitalPort { 169 public: 170 HDMIPort(port_index index); 171 172 virtual uint32 Type() const 173 { return INTEL_PORT_TYPE_HDMI; } 174 175 virtual bool IsConnected(); 176 177 protected: 178 virtual addr_t _PortRegister(); 179 }; 180 181 182 class DisplayPort : public Port { 183 public: 184 DisplayPort(port_index index, 185 const char* baseName = "DisplayPort"); 186 187 virtual uint32 Type() const 188 { return INTEL_PORT_TYPE_DP; } 189 190 virtual status_t SetPipe(Pipe* pipe); 191 virtual status_t SetupI2c(i2c_bus *bus); 192 193 virtual bool IsConnected(); 194 195 virtual status_t SetDisplayMode(display_mode* mode, 196 uint32 colorMode); 197 198 virtual pipe_index PipePreference(); 199 200 protected: 201 virtual addr_t _DDCRegister(); 202 virtual addr_t _PortRegister(); 203 204 private: 205 status_t _SetPortLinkGen4(const display_timing& timing); 206 status_t _SetPortLinkGen6(const display_timing& timing); 207 }; 208 209 210 class EmbeddedDisplayPort : public DisplayPort { 211 public: 212 EmbeddedDisplayPort(); 213 214 virtual uint32 Type() const 215 { return INTEL_PORT_TYPE_eDP; } 216 217 virtual bool IsConnected(); 218 }; 219 220 221 class DigitalDisplayInterface : public Port { 222 public: 223 DigitalDisplayInterface( 224 port_index index = INTEL_PORT_A, 225 const char* baseName = "Digital Display Interface"); 226 227 virtual uint32 Type() const 228 { return INTEL_PORT_TYPE_DVI; } 229 230 virtual status_t Power(bool enabled); 231 232 virtual status_t SetPipe(Pipe* pipe); 233 virtual status_t SetupI2c(i2c_bus *bus); 234 235 virtual bool IsConnected(); 236 237 virtual status_t SetDisplayMode(display_mode* mode, 238 uint32 colorMode); 239 240 protected: 241 virtual addr_t _DDCRegister(); 242 virtual addr_t _PortRegister(); 243 private: 244 uint8 fMaxLanes; 245 246 status_t _SetPortLinkGen8(const display_timing& timing, 247 uint32 pllSel); 248 }; 249 250 251 #endif // INTEL_PORTS_H 252