intel_drv.h 49 KB

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