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>
37 #include "psb_intel_reg.h"
38 #include "psb_intel_drv.h"
39 #include "framebuffer.h"
42 #include "mdfld_output.h"
44 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb);
45 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
46 struct drm_file *file_priv,
47 unsigned int *handle);
49 static const struct drm_framebuffer_funcs psb_fb_funcs = {
50 .destroy = psb_user_framebuffer_destroy,
51 .create_handle = psb_user_framebuffer_create_handle,
54 #define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16)
56 static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
57 unsigned blue, unsigned transp,
60 struct psb_fbdev *fbdev = info->par;
61 struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
70 red = CMAP_TOHW(red, info->var.red.length);
71 blue = CMAP_TOHW(blue, info->var.blue.length);
72 green = CMAP_TOHW(green, info->var.green.length);
73 transp = CMAP_TOHW(transp, info->var.transp.length);
75 v = (red << info->var.red.offset) |
76 (green << info->var.green.offset) |
77 (blue << info->var.blue.offset) |
78 (transp << info->var.transp.offset);
81 switch (fb->bits_per_pixel) {
83 ((uint32_t *) info->pseudo_palette)[regno] = v;
87 ((uint32_t *) info->pseudo_palette)[regno] = v;
95 static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info)
97 struct psb_fbdev *fbdev = info->par;
98 struct psb_framebuffer *psbfb = &fbdev->pfb;
99 struct drm_device *dev = psbfb->base.dev;
102 * We have to poke our nose in here. The core fb code assumes
103 * panning is part of the hardware that can be invoked before
104 * the actual fb is mapped. In our case that isn't quite true.
106 if (psbfb->gtt->npage)
107 psb_gtt_roll(dev, psbfb->gtt, var->yoffset);
111 void psbfb_suspend(struct drm_device *dev)
113 struct drm_framebuffer *fb = 0;
114 struct psb_framebuffer *psbfb = to_psb_fb(fb);
117 mutex_lock(&dev->mode_config.mutex);
118 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
119 struct fb_info *info = psbfb->fbdev;
120 fb_set_suspend(info, 1);
121 drm_fb_helper_blank(FB_BLANK_POWERDOWN, info);
123 mutex_unlock(&dev->mode_config.mutex);
127 void psbfb_resume(struct drm_device *dev)
129 struct drm_framebuffer *fb = 0;
130 struct psb_framebuffer *psbfb = to_psb_fb(fb);
133 mutex_lock(&dev->mode_config.mutex);
134 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
135 struct fb_info *info = psbfb->fbdev;
136 fb_set_suspend(info, 0);
137 drm_fb_helper_blank(FB_BLANK_UNBLANK, info);
139 mutex_unlock(&dev->mode_config.mutex);
141 drm_helper_disable_unused_functions(dev);
144 static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
146 struct psb_framebuffer *psbfb = vma->vm_private_data;
147 struct drm_device *dev = psbfb->base.dev;
148 struct drm_psb_private *dev_priv = dev->dev_private;
151 unsigned long address;
154 /* FIXME: assumes fb at stolen base which may not be true */
155 unsigned long phys_addr = (unsigned long)dev_priv->stolen_base;
157 page_num = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
158 address = (unsigned long)vmf->virtual_address;
160 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
162 for (i = 0; i < page_num; i++) {
163 pfn = (phys_addr >> PAGE_SHIFT);
165 ret = vm_insert_mixed(vma, address, pfn);
166 if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0)))
168 else if (unlikely(ret != 0)) {
169 ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;
172 address += PAGE_SIZE;
173 phys_addr += PAGE_SIZE;
175 return VM_FAULT_NOPAGE;
178 static void psbfb_vm_open(struct vm_area_struct *vma)
182 static void psbfb_vm_close(struct vm_area_struct *vma)
186 static struct vm_operations_struct psbfb_vm_ops = {
187 .fault = psbfb_vm_fault,
188 .open = psbfb_vm_open,
189 .close = psbfb_vm_close
192 static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
194 struct psb_fbdev *fbdev = info->par;
195 struct psb_framebuffer *psbfb = &fbdev->pfb;
197 if (vma->vm_pgoff != 0)
199 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
202 if (!psbfb->addr_space)
203 psbfb->addr_space = vma->vm_file->f_mapping;
205 * If this is a GEM object then info->screen_base is the virtual
206 * kernel remapping of the object. FIXME: Review if this is
207 * suitable for our mmap work
209 vma->vm_ops = &psbfb_vm_ops;
210 vma->vm_private_data = (void *)psbfb;
211 vma->vm_flags |= VM_RESERVED | VM_IO |
212 VM_MIXEDMAP | VM_DONTEXPAND;
216 static int psbfb_ioctl(struct fb_info *info, unsigned int cmd,
222 static struct fb_ops psbfb_ops = {
223 .owner = THIS_MODULE,
224 .fb_check_var = drm_fb_helper_check_var,
225 .fb_set_par = drm_fb_helper_set_par,
226 .fb_blank = drm_fb_helper_blank,
227 .fb_setcolreg = psbfb_setcolreg,
228 .fb_fillrect = cfb_fillrect,
229 .fb_copyarea = psbfb_copyarea,
230 .fb_imageblit = cfb_imageblit,
231 .fb_mmap = psbfb_mmap,
232 .fb_sync = psbfb_sync,
233 .fb_ioctl = psbfb_ioctl,
236 static struct fb_ops psbfb_roll_ops = {
237 .owner = THIS_MODULE,
238 .fb_check_var = drm_fb_helper_check_var,
239 .fb_set_par = drm_fb_helper_set_par,
240 .fb_blank = drm_fb_helper_blank,
241 .fb_setcolreg = psbfb_setcolreg,
242 .fb_fillrect = cfb_fillrect,
243 .fb_copyarea = cfb_copyarea,
244 .fb_imageblit = cfb_imageblit,
245 .fb_pan_display = psbfb_pan,
246 .fb_mmap = psbfb_mmap,
247 .fb_sync = psbfb_sync,
248 .fb_ioctl = psbfb_ioctl,
251 static struct fb_ops psbfb_unaccel_ops = {
252 .owner = THIS_MODULE,
253 .fb_check_var = drm_fb_helper_check_var,
254 .fb_set_par = drm_fb_helper_set_par,
255 .fb_blank = drm_fb_helper_blank,
256 .fb_setcolreg = psbfb_setcolreg,
257 .fb_fillrect = cfb_fillrect,
258 .fb_copyarea = cfb_copyarea,
259 .fb_imageblit = cfb_imageblit,
260 .fb_mmap = psbfb_mmap,
261 .fb_ioctl = psbfb_ioctl,
265 * psb_framebuffer_init - initialize a framebuffer
266 * @dev: our DRM device
267 * @fb: framebuffer to set up
268 * @mode_cmd: mode description
269 * @gt: backing object
271 * Configure and fill in the boilerplate for our frame buffer. Return
272 * 0 on success or an error code if we fail.
274 static int psb_framebuffer_init(struct drm_device *dev,
275 struct psb_framebuffer *fb,
276 struct drm_mode_fb_cmd *mode_cmd,
277 struct gtt_range *gt)
281 if (mode_cmd->pitch & 63)
283 switch (mode_cmd->bpp) {
292 ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs);
294 dev_err(dev->dev, "framebuffer init failed: %d\n", ret);
297 drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd);
303 * psb_framebuffer_create - create a framebuffer backed by gt
304 * @dev: our DRM device
305 * @mode_cmd: the description of the requested mode
306 * @gt: the backing object
308 * Create a framebuffer object backed by the gt, and fill in the
309 * boilerplate required
311 * TODO: review object references
314 static struct drm_framebuffer *psb_framebuffer_create
315 (struct drm_device *dev,
316 struct drm_mode_fb_cmd *mode_cmd,
317 struct gtt_range *gt)
319 struct psb_framebuffer *fb;
322 fb = kzalloc(sizeof(*fb), GFP_KERNEL);
324 return ERR_PTR(-ENOMEM);
326 ret = psb_framebuffer_init(dev, fb, mode_cmd, gt);
335 * psbfb_alloc - allocate frame buffer memory
336 * @dev: the DRM device
337 * @aligned_size: space needed
338 * @force: fall back to GEM buffers if need be
340 * Allocate the frame buffer. In the usual case we get a GTT range that
341 * is stolen memory backed and life is simple. If there isn't sufficient
342 * stolen memory or the system has no stolen memory we allocate a range
343 * and back it with a GEM object.
345 * In this case the GEM object has no handle.
347 static struct gtt_range *psbfb_alloc(struct drm_device *dev,
348 int aligned_size, int force)
350 struct gtt_range *backing;
351 /* Begin by trying to use stolen memory backing */
352 backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
354 if (drm_gem_private_object_init(dev,
355 &backing->gem, aligned_size) == 0)
357 psb_gtt_free_range(dev, backing);
362 /* Next try using GEM host memory */
363 backing = psb_gtt_alloc_range(dev, aligned_size, "fb(gem)", 0);
367 /* Now back it with an object */
368 if (drm_gem_object_init(dev, &backing->gem, aligned_size) != 0) {
369 psb_gtt_free_range(dev, backing);
376 * psbfb_create - create a framebuffer
377 * @fbdev: the framebuffer device
378 * @sizes: specification of the layout
380 * Create a framebuffer to the specifications provided
382 static int psbfb_create(struct psb_fbdev *fbdev,
383 struct drm_fb_helper_surface_size *sizes)
385 struct drm_device *dev = fbdev->psb_fb_helper.dev;
386 struct drm_psb_private *dev_priv = dev->dev_private;
387 struct fb_info *info;
388 struct drm_framebuffer *fb;
389 struct psb_framebuffer *psbfb = &fbdev->pfb;
390 struct drm_mode_fb_cmd mode_cmd;
391 struct device *device = &dev->pdev->dev;
394 struct gtt_range *backing;
397 mode_cmd.width = sizes->surface_width;
398 mode_cmd.height = sizes->surface_height;
399 mode_cmd.bpp = sizes->surface_bpp;
401 /* No 24bit packed */
402 if (mode_cmd.bpp == 24)
405 /* Acceleration via the GTT requires pitch to be 4096 byte aligned
406 (ie 1024 or 2048 pixels in normal use) */
407 mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 4096);
408 mode_cmd.depth = sizes->surface_depth;
410 size = mode_cmd.pitch * mode_cmd.height;
411 size = ALIGN(size, PAGE_SIZE);
413 /* Allocate the framebuffer in the GTT with stolen page backing */
414 backing = psbfb_alloc(dev, size, 0);
415 if (backing == NULL) {
417 * We couldn't get the space we wanted, fall back to the
418 * display engine requirement instead. The HW requires
419 * the pitch to be 64 byte aligned
422 gtt_roll = 0; /* Don't use GTT accelerated scrolling */
424 mode_cmd.pitch = ALIGN(mode_cmd.width * ((mode_cmd.bpp + 7) / 8), 64);
425 mode_cmd.depth = sizes->surface_depth;
427 size = mode_cmd.pitch * mode_cmd.height;
428 size = ALIGN(size, PAGE_SIZE);
430 /* Allocate the framebuffer in the GTT with stolen page
431 backing when there is room */
432 backing = psbfb_alloc(dev, size, 1);
437 mutex_lock(&dev->struct_mutex);
439 info = framebuffer_alloc(0, device);
446 ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing);
453 fbdev->psb_fb_helper.fb = fb;
454 fbdev->psb_fb_helper.fbdev = info;
456 strcpy(info->fix.id, "psbfb");
458 info->flags = FBINFO_DEFAULT;
459 if (gtt_roll) { /* GTT rolling seems best */
460 info->fbops = &psbfb_roll_ops;
461 info->flags |= FBINFO_HWACCEL_YPAN;
463 else if (dev_priv->ops->accel_2d) /* 2D engine */
464 info->fbops = &psbfb_ops;
466 info->fbops = &psbfb_unaccel_ops;
468 ret = fb_alloc_cmap(&info->cmap, 256, 0);
474 info->fix.smem_start = dev->mode_config.fb_base;
475 info->fix.smem_len = size;
476 info->fix.ywrapstep = gtt_roll;
477 info->fix.ypanstep = gtt_roll;
479 if (backing->stolen) {
480 /* Accessed stolen memory directly */
481 info->screen_base = (char *)dev_priv->vram_addr +
484 /* Pin the pages into the GTT and create a mapping to them */
485 psb_gtt_pin(backing);
486 info->screen_base = vm_map_ram(backing->pages, backing->npage,
488 if (info->screen_base == NULL) {
489 psb_gtt_unpin(backing);
495 info->screen_size = size;
497 if (dev_priv->gtt.stolen_size) {
498 info->apertures = alloc_apertures(1);
499 if (!info->apertures) {
503 info->apertures->ranges[0].base = dev->mode_config.fb_base;
504 info->apertures->ranges[0].size = dev_priv->gtt.stolen_size;
507 drm_fb_helper_fill_fix(info, fb->pitch, fb->depth);
508 drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper,
509 sizes->fb_width, sizes->fb_height);
511 info->fix.mmio_start = pci_resource_start(dev->pdev, 0);
512 info->fix.mmio_len = pci_resource_len(dev->pdev, 0);
514 info->pixmap.size = 64 * 1024;
515 info->pixmap.buf_align = 8;
516 info->pixmap.access_align = 32;
517 info->pixmap.flags = FB_PIXMAP_SYSTEM;
518 info->pixmap.scan_align = 1;
520 dev_info(dev->dev, "allocated %dx%d fb\n",
521 psbfb->base.width, psbfb->base.height);
523 mutex_unlock(&dev->struct_mutex);
527 psb_gtt_free_range(dev, backing);
530 vm_unmap_ram(info->screen_base, backing->npage);
531 drm_gem_object_unreference(&backing->gem);
534 mutex_unlock(&dev->struct_mutex);
535 psb_gtt_free_range(dev, backing);
540 * psb_user_framebuffer_create - create framebuffer
541 * @dev: our DRM device
545 * Create a new framebuffer backed by a userspace GEM object
547 static struct drm_framebuffer *psb_user_framebuffer_create
548 (struct drm_device *dev, struct drm_file *filp,
549 struct drm_mode_fb_cmd *cmd)
552 struct drm_gem_object *obj;
555 * Find the GEM object and thus the gtt range object that is
558 obj = drm_gem_object_lookup(dev, filp, cmd->handle);
560 return ERR_PTR(-ENOENT);
562 /* Let the core code do all the work */
563 r = container_of(obj, struct gtt_range, gem);
564 return psb_framebuffer_create(dev, cmd, r);
567 static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
572 static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
573 u16 *green, u16 *blue, int regno)
577 static int psbfb_probe(struct drm_fb_helper *helper,
578 struct drm_fb_helper_surface_size *sizes)
580 struct psb_fbdev *psb_fbdev = (struct psb_fbdev *)helper;
585 ret = psbfb_create(psb_fbdev, sizes);
593 struct drm_fb_helper_funcs psb_fb_helper_funcs = {
594 .gamma_set = psbfb_gamma_set,
595 .gamma_get = psbfb_gamma_get,
596 .fb_probe = psbfb_probe,
599 int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev)
601 struct fb_info *info;
602 struct psb_framebuffer *psbfb = &fbdev->pfb;
604 if (fbdev->psb_fb_helper.fbdev) {
605 info = fbdev->psb_fb_helper.fbdev;
607 /* If this is our base framebuffer then kill any virtual map
608 for the framebuffer layer and unpin it */
610 vm_unmap_ram(info->screen_base, psbfb->gtt->npage);
611 psb_gtt_unpin(psbfb->gtt);
613 unregister_framebuffer(info);
615 fb_dealloc_cmap(&info->cmap);
616 framebuffer_release(info);
618 drm_fb_helper_fini(&fbdev->psb_fb_helper);
619 drm_framebuffer_cleanup(&psbfb->base);
622 drm_gem_object_unreference(&psbfb->gtt->gem);
626 int psb_fbdev_init(struct drm_device *dev)
628 struct psb_fbdev *fbdev;
629 struct drm_psb_private *dev_priv = dev->dev_private;
631 fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL);
633 dev_err(dev->dev, "no memory\n");
637 dev_priv->fbdev = fbdev;
638 fbdev->psb_fb_helper.funcs = &psb_fb_helper_funcs;
640 drm_fb_helper_init(dev, &fbdev->psb_fb_helper, dev_priv->ops->crtcs,
643 drm_fb_helper_single_add_all_connectors(&fbdev->psb_fb_helper);
644 drm_fb_helper_initial_config(&fbdev->psb_fb_helper, 32);
648 void psb_fbdev_fini(struct drm_device *dev)
650 struct drm_psb_private *dev_priv = dev->dev_private;
652 if (!dev_priv->fbdev)
655 psb_fbdev_destroy(dev, dev_priv->fbdev);
656 kfree(dev_priv->fbdev);
657 dev_priv->fbdev = NULL;
660 static void psbfb_output_poll_changed(struct drm_device *dev)
662 struct drm_psb_private *dev_priv = dev->dev_private;
663 struct psb_fbdev *fbdev = (struct psb_fbdev *)dev_priv->fbdev;
664 drm_fb_helper_hotplug_event(&fbdev->psb_fb_helper);
668 * psb_user_framebuffer_create_handle - add hamdle to a framebuffer
670 * @file_priv: our DRM file
671 * @handle: returned handle
673 * Our framebuffer object is a GTT range which also contains a GEM
674 * object. We need to turn it into a handle for userspace. GEM will do
677 static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
678 struct drm_file *file_priv,
679 unsigned int *handle)
681 struct psb_framebuffer *psbfb = to_psb_fb(fb);
682 struct gtt_range *r = psbfb->gtt;
683 return drm_gem_handle_create(file_priv, &r->gem, handle);
687 * psb_user_framebuffer_destroy - destruct user created fb
690 * User framebuffers are backed by GEM objects so all we have to do is
691 * clean up a bit and drop the reference, GEM will handle the fallout
693 static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
695 struct psb_framebuffer *psbfb = to_psb_fb(fb);
696 struct gtt_range *r = psbfb->gtt;
697 struct drm_device *dev = fb->dev;
698 struct drm_psb_private *dev_priv = dev->dev_private;
699 struct psb_fbdev *fbdev = dev_priv->fbdev;
700 struct drm_crtc *crtc;
703 /* Should never get stolen memory for a user fb */
706 /* Check if we are erroneously live */
707 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
713 * Now force a sane response before we permit the DRM CRTC
714 * layer to do stupid things like blank the display. Instead
715 * we reset this framebuffer as if the user had forced a reset.
716 * We must do this before the cleanup so that the DRM layer
717 * doesn't get a chance to stick its oar in where it isn't
720 drm_fb_helper_restore_fbdev_mode(&fbdev->psb_fb_helper);
722 /* Let DRM do its clean up */
723 drm_framebuffer_cleanup(fb);
724 /* We are no longer using the resource in GEM */
725 drm_gem_object_unreference_unlocked(&r->gem);
729 static const struct drm_mode_config_funcs psb_mode_funcs = {
730 .fb_create = psb_user_framebuffer_create,
731 .output_poll_changed = psbfb_output_poll_changed,
734 static int psb_create_backlight_property(struct drm_device *dev)
736 struct drm_psb_private *dev_priv = dev->dev_private;
737 struct drm_property *backlight;
739 if (dev_priv->backlight_property)
742 backlight = drm_property_create(dev, DRM_MODE_PROP_RANGE,
744 backlight->values[0] = 0;
745 backlight->values[1] = 100;
747 dev_priv->backlight_property = backlight;
752 static void psb_setup_outputs(struct drm_device *dev)
754 struct drm_psb_private *dev_priv = dev->dev_private;
755 struct drm_connector *connector;
757 drm_mode_create_scaling_mode_property(dev);
758 psb_create_backlight_property(dev);
760 dev_priv->ops->output_init(dev);
762 list_for_each_entry(connector, &dev->mode_config.connector_list,
764 struct psb_intel_output *psb_intel_output =
765 to_psb_intel_output(connector);
766 struct drm_encoder *encoder = &psb_intel_output->enc;
767 int crtc_mask = 0, clone_mask = 0;
770 switch (psb_intel_output->type) {
771 case INTEL_OUTPUT_ANALOG:
772 crtc_mask = (1 << 0);
773 clone_mask = (1 << INTEL_OUTPUT_ANALOG);
775 case INTEL_OUTPUT_SDVO:
776 crtc_mask = ((1 << 0) | (1 << 1));
777 clone_mask = (1 << INTEL_OUTPUT_SDVO);
779 case INTEL_OUTPUT_LVDS:
781 crtc_mask = (1 << 0);
783 crtc_mask = (1 << 1);
784 clone_mask = (1 << INTEL_OUTPUT_LVDS);
786 case INTEL_OUTPUT_MIPI:
787 crtc_mask = (1 << 0);
788 clone_mask = (1 << INTEL_OUTPUT_MIPI);
790 case INTEL_OUTPUT_MIPI2:
791 crtc_mask = (1 << 2);
792 clone_mask = (1 << INTEL_OUTPUT_MIPI2);
794 case INTEL_OUTPUT_HDMI:
795 /* HDMI on crtc 1 for SoC devices and crtc 0 for
796 Cedarview. HDMI on Poulsbo is only via external
798 if (IS_MFLD(dev) || IS_MRST(dev))
799 crtc_mask = (1 << 1);
801 crtc_mask = (1 << 0); /* Cedarview */
802 clone_mask = (1 << INTEL_OUTPUT_HDMI);
805 encoder->possible_crtcs = crtc_mask;
806 encoder->possible_clones =
807 psb_intel_connector_clones(dev, clone_mask);
811 void psb_modeset_init(struct drm_device *dev)
813 struct drm_psb_private *dev_priv =
814 (struct drm_psb_private *) dev->dev_private;
815 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
818 drm_mode_config_init(dev);
820 dev->mode_config.min_width = 0;
821 dev->mode_config.min_height = 0;
823 dev->mode_config.funcs = (void *) &psb_mode_funcs;
825 /* set memory base */
826 /* MRST and PSB should use BAR 2*/
827 pci_read_config_dword(dev->pdev, PSB_BSM, (u32 *)
828 &(dev->mode_config.fb_base));
830 /* num pipes is 2 for PSB but 1 for Mrst */
831 for (i = 0; i < dev_priv->num_pipe; i++)
832 psb_intel_crtc_init(dev, i, mode_dev);
834 dev->mode_config.max_width = 2048;
835 dev->mode_config.max_height = 2048;
837 psb_setup_outputs(dev);
840 void psb_modeset_cleanup(struct drm_device *dev)
842 mutex_lock(&dev->struct_mutex);
844 drm_kms_helper_poll_fini(dev);
846 drm_mode_config_cleanup(dev);
848 mutex_unlock(&dev->struct_mutex);