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_mode_fb_cmd2 mode_cmd = {};
123 struct drm_i915_gem_object *obj;
126 /* we don't do packed 24bpp */
127 if (sizes->surface_bpp == 24)
128 sizes->surface_bpp = 32;
130 mode_cmd.width = sizes->surface_width;
131 mode_cmd.height = sizes->surface_height;
133 mode_cmd.pitches[0] = ALIGN(mode_cmd.width *
134 DIV_ROUND_UP(sizes->surface_bpp, 8), 64);
135 mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp,
136 sizes->surface_depth);
138 size = mode_cmd.pitches[0] * mode_cmd.height;
139 size = PAGE_ALIGN(size);
140 obj = i915_gem_object_create_stolen(dev, size);
142 obj = i915_gem_alloc_object(dev, size);
144 DRM_ERROR("failed to allocate framebuffer\n");
149 fb = __intel_framebuffer_create(dev, &mode_cmd, obj);
155 /* Flush everything out, we'll be doing GTT only from now on */
156 ret = intel_pin_and_fence_fb_obj(NULL, fb, NULL, NULL, NULL);
158 DRM_ERROR("failed to pin obj: %d\n", ret);
162 ifbdev->fb = to_intel_framebuffer(fb);
167 drm_framebuffer_remove(fb);
169 drm_gem_object_unreference(&obj->base);
174 static int intelfb_create(struct drm_fb_helper *helper,
175 struct drm_fb_helper_surface_size *sizes)
177 struct intel_fbdev *ifbdev =
178 container_of(helper, struct intel_fbdev, helper);
179 struct intel_framebuffer *intel_fb = ifbdev->fb;
180 struct drm_device *dev = helper->dev;
181 struct drm_i915_private *dev_priv = dev->dev_private;
182 struct fb_info *info;
183 struct drm_framebuffer *fb;
184 struct drm_i915_gem_object *obj;
187 bool prealloc = false;
189 mutex_lock(&dev->struct_mutex);
192 (sizes->fb_width > intel_fb->base.width ||
193 sizes->fb_height > intel_fb->base.height)) {
194 DRM_DEBUG_KMS("BIOS fb too small (%dx%d), we require (%dx%d),"
196 intel_fb->base.width, intel_fb->base.height,
197 sizes->fb_width, sizes->fb_height);
198 drm_framebuffer_unreference(&intel_fb->base);
199 intel_fb = ifbdev->fb = NULL;
201 if (!intel_fb || WARN_ON(!intel_fb->obj)) {
202 DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
203 ret = intelfb_alloc(helper, sizes);
206 intel_fb = ifbdev->fb;
208 DRM_DEBUG_KMS("re-using BIOS fb\n");
210 sizes->fb_width = intel_fb->base.width;
211 sizes->fb_height = intel_fb->base.height;
215 size = obj->base.size;
217 info = drm_fb_helper_alloc_fbi(helper);
227 fb = &ifbdev->fb->base;
229 ifbdev->helper.fb = fb;
232 vga_dev = device_get_parent(dev->dev);
233 info->width = sizes->fb_width;
234 info->height = sizes->fb_height;
235 info->stride = fb->pitches[0];
236 info->depth = sizes->surface_bpp;
237 info->paddr = dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj);
238 info->is_vga_boot_display = vga_pci_is_boot_display(vga_dev);
240 (vm_offset_t)pmap_mapdev_attr(info->paddr,
241 sizes->surface_height * info->stride,
242 VM_MEMATTR_WRITE_COMBINING);
244 strcpy(info->fix.id, "inteldrmfb");
246 info->flags = FBINFO_DEFAULT | FBINFO_CAN_FORCE_OUTPUT;
247 info->fbops = &intelfb_ops;
249 /* setup aperture base/size for vesafb takeover */
250 info->apertures->ranges[0].base = dev->mode_config.fb_base;
251 info->apertures->ranges[0].size = dev_priv->gtt.mappable_end;
253 info->fix.smem_start = dev->mode_config.fb_base + i915_gem_obj_ggtt_offset(obj);
254 info->fix.smem_len = size;
257 ioremap_wc(dev_priv->gtt.mappable_base + i915_gem_obj_ggtt_offset(obj),
259 if (!info->screen_base) {
261 goto out_destroy_fbi;
263 info->screen_size = size;
265 /* This driver doesn't need a VT switch to restore the mode on resume */
266 info->skip_vt_switch = true;
268 drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
269 drm_fb_helper_fill_var(info, &ifbdev->helper, sizes->fb_width, sizes->fb_height);
271 /* If the object is shmemfs backed, it will have given us zeroed pages.
272 * If the object is stolen however, it will be full of whatever
273 * garbage was left in there.
275 if (ifbdev->fb->obj->stolen && !prealloc)
276 memset_io(info->screen_base, 0, info->screen_size);
278 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
281 DRM_DEBUG_KMS("allocated %dx%d fb: 0x%08lx, bo %p\n",
282 fb->width, fb->height,
283 i915_gem_obj_ggtt_offset(obj), obj);
285 mutex_unlock(&dev->struct_mutex);
287 vga_switcheroo_client_fb_set(dev->pdev, info);
293 drm_fb_helper_release_fbi(helper);
296 i915_gem_object_ggtt_unpin(obj);
297 drm_gem_object_unreference(&obj->base);
299 mutex_unlock(&dev->struct_mutex);
303 /** Sets the color ramps on behalf of RandR */
304 static void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
307 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
309 intel_crtc->lut_r[regno] = red >> 8;
310 intel_crtc->lut_g[regno] = green >> 8;
311 intel_crtc->lut_b[regno] = blue >> 8;
314 static void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
315 u16 *blue, int regno)
317 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
319 *red = intel_crtc->lut_r[regno] << 8;
320 *green = intel_crtc->lut_g[regno] << 8;
321 *blue = intel_crtc->lut_b[regno] << 8;
324 static struct drm_fb_helper_crtc *
325 intel_fb_helper_crtc(struct drm_fb_helper *fb_helper, struct drm_crtc *crtc)
329 for (i = 0; i < fb_helper->crtc_count; i++)
330 if (fb_helper->crtc_info[i].mode_set.crtc == crtc)
331 return &fb_helper->crtc_info[i];
337 * Try to read the BIOS display configuration and use it for the initial
340 * The BIOS or boot loader will generally create an initial display
341 * configuration for us that includes some set of active pipes and displays.
342 * This routine tries to figure out which pipes and connectors are active
343 * and stuffs them into the crtcs and modes array given to us by the
344 * drm_fb_helper code.
346 * The overall sequence is:
347 * intel_fbdev_init - from driver load
348 * intel_fbdev_init_bios - initialize the intel_fbdev using BIOS data
349 * drm_fb_helper_init - build fb helper structs
350 * drm_fb_helper_single_add_all_connectors - more fb helper structs
351 * intel_fbdev_initial_config - apply the config
352 * drm_fb_helper_initial_config - call ->probe then register_framebuffer()
353 * drm_setup_crtcs - build crtc config for fbdev
354 * intel_fb_initial_config - find active connectors etc
355 * drm_fb_helper_single_fb_probe - set up fbdev
356 * intelfb_create - re-use or alloc fb, build out fbdev structs
358 * Note that we don't make special consideration whether we could actually
359 * switch to the selected modes without a full modeset. E.g. when the display
360 * is in VGA mode we need to recalculate watermarks and set a new high-res
361 * framebuffer anyway.
363 static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,
364 struct drm_fb_helper_crtc **crtcs,
365 struct drm_display_mode **modes,
366 struct drm_fb_offset *offsets,
367 bool *enabled, int width, int height)
369 struct drm_device *dev = fb_helper->dev;
372 bool fallback = true;
373 int num_connectors_enabled = 0;
374 int num_connectors_detected = 0;
375 uint64_t conn_configured = 0, mask;
378 save_enabled = kcalloc(dev->mode_config.num_connector, sizeof(bool),
383 memcpy(save_enabled, enabled, dev->mode_config.num_connector);
384 mask = (1 << fb_helper->connector_count) - 1;
386 for (i = 0; i < fb_helper->connector_count; i++) {
387 struct drm_fb_helper_connector *fb_conn;
388 struct drm_connector *connector;
389 struct drm_encoder *encoder;
390 struct drm_fb_helper_crtc *new_crtc;
392 fb_conn = fb_helper->connector_info[i];
393 connector = fb_conn->connector;
395 if (conn_configured & (1 << i))
398 if (pass == 0 && !connector->has_tile)
401 if (connector->status == connector_status_connected)
402 num_connectors_detected++;
405 DRM_DEBUG_KMS("connector %s not enabled, skipping\n",
407 conn_configured |= (1 << i);
411 if (connector->force == DRM_FORCE_OFF) {
412 DRM_DEBUG_KMS("connector %s is disabled by user, skipping\n",
418 encoder = connector->encoder;
419 if (!encoder || WARN_ON(!encoder->crtc)) {
420 if (connector->force > DRM_FORCE_OFF)
423 DRM_DEBUG_KMS("connector %s has no encoder or crtc, skipping\n",
426 conn_configured |= (1 << i);
430 num_connectors_enabled++;
432 new_crtc = intel_fb_helper_crtc(fb_helper, encoder->crtc);
435 * Make sure we're not trying to drive multiple connectors
436 * with a single CRTC, since our cloning support may not
439 for (j = 0; j < fb_helper->connector_count; j++) {
440 if (crtcs[j] == new_crtc) {
441 DRM_DEBUG_KMS("fallback: cloned configuration\n");
446 DRM_DEBUG_KMS("looking for cmdline mode on connector %s\n",
449 /* go for command line mode first */
450 modes[i] = drm_pick_cmdline_mode(fb_conn, width, height);
452 /* try for preferred next */
454 DRM_DEBUG_KMS("looking for preferred mode on connector %s %d\n",
455 connector->name, connector->has_tile);
456 modes[i] = drm_has_preferred_mode(fb_conn, width,
460 /* No preferred mode marked by the EDID? Are there any modes? */
461 if (!modes[i] && !list_empty(&connector->modes)) {
462 DRM_DEBUG_KMS("using first mode listed on connector %s\n",
464 modes[i] = list_first_entry(&connector->modes,
465 struct drm_display_mode,
469 /* last resort: use current mode */
472 * IMPORTANT: We want to use the adjusted mode (i.e.
473 * after the panel fitter upscaling) as the initial
474 * config, not the input mode, which is what crtc->mode
475 * usually contains. But since our current
476 * code puts a mode derived from the post-pfit timings
477 * into crtc->mode this works out correctly.
479 DRM_DEBUG_KMS("looking for current mode on connector %s\n",
481 modes[i] = &encoder->crtc->mode;
485 DRM_DEBUG_KMS("connector %s on pipe %c [CRTC:%d]: %dx%d%s\n",
487 pipe_name(to_intel_crtc(encoder->crtc)->pipe),
488 encoder->crtc->base.id,
489 modes[i]->hdisplay, modes[i]->vdisplay,
490 modes[i]->flags & DRM_MODE_FLAG_INTERLACE ? "i" :"");
493 conn_configured |= (1 << i);
496 if ((conn_configured & mask) != mask) {
502 * If the BIOS didn't enable everything it could, fall back to have the
503 * same user experiencing of lighting up as much as possible like the
504 * fbdev helper library.
506 if (num_connectors_enabled != num_connectors_detected &&
507 num_connectors_enabled < INTEL_INFO(dev)->num_pipes) {
508 DRM_DEBUG_KMS("fallback: Not all outputs enabled\n");
509 DRM_DEBUG_KMS("Enabled: %i, detected: %i\n", num_connectors_enabled,
510 num_connectors_detected);
516 DRM_DEBUG_KMS("Not using firmware configuration\n");
517 memcpy(enabled, save_enabled, dev->mode_config.num_connector);
526 static const struct drm_fb_helper_funcs intel_fb_helper_funcs = {
527 .initial_config = intel_fb_initial_config,
528 .gamma_set = intel_crtc_fb_gamma_set,
529 .gamma_get = intel_crtc_fb_gamma_get,
530 .fb_probe = intelfb_create,
533 static void intel_fbdev_destroy(struct drm_device *dev,
534 struct intel_fbdev *ifbdev)
537 drm_fb_helper_unregister_fbi(&ifbdev->helper);
538 drm_fb_helper_release_fbi(&ifbdev->helper);
541 drm_fb_helper_fini(&ifbdev->helper);
543 drm_framebuffer_unregister_private(&ifbdev->fb->base);
544 drm_framebuffer_remove(&ifbdev->fb->base);
548 * Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible.
549 * The core display code will have read out the current plane configuration,
550 * so we use that to figure out if there's an object for us to use as the
551 * fb, and if so, we re-use it for the fbdev configuration.
553 * Note we only support a single fb shared across pipes for boot (mostly for
554 * fbcon), so we just find the biggest and use that.
556 static bool intel_fbdev_init_bios(struct drm_device *dev,
557 struct intel_fbdev *ifbdev)
559 struct intel_framebuffer *fb = NULL;
560 struct drm_crtc *crtc;
561 struct intel_crtc *intel_crtc;
562 unsigned int max_size = 0;
567 /* Find the largest fb */
568 for_each_crtc(dev, crtc) {
569 struct drm_i915_gem_object *obj =
570 intel_fb_obj(crtc->primary->state->fb);
571 intel_crtc = to_intel_crtc(crtc);
573 if (!intel_crtc->active || !obj) {
574 DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
575 pipe_name(intel_crtc->pipe));
579 if (obj->base.size > max_size) {
580 DRM_DEBUG_KMS("found possible fb from plane %c\n",
581 pipe_name(intel_crtc->pipe));
582 fb = to_intel_framebuffer(crtc->primary->state->fb);
583 max_size = obj->base.size;
588 DRM_DEBUG_KMS("no active fbs found, not using BIOS config\n");
592 /* Now make sure all the pipes will fit into it */
593 for_each_crtc(dev, crtc) {
594 unsigned int cur_size;
596 intel_crtc = to_intel_crtc(crtc);
598 if (!intel_crtc->active) {
599 DRM_DEBUG_KMS("pipe %c not active, skipping\n",
600 pipe_name(intel_crtc->pipe));
604 DRM_DEBUG_KMS("checking plane %c for BIOS fb\n",
605 pipe_name(intel_crtc->pipe));
608 * See if the plane fb we found above will fit on this
609 * pipe. Note we need to use the selected fb's pitch and bpp
610 * rather than the current pipe's, since they differ.
612 cur_size = intel_crtc->config->base.adjusted_mode.crtc_hdisplay;
613 cur_size = cur_size * fb->base.bits_per_pixel / 8;
614 if (fb->base.pitches[0] < cur_size) {
615 DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
616 pipe_name(intel_crtc->pipe),
617 cur_size, fb->base.pitches[0]);
622 cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay;
623 cur_size = intel_fb_align_height(dev, cur_size,
624 fb->base.pixel_format,
625 fb->base.modifier[0]);
626 cur_size *= fb->base.pitches[0];
627 DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
628 pipe_name(intel_crtc->pipe),
629 intel_crtc->config->base.adjusted_mode.crtc_hdisplay,
630 intel_crtc->config->base.adjusted_mode.crtc_vdisplay,
631 fb->base.bits_per_pixel,
634 if (cur_size > max_size) {
635 DRM_DEBUG_KMS("fb not big enough for plane %c (%d vs %d)\n",
636 pipe_name(intel_crtc->pipe),
642 DRM_DEBUG_KMS("fb big enough for plane %c (%d >= %d)\n",
643 pipe_name(intel_crtc->pipe),
648 DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n");
652 ifbdev->preferred_bpp = fb->base.bits_per_pixel;
655 drm_framebuffer_reference(&ifbdev->fb->base);
657 /* Final pass to check if any active pipes don't have fbs */
658 for_each_crtc(dev, crtc) {
659 intel_crtc = to_intel_crtc(crtc);
661 if (!intel_crtc->active)
664 WARN(!crtc->primary->fb,
665 "re-used BIOS config but lost an fb on crtc %d\n",
670 DRM_DEBUG_KMS("using BIOS fb for initial console\n");
678 static void intel_fbdev_suspend_worker(struct work_struct *work)
680 intel_fbdev_set_suspend(container_of(work,
681 struct drm_i915_private,
682 fbdev_suspend_work)->dev,
683 FBINFO_STATE_RUNNING,
687 int intel_fbdev_init(struct drm_device *dev)
689 struct intel_fbdev *ifbdev;
690 struct drm_i915_private *dev_priv = dev->dev_private;
693 if (WARN_ON(INTEL_INFO(dev)->num_pipes == 0))
696 ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL);
700 drm_fb_helper_prepare(dev, &ifbdev->helper, &intel_fb_helper_funcs);
702 if (!intel_fbdev_init_bios(dev, ifbdev))
703 ifbdev->preferred_bpp = 32;
705 ret = drm_fb_helper_init(dev, &ifbdev->helper,
706 INTEL_INFO(dev)->num_pipes, 4);
712 dev_priv->fbdev = ifbdev;
713 INIT_WORK(&dev_priv->fbdev_suspend_work, intel_fbdev_suspend_worker);
715 drm_fb_helper_single_add_all_connectors(&ifbdev->helper);
720 void intel_fbdev_initial_config(void *data, async_cookie_t cookie)
722 struct drm_i915_private *dev_priv = data;
723 struct intel_fbdev *ifbdev = dev_priv->fbdev;
725 /* Due to peculiar init order wrt to hpd handling this is separate. */
726 drm_fb_helper_initial_config(&ifbdev->helper, ifbdev->preferred_bpp);
729 void intel_fbdev_fini(struct drm_device *dev)
731 struct drm_i915_private *dev_priv = dev->dev_private;
732 if (!dev_priv->fbdev)
736 flush_work(&dev_priv->fbdev_suspend_work);
739 async_synchronize_full();
740 intel_fbdev_destroy(dev, dev_priv->fbdev);
741 kfree(dev_priv->fbdev);
742 dev_priv->fbdev = NULL;
745 void intel_fbdev_set_suspend(struct drm_device *dev, int state, bool synchronous)
748 struct drm_i915_private *dev_priv = dev->dev_private;
749 struct intel_fbdev *ifbdev = dev_priv->fbdev;
750 struct fb_info *info;
755 info = ifbdev->helper.fbdev;
758 /* Flush any pending work to turn the console on, and then
759 * wait to turn it off. It must be synchronous as we are
760 * about to suspend or unload the driver.
762 * Note that from within the work-handler, we cannot flush
763 * ourselves, so only flush outstanding work upon suspend!
765 if (state != FBINFO_STATE_RUNNING)
766 flush_work(&dev_priv->fbdev_suspend_work);
770 * The console lock can be pretty contented on resume due
771 * to all the printk activity. Try to keep it out of the hot
772 * path of resume if possible.
774 WARN_ON(state != FBINFO_STATE_RUNNING);
775 if (!console_trylock()) {
776 /* Don't block our own workqueue as this can
777 * be run in parallel with other i915.ko tasks.
779 schedule_work(&dev_priv->fbdev_suspend_work);
784 /* On resume from hibernation: If the object is shmemfs backed, it has
785 * been restored from swap. If the object is stolen however, it will be
786 * full of whatever garbage was left in there.
788 if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
789 memset_io(info->screen_base, 0, info->screen_size);
791 drm_fb_helper_set_suspend(&ifbdev->helper, state);
796 void intel_fbdev_output_poll_changed(struct drm_device *dev)
798 struct drm_i915_private *dev_priv = dev->dev_private;
800 drm_fb_helper_hotplug_event(&dev_priv->fbdev->helper);
803 void intel_fbdev_restore_mode(struct drm_device *dev)
806 struct drm_i915_private *dev_priv = dev->dev_private;
807 struct intel_fbdev *ifbdev = dev_priv->fbdev;
808 struct drm_fb_helper *fb_helper;
813 fb_helper = &ifbdev->helper;
815 /* XXX: avoid dead-locking the Xorg on exit */
816 if (mutex_is_locked(&dev->mode_config.mutex)) {
817 DRM_ERROR("fubar while trying to restore kms_console\n");
818 return; /* drm_modeset_unlock_all(dev) ? */
821 ret = drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper);
823 DRM_DEBUG("failed to restore crtc mode\n");
825 mutex_lock(&fb_helper->dev->struct_mutex);
826 intel_fb_obj_invalidate(ifbdev->fb->obj, ORIGIN_GTT);
827 mutex_unlock(&fb_helper->dev->struct_mutex);