intel_drv.h 65 KB

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