intel_drv.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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. /**
  35. * _wait_for - magic (register) wait macro
  36. *
  37. * Does the right thing for modeset paths when run under kdgb or similar atomic
  38. * contexts. Note that it's important that we check the condition again after
  39. * having timed out, since the timeout could be due to preemption or similar and
  40. * we've never had a chance to check the condition before the timeout.
  41. */
  42. #define _wait_for(COND, MS, W) ({ \
  43. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
  44. int ret__ = 0; \
  45. while (!(COND)) { \
  46. if (time_after(jiffies, timeout__)) { \
  47. if (!(COND)) \
  48. ret__ = -ETIMEDOUT; \
  49. break; \
  50. } \
  51. if (W && drm_can_sleep()) { \
  52. msleep(W); \
  53. } else { \
  54. cpu_relax(); \
  55. } \
  56. } \
  57. ret__; \
  58. })
  59. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  60. #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
  61. #define wait_for_atomic_us(COND, US) _wait_for((COND), \
  62. DIV_ROUND_UP((US), 1000), 0)
  63. #define KHz(x) (1000*x)
  64. #define MHz(x) KHz(1000*x)
  65. /*
  66. * Display related stuff
  67. */
  68. /* store information about an Ixxx DVO */
  69. /* The i830->i865 use multiple DVOs with multiple i2cs */
  70. /* the i915, i945 have a single sDVO i2c bus - which is different */
  71. #define MAX_OUTPUTS 6
  72. /* maximum connectors per crtcs in the mode set */
  73. #define INTELFB_CONN_LIMIT 4
  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_UNKNOWN 9
  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. struct intel_framebuffer {
  93. struct drm_framebuffer base;
  94. struct drm_i915_gem_object *obj;
  95. };
  96. struct intel_fbdev {
  97. struct drm_fb_helper helper;
  98. struct intel_framebuffer ifb;
  99. struct list_head fbdev_list;
  100. struct drm_display_mode *our_mode;
  101. };
  102. struct intel_encoder {
  103. struct drm_encoder base;
  104. /*
  105. * The new crtc this encoder will be driven from. Only differs from
  106. * base->crtc while a modeset is in progress.
  107. */
  108. struct intel_crtc *new_crtc;
  109. int type;
  110. /*
  111. * Intel hw has only one MUX where encoders could be clone, hence a
  112. * simple flag is enough to compute the possible_clones mask.
  113. */
  114. bool cloneable;
  115. bool connectors_active;
  116. void (*hot_plug)(struct intel_encoder *);
  117. bool (*compute_config)(struct intel_encoder *,
  118. struct intel_crtc_config *);
  119. void (*pre_pll_enable)(struct intel_encoder *);
  120. void (*pre_enable)(struct intel_encoder *);
  121. void (*enable)(struct intel_encoder *);
  122. void (*mode_set)(struct intel_encoder *intel_encoder);
  123. void (*disable)(struct intel_encoder *);
  124. void (*post_disable)(struct intel_encoder *);
  125. /* Read out the current hw state of this connector, returning true if
  126. * the encoder is active. If the encoder is enabled it also set the pipe
  127. * it is connected to in the pipe parameter. */
  128. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  129. int crtc_mask;
  130. enum hpd_pin hpd_pin;
  131. };
  132. struct intel_panel {
  133. struct drm_display_mode *fixed_mode;
  134. int fitting_mode;
  135. };
  136. struct intel_connector {
  137. struct drm_connector base;
  138. /*
  139. * The fixed encoder this connector is connected to.
  140. */
  141. struct intel_encoder *encoder;
  142. /*
  143. * The new encoder this connector will be driven. Only differs from
  144. * encoder while a modeset is in progress.
  145. */
  146. struct intel_encoder *new_encoder;
  147. /* Reads out the current hw, returning true if the connector is enabled
  148. * and active (i.e. dpms ON state). */
  149. bool (*get_hw_state)(struct intel_connector *);
  150. /* Panel info for eDP and LVDS */
  151. struct intel_panel panel;
  152. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  153. struct edid *edid;
  154. /* since POLL and HPD connectors may use the same HPD line keep the native
  155. state of connector->polled in case hotplug storm detection changes it */
  156. u8 polled;
  157. };
  158. typedef struct dpll {
  159. /* given values */
  160. int n;
  161. int m1, m2;
  162. int p1, p2;
  163. /* derived values */
  164. int dot;
  165. int vco;
  166. int m;
  167. int p;
  168. } intel_clock_t;
  169. struct intel_crtc_config {
  170. struct drm_display_mode requested_mode;
  171. struct drm_display_mode adjusted_mode;
  172. /* This flag must be set by the encoder's compute_config callback if it
  173. * changes the crtc timings in the mode to prevent the crtc fixup from
  174. * overwriting them. Currently only lvds needs that. */
  175. bool timings_set;
  176. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  177. * between pch encoders and cpu encoders. */
  178. bool has_pch_encoder;
  179. /* CPU Transcoder for the pipe. Currently this can only differ from the
  180. * pipe on Haswell (where we have a special eDP transcoder). */
  181. enum transcoder cpu_transcoder;
  182. /*
  183. * Use reduced/limited/broadcast rbg range, compressing from the full
  184. * range fed into the crtcs.
  185. */
  186. bool limited_color_range;
  187. /* DP has a bunch of special case unfortunately, so mark the pipe
  188. * accordingly. */
  189. bool has_dp_encoder;
  190. /*
  191. * Enable dithering, used when the selected pipe bpp doesn't match the
  192. * plane bpp.
  193. */
  194. bool dither;
  195. /* Controls for the clock computation, to override various stages. */
  196. bool clock_set;
  197. /* SDVO TV has a bunch of special case. To make multifunction encoders
  198. * work correctly, we need to track this at runtime.*/
  199. bool sdvo_tv_clock;
  200. /*
  201. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  202. * required. This is set in the 2nd loop of calling encoder's
  203. * ->compute_config if the first pick doesn't work out.
  204. */
  205. bool bw_constrained;
  206. /* Settings for the intel dpll used on pretty much everything but
  207. * haswell. */
  208. struct dpll dpll;
  209. int pipe_bpp;
  210. struct intel_link_m_n dp_m_n;
  211. /**
  212. * This is currently used by DP and HDMI encoders since those can have a
  213. * target pixel clock != the port link clock (which is currently stored
  214. * in adjusted_mode->clock).
  215. */
  216. int pixel_target_clock;
  217. /* Used by SDVO (and if we ever fix it, HDMI). */
  218. unsigned pixel_multiplier;
  219. /* Panel fitter controls for gen2-gen4 + VLV */
  220. struct {
  221. u32 control;
  222. u32 pgm_ratios;
  223. u32 lvds_border_bits;
  224. } gmch_pfit;
  225. /* Panel fitter placement and size for Ironlake+ */
  226. struct {
  227. u32 pos;
  228. u32 size;
  229. } pch_pfit;
  230. /* FDI configuration, only valid if has_pch_encoder is set. */
  231. int fdi_lanes;
  232. struct intel_link_m_n fdi_m_n;
  233. };
  234. struct intel_crtc {
  235. struct drm_crtc base;
  236. enum pipe pipe;
  237. enum plane plane;
  238. u8 lut_r[256], lut_g[256], lut_b[256];
  239. /*
  240. * Whether the crtc and the connected output pipeline is active. Implies
  241. * that crtc->enabled is set, i.e. the current mode configuration has
  242. * some outputs connected to this crtc.
  243. */
  244. bool active;
  245. bool eld_vld;
  246. bool primary_disabled; /* is the crtc obscured by a plane? */
  247. bool lowfreq_avail;
  248. struct intel_overlay *overlay;
  249. struct intel_unpin_work *unpin_work;
  250. atomic_t unpin_work_count;
  251. /* Display surface base address adjustement for pageflips. Note that on
  252. * gen4+ this only adjusts up to a tile, offsets within a tile are
  253. * handled in the hw itself (with the TILEOFF register). */
  254. unsigned long dspaddr_offset;
  255. struct drm_i915_gem_object *cursor_bo;
  256. uint32_t cursor_addr;
  257. int16_t cursor_x, cursor_y;
  258. int16_t cursor_width, cursor_height;
  259. bool cursor_visible;
  260. struct intel_crtc_config config;
  261. /* We can share PLLs across outputs if the timings match */
  262. struct intel_pch_pll *pch_pll;
  263. uint32_t ddi_pll_sel;
  264. /* reset counter value when the last flip was submitted */
  265. unsigned int reset_counter;
  266. /* Access to these should be protected by dev_priv->irq_lock. */
  267. bool cpu_fifo_underrun_disabled;
  268. bool pch_fifo_underrun_disabled;
  269. };
  270. struct intel_plane {
  271. struct drm_plane base;
  272. int plane;
  273. enum pipe pipe;
  274. struct drm_i915_gem_object *obj;
  275. bool can_scale;
  276. int max_downscale;
  277. u32 lut_r[1024], lut_g[1024], lut_b[1024];
  278. int crtc_x, crtc_y;
  279. unsigned int crtc_w, crtc_h;
  280. uint32_t src_x, src_y;
  281. uint32_t src_w, src_h;
  282. void (*update_plane)(struct drm_plane *plane,
  283. struct drm_framebuffer *fb,
  284. struct drm_i915_gem_object *obj,
  285. int crtc_x, int crtc_y,
  286. unsigned int crtc_w, unsigned int crtc_h,
  287. uint32_t x, uint32_t y,
  288. uint32_t src_w, uint32_t src_h);
  289. void (*disable_plane)(struct drm_plane *plane);
  290. int (*update_colorkey)(struct drm_plane *plane,
  291. struct drm_intel_sprite_colorkey *key);
  292. void (*get_colorkey)(struct drm_plane *plane,
  293. struct drm_intel_sprite_colorkey *key);
  294. };
  295. struct intel_watermark_params {
  296. unsigned long fifo_size;
  297. unsigned long max_wm;
  298. unsigned long default_wm;
  299. unsigned long guard_size;
  300. unsigned long cacheline_size;
  301. };
  302. struct cxsr_latency {
  303. int is_desktop;
  304. int is_ddr3;
  305. unsigned long fsb_freq;
  306. unsigned long mem_freq;
  307. unsigned long display_sr;
  308. unsigned long display_hpll_disable;
  309. unsigned long cursor_sr;
  310. unsigned long cursor_hpll_disable;
  311. };
  312. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  313. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  314. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  315. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  316. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  317. #define DIP_HEADER_SIZE 5
  318. #define DIP_TYPE_AVI 0x82
  319. #define DIP_VERSION_AVI 0x2
  320. #define DIP_LEN_AVI 13
  321. #define DIP_AVI_PR_1 0
  322. #define DIP_AVI_PR_2 1
  323. #define DIP_AVI_RGB_QUANT_RANGE_DEFAULT (0 << 2)
  324. #define DIP_AVI_RGB_QUANT_RANGE_LIMITED (1 << 2)
  325. #define DIP_AVI_RGB_QUANT_RANGE_FULL (2 << 2)
  326. #define DIP_TYPE_SPD 0x83
  327. #define DIP_VERSION_SPD 0x1
  328. #define DIP_LEN_SPD 25
  329. #define DIP_SPD_UNKNOWN 0
  330. #define DIP_SPD_DSTB 0x1
  331. #define DIP_SPD_DVDP 0x2
  332. #define DIP_SPD_DVHS 0x3
  333. #define DIP_SPD_HDDVR 0x4
  334. #define DIP_SPD_DVC 0x5
  335. #define DIP_SPD_DSC 0x6
  336. #define DIP_SPD_VCD 0x7
  337. #define DIP_SPD_GAME 0x8
  338. #define DIP_SPD_PC 0x9
  339. #define DIP_SPD_BD 0xa
  340. #define DIP_SPD_SCD 0xb
  341. struct dip_infoframe {
  342. uint8_t type; /* HB0 */
  343. uint8_t ver; /* HB1 */
  344. uint8_t len; /* HB2 - body len, not including checksum */
  345. uint8_t ecc; /* Header ECC */
  346. uint8_t checksum; /* PB0 */
  347. union {
  348. struct {
  349. /* PB1 - Y 6:5, A 4:4, B 3:2, S 1:0 */
  350. uint8_t Y_A_B_S;
  351. /* PB2 - C 7:6, M 5:4, R 3:0 */
  352. uint8_t C_M_R;
  353. /* PB3 - ITC 7:7, EC 6:4, Q 3:2, SC 1:0 */
  354. uint8_t ITC_EC_Q_SC;
  355. /* PB4 - VIC 6:0 */
  356. uint8_t VIC;
  357. /* PB5 - YQ 7:6, CN 5:4, PR 3:0 */
  358. uint8_t YQ_CN_PR;
  359. /* PB6 to PB13 */
  360. uint16_t top_bar_end;
  361. uint16_t bottom_bar_start;
  362. uint16_t left_bar_end;
  363. uint16_t right_bar_start;
  364. } __attribute__ ((packed)) avi;
  365. struct {
  366. uint8_t vn[8];
  367. uint8_t pd[16];
  368. uint8_t sdi;
  369. } __attribute__ ((packed)) spd;
  370. uint8_t payload[27];
  371. } __attribute__ ((packed)) body;
  372. } __attribute__((packed));
  373. struct intel_hdmi {
  374. u32 hdmi_reg;
  375. int ddc_bus;
  376. uint32_t color_range;
  377. bool color_range_auto;
  378. bool has_hdmi_sink;
  379. bool has_audio;
  380. enum hdmi_force_audio force_audio;
  381. bool rgb_quant_range_selectable;
  382. void (*write_infoframe)(struct drm_encoder *encoder,
  383. struct dip_infoframe *frame);
  384. void (*set_infoframes)(struct drm_encoder *encoder,
  385. struct drm_display_mode *adjusted_mode);
  386. };
  387. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  388. #define DP_LINK_CONFIGURATION_SIZE 9
  389. struct intel_dp {
  390. uint32_t output_reg;
  391. uint32_t aux_ch_ctl_reg;
  392. uint32_t DP;
  393. uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE];
  394. bool has_audio;
  395. enum hdmi_force_audio force_audio;
  396. uint32_t color_range;
  397. bool color_range_auto;
  398. uint8_t link_bw;
  399. uint8_t lane_count;
  400. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  401. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  402. struct i2c_adapter adapter;
  403. struct i2c_algo_dp_aux_data algo;
  404. uint8_t train_set[4];
  405. int panel_power_up_delay;
  406. int panel_power_down_delay;
  407. int panel_power_cycle_delay;
  408. int backlight_on_delay;
  409. int backlight_off_delay;
  410. struct delayed_work panel_vdd_work;
  411. bool want_panel_vdd;
  412. struct intel_connector *attached_connector;
  413. };
  414. struct intel_digital_port {
  415. struct intel_encoder base;
  416. enum port port;
  417. u32 port_reversal;
  418. struct intel_dp dp;
  419. struct intel_hdmi hdmi;
  420. };
  421. static inline int
  422. vlv_dport_to_channel(struct intel_digital_port *dport)
  423. {
  424. switch (dport->port) {
  425. case PORT_B:
  426. return 0;
  427. case PORT_C:
  428. return 1;
  429. default:
  430. BUG();
  431. }
  432. }
  433. static inline struct drm_crtc *
  434. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  435. {
  436. struct drm_i915_private *dev_priv = dev->dev_private;
  437. return dev_priv->pipe_to_crtc_mapping[pipe];
  438. }
  439. static inline struct drm_crtc *
  440. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  441. {
  442. struct drm_i915_private *dev_priv = dev->dev_private;
  443. return dev_priv->plane_to_crtc_mapping[plane];
  444. }
  445. struct intel_unpin_work {
  446. struct work_struct work;
  447. struct drm_crtc *crtc;
  448. struct drm_i915_gem_object *old_fb_obj;
  449. struct drm_i915_gem_object *pending_flip_obj;
  450. struct drm_pending_vblank_event *event;
  451. atomic_t pending;
  452. #define INTEL_FLIP_INACTIVE 0
  453. #define INTEL_FLIP_PENDING 1
  454. #define INTEL_FLIP_COMPLETE 2
  455. bool enable_stall_check;
  456. };
  457. struct intel_fbc_work {
  458. struct delayed_work work;
  459. struct drm_crtc *crtc;
  460. struct drm_framebuffer *fb;
  461. int interval;
  462. };
  463. int intel_pch_rawclk(struct drm_device *dev);
  464. int intel_connector_update_modes(struct drm_connector *connector,
  465. struct edid *edid);
  466. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  467. extern void intel_attach_force_audio_property(struct drm_connector *connector);
  468. extern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  469. extern bool intel_pipe_has_type(struct drm_crtc *crtc, int type);
  470. extern void intel_crt_init(struct drm_device *dev);
  471. extern void intel_hdmi_init(struct drm_device *dev,
  472. int hdmi_reg, enum port port);
  473. extern void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  474. struct intel_connector *intel_connector);
  475. extern struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  476. extern bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  477. struct intel_crtc_config *pipe_config);
  478. extern void intel_dip_infoframe_csum(struct dip_infoframe *avi_if);
  479. extern bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg,
  480. bool is_sdvob);
  481. extern void intel_dvo_init(struct drm_device *dev);
  482. extern void intel_tv_init(struct drm_device *dev);
  483. extern void intel_mark_busy(struct drm_device *dev);
  484. extern void intel_mark_fb_busy(struct drm_i915_gem_object *obj);
  485. extern void intel_mark_idle(struct drm_device *dev);
  486. extern bool intel_lvds_init(struct drm_device *dev);
  487. extern bool intel_is_dual_link_lvds(struct drm_device *dev);
  488. extern void intel_dp_init(struct drm_device *dev, int output_reg,
  489. enum port port);
  490. extern void intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  491. struct intel_connector *intel_connector);
  492. extern void intel_dp_init_link_config(struct intel_dp *intel_dp);
  493. extern void intel_dp_start_link_train(struct intel_dp *intel_dp);
  494. extern void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  495. extern void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  496. extern void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  497. extern void intel_dp_check_link_status(struct intel_dp *intel_dp);
  498. extern bool intel_dp_compute_config(struct intel_encoder *encoder,
  499. struct intel_crtc_config *pipe_config);
  500. extern bool intel_dpd_is_edp(struct drm_device *dev);
  501. extern void ironlake_edp_backlight_on(struct intel_dp *intel_dp);
  502. extern void ironlake_edp_backlight_off(struct intel_dp *intel_dp);
  503. extern void ironlake_edp_panel_on(struct intel_dp *intel_dp);
  504. extern void ironlake_edp_panel_off(struct intel_dp *intel_dp);
  505. extern void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
  506. extern void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
  507. extern int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  508. extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
  509. enum plane plane);
  510. /* intel_panel.c */
  511. extern int intel_panel_init(struct intel_panel *panel,
  512. struct drm_display_mode *fixed_mode);
  513. extern void intel_panel_fini(struct intel_panel *panel);
  514. extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
  515. struct drm_display_mode *adjusted_mode);
  516. extern void intel_pch_panel_fitting(struct intel_crtc *crtc,
  517. struct intel_crtc_config *pipe_config,
  518. int fitting_mode);
  519. extern void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  520. struct intel_crtc_config *pipe_config,
  521. int fitting_mode);
  522. extern void intel_panel_set_backlight(struct drm_device *dev,
  523. u32 level, u32 max);
  524. extern int intel_panel_setup_backlight(struct drm_connector *connector);
  525. extern void intel_panel_enable_backlight(struct drm_device *dev,
  526. enum pipe pipe);
  527. extern void intel_panel_disable_backlight(struct drm_device *dev);
  528. extern void intel_panel_destroy_backlight(struct drm_device *dev);
  529. extern enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  530. struct intel_set_config {
  531. struct drm_encoder **save_connector_encoders;
  532. struct drm_crtc **save_encoder_crtcs;
  533. bool fb_changed;
  534. bool mode_changed;
  535. };
  536. extern int intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
  537. int x, int y, struct drm_framebuffer *old_fb);
  538. extern void intel_modeset_disable(struct drm_device *dev);
  539. extern void intel_crtc_restore_mode(struct drm_crtc *crtc);
  540. extern void intel_crtc_load_lut(struct drm_crtc *crtc);
  541. extern void intel_crtc_update_dpms(struct drm_crtc *crtc);
  542. extern void intel_encoder_destroy(struct drm_encoder *encoder);
  543. extern void intel_encoder_dpms(struct intel_encoder *encoder, int mode);
  544. extern bool intel_encoder_check_is_cloned(struct intel_encoder *encoder);
  545. extern void intel_connector_dpms(struct drm_connector *, int mode);
  546. extern bool intel_connector_get_hw_state(struct intel_connector *connector);
  547. extern void intel_modeset_check_state(struct drm_device *dev);
  548. extern void intel_plane_restore(struct drm_plane *plane);
  549. static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
  550. {
  551. return to_intel_connector(connector)->encoder;
  552. }
  553. static inline struct intel_digital_port *
  554. enc_to_dig_port(struct drm_encoder *encoder)
  555. {
  556. return container_of(encoder, struct intel_digital_port, base.base);
  557. }
  558. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  559. {
  560. return &enc_to_dig_port(encoder)->dp;
  561. }
  562. static inline struct intel_digital_port *
  563. dp_to_dig_port(struct intel_dp *intel_dp)
  564. {
  565. return container_of(intel_dp, struct intel_digital_port, dp);
  566. }
  567. static inline struct intel_digital_port *
  568. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  569. {
  570. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  571. }
  572. bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
  573. struct intel_digital_port *port);
  574. extern void intel_connector_attach_encoder(struct intel_connector *connector,
  575. struct intel_encoder *encoder);
  576. extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  577. extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  578. struct drm_crtc *crtc);
  579. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  580. struct drm_file *file_priv);
  581. extern enum transcoder
  582. intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  583. enum pipe pipe);
  584. extern void intel_wait_for_vblank(struct drm_device *dev, int pipe);
  585. extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
  586. extern int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  587. extern void vlv_wait_port_ready(struct drm_i915_private *dev_priv, int port);
  588. struct intel_load_detect_pipe {
  589. struct drm_framebuffer *release_fb;
  590. bool load_detect_temp;
  591. int dpms_mode;
  592. };
  593. extern bool intel_get_load_detect_pipe(struct drm_connector *connector,
  594. struct drm_display_mode *mode,
  595. struct intel_load_detect_pipe *old);
  596. extern void intel_release_load_detect_pipe(struct drm_connector *connector,
  597. struct intel_load_detect_pipe *old);
  598. extern void intelfb_restore(void);
  599. extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
  600. u16 blue, int regno);
  601. extern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
  602. u16 *blue, int regno);
  603. extern void intel_enable_clock_gating(struct drm_device *dev);
  604. extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
  605. struct drm_i915_gem_object *obj,
  606. struct intel_ring_buffer *pipelined);
  607. extern void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
  608. extern int intel_framebuffer_init(struct drm_device *dev,
  609. struct intel_framebuffer *ifb,
  610. struct drm_mode_fb_cmd2 *mode_cmd,
  611. struct drm_i915_gem_object *obj);
  612. extern int intel_fbdev_init(struct drm_device *dev);
  613. extern void intel_fbdev_initial_config(struct drm_device *dev);
  614. extern void intel_fbdev_fini(struct drm_device *dev);
  615. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
  616. extern void intel_prepare_page_flip(struct drm_device *dev, int plane);
  617. extern void intel_finish_page_flip(struct drm_device *dev, int pipe);
  618. extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  619. extern void intel_setup_overlay(struct drm_device *dev);
  620. extern void intel_cleanup_overlay(struct drm_device *dev);
  621. extern int intel_overlay_switch_off(struct intel_overlay *overlay);
  622. extern int intel_overlay_put_image(struct drm_device *dev, void *data,
  623. struct drm_file *file_priv);
  624. extern int intel_overlay_attrs(struct drm_device *dev, void *data,
  625. struct drm_file *file_priv);
  626. extern void intel_fb_output_poll_changed(struct drm_device *dev);
  627. extern void intel_fb_restore_mode(struct drm_device *dev);
  628. extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
  629. bool state);
  630. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  631. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  632. extern void intel_init_clock_gating(struct drm_device *dev);
  633. extern void intel_suspend_hw(struct drm_device *dev);
  634. extern void intel_write_eld(struct drm_encoder *encoder,
  635. struct drm_display_mode *mode);
  636. extern void intel_prepare_ddi(struct drm_device *dev);
  637. extern void hsw_fdi_link_train(struct drm_crtc *crtc);
  638. extern void intel_ddi_init(struct drm_device *dev, enum port port);
  639. /* For use by IVB LP watermark workaround in intel_sprite.c */
  640. extern void intel_update_watermarks(struct drm_device *dev);
  641. extern void intel_update_sprite_watermarks(struct drm_device *dev, int pipe,
  642. uint32_t sprite_width,
  643. int pixel_size);
  644. extern void intel_update_linetime_watermarks(struct drm_device *dev, int pipe,
  645. struct drm_display_mode *mode);
  646. extern unsigned long intel_gen4_compute_page_offset(int *x, int *y,
  647. unsigned int tiling_mode,
  648. unsigned int bpp,
  649. unsigned int pitch);
  650. extern int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  651. struct drm_file *file_priv);
  652. extern int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
  653. struct drm_file *file_priv);
  654. extern u32 intel_dpio_read(struct drm_i915_private *dev_priv, int reg);
  655. extern void intel_dpio_write(struct drm_i915_private *dev_priv, int reg,
  656. u32 val);
  657. /* Power-related functions, located in intel_pm.c */
  658. extern void intel_init_pm(struct drm_device *dev);
  659. /* FBC */
  660. extern bool intel_fbc_enabled(struct drm_device *dev);
  661. extern void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval);
  662. extern void intel_update_fbc(struct drm_device *dev);
  663. /* IPS */
  664. extern void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  665. extern void intel_gpu_ips_teardown(void);
  666. extern bool intel_display_power_enabled(struct drm_device *dev,
  667. enum intel_display_power_domain domain);
  668. extern void intel_init_power_well(struct drm_device *dev);
  669. extern void intel_set_power_well(struct drm_device *dev, bool enable);
  670. extern void intel_enable_gt_powersave(struct drm_device *dev);
  671. extern void intel_disable_gt_powersave(struct drm_device *dev);
  672. extern void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv);
  673. extern void ironlake_teardown_rc6(struct drm_device *dev);
  674. extern bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
  675. enum pipe *pipe);
  676. extern int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
  677. extern void intel_ddi_pll_init(struct drm_device *dev);
  678. extern void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  679. extern void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  680. enum transcoder cpu_transcoder);
  681. extern void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  682. extern void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  683. extern void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
  684. extern bool intel_ddi_pll_mode_set(struct drm_crtc *crtc, int clock);
  685. extern void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
  686. extern void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  687. extern void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  688. extern bool
  689. intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  690. extern void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  691. extern void intel_display_handle_reset(struct drm_device *dev);
  692. extern bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
  693. enum pipe pipe,
  694. bool enable);
  695. extern bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,
  696. enum transcoder pch_transcoder,
  697. bool enable);
  698. #endif /* __INTEL_DRV_H__ */