display.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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 <zhiyuan.lv@intel.com>
  26. *
  27. * Contributors:
  28. * Terrence Xu <terrence.xu@intel.com>
  29. * Changbin Du <changbin.du@intel.com>
  30. * Bing Niu <bing.niu@intel.com>
  31. * Zhi Wang <zhi.a.wang@intel.com>
  32. *
  33. */
  34. #include "i915_drv.h"
  35. #include "gvt.h"
  36. static int get_edp_pipe(struct intel_vgpu *vgpu)
  37. {
  38. u32 data = vgpu_vreg(vgpu, _TRANS_DDI_FUNC_CTL_EDP);
  39. int pipe = -1;
  40. switch (data & TRANS_DDI_EDP_INPUT_MASK) {
  41. case TRANS_DDI_EDP_INPUT_A_ON:
  42. case TRANS_DDI_EDP_INPUT_A_ONOFF:
  43. pipe = PIPE_A;
  44. break;
  45. case TRANS_DDI_EDP_INPUT_B_ONOFF:
  46. pipe = PIPE_B;
  47. break;
  48. case TRANS_DDI_EDP_INPUT_C_ONOFF:
  49. pipe = PIPE_C;
  50. break;
  51. }
  52. return pipe;
  53. }
  54. static int edp_pipe_is_enabled(struct intel_vgpu *vgpu)
  55. {
  56. struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
  57. if (!(vgpu_vreg_t(vgpu, PIPECONF(_PIPE_EDP)) & PIPECONF_ENABLE))
  58. return 0;
  59. if (!(vgpu_vreg(vgpu, _TRANS_DDI_FUNC_CTL_EDP) & TRANS_DDI_FUNC_ENABLE))
  60. return 0;
  61. return 1;
  62. }
  63. int pipe_is_enabled(struct intel_vgpu *vgpu, int pipe)
  64. {
  65. struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
  66. if (WARN_ON(pipe < PIPE_A || pipe >= I915_MAX_PIPES))
  67. return -EINVAL;
  68. if (vgpu_vreg_t(vgpu, PIPECONF(pipe)) & PIPECONF_ENABLE)
  69. return 1;
  70. if (edp_pipe_is_enabled(vgpu) &&
  71. get_edp_pipe(vgpu) == pipe)
  72. return 1;
  73. return 0;
  74. }
  75. static unsigned char virtual_dp_monitor_edid[GVT_EDID_NUM][EDID_SIZE] = {
  76. {
  77. /* EDID with 1024x768 as its resolution */
  78. /*Header*/
  79. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
  80. /* Vendor & Product Identification */
  81. 0x22, 0xf0, 0x54, 0x29, 0x00, 0x00, 0x00, 0x00, 0x04, 0x17,
  82. /* Version & Revision */
  83. 0x01, 0x04,
  84. /* Basic Display Parameters & Features */
  85. 0xa5, 0x34, 0x20, 0x78, 0x23,
  86. /* Color Characteristics */
  87. 0xfc, 0x81, 0xa4, 0x55, 0x4d, 0x9d, 0x25, 0x12, 0x50, 0x54,
  88. /* Established Timings: maximum resolution is 1024x768 */
  89. 0x21, 0x08, 0x00,
  90. /* Standard Timings. All invalid */
  91. 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x40, 0x00, 0x80, 0x00, 0x00,
  92. 0x00, 0x40, 0x00, 0x00, 0x00, 0x01,
  93. /* 18 Byte Data Blocks 1: invalid */
  94. 0x00, 0x00, 0x80, 0xa0, 0x70, 0xb0,
  95. 0x23, 0x40, 0x30, 0x20, 0x36, 0x00, 0x06, 0x44, 0x21, 0x00, 0x00, 0x1a,
  96. /* 18 Byte Data Blocks 2: invalid */
  97. 0x00, 0x00, 0x00, 0xfd, 0x00, 0x18, 0x3c, 0x18, 0x50, 0x11, 0x00, 0x0a,
  98. 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  99. /* 18 Byte Data Blocks 3: invalid */
  100. 0x00, 0x00, 0x00, 0xfc, 0x00, 0x48,
  101. 0x50, 0x20, 0x5a, 0x52, 0x32, 0x34, 0x34, 0x30, 0x77, 0x0a, 0x20, 0x20,
  102. /* 18 Byte Data Blocks 4: invalid */
  103. 0x00, 0x00, 0x00, 0xff, 0x00, 0x43, 0x4e, 0x34, 0x33, 0x30, 0x34, 0x30,
  104. 0x44, 0x58, 0x51, 0x0a, 0x20, 0x20,
  105. /* Extension Block Count */
  106. 0x00,
  107. /* Checksum */
  108. 0xef,
  109. },
  110. {
  111. /* EDID with 1920x1200 as its resolution */
  112. /*Header*/
  113. 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
  114. /* Vendor & Product Identification */
  115. 0x22, 0xf0, 0x54, 0x29, 0x00, 0x00, 0x00, 0x00, 0x04, 0x17,
  116. /* Version & Revision */
  117. 0x01, 0x04,
  118. /* Basic Display Parameters & Features */
  119. 0xa5, 0x34, 0x20, 0x78, 0x23,
  120. /* Color Characteristics */
  121. 0xfc, 0x81, 0xa4, 0x55, 0x4d, 0x9d, 0x25, 0x12, 0x50, 0x54,
  122. /* Established Timings: maximum resolution is 1024x768 */
  123. 0x21, 0x08, 0x00,
  124. /*
  125. * Standard Timings.
  126. * below new resolutions can be supported:
  127. * 1920x1080, 1280x720, 1280x960, 1280x1024,
  128. * 1440x900, 1600x1200, 1680x1050
  129. */
  130. 0xd1, 0xc0, 0x81, 0xc0, 0x81, 0x40, 0x81, 0x80, 0x95, 0x00,
  131. 0xa9, 0x40, 0xb3, 0x00, 0x01, 0x01,
  132. /* 18 Byte Data Blocks 1: max resolution is 1920x1200 */
  133. 0x28, 0x3c, 0x80, 0xa0, 0x70, 0xb0,
  134. 0x23, 0x40, 0x30, 0x20, 0x36, 0x00, 0x06, 0x44, 0x21, 0x00, 0x00, 0x1a,
  135. /* 18 Byte Data Blocks 2: invalid */
  136. 0x00, 0x00, 0x00, 0xfd, 0x00, 0x18, 0x3c, 0x18, 0x50, 0x11, 0x00, 0x0a,
  137. 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
  138. /* 18 Byte Data Blocks 3: invalid */
  139. 0x00, 0x00, 0x00, 0xfc, 0x00, 0x48,
  140. 0x50, 0x20, 0x5a, 0x52, 0x32, 0x34, 0x34, 0x30, 0x77, 0x0a, 0x20, 0x20,
  141. /* 18 Byte Data Blocks 4: invalid */
  142. 0x00, 0x00, 0x00, 0xff, 0x00, 0x43, 0x4e, 0x34, 0x33, 0x30, 0x34, 0x30,
  143. 0x44, 0x58, 0x51, 0x0a, 0x20, 0x20,
  144. /* Extension Block Count */
  145. 0x00,
  146. /* Checksum */
  147. 0x45,
  148. },
  149. };
  150. #define DPCD_HEADER_SIZE 0xb
  151. /* let the virtual display supports DP1.2 */
  152. static u8 dpcd_fix_data[DPCD_HEADER_SIZE] = {
  153. 0x12, 0x014, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  154. };
  155. static void emulate_monitor_status_change(struct intel_vgpu *vgpu)
  156. {
  157. struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
  158. int pipe;
  159. vgpu_vreg_t(vgpu, SDEISR) &= ~(SDE_PORTB_HOTPLUG_CPT |
  160. SDE_PORTC_HOTPLUG_CPT |
  161. SDE_PORTD_HOTPLUG_CPT);
  162. if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
  163. vgpu_vreg_t(vgpu, SDEISR) &= ~(SDE_PORTA_HOTPLUG_SPT |
  164. SDE_PORTE_HOTPLUG_SPT);
  165. vgpu_vreg_t(vgpu, SKL_FUSE_STATUS) |=
  166. SKL_FUSE_DOWNLOAD_STATUS |
  167. SKL_FUSE_PG_DIST_STATUS(SKL_PG0) |
  168. SKL_FUSE_PG_DIST_STATUS(SKL_PG1) |
  169. SKL_FUSE_PG_DIST_STATUS(SKL_PG2);
  170. vgpu_vreg_t(vgpu, LCPLL1_CTL) |=
  171. LCPLL_PLL_ENABLE |
  172. LCPLL_PLL_LOCK;
  173. vgpu_vreg_t(vgpu, LCPLL2_CTL) |= LCPLL_PLL_ENABLE;
  174. }
  175. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
  176. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIB_DETECTED;
  177. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
  178. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  179. TRANS_DDI_PORT_MASK);
  180. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  181. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  182. (PORT_B << TRANS_DDI_PORT_SHIFT) |
  183. TRANS_DDI_FUNC_ENABLE);
  184. if (IS_BROADWELL(dev_priv)) {
  185. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_B)) &=
  186. ~PORT_CLK_SEL_MASK;
  187. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_B)) |=
  188. PORT_CLK_SEL_LCPLL_810;
  189. }
  190. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) |= DDI_BUF_CTL_ENABLE;
  191. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) &= ~DDI_BUF_IS_IDLE;
  192. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTB_HOTPLUG_CPT;
  193. }
  194. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
  195. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTC_HOTPLUG_CPT;
  196. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
  197. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  198. TRANS_DDI_PORT_MASK);
  199. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  200. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  201. (PORT_C << TRANS_DDI_PORT_SHIFT) |
  202. TRANS_DDI_FUNC_ENABLE);
  203. if (IS_BROADWELL(dev_priv)) {
  204. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_C)) &=
  205. ~PORT_CLK_SEL_MASK;
  206. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_C)) |=
  207. PORT_CLK_SEL_LCPLL_810;
  208. }
  209. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) |= DDI_BUF_CTL_ENABLE;
  210. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) &= ~DDI_BUF_IS_IDLE;
  211. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIC_DETECTED;
  212. }
  213. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_D)) {
  214. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTD_HOTPLUG_CPT;
  215. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &=
  216. ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK |
  217. TRANS_DDI_PORT_MASK);
  218. vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |=
  219. (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
  220. (PORT_D << TRANS_DDI_PORT_SHIFT) |
  221. TRANS_DDI_FUNC_ENABLE);
  222. if (IS_BROADWELL(dev_priv)) {
  223. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_D)) &=
  224. ~PORT_CLK_SEL_MASK;
  225. vgpu_vreg_t(vgpu, PORT_CLK_SEL(PORT_D)) |=
  226. PORT_CLK_SEL_LCPLL_810;
  227. }
  228. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_D)) |= DDI_BUF_CTL_ENABLE;
  229. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_D)) &= ~DDI_BUF_IS_IDLE;
  230. vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDID_DETECTED;
  231. }
  232. if ((IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) &&
  233. intel_vgpu_has_monitor_on_port(vgpu, PORT_E)) {
  234. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTE_HOTPLUG_SPT;
  235. }
  236. if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) {
  237. if (IS_BROADWELL(dev_priv))
  238. vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
  239. GEN8_PORT_DP_A_HOTPLUG;
  240. else
  241. vgpu_vreg_t(vgpu, SDEISR) |= SDE_PORTA_HOTPLUG_SPT;
  242. vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_A)) |= DDI_INIT_DISPLAY_DETECTED;
  243. }
  244. /* Clear host CRT status, so guest couldn't detect this host CRT. */
  245. if (IS_BROADWELL(dev_priv))
  246. vgpu_vreg_t(vgpu, PCH_ADPA) &= ~ADPA_CRT_HOTPLUG_MONITOR_MASK;
  247. /* Disable Primary/Sprite/Cursor plane */
  248. for_each_pipe(dev_priv, pipe) {
  249. vgpu_vreg_t(vgpu, DSPCNTR(pipe)) &= ~DISPLAY_PLANE_ENABLE;
  250. vgpu_vreg_t(vgpu, SPRCTL(pipe)) &= ~SPRITE_ENABLE;
  251. vgpu_vreg_t(vgpu, CURCNTR(pipe)) &= ~CURSOR_MODE;
  252. vgpu_vreg_t(vgpu, CURCNTR(pipe)) |= CURSOR_MODE_DISABLE;
  253. }
  254. vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= PIPECONF_ENABLE;
  255. }
  256. static void clean_virtual_dp_monitor(struct intel_vgpu *vgpu, int port_num)
  257. {
  258. struct intel_vgpu_port *port = intel_vgpu_port(vgpu, port_num);
  259. kfree(port->edid);
  260. port->edid = NULL;
  261. kfree(port->dpcd);
  262. port->dpcd = NULL;
  263. }
  264. static int setup_virtual_dp_monitor(struct intel_vgpu *vgpu, int port_num,
  265. int type, unsigned int resolution)
  266. {
  267. struct intel_vgpu_port *port = intel_vgpu_port(vgpu, port_num);
  268. if (WARN_ON(resolution >= GVT_EDID_NUM))
  269. return -EINVAL;
  270. port->edid = kzalloc(sizeof(*(port->edid)), GFP_KERNEL);
  271. if (!port->edid)
  272. return -ENOMEM;
  273. port->dpcd = kzalloc(sizeof(*(port->dpcd)), GFP_KERNEL);
  274. if (!port->dpcd) {
  275. kfree(port->edid);
  276. return -ENOMEM;
  277. }
  278. memcpy(port->edid->edid_block, virtual_dp_monitor_edid[resolution],
  279. EDID_SIZE);
  280. port->edid->data_valid = true;
  281. memcpy(port->dpcd->data, dpcd_fix_data, DPCD_HEADER_SIZE);
  282. port->dpcd->data_valid = true;
  283. port->dpcd->data[DPCD_SINK_COUNT] = 0x1;
  284. port->type = type;
  285. emulate_monitor_status_change(vgpu);
  286. return 0;
  287. }
  288. /**
  289. * intel_gvt_check_vblank_emulation - check if vblank emulation timer should
  290. * be turned on/off when a virtual pipe is enabled/disabled.
  291. * @gvt: a GVT device
  292. *
  293. * This function is used to turn on/off vblank timer according to currently
  294. * enabled/disabled virtual pipes.
  295. *
  296. */
  297. void intel_gvt_check_vblank_emulation(struct intel_gvt *gvt)
  298. {
  299. struct intel_gvt_irq *irq = &gvt->irq;
  300. struct intel_vgpu *vgpu;
  301. int pipe, id;
  302. if (WARN_ON(!mutex_is_locked(&gvt->lock)))
  303. return;
  304. for_each_active_vgpu(gvt, vgpu, id) {
  305. for (pipe = 0; pipe < I915_MAX_PIPES; pipe++) {
  306. if (pipe_is_enabled(vgpu, pipe))
  307. goto out;
  308. }
  309. }
  310. /* all the pipes are disabled */
  311. hrtimer_cancel(&irq->vblank_timer.timer);
  312. return;
  313. out:
  314. hrtimer_start(&irq->vblank_timer.timer,
  315. ktime_add_ns(ktime_get(), irq->vblank_timer.period),
  316. HRTIMER_MODE_ABS);
  317. }
  318. static void emulate_vblank_on_pipe(struct intel_vgpu *vgpu, int pipe)
  319. {
  320. struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
  321. struct intel_vgpu_irq *irq = &vgpu->irq;
  322. int vblank_event[] = {
  323. [PIPE_A] = PIPE_A_VBLANK,
  324. [PIPE_B] = PIPE_B_VBLANK,
  325. [PIPE_C] = PIPE_C_VBLANK,
  326. };
  327. int event;
  328. if (pipe < PIPE_A || pipe > PIPE_C)
  329. return;
  330. for_each_set_bit(event, irq->flip_done_event[pipe],
  331. INTEL_GVT_EVENT_MAX) {
  332. clear_bit(event, irq->flip_done_event[pipe]);
  333. if (!pipe_is_enabled(vgpu, pipe))
  334. continue;
  335. vgpu_vreg_t(vgpu, PIPE_FLIPCOUNT_G4X(pipe))++;
  336. intel_vgpu_trigger_virtual_event(vgpu, event);
  337. }
  338. if (pipe_is_enabled(vgpu, pipe)) {
  339. vgpu_vreg_t(vgpu, PIPE_FRMCOUNT_G4X(pipe))++;
  340. intel_vgpu_trigger_virtual_event(vgpu, vblank_event[pipe]);
  341. }
  342. }
  343. static void emulate_vblank(struct intel_vgpu *vgpu)
  344. {
  345. int pipe;
  346. for_each_pipe(vgpu->gvt->dev_priv, pipe)
  347. emulate_vblank_on_pipe(vgpu, pipe);
  348. }
  349. /**
  350. * intel_gvt_emulate_vblank - trigger vblank events for vGPUs on GVT device
  351. * @gvt: a GVT device
  352. *
  353. * This function is used to trigger vblank interrupts for vGPUs on GVT device
  354. *
  355. */
  356. void intel_gvt_emulate_vblank(struct intel_gvt *gvt)
  357. {
  358. struct intel_vgpu *vgpu;
  359. int id;
  360. if (WARN_ON(!mutex_is_locked(&gvt->lock)))
  361. return;
  362. for_each_active_vgpu(gvt, vgpu, id)
  363. emulate_vblank(vgpu);
  364. }
  365. /**
  366. * intel_vgpu_clean_display - clean vGPU virtual display emulation
  367. * @vgpu: a vGPU
  368. *
  369. * This function is used to clean vGPU virtual display emulation stuffs
  370. *
  371. */
  372. void intel_vgpu_clean_display(struct intel_vgpu *vgpu)
  373. {
  374. struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
  375. if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
  376. clean_virtual_dp_monitor(vgpu, PORT_D);
  377. else
  378. clean_virtual_dp_monitor(vgpu, PORT_B);
  379. }
  380. /**
  381. * intel_vgpu_init_display- initialize vGPU virtual display emulation
  382. * @vgpu: a vGPU
  383. *
  384. * This function is used to initialize vGPU virtual display emulation stuffs
  385. *
  386. * Returns:
  387. * Zero on success, negative error code if failed.
  388. *
  389. */
  390. int intel_vgpu_init_display(struct intel_vgpu *vgpu, u64 resolution)
  391. {
  392. struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
  393. intel_vgpu_init_i2c_edid(vgpu);
  394. if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
  395. return setup_virtual_dp_monitor(vgpu, PORT_D, GVT_DP_D,
  396. resolution);
  397. else
  398. return setup_virtual_dp_monitor(vgpu, PORT_B, GVT_DP_B,
  399. resolution);
  400. }
  401. /**
  402. * intel_vgpu_reset_display- reset vGPU virtual display emulation
  403. * @vgpu: a vGPU
  404. *
  405. * This function is used to reset vGPU virtual display emulation stuffs
  406. *
  407. */
  408. void intel_vgpu_reset_display(struct intel_vgpu *vgpu)
  409. {
  410. emulate_monitor_status_change(vgpu);
  411. }