atiwonderio.c revision 32b578d3
1/* 2 * Copyright 2000 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org 3 * 4 * Permission to use, copy, modify, distribute, and sell this software and its 5 * documentation for any purpose is hereby granted without fee, provided that 6 * the above copyright notice appear in all copies and that both that copyright 7 * notice and this permission notice appear in supporting documentation, and 8 * that the name of Marc Aurele La France not be used in advertising or 9 * publicity pertaining to distribution of the software without specific, 10 * written prior permission. Marc Aurele La France makes no representations 11 * about the suitability of this software for any purpose. It is provided 12 * "as-is" without express or implied warranty. 13 * 14 * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO 16 * EVENT SHALL MARC AURELE LA FRANCE BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20 * PERFORMANCE OF THIS SOFTWARE. 21 */ 22 23#ifdef HAVE_CONFIG_H 24#include "config.h" 25#endif 26 27#include "ati.h" 28#include "atichip.h" 29#include "atiwonderio.h" 30 31#ifndef AVOID_CPIO 32 33/* 34 * ATIModifyExtReg -- 35 * 36 * This function is called to modify certain bits in an ATI extended VGA 37 * register while preserving its other bits. The function will not write the 38 * register if it turns out its value would not change. This helps prevent 39 * server hangs on older adapters. 40 */ 41void 42ATIModifyExtReg 43( 44 ATIPtr pATI, 45 const CARD8 Index, 46 int CurrentValue, 47 const CARD8 CurrentMask, 48 CARD8 NewValue 49) 50{ 51 /* Possibly retrieve the current value */ 52 if (CurrentValue < 0) 53 CurrentValue = ATIGetExtReg(Index); 54 55 /* Compute new value */ 56 NewValue &= (CARD8)(~CurrentMask); 57 NewValue |= CurrentValue & CurrentMask; 58 59 /* Check if value will be changed */ 60 if (CurrentValue == NewValue) 61 return; 62 63 ATIPutExtReg(Index, NewValue); 64} 65 66#endif /* AVOID_CPIO */ 67