mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'kraxel/pixman.v11' into staging
# By Gerd Hoffmann (22) and Igor Mitsyanko (2) # Via Gerd Hoffmann * kraxel/pixman.v11: (24 commits) qxl: register QemuConsole for secondary cards gtk: custom cursor support console: allow pinning displaychangelisteners to consoles console: add qemu_console_is_* xen: re-enable refresh interval reporting for xenfb console: gui timer fixes console: add GraphicHwOps console: make DisplayState private to console.c console: move gui_update+gui_setup_refresh from vl.c into console.c console: zap g_width + g_height console: simplify screendump console: give each QemuConsole its own DisplaySurface console: rename vga_hw_*, add QemuConsole param console: displaystate init revamp console: add trace events console: switch color_table_rgb to pixman_color_t console: use pixman for font rendering console: use pixman for fill+blit pixman: render vgafont glyphs into pixman images pixman: add qemu_pixman_color() ... Message-id: 1366105178-26744-1-git-send-email-kraxel@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
+6
-2
@@ -601,6 +601,11 @@ static const MemoryRegionOps musicpal_lcd_ops = {
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
};
|
||||
|
||||
static const GraphicHwOps musicpal_gfx_ops = {
|
||||
.invalidate = lcd_invalidate,
|
||||
.gfx_update = lcd_refresh,
|
||||
};
|
||||
|
||||
static int musicpal_lcd_init(SysBusDevice *dev)
|
||||
{
|
||||
musicpal_lcd_state *s = FROM_SYSBUS(musicpal_lcd_state, dev);
|
||||
@@ -611,8 +616,7 @@ static int musicpal_lcd_init(SysBusDevice *dev)
|
||||
"musicpal-lcd", MP_LCD_SIZE);
|
||||
sysbus_init_mmio(dev, &s->iomem);
|
||||
|
||||
s->con = graphic_console_init(lcd_refresh, lcd_invalidate,
|
||||
NULL, NULL, s);
|
||||
s->con = graphic_console_init(&musicpal_gfx_ops, s);
|
||||
qemu_console_resize(s->con, 128*3, 64*3);
|
||||
|
||||
qdev_init_gpio_in(&dev->qdev, musicpal_lcd_gpio_brigthness_in, 3);
|
||||
|
||||
+6
-15
@@ -933,18 +933,6 @@ static void blizzard_update_display(void *opaque)
|
||||
s->my[1] = 0;
|
||||
}
|
||||
|
||||
static void blizzard_screen_dump(void *opaque, const char *filename,
|
||||
bool cswitch, Error **errp)
|
||||
{
|
||||
BlizzardState *s = (BlizzardState *) opaque;
|
||||
DisplaySurface *surface = qemu_console_surface(s->con);
|
||||
|
||||
blizzard_update_display(opaque);
|
||||
if (s && surface_data(surface)) {
|
||||
ppm_save(filename, surface, errp);
|
||||
}
|
||||
}
|
||||
|
||||
#define DEPTH 8
|
||||
#include "blizzard_template.h"
|
||||
#define DEPTH 15
|
||||
@@ -956,6 +944,11 @@ static void blizzard_screen_dump(void *opaque, const char *filename,
|
||||
#define DEPTH 32
|
||||
#include "blizzard_template.h"
|
||||
|
||||
static const GraphicHwOps blizzard_ops = {
|
||||
.invalidate = blizzard_invalidate_display,
|
||||
.gfx_update = blizzard_update_display,
|
||||
};
|
||||
|
||||
void *s1d13745_init(qemu_irq gpio_int)
|
||||
{
|
||||
BlizzardState *s = (BlizzardState *) g_malloc0(sizeof(*s));
|
||||
@@ -963,9 +956,7 @@ void *s1d13745_init(qemu_irq gpio_int)
|
||||
|
||||
s->fb = g_malloc(0x180000);
|
||||
|
||||
s->con = graphic_console_init(blizzard_update_display,
|
||||
blizzard_invalidate_display,
|
||||
blizzard_screen_dump, NULL, s);
|
||||
s->con = graphic_console_init(&blizzard_ops, s);
|
||||
surface = qemu_console_surface(s->con);
|
||||
|
||||
switch (surface_bits_per_pixel(surface)) {
|
||||
|
||||
@@ -720,7 +720,7 @@ static void cirrus_do_copy(CirrusVGAState *s, int dst, int src, int w, int h)
|
||||
/* we have to flush all pending changes so that the copy
|
||||
is generated at the appropriate moment in time */
|
||||
if (notify)
|
||||
vga_hw_update();
|
||||
graphic_hw_update(s->vga.con);
|
||||
|
||||
(*s->cirrus_rop) (s, s->vga.vram_ptr +
|
||||
(s->cirrus_blt_dstaddr & s->cirrus_addr_mask),
|
||||
@@ -2910,9 +2910,7 @@ static int vga_initfn(ISADevice *dev)
|
||||
vga_common_init(s);
|
||||
cirrus_init_common(&d->cirrus_vga, CIRRUS_ID_CLGD5430, 0,
|
||||
isa_address_space(dev), isa_address_space_io(dev));
|
||||
s->con = graphic_console_init(s->update, s->invalidate,
|
||||
s->screen_dump, s->text_update,
|
||||
s);
|
||||
s->con = graphic_console_init(s->hw_ops, s);
|
||||
rom_add_vga(VGABIOS_CIRRUS_FILENAME);
|
||||
/* XXX ISA-LFB support */
|
||||
/* FIXME not qdev yet */
|
||||
@@ -2959,9 +2957,7 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
|
||||
vga_common_init(&s->vga);
|
||||
cirrus_init_common(s, device_id, 1, pci_address_space(dev),
|
||||
pci_address_space_io(dev));
|
||||
s->vga.con = graphic_console_init(s->vga.update, s->vga.invalidate,
|
||||
s->vga.screen_dump, s->vga.text_update,
|
||||
&s->vga);
|
||||
s->vga.con = graphic_console_init(s->vga.hw_ops, &s->vga);
|
||||
|
||||
/* setup PCI */
|
||||
|
||||
|
||||
@@ -1242,7 +1242,7 @@ static void exynos4210_update_resolution(Exynos4210fimdState *s)
|
||||
static void exynos4210_fimd_update(void *opaque)
|
||||
{
|
||||
Exynos4210fimdState *s = (Exynos4210fimdState *)opaque;
|
||||
DisplaySurface *surface = qemu_console_surface(s->console);
|
||||
DisplaySurface *surface;
|
||||
Exynos4210fimdWindow *w;
|
||||
int i, line;
|
||||
hwaddr fb_line_addr, inc_size;
|
||||
@@ -1255,11 +1255,12 @@ static void exynos4210_fimd_update(void *opaque)
|
||||
const int global_height = ((s->vidtcon[2] >> FIMD_VIDTCON2_VER_SHIFT) &
|
||||
FIMD_VIDTCON2_SIZE_MASK) + 1;
|
||||
|
||||
if (!s || !s->console || !surface_bits_per_pixel(surface) ||
|
||||
!s->enabled) {
|
||||
if (!s || !s->console || !s->enabled ||
|
||||
surface_bits_per_pixel(qemu_console_surface(s->console)) == 0) {
|
||||
return;
|
||||
}
|
||||
exynos4210_update_resolution(s);
|
||||
surface = qemu_console_surface(s->console);
|
||||
|
||||
for (i = 0; i < NUM_OF_WINDOWS; i++) {
|
||||
w = &s->window[i];
|
||||
@@ -1886,6 +1887,11 @@ static const VMStateDescription exynos4210_fimd_vmstate = {
|
||||
}
|
||||
};
|
||||
|
||||
static const GraphicHwOps exynos4210_fimd_ops = {
|
||||
.invalidate = exynos4210_fimd_invalidate,
|
||||
.gfx_update = exynos4210_fimd_update,
|
||||
};
|
||||
|
||||
static int exynos4210_fimd_init(SysBusDevice *dev)
|
||||
{
|
||||
Exynos4210fimdState *s = FROM_SYSBUS(Exynos4210fimdState, dev);
|
||||
@@ -1899,8 +1905,7 @@ static int exynos4210_fimd_init(SysBusDevice *dev)
|
||||
memory_region_init_io(&s->iomem, &exynos4210_fimd_mmio_ops, s,
|
||||
"exynos4210.fimd", FIMD_REGS_SIZE);
|
||||
sysbus_init_mmio(dev, &s->iomem);
|
||||
s->console = graphic_console_init(exynos4210_fimd_update,
|
||||
exynos4210_fimd_invalidate, NULL, NULL, s);
|
||||
s->console = graphic_console_init(&exynos4210_fimd_ops, s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+6
-74
@@ -294,77 +294,6 @@ static void g364fb_reset(G364State *s)
|
||||
g364fb_invalidate_display(s);
|
||||
}
|
||||
|
||||
static void g364fb_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp)
|
||||
{
|
||||
G364State *s = opaque;
|
||||
int ret, y, x;
|
||||
uint8_t index;
|
||||
uint8_t *data_buffer;
|
||||
FILE *f;
|
||||
|
||||
qemu_flush_coalesced_mmio_buffer();
|
||||
|
||||
if (s->depth != 8) {
|
||||
error_setg(errp, "g364: unknown guest depth %d", s->depth);
|
||||
return;
|
||||
}
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
error_setg(errp, "failed to open file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->ctla & CTLA_FORCE_BLANK) {
|
||||
/* blank screen */
|
||||
ret = fprintf(f, "P4\n%d %d\n", s->width, s->height);
|
||||
if (ret < 0) {
|
||||
goto write_err;
|
||||
}
|
||||
for (y = 0; y < s->height; y++)
|
||||
for (x = 0; x < s->width; x++) {
|
||||
ret = fputc(0, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data_buffer = s->vram + s->top_of_screen;
|
||||
ret = fprintf(f, "P6\n%d %d\n%d\n", s->width, s->height, 255);
|
||||
if (ret < 0) {
|
||||
goto write_err;
|
||||
}
|
||||
for (y = 0; y < s->height; y++)
|
||||
for (x = 0; x < s->width; x++, data_buffer++) {
|
||||
index = *data_buffer;
|
||||
ret = fputc(s->color_palette[index][0], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc(s->color_palette[index][1], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc(s->color_palette[index][2], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
fclose(f);
|
||||
return;
|
||||
|
||||
write_err:
|
||||
error_setg(errp, "failed to write to file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
unlink(filename);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* called for accesses to io ports */
|
||||
static uint64_t g364fb_ctrl_read(void *opaque,
|
||||
hwaddr addr,
|
||||
@@ -546,13 +475,16 @@ static const VMStateDescription vmstate_g364fb = {
|
||||
}
|
||||
};
|
||||
|
||||
static const GraphicHwOps g364fb_ops = {
|
||||
.invalidate = g364fb_invalidate_display,
|
||||
.gfx_update = g364fb_update_display,
|
||||
};
|
||||
|
||||
static void g364fb_init(DeviceState *dev, G364State *s)
|
||||
{
|
||||
s->vram = g_malloc0(s->vram_size);
|
||||
|
||||
s->con = graphic_console_init(g364fb_update_display,
|
||||
g364fb_invalidate_display,
|
||||
g364fb_screen_dump, NULL, s);
|
||||
s->con = graphic_console_init(&g364fb_ops, s);
|
||||
|
||||
memory_region_init_io(&s->mem_ctrl, &g364fb_ctrl_ops, s, "ctrl", 0x180000);
|
||||
memory_region_init_ram_ptr(&s->mem_vram, "vram",
|
||||
|
||||
@@ -254,6 +254,12 @@ static const VMStateDescription vmstate_jazz_led = {
|
||||
}
|
||||
};
|
||||
|
||||
static const GraphicHwOps jazz_led_ops = {
|
||||
.invalidate = jazz_led_invalidate_display,
|
||||
.gfx_update = jazz_led_update_display,
|
||||
.text_update = jazz_led_text_update,
|
||||
};
|
||||
|
||||
static int jazz_led_init(SysBusDevice *dev)
|
||||
{
|
||||
LedState *s = FROM_SYSBUS(LedState, dev);
|
||||
@@ -261,10 +267,7 @@ static int jazz_led_init(SysBusDevice *dev)
|
||||
memory_region_init_io(&s->iomem, &led_ops, s, "led", 1);
|
||||
sysbus_init_mmio(dev, &s->iomem);
|
||||
|
||||
s->con = graphic_console_init(jazz_led_update_display,
|
||||
jazz_led_invalidate_display,
|
||||
NULL,
|
||||
jazz_led_text_update, s);
|
||||
s->con = graphic_console_init(&jazz_led_ops, s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -270,6 +270,11 @@ static void milkymist_vgafb_reset(DeviceState *d)
|
||||
s->regs[R_BASEADDRESS] = 0;
|
||||
}
|
||||
|
||||
static const GraphicHwOps vgafb_ops = {
|
||||
.invalidate = vgafb_invalidate_display,
|
||||
.gfx_update = vgafb_update_display,
|
||||
};
|
||||
|
||||
static int milkymist_vgafb_init(SysBusDevice *dev)
|
||||
{
|
||||
MilkymistVgafbState *s = FROM_SYSBUS(typeof(*s), dev);
|
||||
@@ -278,9 +283,7 @@ static int milkymist_vgafb_init(SysBusDevice *dev)
|
||||
"milkymist-vgafb", R_MAX * 4);
|
||||
sysbus_init_mmio(dev, &s->regs_region);
|
||||
|
||||
s->con = graphic_console_init(vgafb_update_display,
|
||||
vgafb_invalidate_display,
|
||||
NULL, NULL, s);
|
||||
s->con = graphic_console_init(&vgafb_ops, s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+6
-87
@@ -227,90 +227,6 @@ static void omap_update_display(void *opaque)
|
||||
omap_lcd->invalidate = 0;
|
||||
}
|
||||
|
||||
static void omap_ppm_save(const char *filename, uint8_t *data,
|
||||
int w, int h, int linesize, Error **errp)
|
||||
{
|
||||
FILE *f;
|
||||
uint8_t *d, *d1;
|
||||
unsigned int v;
|
||||
int ret, y, x, bpp;
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
error_setg(errp, "failed to open file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
ret = fprintf(f, "P6\n%d %d\n%d\n", w, h, 255);
|
||||
if (ret < 0) {
|
||||
goto write_err;
|
||||
}
|
||||
d1 = data;
|
||||
bpp = linesize / w;
|
||||
for (y = 0; y < h; y ++) {
|
||||
d = d1;
|
||||
for (x = 0; x < w; x ++) {
|
||||
v = *(uint32_t *) d;
|
||||
switch (bpp) {
|
||||
case 2:
|
||||
ret = fputc((v >> 8) & 0xf8, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v >> 3) & 0xfc, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v << 3) & 0xf8, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
default:
|
||||
ret = fputc((v >> 16) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v >> 8) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((v) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
break;
|
||||
}
|
||||
d += bpp;
|
||||
}
|
||||
d1 += linesize;
|
||||
}
|
||||
out:
|
||||
fclose(f);
|
||||
return;
|
||||
|
||||
write_err:
|
||||
error_setg(errp, "failed to write to file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
unlink(filename);
|
||||
goto out;
|
||||
}
|
||||
|
||||
static void omap_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp)
|
||||
{
|
||||
struct omap_lcd_panel_s *omap_lcd = opaque;
|
||||
DisplaySurface *surface = qemu_console_surface(omap_lcd->con);
|
||||
|
||||
omap_update_display(opaque);
|
||||
if (omap_lcd && surface_data(surface))
|
||||
omap_ppm_save(filename, surface_data(surface),
|
||||
omap_lcd->width, omap_lcd->height,
|
||||
surface_stride(surface), errp);
|
||||
}
|
||||
|
||||
static void omap_invalidate_display(void *opaque) {
|
||||
struct omap_lcd_panel_s *omap_lcd = opaque;
|
||||
omap_lcd->invalidate = 1;
|
||||
@@ -468,6 +384,11 @@ void omap_lcdc_reset(struct omap_lcd_panel_s *s)
|
||||
s->ctrl = 0;
|
||||
}
|
||||
|
||||
static const GraphicHwOps omap_ops = {
|
||||
.invalidate = omap_invalidate_display,
|
||||
.gfx_update = omap_update_display,
|
||||
};
|
||||
|
||||
struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem,
|
||||
hwaddr base,
|
||||
qemu_irq irq,
|
||||
@@ -485,9 +406,7 @@ struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *sysmem,
|
||||
memory_region_init_io(&s->iomem, &omap_lcdc_ops, s, "omap.lcdc", 0x100);
|
||||
memory_region_add_subregion(sysmem, base, &s->iomem);
|
||||
|
||||
s->con = graphic_console_init(omap_update_display,
|
||||
omap_invalidate_display,
|
||||
omap_screen_dump, NULL, s);
|
||||
s->con = graphic_console_init(&omap_ops, s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
+6
-3
@@ -444,6 +444,11 @@ static int vmstate_pl110_post_load(void *opaque, int version_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const GraphicHwOps pl110_gfx_ops = {
|
||||
.invalidate = pl110_invalidate_display,
|
||||
.gfx_update = pl110_update_display,
|
||||
};
|
||||
|
||||
static int pl110_init(SysBusDevice *dev)
|
||||
{
|
||||
pl110_state *s = FROM_SYSBUS(pl110_state, dev);
|
||||
@@ -452,9 +457,7 @@ static int pl110_init(SysBusDevice *dev)
|
||||
sysbus_init_mmio(dev, &s->iomem);
|
||||
sysbus_init_irq(dev, &s->irq);
|
||||
qdev_init_gpio_in(&s->busdev.qdev, pl110_mux_ctrl_set, 1);
|
||||
s->con = graphic_console_init(pl110_update_display,
|
||||
pl110_invalidate_display,
|
||||
NULL, NULL, s);
|
||||
s->con = graphic_console_init(&pl110_gfx_ops, s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -991,6 +991,11 @@ static const VMStateDescription vmstate_pxa2xx_lcdc = {
|
||||
#define BITS 32
|
||||
#include "pxa2xx_template.h"
|
||||
|
||||
static const GraphicHwOps pxa2xx_ops = {
|
||||
.invalidate = pxa2xx_invalidate_display,
|
||||
.gfx_update = pxa2xx_update_display,
|
||||
};
|
||||
|
||||
PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
|
||||
hwaddr base, qemu_irq irq)
|
||||
{
|
||||
@@ -1008,9 +1013,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
|
||||
"pxa2xx-lcd-controller", 0x00100000);
|
||||
memory_region_add_subregion(sysmem, base, &s->iomem);
|
||||
|
||||
s->con = graphic_console_init(pxa2xx_update_display,
|
||||
pxa2xx_invalidate_display,
|
||||
NULL, NULL, s);
|
||||
s->con = graphic_console_init(&pxa2xx_ops, s);
|
||||
surface = qemu_console_surface(s->con);
|
||||
|
||||
switch (surface_bits_per_pixel(surface)) {
|
||||
|
||||
+15
-27
@@ -1074,7 +1074,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
|
||||
qemu_spice_create_host_primary(&d->ssd);
|
||||
d->mode = QXL_MODE_VGA;
|
||||
vga_dirty_log_start(&d->vga);
|
||||
vga_hw_update();
|
||||
graphic_hw_update(d->vga.con);
|
||||
}
|
||||
|
||||
static void qxl_exit_vga_mode(PCIQXLDevice *d)
|
||||
@@ -1753,7 +1753,7 @@ static void qxl_hw_update(void *opaque)
|
||||
|
||||
switch (qxl->mode) {
|
||||
case QXL_MODE_VGA:
|
||||
vga->update(vga);
|
||||
vga->hw_ops->gfx_update(vga);
|
||||
break;
|
||||
case QXL_MODE_COMPAT:
|
||||
case QXL_MODE_NATIVE:
|
||||
@@ -1769,26 +1769,9 @@ static void qxl_hw_invalidate(void *opaque)
|
||||
PCIQXLDevice *qxl = opaque;
|
||||
VGACommonState *vga = &qxl->vga;
|
||||
|
||||
vga->invalidate(vga);
|
||||
}
|
||||
|
||||
static void qxl_hw_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp)
|
||||
{
|
||||
PCIQXLDevice *qxl = opaque;
|
||||
VGACommonState *vga = &qxl->vga;
|
||||
|
||||
switch (qxl->mode) {
|
||||
case QXL_MODE_COMPAT:
|
||||
case QXL_MODE_NATIVE:
|
||||
qxl_render_update(qxl);
|
||||
ppm_save(filename, qxl->ssd.ds, errp);
|
||||
break;
|
||||
case QXL_MODE_VGA:
|
||||
vga->screen_dump(vga, filename, cswitch, errp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (qxl->mode == QXL_MODE_VGA) {
|
||||
vga->hw_ops->invalidate(vga);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1798,7 +1781,7 @@ static void qxl_hw_text_update(void *opaque, console_ch_t *chardata)
|
||||
VGACommonState *vga = &qxl->vga;
|
||||
|
||||
if (qxl->mode == QXL_MODE_VGA) {
|
||||
vga->text_update(vga, chardata);
|
||||
vga->hw_ops->text_update(vga, chardata);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2058,6 +2041,12 @@ static int qxl_init_common(PCIQXLDevice *qxl)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const GraphicHwOps qxl_ops = {
|
||||
.invalidate = qxl_hw_invalidate,
|
||||
.gfx_update = qxl_hw_update,
|
||||
.text_update = qxl_hw_text_update,
|
||||
};
|
||||
|
||||
static int qxl_init_primary(PCIDevice *dev)
|
||||
{
|
||||
PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
|
||||
@@ -2074,10 +2063,7 @@ static int qxl_init_primary(PCIDevice *dev)
|
||||
portio_list_init(qxl_vga_port_list, qxl_vga_portio_list, vga, "vga");
|
||||
portio_list_add(qxl_vga_port_list, pci_address_space_io(dev), 0x3b0);
|
||||
|
||||
vga->con = graphic_console_init(qxl_hw_update, qxl_hw_invalidate,
|
||||
qxl_hw_screen_dump, qxl_hw_text_update,
|
||||
qxl);
|
||||
qxl->ssd.con = vga->con,
|
||||
vga->con = graphic_console_init(&qxl_ops, qxl);
|
||||
qemu_spice_display_init_common(&qxl->ssd);
|
||||
|
||||
rc = qxl_init_common(qxl);
|
||||
@@ -2086,6 +2072,7 @@ static int qxl_init_primary(PCIDevice *dev)
|
||||
}
|
||||
|
||||
qxl->ssd.dcl.ops = &display_listener_ops;
|
||||
qxl->ssd.dcl.con = vga->con;
|
||||
ds = qemu_console_displaystate(vga->con);
|
||||
register_displaychangelistener(ds, &qxl->ssd.dcl);
|
||||
return rc;
|
||||
@@ -2101,6 +2088,7 @@ static int qxl_init_secondary(PCIDevice *dev)
|
||||
memory_region_init_ram(&qxl->vga.vram, "qxl.vgavram", qxl->vga.vram_size);
|
||||
vmstate_register_ram(&qxl->vga.vram, &qxl->pci.qdev);
|
||||
qxl->vga.vram_ptr = memory_region_get_ram_ptr(&qxl->vga.vram);
|
||||
qxl->vga.con = graphic_console_init(&qxl_ops, qxl);
|
||||
|
||||
return qxl_init_common(qxl);
|
||||
}
|
||||
|
||||
+5
-2
@@ -1383,6 +1383,10 @@ static void sm501_update_display(void *opaque)
|
||||
sm501_draw_crt(s);
|
||||
}
|
||||
|
||||
static const GraphicHwOps sm501_ops = {
|
||||
.gfx_update = sm501_update_display,
|
||||
};
|
||||
|
||||
void sm501_init(MemoryRegion *address_space_mem, uint32_t base,
|
||||
uint32_t local_mem_bytes, qemu_irq irq, CharDriverState *chr)
|
||||
{
|
||||
@@ -1445,6 +1449,5 @@ void sm501_init(MemoryRegion *address_space_mem, uint32_t base,
|
||||
}
|
||||
|
||||
/* create qemu graphic console */
|
||||
s->con = graphic_console_init(sm501_update_display, NULL,
|
||||
NULL, NULL, s);
|
||||
s->con = graphic_console_init(&sm501_ops, s);
|
||||
}
|
||||
|
||||
@@ -284,13 +284,16 @@ static const VMStateDescription vmstate_ssd0303 = {
|
||||
}
|
||||
};
|
||||
|
||||
static const GraphicHwOps ssd0303_ops = {
|
||||
.invalidate = ssd0303_invalidate_display,
|
||||
.gfx_update = ssd0303_update_display,
|
||||
};
|
||||
|
||||
static int ssd0303_init(I2CSlave *i2c)
|
||||
{
|
||||
ssd0303_state *s = FROM_I2C_SLAVE(ssd0303_state, i2c);
|
||||
|
||||
s->con = graphic_console_init(ssd0303_update_display,
|
||||
ssd0303_invalidate_display,
|
||||
NULL, NULL, s);
|
||||
s->con = graphic_console_init(&ssd0303_ops, s);
|
||||
qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -331,15 +331,18 @@ static int ssd0323_load(QEMUFile *f, void *opaque, int version_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const GraphicHwOps ssd0323_ops = {
|
||||
.invalidate = ssd0323_invalidate_display,
|
||||
.gfx_update = ssd0323_update_display,
|
||||
};
|
||||
|
||||
static int ssd0323_init(SSISlave *dev)
|
||||
{
|
||||
ssd0323_state *s = FROM_SSI_SLAVE(ssd0323_state, dev);
|
||||
|
||||
s->col_end = 63;
|
||||
s->row_end = 79;
|
||||
s->con = graphic_console_init(ssd0323_update_display,
|
||||
ssd0323_invalidate_display,
|
||||
NULL, NULL, s);
|
||||
s->con = graphic_console_init(&ssd0323_ops, s);
|
||||
qemu_console_resize(s->con, 128 * MAGNIFY, 64 * MAGNIFY);
|
||||
|
||||
qdev_init_gpio_in(&dev->qdev, ssd0323_cd, 1);
|
||||
|
||||
@@ -548,6 +548,10 @@ static void tc6393xb_writeb(void *opaque, hwaddr addr,
|
||||
(uint32_t) addr, (int)value & 0xff);
|
||||
}
|
||||
|
||||
static const GraphicHwOps tc6393xb_gfx_ops = {
|
||||
.gfx_update = tc6393xb_update_display,
|
||||
};
|
||||
|
||||
TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)
|
||||
{
|
||||
TC6393xbState *s;
|
||||
@@ -583,11 +587,7 @@ TC6393xbState *tc6393xb_init(MemoryRegion *sysmem, uint32_t base, qemu_irq irq)
|
||||
memory_region_add_subregion(sysmem, base + 0x100000, &s->vram);
|
||||
s->scr_width = 480;
|
||||
s->scr_height = 640;
|
||||
s->con = graphic_console_init(tc6393xb_update_display,
|
||||
NULL, /* invalidate */
|
||||
NULL, /* screen_dump */
|
||||
NULL, /* text_update */
|
||||
s);
|
||||
s->con = graphic_console_init(&tc6393xb_gfx_ops, s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
+12
-131
@@ -56,11 +56,6 @@ typedef struct TCXState {
|
||||
uint8_t dac_index, dac_state;
|
||||
} TCXState;
|
||||
|
||||
static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp);
|
||||
static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp);
|
||||
|
||||
static void tcx_set_dirty(TCXState *s)
|
||||
{
|
||||
memory_region_set_dirty(&s->vram_mem, 0, MAXX * MAXY);
|
||||
@@ -515,6 +510,16 @@ static const MemoryRegionOps dummy_ops = {
|
||||
},
|
||||
};
|
||||
|
||||
static const GraphicHwOps tcx_ops = {
|
||||
.invalidate = tcx_invalidate_display,
|
||||
.gfx_update = tcx_update_display,
|
||||
};
|
||||
|
||||
static const GraphicHwOps tcx24_ops = {
|
||||
.invalidate = tcx24_invalidate_display,
|
||||
.gfx_update = tcx24_update_display,
|
||||
};
|
||||
|
||||
static int tcx_init1(SysBusDevice *dev)
|
||||
{
|
||||
TCXState *s = FROM_SYSBUS(TCXState, dev);
|
||||
@@ -567,144 +572,20 @@ static int tcx_init1(SysBusDevice *dev)
|
||||
&s->vram_mem, vram_offset, size);
|
||||
sysbus_init_mmio(dev, &s->vram_cplane);
|
||||
|
||||
s->con = graphic_console_init(tcx24_update_display,
|
||||
tcx24_invalidate_display,
|
||||
tcx24_screen_dump, NULL, s);
|
||||
s->con = graphic_console_init(&tcx24_ops, s);
|
||||
} else {
|
||||
/* THC 8 bit (dummy) */
|
||||
memory_region_init_io(&s->thc8, &dummy_ops, s, "tcx.thc8",
|
||||
TCX_THC_NREGS_8);
|
||||
sysbus_init_mmio(dev, &s->thc8);
|
||||
|
||||
s->con = graphic_console_init(tcx_update_display,
|
||||
tcx_invalidate_display,
|
||||
tcx_screen_dump, NULL, s);
|
||||
s->con = graphic_console_init(&tcx_ops, s);
|
||||
}
|
||||
|
||||
qemu_console_resize(s->con, s->width, s->height);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tcx_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp)
|
||||
{
|
||||
TCXState *s = opaque;
|
||||
FILE *f;
|
||||
uint8_t *d, *d1, v;
|
||||
int ret, y, x;
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
error_setg(errp, "failed to open file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
ret = fprintf(f, "P6\n%d %d\n%d\n", s->width, s->height, 255);
|
||||
if (ret < 0) {
|
||||
goto write_err;
|
||||
}
|
||||
d1 = s->vram;
|
||||
for(y = 0; y < s->height; y++) {
|
||||
d = d1;
|
||||
for(x = 0; x < s->width; x++) {
|
||||
v = *d;
|
||||
ret = fputc(s->r[v], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc(s->g[v], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc(s->b[v], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
d++;
|
||||
}
|
||||
d1 += MAXX;
|
||||
}
|
||||
|
||||
out:
|
||||
fclose(f);
|
||||
return;
|
||||
|
||||
write_err:
|
||||
error_setg(errp, "failed to write to file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
unlink(filename);
|
||||
goto out;
|
||||
}
|
||||
|
||||
static void tcx24_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp)
|
||||
{
|
||||
TCXState *s = opaque;
|
||||
FILE *f;
|
||||
uint8_t *d, *d1, v;
|
||||
uint32_t *s24, *cptr, dval;
|
||||
int ret, y, x;
|
||||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
error_setg(errp, "failed to open file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
ret = fprintf(f, "P6\n%d %d\n%d\n", s->width, s->height, 255);
|
||||
if (ret < 0) {
|
||||
goto write_err;
|
||||
}
|
||||
d1 = s->vram;
|
||||
s24 = s->vram24;
|
||||
cptr = s->cplane;
|
||||
for(y = 0; y < s->height; y++) {
|
||||
d = d1;
|
||||
for(x = 0; x < s->width; x++, d++, s24++) {
|
||||
if ((*cptr++ & 0xff000000) == 0x03000000) { // 24-bit direct
|
||||
dval = *s24 & 0x00ffffff;
|
||||
ret = fputc((dval >> 16) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc((dval >> 8) & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc(dval & 0xff, f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
} else {
|
||||
v = *d;
|
||||
ret = fputc(s->r[v], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc(s->g[v], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
ret = fputc(s->b[v], f);
|
||||
if (ret == EOF) {
|
||||
goto write_err;
|
||||
}
|
||||
}
|
||||
}
|
||||
d1 += MAXX;
|
||||
}
|
||||
|
||||
out:
|
||||
fclose(f);
|
||||
return;
|
||||
|
||||
write_err:
|
||||
error_setg(errp, "failed to write to file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
unlink(filename);
|
||||
goto out;
|
||||
}
|
||||
|
||||
static Property tcx_properties[] = {
|
||||
DEFINE_PROP_HEX32("vram_size", TCXState, vram_size, -1),
|
||||
DEFINE_PROP_UINT16("width", TCXState, width, -1),
|
||||
|
||||
@@ -135,9 +135,7 @@ int isa_vga_mm_init(hwaddr vram_base,
|
||||
vga_common_init(&s->vga);
|
||||
vga_mm_init(s, vram_base, ctrl_base, it_shift, address_space);
|
||||
|
||||
s->vga.con = graphic_console_init(s->vga.update, s->vga.invalidate,
|
||||
s->vga.screen_dump, s->vga.text_update,
|
||||
s);
|
||||
s->vga.con = graphic_console_init(s->vga.hw_ops, s);
|
||||
|
||||
vga_init_vbe(&s->vga, address_space);
|
||||
return 0;
|
||||
|
||||
@@ -62,8 +62,7 @@ static int vga_initfn(ISADevice *dev)
|
||||
isa_mem_base + 0x000a0000,
|
||||
vga_io_memory, 1);
|
||||
memory_region_set_coalescing(vga_io_memory);
|
||||
s->con = graphic_console_init(s->update, s->invalidate,
|
||||
s->screen_dump, s->text_update, s);
|
||||
s->con = graphic_console_init(s->hw_ops, s);
|
||||
|
||||
vga_init_vbe(s, isa_address_space(dev));
|
||||
/* ROM BIOS */
|
||||
|
||||
@@ -150,8 +150,7 @@ static int pci_std_vga_initfn(PCIDevice *dev)
|
||||
vga_common_init(s);
|
||||
vga_init(s, pci_address_space(dev), pci_address_space_io(dev), true);
|
||||
|
||||
s->con = graphic_console_init(s->update, s->invalidate,
|
||||
s->screen_dump, s->text_update, s);
|
||||
s->con = graphic_console_init(s->hw_ops, s);
|
||||
|
||||
/* XXX: VGA_RAM_SIZE must be a power of two */
|
||||
pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram);
|
||||
|
||||
+7
-69
@@ -166,9 +166,6 @@ static uint32_t expand4[256];
|
||||
static uint16_t expand2[256];
|
||||
static uint8_t expand4to8[16];
|
||||
|
||||
static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp);
|
||||
|
||||
static void vga_update_memory_access(VGACommonState *s)
|
||||
{
|
||||
MemoryRegion *region, *old_region = s->chain4_alias;
|
||||
@@ -2253,6 +2250,12 @@ const VMStateDescription vmstate_vga_common = {
|
||||
}
|
||||
};
|
||||
|
||||
static const GraphicHwOps vga_ops = {
|
||||
.invalidate = vga_invalidate_display,
|
||||
.gfx_update = vga_update_display,
|
||||
.text_update = vga_update_text,
|
||||
};
|
||||
|
||||
void vga_common_init(VGACommonState *s)
|
||||
{
|
||||
int i, j, v, b;
|
||||
@@ -2296,10 +2299,7 @@ void vga_common_init(VGACommonState *s)
|
||||
s->get_bpp = vga_get_bpp;
|
||||
s->get_offsets = vga_get_offsets;
|
||||
s->get_resolution = vga_get_resolution;
|
||||
s->update = vga_update_display;
|
||||
s->invalidate = vga_invalidate_display;
|
||||
s->screen_dump = vga_screen_dump;
|
||||
s->text_update = vga_update_text;
|
||||
s->hw_ops = &vga_ops;
|
||||
switch (vga_retrace_method) {
|
||||
case VGA_RETRACE_DUMB:
|
||||
s->retrace = vga_dumb_retrace;
|
||||
@@ -2393,65 +2393,3 @@ void vga_init_vbe(VGACommonState *s, MemoryRegion *system_memory)
|
||||
&s->vram_vbe);
|
||||
s->vbe_mapped = 1;
|
||||
}
|
||||
/********************************************************/
|
||||
/* vga screen dump */
|
||||
|
||||
void ppm_save(const char *filename, struct DisplaySurface *ds, Error **errp)
|
||||
{
|
||||
int width = pixman_image_get_width(ds->image);
|
||||
int height = pixman_image_get_height(ds->image);
|
||||
FILE *f;
|
||||
int y;
|
||||
int ret;
|
||||
pixman_image_t *linebuf;
|
||||
|
||||
trace_ppm_save(filename, ds);
|
||||
f = fopen(filename, "wb");
|
||||
if (!f) {
|
||||
error_setg(errp, "failed to open file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
ret = fprintf(f, "P6\n%d %d\n%d\n", width, height, 255);
|
||||
if (ret < 0) {
|
||||
linebuf = NULL;
|
||||
goto write_err;
|
||||
}
|
||||
linebuf = qemu_pixman_linebuf_create(PIXMAN_BE_r8g8b8, width);
|
||||
for (y = 0; y < height; y++) {
|
||||
qemu_pixman_linebuf_fill(linebuf, ds->image, width, 0, y);
|
||||
clearerr(f);
|
||||
ret = fwrite(pixman_image_get_data(linebuf), 1,
|
||||
pixman_image_get_stride(linebuf), f);
|
||||
(void)ret;
|
||||
if (ferror(f)) {
|
||||
goto write_err;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
qemu_pixman_image_unref(linebuf);
|
||||
fclose(f);
|
||||
return;
|
||||
|
||||
write_err:
|
||||
error_setg(errp, "failed to write to file '%s': %s", filename,
|
||||
strerror(errno));
|
||||
unlink(filename);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* save the vga display in a PPM image even if no display is
|
||||
available */
|
||||
static void vga_screen_dump(void *opaque, const char *filename, bool cswitch,
|
||||
Error **errp)
|
||||
{
|
||||
VGACommonState *s = opaque;
|
||||
DisplaySurface *surface = qemu_console_surface(s->con);
|
||||
|
||||
if (cswitch) {
|
||||
vga_invalidate_display(s);
|
||||
}
|
||||
vga_hw_update();
|
||||
ppm_save(filename, surface, errp);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user