intel_drv.h 49 KB

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