Skip to content

Commit

Permalink
hw/display/bcm2835_fb: Reset resolution, etc correctly
Browse files Browse the repository at this point in the history
The bcm2835_fb's initial resolution and other parameters are set
via QOM properties. We should reset to those initial values on
device reset, which means we need to save the QOM property
values somewhere that they are not overwritten by guest
changes to the framebuffer configuration.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20180814144436.679-5-peter.maydell@linaro.org
  • Loading branch information
pm215 committed Aug 24, 2018
1 parent ea662f7 commit 9e2938a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
27 changes: 15 additions & 12 deletions hw/display/bcm2835_fb.c
Expand Up @@ -329,11 +329,7 @@ static void bcm2835_fb_reset(DeviceState *dev)

s->pending = false;

s->config.xres_virtual = s->config.xres;
s->config.yres_virtual = s->config.yres;
s->config.xoffset = 0;
s->config.yoffset = 0;
s->config.base = s->vcram_base + BCM2835_FB_OFFSET;
s->config = s->initial_config;

s->invalidate = true;
s->lock = false;
Expand All @@ -357,6 +353,13 @@ static void bcm2835_fb_realize(DeviceState *dev, Error **errp)
return;
}

/* Fill in the parts of initial_config that are not set by QOM properties */
s->initial_config.xres_virtual = s->initial_config.xres;
s->initial_config.yres_virtual = s->initial_config.yres;
s->initial_config.xoffset = 0;
s->initial_config.yoffset = 0;
s->initial_config.base = s->vcram_base + BCM2835_FB_OFFSET;

s->dma_mr = MEMORY_REGION(obj);
address_space_init(&s->dma_as, s->dma_mr, NULL);

Expand All @@ -370,13 +373,13 @@ static Property bcm2835_fb_props[] = {
DEFINE_PROP_UINT32("vcram-base", BCM2835FBState, vcram_base, 0),/*required*/
DEFINE_PROP_UINT32("vcram-size", BCM2835FBState, vcram_size,
DEFAULT_VCRAM_SIZE),
DEFINE_PROP_UINT32("xres", BCM2835FBState, config.xres, 640),
DEFINE_PROP_UINT32("yres", BCM2835FBState, config.yres, 480),
DEFINE_PROP_UINT32("bpp", BCM2835FBState, config.bpp, 16),
DEFINE_PROP_UINT32("pixo",
BCM2835FBState, config.pixo, 1), /* 1=RGB, 0=BGR */
DEFINE_PROP_UINT32("alpha",
BCM2835FBState, config.alpha, 2), /* alpha ignored */
DEFINE_PROP_UINT32("xres", BCM2835FBState, initial_config.xres, 640),
DEFINE_PROP_UINT32("yres", BCM2835FBState, initial_config.yres, 480),
DEFINE_PROP_UINT32("bpp", BCM2835FBState, initial_config.bpp, 16),
DEFINE_PROP_UINT32("pixo", BCM2835FBState,
initial_config.pixo, 1), /* 1=RGB, 0=BGR */
DEFINE_PROP_UINT32("alpha", BCM2835FBState,
initial_config.alpha, 2), /* alpha ignored */
DEFINE_PROP_END_OF_LIST()
};

Expand Down
1 change: 1 addition & 0 deletions include/hw/display/bcm2835_fb.h
Expand Up @@ -47,6 +47,7 @@ typedef struct {
bool lock, invalidate, pending;

BCM2835FBConfig config;
BCM2835FBConfig initial_config;
} BCM2835FBState;

void bcm2835_fb_reconfigure(BCM2835FBState *s, BCM2835FBConfig *newconfig);
Expand Down

0 comments on commit 9e2938a

Please sign in to comment.