intel_drv.h 65 KB

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