sim-card
/
qemu
Archived
10
0
Fork 0

Implement resolution switching in common console code.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4812 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
pbrook 2008-07-01 16:24:38 +00:00
parent ea334207a3
commit c60e08d9c6
20 changed files with 109 additions and 91 deletions

View File

@ -28,6 +28,7 @@
//#define DEBUG_CONSOLE
#define DEFAULT_BACKSCROLL 512
#define MAX_CONSOLES 12
#define DEFAULT_MONITOR_SIZE "800x600"
#define QEMU_RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
#define QEMU_RGB(r, g, b) QEMU_RGBA(r, g, b, 0xff)
@ -108,8 +109,7 @@ static int qemu_fifo_read(QEMUFIFO *f, uint8_t *buf, int len1)
typedef enum {
GRAPHIC_CONSOLE,
TEXT_CONSOLE,
TEXT_CONSOLE_FIXED_SIZE
TEXT_CONSOLE
} console_type_t;
/* ??? This is mis-named.
@ -1041,6 +1041,9 @@ void console_select(unsigned int index)
s = consoles[index];
if (s) {
active_console = s;
if (s->g_width && s->g_height
&& (s->g_width != s->ds->width || s->g_height != s->ds->height))
dpy_resize(s->ds, s->g_width, s->g_height);
vga_hw_invalidate();
}
}
@ -1149,18 +1152,6 @@ static void text_console_invalidate(void *opaque)
{
TextConsole *s = (TextConsole *) opaque;
if (s->console_type != GRAPHIC_CONSOLE) {
if (s->g_width != s->ds->width ||
s->g_height != s->ds->height) {
if (s->console_type == TEXT_CONSOLE_FIXED_SIZE)
dpy_resize(s->ds, s->g_width, s->g_height);
else {
s->g_width = s->ds->width;
s->g_height = s->ds->height;
text_console_resize(s);
}
}
}
console_refresh(s);
}
@ -1268,11 +1259,14 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
chr = qemu_mallocz(sizeof(CharDriverState));
if (!chr)
return NULL;
s = new_console(ds, (p == 0) ? TEXT_CONSOLE : TEXT_CONSOLE_FIXED_SIZE);
s = new_console(ds, TEXT_CONSOLE);
if (!s) {
free(chr);
return NULL;
}
if (!p)
p = DEFAULT_MONITOR_SIZE;
chr->opaque = s;
chr->chr_write = console_puts;
chr->chr_send_event = console_send_event;
@ -1332,3 +1326,14 @@ CharDriverState *text_console_init(DisplayState *ds, const char *p)
return chr;
}
void qemu_console_resize(QEMUConsole *console, int width, int height)
{
if (console->g_width != width || console->g_height != height) {
console->g_width = width;
console->g_height = height;
if (active_console == console) {
dpy_resize(console->ds, width, height);
}
}
}

View File

@ -135,6 +135,7 @@ int is_graphic_console(void);
CharDriverState *text_console_init(DisplayState *ds, const char *p);
void console_select(unsigned int index);
void console_color_init(DisplayState *ds);
void qemu_console_resize(QEMUConsole *console, int width, int height);
/* sdl.c */
void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);

View File

@ -73,6 +73,7 @@ struct blizzard_s {
uint8_t iformat;
uint8_t source;
DisplayState *state;
QEMUConsole *console;
blizzard_fn_t *line_fn_tab[2];
void *fb;
@ -896,7 +897,7 @@ static void blizzard_update_display(void *opaque)
if (s->x != s->state->width || s->y != s->state->height) {
s->invalidate = 1;
dpy_resize(s->state, s->x, s->y);
qemu_console_resize(s->console, s->x, s->y);
}
if (s->invalidate) {
@ -993,9 +994,9 @@ void *s1d13745_init(qemu_irq gpio_int, DisplayState *ds)
blizzard_reset(s);
graphic_console_init(s->state, blizzard_update_display,
blizzard_invalidate_display, blizzard_screen_dump,
NULL, s);
s->console = graphic_console_init(s->state, blizzard_update_display,
blizzard_invalidate_display,
blizzard_screen_dump, NULL, s);
return s;
}

View File

@ -3288,8 +3288,8 @@ void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
ds, vga_ram_base, vga_ram_offset, vga_ram_size);
cirrus_init_common(s, device_id, 1);
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
s->text_update, s);
s->console = graphic_console_init(s->ds, s->update, s->invalidate,
s->screen_dump, s->text_update, s);
s->pci_dev = (PCIDevice *)d;

View File

@ -33,6 +33,7 @@ typedef struct G364State {
uint8_t palette[256][3];
/* display refresh support */
DisplayState *ds;
QEMUConsole *console;
int graphic_mode;
uint32_t scr_width, scr_height; /* in pixels */
uint32_t last_scr_width, last_scr_height; /* in pixels */
@ -74,13 +75,6 @@ static void g364fb_draw_graphic(G364State *s, int full_update)
{
if (s->scr_width == 0 || s->scr_height == 0)
return;
if (s->scr_width != s->last_scr_width
|| s->scr_height != s->last_scr_height) {
s->last_scr_width = s->scr_width;
s->last_scr_height = s->scr_height;
dpy_resize(s->ds, s->last_scr_width, s->last_scr_height);
full_update = 1;
}
switch (s->ds->depth) {
case 8:
@ -272,7 +266,10 @@ static void g364fb_ctrl_writeb(void *opaque, target_phys_addr_t addr, uint32_t v
#endif
break;
}
if (s->scr_width && s->scr_height)
qemu_console_resize(s->console, s->scr_width, s->scr_height);
}
s->graphic_mode = -1; /* force full update */
}
static void g364fb_ctrl_writew(void *opaque, target_phys_addr_t addr, uint32_t val)
@ -382,9 +379,9 @@ int g364fb_mm_init(DisplayState *ds,
s->ds = ds;
s->vram_base = vram_base;
graphic_console_init(ds, g364fb_update_display,
g364fb_invalidate_display, g364fb_screen_dump,
NULL, s);
s->console = graphic_console_init(ds, g364fb_update_display,
g364fb_invalidate_display,
g364fb_screen_dump, NULL, s);
io_vram = cpu_register_io_memory(0, g364fb_mem_read, g364fb_mem_write, s);
cpu_register_physical_memory(s->vram_base, vram_size, io_vram);

View File

@ -37,6 +37,7 @@ typedef struct LedState {
target_phys_addr_t base;
uint8_t segments;
DisplayState *ds;
QEMUConsole *console;
screen_state_t state;
} LedState;
@ -291,7 +292,7 @@ static void jazz_led_text_update(void *opaque, console_ch_t *chardata)
char buf[2];
dpy_cursor(s->ds, -1, -1);
dpy_resize(s->ds, 2, 1);
qemu_console_resize(s->console, 2, 1);
/* TODO: draw the segments */
snprintf(buf, 2, "%02hhx\n", s->segments);
@ -317,7 +318,9 @@ void jazz_led_init(DisplayState *ds, target_phys_addr_t base)
io = cpu_register_io_memory(0, led_read, led_write, s);
cpu_register_physical_memory(s->base, 1, io);
graphic_console_init(ds, jazz_led_update_display,
jazz_led_invalidate_display, jazz_led_screen_dump,
jazz_led_text_update, s);
s->console = graphic_console_init(ds, jazz_led_update_display,
jazz_led_invalidate_display,
jazz_led_screen_dump,
jazz_led_text_update, s);
qemu_console_resize(s->console, 60, 80);
}

View File

@ -758,8 +758,8 @@ typedef struct musicpal_lcd_state {
int page;
int page_off;
DisplayState *ds;
QEMUConsole *console;
uint8_t video_ram[128*64/8];
int invalidate;
} musicpal_lcd_state;
static uint32_t lcd_brightness;
@ -818,11 +818,6 @@ static void lcd_refresh(void *opaque)
musicpal_lcd_state *s = opaque;
int x, y, col;
if (s->invalidate && (s->ds->width != 128*3 || s->ds->height != 64*3)) {
dpy_resize(s->ds, 128*3, 64*3);
s->invalidate = 0;
}
switch (s->ds->depth) {
case 0:
return;
@ -851,9 +846,6 @@ static void lcd_refresh(void *opaque)
static void lcd_invalidate(void *opaque)
{
musicpal_lcd_state *s = opaque;
s->invalidate = 1;
}
static uint32_t musicpal_lcd_read(void *opaque, target_phys_addr_t offset)
@ -932,12 +924,13 @@ static void musicpal_lcd_init(DisplayState *ds, uint32_t base)
return;
s->base = base;
s->ds = ds;
s->invalidate = 1;
iomemtype = cpu_register_io_memory(0, musicpal_lcd_readfn,
musicpal_lcd_writefn, s);
cpu_register_physical_memory(base, MP_LCD_SIZE, iomemtype);
graphic_console_init(ds, lcd_refresh, lcd_invalidate, NULL, NULL, s);
s->console = graphic_console_init(ds, lcd_refresh, lcd_invalidate,
NULL, NULL, s);
qemu_console_resize(s->console, 128*3, 64*3);
}
/* PIC register offsets */

View File

@ -1307,7 +1307,9 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device,
n800_setup_nolo_tags(phys_ram_base + sdram_size);
}
/* FIXME: We shouldn't really be doing this here. The LCD controller
will set the size once configured, so this just sets an initial
size until the guest activates the display. */
dpy_resize(ds, 800, 480);
}

View File

@ -26,6 +26,7 @@ struct omap_lcd_panel_s {
target_phys_addr_t base;
qemu_irq irq;
DisplayState *state;
QEMUConsole *console;
ram_addr_t imif_base;
ram_addr_t emiff_base;
@ -175,8 +176,8 @@ static void omap_update_display(void *opaque)
width = omap_lcd->width;
if (width != omap_lcd->state->width ||
omap_lcd->height != omap_lcd->state->height) {
dpy_resize(omap_lcd->state,
omap_lcd->width, omap_lcd->height);
qemu_console_resize(omap_lcd->console,
omap_lcd->width, omap_lcd->height);
omap_lcd->invalidate = 1;
}
@ -494,8 +495,9 @@ struct omap_lcd_panel_s *omap_lcdc_init(target_phys_addr_t base, qemu_irq irq,
omap_lcdc_writefn, s);
cpu_register_physical_memory(s->base, 0x100, iomemtype);
graphic_console_init(ds, omap_update_display,
omap_invalidate_display, omap_screen_dump, NULL, s);
s->console = graphic_console_init(ds, omap_update_display,
omap_invalidate_display,
omap_screen_dump, NULL, s);
return s;
}

View File

@ -275,6 +275,9 @@ static void palmte_init(ram_addr_t ram_size, int vga_ram_size,
arm_load_kernel(cpu->env, &palmte_binfo);
}
/* FIXME: We shouldn't really be doing this here. The LCD controller
will set the size once configured, so this just sets an initial
size until the guest activates the display. */
dpy_resize(ds, 320, 320);
}

View File

@ -30,6 +30,8 @@ enum pl110_bppmode
typedef struct {
uint32_t base;
DisplayState *ds;
QEMUConsole *console;
/* The Versatile/PB uses a slightly modified PL110 controller. */
int versatile;
uint32_t timing[4];
@ -270,7 +272,7 @@ static void pl110_resize(pl110_state *s, int width, int height)
{
if (width != s->cols || height != s->rows) {
if (pl110_enabled(s)) {
dpy_resize(s->ds, width, height);
qemu_console_resize(s->console, width, height);
}
}
s->cols = width;
@ -387,7 +389,7 @@ static void pl110_write(void *opaque, target_phys_addr_t offset,
s->cr = val;
s->bpp = (val >> 1) & 7;
if (pl110_enabled(s)) {
dpy_resize(s->ds, s->cols, s->rows);
qemu_console_resize(s->console, s->cols, s->rows);
}
break;
case 10: /* LCDICR */
@ -425,8 +427,9 @@ void *pl110_init(DisplayState *ds, uint32_t base, qemu_irq irq,
s->ds = ds;
s->versatile = versatile;
s->irq = irq;
graphic_console_init(ds, pl110_update_display, pl110_invalidate_display,
NULL, NULL, s);
s->console = graphic_console_init(ds, pl110_update_display,
pl110_invalidate_display,
NULL, NULL, s);
/* ??? Save/restore. */
return s;
}

View File

@ -23,6 +23,7 @@ struct pxa2xx_lcdc_s {
int invalidated;
DisplayState *ds;
QEMUConsole *console;
drawfn *line_fn[2];
int dest_width;
int xres, yres;
@ -794,9 +795,9 @@ static void pxa2xx_lcdc_resize(struct pxa2xx_lcdc_s *s)
if (width != s->xres || height != s->yres) {
if (s->orientation)
dpy_resize(s->ds, height, width);
qemu_console_resize(s->console, height, width);
else
dpy_resize(s->ds, width, height);
qemu_console_resize(s->console, width, height);
s->invalidated = 1;
s->xres = width;
s->yres = height;
@ -1001,8 +1002,9 @@ struct pxa2xx_lcdc_s *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq,
pxa2xx_lcdc_writefn, s);
cpu_register_physical_memory(base, 0x00100000, iomemtype);
graphic_console_init(ds, pxa2xx_update_display,
pxa2xx_invalidate_display, pxa2xx_screen_dump, NULL, s);
s->console = graphic_console_init(ds, pxa2xx_update_display,
pxa2xx_invalidate_display,
pxa2xx_screen_dump, NULL, s);
switch (s->ds->depth) {
case 0:

View File

@ -45,6 +45,7 @@ enum ssd0303_cmd {
typedef struct {
i2c_slave i2c;
DisplayState *ds;
QEMUConsole *console;
int row;
int col;
int start_line;
@ -269,7 +270,8 @@ void ssd0303_init(DisplayState *ds, i2c_bus *bus, int address)
s->i2c.event = ssd0303_event;
s->i2c.recv = ssd0303_recv;
s->i2c.send = ssd0303_send;
graphic_console_init(ds, ssd0303_update_display, ssd0303_invalidate_display,
NULL, NULL, s);
dpy_resize(s->ds, 96 * MAGNIFY, 16 * MAGNIFY);
s->console = graphic_console_init(ds, ssd0303_update_display,
ssd0303_invalidate_display,
NULL, NULL, s);
qemu_console_resize(s->console, 96 * MAGNIFY, 16 * MAGNIFY);
}

View File

@ -44,6 +44,7 @@ enum ssd0323_mode
typedef struct {
DisplayState *ds;
QEMUConsole *console;
int cmd_len;
int cmd;
@ -278,12 +279,13 @@ void *ssd0323_init(DisplayState *ds, qemu_irq *cmd_p)
qemu_irq *cmd;
s = (ssd0323_state *)qemu_mallocz(sizeof(ssd0323_state));
s->ds = ds;
graphic_console_init(ds, ssd0323_update_display, ssd0323_invalidate_display,
NULL, NULL, s);
dpy_resize(s->ds, 128 * MAGNIFY, 64 * MAGNIFY);
s->col_end = 63;
s->row_end = 79;
s->ds = ds;
s->console = graphic_console_init(ds, ssd0323_update_display,
ssd0323_invalidate_display,
NULL, NULL, s);
qemu_console_resize(s->console, 128 * MAGNIFY, 64 * MAGNIFY);
cmd = qemu_allocate_irqs(ssd0323_cd, s, 1);
*cmd_p = *cmd;

View File

@ -36,6 +36,7 @@
typedef struct TCXState {
target_phys_addr_t addr;
DisplayState *ds;
QEMUConsole *console;
uint8_t *vram;
uint32_t *vram24, *cplane;
ram_addr_t vram_offset, vram24_offset, cplane_offset;
@ -186,8 +187,6 @@ static void tcx_update_display(void *opaque)
if (ts->ds->depth == 0)
return;
if (ts->ds->width != ts->width || ts->ds->height != ts->height)
dpy_resize(ts->ds, ts->width, ts->height);
page = ts->vram_offset;
y_start = -1;
page_min = 0xffffffff;
@ -266,8 +265,6 @@ static void tcx24_update_display(void *opaque)
if (ts->ds->depth != 32)
return;
if (ts->ds->width != ts->width || ts->ds->height != ts->height)
dpy_resize(ts->ds, ts->width, ts->height);
page = ts->vram_offset;
page24 = ts->vram24_offset;
cpage = ts->cplane_offset;
@ -541,14 +538,15 @@ void tcx_init(DisplayState *ds, target_phys_addr_t addr, uint8_t *vram_base,
s->cplane = (uint32_t *)vram_base;
s->cplane_offset = vram_offset;
cpu_register_physical_memory(addr + 0x0a000000ULL, size, vram_offset);
graphic_console_init(s->ds, tcx24_update_display,
tcx24_invalidate_display,
tcx24_screen_dump, NULL, s);
s->console = graphic_console_init(s->ds, tcx24_update_display,
tcx24_invalidate_display,
tcx24_screen_dump, NULL, s);
} else {
cpu_register_physical_memory(addr + 0x00300000ULL, TCX_THC_NREGS_8,
dummy_memory);
graphic_console_init(s->ds, tcx_update_display, tcx_invalidate_display,
tcx_screen_dump, NULL, s);
s->console = graphic_console_init(s->ds, tcx_update_display,
tcx_invalidate_display,
tcx_screen_dump, NULL, s);
}
// NetBSD writes here even with 8-bit display
cpu_register_physical_memory(addr + 0x00301000ULL, TCX_THC_NREGS_24,
@ -557,7 +555,7 @@ void tcx_init(DisplayState *ds, target_phys_addr_t addr, uint8_t *vram_base,
register_savevm("tcx", addr, 4, tcx_save, tcx_load, s);
qemu_register_reset(tcx_reset, s);
tcx_reset(s);
dpy_resize(s->ds, width, height);
qemu_console_resize(s->console, width, height);
}
static void tcx_screen_dump(void *opaque, const char *filename)

View File

@ -1155,7 +1155,7 @@ static void vga_draw_text(VGAState *s, int full_update)
cw != s->last_cw || cheight != s->last_ch) {
s->last_scr_width = width * cw;
s->last_scr_height = height * cheight;
dpy_resize(s->ds, s->last_scr_width, s->last_scr_height);
qemu_console_resize(s->console, s->last_scr_width, s->last_scr_height);
s->last_width = width;
s->last_height = height;
s->last_ch = cheight;
@ -1499,7 +1499,7 @@ static void vga_draw_graphic(VGAState *s, int full_update)
if (disp_width != s->last_width ||
height != s->last_height) {
dpy_resize(s->ds, disp_width, height);
qemu_console_resize(s->console, disp_width, height);
s->last_scr_width = disp_width;
s->last_scr_height = height;
s->last_width = disp_width;
@ -1734,7 +1734,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
cw != s->last_cw || cheight != s->last_ch) {
s->last_scr_width = width * cw;
s->last_scr_height = height * cheight;
dpy_resize(s->ds, width, height);
qemu_console_resize(s->console, width, height);
s->last_width = width;
s->last_height = height;
s->last_ch = cheight;
@ -1814,7 +1814,7 @@ static void vga_update_text(void *opaque, console_ch_t *chardata)
s->last_width = 60;
s->last_height = height = 3;
dpy_cursor(s->ds, -1, -1);
dpy_resize(s->ds, s->last_width, height);
qemu_console_resize(s->console, s->last_width, height);
for (dst = chardata, i = 0; i < s->last_width * height; i ++)
console_write_ch(dst ++, ' ');
@ -2140,8 +2140,8 @@ int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
vga_init(s);
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
s->text_update, s);
s->console = graphic_console_init(s->ds, s->update, s->invalidate,
s->screen_dump, s->text_update, s);
#ifdef CONFIG_BOCHS_VBE
/* XXX: use optimized standard vga accesses */
@ -2165,8 +2165,8 @@ int isa_vga_mm_init(DisplayState *ds, uint8_t *vga_ram_base,
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
vga_mm_init(s, vram_base, ctrl_base, it_shift);
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
s->text_update, s);
s->console = graphic_console_init(s->ds, s->update, s->invalidate,
s->screen_dump, s->text_update, s);
#ifdef CONFIG_BOCHS_VBE
/* XXX: use optimized standard vga accesses */
@ -2194,8 +2194,8 @@ int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
vga_init(s);
graphic_console_init(s->ds, s->update, s->invalidate, s->screen_dump,
s->text_update, s);
s->console = graphic_console_init(s->ds, s->update, s->invalidate,
s->screen_dump, s->text_update, s);
s->pci_dev = &d->dev;

View File

@ -121,6 +121,7 @@
VGA_STATE_COMMON_BOCHS_VBE \
/* display refresh support */ \
DisplayState *ds; \
QEMUConsole *console; \
uint32_t font_offsets[2]; \
int graphic_mode; \
uint8_t shift_control; \

View File

@ -57,6 +57,7 @@ struct vmsvga_state_s {
#ifndef EMBED_STDVGA
DisplayState *ds;
QEMUConsole *console;
int vram_size;
ram_addr_t vram_offset;
#endif
@ -869,7 +870,7 @@ static inline void vmsvga_size(struct vmsvga_state_s *s)
if (s->new_width != s->width || s->new_height != s->height) {
s->width = s->new_width;
s->height = s->new_height;
dpy_resize(s->ds, s->width, s->height);
qemu_console_resize(s->console, s->width, s->height);
s->invalidated = 1;
}
}
@ -1122,9 +1123,10 @@ static void vmsvga_init(struct vmsvga_state_s *s, DisplayState *ds,
vmsvga_reset(s);
graphic_console_init(ds, vmsvga_update_display,
vmsvga_invalidate_display, vmsvga_screen_dump,
vmsvga_text_update, s);
s->console = graphic_console_init(ds, vmsvga_update_display,
vmsvga_invalidate_display,
vmsvga_screen_dump,
vmsvga_text_update, s);
#ifdef EMBED_STDVGA
vga_common_init((VGAState *) s, ds,

View File

@ -119,6 +119,7 @@ typedef struct AudioState AudioState;
typedef struct BlockDriverState BlockDriverState;
typedef struct DisplayState DisplayState;
typedef struct TextConsole TextConsole;
typedef TextConsole QEMUConsole;
typedef struct CharDriverState CharDriverState;
typedef struct VLANState VLANState;
typedef struct QEMUFile QEMUFile;

2
vl.c
View File

@ -7935,7 +7935,7 @@ int main(int argc, char **argv)
kernel_cmdline = "";
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
monitor_device = "vc:800x600";
monitor_device = "vc";
serial_devices[0] = "vc:80Cx24C";
for(i = 1; i < MAX_SERIAL_PORTS; i++)