1
From f931af41957111303396562cd6316eba8681611d Mon Sep 17 00:00:00 2001
2
From: Riku Voipio <riku.voipio@nokia.com>
3
Date: Mon, 18 Feb 2013 16:58:31 +0000
4
Subject: [PATCH 44/69] add hw/omap_dss_drawfn.h
6
Omap DSS draw functions
8
hw/display/omap_dss_drawfn.h | 284 +++++++++++++++++++++++++++++++++++++++++++
9
1 file changed, 284 insertions(+)
10
create mode 100644 hw/display/omap_dss_drawfn.h
12
diff --git a/hw/display/omap_dss_drawfn.h b/hw/display/omap_dss_drawfn.h
14
index 0000000..37ba136
16
+++ b/hw/display/omap_dss_drawfn.h
19
+ * QEMU OMAP DSS display plane rendering emulation templates
21
+ * Copyright (c) 2008 yajin <yajin@vm-kernel.org>
22
+ * Copyright (c) 2008-2009 Nokia Corporation
24
+ * This program is free software; you can redistribute it and/or
25
+ * modify it under the terms of the GNU General Public License as
26
+ * published by the Free Software Foundation; either version 2 or
27
+ * (at your option) version 3 of the License.
29
+ * This program is distributed in the hope that it will be useful,
30
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
+ * GNU General Public License for more details.
34
+ * You should have received a copy of the GNU General Public License
35
+ * along with this program; if not, write to the Free Software
36
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
42
+#define PIXEL_TYPE uint8_t
43
+#define COPY_PIXEL1(to, from) *to ++ = from
44
+#elif DEPTH == 15 || DEPTH == 16
45
+#define PIXEL_TYPE uint16_t
46
+#define COPY_PIXEL1(to, from) *to ++ = from
48
+#define PIXEL_TYPE uint8_t
49
+#define COPY_PIXEL1(to, from) \
50
+ *to ++ = from; *to ++ = (from) >> 8; *to ++ = (from) >> 16
52
+#define PIXEL_TYPE uint32_t
53
+#define COPY_PIXEL1(to, from) *to ++ = from
55
+#error unknown bit depth
58
+#ifdef WORDS_BIGENDIAN
62
+static void glue(omap_dss_draw_line1_, DEPTH)(void *opaque,
68
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
69
+ const uint32_t *palette = opaque;
70
+ unsigned int r, g, b;
71
+ const uint8_t *end = src + (width >> 3);
73
+ uint8_t data = ldub_raw(src++);
75
+ for (; i--; data <<= 1) {
76
+ uint32_t color = palette[data >> 7];
78
+ g = (color >> 8) & 0xff;
79
+ r = (color >> 16) & 0xff;
80
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
85
+static void glue(omap_dss_draw_line2_, DEPTH)(void *opaque,
91
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
92
+ const uint32_t *palette = opaque;
93
+ unsigned int r, g, b;
94
+ const uint8_t *end = src + (width >> 2);
96
+ uint8_t data = ldub_raw(src++);
97
+ uint32_t color = palette[data >> 6];
99
+ g = (color >> 8) & 0xff;
100
+ r = (color >> 16) & 0xff;
101
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
102
+ color = palette[(data >> 4) & 3];
104
+ g = (color >> 8) & 0xff;
105
+ r = (color >> 16) & 0xff;
106
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
107
+ color = palette[(data >> 2) & 3];
109
+ g = (color >> 8) & 0xff;
110
+ r = (color >> 16) & 0xff;
111
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
112
+ color = palette[data & 3];
114
+ g = (color >> 8) & 0xff;
115
+ r = (color >> 16) & 0xff;
116
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
120
+static void glue(omap_dss_draw_line4_, DEPTH)(void *opaque,
122
+ const uint8_t *src,
126
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
127
+ const uint32_t *palette = opaque;
128
+ unsigned int r, g, b;
129
+ const uint8_t *end = src + (width >> 1);
130
+ while (src < end) {
131
+ uint8_t data = ldub_raw(src++);
132
+ uint32_t color = palette[data >> 4];
134
+ g = (color >> 8) & 0xff;
135
+ r = (color >> 16) & 0xff;
136
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
137
+ color = palette[data & 0x0f];
139
+ g = (color >> 8) & 0xff;
140
+ r = (color >> 16) & 0xff;
141
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
145
+static void glue(omap_dss_draw_line8_, DEPTH)(void *opaque,
147
+ const uint8_t *src,
151
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
152
+ const uint32_t *palette = opaque;
153
+ unsigned int r, g, b;
154
+ const uint8_t *end = src + width;
155
+ while (src < end) {
156
+ uint32_t color = palette[ldub_raw(src++)];
158
+ g = (color >> 8) & 0xff;
159
+ r = (color >> 16) & 0xff;
160
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
164
+static void glue(omap_dss_draw_line12_, DEPTH)(void *opaque,
166
+ const uint8_t *src_,
170
+ const uint16_t *src = (const uint16_t *)src_;
171
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
173
+ unsigned int r, g, b;
174
+ const uint16_t *end = src + width;
175
+ while (src < end) {
176
+ data = lduw_raw(src++);
177
+ b = (data & 0x0f) << 4;
179
+ r = (data & 0xf00) >> 4;
180
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
184
+static void glue(omap_dss_draw_line16_, DEPTH)(void *opaque,
186
+ const uint8_t *src_,
190
+#if !defined(SWAP_WORDS) && DEPTH == 16
191
+ memcpy(dest_, src_, width << 1);
193
+ const uint16_t *src = (const uint16_t *)src_;
194
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
196
+ unsigned int r, g, b;
197
+ const uint16_t *end = src + width;
198
+ while (src < end) {
199
+ data = lduw_raw(src++);
200
+ b = (data & 0x1f) << 3;
201
+ g = (data & 0x7e0) >> 3;
203
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
208
+static void glue(omap_dss_draw_line24a_, DEPTH)(void *opaque,
210
+ const uint8_t *src,
214
+#if !defined(SWAP_WORDS) && DEPTH == 32
215
+ memcpy(dest_, src, width << 2);
217
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
218
+ unsigned int r, g, b;
219
+ const uint8_t *end = src + (width << 2);
220
+ while (src < end) {
221
+ b = ldub_raw(src++);
222
+ g = ldub_raw(src++);
223
+ r = ldub_raw(src++);
225
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
230
+static void glue(omap_dss_draw_line24b_, DEPTH)(void *opaque,
232
+ const uint8_t *src,
237
+ memcpy(dest_, src, width * 3);
239
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
240
+ unsigned int r, g, b;
241
+ const uint8_t *end = src + width * 3;
242
+ while (src < end) {
243
+ b = ldub_raw(src++);
244
+ g = ldub_raw(src++);
245
+ r = ldub_raw(src++);
246
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
251
+static void glue(omap_dss_draw_line24c_, DEPTH)(void *opaque,
253
+ const uint8_t *src,
257
+ PIXEL_TYPE *dest = (PIXEL_TYPE *)dest_;
258
+ unsigned int r, g, b;
259
+ const uint8_t *end = src + (width << 2);
260
+ while (src < end) {
262
+ b = ldub_raw(src++);
263
+ g = ldub_raw(src++);
264
+ r = ldub_raw(src++);
265
+ COPY_PIXEL1(dest, glue(rgb_to_pixel, DEPTH)(r, g, b));
270
+static const drawfn glue(omap_dss_drawfn_, DEPTH)[0x10] = {
271
+ (drawfn)glue(omap_dss_draw_line1_, DEPTH),
272
+ (drawfn)glue(omap_dss_draw_line2_, DEPTH),
273
+ (drawfn)glue(omap_dss_draw_line4_, DEPTH),
274
+ (drawfn)glue(omap_dss_draw_line8_, DEPTH),
275
+ (drawfn)glue(omap_dss_draw_line12_, DEPTH),
277
+ (drawfn)glue(omap_dss_draw_line16_, DEPTH),
279
+ (drawfn)glue(omap_dss_draw_line24a_, DEPTH),
280
+ (drawfn)glue(omap_dss_draw_line24b_, DEPTH),
281
+ NULL, /* YUV2 4:2:2 */
282
+ NULL, /* UYVY 4:2:2 */
283
+ (drawfn)glue(omap_dss_draw_line24a_, DEPTH), /* FIXME: handle alpha */
284
+ (drawfn)glue(omap_dss_draw_line24c_, DEPTH), /* FIXME: handle alpha */
285
+ (drawfn)glue(omap_dss_draw_line24c_, DEPTH),
289
+/* 90deg, 180deg and 270deg rotation */
290
+//static omap3_lcd_panel_fn_t glue(omap3_lcd_panel_draw_fn_r_, DEPTH)[0x10] = {
292
+// [0 ... 0xf] = NULL,