intel_drv.h 60 KB

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