intel_drv.h 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325
  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/async.h>
  28. #include <linux/i2c.h>
  29. #include <linux/hdmi.h>
  30. #include <drm/i915_drm.h>
  31. #include "i915_drv.h"
  32. #include <drm/drm_crtc.h>
  33. #include <drm/drm_crtc_helper.h>
  34. #include <drm/drm_fb_helper.h>
  35. #include <drm/drm_dp_mst_helper.h>
  36. #include <drm/drm_rect.h>
  37. #include <drm/drm_atomic.h>
  38. /**
  39. * _wait_for - magic (register) wait macro
  40. *
  41. * Does the right thing for modeset paths when run under kdgb or similar atomic
  42. * contexts. Note that it's important that we check the condition again after
  43. * having timed out, since the timeout could be due to preemption or similar and
  44. * we've never had a chance to check the condition before the timeout.
  45. */
  46. #define _wait_for(COND, MS, W) ({ \
  47. unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
  48. int ret__ = 0; \
  49. while (!(COND)) { \
  50. if (time_after(jiffies, timeout__)) { \
  51. if (!(COND)) \
  52. ret__ = -ETIMEDOUT; \
  53. break; \
  54. } \
  55. if ((W) && drm_can_sleep()) { \
  56. usleep_range((W)*1000, (W)*2000); \
  57. } else { \
  58. cpu_relax(); \
  59. } \
  60. } \
  61. ret__; \
  62. })
  63. #define wait_for(COND, MS) _wait_for(COND, MS, 1)
  64. #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
  65. #define wait_for_atomic_us(COND, US) _wait_for((COND), \
  66. DIV_ROUND_UP((US), 1000), 0)
  67. #define KHz(x) (1000 * (x))
  68. #define MHz(x) KHz(1000 * (x))
  69. /*
  70. * Display related stuff
  71. */
  72. /* store information about an Ixxx DVO */
  73. /* The i830->i865 use multiple DVOs with multiple i2cs */
  74. /* the i915, i945 have a single sDVO i2c bus - which is different */
  75. #define MAX_OUTPUTS 6
  76. /* maximum connectors per crtcs in the mode set */
  77. /* Maximum cursor sizes */
  78. #define GEN2_CURSOR_WIDTH 64
  79. #define GEN2_CURSOR_HEIGHT 64
  80. #define MAX_CURSOR_WIDTH 256
  81. #define MAX_CURSOR_HEIGHT 256
  82. #define INTEL_I2C_BUS_DVO 1
  83. #define INTEL_I2C_BUS_SDVO 2
  84. /* these are outputs from the chip - integrated only
  85. external chips are via DVO or SDVO output */
  86. enum intel_output_type {
  87. INTEL_OUTPUT_UNUSED = 0,
  88. INTEL_OUTPUT_ANALOG = 1,
  89. INTEL_OUTPUT_DVO = 2,
  90. INTEL_OUTPUT_SDVO = 3,
  91. INTEL_OUTPUT_LVDS = 4,
  92. INTEL_OUTPUT_TVOUT = 5,
  93. INTEL_OUTPUT_HDMI = 6,
  94. INTEL_OUTPUT_DISPLAYPORT = 7,
  95. INTEL_OUTPUT_EDP = 8,
  96. INTEL_OUTPUT_DSI = 9,
  97. INTEL_OUTPUT_UNKNOWN = 10,
  98. INTEL_OUTPUT_DP_MST = 11,
  99. };
  100. #define INTEL_DVO_CHIP_NONE 0
  101. #define INTEL_DVO_CHIP_LVDS 1
  102. #define INTEL_DVO_CHIP_TMDS 2
  103. #define INTEL_DVO_CHIP_TVOUT 4
  104. #define INTEL_DSI_VIDEO_MODE 0
  105. #define INTEL_DSI_COMMAND_MODE 1
  106. struct intel_framebuffer {
  107. struct drm_framebuffer base;
  108. struct drm_i915_gem_object *obj;
  109. };
  110. struct intel_fbdev {
  111. struct drm_fb_helper helper;
  112. struct intel_framebuffer *fb;
  113. struct list_head fbdev_list;
  114. struct drm_display_mode *our_mode;
  115. int preferred_bpp;
  116. };
  117. struct intel_encoder {
  118. struct drm_encoder base;
  119. /*
  120. * The new crtc this encoder will be driven from. Only differs from
  121. * base->crtc while a modeset is in progress.
  122. */
  123. struct intel_crtc *new_crtc;
  124. enum intel_output_type type;
  125. unsigned int cloneable;
  126. bool connectors_active;
  127. void (*hot_plug)(struct intel_encoder *);
  128. bool (*compute_config)(struct intel_encoder *,
  129. struct intel_crtc_state *);
  130. void (*pre_pll_enable)(struct intel_encoder *);
  131. void (*pre_enable)(struct intel_encoder *);
  132. void (*enable)(struct intel_encoder *);
  133. void (*mode_set)(struct intel_encoder *intel_encoder);
  134. void (*disable)(struct intel_encoder *);
  135. void (*post_disable)(struct intel_encoder *);
  136. /* Read out the current hw state of this connector, returning true if
  137. * the encoder is active. If the encoder is enabled it also set the pipe
  138. * it is connected to in the pipe parameter. */
  139. bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
  140. /* Reconstructs the equivalent mode flags for the current hardware
  141. * state. This must be called _after_ display->get_pipe_config has
  142. * pre-filled the pipe config. Note that intel_encoder->base.crtc must
  143. * be set correctly before calling this function. */
  144. void (*get_config)(struct intel_encoder *,
  145. struct intel_crtc_state *pipe_config);
  146. /*
  147. * Called during system suspend after all pending requests for the
  148. * encoder are flushed (for example for DP AUX transactions) and
  149. * device interrupts are disabled.
  150. */
  151. void (*suspend)(struct intel_encoder *);
  152. int crtc_mask;
  153. enum hpd_pin hpd_pin;
  154. };
  155. struct intel_panel {
  156. struct drm_display_mode *fixed_mode;
  157. struct drm_display_mode *downclock_mode;
  158. int fitting_mode;
  159. /* backlight */
  160. struct {
  161. bool present;
  162. u32 level;
  163. u32 min;
  164. u32 max;
  165. bool enabled;
  166. bool combination_mode; /* gen 2/4 only */
  167. bool active_low_pwm;
  168. struct backlight_device *device;
  169. } backlight;
  170. void (*backlight_power)(struct intel_connector *, bool enable);
  171. };
  172. struct intel_connector {
  173. struct drm_connector base;
  174. /*
  175. * The fixed encoder this connector is connected to.
  176. */
  177. struct intel_encoder *encoder;
  178. /*
  179. * The new encoder this connector will be driven. Only differs from
  180. * encoder while a modeset is in progress.
  181. */
  182. struct intel_encoder *new_encoder;
  183. /* Reads out the current hw, returning true if the connector is enabled
  184. * and active (i.e. dpms ON state). */
  185. bool (*get_hw_state)(struct intel_connector *);
  186. /*
  187. * Removes all interfaces through which the connector is accessible
  188. * - like sysfs, debugfs entries -, so that no new operations can be
  189. * started on the connector. Also makes sure all currently pending
  190. * operations finish before returing.
  191. */
  192. void (*unregister)(struct intel_connector *);
  193. /* Panel info for eDP and LVDS */
  194. struct intel_panel panel;
  195. /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
  196. struct edid *edid;
  197. struct edid *detect_edid;
  198. /* since POLL and HPD connectors may use the same HPD line keep the native
  199. state of connector->polled in case hotplug storm detection changes it */
  200. u8 polled;
  201. void *port; /* store this opaque as its illegal to dereference it */
  202. struct intel_dp *mst_port;
  203. };
  204. typedef struct dpll {
  205. /* given values */
  206. int n;
  207. int m1, m2;
  208. int p1, p2;
  209. /* derived values */
  210. int dot;
  211. int vco;
  212. int m;
  213. int p;
  214. } intel_clock_t;
  215. struct intel_plane_state {
  216. struct drm_plane_state base;
  217. struct drm_rect src;
  218. struct drm_rect dst;
  219. struct drm_rect clip;
  220. bool visible;
  221. /*
  222. * used only for sprite planes to determine when to implicitly
  223. * enable/disable the primary plane
  224. */
  225. bool hides_primary;
  226. };
  227. struct intel_initial_plane_config {
  228. struct intel_framebuffer *fb;
  229. unsigned int tiling;
  230. int size;
  231. u32 base;
  232. };
  233. struct intel_crtc_state {
  234. struct drm_crtc_state base;
  235. /**
  236. * quirks - bitfield with hw state readout quirks
  237. *
  238. * For various reasons the hw state readout code might not be able to
  239. * completely faithfully read out the current state. These cases are
  240. * tracked with quirk flags so that fastboot and state checker can act
  241. * accordingly.
  242. */
  243. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  244. #define PIPE_CONFIG_QUIRK_INHERITED_MODE (1<<1) /* mode inherited from firmware */
  245. unsigned long quirks;
  246. /* Pipe source size (ie. panel fitter input size)
  247. * All planes will be positioned inside this space,
  248. * and get clipped at the edges. */
  249. int pipe_src_w, pipe_src_h;
  250. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  251. * between pch encoders and cpu encoders. */
  252. bool has_pch_encoder;
  253. /* Are we sending infoframes on the attached port */
  254. bool has_infoframe;
  255. /* CPU Transcoder for the pipe. Currently this can only differ from the
  256. * pipe on Haswell (where we have a special eDP transcoder). */
  257. enum transcoder cpu_transcoder;
  258. /*
  259. * Use reduced/limited/broadcast rbg range, compressing from the full
  260. * range fed into the crtcs.
  261. */
  262. bool limited_color_range;
  263. /* DP has a bunch of special case unfortunately, so mark the pipe
  264. * accordingly. */
  265. bool has_dp_encoder;
  266. /* Whether we should send NULL infoframes. Required for audio. */
  267. bool has_hdmi_sink;
  268. /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
  269. * has_dp_encoder is set. */
  270. bool has_audio;
  271. /*
  272. * Enable dithering, used when the selected pipe bpp doesn't match the
  273. * plane bpp.
  274. */
  275. bool dither;
  276. /* Controls for the clock computation, to override various stages. */
  277. bool clock_set;
  278. /* SDVO TV has a bunch of special case. To make multifunction encoders
  279. * work correctly, we need to track this at runtime.*/
  280. bool sdvo_tv_clock;
  281. /*
  282. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  283. * required. This is set in the 2nd loop of calling encoder's
  284. * ->compute_config if the first pick doesn't work out.
  285. */
  286. bool bw_constrained;
  287. /* Settings for the intel dpll used on pretty much everything but
  288. * haswell. */
  289. struct dpll dpll;
  290. /* Selected dpll when shared or DPLL_ID_PRIVATE. */
  291. enum intel_dpll_id shared_dpll;
  292. /*
  293. * - PORT_CLK_SEL for DDI ports on HSW/BDW.
  294. * - enum skl_dpll on SKL
  295. */
  296. uint32_t ddi_pll_sel;
  297. /* Actual register state of the dpll, for shared dpll cross-checking. */
  298. struct intel_dpll_hw_state dpll_hw_state;
  299. int pipe_bpp;
  300. struct intel_link_m_n dp_m_n;
  301. /* m2_n2 for eDP downclock */
  302. struct intel_link_m_n dp_m2_n2;
  303. bool has_drrs;
  304. /*
  305. * Frequence the dpll for the port should run at. Differs from the
  306. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  307. * already multiplied by pixel_multiplier.
  308. */
  309. int port_clock;
  310. /* Used by SDVO (and if we ever fix it, HDMI). */
  311. unsigned pixel_multiplier;
  312. /* Panel fitter controls for gen2-gen4 + VLV */
  313. struct {
  314. u32 control;
  315. u32 pgm_ratios;
  316. u32 lvds_border_bits;
  317. } gmch_pfit;
  318. /* Panel fitter placement and size for Ironlake+ */
  319. struct {
  320. u32 pos;
  321. u32 size;
  322. bool enabled;
  323. bool force_thru;
  324. } pch_pfit;
  325. /* FDI configuration, only valid if has_pch_encoder is set. */
  326. int fdi_lanes;
  327. struct intel_link_m_n fdi_m_n;
  328. bool ips_enabled;
  329. bool double_wide;
  330. bool dp_encoder_is_mst;
  331. int pbn;
  332. };
  333. struct intel_pipe_wm {
  334. struct intel_wm_level wm[5];
  335. uint32_t linetime;
  336. bool fbc_wm_enabled;
  337. bool pipe_enabled;
  338. bool sprites_enabled;
  339. bool sprites_scaled;
  340. };
  341. struct intel_mmio_flip {
  342. struct drm_i915_gem_request *req;
  343. struct work_struct work;
  344. };
  345. struct skl_pipe_wm {
  346. struct skl_wm_level wm[8];
  347. struct skl_wm_level trans_wm;
  348. uint32_t linetime;
  349. };
  350. /*
  351. * Tracking of operations that need to be performed at the beginning/end of an
  352. * atomic commit, outside the atomic section where interrupts are disabled.
  353. * These are generally operations that grab mutexes or might otherwise sleep
  354. * and thus can't be run with interrupts disabled.
  355. */
  356. struct intel_crtc_atomic_commit {
  357. /* vblank evasion */
  358. bool evade;
  359. unsigned start_vbl_count;
  360. /* Sleepable operations to perform before commit */
  361. bool wait_for_flips;
  362. bool disable_fbc;
  363. bool pre_disable_primary;
  364. bool update_wm;
  365. unsigned disabled_planes;
  366. /* Sleepable operations to perform after commit */
  367. unsigned fb_bits;
  368. bool wait_vblank;
  369. bool update_fbc;
  370. bool post_enable_primary;
  371. unsigned update_sprite_watermarks;
  372. };
  373. struct intel_crtc {
  374. struct drm_crtc base;
  375. enum pipe pipe;
  376. enum plane plane;
  377. u8 lut_r[256], lut_g[256], lut_b[256];
  378. /*
  379. * Whether the crtc and the connected output pipeline is active. Implies
  380. * that crtc->enabled is set, i.e. the current mode configuration has
  381. * some outputs connected to this crtc.
  382. */
  383. bool active;
  384. unsigned long enabled_power_domains;
  385. bool primary_enabled; /* is the primary plane (partially) visible? */
  386. bool lowfreq_avail;
  387. struct intel_overlay *overlay;
  388. struct intel_unpin_work *unpin_work;
  389. atomic_t unpin_work_count;
  390. /* Display surface base address adjustement for pageflips. Note that on
  391. * gen4+ this only adjusts up to a tile, offsets within a tile are
  392. * handled in the hw itself (with the TILEOFF register). */
  393. unsigned long dspaddr_offset;
  394. struct drm_i915_gem_object *cursor_bo;
  395. uint32_t cursor_addr;
  396. uint32_t cursor_cntl;
  397. uint32_t cursor_size;
  398. uint32_t cursor_base;
  399. struct intel_initial_plane_config plane_config;
  400. struct intel_crtc_state *config;
  401. struct intel_crtc_state *new_config;
  402. bool new_enabled;
  403. /* reset counter value when the last flip was submitted */
  404. unsigned int reset_counter;
  405. /* Access to these should be protected by dev_priv->irq_lock. */
  406. bool cpu_fifo_underrun_disabled;
  407. bool pch_fifo_underrun_disabled;
  408. /* per-pipe watermark state */
  409. struct {
  410. /* watermarks currently being used */
  411. struct intel_pipe_wm active;
  412. /* SKL wm values currently in use */
  413. struct skl_pipe_wm skl_active;
  414. } wm;
  415. int scanline_offset;
  416. struct intel_mmio_flip mmio_flip;
  417. struct intel_crtc_atomic_commit atomic;
  418. };
  419. struct intel_plane_wm_parameters {
  420. uint32_t horiz_pixels;
  421. uint32_t vert_pixels;
  422. uint8_t bytes_per_pixel;
  423. bool enabled;
  424. bool scaled;
  425. u64 tiling;
  426. unsigned int rotation;
  427. };
  428. struct intel_plane {
  429. struct drm_plane base;
  430. int plane;
  431. enum pipe pipe;
  432. bool can_scale;
  433. int max_downscale;
  434. /* FIXME convert to properties */
  435. struct drm_intel_sprite_colorkey ckey;
  436. /* Since we need to change the watermarks before/after
  437. * enabling/disabling the planes, we need to store the parameters here
  438. * as the other pieces of the struct may not reflect the values we want
  439. * for the watermark calculations. Currently only Haswell uses this.
  440. */
  441. struct intel_plane_wm_parameters wm;
  442. /*
  443. * NOTE: Do not place new plane state fields here (e.g., when adding
  444. * new plane properties). New runtime state should now be placed in
  445. * the intel_plane_state structure and accessed via drm_plane->state.
  446. */
  447. void (*update_plane)(struct drm_plane *plane,
  448. struct drm_crtc *crtc,
  449. struct drm_framebuffer *fb,
  450. int crtc_x, int crtc_y,
  451. unsigned int crtc_w, unsigned int crtc_h,
  452. uint32_t x, uint32_t y,
  453. uint32_t src_w, uint32_t src_h);
  454. void (*disable_plane)(struct drm_plane *plane,
  455. struct drm_crtc *crtc);
  456. int (*check_plane)(struct drm_plane *plane,
  457. struct intel_plane_state *state);
  458. void (*commit_plane)(struct drm_plane *plane,
  459. struct intel_plane_state *state);
  460. };
  461. struct intel_watermark_params {
  462. unsigned long fifo_size;
  463. unsigned long max_wm;
  464. unsigned long default_wm;
  465. unsigned long guard_size;
  466. unsigned long cacheline_size;
  467. };
  468. struct cxsr_latency {
  469. int is_desktop;
  470. int is_ddr3;
  471. unsigned long fsb_freq;
  472. unsigned long mem_freq;
  473. unsigned long display_sr;
  474. unsigned long display_hpll_disable;
  475. unsigned long cursor_sr;
  476. unsigned long cursor_hpll_disable;
  477. };
  478. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  479. #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
  480. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  481. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  482. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  483. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  484. #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
  485. #define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL)
  486. struct intel_hdmi {
  487. u32 hdmi_reg;
  488. int ddc_bus;
  489. uint32_t color_range;
  490. bool color_range_auto;
  491. bool has_hdmi_sink;
  492. bool has_audio;
  493. enum hdmi_force_audio force_audio;
  494. bool rgb_quant_range_selectable;
  495. enum hdmi_picture_aspect aspect_ratio;
  496. void (*write_infoframe)(struct drm_encoder *encoder,
  497. enum hdmi_infoframe_type type,
  498. const void *frame, ssize_t len);
  499. void (*set_infoframes)(struct drm_encoder *encoder,
  500. bool enable,
  501. struct drm_display_mode *adjusted_mode);
  502. bool (*infoframe_enabled)(struct drm_encoder *encoder);
  503. };
  504. struct intel_dp_mst_encoder;
  505. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  506. /*
  507. * enum link_m_n_set:
  508. * When platform provides two set of M_N registers for dp, we can
  509. * program them and switch between them incase of DRRS.
  510. * But When only one such register is provided, we have to program the
  511. * required divider value on that registers itself based on the DRRS state.
  512. *
  513. * M1_N1 : Program dp_m_n on M1_N1 registers
  514. * dp_m2_n2 on M2_N2 registers (If supported)
  515. *
  516. * M2_N2 : Program dp_m2_n2 on M1_N1 registers
  517. * M2_N2 registers are not supported
  518. */
  519. enum link_m_n_set {
  520. /* Sets the m1_n1 and m2_n2 */
  521. M1_N1 = 0,
  522. M2_N2
  523. };
  524. struct intel_dp {
  525. uint32_t output_reg;
  526. uint32_t aux_ch_ctl_reg;
  527. uint32_t DP;
  528. bool has_audio;
  529. enum hdmi_force_audio force_audio;
  530. uint32_t color_range;
  531. bool color_range_auto;
  532. uint8_t link_bw;
  533. uint8_t rate_select;
  534. uint8_t lane_count;
  535. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  536. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  537. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  538. /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
  539. uint8_t num_sink_rates;
  540. int sink_rates[DP_MAX_SUPPORTED_RATES];
  541. struct drm_dp_aux aux;
  542. uint8_t train_set[4];
  543. int panel_power_up_delay;
  544. int panel_power_down_delay;
  545. int panel_power_cycle_delay;
  546. int backlight_on_delay;
  547. int backlight_off_delay;
  548. struct delayed_work panel_vdd_work;
  549. bool want_panel_vdd;
  550. unsigned long last_power_cycle;
  551. unsigned long last_power_on;
  552. unsigned long last_backlight_off;
  553. struct notifier_block edp_notifier;
  554. /*
  555. * Pipe whose power sequencer is currently locked into
  556. * this port. Only relevant on VLV/CHV.
  557. */
  558. enum pipe pps_pipe;
  559. struct edp_power_seq pps_delays;
  560. bool use_tps3;
  561. bool can_mst; /* this port supports mst */
  562. bool is_mst;
  563. int active_mst_links;
  564. /* connector directly attached - won't be use for modeset in mst world */
  565. struct intel_connector *attached_connector;
  566. /* mst connector list */
  567. struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
  568. struct drm_dp_mst_topology_mgr mst_mgr;
  569. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  570. /*
  571. * This function returns the value we have to program the AUX_CTL
  572. * register with to kick off an AUX transaction.
  573. */
  574. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  575. bool has_aux_irq,
  576. int send_bytes,
  577. uint32_t aux_clock_divider);
  578. };
  579. struct intel_digital_port {
  580. struct intel_encoder base;
  581. enum port port;
  582. u32 saved_port_bits;
  583. struct intel_dp dp;
  584. struct intel_hdmi hdmi;
  585. enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
  586. };
  587. struct intel_dp_mst_encoder {
  588. struct intel_encoder base;
  589. enum pipe pipe;
  590. struct intel_digital_port *primary;
  591. void *port; /* store this opaque as its illegal to dereference it */
  592. };
  593. static inline int
  594. vlv_dport_to_channel(struct intel_digital_port *dport)
  595. {
  596. switch (dport->port) {
  597. case PORT_B:
  598. case PORT_D:
  599. return DPIO_CH0;
  600. case PORT_C:
  601. return DPIO_CH1;
  602. default:
  603. BUG();
  604. }
  605. }
  606. static inline int
  607. vlv_pipe_to_channel(enum pipe pipe)
  608. {
  609. switch (pipe) {
  610. case PIPE_A:
  611. case PIPE_C:
  612. return DPIO_CH0;
  613. case PIPE_B:
  614. return DPIO_CH1;
  615. default:
  616. BUG();
  617. }
  618. }
  619. static inline struct drm_crtc *
  620. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  621. {
  622. struct drm_i915_private *dev_priv = dev->dev_private;
  623. return dev_priv->pipe_to_crtc_mapping[pipe];
  624. }
  625. static inline struct drm_crtc *
  626. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  627. {
  628. struct drm_i915_private *dev_priv = dev->dev_private;
  629. return dev_priv->plane_to_crtc_mapping[plane];
  630. }
  631. struct intel_unpin_work {
  632. struct work_struct work;
  633. struct drm_crtc *crtc;
  634. struct drm_framebuffer *old_fb;
  635. struct drm_i915_gem_object *pending_flip_obj;
  636. struct drm_pending_vblank_event *event;
  637. atomic_t pending;
  638. #define INTEL_FLIP_INACTIVE 0
  639. #define INTEL_FLIP_PENDING 1
  640. #define INTEL_FLIP_COMPLETE 2
  641. u32 flip_count;
  642. u32 gtt_offset;
  643. struct drm_i915_gem_request *flip_queued_req;
  644. int flip_queued_vblank;
  645. int flip_ready_vblank;
  646. bool enable_stall_check;
  647. };
  648. struct intel_set_config {
  649. struct drm_encoder **save_connector_encoders;
  650. struct drm_crtc **save_encoder_crtcs;
  651. bool *save_crtc_enabled;
  652. bool fb_changed;
  653. bool mode_changed;
  654. };
  655. struct intel_load_detect_pipe {
  656. struct drm_framebuffer *release_fb;
  657. bool load_detect_temp;
  658. int dpms_mode;
  659. };
  660. static inline struct intel_encoder *
  661. intel_attached_encoder(struct drm_connector *connector)
  662. {
  663. return to_intel_connector(connector)->encoder;
  664. }
  665. static inline struct intel_digital_port *
  666. enc_to_dig_port(struct drm_encoder *encoder)
  667. {
  668. return container_of(encoder, struct intel_digital_port, base.base);
  669. }
  670. static inline struct intel_dp_mst_encoder *
  671. enc_to_mst(struct drm_encoder *encoder)
  672. {
  673. return container_of(encoder, struct intel_dp_mst_encoder, base.base);
  674. }
  675. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  676. {
  677. return &enc_to_dig_port(encoder)->dp;
  678. }
  679. static inline struct intel_digital_port *
  680. dp_to_dig_port(struct intel_dp *intel_dp)
  681. {
  682. return container_of(intel_dp, struct intel_digital_port, dp);
  683. }
  684. static inline struct intel_digital_port *
  685. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  686. {
  687. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  688. }
  689. /*
  690. * Returns the number of planes for this pipe, ie the number of sprites + 1
  691. * (primary plane). This doesn't count the cursor plane then.
  692. */
  693. static inline unsigned int intel_num_planes(struct intel_crtc *crtc)
  694. {
  695. return INTEL_INFO(crtc->base.dev)->num_sprites[crtc->pipe] + 1;
  696. }
  697. /* intel_fifo_underrun.c */
  698. bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  699. enum pipe pipe, bool enable);
  700. bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  701. enum transcoder pch_transcoder,
  702. bool enable);
  703. void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  704. enum pipe pipe);
  705. void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  706. enum transcoder pch_transcoder);
  707. void i9xx_check_fifo_underruns(struct drm_i915_private *dev_priv);
  708. /* i915_irq.c */
  709. void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  710. void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  711. void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  712. void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  713. void gen6_reset_rps_interrupts(struct drm_device *dev);
  714. void gen6_enable_rps_interrupts(struct drm_device *dev);
  715. void gen6_disable_rps_interrupts(struct drm_device *dev);
  716. u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
  717. void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
  718. void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
  719. static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
  720. {
  721. /*
  722. * We only use drm_irq_uninstall() at unload and VT switch, so
  723. * this is the only thing we need to check.
  724. */
  725. return dev_priv->pm.irqs_enabled;
  726. }
  727. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  728. void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
  729. unsigned int pipe_mask);
  730. /* intel_crt.c */
  731. void intel_crt_init(struct drm_device *dev);
  732. /* intel_ddi.c */
  733. void intel_prepare_ddi(struct drm_device *dev);
  734. void hsw_fdi_link_train(struct drm_crtc *crtc);
  735. void intel_ddi_init(struct drm_device *dev, enum port port);
  736. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  737. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  738. int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
  739. void intel_ddi_pll_init(struct drm_device *dev);
  740. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  741. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  742. enum transcoder cpu_transcoder);
  743. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  744. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  745. bool intel_ddi_pll_select(struct intel_crtc *crtc,
  746. struct intel_crtc_state *crtc_state);
  747. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  748. void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  749. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  750. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  751. void intel_ddi_get_config(struct intel_encoder *encoder,
  752. struct intel_crtc_state *pipe_config);
  753. void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
  754. void intel_ddi_clock_get(struct intel_encoder *encoder,
  755. struct intel_crtc_state *pipe_config);
  756. void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state);
  757. /* intel_frontbuffer.c */
  758. void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
  759. struct intel_engine_cs *ring,
  760. enum fb_op_origin origin);
  761. void intel_frontbuffer_flip_prepare(struct drm_device *dev,
  762. unsigned frontbuffer_bits);
  763. void intel_frontbuffer_flip_complete(struct drm_device *dev,
  764. unsigned frontbuffer_bits);
  765. void intel_frontbuffer_flush(struct drm_device *dev,
  766. unsigned frontbuffer_bits);
  767. /**
  768. * intel_frontbuffer_flip - synchronous frontbuffer flip
  769. * @dev: DRM device
  770. * @frontbuffer_bits: frontbuffer plane tracking bits
  771. *
  772. * This function gets called after scheduling a flip on @obj. This is for
  773. * synchronous plane updates which will happen on the next vblank and which will
  774. * not get delayed by pending gpu rendering.
  775. *
  776. * Can be called without any locks held.
  777. */
  778. static inline
  779. void intel_frontbuffer_flip(struct drm_device *dev,
  780. unsigned frontbuffer_bits)
  781. {
  782. intel_frontbuffer_flush(dev, frontbuffer_bits);
  783. }
  784. unsigned int intel_fb_align_height(struct drm_device *dev,
  785. unsigned int height,
  786. uint32_t pixel_format,
  787. uint64_t fb_format_modifier);
  788. void intel_fb_obj_flush(struct drm_i915_gem_object *obj, bool retire);
  789. u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,
  790. uint32_t pixel_format);
  791. /* intel_audio.c */
  792. void intel_init_audio(struct drm_device *dev);
  793. void intel_audio_codec_enable(struct intel_encoder *encoder);
  794. void intel_audio_codec_disable(struct intel_encoder *encoder);
  795. void i915_audio_component_init(struct drm_i915_private *dev_priv);
  796. void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
  797. /* intel_display.c */
  798. extern const struct drm_plane_funcs intel_plane_funcs;
  799. bool intel_has_pending_fb_unpin(struct drm_device *dev);
  800. int intel_pch_rawclk(struct drm_device *dev);
  801. void intel_mark_busy(struct drm_device *dev);
  802. void intel_mark_idle(struct drm_device *dev);
  803. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  804. void intel_crtc_control(struct drm_crtc *crtc, bool enable);
  805. void intel_crtc_update_dpms(struct drm_crtc *crtc);
  806. void intel_encoder_destroy(struct drm_encoder *encoder);
  807. int intel_connector_init(struct intel_connector *);
  808. struct intel_connector *intel_connector_alloc(void);
  809. void intel_connector_dpms(struct drm_connector *, int mode);
  810. bool intel_connector_get_hw_state(struct intel_connector *connector);
  811. void intel_modeset_check_state(struct drm_device *dev);
  812. bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
  813. struct intel_digital_port *port);
  814. void intel_connector_attach_encoder(struct intel_connector *connector,
  815. struct intel_encoder *encoder);
  816. struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  817. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  818. struct drm_crtc *crtc);
  819. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  820. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  821. struct drm_file *file_priv);
  822. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  823. enum pipe pipe);
  824. bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type);
  825. static inline void
  826. intel_wait_for_vblank(struct drm_device *dev, int pipe)
  827. {
  828. drm_wait_one_vblank(dev, pipe);
  829. }
  830. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  831. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  832. struct intel_digital_port *dport);
  833. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  834. struct drm_display_mode *mode,
  835. struct intel_load_detect_pipe *old,
  836. struct drm_modeset_acquire_ctx *ctx);
  837. void intel_release_load_detect_pipe(struct drm_connector *connector,
  838. struct intel_load_detect_pipe *old,
  839. struct drm_modeset_acquire_ctx *ctx);
  840. int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
  841. struct drm_framebuffer *fb,
  842. const struct drm_plane_state *plane_state,
  843. struct intel_engine_cs *pipelined);
  844. struct drm_framebuffer *
  845. __intel_framebuffer_create(struct drm_device *dev,
  846. struct drm_mode_fb_cmd2 *mode_cmd,
  847. struct drm_i915_gem_object *obj);
  848. void intel_prepare_page_flip(struct drm_device *dev, int plane);
  849. void intel_finish_page_flip(struct drm_device *dev, int pipe);
  850. void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  851. void intel_check_page_flip(struct drm_device *dev, int pipe);
  852. int intel_prepare_plane_fb(struct drm_plane *plane,
  853. struct drm_framebuffer *fb,
  854. const struct drm_plane_state *new_state);
  855. void intel_cleanup_plane_fb(struct drm_plane *plane,
  856. struct drm_framebuffer *fb,
  857. const struct drm_plane_state *old_state);
  858. int intel_plane_atomic_get_property(struct drm_plane *plane,
  859. const struct drm_plane_state *state,
  860. struct drm_property *property,
  861. uint64_t *val);
  862. int intel_plane_atomic_set_property(struct drm_plane *plane,
  863. struct drm_plane_state *state,
  864. struct drm_property *property,
  865. uint64_t val);
  866. unsigned int
  867. intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
  868. uint64_t fb_format_modifier);
  869. static inline bool
  870. intel_rotation_90_or_270(unsigned int rotation)
  871. {
  872. return rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270));
  873. }
  874. bool intel_wm_need_update(struct drm_plane *plane,
  875. struct drm_plane_state *state);
  876. /* shared dpll functions */
  877. struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
  878. void assert_shared_dpll(struct drm_i915_private *dev_priv,
  879. struct intel_shared_dpll *pll,
  880. bool state);
  881. #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
  882. #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
  883. struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
  884. struct intel_crtc_state *state);
  885. void intel_put_shared_dpll(struct intel_crtc *crtc);
  886. void vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
  887. const struct dpll *dpll);
  888. void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe);
  889. /* modesetting asserts */
  890. void assert_panel_unlocked(struct drm_i915_private *dev_priv,
  891. enum pipe pipe);
  892. void assert_pll(struct drm_i915_private *dev_priv,
  893. enum pipe pipe, bool state);
  894. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  895. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  896. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  897. enum pipe pipe, bool state);
  898. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  899. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  900. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  901. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  902. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  903. unsigned long intel_gen4_compute_page_offset(int *x, int *y,
  904. unsigned int tiling_mode,
  905. unsigned int bpp,
  906. unsigned int pitch);
  907. void intel_prepare_reset(struct drm_device *dev);
  908. void intel_finish_reset(struct drm_device *dev);
  909. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  910. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  911. void intel_dp_get_m_n(struct intel_crtc *crtc,
  912. struct intel_crtc_state *pipe_config);
  913. void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
  914. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  915. void
  916. ironlake_check_encoder_dotclock(const struct intel_crtc_state *pipe_config,
  917. int dotclock);
  918. bool intel_crtc_active(struct drm_crtc *crtc);
  919. void hsw_enable_ips(struct intel_crtc *crtc);
  920. void hsw_disable_ips(struct intel_crtc *crtc);
  921. enum intel_display_power_domain
  922. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  923. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  924. struct intel_crtc_state *pipe_config);
  925. void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
  926. void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
  927. unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
  928. struct drm_i915_gem_object *obj);
  929. /* intel_dp.c */
  930. void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
  931. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  932. struct intel_connector *intel_connector);
  933. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  934. void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  935. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  936. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  937. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  938. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  939. bool intel_dp_compute_config(struct intel_encoder *encoder,
  940. struct intel_crtc_state *pipe_config);
  941. bool intel_dp_is_edp(struct drm_device *dev, enum port port);
  942. enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
  943. bool long_hpd);
  944. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  945. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  946. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  947. void intel_edp_panel_on(struct intel_dp *intel_dp);
  948. void intel_edp_panel_off(struct intel_dp *intel_dp);
  949. void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
  950. void intel_dp_mst_suspend(struct drm_device *dev);
  951. void intel_dp_mst_resume(struct drm_device *dev);
  952. int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  953. int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
  954. void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
  955. void vlv_power_sequencer_reset(struct drm_i915_private *dev_priv);
  956. uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
  957. void intel_plane_destroy(struct drm_plane *plane);
  958. void intel_edp_drrs_enable(struct intel_dp *intel_dp);
  959. void intel_edp_drrs_disable(struct intel_dp *intel_dp);
  960. void intel_edp_drrs_invalidate(struct drm_device *dev,
  961. unsigned frontbuffer_bits);
  962. void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits);
  963. /* intel_dp_mst.c */
  964. int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  965. void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
  966. /* intel_dsi.c */
  967. void intel_dsi_init(struct drm_device *dev);
  968. /* intel_dvo.c */
  969. void intel_dvo_init(struct drm_device *dev);
  970. /* legacy fbdev emulation in intel_fbdev.c */
  971. #ifdef CONFIG_DRM_I915_FBDEV
  972. extern int intel_fbdev_init(struct drm_device *dev);
  973. extern void intel_fbdev_initial_config(void *data, async_cookie_t cookie);
  974. extern void intel_fbdev_fini(struct drm_device *dev);
  975. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
  976. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  977. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  978. #else
  979. static inline int intel_fbdev_init(struct drm_device *dev)
  980. {
  981. return 0;
  982. }
  983. static inline void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
  984. {
  985. }
  986. static inline void intel_fbdev_fini(struct drm_device *dev)
  987. {
  988. }
  989. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
  990. {
  991. }
  992. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  993. {
  994. }
  995. #endif
  996. /* intel_fbc.c */
  997. bool intel_fbc_enabled(struct drm_device *dev);
  998. void intel_fbc_update(struct drm_device *dev);
  999. void intel_fbc_init(struct drm_i915_private *dev_priv);
  1000. void intel_fbc_disable(struct drm_device *dev);
  1001. void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
  1002. unsigned int frontbuffer_bits,
  1003. enum fb_op_origin origin);
  1004. void intel_fbc_flush(struct drm_i915_private *dev_priv,
  1005. unsigned int frontbuffer_bits);
  1006. /* intel_hdmi.c */
  1007. void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port);
  1008. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  1009. struct intel_connector *intel_connector);
  1010. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  1011. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  1012. struct intel_crtc_state *pipe_config);
  1013. /* intel_lvds.c */
  1014. void intel_lvds_init(struct drm_device *dev);
  1015. bool intel_is_dual_link_lvds(struct drm_device *dev);
  1016. /* intel_modes.c */
  1017. int intel_connector_update_modes(struct drm_connector *connector,
  1018. struct edid *edid);
  1019. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  1020. void intel_attach_force_audio_property(struct drm_connector *connector);
  1021. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  1022. /* intel_overlay.c */
  1023. void intel_setup_overlay(struct drm_device *dev);
  1024. void intel_cleanup_overlay(struct drm_device *dev);
  1025. int intel_overlay_switch_off(struct intel_overlay *overlay);
  1026. int intel_overlay_put_image(struct drm_device *dev, void *data,
  1027. struct drm_file *file_priv);
  1028. int intel_overlay_attrs(struct drm_device *dev, void *data,
  1029. struct drm_file *file_priv);
  1030. void intel_overlay_reset(struct drm_i915_private *dev_priv);
  1031. /* intel_panel.c */
  1032. int intel_panel_init(struct intel_panel *panel,
  1033. struct drm_display_mode *fixed_mode,
  1034. struct drm_display_mode *downclock_mode);
  1035. void intel_panel_fini(struct intel_panel *panel);
  1036. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  1037. struct drm_display_mode *adjusted_mode);
  1038. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  1039. struct intel_crtc_state *pipe_config,
  1040. int fitting_mode);
  1041. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  1042. struct intel_crtc_state *pipe_config,
  1043. int fitting_mode);
  1044. void intel_panel_set_backlight_acpi(struct intel_connector *connector,
  1045. u32 level, u32 max);
  1046. int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe);
  1047. void intel_panel_enable_backlight(struct intel_connector *connector);
  1048. void intel_panel_disable_backlight(struct intel_connector *connector);
  1049. void intel_panel_destroy_backlight(struct drm_connector *connector);
  1050. void intel_panel_init_backlight_funcs(struct drm_device *dev);
  1051. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  1052. extern struct drm_display_mode *intel_find_panel_downclock(
  1053. struct drm_device *dev,
  1054. struct drm_display_mode *fixed_mode,
  1055. struct drm_connector *connector);
  1056. void intel_backlight_register(struct drm_device *dev);
  1057. void intel_backlight_unregister(struct drm_device *dev);
  1058. /* intel_psr.c */
  1059. void intel_psr_enable(struct intel_dp *intel_dp);
  1060. void intel_psr_disable(struct intel_dp *intel_dp);
  1061. void intel_psr_invalidate(struct drm_device *dev,
  1062. unsigned frontbuffer_bits);
  1063. void intel_psr_flush(struct drm_device *dev,
  1064. unsigned frontbuffer_bits);
  1065. void intel_psr_init(struct drm_device *dev);
  1066. /* intel_runtime_pm.c */
  1067. int intel_power_domains_init(struct drm_i915_private *);
  1068. void intel_power_domains_fini(struct drm_i915_private *);
  1069. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv);
  1070. void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
  1071. bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1072. enum intel_display_power_domain domain);
  1073. bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1074. enum intel_display_power_domain domain);
  1075. void intel_display_power_get(struct drm_i915_private *dev_priv,
  1076. enum intel_display_power_domain domain);
  1077. void intel_display_power_put(struct drm_i915_private *dev_priv,
  1078. enum intel_display_power_domain domain);
  1079. void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv);
  1080. void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
  1081. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  1082. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  1083. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  1084. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  1085. /* intel_pm.c */
  1086. void intel_init_clock_gating(struct drm_device *dev);
  1087. void intel_suspend_hw(struct drm_device *dev);
  1088. int ilk_wm_max_level(const struct drm_device *dev);
  1089. void intel_update_watermarks(struct drm_crtc *crtc);
  1090. void intel_update_sprite_watermarks(struct drm_plane *plane,
  1091. struct drm_crtc *crtc,
  1092. uint32_t sprite_width,
  1093. uint32_t sprite_height,
  1094. int pixel_size,
  1095. bool enabled, bool scaled);
  1096. void intel_init_pm(struct drm_device *dev);
  1097. void intel_pm_setup(struct drm_device *dev);
  1098. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  1099. void intel_gpu_ips_teardown(void);
  1100. void intel_init_gt_powersave(struct drm_device *dev);
  1101. void intel_cleanup_gt_powersave(struct drm_device *dev);
  1102. void intel_enable_gt_powersave(struct drm_device *dev);
  1103. void intel_disable_gt_powersave(struct drm_device *dev);
  1104. void intel_suspend_gt_powersave(struct drm_device *dev);
  1105. void intel_reset_gt_powersave(struct drm_device *dev);
  1106. void gen6_update_ring_freq(struct drm_device *dev);
  1107. void gen6_rps_busy(struct drm_i915_private *dev_priv);
  1108. void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
  1109. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  1110. void gen6_rps_boost(struct drm_i915_private *dev_priv);
  1111. void ilk_wm_get_hw_state(struct drm_device *dev);
  1112. void skl_wm_get_hw_state(struct drm_device *dev);
  1113. void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  1114. struct skl_ddb_allocation *ddb /* out */);
  1115. /* intel_sdvo.c */
  1116. bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
  1117. /* intel_sprite.c */
  1118. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  1119. void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
  1120. enum plane plane);
  1121. int intel_plane_restore(struct drm_plane *plane);
  1122. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  1123. struct drm_file *file_priv);
  1124. bool intel_pipe_update_start(struct intel_crtc *crtc,
  1125. uint32_t *start_vbl_count);
  1126. void intel_pipe_update_end(struct intel_crtc *crtc, u32 start_vbl_count);
  1127. void intel_post_enable_primary(struct drm_crtc *crtc);
  1128. void intel_pre_disable_primary(struct drm_crtc *crtc);
  1129. /* intel_tv.c */
  1130. void intel_tv_init(struct drm_device *dev);
  1131. /* intel_atomic.c */
  1132. int intel_atomic_check(struct drm_device *dev,
  1133. struct drm_atomic_state *state);
  1134. int intel_atomic_commit(struct drm_device *dev,
  1135. struct drm_atomic_state *state,
  1136. bool async);
  1137. int intel_connector_atomic_get_property(struct drm_connector *connector,
  1138. const struct drm_connector_state *state,
  1139. struct drm_property *property,
  1140. uint64_t *val);
  1141. struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
  1142. void intel_crtc_destroy_state(struct drm_crtc *crtc,
  1143. struct drm_crtc_state *state);
  1144. static inline struct intel_crtc_state *
  1145. intel_atomic_get_crtc_state(struct drm_atomic_state *state,
  1146. struct intel_crtc *crtc)
  1147. {
  1148. struct drm_crtc_state *crtc_state;
  1149. crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
  1150. if (IS_ERR(crtc_state))
  1151. return ERR_PTR(PTR_ERR(crtc_state));
  1152. return to_intel_crtc_state(crtc_state);
  1153. }
  1154. /* intel_atomic_plane.c */
  1155. struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
  1156. struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
  1157. void intel_plane_destroy_state(struct drm_plane *plane,
  1158. struct drm_plane_state *state);
  1159. extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
  1160. #endif /* __INTEL_DRV_H__ */