intel_drv.h 67 KB

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