1 /* 2 * Copyright © 2007 David Airlie 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 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: 24 * David Airlie 25 */ 26 27 #include <linux/async.h> 28 #include <linux/console.h> 29 #include <linux/delay.h> 30 #include <linux/errno.h> 31 #include <linux/init.h> 32 #include <linux/kernel.h> 33 #include <linux/mm.h> 34 #include <linux/module.h> 35 #include <linux/string.h> 36 #include <linux/sysrq.h> 37 #include <linux/tty.h> 38 #include <linux/vga_switcheroo.h> 39 40 #include <drm/drm_crtc.h> 41 #include <drm/drm_fb_helper.h> 42 #include <drm/drm_fourcc.h> 43 44 #include "i915_drv.h" 45 #include "intel_display_types.h" 46 #include "intel_fbdev.h" 47 #include "intel_frontbuffer.h" 48 49 static struct intel_frontbuffer *to_frontbuffer(struct intel_fbdev *ifbdev) 50 { 51 return ifbdev->fb->frontbuffer; 52 } 53 54 static void intel_fbdev_invalidate(struct intel_fbdev *ifbdev) 55 { 56 intel_frontbuffer_invalidate(to_frontbuffer(ifbdev), ORIGIN_CPU); 57 } 58 59 static int intel_fbdev_set_par(struct fb_info *info) 60 { 61 struct drm_fb_helper *fb_helper = info->par; 62 struct intel_fbdev *ifbdev = 63 container_of(fb_helper, struct intel_fbdev, helper); 64 int ret; 65 66 ret = drm_fb_helper_set_par(info); 67 if (ret == 0) 68 intel_fbdev_invalidate(ifbdev); 69 70 return ret; 71 } 72 73 static int intel_fbdev_blank(int blank, struct fb_info *info) 74 { 75 struct drm_fb_helper *fb_helper = info->par; 76 struct intel_fbdev *ifbdev = 77 container_of(fb_helper, struct intel_fbdev, helper); 78 int ret; 79 80 ret = drm_fb_helper_blank(blank, info); 81 if (ret == 0) 82 intel_fbdev_invalidate(ifbdev); 83 84 return ret; 85 } 86 87 static int intel_fbdev_pan_display(struct fb_var_screeninfo *var, 88 struct fb_info *info) 89 { 90 struct drm_fb_helper *fb_helper = info->par; 91 struct intel_fbdev *ifbdev = 92 container_of(fb_helper, struct intel_fbdev, helper); 93 int ret; 94 95 ret = drm_fb_helper_pan_display(var, info); 96 if (ret == 0) 97 intel_fbdev_invalidate(ifbdev); 98 99 return ret; 100 } 101 102 #ifdef notyet 103 static const struct fb_ops intelfb_ops = { 104 .owner = THIS_MODULE, 105 DRM_FB_HELPER_DEFAULT_OPS, 106 .fb_set_par = intel_fbdev_set_par, 107 .fb_fillrect = drm_fb_helper_cfb_fillrect, 108 .fb_copyarea = drm_fb_helper_cfb_copyarea, 109 .fb_imageblit = drm_fb_helper_cfb_imageblit, 110 .fb_pan_display = intel_fbdev_pan_display, 111 .fb_blank = intel_fbdev_blank, 112 }; 113 #endif 114 115 static int intelfb_alloc(struct drm_fb_helper *helper, 116 struct drm_fb_helper_surface_size *sizes) 117 { 118 struct intel_fbdev *ifbdev = 119 container_of(helper, struct intel_fbdev, helper); 120 struct drm_framebuffer *fb; 121 struct drm_device *dev = helper->dev; 122 struct drm_i915_private *dev_priv = to_i915(dev); 123 struct drm_mode_fb_cmd2 mode_cmd = {}; 124 struct drm_i915_gem_object *obj; 125 int size; 126 127 /* we don't do packed 24bpp */ 128 if (sizes->surface_bpp == 24) 129 sizes->surface_bpp = 32; 130 131 mode_cmd.width = sizes->surface_width; 132 mode_cmd.height = sizes->surface_height; 133 134 mode_cmd.pitches[0] = roundup2(mode_cmd.width * 135 DIV_ROUND_UP(sizes->surface_bpp, 8), 64); 136 mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, 137 sizes->surface_depth); 138 139 size = mode_cmd.pitches[0] * mode_cmd.height; 140 size = PAGE_ALIGN(size); 141 142 /* If the FB is too big, just don't use it since fbdev is not very 143 * important and we should probably use that space with FBC or other 144 * features. */ 145 obj = ERR_PTR(-ENODEV); 146 if (size * 2 < dev_priv->stolen_usable_size) 147 obj = i915_gem_object_create_stolen(dev_priv, size); 148 if (IS_ERR(obj)) 149 obj = i915_gem_object_create_shmem(dev_priv, size); 150 if (IS_ERR(obj)) { 151 DRM_ERROR("failed to allocate framebuffer\n"); 152 return PTR_ERR(obj); 153 } 154 155 fb = intel_framebuffer_create(obj, &mode_cmd); 156 i915_gem_object_put(obj); 157 if (IS_ERR(fb)) 158 return PTR_ERR(fb); 159 160 ifbdev->fb = to_intel_framebuffer(fb); 161 return 0; 162 } 163 164 static int intelfb_create(struct drm_fb_helper *helper, 165 struct drm_fb_helper_surface_size *sizes) 166 { 167 struct intel_fbdev *ifbdev = 168 container_of(helper, struct intel_fbdev, helper); 169 struct intel_framebuffer *intel_fb = ifbdev->fb; 170 struct drm_device *dev = helper->dev; 171 struct drm_i915_private *dev_priv = to_i915(dev); 172 struct pci_dev *pdev = dev_priv->drm.pdev; 173 struct i915_ggtt *ggtt = &dev_priv->ggtt; 174 const struct i915_ggtt_view view = { 175 .type = I915_GGTT_VIEW_NORMAL, 176 }; 177 intel_wakeref_t wakeref; 178 struct fb_info *info; 179 struct i915_vma *vma; 180 unsigned long flags = 0; 181 bool prealloc = false; 182 void __iomem *vaddr; 183 int ret; 184 185 if (intel_fb && 186 (sizes->fb_width > intel_fb->base.width || 187 sizes->fb_height > intel_fb->base.height)) { 188 DRM_DEBUG_KMS("BIOS fb too small (%dx%d), we require (%dx%d)," 189 " releasing it\n", 190 intel_fb->base.width, intel_fb->base.height, 191 sizes->fb_width, sizes->fb_height); 192 drm_framebuffer_put(&intel_fb->base); 193 intel_fb = ifbdev->fb = NULL; 194 } 195 if (!intel_fb || drm_WARN_ON(dev, !intel_fb_obj(&intel_fb->base))) { 196 DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n"); 197 ret = intelfb_alloc(helper, sizes); 198 if (ret) 199 return ret; 200 intel_fb = ifbdev->fb; 201 } else { 202 DRM_DEBUG_KMS("re-using BIOS fb\n"); 203 prealloc = true; 204 sizes->fb_width = intel_fb->base.width; 205 sizes->fb_height = intel_fb->base.height; 206 } 207 208 wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm); 209 210 /* Pin the GGTT vma for our access via info->screen_base. 211 * This also validates that any existing fb inherited from the 212 * BIOS is suitable for own access. 213 */ 214 vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base, 215 &view, false, &flags); 216 if (IS_ERR(vma)) { 217 ret = PTR_ERR(vma); 218 goto out_unlock; 219 } 220 221 intel_frontbuffer_flush(to_frontbuffer(ifbdev), ORIGIN_DIRTYFB); 222 223 info = drm_fb_helper_alloc_fbi(helper); 224 if (IS_ERR(info)) { 225 DRM_ERROR("Failed to allocate fb_info\n"); 226 ret = PTR_ERR(info); 227 goto out_unpin; 228 } 229 230 ifbdev->helper.fb = &ifbdev->fb->base; 231 232 #ifdef __linux__ 233 info->fbops = &intelfb_ops; 234 235 /* setup aperture base/size for vesafb takeover */ 236 info->apertures->ranges[0].base = ggtt->gmadr.start; 237 info->apertures->ranges[0].size = ggtt->mappable_end; 238 239 /* Our framebuffer is the entirety of fbdev's system memory */ 240 info->fix.smem_start = 241 (unsigned long)(ggtt->gmadr.start + vma->node.start); 242 info->fix.smem_len = vma->node.size; 243 244 vaddr = i915_vma_pin_iomap(vma); 245 if (IS_ERR(vaddr)) { 246 DRM_ERROR("Failed to remap framebuffer into virtual memory\n"); 247 ret = PTR_ERR(vaddr); 248 goto out_unpin; 249 } 250 info->screen_base = vaddr; 251 info->screen_size = vma->node.size; 252 253 drm_fb_helper_fill_info(info, &ifbdev->helper, sizes); 254 255 /* If the object is shmemfs backed, it will have given us zeroed pages. 256 * If the object is stolen however, it will be full of whatever 257 * garbage was left in there. 258 */ 259 if (vma->obj->stolen && !prealloc) 260 memset_io(info->screen_base, 0, info->screen_size); 261 262 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ 263 #else 264 { 265 struct drm_framebuffer *fb = ifbdev->helper.fb; 266 struct rasops_info *ri = &dev_priv->ro; 267 bus_space_handle_t bsh; 268 int err; 269 270 vaddr = i915_vma_pin_iomap(vma); 271 if (IS_ERR(vaddr)) { 272 DRM_ERROR("Failed to remap framebuffer into virtual memory\n"); 273 ret = PTR_ERR(vaddr); 274 goto out_unpin; 275 } 276 277 drm_fb_helper_fill_info(info, &ifbdev->helper, sizes); 278 279 ri->ri_bits = vaddr; 280 ri->ri_depth = fb->format->cpp[0] * 8; 281 ri->ri_stride = fb->pitches[0]; 282 ri->ri_width = sizes->fb_width; 283 ri->ri_height = sizes->fb_height; 284 285 switch (fb->format->format) { 286 case DRM_FORMAT_XRGB8888: 287 ri->ri_rnum = 8; 288 ri->ri_rpos = 16; 289 ri->ri_gnum = 8; 290 ri->ri_gpos = 8; 291 ri->ri_bnum = 8; 292 ri->ri_bpos = 0; 293 break; 294 case DRM_FORMAT_RGB565: 295 ri->ri_rnum = 5; 296 ri->ri_rpos = 11; 297 ri->ri_gnum = 6; 298 ri->ri_gpos = 5; 299 ri->ri_bnum = 5; 300 ri->ri_bpos = 0; 301 break; 302 } 303 304 if (vma->obj->stolen && !prealloc) 305 memset(ri->ri_bits, 0, vma->node.size); 306 } 307 #endif 308 309 DRM_DEBUG_KMS("allocated %dx%d fb: 0x%08x\n", 310 ifbdev->fb->base.width, ifbdev->fb->base.height, 311 i915_ggtt_offset(vma)); 312 ifbdev->vma = vma; 313 ifbdev->vma_flags = flags; 314 315 intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref); 316 vga_switcheroo_client_fb_set(pdev, info); 317 return 0; 318 319 out_unpin: 320 intel_unpin_fb_vma(vma, flags); 321 out_unlock: 322 intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref); 323 return ret; 324 } 325 326 static const struct drm_fb_helper_funcs intel_fb_helper_funcs = { 327 .fb_probe = intelfb_create, 328 }; 329 330 static void intel_fbdev_destroy(struct intel_fbdev *ifbdev) 331 { 332 /* We rely on the object-free to release the VMA pinning for 333 * the info->screen_base mmaping. Leaking the VMA is simpler than 334 * trying to rectify all the possible error paths leading here. 335 */ 336 337 drm_fb_helper_fini(&ifbdev->helper); 338 339 if (ifbdev->vma) 340 intel_unpin_fb_vma(ifbdev->vma, ifbdev->vma_flags); 341 342 if (ifbdev->fb) 343 drm_framebuffer_remove(&ifbdev->fb->base); 344 345 kfree(ifbdev); 346 } 347 348 /* 349 * Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible. 350 * The core display code will have read out the current plane configuration, 351 * so we use that to figure out if there's an object for us to use as the 352 * fb, and if so, we re-use it for the fbdev configuration. 353 * 354 * Note we only support a single fb shared across pipes for boot (mostly for 355 * fbcon), so we just find the biggest and use that. 356 */ 357 static bool intel_fbdev_init_bios(struct drm_device *dev, 358 struct intel_fbdev *ifbdev) 359 { 360 struct intel_framebuffer *fb = NULL; 361 struct drm_crtc *crtc; 362 struct intel_crtc *intel_crtc; 363 unsigned int max_size = 0; 364 365 /* Find the largest fb */ 366 for_each_crtc(dev, crtc) { 367 struct drm_i915_gem_object *obj = 368 intel_fb_obj(crtc->primary->state->fb); 369 intel_crtc = to_intel_crtc(crtc); 370 371 if (!crtc->state->active || !obj) { 372 DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n", 373 pipe_name(intel_crtc->pipe)); 374 continue; 375 } 376 377 if (obj->base.size > max_size) { 378 DRM_DEBUG_KMS("found possible fb from plane %c\n", 379 pipe_name(intel_crtc->pipe)); 380 fb = to_intel_framebuffer(crtc->primary->state->fb); 381 max_size = obj->base.size; 382 } 383 } 384 385 if (!fb) { 386 DRM_DEBUG_KMS("no active fbs found, not using BIOS config\n"); 387 goto out; 388 } 389 390 /* Now make sure all the pipes will fit into it */ 391 for_each_crtc(dev, crtc) { 392 unsigned int cur_size; 393 394 intel_crtc = to_intel_crtc(crtc); 395 396 if (!crtc->state->active) { 397 DRM_DEBUG_KMS("pipe %c not active, skipping\n", 398 pipe_name(intel_crtc->pipe)); 399 continue; 400 } 401 402 DRM_DEBUG_KMS("checking plane %c for BIOS fb\n", 403 pipe_name(intel_crtc->pipe)); 404 405 /* 406 * See if the plane fb we found above will fit on this 407 * pipe. Note we need to use the selected fb's pitch and bpp 408 * rather than the current pipe's, since they differ. 409 */ 410 cur_size = crtc->state->adjusted_mode.crtc_hdisplay; 411 cur_size = cur_size * fb->base.format->cpp[0]; 412 if (fb->base.pitches[0] < cur_size) { 413 DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n", 414 pipe_name(intel_crtc->pipe), 415 cur_size, fb->base.pitches[0]); 416 fb = NULL; 417 break; 418 } 419 420 cur_size = crtc->state->adjusted_mode.crtc_vdisplay; 421 cur_size = intel_fb_align_height(&fb->base, 0, cur_size); 422 cur_size *= fb->base.pitches[0]; 423 DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n", 424 pipe_name(intel_crtc->pipe), 425 crtc->state->adjusted_mode.crtc_hdisplay, 426 crtc->state->adjusted_mode.crtc_vdisplay, 427 fb->base.format->cpp[0] * 8, 428 cur_size); 429 430 if (cur_size > max_size) { 431 DRM_DEBUG_KMS("fb not big enough for plane %c (%d vs %d)\n", 432 pipe_name(intel_crtc->pipe), 433 cur_size, max_size); 434 fb = NULL; 435 break; 436 } 437 438 DRM_DEBUG_KMS("fb big enough for plane %c (%d >= %d)\n", 439 pipe_name(intel_crtc->pipe), 440 max_size, cur_size); 441 } 442 443 if (!fb) { 444 DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n"); 445 goto out; 446 } 447 448 ifbdev->preferred_bpp = fb->base.format->cpp[0] * 8; 449 ifbdev->fb = fb; 450 451 drm_framebuffer_get(&ifbdev->fb->base); 452 453 /* Final pass to check if any active pipes don't have fbs */ 454 for_each_crtc(dev, crtc) { 455 intel_crtc = to_intel_crtc(crtc); 456 457 if (!crtc->state->active) 458 continue; 459 460 drm_WARN(dev, !crtc->primary->state->fb, 461 "re-used BIOS config but lost an fb on crtc %d\n", 462 crtc->base.id); 463 } 464 465 466 DRM_DEBUG_KMS("using BIOS fb for initial console\n"); 467 return true; 468 469 out: 470 471 return false; 472 } 473 474 static void intel_fbdev_suspend_worker(struct work_struct *work) 475 { 476 intel_fbdev_set_suspend(&container_of(work, 477 struct drm_i915_private, 478 fbdev_suspend_work)->drm, 479 FBINFO_STATE_RUNNING, 480 true); 481 } 482 483 int intel_fbdev_init(struct drm_device *dev) 484 { 485 struct drm_i915_private *dev_priv = to_i915(dev); 486 struct intel_fbdev *ifbdev; 487 int ret; 488 489 if (drm_WARN_ON(dev, !HAS_DISPLAY(dev_priv) || 490 !INTEL_DISPLAY_ENABLED(dev_priv))) 491 return -ENODEV; 492 493 ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL); 494 if (ifbdev == NULL) 495 return -ENOMEM; 496 497 rw_init(&ifbdev->hpd_lock, "hdplk"); 498 drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs); 499 500 if (!intel_fbdev_init_bios(dev, ifbdev)) 501 ifbdev->preferred_bpp = 32; 502 503 ret = drm_fb_helper_init(dev, &ifbdev->helper); 504 if (ret) { 505 kfree(ifbdev); 506 return ret; 507 } 508 509 dev_priv->fbdev = ifbdev; 510 INIT_WORK(&dev_priv->fbdev_suspend_work, intel_fbdev_suspend_worker); 511 512 return 0; 513 } 514 515 static void intel_fbdev_initial_config(void *data, async_cookie_t cookie) 516 { 517 struct intel_fbdev *ifbdev = data; 518 519 /* Due to peculiar init order wrt to hpd handling this is separate. */ 520 if (drm_fb_helper_initial_config(&ifbdev->helper, 521 ifbdev->preferred_bpp)) 522 intel_fbdev_unregister(to_i915(ifbdev->helper.dev)); 523 } 524 525 void intel_fbdev_initial_config_async(struct drm_device *dev) 526 { 527 struct intel_fbdev *ifbdev = to_i915(dev)->fbdev; 528 529 if (!ifbdev) 530 return; 531 532 ifbdev->cookie = async_schedule(intel_fbdev_initial_config, ifbdev); 533 } 534 535 static void intel_fbdev_sync(struct intel_fbdev *ifbdev) 536 { 537 #ifdef __linux__ 538 if (!ifbdev->cookie) 539 return; 540 541 /* Only serialises with all preceding async calls, hence +1 */ 542 async_synchronize_cookie(ifbdev->cookie + 1); 543 ifbdev->cookie = 0; 544 #endif 545 } 546 547 void intel_fbdev_unregister(struct drm_i915_private *dev_priv) 548 { 549 struct intel_fbdev *ifbdev = dev_priv->fbdev; 550 551 if (!ifbdev) 552 return; 553 554 cancel_work_sync(&dev_priv->fbdev_suspend_work); 555 #ifdef __linux__ 556 if (!current_is_async()) 557 intel_fbdev_sync(ifbdev); 558 559 drm_fb_helper_unregister_fbi(&ifbdev->helper); 560 #endif 561 } 562 563 void intel_fbdev_fini(struct drm_i915_private *dev_priv) 564 { 565 struct intel_fbdev *ifbdev = fetch_and_zero(&dev_priv->fbdev); 566 567 if (!ifbdev) 568 return; 569 570 intel_fbdev_destroy(ifbdev); 571 } 572 573 /* Suspends/resumes fbdev processing of incoming HPD events. When resuming HPD 574 * processing, fbdev will perform a full connector reprobe if a hotplug event 575 * was received while HPD was suspended. 576 */ 577 static void intel_fbdev_hpd_set_suspend(struct intel_fbdev *ifbdev, int state) 578 { 579 bool send_hpd = false; 580 581 mutex_lock(&ifbdev->hpd_lock); 582 ifbdev->hpd_suspended = state == FBINFO_STATE_SUSPENDED; 583 send_hpd = !ifbdev->hpd_suspended && ifbdev->hpd_waiting; 584 ifbdev->hpd_waiting = false; 585 mutex_unlock(&ifbdev->hpd_lock); 586 587 if (send_hpd) { 588 DRM_DEBUG_KMS("Handling delayed fbcon HPD event\n"); 589 drm_fb_helper_hotplug_event(&ifbdev->helper); 590 } 591 } 592 593 void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous) 594 { 595 #ifdef __linux__ 596 struct drm_i915_private *dev_priv = to_i915(dev); 597 struct intel_fbdev *ifbdev = dev_priv->fbdev; 598 struct fb_info *info; 599 600 if (!ifbdev || !ifbdev->vma) 601 return; 602 603 info = ifbdev->helper.fbdev; 604 605 if (synchronous) { 606 /* Flush any pending work to turn the console on, and then 607 * wait to turn it off. It must be synchronous as we are 608 * about to suspend or unload the driver. 609 * 610 * Note that from within the work-handler, we cannot flush 611 * ourselves, so only flush outstanding work upon suspend! 612 */ 613 if (state != FBINFO_STATE_RUNNING) 614 flush_work(&dev_priv->fbdev_suspend_work); 615 616 console_lock(); 617 } else { 618 /* 619 * The console lock can be pretty contented on resume due 620 * to all the printk activity. Try to keep it out of the hot 621 * path of resume if possible. 622 */ 623 drm_WARN_ON(dev, state != FBINFO_STATE_RUNNING); 624 if (!console_trylock()) { 625 /* Don't block our own workqueue as this can 626 * be run in parallel with other i915.ko tasks. 627 */ 628 schedule_work(&dev_priv->fbdev_suspend_work); 629 return; 630 } 631 } 632 633 /* On resume from hibernation: If the object is shmemfs backed, it has 634 * been restored from swap. If the object is stolen however, it will be 635 * full of whatever garbage was left in there. 636 */ 637 if (state == FBINFO_STATE_RUNNING && 638 intel_fb_obj(&ifbdev->fb->base)->stolen) 639 memset_io(info->screen_base, 0, info->screen_size); 640 641 drm_fb_helper_set_suspend(&ifbdev->helper, state); 642 console_unlock(); 643 644 intel_fbdev_hpd_set_suspend(ifbdev, state); 645 #endif 646 } 647 648 void intel_fbdev_output_poll_changed(struct drm_device *dev) 649 { 650 struct intel_fbdev *ifbdev = to_i915(dev)->fbdev; 651 bool send_hpd; 652 653 if (!ifbdev) 654 return; 655 656 intel_fbdev_sync(ifbdev); 657 658 mutex_lock(&ifbdev->hpd_lock); 659 send_hpd = !ifbdev->hpd_suspended; 660 ifbdev->hpd_waiting = true; 661 mutex_unlock(&ifbdev->hpd_lock); 662 663 if (send_hpd && (ifbdev->vma || ifbdev->helper.deferred_setup)) 664 drm_fb_helper_hotplug_event(&ifbdev->helper); 665 } 666 667 void intel_fbdev_restore_mode(struct drm_device *dev) 668 { 669 struct intel_fbdev *ifbdev = to_i915(dev)->fbdev; 670 671 if (!ifbdev) 672 return; 673 674 intel_fbdev_sync(ifbdev); 675 if (!ifbdev->vma) 676 return; 677 678 if (drm_fb_helper_restore_fbdev_mode_unlocked(&ifbdev->helper) == 0) 679 intel_fbdev_invalidate(ifbdev); 680 } 681