intel_drv.h 63 KB

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