intel_drv.h 58 KB

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