intel_drv.h 72 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167
  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. unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \
  51. long wait__ = (Wmin); /* recommended min for usleep is 10 us */ \
  52. int ret__; \
  53. might_sleep(); \
  54. for (;;) { \
  55. bool expired__ = time_after(jiffies, timeout__); \
  56. 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_ddb_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. #define ICL_MAX_SRC_W 5120
  482. #define ICL_MAX_SRC_H 4096
  483. #define ICL_MAX_DST_W 5120
  484. #define ICL_MAX_DST_H 4096
  485. #define SKL_MIN_YUV_420_SRC_W 16
  486. #define SKL_MIN_YUV_420_SRC_H 16
  487. struct intel_scaler {
  488. int in_use;
  489. uint32_t mode;
  490. };
  491. struct intel_crtc_scaler_state {
  492. #define SKL_NUM_SCALERS 2
  493. struct intel_scaler scalers[SKL_NUM_SCALERS];
  494. /*
  495. * scaler_users: keeps track of users requesting scalers on this crtc.
  496. *
  497. * If a bit is set, a user is using a scaler.
  498. * Here user can be a plane or crtc as defined below:
  499. * bits 0-30 - plane (bit position is index from drm_plane_index)
  500. * bit 31 - crtc
  501. *
  502. * Instead of creating a new index to cover planes and crtc, using
  503. * existing drm_plane_index for planes which is well less than 31
  504. * planes and bit 31 for crtc. This should be fine to cover all
  505. * our platforms.
  506. *
  507. * intel_atomic_setup_scalers will setup available scalers to users
  508. * requesting scalers. It will gracefully fail if request exceeds
  509. * avilability.
  510. */
  511. #define SKL_CRTC_INDEX 31
  512. unsigned scaler_users;
  513. /* scaler used by crtc for panel fitting purpose */
  514. int scaler_id;
  515. };
  516. /* drm_mode->private_flags */
  517. #define I915_MODE_FLAG_INHERITED 1
  518. /* Flag to get scanline using frame time stamps */
  519. #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
  520. struct intel_pipe_wm {
  521. struct intel_wm_level wm[5];
  522. uint32_t linetime;
  523. bool fbc_wm_enabled;
  524. bool pipe_enabled;
  525. bool sprites_enabled;
  526. bool sprites_scaled;
  527. };
  528. struct skl_plane_wm {
  529. struct skl_wm_level wm[8];
  530. struct skl_wm_level uv_wm[8];
  531. struct skl_wm_level trans_wm;
  532. bool is_planar;
  533. };
  534. struct skl_pipe_wm {
  535. struct skl_plane_wm planes[I915_MAX_PLANES];
  536. uint32_t linetime;
  537. };
  538. enum vlv_wm_level {
  539. VLV_WM_LEVEL_PM2,
  540. VLV_WM_LEVEL_PM5,
  541. VLV_WM_LEVEL_DDR_DVFS,
  542. NUM_VLV_WM_LEVELS,
  543. };
  544. struct vlv_wm_state {
  545. struct g4x_pipe_wm wm[NUM_VLV_WM_LEVELS];
  546. struct g4x_sr_wm sr[NUM_VLV_WM_LEVELS];
  547. uint8_t num_levels;
  548. bool cxsr;
  549. };
  550. struct vlv_fifo_state {
  551. u16 plane[I915_MAX_PLANES];
  552. };
  553. enum g4x_wm_level {
  554. G4X_WM_LEVEL_NORMAL,
  555. G4X_WM_LEVEL_SR,
  556. G4X_WM_LEVEL_HPLL,
  557. NUM_G4X_WM_LEVELS,
  558. };
  559. struct g4x_wm_state {
  560. struct g4x_pipe_wm wm;
  561. struct g4x_sr_wm sr;
  562. struct g4x_sr_wm hpll;
  563. bool cxsr;
  564. bool hpll_en;
  565. bool fbc_en;
  566. };
  567. struct intel_crtc_wm_state {
  568. union {
  569. struct {
  570. /*
  571. * Intermediate watermarks; these can be
  572. * programmed immediately since they satisfy
  573. * both the current configuration we're
  574. * switching away from and the new
  575. * configuration we're switching to.
  576. */
  577. struct intel_pipe_wm intermediate;
  578. /*
  579. * Optimal watermarks, programmed post-vblank
  580. * when this state is committed.
  581. */
  582. struct intel_pipe_wm optimal;
  583. } ilk;
  584. struct {
  585. /* gen9+ only needs 1-step wm programming */
  586. struct skl_pipe_wm optimal;
  587. struct skl_ddb_entry ddb;
  588. } skl;
  589. struct {
  590. /* "raw" watermarks (not inverted) */
  591. struct g4x_pipe_wm raw[NUM_VLV_WM_LEVELS];
  592. /* intermediate watermarks (inverted) */
  593. struct vlv_wm_state intermediate;
  594. /* optimal watermarks (inverted) */
  595. struct vlv_wm_state optimal;
  596. /* display FIFO split */
  597. struct vlv_fifo_state fifo_state;
  598. } vlv;
  599. struct {
  600. /* "raw" watermarks */
  601. struct g4x_pipe_wm raw[NUM_G4X_WM_LEVELS];
  602. /* intermediate watermarks */
  603. struct g4x_wm_state intermediate;
  604. /* optimal watermarks */
  605. struct g4x_wm_state optimal;
  606. } g4x;
  607. };
  608. /*
  609. * Platforms with two-step watermark programming will need to
  610. * update watermark programming post-vblank to switch from the
  611. * safe intermediate watermarks to the optimal final
  612. * watermarks.
  613. */
  614. bool need_postvbl_update;
  615. };
  616. struct intel_crtc_state {
  617. struct drm_crtc_state base;
  618. /**
  619. * quirks - bitfield with hw state readout quirks
  620. *
  621. * For various reasons the hw state readout code might not be able to
  622. * completely faithfully read out the current state. These cases are
  623. * tracked with quirk flags so that fastboot and state checker can act
  624. * accordingly.
  625. */
  626. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  627. unsigned long quirks;
  628. unsigned fb_bits; /* framebuffers to flip */
  629. bool update_pipe; /* can a fast modeset be performed? */
  630. bool disable_cxsr;
  631. bool update_wm_pre, update_wm_post; /* watermarks are updated */
  632. bool fb_changed; /* fb on any of the planes is changed */
  633. bool fifo_changed; /* FIFO split is changed */
  634. /* Pipe source size (ie. panel fitter input size)
  635. * All planes will be positioned inside this space,
  636. * and get clipped at the edges. */
  637. int pipe_src_w, pipe_src_h;
  638. /*
  639. * Pipe pixel rate, adjusted for
  640. * panel fitter/pipe scaler downscaling.
  641. */
  642. unsigned int pixel_rate;
  643. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  644. * between pch encoders and cpu encoders. */
  645. bool has_pch_encoder;
  646. /* Are we sending infoframes on the attached port */
  647. bool has_infoframe;
  648. /* CPU Transcoder for the pipe. Currently this can only differ from the
  649. * pipe on Haswell and later (where we have a special eDP transcoder)
  650. * and Broxton (where we have special DSI transcoders). */
  651. enum transcoder cpu_transcoder;
  652. /*
  653. * Use reduced/limited/broadcast rbg range, compressing from the full
  654. * range fed into the crtcs.
  655. */
  656. bool limited_color_range;
  657. /* Bitmask of encoder types (enum intel_output_type)
  658. * driven by the pipe.
  659. */
  660. unsigned int output_types;
  661. /* Whether we should send NULL infoframes. Required for audio. */
  662. bool has_hdmi_sink;
  663. /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
  664. * has_dp_encoder is set. */
  665. bool has_audio;
  666. /*
  667. * Enable dithering, used when the selected pipe bpp doesn't match the
  668. * plane bpp.
  669. */
  670. bool dither;
  671. /*
  672. * Dither gets enabled for 18bpp which causes CRC mismatch errors for
  673. * compliance video pattern tests.
  674. * Disable dither only if it is a compliance test request for
  675. * 18bpp.
  676. */
  677. bool dither_force_disable;
  678. /* Controls for the clock computation, to override various stages. */
  679. bool clock_set;
  680. /* SDVO TV has a bunch of special case. To make multifunction encoders
  681. * work correctly, we need to track this at runtime.*/
  682. bool sdvo_tv_clock;
  683. /*
  684. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  685. * required. This is set in the 2nd loop of calling encoder's
  686. * ->compute_config if the first pick doesn't work out.
  687. */
  688. bool bw_constrained;
  689. /* Settings for the intel dpll used on pretty much everything but
  690. * haswell. */
  691. struct dpll dpll;
  692. /* Selected dpll when shared or NULL. */
  693. struct intel_shared_dpll *shared_dpll;
  694. /* Actual register state of the dpll, for shared dpll cross-checking. */
  695. struct intel_dpll_hw_state dpll_hw_state;
  696. /* DSI PLL registers */
  697. struct {
  698. u32 ctrl, div;
  699. } dsi_pll;
  700. int pipe_bpp;
  701. struct intel_link_m_n dp_m_n;
  702. /* m2_n2 for eDP downclock */
  703. struct intel_link_m_n dp_m2_n2;
  704. bool has_drrs;
  705. bool has_psr;
  706. bool has_psr2;
  707. /*
  708. * Frequence the dpll for the port should run at. Differs from the
  709. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  710. * already multiplied by pixel_multiplier.
  711. */
  712. int port_clock;
  713. /* Used by SDVO (and if we ever fix it, HDMI). */
  714. unsigned pixel_multiplier;
  715. uint8_t lane_count;
  716. /*
  717. * Used by platforms having DP/HDMI PHY with programmable lane
  718. * latency optimization.
  719. */
  720. uint8_t lane_lat_optim_mask;
  721. /* minimum acceptable voltage level */
  722. u8 min_voltage_level;
  723. /* Panel fitter controls for gen2-gen4 + VLV */
  724. struct {
  725. u32 control;
  726. u32 pgm_ratios;
  727. u32 lvds_border_bits;
  728. } gmch_pfit;
  729. /* Panel fitter placement and size for Ironlake+ */
  730. struct {
  731. u32 pos;
  732. u32 size;
  733. bool enabled;
  734. bool force_thru;
  735. } pch_pfit;
  736. /* FDI configuration, only valid if has_pch_encoder is set. */
  737. int fdi_lanes;
  738. struct intel_link_m_n fdi_m_n;
  739. bool ips_enabled;
  740. bool ips_force_disable;
  741. bool enable_fbc;
  742. bool double_wide;
  743. int pbn;
  744. struct intel_crtc_scaler_state scaler_state;
  745. /* w/a for waiting 2 vblanks during crtc enable */
  746. enum pipe hsw_workaround_pipe;
  747. /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
  748. bool disable_lp_wm;
  749. struct intel_crtc_wm_state wm;
  750. /* Gamma mode programmed on the pipe */
  751. uint32_t gamma_mode;
  752. /* bitmask of visible planes (enum plane_id) */
  753. u8 active_planes;
  754. /* HDMI scrambling status */
  755. bool hdmi_scrambling;
  756. /* HDMI High TMDS char rate ratio */
  757. bool hdmi_high_tmds_clock_ratio;
  758. /* output format is YCBCR 4:2:0 */
  759. bool ycbcr420;
  760. };
  761. struct intel_crtc {
  762. struct drm_crtc base;
  763. enum pipe pipe;
  764. /*
  765. * Whether the crtc and the connected output pipeline is active. Implies
  766. * that crtc->enabled is set, i.e. the current mode configuration has
  767. * some outputs connected to this crtc.
  768. */
  769. bool active;
  770. u8 plane_ids_mask;
  771. unsigned long long enabled_power_domains;
  772. struct intel_overlay *overlay;
  773. struct intel_crtc_state *config;
  774. /* global reset count when the last flip was submitted */
  775. unsigned int reset_count;
  776. /* Access to these should be protected by dev_priv->irq_lock. */
  777. bool cpu_fifo_underrun_disabled;
  778. bool pch_fifo_underrun_disabled;
  779. /* per-pipe watermark state */
  780. struct {
  781. /* watermarks currently being used */
  782. union {
  783. struct intel_pipe_wm ilk;
  784. struct vlv_wm_state vlv;
  785. struct g4x_wm_state g4x;
  786. } active;
  787. } wm;
  788. int scanline_offset;
  789. struct {
  790. unsigned start_vbl_count;
  791. ktime_t start_vbl_time;
  792. int min_vbl, max_vbl;
  793. int scanline_start;
  794. } debug;
  795. /* scalers available on this crtc */
  796. int num_scalers;
  797. };
  798. struct intel_plane {
  799. struct drm_plane base;
  800. enum i9xx_plane_id i9xx_plane;
  801. enum plane_id id;
  802. enum pipe pipe;
  803. bool can_scale;
  804. bool has_fbc;
  805. int max_downscale;
  806. uint32_t frontbuffer_bit;
  807. struct {
  808. u32 base, cntl, size;
  809. } cursor;
  810. /*
  811. * NOTE: Do not place new plane state fields here (e.g., when adding
  812. * new plane properties). New runtime state should now be placed in
  813. * the intel_plane_state structure and accessed via plane_state.
  814. */
  815. void (*update_plane)(struct intel_plane *plane,
  816. const struct intel_crtc_state *crtc_state,
  817. const struct intel_plane_state *plane_state);
  818. void (*disable_plane)(struct intel_plane *plane,
  819. struct intel_crtc *crtc);
  820. bool (*get_hw_state)(struct intel_plane *plane);
  821. int (*check_plane)(struct intel_plane *plane,
  822. struct intel_crtc_state *crtc_state,
  823. struct intel_plane_state *state);
  824. };
  825. struct intel_watermark_params {
  826. u16 fifo_size;
  827. u16 max_wm;
  828. u8 default_wm;
  829. u8 guard_size;
  830. u8 cacheline_size;
  831. };
  832. struct cxsr_latency {
  833. bool is_desktop : 1;
  834. bool is_ddr3 : 1;
  835. u16 fsb_freq;
  836. u16 mem_freq;
  837. u16 display_sr;
  838. u16 display_hpll_disable;
  839. u16 cursor_sr;
  840. u16 cursor_hpll_disable;
  841. };
  842. #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
  843. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  844. #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
  845. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  846. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  847. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  848. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  849. #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
  850. #define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL)
  851. struct intel_hdmi {
  852. i915_reg_t hdmi_reg;
  853. int ddc_bus;
  854. struct {
  855. enum drm_dp_dual_mode_type type;
  856. int max_tmds_clock;
  857. } dp_dual_mode;
  858. bool has_hdmi_sink;
  859. bool has_audio;
  860. bool rgb_quant_range_selectable;
  861. struct intel_connector *attached_connector;
  862. };
  863. struct intel_dp_mst_encoder;
  864. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  865. /*
  866. * enum link_m_n_set:
  867. * When platform provides two set of M_N registers for dp, we can
  868. * program them and switch between them incase of DRRS.
  869. * But When only one such register is provided, we have to program the
  870. * required divider value on that registers itself based on the DRRS state.
  871. *
  872. * M1_N1 : Program dp_m_n on M1_N1 registers
  873. * dp_m2_n2 on M2_N2 registers (If supported)
  874. *
  875. * M2_N2 : Program dp_m2_n2 on M1_N1 registers
  876. * M2_N2 registers are not supported
  877. */
  878. enum link_m_n_set {
  879. /* Sets the m1_n1 and m2_n2 */
  880. M1_N1 = 0,
  881. M2_N2
  882. };
  883. struct intel_dp_compliance_data {
  884. unsigned long edid;
  885. uint8_t video_pattern;
  886. uint16_t hdisplay, vdisplay;
  887. uint8_t bpc;
  888. };
  889. struct intel_dp_compliance {
  890. unsigned long test_type;
  891. struct intel_dp_compliance_data test_data;
  892. bool test_active;
  893. int test_link_rate;
  894. u8 test_lane_count;
  895. };
  896. struct intel_dp {
  897. i915_reg_t output_reg;
  898. uint32_t DP;
  899. int link_rate;
  900. uint8_t lane_count;
  901. uint8_t sink_count;
  902. bool link_mst;
  903. bool link_trained;
  904. bool has_audio;
  905. bool detect_done;
  906. bool reset_link_params;
  907. enum aux_ch aux_ch;
  908. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  909. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  910. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  911. uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
  912. /* source rates */
  913. int num_source_rates;
  914. const int *source_rates;
  915. /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */
  916. int num_sink_rates;
  917. int sink_rates[DP_MAX_SUPPORTED_RATES];
  918. bool use_rate_select;
  919. /* intersection of source and sink rates */
  920. int num_common_rates;
  921. int common_rates[DP_MAX_SUPPORTED_RATES];
  922. /* Max lane count for the current link */
  923. int max_link_lane_count;
  924. /* Max rate for the current link */
  925. int max_link_rate;
  926. /* sink or branch descriptor */
  927. struct drm_dp_desc desc;
  928. struct drm_dp_aux aux;
  929. enum intel_display_power_domain aux_power_domain;
  930. uint8_t train_set[4];
  931. int panel_power_up_delay;
  932. int panel_power_down_delay;
  933. int panel_power_cycle_delay;
  934. int backlight_on_delay;
  935. int backlight_off_delay;
  936. struct delayed_work panel_vdd_work;
  937. bool want_panel_vdd;
  938. unsigned long last_power_on;
  939. unsigned long last_backlight_off;
  940. ktime_t panel_power_off_time;
  941. struct notifier_block edp_notifier;
  942. /*
  943. * Pipe whose power sequencer is currently locked into
  944. * this port. Only relevant on VLV/CHV.
  945. */
  946. enum pipe pps_pipe;
  947. /*
  948. * Pipe currently driving the port. Used for preventing
  949. * the use of the PPS for any pipe currentrly driving
  950. * external DP as that will mess things up on VLV.
  951. */
  952. enum pipe active_pipe;
  953. /*
  954. * Set if the sequencer may be reset due to a power transition,
  955. * requiring a reinitialization. Only relevant on BXT.
  956. */
  957. bool pps_reset;
  958. struct edp_power_seq pps_delays;
  959. bool can_mst; /* this port supports mst */
  960. bool is_mst;
  961. int active_mst_links;
  962. /* connector directly attached - won't be use for modeset in mst world */
  963. struct intel_connector *attached_connector;
  964. /* mst connector list */
  965. struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
  966. struct drm_dp_mst_topology_mgr mst_mgr;
  967. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  968. /*
  969. * This function returns the value we have to program the AUX_CTL
  970. * register with to kick off an AUX transaction.
  971. */
  972. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  973. bool has_aux_irq,
  974. int send_bytes,
  975. uint32_t aux_clock_divider);
  976. i915_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp);
  977. i915_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index);
  978. /* This is called before a link training is starterd */
  979. void (*prepare_link_retrain)(struct intel_dp *intel_dp);
  980. /* Displayport compliance testing */
  981. struct intel_dp_compliance compliance;
  982. };
  983. struct intel_lspcon {
  984. bool active;
  985. enum drm_lspcon_mode mode;
  986. };
  987. struct intel_digital_port {
  988. struct intel_encoder base;
  989. u32 saved_port_bits;
  990. struct intel_dp dp;
  991. struct intel_hdmi hdmi;
  992. struct intel_lspcon lspcon;
  993. enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
  994. bool release_cl2_override;
  995. uint8_t max_lanes;
  996. enum intel_display_power_domain ddi_io_power_domain;
  997. void (*write_infoframe)(struct drm_encoder *encoder,
  998. const struct intel_crtc_state *crtc_state,
  999. unsigned int type,
  1000. const void *frame, ssize_t len);
  1001. void (*set_infoframes)(struct drm_encoder *encoder,
  1002. bool enable,
  1003. const struct intel_crtc_state *crtc_state,
  1004. const struct drm_connector_state *conn_state);
  1005. bool (*infoframe_enabled)(struct drm_encoder *encoder,
  1006. const struct intel_crtc_state *pipe_config);
  1007. };
  1008. struct intel_dp_mst_encoder {
  1009. struct intel_encoder base;
  1010. enum pipe pipe;
  1011. struct intel_digital_port *primary;
  1012. struct intel_connector *connector;
  1013. };
  1014. static inline enum dpio_channel
  1015. vlv_dport_to_channel(struct intel_digital_port *dport)
  1016. {
  1017. switch (dport->base.port) {
  1018. case PORT_B:
  1019. case PORT_D:
  1020. return DPIO_CH0;
  1021. case PORT_C:
  1022. return DPIO_CH1;
  1023. default:
  1024. BUG();
  1025. }
  1026. }
  1027. static inline enum dpio_phy
  1028. vlv_dport_to_phy(struct intel_digital_port *dport)
  1029. {
  1030. switch (dport->base.port) {
  1031. case PORT_B:
  1032. case PORT_C:
  1033. return DPIO_PHY0;
  1034. case PORT_D:
  1035. return DPIO_PHY1;
  1036. default:
  1037. BUG();
  1038. }
  1039. }
  1040. static inline enum dpio_channel
  1041. vlv_pipe_to_channel(enum pipe pipe)
  1042. {
  1043. switch (pipe) {
  1044. case PIPE_A:
  1045. case PIPE_C:
  1046. return DPIO_CH0;
  1047. case PIPE_B:
  1048. return DPIO_CH1;
  1049. default:
  1050. BUG();
  1051. }
  1052. }
  1053. static inline struct intel_crtc *
  1054. intel_get_crtc_for_pipe(struct drm_i915_private *dev_priv, enum pipe pipe)
  1055. {
  1056. return dev_priv->pipe_to_crtc_mapping[pipe];
  1057. }
  1058. static inline struct intel_crtc *
  1059. intel_get_crtc_for_plane(struct drm_i915_private *dev_priv, enum i9xx_plane_id plane)
  1060. {
  1061. return dev_priv->plane_to_crtc_mapping[plane];
  1062. }
  1063. struct intel_load_detect_pipe {
  1064. struct drm_atomic_state *restore_state;
  1065. };
  1066. static inline struct intel_encoder *
  1067. intel_attached_encoder(struct drm_connector *connector)
  1068. {
  1069. return to_intel_connector(connector)->encoder;
  1070. }
  1071. static inline struct intel_digital_port *
  1072. enc_to_dig_port(struct drm_encoder *encoder)
  1073. {
  1074. struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
  1075. switch (intel_encoder->type) {
  1076. case INTEL_OUTPUT_DDI:
  1077. WARN_ON(!HAS_DDI(to_i915(encoder->dev)));
  1078. case INTEL_OUTPUT_DP:
  1079. case INTEL_OUTPUT_EDP:
  1080. case INTEL_OUTPUT_HDMI:
  1081. return container_of(encoder, struct intel_digital_port,
  1082. base.base);
  1083. default:
  1084. return NULL;
  1085. }
  1086. }
  1087. static inline struct intel_dp_mst_encoder *
  1088. enc_to_mst(struct drm_encoder *encoder)
  1089. {
  1090. return container_of(encoder, struct intel_dp_mst_encoder, base.base);
  1091. }
  1092. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  1093. {
  1094. return &enc_to_dig_port(encoder)->dp;
  1095. }
  1096. static inline struct intel_digital_port *
  1097. dp_to_dig_port(struct intel_dp *intel_dp)
  1098. {
  1099. return container_of(intel_dp, struct intel_digital_port, dp);
  1100. }
  1101. static inline struct intel_lspcon *
  1102. dp_to_lspcon(struct intel_dp *intel_dp)
  1103. {
  1104. return &dp_to_dig_port(intel_dp)->lspcon;
  1105. }
  1106. static inline struct intel_digital_port *
  1107. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  1108. {
  1109. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  1110. }
  1111. static inline struct intel_plane_state *
  1112. intel_atomic_get_new_plane_state(struct intel_atomic_state *state,
  1113. struct intel_plane *plane)
  1114. {
  1115. return to_intel_plane_state(drm_atomic_get_new_plane_state(&state->base,
  1116. &plane->base));
  1117. }
  1118. static inline struct intel_crtc_state *
  1119. intel_atomic_get_old_crtc_state(struct intel_atomic_state *state,
  1120. struct intel_crtc *crtc)
  1121. {
  1122. return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state->base,
  1123. &crtc->base));
  1124. }
  1125. static inline struct intel_crtc_state *
  1126. intel_atomic_get_new_crtc_state(struct intel_atomic_state *state,
  1127. struct intel_crtc *crtc)
  1128. {
  1129. return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state->base,
  1130. &crtc->base));
  1131. }
  1132. /* intel_fifo_underrun.c */
  1133. bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  1134. enum pipe pipe, bool enable);
  1135. bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  1136. enum pipe pch_transcoder,
  1137. bool enable);
  1138. void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  1139. enum pipe pipe);
  1140. void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  1141. enum pipe pch_transcoder);
  1142. void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv);
  1143. void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv);
  1144. /* i915_irq.c */
  1145. void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  1146. void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  1147. void gen6_mask_pm_irq(struct drm_i915_private *dev_priv, u32 mask);
  1148. void gen6_unmask_pm_irq(struct drm_i915_private *dev_priv, u32 mask);
  1149. void gen11_reset_rps_interrupts(struct drm_i915_private *dev_priv);
  1150. void gen6_reset_rps_interrupts(struct drm_i915_private *dev_priv);
  1151. void gen6_enable_rps_interrupts(struct drm_i915_private *dev_priv);
  1152. void gen6_disable_rps_interrupts(struct drm_i915_private *dev_priv);
  1153. static inline u32 gen6_sanitize_rps_pm_mask(const struct drm_i915_private *i915,
  1154. u32 mask)
  1155. {
  1156. return mask & ~i915->gt_pm.rps.pm_intrmsk_mbz;
  1157. }
  1158. void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
  1159. void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
  1160. static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
  1161. {
  1162. /*
  1163. * We only use drm_irq_uninstall() at unload and VT switch, so
  1164. * this is the only thing we need to check.
  1165. */
  1166. return dev_priv->runtime_pm.irqs_enabled;
  1167. }
  1168. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  1169. void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
  1170. u8 pipe_mask);
  1171. void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv,
  1172. u8 pipe_mask);
  1173. void gen9_reset_guc_interrupts(struct drm_i915_private *dev_priv);
  1174. void gen9_enable_guc_interrupts(struct drm_i915_private *dev_priv);
  1175. void gen9_disable_guc_interrupts(struct drm_i915_private *dev_priv);
  1176. /* intel_crt.c */
  1177. void intel_crt_init(struct drm_i915_private *dev_priv);
  1178. void intel_crt_reset(struct drm_encoder *encoder);
  1179. /* intel_ddi.c */
  1180. void intel_ddi_fdi_post_disable(struct intel_encoder *intel_encoder,
  1181. const struct intel_crtc_state *old_crtc_state,
  1182. const struct drm_connector_state *old_conn_state);
  1183. void hsw_fdi_link_train(struct intel_crtc *crtc,
  1184. const struct intel_crtc_state *crtc_state);
  1185. void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port);
  1186. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  1187. void intel_ddi_enable_transcoder_func(const struct intel_crtc_state *crtc_state);
  1188. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  1189. enum transcoder cpu_transcoder);
  1190. void intel_ddi_enable_pipe_clock(const struct intel_crtc_state *crtc_state);
  1191. void intel_ddi_disable_pipe_clock(const struct intel_crtc_state *crtc_state);
  1192. struct intel_encoder *
  1193. intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
  1194. void intel_ddi_set_pipe_settings(const struct intel_crtc_state *crtc_state);
  1195. void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
  1196. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  1197. void intel_ddi_get_config(struct intel_encoder *encoder,
  1198. struct intel_crtc_state *pipe_config);
  1199. void intel_ddi_set_vc_payload_alloc(const struct intel_crtc_state *crtc_state,
  1200. bool state);
  1201. void intel_ddi_compute_min_voltage_level(struct drm_i915_private *dev_priv,
  1202. struct intel_crtc_state *crtc_state);
  1203. u32 bxt_signal_levels(struct intel_dp *intel_dp);
  1204. uint32_t ddi_signal_levels(struct intel_dp *intel_dp);
  1205. u8 intel_ddi_dp_voltage_max(struct intel_encoder *encoder);
  1206. int intel_ddi_toggle_hdcp_signalling(struct intel_encoder *intel_encoder,
  1207. bool enable);
  1208. unsigned int intel_fb_align_height(const struct drm_framebuffer *fb,
  1209. int plane, unsigned int height);
  1210. /* intel_audio.c */
  1211. void intel_init_audio_hooks(struct drm_i915_private *dev_priv);
  1212. void intel_audio_codec_enable(struct intel_encoder *encoder,
  1213. const struct intel_crtc_state *crtc_state,
  1214. const struct drm_connector_state *conn_state);
  1215. void intel_audio_codec_disable(struct intel_encoder *encoder,
  1216. const struct intel_crtc_state *old_crtc_state,
  1217. const struct drm_connector_state *old_conn_state);
  1218. void i915_audio_component_init(struct drm_i915_private *dev_priv);
  1219. void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
  1220. void intel_audio_init(struct drm_i915_private *dev_priv);
  1221. void intel_audio_deinit(struct drm_i915_private *dev_priv);
  1222. /* intel_cdclk.c */
  1223. int intel_crtc_compute_min_cdclk(const struct intel_crtc_state *crtc_state);
  1224. void skl_init_cdclk(struct drm_i915_private *dev_priv);
  1225. void skl_uninit_cdclk(struct drm_i915_private *dev_priv);
  1226. void cnl_init_cdclk(struct drm_i915_private *dev_priv);
  1227. void cnl_uninit_cdclk(struct drm_i915_private *dev_priv);
  1228. void bxt_init_cdclk(struct drm_i915_private *dev_priv);
  1229. void bxt_uninit_cdclk(struct drm_i915_private *dev_priv);
  1230. void icl_init_cdclk(struct drm_i915_private *dev_priv);
  1231. void icl_uninit_cdclk(struct drm_i915_private *dev_priv);
  1232. void intel_init_cdclk_hooks(struct drm_i915_private *dev_priv);
  1233. void intel_update_max_cdclk(struct drm_i915_private *dev_priv);
  1234. void intel_update_cdclk(struct drm_i915_private *dev_priv);
  1235. void intel_update_rawclk(struct drm_i915_private *dev_priv);
  1236. bool intel_cdclk_needs_modeset(const struct intel_cdclk_state *a,
  1237. const struct intel_cdclk_state *b);
  1238. bool intel_cdclk_changed(const struct intel_cdclk_state *a,
  1239. const struct intel_cdclk_state *b);
  1240. void intel_set_cdclk(struct drm_i915_private *dev_priv,
  1241. const struct intel_cdclk_state *cdclk_state);
  1242. void intel_dump_cdclk_state(const struct intel_cdclk_state *cdclk_state,
  1243. const char *context);
  1244. /* intel_display.c */
  1245. void i830_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe);
  1246. void i830_disable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe);
  1247. enum pipe intel_crtc_pch_transcoder(struct intel_crtc *crtc);
  1248. void intel_update_rawclk(struct drm_i915_private *dev_priv);
  1249. int vlv_get_hpll_vco(struct drm_i915_private *dev_priv);
  1250. int vlv_get_cck_clock(struct drm_i915_private *dev_priv,
  1251. const char *name, u32 reg, int ref_freq);
  1252. int vlv_get_cck_clock_hpll(struct drm_i915_private *dev_priv,
  1253. const char *name, u32 reg);
  1254. void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv);
  1255. void lpt_disable_iclkip(struct drm_i915_private *dev_priv);
  1256. void intel_init_display_hooks(struct drm_i915_private *dev_priv);
  1257. unsigned int intel_fb_xy_to_linear(int x, int y,
  1258. const struct intel_plane_state *state,
  1259. int plane);
  1260. void intel_add_fb_offsets(int *x, int *y,
  1261. const struct intel_plane_state *state, int plane);
  1262. unsigned int intel_rotation_info_size(const struct intel_rotation_info *rot_info);
  1263. bool intel_has_pending_fb_unpin(struct drm_i915_private *dev_priv);
  1264. void intel_mark_busy(struct drm_i915_private *dev_priv);
  1265. void intel_mark_idle(struct drm_i915_private *dev_priv);
  1266. int intel_display_suspend(struct drm_device *dev);
  1267. void intel_pps_unlock_regs_wa(struct drm_i915_private *dev_priv);
  1268. void intel_encoder_destroy(struct drm_encoder *encoder);
  1269. int intel_connector_init(struct intel_connector *);
  1270. struct intel_connector *intel_connector_alloc(void);
  1271. void intel_connector_free(struct intel_connector *connector);
  1272. bool intel_connector_get_hw_state(struct intel_connector *connector);
  1273. void intel_connector_attach_encoder(struct intel_connector *connector,
  1274. struct intel_encoder *encoder);
  1275. struct drm_display_mode *
  1276. intel_encoder_current_mode(struct intel_encoder *encoder);
  1277. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  1278. int intel_get_pipe_from_crtc_id_ioctl(struct drm_device *dev, void *data,
  1279. struct drm_file *file_priv);
  1280. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  1281. enum pipe pipe);
  1282. static inline bool
  1283. intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
  1284. enum intel_output_type type)
  1285. {
  1286. return crtc_state->output_types & (1 << type);
  1287. }
  1288. static inline bool
  1289. intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
  1290. {
  1291. return crtc_state->output_types &
  1292. ((1 << INTEL_OUTPUT_DP) |
  1293. (1 << INTEL_OUTPUT_DP_MST) |
  1294. (1 << INTEL_OUTPUT_EDP));
  1295. }
  1296. static inline void
  1297. intel_wait_for_vblank(struct drm_i915_private *dev_priv, enum pipe pipe)
  1298. {
  1299. drm_wait_one_vblank(&dev_priv->drm, pipe);
  1300. }
  1301. static inline void
  1302. intel_wait_for_vblank_if_active(struct drm_i915_private *dev_priv, int pipe)
  1303. {
  1304. const struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
  1305. if (crtc->active)
  1306. intel_wait_for_vblank(dev_priv, pipe);
  1307. }
  1308. u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc);
  1309. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  1310. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  1311. struct intel_digital_port *dport,
  1312. unsigned int expected_mask);
  1313. int intel_get_load_detect_pipe(struct drm_connector *connector,
  1314. const struct drm_display_mode *mode,
  1315. struct intel_load_detect_pipe *old,
  1316. struct drm_modeset_acquire_ctx *ctx);
  1317. void intel_release_load_detect_pipe(struct drm_connector *connector,
  1318. struct intel_load_detect_pipe *old,
  1319. struct drm_modeset_acquire_ctx *ctx);
  1320. struct i915_vma *
  1321. intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
  1322. unsigned int rotation,
  1323. bool uses_fence,
  1324. unsigned long *out_flags);
  1325. void intel_unpin_fb_vma(struct i915_vma *vma, unsigned long flags);
  1326. struct drm_framebuffer *
  1327. intel_framebuffer_create(struct drm_i915_gem_object *obj,
  1328. struct drm_mode_fb_cmd2 *mode_cmd);
  1329. int intel_prepare_plane_fb(struct drm_plane *plane,
  1330. struct drm_plane_state *new_state);
  1331. void intel_cleanup_plane_fb(struct drm_plane *plane,
  1332. struct drm_plane_state *old_state);
  1333. int intel_plane_atomic_get_property(struct drm_plane *plane,
  1334. const struct drm_plane_state *state,
  1335. struct drm_property *property,
  1336. uint64_t *val);
  1337. int intel_plane_atomic_set_property(struct drm_plane *plane,
  1338. struct drm_plane_state *state,
  1339. struct drm_property *property,
  1340. uint64_t val);
  1341. int intel_plane_atomic_calc_changes(const struct intel_crtc_state *old_crtc_state,
  1342. struct drm_crtc_state *crtc_state,
  1343. const struct intel_plane_state *old_plane_state,
  1344. struct drm_plane_state *plane_state);
  1345. void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
  1346. enum pipe pipe);
  1347. int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe,
  1348. const struct dpll *dpll);
  1349. void vlv_force_pll_off(struct drm_i915_private *dev_priv, enum pipe pipe);
  1350. int lpt_get_iclkip(struct drm_i915_private *dev_priv);
  1351. /* modesetting asserts */
  1352. void assert_panel_unlocked(struct drm_i915_private *dev_priv,
  1353. enum pipe pipe);
  1354. void assert_pll(struct drm_i915_private *dev_priv,
  1355. enum pipe pipe, bool state);
  1356. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  1357. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  1358. void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state);
  1359. #define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true)
  1360. #define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false)
  1361. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  1362. enum pipe pipe, bool state);
  1363. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  1364. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  1365. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  1366. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  1367. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  1368. u32 intel_compute_tile_offset(int *x, int *y,
  1369. const struct intel_plane_state *state, int plane);
  1370. void intel_prepare_reset(struct drm_i915_private *dev_priv);
  1371. void intel_finish_reset(struct drm_i915_private *dev_priv);
  1372. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  1373. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  1374. void gen9_sanitize_dc_state(struct drm_i915_private *dev_priv);
  1375. void bxt_enable_dc9(struct drm_i915_private *dev_priv);
  1376. void bxt_disable_dc9(struct drm_i915_private *dev_priv);
  1377. void gen9_enable_dc5(struct drm_i915_private *dev_priv);
  1378. unsigned int skl_cdclk_get_vco(unsigned int freq);
  1379. void skl_enable_dc6(struct drm_i915_private *dev_priv);
  1380. void skl_disable_dc6(struct drm_i915_private *dev_priv);
  1381. void intel_dp_get_m_n(struct intel_crtc *crtc,
  1382. struct intel_crtc_state *pipe_config);
  1383. void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
  1384. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  1385. bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, int target_clock,
  1386. struct dpll *best_clock);
  1387. int chv_calc_dpll_params(int refclk, struct dpll *pll_clock);
  1388. bool intel_crtc_active(struct intel_crtc *crtc);
  1389. bool hsw_crtc_state_ips_capable(const struct intel_crtc_state *crtc_state);
  1390. void hsw_enable_ips(const struct intel_crtc_state *crtc_state);
  1391. void hsw_disable_ips(const struct intel_crtc_state *crtc_state);
  1392. enum intel_display_power_domain intel_port_to_power_domain(enum port port);
  1393. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  1394. struct intel_crtc_state *pipe_config);
  1395. int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
  1396. int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state,
  1397. uint32_t pixel_format);
  1398. static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state)
  1399. {
  1400. return i915_ggtt_offset(state->vma);
  1401. }
  1402. u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
  1403. const struct intel_plane_state *plane_state);
  1404. u32 skl_plane_ctl(const struct intel_crtc_state *crtc_state,
  1405. const struct intel_plane_state *plane_state);
  1406. u32 glk_color_ctl(const struct intel_plane_state *plane_state);
  1407. u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
  1408. unsigned int rotation);
  1409. int skl_check_plane_surface(const struct intel_crtc_state *crtc_state,
  1410. struct intel_plane_state *plane_state);
  1411. int i9xx_check_plane_surface(struct intel_plane_state *plane_state);
  1412. int skl_format_to_fourcc(int format, bool rgb_order, bool alpha);
  1413. /* intel_csr.c */
  1414. void intel_csr_ucode_init(struct drm_i915_private *);
  1415. void intel_csr_load_program(struct drm_i915_private *);
  1416. void intel_csr_ucode_fini(struct drm_i915_private *);
  1417. void intel_csr_ucode_suspend(struct drm_i915_private *);
  1418. void intel_csr_ucode_resume(struct drm_i915_private *);
  1419. /* intel_dp.c */
  1420. bool intel_dp_init(struct drm_i915_private *dev_priv, i915_reg_t output_reg,
  1421. enum port port);
  1422. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  1423. struct intel_connector *intel_connector);
  1424. void intel_dp_set_link_params(struct intel_dp *intel_dp,
  1425. int link_rate, uint8_t lane_count,
  1426. bool link_mst);
  1427. int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
  1428. int link_rate, uint8_t lane_count);
  1429. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  1430. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  1431. int intel_dp_retrain_link(struct intel_encoder *encoder,
  1432. struct drm_modeset_acquire_ctx *ctx);
  1433. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  1434. void intel_dp_encoder_reset(struct drm_encoder *encoder);
  1435. void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder);
  1436. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  1437. int intel_dp_sink_crc(struct intel_dp *intel_dp,
  1438. struct intel_crtc_state *crtc_state, u8 *crc);
  1439. bool intel_dp_compute_config(struct intel_encoder *encoder,
  1440. struct intel_crtc_state *pipe_config,
  1441. struct drm_connector_state *conn_state);
  1442. bool intel_dp_is_edp(struct intel_dp *intel_dp);
  1443. bool intel_dp_is_port_edp(struct drm_i915_private *dev_priv, enum port port);
  1444. enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
  1445. bool long_hpd);
  1446. void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state,
  1447. const struct drm_connector_state *conn_state);
  1448. void intel_edp_backlight_off(const struct drm_connector_state *conn_state);
  1449. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  1450. void intel_edp_panel_on(struct intel_dp *intel_dp);
  1451. void intel_edp_panel_off(struct intel_dp *intel_dp);
  1452. void intel_dp_mst_suspend(struct drm_device *dev);
  1453. void intel_dp_mst_resume(struct drm_device *dev);
  1454. int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  1455. int intel_dp_max_lane_count(struct intel_dp *intel_dp);
  1456. int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
  1457. void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
  1458. void intel_power_sequencer_reset(struct drm_i915_private *dev_priv);
  1459. uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
  1460. void intel_plane_destroy(struct drm_plane *plane);
  1461. void intel_edp_drrs_enable(struct intel_dp *intel_dp,
  1462. const struct intel_crtc_state *crtc_state);
  1463. void intel_edp_drrs_disable(struct intel_dp *intel_dp,
  1464. const struct intel_crtc_state *crtc_state);
  1465. void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv,
  1466. unsigned int frontbuffer_bits);
  1467. void intel_edp_drrs_flush(struct drm_i915_private *dev_priv,
  1468. unsigned int frontbuffer_bits);
  1469. void
  1470. intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
  1471. uint8_t dp_train_pat);
  1472. void
  1473. intel_dp_set_signal_levels(struct intel_dp *intel_dp);
  1474. void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
  1475. uint8_t
  1476. intel_dp_voltage_max(struct intel_dp *intel_dp);
  1477. uint8_t
  1478. intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing);
  1479. void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
  1480. uint8_t *link_bw, uint8_t *rate_select);
  1481. bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
  1482. bool
  1483. intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]);
  1484. static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
  1485. {
  1486. return ~((1 << lane_count) - 1) & 0xf;
  1487. }
  1488. bool intel_dp_read_dpcd(struct intel_dp *intel_dp);
  1489. int intel_dp_link_required(int pixel_clock, int bpp);
  1490. int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
  1491. bool intel_digital_port_connected(struct intel_encoder *encoder);
  1492. /* intel_dp_aux_backlight.c */
  1493. int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
  1494. /* intel_dp_mst.c */
  1495. int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  1496. void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
  1497. /* intel_dsi.c */
  1498. void intel_dsi_init(struct drm_i915_private *dev_priv);
  1499. /* intel_dsi_dcs_backlight.c */
  1500. int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector);
  1501. /* intel_dvo.c */
  1502. void intel_dvo_init(struct drm_i915_private *dev_priv);
  1503. /* intel_hotplug.c */
  1504. void intel_hpd_poll_init(struct drm_i915_private *dev_priv);
  1505. bool intel_encoder_hotplug(struct intel_encoder *encoder,
  1506. struct intel_connector *connector);
  1507. /* legacy fbdev emulation in intel_fbdev.c */
  1508. #ifdef CONFIG_DRM_FBDEV_EMULATION
  1509. extern int intel_fbdev_init(struct drm_device *dev);
  1510. extern void intel_fbdev_initial_config_async(struct drm_device *dev);
  1511. extern void intel_fbdev_unregister(struct drm_i915_private *dev_priv);
  1512. extern void intel_fbdev_fini(struct drm_i915_private *dev_priv);
  1513. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
  1514. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  1515. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  1516. #else
  1517. static inline int intel_fbdev_init(struct drm_device *dev)
  1518. {
  1519. return 0;
  1520. }
  1521. static inline void intel_fbdev_initial_config_async(struct drm_device *dev)
  1522. {
  1523. }
  1524. static inline void intel_fbdev_unregister(struct drm_i915_private *dev_priv)
  1525. {
  1526. }
  1527. static inline void intel_fbdev_fini(struct drm_i915_private *dev_priv)
  1528. {
  1529. }
  1530. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
  1531. {
  1532. }
  1533. static inline void intel_fbdev_output_poll_changed(struct drm_device *dev)
  1534. {
  1535. }
  1536. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  1537. {
  1538. }
  1539. #endif
  1540. /* intel_fbc.c */
  1541. void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
  1542. struct intel_atomic_state *state);
  1543. bool intel_fbc_is_active(struct drm_i915_private *dev_priv);
  1544. void intel_fbc_pre_update(struct intel_crtc *crtc,
  1545. struct intel_crtc_state *crtc_state,
  1546. struct intel_plane_state *plane_state);
  1547. void intel_fbc_post_update(struct intel_crtc *crtc);
  1548. void intel_fbc_init(struct drm_i915_private *dev_priv);
  1549. void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv);
  1550. void intel_fbc_enable(struct intel_crtc *crtc,
  1551. struct intel_crtc_state *crtc_state,
  1552. struct intel_plane_state *plane_state);
  1553. void intel_fbc_disable(struct intel_crtc *crtc);
  1554. void intel_fbc_global_disable(struct drm_i915_private *dev_priv);
  1555. void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
  1556. unsigned int frontbuffer_bits,
  1557. enum fb_op_origin origin);
  1558. void intel_fbc_flush(struct drm_i915_private *dev_priv,
  1559. unsigned int frontbuffer_bits, enum fb_op_origin origin);
  1560. void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv);
  1561. void intel_fbc_handle_fifo_underrun_irq(struct drm_i915_private *dev_priv);
  1562. /* intel_hdmi.c */
  1563. void intel_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg,
  1564. enum port port);
  1565. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  1566. struct intel_connector *intel_connector);
  1567. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  1568. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  1569. struct intel_crtc_state *pipe_config,
  1570. struct drm_connector_state *conn_state);
  1571. bool intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder,
  1572. struct drm_connector *connector,
  1573. bool high_tmds_clock_ratio,
  1574. bool scrambling);
  1575. void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
  1576. void intel_infoframe_init(struct intel_digital_port *intel_dig_port);
  1577. /* intel_lvds.c */
  1578. void intel_lvds_init(struct drm_i915_private *dev_priv);
  1579. struct intel_encoder *intel_get_lvds_encoder(struct drm_device *dev);
  1580. bool intel_is_dual_link_lvds(struct drm_device *dev);
  1581. /* intel_modes.c */
  1582. int intel_connector_update_modes(struct drm_connector *connector,
  1583. struct edid *edid);
  1584. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  1585. void intel_attach_force_audio_property(struct drm_connector *connector);
  1586. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  1587. void intel_attach_aspect_ratio_property(struct drm_connector *connector);
  1588. /* intel_overlay.c */
  1589. void intel_setup_overlay(struct drm_i915_private *dev_priv);
  1590. void intel_cleanup_overlay(struct drm_i915_private *dev_priv);
  1591. int intel_overlay_switch_off(struct intel_overlay *overlay);
  1592. int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
  1593. struct drm_file *file_priv);
  1594. int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data,
  1595. struct drm_file *file_priv);
  1596. void intel_overlay_reset(struct drm_i915_private *dev_priv);
  1597. /* intel_panel.c */
  1598. int intel_panel_init(struct intel_panel *panel,
  1599. struct drm_display_mode *fixed_mode,
  1600. struct drm_display_mode *alt_fixed_mode,
  1601. struct drm_display_mode *downclock_mode);
  1602. void intel_panel_fini(struct intel_panel *panel);
  1603. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  1604. struct drm_display_mode *adjusted_mode);
  1605. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  1606. struct intel_crtc_state *pipe_config,
  1607. int fitting_mode);
  1608. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  1609. struct intel_crtc_state *pipe_config,
  1610. int fitting_mode);
  1611. void intel_panel_set_backlight_acpi(const struct drm_connector_state *conn_state,
  1612. u32 level, u32 max);
  1613. int intel_panel_setup_backlight(struct drm_connector *connector,
  1614. enum pipe pipe);
  1615. void intel_panel_enable_backlight(const struct intel_crtc_state *crtc_state,
  1616. const struct drm_connector_state *conn_state);
  1617. void intel_panel_disable_backlight(const struct drm_connector_state *old_conn_state);
  1618. void intel_panel_destroy_backlight(struct drm_connector *connector);
  1619. enum drm_connector_status intel_panel_detect(struct drm_i915_private *dev_priv);
  1620. extern struct drm_display_mode *intel_find_panel_downclock(
  1621. struct drm_i915_private *dev_priv,
  1622. struct drm_display_mode *fixed_mode,
  1623. struct drm_connector *connector);
  1624. #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
  1625. int intel_backlight_device_register(struct intel_connector *connector);
  1626. void intel_backlight_device_unregister(struct intel_connector *connector);
  1627. #else /* CONFIG_BACKLIGHT_CLASS_DEVICE */
  1628. static inline int intel_backlight_device_register(struct intel_connector *connector)
  1629. {
  1630. return 0;
  1631. }
  1632. static inline void intel_backlight_device_unregister(struct intel_connector *connector)
  1633. {
  1634. }
  1635. #endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
  1636. /* intel_hdcp.c */
  1637. void intel_hdcp_atomic_check(struct drm_connector *connector,
  1638. struct drm_connector_state *old_state,
  1639. struct drm_connector_state *new_state);
  1640. int intel_hdcp_init(struct intel_connector *connector,
  1641. const struct intel_hdcp_shim *hdcp_shim);
  1642. int intel_hdcp_enable(struct intel_connector *connector);
  1643. int intel_hdcp_disable(struct intel_connector *connector);
  1644. int intel_hdcp_check_link(struct intel_connector *connector);
  1645. bool is_hdcp_supported(struct drm_i915_private *dev_priv, enum port port);
  1646. /* intel_psr.c */
  1647. #define CAN_PSR(dev_priv) (HAS_PSR(dev_priv) && dev_priv->psr.sink_support)
  1648. void intel_psr_init_dpcd(struct intel_dp *intel_dp);
  1649. void intel_psr_enable(struct intel_dp *intel_dp,
  1650. const struct intel_crtc_state *crtc_state);
  1651. void intel_psr_disable(struct intel_dp *intel_dp,
  1652. const struct intel_crtc_state *old_crtc_state);
  1653. void intel_psr_invalidate(struct drm_i915_private *dev_priv,
  1654. unsigned frontbuffer_bits,
  1655. enum fb_op_origin origin);
  1656. void intel_psr_flush(struct drm_i915_private *dev_priv,
  1657. unsigned frontbuffer_bits,
  1658. enum fb_op_origin origin);
  1659. void intel_psr_init(struct drm_i915_private *dev_priv);
  1660. void intel_psr_single_frame_update(struct drm_i915_private *dev_priv,
  1661. unsigned frontbuffer_bits);
  1662. void intel_psr_compute_config(struct intel_dp *intel_dp,
  1663. struct intel_crtc_state *crtc_state);
  1664. /* intel_runtime_pm.c */
  1665. int intel_power_domains_init(struct drm_i915_private *);
  1666. void intel_power_domains_fini(struct drm_i915_private *);
  1667. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume);
  1668. void intel_power_domains_suspend(struct drm_i915_private *dev_priv);
  1669. void intel_power_domains_verify_state(struct drm_i915_private *dev_priv);
  1670. void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume);
  1671. void bxt_display_core_uninit(struct drm_i915_private *dev_priv);
  1672. void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
  1673. const char *
  1674. intel_display_power_domain_str(enum intel_display_power_domain domain);
  1675. bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1676. enum intel_display_power_domain domain);
  1677. bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1678. enum intel_display_power_domain domain);
  1679. void intel_display_power_get(struct drm_i915_private *dev_priv,
  1680. enum intel_display_power_domain domain);
  1681. bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv,
  1682. enum intel_display_power_domain domain);
  1683. void intel_display_power_put(struct drm_i915_private *dev_priv,
  1684. enum intel_display_power_domain domain);
  1685. static inline void
  1686. assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv)
  1687. {
  1688. WARN_ONCE(dev_priv->runtime_pm.suspended,
  1689. "Device suspended during HW access\n");
  1690. }
  1691. static inline void
  1692. assert_rpm_wakelock_held(struct drm_i915_private *dev_priv)
  1693. {
  1694. assert_rpm_device_not_suspended(dev_priv);
  1695. WARN_ONCE(!atomic_read(&dev_priv->runtime_pm.wakeref_count),
  1696. "RPM wakelock ref not held during HW access");
  1697. }
  1698. /**
  1699. * disable_rpm_wakeref_asserts - disable the RPM assert checks
  1700. * @dev_priv: i915 device instance
  1701. *
  1702. * This function disable asserts that check if we hold an RPM wakelock
  1703. * reference, while keeping the device-not-suspended checks still enabled.
  1704. * It's meant to be used only in special circumstances where our rule about
  1705. * the wakelock refcount wrt. the device power state doesn't hold. According
  1706. * to this rule at any point where we access the HW or want to keep the HW in
  1707. * an active state we must hold an RPM wakelock reference acquired via one of
  1708. * the intel_runtime_pm_get() helpers. Currently there are a few special spots
  1709. * where this rule doesn't hold: the IRQ and suspend/resume handlers, the
  1710. * forcewake release timer, and the GPU RPS and hangcheck works. All other
  1711. * users should avoid using this function.
  1712. *
  1713. * Any calls to this function must have a symmetric call to
  1714. * enable_rpm_wakeref_asserts().
  1715. */
  1716. static inline void
  1717. disable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1718. {
  1719. atomic_inc(&dev_priv->runtime_pm.wakeref_count);
  1720. }
  1721. /**
  1722. * enable_rpm_wakeref_asserts - re-enable the RPM assert checks
  1723. * @dev_priv: i915 device instance
  1724. *
  1725. * This function re-enables the RPM assert checks after disabling them with
  1726. * disable_rpm_wakeref_asserts. It's meant to be used only in special
  1727. * circumstances otherwise its use should be avoided.
  1728. *
  1729. * Any calls to this function must have a symmetric call to
  1730. * disable_rpm_wakeref_asserts().
  1731. */
  1732. static inline void
  1733. enable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1734. {
  1735. atomic_dec(&dev_priv->runtime_pm.wakeref_count);
  1736. }
  1737. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  1738. bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv);
  1739. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  1740. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  1741. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  1742. void chv_phy_powergate_lanes(struct intel_encoder *encoder,
  1743. bool override, unsigned int mask);
  1744. bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy,
  1745. enum dpio_channel ch, bool override);
  1746. /* intel_pm.c */
  1747. void intel_init_clock_gating(struct drm_i915_private *dev_priv);
  1748. void intel_suspend_hw(struct drm_i915_private *dev_priv);
  1749. int ilk_wm_max_level(const struct drm_i915_private *dev_priv);
  1750. void intel_update_watermarks(struct intel_crtc *crtc);
  1751. void intel_init_pm(struct drm_i915_private *dev_priv);
  1752. void intel_init_clock_gating_hooks(struct drm_i915_private *dev_priv);
  1753. void intel_pm_setup(struct drm_i915_private *dev_priv);
  1754. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  1755. void intel_gpu_ips_teardown(void);
  1756. void intel_init_gt_powersave(struct drm_i915_private *dev_priv);
  1757. void intel_cleanup_gt_powersave(struct drm_i915_private *dev_priv);
  1758. void intel_sanitize_gt_powersave(struct drm_i915_private *dev_priv);
  1759. void intel_enable_gt_powersave(struct drm_i915_private *dev_priv);
  1760. void intel_disable_gt_powersave(struct drm_i915_private *dev_priv);
  1761. void intel_suspend_gt_powersave(struct drm_i915_private *dev_priv);
  1762. void gen6_rps_busy(struct drm_i915_private *dev_priv);
  1763. void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
  1764. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  1765. void gen6_rps_boost(struct i915_request *rq, struct intel_rps_client *rps);
  1766. void g4x_wm_get_hw_state(struct drm_device *dev);
  1767. void vlv_wm_get_hw_state(struct drm_device *dev);
  1768. void ilk_wm_get_hw_state(struct drm_device *dev);
  1769. void skl_wm_get_hw_state(struct drm_device *dev);
  1770. void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  1771. struct skl_ddb_allocation *ddb /* out */);
  1772. void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc,
  1773. struct skl_pipe_wm *out);
  1774. void g4x_wm_sanitize(struct drm_i915_private *dev_priv);
  1775. void vlv_wm_sanitize(struct drm_i915_private *dev_priv);
  1776. bool intel_can_enable_sagv(struct drm_atomic_state *state);
  1777. int intel_enable_sagv(struct drm_i915_private *dev_priv);
  1778. int intel_disable_sagv(struct drm_i915_private *dev_priv);
  1779. bool skl_wm_level_equals(const struct skl_wm_level *l1,
  1780. const struct skl_wm_level *l2);
  1781. bool skl_ddb_allocation_overlaps(struct drm_i915_private *dev_priv,
  1782. const struct skl_ddb_entry **entries,
  1783. const struct skl_ddb_entry *ddb,
  1784. int ignore);
  1785. bool ilk_disable_lp_wm(struct drm_device *dev);
  1786. int skl_check_pipe_max_pixel_rate(struct intel_crtc *intel_crtc,
  1787. struct intel_crtc_state *cstate);
  1788. void intel_init_ipc(struct drm_i915_private *dev_priv);
  1789. void intel_enable_ipc(struct drm_i915_private *dev_priv);
  1790. /* intel_sdvo.c */
  1791. bool intel_sdvo_init(struct drm_i915_private *dev_priv,
  1792. i915_reg_t reg, enum port port);
  1793. /* intel_sprite.c */
  1794. bool intel_format_is_yuv(u32 format);
  1795. int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
  1796. int usecs);
  1797. struct intel_plane *intel_sprite_plane_create(struct drm_i915_private *dev_priv,
  1798. enum pipe pipe, int plane);
  1799. int intel_sprite_set_colorkey_ioctl(struct drm_device *dev, void *data,
  1800. struct drm_file *file_priv);
  1801. void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state);
  1802. void intel_pipe_update_end(struct intel_crtc_state *new_crtc_state);
  1803. void skl_update_plane(struct intel_plane *plane,
  1804. const struct intel_crtc_state *crtc_state,
  1805. const struct intel_plane_state *plane_state);
  1806. void skl_disable_plane(struct intel_plane *plane, struct intel_crtc *crtc);
  1807. bool skl_plane_get_hw_state(struct intel_plane *plane);
  1808. bool skl_plane_has_ccs(struct drm_i915_private *dev_priv,
  1809. enum pipe pipe, enum plane_id plane_id);
  1810. bool intel_format_is_yuv(uint32_t format);
  1811. /* intel_tv.c */
  1812. void intel_tv_init(struct drm_i915_private *dev_priv);
  1813. /* intel_atomic.c */
  1814. int intel_digital_connector_atomic_get_property(struct drm_connector *connector,
  1815. const struct drm_connector_state *state,
  1816. struct drm_property *property,
  1817. uint64_t *val);
  1818. int intel_digital_connector_atomic_set_property(struct drm_connector *connector,
  1819. struct drm_connector_state *state,
  1820. struct drm_property *property,
  1821. uint64_t val);
  1822. int intel_digital_connector_atomic_check(struct drm_connector *conn,
  1823. struct drm_connector_state *new_state);
  1824. struct drm_connector_state *
  1825. intel_digital_connector_duplicate_state(struct drm_connector *connector);
  1826. struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
  1827. void intel_crtc_destroy_state(struct drm_crtc *crtc,
  1828. struct drm_crtc_state *state);
  1829. struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
  1830. void intel_atomic_state_clear(struct drm_atomic_state *);
  1831. static inline struct intel_crtc_state *
  1832. intel_atomic_get_crtc_state(struct drm_atomic_state *state,
  1833. struct intel_crtc *crtc)
  1834. {
  1835. struct drm_crtc_state *crtc_state;
  1836. crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
  1837. if (IS_ERR(crtc_state))
  1838. return ERR_CAST(crtc_state);
  1839. return to_intel_crtc_state(crtc_state);
  1840. }
  1841. static inline struct intel_crtc_state *
  1842. intel_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
  1843. struct intel_crtc *crtc)
  1844. {
  1845. struct drm_crtc_state *crtc_state;
  1846. crtc_state = drm_atomic_get_existing_crtc_state(state, &crtc->base);
  1847. if (crtc_state)
  1848. return to_intel_crtc_state(crtc_state);
  1849. else
  1850. return NULL;
  1851. }
  1852. static inline struct intel_plane_state *
  1853. intel_atomic_get_existing_plane_state(struct drm_atomic_state *state,
  1854. struct intel_plane *plane)
  1855. {
  1856. struct drm_plane_state *plane_state;
  1857. plane_state = drm_atomic_get_existing_plane_state(state, &plane->base);
  1858. return to_intel_plane_state(plane_state);
  1859. }
  1860. int intel_atomic_setup_scalers(struct drm_i915_private *dev_priv,
  1861. struct intel_crtc *intel_crtc,
  1862. struct intel_crtc_state *crtc_state);
  1863. /* intel_atomic_plane.c */
  1864. struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
  1865. struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
  1866. void intel_plane_destroy_state(struct drm_plane *plane,
  1867. struct drm_plane_state *state);
  1868. extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
  1869. int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_state,
  1870. struct intel_crtc_state *crtc_state,
  1871. const struct intel_plane_state *old_plane_state,
  1872. struct intel_plane_state *intel_state);
  1873. /* intel_color.c */
  1874. void intel_color_init(struct drm_crtc *crtc);
  1875. int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
  1876. void intel_color_set_csc(struct drm_crtc_state *crtc_state);
  1877. void intel_color_load_luts(struct drm_crtc_state *crtc_state);
  1878. /* intel_lspcon.c */
  1879. bool lspcon_init(struct intel_digital_port *intel_dig_port);
  1880. void lspcon_resume(struct intel_lspcon *lspcon);
  1881. void lspcon_wait_pcon_mode(struct intel_lspcon *lspcon);
  1882. /* intel_pipe_crc.c */
  1883. int intel_pipe_crc_create(struct drm_minor *minor);
  1884. #ifdef CONFIG_DEBUG_FS
  1885. int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
  1886. size_t *values_cnt);
  1887. void intel_crtc_disable_pipe_crc(struct intel_crtc *crtc);
  1888. void intel_crtc_enable_pipe_crc(struct intel_crtc *crtc);
  1889. #else
  1890. #define intel_crtc_set_crc_source NULL
  1891. static inline void intel_crtc_disable_pipe_crc(struct intel_crtc *crtc)
  1892. {
  1893. }
  1894. static inline void intel_crtc_enable_pipe_crc(struct intel_crtc *crtc)
  1895. {
  1896. }
  1897. #endif
  1898. extern const struct file_operations i915_display_crc_ctl_fops;
  1899. #endif /* __INTEL_DRV_H__ */