intel_drv.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  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/i2c.h>
  28. #include <linux/hdmi.h>
  29. #include <drm/i915_drm.h>
  30. #include "i915_drv.h"
  31. #include <drm/drm_crtc.h>
  32. #include <drm/drm_crtc_helper.h>
  33. #include <drm/drm_fb_helper.h>
  34. #include <drm/drm_dp_helper.h>
  35. /**
  36. * _wait_for - magic (register) wait macro
  37. *
  38. * Does the right thing for modeset paths when run under kdgb or similar atomic
  39. * contexts. Note that it's important that we check the condition again after
  40. * having timed out, since the timeout could be due to preemption or similar and
  41. * we've never had a chance to check the condition before the timeout.
  42. */
  43. #define _wait_for(COND, MS, W) ({ \
  44. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
  45. int ret__ = 0; \
  46. while (!(COND)) { \
  47. if (time_after(jiffies, timeout__)) { \
  48. if (!(COND)) \
  49. ret__ = -ETIMEDOUT; \
  50. break; \
  51. } \
  52. if (W && drm_can_sleep()) { \
  53. msleep(W); \
  54. } else { \
  55. cpu_relax(); \
  56. } \
  57. } \
  58. ret__; \
  59. })
  60. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  61. #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
  62. #define wait_for_atomic_us(COND, US) _wait_for((COND), \
  63. DIV_ROUND_UP((US), 1000), 0)
  64. #define KHz(x) (1000 * (x))
  65. #define MHz(x) KHz(1000 * (x))
  66. /*
  67. * Display related stuff
  68. */
  69. /* store information about an Ixxx DVO */
  70. /* The i830->i865 use multiple DVOs with multiple i2cs */
  71. /* the i915, i945 have a single sDVO i2c bus - which is different */
  72. #define MAX_OUTPUTS 6
  73. /* maximum connectors per crtcs in the mode set */
  74. /* Maximum cursor sizes */
  75. #define GEN2_CURSOR_WIDTH 64
  76. #define GEN2_CURSOR_HEIGHT 64
  77. #define MAX_CURSOR_WIDTH 256
  78. #define MAX_CURSOR_HEIGHT 256
  79. #define INTEL_I2C_BUS_DVO 1
  80. #define INTEL_I2C_BUS_SDVO 2
  81. /* these are outputs from the chip - integrated only
  82. external chips are via DVO or SDVO output */
  83. #define INTEL_OUTPUT_UNUSED 0
  84. #define INTEL_OUTPUT_ANALOG 1
  85. #define INTEL_OUTPUT_DVO 2
  86. #define INTEL_OUTPUT_SDVO 3
  87. #define INTEL_OUTPUT_LVDS 4
  88. #define INTEL_OUTPUT_TVOUT 5
  89. #define INTEL_OUTPUT_HDMI 6
  90. #define INTEL_OUTPUT_DISPLAYPORT 7
  91. #define INTEL_OUTPUT_EDP 8
  92. #define INTEL_OUTPUT_DSI 9
  93. #define INTEL_OUTPUT_UNKNOWN 10
  94. #define INTEL_DVO_CHIP_NONE 0
  95. #define INTEL_DVO_CHIP_LVDS 1
  96. #define INTEL_DVO_CHIP_TMDS 2
  97. #define INTEL_DVO_CHIP_TVOUT 4
  98. #define INTEL_DSI_COMMAND_MODE 0
  99. #define INTEL_DSI_VIDEO_MODE 1
  100. struct intel_framebuffer {
  101. struct drm_framebuffer base;
  102. struct drm_i915_gem_object *obj;
  103. };
  104. struct intel_fbdev {
  105. struct drm_fb_helper helper;
  106. struct intel_framebuffer *fb;
  107. struct list_head fbdev_list;
  108. struct drm_display_mode *our_mode;
  109. int preferred_bpp;
  110. };
  111. struct intel_encoder {
  112. struct drm_encoder base;
  113. /*
  114. * The new crtc this encoder will be driven from. Only differs from
  115. * base->crtc while a modeset is in progress.
  116. */
  117. struct intel_crtc *new_crtc;
  118. int type;
  119. unsigned int cloneable;
  120. bool connectors_active;
  121. void (*hot_plug)(struct intel_encoder *);
  122. bool (*compute_config)(struct intel_encoder *,
  123. struct intel_crtc_config *);
  124. void (*pre_pll_enable)(struct intel_encoder *);
  125. void (*pre_enable)(struct intel_encoder *);
  126. void (*enable)(struct intel_encoder *);
  127. void (*mode_set)(struct intel_encoder *intel_encoder);
  128. void (*disable)(struct intel_encoder *);
  129. void (*post_disable)(struct intel_encoder *);
  130. /* Read out the current hw state of this connector, returning true if
  131. * the encoder is active. If the encoder is enabled it also set the pipe
  132. * it is connected to in the pipe parameter. */
  133. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  134. /* Reconstructs the equivalent mode flags for the current hardware
  135. * state. This must be called _after_ display->get_pipe_config has
  136. * pre-filled the pipe config. Note that intel_encoder->base.crtc must
  137. * be set correctly before calling this function. */
  138. void (*get_config)(struct intel_encoder *,
  139. struct intel_crtc_config *pipe_config);
  140. int crtc_mask;
  141. enum hpd_pin hpd_pin;
  142. };
  143. struct intel_panel {
  144. struct drm_display_mode *fixed_mode;
  145. struct drm_display_mode *downclock_mode;
  146. int fitting_mode;
  147. /* backlight */
  148. struct {
  149. bool present;
  150. u32 level;
  151. u32 max;
  152. bool enabled;
  153. bool combination_mode; /* gen 2/4 only */
  154. bool active_low_pwm;
  155. struct backlight_device *device;
  156. } backlight;
  157. };
  158. struct intel_connector {
  159. struct drm_connector base;
  160. /*
  161. * The fixed encoder this connector is connected to.
  162. */
  163. struct intel_encoder *encoder;
  164. /*
  165. * The new encoder this connector will be driven. Only differs from
  166. * encoder while a modeset is in progress.
  167. */
  168. struct intel_encoder *new_encoder;
  169. /* Reads out the current hw, returning true if the connector is enabled
  170. * and active (i.e. dpms ON state). */
  171. bool (*get_hw_state)(struct intel_connector *);
  172. /*
  173. * Removes all interfaces through which the connector is accessible
  174. * - like sysfs, debugfs entries -, so that no new operations can be
  175. * started on the connector. Also makes sure all currently pending
  176. * operations finish before returing.
  177. */
  178. void (*unregister)(struct intel_connector *);
  179. /* Panel info for eDP and LVDS */
  180. struct intel_panel panel;
  181. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  182. struct edid *edid;
  183. /* since POLL and HPD connectors may use the same HPD line keep the native
  184. state of connector->polled in case hotplug storm detection changes it */
  185. u8 polled;
  186. };
  187. typedef struct dpll {
  188. /* given values */
  189. int n;
  190. int m1, m2;
  191. int p1, p2;
  192. /* derived values */
  193. int dot;
  194. int vco;
  195. int m;
  196. int p;
  197. } intel_clock_t;
  198. struct intel_plane_config {
  199. bool tiled;
  200. int size;
  201. u32 base;
  202. };
  203. struct intel_crtc_config {
  204. /**
  205. * quirks - bitfield with hw state readout quirks
  206. *
  207. * For various reasons the hw state readout code might not be able to
  208. * completely faithfully read out the current state. These cases are
  209. * tracked with quirk flags so that fastboot and state checker can act
  210. * accordingly.
  211. */
  212. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  213. #define PIPE_CONFIG_QUIRK_INHERITED_MODE (1<<1) /* mode inherited from firmware */
  214. unsigned long quirks;
  215. /* User requested mode, only valid as a starting point to
  216. * compute adjusted_mode, except in the case of (S)DVO where
  217. * it's also for the output timings of the (S)DVO chip.
  218. * adjusted_mode will then correspond to the S(DVO) chip's
  219. * preferred input timings. */
  220. struct drm_display_mode requested_mode;
  221. /* Actual pipe timings ie. what we program into the pipe timing
  222. * registers. adjusted_mode.crtc_clock is the pipe pixel clock. */
  223. struct drm_display_mode adjusted_mode;
  224. /* Pipe source size (ie. panel fitter input size)
  225. * All planes will be positioned inside this space,
  226. * and get clipped at the edges. */
  227. int pipe_src_w, pipe_src_h;
  228. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  229. * between pch encoders and cpu encoders. */
  230. bool has_pch_encoder;
  231. /* CPU Transcoder for the pipe. Currently this can only differ from the
  232. * pipe on Haswell (where we have a special eDP transcoder). */
  233. enum transcoder cpu_transcoder;
  234. /*
  235. * Use reduced/limited/broadcast rbg range, compressing from the full
  236. * range fed into the crtcs.
  237. */
  238. bool limited_color_range;
  239. /* DP has a bunch of special case unfortunately, so mark the pipe
  240. * accordingly. */
  241. bool has_dp_encoder;
  242. /*
  243. * Enable dithering, used when the selected pipe bpp doesn't match the
  244. * plane bpp.
  245. */
  246. bool dither;
  247. /* Controls for the clock computation, to override various stages. */
  248. bool clock_set;
  249. /* SDVO TV has a bunch of special case. To make multifunction encoders
  250. * work correctly, we need to track this at runtime.*/
  251. bool sdvo_tv_clock;
  252. /*
  253. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  254. * required. This is set in the 2nd loop of calling encoder's
  255. * ->compute_config if the first pick doesn't work out.
  256. */
  257. bool bw_constrained;
  258. /* Settings for the intel dpll used on pretty much everything but
  259. * haswell. */
  260. struct dpll dpll;
  261. /* Selected dpll when shared or DPLL_ID_PRIVATE. */
  262. enum intel_dpll_id shared_dpll;
  263. /* Actual register state of the dpll, for shared dpll cross-checking. */
  264. struct intel_dpll_hw_state dpll_hw_state;
  265. int pipe_bpp;
  266. struct intel_link_m_n dp_m_n;
  267. /* m2_n2 for eDP downclock */
  268. struct intel_link_m_n dp_m2_n2;
  269. /*
  270. * Frequence the dpll for the port should run at. Differs from the
  271. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  272. * already multiplied by pixel_multiplier.
  273. */
  274. int port_clock;
  275. /* Used by SDVO (and if we ever fix it, HDMI). */
  276. unsigned pixel_multiplier;
  277. /* Panel fitter controls for gen2-gen4 + VLV */
  278. struct {
  279. u32 control;
  280. u32 pgm_ratios;
  281. u32 lvds_border_bits;
  282. } gmch_pfit;
  283. /* Panel fitter placement and size for Ironlake+ */
  284. struct {
  285. u32 pos;
  286. u32 size;
  287. bool enabled;
  288. } pch_pfit;
  289. /* FDI configuration, only valid if has_pch_encoder is set. */
  290. int fdi_lanes;
  291. struct intel_link_m_n fdi_m_n;
  292. bool ips_enabled;
  293. bool double_wide;
  294. };
  295. struct intel_pipe_wm {
  296. struct intel_wm_level wm[5];
  297. uint32_t linetime;
  298. bool fbc_wm_enabled;
  299. bool pipe_enabled;
  300. bool sprites_enabled;
  301. bool sprites_scaled;
  302. };
  303. struct intel_crtc {
  304. struct drm_crtc base;
  305. enum pipe pipe;
  306. enum plane plane;
  307. u8 lut_r[256], lut_g[256], lut_b[256];
  308. /*
  309. * Whether the crtc and the connected output pipeline is active. Implies
  310. * that crtc->enabled is set, i.e. the current mode configuration has
  311. * some outputs connected to this crtc.
  312. */
  313. bool active;
  314. unsigned long enabled_power_domains;
  315. bool eld_vld;
  316. bool primary_enabled; /* is the primary plane (partially) visible? */
  317. bool lowfreq_avail;
  318. struct intel_overlay *overlay;
  319. struct intel_unpin_work *unpin_work;
  320. atomic_t unpin_work_count;
  321. /* Display surface base address adjustement for pageflips. Note that on
  322. * gen4+ this only adjusts up to a tile, offsets within a tile are
  323. * handled in the hw itself (with the TILEOFF register). */
  324. unsigned long dspaddr_offset;
  325. struct drm_i915_gem_object *cursor_bo;
  326. uint32_t cursor_addr;
  327. int16_t cursor_x, cursor_y;
  328. int16_t cursor_width, cursor_height;
  329. bool cursor_visible;
  330. struct intel_plane_config plane_config;
  331. struct intel_crtc_config config;
  332. struct intel_crtc_config *new_config;
  333. bool new_enabled;
  334. uint32_t ddi_pll_sel;
  335. /* reset counter value when the last flip was submitted */
  336. unsigned int reset_counter;
  337. /* Access to these should be protected by dev_priv->irq_lock. */
  338. bool cpu_fifo_underrun_disabled;
  339. bool pch_fifo_underrun_disabled;
  340. /* per-pipe watermark state */
  341. struct {
  342. /* watermarks currently being used */
  343. struct intel_pipe_wm active;
  344. } wm;
  345. wait_queue_head_t vbl_wait;
  346. };
  347. struct intel_plane_wm_parameters {
  348. uint32_t horiz_pixels;
  349. uint8_t bytes_per_pixel;
  350. bool enabled;
  351. bool scaled;
  352. };
  353. struct intel_plane {
  354. struct drm_plane base;
  355. int plane;
  356. enum pipe pipe;
  357. struct drm_i915_gem_object *obj;
  358. bool can_scale;
  359. int max_downscale;
  360. u32 lut_r[1024], lut_g[1024], lut_b[1024];
  361. int crtc_x, crtc_y;
  362. unsigned int crtc_w, crtc_h;
  363. uint32_t src_x, src_y;
  364. uint32_t src_w, src_h;
  365. /* Since we need to change the watermarks before/after
  366. * enabling/disabling the planes, we need to store the parameters here
  367. * as the other pieces of the struct may not reflect the values we want
  368. * for the watermark calculations. Currently only Haswell uses this.
  369. */
  370. struct intel_plane_wm_parameters wm;
  371. void (*update_plane)(struct drm_plane *plane,
  372. struct drm_crtc *crtc,
  373. struct drm_framebuffer *fb,
  374. struct drm_i915_gem_object *obj,
  375. int crtc_x, int crtc_y,
  376. unsigned int crtc_w, unsigned int crtc_h,
  377. uint32_t x, uint32_t y,
  378. uint32_t src_w, uint32_t src_h);
  379. void (*disable_plane)(struct drm_plane *plane,
  380. struct drm_crtc *crtc);
  381. int (*update_colorkey)(struct drm_plane *plane,
  382. struct drm_intel_sprite_colorkey *key);
  383. void (*get_colorkey)(struct drm_plane *plane,
  384. struct drm_intel_sprite_colorkey *key);
  385. };
  386. struct intel_watermark_params {
  387. unsigned long fifo_size;
  388. unsigned long max_wm;
  389. unsigned long default_wm;
  390. unsigned long guard_size;
  391. unsigned long cacheline_size;
  392. };
  393. struct cxsr_latency {
  394. int is_desktop;
  395. int is_ddr3;
  396. unsigned long fsb_freq;
  397. unsigned long mem_freq;
  398. unsigned long display_sr;
  399. unsigned long display_hpll_disable;
  400. unsigned long cursor_sr;
  401. unsigned long cursor_hpll_disable;
  402. };
  403. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  404. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  405. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  406. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  407. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  408. struct intel_hdmi {
  409. u32 hdmi_reg;
  410. int ddc_bus;
  411. uint32_t color_range;
  412. bool color_range_auto;
  413. bool has_hdmi_sink;
  414. bool has_audio;
  415. enum hdmi_force_audio force_audio;
  416. bool rgb_quant_range_selectable;
  417. void (*write_infoframe)(struct drm_encoder *encoder,
  418. enum hdmi_infoframe_type type,
  419. const void *frame, ssize_t len);
  420. void (*set_infoframes)(struct drm_encoder *encoder,
  421. struct drm_display_mode *adjusted_mode);
  422. };
  423. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  424. /**
  425. * HIGH_RR is the highest eDP panel refresh rate read from EDID
  426. * LOW_RR is the lowest eDP panel refresh rate found from EDID
  427. * parsing for same resolution.
  428. */
  429. enum edp_drrs_refresh_rate_type {
  430. DRRS_HIGH_RR,
  431. DRRS_LOW_RR,
  432. DRRS_MAX_RR, /* RR count */
  433. };
  434. struct intel_dp {
  435. uint32_t output_reg;
  436. uint32_t aux_ch_ctl_reg;
  437. uint32_t DP;
  438. bool has_audio;
  439. enum hdmi_force_audio force_audio;
  440. uint32_t color_range;
  441. bool color_range_auto;
  442. uint8_t link_bw;
  443. uint8_t lane_count;
  444. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  445. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  446. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  447. struct drm_dp_aux aux;
  448. uint8_t train_set[4];
  449. int panel_power_up_delay;
  450. int panel_power_down_delay;
  451. int panel_power_cycle_delay;
  452. int backlight_on_delay;
  453. int backlight_off_delay;
  454. struct delayed_work panel_vdd_work;
  455. bool want_panel_vdd;
  456. unsigned long last_power_cycle;
  457. unsigned long last_power_on;
  458. unsigned long last_backlight_off;
  459. bool psr_setup_done;
  460. bool use_tps3;
  461. struct intel_connector *attached_connector;
  462. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  463. /*
  464. * This function returns the value we have to program the AUX_CTL
  465. * register with to kick off an AUX transaction.
  466. */
  467. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  468. bool has_aux_irq,
  469. int send_bytes,
  470. uint32_t aux_clock_divider);
  471. struct {
  472. enum drrs_support_type type;
  473. enum edp_drrs_refresh_rate_type refresh_rate_type;
  474. struct mutex mutex;
  475. } drrs_state;
  476. };
  477. struct intel_digital_port {
  478. struct intel_encoder base;
  479. enum port port;
  480. u32 saved_port_bits;
  481. struct intel_dp dp;
  482. struct intel_hdmi hdmi;
  483. };
  484. static inline int
  485. vlv_dport_to_channel(struct intel_digital_port *dport)
  486. {
  487. switch (dport->port) {
  488. case PORT_B:
  489. case PORT_D:
  490. return DPIO_CH0;
  491. case PORT_C:
  492. return DPIO_CH1;
  493. default:
  494. BUG();
  495. }
  496. }
  497. static inline struct drm_crtc *
  498. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  499. {
  500. struct drm_i915_private *dev_priv = dev->dev_private;
  501. return dev_priv->pipe_to_crtc_mapping[pipe];
  502. }
  503. static inline struct drm_crtc *
  504. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  505. {
  506. struct drm_i915_private *dev_priv = dev->dev_private;
  507. return dev_priv->plane_to_crtc_mapping[plane];
  508. }
  509. struct intel_unpin_work {
  510. struct work_struct work;
  511. struct drm_crtc *crtc;
  512. struct drm_i915_gem_object *old_fb_obj;
  513. struct drm_i915_gem_object *pending_flip_obj;
  514. struct drm_pending_vblank_event *event;
  515. atomic_t pending;
  516. #define INTEL_FLIP_INACTIVE 0
  517. #define INTEL_FLIP_PENDING 1
  518. #define INTEL_FLIP_COMPLETE 2
  519. bool enable_stall_check;
  520. };
  521. struct intel_set_config {
  522. struct drm_encoder **save_connector_encoders;
  523. struct drm_crtc **save_encoder_crtcs;
  524. bool *save_crtc_enabled;
  525. bool fb_changed;
  526. bool mode_changed;
  527. };
  528. struct intel_load_detect_pipe {
  529. struct drm_framebuffer *release_fb;
  530. bool load_detect_temp;
  531. int dpms_mode;
  532. };
  533. static inline struct intel_encoder *
  534. intel_attached_encoder(struct drm_connector *connector)
  535. {
  536. return to_intel_connector(connector)->encoder;
  537. }
  538. static inline struct intel_digital_port *
  539. enc_to_dig_port(struct drm_encoder *encoder)
  540. {
  541. return container_of(encoder, struct intel_digital_port, base.base);
  542. }
  543. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  544. {
  545. return &enc_to_dig_port(encoder)->dp;
  546. }
  547. static inline struct intel_digital_port *
  548. dp_to_dig_port(struct intel_dp *intel_dp)
  549. {
  550. return container_of(intel_dp, struct intel_digital_port, dp);
  551. }
  552. static inline struct intel_digital_port *
  553. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  554. {
  555. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  556. }
  557. /* i915_irq.c */
  558. bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
  559. enum pipe pipe, bool enable);
  560. bool __intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
  561. enum pipe pipe, bool enable);
  562. bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,
  563. enum transcoder pch_transcoder,
  564. bool enable);
  565. void ilk_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  566. void ilk_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  567. void snb_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  568. void snb_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  569. void intel_runtime_pm_disable_interrupts(struct drm_device *dev);
  570. void intel_runtime_pm_restore_interrupts(struct drm_device *dev);
  571. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  572. /* intel_crt.c */
  573. void intel_crt_init(struct drm_device *dev);
  574. /* intel_ddi.c */
  575. void intel_prepare_ddi(struct drm_device *dev);
  576. void hsw_fdi_link_train(struct drm_crtc *crtc);
  577. void intel_ddi_init(struct drm_device *dev, enum port port);
  578. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  579. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  580. int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
  581. void intel_ddi_pll_init(struct drm_device *dev);
  582. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  583. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  584. enum transcoder cpu_transcoder);
  585. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  586. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  587. void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
  588. bool intel_ddi_pll_select(struct intel_crtc *crtc);
  589. void intel_ddi_pll_enable(struct intel_crtc *crtc);
  590. void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
  591. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  592. void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  593. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  594. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  595. void intel_ddi_get_config(struct intel_encoder *encoder,
  596. struct intel_crtc_config *pipe_config);
  597. /* intel_display.c */
  598. const char *intel_output_name(int output);
  599. bool intel_has_pending_fb_unpin(struct drm_device *dev);
  600. int intel_pch_rawclk(struct drm_device *dev);
  601. int valleyview_cur_cdclk(struct drm_i915_private *dev_priv);
  602. void intel_mark_busy(struct drm_device *dev);
  603. void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
  604. struct intel_ring_buffer *ring);
  605. void intel_mark_idle(struct drm_device *dev);
  606. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  607. void intel_crtc_update_dpms(struct drm_crtc *crtc);
  608. void intel_encoder_destroy(struct drm_encoder *encoder);
  609. void intel_connector_dpms(struct drm_connector *, int mode);
  610. bool intel_connector_get_hw_state(struct intel_connector *connector);
  611. void intel_modeset_check_state(struct drm_device *dev);
  612. bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
  613. struct intel_digital_port *port);
  614. void intel_connector_attach_encoder(struct intel_connector *connector,
  615. struct intel_encoder *encoder);
  616. struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  617. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  618. struct drm_crtc *crtc);
  619. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  620. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  621. struct drm_file *file_priv);
  622. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  623. enum pipe pipe);
  624. void intel_wait_for_vblank(struct drm_device *dev, int pipe);
  625. void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
  626. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  627. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  628. struct intel_digital_port *dport);
  629. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  630. struct drm_display_mode *mode,
  631. struct intel_load_detect_pipe *old);
  632. void intel_release_load_detect_pipe(struct drm_connector *connector,
  633. struct intel_load_detect_pipe *old);
  634. int intel_pin_and_fence_fb_obj(struct drm_device *dev,
  635. struct drm_i915_gem_object *obj,
  636. struct intel_ring_buffer *pipelined);
  637. void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
  638. struct drm_framebuffer *
  639. __intel_framebuffer_create(struct drm_device *dev,
  640. struct drm_mode_fb_cmd2 *mode_cmd,
  641. struct drm_i915_gem_object *obj);
  642. void intel_prepare_page_flip(struct drm_device *dev, int plane);
  643. void intel_finish_page_flip(struct drm_device *dev, int pipe);
  644. void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  645. struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
  646. void assert_shared_dpll(struct drm_i915_private *dev_priv,
  647. struct intel_shared_dpll *pll,
  648. bool state);
  649. #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
  650. #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
  651. void assert_pll(struct drm_i915_private *dev_priv,
  652. enum pipe pipe, bool state);
  653. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  654. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  655. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  656. enum pipe pipe, bool state);
  657. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  658. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  659. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  660. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  661. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  662. void intel_write_eld(struct drm_encoder *encoder,
  663. struct drm_display_mode *mode);
  664. unsigned long intel_gen4_compute_page_offset(int *x, int *y,
  665. unsigned int tiling_mode,
  666. unsigned int bpp,
  667. unsigned int pitch);
  668. void intel_display_handle_reset(struct drm_device *dev);
  669. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  670. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  671. void intel_dp_get_m_n(struct intel_crtc *crtc,
  672. struct intel_crtc_config *pipe_config);
  673. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  674. void
  675. ironlake_check_encoder_dotclock(const struct intel_crtc_config *pipe_config,
  676. int dotclock);
  677. bool intel_crtc_active(struct drm_crtc *crtc);
  678. void hsw_enable_ips(struct intel_crtc *crtc);
  679. void hsw_disable_ips(struct intel_crtc *crtc);
  680. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  681. enum intel_display_power_domain
  682. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  683. int valleyview_get_vco(struct drm_i915_private *dev_priv);
  684. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  685. struct intel_crtc_config *pipe_config);
  686. int intel_format_to_fourcc(int format);
  687. /* intel_dp.c */
  688. void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
  689. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  690. struct intel_connector *intel_connector);
  691. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  692. void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  693. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  694. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  695. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  696. void intel_dp_check_link_status(struct intel_dp *intel_dp);
  697. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  698. bool intel_dp_compute_config(struct intel_encoder *encoder,
  699. struct intel_crtc_config *pipe_config);
  700. bool intel_dp_is_edp(struct drm_device *dev, enum port port);
  701. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  702. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  703. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  704. void intel_edp_panel_on(struct intel_dp *intel_dp);
  705. void intel_edp_panel_off(struct intel_dp *intel_dp);
  706. void intel_edp_psr_enable(struct intel_dp *intel_dp);
  707. void intel_edp_psr_disable(struct intel_dp *intel_dp);
  708. void intel_edp_psr_update(struct drm_device *dev);
  709. void intel_dp_set_drrs_state(struct drm_device *dev, int refresh_rate);
  710. /* intel_dsi.c */
  711. bool intel_dsi_init(struct drm_device *dev);
  712. /* intel_dvo.c */
  713. void intel_dvo_init(struct drm_device *dev);
  714. /* legacy fbdev emulation in intel_fbdev.c */
  715. #ifdef CONFIG_DRM_I915_FBDEV
  716. extern int intel_fbdev_init(struct drm_device *dev);
  717. extern void intel_fbdev_initial_config(struct drm_device *dev);
  718. extern void intel_fbdev_fini(struct drm_device *dev);
  719. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
  720. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  721. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  722. #else
  723. static inline int intel_fbdev_init(struct drm_device *dev)
  724. {
  725. return 0;
  726. }
  727. static inline void intel_fbdev_initial_config(struct drm_device *dev)
  728. {
  729. }
  730. static inline void intel_fbdev_fini(struct drm_device *dev)
  731. {
  732. }
  733. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state)
  734. {
  735. }
  736. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  737. {
  738. }
  739. #endif
  740. /* intel_hdmi.c */
  741. void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port);
  742. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  743. struct intel_connector *intel_connector);
  744. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  745. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  746. struct intel_crtc_config *pipe_config);
  747. /* intel_lvds.c */
  748. void intel_lvds_init(struct drm_device *dev);
  749. bool intel_is_dual_link_lvds(struct drm_device *dev);
  750. /* intel_modes.c */
  751. int intel_connector_update_modes(struct drm_connector *connector,
  752. struct edid *edid);
  753. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  754. void intel_attach_force_audio_property(struct drm_connector *connector);
  755. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  756. /* intel_overlay.c */
  757. void intel_setup_overlay(struct drm_device *dev);
  758. void intel_cleanup_overlay(struct drm_device *dev);
  759. int intel_overlay_switch_off(struct intel_overlay *overlay);
  760. int intel_overlay_put_image(struct drm_device *dev, void *data,
  761. struct drm_file *file_priv);
  762. int intel_overlay_attrs(struct drm_device *dev, void *data,
  763. struct drm_file *file_priv);
  764. /* intel_panel.c */
  765. int intel_panel_init(struct intel_panel *panel,
  766. struct drm_display_mode *fixed_mode,
  767. struct drm_display_mode *downclock_mode);
  768. void intel_panel_fini(struct intel_panel *panel);
  769. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  770. struct drm_display_mode *adjusted_mode);
  771. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  772. struct intel_crtc_config *pipe_config,
  773. int fitting_mode);
  774. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  775. struct intel_crtc_config *pipe_config,
  776. int fitting_mode);
  777. void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
  778. u32 max);
  779. int intel_panel_setup_backlight(struct drm_connector *connector);
  780. void intel_panel_enable_backlight(struct intel_connector *connector);
  781. void intel_panel_disable_backlight(struct intel_connector *connector);
  782. void intel_panel_destroy_backlight(struct drm_connector *connector);
  783. void intel_panel_init_backlight_funcs(struct drm_device *dev);
  784. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  785. extern struct drm_display_mode *intel_find_panel_downclock(
  786. struct drm_device *dev,
  787. struct drm_display_mode *fixed_mode,
  788. struct drm_connector *connector);
  789. /* intel_pm.c */
  790. void intel_init_clock_gating(struct drm_device *dev);
  791. void intel_suspend_hw(struct drm_device *dev);
  792. void intel_update_watermarks(struct drm_crtc *crtc);
  793. void intel_update_sprite_watermarks(struct drm_plane *plane,
  794. struct drm_crtc *crtc,
  795. uint32_t sprite_width, int pixel_size,
  796. bool enabled, bool scaled);
  797. void intel_init_pm(struct drm_device *dev);
  798. void intel_pm_setup(struct drm_device *dev);
  799. bool intel_fbc_enabled(struct drm_device *dev);
  800. void intel_update_fbc(struct drm_device *dev);
  801. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  802. void intel_gpu_ips_teardown(void);
  803. int intel_power_domains_init(struct drm_i915_private *);
  804. void intel_power_domains_remove(struct drm_i915_private *);
  805. bool intel_display_power_enabled(struct drm_i915_private *dev_priv,
  806. enum intel_display_power_domain domain);
  807. bool intel_display_power_enabled_sw(struct drm_i915_private *dev_priv,
  808. enum intel_display_power_domain domain);
  809. void intel_display_power_get(struct drm_i915_private *dev_priv,
  810. enum intel_display_power_domain domain);
  811. void intel_display_power_put(struct drm_i915_private *dev_priv,
  812. enum intel_display_power_domain domain);
  813. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv);
  814. void intel_init_gt_powersave(struct drm_device *dev);
  815. void intel_cleanup_gt_powersave(struct drm_device *dev);
  816. void intel_enable_gt_powersave(struct drm_device *dev);
  817. void intel_disable_gt_powersave(struct drm_device *dev);
  818. void intel_reset_gt_powersave(struct drm_device *dev);
  819. void ironlake_teardown_rc6(struct drm_device *dev);
  820. void gen6_update_ring_freq(struct drm_device *dev);
  821. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  822. void gen6_rps_boost(struct drm_i915_private *dev_priv);
  823. void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv);
  824. void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
  825. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  826. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  827. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  828. void intel_init_runtime_pm(struct drm_i915_private *dev_priv);
  829. void intel_fini_runtime_pm(struct drm_i915_private *dev_priv);
  830. void ilk_wm_get_hw_state(struct drm_device *dev);
  831. /* intel_sdvo.c */
  832. bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
  833. /* intel_sprite.c */
  834. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  835. void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
  836. enum plane plane);
  837. void intel_plane_restore(struct drm_plane *plane);
  838. void intel_plane_disable(struct drm_plane *plane);
  839. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  840. struct drm_file *file_priv);
  841. int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
  842. struct drm_file *file_priv);
  843. /* intel_tv.c */
  844. void intel_tv_init(struct drm_device *dev);
  845. #endif /* __INTEL_DRV_H__ */