intel_drv.h 49 KB

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