intel_drv.h 49 KB

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