intel_drv.h 47 KB

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