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.
28 #include <linux/async.h>
29 #include <linux/module.h>
30 #include <linux/kernel.h>
31 #include <linux/errno.h>
32 #include <linux/string.h>
34 #include <linux/delay.h>
38 #include <drm/drm_crtc.h>
39 #include <drm/drm_fb_helper.h>
40 #include "intel_drv.h"
41 #include <drm/i915_drm.h>
45 static int intel_fbdev_set_par(struct fb_info *info)
47 struct drm_fb_helper *fb_helper = info->par;
48 struct intel_fbdev *ifbdev =
49 container_of(fb_helper, struct intel_fbdev, helper);
52 ret = drm_fb_helper_set_par(info);
55 mutex_lock(&fb_helper->dev->struct_mutex);
56 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
57 mutex_unlock(&fb_helper->dev->struct_mutex);
63 static int intel_fbdev_blank(int blank, struct fb_info *info)
65 struct drm_fb_helper *fb_helper = info->par;
66 struct intel_fbdev *ifbdev =
67 container_of(fb_helper, struct intel_fbdev, helper);
70 ret = drm_fb_helper_blank(blank, info);
73 mutex_lock(&fb_helper->dev->struct_mutex);
74 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
75 mutex_unlock(&fb_helper->dev->struct_mutex);
81 static int intel_fbdev_pan_display(struct fb_var_screeninfo *var,
84 struct drm_fb_helper *fb_helper = info->par;
85 struct intel_fbdev *ifbdev =
86 container_of(fb_helper, struct intel_fbdev, helper);
89 ret = drm_fb_helper_pan_display(var, info);
92 mutex_lock(&fb_helper->dev->struct_mutex);
93 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
94 mutex_unlock(&fb_helper->dev->struct_mutex);
100 static struct fb_ops intelfb_ops = {
101 .owner = THIS_MODULE,
102 .fb_check_var = drm_fb_helper_check_var,
103 .fb_set_par = intel_fbdev_set_par,
104 .fb_fillrect = drm_fb_helper_cfb_fillrect,
105 .fb_copyarea = drm_fb_helper_cfb_copyarea,
106 .fb_imageblit = drm_fb_helper_cfb_imageblit,
107 .fb_pan_display = intel_fbdev_pan_display,
108 .fb_blank = intel_fbdev_blank,
109 .fb_setcmap = drm_fb_helper_setcmap,
110 .fb_debug_enter = drm_fb_helper_debug_enter,
111 .fb_debug_leave = drm_fb_helper_debug_leave,
115 static int intelfb_alloc(struct drm_fb_helper *helper,
116 struct drm_fb_helper_surface_size *sizes)
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 = NULL;
127 /* we don't do packed 24bpp */
128 if (sizes->surface_bpp == 24)
129 sizes->surface_bpp = 32;
131 mode_cmd.width = sizes->surface_width;
132 mode_cmd.height = sizes->surface_height;
134 mode_cmd.pitches[0] = ALIGN(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);
139 size = mode_cmd.pitches[0] * mode_cmd.height;
140 size = PAGE_ALIGN(size);
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
145 if (size * 2 < dev_priv->gtt.stolen_usable_size)
146 obj = i915_gem_object_create_stolen(dev, size);
148 obj = i915_gem_alloc_object(dev, size);
150 DRM_ERROR("failed to allocate framebuffer\n");
155 fb = __intel_framebuffer_create(dev, &mode_cmd, obj);
161 /* Flush everything out, we'll be doing GTT only from now on */
162 ret = intel_pin_and_fence_fb_obj(NULL, fb, NULL, NULL, NULL);
164 DRM_ERROR("failed to pin obj: %d\n", ret);
168 ifbdev->fb = to_intel_framebuffer(fb);
173 drm_framebuffer_remove(fb);
175 drm_gem_object_unreference(&obj->base);
180 static int intelfb_create(struct drm_fb_helper *helper,
181 struct drm_fb_helper_surface_size *sizes)
183 struct intel_fbdev *ifbdev =
184 container_of(helper, struct intel_fbdev, helper);
185 struct intel_framebuffer *intel_fb = ifbdev->fb;
186 struct drm_device *dev = helper->dev;
187 struct drm_i915_private *dev_priv = dev->dev_private;
188 struct fb_info *info;
189 struct drm_framebuffer *fb;
190 struct drm_i915_gem_object *obj;
193 bool prealloc = false;
195 mutex_lock(&dev->struct_mutex);
198 (sizes->fb_width > intel_fb->base.width ||
199 sizes->fb_height > intel_fb->base.height)) {
200 DRM_DEBUG_KMS("BIOS fb too small (%dx%d), we require (%dx%d),"
202 intel_fb->base.width, intel_fb->base.height,
203 sizes->fb_width, sizes->fb_height);
204 drm_framebuffer_unreference(&intel_fb->base);
205 intel_fb = ifbdev->fb = NULL;
207 if (!intel_fb || WARN_ON(!intel_fb->obj)) {
208 DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
209 ret = intelfb_alloc(helper, sizes);
212 intel_fb = ifbdev->fb;
214 DRM_DEBUG_KMS("re-using BIOS fb\n");
216 sizes->fb_width = intel_fb->base.width;
217 sizes->fb_height = intel_fb->base.height;
221 size = obj->base.size;
223 info = drm_fb_helper_alloc_fbi(helper);
233 fb = &ifbdev->fb->base;
235 ifbdev->helper.fb = fb;
238 vga_dev = device_get_parent(dev->dev);
239 info->width = sizes->fb_width;
240 info->height = sizes->fb_height;
241 info->stride = fb->pitches[0];
242 info->depth = sizes->surface_bpp;
243 info->paddr = dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj);
244 info->is_vga_boot_display = vga_pci_is_boot_display(vga_dev);
246 (vm_offset_t)pmap_mapdev_attr(info->paddr,
247 sizes->surface_height * info->stride,
248 VM_MEMATTR_WRITE_COMBINING);
250 strcpy(info->fix.id, "inteldrmfb");
252 info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
253 info->fbops = &intelfb_ops;
255 /* setup aperture base/size for vesafb takeover */
256 info->apertures->ranges[0].base = dev->mode_config.fb_base;
257 info->apertures->ranges[0].size = dev_priv->gtt.mappable_end;
259 info->fix.smem_start = dev->mode_config.fb_base + i915_gem_obj_ggtt_offset(obj);
260 info->fix.smem_len = size;
263 ioremap_wc(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj),
265 if (!info->screen_base) {
267 goto out_destroy_fbi;
269 info->screen_size = size;
271 /* This driver doesn't need a VT switch to restore the mode on resume */
272 info->skip_vt_switch = true;
274 drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
275 drm_fb_helper_fill_var(info, &ifbdev->helper, sizes->fb_width, sizes->fb_height);
277 /* If the object is shmemfs backed, it will have given us zeroed pages.
278 * If the object is stolen however, it will be full of whatever
279 * garbage was left in there.
281 if (ifbdev->fb->obj->stolen && !prealloc)
282 memset_io(info->screen_base, 0, info->screen_size);
284 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
287 DRM_DEBUG_KMS("allocated %dx%d fb: 0x%08lx, bo %p\n",
288 fb->width, fb->height,
289 i915_gem_obj_ggtt_offset(obj), obj);
291 mutex_unlock(&dev->struct_mutex);
293 vga_switcheroo_client_fb_set(dev->pdev, info);
299 drm_fb_helper_release_fbi(helper);
302 i915_gem_object_ggtt_unpin(obj);
303 drm_gem_object_unreference(&obj->base);
305 mutex_unlock(&dev->struct_mutex);
309 /** Sets the color ramps on behalf of RandR */
310 static void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
313 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
315 intel_crtc->lut_r[regno] = red >> 8;
316 intel_crtc->lut_g[regno] = green >> 8;
317 intel_crtc->lut_b[regno] = blue >> 8;
320 static void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
321 u16 *blue, int regno)
323 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
325 *red = intel_crtc->lut_r[regno] << 8;
326 *green = intel_crtc->lut_g[regno] << 8;
327 *blue = intel_crtc->lut_b[regno] << 8;
330 static struct drm_fb_helper_crtc *
331 intel_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc)
335 for (i = 0; i < fb_helper->crtc_count; i++)
336 if (fb_helper->crtc_info[i].mode_set.crtc == crtc)
337 return &fb_helper->crtc_info[i];
343 * Try to read the BIOS display configuration and use it for the initial
346 * The BIOS or boot loader will generally create an initial display
347 * configuration for us that includes some set of active pipes and displays.
348 * This routine tries to figure out which pipes and connectors are active
349 * and stuffs them into the crtcs and modes array given to us by the
350 * drm_fb_helper code.
352 * The overall sequence is:
353 * intel_fbdev_init - from driver load
354 * intel_fbdev_init_bios - initialize the intel_fbdev using BIOS data
355 * drm_fb_helper_init - build fb helper structs
356 * drm_fb_helper_single_add_all_connectors - more fb helper structs
357 * intel_fbdev_initial_config - apply the config
358 * drm_fb_helper_initial_config - call ->probe then register_framebuffer()
359 * drm_setup_crtcs - build crtc config for fbdev
360 * intel_fb_initial_config - find active connectors etc
361 * drm_fb_helper_single_fb_probe - set up fbdev
362 * intelfb_create - re-use or alloc fb, build out fbdev structs
364 * Note that we don't make special consideration whether we could actually
365 * switch to the selected modes without a full modeset. E.g. when the display
366 * is in VGA mode we need to recalculate watermarks and set a new high-res
367 * framebuffer anyway.
369 static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
370 struct drm_fb_helper_crtc **crtcs,
371 struct drm_display_mode **modes,
372 struct drm_fb_offset *offsets,
373 bool *enabled, int width, int height)
375 struct drm_device *dev = fb_helper->dev;
378 bool fallback = true;
379 int num_connectors_enabled = 0;
380 int num_connectors_detected = 0;
381 uint64_t conn_configured = 0, mask;
384 save_enabled = kcalloc(dev->mode_config.num_connector, sizeof(bool),
389 memcpy(save_enabled, enabled, dev->mode_config.num_connector);
390 mask = (1 << fb_helper->connector_count) - 1;
392 for (i = 0; i < fb_helper->connector_count; i++) {
393 struct drm_fb_helper_connector *fb_conn;
394 struct drm_connector *connector;
395 struct drm_encoder *encoder;
396 struct drm_fb_helper_crtc *new_crtc;
398 fb_conn = fb_helper->connector_info[i];
399 connector = fb_conn->connector;
401 if (conn_configured & (1 << i))
404 if (pass == 0 && !connector->has_tile)
407 if (connector->status == connector_status_connected)
408 num_connectors_detected++;
411 DRM_DEBUG_KMS("connector %s not enabled, skipping\n",
413 conn_configured |= (1 << i);
417 if (connector->force == DRM_FORCE_OFF) {
418 DRM_DEBUG_KMS("connector %s is disabled by user, skipping\n",
424 encoder = connector->encoder;
425 if (!encoder || WARN_ON(!encoder->crtc)) {
426 if (connector->force > DRM_FORCE_OFF)
429 DRM_DEBUG_KMS("connector %s has no encoder or crtc, skipping\n",
432 conn_configured |= (1 << i);
436 num_connectors_enabled++;
438 new_crtc = intel_fb_helper_crtc(fb_helper, encoder->crtc);
441 * Make sure we're not trying to drive multiple connectors
442 * with a single CRTC, since our cloning support may not
445 for (j = 0; j < fb_helper->connector_count; j++) {
446 if (crtcs[j] == new_crtc) {
447 DRM_DEBUG_KMS("fallback: cloned configuration\n");
452 DRM_DEBUG_KMS("looking for cmdline mode on connector %s\n",
455 /* go for command line mode first */
456 modes[i] = drm_pick_cmdline_mode(fb_conn, width, height);
458 /* try for preferred next */
460 DRM_DEBUG_KMS("looking for preferred mode on connector %s %d\n",
461 connector->name, connector->has_tile);
462 modes[i] = drm_has_preferred_mode(fb_conn, width,
466 /* No preferred mode marked by the EDID? Are there any modes? */
467 if (!modes[i] && !list_empty(&connector->modes)) {
468 DRM_DEBUG_KMS("using first mode listed on connector %s\n",
470 modes[i] = list_first_entry(&connector->modes,
471 struct drm_display_mode,
475 /* last resort: use current mode */
478 * IMPORTANT: We want to use the adjusted mode (i.e.
479 * after the panel fitter upscaling) as the initial
480 * config, not the input mode, which is what crtc->mode
481 * usually contains. But since our current
482 * code puts a mode derived from the post-pfit timings
483 * into crtc->mode this works out correctly.
485 DRM_DEBUG_KMS("looking for current mode on connector %s\n",
487 modes[i] = &encoder->crtc->mode;
491 DRM_DEBUG_KMS("connector %s on pipe %c [CRTC:%d]: %dx%d%s\n",
493 pipe_name(to_intel_crtc(encoder->crtc)->pipe),
494 encoder->crtc->base.id,
495 modes[i]->hdisplay, modes[i]->vdisplay,
496 modes[i]->flags & DRM_MODE_FLAG_INTERLACE ? "i" :"");
499 conn_configured |= (1 << i);
502 if ((conn_configured & mask) != mask) {
508 * If the BIOS didn't enable everything it could, fall back to have the
509 * same user experiencing of lighting up as much as possible like the
510 * fbdev helper library.
512 if (num_connectors_enabled != num_connectors_detected &&
513 num_connectors_enabled < INTEL_INFO(dev)->num_pipes) {
514 DRM_DEBUG_KMS("fallback: Not all outputs enabled\n");
515 DRM_DEBUG_KMS("Enabled: %i, detected: %i\n", num_connectors_enabled,
516 num_connectors_detected);
522 DRM_DEBUG_KMS("Not using firmware configuration\n");
523 memcpy(enabled, save_enabled, dev->mode_config.num_connector);
532 static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
533 .initial_config = intel_fb_initial_config,
534 .gamma_set = intel_crtc_fb_gamma_set,
535 .gamma_get = intel_crtc_fb_gamma_get,
536 .fb_probe = intelfb_create,
539 static void intel_fbdev_destroy(struct drm_device *dev,
540 struct intel_fbdev *ifbdev)
543 drm_fb_helper_unregister_fbi(&ifbdev->helper);
544 drm_fb_helper_release_fbi(&ifbdev->helper);
547 drm_fb_helper_fini(&ifbdev->helper);
549 drm_framebuffer_unregister_private(&ifbdev->fb->base);
550 drm_framebuffer_remove(&ifbdev->fb->base);
554 * Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible.
555 * The core display code will have read out the current plane configuration,
556 * so we use that to figure out if there's an object for us to use as the
557 * fb, and if so, we re-use it for the fbdev configuration.
559 * Note we only support a single fb shared across pipes for boot (mostly for
560 * fbcon), so we just find the biggest and use that.
562 static bool intel_fbdev_init_bios(struct drm_device *dev,
563 struct intel_fbdev *ifbdev)
565 struct intel_framebuffer *fb = NULL;
566 struct drm_crtc *crtc;
567 struct intel_crtc *intel_crtc;
568 unsigned int max_size = 0;
570 /* Find the largest fb */
571 for_each_crtc(dev, crtc) {
572 struct drm_i915_gem_object *obj =
573 intel_fb_obj(crtc->primary->state->fb);
574 intel_crtc = to_intel_crtc(crtc);
576 if (!crtc->state->active || !obj) {
577 DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
578 pipe_name(intel_crtc->pipe));
582 if (obj->base.size > max_size) {
583 DRM_DEBUG_KMS("found possible fb from plane %c\n",
584 pipe_name(intel_crtc->pipe));
585 fb = to_intel_framebuffer(crtc->primary->state->fb);
586 max_size = obj->base.size;
591 DRM_DEBUG_KMS("no active fbs found, not using BIOS config\n");
595 /* Now make sure all the pipes will fit into it */
596 for_each_crtc(dev, crtc) {
597 unsigned int cur_size;
599 intel_crtc = to_intel_crtc(crtc);
601 if (!crtc->state->active) {
602 DRM_DEBUG_KMS("pipe %c not active, skipping\n",
603 pipe_name(intel_crtc->pipe));
607 DRM_DEBUG_KMS("checking plane %c for BIOS fb\n",
608 pipe_name(intel_crtc->pipe));
611 * See if the plane fb we found above will fit on this
612 * pipe. Note we need to use the selected fb's pitch and bpp
613 * rather than the current pipe's, since they differ.
615 cur_size = intel_crtc->config->base.adjusted_mode.crtc_hdisplay;
616 cur_size = cur_size * fb->base.bits_per_pixel / 8;
617 if (fb->base.pitches[0] < cur_size) {
618 DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
619 pipe_name(intel_crtc->pipe),
620 cur_size, fb->base.pitches[0]);
625 cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay;
626 cur_size = intel_fb_align_height(dev, cur_size,
627 fb->base.pixel_format,
628 fb->base.modifier[0]);
629 cur_size *= fb->base.pitches[0];
630 DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
631 pipe_name(intel_crtc->pipe),
632 intel_crtc->config->base.adjusted_mode.crtc_hdisplay,
633 intel_crtc->config->base.adjusted_mode.crtc_vdisplay,
634 fb->base.bits_per_pixel,
637 if (cur_size > max_size) {
638 DRM_DEBUG_KMS("fb not big enough for plane %c (%d vs %d)\n",
639 pipe_name(intel_crtc->pipe),
645 DRM_DEBUG_KMS("fb big enough for plane %c (%d >= %d)\n",
646 pipe_name(intel_crtc->pipe),
651 DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n");
655 ifbdev->preferred_bpp = fb->base.bits_per_pixel;
658 drm_framebuffer_reference(&ifbdev->fb->base);
660 /* Final pass to check if any active pipes don't have fbs */
661 for_each_crtc(dev, crtc) {
662 intel_crtc = to_intel_crtc(crtc);
664 if (!crtc->state->active)
667 WARN(!crtc->primary->fb,
668 "re-used BIOS config but lost an fb on crtc %d\n",
673 DRM_DEBUG_KMS("using BIOS fb for initial console\n");
681 static void intel_fbdev_suspend_worker(struct work_struct *work)
683 intel_fbdev_set_suspend(container_of(work,
684 struct drm_i915_private,
685 fbdev_suspend_work)->dev,
686 FBINFO_STATE_RUNNING,
690 int intel_fbdev_init(struct drm_device *dev)
692 struct intel_fbdev *ifbdev;
693 struct drm_i915_private *dev_priv = dev->dev_private;
696 if (WARN_ON(INTEL_INFO(dev)->num_pipes == 0))
699 ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL);
703 drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs);
705 if (!intel_fbdev_init_bios(dev, ifbdev))
706 ifbdev->preferred_bpp = 32;
708 ret = drm_fb_helper_init(dev, &ifbdev->helper,
709 INTEL_INFO(dev)->num_pipes, 4);
715 ifbdev->helper.atomic = true;
717 dev_priv->fbdev = ifbdev;
718 INIT_WORK(&dev_priv->fbdev_suspend_work, intel_fbdev_suspend_worker);
720 drm_fb_helper_single_add_all_connectors(&ifbdev->helper);
725 void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
727 struct drm_i915_private *dev_priv = data;
728 struct intel_fbdev *ifbdev = dev_priv->fbdev;
730 /* Due to peculiar init order wrt to hpd handling this is separate. */
731 drm_fb_helper_initial_config(&ifbdev->helper, ifbdev->preferred_bpp);
734 void intel_fbdev_fini(struct drm_device *dev)
736 struct drm_i915_private *dev_priv = dev->dev_private;
737 if (!dev_priv->fbdev)
741 flush_work(&dev_priv->fbdev_suspend_work);
744 async_synchronize_full();
745 intel_fbdev_destroy(dev, dev_priv->fbdev);
746 kfree(dev_priv->fbdev);
747 dev_priv->fbdev = NULL;
750 void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
753 struct drm_i915_private *dev_priv = dev->dev_private;
754 struct intel_fbdev *ifbdev = dev_priv->fbdev;
755 struct fb_info *info;
760 info = ifbdev->helper.fbdev;
763 /* Flush any pending work to turn the console on, and then
764 * wait to turn it off. It must be synchronous as we are
765 * about to suspend or unload the driver.
767 * Note that from within the work-handler, we cannot flush
768 * ourselves, so only flush outstanding work upon suspend!
770 if (state != FBINFO_STATE_RUNNING)
771 flush_work(&dev_priv->fbdev_suspend_work);
775 * The console lock can be pretty contented on resume due
776 * to all the printk activity. Try to keep it out of the hot
777 * path of resume if possible.
779 WARN_ON(state != FBINFO_STATE_RUNNING);
780 if (!console_trylock()) {
781 /* Don't block our own workqueue as this can
782 * be run in parallel with other i915.ko tasks.
784 schedule_work(&dev_priv->fbdev_suspend_work);
789 /* On resume from hibernation: If the object is shmemfs backed, it has
790 * been restored from swap. If the object is stolen however, it will be
791 * full of whatever garbage was left in there.
793 if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
794 memset_io(info->screen_base, 0, info->screen_size);
796 drm_fb_helper_set_suspend(&ifbdev->helper, state);
801 void intel_fbdev_output_poll_changed(struct drm_device *dev)
803 struct drm_i915_private *dev_priv = dev->dev_private;
805 drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper);
808 void intel_fbdev_restore_mode(struct drm_device *dev)
811 struct drm_i915_private *dev_priv = dev->dev_private;
812 struct intel_fbdev *ifbdev = dev_priv->fbdev;
813 struct drm_fb_helper *fb_helper;
818 fb_helper = &ifbdev->helper;
820 /* XXX: avoid dead-locking the Xorg on exit */
821 if (mutex_is_locked(&dev->mode_config.mutex)) {
822 DRM_ERROR("fubar while trying to restore kms_console\n");
823 return; /* drm_modeset_unlock_all(dev) ? */
826 ret = drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper);
828 DRM_DEBUG("failed to restore crtc mode\n");
830 mutex_lock(&fb_helper->dev->struct_mutex);
831 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
832 mutex_unlock(&fb_helper->dev->struct_mutex);