intel_drv.h 61 KB

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