intel_drv.h 67 KB

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