blob: 9e7ac28862a17dbb3f873403a244187868bac701 [file] [log] [blame]
David 'Digit' Turnerf20bf5b2010-03-30 15:50:20 -07001Android Framebuffer emulation technical notes:
2==============================================
3
4This document tries to explain how framebuffer emulation works in the
5Android emulator.
6
71 - Hardware emulation (hw/goldfish_fb.c):
8------------------------------------------
9
10 The emulated hardware provides a bunch of i/o registers to allow
11 the following:
12
13 - let the kernel query the framebuffer's dimensions (both in pixels
14 and millimeters) (see goldfish_fb_read)
15
16 - let the kernel control the physical base address for the framebuffer
17 and the internal pixel rotation to apply before display (see
18 goldfish_fb_write).
19
20 The pixel buffer is itself a set of physical pages allocated by the
21 kernel driver in the emulated system. These pages are contiguous in
22 the emulated system, but not in the emulator's process space which
23 places them randomly in the heap.
24
25 Also, a function called goldfish_fb_update_display() is in charge of
26 checking the dirty bits of the framebuffer physical pages, in order to
27 compute the bounding rectangle of pixel updates since the last call, and
28 send them to the UI through qframebuffer_update(). More on this later.
29
30
312 - Framebuffer abstract interface (framebuffer.h):
32---------------------------------------------------
33
34 The Android-specific header 'framebuffer.h' is used to provide a generic
35 interface between framebuffer 'producers' and 'clients'. Essentially, each
36 QFrameBuffer object:
37
38 - holds a contiguous pixel buffer allocated by the emulator.
39 - can have one producer in charge of drawing into the pixel buffer
40 - can have zero or more clients, in charge of displaying the pixel
41 buffer to the final UI window (or remote VNC connection, whatever).
42
43 The emulator will periodically call 'qframebuffer_check_updates()' which
44 does the following:
45
46 foreach fb in framebuffers:
47 if fb.producer:
48 fb.producer.check_updates()
49 => in producer
50 foreach up in updates:
51 qframebuffer_update(fb, up.x, up.y, up.w, up.h)
52 =>
53 foreach cl in fb.clients:
54 cl.update(cl.opaque, up.x, up.y. up.w, up.h)
55
56 hw/goldfish_fb.c implements a producer
57 the QEmulator type in android/main.c implements a client.
58
59
603 - DisplayState (console.h):
61-----------------------------
62
63 The upstream QEMU sources use a DisplayState object to model the state
64 of each "display". This is not conceptually exactly the same thing than
65 a QFrameBuffer object as it can also be used to emulated text-based
66 displays instead of pixel framebuffers, and incorporates input state
67 as well.
68
69 See sdl_display_init() in android/main.c which is called from vl-android.c
70 on startup to initialize the display. This really registers a function,
71 sdl_refresh() (in android/main.c), that will get called every 1/60th of
72 a second to handle pending inputs.
73
74 sdl_refresh() also calls qframebuffer_check_updates(), ensuring that
75 any animation in the emulated framebuffer will be displayed at the same
76 frequency.
77
78 The refresh frequency is defined by the GUI_REFRESH_INTERVAL defined
79 at the top of console.h
80
81
824 - QEmulator object:
83---------------------
84
85 Currently defined and implemented in android/main.c (we may want to move
86 it to a different location). The QEmulator object bridges provides a
87 framebuffer client that uses the "generic" skin code under android/skin
88 to display the main UI window.