Do not allow AIO to be inited multiple times
[qemu-kvm/fedora.git] / hw / cirrus_vga_rop.h
blob0079d12701dbe30ac01749eeac57c2577bbfab75
1 /*
2 * QEMU Cirrus CLGD 54xx VGA Emulator.
4 * Copyright (c) 2004 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 static void
26 glue(cirrus_bitblt_rop_fwd_, ROP_NAME)(CirrusVGAState *s,
27 uint8_t *dst,const uint8_t *src,
28 int dstpitch,int srcpitch,
29 int bltwidth,int bltheight)
31 int x,y;
32 dstpitch -= bltwidth;
33 srcpitch -= bltwidth;
35 if (dstpitch < 0 || srcpitch < 0) {
36 /* is 0 valid? srcpitch == 0 could be useful */
37 return;
40 for (y = 0; y < bltheight; y++) {
41 for (x = 0; x < bltwidth; x++) {
42 ROP_OP(*dst, *src);
43 dst++;
44 src++;
46 dst += dstpitch;
47 src += srcpitch;
51 static void
52 glue(cirrus_bitblt_rop_bkwd_, ROP_NAME)(CirrusVGAState *s,
53 uint8_t *dst,const uint8_t *src,
54 int dstpitch,int srcpitch,
55 int bltwidth,int bltheight)
57 int x,y;
58 dstpitch += bltwidth;
59 srcpitch += bltwidth;
60 for (y = 0; y < bltheight; y++) {
61 for (x = 0; x < bltwidth; x++) {
62 ROP_OP(*dst, *src);
63 dst--;
64 src--;
66 dst += dstpitch;
67 src += srcpitch;
71 static void
72 glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
73 uint8_t *dst,const uint8_t *src,
74 int dstpitch,int srcpitch,
75 int bltwidth,int bltheight)
77 int x,y;
78 uint8_t p;
79 dstpitch -= bltwidth;
80 srcpitch -= bltwidth;
81 for (y = 0; y < bltheight; y++) {
82 for (x = 0; x < bltwidth; x++) {
83 p = *dst;
84 ROP_OP(p, *src);
85 if (p != s->gr[0x34]) *dst = p;
86 dst++;
87 src++;
89 dst += dstpitch;
90 src += srcpitch;
94 static void
95 glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_8)(CirrusVGAState *s,
96 uint8_t *dst,const uint8_t *src,
97 int dstpitch,int srcpitch,
98 int bltwidth,int bltheight)
100 int x,y;
101 uint8_t p;
102 dstpitch += bltwidth;
103 srcpitch += bltwidth;
104 for (y = 0; y < bltheight; y++) {
105 for (x = 0; x < bltwidth; x++) {
106 p = *dst;
107 ROP_OP(p, *src);
108 if (p != s->gr[0x34]) *dst = p;
109 dst--;
110 src--;
112 dst += dstpitch;
113 src += srcpitch;
117 static void
118 glue(glue(cirrus_bitblt_rop_fwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
119 uint8_t *dst,const uint8_t *src,
120 int dstpitch,int srcpitch,
121 int bltwidth,int bltheight)
123 int x,y;
124 uint8_t p1, p2;
125 dstpitch -= bltwidth;
126 srcpitch -= bltwidth;
127 for (y = 0; y < bltheight; y++) {
128 for (x = 0; x < bltwidth; x+=2) {
129 p1 = *dst;
130 p2 = *(dst+1);
131 ROP_OP(p1, *src);
132 ROP_OP(p2, *(src+1));
133 if ((p1 != s->gr[0x34]) || (p2 != s->gr[0x35])) {
134 *dst = p1;
135 *(dst+1) = p2;
137 dst+=2;
138 src+=2;
140 dst += dstpitch;
141 src += srcpitch;
145 static void
146 glue(glue(cirrus_bitblt_rop_bkwd_transp_, ROP_NAME),_16)(CirrusVGAState *s,
147 uint8_t *dst,const uint8_t *src,
148 int dstpitch,int srcpitch,
149 int bltwidth,int bltheight)
151 int x,y;
152 uint8_t p1, p2;
153 dstpitch += bltwidth;
154 srcpitch += bltwidth;
155 for (y = 0; y < bltheight; y++) {
156 for (x = 0; x < bltwidth; x+=2) {
157 p1 = *(dst-1);
158 p2 = *dst;
159 ROP_OP(p1, *(src-1));
160 ROP_OP(p2, *src);
161 if ((p1 != s->gr[0x34]) || (p2 != s->gr[0x35])) {
162 *(dst-1) = p1;
163 *dst = p2;
165 dst-=2;
166 src-=2;
168 dst += dstpitch;
169 src += srcpitch;
173 #define DEPTH 8
174 #include "cirrus_vga_rop2.h"
176 #define DEPTH 16
177 #include "cirrus_vga_rop2.h"
179 #define DEPTH 24
180 #include "cirrus_vga_rop2.h"
182 #define DEPTH 32
183 #include "cirrus_vga_rop2.h"
185 #undef ROP_NAME
186 #undef ROP_OP