1 /**************************************************************************
2 * Copyright (c) 2007, 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>
37 #include "psb_intel_reg.h"
38 #include "psb_intel_drv.h"
41 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb);
42 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
43 struct drm_file *file_priv,
44 unsigned int *handle);
46 static const struct drm_framebuffer_funcs psb_fb_funcs = {
47 .destroy = psb_user_framebuffer_destroy,
48 .create_handle = psb_user_framebuffer_create_handle,
51 #define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16)
53 void *psbfb_vdc_reg(struct drm_device *dev)
55 struct drm_psb_private *dev_priv;
56 dev_priv = (struct drm_psb_private *) dev->dev_private;
57 return dev_priv->vdc_reg;
59 /*EXPORT_SYMBOL(psbfb_vdc_reg); */
61 static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
62 unsigned blue, unsigned transp,
65 struct psb_fbdev *fbdev = info->par;
66 struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
75 red = CMAP_TOHW(red, info->var.red.length);
76 blue = CMAP_TOHW(blue, info->var.blue.length);
77 green = CMAP_TOHW(green, info->var.green.length);
78 transp = CMAP_TOHW(transp, info->var.transp.length);
80 v = (red << info->var.red.offset) |
81 (green << info->var.green.offset) |
82 (blue << info->var.blue.offset) |
83 (transp << info->var.transp.offset);
86 switch (fb->bits_per_pixel) {
88 ((uint32_t *) info->pseudo_palette)[regno] = v;
92 ((uint32_t *) info->pseudo_palette)[regno] = v;
100 static int psbfb_kms_off(struct drm_device *dev, int suspend)
102 struct drm_framebuffer *fb = 0;
103 struct psb_framebuffer *psbfb = to_psb_fb(fb);
104 DRM_DEBUG("psbfb_kms_off_ioctl\n");
106 mutex_lock(&dev->mode_config.mutex);
107 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
108 struct fb_info *info = psbfb->fbdev;
111 fb_set_suspend(info, 1);
112 drm_fb_helper_blank(FB_BLANK_POWERDOWN, info);
115 mutex_unlock(&dev->mode_config.mutex);
119 int psbfb_kms_off_ioctl(struct drm_device *dev, void *data,
120 struct drm_file *file_priv)
127 ret = psbfb_kms_off(dev, 0);
133 static int psbfb_kms_on(struct drm_device *dev, int resume)
135 struct drm_framebuffer *fb = 0;
136 struct psb_framebuffer *psbfb = to_psb_fb(fb);
138 DRM_DEBUG("psbfb_kms_on_ioctl\n");
140 mutex_lock(&dev->mode_config.mutex);
141 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
142 struct fb_info *info = psbfb->fbdev;
145 fb_set_suspend(info, 0);
146 drm_fb_helper_blank(FB_BLANK_UNBLANK, info);
149 mutex_unlock(&dev->mode_config.mutex);
154 int psbfb_kms_on_ioctl(struct drm_device *dev, void *data,
155 struct drm_file *file_priv)
162 ret = psbfb_kms_on(dev, 0);
164 drm_helper_disable_unused_functions(dev);
168 void psbfb_suspend(struct drm_device *dev)
171 psbfb_kms_off(dev, 1);
175 void psbfb_resume(struct drm_device *dev)
178 psbfb_kms_on(dev, 1);
180 drm_helper_disable_unused_functions(dev);
183 static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
187 unsigned long address = 0;
190 struct psb_framebuffer *psbfb = vma->vm_private_data;
191 struct drm_device *dev = psbfb->base.dev;
192 struct drm_psb_private *dev_priv = dev->dev_private;
193 unsigned long phys_addr = (unsigned long)dev_priv->stolen_base;
195 page_num = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
197 address = (unsigned long)vmf->virtual_address;
199 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
201 for (i = 0; i < page_num; i++) {
202 pfn = (phys_addr >> PAGE_SHIFT); /* phys_to_pfn(phys_addr); */
204 ret = vm_insert_mixed(vma, address, pfn);
205 if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0)))
207 else if (unlikely(ret != 0)) {
208 ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;
212 address += PAGE_SIZE;
213 phys_addr += PAGE_SIZE;
216 return VM_FAULT_NOPAGE;
219 static void psbfb_vm_open(struct vm_area_struct *vma)
221 DRM_DEBUG("vm_open\n");
224 static void psbfb_vm_close(struct vm_area_struct *vma)
226 DRM_DEBUG("vm_close\n");
229 static struct vm_operations_struct psbfb_vm_ops = {
230 .fault = psbfb_vm_fault,
231 .open = psbfb_vm_open,
232 .close = psbfb_vm_close
235 static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
237 struct psb_fbdev *fbdev = info->par;
238 struct psb_framebuffer *psbfb = &fbdev->pfb;
239 char *fb_screen_base = NULL;
240 struct drm_device *dev = psbfb->base.dev;
241 struct drm_psb_private *dev_priv = dev->dev_private;
243 if (vma->vm_pgoff != 0)
245 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
248 if (!psbfb->addr_space)
249 psbfb->addr_space = vma->vm_file->f_mapping;
251 fb_screen_base = (char *)info->screen_base;
253 DRM_DEBUG("vm_pgoff 0x%lx, screen base %p vram_addr %p\n",
254 vma->vm_pgoff, fb_screen_base,
255 dev_priv->vram_addr);
257 /* If this is a GEM object then info->screen_base is the virtual
258 kernel remapping of the object. FIXME: Review if this is
259 suitable for our mmap work */
260 vma->vm_ops = &psbfb_vm_ops;
261 vma->vm_private_data = (void *)psbfb;
262 vma->vm_flags |= VM_RESERVED | VM_IO |
263 VM_MIXEDMAP | VM_DONTEXPAND;
267 static int psbfb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg)
269 struct psb_fbdev *fbdev = info->par;
270 struct psb_framebuffer *psbfb = &fbdev->pfb;
271 struct drm_device *dev = psbfb->base.dev;
272 struct drm_psb_private *dev_priv = dev->dev_private;
273 u32 __user *p = (u32 __user *)arg;
278 if (!capable(CAP_SYS_RAWIO))
284 if (copy_from_user(buf, p + 1, l * sizeof(u32)))
286 psbfb_2d_submit(dev_priv, buf, l);
293 static struct fb_ops psbfb_ops = {
294 .owner = THIS_MODULE,
295 .fb_check_var = drm_fb_helper_check_var,
296 .fb_set_par = drm_fb_helper_set_par,
297 .fb_blank = drm_fb_helper_blank,
298 .fb_setcolreg = psbfb_setcolreg,
299 .fb_fillrect = psbfb_fillrect,
300 .fb_copyarea = psbfb_copyarea,
301 .fb_imageblit = psbfb_imageblit,
302 .fb_mmap = psbfb_mmap,
303 .fb_sync = psbfb_sync,
304 .fb_ioctl = psbfb_ioctl,
308 * psb_framebuffer_init - initialize a framebuffer
309 * @dev: our DRM device
310 * @fb: framebuffer to set up
311 * @mode_cmd: mode description
312 * @gt: backing object
314 * Configure and fill in the boilerplate for our frame buffer. Return
315 * 0 on success or an error code if we fail.
317 static int psb_framebuffer_init(struct drm_device *dev,
318 struct psb_framebuffer *fb,
319 struct drm_mode_fb_cmd *mode_cmd,
320 struct gtt_range *gt)
324 if (mode_cmd->pitch & 63)
326 switch (mode_cmd->bpp) {
335 ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs);
337 dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
340 drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
346 * psb_framebuffer_create - create a framebuffer backed by gt
347 * @dev: our DRM device
348 * @mode_cmd: the description of the requested mode
349 * @gt: the backing object
351 * Create a framebuffer object backed by the gt, and fill in the
352 * boilerplate required
354 * TODO: review object references
356 static struct drm_framebuffer *psb_framebuffer_create
357 (struct drm_device *dev,
358 struct drm_mode_fb_cmd *mode_cmd,
359 struct gtt_range *gt)
361 struct psb_framebuffer *fb;
364 fb = kzalloc(sizeof(*fb), GFP_KERNEL);
366 return ERR_PTR(-ENOMEM);
368 ret = psb_framebuffer_init(dev, fb, mode_cmd, gt);
377 * psbfb_alloc - allocate frame buffer memory
378 * @dev: the DRM device
379 * @aligned_size: space needed
381 * Allocate the frame buffer. In the usual case we get a GTT range that
382 * is stolen memory backed and life is simple. If there isn't sufficient
383 * stolen memory or the system has no stolen memory we allocate a range
384 * and back it with a GEM object.
386 * In this case the GEM object has no handle.
388 * FIXME: console speed up - allocate twice the space if room and use
389 * hardware scrolling for acceleration.
391 static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
393 struct gtt_range *backing;
394 /* Begin by trying to use stolen memory backing */
395 backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
398 /* Next try using GEM host memory */
399 backing = psb_gtt_alloc_range(dev, aligned_size, "fb(gem)", 0);
403 /* Now back it with an object */
404 if (drm_gem_object_init(dev, &backing->gem, aligned_size) != 0) {
405 psb_gtt_free_range(dev, backing);
412 * psbfb_create - create a framebuffer
413 * @fbdev: the framebuffer device
414 * @sizes: specification of the layout
416 * Create a framebuffer to the specifications provided
418 static int psbfb_create(struct psb_fbdev *fbdev,
419 struct drm_fb_helper_surface_size *sizes)
421 struct drm_device *dev = fbdev->psb_fb_helper.dev;
422 struct drm_psb_private *dev_priv = dev->dev_private;
423 struct fb_info *info;
424 struct drm_framebuffer *fb;
425 struct psb_framebuffer *psbfb = &fbdev->pfb;
426 struct drm_mode_fb_cmd mode_cmd;
427 struct device *device = &dev->pdev->dev;
430 struct gtt_range *backing;
432 mode_cmd.width = sizes->surface_width;
433 mode_cmd.height = sizes->surface_height;
434 mode_cmd.bpp = sizes->surface_bpp;
436 /* No 24bit packed */
437 if (mode_cmd.bpp == 24)
440 /* HW requires pitch to be 64 byte aligned */
441 mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 64);
442 mode_cmd.depth = sizes->surface_depth;
444 size = mode_cmd.pitch * mode_cmd.height;
445 size = ALIGN(size, PAGE_SIZE);
447 /* Allocate the framebuffer in the GTT with stolen page backing */
448 backing = psbfb_alloc(dev, size);
452 mutex_lock(&dev->struct_mutex);
454 info = framebuffer_alloc(0, device);
461 ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
468 fbdev->psb_fb_helper.fb = fb;
469 fbdev->psb_fb_helper.fbdev = info;
471 strcpy(info->fix.id, "psbfb");
473 info->flags = FBINFO_DEFAULT;
474 info->fbops = &psbfb_ops;
476 ret = fb_alloc_cmap(&info->cmap, 256, 0);
482 info->fix.smem_start = dev->mode_config.fb_base;
483 info->fix.smem_len = size;
485 if (backing->stolen) {
486 /* Accessed stolen memory directly */
487 info->screen_base = (char *)dev_priv->vram_addr +
490 /* Pin the pages into the GTT and create a mapping to them */
491 psb_gtt_pin(backing);
492 info->screen_base = vm_map_ram(backing->pages, backing->npage,
494 if (info->screen_base == NULL) {
495 psb_gtt_unpin(backing);
501 info->screen_size = size;
502 /* memset(info->screen_base, 0, size); */
504 if (dev_priv->pg->stolen_size) {
505 info->apertures = alloc_apertures(1);
506 if (!info->apertures) {
510 info->apertures->ranges[0].base = dev->mode_config.fb_base;
511 info->apertures->ranges[0].size = dev_priv->pg->stolen_size;
514 drm_fb_helper_fill_fix(info, fb->pitch, fb->depth);
515 drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper,
516 sizes->fb_width, sizes->fb_height);
518 info->fix.mmio_start = pci_resource_start(dev->pdev, 0);
519 info->fix.mmio_len = pci_resource_len(dev->pdev, 0);
521 info->pixmap.size = 64 * 1024;
522 info->pixmap.buf_align = 8;
523 info->pixmap.access_align = 32;
524 info->pixmap.flags = FB_PIXMAP_SYSTEM;
525 info->pixmap.scan_align = 1;
527 DRM_DEBUG("fb depth is %d\n", fb->depth);
528 DRM_DEBUG(" pitch is %d\n", fb->pitch);
530 printk(KERN_INFO"allocated %dx%d fb\n",
531 psbfb->base.width, psbfb->base.height);
533 mutex_unlock(&dev->struct_mutex);
538 psb_gtt_free_range(dev, backing);
541 vm_unmap_ram(info->screen_base, backing->npage);
542 drm_gem_object_unreference(&backing->gem);
545 mutex_unlock(&dev->struct_mutex);
546 psb_gtt_free_range(dev, backing);
551 * psb_user_framebuffer_create - create framebuffer
552 * @dev: our DRM device
556 * Create a new framebuffer backed by a userspace GEM object
558 static struct drm_framebuffer *psb_user_framebuffer_create
559 (struct drm_device *dev, struct drm_file *filp,
560 struct drm_mode_fb_cmd *cmd)
563 struct drm_gem_object *obj;
565 /* Find the GEM object and thus the gtt range object that is
566 to back this space */
567 obj = drm_gem_object_lookup(dev, filp, cmd->handle);
569 return ERR_PTR(-ENOENT);
571 /* Let the core code do all the work */
572 r = container_of(obj, struct gtt_range, gem);
573 return psb_framebuffer_create(dev, cmd, r);
576 static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
579 DRM_DEBUG("%s\n", __func__);
582 static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
583 u16 *green, u16 *blue, int regno)
585 DRM_DEBUG("%s\n", __func__);
588 static int psbfb_probe(struct drm_fb_helper *helper,
589 struct drm_fb_helper_surface_size *sizes)
591 struct psb_fbdev *psb_fbdev = (struct psb_fbdev *)helper;
595 DRM_DEBUG("%s\n", __func__);
598 ret = psbfb_create(psb_fbdev, sizes);
606 struct drm_fb_helper_funcs psb_fb_helper_funcs = {
607 .gamma_set = psbfb_gamma_set,
608 .gamma_get = psbfb_gamma_get,
609 .fb_probe = psbfb_probe,
612 int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev)
614 struct fb_info *info;
615 struct psb_framebuffer *psbfb = &fbdev->pfb;
617 if (fbdev->psb_fb_helper.fbdev) {
618 info = fbdev->psb_fb_helper.fbdev;
620 /* If this is our base framebuffer then kill any virtual map
621 for the framebuffer layer and unpin it */
623 vm_unmap_ram(info->screen_base, psbfb->gtt->npage);
624 psb_gtt_unpin(psbfb->gtt);
626 unregister_framebuffer(info);
628 fb_dealloc_cmap(&info->cmap);
629 framebuffer_release(info);
631 drm_fb_helper_fini(&fbdev->psb_fb_helper);
632 drm_framebuffer_cleanup(&psbfb->base);
635 /* FIXME: this is a bit more inside knowledge than I'd like
636 but I don't see how to make a fake GEM object of the
637 stolen space nicely */
638 if (psbfb->gtt->stolen)
639 psb_gtt_free_range(dev, psbfb->gtt);
641 drm_gem_object_unreference(&psbfb->gtt->gem);
646 int psb_fbdev_init(struct drm_device *dev)
648 struct psb_fbdev *fbdev;
649 struct drm_psb_private *dev_priv = dev->dev_private;
652 fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL);
654 DRM_ERROR("no memory\n");
658 dev_priv->fbdev = fbdev;
659 fbdev->psb_fb_helper.funcs = &psb_fb_helper_funcs;
663 drm_fb_helper_init(dev, &fbdev->psb_fb_helper, num_crtc,
666 drm_fb_helper_single_add_all_connectors(&fbdev->psb_fb_helper);
667 drm_fb_helper_initial_config(&fbdev->psb_fb_helper, 32);
671 void psb_fbdev_fini(struct drm_device *dev)
673 struct drm_psb_private *dev_priv = dev->dev_private;
675 if (!dev_priv->fbdev)
678 psb_fbdev_destroy(dev, dev_priv->fbdev);
679 kfree(dev_priv->fbdev);
680 dev_priv->fbdev = NULL;
683 static void psbfb_output_poll_changed(struct drm_device *dev)
685 struct drm_psb_private *dev_priv = dev->dev_private;
686 struct psb_fbdev *fbdev = (struct psb_fbdev *)dev_priv->fbdev;
687 drm_fb_helper_hotplug_event(&fbdev->psb_fb_helper);
691 * psb_user_framebuffer_create_handle - add hamdle to a framebuffer
693 * @file_priv: our DRM file
694 * @handle: returned handle
696 * Our framebuffer object is a GTT range which also contains a GEM
697 * object. We need to turn it into a handle for userspace. GEM will do
700 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
701 struct drm_file *file_priv,
702 unsigned int *handle)
704 struct psb_framebuffer *psbfb = to_psb_fb(fb);
705 struct gtt_range *r = psbfb->gtt;
708 return drm_gem_handle_create(file_priv, &r->gem, handle);
712 * psb_user_framebuffer_destroy - destruct user created fb
715 * User framebuffers are backed by GEM objects so all we have to do is
716 * clean up a bit and drop the reference, GEM will handle the fallout
718 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
720 struct psb_framebuffer *psbfb = to_psb_fb(fb);
721 struct gtt_range *r = psbfb->gtt;
723 /* Should never get stolen memory for a user fb */
725 pr_err("user framebuffer destroy %p, fbdev %p\n",
726 psbfb, psbfb->fbdev);
727 /* Let DRM do its clean up */
728 drm_framebuffer_cleanup(fb);
729 /* We are no longer using the resource in GEM */
730 drm_gem_object_unreference_unlocked(&r->gem);
735 static const struct drm_mode_config_funcs psb_mode_funcs = {
736 .fb_create = psb_user_framebuffer_create,
737 .output_poll_changed = psbfb_output_poll_changed,
740 static int psb_create_backlight_property(struct drm_device *dev)
742 struct drm_psb_private *dev_priv
743 = (struct drm_psb_private *) dev->dev_private;
744 struct drm_property *backlight;
746 if (dev_priv->backlight_property)
749 backlight = drm_property_create(dev,
753 backlight->values[0] = 0;
754 backlight->values[1] = 100;
756 dev_priv->backlight_property = backlight;
761 static void psb_setup_outputs(struct drm_device *dev)
763 struct drm_psb_private *dev_priv =
764 (struct drm_psb_private *) dev->dev_private;
765 struct drm_connector *connector;
767 PSB_DEBUG_ENTRY("\n");
769 drm_mode_create_scaling_mode_property(dev);
771 psb_create_backlight_property(dev);
774 if (dev_priv->iLVDS_enable)
775 mrst_lvds_init(dev, &dev_priv->mode_dev);
777 DRM_ERROR("DSI is not supported\n");
779 psb_intel_lvds_init(dev, &dev_priv->mode_dev);
780 psb_intel_sdvo_init(dev, SDVOB);
783 list_for_each_entry(connector, &dev->mode_config.connector_list,
785 struct psb_intel_output *psb_intel_output =
786 to_psb_intel_output(connector);
787 struct drm_encoder *encoder = &psb_intel_output->enc;
788 int crtc_mask = 0, clone_mask = 0;
791 switch (psb_intel_output->type) {
792 case INTEL_OUTPUT_SDVO:
793 crtc_mask = ((1 << 0) | (1 << 1));
794 clone_mask = (1 << INTEL_OUTPUT_SDVO);
796 case INTEL_OUTPUT_LVDS:
797 PSB_DEBUG_ENTRY("LVDS.\n");
799 crtc_mask = (1 << 0);
801 crtc_mask = (1 << 1);
802 clone_mask = (1 << INTEL_OUTPUT_LVDS);
804 case INTEL_OUTPUT_MIPI:
805 PSB_DEBUG_ENTRY("MIPI.\n");
806 crtc_mask = (1 << 0);
807 clone_mask = (1 << INTEL_OUTPUT_MIPI);
809 case INTEL_OUTPUT_MIPI2:
810 PSB_DEBUG_ENTRY("MIPI2.\n");
811 crtc_mask = (1 << 2);
812 clone_mask = (1 << INTEL_OUTPUT_MIPI2);
814 case INTEL_OUTPUT_HDMI:
815 PSB_DEBUG_ENTRY("HDMI.\n");
816 crtc_mask = (1 << 1);
817 clone_mask = (1 << INTEL_OUTPUT_HDMI);
821 encoder->possible_crtcs = crtc_mask;
822 encoder->possible_clones =
823 psb_intel_connector_clones(dev, clone_mask);
828 void psb_modeset_init(struct drm_device *dev)
830 struct drm_psb_private *dev_priv =
831 (struct drm_psb_private *) dev->dev_private;
832 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
835 PSB_DEBUG_ENTRY("\n");
837 drm_mode_config_init(dev);
839 dev->mode_config.min_width = 0;
840 dev->mode_config.min_height = 0;
842 dev->mode_config.funcs = (void *) &psb_mode_funcs;
844 /* set memory base */
845 /* MRST and PSB should use BAR 2*/
846 pci_read_config_dword(dev->pdev, PSB_BSM, (u32 *)
847 &(dev->mode_config.fb_base));
849 /* num pipes is 2 for PSB but 1 for Mrst */
850 for (i = 0; i < dev_priv->num_pipe; i++)
851 psb_intel_crtc_init(dev, i, mode_dev);
853 dev->mode_config.max_width = 2048;
854 dev->mode_config.max_height = 2048;
856 psb_setup_outputs(dev);
859 /* drm_initial_config(dev); */
862 void psb_modeset_cleanup(struct drm_device *dev)
864 mutex_lock(&dev->struct_mutex);
866 drm_kms_helper_poll_fini(dev);
869 drm_mode_config_cleanup(dev);
871 mutex_unlock(&dev->struct_mutex);