theatre_detect.c revision 0974d292
1/************************************************************************************* 2 * 3 * Copyright (C) 2005 Bogdan D. bogdand@users.sourceforge.net 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this 6 * software and associated documentation files (the "Software"), to deal in the Software 7 * without restriction, including without limitation the rights to use, copy, modify, 8 * merge, publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in all copies or 12 * substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 15 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 16 * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, 17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 * 20 * Except as contained in this notice, the name of the author shall not be used in advertising or 21 * otherwise to promote the sale, use or other dealings in this Software without prior written 22 * authorization from the author. 23 * 24 * $Log: theatre_detect.c,v $ 25 * Revision 1.1.1.2 2010/11/20 10:00:26 mrg 26 * initial import of xf86-video-ati-6.13.2 27 * 28 * Revision 1.4 2005/08/28 18:00:23 bogdand 29 * Modified the licens type from GPL to a X/MIT one 30 * 31 * Revision 1.3 2005/07/11 02:29:45 ajax 32 * Prep for modular builds by adding guarded #include "config.h" everywhere. 33 * 34 * Revision 1.2 2005/07/01 22:43:11 daniels 35 * Change all misc.h and os.h references to <X11/foo.h>. 36 * 37 * 38 ************************************************************************************/ 39 40#ifdef HAVE_CONFIG_H 41#include "config.h" 42#endif 43 44#include <string.h> 45#include "xf86.h" 46#include "generic_bus.h" 47#include "theatre.h" 48#include "theatre_reg.h" 49#include "theatre_detect.h" 50 51static Bool theatre_read(TheatrePtr t,uint32_t reg, uint32_t *data) 52{ 53 if(t->theatre_num<0)return FALSE; 54 return t->VIP->read(t->VIP, ((t->theatre_num & 0x3)<<14) | reg,4, (uint8_t *) data); 55} 56 57/* Unused code - reference */ 58#if 0 59static Bool theatre_write(TheatrePtr t,uint32_t reg, uint32_t data) 60{ 61 if(t->theatre_num<0)return FALSE; 62 return t->VIP->write(t->VIP,((t->theatre_num & 0x03)<<14) | reg,4, (uint8_t *) &data); 63} 64#define RT_regw(reg,data) theatre_write(t,(reg),(data)) 65#endif 66 67#define RT_regr(reg,data) theatre_read(t,(reg),(data)) 68#define VIP_TYPE "ATI VIP BUS" 69 70 71_X_EXPORT TheatrePtr DetectTheatre(GENERIC_BUS_Ptr b) 72{ 73 TheatrePtr t; 74 int i; 75 uint32_t val; 76 char s[20]; 77 78 b->ioctl(b,GB_IOCTL_GET_TYPE,20,s); 79 if(strcmp(VIP_TYPE, s)){ 80 xf86DrvMsg(b->scrnIndex, X_ERROR, "DetectTheatre must be called with bus of type \"%s\", not \"%s\"\n", 81 VIP_TYPE, s); 82 return NULL; 83 } 84 85 t = calloc(1,sizeof(TheatreRec)); 86 t->VIP = b; 87 t->theatre_num = -1; 88 t->mode=MODE_UNINITIALIZED; 89 90 b->read(b, VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val); 91 for(i=0;i<4;i++) 92 { 93 if(b->read(b, ((i & 0x03)<<14) | VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val)) 94 { 95 if(val)xf86DrvMsg(b->scrnIndex, X_INFO, 96 "Device %d on VIP bus ids as 0x%08x\n", i, 97 (unsigned)val); 98 if(t->theatre_num>=0)continue; /* already found one instance */ 99 switch(val){ 100 case RT100_ATI_ID: 101 t->theatre_num=i; 102 t->theatre_id=RT100_ATI_ID; 103 break; 104 case RT200_ATI_ID: 105 t->theatre_num=i; 106 t->theatre_id=RT200_ATI_ID; 107 break; 108 } 109 } else { 110 xf86DrvMsg(b->scrnIndex, X_INFO, "No response from device %d on VIP bus\n",i); 111 } 112 } 113 if(t->theatre_num>=0)xf86DrvMsg(b->scrnIndex, X_INFO, 114 "Detected Rage Theatre as device %d on VIP bus with id 0x%08x\n", 115 t->theatre_num, (unsigned)t->theatre_id); 116 117 if(t->theatre_num < 0) 118 { 119 free(t); 120 return NULL; 121 } 122 123 RT_regr(VIP_VIP_REVISION_ID, &val); 124 xf86DrvMsg(b->scrnIndex, X_INFO, "Detected Rage Theatre revision %8.8X\n", 125 (unsigned)val); 126 127#if 0 128DumpRageTheatreRegsByName(t); 129#endif 130 131 return t; 132} 133 134