intel_drv.h 60 KB

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