aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/gma500
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2011-11-29 17:27:34 -0500
committerDave Airlie <airlied@redhat.com>2011-12-06 04:55:40 -0500
commit1b223c9ebf11e9597820fac57b211709f8ffce26 (patch)
treed249394aeb95edb1b7c60cf53959d1183cae860f /drivers/gpu/drm/gma500
parenta6ba582d264f67074f669f76172e8a2afadff2a4 (diff)
gma500: Be smarter about layout
If we can't fit a page aligned display stride then it's not the end of the world for a normal font, so try half a page and work down sizes. Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/gma500')
-rw-r--r--drivers/gpu/drm/gma500/framebuffer.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 652f1ecb0a69..9ec167600d04 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -385,7 +385,8 @@ static int psbfb_create(struct psb_fbdev *fbdev,
385 int ret; 385 int ret;
386 struct gtt_range *backing; 386 struct gtt_range *backing;
387 u32 bpp, depth; 387 u32 bpp, depth;
388 int gtt_roll = 1; 388 int gtt_roll = 0;
389 int pitch_lines = 0;
389 390
390 mode_cmd.width = sizes->surface_width; 391 mode_cmd.width = sizes->surface_width;
391 mode_cmd.height = sizes->surface_height; 392 mode_cmd.height = sizes->surface_height;
@@ -395,27 +396,40 @@ static int psbfb_create(struct psb_fbdev *fbdev,
395 if (bpp == 24) 396 if (bpp == 24)
396 bpp = 32; 397 bpp = 32;
397 398
398 /* Acceleration via the GTT requires pitch to be 4096 byte aligned 399 do {
399 (ie 1024 or 2048 pixels in normal use) */ 400 /*
400 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 4096); 401 * Acceleration via the GTT requires pitch to be
401 depth = sizes->surface_depth; 402 * power of two aligned. Preferably page but less
403 * is ok with some fonts
404 */
405 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 4096 >> pitch_lines);
406 depth = sizes->surface_depth;
407
408 size = mode_cmd.pitches[0] * mode_cmd.height;
409 size = ALIGN(size, PAGE_SIZE);
410
411 /* Allocate the fb in the GTT with stolen page backing */
412 backing = psbfb_alloc(dev, size);
413
414 if (pitch_lines)
415 pitch_lines *= 2;
416 else
417 pitch_lines = 1;
418 gtt_roll++;
419 } while (backing == NULL && pitch_lines <= 16);
402 420
403 size = mode_cmd.pitches[0] * mode_cmd.height; 421 /* The final pitch we accepted if we succeeded */
404 size = ALIGN(size, PAGE_SIZE); 422 pitch_lines /= 2;
405 423
406 /* Try and allocate with the alignment we need */
407 backing = psbfb_alloc(dev, size);
408 if (backing == NULL) { 424 if (backing == NULL) {
409 /* 425 /*
410 * We couldn't get the space we wanted, fall back to the 426 * We couldn't get the space we wanted, fall back to the
411 * display engine requirement instead. The HW requires 427 * display engine requirement instead. The HW requires
412 * the pitch to be 64 byte aligned 428 * the pitch to be 64 byte aligned
413 *
414 * FIXME: We could try alignments in a loop so that we can still
415 * accelerate power of two font sizes.
416 */ 429 */
417 430
418 gtt_roll = 0; /* Don't use GTT accelerated scrolling */ 431 gtt_roll = 0; /* Don't use GTT accelerated scrolling */
432 pitch_lines = 64;
419 433
420 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 64); 434 mode_cmd.pitches[0] = ALIGN(mode_cmd.width * ((bpp + 7) / 8), 64);
421 435
@@ -452,12 +466,12 @@ static int psbfb_create(struct psb_fbdev *fbdev,
452 strcpy(info->fix.id, "psbfb"); 466 strcpy(info->fix.id, "psbfb");
453 467
454 info->flags = FBINFO_DEFAULT; 468 info->flags = FBINFO_DEFAULT;
455 if (gtt_roll) { /* GTT rolling seems best */ 469 if (dev_priv->ops->accel_2d && pitch_lines > 8) /* 2D engine */
470 info->fbops = &psbfb_ops;
471 else if (gtt_roll) { /* GTT rolling seems best */
456 info->fbops = &psbfb_roll_ops; 472 info->fbops = &psbfb_roll_ops;
457 info->flags |= FBINFO_HWACCEL_YPAN; 473 info->flags |= FBINFO_HWACCEL_YPAN;
458 } else if (dev_priv->ops->accel_2d) /* 2D engine */ 474 } else /* Software */
459 info->fbops = &psbfb_ops;
460 else /* Software */
461 info->fbops = &psbfb_unaccel_ops; 475 info->fbops = &psbfb_unaccel_ops;
462 476
463 ret = fb_alloc_cmap(&info->cmap, 256, 0); 477 ret = fb_alloc_cmap(&info->cmap, 256, 0);