intel_drv.h 27 KB

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