vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / accelerants / intel_extreme / Ports.h
blobb42b0e4fd25a706b93ce7d949e33ef77aa768b2b
1 /*
2 * Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
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
13 #include <edid.h>
15 #include "intel_extreme.h"
17 #include "Pipes.h"
18 #include "pll.h"
21 #define MAX_PORTS 20 // a generous upper bound
23 struct pll_limits;
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
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
45 class Port {
46 public:
47 Port(port_index index,
48 const char* baseName);
49 virtual ~Port();
51 virtual uint32 Type() const = 0;
52 const char* PortName() const
53 { return fPortName; }
55 port_index PortIndex() const
56 { return fPortIndex; }
58 virtual bool IsConnected() = 0;
60 status_t SetPipe(Pipe* pipe);
61 ::Pipe* GetPipe()
62 { return fPipe; };
64 virtual status_t Power(bool enabled);
66 bool HasEDID();
67 virtual status_t GetEDID(edid1_info* edid,
68 bool forceRead = false);
70 virtual status_t GetPLLLimits(pll_limits& limits);
72 virtual status_t SetDisplayMode(display_mode* mode,
73 uint32 colorMode) { return B_ERROR; };
75 virtual pipe_index PipePreference()
76 { return INTEL_PIPE_ANY; };
78 protected:
79 void _SetName(const char* name);
81 static status_t _GetI2CSignals(void* cookie, int* _clock,
82 int* _data);
83 static status_t _SetI2CSignals(void* cookie, int clock,
84 int data);
86 display_mode fCurrentMode;
87 Pipe* fPipe;
89 status_t fEDIDState;
90 edid1_info fEDIDInfo;
92 private:
93 virtual addr_t _DDCRegister() = 0;
94 virtual addr_t _PortRegister() = 0;
96 port_index fPortIndex;
97 char* fPortName;
101 class AnalogPort : public Port {
102 public:
103 AnalogPort();
105 virtual uint32 Type() const
106 { return INTEL_PORT_TYPE_ANALOG; }
108 virtual bool IsConnected();
110 virtual status_t SetDisplayMode(display_mode* mode,
111 uint32 colorMode);
113 protected:
114 virtual addr_t _DDCRegister();
115 virtual addr_t _PortRegister();
119 class LVDSPort : public Port {
120 public:
121 LVDSPort();
123 virtual uint32 Type() const
124 { return INTEL_PORT_TYPE_LVDS; }
126 virtual bool IsConnected();
128 virtual status_t SetDisplayMode(display_mode* mode,
129 uint32 colorMode);
131 virtual pipe_index PipePreference();
133 protected:
134 virtual addr_t _DDCRegister();
135 virtual addr_t _PortRegister();
139 class DigitalPort : public Port {
140 public:
141 DigitalPort(
142 port_index index = INTEL_PORT_B,
143 const char* baseName = "DVI");
145 virtual uint32 Type() const
146 { return INTEL_PORT_TYPE_DVI; }
148 virtual bool IsConnected();
150 virtual status_t SetDisplayMode(display_mode* mode,
151 uint32 colorMode);
153 protected:
154 virtual addr_t _DDCRegister();
155 virtual addr_t _PortRegister();
159 class HDMIPort : public DigitalPort {
160 public:
161 HDMIPort(port_index index);
163 virtual uint32 Type() const
164 { return INTEL_PORT_TYPE_HDMI; }
166 virtual bool IsConnected();
168 protected:
169 virtual addr_t _PortRegister();
173 class DisplayPort : public Port {
174 public:
175 DisplayPort(port_index index,
176 const char* baseName = "DisplayPort");
178 virtual uint32 Type() const
179 { return INTEL_PORT_TYPE_DP; }
181 virtual bool IsConnected();
183 virtual status_t SetDisplayMode(display_mode* mode,
184 uint32 colorMode);
186 protected:
187 virtual addr_t _DDCRegister();
188 virtual addr_t _PortRegister();
192 class EmbeddedDisplayPort : public DisplayPort {
193 public:
194 EmbeddedDisplayPort();
196 virtual uint32 Type() const
197 { return INTEL_PORT_TYPE_eDP; }
199 virtual bool IsConnected();
203 class DigitalDisplayInterface : public Port {
204 public:
205 DigitalDisplayInterface(
206 port_index index = INTEL_PORT_A,
207 const char* baseName = "Digital Display Interface");
209 virtual uint32 Type() const
210 { return INTEL_PORT_TYPE_DVI; }
212 virtual status_t Power(bool enabled);
214 virtual bool IsConnected();
216 virtual status_t SetDisplayMode(display_mode* mode,
217 uint32 colorMode);
219 protected:
220 virtual addr_t _DDCRegister();
221 virtual addr_t _PortRegister();
222 private:
223 uint8 fMaxLanes;
227 #endif // INTEL_PORTS_H