~ubuntu-branches/ubuntu/precise/qemu-kvm/precise

« back to all changes in this revision

Viewing changes to hw/milkymist-vgafb_template.h

  • Committer: Serge Hallyn
  • Date: 2011-10-19 07:37:43 UTC
  • mfrom: (1.2.7)
  • Revision ID: serge.hallyn@ubuntu.com-20111019073743-7i7n9irsxlm38wic
Tags: 0.15.0+noroms-0ubuntu1
* New upstream release
* Remaining changes from upstream:
  - removed all binary roms and tests/pi_10.com
* Removed Detect-and-use-GCC-atomic-builtins-for-locking.patch - non-NPTL
  implementations were removed with commit
  02615337ef295443daa03233e492194e289a807e
* Drop spice-qxl-locking-fix-for-qemu-kvm.patch - should be unnecessary
  as of commit 196a778428989217b82de042725dc8eb29c8f8d8
* drop patches applied upstream:
  - CVE-2011-1751.diff
  - virtio-guard-against-negative-vq-notifies-CVE-2011-2512.diff
  - CVE-2011-2527.patch
  - fix-pa-configure.patch
* Refreshed the remaining patches:
  - larger_default_ram_size.patch
  - CVE-2011-2212-virtqueue-indirect-overflow.patch
  - qemuifup-fix-paths.patch
  - vpc.patch
* e1000-Dont-set-the-Capabilities-List-bit.patch - switched to the
  cherrypicked upstream patch (as the source file changed quite a bit,
  and the hand-ported patch backported to 0.14.1 does not apply).
* Drop qemu-kvm-spice (all changes from 0.14.1+noroms-0ubuntu7), it will
  need its own source package (LP: #878162)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  QEMU model of the Milkymist VGA framebuffer.
 
3
 *
 
4
 *  Copyright (c) 2010 Michael Walle <michael@walle.cc>
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 */
 
20
 
 
21
#if BITS == 8
 
22
#define COPY_PIXEL(to, r, g, b)                    \
 
23
    do {                                           \
 
24
        *to = rgb_to_pixel8(r, g, b);              \
 
25
        to += 1;                                   \
 
26
    } while (0)
 
27
#elif BITS == 15
 
28
#define COPY_PIXEL(to, r, g, b)                    \
 
29
    do {                                           \
 
30
        *(uint16_t *)to = rgb_to_pixel15(r, g, b); \
 
31
        to += 2;                                   \
 
32
    } while (0)
 
33
#elif BITS == 16
 
34
#define COPY_PIXEL(to, r, g, b)                    \
 
35
    do {                                           \
 
36
        *(uint16_t *)to = rgb_to_pixel16(r, g, b); \
 
37
        to += 2;                                   \
 
38
    } while (0)
 
39
#elif BITS == 24
 
40
#define COPY_PIXEL(to, r, g, b)                    \
 
41
    do {                                           \
 
42
        uint32 tmp = rgb_to_pixel24(r, g, b);      \
 
43
        *(to++) =         tmp & 0xff;              \
 
44
        *(to++) =  (tmp >> 8) & 0xff;              \
 
45
        *(to++) = (tmp >> 16) & 0xff;              \
 
46
    } while (0)
 
47
#elif BITS == 32
 
48
#define COPY_PIXEL(to, r, g, b)                    \
 
49
    do {                                           \
 
50
        *(uint32_t *)to = rgb_to_pixel32(r, g, b); \
 
51
        to += 4;                                   \
 
52
    } while (0)
 
53
#else
 
54
#error unknown bit depth
 
55
#endif
 
56
 
 
57
static void glue(draw_line_, BITS)(void *opaque, uint8_t *d, const uint8_t *s,
 
58
        int width, int deststep)
 
59
{
 
60
    uint16_t rgb565;
 
61
    uint8_t r, g, b;
 
62
 
 
63
    while (width--) {
 
64
        rgb565 = lduw_raw(s);
 
65
        r = ((rgb565 >> 11) & 0x1f) << 3;
 
66
        g = ((rgb565 >>  5) & 0x3f) << 2;
 
67
        b = ((rgb565 >>  0) & 0x1f) << 3;
 
68
        COPY_PIXEL(d, r, g, b);
 
69
        s += 2;
 
70
    }
 
71
}
 
72
 
 
73
#undef BITS
 
74
#undef COPY_PIXEL