1/********************************************************************** 2Copyright 1998, 1999 by Precision Insight, Inc., Cedar Park, Texas. 3 4 All Rights Reserved 5 6Permission to use, copy, modify, distribute, and sell this software and 7its documentation for any purpose is hereby granted without fee, 8provided that the above copyright notice appear in all copies and that 9both that copyright notice and this permission notice appear in 10supporting documentation, and that the name of Precision Insight not be 11used in advertising or publicity pertaining to distribution of the 12software without specific, written prior permission. Precision Insight 13and its suppliers make no representations about the suitability of this 14software for any purpose. It is provided "as is" without express or 15implied warranty. 16 17PRECISION INSIGHT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 18INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 19EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY 20SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 21RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 22CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 23CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 24**********************************************************************/ 25 26/* 27 * The original Precision Insight driver for 28 * XFree86 v.3.3 has been sponsored by Red Hat. 29 * 30 * Authors: 31 * Jens Owen (jens@tungstengraphics.com) 32 * Kevin E. Martin (kevin@precisioninsight.com) 33 * 34 * Port to Xfree86 v.4.0 35 * 1998, 1999 by Egbert Eich (Egbert.Eich@Physik.TU-Darmstadt.DE) 36 */ 37 38#ifdef HAVE_CONFIG_H 39#include "config.h" 40#endif 41 42#include "xf86.h" 43#include "xf86_OSproc.h" 44#include "compiler.h" 45 46#include "xf86Pci.h" 47 48#include "vgaHW.h" 49 50#include "neo.h" 51 52static void 53neo_I2CPutBits(I2CBusPtr b, int clock, int data) { 54 vgaHWPtr hwp = VGAHWPTR(xf86Screens[b->scrnIndex]); 55 unsigned int reg = 0xF0; 56 57 VGAwCR(0x21,0x00); 58 VGAwCR(0x1D,0x01); 59 60 if(clock) reg |= 1; 61 if(data) reg |= 0x4; 62 VGAwGR(0xA1,reg); 63 /*ErrorF("neo_I2CPutBits: %d %d\n", clock, data); */ 64} 65 66static void 67neo_I2CGetBits(I2CBusPtr b, int *clock, int *data) { 68 unsigned int reg; 69 vgaHWPtr hwp = VGAHWPTR(xf86Screens[b->scrnIndex]); 70 71 reg = VGArGR(0xA1); 72 *clock = 1 /* (reg & 0x?? ) */; 73 *data = (reg & 0x8) != 0; 74 /*ErrorF("neo_I2CGetBits: %d %d\n", *clock, *data);*/ 75} 76 77Bool 78neo_I2CInit(ScrnInfoPtr pScrn) 79{ 80 NEOPtr pNeo = NEOPTR(pScrn); 81 I2CBusPtr I2CPtr; 82 83 I2CPtr = xf86CreateI2CBusRec(); 84 85 if(!I2CPtr) return FALSE; 86 87 pNeo->I2C = I2CPtr; 88 89 I2CPtr->BusName = "I2C bus"; 90 I2CPtr->scrnIndex = pScrn->scrnIndex; 91 I2CPtr->I2CPutBits = neo_I2CPutBits; 92 I2CPtr->I2CGetBits = neo_I2CGetBits; 93 /* increase these as the defaults are too low */ 94 I2CPtr->RiseFallTime = 2; 95 I2CPtr->HoldTime = 40; 96 97 if (!xf86I2CBusInit(I2CPtr)) 98 return FALSE; 99 100 return TRUE; 101} 102 103 104 105