qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/9] fbdev: add linux framebuffer display driver


From: Stefano Stabellini
Subject: Re: [Qemu-devel] [PATCH 4/9] fbdev: add linux framebuffer display driver.
Date: Wed, 19 Sep 2012 19:09:14 +0100
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)

On Wed, 19 Sep 2012, Gerd Hoffmann wrote:
> +/* -------------------------------------------------------------------- */
> +/* rendering                                                            */
> +
> +static void fbdev_render(DisplayState *ds, int x, int y, int w, int h)
> +{
> +    uint8_t *dst;
> +    uint8_t *src;
> +    int line;
> +
> +    if (!conv) {
> +        return;
> +    }
> +
> +    src = ds_get_data(ds) + y * ds_get_linesize(ds)
> +        + x * ds_get_bytes_per_pixel(ds);
> +    dst = fb_mem + y * fb_fix.line_length
> +        + x * fbpf.bytes_per_pixel;
> +
> +    dst += cy * fb_fix.line_length;
> +    dst += cx * fbpf.bytes_per_pixel;
> +
> +    if (h > fb_var.yres - y) {
> +        h = fb_var.yres - y;
> +    }
> +    if (w > fb_var.xres - x) {
> +        w = fb_var.xres - x;
> +    }
> +
> +    for (line = y; line < y+h; line++) {
> +        qemu_pf_conv_run(conv, dst, src, w);
> +        dst += fb_fix.line_length;
> +        src += ds_get_linesize(ds);
> +    }
> +}
> +
> +/* -------------------------------------------------------------------- */
> +/* qemu interfaces                                                      */
> +
> +static void fbdev_update(DisplayState *ds, int x, int y, int w, int h)
> +{
> +    if (fb_switch_state != FB_ACTIVE) {
> +        return;
> +    }
> +
> +    if (resize_screen) {
> +        trace_fbdev_dpy_resize(ds_get_width(ds), ds_get_height(ds));
> +        resize_screen = 0;
> +        cx = 0; cy = 0;
> +        cw = ds_get_width(ds);
> +        ch = ds_get_height(ds);
> +        if (ds_get_width(ds) < fb_var.xres) {
> +            cx = (fb_var.xres - ds_get_width(ds)) / 2;
> +        }
> +        if (ds_get_height(ds) < fb_var.yres) {
> +            cy = (fb_var.yres - ds_get_height(ds)) / 2;
> +        }
> +
> +        if (conv) {
> +            qemu_pf_conv_put(conv);
> +        }
> +        conv = qemu_pf_conv_get(&fbpf, &ds->surface->pf);
> +        if (conv == NULL) {
> +            fprintf(stderr, "fbdev: unsupported PixelFormat conversion\n");
> +        }
> +    }
> +
> +    if (redraw_screen) {
> +        trace_fbdev_dpy_redraw();
> +        redraw_screen = 0;
> +        fbdev_cls();
> +        x = 0; y = 0; w = ds_get_width(ds); h = ds_get_height(ds);
> +    }
> +
> +    fbdev_render(ds, x, y, w, h);
> +}
> +
> +static void fbdev_resize(DisplayState *ds)
> +{
> +    resize_screen++;
> +    redraw_screen++;
> +}
> +
> +static void fbdev_refresh(DisplayState *ds)
> +{
> +    switch (fb_switch_state) {
> +    case FB_REL_REQ:
> +        fbdev_switch_release();
> +    case FB_INACTIVE:
> +        return;
> +    case FB_ACQ_REQ:
> +        fbdev_switch_acquire();
> +        redraw_screen++;

Rather than introducing redraw_screen, I would just call vga_hw_invalidate
instead here. It is always a win if we can avoid to introduce one more
state machine.


> +    case FB_ACTIVE:
> +        break;
> +    }
> +
> +    vga_hw_update();
> +    if (redraw_screen) {
> +        fbdev_update(ds, 0, 0, 0, 0);
> +    }
> +}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]