intel_drv.h 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800
  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 has_audio;
  730. bool detect_done;
  731. enum hdmi_force_audio force_audio;
  732. bool limited_color_range;
  733. bool color_range_auto;
  734. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  735. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  736. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  737. uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
  738. /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
  739. uint8_t num_sink_rates;
  740. int sink_rates[DP_MAX_SUPPORTED_RATES];
  741. struct drm_dp_aux aux;
  742. uint8_t train_set[4];
  743. int panel_power_up_delay;
  744. int panel_power_down_delay;
  745. int panel_power_cycle_delay;
  746. int backlight_on_delay;
  747. int backlight_off_delay;
  748. struct delayed_work panel_vdd_work;
  749. bool want_panel_vdd;
  750. unsigned long last_power_on;
  751. unsigned long last_backlight_off;
  752. ktime_t panel_power_off_time;
  753. struct notifier_block edp_notifier;
  754. /*
  755. * Pipe whose power sequencer is currently locked into
  756. * this port. Only relevant on VLV/CHV.
  757. */
  758. enum pipe pps_pipe;
  759. /*
  760. * Set if the sequencer may be reset due to a power transition,
  761. * requiring a reinitialization. Only relevant on BXT.
  762. */
  763. bool pps_reset;
  764. struct edp_power_seq pps_delays;
  765. bool can_mst; /* this port supports mst */
  766. bool is_mst;
  767. int active_mst_links;
  768. /* connector directly attached - won't be use for modeset in mst world */
  769. struct intel_connector *attached_connector;
  770. /* mst connector list */
  771. struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
  772. struct drm_dp_mst_topology_mgr mst_mgr;
  773. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  774. /*
  775. * This function returns the value we have to program the AUX_CTL
  776. * register with to kick off an AUX transaction.
  777. */
  778. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  779. bool has_aux_irq,
  780. int send_bytes,
  781. uint32_t aux_clock_divider);
  782. /* This is called before a link training is starterd */
  783. void (*prepare_link_retrain)(struct intel_dp *intel_dp);
  784. /* Displayport compliance testing */
  785. unsigned long compliance_test_type;
  786. unsigned long compliance_test_data;
  787. bool compliance_test_active;
  788. };
  789. struct intel_digital_port {
  790. struct intel_encoder base;
  791. enum port port;
  792. u32 saved_port_bits;
  793. struct intel_dp dp;
  794. struct intel_hdmi hdmi;
  795. enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
  796. bool release_cl2_override;
  797. uint8_t max_lanes;
  798. /* for communication with audio component; protected by av_mutex */
  799. const struct drm_connector *audio_connector;
  800. };
  801. struct intel_dp_mst_encoder {
  802. struct intel_encoder base;
  803. enum pipe pipe;
  804. struct intel_digital_port *primary;
  805. struct intel_connector *connector;
  806. };
  807. static inline enum dpio_channel
  808. vlv_dport_to_channel(struct intel_digital_port *dport)
  809. {
  810. switch (dport->port) {
  811. case PORT_B:
  812. case PORT_D:
  813. return DPIO_CH0;
  814. case PORT_C:
  815. return DPIO_CH1;
  816. default:
  817. BUG();
  818. }
  819. }
  820. static inline enum dpio_phy
  821. vlv_dport_to_phy(struct intel_digital_port *dport)
  822. {
  823. switch (dport->port) {
  824. case PORT_B:
  825. case PORT_C:
  826. return DPIO_PHY0;
  827. case PORT_D:
  828. return DPIO_PHY1;
  829. default:
  830. BUG();
  831. }
  832. }
  833. static inline enum dpio_channel
  834. vlv_pipe_to_channel(enum pipe pipe)
  835. {
  836. switch (pipe) {
  837. case PIPE_A:
  838. case PIPE_C:
  839. return DPIO_CH0;
  840. case PIPE_B:
  841. return DPIO_CH1;
  842. default:
  843. BUG();
  844. }
  845. }
  846. static inline struct drm_crtc *
  847. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  848. {
  849. struct drm_i915_private *dev_priv = to_i915(dev);
  850. return dev_priv->pipe_to_crtc_mapping[pipe];
  851. }
  852. static inline struct drm_crtc *
  853. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  854. {
  855. struct drm_i915_private *dev_priv = to_i915(dev);
  856. return dev_priv->plane_to_crtc_mapping[plane];
  857. }
  858. struct intel_flip_work {
  859. struct work_struct unpin_work;
  860. struct work_struct mmio_work;
  861. struct drm_crtc *crtc;
  862. struct drm_framebuffer *old_fb;
  863. struct drm_i915_gem_object *pending_flip_obj;
  864. struct drm_pending_vblank_event *event;
  865. atomic_t pending;
  866. u32 flip_count;
  867. u32 gtt_offset;
  868. struct drm_i915_gem_request *flip_queued_req;
  869. u32 flip_queued_vblank;
  870. u32 flip_ready_vblank;
  871. unsigned int rotation;
  872. };
  873. struct intel_load_detect_pipe {
  874. struct drm_atomic_state *restore_state;
  875. };
  876. static inline struct intel_encoder *
  877. intel_attached_encoder(struct drm_connector *connector)
  878. {
  879. return to_intel_connector(connector)->encoder;
  880. }
  881. static inline struct intel_digital_port *
  882. enc_to_dig_port(struct drm_encoder *encoder)
  883. {
  884. return container_of(encoder, struct intel_digital_port, base.base);
  885. }
  886. static inline struct intel_dp_mst_encoder *
  887. enc_to_mst(struct drm_encoder *encoder)
  888. {
  889. return container_of(encoder, struct intel_dp_mst_encoder, base.base);
  890. }
  891. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  892. {
  893. return &enc_to_dig_port(encoder)->dp;
  894. }
  895. static inline struct intel_digital_port *
  896. dp_to_dig_port(struct intel_dp *intel_dp)
  897. {
  898. return container_of(intel_dp, struct intel_digital_port, dp);
  899. }
  900. static inline struct intel_digital_port *
  901. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  902. {
  903. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  904. }
  905. /*
  906. * Returns the number of planes for this pipe, ie the number of sprites + 1
  907. * (primary plane). This doesn't count the cursor plane then.
  908. */
  909. static inline unsigned int intel_num_planes(struct intel_crtc *crtc)
  910. {
  911. return INTEL_INFO(crtc->base.dev)->num_sprites[crtc->pipe] + 1;
  912. }
  913. /* intel_fifo_underrun.c */
  914. bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  915. enum pipe pipe, bool enable);
  916. bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  917. enum transcoder pch_transcoder,
  918. bool enable);
  919. void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  920. enum pipe pipe);
  921. void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  922. enum transcoder pch_transcoder);
  923. void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv);
  924. void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv);
  925. /* i915_irq.c */
  926. void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  927. void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  928. void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  929. void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  930. void gen6_reset_rps_interrupts(struct drm_i915_private *dev_priv);
  931. void gen6_enable_rps_interrupts(struct drm_i915_private *dev_priv);
  932. void gen6_disable_rps_interrupts(struct drm_i915_private *dev_priv);
  933. u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
  934. void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
  935. void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
  936. static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
  937. {
  938. /*
  939. * We only use drm_irq_uninstall() at unload and VT switch, so
  940. * this is the only thing we need to check.
  941. */
  942. return dev_priv->pm.irqs_enabled;
  943. }
  944. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  945. void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
  946. unsigned int pipe_mask);
  947. void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv,
  948. unsigned int pipe_mask);
  949. /* intel_crt.c */
  950. void intel_crt_init(struct drm_device *dev);
  951. void intel_crt_reset(struct drm_encoder *encoder);
  952. /* intel_ddi.c */
  953. void intel_ddi_clk_select(struct intel_encoder *encoder,
  954. const struct intel_crtc_state *pipe_config);
  955. void intel_prepare_ddi_buffer(struct intel_encoder *encoder);
  956. void hsw_fdi_link_train(struct drm_crtc *crtc);
  957. void intel_ddi_init(struct drm_device *dev, enum port port);
  958. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  959. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  960. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  961. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  962. enum transcoder cpu_transcoder);
  963. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  964. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  965. bool intel_ddi_pll_select(struct intel_crtc *crtc,
  966. struct intel_crtc_state *crtc_state);
  967. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  968. void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
  969. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  970. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  971. void intel_ddi_get_config(struct intel_encoder *encoder,
  972. struct intel_crtc_state *pipe_config);
  973. struct intel_encoder *
  974. intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
  975. void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
  976. void intel_ddi_clock_get(struct intel_encoder *encoder,
  977. struct intel_crtc_state *pipe_config);
  978. void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state);
  979. uint32_t ddi_signal_levels(struct intel_dp *intel_dp);
  980. /* intel_frontbuffer.c */
  981. void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
  982. enum fb_op_origin origin);
  983. void intel_frontbuffer_flip_prepare(struct drm_device *dev,
  984. unsigned frontbuffer_bits);
  985. void intel_frontbuffer_flip_complete(struct drm_device *dev,
  986. unsigned frontbuffer_bits);
  987. void intel_frontbuffer_flip(struct drm_device *dev,
  988. unsigned frontbuffer_bits);
  989. unsigned int intel_fb_align_height(struct drm_device *dev,
  990. unsigned int height,
  991. uint32_t pixel_format,
  992. uint64_t fb_format_modifier);
  993. void intel_fb_obj_flush(struct drm_i915_gem_object *obj, bool retire,
  994. enum fb_op_origin origin);
  995. u32 intel_fb_stride_alignment(const struct drm_i915_private *dev_priv,
  996. uint64_t fb_modifier, uint32_t pixel_format);
  997. /* intel_audio.c */
  998. void intel_init_audio_hooks(struct drm_i915_private *dev_priv);
  999. void intel_audio_codec_enable(struct intel_encoder *encoder);
  1000. void intel_audio_codec_disable(struct intel_encoder *encoder);
  1001. void i915_audio_component_init(struct drm_i915_private *dev_priv);
  1002. void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
  1003. /* intel_display.c */
  1004. void skl_set_preferred_cdclk_vco(struct drm_i915_private *dev_priv, int vco);
  1005. void intel_update_rawclk(struct drm_i915_private *dev_priv);
  1006. int vlv_get_cck_clock(struct drm_i915_private *dev_priv,
  1007. const char *name, u32 reg, int ref_freq);
  1008. extern const struct drm_plane_funcs intel_plane_funcs;
  1009. void intel_init_display_hooks(struct drm_i915_private *dev_priv);
  1010. unsigned int intel_rotation_info_size(const struct intel_rotation_info *rot_info);
  1011. bool intel_has_pending_fb_unpin(struct drm_device *dev);
  1012. void intel_mark_busy(struct drm_i915_private *dev_priv);
  1013. void intel_mark_idle(struct drm_i915_private *dev_priv);
  1014. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  1015. int intel_display_suspend(struct drm_device *dev);
  1016. void intel_encoder_destroy(struct drm_encoder *encoder);
  1017. int intel_connector_init(struct intel_connector *);
  1018. struct intel_connector *intel_connector_alloc(void);
  1019. bool intel_connector_get_hw_state(struct intel_connector *connector);
  1020. void intel_connector_attach_encoder(struct intel_connector *connector,
  1021. struct intel_encoder *encoder);
  1022. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  1023. struct drm_crtc *crtc);
  1024. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  1025. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  1026. struct drm_file *file_priv);
  1027. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  1028. enum pipe pipe);
  1029. static inline bool
  1030. intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
  1031. enum intel_output_type type)
  1032. {
  1033. return crtc_state->output_types & (1 << type);
  1034. }
  1035. static inline bool
  1036. intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
  1037. {
  1038. return crtc_state->output_types &
  1039. ((1 << INTEL_OUTPUT_DP) |
  1040. (1 << INTEL_OUTPUT_DP_MST) |
  1041. (1 << INTEL_OUTPUT_EDP));
  1042. }
  1043. static inline void
  1044. intel_wait_for_vblank(struct drm_device *dev, int pipe)
  1045. {
  1046. drm_wait_one_vblank(dev, pipe);
  1047. }
  1048. static inline void
  1049. intel_wait_for_vblank_if_active(struct drm_device *dev, int pipe)
  1050. {
  1051. const struct intel_crtc *crtc =
  1052. to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
  1053. if (crtc->active)
  1054. intel_wait_for_vblank(dev, pipe);
  1055. }
  1056. u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc);
  1057. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  1058. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  1059. struct intel_digital_port *dport,
  1060. unsigned int expected_mask);
  1061. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  1062. struct drm_display_mode *mode,
  1063. struct intel_load_detect_pipe *old,
  1064. struct drm_modeset_acquire_ctx *ctx);
  1065. void intel_release_load_detect_pipe(struct drm_connector *connector,
  1066. struct intel_load_detect_pipe *old,
  1067. struct drm_modeset_acquire_ctx *ctx);
  1068. int intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
  1069. unsigned int rotation);
  1070. void intel_unpin_fb_obj(struct drm_framebuffer *fb, unsigned int rotation);
  1071. struct drm_framebuffer *
  1072. __intel_framebuffer_create(struct drm_device *dev,
  1073. struct drm_mode_fb_cmd2 *mode_cmd,
  1074. struct drm_i915_gem_object *obj);
  1075. void intel_finish_page_flip_cs(struct drm_i915_private *dev_priv, int pipe);
  1076. void intel_finish_page_flip_mmio(struct drm_i915_private *dev_priv, int pipe);
  1077. void intel_check_page_flip(struct drm_i915_private *dev_priv, int pipe);
  1078. int intel_prepare_plane_fb(struct drm_plane *plane,
  1079. const struct drm_plane_state *new_state);
  1080. void intel_cleanup_plane_fb(struct drm_plane *plane,
  1081. const struct drm_plane_state *old_state);
  1082. int intel_plane_atomic_get_property(struct drm_plane *plane,
  1083. const struct drm_plane_state *state,
  1084. struct drm_property *property,
  1085. uint64_t *val);
  1086. int intel_plane_atomic_set_property(struct drm_plane *plane,
  1087. struct drm_plane_state *state,
  1088. struct drm_property *property,
  1089. uint64_t val);
  1090. int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
  1091. struct drm_plane_state *plane_state);
  1092. unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
  1093. uint64_t fb_modifier, unsigned int cpp);
  1094. static inline bool
  1095. intel_rotation_90_or_270(unsigned int rotation)
  1096. {
  1097. return rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270));
  1098. }
  1099. void intel_create_rotation_property(struct drm_device *dev,
  1100. struct intel_plane *plane);
  1101. void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
  1102. enum pipe pipe);
  1103. int vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
  1104. const struct dpll *dpll);
  1105. void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe);
  1106. int lpt_get_iclkip(struct drm_i915_private *dev_priv);
  1107. /* modesetting asserts */
  1108. void assert_panel_unlocked(struct drm_i915_private *dev_priv,
  1109. enum pipe pipe);
  1110. void assert_pll(struct drm_i915_private *dev_priv,
  1111. enum pipe pipe, bool state);
  1112. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  1113. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  1114. void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state);
  1115. #define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true)
  1116. #define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false)
  1117. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  1118. enum pipe pipe, bool state);
  1119. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  1120. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  1121. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  1122. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  1123. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  1124. u32 intel_compute_tile_offset(int *x, int *y,
  1125. const struct drm_framebuffer *fb, int plane,
  1126. unsigned int pitch,
  1127. unsigned int rotation);
  1128. void intel_prepare_reset(struct drm_i915_private *dev_priv);
  1129. void intel_finish_reset(struct drm_i915_private *dev_priv);
  1130. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  1131. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  1132. void bxt_init_cdclk(struct drm_i915_private *dev_priv);
  1133. void bxt_uninit_cdclk(struct drm_i915_private *dev_priv);
  1134. void bxt_ddi_phy_init(struct drm_i915_private *dev_priv, enum dpio_phy phy);
  1135. void bxt_ddi_phy_uninit(struct drm_i915_private *dev_priv, enum dpio_phy phy);
  1136. bool bxt_ddi_phy_is_enabled(struct drm_i915_private *dev_priv,
  1137. enum dpio_phy phy);
  1138. bool bxt_ddi_phy_verify_state(struct drm_i915_private *dev_priv,
  1139. enum dpio_phy phy);
  1140. void gen9_sanitize_dc_state(struct drm_i915_private *dev_priv);
  1141. void bxt_enable_dc9(struct drm_i915_private *dev_priv);
  1142. void bxt_disable_dc9(struct drm_i915_private *dev_priv);
  1143. void gen9_enable_dc5(struct drm_i915_private *dev_priv);
  1144. void skl_init_cdclk(struct drm_i915_private *dev_priv);
  1145. void skl_uninit_cdclk(struct drm_i915_private *dev_priv);
  1146. unsigned int skl_cdclk_get_vco(unsigned int freq);
  1147. void skl_enable_dc6(struct drm_i915_private *dev_priv);
  1148. void skl_disable_dc6(struct drm_i915_private *dev_priv);
  1149. void intel_dp_get_m_n(struct intel_crtc *crtc,
  1150. struct intel_crtc_state *pipe_config);
  1151. void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
  1152. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  1153. bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, int target_clock,
  1154. struct dpll *best_clock);
  1155. int chv_calc_dpll_params(int refclk, struct dpll *pll_clock);
  1156. bool intel_crtc_active(struct drm_crtc *crtc);
  1157. void hsw_enable_ips(struct intel_crtc *crtc);
  1158. void hsw_disable_ips(struct intel_crtc *crtc);
  1159. enum intel_display_power_domain
  1160. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  1161. enum intel_display_power_domain
  1162. intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder);
  1163. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  1164. struct intel_crtc_state *pipe_config);
  1165. int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
  1166. int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
  1167. u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
  1168. struct drm_i915_gem_object *obj,
  1169. unsigned int plane);
  1170. u32 skl_plane_ctl_format(uint32_t pixel_format);
  1171. u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
  1172. u32 skl_plane_ctl_rotation(unsigned int rotation);
  1173. /* intel_csr.c */
  1174. void intel_csr_ucode_init(struct drm_i915_private *);
  1175. void intel_csr_load_program(struct drm_i915_private *);
  1176. void intel_csr_ucode_fini(struct drm_i915_private *);
  1177. void intel_csr_ucode_suspend(struct drm_i915_private *);
  1178. void intel_csr_ucode_resume(struct drm_i915_private *);
  1179. /* intel_dp.c */
  1180. bool intel_dp_init(struct drm_device *dev, i915_reg_t output_reg, enum port port);
  1181. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  1182. struct intel_connector *intel_connector);
  1183. void intel_dp_set_link_params(struct intel_dp *intel_dp,
  1184. const struct intel_crtc_state *pipe_config);
  1185. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  1186. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  1187. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  1188. void intel_dp_encoder_reset(struct drm_encoder *encoder);
  1189. void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder);
  1190. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  1191. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  1192. bool intel_dp_compute_config(struct intel_encoder *encoder,
  1193. struct intel_crtc_state *pipe_config);
  1194. bool intel_dp_is_edp(struct drm_device *dev, enum port port);
  1195. enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
  1196. bool long_hpd);
  1197. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  1198. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  1199. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  1200. void intel_edp_panel_on(struct intel_dp *intel_dp);
  1201. void intel_edp_panel_off(struct intel_dp *intel_dp);
  1202. void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
  1203. void intel_dp_mst_suspend(struct drm_device *dev);
  1204. void intel_dp_mst_resume(struct drm_device *dev);
  1205. int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  1206. int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
  1207. void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
  1208. void intel_power_sequencer_reset(struct drm_i915_private *dev_priv);
  1209. uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
  1210. void intel_plane_destroy(struct drm_plane *plane);
  1211. void intel_edp_drrs_enable(struct intel_dp *intel_dp);
  1212. void intel_edp_drrs_disable(struct intel_dp *intel_dp);
  1213. void intel_edp_drrs_invalidate(struct drm_device *dev,
  1214. unsigned frontbuffer_bits);
  1215. void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits);
  1216. bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
  1217. struct intel_digital_port *port);
  1218. void
  1219. intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
  1220. uint8_t dp_train_pat);
  1221. void
  1222. intel_dp_set_signal_levels(struct intel_dp *intel_dp);
  1223. void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
  1224. uint8_t
  1225. intel_dp_voltage_max(struct intel_dp *intel_dp);
  1226. uint8_t
  1227. intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing);
  1228. void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
  1229. uint8_t *link_bw, uint8_t *rate_select);
  1230. bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
  1231. bool
  1232. intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]);
  1233. static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
  1234. {
  1235. return ~((1 << lane_count) - 1) & 0xf;
  1236. }
  1237. /* intel_dp_aux_backlight.c */
  1238. int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
  1239. /* intel_dp_mst.c */
  1240. int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  1241. void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
  1242. /* intel_dsi.c */
  1243. void intel_dsi_init(struct drm_device *dev);
  1244. /* intel_dsi_dcs_backlight.c */
  1245. int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector);
  1246. /* intel_dvo.c */
  1247. void intel_dvo_init(struct drm_device *dev);
  1248. /* intel_hotplug.c */
  1249. void intel_hpd_poll_init(struct drm_i915_private *dev_priv);
  1250. /* legacy fbdev emulation in intel_fbdev.c */
  1251. #ifdef CONFIG_DRM_FBDEV_EMULATION
  1252. extern int intel_fbdev_init(struct drm_device *dev);
  1253. extern void intel_fbdev_initial_config_async(struct drm_device *dev);
  1254. extern void intel_fbdev_fini(struct drm_device *dev);
  1255. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
  1256. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  1257. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  1258. #else
  1259. static inline int intel_fbdev_init(struct drm_device *dev)
  1260. {
  1261. return 0;
  1262. }
  1263. static inline void intel_fbdev_initial_config_async(struct drm_device *dev)
  1264. {
  1265. }
  1266. static inline void intel_fbdev_fini(struct drm_device *dev)
  1267. {
  1268. }
  1269. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
  1270. {
  1271. }
  1272. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  1273. {
  1274. }
  1275. #endif
  1276. /* intel_fbc.c */
  1277. void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
  1278. struct drm_atomic_state *state);
  1279. bool intel_fbc_is_active(struct drm_i915_private *dev_priv);
  1280. void intel_fbc_pre_update(struct intel_crtc *crtc,
  1281. struct intel_crtc_state *crtc_state,
  1282. struct intel_plane_state *plane_state);
  1283. void intel_fbc_post_update(struct intel_crtc *crtc);
  1284. void intel_fbc_init(struct drm_i915_private *dev_priv);
  1285. void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv);
  1286. void intel_fbc_enable(struct intel_crtc *crtc,
  1287. struct intel_crtc_state *crtc_state,
  1288. struct intel_plane_state *plane_state);
  1289. void intel_fbc_disable(struct intel_crtc *crtc);
  1290. void intel_fbc_global_disable(struct drm_i915_private *dev_priv);
  1291. void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
  1292. unsigned int frontbuffer_bits,
  1293. enum fb_op_origin origin);
  1294. void intel_fbc_flush(struct drm_i915_private *dev_priv,
  1295. unsigned int frontbuffer_bits, enum fb_op_origin origin);
  1296. void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv);
  1297. /* intel_hdmi.c */
  1298. void intel_hdmi_init(struct drm_device *dev, i915_reg_t hdmi_reg, enum port port);
  1299. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  1300. struct intel_connector *intel_connector);
  1301. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  1302. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  1303. struct intel_crtc_state *pipe_config);
  1304. void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
  1305. /* intel_lvds.c */
  1306. void intel_lvds_init(struct drm_device *dev);
  1307. struct intel_encoder *intel_get_lvds_encoder(struct drm_device *dev);
  1308. bool intel_is_dual_link_lvds(struct drm_device *dev);
  1309. /* intel_modes.c */
  1310. int intel_connector_update_modes(struct drm_connector *connector,
  1311. struct edid *edid);
  1312. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  1313. void intel_attach_force_audio_property(struct drm_connector *connector);
  1314. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  1315. void intel_attach_aspect_ratio_property(struct drm_connector *connector);
  1316. /* intel_overlay.c */
  1317. void intel_setup_overlay(struct drm_i915_private *dev_priv);
  1318. void intel_cleanup_overlay(struct drm_i915_private *dev_priv);
  1319. int intel_overlay_switch_off(struct intel_overlay *overlay);
  1320. int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
  1321. struct drm_file *file_priv);
  1322. int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data,
  1323. struct drm_file *file_priv);
  1324. void intel_overlay_reset(struct drm_i915_private *dev_priv);
  1325. /* intel_panel.c */
  1326. int intel_panel_init(struct intel_panel *panel,
  1327. struct drm_display_mode *fixed_mode,
  1328. struct drm_display_mode *downclock_mode);
  1329. void intel_panel_fini(struct intel_panel *panel);
  1330. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  1331. struct drm_display_mode *adjusted_mode);
  1332. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  1333. struct intel_crtc_state *pipe_config,
  1334. int fitting_mode);
  1335. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  1336. struct intel_crtc_state *pipe_config,
  1337. int fitting_mode);
  1338. void intel_panel_set_backlight_acpi(struct intel_connector *connector,
  1339. u32 level, u32 max);
  1340. int intel_panel_setup_backlight(struct drm_connector *connector,
  1341. enum pipe pipe);
  1342. void intel_panel_enable_backlight(struct intel_connector *connector);
  1343. void intel_panel_disable_backlight(struct intel_connector *connector);
  1344. void intel_panel_destroy_backlight(struct drm_connector *connector);
  1345. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  1346. extern struct drm_display_mode *intel_find_panel_downclock(
  1347. struct drm_device *dev,
  1348. struct drm_display_mode *fixed_mode,
  1349. struct drm_connector *connector);
  1350. #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
  1351. int intel_backlight_device_register(struct intel_connector *connector);
  1352. void intel_backlight_device_unregister(struct intel_connector *connector);
  1353. #else /* CONFIG_BACKLIGHT_CLASS_DEVICE */
  1354. static int intel_backlight_device_register(struct intel_connector *connector)
  1355. {
  1356. return 0;
  1357. }
  1358. static inline void intel_backlight_device_unregister(struct intel_connector *connector)
  1359. {
  1360. }
  1361. #endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
  1362. /* intel_psr.c */
  1363. void intel_psr_enable(struct intel_dp *intel_dp);
  1364. void intel_psr_disable(struct intel_dp *intel_dp);
  1365. void intel_psr_invalidate(struct drm_device *dev,
  1366. unsigned frontbuffer_bits);
  1367. void intel_psr_flush(struct drm_device *dev,
  1368. unsigned frontbuffer_bits,
  1369. enum fb_op_origin origin);
  1370. void intel_psr_init(struct drm_device *dev);
  1371. void intel_psr_single_frame_update(struct drm_device *dev,
  1372. unsigned frontbuffer_bits);
  1373. /* intel_runtime_pm.c */
  1374. int intel_power_domains_init(struct drm_i915_private *);
  1375. void intel_power_domains_fini(struct drm_i915_private *);
  1376. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume);
  1377. void intel_power_domains_suspend(struct drm_i915_private *dev_priv);
  1378. void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume);
  1379. void bxt_display_core_uninit(struct drm_i915_private *dev_priv);
  1380. void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
  1381. const char *
  1382. intel_display_power_domain_str(enum intel_display_power_domain domain);
  1383. bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1384. enum intel_display_power_domain domain);
  1385. bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1386. enum intel_display_power_domain domain);
  1387. void intel_display_power_get(struct drm_i915_private *dev_priv,
  1388. enum intel_display_power_domain domain);
  1389. bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv,
  1390. enum intel_display_power_domain domain);
  1391. void intel_display_power_put(struct drm_i915_private *dev_priv,
  1392. enum intel_display_power_domain domain);
  1393. static inline void
  1394. assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv)
  1395. {
  1396. WARN_ONCE(dev_priv->pm.suspended,
  1397. "Device suspended during HW access\n");
  1398. }
  1399. static inline void
  1400. assert_rpm_wakelock_held(struct drm_i915_private *dev_priv)
  1401. {
  1402. assert_rpm_device_not_suspended(dev_priv);
  1403. /* FIXME: Needs to be converted back to WARN_ONCE, but currently causes
  1404. * too much noise. */
  1405. if (!atomic_read(&dev_priv->pm.wakeref_count))
  1406. DRM_DEBUG_DRIVER("RPM wakelock ref not held during HW access");
  1407. }
  1408. static inline int
  1409. assert_rpm_atomic_begin(struct drm_i915_private *dev_priv)
  1410. {
  1411. int seq = atomic_read(&dev_priv->pm.atomic_seq);
  1412. assert_rpm_wakelock_held(dev_priv);
  1413. return seq;
  1414. }
  1415. static inline void
  1416. assert_rpm_atomic_end(struct drm_i915_private *dev_priv, int begin_seq)
  1417. {
  1418. WARN_ONCE(atomic_read(&dev_priv->pm.atomic_seq) != begin_seq,
  1419. "HW access outside of RPM atomic section\n");
  1420. }
  1421. /**
  1422. * disable_rpm_wakeref_asserts - disable the RPM assert checks
  1423. * @dev_priv: i915 device instance
  1424. *
  1425. * This function disable asserts that check if we hold an RPM wakelock
  1426. * reference, while keeping the device-not-suspended checks still enabled.
  1427. * It's meant to be used only in special circumstances where our rule about
  1428. * the wakelock refcount wrt. the device power state doesn't hold. According
  1429. * to this rule at any point where we access the HW or want to keep the HW in
  1430. * an active state we must hold an RPM wakelock reference acquired via one of
  1431. * the intel_runtime_pm_get() helpers. Currently there are a few special spots
  1432. * where this rule doesn't hold: the IRQ and suspend/resume handlers, the
  1433. * forcewake release timer, and the GPU RPS and hangcheck works. All other
  1434. * users should avoid using this function.
  1435. *
  1436. * Any calls to this function must have a symmetric call to
  1437. * enable_rpm_wakeref_asserts().
  1438. */
  1439. static inline void
  1440. disable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1441. {
  1442. atomic_inc(&dev_priv->pm.wakeref_count);
  1443. }
  1444. /**
  1445. * enable_rpm_wakeref_asserts - re-enable the RPM assert checks
  1446. * @dev_priv: i915 device instance
  1447. *
  1448. * This function re-enables the RPM assert checks after disabling them with
  1449. * disable_rpm_wakeref_asserts. It's meant to be used only in special
  1450. * circumstances otherwise its use should be avoided.
  1451. *
  1452. * Any calls to this function must have a symmetric call to
  1453. * disable_rpm_wakeref_asserts().
  1454. */
  1455. static inline void
  1456. enable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1457. {
  1458. atomic_dec(&dev_priv->pm.wakeref_count);
  1459. }
  1460. /* TODO: convert users of these to rely instead on proper RPM refcounting */
  1461. #define DISABLE_RPM_WAKEREF_ASSERTS(dev_priv) \
  1462. disable_rpm_wakeref_asserts(dev_priv)
  1463. #define ENABLE_RPM_WAKEREF_ASSERTS(dev_priv) \
  1464. enable_rpm_wakeref_asserts(dev_priv)
  1465. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  1466. bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv);
  1467. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  1468. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  1469. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  1470. void chv_phy_powergate_lanes(struct intel_encoder *encoder,
  1471. bool override, unsigned int mask);
  1472. bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy,
  1473. enum dpio_channel ch, bool override);
  1474. /* intel_pm.c */
  1475. void intel_init_clock_gating(struct drm_device *dev);
  1476. void intel_suspend_hw(struct drm_device *dev);
  1477. int ilk_wm_max_level(const struct drm_device *dev);
  1478. void intel_update_watermarks(struct drm_crtc *crtc);
  1479. void intel_init_pm(struct drm_device *dev);
  1480. void intel_init_clock_gating_hooks(struct drm_i915_private *dev_priv);
  1481. void intel_pm_setup(struct drm_device *dev);
  1482. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  1483. void intel_gpu_ips_teardown(void);
  1484. void intel_init_gt_powersave(struct drm_i915_private *dev_priv);
  1485. void intel_cleanup_gt_powersave(struct drm_i915_private *dev_priv);
  1486. void intel_enable_gt_powersave(struct drm_i915_private *dev_priv);
  1487. void intel_disable_gt_powersave(struct drm_i915_private *dev_priv);
  1488. void intel_suspend_gt_powersave(struct drm_i915_private *dev_priv);
  1489. void intel_reset_gt_powersave(struct drm_i915_private *dev_priv);
  1490. void gen6_update_ring_freq(struct drm_i915_private *dev_priv);
  1491. void gen6_rps_busy(struct drm_i915_private *dev_priv);
  1492. void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
  1493. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  1494. void gen6_rps_boost(struct drm_i915_private *dev_priv,
  1495. struct intel_rps_client *rps,
  1496. unsigned long submitted);
  1497. void intel_queue_rps_boost_for_request(struct drm_i915_gem_request *req);
  1498. void vlv_wm_get_hw_state(struct drm_device *dev);
  1499. void ilk_wm_get_hw_state(struct drm_device *dev);
  1500. void skl_wm_get_hw_state(struct drm_device *dev);
  1501. void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  1502. struct skl_ddb_allocation *ddb /* out */);
  1503. bool skl_can_enable_sagv(struct drm_atomic_state *state);
  1504. int skl_enable_sagv(struct drm_i915_private *dev_priv);
  1505. int skl_disable_sagv(struct drm_i915_private *dev_priv);
  1506. uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config);
  1507. bool ilk_disable_lp_wm(struct drm_device *dev);
  1508. int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6);
  1509. static inline int intel_enable_rc6(void)
  1510. {
  1511. return i915.enable_rc6;
  1512. }
  1513. /* intel_sdvo.c */
  1514. bool intel_sdvo_init(struct drm_device *dev,
  1515. i915_reg_t reg, enum port port);
  1516. /* intel_sprite.c */
  1517. int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
  1518. int usecs);
  1519. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  1520. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  1521. struct drm_file *file_priv);
  1522. void intel_pipe_update_start(struct intel_crtc *crtc);
  1523. void intel_pipe_update_end(struct intel_crtc *crtc, struct intel_flip_work *work);
  1524. /* intel_tv.c */
  1525. void intel_tv_init(struct drm_device *dev);
  1526. /* intel_atomic.c */
  1527. int intel_connector_atomic_get_property(struct drm_connector *connector,
  1528. const struct drm_connector_state *state,
  1529. struct drm_property *property,
  1530. uint64_t *val);
  1531. struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
  1532. void intel_crtc_destroy_state(struct drm_crtc *crtc,
  1533. struct drm_crtc_state *state);
  1534. struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
  1535. void intel_atomic_state_clear(struct drm_atomic_state *);
  1536. struct intel_shared_dpll_config *
  1537. intel_atomic_get_shared_dpll_state(struct drm_atomic_state *s);
  1538. static inline struct intel_crtc_state *
  1539. intel_atomic_get_crtc_state(struct drm_atomic_state *state,
  1540. struct intel_crtc *crtc)
  1541. {
  1542. struct drm_crtc_state *crtc_state;
  1543. crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
  1544. if (IS_ERR(crtc_state))
  1545. return ERR_CAST(crtc_state);
  1546. return to_intel_crtc_state(crtc_state);
  1547. }
  1548. static inline struct intel_plane_state *
  1549. intel_atomic_get_existing_plane_state(struct drm_atomic_state *state,
  1550. struct intel_plane *plane)
  1551. {
  1552. struct drm_plane_state *plane_state;
  1553. plane_state = drm_atomic_get_existing_plane_state(state, &plane->base);
  1554. return to_intel_plane_state(plane_state);
  1555. }
  1556. int intel_atomic_setup_scalers(struct drm_device *dev,
  1557. struct intel_crtc *intel_crtc,
  1558. struct intel_crtc_state *crtc_state);
  1559. /* intel_atomic_plane.c */
  1560. struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
  1561. struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
  1562. void intel_plane_destroy_state(struct drm_plane *plane,
  1563. struct drm_plane_state *state);
  1564. extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
  1565. /* intel_color.c */
  1566. void intel_color_init(struct drm_crtc *crtc);
  1567. int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
  1568. void intel_color_set_csc(struct drm_crtc_state *crtc_state);
  1569. void intel_color_load_luts(struct drm_crtc_state *crtc_state);
  1570. #endif /* __INTEL_DRV_H__ */