intel_drv.h 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525
  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_fb_helper.h>
  35. #include <drm/drm_dp_mst_helper.h>
  36. #include <drm/drm_rect.h>
  37. #include <drm/drm_atomic.h>
  38. /**
  39. * _wait_for - magic (register) wait macro
  40. *
  41. * Does the right thing for modeset paths when run under kdgb or similar atomic
  42. * contexts. Note that it's important that we check the condition again after
  43. * having timed out, since the timeout could be due to preemption or similar and
  44. * we've never had a chance to check the condition before the timeout.
  45. */
  46. #define _wait_for(COND, MS, W) ({ \
  47. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
  48. int ret__ = 0; \
  49. while (!(COND)) { \
  50. if (time_after(jiffies, timeout__)) { \
  51. if (!(COND)) \
  52. ret__ = -ETIMEDOUT; \
  53. break; \
  54. } \
  55. if ((W) && drm_can_sleep()) { \
  56. usleep_range((W)*1000, (W)*2000); \
  57. } else { \
  58. cpu_relax(); \
  59. } \
  60. } \
  61. ret__; \
  62. })
  63. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  64. #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
  65. #define wait_for_atomic_us(COND, US) _wait_for((COND), \
  66. DIV_ROUND_UP((US), 1000), 0)
  67. #define KHz(x) (1000 * (x))
  68. #define MHz(x) KHz(1000 * (x))
  69. /*
  70. * Display related stuff
  71. */
  72. /* store information about an Ixxx DVO */
  73. /* The i830->i865 use multiple DVOs with multiple i2cs */
  74. /* the i915, i945 have a single sDVO i2c bus - which is different */
  75. #define MAX_OUTPUTS 6
  76. /* maximum connectors per crtcs in the mode set */
  77. /* Maximum cursor sizes */
  78. #define GEN2_CURSOR_WIDTH 64
  79. #define GEN2_CURSOR_HEIGHT 64
  80. #define MAX_CURSOR_WIDTH 256
  81. #define MAX_CURSOR_HEIGHT 256
  82. #define INTEL_I2C_BUS_DVO 1
  83. #define INTEL_I2C_BUS_SDVO 2
  84. /* these are outputs from the chip - integrated only
  85. external chips are via DVO or SDVO output */
  86. enum intel_output_type {
  87. INTEL_OUTPUT_UNUSED = 0,
  88. INTEL_OUTPUT_ANALOG = 1,
  89. INTEL_OUTPUT_DVO = 2,
  90. INTEL_OUTPUT_SDVO = 3,
  91. INTEL_OUTPUT_LVDS = 4,
  92. INTEL_OUTPUT_TVOUT = 5,
  93. INTEL_OUTPUT_HDMI = 6,
  94. INTEL_OUTPUT_DISPLAYPORT = 7,
  95. INTEL_OUTPUT_EDP = 8,
  96. INTEL_OUTPUT_DSI = 9,
  97. INTEL_OUTPUT_UNKNOWN = 10,
  98. INTEL_OUTPUT_DP_MST = 11,
  99. };
  100. #define INTEL_DVO_CHIP_NONE 0
  101. #define INTEL_DVO_CHIP_LVDS 1
  102. #define INTEL_DVO_CHIP_TMDS 2
  103. #define INTEL_DVO_CHIP_TVOUT 4
  104. #define INTEL_DSI_VIDEO_MODE 0
  105. #define INTEL_DSI_COMMAND_MODE 1
  106. struct intel_framebuffer {
  107. struct drm_framebuffer base;
  108. struct drm_i915_gem_object *obj;
  109. };
  110. struct intel_fbdev {
  111. struct drm_fb_helper helper;
  112. struct intel_framebuffer *fb;
  113. struct list_head fbdev_list;
  114. struct drm_display_mode *our_mode;
  115. int preferred_bpp;
  116. };
  117. struct intel_encoder {
  118. struct drm_encoder base;
  119. enum intel_output_type type;
  120. unsigned int cloneable;
  121. void (*hot_plug)(struct intel_encoder *);
  122. bool (*compute_config)(struct intel_encoder *,
  123. struct intel_crtc_state *);
  124. void (*pre_pll_enable)(struct intel_encoder *);
  125. void (*pre_enable)(struct intel_encoder *);
  126. void (*enable)(struct intel_encoder *);
  127. void (*mode_set)(struct intel_encoder *intel_encoder);
  128. void (*disable)(struct intel_encoder *);
  129. void (*post_disable)(struct intel_encoder *);
  130. void (*post_pll_disable)(struct intel_encoder *);
  131. /* Read out the current hw state of this connector, returning true if
  132. * the encoder is active. If the encoder is enabled it also set the pipe
  133. * it is connected to in the pipe parameter. */
  134. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  135. /* Reconstructs the equivalent mode flags for the current hardware
  136. * state. This must be called _after_ display->get_pipe_config has
  137. * pre-filled the pipe config. Note that intel_encoder->base.crtc must
  138. * be set correctly before calling this function. */
  139. void (*get_config)(struct intel_encoder *,
  140. struct intel_crtc_state *pipe_config);
  141. /*
  142. * Called during system suspend after all pending requests for the
  143. * encoder are flushed (for example for DP AUX transactions) and
  144. * device interrupts are disabled.
  145. */
  146. void (*suspend)(struct intel_encoder *);
  147. int crtc_mask;
  148. enum hpd_pin hpd_pin;
  149. };
  150. struct intel_panel {
  151. struct drm_display_mode *fixed_mode;
  152. struct drm_display_mode *downclock_mode;
  153. int fitting_mode;
  154. /* backlight */
  155. struct {
  156. bool present;
  157. u32 level;
  158. u32 min;
  159. u32 max;
  160. bool enabled;
  161. bool combination_mode; /* gen 2/4 only */
  162. bool active_low_pwm;
  163. /* PWM chip */
  164. bool util_pin_active_low; /* bxt+ */
  165. u8 controller; /* bxt+ only */
  166. struct pwm_device *pwm;
  167. struct backlight_device *device;
  168. /* Connector and platform specific backlight functions */
  169. int (*setup)(struct intel_connector *connector, enum pipe pipe);
  170. uint32_t (*get)(struct intel_connector *connector);
  171. void (*set)(struct intel_connector *connector, uint32_t level);
  172. void (*disable)(struct intel_connector *connector);
  173. void (*enable)(struct intel_connector *connector);
  174. uint32_t (*hz_to_pwm)(struct intel_connector *connector,
  175. uint32_t hz);
  176. void (*power)(struct intel_connector *, bool enable);
  177. } backlight;
  178. };
  179. struct intel_connector {
  180. struct drm_connector base;
  181. /*
  182. * The fixed encoder this connector is connected to.
  183. */
  184. struct intel_encoder *encoder;
  185. /* Reads out the current hw, returning true if the connector is enabled
  186. * and active (i.e. dpms ON state). */
  187. bool (*get_hw_state)(struct intel_connector *);
  188. /*
  189. * Removes all interfaces through which the connector is accessible
  190. * - like sysfs, debugfs entries -, so that no new operations can be
  191. * started on the connector. Also makes sure all currently pending
  192. * operations finish before returing.
  193. */
  194. void (*unregister)(struct intel_connector *);
  195. /* Panel info for eDP and LVDS */
  196. struct intel_panel panel;
  197. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  198. struct edid *edid;
  199. struct edid *detect_edid;
  200. /* since POLL and HPD connectors may use the same HPD line keep the native
  201. state of connector->polled in case hotplug storm detection changes it */
  202. u8 polled;
  203. void *port; /* store this opaque as its illegal to dereference it */
  204. struct intel_dp *mst_port;
  205. };
  206. typedef struct dpll {
  207. /* given values */
  208. int n;
  209. int m1, m2;
  210. int p1, p2;
  211. /* derived values */
  212. int dot;
  213. int vco;
  214. int m;
  215. int p;
  216. } intel_clock_t;
  217. struct intel_atomic_state {
  218. struct drm_atomic_state base;
  219. unsigned int cdclk;
  220. bool dpll_set;
  221. struct intel_shared_dpll_config shared_dpll[I915_NUM_PLLS];
  222. struct intel_wm_config wm_config;
  223. };
  224. struct intel_plane_state {
  225. struct drm_plane_state base;
  226. struct drm_rect src;
  227. struct drm_rect dst;
  228. struct drm_rect clip;
  229. bool visible;
  230. /*
  231. * scaler_id
  232. * = -1 : not using a scaler
  233. * >= 0 : using a scalers
  234. *
  235. * plane requiring a scaler:
  236. * - During check_plane, its bit is set in
  237. * crtc_state->scaler_state.scaler_users by calling helper function
  238. * update_scaler_plane.
  239. * - scaler_id indicates the scaler it got assigned.
  240. *
  241. * plane doesn't require a scaler:
  242. * - this can happen when scaling is no more required or plane simply
  243. * got disabled.
  244. * - During check_plane, corresponding bit is reset in
  245. * crtc_state->scaler_state.scaler_users by calling helper function
  246. * update_scaler_plane.
  247. */
  248. int scaler_id;
  249. struct drm_intel_sprite_colorkey ckey;
  250. /* async flip related structures */
  251. struct drm_i915_gem_request *wait_req;
  252. };
  253. struct intel_initial_plane_config {
  254. struct intel_framebuffer *fb;
  255. unsigned int tiling;
  256. int size;
  257. u32 base;
  258. };
  259. #define SKL_MIN_SRC_W 8
  260. #define SKL_MAX_SRC_W 4096
  261. #define SKL_MIN_SRC_H 8
  262. #define SKL_MAX_SRC_H 4096
  263. #define SKL_MIN_DST_W 8
  264. #define SKL_MAX_DST_W 4096
  265. #define SKL_MIN_DST_H 8
  266. #define SKL_MAX_DST_H 4096
  267. struct intel_scaler {
  268. int in_use;
  269. uint32_t mode;
  270. };
  271. struct intel_crtc_scaler_state {
  272. #define SKL_NUM_SCALERS 2
  273. struct intel_scaler scalers[SKL_NUM_SCALERS];
  274. /*
  275. * scaler_users: keeps track of users requesting scalers on this crtc.
  276. *
  277. * If a bit is set, a user is using a scaler.
  278. * Here user can be a plane or crtc as defined below:
  279. * bits 0-30 - plane (bit position is index from drm_plane_index)
  280. * bit 31 - crtc
  281. *
  282. * Instead of creating a new index to cover planes and crtc, using
  283. * existing drm_plane_index for planes which is well less than 31
  284. * planes and bit 31 for crtc. This should be fine to cover all
  285. * our platforms.
  286. *
  287. * intel_atomic_setup_scalers will setup available scalers to users
  288. * requesting scalers. It will gracefully fail if request exceeds
  289. * avilability.
  290. */
  291. #define SKL_CRTC_INDEX 31
  292. unsigned scaler_users;
  293. /* scaler used by crtc for panel fitting purpose */
  294. int scaler_id;
  295. };
  296. /* drm_mode->private_flags */
  297. #define I915_MODE_FLAG_INHERITED 1
  298. struct intel_pipe_wm {
  299. struct intel_wm_level wm[5];
  300. uint32_t linetime;
  301. bool fbc_wm_enabled;
  302. bool pipe_enabled;
  303. bool sprites_enabled;
  304. bool sprites_scaled;
  305. };
  306. struct skl_pipe_wm {
  307. struct skl_wm_level wm[8];
  308. struct skl_wm_level trans_wm;
  309. uint32_t linetime;
  310. };
  311. struct intel_crtc_state {
  312. struct drm_crtc_state base;
  313. /**
  314. * quirks - bitfield with hw state readout quirks
  315. *
  316. * For various reasons the hw state readout code might not be able to
  317. * completely faithfully read out the current state. These cases are
  318. * tracked with quirk flags so that fastboot and state checker can act
  319. * accordingly.
  320. */
  321. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  322. unsigned long quirks;
  323. bool update_pipe; /* can a fast modeset be performed? */
  324. bool disable_cxsr;
  325. /* Pipe source size (ie. panel fitter input size)
  326. * All planes will be positioned inside this space,
  327. * and get clipped at the edges. */
  328. int pipe_src_w, pipe_src_h;
  329. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  330. * between pch encoders and cpu encoders. */
  331. bool has_pch_encoder;
  332. /* Are we sending infoframes on the attached port */
  333. bool has_infoframe;
  334. /* CPU Transcoder for the pipe. Currently this can only differ from the
  335. * pipe on Haswell (where we have a special eDP transcoder). */
  336. enum transcoder cpu_transcoder;
  337. /*
  338. * Use reduced/limited/broadcast rbg range, compressing from the full
  339. * range fed into the crtcs.
  340. */
  341. bool limited_color_range;
  342. /* DP has a bunch of special case unfortunately, so mark the pipe
  343. * accordingly. */
  344. bool has_dp_encoder;
  345. /* DSI has special cases */
  346. bool has_dsi_encoder;
  347. /* Whether we should send NULL infoframes. Required for audio. */
  348. bool has_hdmi_sink;
  349. /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
  350. * has_dp_encoder is set. */
  351. bool has_audio;
  352. /*
  353. * Enable dithering, used when the selected pipe bpp doesn't match the
  354. * plane bpp.
  355. */
  356. bool dither;
  357. /* Controls for the clock computation, to override various stages. */
  358. bool clock_set;
  359. /* SDVO TV has a bunch of special case. To make multifunction encoders
  360. * work correctly, we need to track this at runtime.*/
  361. bool sdvo_tv_clock;
  362. /*
  363. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  364. * required. This is set in the 2nd loop of calling encoder's
  365. * ->compute_config if the first pick doesn't work out.
  366. */
  367. bool bw_constrained;
  368. /* Settings for the intel dpll used on pretty much everything but
  369. * haswell. */
  370. struct dpll dpll;
  371. /* Selected dpll when shared or DPLL_ID_PRIVATE. */
  372. enum intel_dpll_id shared_dpll;
  373. /*
  374. * - PORT_CLK_SEL for DDI ports on HSW/BDW.
  375. * - enum skl_dpll on SKL
  376. */
  377. uint32_t ddi_pll_sel;
  378. /* Actual register state of the dpll, for shared dpll cross-checking. */
  379. struct intel_dpll_hw_state dpll_hw_state;
  380. int pipe_bpp;
  381. struct intel_link_m_n dp_m_n;
  382. /* m2_n2 for eDP downclock */
  383. struct intel_link_m_n dp_m2_n2;
  384. bool has_drrs;
  385. /*
  386. * Frequence the dpll for the port should run at. Differs from the
  387. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  388. * already multiplied by pixel_multiplier.
  389. */
  390. int port_clock;
  391. /* Used by SDVO (and if we ever fix it, HDMI). */
  392. unsigned pixel_multiplier;
  393. uint8_t lane_count;
  394. /* Panel fitter controls for gen2-gen4 + VLV */
  395. struct {
  396. u32 control;
  397. u32 pgm_ratios;
  398. u32 lvds_border_bits;
  399. } gmch_pfit;
  400. /* Panel fitter placement and size for Ironlake+ */
  401. struct {
  402. u32 pos;
  403. u32 size;
  404. bool enabled;
  405. bool force_thru;
  406. } pch_pfit;
  407. /* FDI configuration, only valid if has_pch_encoder is set. */
  408. int fdi_lanes;
  409. struct intel_link_m_n fdi_m_n;
  410. bool ips_enabled;
  411. bool double_wide;
  412. bool dp_encoder_is_mst;
  413. int pbn;
  414. struct intel_crtc_scaler_state scaler_state;
  415. /* w/a for waiting 2 vblanks during crtc enable */
  416. enum pipe hsw_workaround_pipe;
  417. /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
  418. bool disable_lp_wm;
  419. struct {
  420. /*
  421. * optimal watermarks, programmed post-vblank when this state
  422. * is committed
  423. */
  424. union {
  425. struct intel_pipe_wm ilk;
  426. struct skl_pipe_wm skl;
  427. } optimal;
  428. } wm;
  429. };
  430. struct vlv_wm_state {
  431. struct vlv_pipe_wm wm[3];
  432. struct vlv_sr_wm sr[3];
  433. uint8_t num_active_planes;
  434. uint8_t num_levels;
  435. uint8_t level;
  436. bool cxsr;
  437. };
  438. struct intel_mmio_flip {
  439. struct work_struct work;
  440. struct drm_i915_private *i915;
  441. struct drm_i915_gem_request *req;
  442. struct intel_crtc *crtc;
  443. unsigned int rotation;
  444. };
  445. /*
  446. * Tracking of operations that need to be performed at the beginning/end of an
  447. * atomic commit, outside the atomic section where interrupts are disabled.
  448. * These are generally operations that grab mutexes or might otherwise sleep
  449. * and thus can't be run with interrupts disabled.
  450. */
  451. struct intel_crtc_atomic_commit {
  452. /* Sleepable operations to perform before commit */
  453. bool disable_fbc;
  454. bool disable_ips;
  455. bool pre_disable_primary;
  456. bool update_wm_pre, update_wm_post;
  457. /* Sleepable operations to perform after commit */
  458. unsigned fb_bits;
  459. bool wait_vblank;
  460. bool update_fbc;
  461. bool post_enable_primary;
  462. unsigned update_sprite_watermarks;
  463. };
  464. struct intel_crtc {
  465. struct drm_crtc base;
  466. enum pipe pipe;
  467. enum plane plane;
  468. u8 lut_r[256], lut_g[256], lut_b[256];
  469. /*
  470. * Whether the crtc and the connected output pipeline is active. Implies
  471. * that crtc->enabled is set, i.e. the current mode configuration has
  472. * some outputs connected to this crtc.
  473. */
  474. bool active;
  475. unsigned long enabled_power_domains;
  476. bool lowfreq_avail;
  477. struct intel_overlay *overlay;
  478. struct intel_unpin_work *unpin_work;
  479. atomic_t unpin_work_count;
  480. /* Display surface base address adjustement for pageflips. Note that on
  481. * gen4+ this only adjusts up to a tile, offsets within a tile are
  482. * handled in the hw itself (with the TILEOFF register). */
  483. unsigned long dspaddr_offset;
  484. int adjusted_x;
  485. int adjusted_y;
  486. struct drm_i915_gem_object *cursor_bo;
  487. uint32_t cursor_addr;
  488. uint32_t cursor_cntl;
  489. uint32_t cursor_size;
  490. uint32_t cursor_base;
  491. struct intel_crtc_state *config;
  492. /* reset counter value when the last flip was submitted */
  493. unsigned int reset_counter;
  494. /* Access to these should be protected by dev_priv->irq_lock. */
  495. bool cpu_fifo_underrun_disabled;
  496. bool pch_fifo_underrun_disabled;
  497. /* per-pipe watermark state */
  498. struct {
  499. /* watermarks currently being used */
  500. union {
  501. struct intel_pipe_wm ilk;
  502. struct skl_pipe_wm skl;
  503. } active;
  504. /* allow CxSR on this pipe */
  505. bool cxsr_allowed;
  506. } wm;
  507. int scanline_offset;
  508. struct {
  509. unsigned start_vbl_count;
  510. ktime_t start_vbl_time;
  511. int min_vbl, max_vbl;
  512. int scanline_start;
  513. } debug;
  514. struct intel_crtc_atomic_commit atomic;
  515. /* scalers available on this crtc */
  516. int num_scalers;
  517. struct vlv_wm_state wm_state;
  518. };
  519. struct intel_plane_wm_parameters {
  520. uint32_t horiz_pixels;
  521. uint32_t vert_pixels;
  522. /*
  523. * For packed pixel formats:
  524. * bytes_per_pixel - holds bytes per pixel
  525. * For planar pixel formats:
  526. * bytes_per_pixel - holds bytes per pixel for uv-plane
  527. * y_bytes_per_pixel - holds bytes per pixel for y-plane
  528. */
  529. uint8_t bytes_per_pixel;
  530. uint8_t y_bytes_per_pixel;
  531. bool enabled;
  532. bool scaled;
  533. u64 tiling;
  534. unsigned int rotation;
  535. uint16_t fifo_size;
  536. };
  537. struct intel_plane {
  538. struct drm_plane base;
  539. int plane;
  540. enum pipe pipe;
  541. bool can_scale;
  542. int max_downscale;
  543. uint32_t frontbuffer_bit;
  544. /* Since we need to change the watermarks before/after
  545. * enabling/disabling the planes, we need to store the parameters here
  546. * as the other pieces of the struct may not reflect the values we want
  547. * for the watermark calculations. Currently only Haswell uses this.
  548. */
  549. struct intel_plane_wm_parameters wm;
  550. /*
  551. * NOTE: Do not place new plane state fields here (e.g., when adding
  552. * new plane properties). New runtime state should now be placed in
  553. * the intel_plane_state structure and accessed via drm_plane->state.
  554. */
  555. void (*update_plane)(struct drm_plane *plane,
  556. struct drm_crtc *crtc,
  557. struct drm_framebuffer *fb,
  558. int crtc_x, int crtc_y,
  559. unsigned int crtc_w, unsigned int crtc_h,
  560. uint32_t x, uint32_t y,
  561. uint32_t src_w, uint32_t src_h);
  562. void (*disable_plane)(struct drm_plane *plane,
  563. struct drm_crtc *crtc);
  564. int (*check_plane)(struct drm_plane *plane,
  565. struct intel_crtc_state *crtc_state,
  566. struct intel_plane_state *state);
  567. void (*commit_plane)(struct drm_plane *plane,
  568. struct intel_plane_state *state);
  569. };
  570. struct intel_watermark_params {
  571. unsigned long fifo_size;
  572. unsigned long max_wm;
  573. unsigned long default_wm;
  574. unsigned long guard_size;
  575. unsigned long cacheline_size;
  576. };
  577. struct cxsr_latency {
  578. int is_desktop;
  579. int is_ddr3;
  580. unsigned long fsb_freq;
  581. unsigned long mem_freq;
  582. unsigned long display_sr;
  583. unsigned long display_hpll_disable;
  584. unsigned long cursor_sr;
  585. unsigned long cursor_hpll_disable;
  586. };
  587. #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
  588. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  589. #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
  590. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  591. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  592. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  593. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  594. #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
  595. #define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL)
  596. struct intel_hdmi {
  597. i915_reg_t hdmi_reg;
  598. int ddc_bus;
  599. bool limited_color_range;
  600. bool color_range_auto;
  601. bool has_hdmi_sink;
  602. bool has_audio;
  603. enum hdmi_force_audio force_audio;
  604. bool rgb_quant_range_selectable;
  605. enum hdmi_picture_aspect aspect_ratio;
  606. struct intel_connector *attached_connector;
  607. void (*write_infoframe)(struct drm_encoder *encoder,
  608. enum hdmi_infoframe_type type,
  609. const void *frame, ssize_t len);
  610. void (*set_infoframes)(struct drm_encoder *encoder,
  611. bool enable,
  612. const struct drm_display_mode *adjusted_mode);
  613. bool (*infoframe_enabled)(struct drm_encoder *encoder,
  614. const struct intel_crtc_state *pipe_config);
  615. };
  616. struct intel_dp_mst_encoder;
  617. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  618. /*
  619. * enum link_m_n_set:
  620. * When platform provides two set of M_N registers for dp, we can
  621. * program them and switch between them incase of DRRS.
  622. * But When only one such register is provided, we have to program the
  623. * required divider value on that registers itself based on the DRRS state.
  624. *
  625. * M1_N1 : Program dp_m_n on M1_N1 registers
  626. * dp_m2_n2 on M2_N2 registers (If supported)
  627. *
  628. * M2_N2 : Program dp_m2_n2 on M1_N1 registers
  629. * M2_N2 registers are not supported
  630. */
  631. enum link_m_n_set {
  632. /* Sets the m1_n1 and m2_n2 */
  633. M1_N1 = 0,
  634. M2_N2
  635. };
  636. struct intel_dp {
  637. i915_reg_t output_reg;
  638. i915_reg_t aux_ch_ctl_reg;
  639. i915_reg_t aux_ch_data_reg[5];
  640. uint32_t DP;
  641. int link_rate;
  642. uint8_t lane_count;
  643. bool has_audio;
  644. enum hdmi_force_audio force_audio;
  645. bool limited_color_range;
  646. bool color_range_auto;
  647. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  648. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  649. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  650. /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
  651. uint8_t num_sink_rates;
  652. int sink_rates[DP_MAX_SUPPORTED_RATES];
  653. struct drm_dp_aux aux;
  654. uint8_t train_set[4];
  655. int panel_power_up_delay;
  656. int panel_power_down_delay;
  657. int panel_power_cycle_delay;
  658. int backlight_on_delay;
  659. int backlight_off_delay;
  660. struct delayed_work panel_vdd_work;
  661. bool want_panel_vdd;
  662. unsigned long last_power_cycle;
  663. unsigned long last_power_on;
  664. unsigned long last_backlight_off;
  665. struct notifier_block edp_notifier;
  666. /*
  667. * Pipe whose power sequencer is currently locked into
  668. * this port. Only relevant on VLV/CHV.
  669. */
  670. enum pipe pps_pipe;
  671. struct edp_power_seq pps_delays;
  672. bool can_mst; /* this port supports mst */
  673. bool is_mst;
  674. int active_mst_links;
  675. /* connector directly attached - won't be use for modeset in mst world */
  676. struct intel_connector *attached_connector;
  677. /* mst connector list */
  678. struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
  679. struct drm_dp_mst_topology_mgr mst_mgr;
  680. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  681. /*
  682. * This function returns the value we have to program the AUX_CTL
  683. * register with to kick off an AUX transaction.
  684. */
  685. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  686. bool has_aux_irq,
  687. int send_bytes,
  688. uint32_t aux_clock_divider);
  689. /* This is called before a link training is starterd */
  690. void (*prepare_link_retrain)(struct intel_dp *intel_dp);
  691. bool train_set_valid;
  692. /* Displayport compliance testing */
  693. unsigned long compliance_test_type;
  694. unsigned long compliance_test_data;
  695. bool compliance_test_active;
  696. };
  697. struct intel_digital_port {
  698. struct intel_encoder base;
  699. enum port port;
  700. u32 saved_port_bits;
  701. struct intel_dp dp;
  702. struct intel_hdmi hdmi;
  703. enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
  704. bool release_cl2_override;
  705. };
  706. struct intel_dp_mst_encoder {
  707. struct intel_encoder base;
  708. enum pipe pipe;
  709. struct intel_digital_port *primary;
  710. void *port; /* store this opaque as its illegal to dereference it */
  711. };
  712. static inline enum dpio_channel
  713. vlv_dport_to_channel(struct intel_digital_port *dport)
  714. {
  715. switch (dport->port) {
  716. case PORT_B:
  717. case PORT_D:
  718. return DPIO_CH0;
  719. case PORT_C:
  720. return DPIO_CH1;
  721. default:
  722. BUG();
  723. }
  724. }
  725. static inline enum dpio_phy
  726. vlv_dport_to_phy(struct intel_digital_port *dport)
  727. {
  728. switch (dport->port) {
  729. case PORT_B:
  730. case PORT_C:
  731. return DPIO_PHY0;
  732. case PORT_D:
  733. return DPIO_PHY1;
  734. default:
  735. BUG();
  736. }
  737. }
  738. static inline enum dpio_channel
  739. vlv_pipe_to_channel(enum pipe pipe)
  740. {
  741. switch (pipe) {
  742. case PIPE_A:
  743. case PIPE_C:
  744. return DPIO_CH0;
  745. case PIPE_B:
  746. return DPIO_CH1;
  747. default:
  748. BUG();
  749. }
  750. }
  751. static inline struct drm_crtc *
  752. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  753. {
  754. struct drm_i915_private *dev_priv = dev->dev_private;
  755. return dev_priv->pipe_to_crtc_mapping[pipe];
  756. }
  757. static inline struct drm_crtc *
  758. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  759. {
  760. struct drm_i915_private *dev_priv = dev->dev_private;
  761. return dev_priv->plane_to_crtc_mapping[plane];
  762. }
  763. struct intel_unpin_work {
  764. struct work_struct work;
  765. struct drm_crtc *crtc;
  766. struct drm_framebuffer *old_fb;
  767. struct drm_i915_gem_object *pending_flip_obj;
  768. struct drm_pending_vblank_event *event;
  769. atomic_t pending;
  770. #define INTEL_FLIP_INACTIVE 0
  771. #define INTEL_FLIP_PENDING 1
  772. #define INTEL_FLIP_COMPLETE 2
  773. u32 flip_count;
  774. u32 gtt_offset;
  775. struct drm_i915_gem_request *flip_queued_req;
  776. u32 flip_queued_vblank;
  777. u32 flip_ready_vblank;
  778. bool enable_stall_check;
  779. };
  780. struct intel_load_detect_pipe {
  781. struct drm_framebuffer *release_fb;
  782. bool load_detect_temp;
  783. int dpms_mode;
  784. };
  785. static inline struct intel_encoder *
  786. intel_attached_encoder(struct drm_connector *connector)
  787. {
  788. return to_intel_connector(connector)->encoder;
  789. }
  790. static inline struct intel_digital_port *
  791. enc_to_dig_port(struct drm_encoder *encoder)
  792. {
  793. return container_of(encoder, struct intel_digital_port, base.base);
  794. }
  795. static inline struct intel_dp_mst_encoder *
  796. enc_to_mst(struct drm_encoder *encoder)
  797. {
  798. return container_of(encoder, struct intel_dp_mst_encoder, base.base);
  799. }
  800. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  801. {
  802. return &enc_to_dig_port(encoder)->dp;
  803. }
  804. static inline struct intel_digital_port *
  805. dp_to_dig_port(struct intel_dp *intel_dp)
  806. {
  807. return container_of(intel_dp, struct intel_digital_port, dp);
  808. }
  809. static inline struct intel_digital_port *
  810. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  811. {
  812. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  813. }
  814. /*
  815. * Returns the number of planes for this pipe, ie the number of sprites + 1
  816. * (primary plane). This doesn't count the cursor plane then.
  817. */
  818. static inline unsigned int intel_num_planes(struct intel_crtc *crtc)
  819. {
  820. return INTEL_INFO(crtc->base.dev)->num_sprites[crtc->pipe] + 1;
  821. }
  822. /* intel_fifo_underrun.c */
  823. bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  824. enum pipe pipe, bool enable);
  825. bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  826. enum transcoder pch_transcoder,
  827. bool enable);
  828. void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  829. enum pipe pipe);
  830. void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  831. enum transcoder pch_transcoder);
  832. void intel_check_cpu_fifo_underruns(struct drm_i915_private *dev_priv);
  833. void intel_check_pch_fifo_underruns(struct drm_i915_private *dev_priv);
  834. /* i915_irq.c */
  835. void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  836. void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  837. void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  838. void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  839. void gen6_reset_rps_interrupts(struct drm_device *dev);
  840. void gen6_enable_rps_interrupts(struct drm_device *dev);
  841. void gen6_disable_rps_interrupts(struct drm_device *dev);
  842. u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
  843. void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
  844. void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
  845. static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
  846. {
  847. /*
  848. * We only use drm_irq_uninstall() at unload and VT switch, so
  849. * this is the only thing we need to check.
  850. */
  851. return dev_priv->pm.irqs_enabled;
  852. }
  853. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  854. void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
  855. unsigned int pipe_mask);
  856. /* intel_crt.c */
  857. void intel_crt_init(struct drm_device *dev);
  858. /* intel_ddi.c */
  859. void intel_ddi_clk_select(struct intel_encoder *encoder,
  860. const struct intel_crtc_state *pipe_config);
  861. void intel_prepare_ddi(struct drm_device *dev);
  862. void hsw_fdi_link_train(struct drm_crtc *crtc);
  863. void intel_ddi_init(struct drm_device *dev, enum port port);
  864. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  865. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  866. void intel_ddi_pll_init(struct drm_device *dev);
  867. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  868. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  869. enum transcoder cpu_transcoder);
  870. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  871. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  872. bool intel_ddi_pll_select(struct intel_crtc *crtc,
  873. struct intel_crtc_state *crtc_state);
  874. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  875. void intel_ddi_prepare_link_retrain(struct intel_dp *intel_dp);
  876. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  877. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  878. void intel_ddi_get_config(struct intel_encoder *encoder,
  879. struct intel_crtc_state *pipe_config);
  880. struct intel_encoder *
  881. intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
  882. void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
  883. void intel_ddi_clock_get(struct intel_encoder *encoder,
  884. struct intel_crtc_state *pipe_config);
  885. void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state);
  886. uint32_t ddi_signal_levels(struct intel_dp *intel_dp);
  887. /* intel_frontbuffer.c */
  888. void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
  889. enum fb_op_origin origin);
  890. void intel_frontbuffer_flip_prepare(struct drm_device *dev,
  891. unsigned frontbuffer_bits);
  892. void intel_frontbuffer_flip_complete(struct drm_device *dev,
  893. unsigned frontbuffer_bits);
  894. void intel_frontbuffer_flip(struct drm_device *dev,
  895. unsigned frontbuffer_bits);
  896. unsigned int intel_fb_align_height(struct drm_device *dev,
  897. unsigned int height,
  898. uint32_t pixel_format,
  899. uint64_t fb_format_modifier);
  900. void intel_fb_obj_flush(struct drm_i915_gem_object *obj, bool retire,
  901. enum fb_op_origin origin);
  902. u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,
  903. uint32_t pixel_format);
  904. /* intel_audio.c */
  905. void intel_init_audio(struct drm_device *dev);
  906. void intel_audio_codec_enable(struct intel_encoder *encoder);
  907. void intel_audio_codec_disable(struct intel_encoder *encoder);
  908. void i915_audio_component_init(struct drm_i915_private *dev_priv);
  909. void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
  910. /* intel_display.c */
  911. extern const struct drm_plane_funcs intel_plane_funcs;
  912. bool intel_has_pending_fb_unpin(struct drm_device *dev);
  913. int intel_pch_rawclk(struct drm_device *dev);
  914. int intel_hrawclk(struct drm_device *dev);
  915. void intel_mark_busy(struct drm_device *dev);
  916. void intel_mark_idle(struct drm_device *dev);
  917. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  918. int intel_display_suspend(struct drm_device *dev);
  919. void intel_encoder_destroy(struct drm_encoder *encoder);
  920. int intel_connector_init(struct intel_connector *);
  921. struct intel_connector *intel_connector_alloc(void);
  922. bool intel_connector_get_hw_state(struct intel_connector *connector);
  923. void intel_connector_attach_encoder(struct intel_connector *connector,
  924. struct intel_encoder *encoder);
  925. struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  926. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  927. struct drm_crtc *crtc);
  928. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  929. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  930. struct drm_file *file_priv);
  931. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  932. enum pipe pipe);
  933. bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type);
  934. static inline void
  935. intel_wait_for_vblank(struct drm_device *dev, int pipe)
  936. {
  937. drm_wait_one_vblank(dev, pipe);
  938. }
  939. static inline void
  940. intel_wait_for_vblank_if_active(struct drm_device *dev, int pipe)
  941. {
  942. const struct intel_crtc *crtc =
  943. to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe));
  944. if (crtc->active)
  945. intel_wait_for_vblank(dev, pipe);
  946. }
  947. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  948. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  949. struct intel_digital_port *dport,
  950. unsigned int expected_mask);
  951. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  952. struct drm_display_mode *mode,
  953. struct intel_load_detect_pipe *old,
  954. struct drm_modeset_acquire_ctx *ctx);
  955. void intel_release_load_detect_pipe(struct drm_connector *connector,
  956. struct intel_load_detect_pipe *old,
  957. struct drm_modeset_acquire_ctx *ctx);
  958. int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
  959. struct drm_framebuffer *fb,
  960. const struct drm_plane_state *plane_state);
  961. struct drm_framebuffer *
  962. __intel_framebuffer_create(struct drm_device *dev,
  963. struct drm_mode_fb_cmd2 *mode_cmd,
  964. struct drm_i915_gem_object *obj);
  965. void intel_prepare_page_flip(struct drm_device *dev, int plane);
  966. void intel_finish_page_flip(struct drm_device *dev, int pipe);
  967. void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  968. void intel_check_page_flip(struct drm_device *dev, int pipe);
  969. int intel_prepare_plane_fb(struct drm_plane *plane,
  970. const struct drm_plane_state *new_state);
  971. void intel_cleanup_plane_fb(struct drm_plane *plane,
  972. const struct drm_plane_state *old_state);
  973. int intel_plane_atomic_get_property(struct drm_plane *plane,
  974. const struct drm_plane_state *state,
  975. struct drm_property *property,
  976. uint64_t *val);
  977. int intel_plane_atomic_set_property(struct drm_plane *plane,
  978. struct drm_plane_state *state,
  979. struct drm_property *property,
  980. uint64_t val);
  981. int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
  982. struct drm_plane_state *plane_state);
  983. unsigned int
  984. intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
  985. uint64_t fb_format_modifier, unsigned int plane);
  986. static inline bool
  987. intel_rotation_90_or_270(unsigned int rotation)
  988. {
  989. return rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270));
  990. }
  991. void intel_create_rotation_property(struct drm_device *dev,
  992. struct intel_plane *plane);
  993. /* shared dpll functions */
  994. struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
  995. void assert_shared_dpll(struct drm_i915_private *dev_priv,
  996. struct intel_shared_dpll *pll,
  997. bool state);
  998. #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
  999. #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
  1000. struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
  1001. struct intel_crtc_state *state);
  1002. void vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
  1003. const struct dpll *dpll);
  1004. void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe);
  1005. /* modesetting asserts */
  1006. void assert_panel_unlocked(struct drm_i915_private *dev_priv,
  1007. enum pipe pipe);
  1008. void assert_pll(struct drm_i915_private *dev_priv,
  1009. enum pipe pipe, bool state);
  1010. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  1011. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  1012. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  1013. enum pipe pipe, bool state);
  1014. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  1015. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  1016. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  1017. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  1018. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  1019. unsigned long intel_gen4_compute_page_offset(struct drm_i915_private *dev_priv,
  1020. int *x, int *y,
  1021. unsigned int tiling_mode,
  1022. unsigned int bpp,
  1023. unsigned int pitch);
  1024. void intel_prepare_reset(struct drm_device *dev);
  1025. void intel_finish_reset(struct drm_device *dev);
  1026. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  1027. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  1028. void broxton_init_cdclk(struct drm_device *dev);
  1029. void broxton_uninit_cdclk(struct drm_device *dev);
  1030. void broxton_ddi_phy_init(struct drm_device *dev);
  1031. void broxton_ddi_phy_uninit(struct drm_device *dev);
  1032. void bxt_enable_dc9(struct drm_i915_private *dev_priv);
  1033. void bxt_disable_dc9(struct drm_i915_private *dev_priv);
  1034. void skl_init_cdclk(struct drm_i915_private *dev_priv);
  1035. int skl_sanitize_cdclk(struct drm_i915_private *dev_priv);
  1036. void skl_uninit_cdclk(struct drm_i915_private *dev_priv);
  1037. void skl_enable_dc6(struct drm_i915_private *dev_priv);
  1038. void skl_disable_dc6(struct drm_i915_private *dev_priv);
  1039. void intel_dp_get_m_n(struct intel_crtc *crtc,
  1040. struct intel_crtc_state *pipe_config);
  1041. void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
  1042. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  1043. void
  1044. ironlake_check_encoder_dotclock(const struct intel_crtc_state *pipe_config,
  1045. int dotclock);
  1046. bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, int target_clock,
  1047. intel_clock_t *best_clock);
  1048. int chv_calc_dpll_params(int refclk, intel_clock_t *pll_clock);
  1049. bool intel_crtc_active(struct drm_crtc *crtc);
  1050. void hsw_enable_ips(struct intel_crtc *crtc);
  1051. void hsw_disable_ips(struct intel_crtc *crtc);
  1052. enum intel_display_power_domain
  1053. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  1054. enum intel_display_power_domain
  1055. intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder);
  1056. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  1057. struct intel_crtc_state *pipe_config);
  1058. void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
  1059. int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
  1060. int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
  1061. u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
  1062. struct drm_i915_gem_object *obj,
  1063. unsigned int plane);
  1064. u32 skl_plane_ctl_format(uint32_t pixel_format);
  1065. u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
  1066. u32 skl_plane_ctl_rotation(unsigned int rotation);
  1067. /* intel_csr.c */
  1068. void intel_csr_ucode_init(struct drm_i915_private *);
  1069. void intel_csr_load_program(struct drm_i915_private *);
  1070. void intel_csr_ucode_fini(struct drm_i915_private *);
  1071. /* intel_dp.c */
  1072. void intel_dp_init(struct drm_device *dev, i915_reg_t output_reg, enum port port);
  1073. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  1074. struct intel_connector *intel_connector);
  1075. void intel_dp_set_link_params(struct intel_dp *intel_dp,
  1076. const struct intel_crtc_state *pipe_config);
  1077. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  1078. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  1079. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  1080. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  1081. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  1082. bool intel_dp_compute_config(struct intel_encoder *encoder,
  1083. struct intel_crtc_state *pipe_config);
  1084. bool intel_dp_is_edp(struct drm_device *dev, enum port port);
  1085. enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
  1086. bool long_hpd);
  1087. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  1088. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  1089. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  1090. void intel_edp_panel_on(struct intel_dp *intel_dp);
  1091. void intel_edp_panel_off(struct intel_dp *intel_dp);
  1092. void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
  1093. void intel_dp_mst_suspend(struct drm_device *dev);
  1094. void intel_dp_mst_resume(struct drm_device *dev);
  1095. int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  1096. int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
  1097. void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
  1098. void vlv_power_sequencer_reset(struct drm_i915_private *dev_priv);
  1099. uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
  1100. void intel_plane_destroy(struct drm_plane *plane);
  1101. void intel_edp_drrs_enable(struct intel_dp *intel_dp);
  1102. void intel_edp_drrs_disable(struct intel_dp *intel_dp);
  1103. void intel_edp_drrs_invalidate(struct drm_device *dev,
  1104. unsigned frontbuffer_bits);
  1105. void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits);
  1106. bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
  1107. struct intel_digital_port *port);
  1108. void hsw_dp_set_ddi_pll_sel(struct intel_crtc_state *pipe_config);
  1109. void
  1110. intel_dp_program_link_training_pattern(struct intel_dp *intel_dp,
  1111. uint8_t dp_train_pat);
  1112. void
  1113. intel_dp_set_signal_levels(struct intel_dp *intel_dp);
  1114. void intel_dp_set_idle_link_train(struct intel_dp *intel_dp);
  1115. uint8_t
  1116. intel_dp_voltage_max(struct intel_dp *intel_dp);
  1117. uint8_t
  1118. intel_dp_pre_emphasis_max(struct intel_dp *intel_dp, uint8_t voltage_swing);
  1119. void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock,
  1120. uint8_t *link_bw, uint8_t *rate_select);
  1121. bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp);
  1122. bool
  1123. intel_dp_get_link_status(struct intel_dp *intel_dp, uint8_t link_status[DP_LINK_STATUS_SIZE]);
  1124. /* intel_dp_mst.c */
  1125. int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  1126. void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
  1127. /* intel_dsi.c */
  1128. void intel_dsi_init(struct drm_device *dev);
  1129. /* intel_dvo.c */
  1130. void intel_dvo_init(struct drm_device *dev);
  1131. /* legacy fbdev emulation in intel_fbdev.c */
  1132. #ifdef CONFIG_DRM_FBDEV_EMULATION
  1133. extern int intel_fbdev_init(struct drm_device *dev);
  1134. extern void intel_fbdev_initial_config_async(struct drm_device *dev);
  1135. extern void intel_fbdev_fini(struct drm_device *dev);
  1136. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
  1137. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  1138. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  1139. #else
  1140. static inline int intel_fbdev_init(struct drm_device *dev)
  1141. {
  1142. return 0;
  1143. }
  1144. static inline void intel_fbdev_initial_config_async(struct drm_device *dev)
  1145. {
  1146. }
  1147. static inline void intel_fbdev_fini(struct drm_device *dev)
  1148. {
  1149. }
  1150. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
  1151. {
  1152. }
  1153. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  1154. {
  1155. }
  1156. #endif
  1157. /* intel_fbc.c */
  1158. bool intel_fbc_is_active(struct drm_i915_private *dev_priv);
  1159. void intel_fbc_deactivate(struct intel_crtc *crtc);
  1160. void intel_fbc_update(struct intel_crtc *crtc);
  1161. void intel_fbc_init(struct drm_i915_private *dev_priv);
  1162. void intel_fbc_enable(struct intel_crtc *crtc);
  1163. void intel_fbc_disable(struct drm_i915_private *dev_priv);
  1164. void intel_fbc_disable_crtc(struct intel_crtc *crtc);
  1165. void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
  1166. unsigned int frontbuffer_bits,
  1167. enum fb_op_origin origin);
  1168. void intel_fbc_flush(struct drm_i915_private *dev_priv,
  1169. unsigned int frontbuffer_bits, enum fb_op_origin origin);
  1170. void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv);
  1171. /* intel_hdmi.c */
  1172. void intel_hdmi_init(struct drm_device *dev, i915_reg_t hdmi_reg, enum port port);
  1173. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  1174. struct intel_connector *intel_connector);
  1175. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  1176. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  1177. struct intel_crtc_state *pipe_config);
  1178. /* intel_lvds.c */
  1179. void intel_lvds_init(struct drm_device *dev);
  1180. bool intel_is_dual_link_lvds(struct drm_device *dev);
  1181. /* intel_modes.c */
  1182. int intel_connector_update_modes(struct drm_connector *connector,
  1183. struct edid *edid);
  1184. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  1185. void intel_attach_force_audio_property(struct drm_connector *connector);
  1186. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  1187. void intel_attach_aspect_ratio_property(struct drm_connector *connector);
  1188. /* intel_overlay.c */
  1189. void intel_setup_overlay(struct drm_device *dev);
  1190. void intel_cleanup_overlay(struct drm_device *dev);
  1191. int intel_overlay_switch_off(struct intel_overlay *overlay);
  1192. int intel_overlay_put_image(struct drm_device *dev, void *data,
  1193. struct drm_file *file_priv);
  1194. int intel_overlay_attrs(struct drm_device *dev, void *data,
  1195. struct drm_file *file_priv);
  1196. void intel_overlay_reset(struct drm_i915_private *dev_priv);
  1197. /* intel_panel.c */
  1198. int intel_panel_init(struct intel_panel *panel,
  1199. struct drm_display_mode *fixed_mode,
  1200. struct drm_display_mode *downclock_mode);
  1201. void intel_panel_fini(struct intel_panel *panel);
  1202. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  1203. struct drm_display_mode *adjusted_mode);
  1204. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  1205. struct intel_crtc_state *pipe_config,
  1206. int fitting_mode);
  1207. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  1208. struct intel_crtc_state *pipe_config,
  1209. int fitting_mode);
  1210. void intel_panel_set_backlight_acpi(struct intel_connector *connector,
  1211. u32 level, u32 max);
  1212. int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe);
  1213. void intel_panel_enable_backlight(struct intel_connector *connector);
  1214. void intel_panel_disable_backlight(struct intel_connector *connector);
  1215. void intel_panel_destroy_backlight(struct drm_connector *connector);
  1216. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  1217. extern struct drm_display_mode *intel_find_panel_downclock(
  1218. struct drm_device *dev,
  1219. struct drm_display_mode *fixed_mode,
  1220. struct drm_connector *connector);
  1221. void intel_backlight_register(struct drm_device *dev);
  1222. void intel_backlight_unregister(struct drm_device *dev);
  1223. /* intel_psr.c */
  1224. void intel_psr_enable(struct intel_dp *intel_dp);
  1225. void intel_psr_disable(struct intel_dp *intel_dp);
  1226. void intel_psr_invalidate(struct drm_device *dev,
  1227. unsigned frontbuffer_bits);
  1228. void intel_psr_flush(struct drm_device *dev,
  1229. unsigned frontbuffer_bits,
  1230. enum fb_op_origin origin);
  1231. void intel_psr_init(struct drm_device *dev);
  1232. void intel_psr_single_frame_update(struct drm_device *dev,
  1233. unsigned frontbuffer_bits);
  1234. /* intel_runtime_pm.c */
  1235. int intel_power_domains_init(struct drm_i915_private *);
  1236. void intel_power_domains_fini(struct drm_i915_private *);
  1237. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume);
  1238. void intel_power_domains_suspend(struct drm_i915_private *dev_priv);
  1239. void skl_pw1_misc_io_init(struct drm_i915_private *dev_priv);
  1240. void skl_pw1_misc_io_fini(struct drm_i915_private *dev_priv);
  1241. void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
  1242. const char *
  1243. intel_display_power_domain_str(enum intel_display_power_domain domain);
  1244. bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1245. enum intel_display_power_domain domain);
  1246. bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1247. enum intel_display_power_domain domain);
  1248. void intel_display_power_get(struct drm_i915_private *dev_priv,
  1249. enum intel_display_power_domain domain);
  1250. void intel_display_power_put(struct drm_i915_private *dev_priv,
  1251. enum intel_display_power_domain domain);
  1252. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  1253. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  1254. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  1255. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  1256. void chv_phy_powergate_lanes(struct intel_encoder *encoder,
  1257. bool override, unsigned int mask);
  1258. bool chv_phy_powergate_ch(struct drm_i915_private *dev_priv, enum dpio_phy phy,
  1259. enum dpio_channel ch, bool override);
  1260. /* intel_pm.c */
  1261. void intel_init_clock_gating(struct drm_device *dev);
  1262. void intel_suspend_hw(struct drm_device *dev);
  1263. int ilk_wm_max_level(const struct drm_device *dev);
  1264. void intel_update_watermarks(struct drm_crtc *crtc);
  1265. void intel_init_pm(struct drm_device *dev);
  1266. void intel_pm_setup(struct drm_device *dev);
  1267. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  1268. void intel_gpu_ips_teardown(void);
  1269. void intel_init_gt_powersave(struct drm_device *dev);
  1270. void intel_cleanup_gt_powersave(struct drm_device *dev);
  1271. void intel_enable_gt_powersave(struct drm_device *dev);
  1272. void intel_disable_gt_powersave(struct drm_device *dev);
  1273. void intel_suspend_gt_powersave(struct drm_device *dev);
  1274. void intel_reset_gt_powersave(struct drm_device *dev);
  1275. void gen6_update_ring_freq(struct drm_device *dev);
  1276. void gen6_rps_busy(struct drm_i915_private *dev_priv);
  1277. void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
  1278. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  1279. void gen6_rps_boost(struct drm_i915_private *dev_priv,
  1280. struct intel_rps_client *rps,
  1281. unsigned long submitted);
  1282. void intel_queue_rps_boost_for_request(struct drm_device *dev,
  1283. struct drm_i915_gem_request *req);
  1284. void vlv_wm_get_hw_state(struct drm_device *dev);
  1285. void ilk_wm_get_hw_state(struct drm_device *dev);
  1286. void skl_wm_get_hw_state(struct drm_device *dev);
  1287. void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  1288. struct skl_ddb_allocation *ddb /* out */);
  1289. uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config);
  1290. /* intel_sdvo.c */
  1291. bool intel_sdvo_init(struct drm_device *dev,
  1292. i915_reg_t reg, enum port port);
  1293. /* intel_sprite.c */
  1294. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  1295. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  1296. struct drm_file *file_priv);
  1297. void intel_pipe_update_start(struct intel_crtc *crtc);
  1298. void intel_pipe_update_end(struct intel_crtc *crtc);
  1299. /* intel_tv.c */
  1300. void intel_tv_init(struct drm_device *dev);
  1301. /* intel_atomic.c */
  1302. int intel_connector_atomic_get_property(struct drm_connector *connector,
  1303. const struct drm_connector_state *state,
  1304. struct drm_property *property,
  1305. uint64_t *val);
  1306. struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
  1307. void intel_crtc_destroy_state(struct drm_crtc *crtc,
  1308. struct drm_crtc_state *state);
  1309. struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
  1310. void intel_atomic_state_clear(struct drm_atomic_state *);
  1311. struct intel_shared_dpll_config *
  1312. intel_atomic_get_shared_dpll_state(struct drm_atomic_state *s);
  1313. static inline struct intel_crtc_state *
  1314. intel_atomic_get_crtc_state(struct drm_atomic_state *state,
  1315. struct intel_crtc *crtc)
  1316. {
  1317. struct drm_crtc_state *crtc_state;
  1318. crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
  1319. if (IS_ERR(crtc_state))
  1320. return ERR_CAST(crtc_state);
  1321. return to_intel_crtc_state(crtc_state);
  1322. }
  1323. int intel_atomic_setup_scalers(struct drm_device *dev,
  1324. struct intel_crtc *intel_crtc,
  1325. struct intel_crtc_state *crtc_state);
  1326. /* intel_atomic_plane.c */
  1327. struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
  1328. struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
  1329. void intel_plane_destroy_state(struct drm_plane *plane,
  1330. struct drm_plane_state *state);
  1331. extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
  1332. #endif /* __INTEL_DRV_H__ */