1 /**************************************************************************
2 * Copyright (c) 2007-2011, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 **************************************************************************/
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/errno.h>
23 #include <linux/string.h>
25 #include <linux/tty.h>
26 #include <linux/slab.h>
27 #include <linux/delay.h>
29 #include <linux/init.h>
30 #include <linux/console.h>
34 #include <drm/drm_crtc.h>
35 #include <drm/drm_fb_helper.h>
38 #include "psb_intel_reg.h"
39 #include "psb_intel_drv.h"
40 #include "framebuffer.h"
43 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb);
44 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
45 struct drm_file *file_priv,
46 unsigned int *handle);
48 static const struct drm_framebuffer_funcs psb_fb_funcs = {
49 .destroy = psb_user_framebuffer_destroy,
50 .create_handle = psb_user_framebuffer_create_handle,
53 #define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16)
55 static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
56 unsigned blue, unsigned transp,
59 struct psb_fbdev *fbdev = info->par;
60 struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
69 red = CMAP_TOHW(red, info->var.red.length);
70 blue = CMAP_TOHW(blue, info->var.blue.length);
71 green = CMAP_TOHW(green, info->var.green.length);
72 transp = CMAP_TOHW(transp, info->var.transp.length);
74 v = (red << info->var.red.offset) |
75 (green << info->var.green.offset) |
76 (blue << info->var.blue.offset) |
77 (transp << info->var.transp.offset);
80 switch (fb->bits_per_pixel) {
82 ((uint32_t *) info->pseudo_palette)[regno] = v;
86 ((uint32_t *) info->pseudo_palette)[regno] = v;
94 static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info)
96 struct psb_fbdev *fbdev = info->par;
97 struct psb_framebuffer *psbfb = &fbdev->pfb;
98 struct drm_device *dev = psbfb->base.dev;
101 * We have to poke our nose in here. The core fb code assumes
102 * panning is part of the hardware that can be invoked before
103 * the actual fb is mapped. In our case that isn't quite true.
105 if (psbfb->gtt->npage) {
106 /* GTT roll shifts in 4K pages, we need to shift the right
108 int pages = info->fix.line_length >> 12;
109 psb_gtt_roll(dev, psbfb->gtt, var->yoffset * pages);
114 static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
116 struct psb_framebuffer *psbfb = vma->vm_private_data;
117 struct drm_device *dev = psbfb->base.dev;
118 struct drm_psb_private *dev_priv = dev->dev_private;
121 unsigned long address;
124 unsigned long phys_addr = (unsigned long)dev_priv->stolen_base +
127 page_num = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
128 address = (unsigned long)vmf->virtual_address - (vmf->pgoff << PAGE_SHIFT);
130 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
132 for (i = 0; i < page_num; i++) {
133 pfn = (phys_addr >> PAGE_SHIFT);
135 ret = vm_insert_mixed(vma, address, pfn);
136 if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0)))
138 else if (unlikely(ret != 0)) {
139 ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;
142 address += PAGE_SIZE;
143 phys_addr += PAGE_SIZE;
145 return VM_FAULT_NOPAGE;
148 static void psbfb_vm_open(struct vm_area_struct *vma)
152 static void psbfb_vm_close(struct vm_area_struct *vma)
156 static const struct vm_operations_struct psbfb_vm_ops = {
157 .fault = psbfb_vm_fault,
158 .open = psbfb_vm_open,
159 .close = psbfb_vm_close
162 static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
164 struct psb_fbdev *fbdev = info->par;
165 struct psb_framebuffer *psbfb = &fbdev->pfb;
167 if (vma->vm_pgoff != 0)
169 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
172 if (!psbfb->addr_space)
173 psbfb->addr_space = vma->vm_file->f_mapping;
175 * If this is a GEM object then info->screen_base is the virtual
176 * kernel remapping of the object. FIXME: Review if this is
177 * suitable for our mmap work
179 vma->vm_ops = &psbfb_vm_ops;
180 vma->vm_private_data = (void *)psbfb;
181 vma->vm_flags |= VM_IO | VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP;
185 static int psbfb_ioctl(struct fb_info *info, unsigned int cmd,
191 static struct fb_ops psbfb_ops = {
192 .owner = THIS_MODULE,
193 .fb_check_var = drm_fb_helper_check_var,
194 .fb_set_par = drm_fb_helper_set_par,
195 .fb_blank = drm_fb_helper_blank,
196 .fb_setcolreg = psbfb_setcolreg,
197 .fb_fillrect = drm_fb_helper_cfb_fillrect,
198 .fb_copyarea = psbfb_copyarea,
199 .fb_imageblit = drm_fb_helper_cfb_imageblit,
200 .fb_mmap = psbfb_mmap,
201 .fb_sync = psbfb_sync,
202 .fb_ioctl = psbfb_ioctl,
205 static struct fb_ops psbfb_roll_ops = {
206 .owner = THIS_MODULE,
207 .fb_check_var = drm_fb_helper_check_var,
208 .fb_set_par = drm_fb_helper_set_par,
209 .fb_blank = drm_fb_helper_blank,
210 .fb_setcolreg = psbfb_setcolreg,
211 .fb_fillrect = drm_fb_helper_cfb_fillrect,
212 .fb_copyarea = drm_fb_helper_cfb_copyarea,
213 .fb_imageblit = drm_fb_helper_cfb_imageblit,
214 .fb_pan_display = psbfb_pan,
215 .fb_mmap = psbfb_mmap,
216 .fb_ioctl = psbfb_ioctl,
219 static struct fb_ops psbfb_unaccel_ops = {
220 .owner = THIS_MODULE,
221 .fb_check_var = drm_fb_helper_check_var,
222 .fb_set_par = drm_fb_helper_set_par,
223 .fb_blank = drm_fb_helper_blank,
224 .fb_setcolreg = psbfb_setcolreg,
225 .fb_fillrect = drm_fb_helper_cfb_fillrect,
226 .fb_copyarea = drm_fb_helper_cfb_copyarea,
227 .fb_imageblit = drm_fb_helper_cfb_imageblit,
228 .fb_mmap = psbfb_mmap,
229 .fb_ioctl = psbfb_ioctl,
233 * psb_framebuffer_init - initialize a framebuffer
234 * @dev: our DRM device
235 * @fb: framebuffer to set up
236 * @mode_cmd: mode description
237 * @gt: backing object
239 * Configure and fill in the boilerplate for our frame buffer. Return
240 * 0 on success or an error code if we fail.
242 static int psb_framebuffer_init(struct drm_device *dev,
243 struct psb_framebuffer *fb,
244 struct drm_mode_fb_cmd2 *mode_cmd,
245 struct gtt_range *gt)
250 drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);
252 if (mode_cmd->pitches[0] & 63)
263 drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
265 ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs);
267 dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
274 * psb_framebuffer_create - create a framebuffer backed by gt
275 * @dev: our DRM device
276 * @mode_cmd: the description of the requested mode
277 * @gt: the backing object
279 * Create a framebuffer object backed by the gt, and fill in the
280 * boilerplate required
282 * TODO: review object references
285 static struct drm_framebuffer *psb_framebuffer_create
286 (struct drm_device *dev,
287 struct drm_mode_fb_cmd2 *mode_cmd,
288 struct gtt_range *gt)
290 struct psb_framebuffer *fb;
293 fb = kzalloc(sizeof(*fb), GFP_KERNEL);
295 return ERR_PTR(-ENOMEM);
297 ret = psb_framebuffer_init(dev, fb, mode_cmd, gt);
306 * psbfb_alloc - allocate frame buffer memory
307 * @dev: the DRM device
308 * @aligned_size: space needed
309 * @force: fall back to GEM buffers if need be
311 * Allocate the frame buffer. In the usual case we get a GTT range that
312 * is stolen memory backed and life is simple. If there isn't sufficient
313 * we fail as we don't have the virtual mapping space to really vmap it
314 * and the kernel console code can't handle non linear framebuffers.
316 * Re-address this as and if the framebuffer layer grows this ability.
318 static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
320 struct gtt_range *backing;
321 /* Begin by trying to use stolen memory backing */
322 backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1, PAGE_SIZE);
324 drm_gem_private_object_init(dev, &backing->gem, aligned_size);
331 * psbfb_create - create a framebuffer
332 * @fbdev: the framebuffer device
333 * @sizes: specification of the layout
335 * Create a framebuffer to the specifications provided
337 static int psbfb_create(struct psb_fbdev *fbdev,
338 struct drm_fb_helper_surface_size *sizes)
340 struct drm_device *dev = fbdev->psb_fb_helper.dev;
341 struct drm_psb_private *dev_priv = dev->dev_private;
342 struct fb_info *info;
343 struct drm_framebuffer *fb;
344 struct psb_framebuffer *psbfb = &fbdev->pfb;
345 struct drm_mode_fb_cmd2 mode_cmd;
348 struct gtt_range *backing;
353 mode_cmd.width = sizes->surface_width;
354 mode_cmd.height = sizes->surface_height;
355 bpp = sizes->surface_bpp;
356 depth = sizes->surface_depth;
358 /* No 24bit packed */
364 * Acceleration via the GTT requires pitch to be
365 * power of two aligned. Preferably page but less
366 * is ok with some fonts
368 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 4096 >> pitch_lines);
370 size = mode_cmd.pitches[0] * mode_cmd.height;
371 size = ALIGN(size, PAGE_SIZE);
373 /* Allocate the fb in the GTT with stolen page backing */
374 backing = psbfb_alloc(dev, size);
381 } while (backing == NULL && pitch_lines <= 16);
383 /* The final pitch we accepted if we succeeded */
386 if (backing == NULL) {
388 * We couldn't get the space we wanted, fall back to the
389 * display engine requirement instead. The HW requires
390 * the pitch to be 64 byte aligned
393 gtt_roll = 0; /* Don't use GTT accelerated scrolling */
396 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 64);
398 size = mode_cmd.pitches[0] * mode_cmd.height;
399 size = ALIGN(size, PAGE_SIZE);
401 /* Allocate the framebuffer in the GTT with stolen page backing */
402 backing = psbfb_alloc(dev, size);
407 memset(dev_priv->vram_addr + backing->offset, 0, size);
409 mutex_lock(&dev->struct_mutex);
411 info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper);
418 mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth);
420 ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
427 fbdev->psb_fb_helper.fb = fb;
429 drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth);
430 strcpy(info->fix.id, "psbdrmfb");
432 info->flags = FBINFO_DEFAULT;
433 if (dev_priv->ops->accel_2d && pitch_lines > 8) /* 2D engine */
434 info->fbops = &psbfb_ops;
435 else if (gtt_roll) { /* GTT rolling seems best */
436 info->fbops = &psbfb_roll_ops;
437 info->flags |= FBINFO_HWACCEL_YPAN;
438 } else /* Software */
439 info->fbops = &psbfb_unaccel_ops;
441 info->fix.smem_start = dev->mode_config.fb_base;
442 info->fix.smem_len = size;
443 info->fix.ywrapstep = gtt_roll;
444 info->fix.ypanstep = 0;
446 /* Accessed stolen memory directly */
447 info->screen_base = dev_priv->vram_addr + backing->offset;
448 info->screen_size = size;
450 if (dev_priv->gtt.stolen_size) {
451 info->apertures->ranges[0].base = dev->mode_config.fb_base;
452 info->apertures->ranges[0].size = dev_priv->gtt.stolen_size;
455 drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper,
456 sizes->fb_width, sizes->fb_height);
458 info->fix.mmio_start = pci_resource_start(dev->pdev, 0);
459 info->fix.mmio_len = pci_resource_len(dev->pdev, 0);
461 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
463 dev_dbg(dev->dev, "allocated %dx%d fb\n",
464 psbfb->base.width, psbfb->base.height);
466 mutex_unlock(&dev->struct_mutex);
470 psb_gtt_free_range(dev, backing);
472 drm_gem_object_unreference(&backing->gem);
474 drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
476 mutex_unlock(&dev->struct_mutex);
477 psb_gtt_free_range(dev, backing);
482 * psb_user_framebuffer_create - create framebuffer
483 * @dev: our DRM device
487 * Create a new framebuffer backed by a userspace GEM object
489 static struct drm_framebuffer *psb_user_framebuffer_create
490 (struct drm_device *dev, struct drm_file *filp,
491 struct drm_mode_fb_cmd2 *cmd)
494 struct drm_gem_object *obj;
497 * Find the GEM object and thus the gtt range object that is
500 obj = drm_gem_object_lookup(dev, filp, cmd->handles[0]);
502 return ERR_PTR(-ENOENT);
504 /* Let the core code do all the work */
505 r = container_of(obj, struct gtt_range, gem);
506 return psb_framebuffer_create(dev, cmd, r);
509 static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
512 struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
514 gma_crtc->lut_r[regno] = red >> 8;
515 gma_crtc->lut_g[regno] = green >> 8;
516 gma_crtc->lut_b[regno] = blue >> 8;
519 static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
520 u16 *green, u16 *blue, int regno)
522 struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
524 *red = gma_crtc->lut_r[regno] << 8;
525 *green = gma_crtc->lut_g[regno] << 8;
526 *blue = gma_crtc->lut_b[regno] << 8;
529 static int psbfb_probe(struct drm_fb_helper *helper,
530 struct drm_fb_helper_surface_size *sizes)
532 struct psb_fbdev *psb_fbdev =
533 container_of(helper, struct psb_fbdev, psb_fb_helper);
534 struct drm_device *dev = psb_fbdev->psb_fb_helper.dev;
535 struct drm_psb_private *dev_priv = dev->dev_private;
536 unsigned int fb_size;
539 bytespp = sizes->surface_bpp / 8;
540 if (bytespp == 3) /* no 24bit packed */
543 /* If the mode will not fit in 32bit then switch to 16bit to get
544 a console on full resolution. The X mode setting server will
545 allocate its own 32bit GEM framebuffer */
546 fb_size = ALIGN(sizes->surface_width * bytespp, 64) *
547 sizes->surface_height;
548 fb_size = ALIGN(fb_size, PAGE_SIZE);
550 if (fb_size > dev_priv->vram_stolen_size) {
551 sizes->surface_bpp = 16;
552 sizes->surface_depth = 16;
555 return psbfb_create(psb_fbdev, sizes);
558 static const struct drm_fb_helper_funcs psb_fb_helper_funcs = {
559 .gamma_set = psbfb_gamma_set,
560 .gamma_get = psbfb_gamma_get,
561 .fb_probe = psbfb_probe,
564 static int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev)
566 struct psb_framebuffer *psbfb = &fbdev->pfb;
568 drm_fb_helper_unregister_fbi(&fbdev->psb_fb_helper);
569 drm_fb_helper_release_fbi(&fbdev->psb_fb_helper);
571 drm_fb_helper_fini(&fbdev->psb_fb_helper);
572 drm_framebuffer_unregister_private(&psbfb->base);
573 drm_framebuffer_cleanup(&psbfb->base);
576 drm_gem_object_unreference(&psbfb->gtt->gem);
580 int psb_fbdev_init(struct drm_device *dev)
582 struct psb_fbdev *fbdev;
583 struct drm_psb_private *dev_priv = dev->dev_private;
586 fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL);
588 dev_err(dev->dev, "no memory\n");
592 dev_priv->fbdev = fbdev;
594 drm_fb_helper_prepare(dev, &fbdev->psb_fb_helper, &psb_fb_helper_funcs);
596 ret = drm_fb_helper_init(dev, &fbdev->psb_fb_helper,
597 dev_priv->ops->crtcs, INTELFB_CONN_LIMIT);
601 ret = drm_fb_helper_single_add_all_connectors(&fbdev->psb_fb_helper);
605 /* disable all the possible outputs/crtcs before entering KMS mode */
606 drm_helper_disable_unused_functions(dev);
608 ret = drm_fb_helper_initial_config(&fbdev->psb_fb_helper, 32);
615 drm_fb_helper_fini(&fbdev->psb_fb_helper);
621 static void psb_fbdev_fini(struct drm_device *dev)
623 struct drm_psb_private *dev_priv = dev->dev_private;
625 if (!dev_priv->fbdev)
628 psb_fbdev_destroy(dev, dev_priv->fbdev);
629 kfree(dev_priv->fbdev);
630 dev_priv->fbdev = NULL;
633 static void psbfb_output_poll_changed(struct drm_device *dev)
635 struct drm_psb_private *dev_priv = dev->dev_private;
636 struct psb_fbdev *fbdev = (struct psb_fbdev *)dev_priv->fbdev;
637 drm_fb_helper_hotplug_event(&fbdev->psb_fb_helper);
641 * psb_user_framebuffer_create_handle - add hamdle to a framebuffer
643 * @file_priv: our DRM file
644 * @handle: returned handle
646 * Our framebuffer object is a GTT range which also contains a GEM
647 * object. We need to turn it into a handle for userspace. GEM will do
650 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
651 struct drm_file *file_priv,
652 unsigned int *handle)
654 struct psb_framebuffer *psbfb = to_psb_fb(fb);
655 struct gtt_range *r = psbfb->gtt;
656 return drm_gem_handle_create(file_priv, &r->gem, handle);
660 * psb_user_framebuffer_destroy - destruct user created fb
663 * User framebuffers are backed by GEM objects so all we have to do is
664 * clean up a bit and drop the reference, GEM will handle the fallout
666 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
668 struct psb_framebuffer *psbfb = to_psb_fb(fb);
669 struct gtt_range *r = psbfb->gtt;
671 /* Let DRM do its clean up */
672 drm_framebuffer_cleanup(fb);
673 /* We are no longer using the resource in GEM */
674 drm_gem_object_unreference_unlocked(&r->gem);
678 static const struct drm_mode_config_funcs psb_mode_funcs = {
679 .fb_create = psb_user_framebuffer_create,
680 .output_poll_changed = psbfb_output_poll_changed,
683 static int psb_create_backlight_property(struct drm_device *dev)
685 struct drm_psb_private *dev_priv = dev->dev_private;
686 struct drm_property *backlight;
688 if (dev_priv->backlight_property)
691 backlight = drm_property_create_range(dev, 0, "backlight", 0, 100);
693 dev_priv->backlight_property = backlight;
698 static void psb_setup_outputs(struct drm_device *dev)
700 struct drm_psb_private *dev_priv = dev->dev_private;
701 struct drm_connector *connector;
703 drm_mode_create_scaling_mode_property(dev);
704 psb_create_backlight_property(dev);
706 dev_priv->ops->output_init(dev);
708 list_for_each_entry(connector, &dev->mode_config.connector_list,
710 struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
711 struct drm_encoder *encoder = &gma_encoder->base;
712 int crtc_mask = 0, clone_mask = 0;
715 switch (gma_encoder->type) {
716 case INTEL_OUTPUT_ANALOG:
717 crtc_mask = (1 << 0);
718 clone_mask = (1 << INTEL_OUTPUT_ANALOG);
720 case INTEL_OUTPUT_SDVO:
721 crtc_mask = dev_priv->ops->sdvo_mask;
722 clone_mask = (1 << INTEL_OUTPUT_SDVO);
724 case INTEL_OUTPUT_LVDS:
725 crtc_mask = dev_priv->ops->lvds_mask;
726 clone_mask = (1 << INTEL_OUTPUT_LVDS);
728 case INTEL_OUTPUT_MIPI:
729 crtc_mask = (1 << 0);
730 clone_mask = (1 << INTEL_OUTPUT_MIPI);
732 case INTEL_OUTPUT_MIPI2:
733 crtc_mask = (1 << 2);
734 clone_mask = (1 << INTEL_OUTPUT_MIPI2);
736 case INTEL_OUTPUT_HDMI:
737 crtc_mask = dev_priv->ops->hdmi_mask;
738 clone_mask = (1 << INTEL_OUTPUT_HDMI);
740 case INTEL_OUTPUT_DISPLAYPORT:
741 crtc_mask = (1 << 0) | (1 << 1);
742 clone_mask = (1 << INTEL_OUTPUT_DISPLAYPORT);
744 case INTEL_OUTPUT_EDP:
745 crtc_mask = (1 << 1);
746 clone_mask = (1 << INTEL_OUTPUT_EDP);
748 encoder->possible_crtcs = crtc_mask;
749 encoder->possible_clones =
750 gma_connector_clones(dev, clone_mask);
754 void psb_modeset_init(struct drm_device *dev)
756 struct drm_psb_private *dev_priv = dev->dev_private;
757 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
760 drm_mode_config_init(dev);
762 dev->mode_config.min_width = 0;
763 dev->mode_config.min_height = 0;
765 dev->mode_config.funcs = &psb_mode_funcs;
767 /* set memory base */
768 /* Oaktrail and Poulsbo should use BAR 2*/
769 pci_read_config_dword(dev->pdev, PSB_BSM, (u32 *)
770 &(dev->mode_config.fb_base));
772 /* num pipes is 2 for PSB but 1 for Mrst */
773 for (i = 0; i < dev_priv->num_pipe; i++)
774 psb_intel_crtc_init(dev, i, mode_dev);
776 dev->mode_config.max_width = 4096;
777 dev->mode_config.max_height = 4096;
779 psb_setup_outputs(dev);
781 if (dev_priv->ops->errata)
782 dev_priv->ops->errata(dev);
784 dev_priv->modeset = true;
787 void psb_modeset_cleanup(struct drm_device *dev)
789 struct drm_psb_private *dev_priv = dev->dev_private;
790 if (dev_priv->modeset) {
791 mutex_lock(&dev->struct_mutex);
793 drm_kms_helper_poll_fini(dev);
795 drm_mode_config_cleanup(dev);
797 mutex_unlock(&dev->struct_mutex);