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"
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
;
60 static int psbfb_setcolreg(unsigned regno
, unsigned red
, unsigned green
,
61 unsigned blue
, unsigned transp
,
64 struct psb_fbdev
*fbdev
= info
->par
;
65 struct drm_framebuffer
*fb
= fbdev
->psb_fb_helper
.fb
;
74 red
= CMAP_TOHW(red
, info
->var
.red
.length
);
75 blue
= CMAP_TOHW(blue
, info
->var
.blue
.length
);
76 green
= CMAP_TOHW(green
, info
->var
.green
.length
);
77 transp
= CMAP_TOHW(transp
, info
->var
.transp
.length
);
79 v
= (red
<< info
->var
.red
.offset
) |
80 (green
<< info
->var
.green
.offset
) |
81 (blue
<< info
->var
.blue
.offset
) |
82 (transp
<< info
->var
.transp
.offset
);
85 switch (fb
->bits_per_pixel
) {
87 ((uint32_t *) info
->pseudo_palette
)[regno
] = v
;
91 ((uint32_t *) info
->pseudo_palette
)[regno
] = v
;
99 static int psbfb_kms_off(struct drm_device
*dev
, int suspend
)
101 struct drm_framebuffer
*fb
= 0;
102 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
104 mutex_lock(&dev
->mode_config
.mutex
);
105 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, head
) {
106 struct fb_info
*info
= psbfb
->fbdev
;
109 fb_set_suspend(info
, 1);
110 drm_fb_helper_blank(FB_BLANK_POWERDOWN
, info
);
113 mutex_unlock(&dev
->mode_config
.mutex
);
117 int psbfb_kms_off_ioctl(struct drm_device
*dev
, void *data
,
118 struct drm_file
*file_priv
)
125 ret
= psbfb_kms_off(dev
, 0);
131 static int psbfb_kms_on(struct drm_device
*dev
, int resume
)
133 struct drm_framebuffer
*fb
= 0;
134 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
136 mutex_lock(&dev
->mode_config
.mutex
);
137 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, head
) {
138 struct fb_info
*info
= psbfb
->fbdev
;
141 fb_set_suspend(info
, 0);
142 drm_fb_helper_blank(FB_BLANK_UNBLANK
, info
);
145 mutex_unlock(&dev
->mode_config
.mutex
);
150 int psbfb_kms_on_ioctl(struct drm_device
*dev
, void *data
,
151 struct drm_file
*file_priv
)
158 ret
= psbfb_kms_on(dev
, 0);
160 drm_helper_disable_unused_functions(dev
);
164 void psbfb_suspend(struct drm_device
*dev
)
167 psbfb_kms_off(dev
, 1);
171 void psbfb_resume(struct drm_device
*dev
)
174 psbfb_kms_on(dev
, 1);
176 drm_helper_disable_unused_functions(dev
);
179 static int psbfb_vm_fault(struct vm_area_struct
*vma
, struct vm_fault
*vmf
)
183 unsigned long address
= 0;
186 struct psb_framebuffer
*psbfb
= vma
->vm_private_data
;
187 struct drm_device
*dev
= psbfb
->base
.dev
;
188 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
189 unsigned long phys_addr
= (unsigned long)dev_priv
->stolen_base
;
191 page_num
= (vma
->vm_end
- vma
->vm_start
) >> PAGE_SHIFT
;
193 address
= (unsigned long)vmf
->virtual_address
;
195 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
197 for (i
= 0; i
< page_num
; i
++) {
198 pfn
= (phys_addr
>> PAGE_SHIFT
); /* phys_to_pfn(phys_addr); */
200 ret
= vm_insert_mixed(vma
, address
, pfn
);
201 if (unlikely((ret
== -EBUSY
) || (ret
!= 0 && i
> 0)))
203 else if (unlikely(ret
!= 0)) {
204 ret
= (ret
== -ENOMEM
) ? VM_FAULT_OOM
: VM_FAULT_SIGBUS
;
208 address
+= PAGE_SIZE
;
209 phys_addr
+= PAGE_SIZE
;
212 return VM_FAULT_NOPAGE
;
215 static void psbfb_vm_open(struct vm_area_struct
*vma
)
219 static void psbfb_vm_close(struct vm_area_struct
*vma
)
223 static struct vm_operations_struct psbfb_vm_ops
= {
224 .fault
= psbfb_vm_fault
,
225 .open
= psbfb_vm_open
,
226 .close
= psbfb_vm_close
229 static int psbfb_mmap(struct fb_info
*info
, struct vm_area_struct
*vma
)
231 struct psb_fbdev
*fbdev
= info
->par
;
232 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
233 char *fb_screen_base
= NULL
;
235 if (vma
->vm_pgoff
!= 0)
237 if (vma
->vm_pgoff
> (~0UL >> PAGE_SHIFT
))
240 if (!psbfb
->addr_space
)
241 psbfb
->addr_space
= vma
->vm_file
->f_mapping
;
243 fb_screen_base
= (char *)info
->screen_base
;
245 /* If this is a GEM object then info->screen_base is the virtual
246 kernel remapping of the object. FIXME: Review if this is
247 suitable for our mmap work */
248 vma
->vm_ops
= &psbfb_vm_ops
;
249 vma
->vm_private_data
= (void *)psbfb
;
250 vma
->vm_flags
|= VM_RESERVED
| VM_IO
|
251 VM_MIXEDMAP
| VM_DONTEXPAND
;
255 static int psbfb_ioctl(struct fb_info
*info
, unsigned int cmd
, unsigned long arg
)
257 struct psb_fbdev
*fbdev
= info
->par
;
258 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
259 struct drm_device
*dev
= psbfb
->base
.dev
;
260 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
261 u32 __user
*p
= (u32 __user
*)arg
;
266 if (!capable(CAP_SYS_RAWIO
))
272 if (copy_from_user(buf
, p
+ 1, l
* sizeof(u32
)))
274 psbfb_2d_submit(dev_priv
, buf
, l
);
281 static struct fb_ops psbfb_ops
= {
282 .owner
= THIS_MODULE
,
283 .fb_check_var
= drm_fb_helper_check_var
,
284 .fb_set_par
= drm_fb_helper_set_par
,
285 .fb_blank
= drm_fb_helper_blank
,
286 .fb_setcolreg
= psbfb_setcolreg
,
287 .fb_fillrect
= psbfb_fillrect
,
288 .fb_copyarea
= psbfb_copyarea
,
289 .fb_imageblit
= psbfb_imageblit
,
290 .fb_mmap
= psbfb_mmap
,
291 .fb_sync
= psbfb_sync
,
292 .fb_ioctl
= psbfb_ioctl
,
296 * psb_framebuffer_init - initialize a framebuffer
297 * @dev: our DRM device
298 * @fb: framebuffer to set up
299 * @mode_cmd: mode description
300 * @gt: backing object
302 * Configure and fill in the boilerplate for our frame buffer. Return
303 * 0 on success or an error code if we fail.
305 static int psb_framebuffer_init(struct drm_device
*dev
,
306 struct psb_framebuffer
*fb
,
307 struct drm_mode_fb_cmd
*mode_cmd
,
308 struct gtt_range
*gt
)
312 if (mode_cmd
->pitch
& 63)
314 switch (mode_cmd
->bpp
) {
323 ret
= drm_framebuffer_init(dev
, &fb
->base
, &psb_fb_funcs
);
325 dev_err(dev
->dev
, "framebuffer init failed: %d\n", ret
);
328 drm_helper_mode_fill_fb_struct(&fb
->base
, mode_cmd
);
334 * psb_framebuffer_create - create a framebuffer backed by gt
335 * @dev: our DRM device
336 * @mode_cmd: the description of the requested mode
337 * @gt: the backing object
339 * Create a framebuffer object backed by the gt, and fill in the
340 * boilerplate required
342 * TODO: review object references
344 static struct drm_framebuffer
*psb_framebuffer_create
345 (struct drm_device
*dev
,
346 struct drm_mode_fb_cmd
*mode_cmd
,
347 struct gtt_range
*gt
)
349 struct psb_framebuffer
*fb
;
352 fb
= kzalloc(sizeof(*fb
), GFP_KERNEL
);
354 return ERR_PTR(-ENOMEM
);
356 ret
= psb_framebuffer_init(dev
, fb
, mode_cmd
, gt
);
365 * psbfb_alloc - allocate frame buffer memory
366 * @dev: the DRM device
367 * @aligned_size: space needed
369 * Allocate the frame buffer. In the usual case we get a GTT range that
370 * is stolen memory backed and life is simple. If there isn't sufficient
371 * stolen memory or the system has no stolen memory we allocate a range
372 * and back it with a GEM object.
374 * In this case the GEM object has no handle.
376 * FIXME: console speed up - allocate twice the space if room and use
377 * hardware scrolling for acceleration.
379 static struct gtt_range
*psbfb_alloc(struct drm_device
*dev
, int aligned_size
)
381 struct gtt_range
*backing
;
382 /* Begin by trying to use stolen memory backing */
383 backing
= psb_gtt_alloc_range(dev
, aligned_size
, "fb", 1);
386 /* Next try using GEM host memory */
387 backing
= psb_gtt_alloc_range(dev
, aligned_size
, "fb(gem)", 0);
391 /* Now back it with an object */
392 if (drm_gem_object_init(dev
, &backing
->gem
, aligned_size
) != 0) {
393 psb_gtt_free_range(dev
, backing
);
400 * psbfb_create - create a framebuffer
401 * @fbdev: the framebuffer device
402 * @sizes: specification of the layout
404 * Create a framebuffer to the specifications provided
406 static int psbfb_create(struct psb_fbdev
*fbdev
,
407 struct drm_fb_helper_surface_size
*sizes
)
409 struct drm_device
*dev
= fbdev
->psb_fb_helper
.dev
;
410 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
411 struct fb_info
*info
;
412 struct drm_framebuffer
*fb
;
413 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
414 struct drm_mode_fb_cmd mode_cmd
;
415 struct device
*device
= &dev
->pdev
->dev
;
418 struct gtt_range
*backing
;
420 mode_cmd
.width
= sizes
->surface_width
;
421 mode_cmd
.height
= sizes
->surface_height
;
422 mode_cmd
.bpp
= sizes
->surface_bpp
;
424 /* No 24bit packed */
425 if (mode_cmd
.bpp
== 24)
428 /* HW requires pitch to be 64 byte aligned */
429 mode_cmd
.pitch
= ALIGN(mode_cmd
.width
* ((mode_cmd
.bpp
+ 7) / 8), 64);
430 mode_cmd
.depth
= sizes
->surface_depth
;
432 size
= mode_cmd
.pitch
* mode_cmd
.height
;
433 size
= ALIGN(size
, PAGE_SIZE
);
435 /* Allocate the framebuffer in the GTT with stolen page backing */
436 backing
= psbfb_alloc(dev
, size
);
440 mutex_lock(&dev
->struct_mutex
);
442 info
= framebuffer_alloc(0, device
);
449 ret
= psb_framebuffer_init(dev
, psbfb
, &mode_cmd
, backing
);
456 fbdev
->psb_fb_helper
.fb
= fb
;
457 fbdev
->psb_fb_helper
.fbdev
= info
;
459 strcpy(info
->fix
.id
, "psbfb");
461 info
->flags
= FBINFO_DEFAULT
;
462 info
->fbops
= &psbfb_ops
;
464 ret
= fb_alloc_cmap(&info
->cmap
, 256, 0);
470 info
->fix
.smem_start
= dev
->mode_config
.fb_base
;
471 info
->fix
.smem_len
= size
;
473 if (backing
->stolen
) {
474 /* Accessed stolen memory directly */
475 info
->screen_base
= (char *)dev_priv
->vram_addr
+
478 /* Pin the pages into the GTT and create a mapping to them */
479 psb_gtt_pin(backing
);
480 info
->screen_base
= vm_map_ram(backing
->pages
, backing
->npage
,
482 if (info
->screen_base
== NULL
) {
483 psb_gtt_unpin(backing
);
489 info
->screen_size
= size
;
490 /* memset(info->screen_base, 0, size); */
492 if (dev_priv
->pg
->stolen_size
) {
493 info
->apertures
= alloc_apertures(1);
494 if (!info
->apertures
) {
498 info
->apertures
->ranges
[0].base
= dev
->mode_config
.fb_base
;
499 info
->apertures
->ranges
[0].size
= dev_priv
->pg
->stolen_size
;
502 drm_fb_helper_fill_fix(info
, fb
->pitch
, fb
->depth
);
503 drm_fb_helper_fill_var(info
, &fbdev
->psb_fb_helper
,
504 sizes
->fb_width
, sizes
->fb_height
);
506 info
->fix
.mmio_start
= pci_resource_start(dev
->pdev
, 0);
507 info
->fix
.mmio_len
= pci_resource_len(dev
->pdev
, 0);
509 info
->pixmap
.size
= 64 * 1024;
510 info
->pixmap
.buf_align
= 8;
511 info
->pixmap
.access_align
= 32;
512 info
->pixmap
.flags
= FB_PIXMAP_SYSTEM
;
513 info
->pixmap
.scan_align
= 1;
515 dev_info(dev
->dev
, "allocated %dx%d fb\n",
516 psbfb
->base
.width
, psbfb
->base
.height
);
518 mutex_unlock(&dev
->struct_mutex
);
522 psb_gtt_free_range(dev
, backing
);
525 vm_unmap_ram(info
->screen_base
, backing
->npage
);
526 drm_gem_object_unreference(&backing
->gem
);
529 mutex_unlock(&dev
->struct_mutex
);
530 psb_gtt_free_range(dev
, backing
);
535 * psb_user_framebuffer_create - create framebuffer
536 * @dev: our DRM device
540 * Create a new framebuffer backed by a userspace GEM object
542 static struct drm_framebuffer
*psb_user_framebuffer_create
543 (struct drm_device
*dev
, struct drm_file
*filp
,
544 struct drm_mode_fb_cmd
*cmd
)
547 struct drm_gem_object
*obj
;
549 /* Find the GEM object and thus the gtt range object that is
550 to back this space */
551 obj
= drm_gem_object_lookup(dev
, filp
, cmd
->handle
);
553 return ERR_PTR(-ENOENT
);
555 /* Let the core code do all the work */
556 r
= container_of(obj
, struct gtt_range
, gem
);
557 return psb_framebuffer_create(dev
, cmd
, r
);
560 static void psbfb_gamma_set(struct drm_crtc
*crtc
, u16 red
, u16 green
,
565 static void psbfb_gamma_get(struct drm_crtc
*crtc
, u16
*red
,
566 u16
*green
, u16
*blue
, int regno
)
570 static int psbfb_probe(struct drm_fb_helper
*helper
,
571 struct drm_fb_helper_surface_size
*sizes
)
573 struct psb_fbdev
*psb_fbdev
= (struct psb_fbdev
*)helper
;
578 ret
= psbfb_create(psb_fbdev
, sizes
);
586 struct drm_fb_helper_funcs psb_fb_helper_funcs
= {
587 .gamma_set
= psbfb_gamma_set
,
588 .gamma_get
= psbfb_gamma_get
,
589 .fb_probe
= psbfb_probe
,
592 int psb_fbdev_destroy(struct drm_device
*dev
, struct psb_fbdev
*fbdev
)
594 struct fb_info
*info
;
595 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
597 if (fbdev
->psb_fb_helper
.fbdev
) {
598 info
= fbdev
->psb_fb_helper
.fbdev
;
600 /* If this is our base framebuffer then kill any virtual map
601 for the framebuffer layer and unpin it */
603 vm_unmap_ram(info
->screen_base
, psbfb
->gtt
->npage
);
604 psb_gtt_unpin(psbfb
->gtt
);
606 unregister_framebuffer(info
);
608 fb_dealloc_cmap(&info
->cmap
);
609 framebuffer_release(info
);
611 drm_fb_helper_fini(&fbdev
->psb_fb_helper
);
612 drm_framebuffer_cleanup(&psbfb
->base
);
615 /* FIXME: this is a bit more inside knowledge than I'd like
616 but I don't see how to make a fake GEM object of the
617 stolen space nicely */
618 if (psbfb
->gtt
->stolen
)
619 psb_gtt_free_range(dev
, psbfb
->gtt
);
621 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
;
632 fbdev
= kzalloc(sizeof(struct psb_fbdev
), GFP_KERNEL
);
634 dev_err(dev
->dev
, "no memory\n");
638 dev_priv
->fbdev
= fbdev
;
639 fbdev
->psb_fb_helper
.funcs
= &psb_fb_helper_funcs
;
643 drm_fb_helper_init(dev
, &fbdev
->psb_fb_helper
, num_crtc
,
646 drm_fb_helper_single_add_all_connectors(&fbdev
->psb_fb_helper
);
647 drm_fb_helper_initial_config(&fbdev
->psb_fb_helper
, 32);
651 void psb_fbdev_fini(struct drm_device
*dev
)
653 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
655 if (!dev_priv
->fbdev
)
658 psb_fbdev_destroy(dev
, dev_priv
->fbdev
);
659 kfree(dev_priv
->fbdev
);
660 dev_priv
->fbdev
= NULL
;
663 static void psbfb_output_poll_changed(struct drm_device
*dev
)
665 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
666 struct psb_fbdev
*fbdev
= (struct psb_fbdev
*)dev_priv
->fbdev
;
667 drm_fb_helper_hotplug_event(&fbdev
->psb_fb_helper
);
671 * psb_user_framebuffer_create_handle - add hamdle to a framebuffer
673 * @file_priv: our DRM file
674 * @handle: returned handle
676 * Our framebuffer object is a GTT range which also contains a GEM
677 * object. We need to turn it into a handle for userspace. GEM will do
680 static int psb_user_framebuffer_create_handle(struct drm_framebuffer
*fb
,
681 struct drm_file
*file_priv
,
682 unsigned int *handle
)
684 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
685 struct gtt_range
*r
= psbfb
->gtt
;
688 return drm_gem_handle_create(file_priv
, &r
->gem
, handle
);
692 * psb_user_framebuffer_destroy - destruct user created fb
695 * User framebuffers are backed by GEM objects so all we have to do is
696 * clean up a bit and drop the reference, GEM will handle the fallout
698 static void psb_user_framebuffer_destroy(struct drm_framebuffer
*fb
)
700 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
701 struct gtt_range
*r
= psbfb
->gtt
;
702 struct drm_device
*dev
= fb
->dev
;
703 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
704 struct psb_fbdev
*fbdev
= dev_priv
->fbdev
;
705 struct drm_crtc
*crtc
;
708 /* Should never get stolen memory for a user fb */
711 /* Check if we are erroneously live */
712 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, head
)
718 * Now force a sane response before we permit the DRM crc layer to
719 * do stupid things like blank the display. Instead we reset this
720 * framebuffer as if the user had forced a reset. We must do this
721 * before the cleanup so that the DRM layer doesn't get a chance
722 * to stick its oar in where it isn't wanted.
724 drm_fb_helper_restore_fbdev_mode(&fbdev
->psb_fb_helper
);
726 /* Let DRM do its clean up */
727 drm_framebuffer_cleanup(fb
);
728 /* We are no longer using the resource in GEM */
729 drm_gem_object_unreference_unlocked(&r
->gem
);
733 static const struct drm_mode_config_funcs psb_mode_funcs
= {
734 .fb_create
= psb_user_framebuffer_create
,
735 .output_poll_changed
= psbfb_output_poll_changed
,
738 static int psb_create_backlight_property(struct drm_device
*dev
)
740 struct drm_psb_private
*dev_priv
741 = (struct drm_psb_private
*) dev
->dev_private
;
742 struct drm_property
*backlight
;
744 if (dev_priv
->backlight_property
)
747 backlight
= drm_property_create(dev
,
751 backlight
->values
[0] = 0;
752 backlight
->values
[1] = 100;
754 dev_priv
->backlight_property
= backlight
;
759 static void psb_setup_outputs(struct drm_device
*dev
)
761 struct drm_psb_private
*dev_priv
=
762 (struct drm_psb_private
*) dev
->dev_private
;
763 struct drm_connector
*connector
;
765 drm_mode_create_scaling_mode_property(dev
);
767 psb_create_backlight_property(dev
);
770 if (dev_priv
->iLVDS_enable
)
771 mrst_lvds_init(dev
, &dev_priv
->mode_dev
);
773 dev_err(dev
->dev
, "DSI is not supported\n");
775 psb_intel_lvds_init(dev
, &dev_priv
->mode_dev
);
776 psb_intel_sdvo_init(dev
, SDVOB
);
779 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
,
781 struct psb_intel_output
*psb_intel_output
=
782 to_psb_intel_output(connector
);
783 struct drm_encoder
*encoder
= &psb_intel_output
->enc
;
784 int crtc_mask
= 0, clone_mask
= 0;
787 switch (psb_intel_output
->type
) {
788 case INTEL_OUTPUT_SDVO
:
789 crtc_mask
= ((1 << 0) | (1 << 1));
790 clone_mask
= (1 << INTEL_OUTPUT_SDVO
);
792 case INTEL_OUTPUT_LVDS
:
794 crtc_mask
= (1 << 0);
796 crtc_mask
= (1 << 1);
797 clone_mask
= (1 << INTEL_OUTPUT_LVDS
);
799 case INTEL_OUTPUT_MIPI
:
800 crtc_mask
= (1 << 0);
801 clone_mask
= (1 << INTEL_OUTPUT_MIPI
);
803 case INTEL_OUTPUT_MIPI2
:
804 crtc_mask
= (1 << 2);
805 clone_mask
= (1 << INTEL_OUTPUT_MIPI2
);
807 case INTEL_OUTPUT_HDMI
:
808 crtc_mask
= (1 << 1);
809 clone_mask
= (1 << INTEL_OUTPUT_HDMI
);
813 encoder
->possible_crtcs
= crtc_mask
;
814 encoder
->possible_clones
=
815 psb_intel_connector_clones(dev
, clone_mask
);
820 void psb_modeset_init(struct drm_device
*dev
)
822 struct drm_psb_private
*dev_priv
=
823 (struct drm_psb_private
*) dev
->dev_private
;
824 struct psb_intel_mode_device
*mode_dev
= &dev_priv
->mode_dev
;
827 drm_mode_config_init(dev
);
829 dev
->mode_config
.min_width
= 0;
830 dev
->mode_config
.min_height
= 0;
832 dev
->mode_config
.funcs
= (void *) &psb_mode_funcs
;
834 /* set memory base */
835 /* MRST and PSB should use BAR 2*/
836 pci_read_config_dword(dev
->pdev
, PSB_BSM
, (u32
*)
837 &(dev
->mode_config
.fb_base
));
839 /* num pipes is 2 for PSB but 1 for Mrst */
840 for (i
= 0; i
< dev_priv
->num_pipe
; i
++)
841 psb_intel_crtc_init(dev
, i
, mode_dev
);
843 dev
->mode_config
.max_width
= 2048;
844 dev
->mode_config
.max_height
= 2048;
846 psb_setup_outputs(dev
);
849 /* drm_initial_config(dev); */
852 void psb_modeset_cleanup(struct drm_device
*dev
)
854 mutex_lock(&dev
->struct_mutex
);
856 drm_kms_helper_poll_fini(dev
);
859 drm_mode_config_cleanup(dev
);
861 mutex_unlock(&dev
->struct_mutex
);