1301ea0f4Smrg/* 2301ea0f4Smrg * Copyright 2001 by Patrick LERDA 3301ea0f4Smrg * 4301ea0f4Smrg * Permission to use, copy, modify, distribute, and sell this software and its 5301ea0f4Smrg * documentation for any purpose is hereby granted without fee, provided that 6301ea0f4Smrg * the above copyright notice appear in all copies and that both that 7301ea0f4Smrg * copyright notice and this permission notice appear in supporting 8301ea0f4Smrg * documentation, and that the name of Patrick LERDA not be used in 9301ea0f4Smrg * advertising or publicity pertaining to distribution of the software without 10301ea0f4Smrg * specific, written prior permission. Patrick LERDA makes no representations 11301ea0f4Smrg * about the suitability of this software for any purpose. It is provided 12301ea0f4Smrg * "as is" without express or implied warranty. 13301ea0f4Smrg * 14301ea0f4Smrg * PATRICK LERDA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15301ea0f4Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16301ea0f4Smrg * EVENT SHALL PATRICK LERDA BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17301ea0f4Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18301ea0f4Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19301ea0f4Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 20301ea0f4Smrg * PERFORMANCE OF THIS SOFTWARE. 21301ea0f4Smrg * 22301ea0f4Smrg * Authors: Patrick LERDA 23301ea0f4Smrg */ 24301ea0f4Smrg 25301ea0f4Smrg#ifdef HAVE_CONFIG_H 26301ea0f4Smrg#include "config.h" 27301ea0f4Smrg#endif 28301ea0f4Smrg 29301ea0f4Smrg/* not working at this time */ 30301ea0f4Smrg 31301ea0f4Smrg#include "xf86.h" 32301ea0f4Smrg#include "xf86_OSproc.h" 33301ea0f4Smrg#include "compiler.h" 34301ea0f4Smrg 35301ea0f4Smrg#include "xf86Pci.h" 36301ea0f4Smrg 37301ea0f4Smrg#include "vgaHW.h" 38301ea0f4Smrg 39301ea0f4Smrg#include "xf86xv.h" 40301ea0f4Smrg#include "i740.h" 41301ea0f4Smrg 42301ea0f4Smrg 43301ea0f4Smrgstatic void i740_I2CPutBits(I2CBusPtr b, int clk, int dat) 44301ea0f4Smrg{ 45301ea0f4Smrg I740Ptr pI740=I740PTR(xf86Screens[b->scrnIndex]); 46301ea0f4Smrg unsigned char val; 47301ea0f4Smrg 48301ea0f4Smrg val=pI740->readControl(pI740, XRX, 0x1C); 49301ea0f4Smrg 50301ea0f4Smrg if(clk) val&=~0x40; else val|=0x40; if(dat) val&=~0x08; else val|=0x08; 51301ea0f4Smrg 52301ea0f4Smrg /*if ( clk && dat) val&=0xBF; else if( clk && !dat) val&=0xF7; else if(!clk && dat) val|=0x40; else val|=0x08;*/ 53301ea0f4Smrg 54301ea0f4Smrg val|=0x90; 55301ea0f4Smrg 56301ea0f4Smrg pI740->writeControl(pI740, XRX, 0x1C, val); 57301ea0f4Smrg 58301ea0f4Smrg ErrorF("i740_I2CPutBits: clk=%d dat=%d [<1c>=0x%02x] [<63>=0x%02x] clk=%d dat=%d\n", clk, dat,val,pI740->readControl(pI740, XRX, 0x63), 59301ea0f4Smrg !!(pI740->readControl(pI740, XRX, 0x63) & 0x02), !!(pI740->readControl(pI740, XRX, 0x63) & 0x01) ); 60301ea0f4Smrg} 61301ea0f4Smrg 62301ea0f4Smrgstatic void i740_I2CGetBits(I2CBusPtr b, int *clk, int *dat) 63301ea0f4Smrg{ 64301ea0f4Smrg I740Ptr pI740=I740PTR(xf86Screens[b->scrnIndex]); 65301ea0f4Smrg unsigned char val; 66301ea0f4Smrg 67301ea0f4Smrg { 68301ea0f4Smrg val=pI740->readControl(pI740, XRX, 0x1C); 69301ea0f4Smrg val|=0x90; 70301ea0f4Smrg pI740->writeControl(pI740, XRX, 0x1C, val); 71301ea0f4Smrg } 72301ea0f4Smrg 73301ea0f4Smrg { 74301ea0f4Smrg val=pI740->readControl(pI740, XRX, 0x63); 75301ea0f4Smrg *clk=!!(val & 0x02); 76301ea0f4Smrg *dat=!!(val & 0x01); 77301ea0f4Smrg } 78301ea0f4Smrg 79301ea0f4Smrg ErrorF("i740_I2CGetBits: clk=%d dat=%d [<1c>=0x%02x] [<63>=0x%02x]\n", *clk, *dat,pI740->readControl(pI740, XRX, 0x1c) & 0xff,pI740->readControl(pI740, XRX, 0x63)); 80301ea0f4Smrg} 81301ea0f4Smrg 82301ea0f4SmrgBool I740_I2CInit(ScrnInfoPtr pScrn) 83301ea0f4Smrg{ 84301ea0f4Smrg I740Ptr pI740=I740PTR(pScrn); 85301ea0f4Smrg I2CBusPtr I2CPtr; 86301ea0f4Smrg 87301ea0f4Smrg { unsigned char val; val=pI740->readControl(pI740, XRX, 0x63); val&=0xFC; pI740->writeControl(pI740, XRX, 0x63, val); } 88301ea0f4Smrg { unsigned char val; val=pI740->readControl(pI740, XRX, 0x1C); val|=0x90; pI740->writeControl(pI740, XRX, 0x1C, val); } 89301ea0f4Smrg { unsigned char val; val=pI740->readControl(pI740, XRX, 0x63); val&=0xFC; pI740->writeControl(pI740, XRX, 0x63, val); } 90301ea0f4Smrg 91301ea0f4Smrg 92301ea0f4Smrg I2CPtr = xf86CreateI2CBusRec(); 93301ea0f4Smrg if(!I2CPtr) return FALSE; 94301ea0f4Smrg 95301ea0f4Smrg pI740->rc_i2c = I2CPtr; 96301ea0f4Smrg 97301ea0f4Smrg I2CPtr->BusName = "I2C bus"; 98301ea0f4Smrg I2CPtr->scrnIndex = pScrn->scrnIndex; 99301ea0f4Smrg I2CPtr->I2CPutBits = i740_I2CPutBits; 100301ea0f4Smrg I2CPtr->I2CGetBits = i740_I2CGetBits; 101301ea0f4Smrg 102301ea0f4Smrg if (!xf86I2CBusInit(I2CPtr)) 103301ea0f4Smrg return FALSE; 104301ea0f4Smrg 105301ea0f4Smrg return TRUE; 106301ea0f4Smrg} 107