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"
40 #include "psb_pvr_glue.h"
42 static void psb_user_framebuffer_destroy(struct drm_framebuffer
*fb
);
43 static int psb_user_framebuffer_create_handle(struct drm_framebuffer
*fb
,
44 struct drm_file
*file_priv
,
45 unsigned int *handle
);
47 static const struct drm_framebuffer_funcs psb_fb_funcs
= {
48 .destroy
= psb_user_framebuffer_destroy
,
49 .create_handle
= psb_user_framebuffer_create_handle
,
52 #define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16)
54 void *psbfb_vdc_reg(struct drm_device
*dev
)
56 struct drm_psb_private
*dev_priv
;
57 dev_priv
= (struct drm_psb_private
*) dev
->dev_private
;
58 return dev_priv
->vdc_reg
;
60 /*EXPORT_SYMBOL(psbfb_vdc_reg); */
62 static int psbfb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
63 unsigned blue
, unsigned transp
,
66 struct psb_fbdev
*fbdev
= info
->par
;
67 struct drm_framebuffer
*fb
= fbdev
->psb_fb_helper
.fb
;
76 red
= CMAP_TOHW(red
, info
->var
.red
.length
);
77 blue
= CMAP_TOHW(blue
, info
->var
.blue
.length
);
78 green
= CMAP_TOHW(green
, info
->var
.green
.length
);
79 transp
= CMAP_TOHW(transp
, info
->var
.transp
.length
);
81 v
= (red
<< info
->var
.red
.offset
) |
82 (green
<< info
->var
.green
.offset
) |
83 (blue
<< info
->var
.blue
.offset
) |
84 (transp
<< info
->var
.transp
.offset
);
87 switch (fb
->bits_per_pixel
) {
89 ((uint32_t *) info
->pseudo_palette
)[regno
] = v
;
93 ((uint32_t *) info
->pseudo_palette
)[regno
] = v
;
101 static int psbfb_kms_off(struct drm_device
*dev
, int suspend
)
103 struct drm_framebuffer
*fb
= 0;
104 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
105 DRM_DEBUG("psbfb_kms_off_ioctl\n");
107 mutex_lock(&dev
->mode_config
.mutex
);
108 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, head
) {
109 struct fb_info
*info
= psbfb
->fbdev
;
112 fb_set_suspend(info
, 1);
113 drm_fb_helper_blank(FB_BLANK_POWERDOWN
, info
);
116 mutex_unlock(&dev
->mode_config
.mutex
);
120 int psbfb_kms_off_ioctl(struct drm_device
*dev
, void *data
,
121 struct drm_file
*file_priv
)
128 ret
= psbfb_kms_off(dev
, 0);
134 static int psbfb_kms_on(struct drm_device
*dev
, int resume
)
136 struct drm_framebuffer
*fb
= 0;
137 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
139 DRM_DEBUG("psbfb_kms_on_ioctl\n");
141 mutex_lock(&dev
->mode_config
.mutex
);
142 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, head
) {
143 struct fb_info
*info
= psbfb
->fbdev
;
146 fb_set_suspend(info
, 0);
147 drm_fb_helper_blank(FB_BLANK_UNBLANK
, info
);
150 mutex_unlock(&dev
->mode_config
.mutex
);
155 int psbfb_kms_on_ioctl(struct drm_device
*dev
, void *data
,
156 struct drm_file
*file_priv
)
163 ret
= psbfb_kms_on(dev
, 0);
165 drm_helper_disable_unused_functions(dev
);
169 void psbfb_suspend(struct drm_device
*dev
)
172 psbfb_kms_off(dev
, 1);
176 void psbfb_resume(struct drm_device
*dev
)
179 psbfb_kms_on(dev
, 1);
181 drm_helper_disable_unused_functions(dev
);
184 static int psbfb_vm_fault(struct vm_area_struct
*vma
, struct vm_fault
*vmf
)
188 unsigned long address
= 0;
191 struct psb_framebuffer
*psbfb
= vma
->vm_private_data
;
192 struct drm_device
*dev
= psbfb
->base
.dev
;
193 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
194 struct psb_gtt
*pg
= dev_priv
->pg
;
195 unsigned long phys_addr
= (unsigned long)pg
->stolen_base
;
197 page_num
= (vma
->vm_end
- vma
->vm_start
) >> PAGE_SHIFT
;
199 address
= (unsigned long)vmf
->virtual_address
;
201 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
203 for (i
= 0; i
< page_num
; i
++) {
204 pfn
= (phys_addr
>> PAGE_SHIFT
); /* phys_to_pfn(phys_addr); */
206 ret
= vm_insert_mixed(vma
, address
, pfn
);
207 if (unlikely((ret
== -EBUSY
) || (ret
!= 0 && i
> 0)))
209 else if (unlikely(ret
!= 0)) {
210 ret
= (ret
== -ENOMEM
) ? VM_FAULT_OOM
: VM_FAULT_SIGBUS
;
214 address
+= PAGE_SIZE
;
215 phys_addr
+= PAGE_SIZE
;
218 return VM_FAULT_NOPAGE
;
221 static void psbfb_vm_open(struct vm_area_struct
*vma
)
223 DRM_DEBUG("vm_open\n");
226 static void psbfb_vm_close(struct vm_area_struct
*vma
)
228 DRM_DEBUG("vm_close\n");
231 static struct vm_operations_struct psbfb_vm_ops
= {
232 .fault
= psbfb_vm_fault
,
233 .open
= psbfb_vm_open
,
234 .close
= psbfb_vm_close
237 static int psbfb_mmap(struct fb_info
*info
, struct vm_area_struct
*vma
)
239 struct psb_fbdev
*fbdev
= info
->par
;
240 struct psb_framebuffer
*psbfb
= fbdev
->pfb
;
241 char *fb_screen_base
= NULL
;
242 struct drm_device
*dev
= psbfb
->base
.dev
;
243 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
244 struct psb_gtt
*pg
= dev_priv
->pg
;
246 if (vma
->vm_pgoff
!= 0)
248 if (vma
->vm_pgoff
> (~0UL >> PAGE_SHIFT
))
251 if (!psbfb
->addr_space
)
252 psbfb
->addr_space
= vma
->vm_file
->f_mapping
;
254 fb_screen_base
= (char *)info
->screen_base
;
256 DRM_DEBUG("vm_pgoff 0x%lx, screen base %p vram_addr %p\n",
257 vma
->vm_pgoff
, fb_screen_base
, pg
->vram_addr
);
259 /* FIXME: ultimately this needs to become 'if entirely stolen memory' */
260 if (1 || fb_screen_base
== pg
->vram_addr
) {
261 vma
->vm_ops
= &psbfb_vm_ops
;
262 vma
->vm_private_data
= (void *)psbfb
;
263 vma
->vm_flags
|= VM_RESERVED
| VM_IO
|
264 VM_MIXEDMAP
| VM_DONTEXPAND
;
266 /* GTT memory backed by kernel/user pages, needs a different
267 approach ? - GEM ? */
273 static int psbfb_ioctl(struct fb_info
*info
, unsigned int cmd
, unsigned long arg
)
275 struct psb_fbdev
*fbdev
= info
->par
;
276 struct psb_framebuffer
*psbfb
= fbdev
->pfb
;
277 struct drm_device
*dev
= psbfb
->base
.dev
;
278 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
279 u32 __user
*p
= (u32 __user
*)arg
;
284 if (!capable(CAP_SYS_RAWIO
))
290 if (copy_from_user(buf
, p
+ 1, l
* sizeof(u32
)))
292 psbfb_2d_submit(dev_priv
, buf
, l
);
299 static struct fb_ops psbfb_ops
= {
300 .owner
= THIS_MODULE
,
301 .fb_check_var
= drm_fb_helper_check_var
,
302 .fb_set_par
= drm_fb_helper_set_par
,
303 .fb_blank
= drm_fb_helper_blank
,
304 .fb_setcolreg
= psbfb_setcolreg
,
305 .fb_fillrect
= psbfb_fillrect
,
306 .fb_copyarea
= psbfb_copyarea
,
307 .fb_imageblit
= psbfb_imageblit
,
308 .fb_mmap
= psbfb_mmap
,
309 .fb_sync
= psbfb_sync
,
310 .fb_ioctl
= psbfb_ioctl
,
313 static struct drm_framebuffer
*psb_framebuffer_create
314 (struct drm_device
*dev
, struct drm_mode_fb_cmd
*r
,
317 struct psb_framebuffer
*fb
;
320 fb
= kzalloc(sizeof(*fb
), GFP_KERNEL
);
324 ret
= drm_framebuffer_init(dev
, &fb
->base
, &psb_fb_funcs
);
329 drm_helper_mode_fill_fb_struct(&fb
->base
, r
);
331 fb
->mem
= mm_private
;
341 * psbfb_create - create a framebuffer
342 * @fbdev: the framebuffer device
343 * @sizes: specification of the layout
345 * Create a framebuffer to the specifications provided
347 static int psbfb_create(struct psb_fbdev
*fbdev
,
348 struct drm_fb_helper_surface_size
*sizes
)
350 struct drm_device
*dev
= fbdev
->psb_fb_helper
.dev
;
351 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
352 struct psb_gtt
*pg
= dev_priv
->pg
;
353 struct fb_info
*info
;
354 struct drm_framebuffer
*fb
;
355 struct psb_framebuffer
*psbfb
;
356 struct drm_mode_fb_cmd mode_cmd
;
357 struct device
*device
= &dev
->pdev
->dev
;
358 int size
, aligned_size
;
360 struct gtt_range
*backing
;
362 mode_cmd
.width
= sizes
->surface_width
;
363 mode_cmd
.height
= sizes
->surface_height
;
366 /* HW requires pitch to be 64 byte aligned */
367 mode_cmd
.pitch
= ALIGN(mode_cmd
.width
* ((mode_cmd
.bpp
+ 1) / 8), 64);
370 size
= mode_cmd
.pitch
* mode_cmd
.height
;
371 aligned_size
= ALIGN(size
, PAGE_SIZE
);
373 /* Allocate the framebuffer in the GTT with stolen page backing */
374 backing
= psb_gtt_alloc_range(dev
, aligned_size
, "fb", 1);
378 mutex_lock(&dev
->struct_mutex
);
379 fb
= psb_framebuffer_create(dev
, &mode_cmd
, backing
);
381 DRM_ERROR("failed to allocate fb.\n");
385 psbfb
= to_psb_fb(fb
);
388 info
= framebuffer_alloc(sizeof(struct psb_fbdev
), device
);
398 fbdev
->psb_fb_helper
.fb
= fb
;
399 fbdev
->psb_fb_helper
.fbdev
= info
;
402 strcpy(info
->fix
.id
, "psbfb");
404 info
->flags
= FBINFO_DEFAULT
;
405 info
->fbops
= &psbfb_ops
;
406 info
->fix
.smem_start
= dev
->mode_config
.fb_base
;
407 info
->fix
.smem_len
= size
;
409 /* Accessed via stolen memory directly, This only works for stolem
410 memory however. Need to address this once we start using gtt
412 info
->screen_base
= (char *)pg
->vram_addr
+ backing
->offset
;
413 info
->screen_size
= size
;
414 memset(info
->screen_base
, 0, size
);
416 drm_fb_helper_fill_fix(info
, fb
->pitch
, fb
->depth
);
417 drm_fb_helper_fill_var(info
, &fbdev
->psb_fb_helper
,
418 sizes
->fb_width
, sizes
->fb_height
);
420 info
->fix
.mmio_start
= pci_resource_start(dev
->pdev
, 0);
421 info
->fix
.mmio_len
= pci_resource_len(dev
->pdev
, 0);
423 info
->pixmap
.size
= 64 * 1024;
424 info
->pixmap
.buf_align
= 8;
425 info
->pixmap
.access_align
= 32;
426 info
->pixmap
.flags
= FB_PIXMAP_SYSTEM
;
427 info
->pixmap
.scan_align
= 1;
429 DRM_DEBUG("fb depth is %d\n", fb
->depth
);
430 DRM_DEBUG(" pitch is %d\n", fb
->pitch
);
432 printk(KERN_INFO
"allocated %dx%d fb\n",
433 psbfb
->base
.width
, psbfb
->base
.height
);
435 mutex_unlock(&dev
->struct_mutex
);
439 fb
->funcs
->destroy(fb
);
441 mutex_unlock(&dev
->struct_mutex
);
442 psb_gtt_free_range(dev
, backing
);
447 * psb_user_framebuffer_create - create framebuffer
448 * @dev: our DRM device
452 * Create a new framebuffer backed by a userspace GEM object
454 static struct drm_framebuffer
*psb_user_framebuffer_create
455 (struct drm_device
*dev
, struct drm_file
*filp
,
456 struct drm_mode_fb_cmd
*cmd
)
459 struct drm_gem_object
*obj
;
460 struct psb_framebuffer
*psbfb
;
462 /* Find the GEM object and thus the gtt range object that is
463 to back this space */
464 obj
= drm_gem_object_lookup(dev
, filp
, cmd
->handle
);
466 return ERR_PTR(-ENOENT
);
468 /* Allocate a framebuffer */
469 psbfb
= kzalloc(sizeof(*psbfb
), GFP_KERNEL
);
471 drm_gem_object_unreference_unlocked(obj
);
472 return ERR_PTR(-ENOMEM
);
475 /* Let the core code do all the work */
476 r
= container_of(obj
, struct gtt_range
, gem
);
477 if (psb_framebuffer_create(dev
, cmd
, r
) == NULL
) {
478 drm_gem_object_unreference_unlocked(obj
);
480 return ERR_PTR(-EINVAL
);
482 /* Return the drm_framebuffer contained within the psb fbdev which
483 has been initialized by the framebuffer creation */
487 static void psbfb_gamma_set(struct drm_crtc
*crtc
, u16 red
, u16 green
,
490 DRM_DEBUG("%s\n", __func__
);
493 static void psbfb_gamma_get(struct drm_crtc
*crtc
, u16
*red
,
494 u16
*green
, u16
*blue
, int regno
)
496 DRM_DEBUG("%s\n", __func__
);
499 static int psbfb_probe(struct drm_fb_helper
*helper
,
500 struct drm_fb_helper_surface_size
*sizes
)
502 struct psb_fbdev
*psb_fbdev
= (struct psb_fbdev
*)helper
;
506 DRM_DEBUG("%s\n", __func__
);
509 ret
= psbfb_create(psb_fbdev
, sizes
);
517 struct drm_fb_helper_funcs psb_fb_helper_funcs
= {
518 .gamma_set
= psbfb_gamma_set
,
519 .gamma_get
= psbfb_gamma_get
,
520 .fb_probe
= psbfb_probe
,
523 int psb_fbdev_destroy(struct drm_device
*dev
, struct psb_fbdev
*fbdev
)
525 struct fb_info
*info
;
526 struct psb_framebuffer
*psbfb
= fbdev
->pfb
;
528 if (fbdev
->psb_fb_helper
.fbdev
) {
529 info
= fbdev
->psb_fb_helper
.fbdev
;
530 psb_gtt_free_range(dev
, psbfb
->mem
);
531 unregister_framebuffer(info
);
532 iounmap(info
->screen_base
);
533 framebuffer_release(info
);
536 drm_fb_helper_fini(&fbdev
->psb_fb_helper
);
537 drm_framebuffer_cleanup(&psbfb
->base
);
541 int psb_fbdev_init(struct drm_device
*dev
)
543 struct psb_fbdev
*fbdev
;
544 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
547 fbdev
= kzalloc(sizeof(struct psb_fbdev
), GFP_KERNEL
);
549 DRM_ERROR("no memory\n");
553 dev_priv
->fbdev
= fbdev
;
554 fbdev
->psb_fb_helper
.funcs
= &psb_fb_helper_funcs
;
558 drm_fb_helper_init(dev
, &fbdev
->psb_fb_helper
, num_crtc
,
561 drm_fb_helper_single_add_all_connectors(&fbdev
->psb_fb_helper
);
562 drm_fb_helper_initial_config(&fbdev
->psb_fb_helper
, 32);
566 void psb_fbdev_fini(struct drm_device
*dev
)
568 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
570 if (!dev_priv
->fbdev
)
573 psb_fbdev_destroy(dev
, dev_priv
->fbdev
);
574 kfree(dev_priv
->fbdev
);
575 dev_priv
->fbdev
= NULL
;
579 static void psbfb_output_poll_changed(struct drm_device
*dev
)
581 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
582 struct psb_fbdev
*fbdev
= (struct psb_fbdev
*)dev_priv
->fbdev
;
583 drm_fb_helper_hotplug_event(&fbdev
->psb_fb_helper
);
586 int psbfb_remove(struct drm_device
*dev
, struct drm_framebuffer
*fb
)
588 struct fb_info
*info
;
589 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
597 framebuffer_release(info
);
600 /*EXPORT_SYMBOL(psbfb_remove); */
603 * psb_user_framebuffer_create_handle - add hamdle to a framebuffer
605 * @file_priv: our DRM file
606 * @handle: returned handle
608 * Our framebuffer object is a GTT range which also contains a GEM
609 * object. We need to turn it into a handle for userspace. GEM will do
612 static int psb_user_framebuffer_create_handle(struct drm_framebuffer
*fb
,
613 struct drm_file
*file_priv
,
614 unsigned int *handle
)
616 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
617 struct gtt_range
*r
= psbfb
->mem
;
618 return drm_gem_handle_create(file_priv
, &r
->gem
, handle
);
622 * psb_user_framebuffer_destroy - destruct user created fb
625 * User framebuffers are backed by GEM objects so all we have to do is
626 * clean up a bit and drop the reference, GEM will handle the fallout
628 static void psb_user_framebuffer_destroy(struct drm_framebuffer
*fb
)
630 struct drm_device
*dev
= fb
->dev
;
631 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
632 struct gtt_range
*r
= psbfb
->mem
;
635 psbfb_remove(dev
, fb
);
637 /* Let DRM do its clean up */
638 drm_framebuffer_cleanup(fb
);
639 /* We are no longer using the resource in GEM */
640 drm_gem_object_unreference_unlocked(&r
->gem
);
645 static const struct drm_mode_config_funcs psb_mode_funcs
= {
646 .fb_create
= psb_user_framebuffer_create
,
647 .output_poll_changed
= psbfb_output_poll_changed
,
650 static int psb_create_backlight_property(struct drm_device
*dev
)
652 struct drm_psb_private
*dev_priv
653 = (struct drm_psb_private
*) dev
->dev_private
;
654 struct drm_property
*backlight
;
656 if (dev_priv
->backlight_property
)
659 backlight
= drm_property_create(dev
,
663 backlight
->values
[0] = 0;
664 backlight
->values
[1] = 100;
666 dev_priv
->backlight_property
= backlight
;
671 static void psb_setup_outputs(struct drm_device
*dev
)
673 struct drm_psb_private
*dev_priv
=
674 (struct drm_psb_private
*) dev
->dev_private
;
675 struct drm_connector
*connector
;
677 PSB_DEBUG_ENTRY("\n");
679 drm_mode_create_scaling_mode_property(dev
);
681 psb_create_backlight_property(dev
);
684 if (dev_priv
->iLVDS_enable
)
685 mrst_lvds_init(dev
, &dev_priv
->mode_dev
);
687 DRM_ERROR("DSI is not supported\n");
689 psb_intel_lvds_init(dev
, &dev_priv
->mode_dev
);
690 psb_intel_sdvo_init(dev
, SDVOB
);
693 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
,
695 struct psb_intel_output
*psb_intel_output
=
696 to_psb_intel_output(connector
);
697 struct drm_encoder
*encoder
= &psb_intel_output
->enc
;
698 int crtc_mask
= 0, clone_mask
= 0;
701 switch (psb_intel_output
->type
) {
702 case INTEL_OUTPUT_SDVO
:
703 crtc_mask
= ((1 << 0) | (1 << 1));
704 clone_mask
= (1 << INTEL_OUTPUT_SDVO
);
706 case INTEL_OUTPUT_LVDS
:
707 PSB_DEBUG_ENTRY("LVDS.\n");
709 crtc_mask
= (1 << 0);
711 crtc_mask
= (1 << 1);
712 clone_mask
= (1 << INTEL_OUTPUT_LVDS
);
714 case INTEL_OUTPUT_MIPI
:
715 PSB_DEBUG_ENTRY("MIPI.\n");
716 crtc_mask
= (1 << 0);
717 clone_mask
= (1 << INTEL_OUTPUT_MIPI
);
719 case INTEL_OUTPUT_MIPI2
:
720 PSB_DEBUG_ENTRY("MIPI2.\n");
721 crtc_mask
= (1 << 2);
722 clone_mask
= (1 << INTEL_OUTPUT_MIPI2
);
724 case INTEL_OUTPUT_HDMI
:
725 PSB_DEBUG_ENTRY("HDMI.\n");
726 crtc_mask
= (1 << 1);
727 clone_mask
= (1 << INTEL_OUTPUT_HDMI
);
731 encoder
->possible_crtcs
= crtc_mask
;
732 encoder
->possible_clones
=
733 psb_intel_connector_clones(dev
, clone_mask
);
738 static void *psb_bo_from_handle(struct drm_device
*dev
,
739 struct drm_file
*file_priv
,
742 void *psKernelMemInfo
= NULL
;
743 void * hKernelMemInfo
= (void *)handle
;
746 ret
= psb_get_meminfo_by_handle(hKernelMemInfo
, &psKernelMemInfo
);
748 DRM_ERROR("Cannot get meminfo for handle 0x%x\n",
749 (u32
)hKernelMemInfo
);
753 return (void *)psKernelMemInfo
;
756 static size_t psb_bo_size(struct drm_device
*dev
, void *bof
)
759 void *psKernelMemInfo
= (void *)bof
;
760 return (size_t)psKernelMemInfo
->ui32AllocSize
;
766 static size_t psb_bo_offset(struct drm_device
*dev
, void *bof
)
768 struct psb_framebuffer
*psbfb
769 = (struct psb_framebuffer
*)bof
;
771 return (size_t)psbfb
->offset
;
774 static int psb_bo_pin_for_scanout(struct drm_device
*dev
, void *bo
)
779 static int psb_bo_unpin_for_scanout(struct drm_device
*dev
, void *bo
)
784 void psb_modeset_init(struct drm_device
*dev
)
786 struct drm_psb_private
*dev_priv
=
787 (struct drm_psb_private
*) dev
->dev_private
;
788 struct psb_intel_mode_device
*mode_dev
= &dev_priv
->mode_dev
;
791 PSB_DEBUG_ENTRY("\n");
792 /* Init mm functions */
793 mode_dev
->bo_from_handle
= psb_bo_from_handle
;
794 mode_dev
->bo_size
= psb_bo_size
;
795 mode_dev
->bo_offset
= psb_bo_offset
;
796 mode_dev
->bo_pin_for_scanout
= psb_bo_pin_for_scanout
;
797 mode_dev
->bo_unpin_for_scanout
= psb_bo_unpin_for_scanout
;
799 drm_mode_config_init(dev
);
801 dev
->mode_config
.min_width
= 0;
802 dev
->mode_config
.min_height
= 0;
804 dev
->mode_config
.funcs
= (void *) &psb_mode_funcs
;
806 /* set memory base */
807 /* MRST and PSB should use BAR 2*/
808 pci_read_config_dword(dev
->pdev
, PSB_BSM
, (u32
*)
809 &(dev
->mode_config
.fb_base
));
811 /* num pipes is 2 for PSB but 1 for Mrst */
812 for (i
= 0; i
< dev_priv
->num_pipe
; i
++)
813 psb_intel_crtc_init(dev
, i
, mode_dev
);
815 dev
->mode_config
.max_width
= 2048;
816 dev
->mode_config
.max_height
= 2048;
818 psb_setup_outputs(dev
);
821 /* drm_initial_config(dev); */
824 void psb_modeset_cleanup(struct drm_device
*dev
)
826 mutex_lock(&dev
->struct_mutex
);
828 drm_kms_helper_poll_fini(dev
);
831 drm_mode_config_cleanup(dev
);
833 mutex_unlock(&dev
->struct_mutex
);