1706f2543Smrg/*
2706f2543Smrg * Copyright (c) 1987, Oracle and/or its affiliates. All rights reserved.
3706f2543Smrg *
4706f2543Smrg * Permission is hereby granted, free of charge, to any person obtaining a
5706f2543Smrg * copy of this software and associated documentation files (the "Software"),
6706f2543Smrg * to deal in the Software without restriction, including without limitation
7706f2543Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8706f2543Smrg * and/or sell copies of the Software, and to permit persons to whom the
9706f2543Smrg * Software is furnished to do so, subject to the following conditions:
10706f2543Smrg *
11706f2543Smrg * The above copyright notice and this permission notice (including the next
12706f2543Smrg * paragraph) shall be included in all copies or substantial portions of the
13706f2543Smrg * Software.
14706f2543Smrg *
15706f2543Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16706f2543Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17706f2543Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18706f2543Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19706f2543Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20706f2543Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21706f2543Smrg * DEALINGS IN THE SOFTWARE.
22706f2543Smrg */
23706f2543Smrg
24706f2543Smrg/**
25706f2543Smrg * This version of fbcmap.c is implemented in terms of mi functions.
26706f2543Smrg * These functions used to be in fbcmap.c and depended upon the symbol
27706f2543Smrg * XFree86Server being defined.
28706f2543Smrg */
29706f2543Smrg
30706f2543Smrg
31706f2543Smrg#ifdef HAVE_DIX_CONFIG_H
32706f2543Smrg#include <dix-config.h>
33706f2543Smrg#endif
34706f2543Smrg
35706f2543Smrg#include <X11/X.h>
36706f2543Smrg#include "fb.h"
37706f2543Smrg#include "micmap.h"
38706f2543Smrg
39706f2543Smrgint
40706f2543SmrgfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
41706f2543Smrg{
42706f2543Smrg    return miListInstalledColormaps(pScreen, pmaps);
43706f2543Smrg}
44706f2543Smrg
45706f2543Smrgvoid
46706f2543SmrgfbInstallColormap(ColormapPtr pmap)
47706f2543Smrg{
48706f2543Smrg    miInstallColormap(pmap);
49706f2543Smrg}
50706f2543Smrg
51706f2543Smrgvoid
52706f2543SmrgfbUninstallColormap(ColormapPtr pmap)
53706f2543Smrg{
54706f2543Smrg    miUninstallColormap(pmap);
55706f2543Smrg}
56706f2543Smrg
57706f2543Smrgvoid
58706f2543SmrgfbResolveColor(unsigned short   *pred,
59706f2543Smrg	       unsigned short   *pgreen,
60706f2543Smrg	       unsigned short   *pblue,
61706f2543Smrg	       VisualPtr	pVisual)
62706f2543Smrg{
63706f2543Smrg    miResolveColor(pred, pgreen, pblue, pVisual);
64706f2543Smrg}
65706f2543Smrg
66706f2543SmrgBool
67706f2543SmrgfbInitializeColormap(ColormapPtr pmap)
68706f2543Smrg{
69706f2543Smrg    return miInitializeColormap(pmap);
70706f2543Smrg}
71706f2543Smrg
7288c603c7StsutsuiBool
7388c603c7StsutsuimfbCreateColormap(ColormapPtr pmap)
7488c603c7Stsutsui{
7588c603c7Stsutsui    ScreenPtr	pScreen;
7688c603c7Stsutsui    unsigned short  red0, green0, blue0;
7788c603c7Stsutsui    unsigned short  red1, green1, blue1;
7888c603c7Stsutsui    Pixel pix;
7988c603c7Stsutsui
8088c603c7Stsutsui    pScreen = pmap->pScreen;
8188c603c7Stsutsui    if (pScreen->whitePixel == 0)
8288c603c7Stsutsui    {
8388c603c7Stsutsui	red0 = green0 = blue0 = ~0;
8488c603c7Stsutsui	red1 = green1 = blue1 = 0;
8588c603c7Stsutsui    }
8688c603c7Stsutsui    else
8788c603c7Stsutsui    {
8888c603c7Stsutsui	red0 = green0 = blue0 = 0;
8988c603c7Stsutsui	red1 = green1 = blue1 = ~0;
9088c603c7Stsutsui    }
9188c603c7Stsutsui
9288c603c7Stsutsui    /* this is a monochrome colormap, it only has two entries, just fill
9388c603c7Stsutsui     * them in by hand.  If it were a more complex static map, it would be
9488c603c7Stsutsui     * worth writing a for loop or three to initialize it */
9588c603c7Stsutsui
9688c603c7Stsutsui    /* this will be pixel 0 */
9788c603c7Stsutsui    pix = 0;
9888c603c7Stsutsui    if (AllocColor(pmap, &red0, &green0, &blue0, &pix, 0) != Success)
9988c603c7Stsutsui	return FALSE;
10088c603c7Stsutsui
10188c603c7Stsutsui    /* this will be pixel 1 */
10288c603c7Stsutsui    if (AllocColor(pmap, &red1, &green1, &blue1, &pix, 0) != Success)
10388c603c7Stsutsui	return FALSE;
10488c603c7Stsutsui    return TRUE;
10588c603c7Stsutsui}
10688c603c7Stsutsui
107706f2543Smrgint
108706f2543SmrgfbExpandDirectColors (ColormapPtr   pmap,
109706f2543Smrg		      int	    ndef,
110706f2543Smrg		      xColorItem    *indefs,
111706f2543Smrg		      xColorItem    *outdefs)
112706f2543Smrg{
113706f2543Smrg    return miExpandDirectColors(pmap, ndef, indefs, outdefs);
114706f2543Smrg}
115706f2543Smrg
116706f2543SmrgBool
117706f2543SmrgfbCreateDefColormap(ScreenPtr pScreen)
118706f2543Smrg{
119706f2543Smrg    return miCreateDefColormap(pScreen);
120706f2543Smrg}
121706f2543Smrg
122706f2543Smrgvoid
123706f2543SmrgfbClearVisualTypes(void)
124706f2543Smrg{
125706f2543Smrg    miClearVisualTypes();
126706f2543Smrg}
127706f2543Smrg
128706f2543SmrgBool
129706f2543SmrgfbSetVisualTypes (int depth, int visuals, int bitsPerRGB)
130706f2543Smrg{
131706f2543Smrg    return miSetVisualTypes(depth, visuals, bitsPerRGB, -1);
132706f2543Smrg}
133706f2543Smrg
134706f2543SmrgBool
135706f2543SmrgfbSetVisualTypesAndMasks (int depth, int visuals, int bitsPerRGB,
136706f2543Smrg                          Pixel redMask, Pixel greenMask, Pixel blueMask)
137706f2543Smrg{
138706f2543Smrg    return miSetVisualTypesAndMasks(depth, visuals, bitsPerRGB, -1,
139706f2543Smrg                                    redMask, greenMask, blueMask);
140706f2543Smrg}
141706f2543Smrg
142706f2543Smrg/*
143706f2543Smrg * Given a list of formats for a screen, create a list
144706f2543Smrg * of visuals and depths for the screen which coorespond to
145706f2543Smrg * the set which can be used with this version of fb.
146706f2543Smrg */
147706f2543SmrgBool
148706f2543SmrgfbInitVisuals (VisualPtr    *visualp,
149706f2543Smrg	       DepthPtr	    *depthp,
150706f2543Smrg	       int	    *nvisualp,
151706f2543Smrg	       int	    *ndepthp,
152706f2543Smrg	       int	    *rootDepthp,
153706f2543Smrg	       VisualID	    *defaultVisp,
154706f2543Smrg	       unsigned long	sizes,
155706f2543Smrg	       int	    bitsPerRGB)
156706f2543Smrg{
157706f2543Smrg    return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
158706f2543Smrg			 defaultVisp, sizes, bitsPerRGB, -1);
159706f2543Smrg}
160