]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - drivers/gpu/drm/i915/intel_drv.h
drm/i915: Store encoder power domain in struct intel_encoder
[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
d1d70677 28#include <linux/async.h>
79e53945 29#include <linux/i2c.h>
178f736a 30#include <linux/hdmi.h>
760285e7 31#include <drm/i915_drm.h>
80824003 32#include "i915_drv.h"
760285e7
DH
33#include <drm/drm_crtc.h>
34#include <drm/drm_crtc_helper.h>
9338203c 35#include <drm/drm_encoder.h>
760285e7 36#include <drm/drm_fb_helper.h>
b1ba124d 37#include <drm/drm_dp_dual_mode_helper.h>
0e32b39c 38#include <drm/drm_dp_mst_helper.h>
eeca778a 39#include <drm/drm_rect.h>
10f81c19 40#include <drm/drm_atomic.h>
913d8d11 41
1d5bfac9
DV
42/**
43 * _wait_for - magic (register) wait macro
44 *
45 * Does the right thing for modeset paths when run under kdgb or similar atomic
46 * contexts. Note that it's important that we check the condition again after
47 * having timed out, since the timeout could be due to preemption or similar and
48 * we've never had a chance to check the condition before the timeout.
0351b939
TU
49 *
50 * TODO: When modesetting has fully transitioned to atomic, the below
51 * drm_can_sleep() can be removed and in_atomic()/!in_atomic() asserts
52 * added.
1d5bfac9 53 */
3f177625
TU
54#define _wait_for(COND, US, W) ({ \
55 unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \
b0876afd
DG
56 int ret__; \
57 for (;;) { \
58 bool expired__ = time_after(jiffies, timeout__); \
59 if (COND) { \
60 ret__ = 0; \
61 break; \
62 } \
63 if (expired__) { \
64 ret__ = -ETIMEDOUT; \
913d8d11
CW
65 break; \
66 } \
9848de08 67 if ((W) && drm_can_sleep()) { \
3f177625 68 usleep_range((W), (W)*2); \
0cc2764c
BW
69 } else { \
70 cpu_relax(); \
71 } \
913d8d11
CW
72 } \
73 ret__; \
74})
75
3f177625 76#define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 1000)
3f177625 77
0351b939
TU
78/* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */
79#if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT)
18f4b843 80# define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) WARN_ON_ONCE((ATOMIC) && !in_atomic())
0351b939 81#else
18f4b843 82# define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) do { } while (0)
0351b939
TU
83#endif
84
18f4b843
TU
85#define _wait_for_atomic(COND, US, ATOMIC) \
86({ \
87 int cpu, ret, timeout = (US) * 1000; \
88 u64 base; \
89 _WAIT_FOR_ATOMIC_CHECK(ATOMIC); \
0351b939 90 BUILD_BUG_ON((US) > 50000); \
18f4b843
TU
91 if (!(ATOMIC)) { \
92 preempt_disable(); \
93 cpu = smp_processor_id(); \
94 } \
95 base = local_clock(); \
96 for (;;) { \
97 u64 now = local_clock(); \
98 if (!(ATOMIC)) \
99 preempt_enable(); \
100 if (COND) { \
101 ret = 0; \
102 break; \
103 } \
104 if (now - base >= timeout) { \
105 ret = -ETIMEDOUT; \
0351b939
TU
106 break; \
107 } \
108 cpu_relax(); \
18f4b843
TU
109 if (!(ATOMIC)) { \
110 preempt_disable(); \
111 if (unlikely(cpu != smp_processor_id())) { \
112 timeout -= now - base; \
113 cpu = smp_processor_id(); \
114 base = local_clock(); \
115 } \
116 } \
0351b939 117 } \
18f4b843
TU
118 ret; \
119})
120
121#define wait_for_us(COND, US) \
122({ \
123 int ret__; \
124 BUILD_BUG_ON(!__builtin_constant_p(US)); \
125 if ((US) > 10) \
126 ret__ = _wait_for((COND), (US), 10); \
127 else \
128 ret__ = _wait_for_atomic((COND), (US), 0); \
0351b939
TU
129 ret__; \
130})
131
18f4b843
TU
132#define wait_for_atomic(COND, MS) _wait_for_atomic((COND), (MS) * 1000, 1)
133#define wait_for_atomic_us(COND, US) _wait_for_atomic((COND), (US), 1)
481b6af3 134
49938ac4
JN
135#define KHz(x) (1000 * (x))
136#define MHz(x) KHz(1000 * (x))
021357ac 137
79e53945
JB
138/*
139 * Display related stuff
140 */
141
142/* store information about an Ixxx DVO */
143/* The i830->i865 use multiple DVOs with multiple i2cs */
144/* the i915, i945 have a single sDVO i2c bus - which is different */
145#define MAX_OUTPUTS 6
146/* maximum connectors per crtcs in the mode set */
79e53945 147
4726e0b0
SK
148/* Maximum cursor sizes */
149#define GEN2_CURSOR_WIDTH 64
150#define GEN2_CURSOR_HEIGHT 64
068be561
DL
151#define MAX_CURSOR_WIDTH 256
152#define MAX_CURSOR_HEIGHT 256
4726e0b0 153
79e53945
JB
154#define INTEL_I2C_BUS_DVO 1
155#define INTEL_I2C_BUS_SDVO 2
156
157/* these are outputs from the chip - integrated only
158 external chips are via DVO or SDVO output */
6847d71b
PZ
159enum intel_output_type {
160 INTEL_OUTPUT_UNUSED = 0,
161 INTEL_OUTPUT_ANALOG = 1,
162 INTEL_OUTPUT_DVO = 2,
163 INTEL_OUTPUT_SDVO = 3,
164 INTEL_OUTPUT_LVDS = 4,
165 INTEL_OUTPUT_TVOUT = 5,
166 INTEL_OUTPUT_HDMI = 6,
cca0502b 167 INTEL_OUTPUT_DP = 7,
6847d71b
PZ
168 INTEL_OUTPUT_EDP = 8,
169 INTEL_OUTPUT_DSI = 9,
170 INTEL_OUTPUT_UNKNOWN = 10,
171 INTEL_OUTPUT_DP_MST = 11,
172};
79e53945
JB
173
174#define INTEL_DVO_CHIP_NONE 0
175#define INTEL_DVO_CHIP_LVDS 1
176#define INTEL_DVO_CHIP_TMDS 2
177#define INTEL_DVO_CHIP_TVOUT 4
178
dfba2e2d
SK
179#define INTEL_DSI_VIDEO_MODE 0
180#define INTEL_DSI_COMMAND_MODE 1
72ffa333 181
79e53945
JB
182struct intel_framebuffer {
183 struct drm_framebuffer base;
05394f39 184 struct drm_i915_gem_object *obj;
2d7a215f 185 struct intel_rotation_info rot_info;
6687c906
VS
186
187 /* for each plane in the normal GTT view */
188 struct {
189 unsigned int x, y;
190 } normal[2];
191 /* for each plane in the rotated GTT view */
192 struct {
193 unsigned int x, y;
194 unsigned int pitch; /* pixels */
195 } rotated[2];
79e53945
JB
196};
197
37811fcc
CW
198struct intel_fbdev {
199 struct drm_fb_helper helper;
8bcd4553 200 struct intel_framebuffer *fb;
058d88c4 201 struct i915_vma *vma;
43cee314 202 async_cookie_t cookie;
d978ef14 203 int preferred_bpp;
37811fcc 204};
79e53945 205
21d40d37 206struct intel_encoder {
4ef69c7a 207 struct drm_encoder base;
9a935856 208
6847d71b 209 enum intel_output_type type;
03cdc1d4 210 enum port port;
bc079e8b 211 unsigned int cloneable;
21d40d37 212 void (*hot_plug)(struct intel_encoder *);
7ae89233 213 bool (*compute_config)(struct intel_encoder *,
0a478c27
ML
214 struct intel_crtc_state *,
215 struct drm_connector_state *);
fd6bbda9
ML
216 void (*pre_pll_enable)(struct intel_encoder *,
217 struct intel_crtc_state *,
218 struct drm_connector_state *);
219 void (*pre_enable)(struct intel_encoder *,
220 struct intel_crtc_state *,
221 struct drm_connector_state *);
222 void (*enable)(struct intel_encoder *,
223 struct intel_crtc_state *,
224 struct drm_connector_state *);
225 void (*disable)(struct intel_encoder *,
226 struct intel_crtc_state *,
227 struct drm_connector_state *);
228 void (*post_disable)(struct intel_encoder *,
229 struct intel_crtc_state *,
230 struct drm_connector_state *);
231 void (*post_pll_disable)(struct intel_encoder *,
232 struct intel_crtc_state *,
233 struct drm_connector_state *);
f0947c37
DV
234 /* Read out the current hw state of this connector, returning true if
235 * the encoder is active. If the encoder is enabled it also set the pipe
236 * it is connected to in the pipe parameter. */
237 bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
045ac3b5 238 /* Reconstructs the equivalent mode flags for the current hardware
fdafa9e2 239 * state. This must be called _after_ display->get_pipe_config has
63000ef6
XZ
240 * pre-filled the pipe config. Note that intel_encoder->base.crtc must
241 * be set correctly before calling this function. */
045ac3b5 242 void (*get_config)(struct intel_encoder *,
5cec258b 243 struct intel_crtc_state *pipe_config);
07f9cd0b
ID
244 /*
245 * Called during system suspend after all pending requests for the
246 * encoder are flushed (for example for DP AUX transactions) and
247 * device interrupts are disabled.
248 */
249 void (*suspend)(struct intel_encoder *);
f8aed700 250 int crtc_mask;
1d843f9d 251 enum hpd_pin hpd_pin;
79f255a0 252 enum intel_display_power_domain power_domain;
f1a3acea
PD
253 /* for communication with audio component; protected by av_mutex */
254 const struct drm_connector *audio_connector;
79e53945
JB
255};
256
1d508706 257struct intel_panel {
dd06f90e 258 struct drm_display_mode *fixed_mode;
ec9ed197 259 struct drm_display_mode *downclock_mode;
4d891523 260 int fitting_mode;
58c68779
JN
261
262 /* backlight */
263 struct {
c91c9f32 264 bool present;
58c68779 265 u32 level;
6dda730e 266 u32 min;
7bd688cd 267 u32 max;
58c68779 268 bool enabled;
636baebf
JN
269 bool combination_mode; /* gen 2/4 only */
270 bool active_low_pwm;
32b421e7 271 bool alternate_pwm_increment; /* lpt+ */
b029e66f
SK
272
273 /* PWM chip */
022e4e52
SK
274 bool util_pin_active_low; /* bxt+ */
275 u8 controller; /* bxt+ only */
b029e66f
SK
276 struct pwm_device *pwm;
277
58c68779 278 struct backlight_device *device;
ab656bb9 279
5507faeb
JN
280 /* Connector and platform specific backlight functions */
281 int (*setup)(struct intel_connector *connector, enum pipe pipe);
282 uint32_t (*get)(struct intel_connector *connector);
283 void (*set)(struct intel_connector *connector, uint32_t level);
284 void (*disable)(struct intel_connector *connector);
285 void (*enable)(struct intel_connector *connector);
286 uint32_t (*hz_to_pwm)(struct intel_connector *connector,
287 uint32_t hz);
288 void (*power)(struct intel_connector *, bool enable);
289 } backlight;
1d508706
JN
290};
291
5daa55eb
ZW
292struct intel_connector {
293 struct drm_connector base;
9a935856
DV
294 /*
295 * The fixed encoder this connector is connected to.
296 */
df0e9248 297 struct intel_encoder *encoder;
9a935856 298
8e1b56a4
JN
299 /* ACPI device id for ACPI and driver cooperation */
300 u32 acpi_device_id;
301
f0947c37
DV
302 /* Reads out the current hw, returning true if the connector is enabled
303 * and active (i.e. dpms ON state). */
304 bool (*get_hw_state)(struct intel_connector *);
1d508706
JN
305
306 /* Panel info for eDP and LVDS */
307 struct intel_panel panel;
9cd300e0
JN
308
309 /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
310 struct edid *edid;
beb60608 311 struct edid *detect_edid;
821450c6
EE
312
313 /* since POLL and HPD connectors may use the same HPD line keep the native
314 state of connector->polled in case hotplug storm detection changes it */
315 u8 polled;
0e32b39c
DA
316
317 void *port; /* store this opaque as its illegal to dereference it */
318
319 struct intel_dp *mst_port;
5daa55eb
ZW
320};
321
9e2c8475 322struct dpll {
80ad9206
VS
323 /* given values */
324 int n;
325 int m1, m2;
326 int p1, p2;
327 /* derived values */
328 int dot;
329 int vco;
330 int m;
331 int p;
9e2c8475 332};
80ad9206 333
de419ab6
ML
334struct intel_atomic_state {
335 struct drm_atomic_state base;
336
bb0f4aab
VS
337 struct {
338 /*
339 * Logical state of cdclk (used for all scaling, watermark,
340 * etc. calculations and checks). This is computed as if all
341 * enabled crtcs were active.
342 */
343 struct intel_cdclk_state logical;
344
345 /*
346 * Actual state of cdclk, can be different from the logical
347 * state only when all crtc's are DPMS off.
348 */
349 struct intel_cdclk_state actual;
350 } cdclk;
1a617b77 351
565602d7
ML
352 bool dpll_set, modeset;
353
8b4a7d05
MR
354 /*
355 * Does this transaction change the pipes that are active? This mask
356 * tracks which CRTC's have changed their active state at the end of
357 * the transaction (not counting the temporary disable during modesets).
358 * This mask should only be non-zero when intel_state->modeset is true,
359 * but the converse is not necessarily true; simply changing a mode may
360 * not flip the final active status of any CRTC's
361 */
362 unsigned int active_pipe_changes;
363
565602d7
ML
364 unsigned int active_crtcs;
365 unsigned int min_pixclk[I915_MAX_PIPES];
366
2c42e535 367 struct intel_shared_dpll_state shared_dpll[I915_NUM_PLLS];
ed4a6a7c
MR
368
369 /*
370 * Current watermarks can't be trusted during hardware readout, so
371 * don't bother calculating intermediate watermarks.
372 */
373 bool skip_intermediate_wm;
98d39494
MR
374
375 /* Gen9+ only */
734fa01f 376 struct skl_wm_values wm_results;
c004a90b
CW
377
378 struct i915_sw_fence commit_ready;
eb955eee
CW
379
380 struct llist_node freed;
de419ab6
ML
381};
382
eeca778a 383struct intel_plane_state {
2b875c22 384 struct drm_plane_state base;
eeca778a 385 struct drm_rect clip;
be1e3415 386 struct i915_vma *vma;
32b7eeec 387
b63a16f6
VS
388 struct {
389 u32 offset;
390 int x, y;
391 } main;
8d970654
VS
392 struct {
393 u32 offset;
394 int x, y;
395 } aux;
b63a16f6 396
be41e336
CK
397 /*
398 * scaler_id
399 * = -1 : not using a scaler
400 * >= 0 : using a scalers
401 *
402 * plane requiring a scaler:
403 * - During check_plane, its bit is set in
404 * crtc_state->scaler_state.scaler_users by calling helper function
86adf9d7 405 * update_scaler_plane.
be41e336
CK
406 * - scaler_id indicates the scaler it got assigned.
407 *
408 * plane doesn't require a scaler:
409 * - this can happen when scaling is no more required or plane simply
410 * got disabled.
411 * - During check_plane, corresponding bit is reset in
412 * crtc_state->scaler_state.scaler_users by calling helper function
86adf9d7 413 * update_scaler_plane.
be41e336
CK
414 */
415 int scaler_id;
818ed961
ML
416
417 struct drm_intel_sprite_colorkey ckey;
eeca778a
GP
418};
419
5724dbd1 420struct intel_initial_plane_config {
2d14030b 421 struct intel_framebuffer *fb;
49af449b 422 unsigned int tiling;
46f297fb
JB
423 int size;
424 u32 base;
425};
426
be41e336
CK
427#define SKL_MIN_SRC_W 8
428#define SKL_MAX_SRC_W 4096
429#define SKL_MIN_SRC_H 8
6156a456 430#define SKL_MAX_SRC_H 4096
be41e336
CK
431#define SKL_MIN_DST_W 8
432#define SKL_MAX_DST_W 4096
433#define SKL_MIN_DST_H 8
6156a456 434#define SKL_MAX_DST_H 4096
be41e336
CK
435
436struct intel_scaler {
be41e336
CK
437 int in_use;
438 uint32_t mode;
439};
440
441struct intel_crtc_scaler_state {
442#define SKL_NUM_SCALERS 2
443 struct intel_scaler scalers[SKL_NUM_SCALERS];
444
445 /*
446 * scaler_users: keeps track of users requesting scalers on this crtc.
447 *
448 * If a bit is set, a user is using a scaler.
449 * Here user can be a plane or crtc as defined below:
450 * bits 0-30 - plane (bit position is index from drm_plane_index)
451 * bit 31 - crtc
452 *
453 * Instead of creating a new index to cover planes and crtc, using
454 * existing drm_plane_index for planes which is well less than 31
455 * planes and bit 31 for crtc. This should be fine to cover all
456 * our platforms.
457 *
458 * intel_atomic_setup_scalers will setup available scalers to users
459 * requesting scalers. It will gracefully fail if request exceeds
460 * avilability.
461 */
462#define SKL_CRTC_INDEX 31
463 unsigned scaler_users;
464
465 /* scaler used by crtc for panel fitting purpose */
466 int scaler_id;
467};
468
1ed51de9
DV
469/* drm_mode->private_flags */
470#define I915_MODE_FLAG_INHERITED 1
471
4e0963c7
MR
472struct intel_pipe_wm {
473 struct intel_wm_level wm[5];
71f0a626 474 struct intel_wm_level raw_wm[5];
4e0963c7
MR
475 uint32_t linetime;
476 bool fbc_wm_enabled;
477 bool pipe_enabled;
478 bool sprites_enabled;
479 bool sprites_scaled;
480};
481
a62163e9 482struct skl_plane_wm {
4e0963c7
MR
483 struct skl_wm_level wm[8];
484 struct skl_wm_level trans_wm;
a62163e9
L
485};
486
487struct skl_pipe_wm {
488 struct skl_plane_wm planes[I915_MAX_PLANES];
4e0963c7
MR
489 uint32_t linetime;
490};
491
e8f1f02e
MR
492struct intel_crtc_wm_state {
493 union {
494 struct {
495 /*
496 * Intermediate watermarks; these can be
497 * programmed immediately since they satisfy
498 * both the current configuration we're
499 * switching away from and the new
500 * configuration we're switching to.
501 */
502 struct intel_pipe_wm intermediate;
503
504 /*
505 * Optimal watermarks, programmed post-vblank
506 * when this state is committed.
507 */
508 struct intel_pipe_wm optimal;
509 } ilk;
510
511 struct {
512 /* gen9+ only needs 1-step wm programming */
513 struct skl_pipe_wm optimal;
ce0ba283 514 struct skl_ddb_entry ddb;
e8f1f02e
MR
515 } skl;
516 };
517
518 /*
519 * Platforms with two-step watermark programming will need to
520 * update watermark programming post-vblank to switch from the
521 * safe intermediate watermarks to the optimal final
522 * watermarks.
523 */
524 bool need_postvbl_update;
525};
526
5cec258b 527struct intel_crtc_state {
2d112de7
ACO
528 struct drm_crtc_state base;
529
bb760063
DV
530 /**
531 * quirks - bitfield with hw state readout quirks
532 *
533 * For various reasons the hw state readout code might not be able to
534 * completely faithfully read out the current state. These cases are
535 * tracked with quirk flags so that fastboot and state checker can act
536 * accordingly.
537 */
9953599b 538#define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
bb760063
DV
539 unsigned long quirks;
540
cd202f69 541 unsigned fb_bits; /* framebuffers to flip */
ab1d3a0e
ML
542 bool update_pipe; /* can a fast modeset be performed? */
543 bool disable_cxsr;
caed361d 544 bool update_wm_pre, update_wm_post; /* watermarks are updated */
e8861675 545 bool fb_changed; /* fb on any of the planes is changed */
bfd16b2a 546
37327abd
VS
547 /* Pipe source size (ie. panel fitter input size)
548 * All planes will be positioned inside this space,
549 * and get clipped at the edges. */
550 int pipe_src_w, pipe_src_h;
551
a7d1b3f4
VS
552 /*
553 * Pipe pixel rate, adjusted for
554 * panel fitter/pipe scaler downscaling.
555 */
556 unsigned int pixel_rate;
557
5bfe2ac0
DV
558 /* Whether to set up the PCH/FDI. Note that we never allow sharing
559 * between pch encoders and cpu encoders. */
560 bool has_pch_encoder;
50f3b016 561
e43823ec
JB
562 /* Are we sending infoframes on the attached port */
563 bool has_infoframe;
564
3b117c8f 565 /* CPU Transcoder for the pipe. Currently this can only differ from the
4d1de975
JN
566 * pipe on Haswell and later (where we have a special eDP transcoder)
567 * and Broxton (where we have special DSI transcoders). */
3b117c8f
DV
568 enum transcoder cpu_transcoder;
569
50f3b016
DV
570 /*
571 * Use reduced/limited/broadcast rbg range, compressing from the full
572 * range fed into the crtcs.
573 */
574 bool limited_color_range;
575
253c84c8
VS
576 /* Bitmask of encoder types (enum intel_output_type)
577 * driven by the pipe.
578 */
579 unsigned int output_types;
580
6897b4b5
DV
581 /* Whether we should send NULL infoframes. Required for audio. */
582 bool has_hdmi_sink;
583
9ed109a7
DV
584 /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
585 * has_dp_encoder is set. */
586 bool has_audio;
587
d8b32247
DV
588 /*
589 * Enable dithering, used when the selected pipe bpp doesn't match the
590 * plane bpp.
591 */
965e0c48 592 bool dither;
f47709a9 593
611032bf
MN
594 /*
595 * Dither gets enabled for 18bpp which causes CRC mismatch errors for
596 * compliance video pattern tests.
597 * Disable dither only if it is a compliance test request for
598 * 18bpp.
599 */
600 bool dither_force_disable;
601
f47709a9
DV
602 /* Controls for the clock computation, to override various stages. */
603 bool clock_set;
604
09ede541
DV
605 /* SDVO TV has a bunch of special case. To make multifunction encoders
606 * work correctly, we need to track this at runtime.*/
607 bool sdvo_tv_clock;
608
e29c22c0
DV
609 /*
610 * crtc bandwidth limit, don't increase pipe bpp or clock if not really
611 * required. This is set in the 2nd loop of calling encoder's
612 * ->compute_config if the first pick doesn't work out.
613 */
614 bool bw_constrained;
615
f47709a9
DV
616 /* Settings for the intel dpll used on pretty much everything but
617 * haswell. */
80ad9206 618 struct dpll dpll;
f47709a9 619
8106ddbd
ACO
620 /* Selected dpll when shared or NULL. */
621 struct intel_shared_dpll *shared_dpll;
a43f6e0f 622
66e985c0
DV
623 /* Actual register state of the dpll, for shared dpll cross-checking. */
624 struct intel_dpll_hw_state dpll_hw_state;
625
47eacbab
VS
626 /* DSI PLL registers */
627 struct {
628 u32 ctrl, div;
629 } dsi_pll;
630
965e0c48 631 int pipe_bpp;
6cf86a5e 632 struct intel_link_m_n dp_m_n;
ff9a6750 633
439d7ac0
PB
634 /* m2_n2 for eDP downclock */
635 struct intel_link_m_n dp_m2_n2;
f769cd24 636 bool has_drrs;
439d7ac0 637
ff9a6750
DV
638 /*
639 * Frequence the dpll for the port should run at. Differs from the
3c52f4eb
VS
640 * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
641 * already multiplied by pixel_multiplier.
df92b1e6 642 */
ff9a6750
DV
643 int port_clock;
644
6cc5f341
DV
645 /* Used by SDVO (and if we ever fix it, HDMI). */
646 unsigned pixel_multiplier;
2dd24552 647
90a6b7b0
VS
648 uint8_t lane_count;
649
95a7a2ae
ID
650 /*
651 * Used by platforms having DP/HDMI PHY with programmable lane
652 * latency optimization.
653 */
654 uint8_t lane_lat_optim_mask;
655
2dd24552 656 /* Panel fitter controls for gen2-gen4 + VLV */
b074cec8
JB
657 struct {
658 u32 control;
659 u32 pgm_ratios;
68fc8742 660 u32 lvds_border_bits;
b074cec8
JB
661 } gmch_pfit;
662
663 /* Panel fitter placement and size for Ironlake+ */
664 struct {
665 u32 pos;
666 u32 size;
fd4daa9c 667 bool enabled;
fabf6e51 668 bool force_thru;
b074cec8 669 } pch_pfit;
33d29b14 670
ca3a0ff8 671 /* FDI configuration, only valid if has_pch_encoder is set. */
33d29b14 672 int fdi_lanes;
ca3a0ff8 673 struct intel_link_m_n fdi_m_n;
42db64ef
PZ
674
675 bool ips_enabled;
cf532bb2 676
f51be2e0
PZ
677 bool enable_fbc;
678
cf532bb2 679 bool double_wide;
0e32b39c 680
0e32b39c 681 int pbn;
be41e336
CK
682
683 struct intel_crtc_scaler_state scaler_state;
99d736a2
ML
684
685 /* w/a for waiting 2 vblanks during crtc enable */
686 enum pipe hsw_workaround_pipe;
d21fbe87
MR
687
688 /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
689 bool disable_lp_wm;
4e0963c7 690
e8f1f02e 691 struct intel_crtc_wm_state wm;
05dc698c
LL
692
693 /* Gamma mode programmed on the pipe */
694 uint32_t gamma_mode;
b8cecdf5
DV
695};
696
262cd2e1
VS
697struct vlv_wm_state {
698 struct vlv_pipe_wm wm[3];
699 struct vlv_sr_wm sr[3];
700 uint8_t num_active_planes;
701 uint8_t num_levels;
702 uint8_t level;
703 bool cxsr;
704};
705
79e53945
JB
706struct intel_crtc {
707 struct drm_crtc base;
80824003
JB
708 enum pipe pipe;
709 enum plane plane;
79e53945 710 u8 lut_r[256], lut_g[256], lut_b[256];
08a48469
DV
711 /*
712 * Whether the crtc and the connected output pipeline is active. Implies
713 * that crtc->enabled is set, i.e. the current mode configuration has
714 * some outputs connected to this crtc.
08a48469
DV
715 */
716 bool active;
652c393a 717 bool lowfreq_avail;
d97d7b48 718 u8 plane_ids_mask;
d8fc70b7 719 unsigned long long enabled_power_domains;
02e792fb 720 struct intel_overlay *overlay;
5a21b665 721 struct intel_flip_work *flip_work;
cda4b7d3 722
b4a98e57
CW
723 atomic_t unpin_work_count;
724
e506a0c6
DV
725 /* Display surface base address adjustement for pageflips. Note that on
726 * gen4+ this only adjusts up to a tile, offsets within a tile are
727 * handled in the hw itself (with the TILEOFF register). */
54ea9da8 728 u32 dspaddr_offset;
2db3366b
PZ
729 int adjusted_x;
730 int adjusted_y;
e506a0c6 731
cda4b7d3 732 uint32_t cursor_addr;
4b0e333e 733 uint32_t cursor_cntl;
dc41c154 734 uint32_t cursor_size;
4b0e333e 735 uint32_t cursor_base;
4b645f14 736
6e3c9717 737 struct intel_crtc_state *config;
b8cecdf5 738
8af29b0c
CW
739 /* global reset count when the last flip was submitted */
740 unsigned int reset_count;
5a21b665 741
8664281b
PZ
742 /* Access to these should be protected by dev_priv->irq_lock. */
743 bool cpu_fifo_underrun_disabled;
744 bool pch_fifo_underrun_disabled;
0b2ae6d7
VS
745
746 /* per-pipe watermark state */
747 struct {
748 /* watermarks currently being used */
4e0963c7
MR
749 union {
750 struct intel_pipe_wm ilk;
4e0963c7 751 } active;
ed4a6a7c 752
852eb00d
VS
753 /* allow CxSR on this pipe */
754 bool cxsr_allowed;
0b2ae6d7 755 } wm;
8d7849db 756
80715b2f 757 int scanline_offset;
32b7eeec 758
eb120ef6
JB
759 struct {
760 unsigned start_vbl_count;
761 ktime_t start_vbl_time;
762 int min_vbl, max_vbl;
763 int scanline_start;
764 } debug;
85a62bf9 765
be41e336
CK
766 /* scalers available on this crtc */
767 int num_scalers;
262cd2e1
VS
768
769 struct vlv_wm_state wm_state;
79e53945
JB
770};
771
c35426d2
VS
772struct intel_plane_wm_parameters {
773 uint32_t horiz_pixels;
ed57cb8a 774 uint32_t vert_pixels;
2cd601c6
CK
775 /*
776 * For packed pixel formats:
777 * bytes_per_pixel - holds bytes per pixel
778 * For planar pixel formats:
779 * bytes_per_pixel - holds bytes per pixel for uv-plane
780 * y_bytes_per_pixel - holds bytes per pixel for y-plane
781 */
c35426d2 782 uint8_t bytes_per_pixel;
2cd601c6 783 uint8_t y_bytes_per_pixel;
c35426d2
VS
784 bool enabled;
785 bool scaled;
0fda6568 786 u64 tiling;
1fc0a8f7 787 unsigned int rotation;
6eb1a681 788 uint16_t fifo_size;
c35426d2
VS
789};
790
b840d907
JB
791struct intel_plane {
792 struct drm_plane base;
b14e5848
VS
793 u8 plane;
794 enum plane_id id;
b840d907 795 enum pipe pipe;
2d354c34 796 bool can_scale;
b840d907 797 int max_downscale;
a9ff8714 798 uint32_t frontbuffer_bit;
526682e9
PZ
799
800 /* Since we need to change the watermarks before/after
801 * enabling/disabling the planes, we need to store the parameters here
802 * as the other pieces of the struct may not reflect the values we want
803 * for the watermark calculations. Currently only Haswell uses this.
804 */
c35426d2 805 struct intel_plane_wm_parameters wm;
526682e9 806
8e7d688b
MR
807 /*
808 * NOTE: Do not place new plane state fields here (e.g., when adding
809 * new plane properties). New runtime state should now be placed in
2fde1391 810 * the intel_plane_state structure and accessed via plane_state.
8e7d688b
MR
811 */
812
b840d907 813 void (*update_plane)(struct drm_plane *plane,
2fde1391
ML
814 const struct intel_crtc_state *crtc_state,
815 const struct intel_plane_state *plane_state);
b39d53f6 816 void (*disable_plane)(struct drm_plane *plane,
7fabf5ef 817 struct drm_crtc *crtc);
c59cb179 818 int (*check_plane)(struct drm_plane *plane,
061e4b8d 819 struct intel_crtc_state *crtc_state,
c59cb179 820 struct intel_plane_state *state);
b840d907
JB
821};
822
b445e3b0 823struct intel_watermark_params {
ae9400ca
TU
824 u16 fifo_size;
825 u16 max_wm;
826 u8 default_wm;
827 u8 guard_size;
828 u8 cacheline_size;
b445e3b0
ED
829};
830
831struct cxsr_latency {
c13fb778
TU
832 bool is_desktop : 1;
833 bool is_ddr3 : 1;
44a655ca
TU
834 u16 fsb_freq;
835 u16 mem_freq;
836 u16 display_sr;
837 u16 display_hpll_disable;
838 u16 cursor_sr;
839 u16 cursor_hpll_disable;
b445e3b0
ED
840};
841
de419ab6 842#define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
79e53945 843#define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
10f81c19 844#define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
5daa55eb 845#define to_intel_connector(x) container_of(x, struct intel_connector, base)
4ef69c7a 846#define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
79e53945 847#define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
b840d907 848#define to_intel_plane(x) container_of(x, struct intel_plane, base)
ea2c67bb 849#define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
155e6369 850#define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL)
79e53945 851
f5bbfca3 852struct intel_hdmi {
f0f59a00 853 i915_reg_t hdmi_reg;
f5bbfca3 854 int ddc_bus;
b1ba124d
VS
855 struct {
856 enum drm_dp_dual_mode_type type;
857 int max_tmds_clock;
858 } dp_dual_mode;
0f2a2a75 859 bool limited_color_range;
55bc60db 860 bool color_range_auto;
f5bbfca3
ED
861 bool has_hdmi_sink;
862 bool has_audio;
863 enum hdmi_force_audio force_audio;
abedc077 864 bool rgb_quant_range_selectable;
94a11ddc 865 enum hdmi_picture_aspect aspect_ratio;
d8b4c43a 866 struct intel_connector *attached_connector;
f5bbfca3 867 void (*write_infoframe)(struct drm_encoder *encoder,
ac240288 868 const struct intel_crtc_state *crtc_state,
178f736a 869 enum hdmi_infoframe_type type,
fff63867 870 const void *frame, ssize_t len);
687f4d06 871 void (*set_infoframes)(struct drm_encoder *encoder,
6897b4b5 872 bool enable,
ac240288
ML
873 const struct intel_crtc_state *crtc_state,
874 const struct drm_connector_state *conn_state);
cda0aaaf
VS
875 bool (*infoframe_enabled)(struct drm_encoder *encoder,
876 const struct intel_crtc_state *pipe_config);
f5bbfca3
ED
877};
878
0e32b39c 879struct intel_dp_mst_encoder;
b091cd92 880#define DP_MAX_DOWNSTREAM_PORTS 0x10
54d63ca6 881
fe3cd48d
R
882/*
883 * enum link_m_n_set:
884 * When platform provides two set of M_N registers for dp, we can
885 * program them and switch between them incase of DRRS.
886 * But When only one such register is provided, we have to program the
887 * required divider value on that registers itself based on the DRRS state.
888 *
889 * M1_N1 : Program dp_m_n on M1_N1 registers
890 * dp_m2_n2 on M2_N2 registers (If supported)
891 *
892 * M2_N2 : Program dp_m2_n2 on M1_N1 registers
893 * M2_N2 registers are not supported
894 */
895
896enum link_m_n_set {
897 /* Sets the m1_n1 and m2_n2 */
898 M1_N1 = 0,
899 M2_N2
900};
901
7b3fc170
ID
902struct intel_dp_desc {
903 u8 oui[3];
904 u8 device_id[6];
905 u8 hw_rev;
906 u8 sw_major_rev;
907 u8 sw_minor_rev;
908} __packed;
909
c1617abc
MN
910struct intel_dp_compliance_data {
911 unsigned long edid;
611032bf
MN
912 uint8_t video_pattern;
913 uint16_t hdisplay, vdisplay;
914 uint8_t bpc;
c1617abc
MN
915};
916
917struct intel_dp_compliance {
918 unsigned long test_type;
919 struct intel_dp_compliance_data test_data;
920 bool test_active;
da15f7cb
MN
921 int test_link_rate;
922 u8 test_lane_count;
c1617abc
MN
923};
924
54d63ca6 925struct intel_dp {
f0f59a00
VS
926 i915_reg_t output_reg;
927 i915_reg_t aux_ch_ctl_reg;
928 i915_reg_t aux_ch_data_reg[5];
54d63ca6 929 uint32_t DP;
901c2daf
VS
930 int link_rate;
931 uint8_t lane_count;
30d9aa42 932 uint8_t sink_count;
64ee2fd2 933 bool link_mst;
54d63ca6 934 bool has_audio;
7d23e3c3 935 bool detect_done;
c92bd2fa 936 bool channel_eq_status;
d7e8ef02 937 bool reset_link_params;
54d63ca6 938 enum hdmi_force_audio force_audio;
0f2a2a75 939 bool limited_color_range;
55bc60db 940 bool color_range_auto;
54d63ca6 941 uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
2293bb5c 942 uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
b091cd92 943 uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
86ee27b5 944 uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
94ca719e
VS
945 /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
946 uint8_t num_sink_rates;
947 int sink_rates[DP_MAX_SUPPORTED_RATES];
f482984a
MN
948 /* Max lane count for the sink as per DPCD registers */
949 uint8_t max_sink_lane_count;
950 /* Max link BW for the sink as per DPCD registers */
951 int max_sink_link_bw;
7b3fc170
ID
952 /* sink or branch descriptor */
953 struct intel_dp_desc desc;
9d1a1031 954 struct drm_dp_aux aux;
5432fcaf 955 enum intel_display_power_domain aux_power_domain;
54d63ca6
SK
956 uint8_t train_set[4];
957 int panel_power_up_delay;
958 int panel_power_down_delay;
959 int panel_power_cycle_delay;
960 int backlight_on_delay;
961 int backlight_off_delay;
54d63ca6
SK
962 struct delayed_work panel_vdd_work;
963 bool want_panel_vdd;
dce56b3c
PZ
964 unsigned long last_power_on;
965 unsigned long last_backlight_off;
d28d4731 966 ktime_t panel_power_off_time;
5d42f82a 967
01527b31
CT
968 struct notifier_block edp_notifier;
969
a4a5d2f8
VS
970 /*
971 * Pipe whose power sequencer is currently locked into
972 * this port. Only relevant on VLV/CHV.
973 */
974 enum pipe pps_pipe;
9f2bdb00
VS
975 /*
976 * Pipe currently driving the port. Used for preventing
977 * the use of the PPS for any pipe currentrly driving
978 * external DP as that will mess things up on VLV.
979 */
980 enum pipe active_pipe;
78597996
ID
981 /*
982 * Set if the sequencer may be reset due to a power transition,
983 * requiring a reinitialization. Only relevant on BXT.
984 */
985 bool pps_reset;
36b5f425 986 struct edp_power_seq pps_delays;
a4a5d2f8 987
0e32b39c
DA
988 bool can_mst; /* this port supports mst */
989 bool is_mst;
19e0b4ca 990 int active_mst_links;
0e32b39c 991 /* connector directly attached - won't be use for modeset in mst world */
dd06f90e 992 struct intel_connector *attached_connector;
ec5b01dd 993
0e32b39c
DA
994 /* mst connector list */
995 struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
996 struct drm_dp_mst_topology_mgr mst_mgr;
997
ec5b01dd 998 uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
153b1100
DL
999 /*
1000 * This function returns the value we have to program the AUX_CTL
1001 * register with to kick off an AUX transaction.
1002 */
1003 uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
1004 bool has_aux_irq,
1005 int send_bytes,
1006 uint32_t aux_clock_divider);
ad64217b
ACO
1007
1008 /* This is called before a link training is starterd */
1009 void (*prepare_link_retrain)(struct intel_dp *intel_dp);
1010
c5d5ab7a 1011 /* Displayport compliance testing */
c1617abc 1012 struct intel_dp_compliance compliance;
54d63ca6
SK
1013};
1014
dbe9e61b
SS
1015struct intel_lspcon {
1016 bool active;
1017 enum drm_lspcon_mode mode;
dbe9e61b
SS
1018};
1019
da63a9f2
PZ
1020struct intel_digital_port {
1021 struct intel_encoder base;
174edf1f 1022 enum port port;
bcf53de4 1023 u32 saved_port_bits;
da63a9f2
PZ
1024 struct intel_dp dp;
1025 struct intel_hdmi hdmi;
dbe9e61b 1026 struct intel_lspcon lspcon;
b2c5c181 1027 enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
b0b33846 1028 bool release_cl2_override;
ccb1a831 1029 uint8_t max_lanes;
da63a9f2
PZ
1030};
1031
0e32b39c
DA
1032struct intel_dp_mst_encoder {
1033 struct intel_encoder base;
1034 enum pipe pipe;
1035 struct intel_digital_port *primary;
0552f765 1036 struct intel_connector *connector;
0e32b39c
DA
1037};
1038
65d64cc5 1039static inline enum dpio_channel
89b667f8
JB
1040vlv_dport_to_channel(struct intel_digital_port *dport)
1041{
1042 switch (dport->port) {
1043 case PORT_B:
00fc31b7 1044 case PORT_D:
e4607fcf 1045 return DPIO_CH0;
89b667f8 1046 case PORT_C:
e4607fcf 1047 return DPIO_CH1;
89b667f8
JB
1048 default:
1049 BUG();
1050 }
1051}
1052
65d64cc5
VS
1053static inline enum dpio_phy
1054vlv_dport_to_phy(struct intel_digital_port *dport)
1055{
1056 switch (dport->port) {
1057 case PORT_B:
1058 case PORT_C:
1059 return DPIO_PHY0;
1060 case PORT_D:
1061 return DPIO_PHY1;
1062 default:
1063 BUG();
1064 }
1065}
1066
1067static inline enum dpio_channel
eb69b0e5
CML
1068vlv_pipe_to_channel(enum pipe pipe)
1069{
1070 switch (pipe) {
1071 case PIPE_A:
1072 case PIPE_C:
1073 return DPIO_CH0;
1074 case PIPE_B:
1075 return DPIO_CH1;
1076 default:
1077 BUG();
1078 }
1079}
1080
e2af48c6 1081static inline struct intel_crtc *
b91eb5cc 1082intel_get_crtc_for_pipe(struct drm_i915_private *dev_priv, enum pipe pipe)
f875c15a 1083{
f875c15a
CW
1084 return dev_priv->pipe_to_crtc_mapping[pipe];
1085}
1086
e2af48c6 1087static inline struct intel_crtc *
b91eb5cc 1088intel_get_crtc_for_plane(struct drm_i915_private *dev_priv, enum plane plane)
417ae147 1089{
417ae147
CW
1090 return dev_priv->plane_to_crtc_mapping[plane];
1091}
1092
51cbaf01
ML
1093struct intel_flip_work {
1094 struct work_struct unpin_work;
1095 struct work_struct mmio_work;
1096
5a21b665 1097 struct drm_crtc *crtc;
be1e3415 1098 struct i915_vma *old_vma;
5a21b665
DV
1099 struct drm_framebuffer *old_fb;
1100 struct drm_i915_gem_object *pending_flip_obj;
4e5359cd 1101 struct drm_pending_vblank_event *event;
e7d841ca 1102 atomic_t pending;
5a21b665
DV
1103 u32 flip_count;
1104 u32 gtt_offset;
1105 struct drm_i915_gem_request *flip_queued_req;
66f59c5c 1106 u32 flip_queued_vblank;
5a21b665
DV
1107 u32 flip_ready_vblank;
1108 unsigned int rotation;
4e5359cd
SF
1109};
1110
5f1aae65 1111struct intel_load_detect_pipe {
edde3617 1112 struct drm_atomic_state *restore_state;
5f1aae65 1113};
79e53945 1114
5f1aae65
PZ
1115static inline struct intel_encoder *
1116intel_attached_encoder(struct drm_connector *connector)
df0e9248
CW
1117{
1118 return to_intel_connector(connector)->encoder;
1119}
1120
da63a9f2
PZ
1121static inline struct intel_digital_port *
1122enc_to_dig_port(struct drm_encoder *encoder)
1123{
1124 return container_of(encoder, struct intel_digital_port, base.base);
9ff8c9ba
ID
1125}
1126
0e32b39c
DA
1127static inline struct intel_dp_mst_encoder *
1128enc_to_mst(struct drm_encoder *encoder)
1129{
1130 return container_of(encoder, struct intel_dp_mst_encoder, base.base);
1131}
1132
9ff8c9ba
ID
1133static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
1134{
1135 return &enc_to_dig_port(encoder)->dp;
da63a9f2
PZ
1136}
1137
1138static inline struct intel_digital_port *
1139dp_to_dig_port(struct intel_dp *intel_dp)
1140{
1141 return container_of(intel_dp, struct intel_digital_port, dp);
1142}
1143
dd75f6dd
ID
1144static inline struct intel_lspcon *
1145dp_to_lspcon(struct intel_dp *intel_dp)
1146{
1147 return &dp_to_dig_port(intel_dp)->lspcon;
1148}
1149
da63a9f2
PZ
1150static inline struct intel_digital_port *
1151hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
1152{
1153 return container_of(intel_hdmi, struct intel_digital_port, hdmi);
7739c33b
PZ
1154}
1155
47339cd9 1156/* intel_fifo_underrun.c */
a72e4c9f 1157bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
87440425 1158 enum pipe pipe, bool enable);
a72e4c9f 1159bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
87440425
PZ
1160 enum transcoder pch_transcoder,
1161 bool enable);
1f7247c0
DV
1162void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
1163 enum pipe pipe);
1164void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
1165 enum transcoder pch_transcoder);
aca7b684
VS
1166void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv);
1167void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv);
47339cd9
DV
1168
1169/* i915_irq.c */
480c8033
DV
1170void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
1171void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
f4e9af4f
AG
1172void gen6_reset_pm_iir(struct drm_i915_private *dev_priv, u32 mask);
1173void gen6_mask_pm_irq(struct drm_i915_private *dev_priv, u32 mask);
1174void gen6_unmask_pm_irq(struct drm_i915_private *dev_priv, u32 mask);
480c8033
DV
1175void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
1176void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
dc97997a 1177void gen6_reset_rps_interrupts(struct drm_i915_private *dev_priv);
91d14251
TU
1178void gen6_enable_rps_interrupts(struct drm_i915_private *dev_priv);
1179void gen6_disable_rps_interrupts(struct drm_i915_private *dev_priv);
59d02a1f 1180u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
b963291c
DV
1181void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
1182void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
9df7575f
JB
1183static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
1184{
1185 /*
1186 * We only use drm_irq_uninstall() at unload and VT switch, so
1187 * this is the only thing we need to check.
1188 */
2aeb7d3a 1189 return dev_priv->pm.irqs_enabled;
9df7575f
JB
1190}
1191
a225f079 1192int intel_get_crtc_scanline(struct intel_crtc *crtc);
4c6c03be
DL
1193void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
1194 unsigned int pipe_mask);
aae8ba84
VS
1195void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv,
1196 unsigned int pipe_mask);
26705e20
SAK
1197void gen9_reset_guc_interrupts(struct drm_i915_private *dev_priv);
1198void gen9_enable_guc_interrupts(struct drm_i915_private *dev_priv);
1199void gen9_disable_guc_interrupts(struct drm_i915_private *dev_priv);
5f1aae65 1200
5f1aae65 1201/* intel_crt.c */
c39055b0 1202void intel_crt_init(struct drm_i915_private *dev_priv);
9504a892 1203void intel_crt_reset(struct drm_encoder *encoder);
5f1aae65
PZ
1204
1205/* intel_ddi.c */
e404ba8d 1206void intel_ddi_clk_select(struct intel_encoder *encoder,
c856052a 1207 struct intel_shared_dpll *pll);
b7076546
ML
1208void intel_ddi_fdi_post_disable(struct intel_encoder *intel_encoder,
1209 struct intel_crtc_state *old_crtc_state,
1210 struct drm_connector_state *old_conn_state);
32bdc400 1211void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder);
87440425 1212void hsw_fdi_link_train(struct drm_crtc *crtc);
c39055b0 1213void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port);
87440425
PZ
1214enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
1215bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
87440425
PZ
1216void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
1217void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
1218 enum transcoder cpu_transcoder);
1219void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
1220void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
190f68c5
ACO
1221bool intel_ddi_pll_select(struct intel_crtc *crtc,
1222 struct intel_crtc_state *crtc_state);
87440425 1223void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
ad64217b 1224void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
87440425 1225bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
9935f7fa
LY
1226bool intel_ddi_is_audio_enabled(struct drm_i915_private *dev_priv,
1227 struct intel_crtc *intel_crtc);
87440425 1228void intel_ddi_get_config(struct intel_encoder *encoder,
5cec258b 1229 struct intel_crtc_state *pipe_config);
bcddf610
S
1230struct intel_encoder *
1231intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
5f1aae65 1232
44905a27 1233void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
0e32b39c 1234void intel_ddi_clock_get(struct intel_encoder *encoder,
5cec258b 1235 struct intel_crtc_state *pipe_config);
0e32b39c 1236void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state);
f8896f5d 1237uint32_t ddi_signal_levels(struct intel_dp *intel_dp);
ffe5111e
VS
1238u8 intel_ddi_dp_voltage_max(struct intel_encoder *encoder);
1239
24dbf51a 1240unsigned int intel_fb_align_height(struct drm_i915_private *dev_priv,
6761dd31
TU
1241 unsigned int height,
1242 uint32_t pixel_format,
1243 uint64_t fb_format_modifier);
7b49f948
VS
1244u32 intel_fb_stride_alignment(const struct drm_i915_private *dev_priv,
1245 uint64_t fb_modifier, uint32_t pixel_format);
b680c37a 1246
7c10a2b5 1247/* intel_audio.c */
88212941 1248void intel_init_audio_hooks(struct drm_i915_private *dev_priv);
bbf35e9d
ML
1249void intel_audio_codec_enable(struct intel_encoder *encoder,
1250 const struct intel_crtc_state *crtc_state,
1251 const struct drm_connector_state *conn_state);
69bfe1a9 1252void intel_audio_codec_disable(struct intel_encoder *encoder);
58fddc28
ID
1253void i915_audio_component_init(struct drm_i915_private *dev_priv);
1254void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
7c10a2b5 1255
7ff89ca2
VS
1256/* intel_cdclk.c */
1257void intel_init_cdclk_hooks(struct drm_i915_private *dev_priv);
1258void intel_update_max_cdclk(struct drm_i915_private *dev_priv);
1259void intel_update_cdclk(struct drm_i915_private *dev_priv);
1260void intel_update_rawclk(struct drm_i915_private *dev_priv);
49cd97a3
VS
1261bool intel_cdclk_state_compare(const struct intel_cdclk_state *a,
1262 const struct intel_cdclk_state *b);
b0587e4d
VS
1263void intel_set_cdclk(struct drm_i915_private *dev_priv,
1264 const struct intel_cdclk_state *cdclk_state);
7ff89ca2 1265
b680c37a 1266/* intel_display.c */
65f2130c 1267enum transcoder intel_crtc_pch_transcoder(struct intel_crtc *crtc);
19ab4ed3 1268void intel_update_rawclk(struct drm_i915_private *dev_priv);
49cd97a3 1269int vlv_get_hpll_vco(struct drm_i915_private *dev_priv);
c30fec65
VS
1270int vlv_get_cck_clock(struct drm_i915_private *dev_priv,
1271 const char *name, u32 reg, int ref_freq);
7ff89ca2
VS
1272int vlv_get_cck_clock_hpll(struct drm_i915_private *dev_priv,
1273 const char *name, u32 reg);
b7076546
ML
1274void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv);
1275void lpt_disable_iclkip(struct drm_i915_private *dev_priv);
65a3fea0 1276extern const struct drm_plane_funcs intel_plane_funcs;
88212941 1277void intel_init_display_hooks(struct drm_i915_private *dev_priv);
6687c906 1278unsigned int intel_fb_xy_to_linear(int x, int y,
2949056c
VS
1279 const struct intel_plane_state *state,
1280 int plane);
6687c906 1281void intel_add_fb_offsets(int *x, int *y,
2949056c 1282 const struct intel_plane_state *state, int plane);
1663b9d6 1283unsigned int intel_rotation_info_size(const struct intel_rotation_info *rot_info);
49d73912 1284bool intel_has_pending_fb_unpin(struct drm_i915_private *dev_priv);
7d993739
TU
1285void intel_mark_busy(struct drm_i915_private *dev_priv);
1286void intel_mark_idle(struct drm_i915_private *dev_priv);
87440425 1287void intel_crtc_restore_mode(struct drm_crtc *crtc);
70e0bd74 1288int intel_display_suspend(struct drm_device *dev);
8090ba8c 1289void intel_pps_unlock_regs_wa(struct drm_i915_private *dev_priv);
87440425 1290void intel_encoder_destroy(struct drm_encoder *encoder);
08d9bc92
ACO
1291int intel_connector_init(struct intel_connector *);
1292struct intel_connector *intel_connector_alloc(void);
87440425 1293bool intel_connector_get_hw_state(struct intel_connector *connector);
87440425
PZ
1294void intel_connector_attach_encoder(struct intel_connector *connector,
1295 struct intel_encoder *encoder);
87440425
PZ
1296struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
1297 struct drm_crtc *crtc);
752aa88a 1298enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
08d7b3d1
CW
1299int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
1300 struct drm_file *file_priv);
87440425
PZ
1301enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
1302 enum pipe pipe);
2d84d2b3
VS
1303static inline bool
1304intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
1305 enum intel_output_type type)
1306{
1307 return crtc_state->output_types & (1 << type);
1308}
37a5650b
VS
1309static inline bool
1310intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
1311{
1312 return crtc_state->output_types &
cca0502b 1313 ((1 << INTEL_OUTPUT_DP) |
37a5650b
VS
1314 (1 << INTEL_OUTPUT_DP_MST) |
1315 (1 << INTEL_OUTPUT_EDP));
1316}
4f905cf9 1317static inline void
0f0f74bc 1318intel_wait_for_vblank(struct drm_i915_private *dev_priv, enum pipe pipe)
4f905cf9 1319{
0f0f74bc 1320 drm_wait_one_vblank(&dev_priv->drm, pipe);
4f905cf9 1321}
0c241d5b 1322static inline void
0f0f74bc 1323intel_wait_for_vblank_if_active(struct drm_i915_private *dev_priv, int pipe)
0c241d5b 1324{
b91eb5cc 1325 const struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
0c241d5b
VS
1326
1327 if (crtc->active)
0f0f74bc 1328 intel_wait_for_vblank(dev_priv, pipe);
0c241d5b 1329}
a2991414
ML
1330
1331u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc);
1332
87440425 1333int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
e4607fcf 1334void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
9b6de0a1
VS
1335 struct intel_digital_port *dport,
1336 unsigned int expected_mask);
87440425
PZ
1337bool intel_get_load_detect_pipe(struct drm_connector *connector,
1338 struct drm_display_mode *mode,
51fd371b
RC
1339 struct intel_load_detect_pipe *old,
1340 struct drm_modeset_acquire_ctx *ctx);
87440425 1341void intel_release_load_detect_pipe(struct drm_connector *connector,
49172fee
ACO
1342 struct intel_load_detect_pipe *old,
1343 struct drm_modeset_acquire_ctx *ctx);
058d88c4
CW
1344struct i915_vma *
1345intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation);
be1e3415 1346void intel_unpin_fb_vma(struct i915_vma *vma);
a8bb6818 1347struct drm_framebuffer *
24dbf51a
CW
1348intel_framebuffer_create(struct drm_i915_gem_object *obj,
1349 struct drm_mode_fb_cmd2 *mode_cmd);
5a21b665 1350void intel_finish_page_flip_cs(struct drm_i915_private *dev_priv, int pipe);
51cbaf01 1351void intel_finish_page_flip_mmio(struct drm_i915_private *dev_priv, int pipe);
5a21b665 1352void intel_check_page_flip(struct drm_i915_private *dev_priv, int pipe);
6beb8c23 1353int intel_prepare_plane_fb(struct drm_plane *plane,
1832040d 1354 struct drm_plane_state *new_state);
38f3ce3a 1355void intel_cleanup_plane_fb(struct drm_plane *plane,
1832040d 1356 struct drm_plane_state *old_state);
a98b3431
MR
1357int intel_plane_atomic_get_property(struct drm_plane *plane,
1358 const struct drm_plane_state *state,
1359 struct drm_property *property,
1360 uint64_t *val);
1361int intel_plane_atomic_set_property(struct drm_plane *plane,
1362 struct drm_plane_state *state,
1363 struct drm_property *property,
1364 uint64_t val);
da20eabd
ML
1365int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
1366 struct drm_plane_state *plane_state);
716c2e55 1367
832be82f
VS
1368unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
1369 uint64_t fb_modifier, unsigned int cpp);
50470bb0 1370
7abd4b35
ACO
1371void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
1372 enum pipe pipe);
1373
30ad9814 1374int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe,
3f36b937 1375 const struct dpll *dpll);
30ad9814 1376void vlv_force_pll_off(struct drm_i915_private *dev_priv, enum pipe pipe);
8802e5b6 1377int lpt_get_iclkip(struct drm_i915_private *dev_priv);
d288f65f 1378
716c2e55 1379/* modesetting asserts */
b680c37a
DV
1380void assert_panel_unlocked(struct drm_i915_private *dev_priv,
1381 enum pipe pipe);
55607e8a
DV
1382void assert_pll(struct drm_i915_private *dev_priv,
1383 enum pipe pipe, bool state);
1384#define assert_pll_enabled(d, p) assert_pll(d, p, true)
1385#define assert_pll_disabled(d, p) assert_pll(d, p, false)
8563b1e8
LL
1386void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state);
1387#define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true)
1388#define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false)
55607e8a
DV
1389void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
1390 enum pipe pipe, bool state);
1391#define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
1392#define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
87440425 1393void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
b840d907
JB
1394#define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
1395#define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
4f2d9934 1396u32 intel_compute_tile_offset(int *x, int *y,
2949056c 1397 const struct intel_plane_state *state, int plane);
c033666a
CW
1398void intel_prepare_reset(struct drm_i915_private *dev_priv);
1399void intel_finish_reset(struct drm_i915_private *dev_priv);
a14cb6fc
PZ
1400void hsw_enable_pc8(struct drm_i915_private *dev_priv);
1401void hsw_disable_pc8(struct drm_i915_private *dev_priv);
324513c0
ID
1402void bxt_init_cdclk(struct drm_i915_private *dev_priv);
1403void bxt_uninit_cdclk(struct drm_i915_private *dev_priv);
da2f41d1 1404void gen9_sanitize_dc_state(struct drm_i915_private *dev_priv);
664326f8
SK
1405void bxt_enable_dc9(struct drm_i915_private *dev_priv);
1406void bxt_disable_dc9(struct drm_i915_private *dev_priv);
f62c79b3 1407void gen9_enable_dc5(struct drm_i915_private *dev_priv);
5d96d8af
DL
1408void skl_init_cdclk(struct drm_i915_private *dev_priv);
1409void skl_uninit_cdclk(struct drm_i915_private *dev_priv);
c89e39f3 1410unsigned int skl_cdclk_get_vco(unsigned int freq);
0a9d2bed
AM
1411void skl_enable_dc6(struct drm_i915_private *dev_priv);
1412void skl_disable_dc6(struct drm_i915_private *dev_priv);
87440425 1413void intel_dp_get_m_n(struct intel_crtc *crtc,
5cec258b 1414 struct intel_crtc_state *pipe_config);
fe3cd48d 1415void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
87440425 1416int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
5ab7b0b7 1417bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, int target_clock,
9e2c8475
ACO
1418 struct dpll *best_clock);
1419int chv_calc_dpll_params(int refclk, struct dpll *pll_clock);
dccbea3b 1420
525b9311 1421bool intel_crtc_active(struct intel_crtc *crtc);
20bc8673
VS
1422void hsw_enable_ips(struct intel_crtc *crtc);
1423void hsw_disable_ips(struct intel_crtc *crtc);
79f255a0 1424enum intel_display_power_domain intel_port_to_power_domain(enum port port);
f6a83288 1425void intel_mode_from_pipe_config(struct drm_display_mode *mode,
5cec258b 1426 struct intel_crtc_state *pipe_config);
86adf9d7 1427
e435d6e5 1428int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
6156a456 1429int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
8ea30864 1430
be1e3415
CW
1431static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state)
1432{
1433 return i915_ggtt_offset(state->vma);
1434}
dedf278c 1435
6156a456
CK
1436u32 skl_plane_ctl_format(uint32_t pixel_format);
1437u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
1438u32 skl_plane_ctl_rotation(unsigned int rotation);
d2196774
VS
1439u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
1440 unsigned int rotation);
b63a16f6 1441int skl_check_plane_surface(struct intel_plane_state *plane_state);
121920fa 1442
eb805623 1443/* intel_csr.c */
f4448375 1444void intel_csr_ucode_init(struct drm_i915_private *);
2abc525b 1445void intel_csr_load_program(struct drm_i915_private *);
f4448375 1446void intel_csr_ucode_fini(struct drm_i915_private *);
f74ed08d
ID
1447void intel_csr_ucode_suspend(struct drm_i915_private *);
1448void intel_csr_ucode_resume(struct drm_i915_private *);
eb805623 1449
5f1aae65 1450/* intel_dp.c */
c39055b0
ACO
1451bool intel_dp_init(struct drm_i915_private *dev_priv, i915_reg_t output_reg,
1452 enum port port);
87440425
PZ
1453bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
1454 struct intel_connector *intel_connector);
901c2daf 1455void intel_dp_set_link_params(struct intel_dp *intel_dp,
dfa10480
ACO
1456 int link_rate, uint8_t lane_count,
1457 bool link_mst);
fdb14d33
MN
1458int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
1459 int link_rate, uint8_t lane_count);
87440425 1460void intel_dp_start_link_train(struct intel_dp *intel_dp);
87440425
PZ
1461void intel_dp_stop_link_train(struct intel_dp *intel_dp);
1462void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
bf93ba67
ID
1463void intel_dp_encoder_reset(struct drm_encoder *encoder);
1464void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder);
87440425 1465void intel_dp_encoder_destroy(struct drm_encoder *encoder);
d2e216d0 1466int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
87440425 1467bool intel_dp_compute_config(struct intel_encoder *encoder,
0a478c27
ML
1468 struct intel_crtc_state *pipe_config,
1469 struct drm_connector_state *conn_state);
dd11bc10 1470bool intel_dp_is_edp(struct drm_i915_private *dev_priv, enum port port);
b2c5c181
DV
1471enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
1472 bool long_hpd);
4be73780
DV
1473void intel_edp_backlight_on(struct intel_dp *intel_dp);
1474void intel_edp_backlight_off(struct intel_dp *intel_dp);
24f3e092 1475void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
4be73780
DV
1476void intel_edp_panel_on(struct intel_dp *intel_dp);
1477void intel_edp_panel_off(struct intel_dp *intel_dp);
0e32b39c
DA
1478void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
1479void intel_dp_mst_suspend(struct drm_device *dev);
1480void intel_dp_mst_resume(struct drm_device *dev);
50fec21a 1481int intel_dp_max_link_rate(struct intel_dp *intel_dp);
ed4e9c1d 1482int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
0e32b39c 1483void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
78597996 1484void intel_power_sequencer_reset(struct drm_i915_private *dev_priv);
0bc12bcb 1485uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
4a3b8769 1486void intel_plane_destroy(struct drm_plane *plane);
85cb48a1
ML
1487void intel_edp_drrs_enable(struct intel_dp *intel_dp,
1488 struct intel_crtc_state *crtc_state);
1489void intel_edp_drrs_disable(struct intel_dp *intel_dp,
1490 struct intel_crtc_state *crtc_state);
5748b6a1
CW
1491void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv,
1492 unsigned int frontbuffer_bits);
1493void intel_edp_drrs_flush(struct drm_i915_private *dev_priv,
1494 unsigned int frontbuffer_bits);
0bc12bcb 1495
94223d04
ACO
1496void
1497intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
1498 uint8_t dp_train_pat);
1499void
1500intel_dp_set_signal_levels(struct intel_dp *intel_dp);
1501void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
1502uint8_t
1503intel_dp_voltage_max(struct intel_dp *intel_dp);
1504uint8_t
1505intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing);
1506void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
1507 uint8_t *link_bw, uint8_t *rate_select);
e588fa18 1508bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
94223d04
ACO
1509bool
1510intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]);
1511
419b1b7a
ACO
1512static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
1513{
1514 return ~((1 << lane_count) - 1) & 0xf;
1515}
1516
24e807e7 1517bool intel_dp_read_dpcd(struct intel_dp *intel_dp);
489375c8
ID
1518bool __intel_dp_read_desc(struct intel_dp *intel_dp,
1519 struct intel_dp_desc *desc);
12a47a42 1520bool intel_dp_read_desc(struct intel_dp *intel_dp);
22a2c8e0
DP
1521int intel_dp_link_required(int pixel_clock, int bpp);
1522int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
390b4e00
ID
1523bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
1524 struct intel_digital_port *port);
24e807e7 1525
e7156c83
YA
1526/* intel_dp_aux_backlight.c */
1527int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
1528
0e32b39c
DA
1529/* intel_dp_mst.c */
1530int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
1531void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
5f1aae65 1532/* intel_dsi.c */
c39055b0 1533void intel_dsi_init(struct drm_i915_private *dev_priv);
5f1aae65 1534
90198355
JN
1535/* intel_dsi_dcs_backlight.c */
1536int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector);
5f1aae65
PZ
1537
1538/* intel_dvo.c */
c39055b0 1539void intel_dvo_init(struct drm_i915_private *dev_priv);
19625e85
L
1540/* intel_hotplug.c */
1541void intel_hpd_poll_init(struct drm_i915_private *dev_priv);
5f1aae65
PZ
1542
1543
0632fef6 1544/* legacy fbdev emulation in intel_fbdev.c */
0695726e 1545#ifdef CONFIG_DRM_FBDEV_EMULATION
4520f53a 1546extern int intel_fbdev_init(struct drm_device *dev);
e00bf696 1547extern void intel_fbdev_initial_config_async(struct drm_device *dev);
4520f53a 1548extern void intel_fbdev_fini(struct drm_device *dev);
82e3b8c1 1549extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
0632fef6
DV
1550extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
1551extern void intel_fbdev_restore_mode(struct drm_device *dev);
4520f53a
DV
1552#else
1553static inline int intel_fbdev_init(struct drm_device *dev)
1554{
1555 return 0;
1556}
5f1aae65 1557
e00bf696 1558static inline void intel_fbdev_initial_config_async(struct drm_device *dev)
4520f53a
DV
1559{
1560}
1561
1562static inline void intel_fbdev_fini(struct drm_device *dev)
1563{
1564}
1565
82e3b8c1 1566static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
4520f53a
DV
1567{
1568}
1569
d9c409d6
JN
1570static inline void intel_fbdev_output_poll_changed(struct drm_device *dev)
1571{
1572}
1573
0632fef6 1574static inline void intel_fbdev_restore_mode(struct drm_device *dev)
4520f53a
DV
1575{
1576}
1577#endif
5f1aae65 1578
7ff0ebcc 1579/* intel_fbc.c */
f51be2e0
PZ
1580void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
1581 struct drm_atomic_state *state);
0e631adc 1582bool intel_fbc_is_active(struct drm_i915_private *dev_priv);
faf68d92
ML
1583void intel_fbc_pre_update(struct intel_crtc *crtc,
1584 struct intel_crtc_state *crtc_state,
1585 struct intel_plane_state *plane_state);
1eb52238 1586void intel_fbc_post_update(struct intel_crtc *crtc);
7ff0ebcc 1587void intel_fbc_init(struct drm_i915_private *dev_priv);
010cf73d 1588void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv);
faf68d92
ML
1589void intel_fbc_enable(struct intel_crtc *crtc,
1590 struct intel_crtc_state *crtc_state,
1591 struct intel_plane_state *plane_state);
c937ab3e
PZ
1592void intel_fbc_disable(struct intel_crtc *crtc);
1593void intel_fbc_global_disable(struct drm_i915_private *dev_priv);
dbef0f15
PZ
1594void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
1595 unsigned int frontbuffer_bits,
1596 enum fb_op_origin origin);
1597void intel_fbc_flush(struct drm_i915_private *dev_priv,
6f4551fe 1598 unsigned int frontbuffer_bits, enum fb_op_origin origin);
7733b49b 1599void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv);
61a585d6 1600void intel_fbc_handle_fifo_underrun_irq(struct drm_i915_private *dev_priv);
7ff0ebcc 1601
5f1aae65 1602/* intel_hdmi.c */
c39055b0
ACO
1603void intel_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg,
1604 enum port port);
87440425
PZ
1605void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
1606 struct intel_connector *intel_connector);
1607struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
1608bool intel_hdmi_compute_config(struct intel_encoder *encoder,
0a478c27
ML
1609 struct intel_crtc_state *pipe_config,
1610 struct drm_connector_state *conn_state);
b2ccb822 1611void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
5f1aae65
PZ
1612
1613
1614/* intel_lvds.c */
c39055b0 1615void intel_lvds_init(struct drm_i915_private *dev_priv);
97a824e1 1616struct intel_encoder *intel_get_lvds_encoder(struct drm_device *dev);
87440425 1617bool intel_is_dual_link_lvds(struct drm_device *dev);
5f1aae65
PZ
1618
1619
1620/* intel_modes.c */
1621int intel_connector_update_modes(struct drm_connector *connector,
87440425 1622 struct edid *edid);
5f1aae65 1623int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
87440425
PZ
1624void intel_attach_force_audio_property(struct drm_connector *connector);
1625void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
7949dd47 1626void intel_attach_aspect_ratio_property(struct drm_connector *connector);
5f1aae65
PZ
1627
1628
1629/* intel_overlay.c */
1ee8da6d
CW
1630void intel_setup_overlay(struct drm_i915_private *dev_priv);
1631void intel_cleanup_overlay(struct drm_i915_private *dev_priv);
87440425 1632int intel_overlay_switch_off(struct intel_overlay *overlay);
1ee8da6d
CW
1633int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
1634 struct drm_file *file_priv);
1635int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data,
1636 struct drm_file *file_priv);
1362b776 1637void intel_overlay_reset(struct drm_i915_private *dev_priv);
5f1aae65
PZ
1638
1639
1640/* intel_panel.c */
87440425 1641int intel_panel_init(struct intel_panel *panel,
4b6ed685
VK
1642 struct drm_display_mode *fixed_mode,
1643 struct drm_display_mode *downclock_mode);
87440425
PZ
1644void intel_panel_fini(struct intel_panel *panel);
1645void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
1646 struct drm_display_mode *adjusted_mode);
1647void intel_pch_panel_fitting(struct intel_crtc *crtc,
5cec258b 1648 struct intel_crtc_state *pipe_config,
87440425
PZ
1649 int fitting_mode);
1650void intel_gmch_panel_fitting(struct intel_crtc *crtc,
5cec258b 1651 struct intel_crtc_state *pipe_config,
87440425 1652 int fitting_mode);
6dda730e
JN
1653void intel_panel_set_backlight_acpi(struct intel_connector *connector,
1654 u32 level, u32 max);
fda9ee98
CW
1655int intel_panel_setup_backlight(struct drm_connector *connector,
1656 enum pipe pipe);
752aa88a
JB
1657void intel_panel_enable_backlight(struct intel_connector *connector);
1658void intel_panel_disable_backlight(struct intel_connector *connector);
db31af1d 1659void intel_panel_destroy_backlight(struct drm_connector *connector);
1650be74 1660enum drm_connector_status intel_panel_detect(struct drm_i915_private *dev_priv);
ec9ed197 1661extern struct drm_display_mode *intel_find_panel_downclock(
a318b4c4 1662 struct drm_i915_private *dev_priv,
ec9ed197
VK
1663 struct drm_display_mode *fixed_mode,
1664 struct drm_connector *connector);
e63d87c0
CW
1665
1666#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
1ebaa0b9 1667int intel_backlight_device_register(struct intel_connector *connector);
e63d87c0
CW
1668void intel_backlight_device_unregister(struct intel_connector *connector);
1669#else /* CONFIG_BACKLIGHT_CLASS_DEVICE */
1ebaa0b9
CW
1670static int intel_backlight_device_register(struct intel_connector *connector)
1671{
1672 return 0;
1673}
e63d87c0
CW
1674static inline void intel_backlight_device_unregister(struct intel_connector *connector)
1675{
1676}
1677#endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
0962c3c9 1678
5f1aae65 1679
0bc12bcb 1680/* intel_psr.c */
0bc12bcb
RV
1681void intel_psr_enable(struct intel_dp *intel_dp);
1682void intel_psr_disable(struct intel_dp *intel_dp);
5748b6a1 1683void intel_psr_invalidate(struct drm_i915_private *dev_priv,
20c8838b 1684 unsigned frontbuffer_bits);
5748b6a1 1685void intel_psr_flush(struct drm_i915_private *dev_priv,
169de131
RV
1686 unsigned frontbuffer_bits,
1687 enum fb_op_origin origin);
c39055b0 1688void intel_psr_init(struct drm_i915_private *dev_priv);
5748b6a1 1689void intel_psr_single_frame_update(struct drm_i915_private *dev_priv,
20c8838b 1690 unsigned frontbuffer_bits);
0bc12bcb 1691
9c065a7d
DV
1692/* intel_runtime_pm.c */
1693int intel_power_domains_init(struct drm_i915_private *);
f458ebbc 1694void intel_power_domains_fini(struct drm_i915_private *);
73dfc227
ID
1695void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume);
1696void intel_power_domains_suspend(struct drm_i915_private *dev_priv);
8d8c386c 1697void intel_power_domains_verify_state(struct drm_i915_private *dev_priv);
d7d7c9ee
ID
1698void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume);
1699void bxt_display_core_uninit(struct drm_i915_private *dev_priv);
f458ebbc 1700void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
9895ad03
DS
1701const char *
1702intel_display_power_domain_str(enum intel_display_power_domain domain);
9c065a7d 1703
f458ebbc
DV
1704bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
1705 enum intel_display_power_domain domain);
1706bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
1707 enum intel_display_power_domain domain);
9c065a7d
DV
1708void intel_display_power_get(struct drm_i915_private *dev_priv,
1709 enum intel_display_power_domain domain);
09731280
ID
1710bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv,
1711 enum intel_display_power_domain domain);
9c065a7d
DV
1712void intel_display_power_put(struct drm_i915_private *dev_priv,
1713 enum intel_display_power_domain domain);
da5827c3
ID
1714
1715static inline void
1716assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv)
1717{
1718 WARN_ONCE(dev_priv->pm.suspended,
1719 "Device suspended during HW access\n");
1720}
1721
1722static inline void
1723assert_rpm_wakelock_held(struct drm_i915_private *dev_priv)
1724{
1725 assert_rpm_device_not_suspended(dev_priv);
becd9ca2
DV
1726 /* FIXME: Needs to be converted back to WARN_ONCE, but currently causes
1727 * too much noise. */
1728 if (!atomic_read(&dev_priv->pm.wakeref_count))
1729 DRM_DEBUG_DRIVER("RPM wakelock ref not held during HW access");
da5827c3
ID
1730}
1731
1f814dac
ID
1732/**
1733 * disable_rpm_wakeref_asserts - disable the RPM assert checks
1734 * @dev_priv: i915 device instance
1735 *
1736 * This function disable asserts that check if we hold an RPM wakelock
1737 * reference, while keeping the device-not-suspended checks still enabled.
1738 * It's meant to be used only in special circumstances where our rule about
1739 * the wakelock refcount wrt. the device power state doesn't hold. According
1740 * to this rule at any point where we access the HW or want to keep the HW in
1741 * an active state we must hold an RPM wakelock reference acquired via one of
1742 * the intel_runtime_pm_get() helpers. Currently there are a few special spots
1743 * where this rule doesn't hold: the IRQ and suspend/resume handlers, the
1744 * forcewake release timer, and the GPU RPS and hangcheck works. All other
1745 * users should avoid using this function.
1746 *
1747 * Any calls to this function must have a symmetric call to
1748 * enable_rpm_wakeref_asserts().
1749 */
1750static inline void
1751disable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
1752{
1753 atomic_inc(&dev_priv->pm.wakeref_count);
1754}
1755
1756/**
1757 * enable_rpm_wakeref_asserts - re-enable the RPM assert checks
1758 * @dev_priv: i915 device instance
1759 *
1760 * This function re-enables the RPM assert checks after disabling them with
1761 * disable_rpm_wakeref_asserts. It's meant to be used only in special
1762 * circumstances otherwise its use should be avoided.
1763 *
1764 * Any calls to this function must have a symmetric call to
1765 * disable_rpm_wakeref_asserts().
1766 */
1767static inline void
1768enable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
1769{
1770 atomic_dec(&dev_priv->pm.wakeref_count);
1771}
1772
9c065a7d 1773void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
09731280 1774bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv);
9c065a7d
DV
1775void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
1776void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
1777
d9bc89d9
DV
1778void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
1779
e0fce78f
VS
1780void chv_phy_powergate_lanes(struct intel_encoder *encoder,
1781 bool override, unsigned int mask);
b0b33846
VS
1782bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy,
1783 enum dpio_channel ch, bool override);
e0fce78f
VS
1784
1785
5f1aae65 1786/* intel_pm.c */
46f16e63 1787void intel_init_clock_gating(struct drm_i915_private *dev_priv);
712bf364 1788void intel_suspend_hw(struct drm_i915_private *dev_priv);
5db94019 1789int ilk_wm_max_level(const struct drm_i915_private *dev_priv);
432081bc 1790void intel_update_watermarks(struct intel_crtc *crtc);
62d75df7 1791void intel_init_pm(struct drm_i915_private *dev_priv);
bb400da9 1792void intel_init_clock_gating_hooks(struct drm_i915_private *dev_priv);
192aa181 1793void intel_pm_setup(struct drm_i915_private *dev_priv);
87440425
PZ
1794void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
1795void intel_gpu_ips_teardown(void);
dc97997a 1796void intel_init_gt_powersave(struct drm_i915_private *dev_priv);
54b4f68f
CW
1797void intel_cleanup_gt_powersave(struct drm_i915_private *dev_priv);
1798void intel_sanitize_gt_powersave(struct drm_i915_private *dev_priv);
dc97997a 1799void intel_enable_gt_powersave(struct drm_i915_private *dev_priv);
54b4f68f 1800void intel_autoenable_gt_powersave(struct drm_i915_private *dev_priv);
dc97997a 1801void intel_disable_gt_powersave(struct drm_i915_private *dev_priv);
54b4f68f 1802void intel_suspend_gt_powersave(struct drm_i915_private *dev_priv);
43cf3bf0
CW
1803void gen6_rps_busy(struct drm_i915_private *dev_priv);
1804void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
076e29f2 1805void gen6_rps_idle(struct drm_i915_private *dev_priv);
1854d5ca 1806void gen6_rps_boost(struct drm_i915_private *dev_priv,
e61b9958
CW
1807 struct intel_rps_client *rps,
1808 unsigned long submitted);
91d14251 1809void intel_queue_rps_boost_for_request(struct drm_i915_gem_request *req);
6eb1a681 1810void vlv_wm_get_hw_state(struct drm_device *dev);
243e6a44 1811void ilk_wm_get_hw_state(struct drm_device *dev);
3078999f 1812void skl_wm_get_hw_state(struct drm_device *dev);
08db6652
DL
1813void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
1814 struct skl_ddb_allocation *ddb /* out */);
bf9d99ad 1815void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc,
1816 struct skl_pipe_wm *out);
16dcdc4e
PZ
1817bool intel_can_enable_sagv(struct drm_atomic_state *state);
1818int intel_enable_sagv(struct drm_i915_private *dev_priv);
1819int intel_disable_sagv(struct drm_i915_private *dev_priv);
45ece230 1820bool skl_wm_level_equals(const struct skl_wm_level *l1,
1821 const struct skl_wm_level *l2);
5eff503b
ML
1822bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry **entries,
1823 const struct skl_ddb_entry *ddb,
1824 int ignore);
ed4a6a7c 1825bool ilk_disable_lp_wm(struct drm_device *dev);
dc97997a
CW
1826int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6);
1827static inline int intel_enable_rc6(void)
1828{
1829 return i915.enable_rc6;
1830}
72662e10 1831
5f1aae65 1832/* intel_sdvo.c */
c39055b0 1833bool intel_sdvo_init(struct drm_i915_private *dev_priv,
f0f59a00 1834 i915_reg_t reg, enum port port);
96a02917 1835
2b28bb1b 1836
5f1aae65 1837/* intel_sprite.c */
dfd2e9ab
VS
1838int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
1839 int usecs);
580503c7 1840struct intel_plane *intel_sprite_plane_create(struct drm_i915_private *dev_priv,
b079bd17 1841 enum pipe pipe, int plane);
87440425
PZ
1842int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
1843 struct drm_file *file_priv);
34e0adbb 1844void intel_pipe_update_start(struct intel_crtc *crtc);
51cbaf01 1845void intel_pipe_update_end(struct intel_crtc *crtc, struct intel_flip_work *work);
5f1aae65
PZ
1846
1847/* intel_tv.c */
c39055b0 1848void intel_tv_init(struct drm_i915_private *dev_priv);
20ddf665 1849
ea2c67bb 1850/* intel_atomic.c */
2545e4a6
MR
1851int intel_connector_atomic_get_property(struct drm_connector *connector,
1852 const struct drm_connector_state *state,
1853 struct drm_property *property,
1854 uint64_t *val);
1356837e
MR
1855struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
1856void intel_crtc_destroy_state(struct drm_crtc *crtc,
1857 struct drm_crtc_state *state);
de419ab6
ML
1858struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
1859void intel_atomic_state_clear(struct drm_atomic_state *);
de419ab6 1860
10f81c19
ACO
1861static inline struct intel_crtc_state *
1862intel_atomic_get_crtc_state(struct drm_atomic_state *state,
1863 struct intel_crtc *crtc)
1864{
1865 struct drm_crtc_state *crtc_state;
1866 crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
1867 if (IS_ERR(crtc_state))
0b6cc188 1868 return ERR_CAST(crtc_state);
10f81c19
ACO
1869
1870 return to_intel_crtc_state(crtc_state);
1871}
e3bddded 1872
ccc24b39
MK
1873static inline struct intel_crtc_state *
1874intel_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
1875 struct intel_crtc *crtc)
1876{
1877 struct drm_crtc_state *crtc_state;
1878
1879 crtc_state = drm_atomic_get_existing_crtc_state(state, &crtc->base);
1880
1881 if (crtc_state)
1882 return to_intel_crtc_state(crtc_state);
1883 else
1884 return NULL;
1885}
1886
e3bddded
ML
1887static inline struct intel_plane_state *
1888intel_atomic_get_existing_plane_state(struct drm_atomic_state *state,
1889 struct intel_plane *plane)
1890{
1891 struct drm_plane_state *plane_state;
1892
1893 plane_state = drm_atomic_get_existing_plane_state(state, &plane->base);
1894
1895 return to_intel_plane_state(plane_state);
1896}
1897
6ebc6923
ACO
1898int intel_atomic_setup_scalers(struct drm_i915_private *dev_priv,
1899 struct intel_crtc *intel_crtc,
1900 struct intel_crtc_state *crtc_state);
5ee67f1c
MR
1901
1902/* intel_atomic_plane.c */
8e7d688b 1903struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
ea2c67bb
MR
1904struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
1905void intel_plane_destroy_state(struct drm_plane *plane,
1906 struct drm_plane_state *state);
1907extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
f79f2692
ML
1908int intel_plane_atomic_check_with_state(struct intel_crtc_state *crtc_state,
1909 struct intel_plane_state *intel_state);
ea2c67bb 1910
8563b1e8
LL
1911/* intel_color.c */
1912void intel_color_init(struct drm_crtc *crtc);
82cf435b 1913int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
b95c5321
ML
1914void intel_color_set_csc(struct drm_crtc_state *crtc_state);
1915void intel_color_load_luts(struct drm_crtc_state *crtc_state);
8563b1e8 1916
dbe9e61b
SS
1917/* intel_lspcon.c */
1918bool lspcon_init(struct intel_digital_port *intel_dig_port);
910530c0 1919void lspcon_resume(struct intel_lspcon *lspcon);
357c0ae9 1920void lspcon_wait_pcon_mode(struct intel_lspcon *lspcon);
731035fe
TV
1921
1922/* intel_pipe_crc.c */
1923int intel_pipe_crc_create(struct drm_minor *minor);
1924void intel_pipe_crc_cleanup(struct drm_minor *minor);
8c6b709d
TV
1925#ifdef CONFIG_DEBUG_FS
1926int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
1927 size_t *values_cnt);
1928#else
1929#define intel_crtc_set_crc_source NULL
1930#endif
731035fe 1931extern const struct file_operations i915_display_crc_ctl_fops;
79e53945 1932#endif /* __INTEL_DRV_H__ */