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
;
190 /* FIXME: assumes fb at stolen base which may not be true */
191 unsigned long phys_addr
= (unsigned long)dev_priv
->stolen_base
;
193 page_num
= (vma
->vm_end
- vma
->vm_start
) >> PAGE_SHIFT
;
195 address
= (unsigned long)vmf
->virtual_address
;
197 vma
->vm_page_prot
= pgprot_noncached(vma
->vm_page_prot
);
199 for (i
= 0; i
< page_num
; i
++) {
200 pfn
= (phys_addr
>> PAGE_SHIFT
); /* phys_to_pfn(phys_addr); */
202 ret
= vm_insert_mixed(vma
, address
, pfn
);
203 if (unlikely((ret
== -EBUSY
) || (ret
!= 0 && i
> 0)))
205 else if (unlikely(ret
!= 0)) {
206 ret
= (ret
== -ENOMEM
) ? VM_FAULT_OOM
: VM_FAULT_SIGBUS
;
210 address
+= PAGE_SIZE
;
211 phys_addr
+= PAGE_SIZE
;
214 return VM_FAULT_NOPAGE
;
217 static void psbfb_vm_open(struct vm_area_struct
*vma
)
221 static void psbfb_vm_close(struct vm_area_struct
*vma
)
225 static struct vm_operations_struct psbfb_vm_ops
= {
226 .fault
= psbfb_vm_fault
,
227 .open
= psbfb_vm_open
,
228 .close
= psbfb_vm_close
231 static int psbfb_mmap(struct fb_info
*info
, struct vm_area_struct
*vma
)
233 struct psb_fbdev
*fbdev
= info
->par
;
234 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
235 char *fb_screen_base
= NULL
;
237 if (vma
->vm_pgoff
!= 0)
239 if (vma
->vm_pgoff
> (~0UL >> PAGE_SHIFT
))
242 if (!psbfb
->addr_space
)
243 psbfb
->addr_space
= vma
->vm_file
->f_mapping
;
245 fb_screen_base
= (char *)info
->screen_base
;
247 /* If this is a GEM object then info->screen_base is the virtual
248 kernel remapping of the object. FIXME: Review if this is
249 suitable for our mmap work */
250 vma
->vm_ops
= &psbfb_vm_ops
;
251 vma
->vm_private_data
= (void *)psbfb
;
252 vma
->vm_flags
|= VM_RESERVED
| VM_IO
|
253 VM_MIXEDMAP
| VM_DONTEXPAND
;
257 static int psbfb_ioctl(struct fb_info
*info
, unsigned int cmd
, unsigned long arg
)
259 struct psb_fbdev
*fbdev
= info
->par
;
260 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
261 struct drm_device
*dev
= psbfb
->base
.dev
;
262 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
263 u32 __user
*p
= (u32 __user
*)arg
;
268 if (!capable(CAP_SYS_RAWIO
))
274 if (copy_from_user(buf
, p
+ 1, l
* sizeof(u32
)))
276 psbfb_2d_submit(dev_priv
, buf
, l
);
283 static struct fb_ops psbfb_ops
= {
284 .owner
= THIS_MODULE
,
285 .fb_check_var
= drm_fb_helper_check_var
,
286 .fb_set_par
= drm_fb_helper_set_par
,
287 .fb_blank
= drm_fb_helper_blank
,
288 .fb_setcolreg
= psbfb_setcolreg
,
289 .fb_fillrect
= psbfb_fillrect
,
290 .fb_copyarea
= psbfb_copyarea
,
291 .fb_imageblit
= psbfb_imageblit
,
292 .fb_mmap
= psbfb_mmap
,
293 .fb_sync
= psbfb_sync
,
294 .fb_ioctl
= psbfb_ioctl
,
298 * psb_framebuffer_init - initialize a framebuffer
299 * @dev: our DRM device
300 * @fb: framebuffer to set up
301 * @mode_cmd: mode description
302 * @gt: backing object
304 * Configure and fill in the boilerplate for our frame buffer. Return
305 * 0 on success or an error code if we fail.
307 static int psb_framebuffer_init(struct drm_device
*dev
,
308 struct psb_framebuffer
*fb
,
309 struct drm_mode_fb_cmd
*mode_cmd
,
310 struct gtt_range
*gt
)
314 if (mode_cmd
->pitch
& 63)
316 switch (mode_cmd
->bpp
) {
325 ret
= drm_framebuffer_init(dev
, &fb
->base
, &psb_fb_funcs
);
327 dev_err(dev
->dev
, "framebuffer init failed: %d\n", ret
);
330 drm_helper_mode_fill_fb_struct(&fb
->base
, mode_cmd
);
336 * psb_framebuffer_create - create a framebuffer backed by gt
337 * @dev: our DRM device
338 * @mode_cmd: the description of the requested mode
339 * @gt: the backing object
341 * Create a framebuffer object backed by the gt, and fill in the
342 * boilerplate required
344 * TODO: review object references
346 static struct drm_framebuffer
*psb_framebuffer_create
347 (struct drm_device
*dev
,
348 struct drm_mode_fb_cmd
*mode_cmd
,
349 struct gtt_range
*gt
)
351 struct psb_framebuffer
*fb
;
354 fb
= kzalloc(sizeof(*fb
), GFP_KERNEL
);
356 return ERR_PTR(-ENOMEM
);
358 ret
= psb_framebuffer_init(dev
, fb
, mode_cmd
, gt
);
367 * psbfb_alloc - allocate frame buffer memory
368 * @dev: the DRM device
369 * @aligned_size: space needed
371 * Allocate the frame buffer. In the usual case we get a GTT range that
372 * is stolen memory backed and life is simple. If there isn't sufficient
373 * stolen memory or the system has no stolen memory we allocate a range
374 * and back it with a GEM object.
376 * In this case the GEM object has no handle.
378 * FIXME: console speed up - allocate twice the space if room and use
379 * hardware scrolling for acceleration.
381 static struct gtt_range
*psbfb_alloc(struct drm_device
*dev
, int aligned_size
)
383 struct gtt_range
*backing
;
384 /* Begin by trying to use stolen memory backing */
385 backing
= psb_gtt_alloc_range(dev
, aligned_size
, "fb", 1);
387 if (drm_gem_private_object_init(dev
, &backing
->gem
, aligned_size
) == 0)
389 psb_gtt_free_range(dev
, backing
);
391 /* Next try using GEM host memory */
392 backing
= psb_gtt_alloc_range(dev
, aligned_size
, "fb(gem)", 0);
396 /* Now back it with an object */
397 if (drm_gem_object_init(dev
, &backing
->gem
, aligned_size
) != 0) {
398 psb_gtt_free_range(dev
, backing
);
405 * psbfb_create - create a framebuffer
406 * @fbdev: the framebuffer device
407 * @sizes: specification of the layout
409 * Create a framebuffer to the specifications provided
411 static int psbfb_create(struct psb_fbdev
*fbdev
,
412 struct drm_fb_helper_surface_size
*sizes
)
414 struct drm_device
*dev
= fbdev
->psb_fb_helper
.dev
;
415 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
416 struct fb_info
*info
;
417 struct drm_framebuffer
*fb
;
418 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
419 struct drm_mode_fb_cmd mode_cmd
;
420 struct device
*device
= &dev
->pdev
->dev
;
423 struct gtt_range
*backing
;
425 mode_cmd
.width
= sizes
->surface_width
;
426 mode_cmd
.height
= sizes
->surface_height
;
427 mode_cmd
.bpp
= sizes
->surface_bpp
;
429 /* No 24bit packed */
430 if (mode_cmd
.bpp
== 24)
433 /* HW requires pitch to be 64 byte aligned */
434 mode_cmd
.pitch
= ALIGN(mode_cmd
.width
* ((mode_cmd
.bpp
+ 7) / 8), 64);
435 mode_cmd
.depth
= sizes
->surface_depth
;
437 size
= mode_cmd
.pitch
* mode_cmd
.height
;
438 size
= ALIGN(size
, PAGE_SIZE
);
440 /* Allocate the framebuffer in the GTT with stolen page backing */
441 backing
= psbfb_alloc(dev
, size
);
445 mutex_lock(&dev
->struct_mutex
);
447 info
= framebuffer_alloc(0, device
);
454 ret
= psb_framebuffer_init(dev
, psbfb
, &mode_cmd
, backing
);
461 fbdev
->psb_fb_helper
.fb
= fb
;
462 fbdev
->psb_fb_helper
.fbdev
= info
;
464 strcpy(info
->fix
.id
, "psbfb");
466 info
->flags
= FBINFO_DEFAULT
;
467 info
->fbops
= &psbfb_ops
;
469 ret
= fb_alloc_cmap(&info
->cmap
, 256, 0);
475 info
->fix
.smem_start
= dev
->mode_config
.fb_base
;
476 info
->fix
.smem_len
= size
;
478 if (backing
->stolen
) {
479 /* Accessed stolen memory directly */
480 info
->screen_base
= (char *)dev_priv
->vram_addr
+
483 /* Pin the pages into the GTT and create a mapping to them */
484 psb_gtt_pin(backing
);
485 info
->screen_base
= vm_map_ram(backing
->pages
, backing
->npage
,
487 if (info
->screen_base
== NULL
) {
488 psb_gtt_unpin(backing
);
494 info
->screen_size
= size
;
495 /* memset(info->screen_base, 0, size); */
497 if (dev_priv
->pg
->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
->pg
->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
;
554 /* Find the GEM object and thus the gtt range object that is
555 to back this space */
556 obj
= drm_gem_object_lookup(dev
, filp
, cmd
->handle
);
558 return ERR_PTR(-ENOENT
);
560 /* Let the core code do all the work */
561 r
= container_of(obj
, struct gtt_range
, gem
);
562 return psb_framebuffer_create(dev
, cmd
, r
);
565 static void psbfb_gamma_set(struct drm_crtc
*crtc
, u16 red
, u16 green
,
570 static void psbfb_gamma_get(struct drm_crtc
*crtc
, u16
*red
,
571 u16
*green
, u16
*blue
, int regno
)
575 static int psbfb_probe(struct drm_fb_helper
*helper
,
576 struct drm_fb_helper_surface_size
*sizes
)
578 struct psb_fbdev
*psb_fbdev
= (struct psb_fbdev
*)helper
;
583 ret
= psbfb_create(psb_fbdev
, sizes
);
591 struct drm_fb_helper_funcs psb_fb_helper_funcs
= {
592 .gamma_set
= psbfb_gamma_set
,
593 .gamma_get
= psbfb_gamma_get
,
594 .fb_probe
= psbfb_probe
,
597 int psb_fbdev_destroy(struct drm_device
*dev
, struct psb_fbdev
*fbdev
)
599 struct fb_info
*info
;
600 struct psb_framebuffer
*psbfb
= &fbdev
->pfb
;
602 if (fbdev
->psb_fb_helper
.fbdev
) {
603 info
= fbdev
->psb_fb_helper
.fbdev
;
605 /* If this is our base framebuffer then kill any virtual map
606 for the framebuffer layer and unpin it */
608 vm_unmap_ram(info
->screen_base
, psbfb
->gtt
->npage
);
609 psb_gtt_unpin(psbfb
->gtt
);
611 unregister_framebuffer(info
);
613 fb_dealloc_cmap(&info
->cmap
);
614 framebuffer_release(info
);
616 drm_fb_helper_fini(&fbdev
->psb_fb_helper
);
617 drm_framebuffer_cleanup(&psbfb
->base
);
620 /* FIXME: this is a bit more inside knowledge than I'd like
621 but I don't see how to make a fake GEM object of the
622 stolen space nicely */
623 if (psbfb
->gtt
->stolen
)
624 psb_gtt_free_range(dev
, psbfb
->gtt
);
626 drm_gem_object_unreference(&psbfb
->gtt
->gem
);
631 int psb_fbdev_init(struct drm_device
*dev
)
633 struct psb_fbdev
*fbdev
;
634 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
637 fbdev
= kzalloc(sizeof(struct psb_fbdev
), GFP_KERNEL
);
639 dev_err(dev
->dev
, "no memory\n");
643 dev_priv
->fbdev
= fbdev
;
644 fbdev
->psb_fb_helper
.funcs
= &psb_fb_helper_funcs
;
648 drm_fb_helper_init(dev
, &fbdev
->psb_fb_helper
, num_crtc
,
651 drm_fb_helper_single_add_all_connectors(&fbdev
->psb_fb_helper
);
652 drm_fb_helper_initial_config(&fbdev
->psb_fb_helper
, 32);
656 void psb_fbdev_fini(struct drm_device
*dev
)
658 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
660 if (!dev_priv
->fbdev
)
663 psb_fbdev_destroy(dev
, dev_priv
->fbdev
);
664 kfree(dev_priv
->fbdev
);
665 dev_priv
->fbdev
= NULL
;
668 static void psbfb_output_poll_changed(struct drm_device
*dev
)
670 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
671 struct psb_fbdev
*fbdev
= (struct psb_fbdev
*)dev_priv
->fbdev
;
672 drm_fb_helper_hotplug_event(&fbdev
->psb_fb_helper
);
676 * psb_user_framebuffer_create_handle - add hamdle to a framebuffer
678 * @file_priv: our DRM file
679 * @handle: returned handle
681 * Our framebuffer object is a GTT range which also contains a GEM
682 * object. We need to turn it into a handle for userspace. GEM will do
685 static int psb_user_framebuffer_create_handle(struct drm_framebuffer
*fb
,
686 struct drm_file
*file_priv
,
687 unsigned int *handle
)
689 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
690 struct gtt_range
*r
= psbfb
->gtt
;
691 return drm_gem_handle_create(file_priv
, &r
->gem
, handle
);
695 * psb_user_framebuffer_destroy - destruct user created fb
698 * User framebuffers are backed by GEM objects so all we have to do is
699 * clean up a bit and drop the reference, GEM will handle the fallout
701 static void psb_user_framebuffer_destroy(struct drm_framebuffer
*fb
)
703 struct psb_framebuffer
*psbfb
= to_psb_fb(fb
);
704 struct gtt_range
*r
= psbfb
->gtt
;
705 struct drm_device
*dev
= fb
->dev
;
706 struct drm_psb_private
*dev_priv
= dev
->dev_private
;
707 struct psb_fbdev
*fbdev
= dev_priv
->fbdev
;
708 struct drm_crtc
*crtc
;
711 /* Should never get stolen memory for a user fb */
714 /* Check if we are erroneously live */
715 list_for_each_entry(crtc
, &dev
->mode_config
.crtc_list
, head
)
721 * Now force a sane response before we permit the DRM crc layer to
722 * do stupid things like blank the display. Instead we reset this
723 * framebuffer as if the user had forced a reset. We must do this
724 * before the cleanup so that the DRM layer doesn't get a chance
725 * to stick its oar in where it isn't wanted.
727 drm_fb_helper_restore_fbdev_mode(&fbdev
->psb_fb_helper
);
729 /* Let DRM do its clean up */
730 drm_framebuffer_cleanup(fb
);
731 /* We are no longer using the resource in GEM */
732 drm_gem_object_unreference_unlocked(&r
->gem
);
736 static const struct drm_mode_config_funcs psb_mode_funcs
= {
737 .fb_create
= psb_user_framebuffer_create
,
738 .output_poll_changed
= psbfb_output_poll_changed
,
741 static int psb_create_backlight_property(struct drm_device
*dev
)
743 struct drm_psb_private
*dev_priv
744 = (struct drm_psb_private
*) dev
->dev_private
;
745 struct drm_property
*backlight
;
747 if (dev_priv
->backlight_property
)
750 backlight
= drm_property_create(dev
,
754 backlight
->values
[0] = 0;
755 backlight
->values
[1] = 100;
757 dev_priv
->backlight_property
= backlight
;
762 static void psb_setup_outputs(struct drm_device
*dev
)
764 struct drm_psb_private
*dev_priv
=
765 (struct drm_psb_private
*) dev
->dev_private
;
766 struct drm_connector
*connector
;
768 drm_mode_create_scaling_mode_property(dev
);
770 psb_create_backlight_property(dev
);
773 if (dev_priv
->iLVDS_enable
)
774 mrst_lvds_init(dev
, &dev_priv
->mode_dev
);
776 dev_err(dev
->dev
, "DSI is not supported\n");
778 psb_intel_lvds_init(dev
, &dev_priv
->mode_dev
);
779 psb_intel_sdvo_init(dev
, SDVOB
);
782 list_for_each_entry(connector
, &dev
->mode_config
.connector_list
,
784 struct psb_intel_output
*psb_intel_output
=
785 to_psb_intel_output(connector
);
786 struct drm_encoder
*encoder
= &psb_intel_output
->enc
;
787 int crtc_mask
= 0, clone_mask
= 0;
790 switch (psb_intel_output
->type
) {
791 case INTEL_OUTPUT_SDVO
:
792 crtc_mask
= ((1 << 0) | (1 << 1));
793 clone_mask
= (1 << INTEL_OUTPUT_SDVO
);
795 case INTEL_OUTPUT_LVDS
:
797 crtc_mask
= (1 << 0);
799 crtc_mask
= (1 << 1);
800 clone_mask
= (1 << INTEL_OUTPUT_LVDS
);
802 case INTEL_OUTPUT_MIPI
:
803 crtc_mask
= (1 << 0);
804 clone_mask
= (1 << INTEL_OUTPUT_MIPI
);
806 case INTEL_OUTPUT_MIPI2
:
807 crtc_mask
= (1 << 2);
808 clone_mask
= (1 << INTEL_OUTPUT_MIPI2
);
810 case INTEL_OUTPUT_HDMI
:
811 crtc_mask
= (1 << 1);
812 clone_mask
= (1 << INTEL_OUTPUT_HDMI
);
816 encoder
->possible_crtcs
= crtc_mask
;
817 encoder
->possible_clones
=
818 psb_intel_connector_clones(dev
, clone_mask
);
823 void psb_modeset_init(struct drm_device
*dev
)
825 struct drm_psb_private
*dev_priv
=
826 (struct drm_psb_private
*) dev
->dev_private
;
827 struct psb_intel_mode_device
*mode_dev
= &dev_priv
->mode_dev
;
830 drm_mode_config_init(dev
);
832 dev
->mode_config
.min_width
= 0;
833 dev
->mode_config
.min_height
= 0;
835 dev
->mode_config
.funcs
= (void *) &psb_mode_funcs
;
837 /* set memory base */
838 /* MRST and PSB should use BAR 2*/
839 pci_read_config_dword(dev
->pdev
, PSB_BSM
, (u32
*)
840 &(dev
->mode_config
.fb_base
));
842 /* num pipes is 2 for PSB but 1 for Mrst */
843 for (i
= 0; i
< dev_priv
->num_pipe
; i
++)
844 psb_intel_crtc_init(dev
, i
, mode_dev
);
846 dev
->mode_config
.max_width
= 2048;
847 dev
->mode_config
.max_height
= 2048;
849 psb_setup_outputs(dev
);
852 /* drm_initial_config(dev); */
855 void psb_modeset_cleanup(struct drm_device
*dev
)
857 mutex_lock(&dev
->struct_mutex
);
859 drm_kms_helper_poll_fini(dev
);
862 drm_mode_config_cleanup(dev
);
864 mutex_unlock(&dev
->struct_mutex
);