vmwgfx_ldu.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. /**************************************************************************
  2. *
  3. * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #include "vmwgfx_kms.h"
  28. #define vmw_crtc_to_ldu(x) \
  29. container_of(x, struct vmw_legacy_display_unit, base.crtc)
  30. #define vmw_encoder_to_ldu(x) \
  31. container_of(x, struct vmw_legacy_display_unit, base.encoder)
  32. #define vmw_connector_to_ldu(x) \
  33. container_of(x, struct vmw_legacy_display_unit, base.connector)
  34. struct vmw_legacy_display {
  35. struct list_head active;
  36. unsigned num_active;
  37. unsigned last_num_active;
  38. struct vmw_framebuffer *fb;
  39. };
  40. /**
  41. * Display unit using the legacy register interface.
  42. */
  43. struct vmw_legacy_display_unit {
  44. struct vmw_display_unit base;
  45. struct list_head active;
  46. };
  47. static void vmw_ldu_destroy(struct vmw_legacy_display_unit *ldu)
  48. {
  49. list_del_init(&ldu->active);
  50. vmw_display_unit_cleanup(&ldu->base);
  51. kfree(ldu);
  52. }
  53. /*
  54. * Legacy Display Unit CRTC functions
  55. */
  56. static void vmw_ldu_crtc_save(struct drm_crtc *crtc)
  57. {
  58. }
  59. static void vmw_ldu_crtc_restore(struct drm_crtc *crtc)
  60. {
  61. }
  62. static void vmw_ldu_crtc_gamma_set(struct drm_crtc *crtc,
  63. u16 *r, u16 *g, u16 *b,
  64. uint32_t size)
  65. {
  66. }
  67. static void vmw_ldu_crtc_destroy(struct drm_crtc *crtc)
  68. {
  69. vmw_ldu_destroy(vmw_crtc_to_ldu(crtc));
  70. }
  71. static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
  72. {
  73. struct vmw_legacy_display *lds = dev_priv->ldu_priv;
  74. struct vmw_legacy_display_unit *entry;
  75. struct drm_framebuffer *fb = NULL;
  76. struct drm_crtc *crtc = NULL;
  77. int i = 0;
  78. /* If there is no display topology the host just assumes
  79. * that the guest will set the same layout as the host.
  80. */
  81. if (!(dev_priv->capabilities & SVGA_CAP_DISPLAY_TOPOLOGY)) {
  82. int w = 0, h = 0;
  83. list_for_each_entry(entry, &lds->active, active) {
  84. crtc = &entry->base.crtc;
  85. w = max(w, crtc->x + crtc->mode.hdisplay);
  86. h = max(h, crtc->y + crtc->mode.vdisplay);
  87. i++;
  88. }
  89. if (crtc == NULL)
  90. return 0;
  91. fb = entry->base.crtc.fb;
  92. vmw_write(dev_priv, SVGA_REG_ENABLE, 0);
  93. vmw_kms_write_svga(dev_priv, w, h, fb->pitch,
  94. fb->bits_per_pixel, fb->depth);
  95. vmw_write(dev_priv, SVGA_REG_ENABLE, 1);
  96. return 0;
  97. }
  98. vmw_write(dev_priv, SVGA_REG_ENABLE, 0);
  99. for (i = 0; i < lds->last_num_active; i++) {
  100. vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, i);
  101. vmw_write(dev_priv, SVGA_REG_DISPLAY_IS_PRIMARY, !i);
  102. vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_X, 0);
  103. vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_Y, 0);
  104. vmw_write(dev_priv, SVGA_REG_DISPLAY_WIDTH, 0);
  105. vmw_write(dev_priv, SVGA_REG_DISPLAY_HEIGHT, 0);
  106. vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
  107. }
  108. if (!list_empty(&lds->active)) {
  109. entry = list_entry(lds->active.next, typeof(*entry), active);
  110. fb = entry->base.crtc.fb;
  111. vmw_kms_write_svga(dev_priv, fb->width, fb->height, fb->pitch,
  112. fb->bits_per_pixel, fb->depth);
  113. }
  114. i = 0;
  115. list_for_each_entry(entry, &lds->active, active) {
  116. crtc = &entry->base.crtc;
  117. vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, i);
  118. vmw_write(dev_priv, SVGA_REG_DISPLAY_IS_PRIMARY, !i);
  119. vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_X, crtc->x);
  120. vmw_write(dev_priv, SVGA_REG_DISPLAY_POSITION_Y, crtc->y);
  121. vmw_write(dev_priv, SVGA_REG_DISPLAY_WIDTH, crtc->mode.hdisplay);
  122. vmw_write(dev_priv, SVGA_REG_DISPLAY_HEIGHT, crtc->mode.vdisplay);
  123. vmw_write(dev_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
  124. i++;
  125. }
  126. /* Make sure we always show something. */
  127. vmw_write(dev_priv, SVGA_REG_NUM_GUEST_DISPLAYS, i ? i : 1);
  128. vmw_write(dev_priv, SVGA_REG_ENABLE, 1);
  129. BUG_ON(i != lds->num_active);
  130. lds->last_num_active = lds->num_active;
  131. return 0;
  132. }
  133. static int vmw_ldu_del_active(struct vmw_private *vmw_priv,
  134. struct vmw_legacy_display_unit *ldu)
  135. {
  136. struct vmw_legacy_display *ld = vmw_priv->ldu_priv;
  137. if (list_empty(&ldu->active))
  138. return 0;
  139. /* Must init otherwise list_empty(&ldu->active) will not work. */
  140. list_del_init(&ldu->active);
  141. if (--(ld->num_active) == 0) {
  142. BUG_ON(!ld->fb);
  143. if (ld->fb->unpin)
  144. ld->fb->unpin(ld->fb);
  145. ld->fb = NULL;
  146. }
  147. return 0;
  148. }
  149. static int vmw_ldu_add_active(struct vmw_private *vmw_priv,
  150. struct vmw_legacy_display_unit *ldu,
  151. struct vmw_framebuffer *vfb)
  152. {
  153. struct vmw_legacy_display *ld = vmw_priv->ldu_priv;
  154. struct vmw_legacy_display_unit *entry;
  155. struct list_head *at;
  156. BUG_ON(!ld->num_active && ld->fb);
  157. if (vfb != ld->fb) {
  158. if (ld->fb && ld->fb->unpin)
  159. ld->fb->unpin(ld->fb);
  160. if (vfb->pin)
  161. vfb->pin(vfb);
  162. ld->fb = vfb;
  163. }
  164. if (!list_empty(&ldu->active))
  165. return 0;
  166. at = &ld->active;
  167. list_for_each_entry(entry, &ld->active, active) {
  168. if (entry->base.unit > ldu->base.unit)
  169. break;
  170. at = &entry->active;
  171. }
  172. list_add(&ldu->active, at);
  173. ld->num_active++;
  174. return 0;
  175. }
  176. static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
  177. {
  178. struct vmw_private *dev_priv;
  179. struct vmw_legacy_display_unit *ldu;
  180. struct drm_connector *connector;
  181. struct drm_display_mode *mode;
  182. struct drm_encoder *encoder;
  183. struct vmw_framebuffer *vfb;
  184. struct drm_framebuffer *fb;
  185. struct drm_crtc *crtc;
  186. if (!set)
  187. return -EINVAL;
  188. if (!set->crtc)
  189. return -EINVAL;
  190. /* get the ldu */
  191. crtc = set->crtc;
  192. ldu = vmw_crtc_to_ldu(crtc);
  193. vfb = set->fb ? vmw_framebuffer_to_vfb(set->fb) : NULL;
  194. dev_priv = vmw_priv(crtc->dev);
  195. if (set->num_connectors > 1) {
  196. DRM_ERROR("to many connectors\n");
  197. return -EINVAL;
  198. }
  199. if (set->num_connectors == 1 &&
  200. set->connectors[0] != &ldu->base.connector) {
  201. DRM_ERROR("connector doesn't match %p %p\n",
  202. set->connectors[0], &ldu->base.connector);
  203. return -EINVAL;
  204. }
  205. /* ldu only supports one fb active at the time */
  206. if (dev_priv->ldu_priv->fb && vfb &&
  207. !(dev_priv->ldu_priv->num_active == 1 &&
  208. !list_empty(&ldu->active)) &&
  209. dev_priv->ldu_priv->fb != vfb) {
  210. DRM_ERROR("Multiple framebuffers not supported\n");
  211. return -EINVAL;
  212. }
  213. /* since they always map one to one these are safe */
  214. connector = &ldu->base.connector;
  215. encoder = &ldu->base.encoder;
  216. /* should we turn the crtc off? */
  217. if (set->num_connectors == 0 || !set->mode || !set->fb) {
  218. connector->encoder = NULL;
  219. encoder->crtc = NULL;
  220. crtc->fb = NULL;
  221. vmw_ldu_del_active(dev_priv, ldu);
  222. vmw_ldu_commit_list(dev_priv);
  223. return 0;
  224. }
  225. /* we now know we want to set a mode */
  226. mode = set->mode;
  227. fb = set->fb;
  228. if (set->x + mode->hdisplay > fb->width ||
  229. set->y + mode->vdisplay > fb->height) {
  230. DRM_ERROR("set outside of framebuffer\n");
  231. return -EINVAL;
  232. }
  233. vmw_fb_off(dev_priv);
  234. crtc->fb = fb;
  235. encoder->crtc = crtc;
  236. connector->encoder = encoder;
  237. crtc->x = set->x;
  238. crtc->y = set->y;
  239. crtc->mode = *mode;
  240. vmw_ldu_add_active(dev_priv, ldu, vfb);
  241. vmw_ldu_commit_list(dev_priv);
  242. return 0;
  243. }
  244. static struct drm_crtc_funcs vmw_legacy_crtc_funcs = {
  245. .save = vmw_ldu_crtc_save,
  246. .restore = vmw_ldu_crtc_restore,
  247. .cursor_set = vmw_du_crtc_cursor_set,
  248. .cursor_move = vmw_du_crtc_cursor_move,
  249. .gamma_set = vmw_ldu_crtc_gamma_set,
  250. .destroy = vmw_ldu_crtc_destroy,
  251. .set_config = vmw_ldu_crtc_set_config,
  252. };
  253. /*
  254. * Legacy Display Unit encoder functions
  255. */
  256. static void vmw_ldu_encoder_destroy(struct drm_encoder *encoder)
  257. {
  258. vmw_ldu_destroy(vmw_encoder_to_ldu(encoder));
  259. }
  260. static struct drm_encoder_funcs vmw_legacy_encoder_funcs = {
  261. .destroy = vmw_ldu_encoder_destroy,
  262. };
  263. /*
  264. * Legacy Display Unit connector functions
  265. */
  266. static void vmw_ldu_connector_dpms(struct drm_connector *connector, int mode)
  267. {
  268. }
  269. static void vmw_ldu_connector_save(struct drm_connector *connector)
  270. {
  271. }
  272. static void vmw_ldu_connector_restore(struct drm_connector *connector)
  273. {
  274. }
  275. static enum drm_connector_status
  276. vmw_ldu_connector_detect(struct drm_connector *connector)
  277. {
  278. /* XXX vmwctrl should control connection status */
  279. if (vmw_connector_to_ldu(connector)->base.unit == 0)
  280. return connector_status_connected;
  281. return connector_status_disconnected;
  282. }
  283. static struct drm_display_mode vmw_ldu_connector_builtin[] = {
  284. /* 640x480@60Hz */
  285. { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
  286. 752, 800, 0, 480, 489, 492, 525, 0,
  287. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  288. /* 800x600@60Hz */
  289. { DRM_MODE("800x600",
  290. DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
  291. 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628,
  292. 0, DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  293. /* 1024x768@60Hz */
  294. { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 65000, 1024, 1048,
  295. 1184, 1344, 0, 768, 771, 777, 806, 0,
  296. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) },
  297. /* 1152x864@75Hz */
  298. { DRM_MODE("1152x864", DRM_MODE_TYPE_DRIVER, 108000, 1152, 1216,
  299. 1344, 1600, 0, 864, 865, 868, 900, 0,
  300. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  301. /* 1280x768@60Hz */
  302. { DRM_MODE("1280x768", DRM_MODE_TYPE_DRIVER, 79500, 1280, 1344,
  303. 1472, 1664, 0, 768, 771, 778, 798, 0,
  304. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  305. /* 1280x800@60Hz */
  306. { DRM_MODE("1280x800", DRM_MODE_TYPE_DRIVER, 83500, 1280, 1352,
  307. 1480, 1680, 0, 800, 803, 809, 831, 0,
  308. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC) },
  309. /* 1280x960@60Hz */
  310. { DRM_MODE("1280x960", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1376,
  311. 1488, 1800, 0, 960, 961, 964, 1000, 0,
  312. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  313. /* 1280x1024@60Hz */
  314. { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 108000, 1280, 1328,
  315. 1440, 1688, 0, 1024, 1025, 1028, 1066, 0,
  316. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  317. /* 1360x768@60Hz */
  318. { DRM_MODE("1360x768", DRM_MODE_TYPE_DRIVER, 85500, 1360, 1424,
  319. 1536, 1792, 0, 768, 771, 777, 795, 0,
  320. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  321. /* 1440x1050@60Hz */
  322. { DRM_MODE("1400x1050", DRM_MODE_TYPE_DRIVER, 121750, 1400, 1488,
  323. 1632, 1864, 0, 1050, 1053, 1057, 1089, 0,
  324. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  325. /* 1440x900@60Hz */
  326. { DRM_MODE("1440x900", DRM_MODE_TYPE_DRIVER, 106500, 1440, 1520,
  327. 1672, 1904, 0, 900, 903, 909, 934, 0,
  328. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  329. /* 1600x1200@60Hz */
  330. { DRM_MODE("1600x1200", DRM_MODE_TYPE_DRIVER, 162000, 1600, 1664,
  331. 1856, 2160, 0, 1200, 1201, 1204, 1250, 0,
  332. DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
  333. /* 1680x1050@60Hz */
  334. { DRM_MODE("1680x1050", DRM_MODE_TYPE_DRIVER, 146250, 1680, 1784,
  335. 1960, 2240, 0, 1050, 1053, 1059, 1089, 0,
  336. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  337. /* 1792x1344@60Hz */
  338. { DRM_MODE("1792x1344", DRM_MODE_TYPE_DRIVER, 204750, 1792, 1920,
  339. 2120, 2448, 0, 1344, 1345, 1348, 1394, 0,
  340. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  341. /* 1853x1392@60Hz */
  342. { DRM_MODE("1856x1392", DRM_MODE_TYPE_DRIVER, 218250, 1856, 1952,
  343. 2176, 2528, 0, 1392, 1393, 1396, 1439, 0,
  344. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  345. /* 1920x1200@60Hz */
  346. { DRM_MODE("1920x1200", DRM_MODE_TYPE_DRIVER, 193250, 1920, 2056,
  347. 2256, 2592, 0, 1200, 1203, 1209, 1245, 0,
  348. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  349. /* 1920x1440@60Hz */
  350. { DRM_MODE("1920x1440", DRM_MODE_TYPE_DRIVER, 234000, 1920, 2048,
  351. 2256, 2600, 0, 1440, 1441, 1444, 1500, 0,
  352. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  353. /* 2560x1600@60Hz */
  354. { DRM_MODE("2560x1600", DRM_MODE_TYPE_DRIVER, 348500, 2560, 2752,
  355. 3032, 3504, 0, 1600, 1603, 1609, 1658, 0,
  356. DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_PVSYNC) },
  357. /* Terminate */
  358. { DRM_MODE("", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) },
  359. };
  360. static int vmw_ldu_connector_fill_modes(struct drm_connector *connector,
  361. uint32_t max_width, uint32_t max_height)
  362. {
  363. struct drm_device *dev = connector->dev;
  364. struct drm_display_mode *mode = NULL;
  365. int i;
  366. for (i = 0; vmw_ldu_connector_builtin[i].type != 0; i++) {
  367. if (vmw_ldu_connector_builtin[i].hdisplay > max_width ||
  368. vmw_ldu_connector_builtin[i].vdisplay > max_height)
  369. continue;
  370. mode = drm_mode_duplicate(dev, &vmw_ldu_connector_builtin[i]);
  371. if (!mode)
  372. return 0;
  373. mode->vrefresh = drm_mode_vrefresh(mode);
  374. drm_mode_probed_add(connector, mode);
  375. }
  376. drm_mode_connector_list_update(connector);
  377. return 1;
  378. }
  379. static int vmw_ldu_connector_set_property(struct drm_connector *connector,
  380. struct drm_property *property,
  381. uint64_t val)
  382. {
  383. return 0;
  384. }
  385. static void vmw_ldu_connector_destroy(struct drm_connector *connector)
  386. {
  387. vmw_ldu_destroy(vmw_connector_to_ldu(connector));
  388. }
  389. static struct drm_connector_funcs vmw_legacy_connector_funcs = {
  390. .dpms = vmw_ldu_connector_dpms,
  391. .save = vmw_ldu_connector_save,
  392. .restore = vmw_ldu_connector_restore,
  393. .detect = vmw_ldu_connector_detect,
  394. .fill_modes = vmw_ldu_connector_fill_modes,
  395. .set_property = vmw_ldu_connector_set_property,
  396. .destroy = vmw_ldu_connector_destroy,
  397. };
  398. static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
  399. {
  400. struct vmw_legacy_display_unit *ldu;
  401. struct drm_device *dev = dev_priv->dev;
  402. struct drm_connector *connector;
  403. struct drm_encoder *encoder;
  404. struct drm_crtc *crtc;
  405. ldu = kzalloc(sizeof(*ldu), GFP_KERNEL);
  406. if (!ldu)
  407. return -ENOMEM;
  408. ldu->base.unit = unit;
  409. crtc = &ldu->base.crtc;
  410. encoder = &ldu->base.encoder;
  411. connector = &ldu->base.connector;
  412. INIT_LIST_HEAD(&ldu->active);
  413. drm_connector_init(dev, connector, &vmw_legacy_connector_funcs,
  414. DRM_MODE_CONNECTOR_LVDS);
  415. connector->status = vmw_ldu_connector_detect(connector);
  416. drm_encoder_init(dev, encoder, &vmw_legacy_encoder_funcs,
  417. DRM_MODE_ENCODER_LVDS);
  418. drm_mode_connector_attach_encoder(connector, encoder);
  419. encoder->possible_crtcs = (1 << unit);
  420. encoder->possible_clones = 0;
  421. drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs);
  422. drm_connector_attach_property(connector,
  423. dev->mode_config.dirty_info_property,
  424. 1);
  425. return 0;
  426. }
  427. int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv)
  428. {
  429. if (dev_priv->ldu_priv) {
  430. DRM_INFO("ldu system already on\n");
  431. return -EINVAL;
  432. }
  433. dev_priv->ldu_priv = kmalloc(GFP_KERNEL, sizeof(*dev_priv->ldu_priv));
  434. if (!dev_priv->ldu_priv)
  435. return -ENOMEM;
  436. INIT_LIST_HEAD(&dev_priv->ldu_priv->active);
  437. dev_priv->ldu_priv->num_active = 0;
  438. dev_priv->ldu_priv->last_num_active = 0;
  439. dev_priv->ldu_priv->fb = NULL;
  440. drm_mode_create_dirty_info_property(dev_priv->dev);
  441. vmw_ldu_init(dev_priv, 0);
  442. /* for old hardware without multimon only enable one display */
  443. if (dev_priv->capabilities & SVGA_CAP_MULTIMON) {
  444. vmw_ldu_init(dev_priv, 1);
  445. vmw_ldu_init(dev_priv, 2);
  446. vmw_ldu_init(dev_priv, 3);
  447. vmw_ldu_init(dev_priv, 4);
  448. vmw_ldu_init(dev_priv, 5);
  449. vmw_ldu_init(dev_priv, 6);
  450. vmw_ldu_init(dev_priv, 7);
  451. }
  452. return 0;
  453. }
  454. int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv)
  455. {
  456. if (!dev_priv->ldu_priv)
  457. return -ENOSYS;
  458. BUG_ON(!list_empty(&dev_priv->ldu_priv->active));
  459. kfree(dev_priv->ldu_priv);
  460. return 0;
  461. }