~ubuntu-branches/ubuntu/saucy/qemu/saucy-proposed

« back to all changes in this revision

Viewing changes to hw/display/framebuffer.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-05-28 08:18:30 UTC
  • mfrom: (1.8.2) (10.1.37 sid)
  • Revision ID: package-import@ubuntu.com-20130528081830-87xl2z9fq516a814
Tags: 1.5.0+dfsg-2ubuntu1
* Merge 1.5.0+dfs-2 from debian unstable.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - Dropped patches:
    * 0001-fix-wrong-output-with-info-chardev-for-tcp-socket.patch
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * gridcentric patch - updated
    * linaro arm patches from qemu-linaro rebasing branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Framebuffer device helper routines
 
3
 *
 
4
 * Copyright (c) 2009 CodeSourcery
 
5
 * Written by Paul Brook <paul@codesourcery.com>
 
6
 *
 
7
 * This code is licensed under the GNU GPLv2.
 
8
 *
 
9
 * Contributions after 2012-01-13 are licensed under the terms of the
 
10
 * GNU GPL, version 2 or (at your option) any later version.
 
11
 */
 
12
 
 
13
/* TODO:
 
14
   - Do something similar for framebuffers with local ram
 
15
   - Handle rotation here instead of hacking dest_pitch
 
16
   - Use common pixel conversion routines instead of per-device drawfn
 
17
   - Remove all DisplayState knowledge from devices.
 
18
 */
 
19
 
 
20
#include "hw/hw.h"
 
21
#include "ui/console.h"
 
22
#include "framebuffer.h"
 
23
 
 
24
/* Render an image from a shared memory framebuffer.  */
 
25
   
 
26
void framebuffer_update_display(
 
27
    DisplaySurface *ds,
 
28
    MemoryRegion *address_space,
 
29
    hwaddr base,
 
30
    int cols, /* Width in pixels.  */
 
31
    int rows, /* Height in pixels.  */
 
32
    int src_width, /* Length of source line, in bytes.  */
 
33
    int dest_row_pitch, /* Bytes between adjacent horizontal output pixels.  */
 
34
    int dest_col_pitch, /* Bytes between adjacent vertical output pixels.  */
 
35
    int invalidate, /* nonzero to redraw the whole image.  */
 
36
    drawfn fn,
 
37
    void *opaque,
 
38
    int *first_row, /* Input and output.  */
 
39
    int *last_row /* Output only */)
 
40
{
 
41
    hwaddr src_len;
 
42
    uint8_t *dest;
 
43
    uint8_t *src;
 
44
    uint8_t *src_base;
 
45
    int first, last = 0;
 
46
    int dirty;
 
47
    int i;
 
48
    ram_addr_t addr;
 
49
    MemoryRegionSection mem_section;
 
50
    MemoryRegion *mem;
 
51
 
 
52
    i = *first_row;
 
53
    *first_row = -1;
 
54
    src_len = src_width * rows;
 
55
 
 
56
    mem_section = memory_region_find(address_space, base, src_len);
 
57
    if (mem_section.size != src_len || !memory_region_is_ram(mem_section.mr)) {
 
58
        return;
 
59
    }
 
60
    mem = mem_section.mr;
 
61
    assert(mem);
 
62
    assert(mem_section.offset_within_address_space == base);
 
63
 
 
64
    memory_region_sync_dirty_bitmap(mem);
 
65
    src_base = cpu_physical_memory_map(base, &src_len, 0);
 
66
    /* If we can't map the framebuffer then bail.  We could try harder,
 
67
       but it's not really worth it as dirty flag tracking will probably
 
68
       already have failed above.  */
 
69
    if (!src_base)
 
70
        return;
 
71
    if (src_len != src_width * rows) {
 
72
        cpu_physical_memory_unmap(src_base, src_len, 0, 0);
 
73
        return;
 
74
    }
 
75
    src = src_base;
 
76
    dest = surface_data(ds);
 
77
    if (dest_col_pitch < 0)
 
78
        dest -= dest_col_pitch * (cols - 1);
 
79
    if (dest_row_pitch < 0) {
 
80
        dest -= dest_row_pitch * (rows - 1);
 
81
    }
 
82
    first = -1;
 
83
    addr = mem_section.offset_within_region;
 
84
 
 
85
    addr += i * src_width;
 
86
    src += i * src_width;
 
87
    dest += i * dest_row_pitch;
 
88
 
 
89
    for (; i < rows; i++) {
 
90
        dirty = memory_region_get_dirty(mem, addr, src_width,
 
91
                                             DIRTY_MEMORY_VGA);
 
92
        if (dirty || invalidate) {
 
93
            fn(opaque, dest, src, cols, dest_col_pitch);
 
94
            if (first == -1)
 
95
                first = i;
 
96
            last = i;
 
97
        }
 
98
        addr += src_width;
 
99
        src += src_width;
 
100
        dest += dest_row_pitch;
 
101
    }
 
102
    cpu_physical_memory_unmap(src_base, src_len, 0, 0);
 
103
    if (first < 0) {
 
104
        return;
 
105
    }
 
106
    memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len,
 
107
                              DIRTY_MEMORY_VGA);
 
108
    *first_row = first;
 
109
    *last_row = last;
 
110
}