intel_drv.h 63 KB

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