intel_drv.h 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696
  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. #include <linux/async.h>
  28. #include <linux/i2c.h>
  29. #include <linux/hdmi.h>
  30. #include <drm/i915_drm.h>
  31. #include "i915_drv.h"
  32. #include <drm/drm_crtc.h>
  33. #include <drm/drm_crtc_helper.h>
  34. #include <drm/drm_fb_helper.h>
  35. #include <drm/drm_dp_dual_mode_helper.h>
  36. #include <drm/drm_dp_mst_helper.h>
  37. #include <drm/drm_rect.h>
  38. #include <drm/drm_atomic.h>
  39. /**
  40. * _wait_for - magic (register) wait macro
  41. *
  42. * Does the right thing for modeset paths when run under kdgb or similar atomic
  43. * contexts. Note that it's important that we check the condition again after
  44. * having timed out, since the timeout could be due to preemption or similar and
  45. * we've never had a chance to check the condition before the timeout.
  46. *
  47. * TODO: When modesetting has fully transitioned to atomic, the below
  48. * drm_can_sleep() can be removed and in_atomic()/!in_atomic() asserts
  49. * added.
  50. */
  51. #define _wait_for(COND, US, W) ({ \
  52. unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \
  53. int ret__ = 0; \
  54. while (!(COND)) { \
  55. if (time_after(jiffies, timeout__)) { \
  56. if (!(COND)) \
  57. ret__ = -ETIMEDOUT; \
  58. break; \
  59. } \
  60. if ((W) && drm_can_sleep()) { \
  61. usleep_range((W), (W)*2); \
  62. } else { \
  63. cpu_relax(); \
  64. } \
  65. } \
  66. ret__; \
  67. })
  68. #define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 1000)
  69. #define wait_for_us(COND, US) _wait_for((COND), (US), 1)
  70. /* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */
  71. #if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT)
  72. # define _WAIT_FOR_ATOMIC_CHECK WARN_ON_ONCE(!in_atomic())
  73. #else
  74. # define _WAIT_FOR_ATOMIC_CHECK do { } while (0)
  75. #endif
  76. #define _wait_for_atomic(COND, US) ({ \
  77. unsigned long end__; \
  78. int ret__ = 0; \
  79. _WAIT_FOR_ATOMIC_CHECK; \
  80. BUILD_BUG_ON((US) > 50000); \
  81. end__ = (local_clock() >> 10) + (US) + 1; \
  82. while (!(COND)) { \
  83. if (time_after((unsigned long)(local_clock() >> 10), end__)) { \
  84. /* Unlike the regular wait_for(), this atomic variant \
  85. * cannot be preempted (and we'll just ignore the issue\
  86. * of irq interruptions) and so we know that no time \
  87. * has passed since the last check of COND and can \
  88. * immediately report the timeout. \
  89. */ \
  90. ret__ = -ETIMEDOUT; \
  91. break; \
  92. } \
  93. cpu_relax(); \
  94. } \
  95. ret__; \
  96. })
  97. #define wait_for_atomic(COND, MS) _wait_for_atomic((COND), (MS) * 1000)
  98. #define wait_for_atomic_us(COND, US) _wait_for_atomic((COND), (US))
  99. #define KHz(x) (1000 * (x))
  100. #define MHz(x) KHz(1000 * (x))
  101. /*
  102. * Display related stuff
  103. */
  104. /* store information about an Ixxx DVO */
  105. /* The i830->i865 use multiple DVOs with multiple i2cs */
  106. /* the i915, i945 have a single sDVO i2c bus - which is different */
  107. #define MAX_OUTPUTS 6
  108. /* maximum connectors per crtcs in the mode set */
  109. /* Maximum cursor sizes */
  110. #define GEN2_CURSOR_WIDTH 64
  111. #define GEN2_CURSOR_HEIGHT 64
  112. #define MAX_CURSOR_WIDTH 256
  113. #define MAX_CURSOR_HEIGHT 256
  114. #define INTEL_I2C_BUS_DVO 1
  115. #define INTEL_I2C_BUS_SDVO 2
  116. /* these are outputs from the chip - integrated only
  117. external chips are via DVO or SDVO output */
  118. enum intel_output_type {
  119. INTEL_OUTPUT_UNUSED = 0,
  120. INTEL_OUTPUT_ANALOG = 1,
  121. INTEL_OUTPUT_DVO = 2,
  122. INTEL_OUTPUT_SDVO = 3,
  123. INTEL_OUTPUT_LVDS = 4,
  124. INTEL_OUTPUT_TVOUT = 5,
  125. INTEL_OUTPUT_HDMI = 6,
  126. INTEL_OUTPUT_DISPLAYPORT = 7,
  127. INTEL_OUTPUT_EDP = 8,
  128. INTEL_OUTPUT_DSI = 9,
  129. INTEL_OUTPUT_UNKNOWN = 10,
  130. INTEL_OUTPUT_DP_MST = 11,
  131. };
  132. #define INTEL_DVO_CHIP_NONE 0
  133. #define INTEL_DVO_CHIP_LVDS 1
  134. #define INTEL_DVO_CHIP_TMDS 2
  135. #define INTEL_DVO_CHIP_TVOUT 4
  136. #define INTEL_DSI_VIDEO_MODE 0
  137. #define INTEL_DSI_COMMAND_MODE 1
  138. struct intel_framebuffer {
  139. struct drm_framebuffer base;
  140. struct drm_i915_gem_object *obj;
  141. struct intel_rotation_info rot_info;
  142. };
  143. struct intel_fbdev {
  144. struct drm_fb_helper helper;
  145. struct intel_framebuffer *fb;
  146. int preferred_bpp;
  147. };
  148. struct intel_encoder {
  149. struct drm_encoder base;
  150. enum intel_output_type type;
  151. unsigned int cloneable;
  152. void (*hot_plug)(struct intel_encoder *);
  153. bool (*compute_config)(struct intel_encoder *,
  154. struct intel_crtc_state *);
  155. void (*pre_pll_enable)(struct intel_encoder *);
  156. void (*pre_enable)(struct intel_encoder *);
  157. void (*enable)(struct intel_encoder *);
  158. void (*mode_set)(struct intel_encoder *intel_encoder);
  159. void (*disable)(struct intel_encoder *);
  160. void (*post_disable)(struct intel_encoder *);
  161. void (*post_pll_disable)(struct intel_encoder *);
  162. /* Read out the current hw state of this connector, returning true if
  163. * the encoder is active. If the encoder is enabled it also set the pipe
  164. * it is connected to in the pipe parameter. */
  165. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  166. /* Reconstructs the equivalent mode flags for the current hardware
  167. * state. This must be called _after_ display->get_pipe_config has
  168. * pre-filled the pipe config. Note that intel_encoder->base.crtc must
  169. * be set correctly before calling this function. */
  170. void (*get_config)(struct intel_encoder *,
  171. struct intel_crtc_state *pipe_config);
  172. /*
  173. * Called during system suspend after all pending requests for the
  174. * encoder are flushed (for example for DP AUX transactions) and
  175. * device interrupts are disabled.
  176. */
  177. void (*suspend)(struct intel_encoder *);
  178. int crtc_mask;
  179. enum hpd_pin hpd_pin;
  180. };
  181. struct intel_panel {
  182. struct drm_display_mode *fixed_mode;
  183. struct drm_display_mode *downclock_mode;
  184. int fitting_mode;
  185. /* backlight */
  186. struct {
  187. bool present;
  188. u32 level;
  189. u32 min;
  190. u32 max;
  191. bool enabled;
  192. bool combination_mode; /* gen 2/4 only */
  193. bool active_low_pwm;
  194. /* PWM chip */
  195. bool util_pin_active_low; /* bxt+ */
  196. u8 controller; /* bxt+ only */
  197. struct pwm_device *pwm;
  198. struct backlight_device *device;
  199. /* Connector and platform specific backlight functions */
  200. int (*setup)(struct intel_connector *connector, enum pipe pipe);
  201. uint32_t (*get)(struct intel_connector *connector);
  202. void (*set)(struct intel_connector *connector, uint32_t level);
  203. void (*disable)(struct intel_connector *connector);
  204. void (*enable)(struct intel_connector *connector);
  205. uint32_t (*hz_to_pwm)(struct intel_connector *connector,
  206. uint32_t hz);
  207. void (*power)(struct intel_connector *, bool enable);
  208. } backlight;
  209. };
  210. struct intel_connector {
  211. struct drm_connector base;
  212. /*
  213. * The fixed encoder this connector is connected to.
  214. */
  215. struct intel_encoder *encoder;
  216. /* Reads out the current hw, returning true if the connector is enabled
  217. * and active (i.e. dpms ON state). */
  218. bool (*get_hw_state)(struct intel_connector *);
  219. /*
  220. * Removes all interfaces through which the connector is accessible
  221. * - like sysfs, debugfs entries -, so that no new operations can be
  222. * started on the connector. Also makes sure all currently pending
  223. * operations finish before returing.
  224. */
  225. void (*unregister)(struct intel_connector *);
  226. /* Panel info for eDP and LVDS */
  227. struct intel_panel panel;
  228. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  229. struct edid *edid;
  230. struct edid *detect_edid;
  231. /* since POLL and HPD connectors may use the same HPD line keep the native
  232. state of connector->polled in case hotplug storm detection changes it */
  233. u8 polled;
  234. void *port; /* store this opaque as its illegal to dereference it */
  235. struct intel_dp *mst_port;
  236. };
  237. typedef struct dpll {
  238. /* given values */
  239. int n;
  240. int m1, m2;
  241. int p1, p2;
  242. /* derived values */
  243. int dot;
  244. int vco;
  245. int m;
  246. int p;
  247. } intel_clock_t;
  248. struct intel_atomic_state {
  249. struct drm_atomic_state base;
  250. unsigned int cdclk;
  251. /*
  252. * Calculated device cdclk, can be different from cdclk
  253. * only when all crtc's are DPMS off.
  254. */
  255. unsigned int dev_cdclk;
  256. bool dpll_set, modeset;
  257. unsigned int active_crtcs;
  258. unsigned int min_pixclk[I915_MAX_PIPES];
  259. struct intel_shared_dpll_config shared_dpll[I915_NUM_PLLS];
  260. struct intel_wm_config wm_config;
  261. /*
  262. * Current watermarks can't be trusted during hardware readout, so
  263. * don't bother calculating intermediate watermarks.
  264. */
  265. bool skip_intermediate_wm;
  266. };
  267. struct intel_plane_state {
  268. struct drm_plane_state base;
  269. struct drm_rect src;
  270. struct drm_rect dst;
  271. struct drm_rect clip;
  272. bool visible;
  273. /*
  274. * scaler_id
  275. * = -1 : not using a scaler
  276. * >= 0 : using a scalers
  277. *
  278. * plane requiring a scaler:
  279. * - During check_plane, its bit is set in
  280. * crtc_state->scaler_state.scaler_users by calling helper function
  281. * update_scaler_plane.
  282. * - scaler_id indicates the scaler it got assigned.
  283. *
  284. * plane doesn't require a scaler:
  285. * - this can happen when scaling is no more required or plane simply
  286. * got disabled.
  287. * - During check_plane, corresponding bit is reset in
  288. * crtc_state->scaler_state.scaler_users by calling helper function
  289. * update_scaler_plane.
  290. */
  291. int scaler_id;
  292. struct drm_intel_sprite_colorkey ckey;
  293. /* async flip related structures */
  294. struct drm_i915_gem_request *wait_req;
  295. };
  296. struct intel_initial_plane_config {
  297. struct intel_framebuffer *fb;
  298. unsigned int tiling;
  299. int size;
  300. u32 base;
  301. };
  302. #define SKL_MIN_SRC_W 8
  303. #define SKL_MAX_SRC_W 4096
  304. #define SKL_MIN_SRC_H 8
  305. #define SKL_MAX_SRC_H 4096
  306. #define SKL_MIN_DST_W 8
  307. #define SKL_MAX_DST_W 4096
  308. #define SKL_MIN_DST_H 8
  309. #define SKL_MAX_DST_H 4096
  310. struct intel_scaler {
  311. int in_use;
  312. uint32_t mode;
  313. };
  314. struct intel_crtc_scaler_state {
  315. #define SKL_NUM_SCALERS 2
  316. struct intel_scaler scalers[SKL_NUM_SCALERS];
  317. /*
  318. * scaler_users: keeps track of users requesting scalers on this crtc.
  319. *
  320. * If a bit is set, a user is using a scaler.
  321. * Here user can be a plane or crtc as defined below:
  322. * bits 0-30 - plane (bit position is index from drm_plane_index)
  323. * bit 31 - crtc
  324. *
  325. * Instead of creating a new index to cover planes and crtc, using
  326. * existing drm_plane_index for planes which is well less than 31
  327. * planes and bit 31 for crtc. This should be fine to cover all
  328. * our platforms.
  329. *
  330. * intel_atomic_setup_scalers will setup available scalers to users
  331. * requesting scalers. It will gracefully fail if request exceeds
  332. * avilability.
  333. */
  334. #define SKL_CRTC_INDEX 31
  335. unsigned scaler_users;
  336. /* scaler used by crtc for panel fitting purpose */
  337. int scaler_id;
  338. };
  339. /* drm_mode->private_flags */
  340. #define I915_MODE_FLAG_INHERITED 1
  341. struct intel_pipe_wm {
  342. struct intel_wm_level wm[5];
  343. struct intel_wm_level raw_wm[5];
  344. uint32_t linetime;
  345. bool fbc_wm_enabled;
  346. bool pipe_enabled;
  347. bool sprites_enabled;
  348. bool sprites_scaled;
  349. };
  350. struct skl_pipe_wm {
  351. struct skl_wm_level wm[8];
  352. struct skl_wm_level trans_wm;
  353. uint32_t linetime;
  354. };
  355. struct intel_crtc_state {
  356. struct drm_crtc_state base;
  357. /**
  358. * quirks - bitfield with hw state readout quirks
  359. *
  360. * For various reasons the hw state readout code might not be able to
  361. * completely faithfully read out the current state. These cases are
  362. * tracked with quirk flags so that fastboot and state checker can act
  363. * accordingly.
  364. */
  365. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  366. unsigned long quirks;
  367. unsigned fb_bits; /* framebuffers to flip */
  368. bool update_pipe; /* can a fast modeset be performed? */
  369. bool disable_cxsr;
  370. bool update_wm_pre, update_wm_post; /* watermarks are updated */
  371. bool fb_changed; /* fb on any of the planes is changed */
  372. /* Pipe source size (ie. panel fitter input size)
  373. * All planes will be positioned inside this space,
  374. * and get clipped at the edges. */
  375. int pipe_src_w, pipe_src_h;
  376. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  377. * between pch encoders and cpu encoders. */
  378. bool has_pch_encoder;
  379. /* Are we sending infoframes on the attached port */
  380. bool has_infoframe;
  381. /* CPU Transcoder for the pipe. Currently this can only differ from the
  382. * pipe on Haswell and later (where we have a special eDP transcoder)
  383. * and Broxton (where we have special DSI transcoders). */
  384. enum transcoder cpu_transcoder;
  385. /*
  386. * Use reduced/limited/broadcast rbg range, compressing from the full
  387. * range fed into the crtcs.
  388. */
  389. bool limited_color_range;
  390. /* DP has a bunch of special case unfortunately, so mark the pipe
  391. * accordingly. */
  392. bool has_dp_encoder;
  393. /* DSI has special cases */
  394. bool has_dsi_encoder;
  395. /* Whether we should send NULL infoframes. Required for audio. */
  396. bool has_hdmi_sink;
  397. /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
  398. * has_dp_encoder is set. */
  399. bool has_audio;
  400. /*
  401. * Enable dithering, used when the selected pipe bpp doesn't match the
  402. * plane bpp.
  403. */
  404. bool dither;
  405. /* Controls for the clock computation, to override various stages. */
  406. bool clock_set;
  407. /* SDVO TV has a bunch of special case. To make multifunction encoders
  408. * work correctly, we need to track this at runtime.*/
  409. bool sdvo_tv_clock;
  410. /*
  411. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  412. * required. This is set in the 2nd loop of calling encoder's
  413. * ->compute_config if the first pick doesn't work out.
  414. */
  415. bool bw_constrained;
  416. /* Settings for the intel dpll used on pretty much everything but
  417. * haswell. */
  418. struct dpll dpll;
  419. /* Selected dpll when shared or NULL. */
  420. struct intel_shared_dpll *shared_dpll;
  421. /*
  422. * - PORT_CLK_SEL for DDI ports on HSW/BDW.
  423. * - enum skl_dpll on SKL
  424. */
  425. uint32_t ddi_pll_sel;
  426. /* Actual register state of the dpll, for shared dpll cross-checking. */
  427. struct intel_dpll_hw_state dpll_hw_state;
  428. /* DSI PLL registers */
  429. struct {
  430. u32 ctrl, div;
  431. } dsi_pll;
  432. int pipe_bpp;
  433. struct intel_link_m_n dp_m_n;
  434. /* m2_n2 for eDP downclock */
  435. struct intel_link_m_n dp_m2_n2;
  436. bool has_drrs;
  437. /*
  438. * Frequence the dpll for the port should run at. Differs from the
  439. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  440. * already multiplied by pixel_multiplier.
  441. */
  442. int port_clock;
  443. /* Used by SDVO (and if we ever fix it, HDMI). */
  444. unsigned pixel_multiplier;
  445. uint8_t lane_count;
  446. /* Panel fitter controls for gen2-gen4 + VLV */
  447. struct {
  448. u32 control;
  449. u32 pgm_ratios;
  450. u32 lvds_border_bits;
  451. } gmch_pfit;
  452. /* Panel fitter placement and size for Ironlake+ */
  453. struct {
  454. u32 pos;
  455. u32 size;
  456. bool enabled;
  457. bool force_thru;
  458. } pch_pfit;
  459. /* FDI configuration, only valid if has_pch_encoder is set. */
  460. int fdi_lanes;
  461. struct intel_link_m_n fdi_m_n;
  462. bool ips_enabled;
  463. bool enable_fbc;
  464. bool double_wide;
  465. bool dp_encoder_is_mst;
  466. int pbn;
  467. struct intel_crtc_scaler_state scaler_state;
  468. /* w/a for waiting 2 vblanks during crtc enable */
  469. enum pipe hsw_workaround_pipe;
  470. /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
  471. bool disable_lp_wm;
  472. struct {
  473. /*
  474. * Optimal watermarks, programmed post-vblank when this state
  475. * is committed.
  476. */
  477. union {
  478. struct intel_pipe_wm ilk;
  479. struct skl_pipe_wm skl;
  480. } optimal;
  481. /*
  482. * Intermediate watermarks; these can be programmed immediately
  483. * since they satisfy both the current configuration we're
  484. * switching away from and the new configuration we're switching
  485. * to.
  486. */
  487. struct intel_pipe_wm intermediate;
  488. /*
  489. * Platforms with two-step watermark programming will need to
  490. * update watermark programming post-vblank to switch from the
  491. * safe intermediate watermarks to the optimal final
  492. * watermarks.
  493. */
  494. bool need_postvbl_update;
  495. } wm;
  496. /* Gamma mode programmed on the pipe */
  497. uint32_t gamma_mode;
  498. };
  499. struct vlv_wm_state {
  500. struct vlv_pipe_wm wm[3];
  501. struct vlv_sr_wm sr[3];
  502. uint8_t num_active_planes;
  503. uint8_t num_levels;
  504. uint8_t level;
  505. bool cxsr;
  506. };
  507. struct intel_mmio_flip {
  508. struct work_struct work;
  509. struct drm_i915_private *i915;
  510. struct drm_i915_gem_request *req;
  511. struct intel_crtc *crtc;
  512. unsigned int rotation;
  513. };
  514. struct intel_crtc {
  515. struct drm_crtc base;
  516. enum pipe pipe;
  517. enum plane plane;
  518. u8 lut_r[256], lut_g[256], lut_b[256];
  519. /*
  520. * Whether the crtc and the connected output pipeline is active. Implies
  521. * that crtc->enabled is set, i.e. the current mode configuration has
  522. * some outputs connected to this crtc.
  523. */
  524. bool active;
  525. unsigned long enabled_power_domains;
  526. bool lowfreq_avail;
  527. struct intel_overlay *overlay;
  528. struct intel_unpin_work *unpin_work;
  529. atomic_t unpin_work_count;
  530. /* Display surface base address adjustement for pageflips. Note that on
  531. * gen4+ this only adjusts up to a tile, offsets within a tile are
  532. * handled in the hw itself (with the TILEOFF register). */
  533. u32 dspaddr_offset;
  534. int adjusted_x;
  535. int adjusted_y;
  536. uint32_t cursor_addr;
  537. uint32_t cursor_cntl;
  538. uint32_t cursor_size;
  539. uint32_t cursor_base;
  540. struct intel_crtc_state *config;
  541. /* reset counter value when the last flip was submitted */
  542. unsigned int reset_counter;
  543. /* Access to these should be protected by dev_priv->irq_lock. */
  544. bool cpu_fifo_underrun_disabled;
  545. bool pch_fifo_underrun_disabled;
  546. /* per-pipe watermark state */
  547. struct {
  548. /* watermarks currently being used */
  549. union {
  550. struct intel_pipe_wm ilk;
  551. struct skl_pipe_wm skl;
  552. } active;
  553. /* allow CxSR on this pipe */
  554. bool cxsr_allowed;
  555. } wm;
  556. int scanline_offset;
  557. struct {
  558. unsigned start_vbl_count;
  559. ktime_t start_vbl_time;
  560. int min_vbl, max_vbl;
  561. int scanline_start;
  562. } debug;
  563. /* scalers available on this crtc */
  564. int num_scalers;
  565. struct vlv_wm_state wm_state;
  566. };
  567. struct intel_plane_wm_parameters {
  568. uint32_t horiz_pixels;
  569. uint32_t vert_pixels;
  570. /*
  571. * For packed pixel formats:
  572. * bytes_per_pixel - holds bytes per pixel
  573. * For planar pixel formats:
  574. * bytes_per_pixel - holds bytes per pixel for uv-plane
  575. * y_bytes_per_pixel - holds bytes per pixel for y-plane
  576. */
  577. uint8_t bytes_per_pixel;
  578. uint8_t y_bytes_per_pixel;
  579. bool enabled;
  580. bool scaled;
  581. u64 tiling;
  582. unsigned int rotation;
  583. uint16_t fifo_size;
  584. };
  585. struct intel_plane {
  586. struct drm_plane base;
  587. int plane;
  588. enum pipe pipe;
  589. bool can_scale;
  590. int max_downscale;
  591. uint32_t frontbuffer_bit;
  592. /* Since we need to change the watermarks before/after
  593. * enabling/disabling the planes, we need to store the parameters here
  594. * as the other pieces of the struct may not reflect the values we want
  595. * for the watermark calculations. Currently only Haswell uses this.
  596. */
  597. struct intel_plane_wm_parameters wm;
  598. /*
  599. * NOTE: Do not place new plane state fields here (e.g., when adding
  600. * new plane properties). New runtime state should now be placed in
  601. * the intel_plane_state structure and accessed via plane_state.
  602. */
  603. void (*update_plane)(struct drm_plane *plane,
  604. const struct intel_crtc_state *crtc_state,
  605. const struct intel_plane_state *plane_state);
  606. void (*disable_plane)(struct drm_plane *plane,
  607. struct drm_crtc *crtc);
  608. int (*check_plane)(struct drm_plane *plane,
  609. struct intel_crtc_state *crtc_state,
  610. struct intel_plane_state *state);
  611. };
  612. struct intel_watermark_params {
  613. unsigned long fifo_size;
  614. unsigned long max_wm;
  615. unsigned long default_wm;
  616. unsigned long guard_size;
  617. unsigned long cacheline_size;
  618. };
  619. struct cxsr_latency {
  620. int is_desktop;
  621. int is_ddr3;
  622. unsigned long fsb_freq;
  623. unsigned long mem_freq;
  624. unsigned long display_sr;
  625. unsigned long display_hpll_disable;
  626. unsigned long cursor_sr;
  627. unsigned long cursor_hpll_disable;
  628. };
  629. #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
  630. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  631. #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
  632. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  633. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  634. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  635. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  636. #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
  637. #define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL)
  638. struct intel_hdmi {
  639. i915_reg_t hdmi_reg;
  640. int ddc_bus;
  641. struct {
  642. enum drm_dp_dual_mode_type type;
  643. int max_tmds_clock;
  644. } dp_dual_mode;
  645. bool limited_color_range;
  646. bool color_range_auto;
  647. bool has_hdmi_sink;
  648. bool has_audio;
  649. enum hdmi_force_audio force_audio;
  650. bool rgb_quant_range_selectable;
  651. enum hdmi_picture_aspect aspect_ratio;
  652. struct intel_connector *attached_connector;
  653. void (*write_infoframe)(struct drm_encoder *encoder,
  654. enum hdmi_infoframe_type type,
  655. const void *frame, ssize_t len);
  656. void (*set_infoframes)(struct drm_encoder *encoder,
  657. bool enable,
  658. const struct drm_display_mode *adjusted_mode);
  659. bool (*infoframe_enabled)(struct drm_encoder *encoder,
  660. const struct intel_crtc_state *pipe_config);
  661. };
  662. struct intel_dp_mst_encoder;
  663. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  664. /*
  665. * enum link_m_n_set:
  666. * When platform provides two set of M_N registers for dp, we can
  667. * program them and switch between them incase of DRRS.
  668. * But When only one such register is provided, we have to program the
  669. * required divider value on that registers itself based on the DRRS state.
  670. *
  671. * M1_N1 : Program dp_m_n on M1_N1 registers
  672. * dp_m2_n2 on M2_N2 registers (If supported)
  673. *
  674. * M2_N2 : Program dp_m2_n2 on M1_N1 registers
  675. * M2_N2 registers are not supported
  676. */
  677. enum link_m_n_set {
  678. /* Sets the m1_n1 and m2_n2 */
  679. M1_N1 = 0,
  680. M2_N2
  681. };
  682. struct intel_dp {
  683. i915_reg_t output_reg;
  684. i915_reg_t aux_ch_ctl_reg;
  685. i915_reg_t aux_ch_data_reg[5];
  686. uint32_t DP;
  687. int link_rate;
  688. uint8_t lane_count;
  689. uint8_t sink_count;
  690. bool has_audio;
  691. bool detect_done;
  692. enum hdmi_force_audio force_audio;
  693. bool limited_color_range;
  694. bool color_range_auto;
  695. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  696. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  697. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  698. /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
  699. uint8_t num_sink_rates;
  700. int sink_rates[DP_MAX_SUPPORTED_RATES];
  701. struct drm_dp_aux aux;
  702. uint8_t train_set[4];
  703. int panel_power_up_delay;
  704. int panel_power_down_delay;
  705. int panel_power_cycle_delay;
  706. int backlight_on_delay;
  707. int backlight_off_delay;
  708. struct delayed_work panel_vdd_work;
  709. bool want_panel_vdd;
  710. unsigned long last_power_on;
  711. unsigned long last_backlight_off;
  712. ktime_t panel_power_off_time;
  713. struct notifier_block edp_notifier;
  714. /*
  715. * Pipe whose power sequencer is currently locked into
  716. * this port. Only relevant on VLV/CHV.
  717. */
  718. enum pipe pps_pipe;
  719. struct edp_power_seq pps_delays;
  720. bool can_mst; /* this port supports mst */
  721. bool is_mst;
  722. int active_mst_links;
  723. /* connector directly attached - won't be use for modeset in mst world */
  724. struct intel_connector *attached_connector;
  725. /* mst connector list */
  726. struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
  727. struct drm_dp_mst_topology_mgr mst_mgr;
  728. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  729. /*
  730. * This function returns the value we have to program the AUX_CTL
  731. * register with to kick off an AUX transaction.
  732. */
  733. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  734. bool has_aux_irq,
  735. int send_bytes,
  736. uint32_t aux_clock_divider);
  737. /* This is called before a link training is starterd */
  738. void (*prepare_link_retrain)(struct intel_dp *intel_dp);
  739. bool train_set_valid;
  740. /* Displayport compliance testing */
  741. unsigned long compliance_test_type;
  742. unsigned long compliance_test_data;
  743. bool compliance_test_active;
  744. };
  745. struct intel_digital_port {
  746. struct intel_encoder base;
  747. enum port port;
  748. u32 saved_port_bits;
  749. struct intel_dp dp;
  750. struct intel_hdmi hdmi;
  751. enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
  752. bool release_cl2_override;
  753. uint8_t max_lanes;
  754. /* for communication with audio component; protected by av_mutex */
  755. const struct drm_connector *audio_connector;
  756. };
  757. struct intel_dp_mst_encoder {
  758. struct intel_encoder base;
  759. enum pipe pipe;
  760. struct intel_digital_port *primary;
  761. struct intel_connector *connector;
  762. };
  763. static inline enum dpio_channel
  764. vlv_dport_to_channel(struct intel_digital_port *dport)
  765. {
  766. switch (dport->port) {
  767. case PORT_B:
  768. case PORT_D:
  769. return DPIO_CH0;
  770. case PORT_C:
  771. return DPIO_CH1;
  772. default:
  773. BUG();
  774. }
  775. }
  776. static inline enum dpio_phy
  777. vlv_dport_to_phy(struct intel_digital_port *dport)
  778. {
  779. switch (dport->port) {
  780. case PORT_B:
  781. case PORT_C:
  782. return DPIO_PHY0;
  783. case PORT_D:
  784. return DPIO_PHY1;
  785. default:
  786. BUG();
  787. }
  788. }
  789. static inline enum dpio_channel
  790. vlv_pipe_to_channel(enum pipe pipe)
  791. {
  792. switch (pipe) {
  793. case PIPE_A:
  794. case PIPE_C:
  795. return DPIO_CH0;
  796. case PIPE_B:
  797. return DPIO_CH1;
  798. default:
  799. BUG();
  800. }
  801. }
  802. static inline struct drm_crtc *
  803. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  804. {
  805. struct drm_i915_private *dev_priv = dev->dev_private;
  806. return dev_priv->pipe_to_crtc_mapping[pipe];
  807. }
  808. static inline struct drm_crtc *
  809. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  810. {
  811. struct drm_i915_private *dev_priv = dev->dev_private;
  812. return dev_priv->plane_to_crtc_mapping[plane];
  813. }
  814. struct intel_unpin_work {
  815. struct work_struct work;
  816. struct drm_crtc *crtc;
  817. struct drm_framebuffer *old_fb;
  818. struct drm_i915_gem_object *pending_flip_obj;
  819. struct drm_pending_vblank_event *event;
  820. atomic_t pending;
  821. #define INTEL_FLIP_INACTIVE 0
  822. #define INTEL_FLIP_PENDING 1
  823. #define INTEL_FLIP_COMPLETE 2
  824. u32 flip_count;
  825. u32 gtt_offset;
  826. struct drm_i915_gem_request *flip_queued_req;
  827. u32 flip_queued_vblank;
  828. u32 flip_ready_vblank;
  829. bool enable_stall_check;
  830. };
  831. struct intel_load_detect_pipe {
  832. struct drm_atomic_state *restore_state;
  833. };
  834. static inline struct intel_encoder *
  835. intel_attached_encoder(struct drm_connector *connector)
  836. {
  837. return to_intel_connector(connector)->encoder;
  838. }
  839. static inline struct intel_digital_port *
  840. enc_to_dig_port(struct drm_encoder *encoder)
  841. {
  842. return container_of(encoder, struct intel_digital_port, base.base);
  843. }
  844. static inline struct intel_dp_mst_encoder *
  845. enc_to_mst(struct drm_encoder *encoder)
  846. {
  847. return container_of(encoder, struct intel_dp_mst_encoder, base.base);
  848. }
  849. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  850. {
  851. return &enc_to_dig_port(encoder)->dp;
  852. }
  853. static inline struct intel_digital_port *
  854. dp_to_dig_port(struct intel_dp *intel_dp)
  855. {
  856. return container_of(intel_dp, struct intel_digital_port, dp);
  857. }
  858. static inline struct intel_digital_port *
  859. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  860. {
  861. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  862. }
  863. /*
  864. * Returns the number of planes for this pipe, ie the number of sprites + 1
  865. * (primary plane). This doesn't count the cursor plane then.
  866. */
  867. static inline unsigned int intel_num_planes(struct intel_crtc *crtc)
  868. {
  869. return INTEL_INFO(crtc->base.dev)->num_sprites[crtc->pipe] + 1;
  870. }
  871. /* intel_fifo_underrun.c */
  872. bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  873. enum pipe pipe, bool enable);
  874. bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  875. enum transcoder pch_transcoder,
  876. bool enable);
  877. void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  878. enum pipe pipe);
  879. void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  880. enum transcoder pch_transcoder);
  881. void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv);
  882. void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv);
  883. /* i915_irq.c */
  884. void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  885. void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  886. void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  887. void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  888. void gen6_reset_rps_interrupts(struct drm_device *dev);
  889. void gen6_enable_rps_interrupts(struct drm_device *dev);
  890. void gen6_disable_rps_interrupts(struct drm_device *dev);
  891. u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
  892. void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
  893. void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
  894. static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
  895. {
  896. /*
  897. * We only use drm_irq_uninstall() at unload and VT switch, so
  898. * this is the only thing we need to check.
  899. */
  900. return dev_priv->pm.irqs_enabled;
  901. }
  902. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  903. void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
  904. unsigned int pipe_mask);
  905. void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv,
  906. unsigned int pipe_mask);
  907. /* intel_crt.c */
  908. void intel_crt_init(struct drm_device *dev);
  909. /* intel_ddi.c */
  910. void intel_ddi_clk_select(struct intel_encoder *encoder,
  911. const struct intel_crtc_state *pipe_config);
  912. void intel_prepare_ddi_buffer(struct intel_encoder *encoder);
  913. void hsw_fdi_link_train(struct drm_crtc *crtc);
  914. void intel_ddi_init(struct drm_device *dev, enum port port);
  915. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  916. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  917. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  918. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  919. enum transcoder cpu_transcoder);
  920. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  921. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  922. bool intel_ddi_pll_select(struct intel_crtc *crtc,
  923. struct intel_crtc_state *crtc_state);
  924. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  925. void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
  926. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  927. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  928. void intel_ddi_get_config(struct intel_encoder *encoder,
  929. struct intel_crtc_state *pipe_config);
  930. struct intel_encoder *
  931. intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
  932. void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
  933. void intel_ddi_clock_get(struct intel_encoder *encoder,
  934. struct intel_crtc_state *pipe_config);
  935. void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state);
  936. uint32_t ddi_signal_levels(struct intel_dp *intel_dp);
  937. /* intel_frontbuffer.c */
  938. void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
  939. enum fb_op_origin origin);
  940. void intel_frontbuffer_flip_prepare(struct drm_device *dev,
  941. unsigned frontbuffer_bits);
  942. void intel_frontbuffer_flip_complete(struct drm_device *dev,
  943. unsigned frontbuffer_bits);
  944. void intel_frontbuffer_flip(struct drm_device *dev,
  945. unsigned frontbuffer_bits);
  946. unsigned int intel_fb_align_height(struct drm_device *dev,
  947. unsigned int height,
  948. uint32_t pixel_format,
  949. uint64_t fb_format_modifier);
  950. void intel_fb_obj_flush(struct drm_i915_gem_object *obj, bool retire,
  951. enum fb_op_origin origin);
  952. u32 intel_fb_stride_alignment(const struct drm_i915_private *dev_priv,
  953. uint64_t fb_modifier, uint32_t pixel_format);
  954. /* intel_audio.c */
  955. void intel_init_audio_hooks(struct drm_i915_private *dev_priv);
  956. void intel_audio_codec_enable(struct intel_encoder *encoder);
  957. void intel_audio_codec_disable(struct intel_encoder *encoder);
  958. void i915_audio_component_init(struct drm_i915_private *dev_priv);
  959. void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
  960. /* intel_display.c */
  961. int vlv_get_cck_clock(struct drm_i915_private *dev_priv,
  962. const char *name, u32 reg, int ref_freq);
  963. extern const struct drm_plane_funcs intel_plane_funcs;
  964. void intel_init_display_hooks(struct drm_i915_private *dev_priv);
  965. unsigned int intel_rotation_info_size(const struct intel_rotation_info *rot_info);
  966. bool intel_has_pending_fb_unpin(struct drm_device *dev);
  967. void intel_mark_busy(struct drm_device *dev);
  968. void intel_mark_idle(struct drm_device *dev);
  969. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  970. int intel_display_suspend(struct drm_device *dev);
  971. void intel_encoder_destroy(struct drm_encoder *encoder);
  972. int intel_connector_init(struct intel_connector *);
  973. struct intel_connector *intel_connector_alloc(void);
  974. bool intel_connector_get_hw_state(struct intel_connector *connector);
  975. void intel_connector_attach_encoder(struct intel_connector *connector,
  976. struct intel_encoder *encoder);
  977. struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  978. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  979. struct drm_crtc *crtc);
  980. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  981. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  982. struct drm_file *file_priv);
  983. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  984. enum pipe pipe);
  985. bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type);
  986. static inline void
  987. intel_wait_for_vblank(struct drm_device *dev, int pipe)
  988. {
  989. drm_wait_one_vblank(dev, pipe);
  990. }
  991. static inline void
  992. intel_wait_for_vblank_if_active(struct drm_device *dev, int pipe)
  993. {
  994. const struct intel_crtc *crtc =
  995. to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
  996. if (crtc->active)
  997. intel_wait_for_vblank(dev, pipe);
  998. }
  999. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  1000. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  1001. struct intel_digital_port *dport,
  1002. unsigned int expected_mask);
  1003. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  1004. struct drm_display_mode *mode,
  1005. struct intel_load_detect_pipe *old,
  1006. struct drm_modeset_acquire_ctx *ctx);
  1007. void intel_release_load_detect_pipe(struct drm_connector *connector,
  1008. struct intel_load_detect_pipe *old,
  1009. struct drm_modeset_acquire_ctx *ctx);
  1010. int intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
  1011. unsigned int rotation);
  1012. struct drm_framebuffer *
  1013. __intel_framebuffer_create(struct drm_device *dev,
  1014. struct drm_mode_fb_cmd2 *mode_cmd,
  1015. struct drm_i915_gem_object *obj);
  1016. void intel_prepare_page_flip(struct drm_device *dev, int plane);
  1017. void intel_finish_page_flip(struct drm_device *dev, int pipe);
  1018. void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  1019. void intel_check_page_flip(struct drm_device *dev, int pipe);
  1020. int intel_prepare_plane_fb(struct drm_plane *plane,
  1021. const struct drm_plane_state *new_state);
  1022. void intel_cleanup_plane_fb(struct drm_plane *plane,
  1023. const struct drm_plane_state *old_state);
  1024. int intel_plane_atomic_get_property(struct drm_plane *plane,
  1025. const struct drm_plane_state *state,
  1026. struct drm_property *property,
  1027. uint64_t *val);
  1028. int intel_plane_atomic_set_property(struct drm_plane *plane,
  1029. struct drm_plane_state *state,
  1030. struct drm_property *property,
  1031. uint64_t val);
  1032. int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
  1033. struct drm_plane_state *plane_state);
  1034. unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
  1035. uint64_t fb_modifier, unsigned int cpp);
  1036. static inline bool
  1037. intel_rotation_90_or_270(unsigned int rotation)
  1038. {
  1039. return rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270));
  1040. }
  1041. void intel_create_rotation_property(struct drm_device *dev,
  1042. struct intel_plane *plane);
  1043. void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
  1044. enum pipe pipe);
  1045. int vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
  1046. const struct dpll *dpll);
  1047. void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe);
  1048. int lpt_get_iclkip(struct drm_i915_private *dev_priv);
  1049. /* modesetting asserts */
  1050. void assert_panel_unlocked(struct drm_i915_private *dev_priv,
  1051. enum pipe pipe);
  1052. void assert_pll(struct drm_i915_private *dev_priv,
  1053. enum pipe pipe, bool state);
  1054. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  1055. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  1056. void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state);
  1057. #define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true)
  1058. #define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false)
  1059. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  1060. enum pipe pipe, bool state);
  1061. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  1062. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  1063. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  1064. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  1065. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  1066. u32 intel_compute_tile_offset(int *x, int *y,
  1067. const struct drm_framebuffer *fb, int plane,
  1068. unsigned int pitch,
  1069. unsigned int rotation);
  1070. void intel_prepare_reset(struct drm_device *dev);
  1071. void intel_finish_reset(struct drm_device *dev);
  1072. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  1073. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  1074. void broxton_init_cdclk(struct drm_i915_private *dev_priv);
  1075. void broxton_uninit_cdclk(struct drm_i915_private *dev_priv);
  1076. bool broxton_cdclk_verify_state(struct drm_i915_private *dev_priv);
  1077. void broxton_ddi_phy_init(struct drm_i915_private *dev_priv);
  1078. void broxton_ddi_phy_uninit(struct drm_i915_private *dev_priv);
  1079. void broxton_ddi_phy_verify_state(struct drm_i915_private *dev_priv);
  1080. void gen9_sanitize_dc_state(struct drm_i915_private *dev_priv);
  1081. void bxt_enable_dc9(struct drm_i915_private *dev_priv);
  1082. void bxt_disable_dc9(struct drm_i915_private *dev_priv);
  1083. void gen9_enable_dc5(struct drm_i915_private *dev_priv);
  1084. void skl_init_cdclk(struct drm_i915_private *dev_priv);
  1085. int skl_sanitize_cdclk(struct drm_i915_private *dev_priv);
  1086. void skl_uninit_cdclk(struct drm_i915_private *dev_priv);
  1087. void skl_enable_dc6(struct drm_i915_private *dev_priv);
  1088. void skl_disable_dc6(struct drm_i915_private *dev_priv);
  1089. void intel_dp_get_m_n(struct intel_crtc *crtc,
  1090. struct intel_crtc_state *pipe_config);
  1091. void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
  1092. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  1093. bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, int target_clock,
  1094. intel_clock_t *best_clock);
  1095. int chv_calc_dpll_params(int refclk, intel_clock_t *pll_clock);
  1096. bool intel_crtc_active(struct drm_crtc *crtc);
  1097. void hsw_enable_ips(struct intel_crtc *crtc);
  1098. void hsw_disable_ips(struct intel_crtc *crtc);
  1099. enum intel_display_power_domain
  1100. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  1101. enum intel_display_power_domain
  1102. intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder);
  1103. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  1104. struct intel_crtc_state *pipe_config);
  1105. int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
  1106. int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
  1107. u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
  1108. struct drm_i915_gem_object *obj,
  1109. unsigned int plane);
  1110. u32 skl_plane_ctl_format(uint32_t pixel_format);
  1111. u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
  1112. u32 skl_plane_ctl_rotation(unsigned int rotation);
  1113. /* intel_csr.c */
  1114. void intel_csr_ucode_init(struct drm_i915_private *);
  1115. void intel_csr_load_program(struct drm_i915_private *);
  1116. void intel_csr_ucode_fini(struct drm_i915_private *);
  1117. void intel_csr_ucode_suspend(struct drm_i915_private *);
  1118. void intel_csr_ucode_resume(struct drm_i915_private *);
  1119. /* intel_dp.c */
  1120. void intel_dp_init(struct drm_device *dev, i915_reg_t output_reg, enum port port);
  1121. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  1122. struct intel_connector *intel_connector);
  1123. void intel_dp_set_link_params(struct intel_dp *intel_dp,
  1124. const struct intel_crtc_state *pipe_config);
  1125. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  1126. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  1127. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  1128. void intel_dp_encoder_reset(struct drm_encoder *encoder);
  1129. void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder);
  1130. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  1131. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  1132. bool intel_dp_compute_config(struct intel_encoder *encoder,
  1133. struct intel_crtc_state *pipe_config);
  1134. bool intel_dp_is_edp(struct drm_device *dev, enum port port);
  1135. enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
  1136. bool long_hpd);
  1137. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  1138. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  1139. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  1140. void intel_edp_panel_on(struct intel_dp *intel_dp);
  1141. void intel_edp_panel_off(struct intel_dp *intel_dp);
  1142. void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
  1143. void intel_dp_mst_suspend(struct drm_device *dev);
  1144. void intel_dp_mst_resume(struct drm_device *dev);
  1145. int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  1146. int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
  1147. void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
  1148. void vlv_power_sequencer_reset(struct drm_i915_private *dev_priv);
  1149. uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
  1150. void intel_plane_destroy(struct drm_plane *plane);
  1151. void intel_edp_drrs_enable(struct intel_dp *intel_dp);
  1152. void intel_edp_drrs_disable(struct intel_dp *intel_dp);
  1153. void intel_edp_drrs_invalidate(struct drm_device *dev,
  1154. unsigned frontbuffer_bits);
  1155. void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits);
  1156. bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
  1157. struct intel_digital_port *port);
  1158. void
  1159. intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
  1160. uint8_t dp_train_pat);
  1161. void
  1162. intel_dp_set_signal_levels(struct intel_dp *intel_dp);
  1163. void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
  1164. uint8_t
  1165. intel_dp_voltage_max(struct intel_dp *intel_dp);
  1166. uint8_t
  1167. intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing);
  1168. void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
  1169. uint8_t *link_bw, uint8_t *rate_select);
  1170. bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
  1171. bool
  1172. intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]);
  1173. /* intel_dp_mst.c */
  1174. int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  1175. void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
  1176. /* intel_dsi.c */
  1177. void intel_dsi_init(struct drm_device *dev);
  1178. /* intel_dvo.c */
  1179. void intel_dvo_init(struct drm_device *dev);
  1180. /* legacy fbdev emulation in intel_fbdev.c */
  1181. #ifdef CONFIG_DRM_FBDEV_EMULATION
  1182. extern int intel_fbdev_init(struct drm_device *dev);
  1183. extern void intel_fbdev_initial_config_async(struct drm_device *dev);
  1184. extern void intel_fbdev_fini(struct drm_device *dev);
  1185. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
  1186. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  1187. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  1188. #else
  1189. static inline int intel_fbdev_init(struct drm_device *dev)
  1190. {
  1191. return 0;
  1192. }
  1193. static inline void intel_fbdev_initial_config_async(struct drm_device *dev)
  1194. {
  1195. }
  1196. static inline void intel_fbdev_fini(struct drm_device *dev)
  1197. {
  1198. }
  1199. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
  1200. {
  1201. }
  1202. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  1203. {
  1204. }
  1205. #endif
  1206. /* intel_fbc.c */
  1207. void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
  1208. struct drm_atomic_state *state);
  1209. bool intel_fbc_is_active(struct drm_i915_private *dev_priv);
  1210. void intel_fbc_pre_update(struct intel_crtc *crtc);
  1211. void intel_fbc_post_update(struct intel_crtc *crtc);
  1212. void intel_fbc_init(struct drm_i915_private *dev_priv);
  1213. void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv);
  1214. void intel_fbc_enable(struct intel_crtc *crtc);
  1215. void intel_fbc_disable(struct intel_crtc *crtc);
  1216. void intel_fbc_global_disable(struct drm_i915_private *dev_priv);
  1217. void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
  1218. unsigned int frontbuffer_bits,
  1219. enum fb_op_origin origin);
  1220. void intel_fbc_flush(struct drm_i915_private *dev_priv,
  1221. unsigned int frontbuffer_bits, enum fb_op_origin origin);
  1222. void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv);
  1223. /* intel_hdmi.c */
  1224. void intel_hdmi_init(struct drm_device *dev, i915_reg_t hdmi_reg, enum port port);
  1225. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  1226. struct intel_connector *intel_connector);
  1227. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  1228. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  1229. struct intel_crtc_state *pipe_config);
  1230. void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
  1231. /* intel_lvds.c */
  1232. void intel_lvds_init(struct drm_device *dev);
  1233. bool intel_is_dual_link_lvds(struct drm_device *dev);
  1234. /* intel_modes.c */
  1235. int intel_connector_update_modes(struct drm_connector *connector,
  1236. struct edid *edid);
  1237. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  1238. void intel_attach_force_audio_property(struct drm_connector *connector);
  1239. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  1240. void intel_attach_aspect_ratio_property(struct drm_connector *connector);
  1241. /* intel_overlay.c */
  1242. void intel_setup_overlay(struct drm_device *dev);
  1243. void intel_cleanup_overlay(struct drm_device *dev);
  1244. int intel_overlay_switch_off(struct intel_overlay *overlay);
  1245. int intel_overlay_put_image(struct drm_device *dev, void *data,
  1246. struct drm_file *file_priv);
  1247. int intel_overlay_attrs(struct drm_device *dev, void *data,
  1248. struct drm_file *file_priv);
  1249. void intel_overlay_reset(struct drm_i915_private *dev_priv);
  1250. /* intel_panel.c */
  1251. int intel_panel_init(struct intel_panel *panel,
  1252. struct drm_display_mode *fixed_mode,
  1253. struct drm_display_mode *downclock_mode);
  1254. void intel_panel_fini(struct intel_panel *panel);
  1255. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  1256. struct drm_display_mode *adjusted_mode);
  1257. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  1258. struct intel_crtc_state *pipe_config,
  1259. int fitting_mode);
  1260. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  1261. struct intel_crtc_state *pipe_config,
  1262. int fitting_mode);
  1263. void intel_panel_set_backlight_acpi(struct intel_connector *connector,
  1264. u32 level, u32 max);
  1265. int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe);
  1266. void intel_panel_enable_backlight(struct intel_connector *connector);
  1267. void intel_panel_disable_backlight(struct intel_connector *connector);
  1268. void intel_panel_destroy_backlight(struct drm_connector *connector);
  1269. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  1270. extern struct drm_display_mode *intel_find_panel_downclock(
  1271. struct drm_device *dev,
  1272. struct drm_display_mode *fixed_mode,
  1273. struct drm_connector *connector);
  1274. void intel_backlight_register(struct drm_device *dev);
  1275. void intel_backlight_unregister(struct drm_device *dev);
  1276. /* intel_psr.c */
  1277. void intel_psr_enable(struct intel_dp *intel_dp);
  1278. void intel_psr_disable(struct intel_dp *intel_dp);
  1279. void intel_psr_invalidate(struct drm_device *dev,
  1280. unsigned frontbuffer_bits);
  1281. void intel_psr_flush(struct drm_device *dev,
  1282. unsigned frontbuffer_bits,
  1283. enum fb_op_origin origin);
  1284. void intel_psr_init(struct drm_device *dev);
  1285. void intel_psr_single_frame_update(struct drm_device *dev,
  1286. unsigned frontbuffer_bits);
  1287. /* intel_runtime_pm.c */
  1288. int intel_power_domains_init(struct drm_i915_private *);
  1289. void intel_power_domains_fini(struct drm_i915_private *);
  1290. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume);
  1291. void intel_power_domains_suspend(struct drm_i915_private *dev_priv);
  1292. void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume);
  1293. void bxt_display_core_uninit(struct drm_i915_private *dev_priv);
  1294. void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
  1295. const char *
  1296. intel_display_power_domain_str(enum intel_display_power_domain domain);
  1297. bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1298. enum intel_display_power_domain domain);
  1299. bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1300. enum intel_display_power_domain domain);
  1301. void intel_display_power_get(struct drm_i915_private *dev_priv,
  1302. enum intel_display_power_domain domain);
  1303. bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv,
  1304. enum intel_display_power_domain domain);
  1305. void intel_display_power_put(struct drm_i915_private *dev_priv,
  1306. enum intel_display_power_domain domain);
  1307. static inline void
  1308. assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv)
  1309. {
  1310. WARN_ONCE(dev_priv->pm.suspended,
  1311. "Device suspended during HW access\n");
  1312. }
  1313. static inline void
  1314. assert_rpm_wakelock_held(struct drm_i915_private *dev_priv)
  1315. {
  1316. assert_rpm_device_not_suspended(dev_priv);
  1317. /* FIXME: Needs to be converted back to WARN_ONCE, but currently causes
  1318. * too much noise. */
  1319. if (!atomic_read(&dev_priv->pm.wakeref_count))
  1320. DRM_DEBUG_DRIVER("RPM wakelock ref not held during HW access");
  1321. }
  1322. static inline int
  1323. assert_rpm_atomic_begin(struct drm_i915_private *dev_priv)
  1324. {
  1325. int seq = atomic_read(&dev_priv->pm.atomic_seq);
  1326. assert_rpm_wakelock_held(dev_priv);
  1327. return seq;
  1328. }
  1329. static inline void
  1330. assert_rpm_atomic_end(struct drm_i915_private *dev_priv, int begin_seq)
  1331. {
  1332. WARN_ONCE(atomic_read(&dev_priv->pm.atomic_seq) != begin_seq,
  1333. "HW access outside of RPM atomic section\n");
  1334. }
  1335. /**
  1336. * disable_rpm_wakeref_asserts - disable the RPM assert checks
  1337. * @dev_priv: i915 device instance
  1338. *
  1339. * This function disable asserts that check if we hold an RPM wakelock
  1340. * reference, while keeping the device-not-suspended checks still enabled.
  1341. * It's meant to be used only in special circumstances where our rule about
  1342. * the wakelock refcount wrt. the device power state doesn't hold. According
  1343. * to this rule at any point where we access the HW or want to keep the HW in
  1344. * an active state we must hold an RPM wakelock reference acquired via one of
  1345. * the intel_runtime_pm_get() helpers. Currently there are a few special spots
  1346. * where this rule doesn't hold: the IRQ and suspend/resume handlers, the
  1347. * forcewake release timer, and the GPU RPS and hangcheck works. All other
  1348. * users should avoid using this function.
  1349. *
  1350. * Any calls to this function must have a symmetric call to
  1351. * enable_rpm_wakeref_asserts().
  1352. */
  1353. static inline void
  1354. disable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1355. {
  1356. atomic_inc(&dev_priv->pm.wakeref_count);
  1357. }
  1358. /**
  1359. * enable_rpm_wakeref_asserts - re-enable the RPM assert checks
  1360. * @dev_priv: i915 device instance
  1361. *
  1362. * This function re-enables the RPM assert checks after disabling them with
  1363. * disable_rpm_wakeref_asserts. It's meant to be used only in special
  1364. * circumstances otherwise its use should be avoided.
  1365. *
  1366. * Any calls to this function must have a symmetric call to
  1367. * disable_rpm_wakeref_asserts().
  1368. */
  1369. static inline void
  1370. enable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1371. {
  1372. atomic_dec(&dev_priv->pm.wakeref_count);
  1373. }
  1374. /* TODO: convert users of these to rely instead on proper RPM refcounting */
  1375. #define DISABLE_RPM_WAKEREF_ASSERTS(dev_priv) \
  1376. disable_rpm_wakeref_asserts(dev_priv)
  1377. #define ENABLE_RPM_WAKEREF_ASSERTS(dev_priv) \
  1378. enable_rpm_wakeref_asserts(dev_priv)
  1379. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  1380. bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv);
  1381. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  1382. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  1383. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  1384. void chv_phy_powergate_lanes(struct intel_encoder *encoder,
  1385. bool override, unsigned int mask);
  1386. bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy,
  1387. enum dpio_channel ch, bool override);
  1388. /* intel_pm.c */
  1389. void intel_init_clock_gating(struct drm_device *dev);
  1390. void intel_suspend_hw(struct drm_device *dev);
  1391. int ilk_wm_max_level(const struct drm_device *dev);
  1392. void intel_update_watermarks(struct drm_crtc *crtc);
  1393. void intel_init_pm(struct drm_device *dev);
  1394. void intel_init_clock_gating_hooks(struct drm_i915_private *dev_priv);
  1395. void intel_pm_setup(struct drm_device *dev);
  1396. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  1397. void intel_gpu_ips_teardown(void);
  1398. void intel_init_gt_powersave(struct drm_device *dev);
  1399. void intel_cleanup_gt_powersave(struct drm_device *dev);
  1400. void intel_enable_gt_powersave(struct drm_device *dev);
  1401. void intel_disable_gt_powersave(struct drm_device *dev);
  1402. void intel_suspend_gt_powersave(struct drm_device *dev);
  1403. void intel_reset_gt_powersave(struct drm_device *dev);
  1404. void gen6_update_ring_freq(struct drm_device *dev);
  1405. void gen6_rps_busy(struct drm_i915_private *dev_priv);
  1406. void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
  1407. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  1408. void gen6_rps_boost(struct drm_i915_private *dev_priv,
  1409. struct intel_rps_client *rps,
  1410. unsigned long submitted);
  1411. void intel_queue_rps_boost_for_request(struct drm_device *dev,
  1412. struct drm_i915_gem_request *req);
  1413. void vlv_wm_get_hw_state(struct drm_device *dev);
  1414. void ilk_wm_get_hw_state(struct drm_device *dev);
  1415. void skl_wm_get_hw_state(struct drm_device *dev);
  1416. void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  1417. struct skl_ddb_allocation *ddb /* out */);
  1418. uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config);
  1419. bool ilk_disable_lp_wm(struct drm_device *dev);
  1420. int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6);
  1421. /* intel_sdvo.c */
  1422. bool intel_sdvo_init(struct drm_device *dev,
  1423. i915_reg_t reg, enum port port);
  1424. /* intel_sprite.c */
  1425. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  1426. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  1427. struct drm_file *file_priv);
  1428. void intel_pipe_update_start(struct intel_crtc *crtc);
  1429. void intel_pipe_update_end(struct intel_crtc *crtc);
  1430. /* intel_tv.c */
  1431. void intel_tv_init(struct drm_device *dev);
  1432. /* intel_atomic.c */
  1433. int intel_connector_atomic_get_property(struct drm_connector *connector,
  1434. const struct drm_connector_state *state,
  1435. struct drm_property *property,
  1436. uint64_t *val);
  1437. struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
  1438. void intel_crtc_destroy_state(struct drm_crtc *crtc,
  1439. struct drm_crtc_state *state);
  1440. struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
  1441. void intel_atomic_state_clear(struct drm_atomic_state *);
  1442. struct intel_shared_dpll_config *
  1443. intel_atomic_get_shared_dpll_state(struct drm_atomic_state *s);
  1444. static inline struct intel_crtc_state *
  1445. intel_atomic_get_crtc_state(struct drm_atomic_state *state,
  1446. struct intel_crtc *crtc)
  1447. {
  1448. struct drm_crtc_state *crtc_state;
  1449. crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
  1450. if (IS_ERR(crtc_state))
  1451. return ERR_CAST(crtc_state);
  1452. return to_intel_crtc_state(crtc_state);
  1453. }
  1454. static inline struct intel_plane_state *
  1455. intel_atomic_get_existing_plane_state(struct drm_atomic_state *state,
  1456. struct intel_plane *plane)
  1457. {
  1458. struct drm_plane_state *plane_state;
  1459. plane_state = drm_atomic_get_existing_plane_state(state, &plane->base);
  1460. return to_intel_plane_state(plane_state);
  1461. }
  1462. int intel_atomic_setup_scalers(struct drm_device *dev,
  1463. struct intel_crtc *intel_crtc,
  1464. struct intel_crtc_state *crtc_state);
  1465. /* intel_atomic_plane.c */
  1466. struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
  1467. struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
  1468. void intel_plane_destroy_state(struct drm_plane *plane,
  1469. struct drm_plane_state *state);
  1470. extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
  1471. /* intel_color.c */
  1472. void intel_color_init(struct drm_crtc *crtc);
  1473. int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
  1474. void intel_color_set_csc(struct drm_crtc_state *crtc_state);
  1475. void intel_color_load_luts(struct drm_crtc_state *crtc_state);
  1476. #endif /* __INTEL_DRV_H__ */