intel_drv.h 57 KB

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