intel_drv.h 71 KB

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