Separate out off-screen allocation from Init. Fix Enable to update
off-screen addresses. Wrap RandR to update off-screen addresses. Set off_screen_base and memory_size fields correctly.
This commit is contained in:
parent
5b75aae2cf
commit
7ff67f2872
@ -203,6 +203,9 @@ ATICardInit(KdCardInfo *card)
|
||||
atic->backend_funcs.disable = fbdevDisable;
|
||||
atic->backend_funcs.getColors = fbdevGetColors;
|
||||
atic->backend_funcs.putColors = fbdevPutColors;
|
||||
#ifdef RANDR
|
||||
atic->backend_funcs.randrSetConfig = fbdevRandRSetConfig;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#ifdef KDRIVEVESA
|
||||
@ -221,6 +224,9 @@ ATICardInit(KdCardInfo *card)
|
||||
atic->backend_funcs.disable = vesaDisable;
|
||||
atic->backend_funcs.getColors = vesaGetColors;
|
||||
atic->backend_funcs.putColors = vesaPutColors;
|
||||
#ifdef RANDR
|
||||
atic->backend_funcs.randrSetConfig = vesaRandRSetConfig;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -277,62 +283,31 @@ ATICardFini(KdCardInfo *card)
|
||||
atic->backend_funcs.cardfini(card);
|
||||
}
|
||||
|
||||
static Bool
|
||||
ATIScreenInit(KdScreenInfo *screen)
|
||||
/*
|
||||
* Once screen->off_screen_base is set, this function
|
||||
* allocates the remaining memory appropriately
|
||||
*/
|
||||
|
||||
static void
|
||||
ATISetOffscreen (KdScreenInfo *screen)
|
||||
{
|
||||
ATIScreenInfo *atis;
|
||||
ATICardInfo(screen);
|
||||
Bool success = FALSE;
|
||||
int screen_size = 0;
|
||||
int cursor_size;
|
||||
ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
|
||||
int screen_size = screen->fb[0].byteStride * screen->height;
|
||||
#if defined(USE_DRI) && defined(GLXEXT)
|
||||
int l;
|
||||
#endif
|
||||
|
||||
atis = xcalloc(sizeof(ATIScreenInfo), 1);
|
||||
if (atis == NULL)
|
||||
return FALSE;
|
||||
|
||||
atis->atic = atic;
|
||||
atis->screen = screen;
|
||||
screen->driver = atis;
|
||||
|
||||
#ifdef KDRIVEFBDEV
|
||||
if (atic->use_fbdev) {
|
||||
success = fbdevScreenInitialize(screen,
|
||||
&atis->backend_priv.fbdev);
|
||||
screen->memory_size = atic->backend_priv.fbdev.fix.smem_len;
|
||||
screen_size = atic->backend_priv.fbdev.var.yres_virtual *
|
||||
screen->fb[0].byteStride;
|
||||
}
|
||||
#endif
|
||||
#ifdef KDRIVEVESA
|
||||
if (atic->use_vesa) {
|
||||
if (screen->fb[0].depth == 0)
|
||||
screen->fb[0].depth = 16;
|
||||
success = vesaScreenInitialize(screen,
|
||||
&atis->backend_priv.vesa);
|
||||
screen_size = screen->off_screen_base;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!success) {
|
||||
screen->driver = NULL;
|
||||
xfree(atis);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
screen->off_screen_base = screen_size;
|
||||
|
||||
if (atic->is_radeon)
|
||||
cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4;
|
||||
atis->cursor.cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4;
|
||||
else
|
||||
cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 2;
|
||||
/* Reserve the area for the cursor. */
|
||||
if (screen->off_screen_base + cursor_size <= screen->memory_size) {
|
||||
atis->cursor.offset = screen->off_screen_base;
|
||||
screen->off_screen_base += cursor_size;
|
||||
}
|
||||
atis->cursor.cursor_size = ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 3;
|
||||
|
||||
atis->cursor.offset = screen->off_screen_base;
|
||||
|
||||
screen->off_screen_base += atis->cursor.cursor_size;
|
||||
|
||||
#if defined(USE_DRI) && defined(GLXEXT)
|
||||
/* Reserve a static area for the back buffer the same size as the
|
||||
@ -393,13 +368,84 @@ ATIScreenInit(KdScreenInfo *screen)
|
||||
atis->scratch_offset = screen->off_screen_base;
|
||||
screen->off_screen_base += atis->scratch_size;
|
||||
atis->scratch_next = atis->scratch_offset;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
atis->scratch_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static Bool
|
||||
ATIScreenInit(KdScreenInfo *screen)
|
||||
{
|
||||
ATIScreenInfo *atis;
|
||||
ATICardInfo(screen);
|
||||
Bool success = FALSE;
|
||||
|
||||
atis = xcalloc(sizeof(ATIScreenInfo), 1);
|
||||
if (atis == NULL)
|
||||
return FALSE;
|
||||
|
||||
atis->atic = atic;
|
||||
atis->screen = screen;
|
||||
screen->driver = atis;
|
||||
|
||||
if (screen->fb[0].depth == 0)
|
||||
screen->fb[0].depth = 16;
|
||||
#ifdef KDRIVEFBDEV
|
||||
if (atic->use_fbdev) {
|
||||
success = fbdevScreenInitialize(screen,
|
||||
&atis->backend_priv.fbdev);
|
||||
}
|
||||
#endif
|
||||
#ifdef KDRIVEVESA
|
||||
if (atic->use_vesa) {
|
||||
success = vesaScreenInitialize(screen,
|
||||
&atis->backend_priv.vesa);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!success) {
|
||||
screen->driver = NULL;
|
||||
xfree(atis);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ATISetOffscreen (screen);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef RANDR
|
||||
static Bool
|
||||
ATIRandRSetConfig (ScreenPtr pScreen,
|
||||
Rotation randr,
|
||||
int rate,
|
||||
RRScreenSizePtr pSize)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
KdScreenInfo *screen = pScreenPriv->screen;
|
||||
ATICardInfo *atic = screen->card->driver;
|
||||
Bool ret;
|
||||
|
||||
ATIDrawDisable (pScreen);
|
||||
ret = atic->backend_funcs.randrSetConfig(pScreen, randr, rate, pSize);
|
||||
ATISetOffscreen (screen);
|
||||
ATIDrawEnable (pScreen);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Bool
|
||||
ATIRandRInit (ScreenPtr pScreen)
|
||||
{
|
||||
rrScrPrivPtr pScrPriv;
|
||||
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
pScrPriv->rrSetConfig = ATIRandRSetConfig;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
ATIScreenFini(KdScreenInfo *screen)
|
||||
{
|
||||
@ -459,7 +505,13 @@ ATIFinishInitScreen(ScreenPtr pScreen)
|
||||
KdScreenPriv(pScreen);
|
||||
ATICardInfo(pScreenPriv);
|
||||
|
||||
return atic->backend_funcs.finishInitScreen(pScreen);
|
||||
if (!atic->backend_funcs.finishInitScreen(pScreen))
|
||||
return FALSE;
|
||||
#ifdef RANDR
|
||||
if (!ATIRandRInit (pScreen))
|
||||
return FALSE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
@ -507,6 +559,8 @@ ATIEnable(ScreenPtr pScreen)
|
||||
if (!atic->backend_funcs.enable(pScreen))
|
||||
return FALSE;
|
||||
|
||||
ATISetOffscreen (pScreenPriv->screen);
|
||||
|
||||
if ((atic->reg_base == NULL) && !ATIMapReg(pScreenPriv->screen->card,
|
||||
atic))
|
||||
return FALSE;
|
||||
|
@ -122,6 +122,9 @@ struct backend_funcs {
|
||||
void (*disable)(ScreenPtr);
|
||||
void (*getColors)(ScreenPtr, int, int, xColorItem *);
|
||||
void (*putColors)(ScreenPtr, int, int, xColorItem *);
|
||||
#ifdef RANDR
|
||||
Bool (*randrSetConfig) (ScreenPtr, Rotation, int, RRScreenSizePtr);
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct _ATICardInfo {
|
||||
@ -161,6 +164,8 @@ typedef struct _ATICursor {
|
||||
Pixel source, mask;
|
||||
KdOffscreenArea *area;
|
||||
CARD32 offset;
|
||||
|
||||
int cursor_size;
|
||||
} ATICursor;
|
||||
|
||||
typedef struct _ATIPortPriv {
|
||||
|
@ -495,7 +495,7 @@ ATICursorInit(ScreenPtr pScreen)
|
||||
|
||||
pCurPriv->has_cursor = FALSE;
|
||||
|
||||
if (pCurPriv->offset == 0)
|
||||
if (pCurPriv->cursor_size == 0)
|
||||
return FALSE;
|
||||
|
||||
if (atic->reg_base == NULL)
|
||||
|
@ -175,7 +175,9 @@ RadeonSwitchTo2D(ATIScreenInfo *atis)
|
||||
{
|
||||
RING_LOCALS;
|
||||
|
||||
BEGIN_DMA(2);
|
||||
BEGIN_DMA(4);
|
||||
OUT_REG(RADEON_REG_RB2D_DSTCACHE_CTLSTAT,
|
||||
RADEON_RB2D_DC_FLUSH);
|
||||
OUT_REG(ATI_REG_WAIT_UNTIL,
|
||||
RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
|
||||
END_DMA();
|
||||
@ -186,7 +188,9 @@ RadeonSwitchTo3D(ATIScreenInfo *atis)
|
||||
{
|
||||
RING_LOCALS;
|
||||
|
||||
BEGIN_DMA(2);
|
||||
BEGIN_DMA(4);
|
||||
OUT_REG(RADEON_REG_RB2D_DSTCACHE_CTLSTAT,
|
||||
RADEON_RB2D_DC_FLUSH);
|
||||
OUT_REG(ATI_REG_WAIT_UNTIL,
|
||||
RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_2D_IDLECLEAN);
|
||||
END_DMA();
|
||||
@ -658,10 +662,9 @@ ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
|
||||
}
|
||||
|
||||
static void
|
||||
ATIBlockHandler (int screen, pointer blockData, pointer timeout,
|
||||
pointer readmask)
|
||||
ATIBlockHandler (pointer blockData, OSTimePtr timeout, pointer readmask)
|
||||
{
|
||||
ScreenPtr pScreen = screenInfo.screens[screen];
|
||||
ScreenPtr pScreen = (ScreenPtr) blockData;
|
||||
KdScreenPriv(pScreen);
|
||||
ATIScreenInfo(pScreenPriv);
|
||||
|
||||
@ -671,6 +674,11 @@ ATIBlockHandler (int screen, pointer blockData, pointer timeout,
|
||||
ATIFlushIndirect(atis, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
ATIWakeupHandler (pointer blockData, int result, pointer readmask)
|
||||
{
|
||||
}
|
||||
|
||||
Bool
|
||||
ATIDrawInit(ScreenPtr pScreen)
|
||||
{
|
||||
@ -774,8 +782,8 @@ ATIDrawEnable(ScreenPtr pScreen)
|
||||
atis->kaa.UploadToScreen = ATIUploadToScreen;
|
||||
atis->kaa.UploadToScratch = ATIUploadToScratch;
|
||||
|
||||
atis->save_blockhandler = pScreen->BlockHandler;
|
||||
pScreen->BlockHandler = ATIBlockHandler;
|
||||
RegisterBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
|
||||
pScreen);
|
||||
|
||||
KdMarkSync(pScreen);
|
||||
}
|
||||
@ -783,19 +791,17 @@ ATIDrawEnable(ScreenPtr pScreen)
|
||||
void
|
||||
ATIDrawDisable(ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
ATIScreenInfo(pScreenPriv);
|
||||
|
||||
ATIDMATeardown(pScreen);
|
||||
|
||||
pScreen->BlockHandler = atis->save_blockhandler;
|
||||
RemoveBlockAndWakeupHandlers (ATIBlockHandler, ATIWakeupHandler,
|
||||
pScreen);
|
||||
}
|
||||
|
||||
void
|
||||
ATIDrawFini(ScreenPtr pScreen)
|
||||
{
|
||||
KdScreenPriv(pScreen);
|
||||
#ifdef USE_DRI
|
||||
KdScreenPriv(pScreen);
|
||||
ATIScreenInfo(pScreenPriv);
|
||||
if (atis->using_dri) {
|
||||
ATIDRICloseScreen(pScreen);
|
||||
|
@ -333,14 +333,14 @@ fbdevMapFramebuffer (KdScreenInfo *screen)
|
||||
screen->width = priv->var.xres;
|
||||
screen->height = priv->var.yres;
|
||||
screen->memory_base = (CARD8 *) (priv->fb);
|
||||
screen->memory_size = 0;
|
||||
screen->off_screen_base = 0;
|
||||
screen->memory_size = priv->fix.smem_len;
|
||||
|
||||
if (scrpriv->shadow)
|
||||
{
|
||||
if (!KdShadowFbAlloc (screen, 0,
|
||||
scrpriv->randr & (RR_Rotate_90|RR_Rotate_270)))
|
||||
return FALSE;
|
||||
screen->off_screen_base = screen->memory_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -348,6 +348,7 @@ fbdevMapFramebuffer (KdScreenInfo *screen)
|
||||
screen->fb[0].pixelStride = (priv->fix.line_length * 8 /
|
||||
priv->var.bits_per_pixel);
|
||||
screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
|
||||
screen->off_screen_base = screen->fb[0].byteStride * screen->height;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user