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
);
56 * FIXME: fbdev presumes that all callbacks also work from
57 * atomic contexts and relies on that for emergency oops
58 * printing. KMS totally doesn't do that and the locking here is
59 * by far not the only place this goes wrong. Ignore this for
60 * now until we solve this for real.
62 mutex_lock(&fb_helper
->dev
->struct_mutex
);
63 ret
= i915_gem_object_set_to_gtt_domain(ifbdev
->fb
->obj
,
65 mutex_unlock(&fb_helper
->dev
->struct_mutex
);
71 static struct fb_ops intelfb_ops
= {
73 .fb_check_var
= drm_fb_helper_check_var
,
74 .fb_set_par
= intel_fbdev_set_par
,
75 .fb_fillrect
= cfb_fillrect
,
76 .fb_copyarea
= cfb_copyarea
,
77 .fb_imageblit
= cfb_imageblit
,
78 .fb_pan_display
= drm_fb_helper_pan_display
,
79 .fb_blank
= drm_fb_helper_blank
,
80 .fb_setcmap
= drm_fb_helper_setcmap
,
81 .fb_debug_enter
= drm_fb_helper_debug_enter
,
82 .fb_debug_leave
= drm_fb_helper_debug_leave
,
86 static int intelfb_alloc(struct drm_fb_helper
*helper
,
87 struct drm_fb_helper_surface_size
*sizes
)
89 struct intel_fbdev
*ifbdev
=
90 container_of(helper
, struct intel_fbdev
, helper
);
91 struct drm_framebuffer
*fb
;
92 struct drm_device
*dev
= helper
->dev
;
93 struct drm_mode_fb_cmd2 mode_cmd
= {};
94 struct drm_i915_gem_object
*obj
;
97 /* we don't do packed 24bpp */
98 if (sizes
->surface_bpp
== 24)
99 sizes
->surface_bpp
= 32;
101 mode_cmd
.width
= sizes
->surface_width
;
102 mode_cmd
.height
= sizes
->surface_height
;
104 mode_cmd
.pitches
[0] = ALIGN(mode_cmd
.width
*
105 DIV_ROUND_UP(sizes
->surface_bpp
, 8), 64);
106 mode_cmd
.pixel_format
= drm_mode_legacy_fb_format(sizes
->surface_bpp
,
107 sizes
->surface_depth
);
109 size
= mode_cmd
.pitches
[0] * mode_cmd
.height
;
110 size
= PAGE_ALIGN(size
);
111 obj
= i915_gem_object_create_stolen(dev
, size
);
113 obj
= i915_gem_alloc_object(dev
, size
);
115 DRM_ERROR("failed to allocate framebuffer\n");
120 /* Flush everything out, we'll be doing GTT only from now on */
121 ret
= intel_pin_and_fence_fb_obj(dev
, obj
, NULL
);
123 DRM_ERROR("failed to pin obj: %d\n", ret
);
127 fb
= __intel_framebuffer_create(dev
, &mode_cmd
, obj
);
133 ifbdev
->fb
= to_intel_framebuffer(fb
);
138 i915_gem_object_ggtt_unpin(obj
);
140 drm_gem_object_unreference(&obj
->base
);
145 static int intelfb_create(struct drm_fb_helper
*helper
,
146 struct drm_fb_helper_surface_size
*sizes
)
148 struct intel_fbdev
*ifbdev
=
149 container_of(helper
, struct intel_fbdev
, helper
);
150 struct intel_framebuffer
*intel_fb
= ifbdev
->fb
;
151 struct drm_device
*dev
= helper
->dev
;
152 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
153 struct fb_info
*info
;
154 struct drm_framebuffer
*fb
;
155 struct drm_i915_gem_object
*obj
;
158 bool prealloc
= false;
160 mutex_lock(&dev
->struct_mutex
);
163 (sizes
->fb_width
> intel_fb
->base
.width
||
164 sizes
->fb_height
> intel_fb
->base
.height
)) {
165 DRM_DEBUG_KMS("BIOS fb too small (%dx%d), we require (%dx%d),"
167 intel_fb
->base
.width
, intel_fb
->base
.height
,
168 sizes
->fb_width
, sizes
->fb_height
);
169 drm_framebuffer_unreference(&intel_fb
->base
);
170 intel_fb
= ifbdev
->fb
= NULL
;
172 if (!intel_fb
|| WARN_ON(!intel_fb
->obj
)) {
173 DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
174 ret
= intelfb_alloc(helper
, sizes
);
177 intel_fb
= ifbdev
->fb
;
179 DRM_DEBUG_KMS("re-using BIOS fb\n");
181 sizes
->fb_width
= intel_fb
->base
.width
;
182 sizes
->fb_height
= intel_fb
->base
.height
;
186 size
= obj
->base
.size
;
189 info
= framebuffer_alloc(0, &dev
->pdev
->dev
);
191 info
= kmalloc(sizeof(struct fb_info
), M_DRM
, M_WAITOK
| M_ZERO
);
201 fb
= &ifbdev
->fb
->base
;
204 vga_dev
= device_get_parent(dev
->dev
);
205 info
->width
= sizes
->fb_width
;
206 info
->height
= sizes
->fb_height
;
207 info
->stride
= fb
->pitches
[0];
208 info
->depth
= sizes
->surface_bpp
;
209 info
->paddr
= dev_priv
->gtt
.mappable_base
+ i915_gem_obj_ggtt_offset(obj
);
210 info
->is_vga_boot_display
= vga_pci_is_boot_display(vga_dev
);
212 (vm_offset_t
)pmap_mapdev_attr(info
->paddr
,
213 sizes
->surface_height
* info
->stride
,
214 VM_MEMATTR_WRITE_COMBINING
);
217 ifbdev
->helper
.fb
= fb
;
218 ifbdev
->helper
.fbdev
= info
;
221 strcpy(info
->fix
.id
, "inteldrmfb");
223 info
->flags
= FBINFO_DEFAULT
| FBINFO_CAN_FORCE_OUTPUT
;
224 info
->fbops
= &intelfb_ops
;
226 ret
= fb_alloc_cmap(&info
->cmap
, 256, 0);
231 /* setup aperture base/size for vesafb takeover */
232 info
->apertures
= alloc_apertures(1);
233 if (!info
->apertures
) {
237 info
->apertures
->ranges
[0].base
= dev
->mode_config
.fb_base
;
238 info
->apertures
->ranges
[0].size
= dev_priv
->gtt
.mappable_end
;
240 info
->fix
.smem_start
= dev
->mode_config
.fb_base
+ i915_gem_obj_ggtt_offset(obj
);
241 info
->fix
.smem_len
= size
;
244 ioremap_wc(dev_priv
->gtt
.mappable_base
+ i915_gem_obj_ggtt_offset(obj
),
246 if (!info
->screen_base
) {
250 info
->screen_size
= size
;
252 /* This driver doesn't need a VT switch to restore the mode on resume */
253 info
->skip_vt_switch
= true;
255 drm_fb_helper_fill_fix(info
, fb
->pitches
[0], fb
->depth
);
256 drm_fb_helper_fill_var(info
, &ifbdev
->helper
, sizes
->fb_width
, sizes
->fb_height
);
258 /* If the object is shmemfs backed, it will have given us zeroed pages.
259 * If the object is stolen however, it will be full of whatever
260 * garbage was left in there.
262 if (ifbdev
->fb
->obj
->stolen
&& !prealloc
)
263 memset_io(info
->screen_base
, 0, info
->screen_size
);
265 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
268 DRM_DEBUG_KMS("allocated %dx%d fb: 0x%08lx, bo %p\n",
269 fb
->width
, fb
->height
,
270 i915_gem_obj_ggtt_offset(obj
), obj
);
272 mutex_unlock(&dev
->struct_mutex
);
274 vga_switcheroo_client_fb_set(dev
->pdev
, info
);
279 i915_gem_object_ggtt_unpin(obj
);
280 drm_gem_object_unreference(&obj
->base
);
282 mutex_unlock(&dev
->struct_mutex
);
286 /** Sets the color ramps on behalf of RandR */
287 static void intel_crtc_fb_gamma_set(struct drm_crtc
*crtc
, u16 red
, u16 green
,
290 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
292 intel_crtc
->lut_r
[regno
] = red
>> 8;
293 intel_crtc
->lut_g
[regno
] = green
>> 8;
294 intel_crtc
->lut_b
[regno
] = blue
>> 8;
297 static void intel_crtc_fb_gamma_get(struct drm_crtc
*crtc
, u16
*red
, u16
*green
,
298 u16
*blue
, int regno
)
300 struct intel_crtc
*intel_crtc
= to_intel_crtc(crtc
);
302 *red
= intel_crtc
->lut_r
[regno
] << 8;
303 *green
= intel_crtc
->lut_g
[regno
] << 8;
304 *blue
= intel_crtc
->lut_b
[regno
] << 8;
307 static struct drm_fb_helper_crtc
*
308 intel_fb_helper_crtc(struct drm_fb_helper
*fb_helper
, struct drm_crtc
*crtc
)
312 for (i
= 0; i
< fb_helper
->crtc_count
; i
++)
313 if (fb_helper
->crtc_info
[i
].mode_set
.crtc
== crtc
)
314 return &fb_helper
->crtc_info
[i
];
320 * Try to read the BIOS display configuration and use it for the initial
323 * The BIOS or boot loader will generally create an initial display
324 * configuration for us that includes some set of active pipes and displays.
325 * This routine tries to figure out which pipes and connectors are active
326 * and stuffs them into the crtcs and modes array given to us by the
327 * drm_fb_helper code.
329 * The overall sequence is:
330 * intel_fbdev_init - from driver load
331 * intel_fbdev_init_bios - initialize the intel_fbdev using BIOS data
332 * drm_fb_helper_init - build fb helper structs
333 * drm_fb_helper_single_add_all_connectors - more fb helper structs
334 * intel_fbdev_initial_config - apply the config
335 * drm_fb_helper_initial_config - call ->probe then register_framebuffer()
336 * drm_setup_crtcs - build crtc config for fbdev
337 * intel_fb_initial_config - find active connectors etc
338 * drm_fb_helper_single_fb_probe - set up fbdev
339 * intelfb_create - re-use or alloc fb, build out fbdev structs
341 * Note that we don't make special consideration whether we could actually
342 * switch to the selected modes without a full modeset. E.g. when the display
343 * is in VGA mode we need to recalculate watermarks and set a new high-res
344 * framebuffer anyway.
346 static bool intel_fb_initial_config(struct drm_fb_helper
*fb_helper
,
347 struct drm_fb_helper_crtc
**crtcs
,
348 struct drm_display_mode
**modes
,
349 bool *enabled
, int width
, int height
)
351 struct drm_device
*dev
= fb_helper
->dev
;
354 bool fallback
= true;
355 int num_connectors_enabled
= 0;
356 int num_connectors_detected
= 0;
358 save_enabled
= kcalloc(dev
->mode_config
.num_connector
, sizeof(bool),
363 memcpy(save_enabled
, enabled
, dev
->mode_config
.num_connector
);
365 for (i
= 0; i
< fb_helper
->connector_count
; i
++) {
366 struct drm_fb_helper_connector
*fb_conn
;
367 struct drm_connector
*connector
;
368 struct drm_encoder
*encoder
;
369 struct drm_fb_helper_crtc
*new_crtc
;
371 fb_conn
= fb_helper
->connector_info
[i
];
372 connector
= fb_conn
->connector
;
374 if (connector
->status
== connector_status_connected
)
375 num_connectors_detected
++;
378 DRM_DEBUG_KMS("connector %s not enabled, skipping\n",
383 if (connector
->force
== DRM_FORCE_OFF
) {
384 DRM_DEBUG_KMS("connector %s is disabled by user, skipping\n",
390 encoder
= connector
->encoder
;
391 if (!encoder
|| WARN_ON(!encoder
->crtc
)) {
392 if (connector
->force
> DRM_FORCE_OFF
)
395 DRM_DEBUG_KMS("connector %s has no encoder or crtc, skipping\n",
401 num_connectors_enabled
++;
403 new_crtc
= intel_fb_helper_crtc(fb_helper
, encoder
->crtc
);
406 * Make sure we're not trying to drive multiple connectors
407 * with a single CRTC, since our cloning support may not
410 for (j
= 0; j
< fb_helper
->connector_count
; j
++) {
411 if (crtcs
[j
] == new_crtc
) {
412 DRM_DEBUG_KMS("fallback: cloned configuration\n");
417 DRM_DEBUG_KMS("looking for cmdline mode on connector %s\n",
420 /* go for command line mode first */
421 modes
[i
] = drm_pick_cmdline_mode(fb_conn
, width
, height
);
423 /* try for preferred next */
425 DRM_DEBUG_KMS("looking for preferred mode on connector %s\n",
427 modes
[i
] = drm_has_preferred_mode(fb_conn
, width
,
431 /* No preferred mode marked by the EDID? Are there any modes? */
432 if (!modes
[i
] && !list_empty(&connector
->modes
)) {
433 DRM_DEBUG_KMS("using first mode listed on connector %s\n",
435 modes
[i
] = list_first_entry(&connector
->modes
,
436 struct drm_display_mode
,
440 /* last resort: use current mode */
443 * IMPORTANT: We want to use the adjusted mode (i.e.
444 * after the panel fitter upscaling) as the initial
445 * config, not the input mode, which is what crtc->mode
446 * usually contains. But since our current fastboot
447 * code puts a mode derived from the post-pfit timings
448 * into crtc->mode this works out correctly. We don't
449 * use hwmode anywhere right now, so use it for this
450 * since the fb helper layer wants a pointer to
453 DRM_DEBUG_KMS("looking for current mode on connector %s\n",
455 intel_mode_from_pipe_config(&encoder
->crtc
->hwmode
,
456 &to_intel_crtc(encoder
->crtc
)->config
);
457 modes
[i
] = &encoder
->crtc
->hwmode
;
461 DRM_DEBUG_KMS("connector %s on pipe %c [CRTC:%d]: %dx%d%s\n",
463 pipe_name(to_intel_crtc(encoder
->crtc
)->pipe
),
464 encoder
->crtc
->base
.id
,
465 modes
[i
]->hdisplay
, modes
[i
]->vdisplay
,
466 modes
[i
]->flags
& DRM_MODE_FLAG_INTERLACE
? "i" :"");
472 * If the BIOS didn't enable everything it could, fall back to have the
473 * same user experiencing of lighting up as much as possible like the
474 * fbdev helper library.
476 if (num_connectors_enabled
!= num_connectors_detected
&&
477 num_connectors_enabled
< INTEL_INFO(dev
)->num_pipes
) {
478 DRM_DEBUG_KMS("fallback: Not all outputs enabled\n");
479 DRM_DEBUG_KMS("Enabled: %i, detected: %i\n", num_connectors_enabled
,
480 num_connectors_detected
);
486 DRM_DEBUG_KMS("Not using firmware configuration\n");
487 memcpy(enabled
, save_enabled
, dev
->mode_config
.num_connector
);
496 static const struct drm_fb_helper_funcs intel_fb_helper_funcs
= {
497 .initial_config
= intel_fb_initial_config
,
498 .gamma_set
= intel_crtc_fb_gamma_set
,
499 .gamma_get
= intel_crtc_fb_gamma_get
,
500 .fb_probe
= intelfb_create
,
503 static void intel_fbdev_destroy(struct drm_device
*dev
,
504 struct intel_fbdev
*ifbdev
)
507 if (ifbdev
->helper
.fbdev
) {
508 struct fb_info
*info
= ifbdev
->helper
.fbdev
;
510 unregister_framebuffer(info
);
511 iounmap(info
->screen_base
);
513 fb_dealloc_cmap(&info
->cmap
);
515 framebuffer_release(info
);
519 drm_fb_helper_fini(&ifbdev
->helper
);
521 drm_framebuffer_unregister_private(&ifbdev
->fb
->base
);
522 drm_framebuffer_unreference(&ifbdev
->fb
->base
);
526 * Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible.
527 * The core display code will have read out the current plane configuration,
528 * so we use that to figure out if there's an object for us to use as the
529 * fb, and if so, we re-use it for the fbdev configuration.
531 * Note we only support a single fb shared across pipes for boot (mostly for
532 * fbcon), so we just find the biggest and use that.
534 static bool intel_fbdev_init_bios(struct drm_device
*dev
,
535 struct intel_fbdev
*ifbdev
)
537 struct intel_framebuffer
*fb
= NULL
;
538 struct drm_crtc
*crtc
;
539 struct intel_crtc
*intel_crtc
;
540 struct intel_plane_config
*plane_config
= NULL
;
541 unsigned int max_size
= 0;
546 /* Find the largest fb */
547 for_each_crtc(dev
, crtc
) {
548 intel_crtc
= to_intel_crtc(crtc
);
550 if (!intel_crtc
->active
|| !crtc
->primary
->fb
) {
551 DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
552 pipe_name(intel_crtc
->pipe
));
556 if (intel_crtc
->plane_config
.size
> max_size
) {
557 DRM_DEBUG_KMS("found possible fb from plane %c\n",
558 pipe_name(intel_crtc
->pipe
));
559 plane_config
= &intel_crtc
->plane_config
;
560 fb
= to_intel_framebuffer(crtc
->primary
->fb
);
561 max_size
= plane_config
->size
;
566 DRM_DEBUG_KMS("no active fbs found, not using BIOS config\n");
570 /* Now make sure all the pipes will fit into it */
571 for_each_crtc(dev
, crtc
) {
572 unsigned int cur_size
;
574 intel_crtc
= to_intel_crtc(crtc
);
576 if (!intel_crtc
->active
) {
577 DRM_DEBUG_KMS("pipe %c not active, skipping\n",
578 pipe_name(intel_crtc
->pipe
));
582 DRM_DEBUG_KMS("checking plane %c for BIOS fb\n",
583 pipe_name(intel_crtc
->pipe
));
586 * See if the plane fb we found above will fit on this
587 * pipe. Note we need to use the selected fb's pitch and bpp
588 * rather than the current pipe's, since they differ.
590 cur_size
= intel_crtc
->config
.adjusted_mode
.crtc_hdisplay
;
591 cur_size
= cur_size
* fb
->base
.bits_per_pixel
/ 8;
592 if (fb
->base
.pitches
[0] < cur_size
) {
593 DRM_DEBUG_KMS("fb not wide enough for plane %c (%d vs %d)\n",
594 pipe_name(intel_crtc
->pipe
),
595 cur_size
, fb
->base
.pitches
[0]);
601 cur_size
= intel_crtc
->config
.adjusted_mode
.crtc_vdisplay
;
602 cur_size
= ALIGN(cur_size
, plane_config
->tiled
? (IS_GEN2(dev
) ? 16 : 8) : 1);
603 cur_size
*= fb
->base
.pitches
[0];
604 DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
605 pipe_name(intel_crtc
->pipe
),
606 intel_crtc
->config
.adjusted_mode
.crtc_hdisplay
,
607 intel_crtc
->config
.adjusted_mode
.crtc_vdisplay
,
608 fb
->base
.bits_per_pixel
,
611 if (cur_size
> max_size
) {
612 DRM_DEBUG_KMS("fb not big enough for plane %c (%d vs %d)\n",
613 pipe_name(intel_crtc
->pipe
),
620 DRM_DEBUG_KMS("fb big enough for plane %c (%d >= %d)\n",
621 pipe_name(intel_crtc
->pipe
),
626 DRM_DEBUG_KMS("BIOS fb not suitable for all pipes, not using\n");
630 ifbdev
->preferred_bpp
= fb
->base
.bits_per_pixel
;
633 drm_framebuffer_reference(&ifbdev
->fb
->base
);
635 /* Final pass to check if any active pipes don't have fbs */
636 for_each_crtc(dev
, crtc
) {
637 intel_crtc
= to_intel_crtc(crtc
);
639 if (!intel_crtc
->active
)
642 WARN(!crtc
->primary
->fb
,
643 "re-used BIOS config but lost an fb on crtc %d\n",
648 DRM_DEBUG_KMS("using BIOS fb for initial console\n");
656 static void intel_fbdev_suspend_worker(struct work_struct
*work
)
658 intel_fbdev_set_suspend(container_of(work
,
659 struct drm_i915_private
,
660 fbdev_suspend_work
)->dev
,
661 FBINFO_STATE_RUNNING
,
665 int intel_fbdev_init(struct drm_device
*dev
)
667 struct intel_fbdev
*ifbdev
;
668 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
671 if (WARN_ON(INTEL_INFO(dev
)->num_pipes
== 0))
674 ifbdev
= kzalloc(sizeof(struct intel_fbdev
), GFP_KERNEL
);
678 drm_fb_helper_prepare(dev
, &ifbdev
->helper
, &intel_fb_helper_funcs
);
680 if (!intel_fbdev_init_bios(dev
, ifbdev
))
681 ifbdev
->preferred_bpp
= 32;
683 ret
= drm_fb_helper_init(dev
, &ifbdev
->helper
,
684 INTEL_INFO(dev
)->num_pipes
, 4);
690 dev_priv
->fbdev
= ifbdev
;
691 INIT_WORK(&dev_priv
->fbdev_suspend_work
, intel_fbdev_suspend_worker
);
693 drm_fb_helper_single_add_all_connectors(&ifbdev
->helper
);
698 void intel_fbdev_initial_config(void *data
, async_cookie_t cookie
)
700 struct drm_i915_private
*dev_priv
= data
;
702 /* Due to peculiar init order wrt to hpd handling this is separate. */
703 drm_fb_helper_initial_config(&dev_priv
->fbdev
->helper
, 32);
706 void intel_fbdev_fini(struct drm_device
*dev
)
708 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
709 if (!dev_priv
->fbdev
)
713 flush_work(&dev_priv
->fbdev_suspend_work
);
716 async_synchronize_full();
717 intel_fbdev_destroy(dev
, dev_priv
->fbdev
);
718 kfree(dev_priv
->fbdev
);
719 dev_priv
->fbdev
= NULL
;
722 void intel_fbdev_set_suspend(struct drm_device
*dev
, int state
, bool synchronous
)
725 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
726 struct intel_fbdev
*ifbdev
= dev_priv
->fbdev
;
727 struct fb_info
*info
;
732 info
= ifbdev
->helper
.fbdev
;
735 /* Flush any pending work to turn the console on, and then
736 * wait to turn it off. It must be synchronous as we are
737 * about to suspend or unload the driver.
739 * Note that from within the work-handler, we cannot flush
740 * ourselves, so only flush outstanding work upon suspend!
742 if (state
!= FBINFO_STATE_RUNNING
)
743 flush_work(&dev_priv
->fbdev_suspend_work
);
747 * The console lock can be pretty contented on resume due
748 * to all the printk activity. Try to keep it out of the hot
749 * path of resume if possible.
751 WARN_ON(state
!= FBINFO_STATE_RUNNING
);
752 if (!console_trylock()) {
753 /* Don't block our own workqueue as this can
754 * be run in parallel with other i915.ko tasks.
756 schedule_work(&dev_priv
->fbdev_suspend_work
);
761 /* On resume from hibernation: If the object is shmemfs backed, it has
762 * been restored from swap. If the object is stolen however, it will be
763 * full of whatever garbage was left in there.
765 if (state
== FBINFO_STATE_RUNNING
&& ifbdev
->fb
->obj
->stolen
)
766 memset_io(info
->screen_base
, 0, info
->screen_size
);
768 fb_set_suspend(info
, state
);
773 void intel_fbdev_output_poll_changed(struct drm_device
*dev
)
775 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
776 drm_fb_helper_hotplug_event(&dev_priv
->fbdev
->helper
);
779 void intel_fbdev_restore_mode(struct drm_device
*dev
)
782 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
784 if (INTEL_INFO(dev
)->num_pipes
== 0)
787 ret
= drm_fb_helper_restore_fbdev_mode_unlocked(&dev_priv
->fbdev
->helper
);
789 DRM_DEBUG("failed to restore crtc mode\n");