intel_drv.h 31 KB

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