intel_drv.h 74 KB

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