]> Git Repo - qemu.git/blame - hw/display/blizzard_template.h
hw/intc: QOM'ify exynos4210_gic.c
[qemu.git] / hw / display / blizzard_template.h
CommitLineData
7e7c5e4c
AZ
1/*
2 * QEMU Epson S1D13744/S1D13745 templates
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 * Written by Andrzej Zaborowski <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 or
10 * (at your option) version 3 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
fad6cb1a 17 * You should have received a copy of the GNU General Public License along
8167ee88 18 * with this program; if not, see <http://www.gnu.org/licenses/>.
7e7c5e4c
AZ
19 */
20
2cdaca90 21#define SKIP_PIXEL(to) (to += deststep)
5c87c408 22#if DEPTH == 32
2cdaca90
PB
23# define PIXEL_TYPE uint32_t
24# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0)
25# define COPY_PIXEL1(to, from) (*to++ = from)
7e7c5e4c
AZ
26#else
27# error unknown bit depth
28#endif
29
e2542fe2 30#ifdef HOST_WORDS_BIGENDIAN
7e7c5e4c
AZ
31# define SWAP_WORDS 1
32#endif
33
34static void glue(blizzard_draw_line16_, DEPTH)(PIXEL_TYPE *dest,
35 const uint16_t *src, unsigned int width)
36{
7e7c5e4c
AZ
37 uint16_t data;
38 unsigned int r, g, b;
b21e9863 39 const uint16_t *end = (const void *) src + width;
7e7c5e4c 40 while (src < end) {
fc97bb5b 41 data = *src ++;
7e7c5e4c
AZ
42 b = (data & 0x1f) << 3;
43 data >>= 5;
44 g = (data & 0x3f) << 2;
45 data >>= 6;
46 r = (data & 0x1f) << 3;
47 data >>= 5;
48 COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
49 }
7e7c5e4c
AZ
50}
51
52static void glue(blizzard_draw_line24mode1_, DEPTH)(PIXEL_TYPE *dest,
53 const uint8_t *src, unsigned int width)
54{
55 /* TODO: check if SDL 24-bit planes are not in the same format and
56 * if so, use memcpy */
57 unsigned int r[2], g[2], b[2];
58 const uint8_t *end = src + width;
59 while (src < end) {
60 g[0] = *src ++;
61 r[0] = *src ++;
62 r[1] = *src ++;
63 b[0] = *src ++;
64 COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r[0], g[0], b[0]));
65 b[1] = *src ++;
66 g[1] = *src ++;
67 COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r[1], g[1], b[1]));
68 }
69}
70
71static void glue(blizzard_draw_line24mode2_, DEPTH)(PIXEL_TYPE *dest,
72 const uint8_t *src, unsigned int width)
73{
74 unsigned int r, g, b;
75 const uint8_t *end = src + width;
76 while (src < end) {
77 r = *src ++;
78 src ++;
79 b = *src ++;
80 g = *src ++;
81 COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
82 }
83}
84
85/* No rotation */
86static blizzard_fn_t glue(blizzard_draw_fn_, DEPTH)[0x10] = {
87 NULL,
88 /* RGB 5:6:5*/
89 (blizzard_fn_t) glue(blizzard_draw_line16_, DEPTH),
90 /* RGB 6:6:6 mode 1 */
91 (blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH),
92 /* RGB 8:8:8 mode 1 */
93 (blizzard_fn_t) glue(blizzard_draw_line24mode1_, DEPTH),
94 NULL, NULL,
95 /* RGB 6:6:6 mode 2 */
96 (blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH),
97 /* RGB 8:8:8 mode 2 */
98 (blizzard_fn_t) glue(blizzard_draw_line24mode2_, DEPTH),
99 /* YUV 4:2:2 */
100 NULL,
101 /* YUV 4:2:0 */
102 NULL,
103 NULL, NULL, NULL, NULL, NULL, NULL,
104};
105
106/* 90deg, 180deg and 270deg rotation */
107static blizzard_fn_t glue(blizzard_draw_fn_r_, DEPTH)[0x10] = {
108 /* TODO */
109 [0 ... 0xf] = NULL,
110};
111
112#undef DEPTH
113#undef SKIP_PIXEL
114#undef COPY_PIXEL
115#undef COPY_PIXEL1
116#undef PIXEL_TYPE
117
118#undef SWAP_WORDS
This page took 0.628135 seconds and 4 git commands to generate.