intel_drv.h 48 KB

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