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