s3v_i2c.c revision 1d54945d
11d54945dSmrg/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c,v 1.4 2000/03/31 20:13:32 dawes Exp $ */ 21d54945dSmrg 31d54945dSmrg/* 41d54945dSmrgCopyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 51d54945dSmrg 61d54945dSmrgPermission is hereby granted, free of charge, to any person obtaining a copy of 71d54945dSmrgthis software and associated documentation files (the "Software"), to deal in 81d54945dSmrgthe Software without restriction, including without limitation the rights to 91d54945dSmrguse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 101d54945dSmrgof the Software, and to permit persons to whom the Software is furnished to do 111d54945dSmrgso, subject to the following conditions: 121d54945dSmrg 131d54945dSmrgThe above copyright notice and this permission notice shall be included in all 141d54945dSmrgcopies or substantial portions of the Software. 151d54945dSmrg 161d54945dSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 171d54945dSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 181d54945dSmrgNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 191d54945dSmrgXFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 201d54945dSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 211d54945dSmrgWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 221d54945dSmrg 231d54945dSmrgExcept as contained in this notice, the name of the XFree86 Project shall not 241d54945dSmrgbe used in advertising or otherwise to promote the sale, use or other dealings 251d54945dSmrgin this Software without prior written authorization from the XFree86 Project. 261d54945dSmrg*/ 271d54945dSmrg 281d54945dSmrg/* 291d54945dSmrgCopyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 301d54945dSmrg 311d54945dSmrgPermission is hereby granted, free of charge, to any person obtaining a copy of 321d54945dSmrgthis software and associated documentation files (the "Software"), to deal in 331d54945dSmrgthe Software without restriction, including without limitation the rights to 341d54945dSmrguse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 351d54945dSmrgof the Software, and to permit persons to whom the Software is furnished to do 361d54945dSmrgso, subject to the following conditions: 371d54945dSmrg 381d54945dSmrgThe above copyright notice and this permission notice shall be included in all 391d54945dSmrgcopies or substantial portions of the Software. 401d54945dSmrg 411d54945dSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 421d54945dSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 431d54945dSmrgNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 441d54945dSmrgXFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 451d54945dSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 461d54945dSmrgWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 471d54945dSmrg 481d54945dSmrgExcept as contained in this notice, the name of the XFree86 Project shall not 491d54945dSmrgbe used in advertising or otherwise to promote the sale, use or other dealings 501d54945dSmrgin this Software without prior written authorization from the XFree86 Project. 511d54945dSmrg*/ 521d54945dSmrg 531d54945dSmrg#ifdef HAVE_CONFIG_H 541d54945dSmrg#include "config.h" 551d54945dSmrg#endif 561d54945dSmrg 571d54945dSmrg#include "xf86.h" 581d54945dSmrg#include "xf86_OSproc.h" 591d54945dSmrg#include "compiler.h" 601d54945dSmrg 611d54945dSmrg#include "xf86Pci.h" 621d54945dSmrg#include "xf86PciInfo.h" 631d54945dSmrg 641d54945dSmrg#include "vgaHW.h" 651d54945dSmrg 661d54945dSmrg#include "s3v.h" 671d54945dSmrg 681d54945dSmrgstatic void 691d54945dSmrgs3v_I2CPutBits(I2CBusPtr b, int clock, int data) 701d54945dSmrg{ 711d54945dSmrg S3VPtr ps3v = S3VPTR(xf86Screens[b->scrnIndex]); 721d54945dSmrg unsigned int reg = 0x10; 731d54945dSmrg 741d54945dSmrg if(clock) reg |= 0x1; 751d54945dSmrg if(data) reg |= 0x2; 761d54945dSmrg 771d54945dSmrg OUTREG(DDC_REG,reg); 781d54945dSmrg /*ErrorF("s3v_I2CPutBits: %d %d\n", clock, data); */ 791d54945dSmrg} 801d54945dSmrg 811d54945dSmrgstatic void 821d54945dSmrgs3v_I2CGetBits(I2CBusPtr b, int *clock, int *data) 831d54945dSmrg{ 841d54945dSmrg S3VPtr ps3v = S3VPTR(xf86Screens[b->scrnIndex]); 851d54945dSmrg unsigned int reg; 861d54945dSmrg 871d54945dSmrg reg = (INREG(DDC_REG)); 881d54945dSmrg 891d54945dSmrg *clock = reg & 0x4; 901d54945dSmrg *data = reg & 0x8; 911d54945dSmrg 921d54945dSmrg /*ErrorF("s3v_I2CGetBits: %d %d\n", *clock, *data);*/ 931d54945dSmrg} 941d54945dSmrg 951d54945dSmrgBool 961d54945dSmrgS3V_I2CInit(ScrnInfoPtr pScrn) 971d54945dSmrg{ 981d54945dSmrg S3VPtr ps3v = S3VPTR(pScrn); 991d54945dSmrg I2CBusPtr I2CPtr; 1001d54945dSmrg 1011d54945dSmrg 1021d54945dSmrg I2CPtr = xf86CreateI2CBusRec(); 1031d54945dSmrg if(!I2CPtr) return FALSE; 1041d54945dSmrg 1051d54945dSmrg ps3v->I2C = I2CPtr; 1061d54945dSmrg 1071d54945dSmrg I2CPtr->BusName = "I2C bus"; 1081d54945dSmrg I2CPtr->scrnIndex = pScrn->scrnIndex; 1091d54945dSmrg I2CPtr->I2CPutBits = s3v_I2CPutBits; 1101d54945dSmrg I2CPtr->I2CGetBits = s3v_I2CGetBits; 1111d54945dSmrg 1121d54945dSmrg if (!xf86I2CBusInit(I2CPtr)) 1131d54945dSmrg return FALSE; 1141d54945dSmrg 1151d54945dSmrg return TRUE; 1161d54945dSmrg} 1171d54945dSmrg 1181d54945dSmrg 1191d54945dSmrg 120