intel_drv.h 72 KB

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