14d8d096eSAlan Cox /************************************************************************** 24d8d096eSAlan Cox * Copyright (c) 2007-2011, Intel Corporation. 34d8d096eSAlan Cox * All Rights Reserved. 44d8d096eSAlan Cox * 54d8d096eSAlan Cox * This program is free software; you can redistribute it and/or modify it 64d8d096eSAlan Cox * under the terms and conditions of the GNU General Public License, 74d8d096eSAlan Cox * version 2, as published by the Free Software Foundation. 84d8d096eSAlan Cox * 94d8d096eSAlan Cox * This program is distributed in the hope it will be useful, but WITHOUT 104d8d096eSAlan Cox * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 114d8d096eSAlan Cox * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 124d8d096eSAlan Cox * more details. 134d8d096eSAlan Cox * 144d8d096eSAlan Cox * You should have received a copy of the GNU General Public License along with 154d8d096eSAlan Cox * this program; if not, write to the Free Software Foundation, Inc., 164d8d096eSAlan Cox * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 174d8d096eSAlan Cox * 184d8d096eSAlan Cox **************************************************************************/ 194d8d096eSAlan Cox 204d8d096eSAlan Cox #include <linux/module.h> 214d8d096eSAlan Cox #include <linux/kernel.h> 224d8d096eSAlan Cox #include <linux/errno.h> 234d8d096eSAlan Cox #include <linux/string.h> 2401c8f1c4SDan Williams #include <linux/pfn_t.h> 254d8d096eSAlan Cox #include <linux/mm.h> 264d8d096eSAlan Cox #include <linux/tty.h> 274d8d096eSAlan Cox #include <linux/slab.h> 284d8d096eSAlan Cox #include <linux/delay.h> 294d8d096eSAlan Cox #include <linux/init.h> 304d8d096eSAlan Cox #include <linux/console.h> 314d8d096eSAlan Cox 324d8d096eSAlan Cox #include <drm/drmP.h> 334d8d096eSAlan Cox #include <drm/drm.h> 344d8d096eSAlan Cox #include <drm/drm_crtc.h> 35a9a644acSDave Airlie #include <drm/drm_fb_helper.h> 364d8d096eSAlan Cox 374d8d096eSAlan Cox #include "psb_drv.h" 384d8d096eSAlan Cox #include "psb_intel_reg.h" 394d8d096eSAlan Cox #include "psb_intel_drv.h" 404d8d096eSAlan Cox #include "framebuffer.h" 41a6ba582dSAlan Cox #include "gtt.h" 424d8d096eSAlan Cox 434d8d096eSAlan Cox static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb); 444d8d096eSAlan Cox static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb, 454d8d096eSAlan Cox struct drm_file *file_priv, 464d8d096eSAlan Cox unsigned int *handle); 474d8d096eSAlan Cox 484d8d096eSAlan Cox static const struct drm_framebuffer_funcs psb_fb_funcs = { 494d8d096eSAlan Cox .destroy = psb_user_framebuffer_destroy, 504d8d096eSAlan Cox .create_handle = psb_user_framebuffer_create_handle, 514d8d096eSAlan Cox }; 524d8d096eSAlan Cox 534d8d096eSAlan Cox #define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) 544d8d096eSAlan Cox 554d8d096eSAlan Cox static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green, 564d8d096eSAlan Cox unsigned blue, unsigned transp, 574d8d096eSAlan Cox struct fb_info *info) 584d8d096eSAlan Cox { 594d8d096eSAlan Cox struct psb_fbdev *fbdev = info->par; 604d8d096eSAlan Cox struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb; 614d8d096eSAlan Cox uint32_t v; 624d8d096eSAlan Cox 634d8d096eSAlan Cox if (!fb) 644d8d096eSAlan Cox return -ENOMEM; 654d8d096eSAlan Cox 664d8d096eSAlan Cox if (regno > 255) 674d8d096eSAlan Cox return 1; 684d8d096eSAlan Cox 694d8d096eSAlan Cox red = CMAP_TOHW(red, info->var.red.length); 704d8d096eSAlan Cox blue = CMAP_TOHW(blue, info->var.blue.length); 714d8d096eSAlan Cox green = CMAP_TOHW(green, info->var.green.length); 724d8d096eSAlan Cox transp = CMAP_TOHW(transp, info->var.transp.length); 734d8d096eSAlan Cox 744d8d096eSAlan Cox v = (red << info->var.red.offset) | 754d8d096eSAlan Cox (green << info->var.green.offset) | 764d8d096eSAlan Cox (blue << info->var.blue.offset) | 774d8d096eSAlan Cox (transp << info->var.transp.offset); 784d8d096eSAlan Cox 794d8d096eSAlan Cox if (regno < 16) { 80272725c7SVille Syrjälä switch (fb->format->cpp[0] * 8) { 814d8d096eSAlan Cox case 16: 824d8d096eSAlan Cox ((uint32_t *) info->pseudo_palette)[regno] = v; 834d8d096eSAlan Cox break; 844d8d096eSAlan Cox case 24: 854d8d096eSAlan Cox case 32: 864d8d096eSAlan Cox ((uint32_t *) info->pseudo_palette)[regno] = v; 874d8d096eSAlan Cox break; 884d8d096eSAlan Cox } 894d8d096eSAlan Cox } 904d8d096eSAlan Cox 914d8d096eSAlan Cox return 0; 924d8d096eSAlan Cox } 934d8d096eSAlan Cox 94a6ba582dSAlan Cox static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info) 95a6ba582dSAlan Cox { 96a6ba582dSAlan Cox struct psb_fbdev *fbdev = info->par; 97a6ba582dSAlan Cox struct psb_framebuffer *psbfb = &fbdev->pfb; 98a6ba582dSAlan Cox struct drm_device *dev = psbfb->base.dev; 99a6ba582dSAlan Cox 100a6ba582dSAlan Cox /* 101a6ba582dSAlan Cox * We have to poke our nose in here. The core fb code assumes 102a6ba582dSAlan Cox * panning is part of the hardware that can be invoked before 103a6ba582dSAlan Cox * the actual fb is mapped. In our case that isn't quite true. 104a6ba582dSAlan Cox */ 105a6ba582dSAlan Cox if (psbfb->gtt->npage) { 106a6ba582dSAlan Cox /* GTT roll shifts in 4K pages, we need to shift the right 107a6ba582dSAlan Cox number of pages */ 108a6ba582dSAlan Cox int pages = info->fix.line_length >> 12; 109a6ba582dSAlan Cox psb_gtt_roll(dev, psbfb->gtt, var->yoffset * pages); 110a6ba582dSAlan Cox } 111a6ba582dSAlan Cox return 0; 112a6ba582dSAlan Cox } 1134d8d096eSAlan Cox 1144d8d096eSAlan Cox static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 1154d8d096eSAlan Cox { 1164d8d096eSAlan Cox struct psb_framebuffer *psbfb = vma->vm_private_data; 1174d8d096eSAlan Cox struct drm_device *dev = psbfb->base.dev; 1184d8d096eSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 1194d8d096eSAlan Cox int page_num; 1204d8d096eSAlan Cox int i; 1214d8d096eSAlan Cox unsigned long address; 1224d8d096eSAlan Cox int ret; 1234d8d096eSAlan Cox unsigned long pfn; 12461bb3feaSPatrik Jakobsson unsigned long phys_addr = (unsigned long)dev_priv->stolen_base + 12561bb3feaSPatrik Jakobsson psbfb->gtt->offset; 1264d8d096eSAlan Cox 127024b6a63SShyam Saini page_num = vma_pages(vma); 1281278f7deSYoichi Yuasa address = (unsigned long)vmf->virtual_address - (vmf->pgoff << PAGE_SHIFT); 1294d8d096eSAlan Cox 1304d8d096eSAlan Cox vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 1314d8d096eSAlan Cox 1324d8d096eSAlan Cox for (i = 0; i < page_num; i++) { 1334d8d096eSAlan Cox pfn = (phys_addr >> PAGE_SHIFT); 1344d8d096eSAlan Cox 13501c8f1c4SDan Williams ret = vm_insert_mixed(vma, address, 13601c8f1c4SDan Williams __pfn_to_pfn_t(pfn, PFN_DEV)); 1374d8d096eSAlan Cox if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0))) 1384d8d096eSAlan Cox break; 1394d8d096eSAlan Cox else if (unlikely(ret != 0)) { 1404d8d096eSAlan Cox ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS; 1414d8d096eSAlan Cox return ret; 1424d8d096eSAlan Cox } 1434d8d096eSAlan Cox address += PAGE_SIZE; 1444d8d096eSAlan Cox phys_addr += PAGE_SIZE; 1454d8d096eSAlan Cox } 1464d8d096eSAlan Cox return VM_FAULT_NOPAGE; 1474d8d096eSAlan Cox } 1484d8d096eSAlan Cox 1494d8d096eSAlan Cox static void psbfb_vm_open(struct vm_area_struct *vma) 1504d8d096eSAlan Cox { 1514d8d096eSAlan Cox } 1524d8d096eSAlan Cox 1534d8d096eSAlan Cox static void psbfb_vm_close(struct vm_area_struct *vma) 1544d8d096eSAlan Cox { 1554d8d096eSAlan Cox } 1564d8d096eSAlan Cox 15778b68556SLaurent Pinchart static const struct vm_operations_struct psbfb_vm_ops = { 1584d8d096eSAlan Cox .fault = psbfb_vm_fault, 1594d8d096eSAlan Cox .open = psbfb_vm_open, 1604d8d096eSAlan Cox .close = psbfb_vm_close 1614d8d096eSAlan Cox }; 1624d8d096eSAlan Cox 1634d8d096eSAlan Cox static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma) 1644d8d096eSAlan Cox { 1654d8d096eSAlan Cox struct psb_fbdev *fbdev = info->par; 1664d8d096eSAlan Cox struct psb_framebuffer *psbfb = &fbdev->pfb; 1674d8d096eSAlan Cox 1684d8d096eSAlan Cox if (vma->vm_pgoff != 0) 1694d8d096eSAlan Cox return -EINVAL; 1704d8d096eSAlan Cox if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 1714d8d096eSAlan Cox return -EINVAL; 1724d8d096eSAlan Cox 1734d8d096eSAlan Cox if (!psbfb->addr_space) 1744d8d096eSAlan Cox psbfb->addr_space = vma->vm_file->f_mapping; 1754d8d096eSAlan Cox /* 1764d8d096eSAlan Cox * If this is a GEM object then info->screen_base is the virtual 1774d8d096eSAlan Cox * kernel remapping of the object. FIXME: Review if this is 1784d8d096eSAlan Cox * suitable for our mmap work 1794d8d096eSAlan Cox */ 1804d8d096eSAlan Cox vma->vm_ops = &psbfb_vm_ops; 1814d8d096eSAlan Cox vma->vm_private_data = (void *)psbfb; 182314e51b9SKonstantin Khlebnikov vma->vm_flags |= VM_IO | VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP; 1834d8d096eSAlan Cox return 0; 1844d8d096eSAlan Cox } 1854d8d096eSAlan Cox 1864d8d096eSAlan Cox static struct fb_ops psbfb_ops = { 1874d8d096eSAlan Cox .owner = THIS_MODULE, 1883da6c2f3SStefan Christ DRM_FB_HELPER_DEFAULT_OPS, 1894d8d096eSAlan Cox .fb_setcolreg = psbfb_setcolreg, 190546187c8SArchit Taneja .fb_fillrect = drm_fb_helper_cfb_fillrect, 1914d8d096eSAlan Cox .fb_copyarea = psbfb_copyarea, 192546187c8SArchit Taneja .fb_imageblit = drm_fb_helper_cfb_imageblit, 1934d8d096eSAlan Cox .fb_mmap = psbfb_mmap, 1944d8d096eSAlan Cox .fb_sync = psbfb_sync, 1954d8d096eSAlan Cox }; 1964d8d096eSAlan Cox 197a6ba582dSAlan Cox static struct fb_ops psbfb_roll_ops = { 198a6ba582dSAlan Cox .owner = THIS_MODULE, 1993da6c2f3SStefan Christ DRM_FB_HELPER_DEFAULT_OPS, 200a6ba582dSAlan Cox .fb_setcolreg = psbfb_setcolreg, 201546187c8SArchit Taneja .fb_fillrect = drm_fb_helper_cfb_fillrect, 202546187c8SArchit Taneja .fb_copyarea = drm_fb_helper_cfb_copyarea, 203546187c8SArchit Taneja .fb_imageblit = drm_fb_helper_cfb_imageblit, 204a6ba582dSAlan Cox .fb_pan_display = psbfb_pan, 205a6ba582dSAlan Cox .fb_mmap = psbfb_mmap, 206a6ba582dSAlan Cox }; 207a6ba582dSAlan Cox 2084d8d096eSAlan Cox static struct fb_ops psbfb_unaccel_ops = { 2094d8d096eSAlan Cox .owner = THIS_MODULE, 2103da6c2f3SStefan Christ DRM_FB_HELPER_DEFAULT_OPS, 2114d8d096eSAlan Cox .fb_setcolreg = psbfb_setcolreg, 212546187c8SArchit Taneja .fb_fillrect = drm_fb_helper_cfb_fillrect, 213546187c8SArchit Taneja .fb_copyarea = drm_fb_helper_cfb_copyarea, 214546187c8SArchit Taneja .fb_imageblit = drm_fb_helper_cfb_imageblit, 2154d8d096eSAlan Cox .fb_mmap = psbfb_mmap, 2164d8d096eSAlan Cox }; 2174d8d096eSAlan Cox 2184d8d096eSAlan Cox /** 2194d8d096eSAlan Cox * psb_framebuffer_init - initialize a framebuffer 2204d8d096eSAlan Cox * @dev: our DRM device 2214d8d096eSAlan Cox * @fb: framebuffer to set up 2224d8d096eSAlan Cox * @mode_cmd: mode description 2234d8d096eSAlan Cox * @gt: backing object 2244d8d096eSAlan Cox * 2254d8d096eSAlan Cox * Configure and fill in the boilerplate for our frame buffer. Return 2264d8d096eSAlan Cox * 0 on success or an error code if we fail. 2274d8d096eSAlan Cox */ 2284d8d096eSAlan Cox static int psb_framebuffer_init(struct drm_device *dev, 2294d8d096eSAlan Cox struct psb_framebuffer *fb, 2301eb83451SVille Syrjälä const struct drm_mode_fb_cmd2 *mode_cmd, 2314d8d096eSAlan Cox struct gtt_range *gt) 2324d8d096eSAlan Cox { 233e0f9a4abSLaurent Pinchart const struct drm_format_info *info; 2344d8d096eSAlan Cox int ret; 2354d8d096eSAlan Cox 236e0f9a4abSLaurent Pinchart /* 237e0f9a4abSLaurent Pinchart * Reject unknown formats, YUV formats, and formats with more than 238e0f9a4abSLaurent Pinchart * 4 bytes per pixel. 239e0f9a4abSLaurent Pinchart */ 240e0f9a4abSLaurent Pinchart info = drm_format_info(mode_cmd->pixel_format); 241e0f9a4abSLaurent Pinchart if (!info || !info->depth || info->cpp[0] > 4) 242e0f9a4abSLaurent Pinchart return -EINVAL; 243a9a644acSDave Airlie 244a9a644acSDave Airlie if (mode_cmd->pitches[0] & 63) 2454d8d096eSAlan Cox return -EINVAL; 246e0f9a4abSLaurent Pinchart 247a3f913caSVille Syrjälä drm_helper_mode_fill_fb_struct(dev, &fb->base, mode_cmd); 248c7d73f6aSDaniel Vetter fb->gtt = gt; 2494d8d096eSAlan Cox ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs); 2504d8d096eSAlan Cox if (ret) { 2514d8d096eSAlan Cox dev_err(dev->dev, "framebuffer init failed: %d\n", ret); 2524d8d096eSAlan Cox return ret; 2534d8d096eSAlan Cox } 2544d8d096eSAlan Cox return 0; 2554d8d096eSAlan Cox } 2564d8d096eSAlan Cox 2574d8d096eSAlan Cox /** 2584d8d096eSAlan Cox * psb_framebuffer_create - create a framebuffer backed by gt 2594d8d096eSAlan Cox * @dev: our DRM device 2604d8d096eSAlan Cox * @mode_cmd: the description of the requested mode 2614d8d096eSAlan Cox * @gt: the backing object 2624d8d096eSAlan Cox * 2634d8d096eSAlan Cox * Create a framebuffer object backed by the gt, and fill in the 2644d8d096eSAlan Cox * boilerplate required 2654d8d096eSAlan Cox * 2664d8d096eSAlan Cox * TODO: review object references 2674d8d096eSAlan Cox */ 2684d8d096eSAlan Cox 2694d8d096eSAlan Cox static struct drm_framebuffer *psb_framebuffer_create 2704d8d096eSAlan Cox (struct drm_device *dev, 2711eb83451SVille Syrjälä const struct drm_mode_fb_cmd2 *mode_cmd, 2724d8d096eSAlan Cox struct gtt_range *gt) 2734d8d096eSAlan Cox { 2744d8d096eSAlan Cox struct psb_framebuffer *fb; 2754d8d096eSAlan Cox int ret; 2764d8d096eSAlan Cox 2774d8d096eSAlan Cox fb = kzalloc(sizeof(*fb), GFP_KERNEL); 2784d8d096eSAlan Cox if (!fb) 2794d8d096eSAlan Cox return ERR_PTR(-ENOMEM); 2804d8d096eSAlan Cox 2814d8d096eSAlan Cox ret = psb_framebuffer_init(dev, fb, mode_cmd, gt); 2824d8d096eSAlan Cox if (ret) { 2834d8d096eSAlan Cox kfree(fb); 2844d8d096eSAlan Cox return ERR_PTR(ret); 2854d8d096eSAlan Cox } 2864d8d096eSAlan Cox return &fb->base; 2874d8d096eSAlan Cox } 2884d8d096eSAlan Cox 2894d8d096eSAlan Cox /** 2904d8d096eSAlan Cox * psbfb_alloc - allocate frame buffer memory 2914d8d096eSAlan Cox * @dev: the DRM device 2924d8d096eSAlan Cox * @aligned_size: space needed 2934d8d096eSAlan Cox * 2944d8d096eSAlan Cox * Allocate the frame buffer. In the usual case we get a GTT range that 2954d8d096eSAlan Cox * is stolen memory backed and life is simple. If there isn't sufficient 296dffc9cebSAlan Cox * we fail as we don't have the virtual mapping space to really vmap it 297dffc9cebSAlan Cox * and the kernel console code can't handle non linear framebuffers. 2984d8d096eSAlan Cox * 299dffc9cebSAlan Cox * Re-address this as and if the framebuffer layer grows this ability. 3004d8d096eSAlan Cox */ 3014d8d096eSAlan Cox static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size) 3024d8d096eSAlan Cox { 3034d8d096eSAlan Cox struct gtt_range *backing; 3044d8d096eSAlan Cox /* Begin by trying to use stolen memory backing */ 305c269c685SPatrik Jakobsson backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1, PAGE_SIZE); 3064d8d096eSAlan Cox if (backing) { 30789c8233fSDavid Herrmann drm_gem_private_object_init(dev, &backing->gem, aligned_size); 3084d8d096eSAlan Cox return backing; 3094d8d096eSAlan Cox } 3104d8d096eSAlan Cox return NULL; 3114d8d096eSAlan Cox } 3124d8d096eSAlan Cox 3134d8d096eSAlan Cox /** 3144d8d096eSAlan Cox * psbfb_create - create a framebuffer 3154d8d096eSAlan Cox * @fbdev: the framebuffer device 3164d8d096eSAlan Cox * @sizes: specification of the layout 3174d8d096eSAlan Cox * 3184d8d096eSAlan Cox * Create a framebuffer to the specifications provided 3194d8d096eSAlan Cox */ 3204d8d096eSAlan Cox static int psbfb_create(struct psb_fbdev *fbdev, 3214d8d096eSAlan Cox struct drm_fb_helper_surface_size *sizes) 3224d8d096eSAlan Cox { 3234d8d096eSAlan Cox struct drm_device *dev = fbdev->psb_fb_helper.dev; 3244d8d096eSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 3254d8d096eSAlan Cox struct fb_info *info; 3264d8d096eSAlan Cox struct drm_framebuffer *fb; 3274d8d096eSAlan Cox struct psb_framebuffer *psbfb = &fbdev->pfb; 328a9a644acSDave Airlie struct drm_mode_fb_cmd2 mode_cmd; 3294d8d096eSAlan Cox int size; 3304d8d096eSAlan Cox int ret; 3314d8d096eSAlan Cox struct gtt_range *backing; 332a9a644acSDave Airlie u32 bpp, depth; 3331b223c9eSAlan Cox int gtt_roll = 0; 3341b223c9eSAlan Cox int pitch_lines = 0; 3354d8d096eSAlan Cox 3364d8d096eSAlan Cox mode_cmd.width = sizes->surface_width; 3374d8d096eSAlan Cox mode_cmd.height = sizes->surface_height; 338a9a644acSDave Airlie bpp = sizes->surface_bpp; 3396aa1ead1SKirill A. Shutemov depth = sizes->surface_depth; 3404d8d096eSAlan Cox 3414d8d096eSAlan Cox /* No 24bit packed */ 342a9a644acSDave Airlie if (bpp == 24) 343a9a644acSDave Airlie bpp = 32; 3444d8d096eSAlan Cox 3451b223c9eSAlan Cox do { 3461b223c9eSAlan Cox /* 3471b223c9eSAlan Cox * Acceleration via the GTT requires pitch to be 3481b223c9eSAlan Cox * power of two aligned. Preferably page but less 3491b223c9eSAlan Cox * is ok with some fonts 3501b223c9eSAlan Cox */ 3511b223c9eSAlan Cox mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 4096 >> pitch_lines); 3524d8d096eSAlan Cox 353a9a644acSDave Airlie size = mode_cmd.pitches[0] * mode_cmd.height; 3544d8d096eSAlan Cox size = ALIGN(size, PAGE_SIZE); 3554d8d096eSAlan Cox 3561b223c9eSAlan Cox /* Allocate the fb in the GTT with stolen page backing */ 357a6ba582dSAlan Cox backing = psbfb_alloc(dev, size); 3581b223c9eSAlan Cox 3591b223c9eSAlan Cox if (pitch_lines) 3601b223c9eSAlan Cox pitch_lines *= 2; 3611b223c9eSAlan Cox else 3621b223c9eSAlan Cox pitch_lines = 1; 3631b223c9eSAlan Cox gtt_roll++; 3641b223c9eSAlan Cox } while (backing == NULL && pitch_lines <= 16); 3651b223c9eSAlan Cox 3661b223c9eSAlan Cox /* The final pitch we accepted if we succeeded */ 3671b223c9eSAlan Cox pitch_lines /= 2; 3681b223c9eSAlan Cox 369a6ba582dSAlan Cox if (backing == NULL) { 370a6ba582dSAlan Cox /* 371a6ba582dSAlan Cox * We couldn't get the space we wanted, fall back to the 372a6ba582dSAlan Cox * display engine requirement instead. The HW requires 373a6ba582dSAlan Cox * the pitch to be 64 byte aligned 374a6ba582dSAlan Cox */ 375a6ba582dSAlan Cox 376a6ba582dSAlan Cox gtt_roll = 0; /* Don't use GTT accelerated scrolling */ 3771b223c9eSAlan Cox pitch_lines = 64; 378a6ba582dSAlan Cox 379a6ba582dSAlan Cox mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 64); 380a6ba582dSAlan Cox 381a6ba582dSAlan Cox size = mode_cmd.pitches[0] * mode_cmd.height; 382a6ba582dSAlan Cox size = ALIGN(size, PAGE_SIZE); 383a6ba582dSAlan Cox 3844d8d096eSAlan Cox /* Allocate the framebuffer in the GTT with stolen page backing */ 3854d8d096eSAlan Cox backing = psbfb_alloc(dev, size); 3864d8d096eSAlan Cox if (backing == NULL) 3874d8d096eSAlan Cox return -ENOMEM; 388a6ba582dSAlan Cox } 3894d8d096eSAlan Cox 390bb849779SAlan Cox memset(dev_priv->vram_addr + backing->offset, 0, size); 391bb849779SAlan Cox 392546187c8SArchit Taneja info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper); 393546187c8SArchit Taneja if (IS_ERR(info)) { 394546187c8SArchit Taneja ret = PTR_ERR(info); 3954cd54d98SSudip Mukherjee goto err_free_range; 3964d8d096eSAlan Cox } 3974d8d096eSAlan Cox info->par = fbdev; 3984d8d096eSAlan Cox 399a9a644acSDave Airlie mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth); 400a9a644acSDave Airlie 4014d8d096eSAlan Cox ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing); 4024d8d096eSAlan Cox if (ret) 4034cd54d98SSudip Mukherjee goto err_release; 4044d8d096eSAlan Cox 4054d8d096eSAlan Cox fb = &psbfb->base; 4064d8d096eSAlan Cox psbfb->fbdev = info; 4074d8d096eSAlan Cox 4084d8d096eSAlan Cox fbdev->psb_fb_helper.fb = fb; 4094d8d096eSAlan Cox 410b00c600eSVille Syrjälä drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 411f9d8149aSPatrik Jakobsson strcpy(info->fix.id, "psbdrmfb"); 4124d8d096eSAlan Cox 4134d8d096eSAlan Cox info->flags = FBINFO_DEFAULT; 4141b223c9eSAlan Cox if (dev_priv->ops->accel_2d && pitch_lines > 8) /* 2D engine */ 4151b223c9eSAlan Cox info->fbops = &psbfb_ops; 4161b223c9eSAlan Cox else if (gtt_roll) { /* GTT rolling seems best */ 417a6ba582dSAlan Cox info->fbops = &psbfb_roll_ops; 418a6ba582dSAlan Cox info->flags |= FBINFO_HWACCEL_YPAN; 4191b223c9eSAlan Cox } else /* Software */ 420a6ba582dSAlan Cox info->fbops = &psbfb_unaccel_ops; 4214d8d096eSAlan Cox 4224d8d096eSAlan Cox info->fix.smem_start = dev->mode_config.fb_base; 4234d8d096eSAlan Cox info->fix.smem_len = size; 424a6ba582dSAlan Cox info->fix.ywrapstep = gtt_roll; 425a6ba582dSAlan Cox info->fix.ypanstep = 0; 4264d8d096eSAlan Cox 4274d8d096eSAlan Cox /* Accessed stolen memory directly */ 42837214ca0SKirill A. Shutemov info->screen_base = dev_priv->vram_addr + backing->offset; 4294d8d096eSAlan Cox info->screen_size = size; 4304d8d096eSAlan Cox 4314d8d096eSAlan Cox if (dev_priv->gtt.stolen_size) { 4324d8d096eSAlan Cox info->apertures->ranges[0].base = dev->mode_config.fb_base; 4334d8d096eSAlan Cox info->apertures->ranges[0].size = dev_priv->gtt.stolen_size; 4344d8d096eSAlan Cox } 4354d8d096eSAlan Cox 4364d8d096eSAlan Cox drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper, 4374d8d096eSAlan Cox sizes->fb_width, sizes->fb_height); 4384d8d096eSAlan Cox 4394d8d096eSAlan Cox info->fix.mmio_start = pci_resource_start(dev->pdev, 0); 4404d8d096eSAlan Cox info->fix.mmio_len = pci_resource_len(dev->pdev, 0); 4414d8d096eSAlan Cox 442fb2a99e1SSascha Hauer /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ 4434d8d096eSAlan Cox 44431a0685aSAlan Cox dev_dbg(dev->dev, "allocated %dx%d fb\n", 4454d8d096eSAlan Cox psbfb->base.width, psbfb->base.height); 4464d8d096eSAlan Cox 4474d8d096eSAlan Cox return 0; 4484cd54d98SSudip Mukherjee err_release: 449546187c8SArchit Taneja drm_fb_helper_release_fbi(&fbdev->psb_fb_helper); 4504cd54d98SSudip Mukherjee err_free_range: 4514d8d096eSAlan Cox psb_gtt_free_range(dev, backing); 4524d8d096eSAlan Cox return ret; 4534d8d096eSAlan Cox } 4544d8d096eSAlan Cox 4554d8d096eSAlan Cox /** 4564d8d096eSAlan Cox * psb_user_framebuffer_create - create framebuffer 4574d8d096eSAlan Cox * @dev: our DRM device 4584d8d096eSAlan Cox * @filp: client file 4594d8d096eSAlan Cox * @cmd: mode request 4604d8d096eSAlan Cox * 4614d8d096eSAlan Cox * Create a new framebuffer backed by a userspace GEM object 4624d8d096eSAlan Cox */ 4634d8d096eSAlan Cox static struct drm_framebuffer *psb_user_framebuffer_create 4644d8d096eSAlan Cox (struct drm_device *dev, struct drm_file *filp, 4651eb83451SVille Syrjälä const struct drm_mode_fb_cmd2 *cmd) 4664d8d096eSAlan Cox { 4674d8d096eSAlan Cox struct gtt_range *r; 4684d8d096eSAlan Cox struct drm_gem_object *obj; 4694d8d096eSAlan Cox 4704d8d096eSAlan Cox /* 4714d8d096eSAlan Cox * Find the GEM object and thus the gtt range object that is 4724d8d096eSAlan Cox * to back this space 4734d8d096eSAlan Cox */ 474a8ad0bd8SChris Wilson obj = drm_gem_object_lookup(filp, cmd->handles[0]); 4754d8d096eSAlan Cox if (obj == NULL) 4764d8d096eSAlan Cox return ERR_PTR(-ENOENT); 4774d8d096eSAlan Cox 4784d8d096eSAlan Cox /* Let the core code do all the work */ 4794d8d096eSAlan Cox r = container_of(obj, struct gtt_range, gem); 4804d8d096eSAlan Cox return psb_framebuffer_create(dev, cmd, r); 4814d8d096eSAlan Cox } 4824d8d096eSAlan Cox 4834d8d096eSAlan Cox static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, 4844d8d096eSAlan Cox u16 blue, int regno) 4854d8d096eSAlan Cox { 4866306865dSPatrik Jakobsson struct gma_crtc *gma_crtc = to_gma_crtc(crtc); 4873df546beSAlan Cox 4886306865dSPatrik Jakobsson gma_crtc->lut_r[regno] = red >> 8; 4896306865dSPatrik Jakobsson gma_crtc->lut_g[regno] = green >> 8; 4906306865dSPatrik Jakobsson gma_crtc->lut_b[regno] = blue >> 8; 4914d8d096eSAlan Cox } 4924d8d096eSAlan Cox 4934d8d096eSAlan Cox static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red, 4944d8d096eSAlan Cox u16 *green, u16 *blue, int regno) 4954d8d096eSAlan Cox { 4966306865dSPatrik Jakobsson struct gma_crtc *gma_crtc = to_gma_crtc(crtc); 4973df546beSAlan Cox 4986306865dSPatrik Jakobsson *red = gma_crtc->lut_r[regno] << 8; 4996306865dSPatrik Jakobsson *green = gma_crtc->lut_g[regno] << 8; 5006306865dSPatrik Jakobsson *blue = gma_crtc->lut_b[regno] << 8; 5014d8d096eSAlan Cox } 5024d8d096eSAlan Cox 5034d8d096eSAlan Cox static int psbfb_probe(struct drm_fb_helper *helper, 5044d8d096eSAlan Cox struct drm_fb_helper_surface_size *sizes) 5054d8d096eSAlan Cox { 506c39aa6a1SFabian Frederick struct psb_fbdev *psb_fbdev = 507c39aa6a1SFabian Frederick container_of(helper, struct psb_fbdev, psb_fb_helper); 5083aad16d2SAlan Cox struct drm_device *dev = psb_fbdev->psb_fb_helper.dev; 5093aad16d2SAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 5103aad16d2SAlan Cox int bytespp; 5114d8d096eSAlan Cox 5123aad16d2SAlan Cox bytespp = sizes->surface_bpp / 8; 5133aad16d2SAlan Cox if (bytespp == 3) /* no 24bit packed */ 5143aad16d2SAlan Cox bytespp = 4; 5153aad16d2SAlan Cox 5163aad16d2SAlan Cox /* If the mode will not fit in 32bit then switch to 16bit to get 5173aad16d2SAlan Cox a console on full resolution. The X mode setting server will 5183aad16d2SAlan Cox allocate its own 32bit GEM framebuffer */ 5193aad16d2SAlan Cox if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height > 5203aad16d2SAlan Cox dev_priv->vram_stolen_size) { 5213aad16d2SAlan Cox sizes->surface_bpp = 16; 5223aad16d2SAlan Cox sizes->surface_depth = 16; 5233aad16d2SAlan Cox } 5243aad16d2SAlan Cox 525cd5428a5SDaniel Vetter return psbfb_create(psb_fbdev, sizes); 5264d8d096eSAlan Cox } 5274d8d096eSAlan Cox 5283a493879SThierry Reding static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { 5294d8d096eSAlan Cox .gamma_set = psbfb_gamma_set, 5304d8d096eSAlan Cox .gamma_get = psbfb_gamma_get, 5314d8d096eSAlan Cox .fb_probe = psbfb_probe, 5324d8d096eSAlan Cox }; 5334d8d096eSAlan Cox 534bc7f2b08SKirill A. Shutemov static int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev) 5354d8d096eSAlan Cox { 5364d8d096eSAlan Cox struct psb_framebuffer *psbfb = &fbdev->pfb; 5374d8d096eSAlan Cox 538546187c8SArchit Taneja drm_fb_helper_unregister_fbi(&fbdev->psb_fb_helper); 539546187c8SArchit Taneja drm_fb_helper_release_fbi(&fbdev->psb_fb_helper); 540546187c8SArchit Taneja 5414d8d096eSAlan Cox drm_fb_helper_fini(&fbdev->psb_fb_helper); 54236206361SDaniel Vetter drm_framebuffer_unregister_private(&psbfb->base); 5434d8d096eSAlan Cox drm_framebuffer_cleanup(&psbfb->base); 5444d8d096eSAlan Cox 5454d8d096eSAlan Cox if (psbfb->gtt) 54646a0f223SDaniel Vetter drm_gem_object_unreference_unlocked(&psbfb->gtt->gem); 5474d8d096eSAlan Cox return 0; 5484d8d096eSAlan Cox } 5494d8d096eSAlan Cox 5504d8d096eSAlan Cox int psb_fbdev_init(struct drm_device *dev) 5514d8d096eSAlan Cox { 5524d8d096eSAlan Cox struct psb_fbdev *fbdev; 5534d8d096eSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 55401934c2aSThierry Reding int ret; 5554d8d096eSAlan Cox 5564d8d096eSAlan Cox fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL); 5574d8d096eSAlan Cox if (!fbdev) { 5584d8d096eSAlan Cox dev_err(dev->dev, "no memory\n"); 5594d8d096eSAlan Cox return -ENOMEM; 5604d8d096eSAlan Cox } 5614d8d096eSAlan Cox 5624d8d096eSAlan Cox dev_priv->fbdev = fbdev; 56310a23102SThierry Reding 56410a23102SThierry Reding drm_fb_helper_prepare(dev, &fbdev->psb_fb_helper, &psb_fb_helper_funcs); 5654d8d096eSAlan Cox 56601934c2aSThierry Reding ret = drm_fb_helper_init(dev, &fbdev->psb_fb_helper, 56701934c2aSThierry Reding dev_priv->ops->crtcs, INTELFB_CONN_LIMIT); 56801934c2aSThierry Reding if (ret) 56901934c2aSThierry Reding goto free; 5704d8d096eSAlan Cox 57101934c2aSThierry Reding ret = drm_fb_helper_single_add_all_connectors(&fbdev->psb_fb_helper); 57201934c2aSThierry Reding if (ret) 57301934c2aSThierry Reding goto fini; 57476a39dbfSDaniel Vetter 57576a39dbfSDaniel Vetter /* disable all the possible outputs/crtcs before entering KMS mode */ 57676a39dbfSDaniel Vetter drm_helper_disable_unused_functions(dev); 57776a39dbfSDaniel Vetter 57801934c2aSThierry Reding ret = drm_fb_helper_initial_config(&fbdev->psb_fb_helper, 32); 57901934c2aSThierry Reding if (ret) 58001934c2aSThierry Reding goto fini; 58101934c2aSThierry Reding 5824d8d096eSAlan Cox return 0; 58301934c2aSThierry Reding 58401934c2aSThierry Reding fini: 58501934c2aSThierry Reding drm_fb_helper_fini(&fbdev->psb_fb_helper); 58601934c2aSThierry Reding free: 58701934c2aSThierry Reding kfree(fbdev); 58801934c2aSThierry Reding return ret; 5894d8d096eSAlan Cox } 5904d8d096eSAlan Cox 591bc7f2b08SKirill A. Shutemov static void psb_fbdev_fini(struct drm_device *dev) 5924d8d096eSAlan Cox { 5934d8d096eSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 5944d8d096eSAlan Cox 5954d8d096eSAlan Cox if (!dev_priv->fbdev) 5964d8d096eSAlan Cox return; 5974d8d096eSAlan Cox 5984d8d096eSAlan Cox psb_fbdev_destroy(dev, dev_priv->fbdev); 5994d8d096eSAlan Cox kfree(dev_priv->fbdev); 6004d8d096eSAlan Cox dev_priv->fbdev = NULL; 6014d8d096eSAlan Cox } 6024d8d096eSAlan Cox 6034d8d096eSAlan Cox static void psbfb_output_poll_changed(struct drm_device *dev) 6044d8d096eSAlan Cox { 6054d8d096eSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 6064d8d096eSAlan Cox struct psb_fbdev *fbdev = (struct psb_fbdev *)dev_priv->fbdev; 6074d8d096eSAlan Cox drm_fb_helper_hotplug_event(&fbdev->psb_fb_helper); 6084d8d096eSAlan Cox } 6094d8d096eSAlan Cox 6104d8d096eSAlan Cox /** 6114d8d096eSAlan Cox * psb_user_framebuffer_create_handle - add hamdle to a framebuffer 6124d8d096eSAlan Cox * @fb: framebuffer 6134d8d096eSAlan Cox * @file_priv: our DRM file 6144d8d096eSAlan Cox * @handle: returned handle 6154d8d096eSAlan Cox * 6164d8d096eSAlan Cox * Our framebuffer object is a GTT range which also contains a GEM 6174d8d096eSAlan Cox * object. We need to turn it into a handle for userspace. GEM will do 6184d8d096eSAlan Cox * the work for us 6194d8d096eSAlan Cox */ 6204d8d096eSAlan Cox static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb, 6214d8d096eSAlan Cox struct drm_file *file_priv, 6224d8d096eSAlan Cox unsigned int *handle) 6234d8d096eSAlan Cox { 6244d8d096eSAlan Cox struct psb_framebuffer *psbfb = to_psb_fb(fb); 6254d8d096eSAlan Cox struct gtt_range *r = psbfb->gtt; 6264d8d096eSAlan Cox return drm_gem_handle_create(file_priv, &r->gem, handle); 6274d8d096eSAlan Cox } 6284d8d096eSAlan Cox 6294d8d096eSAlan Cox /** 6304d8d096eSAlan Cox * psb_user_framebuffer_destroy - destruct user created fb 6314d8d096eSAlan Cox * @fb: framebuffer 6324d8d096eSAlan Cox * 6334d8d096eSAlan Cox * User framebuffers are backed by GEM objects so all we have to do is 6344d8d096eSAlan Cox * clean up a bit and drop the reference, GEM will handle the fallout 6354d8d096eSAlan Cox */ 6364d8d096eSAlan Cox static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb) 6374d8d096eSAlan Cox { 6384d8d096eSAlan Cox struct psb_framebuffer *psbfb = to_psb_fb(fb); 6394d8d096eSAlan Cox struct gtt_range *r = psbfb->gtt; 6404d8d096eSAlan Cox 6414d8d096eSAlan Cox /* Let DRM do its clean up */ 6424d8d096eSAlan Cox drm_framebuffer_cleanup(fb); 6434d8d096eSAlan Cox /* We are no longer using the resource in GEM */ 6444d8d096eSAlan Cox drm_gem_object_unreference_unlocked(&r->gem); 6454d8d096eSAlan Cox kfree(fb); 6464d8d096eSAlan Cox } 6474d8d096eSAlan Cox 6484d8d096eSAlan Cox static const struct drm_mode_config_funcs psb_mode_funcs = { 6494d8d096eSAlan Cox .fb_create = psb_user_framebuffer_create, 6504d8d096eSAlan Cox .output_poll_changed = psbfb_output_poll_changed, 6514d8d096eSAlan Cox }; 6524d8d096eSAlan Cox 6534d8d096eSAlan Cox static void psb_setup_outputs(struct drm_device *dev) 6544d8d096eSAlan Cox { 6554d8d096eSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 6564d8d096eSAlan Cox struct drm_connector *connector; 6574d8d096eSAlan Cox 6584d8d096eSAlan Cox drm_mode_create_scaling_mode_property(dev); 6594d8d096eSAlan Cox 66013619ce5SAlan Cox /* It is ok for this to fail - we just don't get backlight control */ 66113619ce5SAlan Cox if (!dev_priv->backlight_property) 66213619ce5SAlan Cox dev_priv->backlight_property = drm_property_create_range(dev, 0, 66313619ce5SAlan Cox "backlight", 0, 100); 6644d8d096eSAlan Cox dev_priv->ops->output_init(dev); 6654d8d096eSAlan Cox 6664d8d096eSAlan Cox list_for_each_entry(connector, &dev->mode_config.connector_list, 6674d8d096eSAlan Cox head) { 668367e4408SPatrik Jakobsson struct gma_encoder *gma_encoder = gma_attached_encoder(connector); 669367e4408SPatrik Jakobsson struct drm_encoder *encoder = &gma_encoder->base; 6704d8d096eSAlan Cox int crtc_mask = 0, clone_mask = 0; 6714d8d096eSAlan Cox 6724d8d096eSAlan Cox /* valid crtcs */ 673367e4408SPatrik Jakobsson switch (gma_encoder->type) { 6744d8d096eSAlan Cox case INTEL_OUTPUT_ANALOG: 6754d8d096eSAlan Cox crtc_mask = (1 << 0); 6764d8d096eSAlan Cox clone_mask = (1 << INTEL_OUTPUT_ANALOG); 6774d8d096eSAlan Cox break; 6784d8d096eSAlan Cox case INTEL_OUTPUT_SDVO: 679cf8efd3aSPatrik Jakobsson crtc_mask = dev_priv->ops->sdvo_mask; 6804d8d096eSAlan Cox clone_mask = (1 << INTEL_OUTPUT_SDVO); 6814d8d096eSAlan Cox break; 6824d8d096eSAlan Cox case INTEL_OUTPUT_LVDS: 683d235e64aSAlan Cox crtc_mask = dev_priv->ops->lvds_mask; 6844d8d096eSAlan Cox clone_mask = (1 << INTEL_OUTPUT_LVDS); 6854d8d096eSAlan Cox break; 6864d8d096eSAlan Cox case INTEL_OUTPUT_MIPI: 6874d8d096eSAlan Cox crtc_mask = (1 << 0); 6884d8d096eSAlan Cox clone_mask = (1 << INTEL_OUTPUT_MIPI); 6894d8d096eSAlan Cox break; 6904d8d096eSAlan Cox case INTEL_OUTPUT_MIPI2: 6914d8d096eSAlan Cox crtc_mask = (1 << 2); 6924d8d096eSAlan Cox clone_mask = (1 << INTEL_OUTPUT_MIPI2); 6934d8d096eSAlan Cox break; 6944d8d096eSAlan Cox case INTEL_OUTPUT_HDMI: 695d235e64aSAlan Cox crtc_mask = dev_priv->ops->hdmi_mask; 6964d8d096eSAlan Cox clone_mask = (1 << INTEL_OUTPUT_HDMI); 6974d8d096eSAlan Cox break; 698220801bdSAlan Cox case INTEL_OUTPUT_DISPLAYPORT: 699220801bdSAlan Cox crtc_mask = (1 << 0) | (1 << 1); 700220801bdSAlan Cox clone_mask = (1 << INTEL_OUTPUT_DISPLAYPORT); 701220801bdSAlan Cox break; 702d112a816SZhao Yakui case INTEL_OUTPUT_EDP: 703d112a816SZhao Yakui crtc_mask = (1 << 1); 704d112a816SZhao Yakui clone_mask = (1 << INTEL_OUTPUT_EDP); 7054d8d096eSAlan Cox } 7064d8d096eSAlan Cox encoder->possible_crtcs = crtc_mask; 7074d8d096eSAlan Cox encoder->possible_clones = 708a3d5d75fSPatrik Jakobsson gma_connector_clones(dev, clone_mask); 7094d8d096eSAlan Cox } 7104d8d096eSAlan Cox } 7114d8d096eSAlan Cox 7124d8d096eSAlan Cox void psb_modeset_init(struct drm_device *dev) 7134d8d096eSAlan Cox { 7144d8d096eSAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 7154d8d096eSAlan Cox struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; 7164d8d096eSAlan Cox int i; 7174d8d096eSAlan Cox 7184d8d096eSAlan Cox drm_mode_config_init(dev); 7194d8d096eSAlan Cox 7204d8d096eSAlan Cox dev->mode_config.min_width = 0; 7214d8d096eSAlan Cox dev->mode_config.min_height = 0; 7224d8d096eSAlan Cox 723e6ecefaaSLaurent Pinchart dev->mode_config.funcs = &psb_mode_funcs; 7244d8d096eSAlan Cox 7254d8d096eSAlan Cox /* set memory base */ 726dffc9cebSAlan Cox /* Oaktrail and Poulsbo should use BAR 2*/ 7274d8d096eSAlan Cox pci_read_config_dword(dev->pdev, PSB_BSM, (u32 *) 7284d8d096eSAlan Cox &(dev->mode_config.fb_base)); 7294d8d096eSAlan Cox 7304d8d096eSAlan Cox /* num pipes is 2 for PSB but 1 for Mrst */ 7314d8d096eSAlan Cox for (i = 0; i < dev_priv->num_pipe; i++) 7324d8d096eSAlan Cox psb_intel_crtc_init(dev, i, mode_dev); 7334d8d096eSAlan Cox 734cbbd379aSPatrik Jakobsson dev->mode_config.max_width = 4096; 735cbbd379aSPatrik Jakobsson dev->mode_config.max_height = 4096; 7364d8d096eSAlan Cox 7374d8d096eSAlan Cox psb_setup_outputs(dev); 738d235e64aSAlan Cox 739d235e64aSAlan Cox if (dev_priv->ops->errata) 740d235e64aSAlan Cox dev_priv->ops->errata(dev); 7414ab2c7f1SAlan Cox 7424ab2c7f1SAlan Cox dev_priv->modeset = true; 7434d8d096eSAlan Cox } 7444d8d096eSAlan Cox 7454d8d096eSAlan Cox void psb_modeset_cleanup(struct drm_device *dev) 7464d8d096eSAlan Cox { 7474ab2c7f1SAlan Cox struct drm_psb_private *dev_priv = dev->dev_private; 7484ab2c7f1SAlan Cox if (dev_priv->modeset) { 7494d8d096eSAlan Cox drm_kms_helper_poll_fini(dev); 7504d8d096eSAlan Cox psb_fbdev_fini(dev); 7514d8d096eSAlan Cox drm_mode_config_cleanup(dev); 7524d8d096eSAlan Cox } 7534ab2c7f1SAlan Cox } 754