theatre_detect.c revision 0974d292
1209ff23fSmrg/************************************************************************************* 2209ff23fSmrg * 3209ff23fSmrg * Copyright (C) 2005 Bogdan D. bogdand@users.sourceforge.net 4209ff23fSmrg * 5209ff23fSmrg * Permission is hereby granted, free of charge, to any person obtaining a copy of this 6209ff23fSmrg * software and associated documentation files (the "Software"), to deal in the Software 7209ff23fSmrg * without restriction, including without limitation the rights to use, copy, modify, 8209ff23fSmrg * merge, publish, distribute, sublicense, and/or sell copies of the Software, 9209ff23fSmrg * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10209ff23fSmrg * 11209ff23fSmrg * The above copyright notice and this permission notice shall be included in all copies or 12209ff23fSmrg * substantial portions of the Software. 13209ff23fSmrg * 14209ff23fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15209ff23fSmrg * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 16209ff23fSmrg * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, 17209ff23fSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18209ff23fSmrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19209ff23fSmrg * 20209ff23fSmrg * Except as contained in this notice, the name of the author shall not be used in advertising or 21209ff23fSmrg * otherwise to promote the sale, use or other dealings in this Software without prior written 22209ff23fSmrg * authorization from the author. 23209ff23fSmrg * 24209ff23fSmrg * $Log: theatre_detect.c,v $ 250974d292Smrg * Revision 1.1.1.2 2010/11/20 10:00:26 mrg 260974d292Smrg * initial import of xf86-video-ati-6.13.2 27209ff23fSmrg * 28209ff23fSmrg * Revision 1.4 2005/08/28 18:00:23 bogdand 29209ff23fSmrg * Modified the licens type from GPL to a X/MIT one 30209ff23fSmrg * 31209ff23fSmrg * Revision 1.3 2005/07/11 02:29:45 ajax 32209ff23fSmrg * Prep for modular builds by adding guarded #include "config.h" everywhere. 33209ff23fSmrg * 34209ff23fSmrg * Revision 1.2 2005/07/01 22:43:11 daniels 35209ff23fSmrg * Change all misc.h and os.h references to <X11/foo.h>. 36209ff23fSmrg * 37209ff23fSmrg * 38209ff23fSmrg ************************************************************************************/ 39209ff23fSmrg 40209ff23fSmrg#ifdef HAVE_CONFIG_H 41209ff23fSmrg#include "config.h" 42209ff23fSmrg#endif 43209ff23fSmrg 44209ff23fSmrg#include <string.h> 45209ff23fSmrg#include "xf86.h" 46209ff23fSmrg#include "generic_bus.h" 47209ff23fSmrg#include "theatre.h" 48209ff23fSmrg#include "theatre_reg.h" 49209ff23fSmrg#include "theatre_detect.h" 50209ff23fSmrg 51209ff23fSmrgstatic Bool theatre_read(TheatrePtr t,uint32_t reg, uint32_t *data) 52209ff23fSmrg{ 53209ff23fSmrg if(t->theatre_num<0)return FALSE; 54209ff23fSmrg return t->VIP->read(t->VIP, ((t->theatre_num & 0x3)<<14) | reg,4, (uint8_t *) data); 55209ff23fSmrg} 56209ff23fSmrg 57209ff23fSmrg/* Unused code - reference */ 58209ff23fSmrg#if 0 59209ff23fSmrgstatic Bool theatre_write(TheatrePtr t,uint32_t reg, uint32_t data) 60209ff23fSmrg{ 61209ff23fSmrg if(t->theatre_num<0)return FALSE; 62209ff23fSmrg return t->VIP->write(t->VIP,((t->theatre_num & 0x03)<<14) | reg,4, (uint8_t *) &data); 63209ff23fSmrg} 64209ff23fSmrg#define RT_regw(reg,data) theatre_write(t,(reg),(data)) 65209ff23fSmrg#endif 66209ff23fSmrg 67209ff23fSmrg#define RT_regr(reg,data) theatre_read(t,(reg),(data)) 68209ff23fSmrg#define VIP_TYPE "ATI VIP BUS" 69209ff23fSmrg 70209ff23fSmrg 71209ff23fSmrg_X_EXPORT TheatrePtr DetectTheatre(GENERIC_BUS_Ptr b) 72209ff23fSmrg{ 73209ff23fSmrg TheatrePtr t; 74209ff23fSmrg int i; 75209ff23fSmrg uint32_t val; 76209ff23fSmrg char s[20]; 77209ff23fSmrg 78209ff23fSmrg b->ioctl(b,GB_IOCTL_GET_TYPE,20,s); 79209ff23fSmrg if(strcmp(VIP_TYPE, s)){ 80209ff23fSmrg xf86DrvMsg(b->scrnIndex, X_ERROR, "DetectTheatre must be called with bus of type \"%s\", not \"%s\"\n", 81209ff23fSmrg VIP_TYPE, s); 82209ff23fSmrg return NULL; 83209ff23fSmrg } 84209ff23fSmrg 850974d292Smrg t = calloc(1,sizeof(TheatreRec)); 86209ff23fSmrg t->VIP = b; 87209ff23fSmrg t->theatre_num = -1; 88209ff23fSmrg t->mode=MODE_UNINITIALIZED; 89209ff23fSmrg 90209ff23fSmrg b->read(b, VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val); 91209ff23fSmrg for(i=0;i<4;i++) 92209ff23fSmrg { 93209ff23fSmrg if(b->read(b, ((i & 0x03)<<14) | VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val)) 94209ff23fSmrg { 95209ff23fSmrg if(val)xf86DrvMsg(b->scrnIndex, X_INFO, 96209ff23fSmrg "Device %d on VIP bus ids as 0x%08x\n", i, 97209ff23fSmrg (unsigned)val); 98209ff23fSmrg if(t->theatre_num>=0)continue; /* already found one instance */ 99209ff23fSmrg switch(val){ 100209ff23fSmrg case RT100_ATI_ID: 101209ff23fSmrg t->theatre_num=i; 102209ff23fSmrg t->theatre_id=RT100_ATI_ID; 103209ff23fSmrg break; 104209ff23fSmrg case RT200_ATI_ID: 105209ff23fSmrg t->theatre_num=i; 106209ff23fSmrg t->theatre_id=RT200_ATI_ID; 107209ff23fSmrg break; 108209ff23fSmrg } 109209ff23fSmrg } else { 110209ff23fSmrg xf86DrvMsg(b->scrnIndex, X_INFO, "No response from device %d on VIP bus\n",i); 111209ff23fSmrg } 112209ff23fSmrg } 113209ff23fSmrg if(t->theatre_num>=0)xf86DrvMsg(b->scrnIndex, X_INFO, 114209ff23fSmrg "Detected Rage Theatre as device %d on VIP bus with id 0x%08x\n", 115209ff23fSmrg t->theatre_num, (unsigned)t->theatre_id); 116209ff23fSmrg 117209ff23fSmrg if(t->theatre_num < 0) 118209ff23fSmrg { 1190974d292Smrg free(t); 120209ff23fSmrg return NULL; 121209ff23fSmrg } 122209ff23fSmrg 123209ff23fSmrg RT_regr(VIP_VIP_REVISION_ID, &val); 124209ff23fSmrg xf86DrvMsg(b->scrnIndex, X_INFO, "Detected Rage Theatre revision %8.8X\n", 125209ff23fSmrg (unsigned)val); 126209ff23fSmrg 127209ff23fSmrg#if 0 128209ff23fSmrgDumpRageTheatreRegsByName(t); 129209ff23fSmrg#endif 130209ff23fSmrg 131209ff23fSmrg return t; 132209ff23fSmrg} 133209ff23fSmrg 134