Commit a455d3814d692d22cd2b18f6f85ee96d6bf5ec76

  • avatar
  • Chia-I Wu <olvaffe @gm…l.com>
  • Wed Nov 25 11:44:29 CET 2009
EGLKMSSurface: Align framebuffer pitch and size.

Align pitch to 64 bytes and fb size to page size.  It fixes the skewed
screen on devices with weird resolutions like 1366x768.
  
9292 uint32_t handle;
9393 size_t size;
9494 int width, height;
95 int stride;
95 int pitch;
9696 int bpp;
9797 int format;
9898 char *base;
  
9898 egl_native_window_t::width = mFb[1 - mIndex].width;
9999 egl_native_window_t::height = mFb[1 - mIndex].height;
100100 egl_native_window_t::stride =
101 mFb[1 - mIndex].stride / (mFb[1 - mIndex].bpp / 8);
101 mFb[1 - mIndex].pitch / (mFb[1 - mIndex].bpp / 8);
102102 egl_native_window_t::format = mFb[1 - mIndex].format;
103103#if AGL_SUPPORT
104104 egl_native_window_t::base = intptr_t(mFb[0].base);
414414#if AGL_SUPPORT
415415 struct drm_i915_gem_mmap gmap;
416416#endif
417 int ret;
417 int pitch, ret;
418 size_t size;
418419
419420 mFb[i].width = mMode->hdisplay;
420421 mFb[i].height = mMode->vdisplay;
421422 mFb[i].format = GGL_PIXEL_FORMAT_RGB_565;
422423 mFb[i].bpp = bytesPerPixel(mFb[i].format) * 8;
423 mFb[i].stride = mFb[i].width * mFb[i].bpp / 8;
424 mFb[i].size = mFb[i].stride * mFb[i].height;
425424
425 pitch = mFb[i].width * mFb[i].bpp / 8;
426 /* align to 64 bytes */
427 pitch = (pitch + 63) & ~63;
428 size = pitch * mFb[i].height;
429 /* align to page size */
430 size = (size + 4095) & ~4095;
431
432 mFb[i].pitch = pitch;
433 mFb[i].size = size;
434
426435 memset(&create, 0, sizeof(create));
427436 memset(&flink, 0, sizeof(flink));
428437
464464#endif
465465
466466 ret = drmModeAddFB(fd, mFb[i].width, mFb[i].height,
467 mFb[i].bpp, mFb[i].bpp, mFb[i].stride,
467 mFb[i].bpp, mFb[i].bpp, mFb[i].pitch,
468468 mFb[i].handle, &mFb[i].id);
469469 if (ret) {
470470 LOGE("failed to add frame buffer");
570570 "size = %d\n"
571571 "width = %d\n"
572572 "height = %d\n"
573 "stride = %d\n"
573 "pitch = %d\n"
574574 "bpp = %d\n",
575575 mFb[0].id, mFb[1].id,
576576 mFb[0].name, mFb[1].name,
577577 mFb[0].handle, mFb[1].handle,
578578 mFb[0].size, mFb[0].width, mFb[0].height,
579 mFb[0].stride, mFb[0].bpp);
579 mFb[0].pitch, mFb[0].bpp);
580580
581581 mFlags = PAGE_FLIP;
582582 mIndex = 0;