Commit | Line | Data |
---|---|---|
89c78134 AC |
1 | /* |
2 | * Copyright (c) 2009-2011, Intel Corporation. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms and conditions of the GNU General Public License, | |
6 | * version 2, as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
11 | * more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License along with | |
14 | * this program; if not, write to the Free Software Foundation, Inc., | |
15 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | |
16 | * | |
17 | */ | |
18 | ||
19 | #ifndef __INTEL_DRV_H__ | |
20 | #define __INTEL_DRV_H__ | |
21 | ||
22 | #include <linux/i2c.h> | |
23 | #include <linux/i2c-algo-bit.h> | |
24 | #include <drm/drm_crtc.h> | |
25 | #include <drm/drm_crtc_helper.h> | |
26 | #include <linux/gpio.h> | |
27 | ||
28 | /* | |
29 | * Display related stuff | |
30 | */ | |
31 | ||
32 | /* store information about an Ixxx DVO */ | |
33 | /* The i830->i865 use multiple DVOs with multiple i2cs */ | |
34 | /* the i915, i945 have a single sDVO i2c bus - which is different */ | |
35 | #define MAX_OUTPUTS 6 | |
36 | /* maximum connectors per crtcs in the mode set */ | |
37 | #define INTELFB_CONN_LIMIT 4 | |
38 | ||
39 | #define INTEL_I2C_BUS_DVO 1 | |
40 | #define INTEL_I2C_BUS_SDVO 2 | |
41 | ||
5736995b PJ |
42 | /* Intel Pipe Clone Bit */ |
43 | #define INTEL_HDMIB_CLONE_BIT 1 | |
44 | #define INTEL_HDMIC_CLONE_BIT 2 | |
45 | #define INTEL_HDMID_CLONE_BIT 3 | |
46 | #define INTEL_HDMIE_CLONE_BIT 4 | |
47 | #define INTEL_HDMIF_CLONE_BIT 5 | |
48 | #define INTEL_SDVO_NON_TV_CLONE_BIT 6 | |
49 | #define INTEL_SDVO_TV_CLONE_BIT 7 | |
50 | #define INTEL_SDVO_LVDS_CLONE_BIT 8 | |
51 | #define INTEL_ANALOG_CLONE_BIT 9 | |
52 | #define INTEL_TV_CLONE_BIT 10 | |
53 | #define INTEL_DP_B_CLONE_BIT 11 | |
54 | #define INTEL_DP_C_CLONE_BIT 12 | |
55 | #define INTEL_DP_D_CLONE_BIT 13 | |
56 | #define INTEL_LVDS_CLONE_BIT 14 | |
57 | #define INTEL_DVO_TMDS_CLONE_BIT 15 | |
58 | #define INTEL_DVO_LVDS_CLONE_BIT 16 | |
59 | #define INTEL_EDP_CLONE_BIT 17 | |
60 | ||
89c78134 AC |
61 | /* these are outputs from the chip - integrated only |
62 | * external chips are via DVO or SDVO output */ | |
63 | #define INTEL_OUTPUT_UNUSED 0 | |
64 | #define INTEL_OUTPUT_ANALOG 1 | |
65 | #define INTEL_OUTPUT_DVO 2 | |
66 | #define INTEL_OUTPUT_SDVO 3 | |
67 | #define INTEL_OUTPUT_LVDS 4 | |
68 | #define INTEL_OUTPUT_TVOUT 5 | |
69 | #define INTEL_OUTPUT_HDMI 6 | |
70 | #define INTEL_OUTPUT_MIPI 7 | |
71 | #define INTEL_OUTPUT_MIPI2 8 | |
72 | ||
73 | #define INTEL_DVO_CHIP_NONE 0 | |
74 | #define INTEL_DVO_CHIP_LVDS 1 | |
75 | #define INTEL_DVO_CHIP_TMDS 2 | |
76 | #define INTEL_DVO_CHIP_TVOUT 4 | |
77 | ||
5736995b PJ |
78 | #define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0) |
79 | #define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT) | |
80 | ||
81 | static inline void | |
82 | psb_intel_mode_set_pixel_multiplier(struct drm_display_mode *mode, | |
83 | int multiplier) | |
84 | { | |
85 | mode->clock *= multiplier; | |
86 | mode->private_flags |= multiplier; | |
87 | } | |
88 | ||
89 | static inline int | |
90 | psb_intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode) | |
91 | { | |
92 | return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK) | |
93 | >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT; | |
94 | } | |
95 | ||
96 | ||
89c78134 AC |
97 | /* |
98 | * Hold information useally put on the device driver privates here, | |
99 | * since it needs to be shared across multiple of devices drivers privates. | |
100 | */ | |
101 | struct psb_intel_mode_device { | |
102 | ||
103 | /* | |
104 | * Abstracted memory manager operations | |
105 | */ | |
106 | size_t(*bo_offset) (struct drm_device *dev, void *bo); | |
107 | ||
108 | /* | |
109 | * Cursor (Can go ?) | |
110 | */ | |
111 | int cursor_needs_physical; | |
112 | ||
113 | /* | |
114 | * LVDS info | |
115 | */ | |
116 | int backlight_duty_cycle; /* restore backlight to this value */ | |
117 | bool panel_wants_dither; | |
118 | struct drm_display_mode *panel_fixed_mode; | |
119 | struct drm_display_mode *panel_fixed_mode2; | |
120 | struct drm_display_mode *vbt_mode; /* if any */ | |
121 | ||
122 | uint32_t saveBLC_PWM_CTL; | |
123 | }; | |
124 | ||
125 | struct psb_intel_i2c_chan { | |
126 | /* for getting at dev. private (mmio etc.) */ | |
127 | struct drm_device *drm_dev; | |
128 | u32 reg; /* GPIO reg */ | |
129 | struct i2c_adapter adapter; | |
130 | struct i2c_algo_bit_data algo; | |
131 | u8 slave_addr; | |
132 | }; | |
133 | ||
75e9d019 PJ |
134 | struct psb_intel_encoder { |
135 | struct drm_encoder base; | |
89c78134 | 136 | int type; |
75e9d019 PJ |
137 | bool needs_tv_clock; |
138 | void (*hot_plug)(struct psb_intel_encoder *); | |
139 | int crtc_mask; | |
140 | int clone_mask; | |
141 | void *dev_priv; /* For sdvo_priv, lvds_priv, etc... */ | |
a12d6a07 PJ |
142 | |
143 | /* FIXME: Either make SDVO and LVDS store it's i2c here or give CDV it's | |
144 | own set of output privates */ | |
145 | struct psb_intel_i2c_chan *i2c_bus; | |
146 | struct psb_intel_i2c_chan *ddc_bus; | |
75e9d019 | 147 | }; |
89c78134 | 148 | |
75e9d019 PJ |
149 | struct psb_intel_connector { |
150 | struct drm_connector base; | |
151 | struct psb_intel_encoder *encoder; | |
89c78134 AC |
152 | }; |
153 | ||
154 | struct psb_intel_crtc_state { | |
155 | uint32_t saveDSPCNTR; | |
156 | uint32_t savePIPECONF; | |
157 | uint32_t savePIPESRC; | |
158 | uint32_t saveDPLL; | |
159 | uint32_t saveFP0; | |
160 | uint32_t saveFP1; | |
161 | uint32_t saveHTOTAL; | |
162 | uint32_t saveHBLANK; | |
163 | uint32_t saveHSYNC; | |
164 | uint32_t saveVTOTAL; | |
165 | uint32_t saveVBLANK; | |
166 | uint32_t saveVSYNC; | |
167 | uint32_t saveDSPSTRIDE; | |
168 | uint32_t saveDSPSIZE; | |
169 | uint32_t saveDSPPOS; | |
170 | uint32_t saveDSPBASE; | |
171 | uint32_t savePalette[256]; | |
172 | }; | |
173 | ||
174 | struct psb_intel_crtc { | |
175 | struct drm_crtc base; | |
176 | int pipe; | |
177 | int plane; | |
178 | uint32_t cursor_addr; | |
179 | u8 lut_r[256], lut_g[256], lut_b[256]; | |
180 | u8 lut_adj[256]; | |
181 | struct psb_intel_framebuffer *fbdev_fb; | |
182 | /* a mode_set for fbdev users on this crtc */ | |
183 | struct drm_mode_set mode_set; | |
184 | ||
185 | /* GEM object that holds our cursor */ | |
186 | struct drm_gem_object *cursor_obj; | |
187 | ||
188 | struct drm_display_mode saved_mode; | |
189 | struct drm_display_mode saved_adjusted_mode; | |
190 | ||
191 | struct psb_intel_mode_device *mode_dev; | |
192 | ||
193 | /*crtc mode setting flags*/ | |
194 | u32 mode_flags; | |
195 | ||
acd7ef92 AC |
196 | bool active; |
197 | bool crtc_enable; | |
198 | ||
89c78134 AC |
199 | /* Saved Crtc HW states */ |
200 | struct psb_intel_crtc_state *crtc_state; | |
201 | }; | |
202 | ||
203 | #define to_psb_intel_crtc(x) \ | |
204 | container_of(x, struct psb_intel_crtc, base) | |
75e9d019 PJ |
205 | #define to_psb_intel_connector(x) \ |
206 | container_of(x, struct psb_intel_connector, base) | |
207 | #define to_psb_intel_encoder(x) \ | |
208 | container_of(x, struct psb_intel_encoder, base) | |
89c78134 AC |
209 | #define to_psb_intel_framebuffer(x) \ |
210 | container_of(x, struct psb_intel_framebuffer, base) | |
211 | ||
212 | struct psb_intel_i2c_chan *psb_intel_i2c_create(struct drm_device *dev, | |
213 | const u32 reg, const char *name); | |
214 | void psb_intel_i2c_destroy(struct psb_intel_i2c_chan *chan); | |
352b16a0 PJ |
215 | int psb_intel_ddc_get_modes(struct drm_connector *connector, |
216 | struct i2c_adapter *adapter); | |
217 | extern bool psb_intel_ddc_probe(struct i2c_adapter *adapter); | |
89c78134 AC |
218 | |
219 | extern void psb_intel_crtc_init(struct drm_device *dev, int pipe, | |
220 | struct psb_intel_mode_device *mode_dev); | |
221 | extern void psb_intel_crt_init(struct drm_device *dev); | |
5736995b | 222 | extern bool psb_intel_sdvo_init(struct drm_device *dev, int output_device); |
89c78134 AC |
223 | extern void psb_intel_dvo_init(struct drm_device *dev); |
224 | extern void psb_intel_tv_init(struct drm_device *dev); | |
225 | extern void psb_intel_lvds_init(struct drm_device *dev, | |
226 | struct psb_intel_mode_device *mode_dev); | |
227 | extern void psb_intel_lvds_set_brightness(struct drm_device *dev, int level); | |
228 | extern void oaktrail_lvds_init(struct drm_device *dev, | |
229 | struct psb_intel_mode_device *mode_dev); | |
230 | extern void oaktrail_wait_for_INTR_PKT_SENT(struct drm_device *dev); | |
231 | extern void oaktrail_dsi_init(struct drm_device *dev, | |
232 | struct psb_intel_mode_device *mode_dev); | |
233 | extern void mid_dsi_init(struct drm_device *dev, | |
234 | struct psb_intel_mode_device *mode_dev, int dsi_num); | |
235 | ||
236 | extern void psb_intel_crtc_load_lut(struct drm_crtc *crtc); | |
237 | extern void psb_intel_encoder_prepare(struct drm_encoder *encoder); | |
238 | extern void psb_intel_encoder_commit(struct drm_encoder *encoder); | |
5736995b | 239 | extern void psb_intel_encoder_destroy(struct drm_encoder *encoder); |
89c78134 | 240 | |
75e9d019 PJ |
241 | static inline struct psb_intel_encoder *psb_intel_attached_encoder( |
242 | struct drm_connector *connector) | |
243 | { | |
244 | return to_psb_intel_connector(connector)->encoder; | |
245 | } | |
246 | ||
247 | extern void psb_intel_connector_attach_encoder( | |
248 | struct psb_intel_connector *connector, | |
249 | struct psb_intel_encoder *encoder); | |
250 | ||
89c78134 AC |
251 | extern struct drm_encoder *psb_intel_best_encoder(struct drm_connector |
252 | *connector); | |
253 | ||
254 | extern struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev, | |
255 | struct drm_crtc *crtc); | |
256 | extern void psb_intel_wait_for_vblank(struct drm_device *dev); | |
257 | extern int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, | |
258 | struct drm_file *file_priv); | |
259 | extern struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev, | |
260 | int pipe); | |
261 | extern struct drm_connector *psb_intel_sdvo_find(struct drm_device *dev, | |
262 | int sdvoB); | |
263 | extern int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector); | |
264 | extern void psb_intel_sdvo_set_hotplug(struct drm_connector *connector, | |
265 | int enable); | |
266 | extern int intelfb_probe(struct drm_device *dev); | |
267 | extern int intelfb_remove(struct drm_device *dev, | |
268 | struct drm_framebuffer *fb); | |
269 | extern struct drm_framebuffer *psb_intel_framebuffer_create(struct drm_device | |
270 | *dev, struct | |
271 | drm_mode_fb_cmd | |
272 | *mode_cmd, | |
273 | void *mm_private); | |
274 | extern bool psb_intel_lvds_mode_fixup(struct drm_encoder *encoder, | |
275 | struct drm_display_mode *mode, | |
276 | struct drm_display_mode *adjusted_mode); | |
277 | extern int psb_intel_lvds_mode_valid(struct drm_connector *connector, | |
278 | struct drm_display_mode *mode); | |
279 | extern int psb_intel_lvds_set_property(struct drm_connector *connector, | |
280 | struct drm_property *property, | |
281 | uint64_t value); | |
282 | extern void psb_intel_lvds_destroy(struct drm_connector *connector); | |
283 | extern const struct drm_encoder_funcs psb_intel_lvds_enc_funcs; | |
284 | ||
5c0c1d50 PJ |
285 | /* intel_gmbus.c */ |
286 | extern void gma_intel_i2c_reset(struct drm_device *dev); | |
287 | extern int gma_intel_setup_gmbus(struct drm_device *dev); | |
288 | extern void gma_intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed); | |
289 | extern void gma_intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit); | |
290 | extern void gma_intel_teardown_gmbus(struct drm_device *dev); | |
89c78134 AC |
291 | |
292 | #endif /* __INTEL_DRV_H__ */ |