intel_drv.h 73 KB

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