intel_drv.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  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. unsigned long quirks;
  214. /* User requested mode, only valid as a starting point to
  215. * compute adjusted_mode, except in the case of (S)DVO where
  216. * it's also for the output timings of the (S)DVO chip.
  217. * adjusted_mode will then correspond to the S(DVO) chip's
  218. * preferred input timings. */
  219. struct drm_display_mode requested_mode;
  220. /* Actual pipe timings ie. what we program into the pipe timing
  221. * registers. adjusted_mode.crtc_clock is the pipe pixel clock. */
  222. struct drm_display_mode adjusted_mode;
  223. /* Pipe source size (ie. panel fitter input size)
  224. * All planes will be positioned inside this space,
  225. * and get clipped at the edges. */
  226. int pipe_src_w, pipe_src_h;
  227. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  228. * between pch encoders and cpu encoders. */
  229. bool has_pch_encoder;
  230. /* CPU Transcoder for the pipe. Currently this can only differ from the
  231. * pipe on Haswell (where we have a special eDP transcoder). */
  232. enum transcoder cpu_transcoder;
  233. /*
  234. * Use reduced/limited/broadcast rbg range, compressing from the full
  235. * range fed into the crtcs.
  236. */
  237. bool limited_color_range;
  238. /* DP has a bunch of special case unfortunately, so mark the pipe
  239. * accordingly. */
  240. bool has_dp_encoder;
  241. /*
  242. * Enable dithering, used when the selected pipe bpp doesn't match the
  243. * plane bpp.
  244. */
  245. bool dither;
  246. /* Controls for the clock computation, to override various stages. */
  247. bool clock_set;
  248. /* SDVO TV has a bunch of special case. To make multifunction encoders
  249. * work correctly, we need to track this at runtime.*/
  250. bool sdvo_tv_clock;
  251. /*
  252. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  253. * required. This is set in the 2nd loop of calling encoder's
  254. * ->compute_config if the first pick doesn't work out.
  255. */
  256. bool bw_constrained;
  257. /* Settings for the intel dpll used on pretty much everything but
  258. * haswell. */
  259. struct dpll dpll;
  260. /* Selected dpll when shared or DPLL_ID_PRIVATE. */
  261. enum intel_dpll_id shared_dpll;
  262. /* Actual register state of the dpll, for shared dpll cross-checking. */
  263. struct intel_dpll_hw_state dpll_hw_state;
  264. int pipe_bpp;
  265. struct intel_link_m_n dp_m_n;
  266. /*
  267. * Frequence the dpll for the port should run at. Differs from the
  268. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  269. * already multiplied by pixel_multiplier.
  270. */
  271. int port_clock;
  272. /* Used by SDVO (and if we ever fix it, HDMI). */
  273. unsigned pixel_multiplier;
  274. /* Panel fitter controls for gen2-gen4 + VLV */
  275. struct {
  276. u32 control;
  277. u32 pgm_ratios;
  278. u32 lvds_border_bits;
  279. } gmch_pfit;
  280. /* Panel fitter placement and size for Ironlake+ */
  281. struct {
  282. u32 pos;
  283. u32 size;
  284. bool enabled;
  285. } pch_pfit;
  286. /* FDI configuration, only valid if has_pch_encoder is set. */
  287. int fdi_lanes;
  288. struct intel_link_m_n fdi_m_n;
  289. bool ips_enabled;
  290. bool double_wide;
  291. };
  292. struct intel_pipe_wm {
  293. struct intel_wm_level wm[5];
  294. uint32_t linetime;
  295. bool fbc_wm_enabled;
  296. bool pipe_enabled;
  297. bool sprites_enabled;
  298. bool sprites_scaled;
  299. };
  300. struct intel_crtc {
  301. struct drm_crtc base;
  302. enum pipe pipe;
  303. enum plane plane;
  304. u8 lut_r[256], lut_g[256], lut_b[256];
  305. /*
  306. * Whether the crtc and the connected output pipeline is active. Implies
  307. * that crtc->enabled is set, i.e. the current mode configuration has
  308. * some outputs connected to this crtc.
  309. */
  310. bool active;
  311. unsigned long enabled_power_domains;
  312. bool eld_vld;
  313. bool primary_enabled; /* is the primary plane (partially) visible? */
  314. bool lowfreq_avail;
  315. struct intel_overlay *overlay;
  316. struct intel_unpin_work *unpin_work;
  317. atomic_t unpin_work_count;
  318. /* Display surface base address adjustement for pageflips. Note that on
  319. * gen4+ this only adjusts up to a tile, offsets within a tile are
  320. * handled in the hw itself (with the TILEOFF register). */
  321. unsigned long dspaddr_offset;
  322. struct drm_i915_gem_object *cursor_bo;
  323. uint32_t cursor_addr;
  324. int16_t cursor_x, cursor_y;
  325. int16_t cursor_width, cursor_height;
  326. bool cursor_visible;
  327. struct intel_plane_config plane_config;
  328. struct intel_crtc_config config;
  329. struct intel_crtc_config *new_config;
  330. bool new_enabled;
  331. uint32_t ddi_pll_sel;
  332. /* reset counter value when the last flip was submitted */
  333. unsigned int reset_counter;
  334. /* Access to these should be protected by dev_priv->irq_lock. */
  335. bool cpu_fifo_underrun_disabled;
  336. bool pch_fifo_underrun_disabled;
  337. /* per-pipe watermark state */
  338. struct {
  339. /* watermarks currently being used */
  340. struct intel_pipe_wm active;
  341. } wm;
  342. };
  343. struct intel_plane_wm_parameters {
  344. uint32_t horiz_pixels;
  345. uint8_t bytes_per_pixel;
  346. bool enabled;
  347. bool scaled;
  348. };
  349. struct intel_plane {
  350. struct drm_plane base;
  351. int plane;
  352. enum pipe pipe;
  353. struct drm_i915_gem_object *obj;
  354. bool can_scale;
  355. int max_downscale;
  356. u32 lut_r[1024], lut_g[1024], lut_b[1024];
  357. int crtc_x, crtc_y;
  358. unsigned int crtc_w, crtc_h;
  359. uint32_t src_x, src_y;
  360. uint32_t src_w, src_h;
  361. /* Since we need to change the watermarks before/after
  362. * enabling/disabling the planes, we need to store the parameters here
  363. * as the other pieces of the struct may not reflect the values we want
  364. * for the watermark calculations. Currently only Haswell uses this.
  365. */
  366. struct intel_plane_wm_parameters wm;
  367. void (*update_plane)(struct drm_plane *plane,
  368. struct drm_crtc *crtc,
  369. struct drm_framebuffer *fb,
  370. struct drm_i915_gem_object *obj,
  371. int crtc_x, int crtc_y,
  372. unsigned int crtc_w, unsigned int crtc_h,
  373. uint32_t x, uint32_t y,
  374. uint32_t src_w, uint32_t src_h);
  375. void (*disable_plane)(struct drm_plane *plane,
  376. struct drm_crtc *crtc);
  377. int (*update_colorkey)(struct drm_plane *plane,
  378. struct drm_intel_sprite_colorkey *key);
  379. void (*get_colorkey)(struct drm_plane *plane,
  380. struct drm_intel_sprite_colorkey *key);
  381. };
  382. struct intel_watermark_params {
  383. unsigned long fifo_size;
  384. unsigned long max_wm;
  385. unsigned long default_wm;
  386. unsigned long guard_size;
  387. unsigned long cacheline_size;
  388. };
  389. struct cxsr_latency {
  390. int is_desktop;
  391. int is_ddr3;
  392. unsigned long fsb_freq;
  393. unsigned long mem_freq;
  394. unsigned long display_sr;
  395. unsigned long display_hpll_disable;
  396. unsigned long cursor_sr;
  397. unsigned long cursor_hpll_disable;
  398. };
  399. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  400. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  401. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  402. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  403. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  404. struct intel_hdmi {
  405. u32 hdmi_reg;
  406. int ddc_bus;
  407. uint32_t color_range;
  408. bool color_range_auto;
  409. bool has_hdmi_sink;
  410. bool has_audio;
  411. enum hdmi_force_audio force_audio;
  412. bool rgb_quant_range_selectable;
  413. void (*write_infoframe)(struct drm_encoder *encoder,
  414. enum hdmi_infoframe_type type,
  415. const void *frame, ssize_t len);
  416. void (*set_infoframes)(struct drm_encoder *encoder,
  417. struct drm_display_mode *adjusted_mode);
  418. };
  419. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  420. /**
  421. * HIGH_RR is the highest eDP panel refresh rate read from EDID
  422. * LOW_RR is the lowest eDP panel refresh rate found from EDID
  423. * parsing for same resolution.
  424. */
  425. enum edp_drrs_refresh_rate_type {
  426. DRRS_HIGH_RR,
  427. DRRS_LOW_RR,
  428. DRRS_MAX_RR, /* RR count */
  429. };
  430. struct intel_dp {
  431. uint32_t output_reg;
  432. uint32_t aux_ch_ctl_reg;
  433. uint32_t DP;
  434. bool has_audio;
  435. enum hdmi_force_audio force_audio;
  436. uint32_t color_range;
  437. bool color_range_auto;
  438. uint8_t link_bw;
  439. uint8_t lane_count;
  440. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  441. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  442. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  443. struct drm_dp_aux aux;
  444. uint8_t train_set[4];
  445. int panel_power_up_delay;
  446. int panel_power_down_delay;
  447. int panel_power_cycle_delay;
  448. int backlight_on_delay;
  449. int backlight_off_delay;
  450. struct delayed_work panel_vdd_work;
  451. bool want_panel_vdd;
  452. unsigned long last_power_cycle;
  453. unsigned long last_power_on;
  454. unsigned long last_backlight_off;
  455. bool psr_setup_done;
  456. bool use_tps3;
  457. struct intel_connector *attached_connector;
  458. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  459. /*
  460. * This function returns the value we have to program the AUX_CTL
  461. * register with to kick off an AUX transaction.
  462. */
  463. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  464. bool has_aux_irq,
  465. int send_bytes,
  466. uint32_t aux_clock_divider);
  467. struct {
  468. enum drrs_support_type type;
  469. enum edp_drrs_refresh_rate_type refresh_rate_type;
  470. } drrs_state;
  471. };
  472. struct intel_digital_port {
  473. struct intel_encoder base;
  474. enum port port;
  475. u32 saved_port_bits;
  476. struct intel_dp dp;
  477. struct intel_hdmi hdmi;
  478. };
  479. static inline int
  480. vlv_dport_to_channel(struct intel_digital_port *dport)
  481. {
  482. switch (dport->port) {
  483. case PORT_B:
  484. return DPIO_CH0;
  485. case PORT_C:
  486. return DPIO_CH1;
  487. default:
  488. BUG();
  489. }
  490. }
  491. static inline struct drm_crtc *
  492. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  493. {
  494. struct drm_i915_private *dev_priv = dev->dev_private;
  495. return dev_priv->pipe_to_crtc_mapping[pipe];
  496. }
  497. static inline struct drm_crtc *
  498. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  499. {
  500. struct drm_i915_private *dev_priv = dev->dev_private;
  501. return dev_priv->plane_to_crtc_mapping[plane];
  502. }
  503. struct intel_unpin_work {
  504. struct work_struct work;
  505. struct drm_crtc *crtc;
  506. struct drm_i915_gem_object *old_fb_obj;
  507. struct drm_i915_gem_object *pending_flip_obj;
  508. struct drm_pending_vblank_event *event;
  509. atomic_t pending;
  510. #define INTEL_FLIP_INACTIVE 0
  511. #define INTEL_FLIP_PENDING 1
  512. #define INTEL_FLIP_COMPLETE 2
  513. bool enable_stall_check;
  514. };
  515. struct intel_set_config {
  516. struct drm_encoder **save_connector_encoders;
  517. struct drm_crtc **save_encoder_crtcs;
  518. bool *save_crtc_enabled;
  519. bool fb_changed;
  520. bool mode_changed;
  521. };
  522. struct intel_load_detect_pipe {
  523. struct drm_framebuffer *release_fb;
  524. bool load_detect_temp;
  525. int dpms_mode;
  526. };
  527. static inline struct intel_encoder *
  528. intel_attached_encoder(struct drm_connector *connector)
  529. {
  530. return to_intel_connector(connector)->encoder;
  531. }
  532. static inline struct intel_digital_port *
  533. enc_to_dig_port(struct drm_encoder *encoder)
  534. {
  535. return container_of(encoder, struct intel_digital_port, base.base);
  536. }
  537. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  538. {
  539. return &enc_to_dig_port(encoder)->dp;
  540. }
  541. static inline struct intel_digital_port *
  542. dp_to_dig_port(struct intel_dp *intel_dp)
  543. {
  544. return container_of(intel_dp, struct intel_digital_port, dp);
  545. }
  546. static inline struct intel_digital_port *
  547. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  548. {
  549. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  550. }
  551. /* i915_irq.c */
  552. bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
  553. enum pipe pipe, bool enable);
  554. bool __intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
  555. enum pipe pipe, bool enable);
  556. bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,
  557. enum transcoder pch_transcoder,
  558. bool enable);
  559. void ilk_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  560. void ilk_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  561. void snb_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  562. void snb_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  563. void intel_runtime_pm_disable_interrupts(struct drm_device *dev);
  564. void intel_runtime_pm_restore_interrupts(struct drm_device *dev);
  565. /* intel_crt.c */
  566. void intel_crt_init(struct drm_device *dev);
  567. /* intel_ddi.c */
  568. void intel_prepare_ddi(struct drm_device *dev);
  569. void hsw_fdi_link_train(struct drm_crtc *crtc);
  570. void intel_ddi_init(struct drm_device *dev, enum port port);
  571. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  572. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  573. int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
  574. void intel_ddi_pll_init(struct drm_device *dev);
  575. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  576. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  577. enum transcoder cpu_transcoder);
  578. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  579. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  580. void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
  581. bool intel_ddi_pll_select(struct intel_crtc *crtc);
  582. void intel_ddi_pll_enable(struct intel_crtc *crtc);
  583. void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
  584. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  585. void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  586. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  587. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  588. void intel_ddi_get_config(struct intel_encoder *encoder,
  589. struct intel_crtc_config *pipe_config);
  590. /* intel_display.c */
  591. const char *intel_output_name(int output);
  592. bool intel_has_pending_fb_unpin(struct drm_device *dev);
  593. int intel_pch_rawclk(struct drm_device *dev);
  594. int valleyview_cur_cdclk(struct drm_i915_private *dev_priv);
  595. void intel_mark_busy(struct drm_device *dev);
  596. void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
  597. struct intel_ring_buffer *ring);
  598. void intel_mark_idle(struct drm_device *dev);
  599. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  600. void intel_crtc_update_dpms(struct drm_crtc *crtc);
  601. void intel_encoder_destroy(struct drm_encoder *encoder);
  602. void intel_connector_dpms(struct drm_connector *, int mode);
  603. bool intel_connector_get_hw_state(struct intel_connector *connector);
  604. void intel_modeset_check_state(struct drm_device *dev);
  605. bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
  606. struct intel_digital_port *port);
  607. void intel_connector_attach_encoder(struct intel_connector *connector,
  608. struct intel_encoder *encoder);
  609. struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  610. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  611. struct drm_crtc *crtc);
  612. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  613. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  614. struct drm_file *file_priv);
  615. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  616. enum pipe pipe);
  617. void intel_wait_for_vblank(struct drm_device *dev, int pipe);
  618. void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
  619. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  620. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  621. struct intel_digital_port *dport);
  622. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  623. struct drm_display_mode *mode,
  624. struct intel_load_detect_pipe *old);
  625. void intel_release_load_detect_pipe(struct drm_connector *connector,
  626. struct intel_load_detect_pipe *old);
  627. int intel_pin_and_fence_fb_obj(struct drm_device *dev,
  628. struct drm_i915_gem_object *obj,
  629. struct intel_ring_buffer *pipelined);
  630. void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
  631. struct drm_framebuffer *
  632. __intel_framebuffer_create(struct drm_device *dev,
  633. struct drm_mode_fb_cmd2 *mode_cmd,
  634. struct drm_i915_gem_object *obj);
  635. void intel_prepare_page_flip(struct drm_device *dev, int plane);
  636. void intel_finish_page_flip(struct drm_device *dev, int pipe);
  637. void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  638. struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
  639. void assert_shared_dpll(struct drm_i915_private *dev_priv,
  640. struct intel_shared_dpll *pll,
  641. bool state);
  642. #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
  643. #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
  644. void assert_pll(struct drm_i915_private *dev_priv,
  645. enum pipe pipe, bool state);
  646. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  647. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  648. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  649. enum pipe pipe, bool state);
  650. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  651. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  652. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  653. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  654. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  655. void intel_write_eld(struct drm_encoder *encoder,
  656. struct drm_display_mode *mode);
  657. unsigned long intel_gen4_compute_page_offset(int *x, int *y,
  658. unsigned int tiling_mode,
  659. unsigned int bpp,
  660. unsigned int pitch);
  661. void intel_display_handle_reset(struct drm_device *dev);
  662. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  663. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  664. void intel_dp_get_m_n(struct intel_crtc *crtc,
  665. struct intel_crtc_config *pipe_config);
  666. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  667. void
  668. ironlake_check_encoder_dotclock(const struct intel_crtc_config *pipe_config,
  669. int dotclock);
  670. bool intel_crtc_active(struct drm_crtc *crtc);
  671. void hsw_enable_ips(struct intel_crtc *crtc);
  672. void hsw_disable_ips(struct intel_crtc *crtc);
  673. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  674. enum intel_display_power_domain
  675. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  676. int valleyview_get_vco(struct drm_i915_private *dev_priv);
  677. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  678. struct intel_crtc_config *pipe_config);
  679. int intel_format_to_fourcc(int format);
  680. /* intel_dp.c */
  681. void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
  682. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  683. struct intel_connector *intel_connector);
  684. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  685. void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  686. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  687. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  688. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  689. void intel_dp_check_link_status(struct intel_dp *intel_dp);
  690. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  691. bool intel_dp_compute_config(struct intel_encoder *encoder,
  692. struct intel_crtc_config *pipe_config);
  693. bool intel_dp_is_edp(struct drm_device *dev, enum port port);
  694. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  695. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  696. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  697. void intel_edp_panel_on(struct intel_dp *intel_dp);
  698. void intel_edp_panel_off(struct intel_dp *intel_dp);
  699. void intel_edp_psr_enable(struct intel_dp *intel_dp);
  700. void intel_edp_psr_disable(struct intel_dp *intel_dp);
  701. void intel_edp_psr_update(struct drm_device *dev);
  702. /* intel_dsi.c */
  703. bool intel_dsi_init(struct drm_device *dev);
  704. /* intel_dvo.c */
  705. void intel_dvo_init(struct drm_device *dev);
  706. /* legacy fbdev emulation in intel_fbdev.c */
  707. #ifdef CONFIG_DRM_I915_FBDEV
  708. extern int intel_fbdev_init(struct drm_device *dev);
  709. extern void intel_fbdev_initial_config(struct drm_device *dev);
  710. extern void intel_fbdev_fini(struct drm_device *dev);
  711. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
  712. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  713. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  714. #else
  715. static inline int intel_fbdev_init(struct drm_device *dev)
  716. {
  717. return 0;
  718. }
  719. static inline void intel_fbdev_initial_config(struct drm_device *dev)
  720. {
  721. }
  722. static inline void intel_fbdev_fini(struct drm_device *dev)
  723. {
  724. }
  725. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state)
  726. {
  727. }
  728. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  729. {
  730. }
  731. #endif
  732. /* intel_hdmi.c */
  733. void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port);
  734. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  735. struct intel_connector *intel_connector);
  736. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  737. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  738. struct intel_crtc_config *pipe_config);
  739. /* intel_lvds.c */
  740. void intel_lvds_init(struct drm_device *dev);
  741. bool intel_is_dual_link_lvds(struct drm_device *dev);
  742. /* intel_modes.c */
  743. int intel_connector_update_modes(struct drm_connector *connector,
  744. struct edid *edid);
  745. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  746. void intel_attach_force_audio_property(struct drm_connector *connector);
  747. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  748. /* intel_overlay.c */
  749. void intel_setup_overlay(struct drm_device *dev);
  750. void intel_cleanup_overlay(struct drm_device *dev);
  751. int intel_overlay_switch_off(struct intel_overlay *overlay);
  752. int intel_overlay_put_image(struct drm_device *dev, void *data,
  753. struct drm_file *file_priv);
  754. int intel_overlay_attrs(struct drm_device *dev, void *data,
  755. struct drm_file *file_priv);
  756. /* intel_panel.c */
  757. int intel_panel_init(struct intel_panel *panel,
  758. struct drm_display_mode *fixed_mode,
  759. struct drm_display_mode *downclock_mode);
  760. void intel_panel_fini(struct intel_panel *panel);
  761. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  762. struct drm_display_mode *adjusted_mode);
  763. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  764. struct intel_crtc_config *pipe_config,
  765. int fitting_mode);
  766. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  767. struct intel_crtc_config *pipe_config,
  768. int fitting_mode);
  769. void intel_panel_set_backlight(struct intel_connector *connector, u32 level,
  770. u32 max);
  771. int intel_panel_setup_backlight(struct drm_connector *connector);
  772. void intel_panel_enable_backlight(struct intel_connector *connector);
  773. void intel_panel_disable_backlight(struct intel_connector *connector);
  774. void intel_panel_destroy_backlight(struct drm_connector *connector);
  775. void intel_panel_init_backlight_funcs(struct drm_device *dev);
  776. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  777. extern struct drm_display_mode *intel_find_panel_downclock(
  778. struct drm_device *dev,
  779. struct drm_display_mode *fixed_mode,
  780. struct drm_connector *connector);
  781. /* intel_pm.c */
  782. void intel_init_clock_gating(struct drm_device *dev);
  783. void intel_suspend_hw(struct drm_device *dev);
  784. void intel_update_watermarks(struct drm_crtc *crtc);
  785. void intel_update_sprite_watermarks(struct drm_plane *plane,
  786. struct drm_crtc *crtc,
  787. uint32_t sprite_width, int pixel_size,
  788. bool enabled, bool scaled);
  789. void intel_init_pm(struct drm_device *dev);
  790. void intel_pm_setup(struct drm_device *dev);
  791. bool intel_fbc_enabled(struct drm_device *dev);
  792. void intel_update_fbc(struct drm_device *dev);
  793. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  794. void intel_gpu_ips_teardown(void);
  795. int intel_power_domains_init(struct drm_i915_private *);
  796. void intel_power_domains_remove(struct drm_i915_private *);
  797. bool intel_display_power_enabled(struct drm_i915_private *dev_priv,
  798. enum intel_display_power_domain domain);
  799. bool intel_display_power_enabled_sw(struct drm_i915_private *dev_priv,
  800. enum intel_display_power_domain domain);
  801. void intel_display_power_get(struct drm_i915_private *dev_priv,
  802. enum intel_display_power_domain domain);
  803. void intel_display_power_put(struct drm_i915_private *dev_priv,
  804. enum intel_display_power_domain domain);
  805. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv);
  806. void intel_init_gt_powersave(struct drm_device *dev);
  807. void intel_cleanup_gt_powersave(struct drm_device *dev);
  808. void intel_enable_gt_powersave(struct drm_device *dev);
  809. void intel_disable_gt_powersave(struct drm_device *dev);
  810. void ironlake_teardown_rc6(struct drm_device *dev);
  811. void gen6_update_ring_freq(struct drm_device *dev);
  812. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  813. void gen6_rps_boost(struct drm_i915_private *dev_priv);
  814. void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv);
  815. void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
  816. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  817. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  818. void intel_init_runtime_pm(struct drm_i915_private *dev_priv);
  819. void intel_fini_runtime_pm(struct drm_i915_private *dev_priv);
  820. void ilk_wm_get_hw_state(struct drm_device *dev);
  821. /* intel_sdvo.c */
  822. bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
  823. /* intel_sprite.c */
  824. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  825. void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
  826. enum plane plane);
  827. void intel_plane_restore(struct drm_plane *plane);
  828. void intel_plane_disable(struct drm_plane *plane);
  829. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  830. struct drm_file *file_priv);
  831. int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
  832. struct drm_file *file_priv);
  833. /* intel_tv.c */
  834. void intel_tv_init(struct drm_device *dev);
  835. #endif /* __INTEL_DRV_H__ */