display.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. /*
  2. * Copyright(c) 2011-2016 Intel Corporation. All rights reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Authors:
  24. * Ke Yu
  25. * Zhiyuan Lv <[email protected]>
  26. *
  27. * Contributors:
  28. * Terrence Xu <[email protected]>
  29. * Changbin Du <[email protected]>
  30. * Bing Niu <[email protected]>
  31. * Zhi Wang <[email protected]>
  32. *
  33. */
  34. #include "i915_drv.h"
  35. #include "i915_reg.h"
  36. #include "gvt.h"
  37. static int get_edp_pipe(struct intel_vgpu *vgpu)
  38. {
  39. u32 data = vgpu_vreg(vgpu, _TRANS_DDI_FUNC_CTL_EDP);
  40. int pipe = -1;
  41. switch (data & TRANS_DDI_EDP_INPUT_MASK) {
  42. case TRANS_DDI_EDP_INPUT_A_ON:
  43. case TRANS_DDI_EDP_INPUT_A_ONOFF:
  44. pipe = PIPE_A;
  45. break;
  46. case TRANS_DDI_EDP_INPUT_B_ONOFF:
  47. pipe = PIPE_B;
  48. break;
  49. case TRANS_DDI_EDP_INPUT_C_ONOFF:
  50. pipe = PIPE_C;
  51. break;
  52. }
  53. return pipe;
  54. }
  55. static int edp_pipe_is_enabled(struct intel_vgpu *vgpu)
  56. {
  57. struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
  58. if (!(vgpu_vreg_t(vgpu, PIPECONF(_PIPE_EDP)) & PIPECONF_ENABLE))
  59. return 0;
  60. if (!(vgpu_vreg(vgpu, _TRANS_DDI_FUNC_CTL_EDP) & TRANS_DDI_FUNC_ENABLE))
  61. return 0;
  62. return 1;
  63. }
  64. int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe)
  65. {
  66. struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
  67. if (drm_WARN_ON(&dev_priv->drm,
  68. pipe < PIPE_A || pipe >= I915_MAX_PIPES))
  69. return -EINVAL;
  70. if (vgpu_vreg_t(vgpu, PIPECONF(pipe)) & PIPECONF_ENABLE)
  71. return 1;
  72. if (edp_pipe_is_enabled(vgpu) &&
  73. get_edp_pipe(vgpu) == pipe)
  74. return 1;
  75. return 0;
  76. }
  77. static unsigned char virtual_dp_monitor_edid[GVT_EDID_NUM][EDID_SIZE] = {
  78. {
  79. /* EDID with 1024x768 as its resolution */
  80. /*Header*/
  81. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
  82. /* Vendor & Product Identification */
  83. 0x22, 0xf0, 0x54, 0x29, 0x00, 0x00, 0x00, 0x00, 0x04, 0x17,
  84. /* Version & Revision */
  85. 0x01, 0x04,
  86. /* Basic Display Parameters & Features */
  87. 0xa5, 0x34, 0x20, 0x78, 0x23,
  88. /* Color Characteristics */
  89. 0xfc, 0x81, 0xa4, 0x55, 0x4d, 0x9d, 0x25, 0x12, 0x50, 0x54,
  90. /* Established Timings: maximum resolution is 1024x768 */
  91. 0x21, 0x08, 0x00,
  92. /* Standard Timings. All invalid */
  93. 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x40, 0x00, 0x80, 0x00, 0x00,
  94. 0x00, 0x40, 0x00, 0x00, 0x00, 0x01,
  95. /* 18 Byte Data Blocks 1: invalid */
  96. 0x00, 0x00, 0x80, 0xa0, 0x70, 0xb0,
  97. 0x23, 0x40, 0x30, 0x20, 0x36, 0x00, 0x06, 0x44, 0x21, 0x00, 0x00, 0x1a,
  98. /* 18 Byte Data Blocks 2: invalid */
  99. 0x00, 0x00, 0x00, 0xfd, 0x00, 0x18, 0x3c, 0x18, 0x50, 0x11, 0x00, 0x0a,
  100. 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  101. /* 18 Byte Data Blocks 3: invalid */
  102. 0x00, 0x00, 0x00, 0xfc, 0x00, 0x48,
  103. 0x50, 0x20, 0x5a, 0x52, 0x32, 0x34, 0x34, 0x30, 0x77, 0x0a, 0x20, 0x20,
  104. /* 18 Byte Data Blocks 4: invalid */
  105. 0x00, 0x00, 0x00, 0xff, 0x00, 0x43, 0x4e, 0x34, 0x33, 0x30, 0x34, 0x30,
  106. 0x44, 0x58, 0x51, 0x0a, 0x20, 0x20,
  107. /* Extension Block Count */
  108. 0x00,
  109. /* Checksum */
  110. 0xef,
  111. },
  112. {
  113. /* EDID with 1920x1200 as its resolution */
  114. /*Header*/
  115. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
  116. /* Vendor & Product Identification */
  117. 0x22, 0xf0, 0x54, 0x29, 0x00, 0x00, 0x00, 0x00, 0x04, 0x17,
  118. /* Version & Revision */
  119. 0x01, 0x04,
  120. /* Basic Display Parameters & Features */
  121. 0xa5, 0x34, 0x20, 0x78, 0x23,
  122. /* Color Characteristics */
  123. 0xfc, 0x81, 0xa4, 0x55, 0x4d, 0x9d, 0x25, 0x12, 0x50, 0x54,
  124. /* Established Timings: maximum resolution is 1024x768 */
  125. 0x21, 0x08, 0x00,
  126. /*
  127. * Standard Timings.
  128. * below new resolutions can be supported:
  129. * 1920x1080, 1280x720, 1280x960, 1280x1024,
  130. * 1440x900, 1600x1200, 1680x1050
  131. */
  132. 0xd1, 0xc0, 0x81, 0xc0, 0x81, 0x40, 0x81, 0x80, 0x95, 0x00,
  133. 0xa9, 0x40, 0xb3, 0x00, 0x01, 0x01,
  134. /* 18 Byte Data Blocks 1: max resolution is 1920x1200 */
  135. 0x28, 0x3c, 0x80, 0xa0, 0x70, 0xb0,
  136. 0x23, 0x40, 0x30, 0x20, 0x36, 0x00, 0x06, 0x44, 0x21, 0x00, 0x00, 0x1a,
  137. /* 18 Byte Data Blocks 2: invalid */
  138. 0x00, 0x00, 0x00, 0xfd, 0x00, 0x18, 0x3c, 0x18, 0x50, 0x11, 0x00, 0x0a,
  139. 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  140. /* 18 Byte Data Blocks 3: invalid */
  141. 0x00, 0x00, 0x00, 0xfc, 0x00, 0x48,
  142. 0x50, 0x20, 0x5a, 0x52, 0x32, 0x34, 0x34, 0x30, 0x77, 0x0a, 0x20, 0x20,
  143. /* 18 Byte Data Blocks 4: invalid */
  144. 0x00, 0x00, 0x00, 0xff, 0x00, 0x43, 0x4e, 0x34, 0x33, 0x30, 0x34, 0x30,
  145. 0x44, 0x58, 0x51, 0x0a, 0x20, 0x20,
  146. /* Extension Block Count */
  147. 0x00,
  148. /* Checksum */
  149. 0x45,
  150. },
  151. };
  152. #define DPCD_HEADER_SIZE 0xb
  153. /* let the virtual display supports DP1.2 */
  154. static u8 dpcd_fix_data[DPCD_HEADER_SIZE] = {
  155. 0x12, 0x014, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  156. };
  157. static void emulate_monitor_status_change(struct intel_vgpu *vgpu)
  158. {
  159. struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
  160. int pipe;
  161. if (IS_BROXTON(dev_priv)) {
  162. enum transcoder trans;
  163. enum port port;
  164. /* Clear PIPE, DDI, PHY, HPD before setting new */
  165. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
  166. ~(GEN8_DE_PORT_HOTPLUG(HPD_PORT_A) |
  167. GEN8_DE_PORT_HOTPLUG(HPD_PORT_B) |
  168. GEN8_DE_PORT_HOTPLUG(HPD_PORT_C));
  169. for_each_pipe(dev_priv, pipe) {
  170. vgpu_vreg_t(vgpu, PIPECONF(pipe)) &=
  171. ~(PIPECONF_ENABLE | PIPECONF_STATE_ENABLE);
  172. vgpu_vreg_t(vgpu, DSPCNTR(pipe)) &= ~DISP_ENABLE;
  173. vgpu_vreg_t(vgpu, SPRCTL(pipe)) &= ~SPRITE_ENABLE;
  174. vgpu_vreg_t(vgpu, CURCNTR(pipe)) &= ~MCURSOR_MODE_MASK;
  175. vgpu_vreg_t(vgpu, CURCNTR(pipe)) |= MCURSOR_MODE_DISABLE;
  176. }
  177. for (trans = TRANSCODER_A; trans <= TRANSCODER_EDP; trans++) {
  178. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(trans)) &=
  179. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  180. TRANS_DDI_PORT_MASK | TRANS_DDI_FUNC_ENABLE);
  181. }
  182. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
  183. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  184. TRANS_DDI_PORT_MASK);
  185. for (port = PORT_A; port <= PORT_C; port++) {
  186. vgpu_vreg_t(vgpu, BXT_PHY_CTL(port)) &=
  187. ~BXT_PHY_LANE_ENABLED;
  188. vgpu_vreg_t(vgpu, BXT_PHY_CTL(port)) |=
  189. (BXT_PHY_CMNLANE_POWERDOWN_ACK |
  190. BXT_PHY_LANE_POWERDOWN_ACK);
  191. vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(port)) &=
  192. ~(PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE |
  193. PORT_PLL_REF_SEL | PORT_PLL_LOCK |
  194. PORT_PLL_ENABLE);
  195. vgpu_vreg_t(vgpu, DDI_BUF_CTL(port)) &=
  196. ~(DDI_INIT_DISPLAY_DETECTED |
  197. DDI_BUF_CTL_ENABLE);
  198. vgpu_vreg_t(vgpu, DDI_BUF_CTL(port)) |= DDI_BUF_IS_IDLE;
  199. }
  200. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
  201. ~(PORTA_HOTPLUG_ENABLE | PORTA_HOTPLUG_STATUS_MASK);
  202. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
  203. ~(PORTB_HOTPLUG_ENABLE | PORTB_HOTPLUG_STATUS_MASK);
  204. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
  205. ~(PORTC_HOTPLUG_ENABLE | PORTC_HOTPLUG_STATUS_MASK);
  206. /* No hpd_invert set in vgpu vbt, need to clear invert mask */
  207. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= ~BXT_DDI_HPD_INVERT_MASK;
  208. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &= ~BXT_DE_PORT_HOTPLUG_MASK;
  209. vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) &= ~(BIT(0) | BIT(1));
  210. vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) &=
  211. ~PHY_POWER_GOOD;
  212. vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY1)) &=
  213. ~PHY_POWER_GOOD;
  214. vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY0)) &= ~BIT(30);
  215. vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY1)) &= ~BIT(30);
  216. vgpu_vreg_t(vgpu, SFUSE_STRAP) &= ~SFUSE_STRAP_DDIB_DETECTED;
  217. vgpu_vreg_t(vgpu, SFUSE_STRAP) &= ~SFUSE_STRAP_DDIC_DETECTED;
  218. /*
  219. * Only 1 PIPE enabled in current vGPU display and PIPE_A is
  220. * tied to TRANSCODER_A in HW, so it's safe to assume PIPE_A,
  221. * TRANSCODER_A can be enabled. PORT_x depends on the input of
  222. * setup_virtual_dp_monitor.
  223. */
  224. vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= PIPECONF_ENABLE;
  225. vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= PIPECONF_STATE_ENABLE;
  226. /*
  227. * Golden M/N are calculated based on:
  228. * 24 bpp, 4 lanes, 154000 pixel clk (from virtual EDID),
  229. * DP link clk 1620 MHz and non-constant_n.
  230. * TODO: calculate DP link symbol clk and stream clk m/n.
  231. */
  232. vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) = TU_SIZE(64);
  233. vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) |= 0x5b425e;
  234. vgpu_vreg_t(vgpu, PIPE_DATA_N1(TRANSCODER_A)) = 0x800000;
  235. vgpu_vreg_t(vgpu, PIPE_LINK_M1(TRANSCODER_A)) = 0x3cd6e;
  236. vgpu_vreg_t(vgpu, PIPE_LINK_N1(TRANSCODER_A)) = 0x80000;
  237. /* Enable per-DDI/PORT vreg */
  238. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) {
  239. vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) |= BIT(1);
  240. vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY1)) |=
  241. PHY_POWER_GOOD;
  242. vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY1)) |=
  243. BIT(30);
  244. vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_A)) |=
  245. BXT_PHY_LANE_ENABLED;
  246. vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_A)) &=
  247. ~(BXT_PHY_CMNLANE_POWERDOWN_ACK |
  248. BXT_PHY_LANE_POWERDOWN_ACK);
  249. vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(PORT_A)) |=
  250. (PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE |
  251. PORT_PLL_REF_SEL | PORT_PLL_LOCK |
  252. PORT_PLL_ENABLE);
  253. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_A)) |=
  254. (DDI_BUF_CTL_ENABLE | DDI_INIT_DISPLAY_DETECTED);
  255. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_A)) &=
  256. ~DDI_BUF_IS_IDLE;
  257. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_EDP)) |=
  258. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  259. TRANS_DDI_FUNC_ENABLE);
  260. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
  261. PORTA_HOTPLUG_ENABLE;
  262. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  263. GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
  264. }
  265. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
  266. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIB_DETECTED;
  267. vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) |= BIT(0);
  268. vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) |=
  269. PHY_POWER_GOOD;
  270. vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY0)) |=
  271. BIT(30);
  272. vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_B)) |=
  273. BXT_PHY_LANE_ENABLED;
  274. vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_B)) &=
  275. ~(BXT_PHY_CMNLANE_POWERDOWN_ACK |
  276. BXT_PHY_LANE_POWERDOWN_ACK);
  277. vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(PORT_B)) |=
  278. (PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE |
  279. PORT_PLL_REF_SEL | PORT_PLL_LOCK |
  280. PORT_PLL_ENABLE);
  281. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) |=
  282. DDI_BUF_CTL_ENABLE;
  283. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) &=
  284. ~DDI_BUF_IS_IDLE;
  285. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  286. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  287. (PORT_B << TRANS_DDI_PORT_SHIFT) |
  288. TRANS_DDI_FUNC_ENABLE);
  289. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
  290. PORTB_HOTPLUG_ENABLE;
  291. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  292. GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
  293. }
  294. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
  295. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIC_DETECTED;
  296. vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) |= BIT(0);
  297. vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) |=
  298. PHY_POWER_GOOD;
  299. vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY0)) |=
  300. BIT(30);
  301. vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_C)) |=
  302. BXT_PHY_LANE_ENABLED;
  303. vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_C)) &=
  304. ~(BXT_PHY_CMNLANE_POWERDOWN_ACK |
  305. BXT_PHY_LANE_POWERDOWN_ACK);
  306. vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(PORT_C)) |=
  307. (PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE |
  308. PORT_PLL_REF_SEL | PORT_PLL_LOCK |
  309. PORT_PLL_ENABLE);
  310. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) |=
  311. DDI_BUF_CTL_ENABLE;
  312. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) &=
  313. ~DDI_BUF_IS_IDLE;
  314. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  315. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  316. (PORT_B << TRANS_DDI_PORT_SHIFT) |
  317. TRANS_DDI_FUNC_ENABLE);
  318. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
  319. PORTC_HOTPLUG_ENABLE;
  320. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  321. GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
  322. }
  323. return;
  324. }
  325. vgpu_vreg_t(vgpu, SDEISR) &= ~(SDE_PORTB_HOTPLUG_CPT |
  326. SDE_PORTC_HOTPLUG_CPT |
  327. SDE_PORTD_HOTPLUG_CPT);
  328. if (IS_SKYLAKE(dev_priv) ||
  329. IS_KABYLAKE(dev_priv) ||
  330. IS_COFFEELAKE(dev_priv) ||
  331. IS_COMETLAKE(dev_priv)) {
  332. vgpu_vreg_t(vgpu, SDEISR) &= ~(SDE_PORTA_HOTPLUG_SPT |
  333. SDE_PORTE_HOTPLUG_SPT);
  334. vgpu_vreg_t(vgpu, SKL_FUSE_STATUS) |=
  335. SKL_FUSE_DOWNLOAD_STATUS |
  336. SKL_FUSE_PG_DIST_STATUS(SKL_PG0) |
  337. SKL_FUSE_PG_DIST_STATUS(SKL_PG1) |
  338. SKL_FUSE_PG_DIST_STATUS(SKL_PG2);
  339. /*
  340. * Only 1 PIPE enabled in current vGPU display and PIPE_A is
  341. * tied to TRANSCODER_A in HW, so it's safe to assume PIPE_A,
  342. * TRANSCODER_A can be enabled. PORT_x depends on the input of
  343. * setup_virtual_dp_monitor, we can bind DPLL0 to any PORT_x
  344. * so we fixed to DPLL0 here.
  345. * Setup DPLL0: DP link clk 1620 MHz, non SSC, DP Mode
  346. */
  347. vgpu_vreg_t(vgpu, DPLL_CTRL1) =
  348. DPLL_CTRL1_OVERRIDE(DPLL_ID_SKL_DPLL0);
  349. vgpu_vreg_t(vgpu, DPLL_CTRL1) |=
  350. DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_1620, DPLL_ID_SKL_DPLL0);
  351. vgpu_vreg_t(vgpu, LCPLL1_CTL) =
  352. LCPLL_PLL_ENABLE | LCPLL_PLL_LOCK;
  353. vgpu_vreg_t(vgpu, DPLL_STATUS) = DPLL_LOCK(DPLL_ID_SKL_DPLL0);
  354. /*
  355. * Golden M/N are calculated based on:
  356. * 24 bpp, 4 lanes, 154000 pixel clk (from virtual EDID),
  357. * DP link clk 1620 MHz and non-constant_n.
  358. * TODO: calculate DP link symbol clk and stream clk m/n.
  359. */
  360. vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) = TU_SIZE(64);
  361. vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) |= 0x5b425e;
  362. vgpu_vreg_t(vgpu, PIPE_DATA_N1(TRANSCODER_A)) = 0x800000;
  363. vgpu_vreg_t(vgpu, PIPE_LINK_M1(TRANSCODER_A)) = 0x3cd6e;
  364. vgpu_vreg_t(vgpu, PIPE_LINK_N1(TRANSCODER_A)) = 0x80000;
  365. }
  366. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
  367. vgpu_vreg_t(vgpu, DPLL_CTRL2) &=
  368. ~DPLL_CTRL2_DDI_CLK_OFF(PORT_B);
  369. vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
  370. DPLL_CTRL2_DDI_CLK_SEL(DPLL_ID_SKL_DPLL0, PORT_B);
  371. vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
  372. DPLL_CTRL2_DDI_SEL_OVERRIDE(PORT_B);
  373. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIB_DETECTED;
  374. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
  375. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  376. TRANS_DDI_PORT_MASK);
  377. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  378. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  379. (PORT_B << TRANS_DDI_PORT_SHIFT) |
  380. TRANS_DDI_FUNC_ENABLE);
  381. if (IS_BROADWELL(dev_priv)) {
  382. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_B)) &=
  383. ~PORT_CLK_SEL_MASK;
  384. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_B)) |=
  385. PORT_CLK_SEL_LCPLL_810;
  386. }
  387. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) |= DDI_BUF_CTL_ENABLE;
  388. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) &= ~DDI_BUF_IS_IDLE;
  389. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTB_HOTPLUG_CPT;
  390. }
  391. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
  392. vgpu_vreg_t(vgpu, DPLL_CTRL2) &=
  393. ~DPLL_CTRL2_DDI_CLK_OFF(PORT_C);
  394. vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
  395. DPLL_CTRL2_DDI_CLK_SEL(DPLL_ID_SKL_DPLL0, PORT_C);
  396. vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
  397. DPLL_CTRL2_DDI_SEL_OVERRIDE(PORT_C);
  398. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTC_HOTPLUG_CPT;
  399. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
  400. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  401. TRANS_DDI_PORT_MASK);
  402. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  403. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  404. (PORT_C << TRANS_DDI_PORT_SHIFT) |
  405. TRANS_DDI_FUNC_ENABLE);
  406. if (IS_BROADWELL(dev_priv)) {
  407. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_C)) &=
  408. ~PORT_CLK_SEL_MASK;
  409. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_C)) |=
  410. PORT_CLK_SEL_LCPLL_810;
  411. }
  412. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) |= DDI_BUF_CTL_ENABLE;
  413. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) &= ~DDI_BUF_IS_IDLE;
  414. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIC_DETECTED;
  415. }
  416. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_D)) {
  417. vgpu_vreg_t(vgpu, DPLL_CTRL2) &=
  418. ~DPLL_CTRL2_DDI_CLK_OFF(PORT_D);
  419. vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
  420. DPLL_CTRL2_DDI_CLK_SEL(DPLL_ID_SKL_DPLL0, PORT_D);
  421. vgpu_vreg_t(vgpu, DPLL_CTRL2) |=
  422. DPLL_CTRL2_DDI_SEL_OVERRIDE(PORT_D);
  423. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTD_HOTPLUG_CPT;
  424. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
  425. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  426. TRANS_DDI_PORT_MASK);
  427. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  428. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  429. (PORT_D << TRANS_DDI_PORT_SHIFT) |
  430. TRANS_DDI_FUNC_ENABLE);
  431. if (IS_BROADWELL(dev_priv)) {
  432. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_D)) &=
  433. ~PORT_CLK_SEL_MASK;
  434. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_D)) |=
  435. PORT_CLK_SEL_LCPLL_810;
  436. }
  437. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_D)) |= DDI_BUF_CTL_ENABLE;
  438. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_D)) &= ~DDI_BUF_IS_IDLE;
  439. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDID_DETECTED;
  440. }
  441. if ((IS_SKYLAKE(dev_priv) ||
  442. IS_KABYLAKE(dev_priv) ||
  443. IS_COFFEELAKE(dev_priv) ||
  444. IS_COMETLAKE(dev_priv)) &&
  445. intel_vgpu_has_monitor_on_port(vgpu, PORT_E)) {
  446. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTE_HOTPLUG_SPT;
  447. }
  448. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) {
  449. if (IS_BROADWELL(dev_priv))
  450. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  451. GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
  452. else
  453. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTA_HOTPLUG_SPT;
  454. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_A)) |= DDI_INIT_DISPLAY_DETECTED;
  455. }
  456. /* Clear host CRT status, so guest couldn't detect this host CRT. */
  457. if (IS_BROADWELL(dev_priv))
  458. vgpu_vreg_t(vgpu, PCH_ADPA) &= ~ADPA_CRT_HOTPLUG_MONITOR_MASK;
  459. /* Disable Primary/Sprite/Cursor plane */
  460. for_each_pipe(dev_priv, pipe) {
  461. vgpu_vreg_t(vgpu, DSPCNTR(pipe)) &= ~DISP_ENABLE;
  462. vgpu_vreg_t(vgpu, SPRCTL(pipe)) &= ~SPRITE_ENABLE;
  463. vgpu_vreg_t(vgpu, CURCNTR(pipe)) &= ~MCURSOR_MODE_MASK;
  464. vgpu_vreg_t(vgpu, CURCNTR(pipe)) |= MCURSOR_MODE_DISABLE;
  465. }
  466. vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= PIPECONF_ENABLE;
  467. }
  468. static void clean_virtual_dp_monitor(struct intel_vgpu *vgpu, int port_num)
  469. {
  470. struct intel_vgpu_port *port = intel_vgpu_port(vgpu, port_num);
  471. kfree(port->edid);
  472. port->edid = NULL;
  473. kfree(port->dpcd);
  474. port->dpcd = NULL;
  475. }
  476. static enum hrtimer_restart vblank_timer_fn(struct hrtimer *data)
  477. {
  478. struct intel_vgpu_vblank_timer *vblank_timer;
  479. struct intel_vgpu *vgpu;
  480. vblank_timer = container_of(data, struct intel_vgpu_vblank_timer, timer);
  481. vgpu = container_of(vblank_timer, struct intel_vgpu, vblank_timer);
  482. /* Set vblank emulation request per-vGPU bit */
  483. intel_gvt_request_service(vgpu->gvt,
  484. INTEL_GVT_REQUEST_EMULATE_VBLANK + vgpu->id);
  485. hrtimer_add_expires_ns(&vblank_timer->timer, vblank_timer->period);
  486. return HRTIMER_RESTART;
  487. }
  488. static int setup_virtual_dp_monitor(struct intel_vgpu *vgpu, int port_num,
  489. int type, unsigned int resolution)
  490. {
  491. struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
  492. struct intel_vgpu_port *port = intel_vgpu_port(vgpu, port_num);
  493. struct intel_vgpu_vblank_timer *vblank_timer = &vgpu->vblank_timer;
  494. if (drm_WARN_ON(&i915->drm, resolution >= GVT_EDID_NUM))
  495. return -EINVAL;
  496. port->edid = kzalloc(sizeof(*(port->edid)), GFP_KERNEL);
  497. if (!port->edid)
  498. return -ENOMEM;
  499. port->dpcd = kzalloc(sizeof(*(port->dpcd)), GFP_KERNEL);
  500. if (!port->dpcd) {
  501. kfree(port->edid);
  502. return -ENOMEM;
  503. }
  504. memcpy(port->edid->edid_block, virtual_dp_monitor_edid[resolution],
  505. EDID_SIZE);
  506. port->edid->data_valid = true;
  507. memcpy(port->dpcd->data, dpcd_fix_data, DPCD_HEADER_SIZE);
  508. port->dpcd->data_valid = true;
  509. port->dpcd->data[DPCD_SINK_COUNT] = 0x1;
  510. port->type = type;
  511. port->id = resolution;
  512. port->vrefresh_k = GVT_DEFAULT_REFRESH_RATE * MSEC_PER_SEC;
  513. vgpu->display.port_num = port_num;
  514. /* Init hrtimer based on default refresh rate */
  515. hrtimer_init(&vblank_timer->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
  516. vblank_timer->timer.function = vblank_timer_fn;
  517. vblank_timer->vrefresh_k = port->vrefresh_k;
  518. vblank_timer->period = DIV64_U64_ROUND_CLOSEST(NSEC_PER_SEC * MSEC_PER_SEC, vblank_timer->vrefresh_k);
  519. emulate_monitor_status_change(vgpu);
  520. return 0;
  521. }
  522. /**
  523. * vgpu_update_vblank_emulation - Update per-vGPU vblank_timer
  524. * @vgpu: vGPU operated
  525. * @turnon: Turn ON/OFF vblank_timer
  526. *
  527. * This function is used to turn on/off or update the per-vGPU vblank_timer
  528. * when PIPECONF is enabled or disabled. vblank_timer period is also updated
  529. * if guest changed the refresh rate.
  530. *
  531. */
  532. void vgpu_update_vblank_emulation(struct intel_vgpu *vgpu, bool turnon)
  533. {
  534. struct intel_vgpu_vblank_timer *vblank_timer = &vgpu->vblank_timer;
  535. struct intel_vgpu_port *port =
  536. intel_vgpu_port(vgpu, vgpu->display.port_num);
  537. if (turnon) {
  538. /*
  539. * Skip the re-enable if already active and vrefresh unchanged.
  540. * Otherwise, stop timer if already active and restart with new
  541. * period.
  542. */
  543. if (vblank_timer->vrefresh_k != port->vrefresh_k ||
  544. !hrtimer_active(&vblank_timer->timer)) {
  545. /* Stop timer before start with new period if active */
  546. if (hrtimer_active(&vblank_timer->timer))
  547. hrtimer_cancel(&vblank_timer->timer);
  548. /* Make sure new refresh rate updated to timer period */
  549. vblank_timer->vrefresh_k = port->vrefresh_k;
  550. vblank_timer->period = DIV64_U64_ROUND_CLOSEST(NSEC_PER_SEC * MSEC_PER_SEC, vblank_timer->vrefresh_k);
  551. hrtimer_start(&vblank_timer->timer,
  552. ktime_add_ns(ktime_get(), vblank_timer->period),
  553. HRTIMER_MODE_ABS);
  554. }
  555. } else {
  556. /* Caller request to stop vblank */
  557. hrtimer_cancel(&vblank_timer->timer);
  558. }
  559. }
  560. static void emulate_vblank_on_pipe(struct intel_vgpu *vgpu, int pipe)
  561. {
  562. struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
  563. struct intel_vgpu_irq *irq = &vgpu->irq;
  564. int vblank_event[] = {
  565. [PIPE_A] = PIPE_A_VBLANK,
  566. [PIPE_B] = PIPE_B_VBLANK,
  567. [PIPE_C] = PIPE_C_VBLANK,
  568. };
  569. int event;
  570. if (pipe < PIPE_A || pipe > PIPE_C)
  571. return;
  572. for_each_set_bit(event, irq->flip_done_event[pipe],
  573. INTEL_GVT_EVENT_MAX) {
  574. clear_bit(event, irq->flip_done_event[pipe]);
  575. if (!pipe_is_enabled(vgpu, pipe))
  576. continue;
  577. intel_vgpu_trigger_virtual_event(vgpu, event);
  578. }
  579. if (pipe_is_enabled(vgpu, pipe)) {
  580. vgpu_vreg_t(vgpu, PIPE_FRMCOUNT_G4X(pipe))++;
  581. intel_vgpu_trigger_virtual_event(vgpu, vblank_event[pipe]);
  582. }
  583. }
  584. void intel_vgpu_emulate_vblank(struct intel_vgpu *vgpu)
  585. {
  586. int pipe;
  587. mutex_lock(&vgpu->vgpu_lock);
  588. for_each_pipe(vgpu->gvt->gt->i915, pipe)
  589. emulate_vblank_on_pipe(vgpu, pipe);
  590. mutex_unlock(&vgpu->vgpu_lock);
  591. }
  592. /**
  593. * intel_vgpu_emulate_hotplug - trigger hotplug event for vGPU
  594. * @vgpu: a vGPU
  595. * @connected: link state
  596. *
  597. * This function is used to trigger hotplug interrupt for vGPU
  598. *
  599. */
  600. void intel_vgpu_emulate_hotplug(struct intel_vgpu *vgpu, bool connected)
  601. {
  602. struct drm_i915_private *i915 = vgpu->gvt->gt->i915;
  603. /* TODO: add more platforms support */
  604. if (IS_SKYLAKE(i915) ||
  605. IS_KABYLAKE(i915) ||
  606. IS_COFFEELAKE(i915) ||
  607. IS_COMETLAKE(i915)) {
  608. if (connected) {
  609. vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
  610. SFUSE_STRAP_DDID_DETECTED;
  611. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTD_HOTPLUG_CPT;
  612. } else {
  613. vgpu_vreg_t(vgpu, SFUSE_STRAP) &=
  614. ~SFUSE_STRAP_DDID_DETECTED;
  615. vgpu_vreg_t(vgpu, SDEISR) &= ~SDE_PORTD_HOTPLUG_CPT;
  616. }
  617. vgpu_vreg_t(vgpu, SDEIIR) |= SDE_PORTD_HOTPLUG_CPT;
  618. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
  619. PORTD_HOTPLUG_STATUS_MASK;
  620. intel_vgpu_trigger_virtual_event(vgpu, DP_D_HOTPLUG);
  621. } else if (IS_BROXTON(i915)) {
  622. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) {
  623. if (connected) {
  624. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  625. GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
  626. } else {
  627. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
  628. ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
  629. }
  630. vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |=
  631. GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
  632. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
  633. ~PORTA_HOTPLUG_STATUS_MASK;
  634. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
  635. PORTA_HOTPLUG_LONG_DETECT;
  636. intel_vgpu_trigger_virtual_event(vgpu, DP_A_HOTPLUG);
  637. }
  638. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
  639. if (connected) {
  640. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  641. GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
  642. vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
  643. SFUSE_STRAP_DDIB_DETECTED;
  644. } else {
  645. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
  646. ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
  647. vgpu_vreg_t(vgpu, SFUSE_STRAP) &=
  648. ~SFUSE_STRAP_DDIB_DETECTED;
  649. }
  650. vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |=
  651. GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
  652. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
  653. ~PORTB_HOTPLUG_STATUS_MASK;
  654. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
  655. PORTB_HOTPLUG_LONG_DETECT;
  656. intel_vgpu_trigger_virtual_event(vgpu, DP_B_HOTPLUG);
  657. }
  658. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
  659. if (connected) {
  660. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  661. GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
  662. vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
  663. SFUSE_STRAP_DDIC_DETECTED;
  664. } else {
  665. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
  666. ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
  667. vgpu_vreg_t(vgpu, SFUSE_STRAP) &=
  668. ~SFUSE_STRAP_DDIC_DETECTED;
  669. }
  670. vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |=
  671. GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
  672. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
  673. ~PORTC_HOTPLUG_STATUS_MASK;
  674. vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
  675. PORTC_HOTPLUG_LONG_DETECT;
  676. intel_vgpu_trigger_virtual_event(vgpu, DP_C_HOTPLUG);
  677. }
  678. }
  679. }
  680. /**
  681. * intel_vgpu_clean_display - clean vGPU virtual display emulation
  682. * @vgpu: a vGPU
  683. *
  684. * This function is used to clean vGPU virtual display emulation stuffs
  685. *
  686. */
  687. void intel_vgpu_clean_display(struct intel_vgpu *vgpu)
  688. {
  689. struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
  690. if (IS_SKYLAKE(dev_priv) ||
  691. IS_KABYLAKE(dev_priv) ||
  692. IS_COFFEELAKE(dev_priv) ||
  693. IS_COMETLAKE(dev_priv))
  694. clean_virtual_dp_monitor(vgpu, PORT_D);
  695. else
  696. clean_virtual_dp_monitor(vgpu, PORT_B);
  697. vgpu_update_vblank_emulation(vgpu, false);
  698. }
  699. /**
  700. * intel_vgpu_init_display- initialize vGPU virtual display emulation
  701. * @vgpu: a vGPU
  702. * @resolution: resolution index for intel_vgpu_edid
  703. *
  704. * This function is used to initialize vGPU virtual display emulation stuffs
  705. *
  706. * Returns:
  707. * Zero on success, negative error code if failed.
  708. *
  709. */
  710. int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 resolution)
  711. {
  712. struct drm_i915_private *dev_priv = vgpu->gvt->gt->i915;
  713. intel_vgpu_init_i2c_edid(vgpu);
  714. if (IS_SKYLAKE(dev_priv) ||
  715. IS_KABYLAKE(dev_priv) ||
  716. IS_COFFEELAKE(dev_priv) ||
  717. IS_COMETLAKE(dev_priv))
  718. return setup_virtual_dp_monitor(vgpu, PORT_D, GVT_DP_D,
  719. resolution);
  720. else
  721. return setup_virtual_dp_monitor(vgpu, PORT_B, GVT_DP_B,
  722. resolution);
  723. }
  724. /**
  725. * intel_vgpu_reset_display- reset vGPU virtual display emulation
  726. * @vgpu: a vGPU
  727. *
  728. * This function is used to reset vGPU virtual display emulation stuffs
  729. *
  730. */
  731. void intel_vgpu_reset_display(struct intel_vgpu *vgpu)
  732. {
  733. emulate_monitor_status_change(vgpu);
  734. }