Framebuffer in Android

Source: Internet
Author: User
Author:Li xianjing xianjimli@gmail.com Date:This article introduces the overall architecture of framebuffer for Android, which is illustrated in the following figures and clear. Article from http://www.limodev.cn/blog
Introduction

Framebuffer is not as intuitive as other guis in Android, and there are many abstract layers. In addition, Gui updates are implemented through opengles. Therefore, it is difficult to figure out the entire process of GUI update. A lecture has been prepared recently, so I spent some research. Here I will take some notes for your reference. The source code is based on the Qualcomm platform, these codes can be downloaded online.

Shows the related components of framebuffer:

  • Surfaceflinger is a service that is mainly used to synthesize the surface of each window and display it on framebuffer through opengles. Surfaceflinger itself is important and complex. I will write a special article later.
  • Displayhardware is an abstraction of display devices, including framebuffer and overlay. It loads the framebuffer and overlay plug-ins and initializes opengles:
    mNativeWindow = new FramebufferNativeWindow();    framebuffer_device_t const * fbDev = mNativeWindow->getDevice();    if (hw_get_module(OVERLAY_HARDWARE_MODULE_ID, &module) == 0) {       overlay_control_open(module, &mOverlayEngine);    }    surface = eglCreateWindowSurface(display, config, mNativeWindow.get(), NULL);    eglMakeCurrent(display, surface, surface, context);
  • Framebuffernativewindow is the abstraction of framebuffer. It loads libgralloc and opens the framebuffer device. Framebuffernativewindow does not directly use framebuffer, but creates two buffers by itself:

    1. Queuebuffer is used to display a buffer to the screen. It calls FB-> post to display the buffer.
    2. Dequeuebuffer gets an idle buffer, which is used to draw in the background.

These two functions are called by eglswapbuffers and adjusted:

egl_window_surface_v2_t::swapBuffers:    nativeWindow->queueBuffer(nativeWindow, buffer);    nativeWindow->dequeueBuffer(nativeWindow, &buffer);
  • Msm7k/liboverlay is implemented by Overlay. Unlike other platforms, overlay on Qualcomm does not provide a framebuffer device, but is implemented by fb0 IOCTL, IOCTL is divided into two types of operations:

Overlaycontrolchannel is used to set parameters, such as overlay location, width, and height:

bool OverlayControlChannel::setPosition(int x, int y, uint32_t w, uint32_t h) {    ov.dst_rect.x = x;    ov.dst_rect.y = y;    ov.dst_rect.w = w;    ov.dst_rect.h = h;    ioctl(mFD, MSMFB_OVERLAY_SET, &ov);}

Overlaydatachannel is used to display overlay. The most important function is queuebuffer:

bool OverlayDataChannel::queueBuffer(uint32_t offset) {mOvData.data.offset = offset;ioctl(mFD, MSMFB_OVERLAY_PLAY, odPtr))}
  • Msm7k/libgralloc is the abstraction of the display cache, including framebuffer and the buffer of the normal surface.

Framebuffer is only a/dev/graphic/fb0 package, while the surface buffer is a package for/dev/pmem, ashmem, and GPU memory (msm_hw3dm, its goal is to facilitate hardware acceleration. Because DMA transmission uses physical addresses, it requires that the physical addresses exist continuously.

  • Msm7k/libcopybit, a 2D acceleration Library, is mainly responsible for stretching, rotating, and merging surface operations. It can be implemented in two ways:

    1. Copybit. cpp: The implementation of IOCTL (msmfb_b133) based on fb0.
    2. Copybit_c2d.cpp: Based on the Implementation of kgsl, it only packs libc2d2. So. libc2d2. So should not be open-source.
  • Pmem
  1. Misc/pmem. C: physical memory management, algorithms, and user space interfaces.
  2. The board-msm7x27.c defines the default size of physical memory:
#define MSM_PMEM_MDP_SIZE   0x1B76000#define MSM_PMEM_ADSP_SIZE  0xB71000#define MSM_PMEM_AUDIO_SIZE 0x5B000#define MSM_FB_SIZE     0x177000#define MSM_GPU_PHYS_SIZE   SZ_2M#define PMEM_KERNEL_EBI1_SIZE   0x1C000

Msm_msm7x2x_allocate_memory_regions allocates several blocks of memory for secondary allocation to pmem.

  • Kgsl

Kernel graphics system layer (kgsl), 3D graphics acceleration driver, under the drivers/GPU/MSM directory of the source code, it is GPU packaging and Provides abstract interfaces to opengles 2.0.

  • Msm_hw3dm

I did not find the relevant code in the kernel.

  • Msm_fb

Msm_fb.c: user interfaces of framebuffer, overlay, and BLAY.

Mdp_dma.c: provides two framebuffer update Methods for packaging specific display devices:

Mdp_refresh_screen: Scheduled Update.

Mdp_dma_pan_update: actively updates data through pan display.

Mdp_dma_lcdc.c: Update framebuffer for LCD display devices.

Seealso
  1. Framebuffer in Android
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.