intel_drv.h 75 KB

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