intel_drv.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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 <drm/i915_drm.h>
  29. #include "i915_drv.h"
  30. #include <drm/drm_crtc.h>
  31. #include <drm/drm_crtc_helper.h>
  32. #include <drm/drm_fb_helper.h>
  33. #include <drm/drm_dp_helper.h>
  34. #define _wait_for(COND, MS, W) ({ \
  35. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
  36. int ret__ = 0; \
  37. while (!(COND)) { \
  38. if (time_after(jiffies, timeout__)) { \
  39. ret__ = -ETIMEDOUT; \
  40. break; \
  41. } \
  42. if (W && drm_can_sleep()) { \
  43. msleep(W); \
  44. } else { \
  45. cpu_relax(); \
  46. } \
  47. } \
  48. ret__; \
  49. })
  50. #define wait_for_atomic_us(COND, US) ({ \
  51. unsigned long timeout__ = jiffies + usecs_to_jiffies(US); \
  52. int ret__ = 0; \
  53. while (!(COND)) { \
  54. if (time_after(jiffies, timeout__)) { \
  55. ret__ = -ETIMEDOUT; \
  56. break; \
  57. } \
  58. cpu_relax(); \
  59. } \
  60. ret__; \
  61. })
  62. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  63. #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 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_DVO_CHIP_NONE 0
  89. #define INTEL_DVO_CHIP_LVDS 1
  90. #define INTEL_DVO_CHIP_TMDS 2
  91. #define INTEL_DVO_CHIP_TVOUT 4
  92. /* drm_display_mode->private_flags */
  93. #define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)
  94. #define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)
  95. #define INTEL_MODE_DP_FORCE_6BPC (0x10)
  96. /* This flag must be set by the encoder's mode_fixup if it changes the crtc
  97. * timings in the mode to prevent the crtc fixup from overwriting them.
  98. * Currently only lvds needs that. */
  99. #define INTEL_MODE_CRTC_TIMINGS_SET (0x20)
  100. static inline void
  101. intel_mode_set_pixel_multiplier(struct drm_display_mode *mode,
  102. int multiplier)
  103. {
  104. mode->clock *= multiplier;
  105. mode->private_flags |= multiplier;
  106. }
  107. static inline int
  108. intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode)
  109. {
  110. return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK) >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT;
  111. }
  112. struct intel_framebuffer {
  113. struct drm_framebuffer base;
  114. struct drm_i915_gem_object *obj;
  115. };
  116. struct intel_fbdev {
  117. struct drm_fb_helper helper;
  118. struct intel_framebuffer ifb;
  119. struct list_head fbdev_list;
  120. struct drm_display_mode *our_mode;
  121. };
  122. struct intel_encoder {
  123. struct drm_encoder base;
  124. /*
  125. * The new crtc this encoder will be driven from. Only differs from
  126. * base->crtc while a modeset is in progress.
  127. */
  128. struct intel_crtc *new_crtc;
  129. int type;
  130. bool needs_tv_clock;
  131. /*
  132. * Intel hw has only one MUX where encoders could be clone, hence a
  133. * simple flag is enough to compute the possible_clones mask.
  134. */
  135. bool cloneable;
  136. bool connectors_active;
  137. void (*hot_plug)(struct intel_encoder *);
  138. void (*pre_enable)(struct intel_encoder *);
  139. void (*enable)(struct intel_encoder *);
  140. void (*disable)(struct intel_encoder *);
  141. void (*post_disable)(struct intel_encoder *);
  142. /* Read out the current hw state of this connector, returning true if
  143. * the encoder is active. If the encoder is enabled it also set the pipe
  144. * it is connected to in the pipe parameter. */
  145. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  146. int crtc_mask;
  147. };
  148. struct intel_panel {
  149. struct drm_display_mode *fixed_mode;
  150. int fitting_mode;
  151. };
  152. struct intel_connector {
  153. struct drm_connector base;
  154. /*
  155. * The fixed encoder this connector is connected to.
  156. */
  157. struct intel_encoder *encoder;
  158. /*
  159. * The new encoder this connector will be driven. Only differs from
  160. * encoder while a modeset is in progress.
  161. */
  162. struct intel_encoder *new_encoder;
  163. /* Reads out the current hw, returning true if the connector is enabled
  164. * and active (i.e. dpms ON state). */
  165. bool (*get_hw_state)(struct intel_connector *);
  166. /* Panel info for eDP and LVDS */
  167. struct intel_panel panel;
  168. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  169. struct edid *edid;
  170. };
  171. struct intel_crtc {
  172. struct drm_crtc base;
  173. enum pipe pipe;
  174. enum plane plane;
  175. enum transcoder cpu_transcoder;
  176. u8 lut_r[256], lut_g[256], lut_b[256];
  177. /*
  178. * Whether the crtc and the connected output pipeline is active. Implies
  179. * that crtc->enabled is set, i.e. the current mode configuration has
  180. * some outputs connected to this crtc.
  181. */
  182. bool active;
  183. bool primary_disabled; /* is the crtc obscured by a plane? */
  184. bool lowfreq_avail;
  185. struct intel_overlay *overlay;
  186. struct intel_unpin_work *unpin_work;
  187. int fdi_lanes;
  188. /* Display surface base address adjustement for pageflips. Note that on
  189. * gen4+ this only adjusts up to a tile, offsets within a tile are
  190. * handled in the hw itself (with the TILEOFF register). */
  191. unsigned long dspaddr_offset;
  192. struct drm_i915_gem_object *cursor_bo;
  193. uint32_t cursor_addr;
  194. int16_t cursor_x, cursor_y;
  195. int16_t cursor_width, cursor_height;
  196. bool cursor_visible;
  197. unsigned int bpp;
  198. /* We can share PLLs across outputs if the timings match */
  199. struct intel_pch_pll *pch_pll;
  200. uint32_t ddi_pll_sel;
  201. };
  202. struct intel_plane {
  203. struct drm_plane base;
  204. enum pipe pipe;
  205. struct drm_i915_gem_object *obj;
  206. bool can_scale;
  207. int max_downscale;
  208. u32 lut_r[1024], lut_g[1024], lut_b[1024];
  209. void (*update_plane)(struct drm_plane *plane,
  210. struct drm_framebuffer *fb,
  211. struct drm_i915_gem_object *obj,
  212. int crtc_x, int crtc_y,
  213. unsigned int crtc_w, unsigned int crtc_h,
  214. uint32_t x, uint32_t y,
  215. uint32_t src_w, uint32_t src_h);
  216. void (*disable_plane)(struct drm_plane *plane);
  217. int (*update_colorkey)(struct drm_plane *plane,
  218. struct drm_intel_sprite_colorkey *key);
  219. void (*get_colorkey)(struct drm_plane *plane,
  220. struct drm_intel_sprite_colorkey *key);
  221. };
  222. struct intel_watermark_params {
  223. unsigned long fifo_size;
  224. unsigned long max_wm;
  225. unsigned long default_wm;
  226. unsigned long guard_size;
  227. unsigned long cacheline_size;
  228. };
  229. struct cxsr_latency {
  230. int is_desktop;
  231. int is_ddr3;
  232. unsigned long fsb_freq;
  233. unsigned long mem_freq;
  234. unsigned long display_sr;
  235. unsigned long display_hpll_disable;
  236. unsigned long cursor_sr;
  237. unsigned long cursor_hpll_disable;
  238. };
  239. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  240. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  241. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  242. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  243. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  244. #define DIP_HEADER_SIZE 5
  245. #define DIP_TYPE_AVI 0x82
  246. #define DIP_VERSION_AVI 0x2
  247. #define DIP_LEN_AVI 13
  248. #define DIP_AVI_PR_1 0
  249. #define DIP_AVI_PR_2 1
  250. #define DIP_TYPE_SPD 0x83
  251. #define DIP_VERSION_SPD 0x1
  252. #define DIP_LEN_SPD 25
  253. #define DIP_SPD_UNKNOWN 0
  254. #define DIP_SPD_DSTB 0x1
  255. #define DIP_SPD_DVDP 0x2
  256. #define DIP_SPD_DVHS 0x3
  257. #define DIP_SPD_HDDVR 0x4
  258. #define DIP_SPD_DVC 0x5
  259. #define DIP_SPD_DSC 0x6
  260. #define DIP_SPD_VCD 0x7
  261. #define DIP_SPD_GAME 0x8
  262. #define DIP_SPD_PC 0x9
  263. #define DIP_SPD_BD 0xa
  264. #define DIP_SPD_SCD 0xb
  265. struct dip_infoframe {
  266. uint8_t type; /* HB0 */
  267. uint8_t ver; /* HB1 */
  268. uint8_t len; /* HB2 - body len, not including checksum */
  269. uint8_t ecc; /* Header ECC */
  270. uint8_t checksum; /* PB0 */
  271. union {
  272. struct {
  273. /* PB1 - Y 6:5, A 4:4, B 3:2, S 1:0 */
  274. uint8_t Y_A_B_S;
  275. /* PB2 - C 7:6, M 5:4, R 3:0 */
  276. uint8_t C_M_R;
  277. /* PB3 - ITC 7:7, EC 6:4, Q 3:2, SC 1:0 */
  278. uint8_t ITC_EC_Q_SC;
  279. /* PB4 - VIC 6:0 */
  280. uint8_t VIC;
  281. /* PB5 - YQ 7:6, CN 5:4, PR 3:0 */
  282. uint8_t YQ_CN_PR;
  283. /* PB6 to PB13 */
  284. uint16_t top_bar_end;
  285. uint16_t bottom_bar_start;
  286. uint16_t left_bar_end;
  287. uint16_t right_bar_start;
  288. } __attribute__ ((packed)) avi;
  289. struct {
  290. uint8_t vn[8];
  291. uint8_t pd[16];
  292. uint8_t sdi;
  293. } __attribute__ ((packed)) spd;
  294. uint8_t payload[27];
  295. } __attribute__ ((packed)) body;
  296. } __attribute__((packed));
  297. struct intel_hdmi {
  298. struct intel_encoder base;
  299. u32 sdvox_reg;
  300. int ddc_bus;
  301. int ddi_port;
  302. uint32_t color_range;
  303. bool has_hdmi_sink;
  304. bool has_audio;
  305. enum hdmi_force_audio force_audio;
  306. void (*write_infoframe)(struct drm_encoder *encoder,
  307. struct dip_infoframe *frame);
  308. void (*set_infoframes)(struct drm_encoder *encoder,
  309. struct drm_display_mode *adjusted_mode);
  310. };
  311. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  312. #define DP_LINK_CONFIGURATION_SIZE 9
  313. struct intel_dp {
  314. struct intel_encoder base;
  315. uint32_t output_reg;
  316. uint32_t DP;
  317. uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE];
  318. bool has_audio;
  319. enum hdmi_force_audio force_audio;
  320. enum port port;
  321. uint32_t color_range;
  322. uint8_t link_bw;
  323. uint8_t lane_count;
  324. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  325. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  326. struct i2c_adapter adapter;
  327. struct i2c_algo_dp_aux_data algo;
  328. bool is_pch_edp;
  329. uint8_t train_set[4];
  330. int panel_power_up_delay;
  331. int panel_power_down_delay;
  332. int panel_power_cycle_delay;
  333. int backlight_on_delay;
  334. int backlight_off_delay;
  335. struct delayed_work panel_vdd_work;
  336. bool want_panel_vdd;
  337. struct intel_connector *attached_connector;
  338. };
  339. static inline struct drm_crtc *
  340. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  341. {
  342. struct drm_i915_private *dev_priv = dev->dev_private;
  343. return dev_priv->pipe_to_crtc_mapping[pipe];
  344. }
  345. static inline struct drm_crtc *
  346. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  347. {
  348. struct drm_i915_private *dev_priv = dev->dev_private;
  349. return dev_priv->plane_to_crtc_mapping[plane];
  350. }
  351. struct intel_unpin_work {
  352. struct work_struct work;
  353. struct drm_device *dev;
  354. struct drm_i915_gem_object *old_fb_obj;
  355. struct drm_i915_gem_object *pending_flip_obj;
  356. struct drm_pending_vblank_event *event;
  357. int pending;
  358. bool enable_stall_check;
  359. };
  360. struct intel_fbc_work {
  361. struct delayed_work work;
  362. struct drm_crtc *crtc;
  363. struct drm_framebuffer *fb;
  364. int interval;
  365. };
  366. int intel_pch_rawclk(struct drm_device *dev);
  367. int intel_connector_update_modes(struct drm_connector *connector,
  368. struct edid *edid);
  369. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  370. extern void intel_attach_force_audio_property(struct drm_connector *connector);
  371. extern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  372. extern void intel_crt_init(struct drm_device *dev);
  373. extern void intel_hdmi_init(struct drm_device *dev,
  374. int sdvox_reg, enum port port);
  375. extern struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  376. extern void intel_dip_infoframe_csum(struct dip_infoframe *avi_if);
  377. extern bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg,
  378. bool is_sdvob);
  379. extern void intel_dvo_init(struct drm_device *dev);
  380. extern void intel_tv_init(struct drm_device *dev);
  381. extern void intel_mark_busy(struct drm_device *dev);
  382. extern void intel_mark_idle(struct drm_device *dev);
  383. extern void intel_mark_fb_busy(struct drm_i915_gem_object *obj);
  384. extern void intel_mark_fb_idle(struct drm_i915_gem_object *obj);
  385. extern bool intel_lvds_init(struct drm_device *dev);
  386. extern void intel_dp_init(struct drm_device *dev, int output_reg,
  387. enum port port);
  388. void
  389. intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
  390. struct drm_display_mode *adjusted_mode);
  391. extern void intel_dp_init_link_config(struct intel_dp *intel_dp);
  392. extern void intel_dp_start_link_train(struct intel_dp *intel_dp);
  393. extern void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  394. extern void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  395. extern bool intel_dpd_is_edp(struct drm_device *dev);
  396. extern void ironlake_edp_backlight_on(struct intel_dp *intel_dp);
  397. extern void ironlake_edp_backlight_off(struct intel_dp *intel_dp);
  398. extern void ironlake_edp_panel_on(struct intel_dp *intel_dp);
  399. extern void ironlake_edp_panel_off(struct intel_dp *intel_dp);
  400. extern void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
  401. extern void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
  402. extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
  403. extern int intel_edp_target_clock(struct intel_encoder *,
  404. struct drm_display_mode *mode);
  405. extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
  406. extern int intel_plane_init(struct drm_device *dev, enum pipe pipe);
  407. extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
  408. enum plane plane);
  409. /* intel_panel.c */
  410. extern int intel_panel_init(struct intel_panel *panel,
  411. struct drm_display_mode *fixed_mode);
  412. extern void intel_panel_fini(struct intel_panel *panel);
  413. extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
  414. struct drm_display_mode *adjusted_mode);
  415. extern void intel_pch_panel_fitting(struct drm_device *dev,
  416. int fitting_mode,
  417. const struct drm_display_mode *mode,
  418. struct drm_display_mode *adjusted_mode);
  419. extern u32 intel_panel_get_max_backlight(struct drm_device *dev);
  420. extern void intel_panel_set_backlight(struct drm_device *dev, u32 level);
  421. extern int intel_panel_setup_backlight(struct drm_connector *connector);
  422. extern void intel_panel_enable_backlight(struct drm_device *dev,
  423. enum pipe pipe);
  424. extern void intel_panel_disable_backlight(struct drm_device *dev);
  425. extern void intel_panel_destroy_backlight(struct drm_device *dev);
  426. extern enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  427. struct intel_set_config {
  428. struct drm_encoder **save_connector_encoders;
  429. struct drm_crtc **save_encoder_crtcs;
  430. bool fb_changed;
  431. bool mode_changed;
  432. };
  433. extern bool intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
  434. int x, int y, struct drm_framebuffer *old_fb);
  435. extern void intel_modeset_disable(struct drm_device *dev);
  436. extern void intel_crtc_load_lut(struct drm_crtc *crtc);
  437. extern void intel_crtc_update_dpms(struct drm_crtc *crtc);
  438. extern void intel_encoder_noop(struct drm_encoder *encoder);
  439. extern void intel_encoder_destroy(struct drm_encoder *encoder);
  440. extern void intel_encoder_dpms(struct intel_encoder *encoder, int mode);
  441. extern bool intel_encoder_check_is_cloned(struct intel_encoder *encoder);
  442. extern void intel_connector_dpms(struct drm_connector *, int mode);
  443. extern bool intel_connector_get_hw_state(struct intel_connector *connector);
  444. extern void intel_modeset_check_state(struct drm_device *dev);
  445. static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
  446. {
  447. return to_intel_connector(connector)->encoder;
  448. }
  449. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  450. {
  451. return container_of(encoder, struct intel_dp, base.base);
  452. }
  453. extern void intel_connector_attach_encoder(struct intel_connector *connector,
  454. struct intel_encoder *encoder);
  455. extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  456. extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  457. struct drm_crtc *crtc);
  458. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  459. struct drm_file *file_priv);
  460. extern enum transcoder
  461. intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  462. enum pipe pipe);
  463. extern void intel_wait_for_vblank(struct drm_device *dev, int pipe);
  464. extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
  465. struct intel_load_detect_pipe {
  466. struct drm_framebuffer *release_fb;
  467. bool load_detect_temp;
  468. int dpms_mode;
  469. };
  470. extern bool intel_get_load_detect_pipe(struct drm_connector *connector,
  471. struct drm_display_mode *mode,
  472. struct intel_load_detect_pipe *old);
  473. extern void intel_release_load_detect_pipe(struct drm_connector *connector,
  474. struct intel_load_detect_pipe *old);
  475. extern void intelfb_restore(void);
  476. extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
  477. u16 blue, int regno);
  478. extern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
  479. u16 *blue, int regno);
  480. extern void intel_enable_clock_gating(struct drm_device *dev);
  481. extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
  482. struct drm_i915_gem_object *obj,
  483. struct intel_ring_buffer *pipelined);
  484. extern void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
  485. extern int intel_framebuffer_init(struct drm_device *dev,
  486. struct intel_framebuffer *ifb,
  487. struct drm_mode_fb_cmd2 *mode_cmd,
  488. struct drm_i915_gem_object *obj);
  489. extern int intel_fbdev_init(struct drm_device *dev);
  490. extern void intel_fbdev_fini(struct drm_device *dev);
  491. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
  492. extern void intel_prepare_page_flip(struct drm_device *dev, int plane);
  493. extern void intel_finish_page_flip(struct drm_device *dev, int pipe);
  494. extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  495. extern void intel_setup_overlay(struct drm_device *dev);
  496. extern void intel_cleanup_overlay(struct drm_device *dev);
  497. extern int intel_overlay_switch_off(struct intel_overlay *overlay);
  498. extern int intel_overlay_put_image(struct drm_device *dev, void *data,
  499. struct drm_file *file_priv);
  500. extern int intel_overlay_attrs(struct drm_device *dev, void *data,
  501. struct drm_file *file_priv);
  502. extern void intel_fb_output_poll_changed(struct drm_device *dev);
  503. extern void intel_fb_restore_mode(struct drm_device *dev);
  504. extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
  505. bool state);
  506. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  507. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  508. extern void intel_init_clock_gating(struct drm_device *dev);
  509. extern void intel_write_eld(struct drm_encoder *encoder,
  510. struct drm_display_mode *mode);
  511. extern void intel_cpt_verify_modeset(struct drm_device *dev, int pipe);
  512. extern void intel_prepare_ddi(struct drm_device *dev);
  513. extern void hsw_fdi_link_train(struct drm_crtc *crtc);
  514. extern void intel_ddi_init(struct drm_device *dev, enum port port);
  515. /* For use by IVB LP watermark workaround in intel_sprite.c */
  516. extern void intel_update_watermarks(struct drm_device *dev);
  517. extern void intel_update_sprite_watermarks(struct drm_device *dev, int pipe,
  518. uint32_t sprite_width,
  519. int pixel_size);
  520. extern void intel_update_linetime_watermarks(struct drm_device *dev, int pipe,
  521. struct drm_display_mode *mode);
  522. extern unsigned long intel_gen4_compute_offset_xtiled(int *x, int *y,
  523. unsigned int bpp,
  524. unsigned int pitch);
  525. extern int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  526. struct drm_file *file_priv);
  527. extern int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
  528. struct drm_file *file_priv);
  529. extern u32 intel_dpio_read(struct drm_i915_private *dev_priv, int reg);
  530. /* Power-related functions, located in intel_pm.c */
  531. extern void intel_init_pm(struct drm_device *dev);
  532. /* FBC */
  533. extern bool intel_fbc_enabled(struct drm_device *dev);
  534. extern void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval);
  535. extern void intel_update_fbc(struct drm_device *dev);
  536. /* IPS */
  537. extern void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  538. extern void intel_gpu_ips_teardown(void);
  539. extern void intel_init_power_wells(struct drm_device *dev);
  540. extern void intel_enable_gt_powersave(struct drm_device *dev);
  541. extern void intel_disable_gt_powersave(struct drm_device *dev);
  542. extern void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv);
  543. extern void ironlake_teardown_rc6(struct drm_device *dev);
  544. extern void intel_enable_ddi(struct intel_encoder *intel_encoder);
  545. extern void intel_disable_ddi(struct intel_encoder *intel_encoder);
  546. extern bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
  547. enum pipe *pipe);
  548. extern void intel_ddi_mode_set(struct drm_encoder *encoder,
  549. struct drm_display_mode *mode,
  550. struct drm_display_mode *adjusted_mode);
  551. extern int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
  552. extern void intel_ddi_pll_init(struct drm_device *dev);
  553. extern void intel_ddi_enable_pipe_func(struct drm_crtc *crtc);
  554. extern void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  555. enum transcoder cpu_transcoder);
  556. extern void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  557. extern void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  558. extern void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
  559. extern bool intel_ddi_pll_mode_set(struct drm_crtc *crtc, int clock);
  560. extern void intel_ddi_pre_enable(struct intel_encoder *intel_encoder);
  561. extern void intel_ddi_post_disable(struct intel_encoder *intel_encoder);
  562. extern void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
  563. extern void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  564. extern void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  565. #endif /* __INTEL_DRV_H__ */