intel_drv.h 64 KB

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