vmwgfx_ldu.c 16 KB

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