xref: /openbmc/qemu/hw/display/framebuffer.h (revision f793d97e454a56d17e404004867985622ca1a63b)
147b43a1fSPaolo Bonzini #ifndef QEMU_FRAMEBUFFER_H
247b43a1fSPaolo Bonzini #define QEMU_FRAMEBUFFER_H
347b43a1fSPaolo Bonzini 
447b43a1fSPaolo Bonzini #include "exec/memory.h"
547b43a1fSPaolo Bonzini 
647b43a1fSPaolo Bonzini /* Framebuffer device helper routines.  */
747b43a1fSPaolo Bonzini 
847b43a1fSPaolo Bonzini typedef void (*drawfn)(void *, uint8_t *, const uint8_t *, int, int);
947b43a1fSPaolo Bonzini 
10*c1076c3eSPaolo Bonzini /* framebuffer_update_memory_section: Update framebuffer
11*c1076c3eSPaolo Bonzini  * #MemoryRegionSection, for example if the framebuffer is switched to
12*c1076c3eSPaolo Bonzini  * a different memory area.
13*c1076c3eSPaolo Bonzini  *
14*c1076c3eSPaolo Bonzini  * @mem_section: Output #MemoryRegionSection, to be passed to
15*c1076c3eSPaolo Bonzini  * framebuffer_update_display().
16*c1076c3eSPaolo Bonzini  * @root: #MemoryRegion within which the framebuffer lies
17*c1076c3eSPaolo Bonzini  * @base: Base address of the framebuffer within @root.
18*c1076c3eSPaolo Bonzini  * @rows: Height of the screen.
19*c1076c3eSPaolo Bonzini  * @src_width: Number of bytes in framebuffer memory between two rows.
20*c1076c3eSPaolo Bonzini  */
21*c1076c3eSPaolo Bonzini void framebuffer_update_memory_section(
22*c1076c3eSPaolo Bonzini     MemoryRegionSection *mem_section,
23*c1076c3eSPaolo Bonzini     MemoryRegion *root,
24*c1076c3eSPaolo Bonzini     hwaddr base,
25*c1076c3eSPaolo Bonzini     unsigned rows,
26*c1076c3eSPaolo Bonzini     unsigned src_width);
27*c1076c3eSPaolo Bonzini 
28*c1076c3eSPaolo Bonzini /* framebuffer_update_display: Draw the framebuffer on a surface.
29*c1076c3eSPaolo Bonzini  *
30*c1076c3eSPaolo Bonzini  * @ds: #DisplaySurface to draw to.
31*c1076c3eSPaolo Bonzini  * @mem_section: #MemoryRegionSection provided by
32*c1076c3eSPaolo Bonzini  * framebuffer_update_memory_section().
33*c1076c3eSPaolo Bonzini  * @cols: Width the screen.
34*c1076c3eSPaolo Bonzini  * @rows: Height of the screen.
35*c1076c3eSPaolo Bonzini  * @src_width: Number of bytes in framebuffer memory between two rows.
36*c1076c3eSPaolo Bonzini  * @dest_row_pitch: Number of bytes in the surface data between two rows.
37*c1076c3eSPaolo Bonzini  * Negative if the framebuffer is stored in the opposite order (e.g.
38*c1076c3eSPaolo Bonzini  * bottom-to-top) compared to the framebuffer.
39*c1076c3eSPaolo Bonzini  * @dest_col_pitch: Number of bytes in the surface data between two pixels.
40*c1076c3eSPaolo Bonzini  * Negative if the framebuffer is stored in the opposite order (e.g.
41*c1076c3eSPaolo Bonzini  * right-to-left) compared to the framebuffer.
42*c1076c3eSPaolo Bonzini  * @invalidate: True if the function should redraw the whole screen
43*c1076c3eSPaolo Bonzini  * without checking the DIRTY_MEMORY_VGA dirty bitmap.
44*c1076c3eSPaolo Bonzini  * @fn: Drawing function to be called for each row that has to be drawn.
45*c1076c3eSPaolo Bonzini  * @opaque: Opaque pointer passed to @fn.
46*c1076c3eSPaolo Bonzini  * @first_row: Pointer to an integer, receives the number of the first row
47*c1076c3eSPaolo Bonzini  * that was drawn (either the first dirty row, or 0 if @invalidate is true).
48*c1076c3eSPaolo Bonzini  * @last_row: Pointer to an integer, receives the number of the last row that
49*c1076c3eSPaolo Bonzini  * was drawn (either the last dirty row, or @rows-1 if @invalidate is true).
50*c1076c3eSPaolo Bonzini  */
5147b43a1fSPaolo Bonzini void framebuffer_update_display(
5247b43a1fSPaolo Bonzini     DisplaySurface *ds,
53*c1076c3eSPaolo Bonzini     MemoryRegionSection *mem_section,
5447b43a1fSPaolo Bonzini     int cols,
5547b43a1fSPaolo Bonzini     int rows,
5647b43a1fSPaolo Bonzini     int src_width,
5747b43a1fSPaolo Bonzini     int dest_row_pitch,
5847b43a1fSPaolo Bonzini     int dest_col_pitch,
5947b43a1fSPaolo Bonzini     int invalidate,
6047b43a1fSPaolo Bonzini     drawfn fn,
6147b43a1fSPaolo Bonzini     void *opaque,
6247b43a1fSPaolo Bonzini     int *first_row,
6347b43a1fSPaolo Bonzini     int *last_row);
6447b43a1fSPaolo Bonzini 
6547b43a1fSPaolo Bonzini #endif
66