intel_drv.h 73 KB

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