intel_drv.h 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451
  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_atomic_state {
  216. struct drm_atomic_state base;
  217. unsigned int cdclk;
  218. bool dpll_set;
  219. struct intel_shared_dpll_config shared_dpll[I915_NUM_PLLS];
  220. };
  221. struct intel_plane_state {
  222. struct drm_plane_state base;
  223. struct drm_rect src;
  224. struct drm_rect dst;
  225. struct drm_rect clip;
  226. bool visible;
  227. /*
  228. * scaler_id
  229. * = -1 : not using a scaler
  230. * >= 0 : using a scalers
  231. *
  232. * plane requiring a scaler:
  233. * - During check_plane, its bit is set in
  234. * crtc_state->scaler_state.scaler_users by calling helper function
  235. * update_scaler_plane.
  236. * - scaler_id indicates the scaler it got assigned.
  237. *
  238. * plane doesn't require a scaler:
  239. * - this can happen when scaling is no more required or plane simply
  240. * got disabled.
  241. * - During check_plane, corresponding bit is reset in
  242. * crtc_state->scaler_state.scaler_users by calling helper function
  243. * update_scaler_plane.
  244. */
  245. int scaler_id;
  246. struct drm_intel_sprite_colorkey ckey;
  247. };
  248. struct intel_initial_plane_config {
  249. struct intel_framebuffer *fb;
  250. unsigned int tiling;
  251. int size;
  252. u32 base;
  253. };
  254. #define SKL_MIN_SRC_W 8
  255. #define SKL_MAX_SRC_W 4096
  256. #define SKL_MIN_SRC_H 8
  257. #define SKL_MAX_SRC_H 4096
  258. #define SKL_MIN_DST_W 8
  259. #define SKL_MAX_DST_W 4096
  260. #define SKL_MIN_DST_H 8
  261. #define SKL_MAX_DST_H 4096
  262. struct intel_scaler {
  263. int in_use;
  264. uint32_t mode;
  265. };
  266. struct intel_crtc_scaler_state {
  267. #define SKL_NUM_SCALERS 2
  268. struct intel_scaler scalers[SKL_NUM_SCALERS];
  269. /*
  270. * scaler_users: keeps track of users requesting scalers on this crtc.
  271. *
  272. * If a bit is set, a user is using a scaler.
  273. * Here user can be a plane or crtc as defined below:
  274. * bits 0-30 - plane (bit position is index from drm_plane_index)
  275. * bit 31 - crtc
  276. *
  277. * Instead of creating a new index to cover planes and crtc, using
  278. * existing drm_plane_index for planes which is well less than 31
  279. * planes and bit 31 for crtc. This should be fine to cover all
  280. * our platforms.
  281. *
  282. * intel_atomic_setup_scalers will setup available scalers to users
  283. * requesting scalers. It will gracefully fail if request exceeds
  284. * avilability.
  285. */
  286. #define SKL_CRTC_INDEX 31
  287. unsigned scaler_users;
  288. /* scaler used by crtc for panel fitting purpose */
  289. int scaler_id;
  290. };
  291. struct intel_crtc_state {
  292. struct drm_crtc_state base;
  293. /**
  294. * quirks - bitfield with hw state readout quirks
  295. *
  296. * For various reasons the hw state readout code might not be able to
  297. * completely faithfully read out the current state. These cases are
  298. * tracked with quirk flags so that fastboot and state checker can act
  299. * accordingly.
  300. */
  301. #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
  302. #define PIPE_CONFIG_QUIRK_INHERITED_MODE (1<<1) /* mode inherited from firmware */
  303. #define PIPE_CONFIG_QUIRK_INITIAL_PLANES (1<<2) /* planes are in unknown state */
  304. unsigned long quirks;
  305. /* Pipe source size (ie. panel fitter input size)
  306. * All planes will be positioned inside this space,
  307. * and get clipped at the edges. */
  308. int pipe_src_w, pipe_src_h;
  309. /* Whether to set up the PCH/FDI. Note that we never allow sharing
  310. * between pch encoders and cpu encoders. */
  311. bool has_pch_encoder;
  312. /* Are we sending infoframes on the attached port */
  313. bool has_infoframe;
  314. /* CPU Transcoder for the pipe. Currently this can only differ from the
  315. * pipe on Haswell (where we have a special eDP transcoder). */
  316. enum transcoder cpu_transcoder;
  317. /*
  318. * Use reduced/limited/broadcast rbg range, compressing from the full
  319. * range fed into the crtcs.
  320. */
  321. bool limited_color_range;
  322. /* DP has a bunch of special case unfortunately, so mark the pipe
  323. * accordingly. */
  324. bool has_dp_encoder;
  325. /* Whether we should send NULL infoframes. Required for audio. */
  326. bool has_hdmi_sink;
  327. /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
  328. * has_dp_encoder is set. */
  329. bool has_audio;
  330. /*
  331. * Enable dithering, used when the selected pipe bpp doesn't match the
  332. * plane bpp.
  333. */
  334. bool dither;
  335. /* Controls for the clock computation, to override various stages. */
  336. bool clock_set;
  337. /* SDVO TV has a bunch of special case. To make multifunction encoders
  338. * work correctly, we need to track this at runtime.*/
  339. bool sdvo_tv_clock;
  340. /*
  341. * crtc bandwidth limit, don't increase pipe bpp or clock if not really
  342. * required. This is set in the 2nd loop of calling encoder's
  343. * ->compute_config if the first pick doesn't work out.
  344. */
  345. bool bw_constrained;
  346. /* Settings for the intel dpll used on pretty much everything but
  347. * haswell. */
  348. struct dpll dpll;
  349. /* Selected dpll when shared or DPLL_ID_PRIVATE. */
  350. enum intel_dpll_id shared_dpll;
  351. /*
  352. * - PORT_CLK_SEL for DDI ports on HSW/BDW.
  353. * - enum skl_dpll on SKL
  354. */
  355. uint32_t ddi_pll_sel;
  356. /* Actual register state of the dpll, for shared dpll cross-checking. */
  357. struct intel_dpll_hw_state dpll_hw_state;
  358. int pipe_bpp;
  359. struct intel_link_m_n dp_m_n;
  360. /* m2_n2 for eDP downclock */
  361. struct intel_link_m_n dp_m2_n2;
  362. bool has_drrs;
  363. /*
  364. * Frequence the dpll for the port should run at. Differs from the
  365. * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
  366. * already multiplied by pixel_multiplier.
  367. */
  368. int port_clock;
  369. /* Used by SDVO (and if we ever fix it, HDMI). */
  370. unsigned pixel_multiplier;
  371. /* Panel fitter controls for gen2-gen4 + VLV */
  372. struct {
  373. u32 control;
  374. u32 pgm_ratios;
  375. u32 lvds_border_bits;
  376. } gmch_pfit;
  377. /* Panel fitter placement and size for Ironlake+ */
  378. struct {
  379. u32 pos;
  380. u32 size;
  381. bool enabled;
  382. bool force_thru;
  383. } pch_pfit;
  384. /* FDI configuration, only valid if has_pch_encoder is set. */
  385. int fdi_lanes;
  386. struct intel_link_m_n fdi_m_n;
  387. bool ips_enabled;
  388. bool double_wide;
  389. bool dp_encoder_is_mst;
  390. int pbn;
  391. struct intel_crtc_scaler_state scaler_state;
  392. /* w/a for waiting 2 vblanks during crtc enable */
  393. enum pipe hsw_workaround_pipe;
  394. };
  395. struct vlv_wm_state {
  396. struct vlv_pipe_wm wm[3];
  397. struct vlv_sr_wm sr[3];
  398. uint8_t num_active_planes;
  399. uint8_t num_levels;
  400. uint8_t level;
  401. bool cxsr;
  402. };
  403. struct intel_pipe_wm {
  404. struct intel_wm_level wm[5];
  405. uint32_t linetime;
  406. bool fbc_wm_enabled;
  407. bool pipe_enabled;
  408. bool sprites_enabled;
  409. bool sprites_scaled;
  410. };
  411. struct intel_mmio_flip {
  412. struct work_struct work;
  413. struct drm_i915_private *i915;
  414. struct drm_i915_gem_request *req;
  415. struct intel_crtc *crtc;
  416. };
  417. struct skl_pipe_wm {
  418. struct skl_wm_level wm[8];
  419. struct skl_wm_level trans_wm;
  420. uint32_t linetime;
  421. };
  422. /*
  423. * Tracking of operations that need to be performed at the beginning/end of an
  424. * atomic commit, outside the atomic section where interrupts are disabled.
  425. * These are generally operations that grab mutexes or might otherwise sleep
  426. * and thus can't be run with interrupts disabled.
  427. */
  428. struct intel_crtc_atomic_commit {
  429. /* vblank evasion */
  430. bool evade;
  431. unsigned start_vbl_count;
  432. /* Sleepable operations to perform before commit */
  433. bool wait_for_flips;
  434. bool disable_fbc;
  435. bool disable_ips;
  436. bool disable_cxsr;
  437. bool pre_disable_primary;
  438. bool update_wm_pre, update_wm_post;
  439. unsigned disabled_planes;
  440. /* Sleepable operations to perform after commit */
  441. unsigned fb_bits;
  442. bool wait_vblank;
  443. bool update_fbc;
  444. bool post_enable_primary;
  445. unsigned update_sprite_watermarks;
  446. };
  447. struct intel_crtc {
  448. struct drm_crtc base;
  449. enum pipe pipe;
  450. enum plane plane;
  451. u8 lut_r[256], lut_g[256], lut_b[256];
  452. /*
  453. * Whether the crtc and the connected output pipeline is active. Implies
  454. * that crtc->enabled is set, i.e. the current mode configuration has
  455. * some outputs connected to this crtc.
  456. */
  457. bool active;
  458. unsigned long enabled_power_domains;
  459. bool lowfreq_avail;
  460. struct intel_overlay *overlay;
  461. struct intel_unpin_work *unpin_work;
  462. atomic_t unpin_work_count;
  463. /* Display surface base address adjustement for pageflips. Note that on
  464. * gen4+ this only adjusts up to a tile, offsets within a tile are
  465. * handled in the hw itself (with the TILEOFF register). */
  466. unsigned long dspaddr_offset;
  467. struct drm_i915_gem_object *cursor_bo;
  468. uint32_t cursor_addr;
  469. uint32_t cursor_cntl;
  470. uint32_t cursor_size;
  471. uint32_t cursor_base;
  472. struct intel_initial_plane_config plane_config;
  473. struct intel_crtc_state *config;
  474. bool new_enabled;
  475. /* reset counter value when the last flip was submitted */
  476. unsigned int reset_counter;
  477. /* Access to these should be protected by dev_priv->irq_lock. */
  478. bool cpu_fifo_underrun_disabled;
  479. bool pch_fifo_underrun_disabled;
  480. /* per-pipe watermark state */
  481. struct {
  482. /* watermarks currently being used */
  483. struct intel_pipe_wm active;
  484. /* SKL wm values currently in use */
  485. struct skl_pipe_wm skl_active;
  486. /* allow CxSR on this pipe */
  487. bool cxsr_allowed;
  488. } wm;
  489. int scanline_offset;
  490. struct intel_crtc_atomic_commit atomic;
  491. /* scalers available on this crtc */
  492. int num_scalers;
  493. struct vlv_wm_state wm_state;
  494. };
  495. struct intel_plane_wm_parameters {
  496. uint32_t horiz_pixels;
  497. uint32_t vert_pixels;
  498. /*
  499. * For packed pixel formats:
  500. * bytes_per_pixel - holds bytes per pixel
  501. * For planar pixel formats:
  502. * bytes_per_pixel - holds bytes per pixel for uv-plane
  503. * y_bytes_per_pixel - holds bytes per pixel for y-plane
  504. */
  505. uint8_t bytes_per_pixel;
  506. uint8_t y_bytes_per_pixel;
  507. bool enabled;
  508. bool scaled;
  509. u64 tiling;
  510. unsigned int rotation;
  511. uint16_t fifo_size;
  512. };
  513. struct intel_plane {
  514. struct drm_plane base;
  515. int plane;
  516. enum pipe pipe;
  517. bool can_scale;
  518. int max_downscale;
  519. uint32_t frontbuffer_bit;
  520. /* Since we need to change the watermarks before/after
  521. * enabling/disabling the planes, we need to store the parameters here
  522. * as the other pieces of the struct may not reflect the values we want
  523. * for the watermark calculations. Currently only Haswell uses this.
  524. */
  525. struct intel_plane_wm_parameters wm;
  526. /*
  527. * NOTE: Do not place new plane state fields here (e.g., when adding
  528. * new plane properties). New runtime state should now be placed in
  529. * the intel_plane_state structure and accessed via drm_plane->state.
  530. */
  531. void (*update_plane)(struct drm_plane *plane,
  532. struct drm_crtc *crtc,
  533. struct drm_framebuffer *fb,
  534. int crtc_x, int crtc_y,
  535. unsigned int crtc_w, unsigned int crtc_h,
  536. uint32_t x, uint32_t y,
  537. uint32_t src_w, uint32_t src_h);
  538. void (*disable_plane)(struct drm_plane *plane,
  539. struct drm_crtc *crtc);
  540. int (*check_plane)(struct drm_plane *plane,
  541. struct intel_crtc_state *crtc_state,
  542. struct intel_plane_state *state);
  543. void (*commit_plane)(struct drm_plane *plane,
  544. struct intel_plane_state *state);
  545. };
  546. struct intel_watermark_params {
  547. unsigned long fifo_size;
  548. unsigned long max_wm;
  549. unsigned long default_wm;
  550. unsigned long guard_size;
  551. unsigned long cacheline_size;
  552. };
  553. struct cxsr_latency {
  554. int is_desktop;
  555. int is_ddr3;
  556. unsigned long fsb_freq;
  557. unsigned long mem_freq;
  558. unsigned long display_sr;
  559. unsigned long display_hpll_disable;
  560. unsigned long cursor_sr;
  561. unsigned long cursor_hpll_disable;
  562. };
  563. #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
  564. #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
  565. #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
  566. #define to_intel_connector(x) container_of(x, struct intel_connector, base)
  567. #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
  568. #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
  569. #define to_intel_plane(x) container_of(x, struct intel_plane, base)
  570. #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
  571. #define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL)
  572. struct intel_hdmi {
  573. u32 hdmi_reg;
  574. int ddc_bus;
  575. uint32_t color_range;
  576. bool color_range_auto;
  577. bool has_hdmi_sink;
  578. bool has_audio;
  579. enum hdmi_force_audio force_audio;
  580. bool rgb_quant_range_selectable;
  581. enum hdmi_picture_aspect aspect_ratio;
  582. void (*write_infoframe)(struct drm_encoder *encoder,
  583. enum hdmi_infoframe_type type,
  584. const void *frame, ssize_t len);
  585. void (*set_infoframes)(struct drm_encoder *encoder,
  586. bool enable,
  587. struct drm_display_mode *adjusted_mode);
  588. bool (*infoframe_enabled)(struct drm_encoder *encoder);
  589. };
  590. struct intel_dp_mst_encoder;
  591. #define DP_MAX_DOWNSTREAM_PORTS 0x10
  592. /*
  593. * enum link_m_n_set:
  594. * When platform provides two set of M_N registers for dp, we can
  595. * program them and switch between them incase of DRRS.
  596. * But When only one such register is provided, we have to program the
  597. * required divider value on that registers itself based on the DRRS state.
  598. *
  599. * M1_N1 : Program dp_m_n on M1_N1 registers
  600. * dp_m2_n2 on M2_N2 registers (If supported)
  601. *
  602. * M2_N2 : Program dp_m2_n2 on M1_N1 registers
  603. * M2_N2 registers are not supported
  604. */
  605. enum link_m_n_set {
  606. /* Sets the m1_n1 and m2_n2 */
  607. M1_N1 = 0,
  608. M2_N2
  609. };
  610. struct intel_dp {
  611. uint32_t output_reg;
  612. uint32_t aux_ch_ctl_reg;
  613. uint32_t DP;
  614. bool has_audio;
  615. enum hdmi_force_audio force_audio;
  616. uint32_t color_range;
  617. bool color_range_auto;
  618. uint8_t link_bw;
  619. uint8_t rate_select;
  620. uint8_t lane_count;
  621. uint8_t dpcd[DP_RECEIVER_CAP_SIZE];
  622. uint8_t psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
  623. uint8_t downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
  624. /* sink rates as reported by DP_SUPPORTED_LINK_RATES */
  625. uint8_t num_sink_rates;
  626. int sink_rates[DP_MAX_SUPPORTED_RATES];
  627. struct drm_dp_aux aux;
  628. uint8_t train_set[4];
  629. int panel_power_up_delay;
  630. int panel_power_down_delay;
  631. int panel_power_cycle_delay;
  632. int backlight_on_delay;
  633. int backlight_off_delay;
  634. struct delayed_work panel_vdd_work;
  635. bool want_panel_vdd;
  636. unsigned long last_power_cycle;
  637. unsigned long last_power_on;
  638. unsigned long last_backlight_off;
  639. struct notifier_block edp_notifier;
  640. /*
  641. * Pipe whose power sequencer is currently locked into
  642. * this port. Only relevant on VLV/CHV.
  643. */
  644. enum pipe pps_pipe;
  645. struct edp_power_seq pps_delays;
  646. bool use_tps3;
  647. bool can_mst; /* this port supports mst */
  648. bool is_mst;
  649. int active_mst_links;
  650. /* connector directly attached - won't be use for modeset in mst world */
  651. struct intel_connector *attached_connector;
  652. /* mst connector list */
  653. struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
  654. struct drm_dp_mst_topology_mgr mst_mgr;
  655. uint32_t (*get_aux_clock_divider)(struct intel_dp *dp, int index);
  656. /*
  657. * This function returns the value we have to program the AUX_CTL
  658. * register with to kick off an AUX transaction.
  659. */
  660. uint32_t (*get_aux_send_ctl)(struct intel_dp *dp,
  661. bool has_aux_irq,
  662. int send_bytes,
  663. uint32_t aux_clock_divider);
  664. bool train_set_valid;
  665. /* Displayport compliance testing */
  666. unsigned long compliance_test_type;
  667. unsigned long compliance_test_data;
  668. bool compliance_test_active;
  669. };
  670. struct intel_digital_port {
  671. struct intel_encoder base;
  672. enum port port;
  673. u32 saved_port_bits;
  674. struct intel_dp dp;
  675. struct intel_hdmi hdmi;
  676. enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
  677. };
  678. struct intel_dp_mst_encoder {
  679. struct intel_encoder base;
  680. enum pipe pipe;
  681. struct intel_digital_port *primary;
  682. void *port; /* store this opaque as its illegal to dereference it */
  683. };
  684. static inline int
  685. vlv_dport_to_channel(struct intel_digital_port *dport)
  686. {
  687. switch (dport->port) {
  688. case PORT_B:
  689. case PORT_D:
  690. return DPIO_CH0;
  691. case PORT_C:
  692. return DPIO_CH1;
  693. default:
  694. BUG();
  695. }
  696. }
  697. static inline int
  698. vlv_pipe_to_channel(enum pipe pipe)
  699. {
  700. switch (pipe) {
  701. case PIPE_A:
  702. case PIPE_C:
  703. return DPIO_CH0;
  704. case PIPE_B:
  705. return DPIO_CH1;
  706. default:
  707. BUG();
  708. }
  709. }
  710. static inline struct drm_crtc *
  711. intel_get_crtc_for_pipe(struct drm_device *dev, int pipe)
  712. {
  713. struct drm_i915_private *dev_priv = dev->dev_private;
  714. return dev_priv->pipe_to_crtc_mapping[pipe];
  715. }
  716. static inline struct drm_crtc *
  717. intel_get_crtc_for_plane(struct drm_device *dev, int plane)
  718. {
  719. struct drm_i915_private *dev_priv = dev->dev_private;
  720. return dev_priv->plane_to_crtc_mapping[plane];
  721. }
  722. struct intel_unpin_work {
  723. struct work_struct work;
  724. struct drm_crtc *crtc;
  725. struct drm_framebuffer *old_fb;
  726. struct drm_i915_gem_object *pending_flip_obj;
  727. struct drm_pending_vblank_event *event;
  728. atomic_t pending;
  729. #define INTEL_FLIP_INACTIVE 0
  730. #define INTEL_FLIP_PENDING 1
  731. #define INTEL_FLIP_COMPLETE 2
  732. u32 flip_count;
  733. u32 gtt_offset;
  734. struct drm_i915_gem_request *flip_queued_req;
  735. int flip_queued_vblank;
  736. int flip_ready_vblank;
  737. bool enable_stall_check;
  738. };
  739. struct intel_load_detect_pipe {
  740. struct drm_framebuffer *release_fb;
  741. bool load_detect_temp;
  742. int dpms_mode;
  743. };
  744. static inline struct intel_encoder *
  745. intel_attached_encoder(struct drm_connector *connector)
  746. {
  747. return to_intel_connector(connector)->encoder;
  748. }
  749. static inline struct intel_digital_port *
  750. enc_to_dig_port(struct drm_encoder *encoder)
  751. {
  752. return container_of(encoder, struct intel_digital_port, base.base);
  753. }
  754. static inline struct intel_dp_mst_encoder *
  755. enc_to_mst(struct drm_encoder *encoder)
  756. {
  757. return container_of(encoder, struct intel_dp_mst_encoder, base.base);
  758. }
  759. static inline struct intel_dp *enc_to_intel_dp(struct drm_encoder *encoder)
  760. {
  761. return &enc_to_dig_port(encoder)->dp;
  762. }
  763. static inline struct intel_digital_port *
  764. dp_to_dig_port(struct intel_dp *intel_dp)
  765. {
  766. return container_of(intel_dp, struct intel_digital_port, dp);
  767. }
  768. static inline struct intel_digital_port *
  769. hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
  770. {
  771. return container_of(intel_hdmi, struct intel_digital_port, hdmi);
  772. }
  773. /*
  774. * Returns the number of planes for this pipe, ie the number of sprites + 1
  775. * (primary plane). This doesn't count the cursor plane then.
  776. */
  777. static inline unsigned int intel_num_planes(struct intel_crtc *crtc)
  778. {
  779. return INTEL_INFO(crtc->base.dev)->num_sprites[crtc->pipe] + 1;
  780. }
  781. /* intel_fifo_underrun.c */
  782. bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  783. enum pipe pipe, bool enable);
  784. bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private *dev_priv,
  785. enum transcoder pch_transcoder,
  786. bool enable);
  787. void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  788. enum pipe pipe);
  789. void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private *dev_priv,
  790. enum transcoder pch_transcoder);
  791. void i9xx_check_fifo_underruns(struct drm_i915_private *dev_priv);
  792. /* i915_irq.c */
  793. void gen5_enable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  794. void gen5_disable_gt_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  795. void gen6_enable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  796. void gen6_disable_pm_irq(struct drm_i915_private *dev_priv, uint32_t mask);
  797. void gen6_reset_rps_interrupts(struct drm_device *dev);
  798. void gen6_enable_rps_interrupts(struct drm_device *dev);
  799. void gen6_disable_rps_interrupts(struct drm_device *dev);
  800. u32 gen6_sanitize_rps_pm_mask(struct drm_i915_private *dev_priv, u32 mask);
  801. void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv);
  802. void intel_runtime_pm_enable_interrupts(struct drm_i915_private *dev_priv);
  803. static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
  804. {
  805. /*
  806. * We only use drm_irq_uninstall() at unload and VT switch, so
  807. * this is the only thing we need to check.
  808. */
  809. return dev_priv->pm.irqs_enabled;
  810. }
  811. int intel_get_crtc_scanline(struct intel_crtc *crtc);
  812. void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
  813. unsigned int pipe_mask);
  814. /* intel_crt.c */
  815. void intel_crt_init(struct drm_device *dev);
  816. /* intel_ddi.c */
  817. void intel_prepare_ddi(struct drm_device *dev);
  818. void hsw_fdi_link_train(struct drm_crtc *crtc);
  819. void intel_ddi_init(struct drm_device *dev, enum port port);
  820. enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
  821. bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
  822. void intel_ddi_pll_init(struct drm_device *dev);
  823. void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
  824. void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
  825. enum transcoder cpu_transcoder);
  826. void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc);
  827. void intel_ddi_disable_pipe_clock(struct intel_crtc *intel_crtc);
  828. bool intel_ddi_pll_select(struct intel_crtc *crtc,
  829. struct intel_crtc_state *crtc_state);
  830. void intel_ddi_set_pipe_settings(struct drm_crtc *crtc);
  831. void intel_ddi_prepare_link_retrain(struct drm_encoder *encoder);
  832. bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector);
  833. void intel_ddi_fdi_disable(struct drm_crtc *crtc);
  834. void intel_ddi_get_config(struct intel_encoder *encoder,
  835. struct intel_crtc_state *pipe_config);
  836. struct intel_encoder *
  837. intel_ddi_get_crtc_new_encoder(struct intel_crtc_state *crtc_state);
  838. void intel_ddi_init_dp_buf_reg(struct intel_encoder *encoder);
  839. void intel_ddi_clock_get(struct intel_encoder *encoder,
  840. struct intel_crtc_state *pipe_config);
  841. void intel_ddi_set_vc_payload_alloc(struct drm_crtc *crtc, bool state);
  842. uint32_t ddi_signal_levels(struct intel_dp *intel_dp);
  843. /* intel_frontbuffer.c */
  844. void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj,
  845. enum fb_op_origin origin);
  846. void intel_frontbuffer_flip_prepare(struct drm_device *dev,
  847. unsigned frontbuffer_bits);
  848. void intel_frontbuffer_flip_complete(struct drm_device *dev,
  849. unsigned frontbuffer_bits);
  850. void intel_frontbuffer_flush(struct drm_device *dev,
  851. unsigned frontbuffer_bits);
  852. void intel_frontbuffer_flip(struct drm_device *dev,
  853. unsigned frontbuffer_bits);
  854. unsigned int intel_fb_align_height(struct drm_device *dev,
  855. unsigned int height,
  856. uint32_t pixel_format,
  857. uint64_t fb_format_modifier);
  858. void intel_fb_obj_flush(struct drm_i915_gem_object *obj, bool retire);
  859. u32 intel_fb_stride_alignment(struct drm_device *dev, uint64_t fb_modifier,
  860. uint32_t pixel_format);
  861. /* intel_audio.c */
  862. void intel_init_audio(struct drm_device *dev);
  863. void intel_audio_codec_enable(struct intel_encoder *encoder);
  864. void intel_audio_codec_disable(struct intel_encoder *encoder);
  865. void i915_audio_component_init(struct drm_i915_private *dev_priv);
  866. void i915_audio_component_cleanup(struct drm_i915_private *dev_priv);
  867. /* intel_display.c */
  868. extern const struct drm_plane_funcs intel_plane_funcs;
  869. bool intel_has_pending_fb_unpin(struct drm_device *dev);
  870. int intel_pch_rawclk(struct drm_device *dev);
  871. void intel_mark_busy(struct drm_device *dev);
  872. void intel_mark_idle(struct drm_device *dev);
  873. void intel_crtc_restore_mode(struct drm_crtc *crtc);
  874. void intel_display_suspend(struct drm_device *dev);
  875. int intel_crtc_control(struct drm_crtc *crtc, bool enable);
  876. void intel_crtc_update_dpms(struct drm_crtc *crtc);
  877. void intel_encoder_destroy(struct drm_encoder *encoder);
  878. int intel_connector_init(struct intel_connector *);
  879. struct intel_connector *intel_connector_alloc(void);
  880. void intel_connector_dpms(struct drm_connector *, int mode);
  881. bool intel_connector_get_hw_state(struct intel_connector *connector);
  882. void intel_modeset_check_state(struct drm_device *dev);
  883. bool ibx_digital_port_connected(struct drm_i915_private *dev_priv,
  884. struct intel_digital_port *port);
  885. void intel_connector_attach_encoder(struct intel_connector *connector,
  886. struct intel_encoder *encoder);
  887. struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
  888. struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
  889. struct drm_crtc *crtc);
  890. enum pipe intel_get_pipe_from_connector(struct intel_connector *connector);
  891. int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
  892. struct drm_file *file_priv);
  893. enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
  894. enum pipe pipe);
  895. bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type);
  896. static inline void
  897. intel_wait_for_vblank(struct drm_device *dev, int pipe)
  898. {
  899. drm_wait_one_vblank(dev, pipe);
  900. }
  901. int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp);
  902. void vlv_wait_port_ready(struct drm_i915_private *dev_priv,
  903. struct intel_digital_port *dport,
  904. unsigned int expected_mask);
  905. bool intel_get_load_detect_pipe(struct drm_connector *connector,
  906. struct drm_display_mode *mode,
  907. struct intel_load_detect_pipe *old,
  908. struct drm_modeset_acquire_ctx *ctx);
  909. void intel_release_load_detect_pipe(struct drm_connector *connector,
  910. struct intel_load_detect_pipe *old,
  911. struct drm_modeset_acquire_ctx *ctx);
  912. int intel_pin_and_fence_fb_obj(struct drm_plane *plane,
  913. struct drm_framebuffer *fb,
  914. const struct drm_plane_state *plane_state,
  915. struct intel_engine_cs *pipelined,
  916. struct drm_i915_gem_request **pipelined_request);
  917. struct drm_framebuffer *
  918. __intel_framebuffer_create(struct drm_device *dev,
  919. struct drm_mode_fb_cmd2 *mode_cmd,
  920. struct drm_i915_gem_object *obj);
  921. void intel_prepare_page_flip(struct drm_device *dev, int plane);
  922. void intel_finish_page_flip(struct drm_device *dev, int pipe);
  923. void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
  924. void intel_check_page_flip(struct drm_device *dev, int pipe);
  925. int intel_prepare_plane_fb(struct drm_plane *plane,
  926. struct drm_framebuffer *fb,
  927. const struct drm_plane_state *new_state);
  928. void intel_cleanup_plane_fb(struct drm_plane *plane,
  929. struct drm_framebuffer *fb,
  930. const struct drm_plane_state *old_state);
  931. int intel_plane_atomic_get_property(struct drm_plane *plane,
  932. const struct drm_plane_state *state,
  933. struct drm_property *property,
  934. uint64_t *val);
  935. int intel_plane_atomic_set_property(struct drm_plane *plane,
  936. struct drm_plane_state *state,
  937. struct drm_property *property,
  938. uint64_t val);
  939. int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
  940. struct drm_plane_state *plane_state);
  941. unsigned int
  942. intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
  943. uint64_t fb_format_modifier);
  944. static inline bool
  945. intel_rotation_90_or_270(unsigned int rotation)
  946. {
  947. return rotation & (BIT(DRM_ROTATE_90) | BIT(DRM_ROTATE_270));
  948. }
  949. void intel_create_rotation_property(struct drm_device *dev,
  950. struct intel_plane *plane);
  951. /* shared dpll functions */
  952. struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
  953. void assert_shared_dpll(struct drm_i915_private *dev_priv,
  954. struct intel_shared_dpll *pll,
  955. bool state);
  956. #define assert_shared_dpll_enabled(d, p) assert_shared_dpll(d, p, true)
  957. #define assert_shared_dpll_disabled(d, p) assert_shared_dpll(d, p, false)
  958. struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc,
  959. struct intel_crtc_state *state);
  960. void vlv_force_pll_on(struct drm_device *dev, enum pipe pipe,
  961. const struct dpll *dpll);
  962. void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe);
  963. /* modesetting asserts */
  964. void assert_panel_unlocked(struct drm_i915_private *dev_priv,
  965. enum pipe pipe);
  966. void assert_pll(struct drm_i915_private *dev_priv,
  967. enum pipe pipe, bool state);
  968. #define assert_pll_enabled(d, p) assert_pll(d, p, true)
  969. #define assert_pll_disabled(d, p) assert_pll(d, p, false)
  970. void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
  971. enum pipe pipe, bool state);
  972. #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
  973. #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
  974. void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
  975. #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
  976. #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
  977. unsigned long intel_gen4_compute_page_offset(struct drm_i915_private *dev_priv,
  978. int *x, int *y,
  979. unsigned int tiling_mode,
  980. unsigned int bpp,
  981. unsigned int pitch);
  982. void intel_prepare_reset(struct drm_device *dev);
  983. void intel_finish_reset(struct drm_device *dev);
  984. void hsw_enable_pc8(struct drm_i915_private *dev_priv);
  985. void hsw_disable_pc8(struct drm_i915_private *dev_priv);
  986. void broxton_init_cdclk(struct drm_device *dev);
  987. void broxton_uninit_cdclk(struct drm_device *dev);
  988. void broxton_ddi_phy_init(struct drm_device *dev);
  989. void broxton_ddi_phy_uninit(struct drm_device *dev);
  990. void bxt_enable_dc9(struct drm_i915_private *dev_priv);
  991. void bxt_disable_dc9(struct drm_i915_private *dev_priv);
  992. void skl_init_cdclk(struct drm_i915_private *dev_priv);
  993. void skl_uninit_cdclk(struct drm_i915_private *dev_priv);
  994. void intel_dp_get_m_n(struct intel_crtc *crtc,
  995. struct intel_crtc_state *pipe_config);
  996. void intel_dp_set_m_n(struct intel_crtc *crtc, enum link_m_n_set m_n);
  997. int intel_dotclock_calculate(int link_freq, const struct intel_link_m_n *m_n);
  998. void
  999. ironlake_check_encoder_dotclock(const struct intel_crtc_state *pipe_config,
  1000. int dotclock);
  1001. bool bxt_find_best_dpll(struct intel_crtc_state *crtc_state, int target_clock,
  1002. intel_clock_t *best_clock);
  1003. int chv_calc_dpll_params(int refclk, intel_clock_t *pll_clock);
  1004. bool intel_crtc_active(struct drm_crtc *crtc);
  1005. void hsw_enable_ips(struct intel_crtc *crtc);
  1006. void hsw_disable_ips(struct intel_crtc *crtc);
  1007. enum intel_display_power_domain
  1008. intel_display_port_power_domain(struct intel_encoder *intel_encoder);
  1009. void intel_mode_from_pipe_config(struct drm_display_mode *mode,
  1010. struct intel_crtc_state *pipe_config);
  1011. void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
  1012. void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
  1013. int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state, int force_detach);
  1014. int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
  1015. unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
  1016. struct drm_i915_gem_object *obj);
  1017. u32 skl_plane_ctl_format(uint32_t pixel_format);
  1018. u32 skl_plane_ctl_tiling(uint64_t fb_modifier);
  1019. u32 skl_plane_ctl_rotation(unsigned int rotation);
  1020. /* intel_csr.c */
  1021. void intel_csr_ucode_init(struct drm_device *dev);
  1022. enum csr_state intel_csr_load_status_get(struct drm_i915_private *dev_priv);
  1023. void intel_csr_load_status_set(struct drm_i915_private *dev_priv,
  1024. enum csr_state state);
  1025. void intel_csr_load_program(struct drm_device *dev);
  1026. void intel_csr_ucode_fini(struct drm_device *dev);
  1027. void assert_csr_loaded(struct drm_i915_private *dev_priv);
  1028. /* intel_dp.c */
  1029. void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
  1030. bool intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
  1031. struct intel_connector *intel_connector);
  1032. void intel_dp_start_link_train(struct intel_dp *intel_dp);
  1033. void intel_dp_complete_link_train(struct intel_dp *intel_dp);
  1034. void intel_dp_stop_link_train(struct intel_dp *intel_dp);
  1035. void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
  1036. void intel_dp_encoder_destroy(struct drm_encoder *encoder);
  1037. int intel_dp_sink_crc(struct intel_dp *intel_dp, u8 *crc);
  1038. bool intel_dp_compute_config(struct intel_encoder *encoder,
  1039. struct intel_crtc_state *pipe_config);
  1040. bool intel_dp_is_edp(struct drm_device *dev, enum port port);
  1041. enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port,
  1042. bool long_hpd);
  1043. void intel_edp_backlight_on(struct intel_dp *intel_dp);
  1044. void intel_edp_backlight_off(struct intel_dp *intel_dp);
  1045. void intel_edp_panel_vdd_on(struct intel_dp *intel_dp);
  1046. void intel_edp_panel_on(struct intel_dp *intel_dp);
  1047. void intel_edp_panel_off(struct intel_dp *intel_dp);
  1048. void intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connector);
  1049. void intel_dp_mst_suspend(struct drm_device *dev);
  1050. void intel_dp_mst_resume(struct drm_device *dev);
  1051. int intel_dp_max_link_rate(struct intel_dp *intel_dp);
  1052. int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
  1053. void intel_dp_hot_plug(struct intel_encoder *intel_encoder);
  1054. void vlv_power_sequencer_reset(struct drm_i915_private *dev_priv);
  1055. uint32_t intel_dp_pack_aux(const uint8_t *src, int src_bytes);
  1056. void intel_plane_destroy(struct drm_plane *plane);
  1057. void intel_edp_drrs_enable(struct intel_dp *intel_dp);
  1058. void intel_edp_drrs_disable(struct intel_dp *intel_dp);
  1059. void intel_edp_drrs_invalidate(struct drm_device *dev,
  1060. unsigned frontbuffer_bits);
  1061. void intel_edp_drrs_flush(struct drm_device *dev, unsigned frontbuffer_bits);
  1062. /* intel_dp_mst.c */
  1063. int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_id);
  1064. void intel_dp_mst_encoder_cleanup(struct intel_digital_port *intel_dig_port);
  1065. /* intel_dsi.c */
  1066. void intel_dsi_init(struct drm_device *dev);
  1067. /* intel_dvo.c */
  1068. void intel_dvo_init(struct drm_device *dev);
  1069. /* legacy fbdev emulation in intel_fbdev.c */
  1070. #ifdef CONFIG_DRM_I915_FBDEV
  1071. extern int intel_fbdev_init(struct drm_device *dev);
  1072. extern void intel_fbdev_initial_config(void *data, async_cookie_t cookie);
  1073. extern void intel_fbdev_fini(struct drm_device *dev);
  1074. extern void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous);
  1075. extern void intel_fbdev_output_poll_changed(struct drm_device *dev);
  1076. extern void intel_fbdev_restore_mode(struct drm_device *dev);
  1077. #else
  1078. static inline int intel_fbdev_init(struct drm_device *dev)
  1079. {
  1080. return 0;
  1081. }
  1082. static inline void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
  1083. {
  1084. }
  1085. static inline void intel_fbdev_fini(struct drm_device *dev)
  1086. {
  1087. }
  1088. static inline void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
  1089. {
  1090. }
  1091. static inline void intel_fbdev_restore_mode(struct drm_device *dev)
  1092. {
  1093. }
  1094. #endif
  1095. /* intel_fbc.c */
  1096. bool intel_fbc_enabled(struct drm_i915_private *dev_priv);
  1097. void intel_fbc_update(struct drm_i915_private *dev_priv);
  1098. void intel_fbc_init(struct drm_i915_private *dev_priv);
  1099. void intel_fbc_disable(struct drm_i915_private *dev_priv);
  1100. void intel_fbc_disable_crtc(struct intel_crtc *crtc);
  1101. void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
  1102. unsigned int frontbuffer_bits,
  1103. enum fb_op_origin origin);
  1104. void intel_fbc_flush(struct drm_i915_private *dev_priv,
  1105. unsigned int frontbuffer_bits);
  1106. const char *intel_no_fbc_reason_str(enum no_fbc_reason reason);
  1107. void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv);
  1108. /* intel_hdmi.c */
  1109. void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port);
  1110. void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
  1111. struct intel_connector *intel_connector);
  1112. struct intel_hdmi *enc_to_intel_hdmi(struct drm_encoder *encoder);
  1113. bool intel_hdmi_compute_config(struct intel_encoder *encoder,
  1114. struct intel_crtc_state *pipe_config);
  1115. /* intel_lvds.c */
  1116. void intel_lvds_init(struct drm_device *dev);
  1117. bool intel_is_dual_link_lvds(struct drm_device *dev);
  1118. /* intel_modes.c */
  1119. int intel_connector_update_modes(struct drm_connector *connector,
  1120. struct edid *edid);
  1121. int intel_ddc_get_modes(struct drm_connector *c, struct i2c_adapter *adapter);
  1122. void intel_attach_force_audio_property(struct drm_connector *connector);
  1123. void intel_attach_broadcast_rgb_property(struct drm_connector *connector);
  1124. /* intel_overlay.c */
  1125. void intel_setup_overlay(struct drm_device *dev);
  1126. void intel_cleanup_overlay(struct drm_device *dev);
  1127. int intel_overlay_switch_off(struct intel_overlay *overlay);
  1128. int intel_overlay_put_image(struct drm_device *dev, void *data,
  1129. struct drm_file *file_priv);
  1130. int intel_overlay_attrs(struct drm_device *dev, void *data,
  1131. struct drm_file *file_priv);
  1132. void intel_overlay_reset(struct drm_i915_private *dev_priv);
  1133. /* intel_panel.c */
  1134. int intel_panel_init(struct intel_panel *panel,
  1135. struct drm_display_mode *fixed_mode,
  1136. struct drm_display_mode *downclock_mode);
  1137. void intel_panel_fini(struct intel_panel *panel);
  1138. void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
  1139. struct drm_display_mode *adjusted_mode);
  1140. void intel_pch_panel_fitting(struct intel_crtc *crtc,
  1141. struct intel_crtc_state *pipe_config,
  1142. int fitting_mode);
  1143. void intel_gmch_panel_fitting(struct intel_crtc *crtc,
  1144. struct intel_crtc_state *pipe_config,
  1145. int fitting_mode);
  1146. void intel_panel_set_backlight_acpi(struct intel_connector *connector,
  1147. u32 level, u32 max);
  1148. int intel_panel_setup_backlight(struct drm_connector *connector, enum pipe pipe);
  1149. void intel_panel_enable_backlight(struct intel_connector *connector);
  1150. void intel_panel_disable_backlight(struct intel_connector *connector);
  1151. void intel_panel_destroy_backlight(struct drm_connector *connector);
  1152. void intel_panel_init_backlight_funcs(struct drm_device *dev);
  1153. enum drm_connector_status intel_panel_detect(struct drm_device *dev);
  1154. extern struct drm_display_mode *intel_find_panel_downclock(
  1155. struct drm_device *dev,
  1156. struct drm_display_mode *fixed_mode,
  1157. struct drm_connector *connector);
  1158. void intel_backlight_register(struct drm_device *dev);
  1159. void intel_backlight_unregister(struct drm_device *dev);
  1160. /* intel_psr.c */
  1161. void intel_psr_enable(struct intel_dp *intel_dp);
  1162. void intel_psr_disable(struct intel_dp *intel_dp);
  1163. void intel_psr_invalidate(struct drm_device *dev,
  1164. unsigned frontbuffer_bits);
  1165. void intel_psr_flush(struct drm_device *dev,
  1166. unsigned frontbuffer_bits);
  1167. void intel_psr_init(struct drm_device *dev);
  1168. void intel_psr_single_frame_update(struct drm_device *dev,
  1169. unsigned frontbuffer_bits);
  1170. /* intel_runtime_pm.c */
  1171. int intel_power_domains_init(struct drm_i915_private *);
  1172. void intel_power_domains_fini(struct drm_i915_private *);
  1173. void intel_power_domains_init_hw(struct drm_i915_private *dev_priv);
  1174. void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
  1175. bool intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1176. enum intel_display_power_domain domain);
  1177. bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
  1178. enum intel_display_power_domain domain);
  1179. void intel_display_power_get(struct drm_i915_private *dev_priv,
  1180. enum intel_display_power_domain domain);
  1181. void intel_display_power_put(struct drm_i915_private *dev_priv,
  1182. enum intel_display_power_domain domain);
  1183. void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv);
  1184. void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
  1185. void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
  1186. void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
  1187. void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
  1188. void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
  1189. /* intel_pm.c */
  1190. void intel_init_clock_gating(struct drm_device *dev);
  1191. void intel_suspend_hw(struct drm_device *dev);
  1192. int ilk_wm_max_level(const struct drm_device *dev);
  1193. void intel_update_watermarks(struct drm_crtc *crtc);
  1194. void intel_update_sprite_watermarks(struct drm_plane *plane,
  1195. struct drm_crtc *crtc,
  1196. uint32_t sprite_width,
  1197. uint32_t sprite_height,
  1198. int pixel_size,
  1199. bool enabled, bool scaled);
  1200. void intel_init_pm(struct drm_device *dev);
  1201. void intel_pm_setup(struct drm_device *dev);
  1202. void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
  1203. void intel_gpu_ips_teardown(void);
  1204. void intel_init_gt_powersave(struct drm_device *dev);
  1205. void intel_cleanup_gt_powersave(struct drm_device *dev);
  1206. void intel_enable_gt_powersave(struct drm_device *dev);
  1207. void intel_disable_gt_powersave(struct drm_device *dev);
  1208. void intel_suspend_gt_powersave(struct drm_device *dev);
  1209. void intel_reset_gt_powersave(struct drm_device *dev);
  1210. void gen6_update_ring_freq(struct drm_device *dev);
  1211. void gen6_rps_busy(struct drm_i915_private *dev_priv);
  1212. void gen6_rps_reset_ei(struct drm_i915_private *dev_priv);
  1213. void gen6_rps_idle(struct drm_i915_private *dev_priv);
  1214. void gen6_rps_boost(struct drm_i915_private *dev_priv,
  1215. struct intel_rps_client *rps,
  1216. unsigned long submitted);
  1217. void intel_queue_rps_boost_for_request(struct drm_device *dev,
  1218. struct drm_i915_gem_request *req);
  1219. void vlv_wm_get_hw_state(struct drm_device *dev);
  1220. void ilk_wm_get_hw_state(struct drm_device *dev);
  1221. void skl_wm_get_hw_state(struct drm_device *dev);
  1222. void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
  1223. struct skl_ddb_allocation *ddb /* out */);
  1224. uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config);
  1225. /* intel_sdvo.c */
  1226. bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
  1227. /* intel_sprite.c */
  1228. int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
  1229. int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
  1230. struct drm_file *file_priv);
  1231. bool intel_pipe_update_start(struct intel_crtc *crtc,
  1232. uint32_t *start_vbl_count);
  1233. void intel_pipe_update_end(struct intel_crtc *crtc, u32 start_vbl_count);
  1234. /* intel_tv.c */
  1235. void intel_tv_init(struct drm_device *dev);
  1236. /* intel_atomic.c */
  1237. int intel_atomic_check(struct drm_device *dev,
  1238. struct drm_atomic_state *state);
  1239. int intel_atomic_commit(struct drm_device *dev,
  1240. struct drm_atomic_state *state,
  1241. bool async);
  1242. int intel_connector_atomic_get_property(struct drm_connector *connector,
  1243. const struct drm_connector_state *state,
  1244. struct drm_property *property,
  1245. uint64_t *val);
  1246. struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
  1247. void intel_crtc_destroy_state(struct drm_crtc *crtc,
  1248. struct drm_crtc_state *state);
  1249. struct drm_atomic_state *intel_atomic_state_alloc(struct drm_device *dev);
  1250. void intel_atomic_state_clear(struct drm_atomic_state *);
  1251. struct intel_shared_dpll_config *
  1252. intel_atomic_get_shared_dpll_state(struct drm_atomic_state *s);
  1253. static inline struct intel_crtc_state *
  1254. intel_atomic_get_crtc_state(struct drm_atomic_state *state,
  1255. struct intel_crtc *crtc)
  1256. {
  1257. struct drm_crtc_state *crtc_state;
  1258. crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
  1259. if (IS_ERR(crtc_state))
  1260. return ERR_CAST(crtc_state);
  1261. return to_intel_crtc_state(crtc_state);
  1262. }
  1263. int intel_atomic_setup_scalers(struct drm_device *dev,
  1264. struct intel_crtc *intel_crtc,
  1265. struct intel_crtc_state *crtc_state);
  1266. /* intel_atomic_plane.c */
  1267. struct intel_plane_state *intel_create_plane_state(struct drm_plane *plane);
  1268. struct drm_plane_state *intel_plane_duplicate_state(struct drm_plane *plane);
  1269. void intel_plane_destroy_state(struct drm_plane *plane,
  1270. struct drm_plane_state *state);
  1271. extern const struct drm_plane_helper_funcs intel_plane_helper_funcs;
  1272. #endif /* __INTEL_DRV_H__ */