From 7fe60435bce6595a9c58a9bfd8244d74b5320e96 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 15 Jan 2013 08:46:13 +0100 Subject: Import DirectFB141_2k11R3_beta5 --- Source/DirectFB/gfxdrivers/radeon/radeon_crtc1.c | 171 +++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100755 Source/DirectFB/gfxdrivers/radeon/radeon_crtc1.c (limited to 'Source/DirectFB/gfxdrivers/radeon/radeon_crtc1.c') diff --git a/Source/DirectFB/gfxdrivers/radeon/radeon_crtc1.c b/Source/DirectFB/gfxdrivers/radeon/radeon_crtc1.c new file mode 100755 index 0000000..c4b1610 --- /dev/null +++ b/Source/DirectFB/gfxdrivers/radeon/radeon_crtc1.c @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2006 Claudio Ciccani + * + * Graphics driver for ATI Radeon cards written by + * Claudio Ciccani . + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "radeon.h" +#include "radeon_regs.h" +#include "radeon_mmio.h" + + + +/*************************** CRTC1 Screen functions **************************/ + +static DFBResult +crtc1WaitVSync( CoreScreen *screen, + void *driver_data, + void *screen_data ) +{ + RadeonDriverData *rdrv = (RadeonDriverData*) driver_data; + volatile u8 *mmio = rdrv->mmio_base; + int i; + + if (dfb_config->pollvsync_none) + return DFB_OK; + + radeon_out32( mmio, GEN_INT_STATUS, + (radeon_in32( mmio, GEN_INT_STATUS ) & ~VSYNC_INT) | VSYNC_INT_AK ); + + for (i = 0; i < 2000000; i++) { + struct timespec t = { 0, 10000 }; + + if (radeon_in32( mmio, GEN_INT_STATUS ) & VSYNC_INT) + break; + nanosleep( &t, NULL ); + } + + return DFB_OK; +} + +ScreenFuncs RadeonCrtc1ScreenFuncs = { + .WaitVSync = crtc1WaitVSync +}; + +ScreenFuncs OldPrimaryScreenFuncs; +void *OldPrimaryScreenDriverData; + + +/*************************** CRTC1 Layer functions **************************/ + +#define CRTC1_SUPPORTED_OPTIONS ( DLOP_ALPHACHANNEL ) + +static DFBResult +crtc1InitLayer( CoreLayer *layer, + void *driver_data, + void *layer_data, + DFBDisplayLayerDescription *description, + DFBDisplayLayerConfig *config, + DFBColorAdjustment *adjustment ) +{ + DFBResult ret; + + ret = OldPrimaryLayerFuncs.InitLayer( layer, + OldPrimaryLayerDriverData, + layer_data, description, + config, adjustment ); + + description->caps |= DLCAPS_ALPHACHANNEL; + + return ret; +} + +static DFBResult +crtc1TestRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags *failed ) +{ + CoreLayerRegionConfig layer_config; + CoreLayerRegionConfigFlags fail = 0; + DFBResult ret; + + layer_config = *config; + layer_config.options &= ~CRTC1_SUPPORTED_OPTIONS; + + ret = OldPrimaryLayerFuncs.TestRegion( layer, + OldPrimaryLayerDriverData, + layer_data, &layer_config, &fail ); + + if (config->options & ~CRTC1_SUPPORTED_OPTIONS) + fail |= CLRCF_OPTIONS; + + if (config->options & DLOP_ALPHACHANNEL && config->format != DSPF_ARGB) + fail |= CLRCF_OPTIONS; + + if (failed) + *failed = fail; + + return fail ? DFB_UNSUPPORTED : DFB_OK; +} + +static DFBResult +crtc1SetRegion( CoreLayer *layer, + void *driver_data, + void *layer_data, + void *region_data, + CoreLayerRegionConfig *config, + CoreLayerRegionConfigFlags updated, + CoreSurface *surface, + CorePalette *palette, + CoreSurfaceBufferLock *lock ) +{ + + if (updated & ~CLRCF_OPTIONS) { + return OldPrimaryLayerFuncs.SetRegion( layer, + OldPrimaryLayerDriverData, + layer_data, region_data, + config, updated, surface, palette, lock ); + } + + return DFB_OK; +} + +DisplayLayerFuncs RadeonCrtc1LayerFuncs = { + .InitLayer = crtc1InitLayer, + .TestRegion = crtc1TestRegion, + .SetRegion = crtc1SetRegion +}; + +DisplayLayerFuncs OldPrimaryLayerFuncs; +void *OldPrimaryLayerDriverData; + -- cgit