intel_drv.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  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. /* Reconstructs the equivalent mode flags for the current hardware
  130. * state. This must be called _after_ display->get_pipe_config has
  131. * pre-filled the pipe config. */
  132. void (*get_config)(struct intel_encoder *,
  133. struct intel_crtc_config *pipe_config);
  134. int crtc_mask;
  135. enum hpd_pin hpd_pin;
  136. };
  137. struct intel_panel {
  138. struct drm_display_mode *fixed_mode;
  139. int fitting_mode;
  140. };
  141. struct intel_connector {
  142. struct drm_connector base;
  143. /*
  144. * The fixed encoder this connector is connected to.
  145. */
  146. struct intel_encoder *encoder;
  147. /*
  148. * The new encoder this connector will be driven. Only differs from
  149. * encoder while a modeset is in progress.
  150. */
  151. struct intel_encoder *new_encoder;
  152. /* Reads out the current hw, returning true if the connector is enabled
  153. * and active (i.e. dpms ON state). */
  154. bool (*get_hw_state)(struct intel_connector *);
  155. /* Panel info for eDP and LVDS */
  156. struct intel_panel panel;
  157. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  158. struct edid *edid;
  159. /* since POLL and HPD connectors may use the same HPD line keep the native
  160. state of connector->polled in case hotplug storm detection changes it */
  161. u8 polled;
  162. };
  163. typedef struct dpll {
  164. /* given values */
  165. int n;
  166. int m1, m2;
  167. int p1, p2;
  168. /* derived values */
  169. int dot;
  170. int vco;
  171. int m;
  172. int p;
  173. } intel_clock_t;
  174. struct intel_crtc_config {
  175. /**
  176. * quirks - bitfield with hw state readout quirks
  177. *
  178. * For various reasons the hw state readout code might not be able to
  179. * completely faithfully read out the current state. These cases are
  180. * tracked with quirk flags so that fastboot and state checker can act
  181. * accordingly.
  182. */
  183. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  184. unsigned long quirks;
  185. struct drm_display_mode requested_mode;
  186. struct drm_display_mode adjusted_mode;
  187. /* This flag must be set by the encoder's compute_config callback if it
  188. * changes the crtc timings in the mode to prevent the crtc fixup from
  189. * overwriting them. Currently only lvds needs that. */
  190. bool timings_set;
  191. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  192. * between pch encoders and cpu encoders. */
  193. bool has_pch_encoder;
  194. /* CPU Transcoder for the pipe. Currently this can only differ from the
  195. * pipe on Haswell (where we have a special eDP transcoder). */
  196. enum transcoder cpu_transcoder;
  197. /*
  198. * Use reduced/limited/broadcast rbg range, compressing from the full
  199. * range fed into the crtcs.
  200. */
  201. bool limited_color_range;
  202. /* DP has a bunch of special case unfortunately, so mark the pipe
  203. * accordingly. */
  204. bool has_dp_encoder;
  205. /*
  206. * Enable dithering, used when the selected pipe bpp doesn't match the
  207. * plane bpp.
  208. */
  209. bool dither;
  210. /* Controls for the clock computation, to override various stages. */
  211. bool clock_set;
  212. /* SDVO TV has a bunch of special case. To make multifunction encoders
  213. * work correctly, we need to track this at runtime.*/
  214. bool sdvo_tv_clock;
  215. /*
  216. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  217. * required. This is set in the 2nd loop of calling encoder's
  218. * ->compute_config if the first pick doesn't work out.
  219. */
  220. bool bw_constrained;
  221. /* Settings for the intel dpll used on pretty much everything but
  222. * haswell. */
  223. struct dpll dpll;
  224. /* Selected dpll when shared or DPLL_ID_PRIVATE. */
  225. enum intel_dpll_id shared_dpll;
  226. /* Actual register state of the dpll, for shared dpll cross-checking. */
  227. struct intel_dpll_hw_state dpll_hw_state;
  228. int pipe_bpp;
  229. struct intel_link_m_n dp_m_n;
  230. /*
  231. * Frequence the dpll for the port should run at. Differs from the
  232. * adjusted dotclock e.g. for DP or 12bpc hdmi mode.
  233. */
  234. int port_clock;
  235. /* Used by SDVO (and if we ever fix it, HDMI). */
  236. unsigned pixel_multiplier;
  237. /* Panel fitter controls for gen2-gen4 + VLV */
  238. struct {
  239. u32 control;
  240. u32 pgm_ratios;
  241. u32 lvds_border_bits;
  242. } gmch_pfit;
  243. /* Panel fitter placement and size for Ironlake+ */
  244. struct {
  245. u32 pos;
  246. u32 size;
  247. } pch_pfit;
  248. /* FDI configuration, only valid if has_pch_encoder is set. */
  249. int fdi_lanes;
  250. struct intel_link_m_n fdi_m_n;
  251. bool ips_enabled;
  252. };
  253. struct intel_crtc {
  254. struct drm_crtc base;
  255. enum pipe pipe;
  256. enum plane plane;
  257. u8 lut_r[256], lut_g[256], lut_b[256];
  258. /*
  259. * Whether the crtc and the connected output pipeline is active. Implies
  260. * that crtc->enabled is set, i.e. the current mode configuration has
  261. * some outputs connected to this crtc.
  262. */
  263. bool active;
  264. bool eld_vld;
  265. bool primary_disabled; /* is the crtc obscured by a plane? */
  266. bool lowfreq_avail;
  267. struct intel_overlay *overlay;
  268. struct intel_unpin_work *unpin_work;
  269. atomic_t unpin_work_count;
  270. /* Display surface base address adjustement for pageflips. Note that on
  271. * gen4+ this only adjusts up to a tile, offsets within a tile are
  272. * handled in the hw itself (with the TILEOFF register). */
  273. unsigned long dspaddr_offset;
  274. struct drm_i915_gem_object *cursor_bo;
  275. uint32_t cursor_addr;
  276. int16_t cursor_x, cursor_y;
  277. int16_t cursor_width, cursor_height;
  278. bool cursor_visible;
  279. struct intel_crtc_config config;
  280. uint32_t ddi_pll_sel;
  281. /* reset counter value when the last flip was submitted */
  282. unsigned int reset_counter;
  283. /* Access to these should be protected by dev_priv->irq_lock. */
  284. bool cpu_fifo_underrun_disabled;
  285. bool pch_fifo_underrun_disabled;
  286. };
  287. struct intel_plane {
  288. struct drm_plane base;
  289. int plane;
  290. enum pipe pipe;
  291. struct drm_i915_gem_object *obj;
  292. bool can_scale;
  293. int max_downscale;
  294. u32 lut_r[1024], lut_g[1024], lut_b[1024];
  295. int crtc_x, crtc_y;
  296. unsigned int crtc_w, crtc_h;
  297. uint32_t src_x, src_y;
  298. uint32_t src_w, src_h;
  299. /* Since we need to change the watermarks before/after
  300. * enabling/disabling the planes, we need to store the parameters here
  301. * as the other pieces of the struct may not reflect the values we want
  302. * for the watermark calculations. Currently only Haswell uses this.
  303. */
  304. struct {
  305. bool enable;
  306. uint8_t bytes_per_pixel;
  307. uint32_t horiz_pixels;
  308. } 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. #define DIP_HEADER_SIZE 5
  345. #define DIP_TYPE_AVI 0x82
  346. #define DIP_VERSION_AVI 0x2
  347. #define DIP_LEN_AVI 13
  348. #define DIP_AVI_PR_1 0
  349. #define DIP_AVI_PR_2 1
  350. #define DIP_AVI_RGB_QUANT_RANGE_DEFAULT (0 << 2)
  351. #define DIP_AVI_RGB_QUANT_RANGE_LIMITED (1 << 2)
  352. #define DIP_AVI_RGB_QUANT_RANGE_FULL (2 << 2)
  353. #define DIP_TYPE_SPD 0x83
  354. #define DIP_VERSION_SPD 0x1
  355. #define DIP_LEN_SPD 25
  356. #define DIP_SPD_UNKNOWN 0
  357. #define DIP_SPD_DSTB 0x1
  358. #define DIP_SPD_DVDP 0x2
  359. #define DIP_SPD_DVHS 0x3
  360. #define DIP_SPD_HDDVR 0x4
  361. #define DIP_SPD_DVC 0x5
  362. #define DIP_SPD_DSC 0x6
  363. #define DIP_SPD_VCD 0x7
  364. #define DIP_SPD_GAME 0x8
  365. #define DIP_SPD_PC 0x9
  366. #define DIP_SPD_BD 0xa
  367. #define DIP_SPD_SCD 0xb
  368. struct dip_infoframe {
  369. uint8_t type; /* HB0 */
  370. uint8_t ver; /* HB1 */
  371. uint8_t len; /* HB2 - body len, not including checksum */
  372. uint8_t ecc; /* Header ECC */
  373. uint8_t checksum; /* PB0 */
  374. union {
  375. struct {
  376. /* PB1 - Y 6:5, A 4:4, B 3:2, S 1:0 */
  377. uint8_t Y_A_B_S;
  378. /* PB2 - C 7:6, M 5:4, R 3:0 */
  379. uint8_t C_M_R;
  380. /* PB3 - ITC 7:7, EC 6:4, Q 3:2, SC 1:0 */
  381. uint8_t ITC_EC_Q_SC;
  382. /* PB4 - VIC 6:0 */
  383. uint8_t VIC;
  384. /* PB5 - YQ 7:6, CN 5:4, PR 3:0 */
  385. uint8_t YQ_CN_PR;
  386. /* PB6 to PB13 */
  387. uint16_t top_bar_end;
  388. uint16_t bottom_bar_start;
  389. uint16_t left_bar_end;
  390. uint16_t right_bar_start;
  391. } __attribute__ ((packed)) avi;
  392. struct {
  393. uint8_t vn[8];
  394. uint8_t pd[16];
  395. uint8_t sdi;
  396. } __attribute__ ((packed)) spd;
  397. uint8_t payload[27];
  398. } __attribute__ ((packed)) body;
  399. } __attribute__((packed));
  400. struct intel_hdmi {
  401. u32 hdmi_reg;
  402. int ddc_bus;
  403. uint32_t color_range;
  404. bool color_range_auto;
  405. bool has_hdmi_sink;
  406. bool has_audio;
  407. enum hdmi_force_audio force_audio;
  408. bool rgb_quant_range_selectable;
  409. void (*write_infoframe)(struct drm_encoder *encoder,
  410. struct dip_infoframe *frame);
  411. void (*set_infoframes)(struct drm_encoder *encoder,
  412. struct drm_display_mode *adjusted_mode);
  413. };
  414. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  415. #define DP_LINK_CONFIGURATION_SIZE 9
  416. struct intel_dp {
  417. uint32_t output_reg;
  418. uint32_t aux_ch_ctl_reg;
  419. uint32_t DP;
  420. uint8_t link_configuration[DP_LINK_CONFIGURATION_SIZE];
  421. bool has_audio;
  422. enum hdmi_force_audio force_audio;
  423. uint32_t color_range;
  424. bool color_range_auto;
  425. uint8_t link_bw;
  426. uint8_t lane_count;
  427. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  428. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  429. struct i2c_adapter adapter;
  430. struct i2c_algo_dp_aux_data algo;
  431. uint8_t train_set[4];
  432. int panel_power_up_delay;
  433. int panel_power_down_delay;
  434. int panel_power_cycle_delay;
  435. int backlight_on_delay;
  436. int backlight_off_delay;
  437. struct delayed_work panel_vdd_work;
  438. bool want_panel_vdd;
  439. struct intel_connector *attached_connector;
  440. };
  441. struct intel_digital_port {
  442. struct intel_encoder base;
  443. enum port port;
  444. u32 port_reversal;
  445. struct intel_dp dp;
  446. struct intel_hdmi hdmi;
  447. };
  448. static inline int
  449. vlv_dport_to_channel(struct intel_digital_port *dport)
  450. {
  451. switch (dport->port) {
  452. case PORT_B:
  453. return 0;
  454. case PORT_C:
  455. return 1;
  456. default:
  457. BUG();
  458. }
  459. }
  460. static inline struct drm_crtc *
  461. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  462. {
  463. struct drm_i915_private *dev_priv = dev->dev_private;
  464. return dev_priv->pipe_to_crtc_mapping[pipe];
  465. }
  466. static inline struct drm_crtc *
  467. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  468. {
  469. struct drm_i915_private *dev_priv = dev->dev_private;
  470. return dev_priv->plane_to_crtc_mapping[plane];
  471. }
  472. struct intel_unpin_work {
  473. struct work_struct work;
  474. struct drm_crtc *crtc;
  475. struct drm_i915_gem_object *old_fb_obj;
  476. struct drm_i915_gem_object *pending_flip_obj;
  477. struct drm_pending_vblank_event *event;
  478. atomic_t pending;
  479. #define INTEL_FLIP_INACTIVE 0
  480. #define INTEL_FLIP_PENDING 1
  481. #define INTEL_FLIP_COMPLETE 2
  482. bool enable_stall_check;
  483. };
  484. struct intel_fbc_work {
  485. struct delayed_work work;
  486. struct drm_crtc *crtc;
  487. struct drm_framebuffer *fb;
  488. int interval;
  489. };
  490. int intel_pch_rawclk(struct drm_device *dev);
  491. int intel_connector_update_modes(struct drm_connector *connector,
  492. struct edid *edid);
  493. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  494. extern void intel_attach_force_audio_property(struct drm_connector *connector);
  495. extern void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  496. extern bool intel_pipe_has_type(struct drm_crtc *crtc, int type);
  497. extern void intel_crt_init(struct drm_device *dev);
  498. extern void intel_hdmi_init(struct drm_device *dev,
  499. int hdmi_reg, enum port port);
  500. extern void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  501. struct intel_connector *intel_connector);
  502. extern struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  503. extern bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  504. struct intel_crtc_config *pipe_config);
  505. extern void intel_dip_infoframe_csum(struct dip_infoframe *avi_if);
  506. extern bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg,
  507. bool is_sdvob);
  508. extern void intel_dvo_init(struct drm_device *dev);
  509. extern void intel_tv_init(struct drm_device *dev);
  510. extern void intel_mark_busy(struct drm_device *dev);
  511. extern void intel_mark_fb_busy(struct drm_i915_gem_object *obj,
  512. struct intel_ring_buffer *ring);
  513. extern void intel_mark_idle(struct drm_device *dev);
  514. extern void intel_lvds_init(struct drm_device *dev);
  515. extern bool intel_is_dual_link_lvds(struct drm_device *dev);
  516. extern void intel_dp_init(struct drm_device *dev, int output_reg,
  517. enum port port);
  518. extern void intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  519. struct intel_connector *intel_connector);
  520. extern void intel_dp_init_link_config(struct intel_dp *intel_dp);
  521. extern void intel_dp_start_link_train(struct intel_dp *intel_dp);
  522. extern void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  523. extern void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  524. extern void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  525. extern void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  526. extern void intel_dp_check_link_status(struct intel_dp *intel_dp);
  527. extern bool intel_dp_compute_config(struct intel_encoder *encoder,
  528. struct intel_crtc_config *pipe_config);
  529. extern bool intel_dpd_is_edp(struct drm_device *dev);
  530. extern void ironlake_edp_backlight_on(struct intel_dp *intel_dp);
  531. extern void ironlake_edp_backlight_off(struct intel_dp *intel_dp);
  532. extern void ironlake_edp_panel_on(struct intel_dp *intel_dp);
  533. extern void ironlake_edp_panel_off(struct intel_dp *intel_dp);
  534. extern void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
  535. extern void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
  536. extern int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  537. extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
  538. enum plane plane);
  539. /* intel_panel.c */
  540. extern int intel_panel_init(struct intel_panel *panel,
  541. struct drm_display_mode *fixed_mode);
  542. extern void intel_panel_fini(struct intel_panel *panel);
  543. extern void intel_fixed_panel_mode(struct drm_display_mode *fixed_mode,
  544. struct drm_display_mode *adjusted_mode);
  545. extern void intel_pch_panel_fitting(struct intel_crtc *crtc,
  546. struct intel_crtc_config *pipe_config,
  547. int fitting_mode);
  548. extern void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  549. struct intel_crtc_config *pipe_config,
  550. int fitting_mode);
  551. extern void intel_panel_set_backlight(struct drm_device *dev,
  552. u32 level, u32 max);
  553. extern int intel_panel_setup_backlight(struct drm_connector *connector);
  554. extern void intel_panel_enable_backlight(struct drm_device *dev,
  555. enum pipe pipe);
  556. extern void intel_panel_disable_backlight(struct drm_device *dev);
  557. extern void intel_panel_destroy_backlight(struct drm_device *dev);
  558. extern enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  559. struct intel_set_config {
  560. struct drm_encoder **save_connector_encoders;
  561. struct drm_crtc **save_encoder_crtcs;
  562. bool fb_changed;
  563. bool mode_changed;
  564. };
  565. extern int intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode,
  566. int x, int y, struct drm_framebuffer *old_fb);
  567. extern void intel_modeset_disable(struct drm_device *dev);
  568. extern void intel_crtc_restore_mode(struct drm_crtc *crtc);
  569. extern void intel_crtc_load_lut(struct drm_crtc *crtc);
  570. extern void intel_crtc_update_dpms(struct drm_crtc *crtc);
  571. extern void intel_encoder_destroy(struct drm_encoder *encoder);
  572. extern void intel_encoder_dpms(struct intel_encoder *encoder, int mode);
  573. extern void intel_connector_dpms(struct drm_connector *, int mode);
  574. extern bool intel_connector_get_hw_state(struct intel_connector *connector);
  575. extern void intel_modeset_check_state(struct drm_device *dev);
  576. extern void intel_plane_restore(struct drm_plane *plane);
  577. extern void intel_plane_disable(struct drm_plane *plane);
  578. static inline struct intel_encoder *intel_attached_encoder(struct drm_connector *connector)
  579. {
  580. return to_intel_connector(connector)->encoder;
  581. }
  582. static inline struct intel_digital_port *
  583. enc_to_dig_port(struct drm_encoder *encoder)
  584. {
  585. return container_of(encoder, struct intel_digital_port, base.base);
  586. }
  587. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  588. {
  589. return &enc_to_dig_port(encoder)->dp;
  590. }
  591. static inline struct intel_digital_port *
  592. dp_to_dig_port(struct intel_dp *intel_dp)
  593. {
  594. return container_of(intel_dp, struct intel_digital_port, dp);
  595. }
  596. static inline struct intel_digital_port *
  597. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  598. {
  599. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  600. }
  601. bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
  602. struct intel_digital_port *port);
  603. extern void intel_connector_attach_encoder(struct intel_connector *connector,
  604. struct intel_encoder *encoder);
  605. extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  606. extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  607. struct drm_crtc *crtc);
  608. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  609. struct drm_file *file_priv);
  610. extern enum transcoder
  611. intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  612. enum pipe pipe);
  613. extern void intel_wait_for_vblank(struct drm_device *dev, int pipe);
  614. extern void intel_wait_for_pipe_off(struct drm_device *dev, int pipe);
  615. extern int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  616. extern void vlv_wait_port_ready(struct drm_i915_private *dev_priv, int port);
  617. struct intel_load_detect_pipe {
  618. struct drm_framebuffer *release_fb;
  619. bool load_detect_temp;
  620. int dpms_mode;
  621. };
  622. extern bool intel_get_load_detect_pipe(struct drm_connector *connector,
  623. struct drm_display_mode *mode,
  624. struct intel_load_detect_pipe *old);
  625. extern void intel_release_load_detect_pipe(struct drm_connector *connector,
  626. struct intel_load_detect_pipe *old);
  627. extern void intelfb_restore(void);
  628. extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
  629. u16 blue, int regno);
  630. extern void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
  631. u16 *blue, int regno);
  632. extern void intel_enable_clock_gating(struct drm_device *dev);
  633. extern int intel_pin_and_fence_fb_obj(struct drm_device *dev,
  634. struct drm_i915_gem_object *obj,
  635. struct intel_ring_buffer *pipelined);
  636. extern void intel_unpin_fb_obj(struct drm_i915_gem_object *obj);
  637. extern int intel_framebuffer_init(struct drm_device *dev,
  638. struct intel_framebuffer *ifb,
  639. struct drm_mode_fb_cmd2 *mode_cmd,
  640. struct drm_i915_gem_object *obj);
  641. extern int intel_fbdev_init(struct drm_device *dev);
  642. extern void intel_fbdev_initial_config(struct drm_device *dev);
  643. extern void intel_fbdev_fini(struct drm_device *dev);
  644. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state);
  645. extern void intel_prepare_page_flip(struct drm_device *dev, int plane);
  646. extern void intel_finish_page_flip(struct drm_device *dev, int pipe);
  647. extern void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  648. extern void intel_setup_overlay(struct drm_device *dev);
  649. extern void intel_cleanup_overlay(struct drm_device *dev);
  650. extern int intel_overlay_switch_off(struct intel_overlay *overlay);
  651. extern int intel_overlay_put_image(struct drm_device *dev, void *data,
  652. struct drm_file *file_priv);
  653. extern int intel_overlay_attrs(struct drm_device *dev, void *data,
  654. struct drm_file *file_priv);
  655. extern void intel_fb_output_poll_changed(struct drm_device *dev);
  656. extern void intel_fb_restore_mode(struct drm_device *dev);
  657. extern void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe,
  658. bool state);
  659. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  660. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  661. extern void intel_init_clock_gating(struct drm_device *dev);
  662. extern void intel_suspend_hw(struct drm_device *dev);
  663. extern void intel_write_eld(struct drm_encoder *encoder,
  664. struct drm_display_mode *mode);
  665. extern void intel_prepare_ddi(struct drm_device *dev);
  666. extern void hsw_fdi_link_train(struct drm_crtc *crtc);
  667. extern void intel_ddi_init(struct drm_device *dev, enum port port);
  668. /* For use by IVB LP watermark workaround in intel_sprite.c */
  669. extern void intel_update_watermarks(struct drm_device *dev);
  670. extern void intel_update_sprite_watermarks(struct drm_device *dev, int pipe,
  671. uint32_t sprite_width,
  672. int pixel_size, bool enable);
  673. extern unsigned long intel_gen4_compute_page_offset(int *x, int *y,
  674. unsigned int tiling_mode,
  675. unsigned int bpp,
  676. unsigned int pitch);
  677. extern int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  678. struct drm_file *file_priv);
  679. extern int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
  680. struct drm_file *file_priv);
  681. /* Power-related functions, located in intel_pm.c */
  682. extern void intel_init_pm(struct drm_device *dev);
  683. /* FBC */
  684. extern bool intel_fbc_enabled(struct drm_device *dev);
  685. extern void intel_enable_fbc(struct drm_crtc *crtc, unsigned long interval);
  686. extern void intel_update_fbc(struct drm_device *dev);
  687. /* IPS */
  688. extern void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  689. extern void intel_gpu_ips_teardown(void);
  690. /* Power well */
  691. extern int i915_init_power_well(struct drm_device *dev);
  692. extern void i915_remove_power_well(struct drm_device *dev);
  693. extern bool intel_display_power_enabled(struct drm_device *dev,
  694. enum intel_display_power_domain domain);
  695. extern void intel_init_power_well(struct drm_device *dev);
  696. extern void intel_set_power_well(struct drm_device *dev, bool enable);
  697. extern void intel_enable_gt_powersave(struct drm_device *dev);
  698. extern void intel_disable_gt_powersave(struct drm_device *dev);
  699. extern void gen6_gt_check_fifodbg(struct drm_i915_private *dev_priv);
  700. extern void ironlake_teardown_rc6(struct drm_device *dev);
  701. extern bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
  702. enum pipe *pipe);
  703. extern int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
  704. extern void intel_ddi_pll_init(struct drm_device *dev);
  705. extern void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  706. extern void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  707. enum transcoder cpu_transcoder);
  708. extern void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  709. extern void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  710. extern void intel_ddi_setup_hw_pll_state(struct drm_device *dev);
  711. extern bool intel_ddi_pll_mode_set(struct drm_crtc *crtc);
  712. extern void intel_ddi_put_crtc_pll(struct drm_crtc *crtc);
  713. extern void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  714. extern void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  715. extern bool
  716. intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  717. extern void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  718. extern void intel_display_handle_reset(struct drm_device *dev);
  719. extern bool intel_set_cpu_fifo_underrun_reporting(struct drm_device *dev,
  720. enum pipe pipe,
  721. bool enable);
  722. extern bool intel_set_pch_fifo_underrun_reporting(struct drm_device *dev,
  723. enum transcoder pch_transcoder,
  724. bool enable);
  725. #endif /* __INTEL_DRV_H__ */