intel_drv.h 62 KB

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