105b261ecSmrg
205b261ecSmrg/*
305b261ecSmrg * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
405b261ecSmrg *
505b261ecSmrg * Permission is hereby granted, free of charge, to any person obtaining a
605b261ecSmrg * copy of this software and associated documentation files (the "Software"),
705b261ecSmrg * to deal in the Software without restriction, including without limitation
805b261ecSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
905b261ecSmrg * and/or sell copies of the Software, and to permit persons to whom the
1005b261ecSmrg * Software is furnished to do so, subject to the following conditions:
1105b261ecSmrg *
1205b261ecSmrg * The above copyright notice and this permission notice shall be included in
1305b261ecSmrg * all copies or substantial portions of the Software.
1405b261ecSmrg *
1505b261ecSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1605b261ecSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1705b261ecSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1805b261ecSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1905b261ecSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2005b261ecSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2105b261ecSmrg * OTHER DEALINGS IN THE SOFTWARE.
2205b261ecSmrg *
2305b261ecSmrg * Except as contained in this notice, the name of the copyright holder(s)
2405b261ecSmrg * and author(s) shall not be used in advertising or otherwise to promote
2505b261ecSmrg * the sale, use or other dealings in this Software without prior written
2605b261ecSmrg * authorization from the copyright holder(s) and author(s).
2705b261ecSmrg */
2805b261ecSmrg
2905b261ecSmrg#ifndef _XF86FBMAN_H
3005b261ecSmrg#define _XF86FBMAN_H
3105b261ecSmrg
3205b261ecSmrg#include "scrnintstr.h"
3305b261ecSmrg#include "regionstr.h"
3405b261ecSmrg
3505b261ecSmrg#define FAVOR_AREA_THEN_WIDTH		0
3605b261ecSmrg#define FAVOR_AREA_THEN_HEIGHT		1
3705b261ecSmrg#define FAVOR_WIDTH_THEN_AREA		2
3805b261ecSmrg#define FAVOR_HEIGHT_THEN_AREA		3
3905b261ecSmrg
4005b261ecSmrg#define PRIORITY_LOW			0
4105b261ecSmrg#define PRIORITY_NORMAL			1
4205b261ecSmrg#define PRIORITY_EXTREME		2
4305b261ecSmrg
4405b261ecSmrgtypedef struct _FBArea {
4535c4bbdfSmrg    ScreenPtr pScreen;
4635c4bbdfSmrg    BoxRec box;
4735c4bbdfSmrg    int granularity;
4835c4bbdfSmrg    void (*MoveAreaCallback) (struct _FBArea *, struct _FBArea *);
4935c4bbdfSmrg    void (*RemoveAreaCallback) (struct _FBArea *);
5035c4bbdfSmrg    DevUnion devPrivate;
5105b261ecSmrg} FBArea, *FBAreaPtr;
5205b261ecSmrg
5305b261ecSmrgtypedef struct _FBLinear {
5435c4bbdfSmrg    ScreenPtr pScreen;
5535c4bbdfSmrg    int size;
5635c4bbdfSmrg    int offset;
5735c4bbdfSmrg    int granularity;
5835c4bbdfSmrg    void (*MoveLinearCallback) (struct _FBLinear *, struct _FBLinear *);
5935c4bbdfSmrg    void (*RemoveLinearCallback) (struct _FBLinear *);
6035c4bbdfSmrg    DevUnion devPrivate;
6105b261ecSmrg} FBLinear, *FBLinearPtr;
6205b261ecSmrg
6335c4bbdfSmrgtypedef void (*FreeBoxCallbackProcPtr) (ScreenPtr, RegionPtr, void *);
6435c4bbdfSmrgtypedef void (*MoveAreaCallbackProcPtr) (FBAreaPtr, FBAreaPtr);
6535c4bbdfSmrgtypedef void (*RemoveAreaCallbackProcPtr) (FBAreaPtr);
6605b261ecSmrg
6735c4bbdfSmrgtypedef void (*MoveLinearCallbackProcPtr) (FBLinearPtr, FBLinearPtr);
6835c4bbdfSmrgtypedef void (*RemoveLinearCallbackProcPtr) (FBLinearPtr);
6905b261ecSmrg
7005b261ecSmrgtypedef struct {
7135c4bbdfSmrg    FBAreaPtr(*AllocateOffscreenArea) (ScreenPtr pScreen,
7235c4bbdfSmrg                                       int w, int h,
7335c4bbdfSmrg                                       int granularity,
7435c4bbdfSmrg                                       MoveAreaCallbackProcPtr moveCB,
7535c4bbdfSmrg                                       RemoveAreaCallbackProcPtr removeCB,
7635c4bbdfSmrg                                       void *privData);
7735c4bbdfSmrg    void (*FreeOffscreenArea) (FBAreaPtr area);
7835c4bbdfSmrg    Bool (*ResizeOffscreenArea) (FBAreaPtr area, int w, int h);
7935c4bbdfSmrg    Bool (*QueryLargestOffscreenArea) (ScreenPtr pScreen,
8035c4bbdfSmrg                                       int *width, int *height,
8135c4bbdfSmrg                                       int granularity,
8235c4bbdfSmrg                                       int preferences, int priority);
8335c4bbdfSmrg    Bool (*RegisterFreeBoxCallback) (ScreenPtr pScreen,
8435c4bbdfSmrg                                     FreeBoxCallbackProcPtr FreeBoxCallback,
8535c4bbdfSmrg                                     void *devPriv);
8605b261ecSmrg/* linear functions */
8735c4bbdfSmrg     FBLinearPtr(*AllocateOffscreenLinear) (ScreenPtr pScreen,
8835c4bbdfSmrg                                            int size,
8935c4bbdfSmrg                                            int granularity,
9035c4bbdfSmrg                                            MoveLinearCallbackProcPtr moveCB,
9135c4bbdfSmrg                                            RemoveLinearCallbackProcPtr
9235c4bbdfSmrg                                            removeCB, void *privData);
9335c4bbdfSmrg    void (*FreeOffscreenLinear) (FBLinearPtr area);
9435c4bbdfSmrg    Bool (*ResizeOffscreenLinear) (FBLinearPtr area, int size);
9535c4bbdfSmrg    Bool (*QueryLargestOffscreenLinear) (ScreenPtr pScreen,
9635c4bbdfSmrg                                         int *size,
9735c4bbdfSmrg                                         int granularity, int priority);
9835c4bbdfSmrg    Bool (*PurgeOffscreenAreas) (ScreenPtr);
9905b261ecSmrg} FBManagerFuncs, *FBManagerFuncsPtr;
10005b261ecSmrg
10135c4bbdfSmrgextern _X_EXPORT Bool xf86RegisterOffscreenManager(ScreenPtr pScreen,
10235c4bbdfSmrg                                                   FBManagerFuncsPtr funcs);
10305b261ecSmrg
1046747b715Smrgextern _X_EXPORT Bool
10535c4bbdfSmrg xf86InitFBManagerRegion(ScreenPtr pScreen, RegionPtr ScreenRegion);
10605b261ecSmrg
1076747b715Smrgextern _X_EXPORT Bool
10835c4bbdfSmrg xf86InitFBManagerArea(ScreenPtr pScreen, int PixalArea, int Verbosity);
10905b261ecSmrg
1106747b715Smrgextern _X_EXPORT Bool
11135c4bbdfSmrg xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox);
11205b261ecSmrg
1136747b715Smrgextern _X_EXPORT Bool
11435c4bbdfSmrg xf86InitFBManagerLinear(ScreenPtr pScreen, int offset, int size);
11505b261ecSmrg
1166747b715Smrgextern _X_EXPORT Bool
11735c4bbdfSmrg xf86FBManagerRunning(ScreenPtr pScreen);
11805b261ecSmrg
1196747b715Smrgextern _X_EXPORT FBAreaPtr
12035c4bbdfSmrgxf86AllocateOffscreenArea(ScreenPtr pScreen,
12135c4bbdfSmrg                          int w, int h,
12235c4bbdfSmrg                          int granularity,
12335c4bbdfSmrg                          MoveAreaCallbackProcPtr moveCB,
12435c4bbdfSmrg                          RemoveAreaCallbackProcPtr removeCB, void *privData);
12505b261ecSmrg
1266747b715Smrgextern _X_EXPORT FBAreaPtr
12735c4bbdfSmrgxf86AllocateLinearOffscreenArea(ScreenPtr pScreen,
12835c4bbdfSmrg                                int length,
12935c4bbdfSmrg                                int granularity,
13035c4bbdfSmrg                                MoveAreaCallbackProcPtr moveCB,
13135c4bbdfSmrg                                RemoveAreaCallbackProcPtr removeCB,
13235c4bbdfSmrg                                void *privData);
13305b261ecSmrg
1346747b715Smrgextern _X_EXPORT FBLinearPtr
13535c4bbdfSmrgxf86AllocateOffscreenLinear(ScreenPtr pScreen,
13635c4bbdfSmrg                            int length,
13735c4bbdfSmrg                            int granularity,
13835c4bbdfSmrg                            MoveLinearCallbackProcPtr moveCB,
13935c4bbdfSmrg                            RemoveLinearCallbackProcPtr removeCB,
14035c4bbdfSmrg                            void *privData);
14105b261ecSmrg
1426747b715Smrgextern _X_EXPORT void xf86FreeOffscreenArea(FBAreaPtr area);
1436747b715Smrgextern _X_EXPORT void xf86FreeOffscreenLinear(FBLinearPtr area);
14405b261ecSmrg
1456747b715Smrgextern _X_EXPORT Bool
14635c4bbdfSmrg xf86ResizeOffscreenArea(FBAreaPtr resize, int w, int h);
14705b261ecSmrg
1486747b715Smrgextern _X_EXPORT Bool
14935c4bbdfSmrg xf86ResizeOffscreenLinear(FBLinearPtr resize, int size);
15005b261ecSmrg
1516747b715Smrgextern _X_EXPORT Bool
15205b261ecSmrg
15335c4bbdfSmrgxf86RegisterFreeBoxCallback(ScreenPtr pScreen,
15435c4bbdfSmrg                            FreeBoxCallbackProcPtr FreeBoxCallback,
15535c4bbdfSmrg                            void *devPriv);
15605b261ecSmrg
15735c4bbdfSmrgextern _X_EXPORT Bool
15835c4bbdfSmrg xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen);
15905b261ecSmrg
1606747b715Smrgextern _X_EXPORT Bool
16135c4bbdfSmrg
16235c4bbdfSmrgxf86QueryLargestOffscreenArea(ScreenPtr pScreen,
16335c4bbdfSmrg                              int *width, int *height,
16435c4bbdfSmrg                              int granularity, int preferences, int priority);
16505b261ecSmrg
1666747b715Smrgextern _X_EXPORT Bool
16705b261ecSmrg
16835c4bbdfSmrgxf86QueryLargestOffscreenLinear(ScreenPtr pScreen,
16935c4bbdfSmrg                                int *size, int granularity, int priority);
17005b261ecSmrg
17135c4bbdfSmrg#endif                          /* _XF86FBMAN_H */
172