1 /************************************************************************** 2 * Copyright (c) 2007-2011, Intel Corporation. 3 * All Rights Reserved. 4 * 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. 8 * 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 12 * more details. 13 * 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. 17 * 18 **************************************************************************/ 19 20 #include <linux/module.h> 21 #include <linux/kernel.h> 22 #include <linux/errno.h> 23 #include <linux/string.h> 24 #include <linux/pfn_t.h> 25 #include <linux/mm.h> 26 #include <linux/tty.h> 27 #include <linux/slab.h> 28 #include <linux/delay.h> 29 #include <linux/init.h> 30 #include <linux/console.h> 31 32 #include <drm/drmP.h> 33 #include <drm/drm.h> 34 #include <drm/drm_crtc.h> 35 #include <drm/drm_fb_helper.h> 36 #include <drm/drm_gem_framebuffer_helper.h> 37 38 #include "psb_drv.h" 39 #include "psb_intel_reg.h" 40 #include "psb_intel_drv.h" 41 #include "framebuffer.h" 42 #include "gtt.h" 43 44 static const struct drm_framebuffer_funcs psb_fb_funcs = { 45 .destroy = drm_gem_fb_destroy, 46 .create_handle = drm_gem_fb_create_handle, 47 }; 48 49 #define CMAP_TOHW(_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) 50 51 static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green, 52 unsigned blue, unsigned transp, 53 struct fb_info *info) 54 { 55 struct psb_fbdev *fbdev = info->par; 56 struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb; 57 uint32_t v; 58 59 if (!fb) 60 return -ENOMEM; 61 62 if (regno > 255) 63 return 1; 64 65 red = CMAP_TOHW(red, info->var.red.length); 66 blue = CMAP_TOHW(blue, info->var.blue.length); 67 green = CMAP_TOHW(green, info->var.green.length); 68 transp = CMAP_TOHW(transp, info->var.transp.length); 69 70 v = (red << info->var.red.offset) | 71 (green << info->var.green.offset) | 72 (blue << info->var.blue.offset) | 73 (transp << info->var.transp.offset); 74 75 if (regno < 16) { 76 switch (fb->format->cpp[0] * 8) { 77 case 16: 78 ((uint32_t *) info->pseudo_palette)[regno] = v; 79 break; 80 case 24: 81 case 32: 82 ((uint32_t *) info->pseudo_palette)[regno] = v; 83 break; 84 } 85 } 86 87 return 0; 88 } 89 90 static int psbfb_pan(struct fb_var_screeninfo *var, struct fb_info *info) 91 { 92 struct psb_fbdev *fbdev = info->par; 93 struct psb_framebuffer *psbfb = &fbdev->pfb; 94 struct drm_device *dev = psbfb->base.dev; 95 struct gtt_range *gtt = to_gtt_range(psbfb->base.obj[0]); 96 97 /* 98 * We have to poke our nose in here. The core fb code assumes 99 * panning is part of the hardware that can be invoked before 100 * the actual fb is mapped. In our case that isn't quite true. 101 */ 102 if (gtt->npage) { 103 /* GTT roll shifts in 4K pages, we need to shift the right 104 number of pages */ 105 int pages = info->fix.line_length >> 12; 106 psb_gtt_roll(dev, gtt, var->yoffset * pages); 107 } 108 return 0; 109 } 110 111 static int psbfb_vm_fault(struct vm_fault *vmf) 112 { 113 struct vm_area_struct *vma = vmf->vma; 114 struct psb_framebuffer *psbfb = vma->vm_private_data; 115 struct drm_device *dev = psbfb->base.dev; 116 struct drm_psb_private *dev_priv = dev->dev_private; 117 struct gtt_range *gtt = to_gtt_range(psbfb->base.obj[0]); 118 int page_num; 119 int i; 120 unsigned long address; 121 int ret; 122 unsigned long pfn; 123 unsigned long phys_addr = (unsigned long)dev_priv->stolen_base + 124 gtt->offset; 125 126 page_num = vma_pages(vma); 127 address = vmf->address - (vmf->pgoff << PAGE_SHIFT); 128 129 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 130 131 for (i = 0; i < page_num; i++) { 132 pfn = (phys_addr >> PAGE_SHIFT); 133 134 ret = vm_insert_mixed(vma, address, 135 __pfn_to_pfn_t(pfn, PFN_DEV)); 136 if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0))) 137 break; 138 else if (unlikely(ret != 0)) { 139 ret = (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS; 140 return ret; 141 } 142 address += PAGE_SIZE; 143 phys_addr += PAGE_SIZE; 144 } 145 return VM_FAULT_NOPAGE; 146 } 147 148 static void psbfb_vm_open(struct vm_area_struct *vma) 149 { 150 } 151 152 static void psbfb_vm_close(struct vm_area_struct *vma) 153 { 154 } 155 156 static const struct vm_operations_struct psbfb_vm_ops = { 157 .fault = psbfb_vm_fault, 158 .open = psbfb_vm_open, 159 .close = psbfb_vm_close 160 }; 161 162 static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma) 163 { 164 struct psb_fbdev *fbdev = info->par; 165 struct psb_framebuffer *psbfb = &fbdev->pfb; 166 167 if (vma->vm_pgoff != 0) 168 return -EINVAL; 169 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 170 return -EINVAL; 171 172 if (!psbfb->addr_space) 173 psbfb->addr_space = vma->vm_file->f_mapping; 174 /* 175 * If this is a GEM object then info->screen_base is the virtual 176 * kernel remapping of the object. FIXME: Review if this is 177 * suitable for our mmap work 178 */ 179 vma->vm_ops = &psbfb_vm_ops; 180 vma->vm_private_data = (void *)psbfb; 181 vma->vm_flags |= VM_IO | VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP; 182 return 0; 183 } 184 185 static struct fb_ops psbfb_ops = { 186 .owner = THIS_MODULE, 187 DRM_FB_HELPER_DEFAULT_OPS, 188 .fb_setcolreg = psbfb_setcolreg, 189 .fb_fillrect = drm_fb_helper_cfb_fillrect, 190 .fb_copyarea = psbfb_copyarea, 191 .fb_imageblit = drm_fb_helper_cfb_imageblit, 192 .fb_mmap = psbfb_mmap, 193 .fb_sync = psbfb_sync, 194 }; 195 196 static struct fb_ops psbfb_roll_ops = { 197 .owner = THIS_MODULE, 198 DRM_FB_HELPER_DEFAULT_OPS, 199 .fb_setcolreg = psbfb_setcolreg, 200 .fb_fillrect = drm_fb_helper_cfb_fillrect, 201 .fb_copyarea = drm_fb_helper_cfb_copyarea, 202 .fb_imageblit = drm_fb_helper_cfb_imageblit, 203 .fb_pan_display = psbfb_pan, 204 .fb_mmap = psbfb_mmap, 205 }; 206 207 static struct fb_ops psbfb_unaccel_ops = { 208 .owner = THIS_MODULE, 209 DRM_FB_HELPER_DEFAULT_OPS, 210 .fb_setcolreg = psbfb_setcolreg, 211 .fb_fillrect = drm_fb_helper_cfb_fillrect, 212 .fb_copyarea = drm_fb_helper_cfb_copyarea, 213 .fb_imageblit = drm_fb_helper_cfb_imageblit, 214 .fb_mmap = psbfb_mmap, 215 }; 216 217 /** 218 * psb_framebuffer_init - initialize a framebuffer 219 * @dev: our DRM device 220 * @fb: framebuffer to set up 221 * @mode_cmd: mode description 222 * @gt: backing object 223 * 224 * Configure and fill in the boilerplate for our frame buffer. Return 225 * 0 on success or an error code if we fail. 226 */ 227 static int psb_framebuffer_init(struct drm_device *dev, 228 struct psb_framebuffer *fb, 229 const struct drm_mode_fb_cmd2 *mode_cmd, 230 struct gtt_range *gt) 231 { 232 const struct drm_format_info *info; 233 int ret; 234 235 /* 236 * Reject unknown formats, YUV formats, and formats with more than 237 * 4 bytes per pixel. 238 */ 239 info = drm_format_info(mode_cmd->pixel_format); 240 if (!info || !info->depth || info->cpp[0] > 4) 241 return -EINVAL; 242 243 if (mode_cmd->pitches[0] & 63) 244 return -EINVAL; 245 246 drm_helper_mode_fill_fb_struct(dev, &fb->base, mode_cmd); 247 fb->base.obj[0] = >->gem; 248 ret = drm_framebuffer_init(dev, &fb->base, &psb_fb_funcs); 249 if (ret) { 250 dev_err(dev->dev, "framebuffer init failed: %d\n", ret); 251 return ret; 252 } 253 return 0; 254 } 255 256 /** 257 * psb_framebuffer_create - create a framebuffer backed by gt 258 * @dev: our DRM device 259 * @mode_cmd: the description of the requested mode 260 * @gt: the backing object 261 * 262 * Create a framebuffer object backed by the gt, and fill in the 263 * boilerplate required 264 * 265 * TODO: review object references 266 */ 267 268 static struct drm_framebuffer *psb_framebuffer_create 269 (struct drm_device *dev, 270 const struct drm_mode_fb_cmd2 *mode_cmd, 271 struct gtt_range *gt) 272 { 273 struct psb_framebuffer *fb; 274 int ret; 275 276 fb = kzalloc(sizeof(*fb), GFP_KERNEL); 277 if (!fb) 278 return ERR_PTR(-ENOMEM); 279 280 ret = psb_framebuffer_init(dev, fb, mode_cmd, gt); 281 if (ret) { 282 kfree(fb); 283 return ERR_PTR(ret); 284 } 285 return &fb->base; 286 } 287 288 /** 289 * psbfb_alloc - allocate frame buffer memory 290 * @dev: the DRM device 291 * @aligned_size: space needed 292 * 293 * Allocate the frame buffer. In the usual case we get a GTT range that 294 * is stolen memory backed and life is simple. If there isn't sufficient 295 * we fail as we don't have the virtual mapping space to really vmap it 296 * and the kernel console code can't handle non linear framebuffers. 297 * 298 * Re-address this as and if the framebuffer layer grows this ability. 299 */ 300 static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size) 301 { 302 struct gtt_range *backing; 303 /* Begin by trying to use stolen memory backing */ 304 backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1, PAGE_SIZE); 305 if (backing) { 306 drm_gem_private_object_init(dev, &backing->gem, aligned_size); 307 return backing; 308 } 309 return NULL; 310 } 311 312 /** 313 * psbfb_create - create a framebuffer 314 * @fbdev: the framebuffer device 315 * @sizes: specification of the layout 316 * 317 * Create a framebuffer to the specifications provided 318 */ 319 static int psbfb_create(struct psb_fbdev *fbdev, 320 struct drm_fb_helper_surface_size *sizes) 321 { 322 struct drm_device *dev = fbdev->psb_fb_helper.dev; 323 struct drm_psb_private *dev_priv = dev->dev_private; 324 struct fb_info *info; 325 struct drm_framebuffer *fb; 326 struct psb_framebuffer *psbfb = &fbdev->pfb; 327 struct drm_mode_fb_cmd2 mode_cmd; 328 int size; 329 int ret; 330 struct gtt_range *backing; 331 u32 bpp, depth; 332 int gtt_roll = 0; 333 int pitch_lines = 0; 334 335 mode_cmd.width = sizes->surface_width; 336 mode_cmd.height = sizes->surface_height; 337 bpp = sizes->surface_bpp; 338 depth = sizes->surface_depth; 339 340 /* No 24bit packed */ 341 if (bpp == 24) 342 bpp = 32; 343 344 do { 345 /* 346 * Acceleration via the GTT requires pitch to be 347 * power of two aligned. Preferably page but less 348 * is ok with some fonts 349 */ 350 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 4096 >> pitch_lines); 351 352 size = mode_cmd.pitches[0] * mode_cmd.height; 353 size = ALIGN(size, PAGE_SIZE); 354 355 /* Allocate the fb in the GTT with stolen page backing */ 356 backing = psbfb_alloc(dev, size); 357 358 if (pitch_lines) 359 pitch_lines *= 2; 360 else 361 pitch_lines = 1; 362 gtt_roll++; 363 } while (backing == NULL && pitch_lines <= 16); 364 365 /* The final pitch we accepted if we succeeded */ 366 pitch_lines /= 2; 367 368 if (backing == NULL) { 369 /* 370 * We couldn't get the space we wanted, fall back to the 371 * display engine requirement instead. The HW requires 372 * the pitch to be 64 byte aligned 373 */ 374 375 gtt_roll = 0; /* Don't use GTT accelerated scrolling */ 376 pitch_lines = 64; 377 378 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 64); 379 380 size = mode_cmd.pitches[0] * mode_cmd.height; 381 size = ALIGN(size, PAGE_SIZE); 382 383 /* Allocate the framebuffer in the GTT with stolen page backing */ 384 backing = psbfb_alloc(dev, size); 385 if (backing == NULL) 386 return -ENOMEM; 387 } 388 389 memset(dev_priv->vram_addr + backing->offset, 0, size); 390 391 info = drm_fb_helper_alloc_fbi(&fbdev->psb_fb_helper); 392 if (IS_ERR(info)) { 393 ret = PTR_ERR(info); 394 goto out; 395 } 396 info->par = fbdev; 397 398 mode_cmd.pixel_format = drm_mode_legacy_fb_format(bpp, depth); 399 400 ret = psb_framebuffer_init(dev, psbfb, &mode_cmd, backing); 401 if (ret) 402 goto out; 403 404 fb = &psbfb->base; 405 psbfb->fbdev = info; 406 407 fbdev->psb_fb_helper.fb = fb; 408 409 drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); 410 strcpy(info->fix.id, "psbdrmfb"); 411 412 info->flags = FBINFO_DEFAULT; 413 if (dev_priv->ops->accel_2d && pitch_lines > 8) /* 2D engine */ 414 info->fbops = &psbfb_ops; 415 else if (gtt_roll) { /* GTT rolling seems best */ 416 info->fbops = &psbfb_roll_ops; 417 info->flags |= FBINFO_HWACCEL_YPAN; 418 } else /* Software */ 419 info->fbops = &psbfb_unaccel_ops; 420 421 info->fix.smem_start = dev->mode_config.fb_base; 422 info->fix.smem_len = size; 423 info->fix.ywrapstep = gtt_roll; 424 info->fix.ypanstep = 0; 425 426 /* Accessed stolen memory directly */ 427 info->screen_base = dev_priv->vram_addr + backing->offset; 428 info->screen_size = size; 429 430 if (dev_priv->gtt.stolen_size) { 431 info->apertures->ranges[0].base = dev->mode_config.fb_base; 432 info->apertures->ranges[0].size = dev_priv->gtt.stolen_size; 433 } 434 435 drm_fb_helper_fill_var(info, &fbdev->psb_fb_helper, 436 sizes->fb_width, sizes->fb_height); 437 438 info->fix.mmio_start = pci_resource_start(dev->pdev, 0); 439 info->fix.mmio_len = pci_resource_len(dev->pdev, 0); 440 441 /* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ 442 443 dev_dbg(dev->dev, "allocated %dx%d fb\n", 444 psbfb->base.width, psbfb->base.height); 445 446 return 0; 447 out: 448 psb_gtt_free_range(dev, backing); 449 return ret; 450 } 451 452 /** 453 * psb_user_framebuffer_create - create framebuffer 454 * @dev: our DRM device 455 * @filp: client file 456 * @cmd: mode request 457 * 458 * Create a new framebuffer backed by a userspace GEM object 459 */ 460 static struct drm_framebuffer *psb_user_framebuffer_create 461 (struct drm_device *dev, struct drm_file *filp, 462 const struct drm_mode_fb_cmd2 *cmd) 463 { 464 struct gtt_range *r; 465 struct drm_gem_object *obj; 466 467 /* 468 * Find the GEM object and thus the gtt range object that is 469 * to back this space 470 */ 471 obj = drm_gem_object_lookup(filp, cmd->handles[0]); 472 if (obj == NULL) 473 return ERR_PTR(-ENOENT); 474 475 /* Let the core code do all the work */ 476 r = container_of(obj, struct gtt_range, gem); 477 return psb_framebuffer_create(dev, cmd, r); 478 } 479 480 static int psbfb_probe(struct drm_fb_helper *helper, 481 struct drm_fb_helper_surface_size *sizes) 482 { 483 struct psb_fbdev *psb_fbdev = 484 container_of(helper, struct psb_fbdev, psb_fb_helper); 485 struct drm_device *dev = psb_fbdev->psb_fb_helper.dev; 486 struct drm_psb_private *dev_priv = dev->dev_private; 487 int bytespp; 488 489 bytespp = sizes->surface_bpp / 8; 490 if (bytespp == 3) /* no 24bit packed */ 491 bytespp = 4; 492 493 /* If the mode will not fit in 32bit then switch to 16bit to get 494 a console on full resolution. The X mode setting server will 495 allocate its own 32bit GEM framebuffer */ 496 if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height > 497 dev_priv->vram_stolen_size) { 498 sizes->surface_bpp = 16; 499 sizes->surface_depth = 16; 500 } 501 502 return psbfb_create(psb_fbdev, sizes); 503 } 504 505 static const struct drm_fb_helper_funcs psb_fb_helper_funcs = { 506 .fb_probe = psbfb_probe, 507 }; 508 509 static int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev) 510 { 511 struct psb_framebuffer *psbfb = &fbdev->pfb; 512 513 drm_fb_helper_unregister_fbi(&fbdev->psb_fb_helper); 514 515 drm_fb_helper_fini(&fbdev->psb_fb_helper); 516 drm_framebuffer_unregister_private(&psbfb->base); 517 drm_framebuffer_cleanup(&psbfb->base); 518 519 if (psbfb->base.obj[0]) 520 drm_gem_object_put_unlocked(psbfb->base.obj[0]); 521 return 0; 522 } 523 524 int psb_fbdev_init(struct drm_device *dev) 525 { 526 struct psb_fbdev *fbdev; 527 struct drm_psb_private *dev_priv = dev->dev_private; 528 int ret; 529 530 fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL); 531 if (!fbdev) { 532 dev_err(dev->dev, "no memory\n"); 533 return -ENOMEM; 534 } 535 536 dev_priv->fbdev = fbdev; 537 538 drm_fb_helper_prepare(dev, &fbdev->psb_fb_helper, &psb_fb_helper_funcs); 539 540 ret = drm_fb_helper_init(dev, &fbdev->psb_fb_helper, 541 INTELFB_CONN_LIMIT); 542 if (ret) 543 goto free; 544 545 ret = drm_fb_helper_single_add_all_connectors(&fbdev->psb_fb_helper); 546 if (ret) 547 goto fini; 548 549 /* disable all the possible outputs/crtcs before entering KMS mode */ 550 drm_helper_disable_unused_functions(dev); 551 552 ret = drm_fb_helper_initial_config(&fbdev->psb_fb_helper, 32); 553 if (ret) 554 goto fini; 555 556 return 0; 557 558 fini: 559 drm_fb_helper_fini(&fbdev->psb_fb_helper); 560 free: 561 kfree(fbdev); 562 return ret; 563 } 564 565 static void psb_fbdev_fini(struct drm_device *dev) 566 { 567 struct drm_psb_private *dev_priv = dev->dev_private; 568 569 if (!dev_priv->fbdev) 570 return; 571 572 psb_fbdev_destroy(dev, dev_priv->fbdev); 573 kfree(dev_priv->fbdev); 574 dev_priv->fbdev = NULL; 575 } 576 577 static const struct drm_mode_config_funcs psb_mode_funcs = { 578 .fb_create = psb_user_framebuffer_create, 579 .output_poll_changed = drm_fb_helper_output_poll_changed, 580 }; 581 582 static void psb_setup_outputs(struct drm_device *dev) 583 { 584 struct drm_psb_private *dev_priv = dev->dev_private; 585 struct drm_connector *connector; 586 587 drm_mode_create_scaling_mode_property(dev); 588 589 /* It is ok for this to fail - we just don't get backlight control */ 590 if (!dev_priv->backlight_property) 591 dev_priv->backlight_property = drm_property_create_range(dev, 0, 592 "backlight", 0, 100); 593 dev_priv->ops->output_init(dev); 594 595 list_for_each_entry(connector, &dev->mode_config.connector_list, 596 head) { 597 struct gma_encoder *gma_encoder = gma_attached_encoder(connector); 598 struct drm_encoder *encoder = &gma_encoder->base; 599 int crtc_mask = 0, clone_mask = 0; 600 601 /* valid crtcs */ 602 switch (gma_encoder->type) { 603 case INTEL_OUTPUT_ANALOG: 604 crtc_mask = (1 << 0); 605 clone_mask = (1 << INTEL_OUTPUT_ANALOG); 606 break; 607 case INTEL_OUTPUT_SDVO: 608 crtc_mask = dev_priv->ops->sdvo_mask; 609 clone_mask = (1 << INTEL_OUTPUT_SDVO); 610 break; 611 case INTEL_OUTPUT_LVDS: 612 crtc_mask = dev_priv->ops->lvds_mask; 613 clone_mask = (1 << INTEL_OUTPUT_LVDS); 614 break; 615 case INTEL_OUTPUT_MIPI: 616 crtc_mask = (1 << 0); 617 clone_mask = (1 << INTEL_OUTPUT_MIPI); 618 break; 619 case INTEL_OUTPUT_MIPI2: 620 crtc_mask = (1 << 2); 621 clone_mask = (1 << INTEL_OUTPUT_MIPI2); 622 break; 623 case INTEL_OUTPUT_HDMI: 624 crtc_mask = dev_priv->ops->hdmi_mask; 625 clone_mask = (1 << INTEL_OUTPUT_HDMI); 626 break; 627 case INTEL_OUTPUT_DISPLAYPORT: 628 crtc_mask = (1 << 0) | (1 << 1); 629 clone_mask = (1 << INTEL_OUTPUT_DISPLAYPORT); 630 break; 631 case INTEL_OUTPUT_EDP: 632 crtc_mask = (1 << 1); 633 clone_mask = (1 << INTEL_OUTPUT_EDP); 634 } 635 encoder->possible_crtcs = crtc_mask; 636 encoder->possible_clones = 637 gma_connector_clones(dev, clone_mask); 638 } 639 } 640 641 void psb_modeset_init(struct drm_device *dev) 642 { 643 struct drm_psb_private *dev_priv = dev->dev_private; 644 struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev; 645 int i; 646 647 drm_mode_config_init(dev); 648 649 dev->mode_config.min_width = 0; 650 dev->mode_config.min_height = 0; 651 652 dev->mode_config.funcs = &psb_mode_funcs; 653 654 /* set memory base */ 655 /* Oaktrail and Poulsbo should use BAR 2*/ 656 pci_read_config_dword(dev->pdev, PSB_BSM, (u32 *) 657 &(dev->mode_config.fb_base)); 658 659 /* num pipes is 2 for PSB but 1 for Mrst */ 660 for (i = 0; i < dev_priv->num_pipe; i++) 661 psb_intel_crtc_init(dev, i, mode_dev); 662 663 dev->mode_config.max_width = 4096; 664 dev->mode_config.max_height = 4096; 665 666 psb_setup_outputs(dev); 667 668 if (dev_priv->ops->errata) 669 dev_priv->ops->errata(dev); 670 671 dev_priv->modeset = true; 672 } 673 674 void psb_modeset_cleanup(struct drm_device *dev) 675 { 676 struct drm_psb_private *dev_priv = dev->dev_private; 677 if (dev_priv->modeset) { 678 drm_kms_helper_poll_fini(dev); 679 psb_fbdev_fini(dev); 680 drm_mode_config_cleanup(dev); 681 } 682 } 683