~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to Xext/EVI.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: EVI.c,v 1.3 2000/08/17 19:47:55 cpqbld Exp $ */
 
2
/************************************************************
 
3
Copyright (c) 1997 by Silicon Graphics Computer Systems, Inc.
 
4
Permission to use, copy, modify, and distribute this
 
5
software and its documentation for any purpose and without
 
6
fee is hereby granted, provided that the above copyright
 
7
notice appear in all copies and that both that copyright
 
8
notice and this permission notice appear in supporting
 
9
documentation, and that the name of Silicon Graphics not be
 
10
used in advertising or publicity pertaining to distribution
 
11
of the software without specific prior written permission.
 
12
Silicon Graphics makes no representation about the suitability
 
13
of this software for any purpose. It is provided "as is"
 
14
without any express or implied warranty.
 
15
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
 
16
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 
17
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
 
18
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
 
19
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 
21
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
 
22
THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
23
********************************************************/
 
24
/* $XFree86: xc/programs/Xserver/Xext/EVI.c,v 3.10tsi Exp $ */
 
25
 
 
26
#ifdef HAVE_DIX_CONFIG_H
 
27
#include <dix-config.h>
 
28
#endif
 
29
 
 
30
#include <X11/X.h>
 
31
#include <X11/Xproto.h>
 
32
#include "dixstruct.h"
 
33
#include "extnsionst.h"
 
34
#include "dix.h"
 
35
#define _XEVI_SERVER_
 
36
#include <X11/extensions/XEVIstr.h>
 
37
#include "EVIstruct.h"
 
38
#include "modinit.h"
 
39
 
 
40
#if 0
 
41
static unsigned char XEVIReqCode = 0;
 
42
#endif
 
43
static EviPrivPtr eviPriv;
 
44
 
 
45
static int
 
46
ProcEVIQueryVersion(ClientPtr client)
 
47
{
 
48
    /* REQUEST(xEVIQueryVersionReq); */
 
49
    xEVIQueryVersionReply rep;
 
50
    register int n;
 
51
    REQUEST_SIZE_MATCH (xEVIQueryVersionReq);
 
52
    rep.type = X_Reply;
 
53
    rep.length = 0;
 
54
    rep.sequenceNumber = client->sequence;
 
55
    rep.majorVersion = XEVI_MAJOR_VERSION;
 
56
    rep.minorVersion = XEVI_MAJOR_VERSION;
 
57
    if (client->swapped) {
 
58
        swaps(&rep.sequenceNumber, n);
 
59
        swapl(&rep.length, n);
 
60
        swaps(&rep.majorVersion, n);
 
61
        swaps(&rep.minorVersion, n);
 
62
    }
 
63
    WriteToClient(client, sizeof (xEVIQueryVersionReply), (char *)&rep);
 
64
    return (client->noClientException);
 
65
}
 
66
#define swapEviInfo(eviInfo, l)                         \
 
67
{                                                       \
 
68
   int l1 = l;                                          \
 
69
   xExtendedVisualInfo *eviInfo1 = eviInfo;             \
 
70
   while (l1-- > 0) {                                   \
 
71
       swapl(&eviInfo1->core_visual_id, n);             \
 
72
       swapl(&eviInfo1->transparency_value, n);         \
 
73
       swaps(&eviInfo1->num_colormap_conflicts, n);     \
 
74
       eviInfo1++;                                      \
 
75
   }                                                    \
 
76
}
 
77
#define swapVisual(visual, l)                           \
 
78
{                                                       \
 
79
    int l1 = l;                                         \
 
80
    VisualID32 *visual1 = visual;                               \
 
81
    while (l1-- > 0) {                                  \
 
82
       swapl(visual1, n);                               \
 
83
       visual1++;                                       \
 
84
    }                                                   \
 
85
}
 
86
 
 
87
static int
 
88
ProcEVIGetVisualInfo(ClientPtr client)
 
89
{
 
90
    REQUEST(xEVIGetVisualInfoReq);
 
91
    xEVIGetVisualInfoReply rep;
 
92
    int n, n_conflict, n_info, sz_info, sz_conflict;
 
93
    VisualID32 *conflict;
 
94
    xExtendedVisualInfo *eviInfo;
 
95
    int status;
 
96
    REQUEST_FIXED_SIZE(xEVIGetVisualInfoReq, stuff->n_visual * sz_VisualID32);
 
97
    status = eviPriv->getVisualInfo((VisualID32 *)&stuff[1], (int)stuff->n_visual,
 
98
                &eviInfo, &n_info, &conflict, &n_conflict);
 
99
    if (status != Success)
 
100
        return status;
 
101
    sz_info = n_info * sz_xExtendedVisualInfo;
 
102
    sz_conflict = n_conflict * sz_VisualID32;
 
103
    rep.type = X_Reply;
 
104
    rep.n_info = n_info;
 
105
    rep.n_conflicts = n_conflict;
 
106
    rep.sequenceNumber = client->sequence;
 
107
    rep.length = (sz_info + sz_conflict) >> 2;
 
108
    if (client->swapped) {
 
109
        swaps(&rep.sequenceNumber, n);
 
110
        swapl(&rep.length, n);
 
111
        swapl(&rep.n_info, n);
 
112
        swapl(&rep.n_conflicts, n);
 
113
        swapEviInfo(eviInfo, n_info);
 
114
        swapVisual(conflict, n_conflict);
 
115
    }
 
116
    WriteToClient(client, sz_xEVIGetVisualInfoReply, (char *)&rep);
 
117
    WriteToClient(client, sz_info, (char *)eviInfo);
 
118
    WriteToClient(client, sz_conflict, (char *)conflict);
 
119
    eviPriv->freeVisualInfo(eviInfo, conflict);
 
120
    return (client->noClientException);
 
121
}
 
122
 
 
123
static int
 
124
ProcEVIDispatch(ClientPtr client)
 
125
{
 
126
    REQUEST(xReq);
 
127
    switch (stuff->data) {
 
128
    case X_EVIQueryVersion:
 
129
        return ProcEVIQueryVersion (client);
 
130
    case X_EVIGetVisualInfo:
 
131
        return ProcEVIGetVisualInfo (client);
 
132
    default:
 
133
        return BadRequest;
 
134
    }
 
135
}
 
136
 
 
137
static int
 
138
SProcEVIQueryVersion(ClientPtr client)
 
139
{
 
140
   REQUEST(xEVIQueryVersionReq);
 
141
   int n;
 
142
   swaps(&stuff->length, n);
 
143
   return ProcEVIQueryVersion(client);
 
144
}
 
145
 
 
146
static int
 
147
SProcEVIGetVisualInfo(ClientPtr client)
 
148
{
 
149
    register int n;
 
150
    REQUEST(xEVIGetVisualInfoReq);
 
151
    swaps(&stuff->length, n);
 
152
    return ProcEVIGetVisualInfo(client);
 
153
}
 
154
 
 
155
static int
 
156
SProcEVIDispatch(ClientPtr client)
 
157
{
 
158
    REQUEST(xReq);
 
159
    switch (stuff->data)
 
160
    {
 
161
    case X_EVIQueryVersion:
 
162
        return SProcEVIQueryVersion (client);
 
163
    case X_EVIGetVisualInfo:
 
164
        return SProcEVIGetVisualInfo (client);
 
165
    default:
 
166
        return BadRequest;
 
167
    }
 
168
}
 
169
 
 
170
/*ARGSUSED*/
 
171
static void
 
172
EVIResetProc(ExtensionEntry *extEntry)
 
173
{
 
174
    eviDDXReset();
 
175
}
 
176
 
 
177
/****************
 
178
 * XEVIExtensionInit
 
179
 *
 
180
 * Called from InitExtensions in main() or from QueryExtension() if the
 
181
 * extension is dynamically loaded.
 
182
 *
 
183
 ****************/
 
184
void
 
185
EVIExtensionInit(INITARGS)
 
186
{
 
187
#if 0
 
188
    ExtensionEntry *extEntry;
 
189
 
 
190
    if ((extEntry = AddExtension(EVINAME, 0, 0,
 
191
                                ProcEVIDispatch,
 
192
                                SProcEVIDispatch,
 
193
                                EVIResetProc, StandardMinorOpcode))) {
 
194
        XEVIReqCode = (unsigned char)extEntry->base;
 
195
#else
 
196
    if (AddExtension(EVINAME, 0, 0,
 
197
                     ProcEVIDispatch, SProcEVIDispatch,
 
198
                     EVIResetProc, StandardMinorOpcode)) {
 
199
#endif
 
200
        eviPriv = eviDDXInit();
 
201
    }
 
202
}