intel_drv.h 50 KB

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