Indicate the source and author's contact information during reprinting.
Article Source: http://www.limodev.cn/blog
Author contact: Li xianjing <xianjimli@gmail.com>
Framebuffer
In Android, it is not as intuitive as in other guis, and there are many abstract layers. In addition, Gui updates are implemented through opengles. It is difficult to figure out the whole stream of GUI updates.
Cheng, I have prepared a lecture recently, so I spent some research. Here I will take some notes for your reference. The source code is based on the Qualcomm platform and can be downloaded online.
Framebuffer-related components
1. 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.
2. displayhardware is an abstraction of the display device, 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);
3. framebuffernativewindow is framebuffer
It loads libgralloc and opens the framebuffer device. Framebuffernativewindow is not directly used
Framebuffer, but creates two buffers:
Queuebuffer is used to display a buffer to the screen. It calls FB-> post to display the buffer.
Dequeuebuffer gets an idle buffer, which is used to draw in the background.
These two functions are called by eglswapbuffers and tuned
egl_window_surface_v2_t::swapBuffers: nativeWindow->queueBuffer(nativeWindow, buffer); nativeWindow->dequeueBuffer(nativeWindow, &buffer);
4. 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))}
5. msm7k/libgralloc
Is the cache abstraction, including the buffer of framebuffer and normal surface. Framebuffer is only a/dev/graphic/fb0 package.
Surface buffer is the encapsulation of/dev/pmem, ashmem, and GPU memory (msm_hw3dm). It aims to facilitate hardware acceleration because
The DMA transmission uses a physical address, which must exist consecutively in the physical address.
6. msm7k/libcopybit this is a 2D acceleration library, mainly responsible for stretching, rotating and merging surface operations. It can be implemented in two ways:
Copybit. cpp: The implementation of IOCTL (msmfb_b133) based on fb0.
Copybit_c2d.cpp: Based on the Implementation of kgsl, it only packs libc2d2. So. libc2d2. So should not be open-source.
7. pmem
Misc/pmem. C: physical memory management, algorithms, and user space interfaces.
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.
8. 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.
9. msm_hw3dm
I did not find the relevant code in the kernel.
10. 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.