Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 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 | |
| 28 | #include "vmwgfx_kms.h" |
| 29 | |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 30 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 31 | #define vmw_crtc_to_ldu(x) \ |
| 32 | container_of(x, struct vmw_legacy_display_unit, base.crtc) |
| 33 | #define vmw_encoder_to_ldu(x) \ |
| 34 | container_of(x, struct vmw_legacy_display_unit, base.encoder) |
| 35 | #define vmw_connector_to_ldu(x) \ |
| 36 | container_of(x, struct vmw_legacy_display_unit, base.connector) |
| 37 | |
| 38 | struct vmw_legacy_display { |
| 39 | struct list_head active; |
| 40 | |
| 41 | unsigned num_active; |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 42 | unsigned last_num_active; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 43 | |
| 44 | struct vmw_framebuffer *fb; |
| 45 | }; |
| 46 | |
| 47 | /** |
| 48 | * Display unit using the legacy register interface. |
| 49 | */ |
| 50 | struct vmw_legacy_display_unit { |
| 51 | struct vmw_display_unit base; |
| 52 | |
| 53 | struct list_head active; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | static void vmw_ldu_destroy(struct vmw_legacy_display_unit *ldu) |
| 57 | { |
| 58 | list_del_init(&ldu->active); |
| 59 | vmw_display_unit_cleanup(&ldu->base); |
| 60 | kfree(ldu); |
| 61 | } |
| 62 | |
| 63 | |
| 64 | /* |
| 65 | * Legacy Display Unit CRTC functions |
| 66 | */ |
| 67 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 68 | static void vmw_ldu_crtc_destroy(struct drm_crtc *crtc) |
| 69 | { |
| 70 | vmw_ldu_destroy(vmw_crtc_to_ldu(crtc)); |
| 71 | } |
| 72 | |
| 73 | static int vmw_ldu_commit_list(struct vmw_private *dev_priv) |
| 74 | { |
| 75 | struct vmw_legacy_display *lds = dev_priv->ldu_priv; |
| 76 | struct vmw_legacy_display_unit *entry; |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 77 | struct drm_framebuffer *fb = NULL; |
| 78 | struct drm_crtc *crtc = NULL; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 79 | int i = 0; |
| 80 | |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 81 | /* If there is no display topology the host just assumes |
| 82 | * that the guest will set the same layout as the host. |
| 83 | */ |
| 84 | if (!(dev_priv->capabilities & SVGA_CAP_DISPLAY_TOPOLOGY)) { |
| 85 | int w = 0, h = 0; |
| 86 | list_for_each_entry(entry, &lds->active, active) { |
| 87 | crtc = &entry->base.crtc; |
| 88 | w = max(w, crtc->x + crtc->mode.hdisplay); |
| 89 | h = max(h, crtc->y + crtc->mode.vdisplay); |
| 90 | i++; |
| 91 | } |
| 92 | |
| 93 | if (crtc == NULL) |
| 94 | return 0; |
| 95 | fb = entry->base.crtc.fb; |
| 96 | |
Michel Dänzer | 0bef23f | 2011-08-31 07:42:50 +0000 | [diff] [blame] | 97 | return vmw_kms_write_svga(dev_priv, w, h, fb->pitch, |
| 98 | fb->bits_per_pixel, fb->depth); |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 99 | } |
| 100 | |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 101 | if (!list_empty(&lds->active)) { |
| 102 | entry = list_entry(lds->active.next, typeof(*entry), active); |
| 103 | fb = entry->base.crtc.fb; |
| 104 | |
| 105 | vmw_kms_write_svga(dev_priv, fb->width, fb->height, fb->pitch, |
| 106 | fb->bits_per_pixel, fb->depth); |
| 107 | } |
| 108 | |
Jakob Bornecrantz | 259600d5 | 2010-05-28 11:22:03 +0200 | [diff] [blame] | 109 | /* Make sure we always show something. */ |
| 110 | vmw_write(dev_priv, SVGA_REG_NUM_GUEST_DISPLAYS, |
| 111 | lds->num_active ? lds->num_active : 1); |
| 112 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 113 | i = 0; |
| 114 | list_for_each_entry(entry, &lds->active, active) { |
| 115 | crtc = &entry->base.crtc; |
| 116 | |
| 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 | |
| 125 | i++; |
| 126 | } |
| 127 | |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 128 | BUG_ON(i != lds->num_active); |
| 129 | |
| 130 | lds->last_num_active = lds->num_active; |
| 131 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 132 | return 0; |
| 133 | } |
| 134 | |
| 135 | static int vmw_ldu_del_active(struct vmw_private *vmw_priv, |
| 136 | struct vmw_legacy_display_unit *ldu) |
| 137 | { |
| 138 | struct vmw_legacy_display *ld = vmw_priv->ldu_priv; |
| 139 | if (list_empty(&ldu->active)) |
| 140 | return 0; |
| 141 | |
Jakob Bornecrantz | 6a591a9 | 2010-05-28 11:21:55 +0200 | [diff] [blame] | 142 | /* Must init otherwise list_empty(&ldu->active) will not work. */ |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 143 | list_del_init(&ldu->active); |
| 144 | if (--(ld->num_active) == 0) { |
| 145 | BUG_ON(!ld->fb); |
| 146 | if (ld->fb->unpin) |
| 147 | ld->fb->unpin(ld->fb); |
| 148 | ld->fb = NULL; |
| 149 | } |
| 150 | |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | static int vmw_ldu_add_active(struct vmw_private *vmw_priv, |
| 155 | struct vmw_legacy_display_unit *ldu, |
| 156 | struct vmw_framebuffer *vfb) |
| 157 | { |
| 158 | struct vmw_legacy_display *ld = vmw_priv->ldu_priv; |
| 159 | struct vmw_legacy_display_unit *entry; |
| 160 | struct list_head *at; |
| 161 | |
Jakob Bornecrantz | 04e9e94 | 2010-05-28 11:21:56 +0200 | [diff] [blame] | 162 | BUG_ON(!ld->num_active && ld->fb); |
| 163 | if (vfb != ld->fb) { |
| 164 | if (ld->fb && ld->fb->unpin) |
| 165 | ld->fb->unpin(ld->fb); |
| 166 | if (vfb->pin) |
| 167 | vfb->pin(vfb); |
| 168 | ld->fb = vfb; |
| 169 | } |
| 170 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 171 | if (!list_empty(&ldu->active)) |
| 172 | return 0; |
| 173 | |
| 174 | at = &ld->active; |
| 175 | list_for_each_entry(entry, &ld->active, active) { |
Jakob Bornecrantz | bbfad33 | 2010-05-28 11:22:01 +0200 | [diff] [blame] | 176 | if (entry->base.unit > ldu->base.unit) |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 177 | break; |
| 178 | |
| 179 | at = &entry->active; |
| 180 | } |
| 181 | |
| 182 | list_add(&ldu->active, at); |
Jakob Bornecrantz | 04e9e94 | 2010-05-28 11:21:56 +0200 | [diff] [blame] | 183 | |
| 184 | ld->num_active++; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) |
| 190 | { |
| 191 | struct vmw_private *dev_priv; |
| 192 | struct vmw_legacy_display_unit *ldu; |
| 193 | struct drm_connector *connector; |
| 194 | struct drm_display_mode *mode; |
| 195 | struct drm_encoder *encoder; |
| 196 | struct vmw_framebuffer *vfb; |
| 197 | struct drm_framebuffer *fb; |
| 198 | struct drm_crtc *crtc; |
| 199 | |
| 200 | if (!set) |
| 201 | return -EINVAL; |
| 202 | |
| 203 | if (!set->crtc) |
| 204 | return -EINVAL; |
| 205 | |
| 206 | /* get the ldu */ |
| 207 | crtc = set->crtc; |
| 208 | ldu = vmw_crtc_to_ldu(crtc); |
| 209 | vfb = set->fb ? vmw_framebuffer_to_vfb(set->fb) : NULL; |
| 210 | dev_priv = vmw_priv(crtc->dev); |
| 211 | |
| 212 | if (set->num_connectors > 1) { |
| 213 | DRM_ERROR("to many connectors\n"); |
| 214 | return -EINVAL; |
| 215 | } |
| 216 | |
| 217 | if (set->num_connectors == 1 && |
| 218 | set->connectors[0] != &ldu->base.connector) { |
| 219 | DRM_ERROR("connector doesn't match %p %p\n", |
| 220 | set->connectors[0], &ldu->base.connector); |
| 221 | return -EINVAL; |
| 222 | } |
| 223 | |
| 224 | /* ldu only supports one fb active at the time */ |
| 225 | if (dev_priv->ldu_priv->fb && vfb && |
Jakob Bornecrantz | 6a591a9 | 2010-05-28 11:21:55 +0200 | [diff] [blame] | 226 | !(dev_priv->ldu_priv->num_active == 1 && |
| 227 | !list_empty(&ldu->active)) && |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 228 | dev_priv->ldu_priv->fb != vfb) { |
| 229 | DRM_ERROR("Multiple framebuffers not supported\n"); |
| 230 | return -EINVAL; |
| 231 | } |
| 232 | |
| 233 | /* since they always map one to one these are safe */ |
| 234 | connector = &ldu->base.connector; |
| 235 | encoder = &ldu->base.encoder; |
| 236 | |
| 237 | /* should we turn the crtc off? */ |
| 238 | if (set->num_connectors == 0 || !set->mode || !set->fb) { |
| 239 | |
| 240 | connector->encoder = NULL; |
| 241 | encoder->crtc = NULL; |
| 242 | crtc->fb = NULL; |
| 243 | |
| 244 | vmw_ldu_del_active(dev_priv, ldu); |
| 245 | |
Michel Dänzer | 0bef23f | 2011-08-31 07:42:50 +0000 | [diff] [blame] | 246 | return vmw_ldu_commit_list(dev_priv); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | |
| 250 | /* we now know we want to set a mode */ |
| 251 | mode = set->mode; |
| 252 | fb = set->fb; |
| 253 | |
| 254 | if (set->x + mode->hdisplay > fb->width || |
| 255 | set->y + mode->vdisplay > fb->height) { |
| 256 | DRM_ERROR("set outside of framebuffer\n"); |
| 257 | return -EINVAL; |
| 258 | } |
| 259 | |
| 260 | vmw_fb_off(dev_priv); |
| 261 | |
| 262 | crtc->fb = fb; |
| 263 | encoder->crtc = crtc; |
| 264 | connector->encoder = encoder; |
| 265 | crtc->x = set->x; |
| 266 | crtc->y = set->y; |
| 267 | crtc->mode = *mode; |
| 268 | |
| 269 | vmw_ldu_add_active(dev_priv, ldu, vfb); |
| 270 | |
Michel Dänzer | 0bef23f | 2011-08-31 07:42:50 +0000 | [diff] [blame] | 271 | return vmw_ldu_commit_list(dev_priv); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | static struct drm_crtc_funcs vmw_legacy_crtc_funcs = { |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 275 | .save = vmw_du_crtc_save, |
| 276 | .restore = vmw_du_crtc_restore, |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 277 | .cursor_set = vmw_du_crtc_cursor_set, |
| 278 | .cursor_move = vmw_du_crtc_cursor_move, |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 279 | .gamma_set = vmw_du_crtc_gamma_set, |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 280 | .destroy = vmw_ldu_crtc_destroy, |
| 281 | .set_config = vmw_ldu_crtc_set_config, |
| 282 | }; |
| 283 | |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 284 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 285 | /* |
| 286 | * Legacy Display Unit encoder functions |
| 287 | */ |
| 288 | |
| 289 | static void vmw_ldu_encoder_destroy(struct drm_encoder *encoder) |
| 290 | { |
| 291 | vmw_ldu_destroy(vmw_encoder_to_ldu(encoder)); |
| 292 | } |
| 293 | |
| 294 | static struct drm_encoder_funcs vmw_legacy_encoder_funcs = { |
| 295 | .destroy = vmw_ldu_encoder_destroy, |
| 296 | }; |
| 297 | |
| 298 | /* |
| 299 | * Legacy Display Unit connector functions |
| 300 | */ |
| 301 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 302 | static void vmw_ldu_connector_destroy(struct drm_connector *connector) |
| 303 | { |
| 304 | vmw_ldu_destroy(vmw_connector_to_ldu(connector)); |
| 305 | } |
| 306 | |
| 307 | static struct drm_connector_funcs vmw_legacy_connector_funcs = { |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 308 | .dpms = vmw_du_connector_dpms, |
| 309 | .save = vmw_du_connector_save, |
| 310 | .restore = vmw_du_connector_restore, |
| 311 | .detect = vmw_du_connector_detect, |
| 312 | .fill_modes = vmw_du_connector_fill_modes, |
| 313 | .set_property = vmw_du_connector_set_property, |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 314 | .destroy = vmw_ldu_connector_destroy, |
| 315 | }; |
| 316 | |
| 317 | static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit) |
| 318 | { |
| 319 | struct vmw_legacy_display_unit *ldu; |
| 320 | struct drm_device *dev = dev_priv->dev; |
| 321 | struct drm_connector *connector; |
| 322 | struct drm_encoder *encoder; |
| 323 | struct drm_crtc *crtc; |
| 324 | |
| 325 | ldu = kzalloc(sizeof(*ldu), GFP_KERNEL); |
| 326 | if (!ldu) |
| 327 | return -ENOMEM; |
| 328 | |
Jakob Bornecrantz | bbfad33 | 2010-05-28 11:22:01 +0200 | [diff] [blame] | 329 | ldu->base.unit = unit; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 330 | crtc = &ldu->base.crtc; |
| 331 | encoder = &ldu->base.encoder; |
| 332 | connector = &ldu->base.connector; |
| 333 | |
Jakob Bornecrantz | 1ae1ddd | 2010-05-28 11:21:58 +0200 | [diff] [blame] | 334 | INIT_LIST_HEAD(&ldu->active); |
| 335 | |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 336 | ldu->base.pref_active = (unit == 0); |
| 337 | ldu->base.pref_width = 800; |
| 338 | ldu->base.pref_height = 600; |
| 339 | ldu->base.pref_mode = NULL; |
Jakob Bornecrantz | d8bd19d | 2010-06-01 11:54:20 +0200 | [diff] [blame] | 340 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 341 | drm_connector_init(dev, connector, &vmw_legacy_connector_funcs, |
| 342 | DRM_MODE_CONNECTOR_LVDS); |
Jakob Bornecrantz | 626ab77 | 2011-10-04 20:13:20 +0200 | [diff] [blame] | 343 | connector->status = vmw_du_connector_detect(connector, true); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 344 | |
| 345 | drm_encoder_init(dev, encoder, &vmw_legacy_encoder_funcs, |
| 346 | DRM_MODE_ENCODER_LVDS); |
| 347 | drm_mode_connector_attach_encoder(connector, encoder); |
| 348 | encoder->possible_crtcs = (1 << unit); |
| 349 | encoder->possible_clones = 0; |
| 350 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 351 | drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs); |
| 352 | |
Michel Dänzer | f01b7ba | 2011-08-31 07:42:47 +0000 | [diff] [blame] | 353 | drm_mode_crtc_set_gamma_size(crtc, 256); |
| 354 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 355 | drm_connector_attach_property(connector, |
| 356 | dev->mode_config.dirty_info_property, |
| 357 | 1); |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv) |
| 363 | { |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 364 | struct drm_device *dev = dev_priv->dev; |
| 365 | int i; |
| 366 | int ret; |
| 367 | |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 368 | if (dev_priv->ldu_priv) { |
| 369 | DRM_INFO("ldu system already on\n"); |
| 370 | return -EINVAL; |
| 371 | } |
| 372 | |
Joe Perches | 85b54e0 | 2010-10-31 22:33:53 +0000 | [diff] [blame] | 373 | dev_priv->ldu_priv = kmalloc(sizeof(*dev_priv->ldu_priv), GFP_KERNEL); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 374 | |
| 375 | if (!dev_priv->ldu_priv) |
| 376 | return -ENOMEM; |
| 377 | |
| 378 | INIT_LIST_HEAD(&dev_priv->ldu_priv->active); |
| 379 | dev_priv->ldu_priv->num_active = 0; |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 380 | dev_priv->ldu_priv->last_num_active = 0; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 381 | dev_priv->ldu_priv->fb = NULL; |
| 382 | |
| 383 | drm_mode_create_dirty_info_property(dev_priv->dev); |
| 384 | |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 385 | if (dev_priv->capabilities & SVGA_CAP_MULTIMON) { |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 386 | for (i = 0; i < VMWGFX_NUM_DISPLAY_UNITS; ++i) |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 387 | vmw_ldu_init(dev_priv, i); |
Jakob Bornecrantz | 56d1c78 | 2011-10-04 20:13:22 +0200 | [diff] [blame] | 388 | ret = drm_vblank_init(dev, VMWGFX_NUM_DISPLAY_UNITS); |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 389 | } else { |
| 390 | /* for old hardware without multimon only enable one display */ |
| 391 | vmw_ldu_init(dev_priv, 0); |
| 392 | ret = drm_vblank_init(dev, 1); |
Jakob Bornecrantz | d7e1958 | 2010-05-28 11:21:59 +0200 | [diff] [blame] | 393 | } |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 394 | |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 395 | return ret; |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | int vmw_kms_close_legacy_display_system(struct vmw_private *dev_priv) |
| 399 | { |
Thomas Hellstrom | 7a1c2f6 | 2010-10-01 10:21:49 +0200 | [diff] [blame] | 400 | struct drm_device *dev = dev_priv->dev; |
| 401 | |
| 402 | drm_vblank_cleanup(dev); |
Jakob Bornecrantz | fb1d973 | 2009-12-10 00:19:58 +0000 | [diff] [blame] | 403 | if (!dev_priv->ldu_priv) |
| 404 | return -ENOSYS; |
| 405 | |
| 406 | BUG_ON(!list_empty(&dev_priv->ldu_priv->active)); |
| 407 | |
| 408 | kfree(dev_priv->ldu_priv); |
| 409 | |
| 410 | return 0; |
| 411 | } |