intel_drv.h 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895
  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 <drm/i915_drm.h>
  31. #include "i915_drv.h"
  32. #include <drm/drm_crtc.h>
  33. #include <drm/drm_crtc_helper.h>
  34. #include <drm/drm_encoder.h>
  35. #include <drm/drm_fb_helper.h>
  36. #include <drm/drm_dp_dual_mode_helper.h>
  37. #include <drm/drm_dp_mst_helper.h>
  38. #include <drm/drm_rect.h>
  39. #include <drm/drm_atomic.h>
  40. /**
  41. * _wait_for - magic (register) wait macro
  42. *
  43. * Does the right thing for modeset paths when run under kdgb or similar atomic
  44. * contexts. Note that it's important that we check the condition again after
  45. * having timed out, since the timeout could be due to preemption or similar and
  46. * we've never had a chance to check the condition before the timeout.
  47. *
  48. * TODO: When modesetting has fully transitioned to atomic, the below
  49. * drm_can_sleep() can be removed and in_atomic()/!in_atomic() asserts
  50. * added.
  51. */
  52. #define _wait_for(COND, US, W) ({ \
  53. unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \
  54. int ret__; \
  55. for (;;) { \
  56. bool expired__ = time_after(jiffies, timeout__); \
  57. if (COND) { \
  58. ret__ = 0; \
  59. break; \
  60. } \
  61. if (expired__) { \
  62. ret__ = -ETIMEDOUT; \
  63. break; \
  64. } \
  65. if ((W) && drm_can_sleep()) { \
  66. usleep_range((W), (W)*2); \
  67. } else { \
  68. cpu_relax(); \
  69. } \
  70. } \
  71. ret__; \
  72. })
  73. #define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 1000)
  74. /* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */
  75. #if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT)
  76. # define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) WARN_ON_ONCE((ATOMIC) && !in_atomic())
  77. #else
  78. # define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) do { } while (0)
  79. #endif
  80. #define _wait_for_atomic(COND, US, ATOMIC) \
  81. ({ \
  82. int cpu, ret, timeout = (US) * 1000; \
  83. u64 base; \
  84. _WAIT_FOR_ATOMIC_CHECK(ATOMIC); \
  85. BUILD_BUG_ON((US) > 50000); \
  86. if (!(ATOMIC)) { \
  87. preempt_disable(); \
  88. cpu = smp_processor_id(); \
  89. } \
  90. base = local_clock(); \
  91. for (;;) { \
  92. u64 now = local_clock(); \
  93. if (!(ATOMIC)) \
  94. preempt_enable(); \
  95. if (COND) { \
  96. ret = 0; \
  97. break; \
  98. } \
  99. if (now - base >= timeout) { \
  100. ret = -ETIMEDOUT; \
  101. break; \
  102. } \
  103. cpu_relax(); \
  104. if (!(ATOMIC)) { \
  105. preempt_disable(); \
  106. if (unlikely(cpu != smp_processor_id())) { \
  107. timeout -= now - base; \
  108. cpu = smp_processor_id(); \
  109. base = local_clock(); \
  110. } \
  111. } \
  112. } \
  113. ret; \
  114. })
  115. #define wait_for_us(COND, US) \
  116. ({ \
  117. int ret__; \
  118. BUILD_BUG_ON(!__builtin_constant_p(US)); \
  119. if ((US) > 10) \
  120. ret__ = _wait_for((COND), (US), 10); \
  121. else \
  122. ret__ = _wait_for_atomic((COND), (US), 0); \
  123. ret__; \
  124. })
  125. #define wait_for_atomic(COND, MS) _wait_for_atomic((COND), (MS) * 1000, 1)
  126. #define wait_for_atomic_us(COND, US) _wait_for_atomic((COND), (US), 1)
  127. #define KHz(x) (1000 * (x))
  128. #define MHz(x) KHz(1000 * (x))
  129. /*
  130. * Display related stuff
  131. */
  132. /* store information about an Ixxx DVO */
  133. /* The i830->i865 use multiple DVOs with multiple i2cs */
  134. /* the i915, i945 have a single sDVO i2c bus - which is different */
  135. #define MAX_OUTPUTS 6
  136. /* maximum connectors per crtcs in the mode set */
  137. /* Maximum cursor sizes */
  138. #define GEN2_CURSOR_WIDTH 64
  139. #define GEN2_CURSOR_HEIGHT 64
  140. #define MAX_CURSOR_WIDTH 256
  141. #define MAX_CURSOR_HEIGHT 256
  142. #define INTEL_I2C_BUS_DVO 1
  143. #define INTEL_I2C_BUS_SDVO 2
  144. /* these are outputs from the chip - integrated only
  145. external chips are via DVO or SDVO output */
  146. enum intel_output_type {
  147. INTEL_OUTPUT_UNUSED = 0,
  148. INTEL_OUTPUT_ANALOG = 1,
  149. INTEL_OUTPUT_DVO = 2,
  150. INTEL_OUTPUT_SDVO = 3,
  151. INTEL_OUTPUT_LVDS = 4,
  152. INTEL_OUTPUT_TVOUT = 5,
  153. INTEL_OUTPUT_HDMI = 6,
  154. INTEL_OUTPUT_DP = 7,
  155. INTEL_OUTPUT_EDP = 8,
  156. INTEL_OUTPUT_DSI = 9,
  157. INTEL_OUTPUT_UNKNOWN = 10,
  158. INTEL_OUTPUT_DP_MST = 11,
  159. };
  160. #define INTEL_DVO_CHIP_NONE 0
  161. #define INTEL_DVO_CHIP_LVDS 1
  162. #define INTEL_DVO_CHIP_TMDS 2
  163. #define INTEL_DVO_CHIP_TVOUT 4
  164. #define INTEL_DSI_VIDEO_MODE 0
  165. #define INTEL_DSI_COMMAND_MODE 1
  166. struct intel_framebuffer {
  167. struct drm_framebuffer base;
  168. struct drm_i915_gem_object *obj;
  169. struct intel_rotation_info rot_info;
  170. /* for each plane in the normal GTT view */
  171. struct {
  172. unsigned int x, y;
  173. } normal[2];
  174. /* for each plane in the rotated GTT view */
  175. struct {
  176. unsigned int x, y;
  177. unsigned int pitch; /* pixels */
  178. } rotated[2];
  179. };
  180. struct intel_fbdev {
  181. struct drm_fb_helper helper;
  182. struct intel_framebuffer *fb;
  183. struct i915_vma *vma;
  184. async_cookie_t cookie;
  185. int preferred_bpp;
  186. };
  187. struct intel_encoder {
  188. struct drm_encoder base;
  189. enum intel_output_type type;
  190. enum port port;
  191. unsigned int cloneable;
  192. void (*hot_plug)(struct intel_encoder *);
  193. bool (*compute_config)(struct intel_encoder *,
  194. struct intel_crtc_state *,
  195. struct drm_connector_state *);
  196. void (*pre_pll_enable)(struct intel_encoder *,
  197. struct intel_crtc_state *,
  198. struct drm_connector_state *);
  199. void (*pre_enable)(struct intel_encoder *,
  200. struct intel_crtc_state *,
  201. struct drm_connector_state *);
  202. void (*enable)(struct intel_encoder *,
  203. struct intel_crtc_state *,
  204. struct drm_connector_state *);
  205. void (*disable)(struct intel_encoder *,
  206. struct intel_crtc_state *,
  207. struct drm_connector_state *);
  208. void (*post_disable)(struct intel_encoder *,
  209. struct intel_crtc_state *,
  210. struct drm_connector_state *);
  211. void (*post_pll_disable)(struct intel_encoder *,
  212. struct intel_crtc_state *,
  213. struct drm_connector_state *);
  214. /* Read out the current hw state of this connector, returning true if
  215. * the encoder is active. If the encoder is enabled it also set the pipe
  216. * it is connected to in the pipe parameter. */
  217. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  218. /* Reconstructs the equivalent mode flags for the current hardware
  219. * state. This must be called _after_ display->get_pipe_config has
  220. * pre-filled the pipe config. Note that intel_encoder->base.crtc must
  221. * be set correctly before calling this function. */
  222. void (*get_config)(struct intel_encoder *,
  223. struct intel_crtc_state *pipe_config);
  224. /*
  225. * Called during system suspend after all pending requests for the
  226. * encoder are flushed (for example for DP AUX transactions) and
  227. * device interrupts are disabled.
  228. */
  229. void (*suspend)(struct intel_encoder *);
  230. int crtc_mask;
  231. enum hpd_pin hpd_pin;
  232. /* for communication with audio component; protected by av_mutex */
  233. const struct drm_connector *audio_connector;
  234. };
  235. struct intel_panel {
  236. struct drm_display_mode *fixed_mode;
  237. struct drm_display_mode *downclock_mode;
  238. int fitting_mode;
  239. /* backlight */
  240. struct {
  241. bool present;
  242. u32 level;
  243. u32 min;
  244. u32 max;
  245. bool enabled;
  246. bool combination_mode; /* gen 2/4 only */
  247. bool active_low_pwm;
  248. bool alternate_pwm_increment; /* lpt+ */
  249. /* PWM chip */
  250. bool util_pin_active_low; /* bxt+ */
  251. u8 controller; /* bxt+ only */
  252. struct pwm_device *pwm;
  253. struct backlight_device *device;
  254. /* Connector and platform specific backlight functions */
  255. int (*setup)(struct intel_connector *connector, enum pipe pipe);
  256. uint32_t (*get)(struct intel_connector *connector);
  257. void (*set)(struct intel_connector *connector, uint32_t level);
  258. void (*disable)(struct intel_connector *connector);
  259. void (*enable)(struct intel_connector *connector);
  260. uint32_t (*hz_to_pwm)(struct intel_connector *connector,
  261. uint32_t hz);
  262. void (*power)(struct intel_connector *, bool enable);
  263. } backlight;
  264. };
  265. struct intel_connector {
  266. struct drm_connector base;
  267. /*
  268. * The fixed encoder this connector is connected to.
  269. */
  270. struct intel_encoder *encoder;
  271. /* ACPI device id for ACPI and driver cooperation */
  272. u32 acpi_device_id;
  273. /* Reads out the current hw, returning true if the connector is enabled
  274. * and active (i.e. dpms ON state). */
  275. bool (*get_hw_state)(struct intel_connector *);
  276. /* Panel info for eDP and LVDS */
  277. struct intel_panel panel;
  278. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  279. struct edid *edid;
  280. struct edid *detect_edid;
  281. /* since POLL and HPD connectors may use the same HPD line keep the native
  282. state of connector->polled in case hotplug storm detection changes it */
  283. u8 polled;
  284. void *port; /* store this opaque as its illegal to dereference it */
  285. struct intel_dp *mst_port;
  286. };
  287. struct dpll {
  288. /* given values */
  289. int n;
  290. int m1, m2;
  291. int p1, p2;
  292. /* derived values */
  293. int dot;
  294. int vco;
  295. int m;
  296. int p;
  297. };
  298. struct intel_atomic_state {
  299. struct drm_atomic_state base;
  300. unsigned int cdclk;
  301. /*
  302. * Calculated device cdclk, can be different from cdclk
  303. * only when all crtc's are DPMS off.
  304. */
  305. unsigned int dev_cdclk;
  306. bool dpll_set, modeset;
  307. /*
  308. * Does this transaction change the pipes that are active? This mask
  309. * tracks which CRTC's have changed their active state at the end of
  310. * the transaction (not counting the temporary disable during modesets).
  311. * This mask should only be non-zero when intel_state->modeset is true,
  312. * but the converse is not necessarily true; simply changing a mode may
  313. * not flip the final active status of any CRTC's
  314. */
  315. unsigned int active_pipe_changes;
  316. unsigned int active_crtcs;
  317. unsigned int min_pixclk[I915_MAX_PIPES];
  318. /* SKL/KBL Only */
  319. unsigned int cdclk_pll_vco;
  320. struct intel_shared_dpll_state shared_dpll[I915_NUM_PLLS];
  321. /*
  322. * Current watermarks can't be trusted during hardware readout, so
  323. * don't bother calculating intermediate watermarks.
  324. */
  325. bool skip_intermediate_wm;
  326. /* Gen9+ only */
  327. struct skl_wm_values wm_results;
  328. struct i915_sw_fence commit_ready;
  329. };
  330. struct intel_plane_state {
  331. struct drm_plane_state base;
  332. struct drm_rect clip;
  333. struct i915_vma *vma;
  334. struct {
  335. u32 offset;
  336. int x, y;
  337. } main;
  338. struct {
  339. u32 offset;
  340. int x, y;
  341. } aux;
  342. /*
  343. * scaler_id
  344. * = -1 : not using a scaler
  345. * >= 0 : using a scalers
  346. *
  347. * plane requiring a scaler:
  348. * - During check_plane, its bit is set in
  349. * crtc_state->scaler_state.scaler_users by calling helper function
  350. * update_scaler_plane.
  351. * - scaler_id indicates the scaler it got assigned.
  352. *
  353. * plane doesn't require a scaler:
  354. * - this can happen when scaling is no more required or plane simply
  355. * got disabled.
  356. * - During check_plane, corresponding bit is reset in
  357. * crtc_state->scaler_state.scaler_users by calling helper function
  358. * update_scaler_plane.
  359. */
  360. int scaler_id;
  361. struct drm_intel_sprite_colorkey ckey;
  362. };
  363. struct intel_initial_plane_config {
  364. struct intel_framebuffer *fb;
  365. unsigned int tiling;
  366. int size;
  367. u32 base;
  368. };
  369. #define SKL_MIN_SRC_W 8
  370. #define SKL_MAX_SRC_W 4096
  371. #define SKL_MIN_SRC_H 8
  372. #define SKL_MAX_SRC_H 4096
  373. #define SKL_MIN_DST_W 8
  374. #define SKL_MAX_DST_W 4096
  375. #define SKL_MIN_DST_H 8
  376. #define SKL_MAX_DST_H 4096
  377. struct intel_scaler {
  378. int in_use;
  379. uint32_t mode;
  380. };
  381. struct intel_crtc_scaler_state {
  382. #define SKL_NUM_SCALERS 2
  383. struct intel_scaler scalers[SKL_NUM_SCALERS];
  384. /*
  385. * scaler_users: keeps track of users requesting scalers on this crtc.
  386. *
  387. * If a bit is set, a user is using a scaler.
  388. * Here user can be a plane or crtc as defined below:
  389. * bits 0-30 - plane (bit position is index from drm_plane_index)
  390. * bit 31 - crtc
  391. *
  392. * Instead of creating a new index to cover planes and crtc, using
  393. * existing drm_plane_index for planes which is well less than 31
  394. * planes and bit 31 for crtc. This should be fine to cover all
  395. * our platforms.
  396. *
  397. * intel_atomic_setup_scalers will setup available scalers to users
  398. * requesting scalers. It will gracefully fail if request exceeds
  399. * avilability.
  400. */
  401. #define SKL_CRTC_INDEX 31
  402. unsigned scaler_users;
  403. /* scaler used by crtc for panel fitting purpose */
  404. int scaler_id;
  405. };
  406. /* drm_mode->private_flags */
  407. #define I915_MODE_FLAG_INHERITED 1
  408. struct intel_pipe_wm {
  409. struct intel_wm_level wm[5];
  410. struct intel_wm_level raw_wm[5];
  411. uint32_t linetime;
  412. bool fbc_wm_enabled;
  413. bool pipe_enabled;
  414. bool sprites_enabled;
  415. bool sprites_scaled;
  416. };
  417. struct skl_plane_wm {
  418. struct skl_wm_level wm[8];
  419. struct skl_wm_level trans_wm;
  420. };
  421. struct skl_pipe_wm {
  422. struct skl_plane_wm planes[I915_MAX_PLANES];
  423. uint32_t linetime;
  424. };
  425. struct intel_crtc_wm_state {
  426. union {
  427. struct {
  428. /*
  429. * Intermediate watermarks; these can be
  430. * programmed immediately since they satisfy
  431. * both the current configuration we're
  432. * switching away from and the new
  433. * configuration we're switching to.
  434. */
  435. struct intel_pipe_wm intermediate;
  436. /*
  437. * Optimal watermarks, programmed post-vblank
  438. * when this state is committed.
  439. */
  440. struct intel_pipe_wm optimal;
  441. } ilk;
  442. struct {
  443. /* gen9+ only needs 1-step wm programming */
  444. struct skl_pipe_wm optimal;
  445. struct skl_ddb_entry ddb;
  446. } skl;
  447. };
  448. /*
  449. * Platforms with two-step watermark programming will need to
  450. * update watermark programming post-vblank to switch from the
  451. * safe intermediate watermarks to the optimal final
  452. * watermarks.
  453. */
  454. bool need_postvbl_update;
  455. };
  456. struct intel_crtc_state {
  457. struct drm_crtc_state base;
  458. /**
  459. * quirks - bitfield with hw state readout quirks
  460. *
  461. * For various reasons the hw state readout code might not be able to
  462. * completely faithfully read out the current state. These cases are
  463. * tracked with quirk flags so that fastboot and state checker can act
  464. * accordingly.
  465. */
  466. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  467. unsigned long quirks;
  468. unsigned fb_bits; /* framebuffers to flip */
  469. bool update_pipe; /* can a fast modeset be performed? */
  470. bool disable_cxsr;
  471. bool update_wm_pre, update_wm_post; /* watermarks are updated */
  472. bool fb_changed; /* fb on any of the planes is changed */
  473. /* Pipe source size (ie. panel fitter input size)
  474. * All planes will be positioned inside this space,
  475. * and get clipped at the edges. */
  476. int pipe_src_w, pipe_src_h;
  477. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  478. * between pch encoders and cpu encoders. */
  479. bool has_pch_encoder;
  480. /* Are we sending infoframes on the attached port */
  481. bool has_infoframe;
  482. /* CPU Transcoder for the pipe. Currently this can only differ from the
  483. * pipe on Haswell and later (where we have a special eDP transcoder)
  484. * and Broxton (where we have special DSI transcoders). */
  485. enum transcoder cpu_transcoder;
  486. /*
  487. * Use reduced/limited/broadcast rbg range, compressing from the full
  488. * range fed into the crtcs.
  489. */
  490. bool limited_color_range;
  491. /* Bitmask of encoder types (enum intel_output_type)
  492. * driven by the pipe.
  493. */
  494. unsigned int output_types;
  495. /* Whether we should send NULL infoframes. Required for audio. */
  496. bool has_hdmi_sink;
  497. /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
  498. * has_dp_encoder is set. */
  499. bool has_audio;
  500. /*
  501. * Enable dithering, used when the selected pipe bpp doesn't match the
  502. * plane bpp.
  503. */
  504. bool dither;
  505. /* Controls for the clock computation, to override various stages. */
  506. bool clock_set;
  507. /* SDVO TV has a bunch of special case. To make multifunction encoders
  508. * work correctly, we need to track this at runtime.*/
  509. bool sdvo_tv_clock;
  510. /*
  511. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  512. * required. This is set in the 2nd loop of calling encoder's
  513. * ->compute_config if the first pick doesn't work out.
  514. */
  515. bool bw_constrained;
  516. /* Settings for the intel dpll used on pretty much everything but
  517. * haswell. */
  518. struct dpll dpll;
  519. /* Selected dpll when shared or NULL. */
  520. struct intel_shared_dpll *shared_dpll;
  521. /* Actual register state of the dpll, for shared dpll cross-checking. */
  522. struct intel_dpll_hw_state dpll_hw_state;
  523. /* DSI PLL registers */
  524. struct {
  525. u32 ctrl, div;
  526. } dsi_pll;
  527. int pipe_bpp;
  528. struct intel_link_m_n dp_m_n;
  529. /* m2_n2 for eDP downclock */
  530. struct intel_link_m_n dp_m2_n2;
  531. bool has_drrs;
  532. /*
  533. * Frequence the dpll for the port should run at. Differs from the
  534. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  535. * already multiplied by pixel_multiplier.
  536. */
  537. int port_clock;
  538. /* Used by SDVO (and if we ever fix it, HDMI). */
  539. unsigned pixel_multiplier;
  540. uint8_t lane_count;
  541. /*
  542. * Used by platforms having DP/HDMI PHY with programmable lane
  543. * latency optimization.
  544. */
  545. uint8_t lane_lat_optim_mask;
  546. /* Panel fitter controls for gen2-gen4 + VLV */
  547. struct {
  548. u32 control;
  549. u32 pgm_ratios;
  550. u32 lvds_border_bits;
  551. } gmch_pfit;
  552. /* Panel fitter placement and size for Ironlake+ */
  553. struct {
  554. u32 pos;
  555. u32 size;
  556. bool enabled;
  557. bool force_thru;
  558. } pch_pfit;
  559. /* FDI configuration, only valid if has_pch_encoder is set. */
  560. int fdi_lanes;
  561. struct intel_link_m_n fdi_m_n;
  562. bool ips_enabled;
  563. bool enable_fbc;
  564. bool double_wide;
  565. int pbn;
  566. struct intel_crtc_scaler_state scaler_state;
  567. /* w/a for waiting 2 vblanks during crtc enable */
  568. enum pipe hsw_workaround_pipe;
  569. /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
  570. bool disable_lp_wm;
  571. struct intel_crtc_wm_state wm;
  572. /* Gamma mode programmed on the pipe */
  573. uint32_t gamma_mode;
  574. };
  575. struct vlv_wm_state {
  576. struct vlv_pipe_wm wm[3];
  577. struct vlv_sr_wm sr[3];
  578. uint8_t num_active_planes;
  579. uint8_t num_levels;
  580. uint8_t level;
  581. bool cxsr;
  582. };
  583. struct intel_crtc {
  584. struct drm_crtc base;
  585. enum pipe pipe;
  586. enum plane plane;
  587. u8 lut_r[256], lut_g[256], lut_b[256];
  588. /*
  589. * Whether the crtc and the connected output pipeline is active. Implies
  590. * that crtc->enabled is set, i.e. the current mode configuration has
  591. * some outputs connected to this crtc.
  592. */
  593. bool active;
  594. bool lowfreq_avail;
  595. u8 plane_ids_mask;
  596. unsigned long enabled_power_domains;
  597. struct intel_overlay *overlay;
  598. struct intel_flip_work *flip_work;
  599. atomic_t unpin_work_count;
  600. /* Display surface base address adjustement for pageflips. Note that on
  601. * gen4+ this only adjusts up to a tile, offsets within a tile are
  602. * handled in the hw itself (with the TILEOFF register). */
  603. u32 dspaddr_offset;
  604. int adjusted_x;
  605. int adjusted_y;
  606. uint32_t cursor_addr;
  607. uint32_t cursor_cntl;
  608. uint32_t cursor_size;
  609. uint32_t cursor_base;
  610. struct intel_crtc_state *config;
  611. /* global reset count when the last flip was submitted */
  612. unsigned int reset_count;
  613. /* Access to these should be protected by dev_priv->irq_lock. */
  614. bool cpu_fifo_underrun_disabled;
  615. bool pch_fifo_underrun_disabled;
  616. /* per-pipe watermark state */
  617. struct {
  618. /* watermarks currently being used */
  619. union {
  620. struct intel_pipe_wm ilk;
  621. } active;
  622. /* allow CxSR on this pipe */
  623. bool cxsr_allowed;
  624. } wm;
  625. int scanline_offset;
  626. struct {
  627. unsigned start_vbl_count;
  628. ktime_t start_vbl_time;
  629. int min_vbl, max_vbl;
  630. int scanline_start;
  631. } debug;
  632. /* scalers available on this crtc */
  633. int num_scalers;
  634. struct vlv_wm_state wm_state;
  635. };
  636. struct intel_plane_wm_parameters {
  637. uint32_t horiz_pixels;
  638. uint32_t vert_pixels;
  639. /*
  640. * For packed pixel formats:
  641. * bytes_per_pixel - holds bytes per pixel
  642. * For planar pixel formats:
  643. * bytes_per_pixel - holds bytes per pixel for uv-plane
  644. * y_bytes_per_pixel - holds bytes per pixel for y-plane
  645. */
  646. uint8_t bytes_per_pixel;
  647. uint8_t y_bytes_per_pixel;
  648. bool enabled;
  649. bool scaled;
  650. u64 tiling;
  651. unsigned int rotation;
  652. uint16_t fifo_size;
  653. };
  654. struct intel_plane {
  655. struct drm_plane base;
  656. u8 plane;
  657. enum plane_id id;
  658. enum pipe pipe;
  659. bool can_scale;
  660. int max_downscale;
  661. uint32_t frontbuffer_bit;
  662. /* Since we need to change the watermarks before/after
  663. * enabling/disabling the planes, we need to store the parameters here
  664. * as the other pieces of the struct may not reflect the values we want
  665. * for the watermark calculations. Currently only Haswell uses this.
  666. */
  667. struct intel_plane_wm_parameters wm;
  668. /*
  669. * NOTE: Do not place new plane state fields here (e.g., when adding
  670. * new plane properties). New runtime state should now be placed in
  671. * the intel_plane_state structure and accessed via plane_state.
  672. */
  673. void (*update_plane)(struct drm_plane *plane,
  674. const struct intel_crtc_state *crtc_state,
  675. const struct intel_plane_state *plane_state);
  676. void (*disable_plane)(struct drm_plane *plane,
  677. struct drm_crtc *crtc);
  678. int (*check_plane)(struct drm_plane *plane,
  679. struct intel_crtc_state *crtc_state,
  680. struct intel_plane_state *state);
  681. };
  682. struct intel_watermark_params {
  683. u16 fifo_size;
  684. u16 max_wm;
  685. u8 default_wm;
  686. u8 guard_size;
  687. u8 cacheline_size;
  688. };
  689. struct cxsr_latency {
  690. bool is_desktop : 1;
  691. bool is_ddr3 : 1;
  692. u16 fsb_freq;
  693. u16 mem_freq;
  694. u16 display_sr;
  695. u16 display_hpll_disable;
  696. u16 cursor_sr;
  697. u16 cursor_hpll_disable;
  698. };
  699. #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
  700. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  701. #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
  702. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  703. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  704. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  705. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  706. #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
  707. #define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL)
  708. struct intel_hdmi {
  709. i915_reg_t hdmi_reg;
  710. int ddc_bus;
  711. struct {
  712. enum drm_dp_dual_mode_type type;
  713. int max_tmds_clock;
  714. } dp_dual_mode;
  715. bool limited_color_range;
  716. bool color_range_auto;
  717. bool has_hdmi_sink;
  718. bool has_audio;
  719. enum hdmi_force_audio force_audio;
  720. bool rgb_quant_range_selectable;
  721. enum hdmi_picture_aspect aspect_ratio;
  722. struct intel_connector *attached_connector;
  723. void (*write_infoframe)(struct drm_encoder *encoder,
  724. const struct intel_crtc_state *crtc_state,
  725. enum hdmi_infoframe_type type,
  726. const void *frame, ssize_t len);
  727. void (*set_infoframes)(struct drm_encoder *encoder,
  728. bool enable,
  729. const struct intel_crtc_state *crtc_state,
  730. const struct drm_connector_state *conn_state);
  731. bool (*infoframe_enabled)(struct drm_encoder *encoder,
  732. const struct intel_crtc_state *pipe_config);
  733. };
  734. struct intel_dp_mst_encoder;
  735. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  736. /*
  737. * enum link_m_n_set:
  738. * When platform provides two set of M_N registers for dp, we can
  739. * program them and switch between them incase of DRRS.
  740. * But When only one such register is provided, we have to program the
  741. * required divider value on that registers itself based on the DRRS state.
  742. *
  743. * M1_N1 : Program dp_m_n on M1_N1 registers
  744. * dp_m2_n2 on M2_N2 registers (If supported)
  745. *
  746. * M2_N2 : Program dp_m2_n2 on M1_N1 registers
  747. * M2_N2 registers are not supported
  748. */
  749. enum link_m_n_set {
  750. /* Sets the m1_n1 and m2_n2 */
  751. M1_N1 = 0,
  752. M2_N2
  753. };
  754. struct intel_dp_desc {
  755. u8 oui[3];
  756. u8 device_id[6];
  757. u8 hw_rev;
  758. u8 sw_major_rev;
  759. u8 sw_minor_rev;
  760. } __packed;
  761. struct intel_dp_compliance_data {
  762. unsigned long edid;
  763. };
  764. struct intel_dp_compliance {
  765. unsigned long test_type;
  766. struct intel_dp_compliance_data test_data;
  767. bool test_active;
  768. };
  769. struct intel_dp {
  770. i915_reg_t output_reg;
  771. i915_reg_t aux_ch_ctl_reg;
  772. i915_reg_t aux_ch_data_reg[5];
  773. uint32_t DP;
  774. int link_rate;
  775. uint8_t lane_count;
  776. uint8_t sink_count;
  777. bool link_mst;
  778. bool has_audio;
  779. bool detect_done;
  780. bool channel_eq_status;
  781. enum hdmi_force_audio force_audio;
  782. bool limited_color_range;
  783. bool color_range_auto;
  784. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  785. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  786. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  787. uint8_t edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
  788. /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
  789. uint8_t num_sink_rates;
  790. int sink_rates[DP_MAX_SUPPORTED_RATES];
  791. /* Max lane count for the sink as per DPCD registers */
  792. uint8_t max_sink_lane_count;
  793. /* Max link BW for the sink as per DPCD registers */
  794. int max_sink_link_bw;
  795. /* sink or branch descriptor */
  796. struct intel_dp_desc desc;
  797. struct drm_dp_aux aux;
  798. uint8_t train_set[4];
  799. int panel_power_up_delay;
  800. int panel_power_down_delay;
  801. int panel_power_cycle_delay;
  802. int backlight_on_delay;
  803. int backlight_off_delay;
  804. struct delayed_work panel_vdd_work;
  805. bool want_panel_vdd;
  806. unsigned long last_power_on;
  807. unsigned long last_backlight_off;
  808. ktime_t panel_power_off_time;
  809. struct notifier_block edp_notifier;
  810. /*
  811. * Pipe whose power sequencer is currently locked into
  812. * this port. Only relevant on VLV/CHV.
  813. */
  814. enum pipe pps_pipe;
  815. /*
  816. * Pipe currently driving the port. Used for preventing
  817. * the use of the PPS for any pipe currentrly driving
  818. * external DP as that will mess things up on VLV.
  819. */
  820. enum pipe active_pipe;
  821. /*
  822. * Set if the sequencer may be reset due to a power transition,
  823. * requiring a reinitialization. Only relevant on BXT.
  824. */
  825. bool pps_reset;
  826. struct edp_power_seq pps_delays;
  827. bool can_mst; /* this port supports mst */
  828. bool is_mst;
  829. int active_mst_links;
  830. /* connector directly attached - won't be use for modeset in mst world */
  831. struct intel_connector *attached_connector;
  832. /* mst connector list */
  833. struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
  834. struct drm_dp_mst_topology_mgr mst_mgr;
  835. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  836. /*
  837. * This function returns the value we have to program the AUX_CTL
  838. * register with to kick off an AUX transaction.
  839. */
  840. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  841. bool has_aux_irq,
  842. int send_bytes,
  843. uint32_t aux_clock_divider);
  844. /* This is called before a link training is starterd */
  845. void (*prepare_link_retrain)(struct intel_dp *intel_dp);
  846. /* Displayport compliance testing */
  847. struct intel_dp_compliance compliance;
  848. };
  849. struct intel_lspcon {
  850. bool active;
  851. enum drm_lspcon_mode mode;
  852. bool desc_valid;
  853. };
  854. struct intel_digital_port {
  855. struct intel_encoder base;
  856. enum port port;
  857. u32 saved_port_bits;
  858. struct intel_dp dp;
  859. struct intel_hdmi hdmi;
  860. struct intel_lspcon lspcon;
  861. enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
  862. bool release_cl2_override;
  863. uint8_t max_lanes;
  864. };
  865. struct intel_dp_mst_encoder {
  866. struct intel_encoder base;
  867. enum pipe pipe;
  868. struct intel_digital_port *primary;
  869. struct intel_connector *connector;
  870. };
  871. static inline enum dpio_channel
  872. vlv_dport_to_channel(struct intel_digital_port *dport)
  873. {
  874. switch (dport->port) {
  875. case PORT_B:
  876. case PORT_D:
  877. return DPIO_CH0;
  878. case PORT_C:
  879. return DPIO_CH1;
  880. default:
  881. BUG();
  882. }
  883. }
  884. static inline enum dpio_phy
  885. vlv_dport_to_phy(struct intel_digital_port *dport)
  886. {
  887. switch (dport->port) {
  888. case PORT_B:
  889. case PORT_C:
  890. return DPIO_PHY0;
  891. case PORT_D:
  892. return DPIO_PHY1;
  893. default:
  894. BUG();
  895. }
  896. }
  897. static inline enum dpio_channel
  898. vlv_pipe_to_channel(enum pipe pipe)
  899. {
  900. switch (pipe) {
  901. case PIPE_A:
  902. case PIPE_C:
  903. return DPIO_CH0;
  904. case PIPE_B:
  905. return DPIO_CH1;
  906. default:
  907. BUG();
  908. }
  909. }
  910. static inline struct intel_crtc *
  911. intel_get_crtc_for_pipe(struct drm_i915_private *dev_priv, enum pipe pipe)
  912. {
  913. return dev_priv->pipe_to_crtc_mapping[pipe];
  914. }
  915. static inline struct intel_crtc *
  916. intel_get_crtc_for_plane(struct drm_i915_private *dev_priv, enum plane plane)
  917. {
  918. return dev_priv->plane_to_crtc_mapping[plane];
  919. }
  920. struct intel_flip_work {
  921. struct work_struct unpin_work;
  922. struct work_struct mmio_work;
  923. struct drm_crtc *crtc;
  924. struct i915_vma *old_vma;
  925. struct drm_framebuffer *old_fb;
  926. struct drm_i915_gem_object *pending_flip_obj;
  927. struct drm_pending_vblank_event *event;
  928. atomic_t pending;
  929. u32 flip_count;
  930. u32 gtt_offset;
  931. struct drm_i915_gem_request *flip_queued_req;
  932. u32 flip_queued_vblank;
  933. u32 flip_ready_vblank;
  934. unsigned int rotation;
  935. };
  936. struct intel_load_detect_pipe {
  937. struct drm_atomic_state *restore_state;
  938. };
  939. static inline struct intel_encoder *
  940. intel_attached_encoder(struct drm_connector *connector)
  941. {
  942. return to_intel_connector(connector)->encoder;
  943. }
  944. static inline struct intel_digital_port *
  945. enc_to_dig_port(struct drm_encoder *encoder)
  946. {
  947. return container_of(encoder, struct intel_digital_port, base.base);
  948. }
  949. static inline struct intel_dp_mst_encoder *
  950. enc_to_mst(struct drm_encoder *encoder)
  951. {
  952. return container_of(encoder, struct intel_dp_mst_encoder, base.base);
  953. }
  954. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  955. {
  956. return &enc_to_dig_port(encoder)->dp;
  957. }
  958. static inline struct intel_digital_port *
  959. dp_to_dig_port(struct intel_dp *intel_dp)
  960. {
  961. return container_of(intel_dp, struct intel_digital_port, dp);
  962. }
  963. static inline struct intel_lspcon *
  964. dp_to_lspcon(struct intel_dp *intel_dp)
  965. {
  966. return &dp_to_dig_port(intel_dp)->lspcon;
  967. }
  968. static inline struct intel_digital_port *
  969. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  970. {
  971. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  972. }
  973. /* intel_fifo_underrun.c */
  974. bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  975. enum pipe pipe, bool enable);
  976. bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  977. enum transcoder pch_transcoder,
  978. bool enable);
  979. void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  980. enum pipe pipe);
  981. void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  982. enum transcoder pch_transcoder);
  983. void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv);
  984. void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv);
  985. /* i915_irq.c */
  986. void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  987. void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  988. void gen6_reset_pm_iir(struct drm_i915_private *dev_priv, u32 mask);
  989. void gen6_mask_pm_irq(struct drm_i915_private *dev_priv, u32 mask);
  990. void gen6_unmask_pm_irq(struct drm_i915_private *dev_priv, u32 mask);
  991. void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  992. void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  993. void gen6_reset_rps_interrupts(struct drm_i915_private *dev_priv);
  994. void gen6_enable_rps_interrupts(struct drm_i915_private *dev_priv);
  995. void gen6_disable_rps_interrupts(struct drm_i915_private *dev_priv);
  996. u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
  997. void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
  998. void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
  999. static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
  1000. {
  1001. /*
  1002. * We only use drm_irq_uninstall() at unload and VT switch, so
  1003. * this is the only thing we need to check.
  1004. */
  1005. return dev_priv->pm.irqs_enabled;
  1006. }
  1007. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  1008. void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
  1009. unsigned int pipe_mask);
  1010. void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv,
  1011. unsigned int pipe_mask);
  1012. void gen9_reset_guc_interrupts(struct drm_i915_private *dev_priv);
  1013. void gen9_enable_guc_interrupts(struct drm_i915_private *dev_priv);
  1014. void gen9_disable_guc_interrupts(struct drm_i915_private *dev_priv);
  1015. /* intel_crt.c */
  1016. void intel_crt_init(struct drm_i915_private *dev_priv);
  1017. void intel_crt_reset(struct drm_encoder *encoder);
  1018. /* intel_ddi.c */
  1019. void intel_ddi_clk_select(struct intel_encoder *encoder,
  1020. struct intel_shared_dpll *pll);
  1021. void intel_ddi_fdi_post_disable(struct intel_encoder *intel_encoder,
  1022. struct intel_crtc_state *old_crtc_state,
  1023. struct drm_connector_state *old_conn_state);
  1024. void intel_prepare_dp_ddi_buffers(struct intel_encoder *encoder);
  1025. void hsw_fdi_link_train(struct drm_crtc *crtc);
  1026. void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port);
  1027. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  1028. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  1029. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  1030. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  1031. enum transcoder cpu_transcoder);
  1032. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  1033. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  1034. bool intel_ddi_pll_select(struct intel_crtc *crtc,
  1035. struct intel_crtc_state *crtc_state);
  1036. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  1037. void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
  1038. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  1039. bool intel_ddi_is_audio_enabled(struct drm_i915_private *dev_priv,
  1040. struct intel_crtc *intel_crtc);
  1041. void intel_ddi_get_config(struct intel_encoder *encoder,
  1042. struct intel_crtc_state *pipe_config);
  1043. struct intel_encoder *
  1044. intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
  1045. void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
  1046. void intel_ddi_clock_get(struct intel_encoder *encoder,
  1047. struct intel_crtc_state *pipe_config);
  1048. void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state);
  1049. uint32_t ddi_signal_levels(struct intel_dp *intel_dp);
  1050. struct intel_shared_dpll *intel_ddi_get_link_dpll(struct intel_dp *intel_dp,
  1051. int clock);
  1052. unsigned int intel_fb_align_height(struct drm_device *dev,
  1053. unsigned int height,
  1054. uint32_t pixel_format,
  1055. uint64_t fb_format_modifier);
  1056. u32 intel_fb_stride_alignment(const struct drm_i915_private *dev_priv,
  1057. uint64_t fb_modifier, uint32_t pixel_format);
  1058. /* intel_audio.c */
  1059. void intel_init_audio_hooks(struct drm_i915_private *dev_priv);
  1060. void intel_audio_codec_enable(struct intel_encoder *encoder,
  1061. const struct intel_crtc_state *crtc_state,
  1062. const struct drm_connector_state *conn_state);
  1063. void intel_audio_codec_disable(struct intel_encoder *encoder);
  1064. void i915_audio_component_init(struct drm_i915_private *dev_priv);
  1065. void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
  1066. /* intel_display.c */
  1067. enum transcoder intel_crtc_pch_transcoder(struct intel_crtc *crtc);
  1068. void skl_set_preferred_cdclk_vco(struct drm_i915_private *dev_priv, int vco);
  1069. void intel_update_rawclk(struct drm_i915_private *dev_priv);
  1070. int vlv_get_cck_clock(struct drm_i915_private *dev_priv,
  1071. const char *name, u32 reg, int ref_freq);
  1072. void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv);
  1073. void lpt_disable_iclkip(struct drm_i915_private *dev_priv);
  1074. extern const struct drm_plane_funcs intel_plane_funcs;
  1075. void intel_init_display_hooks(struct drm_i915_private *dev_priv);
  1076. unsigned int intel_fb_xy_to_linear(int x, int y,
  1077. const struct intel_plane_state *state,
  1078. int plane);
  1079. void intel_add_fb_offsets(int *x, int *y,
  1080. const struct intel_plane_state *state, int plane);
  1081. unsigned int intel_rotation_info_size(const struct intel_rotation_info *rot_info);
  1082. bool intel_has_pending_fb_unpin(struct drm_i915_private *dev_priv);
  1083. void intel_mark_busy(struct drm_i915_private *dev_priv);
  1084. void intel_mark_idle(struct drm_i915_private *dev_priv);
  1085. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  1086. int intel_display_suspend(struct drm_device *dev);
  1087. void intel_pps_unlock_regs_wa(struct drm_i915_private *dev_priv);
  1088. void intel_encoder_destroy(struct drm_encoder *encoder);
  1089. int intel_connector_init(struct intel_connector *);
  1090. struct intel_connector *intel_connector_alloc(void);
  1091. bool intel_connector_get_hw_state(struct intel_connector *connector);
  1092. void intel_connector_attach_encoder(struct intel_connector *connector,
  1093. struct intel_encoder *encoder);
  1094. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  1095. struct drm_crtc *crtc);
  1096. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  1097. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  1098. struct drm_file *file_priv);
  1099. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  1100. enum pipe pipe);
  1101. static inline bool
  1102. intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
  1103. enum intel_output_type type)
  1104. {
  1105. return crtc_state->output_types & (1 << type);
  1106. }
  1107. static inline bool
  1108. intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
  1109. {
  1110. return crtc_state->output_types &
  1111. ((1 << INTEL_OUTPUT_DP) |
  1112. (1 << INTEL_OUTPUT_DP_MST) |
  1113. (1 << INTEL_OUTPUT_EDP));
  1114. }
  1115. static inline void
  1116. intel_wait_for_vblank(struct drm_i915_private *dev_priv, enum pipe pipe)
  1117. {
  1118. drm_wait_one_vblank(&dev_priv->drm, pipe);
  1119. }
  1120. static inline void
  1121. intel_wait_for_vblank_if_active(struct drm_i915_private *dev_priv, int pipe)
  1122. {
  1123. const struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
  1124. if (crtc->active)
  1125. intel_wait_for_vblank(dev_priv, pipe);
  1126. }
  1127. u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc);
  1128. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  1129. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  1130. struct intel_digital_port *dport,
  1131. unsigned int expected_mask);
  1132. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  1133. struct drm_display_mode *mode,
  1134. struct intel_load_detect_pipe *old,
  1135. struct drm_modeset_acquire_ctx *ctx);
  1136. void intel_release_load_detect_pipe(struct drm_connector *connector,
  1137. struct intel_load_detect_pipe *old,
  1138. struct drm_modeset_acquire_ctx *ctx);
  1139. struct i915_vma *
  1140. intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, unsigned int rotation);
  1141. void intel_unpin_fb_vma(struct i915_vma *vma);
  1142. struct drm_framebuffer *
  1143. __intel_framebuffer_create(struct drm_device *dev,
  1144. struct drm_mode_fb_cmd2 *mode_cmd,
  1145. struct drm_i915_gem_object *obj);
  1146. void intel_finish_page_flip_cs(struct drm_i915_private *dev_priv, int pipe);
  1147. void intel_finish_page_flip_mmio(struct drm_i915_private *dev_priv, int pipe);
  1148. void intel_check_page_flip(struct drm_i915_private *dev_priv, int pipe);
  1149. int intel_prepare_plane_fb(struct drm_plane *plane,
  1150. struct drm_plane_state *new_state);
  1151. void intel_cleanup_plane_fb(struct drm_plane *plane,
  1152. struct drm_plane_state *old_state);
  1153. int intel_plane_atomic_get_property(struct drm_plane *plane,
  1154. const struct drm_plane_state *state,
  1155. struct drm_property *property,
  1156. uint64_t *val);
  1157. int intel_plane_atomic_set_property(struct drm_plane *plane,
  1158. struct drm_plane_state *state,
  1159. struct drm_property *property,
  1160. uint64_t val);
  1161. int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
  1162. struct drm_plane_state *plane_state);
  1163. unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
  1164. uint64_t fb_modifier, unsigned int cpp);
  1165. void assert_pch_transcoder_disabled(struct drm_i915_private *dev_priv,
  1166. enum pipe pipe);
  1167. int vlv_force_pll_on(struct drm_i915_private *dev_priv, enum pipe pipe,
  1168. const struct dpll *dpll);
  1169. void vlv_force_pll_off(struct drm_i915_private *dev_priv, enum pipe pipe);
  1170. int lpt_get_iclkip(struct drm_i915_private *dev_priv);
  1171. /* modesetting asserts */
  1172. void assert_panel_unlocked(struct drm_i915_private *dev_priv,
  1173. enum pipe pipe);
  1174. void assert_pll(struct drm_i915_private *dev_priv,
  1175. enum pipe pipe, bool state);
  1176. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  1177. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  1178. void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state);
  1179. #define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true)
  1180. #define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false)
  1181. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  1182. enum pipe pipe, bool state);
  1183. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  1184. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  1185. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  1186. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  1187. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  1188. u32 intel_compute_tile_offset(int *x, int *y,
  1189. const struct intel_plane_state *state, int plane);
  1190. void intel_prepare_reset(struct drm_i915_private *dev_priv);
  1191. void intel_finish_reset(struct drm_i915_private *dev_priv);
  1192. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  1193. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  1194. void bxt_init_cdclk(struct drm_i915_private *dev_priv);
  1195. void bxt_uninit_cdclk(struct drm_i915_private *dev_priv);
  1196. void gen9_sanitize_dc_state(struct drm_i915_private *dev_priv);
  1197. void bxt_enable_dc9(struct drm_i915_private *dev_priv);
  1198. void bxt_disable_dc9(struct drm_i915_private *dev_priv);
  1199. void gen9_enable_dc5(struct drm_i915_private *dev_priv);
  1200. void skl_init_cdclk(struct drm_i915_private *dev_priv);
  1201. void skl_uninit_cdclk(struct drm_i915_private *dev_priv);
  1202. unsigned int skl_cdclk_get_vco(unsigned int freq);
  1203. void skl_enable_dc6(struct drm_i915_private *dev_priv);
  1204. void skl_disable_dc6(struct drm_i915_private *dev_priv);
  1205. void intel_dp_get_m_n(struct intel_crtc *crtc,
  1206. struct intel_crtc_state *pipe_config);
  1207. void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
  1208. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  1209. bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, int target_clock,
  1210. struct dpll *best_clock);
  1211. int chv_calc_dpll_params(int refclk, struct dpll *pll_clock);
  1212. bool intel_crtc_active(struct intel_crtc *crtc);
  1213. void hsw_enable_ips(struct intel_crtc *crtc);
  1214. void hsw_disable_ips(struct intel_crtc *crtc);
  1215. enum intel_display_power_domain
  1216. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  1217. enum intel_display_power_domain
  1218. intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder);
  1219. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  1220. struct intel_crtc_state *pipe_config);
  1221. int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
  1222. int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
  1223. static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *state)
  1224. {
  1225. return i915_ggtt_offset(state->vma);
  1226. }
  1227. u32 skl_plane_ctl_format(uint32_t pixel_format);
  1228. u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
  1229. u32 skl_plane_ctl_rotation(unsigned int rotation);
  1230. u32 skl_plane_stride(const struct drm_framebuffer *fb, int plane,
  1231. unsigned int rotation);
  1232. int skl_check_plane_surface(struct intel_plane_state *plane_state);
  1233. /* intel_csr.c */
  1234. void intel_csr_ucode_init(struct drm_i915_private *);
  1235. void intel_csr_load_program(struct drm_i915_private *);
  1236. void intel_csr_ucode_fini(struct drm_i915_private *);
  1237. void intel_csr_ucode_suspend(struct drm_i915_private *);
  1238. void intel_csr_ucode_resume(struct drm_i915_private *);
  1239. /* intel_dp.c */
  1240. bool intel_dp_init(struct drm_i915_private *dev_priv, i915_reg_t output_reg,
  1241. enum port port);
  1242. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  1243. struct intel_connector *intel_connector);
  1244. void intel_dp_set_link_params(struct intel_dp *intel_dp,
  1245. int link_rate, uint8_t lane_count,
  1246. bool link_mst);
  1247. int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
  1248. int link_rate, uint8_t lane_count);
  1249. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  1250. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  1251. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  1252. void intel_dp_encoder_reset(struct drm_encoder *encoder);
  1253. void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder);
  1254. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  1255. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  1256. bool intel_dp_compute_config(struct intel_encoder *encoder,
  1257. struct intel_crtc_state *pipe_config,
  1258. struct drm_connector_state *conn_state);
  1259. bool intel_dp_is_edp(struct drm_i915_private *dev_priv, enum port port);
  1260. enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
  1261. bool long_hpd);
  1262. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  1263. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  1264. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  1265. void intel_edp_panel_on(struct intel_dp *intel_dp);
  1266. void intel_edp_panel_off(struct intel_dp *intel_dp);
  1267. void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
  1268. void intel_dp_mst_suspend(struct drm_device *dev);
  1269. void intel_dp_mst_resume(struct drm_device *dev);
  1270. int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  1271. int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
  1272. void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
  1273. void intel_power_sequencer_reset(struct drm_i915_private *dev_priv);
  1274. uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
  1275. void intel_plane_destroy(struct drm_plane *plane);
  1276. void intel_edp_drrs_enable(struct intel_dp *intel_dp,
  1277. struct intel_crtc_state *crtc_state);
  1278. void intel_edp_drrs_disable(struct intel_dp *intel_dp,
  1279. struct intel_crtc_state *crtc_state);
  1280. void intel_edp_drrs_invalidate(struct drm_i915_private *dev_priv,
  1281. unsigned int frontbuffer_bits);
  1282. void intel_edp_drrs_flush(struct drm_i915_private *dev_priv,
  1283. unsigned int frontbuffer_bits);
  1284. void
  1285. intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
  1286. uint8_t dp_train_pat);
  1287. void
  1288. intel_dp_set_signal_levels(struct intel_dp *intel_dp);
  1289. void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
  1290. uint8_t
  1291. intel_dp_voltage_max(struct intel_dp *intel_dp);
  1292. uint8_t
  1293. intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing);
  1294. void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
  1295. uint8_t *link_bw, uint8_t *rate_select);
  1296. bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
  1297. bool
  1298. intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]);
  1299. static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
  1300. {
  1301. return ~((1 << lane_count) - 1) & 0xf;
  1302. }
  1303. bool intel_dp_read_dpcd(struct intel_dp *intel_dp);
  1304. bool __intel_dp_read_desc(struct intel_dp *intel_dp,
  1305. struct intel_dp_desc *desc);
  1306. bool intel_dp_read_desc(struct intel_dp *intel_dp);
  1307. int intel_dp_link_required(int pixel_clock, int bpp);
  1308. int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
  1309. /* intel_dp_aux_backlight.c */
  1310. int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
  1311. /* intel_dp_mst.c */
  1312. int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  1313. void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
  1314. /* intel_dsi.c */
  1315. void intel_dsi_init(struct drm_i915_private *dev_priv);
  1316. /* intel_dsi_dcs_backlight.c */
  1317. int intel_dsi_dcs_init_backlight_funcs(struct intel_connector *intel_connector);
  1318. /* intel_dvo.c */
  1319. void intel_dvo_init(struct drm_i915_private *dev_priv);
  1320. /* intel_hotplug.c */
  1321. void intel_hpd_poll_init(struct drm_i915_private *dev_priv);
  1322. /* legacy fbdev emulation in intel_fbdev.c */
  1323. #ifdef CONFIG_DRM_FBDEV_EMULATION
  1324. extern int intel_fbdev_init(struct drm_device *dev);
  1325. extern void intel_fbdev_initial_config_async(struct drm_device *dev);
  1326. extern void intel_fbdev_fini(struct drm_device *dev);
  1327. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
  1328. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  1329. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  1330. #else
  1331. static inline int intel_fbdev_init(struct drm_device *dev)
  1332. {
  1333. return 0;
  1334. }
  1335. static inline void intel_fbdev_initial_config_async(struct drm_device *dev)
  1336. {
  1337. }
  1338. static inline void intel_fbdev_fini(struct drm_device *dev)
  1339. {
  1340. }
  1341. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
  1342. {
  1343. }
  1344. static inline void intel_fbdev_output_poll_changed(struct drm_device *dev)
  1345. {
  1346. }
  1347. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  1348. {
  1349. }
  1350. #endif
  1351. /* intel_fbc.c */
  1352. void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
  1353. struct drm_atomic_state *state);
  1354. bool intel_fbc_is_active(struct drm_i915_private *dev_priv);
  1355. void intel_fbc_pre_update(struct intel_crtc *crtc,
  1356. struct intel_crtc_state *crtc_state,
  1357. struct intel_plane_state *plane_state);
  1358. void intel_fbc_post_update(struct intel_crtc *crtc);
  1359. void intel_fbc_init(struct drm_i915_private *dev_priv);
  1360. void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv);
  1361. void intel_fbc_enable(struct intel_crtc *crtc,
  1362. struct intel_crtc_state *crtc_state,
  1363. struct intel_plane_state *plane_state);
  1364. void intel_fbc_disable(struct intel_crtc *crtc);
  1365. void intel_fbc_global_disable(struct drm_i915_private *dev_priv);
  1366. void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
  1367. unsigned int frontbuffer_bits,
  1368. enum fb_op_origin origin);
  1369. void intel_fbc_flush(struct drm_i915_private *dev_priv,
  1370. unsigned int frontbuffer_bits, enum fb_op_origin origin);
  1371. void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv);
  1372. void intel_fbc_handle_fifo_underrun_irq(struct drm_i915_private *dev_priv);
  1373. /* intel_hdmi.c */
  1374. void intel_hdmi_init(struct drm_i915_private *dev_priv, i915_reg_t hdmi_reg,
  1375. enum port port);
  1376. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  1377. struct intel_connector *intel_connector);
  1378. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  1379. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  1380. struct intel_crtc_state *pipe_config,
  1381. struct drm_connector_state *conn_state);
  1382. void intel_dp_dual_mode_set_tmds_output(struct intel_hdmi *hdmi, bool enable);
  1383. /* intel_lvds.c */
  1384. void intel_lvds_init(struct drm_i915_private *dev_priv);
  1385. struct intel_encoder *intel_get_lvds_encoder(struct drm_device *dev);
  1386. bool intel_is_dual_link_lvds(struct drm_device *dev);
  1387. /* intel_modes.c */
  1388. int intel_connector_update_modes(struct drm_connector *connector,
  1389. struct edid *edid);
  1390. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  1391. void intel_attach_force_audio_property(struct drm_connector *connector);
  1392. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  1393. void intel_attach_aspect_ratio_property(struct drm_connector *connector);
  1394. /* intel_overlay.c */
  1395. void intel_setup_overlay(struct drm_i915_private *dev_priv);
  1396. void intel_cleanup_overlay(struct drm_i915_private *dev_priv);
  1397. int intel_overlay_switch_off(struct intel_overlay *overlay);
  1398. int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
  1399. struct drm_file *file_priv);
  1400. int intel_overlay_attrs_ioctl(struct drm_device *dev, void *data,
  1401. struct drm_file *file_priv);
  1402. void intel_overlay_reset(struct drm_i915_private *dev_priv);
  1403. /* intel_panel.c */
  1404. int intel_panel_init(struct intel_panel *panel,
  1405. struct drm_display_mode *fixed_mode,
  1406. struct drm_display_mode *downclock_mode);
  1407. void intel_panel_fini(struct intel_panel *panel);
  1408. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  1409. struct drm_display_mode *adjusted_mode);
  1410. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  1411. struct intel_crtc_state *pipe_config,
  1412. int fitting_mode);
  1413. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  1414. struct intel_crtc_state *pipe_config,
  1415. int fitting_mode);
  1416. void intel_panel_set_backlight_acpi(struct intel_connector *connector,
  1417. u32 level, u32 max);
  1418. int intel_panel_setup_backlight(struct drm_connector *connector,
  1419. enum pipe pipe);
  1420. void intel_panel_enable_backlight(struct intel_connector *connector);
  1421. void intel_panel_disable_backlight(struct intel_connector *connector);
  1422. void intel_panel_destroy_backlight(struct drm_connector *connector);
  1423. enum drm_connector_status intel_panel_detect(struct drm_i915_private *dev_priv);
  1424. extern struct drm_display_mode *intel_find_panel_downclock(
  1425. struct drm_i915_private *dev_priv,
  1426. struct drm_display_mode *fixed_mode,
  1427. struct drm_connector *connector);
  1428. #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
  1429. int intel_backlight_device_register(struct intel_connector *connector);
  1430. void intel_backlight_device_unregister(struct intel_connector *connector);
  1431. #else /* CONFIG_BACKLIGHT_CLASS_DEVICE */
  1432. static int intel_backlight_device_register(struct intel_connector *connector)
  1433. {
  1434. return 0;
  1435. }
  1436. static inline void intel_backlight_device_unregister(struct intel_connector *connector)
  1437. {
  1438. }
  1439. #endif /* CONFIG_BACKLIGHT_CLASS_DEVICE */
  1440. /* intel_psr.c */
  1441. void intel_psr_enable(struct intel_dp *intel_dp);
  1442. void intel_psr_disable(struct intel_dp *intel_dp);
  1443. void intel_psr_invalidate(struct drm_i915_private *dev_priv,
  1444. unsigned frontbuffer_bits);
  1445. void intel_psr_flush(struct drm_i915_private *dev_priv,
  1446. unsigned frontbuffer_bits,
  1447. enum fb_op_origin origin);
  1448. void intel_psr_init(struct drm_i915_private *dev_priv);
  1449. void intel_psr_single_frame_update(struct drm_i915_private *dev_priv,
  1450. unsigned frontbuffer_bits);
  1451. /* intel_runtime_pm.c */
  1452. int intel_power_domains_init(struct drm_i915_private *);
  1453. void intel_power_domains_fini(struct drm_i915_private *);
  1454. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume);
  1455. void intel_power_domains_suspend(struct drm_i915_private *dev_priv);
  1456. void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume);
  1457. void bxt_display_core_uninit(struct drm_i915_private *dev_priv);
  1458. void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
  1459. const char *
  1460. intel_display_power_domain_str(enum intel_display_power_domain domain);
  1461. bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1462. enum intel_display_power_domain domain);
  1463. bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1464. enum intel_display_power_domain domain);
  1465. void intel_display_power_get(struct drm_i915_private *dev_priv,
  1466. enum intel_display_power_domain domain);
  1467. bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv,
  1468. enum intel_display_power_domain domain);
  1469. void intel_display_power_put(struct drm_i915_private *dev_priv,
  1470. enum intel_display_power_domain domain);
  1471. static inline void
  1472. assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv)
  1473. {
  1474. WARN_ONCE(dev_priv->pm.suspended,
  1475. "Device suspended during HW access\n");
  1476. }
  1477. static inline void
  1478. assert_rpm_wakelock_held(struct drm_i915_private *dev_priv)
  1479. {
  1480. assert_rpm_device_not_suspended(dev_priv);
  1481. /* FIXME: Needs to be converted back to WARN_ONCE, but currently causes
  1482. * too much noise. */
  1483. if (!atomic_read(&dev_priv->pm.wakeref_count))
  1484. DRM_DEBUG_DRIVER("RPM wakelock ref not held during HW access");
  1485. }
  1486. /**
  1487. * disable_rpm_wakeref_asserts - disable the RPM assert checks
  1488. * @dev_priv: i915 device instance
  1489. *
  1490. * This function disable asserts that check if we hold an RPM wakelock
  1491. * reference, while keeping the device-not-suspended checks still enabled.
  1492. * It's meant to be used only in special circumstances where our rule about
  1493. * the wakelock refcount wrt. the device power state doesn't hold. According
  1494. * to this rule at any point where we access the HW or want to keep the HW in
  1495. * an active state we must hold an RPM wakelock reference acquired via one of
  1496. * the intel_runtime_pm_get() helpers. Currently there are a few special spots
  1497. * where this rule doesn't hold: the IRQ and suspend/resume handlers, the
  1498. * forcewake release timer, and the GPU RPS and hangcheck works. All other
  1499. * users should avoid using this function.
  1500. *
  1501. * Any calls to this function must have a symmetric call to
  1502. * enable_rpm_wakeref_asserts().
  1503. */
  1504. static inline void
  1505. disable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1506. {
  1507. atomic_inc(&dev_priv->pm.wakeref_count);
  1508. }
  1509. /**
  1510. * enable_rpm_wakeref_asserts - re-enable the RPM assert checks
  1511. * @dev_priv: i915 device instance
  1512. *
  1513. * This function re-enables the RPM assert checks after disabling them with
  1514. * disable_rpm_wakeref_asserts. It's meant to be used only in special
  1515. * circumstances otherwise its use should be avoided.
  1516. *
  1517. * Any calls to this function must have a symmetric call to
  1518. * disable_rpm_wakeref_asserts().
  1519. */
  1520. static inline void
  1521. enable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
  1522. {
  1523. atomic_dec(&dev_priv->pm.wakeref_count);
  1524. }
  1525. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  1526. bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv);
  1527. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  1528. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  1529. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  1530. void chv_phy_powergate_lanes(struct intel_encoder *encoder,
  1531. bool override, unsigned int mask);
  1532. bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy,
  1533. enum dpio_channel ch, bool override);
  1534. /* intel_pm.c */
  1535. void intel_init_clock_gating(struct drm_i915_private *dev_priv);
  1536. void intel_suspend_hw(struct drm_i915_private *dev_priv);
  1537. int ilk_wm_max_level(const struct drm_i915_private *dev_priv);
  1538. void intel_update_watermarks(struct intel_crtc *crtc);
  1539. void intel_init_pm(struct drm_i915_private *dev_priv);
  1540. void intel_init_clock_gating_hooks(struct drm_i915_private *dev_priv);
  1541. void intel_pm_setup(struct drm_i915_private *dev_priv);
  1542. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  1543. void intel_gpu_ips_teardown(void);
  1544. void intel_init_gt_powersave(struct drm_i915_private *dev_priv);
  1545. void intel_cleanup_gt_powersave(struct drm_i915_private *dev_priv);
  1546. void intel_sanitize_gt_powersave(struct drm_i915_private *dev_priv);
  1547. void intel_enable_gt_powersave(struct drm_i915_private *dev_priv);
  1548. void intel_autoenable_gt_powersave(struct drm_i915_private *dev_priv);
  1549. void intel_disable_gt_powersave(struct drm_i915_private *dev_priv);
  1550. void intel_suspend_gt_powersave(struct drm_i915_private *dev_priv);
  1551. void gen6_rps_busy(struct drm_i915_private *dev_priv);
  1552. void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
  1553. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  1554. void gen6_rps_boost(struct drm_i915_private *dev_priv,
  1555. struct intel_rps_client *rps,
  1556. unsigned long submitted);
  1557. void intel_queue_rps_boost_for_request(struct drm_i915_gem_request *req);
  1558. void vlv_wm_get_hw_state(struct drm_device *dev);
  1559. void ilk_wm_get_hw_state(struct drm_device *dev);
  1560. void skl_wm_get_hw_state(struct drm_device *dev);
  1561. void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  1562. struct skl_ddb_allocation *ddb /* out */);
  1563. void skl_pipe_wm_get_hw_state(struct drm_crtc *crtc,
  1564. struct skl_pipe_wm *out);
  1565. bool intel_can_enable_sagv(struct drm_atomic_state *state);
  1566. int intel_enable_sagv(struct drm_i915_private *dev_priv);
  1567. int intel_disable_sagv(struct drm_i915_private *dev_priv);
  1568. bool skl_wm_level_equals(const struct skl_wm_level *l1,
  1569. const struct skl_wm_level *l2);
  1570. bool skl_ddb_allocation_overlaps(const struct skl_ddb_entry **entries,
  1571. const struct skl_ddb_entry *ddb,
  1572. int ignore);
  1573. uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config);
  1574. bool ilk_disable_lp_wm(struct drm_device *dev);
  1575. int sanitize_rc6_option(struct drm_i915_private *dev_priv, int enable_rc6);
  1576. static inline int intel_enable_rc6(void)
  1577. {
  1578. return i915.enable_rc6;
  1579. }
  1580. /* intel_sdvo.c */
  1581. bool intel_sdvo_init(struct drm_i915_private *dev_priv,
  1582. i915_reg_t reg, enum port port);
  1583. /* intel_sprite.c */
  1584. int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode,
  1585. int usecs);
  1586. struct intel_plane *intel_sprite_plane_create(struct drm_i915_private *dev_priv,
  1587. enum pipe pipe, int plane);
  1588. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  1589. struct drm_file *file_priv);
  1590. void intel_pipe_update_start(struct intel_crtc *crtc);
  1591. void intel_pipe_update_end(struct intel_crtc *crtc, struct intel_flip_work *work);
  1592. /* intel_tv.c */
  1593. void intel_tv_init(struct drm_i915_private *dev_priv);
  1594. /* intel_atomic.c */
  1595. int intel_connector_atomic_get_property(struct drm_connector *connector,
  1596. const struct drm_connector_state *state,
  1597. struct drm_property *property,
  1598. uint64_t *val);
  1599. struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
  1600. void intel_crtc_destroy_state(struct drm_crtc *crtc,
  1601. struct drm_crtc_state *state);
  1602. struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
  1603. void intel_atomic_state_clear(struct drm_atomic_state *);
  1604. static inline struct intel_crtc_state *
  1605. intel_atomic_get_crtc_state(struct drm_atomic_state *state,
  1606. struct intel_crtc *crtc)
  1607. {
  1608. struct drm_crtc_state *crtc_state;
  1609. crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
  1610. if (IS_ERR(crtc_state))
  1611. return ERR_CAST(crtc_state);
  1612. return to_intel_crtc_state(crtc_state);
  1613. }
  1614. static inline struct intel_crtc_state *
  1615. intel_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
  1616. struct intel_crtc *crtc)
  1617. {
  1618. struct drm_crtc_state *crtc_state;
  1619. crtc_state = drm_atomic_get_existing_crtc_state(state, &crtc->base);
  1620. if (crtc_state)
  1621. return to_intel_crtc_state(crtc_state);
  1622. else
  1623. return NULL;
  1624. }
  1625. static inline struct intel_plane_state *
  1626. intel_atomic_get_existing_plane_state(struct drm_atomic_state *state,
  1627. struct intel_plane *plane)
  1628. {
  1629. struct drm_plane_state *plane_state;
  1630. plane_state = drm_atomic_get_existing_plane_state(state, &plane->base);
  1631. return to_intel_plane_state(plane_state);
  1632. }
  1633. int intel_atomic_setup_scalers(struct drm_device *dev,
  1634. struct intel_crtc *intel_crtc,
  1635. struct intel_crtc_state *crtc_state);
  1636. /* intel_atomic_plane.c */
  1637. struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
  1638. struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
  1639. void intel_plane_destroy_state(struct drm_plane *plane,
  1640. struct drm_plane_state *state);
  1641. extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
  1642. int intel_plane_atomic_check_with_state(struct intel_crtc_state *crtc_state,
  1643. struct intel_plane_state *intel_state);
  1644. /* intel_color.c */
  1645. void intel_color_init(struct drm_crtc *crtc);
  1646. int intel_color_check(struct drm_crtc *crtc, struct drm_crtc_state *state);
  1647. void intel_color_set_csc(struct drm_crtc_state *crtc_state);
  1648. void intel_color_load_luts(struct drm_crtc_state *crtc_state);
  1649. /* intel_lspcon.c */
  1650. bool lspcon_init(struct intel_digital_port *intel_dig_port);
  1651. void lspcon_resume(struct intel_lspcon *lspcon);
  1652. void lspcon_wait_pcon_mode(struct intel_lspcon *lspcon);
  1653. /* intel_pipe_crc.c */
  1654. int intel_pipe_crc_create(struct drm_minor *minor);
  1655. void intel_pipe_crc_cleanup(struct drm_minor *minor);
  1656. #ifdef CONFIG_DEBUG_FS
  1657. int intel_crtc_set_crc_source(struct drm_crtc *crtc, const char *source_name,
  1658. size_t *values_cnt);
  1659. #else
  1660. #define intel_crtc_set_crc_source NULL
  1661. #endif
  1662. extern const struct file_operations i915_display_crc_ctl_fops;
  1663. #endif /* __INTEL_DRV_H__ */