]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/gpu/drm/i915/intel_drv.h
drm/i915: add intel_dp_to_dev and intel_hdmi_to_dev
[mirror_ubuntu-bionic-kernel.git] / drivers / gpu / drm / i915 / intel_drv.h
CommitLineData
79e53945
JB
1/*
2 * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
3 * Copyright (c) 2007-2008 Intel Corporation
4 * Jesse Barnes <jesse.barnes@intel.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * IN THE SOFTWARE.
24 */
25#ifndef __INTEL_DRV_H__
26#define __INTEL_DRV_H__
27
28#include <linux/i2c.h>
760285e7 29#include <drm/i915_drm.h>
80824003 30#include "i915_drv.h"
760285e7
DH
31#include <drm/drm_crtc.h>
32#include <drm/drm_crtc_helper.h>
33#include <drm/drm_fb_helper.h>
612a9aab 34#include <drm/drm_dp_helper.h>
913d8d11 35
481b6af3 36#define _wait_for(COND, MS, W) ({ \
913d8d11
CW
37 unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
38 int ret__ = 0; \
0206e353 39 while (!(COND)) { \
913d8d11
CW
40 if (time_after(jiffies, timeout__)) { \
41 ret__ = -ETIMEDOUT; \
42 break; \
43 } \
0cc2764c
BW
44 if (W && drm_can_sleep()) { \
45 msleep(W); \
46 } else { \
47 cpu_relax(); \
48 } \
913d8d11
CW
49 } \
50 ret__; \
51})
52
57f350b6 53#define wait_for_atomic_us(COND, US) ({ \
bcf9dcc1
CW
54 unsigned long timeout__ = jiffies + usecs_to_jiffies(US); \
55 int ret__ = 0; \
56 while (!(COND)) { \
57 if (time_after(jiffies, timeout__)) { \
58 ret__ = -ETIMEDOUT; \
59 break; \
60 } \
61 cpu_relax(); \
62 } \
63 ret__; \
57f350b6
JB
64})
65
481b6af3
CW
66#define wait_for(COND, MS) _wait_for(COND, MS, 1)
67#define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
68
021357ac
CW
69#define KHz(x) (1000*x)
70#define MHz(x) KHz(1000*x)
71
79e53945
JB
72/*
73 * Display related stuff
74 */
75
76/* store information about an Ixxx DVO */
77/* The i830->i865 use multiple DVOs with multiple i2cs */
78/* the i915, i945 have a single sDVO i2c bus - which is different */
79#define MAX_OUTPUTS 6
80/* maximum connectors per crtcs in the mode set */
81#define INTELFB_CONN_LIMIT 4
82
83#define INTEL_I2C_BUS_DVO 1
84#define INTEL_I2C_BUS_SDVO 2
85
86/* these are outputs from the chip - integrated only
87 external chips are via DVO or SDVO output */
88#define INTEL_OUTPUT_UNUSED 0
89#define INTEL_OUTPUT_ANALOG 1
90#define INTEL_OUTPUT_DVO 2
91#define INTEL_OUTPUT_SDVO 3
92#define INTEL_OUTPUT_LVDS 4
93#define INTEL_OUTPUT_TVOUT 5
7d57382e 94#define INTEL_OUTPUT_HDMI 6
a4fc5ed6 95#define INTEL_OUTPUT_DISPLAYPORT 7
32f9d658 96#define INTEL_OUTPUT_EDP 8
79e53945
JB
97
98#define INTEL_DVO_CHIP_NONE 0
99#define INTEL_DVO_CHIP_LVDS 1
100#define INTEL_DVO_CHIP_TMDS 2
101#define INTEL_DVO_CHIP_TVOUT 4
102
6c9547ff
CW
103/* drm_display_mode->private_flags */
104#define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)
105#define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)
3b5c78a3 106#define INTEL_MODE_DP_FORCE_6BPC (0x10)
f9bef081
DV
107/* This flag must be set by the encoder's mode_fixup if it changes the crtc
108 * timings in the mode to prevent the crtc fixup from overwriting them.
109 * Currently only lvds needs that. */
110#define INTEL_MODE_CRTC_TIMINGS_SET (0x20)
6c9547ff
CW
111
112static inline void
113intel_mode_set_pixel_multiplier(struct drm_display_mode *mode,
114 int multiplier)
115{
116 mode->clock *= multiplier;
117 mode->private_flags |= multiplier;
118}
119
120static inline int
121intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode)
122{
123 return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK) >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT;
124}
125
79e53945
JB
126struct intel_framebuffer {
127 struct drm_framebuffer base;
05394f39 128 struct drm_i915_gem_object *obj;
79e53945
JB
129};
130
37811fcc
CW
131struct intel_fbdev {
132 struct drm_fb_helper helper;
133 struct intel_framebuffer ifb;
134 struct list_head fbdev_list;
135 struct drm_display_mode *our_mode;
136};
79e53945 137
21d40d37 138struct intel_encoder {
4ef69c7a 139 struct drm_encoder base;
9a935856
DV
140 /*
141 * The new crtc this encoder will be driven from. Only differs from
142 * base->crtc while a modeset is in progress.
143 */
144 struct intel_crtc *new_crtc;
145
79e53945 146 int type;
e2f0ba97 147 bool needs_tv_clock;
66a9278e
DV
148 /*
149 * Intel hw has only one MUX where encoders could be clone, hence a
150 * simple flag is enough to compute the possible_clones mask.
151 */
152 bool cloneable;
5ab432ef 153 bool connectors_active;
21d40d37 154 void (*hot_plug)(struct intel_encoder *);
bf49ec8c 155 void (*pre_enable)(struct intel_encoder *);
ef9c3aee
DV
156 void (*enable)(struct intel_encoder *);
157 void (*disable)(struct intel_encoder *);
bf49ec8c 158 void (*post_disable)(struct intel_encoder *);
f0947c37
DV
159 /* Read out the current hw state of this connector, returning true if
160 * the encoder is active. If the encoder is enabled it also set the pipe
161 * it is connected to in the pipe parameter. */
162 bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
f8aed700 163 int crtc_mask;
79e53945
JB
164};
165
1d508706 166struct intel_panel {
dd06f90e 167 struct drm_display_mode *fixed_mode;
4d891523 168 int fitting_mode;
1d508706
JN
169};
170
5daa55eb
ZW
171struct intel_connector {
172 struct drm_connector base;
9a935856
DV
173 /*
174 * The fixed encoder this connector is connected to.
175 */
df0e9248 176 struct intel_encoder *encoder;
9a935856
DV
177
178 /*
179 * The new encoder this connector will be driven. Only differs from
180 * encoder while a modeset is in progress.
181 */
182 struct intel_encoder *new_encoder;
183
f0947c37
DV
184 /* Reads out the current hw, returning true if the connector is enabled
185 * and active (i.e. dpms ON state). */
186 bool (*get_hw_state)(struct intel_connector *);
1d508706
JN
187
188 /* Panel info for eDP and LVDS */
189 struct intel_panel panel;
9cd300e0
JN
190
191 /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
192 struct edid *edid;
5daa55eb
ZW
193};
194
79e53945
JB
195struct intel_crtc {
196 struct drm_crtc base;
80824003
JB
197 enum pipe pipe;
198 enum plane plane;
a5c961d1 199 enum transcoder cpu_transcoder;
79e53945 200 u8 lut_r[256], lut_g[256], lut_b[256];
08a48469
DV
201 /*
202 * Whether the crtc and the connected output pipeline is active. Implies
203 * that crtc->enabled is set, i.e. the current mode configuration has
204 * some outputs connected to this crtc.
08a48469
DV
205 */
206 bool active;
93314b5b 207 bool primary_disabled; /* is the crtc obscured by a plane? */
652c393a 208 bool lowfreq_avail;
02e792fb 209 struct intel_overlay *overlay;
6b95a207 210 struct intel_unpin_work *unpin_work;
77ffb597 211 int fdi_lanes;
cda4b7d3 212
e506a0c6
DV
213 /* Display surface base address adjustement for pageflips. Note that on
214 * gen4+ this only adjusts up to a tile, offsets within a tile are
215 * handled in the hw itself (with the TILEOFF register). */
216 unsigned long dspaddr_offset;
217
05394f39 218 struct drm_i915_gem_object *cursor_bo;
cda4b7d3
CW
219 uint32_t cursor_addr;
220 int16_t cursor_x, cursor_y;
221 int16_t cursor_width, cursor_height;
6b383a7f 222 bool cursor_visible;
5a354204 223 unsigned int bpp;
4b645f14 224
ee7b9f93
JB
225 /* We can share PLLs across outputs if the timings match */
226 struct intel_pch_pll *pch_pll;
6441ab5f 227 uint32_t ddi_pll_sel;
79e53945
JB
228};
229
b840d907
JB
230struct intel_plane {
231 struct drm_plane base;
232 enum pipe pipe;
233 struct drm_i915_gem_object *obj;
2d354c34 234 bool can_scale;
b840d907
JB
235 int max_downscale;
236 u32 lut_r[1024], lut_g[1024], lut_b[1024];
237 void (*update_plane)(struct drm_plane *plane,
238 struct drm_framebuffer *fb,
239 struct drm_i915_gem_object *obj,
240 int crtc_x, int crtc_y,
241 unsigned int crtc_w, unsigned int crtc_h,
242 uint32_t x, uint32_t y,
243 uint32_t src_w, uint32_t src_h);
244 void (*disable_plane)(struct drm_plane *plane);
8ea30864
JB
245 int (*update_colorkey)(struct drm_plane *plane,
246 struct drm_intel_sprite_colorkey *key);
247 void (*get_colorkey)(struct drm_plane *plane,
248 struct drm_intel_sprite_colorkey *key);
b840d907
JB
249};
250
b445e3b0
ED
251struct intel_watermark_params {
252 unsigned long fifo_size;
253 unsigned long max_wm;
254 unsigned long default_wm;
255 unsigned long guard_size;
256 unsigned long cacheline_size;
257};
258
259struct cxsr_latency {
260 int is_desktop;
261 int is_ddr3;
262 unsigned long fsb_freq;
263 unsigned long mem_freq;
264 unsigned long display_sr;
265 unsigned long display_hpll_disable;
266 unsigned long cursor_sr;
267 unsigned long cursor_hpll_disable;
268};
269
79e53945 270#define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
5daa55eb 271#define to_intel_connector(x) container_of(x, struct intel_connector, base)
4ef69c7a 272#define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
79e53945 273#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
b840d907 274#define to_intel_plane(x) container_of(x, struct intel_plane, base)
79e53945 275
45187ace
JB
276#define DIP_HEADER_SIZE 5
277
3c17fe4b
DH
278#define DIP_TYPE_AVI 0x82
279#define DIP_VERSION_AVI 0x2
280#define DIP_LEN_AVI 13
c846b619
PZ
281#define DIP_AVI_PR_1 0
282#define DIP_AVI_PR_2 1
3c17fe4b 283
26005210 284#define DIP_TYPE_SPD 0x83
c0864cb3
JB
285#define DIP_VERSION_SPD 0x1
286#define DIP_LEN_SPD 25
287#define DIP_SPD_UNKNOWN 0
288#define DIP_SPD_DSTB 0x1
289#define DIP_SPD_DVDP 0x2
290#define DIP_SPD_DVHS 0x3
291#define DIP_SPD_HDDVR 0x4
292#define DIP_SPD_DVC 0x5
293#define DIP_SPD_DSC 0x6
294#define DIP_SPD_VCD 0x7
295#define DIP_SPD_GAME 0x8
296#define DIP_SPD_PC 0x9
297#define DIP_SPD_BD 0xa
298#define DIP_SPD_SCD 0xb
299
3c17fe4b
DH
300struct dip_infoframe {
301 uint8_t type; /* HB0 */
302 uint8_t ver; /* HB1 */
303 uint8_t len; /* HB2 - body len, not including checksum */
304 uint8_t ecc; /* Header ECC */
305 uint8_t checksum; /* PB0 */
306 union {
307 struct {
308 /* PB1 - Y 6:5, A 4:4, B 3:2, S 1:0 */
309 uint8_t Y_A_B_S;
310 /* PB2 - C 7:6, M 5:4, R 3:0 */
311 uint8_t C_M_R;
312 /* PB3 - ITC 7:7, EC 6:4, Q 3:2, SC 1:0 */
313 uint8_t ITC_EC_Q_SC;
314 /* PB4 - VIC 6:0 */
315 uint8_t VIC;
0aa534df
PZ
316 /* PB5 - YQ 7:6, CN 5:4, PR 3:0 */
317 uint8_t YQ_CN_PR;
3c17fe4b
DH
318 /* PB6 to PB13 */
319 uint16_t top_bar_end;
320 uint16_t bottom_bar_start;
321 uint16_t left_bar_end;
322 uint16_t right_bar_start;
81014b9d 323 } __attribute__ ((packed)) avi;
c0864cb3
JB
324 struct {
325 uint8_t vn[8];
326 uint8_t pd[16];
327 uint8_t sdi;
81014b9d 328 } __attribute__ ((packed)) spd;
3c17fe4b
DH
329 uint8_t payload[27];
330 } __attribute__ ((packed)) body;
331} __attribute__((packed));
332
f5bbfca3
ED
333struct intel_hdmi {
334 struct intel_encoder base;
335 u32 sdvox_reg;
336 int ddc_bus;
337 int ddi_port;
338 uint32_t color_range;
339 bool has_hdmi_sink;
340 bool has_audio;
341 enum hdmi_force_audio force_audio;
342 void (*write_infoframe)(struct drm_encoder *encoder,
343 struct dip_infoframe *frame);
687f4d06
PZ
344 void (*set_infoframes)(struct drm_encoder *encoder,
345 struct drm_display_mode *adjusted_mode);
f5bbfca3
ED
346};
347
b091cd92 348#define DP_MAX_DOWNSTREAM_PORTS 0x10
54d63ca6
SK
349#define DP_LINK_CONFIGURATION_SIZE 9
350
351struct intel_dp {
352 struct intel_encoder base;
353 uint32_t output_reg;
354 uint32_t DP;
355 uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE];
356 bool has_audio;
357 enum hdmi_force_audio force_audio;
ab9d7c30 358 enum port port;
54d63ca6 359 uint32_t color_range;
54d63ca6
SK
360 uint8_t link_bw;
361 uint8_t lane_count;
362 uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
b091cd92 363 uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
54d63ca6
SK
364 struct i2c_adapter adapter;
365 struct i2c_algo_dp_aux_data algo;
366 bool is_pch_edp;
367 uint8_t train_set[4];
368 int panel_power_up_delay;
369 int panel_power_down_delay;
370 int panel_power_cycle_delay;
371 int backlight_on_delay;
372 int backlight_off_delay;
54d63ca6
SK
373 struct delayed_work panel_vdd_work;
374 bool want_panel_vdd;
dd06f90e 375 struct intel_connector *attached_connector;
54d63ca6
SK
376};
377
f875c15a
CW
378static inline struct drm_crtc *
379intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
380{
381 struct drm_i915_private *dev_priv = dev->dev_private;
382 return dev_priv->pipe_to_crtc_mapping[pipe];
383}
384
417ae147
CW
385static inline struct drm_crtc *
386intel_get_crtc_for_plane(struct drm_device *dev, int plane)
387{
388 struct drm_i915_private *dev_priv = dev->dev_private;
389 return dev_priv->plane_to_crtc_mapping[plane];
390}
391
4e5359cd
SF
392struct intel_unpin_work {
393 struct work_struct work;
394 struct drm_device *dev;
05394f39
CW
395 struct drm_i915_gem_object *old_fb_obj;
396 struct drm_i915_gem_object *pending_flip_obj;
4e5359cd
SF
397 struct drm_pending_vblank_event *event;
398 int pending;
399 bool enable_stall_check;
400};
401
1630fe75
CW
402struct intel_fbc_work {
403 struct delayed_work work;
404 struct drm_crtc *crtc;
405 struct drm_framebuffer *fb;
406 int interval;
407};
408
d2acd215
DV
409int intel_pch_rawclk(struct drm_device *dev);
410
4eab8136
JN
411int intel_connector_update_modes(struct drm_connector *connector,
412 struct edid *edid);
335af9a2 413int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
f0217c42 414
3f43c48d 415extern void intel_attach_force_audio_property(struct drm_connector *connector);
e953fd7b
CW
416extern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
417
79e53945 418extern void intel_crt_init(struct drm_device *dev);
08d644ad
DV
419extern void intel_hdmi_init(struct drm_device *dev,
420 int sdvox_reg, enum port port);
f5bbfca3 421extern struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
f5bbfca3 422extern void intel_dip_infoframe_csum(struct dip_infoframe *avi_if);
eef4eacb
DV
423extern bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg,
424 bool is_sdvob);
79e53945
JB
425extern void intel_dvo_init(struct drm_device *dev);
426extern void intel_tv_init(struct drm_device *dev);
f047e395
CW
427extern void intel_mark_busy(struct drm_device *dev);
428extern void intel_mark_idle(struct drm_device *dev);
429extern void intel_mark_fb_busy(struct drm_i915_gem_object *obj);
430extern void intel_mark_fb_idle(struct drm_i915_gem_object *obj);
c5d1b51d 431extern bool intel_lvds_init(struct drm_device *dev);
ab9d7c30
PZ
432extern void intel_dp_init(struct drm_device *dev, int output_reg,
433 enum port port);
a4fc5ed6
KP
434void
435intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
436 struct drm_display_mode *adjusted_mode);
247d89f6 437extern void intel_dp_init_link_config(struct intel_dp *intel_dp);
c19b0669
PZ
438extern void intel_dp_start_link_train(struct intel_dp *intel_dp);
439extern void intel_dp_complete_link_train(struct intel_dp *intel_dp);
440extern void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
cb0953d7 441extern bool intel_dpd_is_edp(struct drm_device *dev);
d6c50ff8
PZ
442extern void ironlake_edp_backlight_on(struct intel_dp *intel_dp);
443extern void ironlake_edp_backlight_off(struct intel_dp *intel_dp);
82a4d9c0
PZ
444extern void ironlake_edp_panel_on(struct intel_dp *intel_dp);
445extern void ironlake_edp_panel_off(struct intel_dp *intel_dp);
446extern void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
447extern void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
0206e353 448extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
94bf2ced
DV
449extern int intel_edp_target_clock(struct intel_encoder *,
450 struct drm_display_mode *mode);
814948ad 451extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
b840d907 452extern int intel_plane_init(struct drm_device *dev, enum pipe pipe);
6f1d69b0
ED
453extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
454 enum plane plane);
32f9d658 455
a9573556 456/* intel_panel.c */
dd06f90e
JN
457extern int intel_panel_init(struct intel_panel *panel,
458 struct drm_display_mode *fixed_mode);
1d508706
JN
459extern void intel_panel_fini(struct intel_panel *panel);
460
1d8e1c75
CW
461extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
462 struct drm_display_mode *adjusted_mode);
463extern void intel_pch_panel_fitting(struct drm_device *dev,
464 int fitting_mode,
cb1793ce 465 const struct drm_display_mode *mode,
1d8e1c75 466 struct drm_display_mode *adjusted_mode);
a9573556 467extern u32 intel_panel_get_max_backlight(struct drm_device *dev);
a9573556 468extern void intel_panel_set_backlight(struct drm_device *dev, u32 level);
0657b6b1 469extern int intel_panel_setup_backlight(struct drm_connector *connector);
24ded204
DV
470extern void intel_panel_enable_backlight(struct drm_device *dev,
471 enum pipe pipe);
47356eb6 472extern void intel_panel_disable_backlight(struct drm_device *dev);
aaa6fd2a 473extern void intel_panel_destroy_backlight(struct drm_device *dev);
fe16d949 474extern enum drm_connector_status intel_panel_detect(struct drm_device *dev);
1d8e1c75 475
d9e55608 476struct intel_set_config {
1aa4b628
DV
477 struct drm_encoder **save_connector_encoders;
478 struct drm_crtc **save_encoder_crtcs;
5e2b584e
DV
479
480 bool fb_changed;
481 bool mode_changed;
d9e55608
DV
482};
483
a6778b3c
DV
484extern bool intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
485 int x, int y, struct drm_framebuffer *old_fb);
a261b246 486extern void intel_modeset_disable(struct drm_device *dev);
79e53945 487extern void intel_crtc_load_lut(struct drm_crtc *crtc);
b2cabb0e 488extern void intel_crtc_update_dpms(struct drm_crtc *crtc);
1f703855 489extern void intel_encoder_noop(struct drm_encoder *encoder);
ea5b213a 490extern void intel_encoder_destroy(struct drm_encoder *encoder);
5ab432ef 491extern void intel_encoder_dpms(struct intel_encoder *encoder, int mode);
6ed0f796 492extern bool intel_encoder_check_is_cloned(struct intel_encoder *encoder);
5ab432ef 493extern void intel_connector_dpms(struct drm_connector *, int mode);
f0947c37 494extern bool intel_connector_get_hw_state(struct intel_connector *connector);
b980514c
DV
495extern void intel_modeset_check_state(struct drm_device *dev);
496
79e53945 497
df0e9248
CW
498static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
499{
500 return to_intel_connector(connector)->encoder;
501}
502
7739c33b
PZ
503static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
504{
505 return container_of(encoder, struct intel_dp, base.base);
506}
507
df0e9248
CW
508extern void intel_connector_attach_encoder(struct intel_connector *connector,
509 struct intel_encoder *encoder);
510extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
79e53945
JB
511
512extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
513 struct drm_crtc *crtc);
08d7b3d1
CW
514int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
515 struct drm_file *file_priv);
a5c961d1
PZ
516extern enum transcoder
517intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
518 enum pipe pipe);
9d0498a2 519extern void intel_wait_for_vblank(struct drm_device *dev, int pipe);
58e10eb9 520extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
8261b191
CW
521
522struct intel_load_detect_pipe {
d2dff872 523 struct drm_framebuffer *release_fb;
8261b191
CW
524 bool load_detect_temp;
525 int dpms_mode;
526};
d2434ab7 527extern bool intel_get_load_detect_pipe(struct drm_connector *connector,
7173188d 528 struct drm_display_mode *mode,
8261b191 529 struct intel_load_detect_pipe *old);
d2434ab7 530extern void intel_release_load_detect_pipe(struct drm_connector *connector,
8261b191 531 struct intel_load_detect_pipe *old);
79e53945 532
79e53945
JB
533extern void intelfb_restore(void);
534extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
535 u16 blue, int regno);
b8c00ac5
DA
536extern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
537 u16 *blue, int regno);
0cdab21f 538extern void intel_enable_clock_gating(struct drm_device *dev);
79e53945 539
127bd2ac 540extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
05394f39 541 struct drm_i915_gem_object *obj,
919926ae 542 struct intel_ring_buffer *pipelined);
1690e1eb 543extern void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
127bd2ac 544
38651674
DA
545extern int intel_framebuffer_init(struct drm_device *dev,
546 struct intel_framebuffer *ifb,
308e5bcb 547 struct drm_mode_fb_cmd2 *mode_cmd,
05394f39 548 struct drm_i915_gem_object *obj);
38651674
DA
549extern int intel_fbdev_init(struct drm_device *dev);
550extern void intel_fbdev_fini(struct drm_device *dev);
3fa016a0 551extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
6b95a207
KH
552extern void intel_prepare_page_flip(struct drm_device *dev, int plane);
553extern void intel_finish_page_flip(struct drm_device *dev, int pipe);
1afe3e9d 554extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
6b95a207 555
02e792fb
DV
556extern void intel_setup_overlay(struct drm_device *dev);
557extern void intel_cleanup_overlay(struct drm_device *dev);
ce453d81 558extern int intel_overlay_switch_off(struct intel_overlay *overlay);
02e792fb
DV
559extern int intel_overlay_put_image(struct drm_device *dev, void *data,
560 struct drm_file *file_priv);
561extern int intel_overlay_attrs(struct drm_device *dev, void *data,
562 struct drm_file *file_priv);
4abe3520 563
eb1f8e4f 564extern void intel_fb_output_poll_changed(struct drm_device *dev);
e8e7a2b8 565extern void intel_fb_restore_mode(struct drm_device *dev);
645c62a5 566
b840d907
JB
567extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
568 bool state);
569#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
570#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
571
645c62a5 572extern void intel_init_clock_gating(struct drm_device *dev);
e0dac65e
WF
573extern void intel_write_eld(struct drm_encoder *encoder,
574 struct drm_display_mode *mode);
d4270e57 575extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
45244b87 576extern void intel_prepare_ddi(struct drm_device *dev);
c82e4d26 577extern void hsw_fdi_link_train(struct drm_crtc *crtc);
0e72a5b5 578extern void intel_ddi_init(struct drm_device *dev, enum port port);
d4270e57 579
b840d907 580/* For use by IVB LP watermark workaround in intel_sprite.c */
f681fa23 581extern void intel_update_watermarks(struct drm_device *dev);
b840d907
JB
582extern void intel_update_sprite_watermarks(struct drm_device *dev, int pipe,
583 uint32_t sprite_width,
584 int pixel_size);
1f8eeabf
ED
585extern void intel_update_linetime_watermarks(struct drm_device *dev, int pipe,
586 struct drm_display_mode *mode);
8ea30864 587
5a35e99e
DL
588extern unsigned long intel_gen4_compute_offset_xtiled(int *x, int *y,
589 unsigned int bpp,
590 unsigned int pitch);
591
8ea30864
JB
592extern int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
593 struct drm_file *file_priv);
594extern int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
595 struct drm_file *file_priv);
596
57f350b6
JB
597extern u32 intel_dpio_read(struct drm_i915_private *dev_priv, int reg);
598
85208be0 599/* Power-related functions, located in intel_pm.c */
1fa61106 600extern void intel_init_pm(struct drm_device *dev);
85208be0 601/* FBC */
85208be0
ED
602extern bool intel_fbc_enabled(struct drm_device *dev);
603extern void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval);
604extern void intel_update_fbc(struct drm_device *dev);
eb48eb00
DV
605/* IPS */
606extern void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
607extern void intel_gpu_ips_teardown(void);
85208be0 608
0232e927 609extern void intel_init_power_wells(struct drm_device *dev);
8090c6b9
DV
610extern void intel_enable_gt_powersave(struct drm_device *dev);
611extern void intel_disable_gt_powersave(struct drm_device *dev);
6590190d 612extern void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv);
930ebb46 613extern void ironlake_teardown_rc6(struct drm_device *dev);
b3daeaef 614
d6c50ff8
PZ
615extern void intel_enable_ddi(struct intel_encoder *intel_encoder);
616extern void intel_disable_ddi(struct intel_encoder *intel_encoder);
85234cdc
DV
617extern bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
618 enum pipe *pipe);
72662e10
ED
619extern void intel_ddi_mode_set(struct drm_encoder *encoder,
620 struct drm_display_mode *mode,
621 struct drm_display_mode *adjusted_mode);
b8fc2f6a 622extern int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
79f689aa 623extern void intel_ddi_pll_init(struct drm_device *dev);
8d9ddbcb 624extern void intel_ddi_enable_pipe_func(struct drm_crtc *crtc);
ad80a810
PZ
625extern void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
626 enum transcoder cpu_transcoder);
fc914639
PZ
627extern void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
628extern void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
6441ab5f
PZ
629extern void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
630extern bool intel_ddi_pll_mode_set(struct drm_crtc *crtc, int clock);
631extern void intel_ddi_pre_enable(struct intel_encoder *intel_encoder);
632extern void intel_ddi_post_disable(struct intel_encoder *intel_encoder);
633extern void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
dae84799 634extern void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
c19b0669 635extern void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
72662e10 636
79e53945 637#endif /* __INTEL_DRV_H__ */