intel_drv.h 30 KB

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