intel_drv.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  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. #define INTEL_I2C_BUS_DVO 1
  75. #define INTEL_I2C_BUS_SDVO 2
  76. /* these are outputs from the chip - integrated only
  77. external chips are via DVO or SDVO output */
  78. #define INTEL_OUTPUT_UNUSED 0
  79. #define INTEL_OUTPUT_ANALOG 1
  80. #define INTEL_OUTPUT_DVO 2
  81. #define INTEL_OUTPUT_SDVO 3
  82. #define INTEL_OUTPUT_LVDS 4
  83. #define INTEL_OUTPUT_TVOUT 5
  84. #define INTEL_OUTPUT_HDMI 6
  85. #define INTEL_OUTPUT_DISPLAYPORT 7
  86. #define INTEL_OUTPUT_EDP 8
  87. #define INTEL_OUTPUT_DSI 9
  88. #define INTEL_OUTPUT_UNKNOWN 10
  89. #define INTEL_DVO_CHIP_NONE 0
  90. #define INTEL_DVO_CHIP_LVDS 1
  91. #define INTEL_DVO_CHIP_TMDS 2
  92. #define INTEL_DVO_CHIP_TVOUT 4
  93. #define INTEL_DSI_COMMAND_MODE 0
  94. #define INTEL_DSI_VIDEO_MODE 1
  95. struct intel_framebuffer {
  96. struct drm_framebuffer base;
  97. struct drm_i915_gem_object *obj;
  98. };
  99. struct intel_fbdev {
  100. struct drm_fb_helper helper;
  101. struct intel_framebuffer ifb;
  102. struct list_head fbdev_list;
  103. struct drm_display_mode *our_mode;
  104. };
  105. struct intel_encoder {
  106. struct drm_encoder base;
  107. /*
  108. * The new crtc this encoder will be driven from. Only differs from
  109. * base->crtc while a modeset is in progress.
  110. */
  111. struct intel_crtc *new_crtc;
  112. int type;
  113. /*
  114. * Intel hw has only one MUX where encoders could be clone, hence a
  115. * simple flag is enough to compute the possible_clones mask.
  116. */
  117. bool cloneable;
  118. bool connectors_active;
  119. void (*hot_plug)(struct intel_encoder *);
  120. bool (*compute_config)(struct intel_encoder *,
  121. struct intel_crtc_config *);
  122. void (*pre_pll_enable)(struct intel_encoder *);
  123. void (*pre_enable)(struct intel_encoder *);
  124. void (*enable)(struct intel_encoder *);
  125. void (*mode_set)(struct intel_encoder *intel_encoder);
  126. void (*disable)(struct intel_encoder *);
  127. void (*post_disable)(struct intel_encoder *);
  128. /* Read out the current hw state of this connector, returning true if
  129. * the encoder is active. If the encoder is enabled it also set the pipe
  130. * it is connected to in the pipe parameter. */
  131. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  132. /* Reconstructs the equivalent mode flags for the current hardware
  133. * state. This must be called _after_ display->get_pipe_config has
  134. * pre-filled the pipe config. Note that intel_encoder->base.crtc must
  135. * be set correctly before calling this function. */
  136. void (*get_config)(struct intel_encoder *,
  137. struct intel_crtc_config *pipe_config);
  138. int crtc_mask;
  139. enum hpd_pin hpd_pin;
  140. };
  141. struct intel_panel {
  142. struct drm_display_mode *fixed_mode;
  143. int fitting_mode;
  144. };
  145. struct intel_connector {
  146. struct drm_connector base;
  147. /*
  148. * The fixed encoder this connector is connected to.
  149. */
  150. struct intel_encoder *encoder;
  151. /*
  152. * The new encoder this connector will be driven. Only differs from
  153. * encoder while a modeset is in progress.
  154. */
  155. struct intel_encoder *new_encoder;
  156. /* Reads out the current hw, returning true if the connector is enabled
  157. * and active (i.e. dpms ON state). */
  158. bool (*get_hw_state)(struct intel_connector *);
  159. /* Panel info for eDP and LVDS */
  160. struct intel_panel panel;
  161. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  162. struct edid *edid;
  163. /* since POLL and HPD connectors may use the same HPD line keep the native
  164. state of connector->polled in case hotplug storm detection changes it */
  165. u8 polled;
  166. };
  167. typedef struct dpll {
  168. /* given values */
  169. int n;
  170. int m1, m2;
  171. int p1, p2;
  172. /* derived values */
  173. int dot;
  174. int vco;
  175. int m;
  176. int p;
  177. } intel_clock_t;
  178. struct intel_crtc_config {
  179. /**
  180. * quirks - bitfield with hw state readout quirks
  181. *
  182. * For various reasons the hw state readout code might not be able to
  183. * completely faithfully read out the current state. These cases are
  184. * tracked with quirk flags so that fastboot and state checker can act
  185. * accordingly.
  186. */
  187. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  188. unsigned long quirks;
  189. /* User requested mode, only valid as a starting point to
  190. * compute adjusted_mode, except in the case of (S)DVO where
  191. * it's also for the output timings of the (S)DVO chip.
  192. * adjusted_mode will then correspond to the S(DVO) chip's
  193. * preferred input timings. */
  194. struct drm_display_mode requested_mode;
  195. /* Actual pipe timings ie. what we program into the pipe timing
  196. * registers. adjusted_mode.crtc_clock is the pipe pixel clock. */
  197. struct drm_display_mode adjusted_mode;
  198. /* Pipe source size (ie. panel fitter input size)
  199. * All planes will be positioned inside this space,
  200. * and get clipped at the edges. */
  201. int pipe_src_w, pipe_src_h;
  202. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  203. * between pch encoders and cpu encoders. */
  204. bool has_pch_encoder;
  205. /* CPU Transcoder for the pipe. Currently this can only differ from the
  206. * pipe on Haswell (where we have a special eDP transcoder). */
  207. enum transcoder cpu_transcoder;
  208. /*
  209. * Use reduced/limited/broadcast rbg range, compressing from the full
  210. * range fed into the crtcs.
  211. */
  212. bool limited_color_range;
  213. /* DP has a bunch of special case unfortunately, so mark the pipe
  214. * accordingly. */
  215. bool has_dp_encoder;
  216. /*
  217. * Enable dithering, used when the selected pipe bpp doesn't match the
  218. * plane bpp.
  219. */
  220. bool dither;
  221. /* Controls for the clock computation, to override various stages. */
  222. bool clock_set;
  223. /* SDVO TV has a bunch of special case. To make multifunction encoders
  224. * work correctly, we need to track this at runtime.*/
  225. bool sdvo_tv_clock;
  226. /*
  227. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  228. * required. This is set in the 2nd loop of calling encoder's
  229. * ->compute_config if the first pick doesn't work out.
  230. */
  231. bool bw_constrained;
  232. /* Settings for the intel dpll used on pretty much everything but
  233. * haswell. */
  234. struct dpll dpll;
  235. /* Selected dpll when shared or DPLL_ID_PRIVATE. */
  236. enum intel_dpll_id shared_dpll;
  237. /* Actual register state of the dpll, for shared dpll cross-checking. */
  238. struct intel_dpll_hw_state dpll_hw_state;
  239. int pipe_bpp;
  240. struct intel_link_m_n dp_m_n;
  241. /*
  242. * Frequence the dpll for the port should run at. Differs from the
  243. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  244. * already multiplied by pixel_multiplier.
  245. */
  246. int port_clock;
  247. /* Used by SDVO (and if we ever fix it, HDMI). */
  248. unsigned pixel_multiplier;
  249. /* Panel fitter controls for gen2-gen4 + VLV */
  250. struct {
  251. u32 control;
  252. u32 pgm_ratios;
  253. u32 lvds_border_bits;
  254. } gmch_pfit;
  255. /* Panel fitter placement and size for Ironlake+ */
  256. struct {
  257. u32 pos;
  258. u32 size;
  259. bool enabled;
  260. } pch_pfit;
  261. /* FDI configuration, only valid if has_pch_encoder is set. */
  262. int fdi_lanes;
  263. struct intel_link_m_n fdi_m_n;
  264. bool ips_enabled;
  265. bool double_wide;
  266. };
  267. struct intel_pipe_wm {
  268. struct intel_wm_level wm[5];
  269. uint32_t linetime;
  270. bool fbc_wm_enabled;
  271. };
  272. struct intel_crtc {
  273. struct drm_crtc base;
  274. enum pipe pipe;
  275. enum plane plane;
  276. u8 lut_r[256], lut_g[256], lut_b[256];
  277. /*
  278. * Whether the crtc and the connected output pipeline is active. Implies
  279. * that crtc->enabled is set, i.e. the current mode configuration has
  280. * some outputs connected to this crtc.
  281. */
  282. bool active;
  283. bool eld_vld;
  284. bool primary_enabled; /* is the primary plane (partially) visible? */
  285. bool lowfreq_avail;
  286. struct intel_overlay *overlay;
  287. struct intel_unpin_work *unpin_work;
  288. atomic_t unpin_work_count;
  289. /* Display surface base address adjustement for pageflips. Note that on
  290. * gen4+ this only adjusts up to a tile, offsets within a tile are
  291. * handled in the hw itself (with the TILEOFF register). */
  292. unsigned long dspaddr_offset;
  293. struct drm_i915_gem_object *cursor_bo;
  294. uint32_t cursor_addr;
  295. int16_t cursor_x, cursor_y;
  296. int16_t cursor_width, cursor_height;
  297. bool cursor_visible;
  298. struct intel_crtc_config config;
  299. uint32_t ddi_pll_sel;
  300. /* reset counter value when the last flip was submitted */
  301. unsigned int reset_counter;
  302. /* Access to these should be protected by dev_priv->irq_lock. */
  303. bool cpu_fifo_underrun_disabled;
  304. bool pch_fifo_underrun_disabled;
  305. /* per-pipe watermark state */
  306. struct {
  307. /* watermarks currently being used */
  308. struct intel_pipe_wm active;
  309. } wm;
  310. };
  311. struct intel_plane_wm_parameters {
  312. uint32_t horiz_pixels;
  313. uint8_t bytes_per_pixel;
  314. bool enabled;
  315. bool scaled;
  316. };
  317. struct intel_plane {
  318. struct drm_plane base;
  319. int plane;
  320. enum pipe pipe;
  321. struct drm_i915_gem_object *obj;
  322. bool can_scale;
  323. int max_downscale;
  324. u32 lut_r[1024], lut_g[1024], lut_b[1024];
  325. int crtc_x, crtc_y;
  326. unsigned int crtc_w, crtc_h;
  327. uint32_t src_x, src_y;
  328. uint32_t src_w, src_h;
  329. /* Since we need to change the watermarks before/after
  330. * enabling/disabling the planes, we need to store the parameters here
  331. * as the other pieces of the struct may not reflect the values we want
  332. * for the watermark calculations. Currently only Haswell uses this.
  333. */
  334. struct intel_plane_wm_parameters wm;
  335. void (*update_plane)(struct drm_plane *plane,
  336. struct drm_crtc *crtc,
  337. struct drm_framebuffer *fb,
  338. struct drm_i915_gem_object *obj,
  339. int crtc_x, int crtc_y,
  340. unsigned int crtc_w, unsigned int crtc_h,
  341. uint32_t x, uint32_t y,
  342. uint32_t src_w, uint32_t src_h);
  343. void (*disable_plane)(struct drm_plane *plane,
  344. struct drm_crtc *crtc);
  345. int (*update_colorkey)(struct drm_plane *plane,
  346. struct drm_intel_sprite_colorkey *key);
  347. void (*get_colorkey)(struct drm_plane *plane,
  348. struct drm_intel_sprite_colorkey *key);
  349. };
  350. struct intel_watermark_params {
  351. unsigned long fifo_size;
  352. unsigned long max_wm;
  353. unsigned long default_wm;
  354. unsigned long guard_size;
  355. unsigned long cacheline_size;
  356. };
  357. struct cxsr_latency {
  358. int is_desktop;
  359. int is_ddr3;
  360. unsigned long fsb_freq;
  361. unsigned long mem_freq;
  362. unsigned long display_sr;
  363. unsigned long display_hpll_disable;
  364. unsigned long cursor_sr;
  365. unsigned long cursor_hpll_disable;
  366. };
  367. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  368. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  369. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  370. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  371. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  372. struct intel_hdmi {
  373. u32 hdmi_reg;
  374. int ddc_bus;
  375. uint32_t color_range;
  376. bool color_range_auto;
  377. bool has_hdmi_sink;
  378. bool has_audio;
  379. enum hdmi_force_audio force_audio;
  380. bool rgb_quant_range_selectable;
  381. void (*write_infoframe)(struct drm_encoder *encoder,
  382. enum hdmi_infoframe_type type,
  383. const uint8_t *frame, ssize_t len);
  384. void (*set_infoframes)(struct drm_encoder *encoder,
  385. struct drm_display_mode *adjusted_mode);
  386. };
  387. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  388. struct intel_dp {
  389. uint32_t output_reg;
  390. uint32_t aux_ch_ctl_reg;
  391. uint32_t DP;
  392. bool has_audio;
  393. enum hdmi_force_audio force_audio;
  394. uint32_t color_range;
  395. bool color_range_auto;
  396. uint8_t link_bw;
  397. uint8_t lane_count;
  398. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  399. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  400. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  401. struct i2c_adapter adapter;
  402. struct i2c_algo_dp_aux_data algo;
  403. uint8_t train_set[4];
  404. int panel_power_up_delay;
  405. int panel_power_down_delay;
  406. int panel_power_cycle_delay;
  407. int backlight_on_delay;
  408. int backlight_off_delay;
  409. struct delayed_work panel_vdd_work;
  410. bool want_panel_vdd;
  411. bool psr_setup_done;
  412. struct intel_connector *attached_connector;
  413. };
  414. struct intel_digital_port {
  415. struct intel_encoder base;
  416. enum port port;
  417. u32 saved_port_bits;
  418. struct intel_dp dp;
  419. struct intel_hdmi hdmi;
  420. };
  421. static inline int
  422. vlv_dport_to_channel(struct intel_digital_port *dport)
  423. {
  424. switch (dport->port) {
  425. case PORT_B:
  426. return 0;
  427. case PORT_C:
  428. return 1;
  429. default:
  430. BUG();
  431. }
  432. }
  433. static inline struct drm_crtc *
  434. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  435. {
  436. struct drm_i915_private *dev_priv = dev->dev_private;
  437. return dev_priv->pipe_to_crtc_mapping[pipe];
  438. }
  439. static inline struct drm_crtc *
  440. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  441. {
  442. struct drm_i915_private *dev_priv = dev->dev_private;
  443. return dev_priv->plane_to_crtc_mapping[plane];
  444. }
  445. struct intel_unpin_work {
  446. struct work_struct work;
  447. struct drm_crtc *crtc;
  448. struct drm_i915_gem_object *old_fb_obj;
  449. struct drm_i915_gem_object *pending_flip_obj;
  450. struct drm_pending_vblank_event *event;
  451. atomic_t pending;
  452. #define INTEL_FLIP_INACTIVE 0
  453. #define INTEL_FLIP_PENDING 1
  454. #define INTEL_FLIP_COMPLETE 2
  455. bool enable_stall_check;
  456. };
  457. struct intel_set_config {
  458. struct drm_encoder **save_connector_encoders;
  459. struct drm_crtc **save_encoder_crtcs;
  460. bool fb_changed;
  461. bool mode_changed;
  462. };
  463. struct intel_load_detect_pipe {
  464. struct drm_framebuffer *release_fb;
  465. bool load_detect_temp;
  466. int dpms_mode;
  467. };
  468. static inline struct intel_encoder *
  469. intel_attached_encoder(struct drm_connector *connector)
  470. {
  471. return to_intel_connector(connector)->encoder;
  472. }
  473. static inline struct intel_digital_port *
  474. enc_to_dig_port(struct drm_encoder *encoder)
  475. {
  476. return container_of(encoder, struct intel_digital_port, base.base);
  477. }
  478. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  479. {
  480. return &enc_to_dig_port(encoder)->dp;
  481. }
  482. static inline struct intel_digital_port *
  483. dp_to_dig_port(struct intel_dp *intel_dp)
  484. {
  485. return container_of(intel_dp, struct intel_digital_port, dp);
  486. }
  487. static inline struct intel_digital_port *
  488. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  489. {
  490. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  491. }
  492. /* i915_irq.c */
  493. bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
  494. enum pipe pipe, bool enable);
  495. bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,
  496. enum transcoder pch_transcoder,
  497. bool enable);
  498. void ilk_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  499. void ilk_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  500. void snb_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  501. void snb_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  502. void hsw_pc8_disable_interrupts(struct drm_device *dev);
  503. void hsw_pc8_restore_interrupts(struct drm_device *dev);
  504. /* intel_crt.c */
  505. void intel_crt_init(struct drm_device *dev);
  506. /* intel_ddi.c */
  507. void intel_prepare_ddi(struct drm_device *dev);
  508. void hsw_fdi_link_train(struct drm_crtc *crtc);
  509. void intel_ddi_init(struct drm_device *dev, enum port port);
  510. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  511. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  512. int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
  513. void intel_ddi_pll_init(struct drm_device *dev);
  514. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  515. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  516. enum transcoder cpu_transcoder);
  517. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  518. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  519. void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
  520. bool intel_ddi_pll_mode_set(struct drm_crtc *crtc);
  521. void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
  522. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  523. void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  524. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  525. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  526. void intel_ddi_get_config(struct intel_encoder *encoder,
  527. struct intel_crtc_config *pipe_config);
  528. /* intel_display.c */
  529. int intel_pch_rawclk(struct drm_device *dev);
  530. void intel_mark_busy(struct drm_device *dev);
  531. void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
  532. struct intel_ring_buffer *ring);
  533. void intel_mark_idle(struct drm_device *dev);
  534. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  535. void intel_crtc_update_dpms(struct drm_crtc *crtc);
  536. void intel_encoder_destroy(struct drm_encoder *encoder);
  537. void intel_connector_dpms(struct drm_connector *, int mode);
  538. bool intel_connector_get_hw_state(struct intel_connector *connector);
  539. void intel_modeset_check_state(struct drm_device *dev);
  540. bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
  541. struct intel_digital_port *port);
  542. void intel_connector_attach_encoder(struct intel_connector *connector,
  543. struct intel_encoder *encoder);
  544. struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  545. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  546. struct drm_crtc *crtc);
  547. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  548. struct drm_file *file_priv);
  549. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  550. enum pipe pipe);
  551. void intel_wait_for_vblank(struct drm_device *dev, int pipe);
  552. void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
  553. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  554. void vlv_wait_port_ready(struct drm_i915_private *dev_priv, int port);
  555. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  556. struct drm_display_mode *mode,
  557. struct intel_load_detect_pipe *old);
  558. void intel_release_load_detect_pipe(struct drm_connector *connector,
  559. struct intel_load_detect_pipe *old);
  560. int intel_pin_and_fence_fb_obj(struct drm_device *dev,
  561. struct drm_i915_gem_object *obj,
  562. struct intel_ring_buffer *pipelined);
  563. void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
  564. int intel_framebuffer_init(struct drm_device *dev,
  565. struct intel_framebuffer *ifb,
  566. struct drm_mode_fb_cmd2 *mode_cmd,
  567. struct drm_i915_gem_object *obj);
  568. void intel_framebuffer_fini(struct intel_framebuffer *fb);
  569. void intel_prepare_page_flip(struct drm_device *dev, int plane);
  570. void intel_finish_page_flip(struct drm_device *dev, int pipe);
  571. void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  572. struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
  573. void assert_shared_dpll(struct drm_i915_private *dev_priv,
  574. struct intel_shared_dpll *pll,
  575. bool state);
  576. #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
  577. #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
  578. void assert_pll(struct drm_i915_private *dev_priv,
  579. enum pipe pipe, bool state);
  580. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  581. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  582. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  583. enum pipe pipe, bool state);
  584. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  585. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  586. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  587. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  588. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  589. void intel_write_eld(struct drm_encoder *encoder,
  590. struct drm_display_mode *mode);
  591. unsigned long intel_gen4_compute_page_offset(int *x, int *y,
  592. unsigned int tiling_mode,
  593. unsigned int bpp,
  594. unsigned int pitch);
  595. void intel_display_handle_reset(struct drm_device *dev);
  596. void hsw_enable_pc8_work(struct work_struct *__work);
  597. void hsw_enable_package_c8(struct drm_i915_private *dev_priv);
  598. void hsw_disable_package_c8(struct drm_i915_private *dev_priv);
  599. void intel_dp_get_m_n(struct intel_crtc *crtc,
  600. struct intel_crtc_config *pipe_config);
  601. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  602. void
  603. ironlake_check_encoder_dotclock(const struct intel_crtc_config *pipe_config,
  604. int dotclock);
  605. bool intel_crtc_active(struct drm_crtc *crtc);
  606. void i915_disable_vga_mem(struct drm_device *dev);
  607. void hsw_enable_ips(struct intel_crtc *crtc);
  608. void hsw_disable_ips(struct intel_crtc *crtc);
  609. /* intel_dp.c */
  610. void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
  611. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  612. struct intel_connector *intel_connector);
  613. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  614. void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  615. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  616. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  617. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  618. void intel_dp_check_link_status(struct intel_dp *intel_dp);
  619. bool intel_dp_compute_config(struct intel_encoder *encoder,
  620. struct intel_crtc_config *pipe_config);
  621. bool intel_dpd_is_edp(struct drm_device *dev);
  622. void ironlake_edp_backlight_on(struct intel_dp *intel_dp);
  623. void ironlake_edp_backlight_off(struct intel_dp *intel_dp);
  624. void ironlake_edp_panel_on(struct intel_dp *intel_dp);
  625. void ironlake_edp_panel_off(struct intel_dp *intel_dp);
  626. void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
  627. void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
  628. void intel_edp_psr_enable(struct intel_dp *intel_dp);
  629. void intel_edp_psr_disable(struct intel_dp *intel_dp);
  630. void intel_edp_psr_update(struct drm_device *dev);
  631. /* intel_dsi.c */
  632. bool intel_dsi_init(struct drm_device *dev);
  633. /* intel_dvo.c */
  634. void intel_dvo_init(struct drm_device *dev);
  635. /* legacy fbdev emulation in intel_fbdev.c */
  636. #ifdef CONFIG_DRM_I915_FBDEV
  637. extern int intel_fbdev_init(struct drm_device *dev);
  638. extern void intel_fbdev_initial_config(struct drm_device *dev);
  639. extern void intel_fbdev_fini(struct drm_device *dev);
  640. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
  641. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  642. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  643. #else
  644. static inline int intel_fbdev_init(struct drm_device *dev)
  645. {
  646. return 0;
  647. }
  648. static inline void intel_fbdev_initial_config(struct drm_device *dev)
  649. {
  650. }
  651. static inline void intel_fbdev_fini(struct drm_device *dev)
  652. {
  653. }
  654. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state)
  655. {
  656. }
  657. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  658. {
  659. }
  660. #endif
  661. /* intel_hdmi.c */
  662. void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port);
  663. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  664. struct intel_connector *intel_connector);
  665. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  666. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  667. struct intel_crtc_config *pipe_config);
  668. /* intel_lvds.c */
  669. void intel_lvds_init(struct drm_device *dev);
  670. bool intel_is_dual_link_lvds(struct drm_device *dev);
  671. /* intel_modes.c */
  672. int intel_connector_update_modes(struct drm_connector *connector,
  673. struct edid *edid);
  674. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  675. void intel_attach_force_audio_property(struct drm_connector *connector);
  676. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  677. /* intel_overlay.c */
  678. void intel_setup_overlay(struct drm_device *dev);
  679. void intel_cleanup_overlay(struct drm_device *dev);
  680. int intel_overlay_switch_off(struct intel_overlay *overlay);
  681. int intel_overlay_put_image(struct drm_device *dev, void *data,
  682. struct drm_file *file_priv);
  683. int intel_overlay_attrs(struct drm_device *dev, void *data,
  684. struct drm_file *file_priv);
  685. /* intel_panel.c */
  686. int intel_panel_init(struct intel_panel *panel,
  687. struct drm_display_mode *fixed_mode);
  688. void intel_panel_fini(struct intel_panel *panel);
  689. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  690. struct drm_display_mode *adjusted_mode);
  691. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  692. struct intel_crtc_config *pipe_config,
  693. int fitting_mode);
  694. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  695. struct intel_crtc_config *pipe_config,
  696. int fitting_mode);
  697. void intel_panel_set_backlight(struct drm_device *dev, u32 level, u32 max);
  698. int intel_panel_setup_backlight(struct drm_connector *connector);
  699. void intel_panel_enable_backlight(struct drm_device *dev, enum pipe pipe);
  700. void intel_panel_disable_backlight(struct drm_device *dev);
  701. void intel_panel_destroy_backlight(struct drm_device *dev);
  702. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  703. /* intel_pm.c */
  704. void intel_init_clock_gating(struct drm_device *dev);
  705. void intel_suspend_hw(struct drm_device *dev);
  706. void intel_update_watermarks(struct drm_crtc *crtc);
  707. void intel_update_sprite_watermarks(struct drm_plane *plane,
  708. struct drm_crtc *crtc,
  709. uint32_t sprite_width, int pixel_size,
  710. bool enabled, bool scaled);
  711. void intel_init_pm(struct drm_device *dev);
  712. bool intel_fbc_enabled(struct drm_device *dev);
  713. void intel_update_fbc(struct drm_device *dev);
  714. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  715. void intel_gpu_ips_teardown(void);
  716. int i915_init_power_well(struct drm_device *dev);
  717. void i915_remove_power_well(struct drm_device *dev);
  718. bool intel_display_power_enabled(struct drm_device *dev,
  719. enum intel_display_power_domain domain);
  720. void intel_display_power_get(struct drm_device *dev,
  721. enum intel_display_power_domain domain);
  722. void intel_display_power_put(struct drm_device *dev,
  723. enum intel_display_power_domain domain);
  724. void intel_init_power_well(struct drm_device *dev);
  725. void intel_set_power_well(struct drm_device *dev, bool enable);
  726. void intel_enable_gt_powersave(struct drm_device *dev);
  727. void intel_disable_gt_powersave(struct drm_device *dev);
  728. void ironlake_teardown_rc6(struct drm_device *dev);
  729. void gen6_update_ring_freq(struct drm_device *dev);
  730. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  731. void gen6_rps_boost(struct drm_i915_private *dev_priv);
  732. void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv);
  733. void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
  734. void ilk_wm_get_hw_state(struct drm_device *dev);
  735. /* intel_sdvo.c */
  736. bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
  737. /* intel_sprite.c */
  738. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  739. void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
  740. enum plane plane);
  741. void intel_plane_restore(struct drm_plane *plane);
  742. void intel_plane_disable(struct drm_plane *plane);
  743. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  744. struct drm_file *file_priv);
  745. int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
  746. struct drm_file *file_priv);
  747. /* intel_tv.c */
  748. void intel_tv_init(struct drm_device *dev);
  749. #endif /* __INTEL_DRV_H__ */