~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to console.c

  • Committer: aliguori
  • Date: 2009-01-16 19:04:14 UTC
  • Revision ID: git-v1:3023f3329d87a6203d03a0e9ccb948772940da96
graphical_console_init change (Stefano Stabellini)

Patch 5/7

This patch changes the graphical_console_init function to return an
allocated DisplayState instead of a QEMUConsole.

This patch contains just the graphical_console_init change and few other
modifications mainly in console.c and vl.c.
It was necessary to move the display frontends (e.g. sdl and vnc)
initialization after machine->init in vl.c.

This patch does *not* include any required changes to any device, these
changes come with the following patches.

Patch 6/7

This patch changes the QEMUMachine init functions not to take a
DisplayState as an argument because is not needed any more;

In few places the graphic hardware initialization function was called
only if DisplayState was not NULL, now they are always called.
Apart from these cases, the rest are all mechanical substitutions.

Patch 7/7

This patch updates the graphic device code to use the new
graphical_console_init function.

As for the previous patch, in few places graphical_console_init was called
only if DisplayState was not NULL, now it is always called.
Apart from these cases, the rest are all mechanical substitutions.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6344 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
1190
1190
    }
1191
1191
}
1192
1192
 
 
1193
static TextConsole *get_graphic_console() {
 
1194
    int i;
 
1195
    TextConsole *s;
 
1196
    for (i = 0; i < nb_consoles; i++) {
 
1197
        s = consoles[i];
 
1198
        if (s->console_type == GRAPHIC_CONSOLE)
 
1199
            return s;
 
1200
    }
 
1201
    return NULL;
 
1202
}
 
1203
 
1193
1204
static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
1194
1205
{
1195
1206
    TextConsole *s;
1217
1228
            consoles[i] = consoles[i - 1];
1218
1229
        }
1219
1230
        consoles[i] = s;
 
1231
        nb_consoles++;
1220
1232
    }
1221
1233
    return s;
1222
1234
}
1223
1235
 
1224
 
TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
1225
 
                                  vga_hw_invalidate_ptr invalidate,
1226
 
                                  vga_hw_screen_dump_ptr screen_dump,
1227
 
                                  vga_hw_text_update_ptr text_update,
1228
 
                                  void *opaque)
 
1236
DisplayState *graphic_console_init(vga_hw_update_ptr update,
 
1237
                                   vga_hw_invalidate_ptr invalidate,
 
1238
                                   vga_hw_screen_dump_ptr screen_dump,
 
1239
                                   vga_hw_text_update_ptr text_update,
 
1240
                                   void *opaque)
1229
1241
{
1230
1242
    TextConsole *s;
 
1243
    DisplayState *ds;
 
1244
    
 
1245
    ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState));
 
1246
    if (ds == NULL)
 
1247
        return NULL;
 
1248
    ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4);
1231
1249
 
1232
1250
    s = new_console(ds, GRAPHIC_CONSOLE);
1233
 
    if (!s)
1234
 
      return NULL;
 
1251
    if (s == NULL) {
 
1252
        qemu_free_displaysurface(ds->surface);
 
1253
        qemu_free(ds);
 
1254
        return NULL;
 
1255
    }
1235
1256
    s->hw_update = update;
1236
1257
    s->hw_invalidate = invalidate;
1237
1258
    s->hw_screen_dump = screen_dump;
1238
1259
    s->hw_text_update = text_update;
1239
1260
    s->hw = opaque;
1240
 
    return s;
 
1261
 
 
1262
    register_displaystate(ds); 
 
1263
    return ds;
1241
1264
}
1242
1265
 
1243
1266
int is_graphic_console(void)
1285
1308
    s->out_fifo.buf = s->out_fifo_buf;
1286
1309
    s->out_fifo.buf_size = sizeof(s->out_fifo_buf);
1287
1310
    s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);
 
1311
    s->ds = ds;
1288
1312
 
1289
1313
    if (!color_inited) {
1290
1314
        color_inited = 1;
1337
1361
    return chr;
1338
1362
}
1339
1363
 
1340
 
void qemu_console_resize(QEMUConsole *console, int width, int height)
 
1364
void qemu_console_resize(DisplayState *ds, int width, int height)
1341
1365
{
1342
 
    console->g_width = width;
1343
 
    console->g_height = height;
1344
 
    if (active_console == console) {
1345
 
        DisplayState *ds = console->ds;
 
1366
    TextConsole *s = get_graphic_console();
 
1367
    s->g_width = width;
 
1368
    s->g_height = height;
 
1369
    if (is_graphic_console()) {
1346
1370
        ds->surface = qemu_resize_displaysurface(ds->surface, width, height, 32, 4 * width);
1347
 
        dpy_resize(console->ds);
 
1371
        dpy_resize(ds);
1348
1372
    }
1349
1373
}
1350
1374
 
1351
 
void qemu_console_copy(QEMUConsole *console, int src_x, int src_y,
1352
 
                int dst_x, int dst_y, int w, int h)
 
1375
void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
 
1376
                       int dst_x, int dst_y, int w, int h)
1353
1377
{
1354
 
    if (active_console == console) {
1355
 
            dpy_copy(console->ds, src_x, src_y, dst_x, dst_y, w, h);
 
1378
    if (is_graphic_console()) {
 
1379
        dpy_copy(ds, src_x, src_y, dst_x, dst_y, w, h);
1356
1380
    }
1357
1381
}
1358
1382