2 * Raspberry Pi emulation (c) 2012 Gregory Estrade
3 * Upstreaming code cleanup [including bcm2835_*] (c) 2013 Jan Petrous
5 * Rasperry Pi 2 emulation and refactoring Copyright (c) 2015, Microsoft
6 * Written by Andrew Baumann
8 * This work is licensed under the terms of the GNU GPL, version 2 or later.
9 * See the COPYING file in the top-level directory.
15 #include "hw/sysbus.h"
16 #include "ui/console.h"
17 #include "qom/object.h"
19 #define TYPE_BCM2835_FB "bcm2835-fb"
20 OBJECT_DECLARE_SIMPLE_TYPE(BCM2835FBState
, BCM2835_FB
)
23 * Configuration information about the fb which the guest can program
24 * via the mailbox property interface.
28 uint32_t xres_virtual
, yres_virtual
;
29 uint32_t xoffset
, yoffset
;
36 struct BCM2835FBState
{
41 uint32_t vcram_base
, vcram_size
;
45 MemoryRegionSection fbsection
;
49 bool lock
, invalidate
, pending
;
51 BCM2835FBConfig config
;
52 BCM2835FBConfig initial_config
;
55 void bcm2835_fb_reconfigure(BCM2835FBState
*s
, BCM2835FBConfig
*newconfig
);
58 * bcm2835_fb_get_pitch: return number of bytes per line of the framebuffer
59 * @config: configuration info for the framebuffer
61 * Return the number of bytes per line of the framebuffer, ie the number
62 * that must be added to a pixel address to get the address of the pixel
63 * directly below it on screen.
65 static inline uint32_t bcm2835_fb_get_pitch(BCM2835FBConfig
*config
)
67 uint32_t xres
= MAX(config
->xres
, config
->xres_virtual
);
68 return xres
* (config
->bpp
>> 3);
72 * bcm2835_fb_get_size: return total size of framebuffer in bytes
73 * @config: configuration info for the framebuffer
75 static inline uint32_t bcm2835_fb_get_size(BCM2835FBConfig
*config
)
77 uint32_t yres
= MAX(config
->yres
, config
->yres_virtual
);
78 return yres
* bcm2835_fb_get_pitch(config
);
82 * bcm2835_fb_validate_config: check provided config
84 * Validates the configuration information provided by the guest and
85 * adjusts it if necessary.
87 void bcm2835_fb_validate_config(BCM2835FBConfig
*config
);