/* $XFree86$ */
/*
 * Copyright 2004 Alex Deucher.
 *
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation on the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial
 * portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NON-INFRINGEMENT.  IN NO EVENT SHALL ALEX DEUCHER, OR ANY OTHER
 * CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

/*
 * Authors:
 *   Alex Deucher <agd5f@yahoo.com>
 *
 */

#ifndef _SAVAGE_MERGEDFB_H_
#define _SAVAGE_MERGEDFB_H_

#include "xf86.h"

#include "savage_driver.h"


#define SDMPTR(x) ((SavageMergedDisplayModePtr)(x->currentMode->Private))
#define CDMPTR    ((SavageMergedDisplayModePtr)(psav->CurrentLayout.mode->Private))

#define BOUND(test,low,hi) { \
    if(test < low) test = low; \
    if(test > hi) test = hi; }

#define REBOUND(low,hi,test) { \
    if(test < low) { \
        hi += test-low; \
        low = test; } \
    if(test > hi) { \
        low += test-hi; \
        hi = test; } }

typedef struct _MergedDisplayModeRec {
    DisplayModePtr CRT1;
    DisplayModePtr CRT2;
    SavageScrn2Rel    CRT2Position;
} SavageMergedDisplayModeRec, *SavageMergedDisplayModePtr;

typedef struct _region {
    int x0,x1,y0,y1;
} region;

typedef struct _SavageXineramaData {
    int x;
    int y;
    int width;
    int height;
} SavageXineramaData;

/* needed by savage_driver.c */
extern void
SavageAdjustFrameMerged(int scrnIndex, int x, int y, int flags);
extern void
SavageMergePointerMoved(int scrnIndex, int x, int y);
extern DisplayModePtr
SavageGenerateModeList(ScrnInfoPtr pScrn, char* str,
		    DisplayModePtr i, DisplayModePtr j,
		    SavageScrn2Rel srel);
extern int
SavageStrToRanges(range *r, char *s, int max);
extern void
SavageXineramaExtensionInit(ScrnInfoPtr pScrn);
extern void
SavageUpdateXineramaScreenInfo(ScrnInfoPtr pScrn1);
extern void
SavageMergedFBSetDpi(ScrnInfoPtr pScrn1, ScrnInfoPtr pScrn2, SavageScrn2Rel srel);
extern void
SavageRecalcDefaultVirtualSize(ScrnInfoPtr pScrn);

/* needed by savage_cursor.c */
extern void
SavageSetCursorPositionMerged(ScrnInfoPtr pScrn, int x, int y);

#if 0
/* needed by savage_video.c */
extern void
SavageChooseOverlayCRTC(ScrnInfoPtr, BoxPtr);
#endif

#endif /* _SAVAGE_MERGEDFB_H_ */
