s3v_rop.h revision ba85709e
1
2/*
3Copyright (C) 1994-1998 The XFree86 Project, Inc.  All Rights Reserved.
4
5Permission is hereby granted, free of charge, to any person obtaining a copy of
6this software and associated documentation files (the "Software"), to deal in
7the Software without restriction, including without limitation the rights to
8use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9of the Software, and to permit persons to whom the Software is furnished to do
10so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all
13copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
17NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the XFree86 Project shall not
23be used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the XFree86 Project.
25*/
26
27/* This file contains the data structures which map the X ROPs to the
28 * ViRGE ROPs. It also contains other mappings which are used when supporting
29 * planemasks and transparency.
30 *
31 * Created by Sebastien Marineau, 29/03/97.
32 * This file should be included only from s3v_accel.c to avoid
33 * duplicate symbols.
34 *
35 */
36
37#include "regs3v.h"
38
39static int s3vAlu[16] =
40{
41   ROP_0,               /* GXclear */
42   ROP_DSa,             /* GXand */
43   ROP_SDna,            /* GXandReverse */
44   ROP_S,               /* GXcopy */
45   ROP_DSna,            /* GXandInverted */
46   ROP_D,               /* GXnoop */
47   ROP_DSx,             /* GXxor */
48   ROP_DSo,             /* GXor */
49   ROP_DSon,            /* GXnor */
50   ROP_DSxn,            /* GXequiv */
51   ROP_Dn,              /* GXinvert*/
52   ROP_SDno,            /* GXorReverse */
53   ROP_Sn,              /* GXcopyInverted */
54   ROP_DSno,            /* GXorInverted */
55   ROP_DSan,            /* GXnand */
56   ROP_1                /* GXset */
57};
58
59/* S -> P, for solid and pattern fills. */
60static int s3vAlu_sp[16]=
61{
62   ROP_0,
63   ROP_DPa,
64   ROP_PDna,
65   ROP_P,
66   ROP_DPna,
67   ROP_D,
68   ROP_DPx,
69   ROP_DPo,
70   ROP_DPon,
71   ROP_DPxn,
72   ROP_Dn,
73   ROP_PDno,
74   ROP_Pn,
75   ROP_DPno,
76   ROP_DPan,
77   ROP_1
78};
79
80/* ROP  ->  (ROP & P) | (D & ~P) */
81/* These are used to support a planemask for S->D ops */
82static int s3vAlu_pat[16] =
83{
84   ROP_0_PaDPnao,
85   ROP_DSa_PaDPnao,
86   ROP_SDna_PaDPnao,
87   ROP_S_PaDPnao,
88   ROP_DSna_PaDPnao,
89   ROP_D_PaDPnao,
90   ROP_DSx_PaDPnao,
91   ROP_DSo_PaDPnao,
92   ROP_DSon_PaDPnao,
93   ROP_DSxn_PaDPnao,
94   ROP_Dn_PaDPnao,
95   ROP_SDno_PaDPnao,
96   ROP_Sn_PaDPnao,
97   ROP_DSno_PaDPnao,
98   ROP_DSan_PaDPnao,
99   ROP_1_PaDPnao
100};
101
102/* ROP_sp -> (ROP_sp & S) | (D & ~S) */
103/* This is used for our transparent mono pattern fills to support trans/plane*/
104static int s3vAlu_MonoTrans[16] =
105{
106   ROP_0_SaDSnao,
107   ROP_DPa_SaDSnao,
108   ROP_PDna_SaDSnao,
109   ROP_P_SaDSnao,
110   ROP_DPna_SaDSnao,
111   ROP_D_SaDSnao,
112   ROP_DPx_SaDSnao,
113   ROP_DPo_SaDSnao,
114   ROP_DPon_SaDSnao,
115   ROP_DPxn_SaDSnao,
116   ROP_Dn_SaDSnao,
117   ROP_PDno_SaDSnao,
118   ROP_Pn_SaDSnao,
119   ROP_DPno_SaDSnao,
120   ROP_DPan_SaDSnao,
121   ROP_1_SaDSnao
122};
123
124
125
126/* This function was taken from accel/s3v.h. It adjusts the width
127 * of transfers for mono images to works around some bugs.
128 */
129
130static __inline__ int S3VCheckLSPN(S3VPtr ps3v, int w, int dir)
131{
132   int lspn = (w * ps3v->Bpp) & 63;  /* scanline width in bytes modulo 64*/
133
134   if (ps3v->Bpp == 1) {
135      if (lspn <= 8*1)
136	 w += 16;
137      else if (lspn <= 16*1)
138	 w += 8;
139   } else if (ps3v->Bpp == 2) {
140      if (lspn <= 4*2)
141	 w += 8;
142      else if (lspn <= 8*2)
143	 w += 4;
144   } else {  /* ps3v->Bpp == 3 */
145      if (lspn <= 3*3)
146	 w += 6;
147      else if (lspn <= 6*3)
148	 w += 3;
149   }
150   if (dir && w >= ps3v->bltbug_width1 && w <= ps3v->bltbug_width2) {
151      w = ps3v->bltbug_width2 + 1;
152   }
153
154   return w;
155}
156
157/* And this adjusts color bitblts widths to work around GE bugs */
158
159static __inline__ int S3VCheckBltWidth(S3VPtr ps3v, int w)
160{
161   if (w >= ps3v->bltbug_width1 && w <= ps3v->bltbug_width2) {
162      w = ps3v->bltbug_width2 + 1;
163   }
164   return w;
165}
166
167/* This next function determines if the Source operand is present in the
168 * given ROP. The rule is that both the lower and upper nibble of the rop
169 * have to be neither 0x00, 0x05, 0x0a or 0x0f. If a CPU-Screen blit is done
170 * with a ROP which does not contain the source, the virge will hang when
171 * data is written to the image transfer area.
172 */
173
174static __inline__ Bool S3VROPHasSrc(int shifted_rop)
175{
176    int rop = (shifted_rop & (0xff << 17)) >> 17;
177
178    if ((((rop & 0x0f) == 0x0a) | ((rop & 0x0f) == 0x0f)
179        | ((rop & 0x0f) == 0x05) | ((rop & 0x0f) == 0x00)) &
180       (((rop & 0xf0) == 0xa0) | ((rop & 0xf0) == 0xf0)
181        | ((rop & 0xf0) == 0x50) | ((rop & 0xf0) == 0x00)))
182            return FALSE;
183    else
184            return TRUE;
185}
186
187/* This next function determines if the Destination operand is present in the
188 * given ROP. The rule is that both the lower and upper nibble of the rop
189 * have to be neither 0x00, 0x03, 0x0c or 0x0f.
190 */
191
192static __inline__ Bool S3VROPHasDst(int shifted_rop)
193{
194    int rop = (shifted_rop & (0xff << 17)) >> 17;
195
196    if ((((rop & 0x0f) == 0x0c) | ((rop & 0x0f) == 0x0f)
197        | ((rop & 0x0f) == 0x03) | ((rop & 0x0f) == 0x00)) &
198       (((rop & 0xf0) == 0xc0) | ((rop & 0xf0) == 0xf0)
199        | ((rop & 0xf0) == 0x30) | ((rop & 0xf0) == 0x00)))
200            return FALSE;
201    else
202            return TRUE;
203}
204
205
206
207