intel_drv.h 58 KB

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