savage_i2c.c revision ab47cfaa
1/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/savage/savage_i2c.c,v 1.1 2001/02/13 21:15:19 dawes Exp $ */ 2 3/* 4Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 5 6Permission is hereby granted, free of charge, to any person obtaining a copy of 7this software and associated documentation files (the "Software"), to deal in 8the Software without restriction, including without limitation the rights to 9use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 10of the Software, and to permit persons to whom the Software is furnished to do 11so, subject to the following conditions: 12 13The above copyright notice and this permission notice shall be included in all 14copies or substantial portions of the Software. 15 16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 18NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 23Except as contained in this notice, the name of the XFree86 Project shall not 24be used in advertising or otherwise to promote the sale, use or other dealings 25in this Software without prior written authorization from the XFree86 Project. 26*/ 27 28#ifdef HAVE_CONFIG_H 29#include "config.h" 30#endif 31 32#include "xf86.h" 33#include "xf86_OSproc.h" 34#include "compiler.h" 35 36#include "xf86Pci.h" 37#include "xf86PciInfo.h" 38 39#include "vgaHW.h" 40 41#include "savage_driver.h" 42 43static void 44SavageI2CPutBits(I2CBusPtr b, int clock, int data) 45{ 46 ScrnInfoPtr pScrn = (ScrnInfoPtr)(xf86Screens[b->scrnIndex]); 47 SavagePtr psav = SAVPTR(pScrn); 48 unsigned char reg = 0x10; 49 50 if(clock) reg |= 0x1; 51 if(data) reg |= 0x2; 52 53 OutI2CREG(reg,psav->DDCPort); 54 /*ErrorF("SavageI2CPutBits: %d %d\n", clock, data); */ 55} 56 57static void 58SavageI2CGetBits(I2CBusPtr b, int *clock, int *data) 59{ 60 ScrnInfoPtr pScrn = (ScrnInfoPtr)(xf86Screens[b->scrnIndex]); 61 SavagePtr psav = SAVPTR(pScrn); 62 unsigned char reg = 0x10; 63 64 InI2CREG(reg,psav->DDCPort); 65 66 *clock = reg & 0x4; 67 *data = reg & 0x8; 68 69 /*ErrorF("SavageI2CGetBits: %d %d\n", *clock, *data); */ 70} 71 72Bool 73SavageI2CInit(ScrnInfoPtr pScrn) 74{ 75 SavagePtr psav = SAVPTR(pScrn); 76 I2CBusPtr I2CPtr; 77 78 I2CPtr = xf86CreateI2CBusRec(); 79 if(!I2CPtr) return FALSE; 80 81 psav->I2C = I2CPtr; 82 83 I2CPtr->BusName = "I2C bus"; 84 I2CPtr->scrnIndex = pScrn->scrnIndex; 85 I2CPtr->I2CPutBits = SavageI2CPutBits; 86 I2CPtr->I2CGetBits = SavageI2CGetBits; 87 88 if (!xf86I2CBusInit(I2CPtr)) 89 return FALSE; 90 91 return TRUE; 92} 93 94 95 96