2 * Copyright © 2007 David Airlie
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:
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
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.
27 #include <linux/async.h>
28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/console.h>
31 #include <linux/errno.h>
32 #include <linux/string.h>
34 #include <linux/tty.h>
35 #include <linux/sysrq.h>
36 #include <linux/delay.h>
38 #include <linux/init.h>
39 #include <linux/vga_switcheroo.h>
42 #include <drm/drm_crtc.h>
43 #include <drm/drm_fb_helper.h>
44 #include "intel_drv.h"
45 #include <drm/i915_drm.h>
48 static int intel_fbdev_set_par(struct fb_info *info)
50 struct drm_fb_helper *fb_helper = info->par;
51 struct intel_fbdev *ifbdev =
52 container_of(fb_helper, struct intel_fbdev, helper);
55 ret = drm_fb_helper_set_par(info);
58 mutex_lock(&fb_helper->dev->struct_mutex);
59 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
60 mutex_unlock(&fb_helper->dev->struct_mutex);
66 static int intel_fbdev_blank(int blank, struct fb_info *info)
68 struct drm_fb_helper *fb_helper = info->par;
69 struct intel_fbdev *ifbdev =
70 container_of(fb_helper, struct intel_fbdev, helper);
73 ret = drm_fb_helper_blank(blank, info);
76 mutex_lock(&fb_helper->dev->struct_mutex);
77 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
78 mutex_unlock(&fb_helper->dev->struct_mutex);
84 static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,
87 struct drm_fb_helper *fb_helper = info->par;
88 struct intel_fbdev *ifbdev =
89 container_of(fb_helper, struct intel_fbdev, helper);
92 ret = drm_fb_helper_pan_display(var, info);
95 mutex_lock(&fb_helper->dev->struct_mutex);
96 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
97 mutex_unlock(&fb_helper->dev->struct_mutex);
103 static struct fb_ops intelfb_ops = {
104 .owner = THIS_MODULE,
105 .fb_check_var = drm_fb_helper_check_var,
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 .fb_setcmap = drm_fb_helper_setcmap,
113 .fb_debug_enter = drm_fb_helper_debug_enter,
114 .fb_debug_leave = drm_fb_helper_debug_leave,
117 static int intelfb_alloc(struct drm_fb_helper *helper,
118 struct drm_fb_helper_surface_size *sizes)
120 struct intel_fbdev *ifbdev =
121 container_of(helper, struct intel_fbdev, helper);
122 struct drm_framebuffer *fb = NULL;
123 struct drm_device *dev = helper->dev;
124 struct drm_i915_private *dev_priv = to_i915(dev);
125 struct drm_mode_fb_cmd2 mode_cmd = {};
126 struct drm_i915_gem_object *obj = NULL;
129 /* we don't do packed 24bpp */
130 if (sizes->surface_bpp == 24)
131 sizes->surface_bpp = 32;
133 mode_cmd.width = sizes->surface_width;
134 mode_cmd.height = sizes->surface_height;
136 mode_cmd.pitches[0] = ALIGN(mode_cmd.width *
137 DIV_ROUND_UP(sizes->surface_bpp, 8), 64);
138 mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
139 sizes->surface_depth);
141 mutex_lock(&dev->struct_mutex);
143 size = mode_cmd.pitches[0] * mode_cmd.height;
144 size = PAGE_ALIGN(size);
146 /* If the FB is too big, just don't use it since fbdev is not very
147 * important and we should probably use that space with FBC or other
149 if (size * 2 < dev_priv->gtt.stolen_usable_size)
150 obj = i915_gem_object_create_stolen(dev, size);
152 obj = i915_gem_alloc_object(dev, size);
154 DRM_ERROR("failed to allocate framebuffer\n");
159 fb = __intel_framebuffer_create(dev, &mode_cmd, obj);
161 drm_gem_object_unreference(&obj->base);
166 mutex_unlock(&dev->struct_mutex);
168 ifbdev->fb = to_intel_framebuffer(fb);
173 mutex_unlock(&dev->struct_mutex);
174 if (!IS_ERR_OR_NULL(fb))
175 drm_framebuffer_unreference(fb);
179 static int intelfb_create(struct drm_fb_helper *helper,
180 struct drm_fb_helper_surface_size *sizes)
182 struct intel_fbdev *ifbdev =
183 container_of(helper, struct intel_fbdev, helper);
184 struct intel_framebuffer *intel_fb = ifbdev->fb;
185 struct drm_device *dev = helper->dev;
186 struct drm_i915_private *dev_priv = dev->dev_private;
187 struct fb_info *info;
188 struct drm_framebuffer *fb;
189 struct drm_i915_gem_object *obj;
191 bool prealloc = false;
194 (sizes->fb_width > intel_fb->base.width ||
195 sizes->fb_height > intel_fb->base.height)) {
196 DRM_DEBUG_KMS("BIOS fb too small (%dx%d), we require (%dx%d),"
198 intel_fb->base.width, intel_fb->base.height,
199 sizes->fb_width, sizes->fb_height);
200 drm_framebuffer_unreference(&intel_fb->base);
201 intel_fb = ifbdev->fb = NULL;
203 if (!intel_fb || WARN_ON(!intel_fb->obj)) {
204 DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
205 ret = intelfb_alloc(helper, sizes);
208 intel_fb = ifbdev->fb;
210 DRM_DEBUG_KMS("re-using BIOS fb\n");
212 sizes->fb_width = intel_fb->base.width;
213 sizes->fb_height = intel_fb->base.height;
217 size = obj->base.size;
219 mutex_lock(&dev->struct_mutex);
221 /* Pin the GGTT vma for our access via info->screen_base.
222 * This also validates that any existing fb inherited from the
223 * BIOS is suitable for own access.
225 ret = intel_pin_and_fence_fb_obj(NULL, &ifbdev->fb->base, NULL);
229 info = drm_fb_helper_alloc_fbi(helper);
231 DRM_ERROR("Failed to allocate fb_info\n");
238 fb = &ifbdev->fb->base;
240 ifbdev->helper.fb = fb;
242 strcpy(info->fix.id, "inteldrmfb");
244 info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
245 info->fbops = &intelfb_ops;
247 /* setup aperture base/size for vesafb takeover */
248 info->apertures->ranges[0].base = dev->mode_config.fb_base;
249 info->apertures->ranges[0].size = dev_priv->gtt.mappable_end;
251 info->fix.smem_start = dev->mode_config.fb_base + i915_gem_obj_ggtt_offset(obj);
252 info->fix.smem_len = size;
255 ioremap_wc(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj),
257 if (!info->screen_base) {
258 DRM_ERROR("Failed to remap framebuffer into virtual memory\n");
260 goto out_destroy_fbi;
262 info->screen_size = size;
264 /* This driver doesn't need a VT switch to restore the mode on resume */
265 info->skip_vt_switch = true;
267 drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
268 drm_fb_helper_fill_var(info, &ifbdev->helper, sizes->fb_width, sizes->fb_height);
270 /* If the object is shmemfs backed, it will have given us zeroed pages.
271 * If the object is stolen however, it will be full of whatever
272 * garbage was left in there.
274 if (ifbdev->fb->obj->stolen && !prealloc)
275 memset_io(info->screen_base, 0, info->screen_size);
277 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
279 DRM_DEBUG_KMS("allocated %dx%d fb: 0x%08llx, bo %p\n",
280 fb->width, fb->height,
281 i915_gem_obj_ggtt_offset(obj), obj);
283 mutex_unlock(&dev->struct_mutex);
284 vga_switcheroo_client_fb_set(dev->pdev, info);
288 drm_fb_helper_release_fbi(helper);
290 i915_gem_object_ggtt_unpin(obj);
292 mutex_unlock(&dev->struct_mutex);
296 /** Sets the color ramps on behalf of RandR */
297 static void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
300 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
302 intel_crtc->lut_r[regno] = red >> 8;
303 intel_crtc->lut_g[regno] = green >> 8;
304 intel_crtc->lut_b[regno] = blue >> 8;
307 static void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
308 u16 *blue, int regno)
310 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
312 *red = intel_crtc->lut_r[regno] << 8;
313 *green = intel_crtc->lut_g[regno] << 8;
314 *blue = intel_crtc->lut_b[regno] << 8;
317 static struct drm_fb_helper_crtc *
318 intel_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc)
322 for (i = 0; i < fb_helper->crtc_count; i++)
323 if (fb_helper->crtc_info[i].mode_set.crtc == crtc)
324 return &fb_helper->crtc_info[i];
330 * Try to read the BIOS display configuration and use it for the initial
333 * The BIOS or boot loader will generally create an initial display
334 * configuration for us that includes some set of active pipes and displays.
335 * This routine tries to figure out which pipes and connectors are active
336 * and stuffs them into the crtcs and modes array given to us by the
337 * drm_fb_helper code.
339 * The overall sequence is:
340 * intel_fbdev_init - from driver load
341 * intel_fbdev_init_bios - initialize the intel_fbdev using BIOS data
342 * drm_fb_helper_init - build fb helper structs
343 * drm_fb_helper_single_add_all_connectors - more fb helper structs
344 * intel_fbdev_initial_config - apply the config
345 * drm_fb_helper_initial_config - call ->probe then register_framebuffer()
346 * drm_setup_crtcs - build crtc config for fbdev
347 * intel_fb_initial_config - find active connectors etc
348 * drm_fb_helper_single_fb_probe - set up fbdev
349 * intelfb_create - re-use or alloc fb, build out fbdev structs
351 * Note that we don't make special consideration whether we could actually
352 * switch to the selected modes without a full modeset. E.g. when the display
353 * is in VGA mode we need to recalculate watermarks and set a new high-res
354 * framebuffer anyway.
356 static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
357 struct drm_fb_helper_crtc **crtcs,
358 struct drm_display_mode **modes,
359 struct drm_fb_offset *offsets,
360 bool *enabled, int width, int height)
362 struct drm_device *dev = fb_helper->dev;
365 bool fallback = true;
366 int num_connectors_enabled = 0;
367 int num_connectors_detected = 0;
368 uint64_t conn_configured = 0, mask;
371 save_enabled = kcalloc(dev->mode_config.num_connector, sizeof(bool),
376 memcpy(save_enabled, enabled, dev->mode_config.num_connector);
377 mask = (1 << fb_helper->connector_count) - 1;
379 for (i = 0; i < fb_helper->connector_count; i++) {
380 struct drm_fb_helper_connector *fb_conn;
381 struct drm_connector *connector;
382 struct drm_encoder *encoder;
383 struct drm_fb_helper_crtc *new_crtc;
385 fb_conn = fb_helper->connector_info[i];
386 connector = fb_conn->connector;
388 if (conn_configured & (1 << i))
391 if (pass == 0 && !connector->has_tile)
394 if (connector->status == connector_status_connected)
395 num_connectors_detected++;
398 DRM_DEBUG_KMS("connector %s not enabled, skipping\n",
400 conn_configured |= (1 << i);
404 if (connector->force == DRM_FORCE_OFF) {
405 DRM_DEBUG_KMS("connector %s is disabled by user, skipping\n",
411 encoder = connector->encoder;
412 if (!encoder || WARN_ON(!encoder->crtc)) {
413 if (connector->force > DRM_FORCE_OFF)
416 DRM_DEBUG_KMS("connector %s has no encoder or crtc, skipping\n",
419 conn_configured |= (1 << i);
423 num_connectors_enabled++;
425 new_crtc = intel_fb_helper_crtc(fb_helper, encoder->crtc);
428 * Make sure we're not trying to drive multiple connectors
429 * with a single CRTC, since our cloning support may not
432 for (j = 0; j < fb_helper->connector_count; j++) {
433 if (crtcs[j] == new_crtc) {
434 DRM_DEBUG_KMS("fallback: cloned configuration\n");
439 DRM_DEBUG_KMS("looking for cmdline mode on connector %s\n",
442 /* go for command line mode first */
443 modes[i] = drm_pick_cmdline_mode(fb_conn, width, height);
445 /* try for preferred next */
447 DRM_DEBUG_KMS("looking for preferred mode on connector %s %d\n",
448 connector->name, connector->has_tile);
449 modes[i] = drm_has_preferred_mode(fb_conn, width,
453 /* No preferred mode marked by the EDID? Are there any modes? */
454 if (!modes[i] && !list_empty(&connector->modes)) {
455 DRM_DEBUG_KMS("using first mode listed on connector %s\n",
457 modes[i] = list_first_entry(&connector->modes,
458 struct drm_display_mode,
462 /* last resort: use current mode */
465 * IMPORTANT: We want to use the adjusted mode (i.e.
466 * after the panel fitter upscaling) as the initial
467 * config, not the input mode, which is what crtc->mode
468 * usually contains. But since our current
469 * code puts a mode derived from the post-pfit timings
470 * into crtc->mode this works out correctly.
472 DRM_DEBUG_KMS("looking for current mode on connector %s\n",
474 modes[i] = &encoder->crtc->mode;
478 DRM_DEBUG_KMS("connector %s on pipe %c [CRTC:%d]: %dx%d%s\n",
480 pipe_name(to_intel_crtc(encoder->crtc)->pipe),
481 encoder->crtc->base.id,
482 modes[i]->hdisplay, modes[i]->vdisplay,
483 modes[i]->flags & DRM_MODE_FLAG_INTERLACE ? "i" :"");
486 conn_configured |= (1 << i);
489 if ((conn_configured & mask) != mask) {
495 * If the BIOS didn't enable everything it could, fall back to have the
496 * same user experiencing of lighting up as much as possible like the
497 * fbdev helper library.
499 if (num_connectors_enabled != num_connectors_detected &&
500 num_connectors_enabled < INTEL_INFO(dev)->num_pipes) {
501 DRM_DEBUG_KMS("fallback: Not all outputs enabled\n");
502 DRM_DEBUG_KMS("Enabled: %i, detected: %i\n", num_connectors_enabled,
503 num_connectors_detected);
509 DRM_DEBUG_KMS("Not using firmware configuration\n");
510 memcpy(enabled, save_enabled, dev->mode_config.num_connector);
519 static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
520 .initial_config = intel_fb_initial_config,
521 .gamma_set = intel_crtc_fb_gamma_set,
522 .gamma_get = intel_crtc_fb_gamma_get,
523 .fb_probe = intelfb_create,
526 static void intel_fbdev_destroy(struct drm_device *dev,
527 struct intel_fbdev *ifbdev)
529 /* We rely on the object-free to release the VMA pinning for
530 * the info->screen_base mmaping. Leaking the VMA is simpler than
531 * trying to rectify all the possible error paths leading here.
534 drm_fb_helper_unregister_fbi(&ifbdev->helper);
535 drm_fb_helper_release_fbi(&ifbdev->helper);
537 drm_fb_helper_fini(&ifbdev->helper);
540 drm_framebuffer_unregister_private(&ifbdev->fb->base);
541 drm_framebuffer_remove(&ifbdev->fb->base);
546 * Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible.
547 * The core display code will have read out the current plane configuration,
548 * so we use that to figure out if there's an object for us to use as the
549 * fb, and if so, we re-use it for the fbdev configuration.
551 * Note we only support a single fb shared across pipes for boot (mostly for
552 * fbcon), so we just find the biggest and use that.
554 static bool intel_fbdev_init_bios(struct drm_device *dev,
555 struct intel_fbdev *ifbdev)
557 struct intel_framebuffer *fb = NULL;
558 struct drm_crtc *crtc;
559 struct intel_crtc *intel_crtc;
560 unsigned int max_size = 0;
562 /* Find the largest fb */
563 for_each_crtc(dev, crtc) {
564 struct drm_i915_gem_object *obj =
565 intel_fb_obj(crtc->primary->state->fb);
566 intel_crtc = to_intel_crtc(crtc);
568 if (!crtc->state->active || !obj) {
569 DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
570 pipe_name(intel_crtc->pipe));
574 if (obj->base.size > max_size) {
575 DRM_DEBUG_KMS("found possible fb from plane %c\n",
576 pipe_name(intel_crtc->pipe));
577 fb = to_intel_framebuffer(crtc->primary->state->fb);
578 max_size = obj->base.size;
583 DRM_DEBUG_KMS("no active fbs found, not using BIOS config\n");
587 /* Now make sure all the pipes will fit into it */
588 for_each_crtc(dev, crtc) {
589 unsigned int cur_size;
591 intel_crtc = to_intel_crtc(crtc);
593 if (!crtc->state->active) {
594 DRM_DEBUG_KMS("pipe %c not active, skipping\n",
595 pipe_name(intel_crtc->pipe));
599 DRM_DEBUG_KMS("checking plane %c for BIOS fb\n",
600 pipe_name(intel_crtc->pipe));
603 * See if the plane fb we found above will fit on this
604 * pipe. Note we need to use the selected fb's pitch and bpp
605 * rather than the current pipe's, since they differ.
607 cur_size = intel_crtc->config->base.adjusted_mode.crtc_hdisplay;
608 cur_size = cur_size * fb->base.bits_per_pixel / 8;
609 if (fb->base.pitches[0] < cur_size) {
610 DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
611 pipe_name(intel_crtc->pipe),
612 cur_size, fb->base.pitches[0]);
617 cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay;
618 cur_size = intel_fb_align_height(dev, cur_size,
619 fb->base.pixel_format,
620 fb->base.modifier[0]);
621 cur_size *= fb->base.pitches[0];
622 DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
623 pipe_name(intel_crtc->pipe),
624 intel_crtc->config->base.adjusted_mode.crtc_hdisplay,
625 intel_crtc->config->base.adjusted_mode.crtc_vdisplay,
626 fb->base.bits_per_pixel,
629 if (cur_size > max_size) {
630 DRM_DEBUG_KMS("fb not big enough for plane %c (%d vs %d)\n",
631 pipe_name(intel_crtc->pipe),
637 DRM_DEBUG_KMS("fb big enough for plane %c (%d >= %d)\n",
638 pipe_name(intel_crtc->pipe),
643 DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n");
647 ifbdev->preferred_bpp = fb->base.bits_per_pixel;
650 drm_framebuffer_reference(&ifbdev->fb->base);
652 /* Final pass to check if any active pipes don't have fbs */
653 for_each_crtc(dev, crtc) {
654 intel_crtc = to_intel_crtc(crtc);
656 if (!crtc->state->active)
659 WARN(!crtc->primary->fb,
660 "re-used BIOS config but lost an fb on crtc %d\n",
665 DRM_DEBUG_KMS("using BIOS fb for initial console\n");
673 static void intel_fbdev_suspend_worker(struct work_struct *work)
675 intel_fbdev_set_suspend(container_of(work,
676 struct drm_i915_private,
677 fbdev_suspend_work)->dev,
678 FBINFO_STATE_RUNNING,
682 int intel_fbdev_init(struct drm_device *dev)
684 struct intel_fbdev *ifbdev;
685 struct drm_i915_private *dev_priv = dev->dev_private;
688 if (WARN_ON(INTEL_INFO(dev)->num_pipes == 0))
691 ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL);
695 drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs);
697 if (!intel_fbdev_init_bios(dev, ifbdev))
698 ifbdev->preferred_bpp = 32;
700 ret = drm_fb_helper_init(dev, &ifbdev->helper,
701 INTEL_INFO(dev)->num_pipes, 4);
707 ifbdev->helper.atomic = true;
709 dev_priv->fbdev = ifbdev;
710 INIT_WORK(&dev_priv->fbdev_suspend_work, intel_fbdev_suspend_worker);
712 drm_fb_helper_single_add_all_connectors(&ifbdev->helper);
717 static void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
719 struct drm_i915_private *dev_priv = data;
720 struct intel_fbdev *ifbdev = dev_priv->fbdev;
722 /* Due to peculiar init order wrt to hpd handling this is separate. */
723 if (drm_fb_helper_initial_config(&ifbdev->helper,
724 ifbdev->preferred_bpp))
725 intel_fbdev_fini(dev_priv->dev);
728 void intel_fbdev_initial_config_async(struct drm_device *dev)
730 async_schedule(intel_fbdev_initial_config, to_i915(dev));
733 void intel_fbdev_fini(struct drm_device *dev)
735 struct drm_i915_private *dev_priv = dev->dev_private;
736 if (!dev_priv->fbdev)
739 flush_work(&dev_priv->fbdev_suspend_work);
741 if (!current_is_async())
742 async_synchronize_full();
743 intel_fbdev_destroy(dev, dev_priv->fbdev);
744 kfree(dev_priv->fbdev);
745 dev_priv->fbdev = NULL;
748 void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
750 struct drm_i915_private *dev_priv = dev->dev_private;
751 struct intel_fbdev *ifbdev = dev_priv->fbdev;
752 struct fb_info *info;
757 info = ifbdev->helper.fbdev;
760 /* Flush any pending work to turn the console on, and then
761 * wait to turn it off. It must be synchronous as we are
762 * about to suspend or unload the driver.
764 * Note that from within the work-handler, we cannot flush
765 * ourselves, so only flush outstanding work upon suspend!
767 if (state != FBINFO_STATE_RUNNING)
768 flush_work(&dev_priv->fbdev_suspend_work);
772 * The console lock can be pretty contented on resume due
773 * to all the printk activity. Try to keep it out of the hot
774 * path of resume if possible.
776 WARN_ON(state != FBINFO_STATE_RUNNING);
777 if (!console_trylock()) {
778 /* Don't block our own workqueue as this can
779 * be run in parallel with other i915.ko tasks.
781 schedule_work(&dev_priv->fbdev_suspend_work);
786 /* On resume from hibernation: If the object is shmemfs backed, it has
787 * been restored from swap. If the object is stolen however, it will be
788 * full of whatever garbage was left in there.
790 if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
791 memset_io(info->screen_base, 0, info->screen_size);
793 drm_fb_helper_set_suspend(&ifbdev->helper, state);
797 void intel_fbdev_output_poll_changed(struct drm_device *dev)
799 struct drm_i915_private *dev_priv = dev->dev_private;
801 drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper);
804 void intel_fbdev_restore_mode(struct drm_device *dev)
807 struct drm_i915_private *dev_priv = dev->dev_private;
808 struct intel_fbdev *ifbdev = dev_priv->fbdev;
809 struct drm_fb_helper *fb_helper;
814 fb_helper = &ifbdev->helper;
816 ret = drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper);
818 DRM_DEBUG("failed to restore crtc mode\n");
820 mutex_lock(&fb_helper->dev->struct_mutex);
821 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
822 mutex_unlock(&fb_helper->dev->struct_mutex);