theatre_detect.c revision 68105dcb
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.3 2012/09/23 19:49:19 veego 26 * initial import of xf86-video-ati-6.14.6. 27 * 28 * NetBSD note: The libdrm requirement seems to be KMS related which we do 29 * not have. 30 * 31 * * 6.15.6 32 * This version requires the latest libdrm 2.4.36 release, and fixes a few 33 * other bugs seen since 6.14.5. 34 * * 6.14.5 35 * - add solid picture accel 36 * - tiling fixes 37 * - new pci ids 38 * - 6xx-9xx Xv improvements 39 * - support for upcoming xserver API changes 40 * - bug fixes 41 * 42 * Revision 1.4 2005/08/28 18:00:23 bogdand 43 * Modified the licens type from GPL to a X/MIT one 44 * 45 * Revision 1.3 2005/07/11 02:29:45 ajax 46 * Prep for modular builds by adding guarded #include "config.h" everywhere. 47 * 48 * Revision 1.2 2005/07/01 22:43:11 daniels 49 * Change all misc.h and os.h references to <X11/foo.h>. 50 * 51 * 52 ************************************************************************************/ 53 54#ifdef HAVE_CONFIG_H 55#include "config.h" 56#endif 57 58#include <string.h> 59#include "xf86.h" 60#include "generic_bus.h" 61#include "theatre.h" 62#include "theatre_reg.h" 63#include "theatre_detect.h" 64 65static Bool theatre_read(TheatrePtr t,uint32_t reg, uint32_t *data) 66{ 67 if(t->theatre_num<0)return FALSE; 68 return t->VIP->read(t->VIP, ((t->theatre_num & 0x3)<<14) | reg,4, (uint8_t *) data); 69} 70 71/* Unused code - reference */ 72#if 0 73static Bool theatre_write(TheatrePtr t,uint32_t reg, uint32_t data) 74{ 75 if(t->theatre_num<0)return FALSE; 76 return t->VIP->write(t->VIP,((t->theatre_num & 0x03)<<14) | reg,4, (uint8_t *) &data); 77} 78#define RT_regw(reg,data) theatre_write(t,(reg),(data)) 79#endif 80 81#define RT_regr(reg,data) theatre_read(t,(reg),(data)) 82#define VIP_TYPE "ATI VIP BUS" 83 84 85_X_EXPORT TheatrePtr DetectTheatre(GENERIC_BUS_Ptr b) 86{ 87 TheatrePtr t; 88 int i; 89 uint32_t val; 90 char s[20]; 91 92 b->ioctl(b,GB_IOCTL_GET_TYPE,20,s); 93 if(strcmp(VIP_TYPE, s)){ 94 xf86DrvMsg(b->pScrn->scrnIndex, X_ERROR, "DetectTheatre must be called with bus of type \"%s\", not \"%s\"\n", 95 VIP_TYPE, s); 96 return NULL; 97 } 98 99 t = calloc(1,sizeof(TheatreRec)); 100 t->VIP = b; 101 t->theatre_num = -1; 102 t->mode=MODE_UNINITIALIZED; 103 104 b->read(b, VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val); 105 for(i=0;i<4;i++) 106 { 107 if(b->read(b, ((i & 0x03)<<14) | VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val)) 108 { 109 if(val)xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, 110 "Device %d on VIP bus ids as 0x%08x\n", i, 111 (unsigned)val); 112 if(t->theatre_num>=0)continue; /* already found one instance */ 113 switch(val){ 114 case RT100_ATI_ID: 115 t->theatre_num=i; 116 t->theatre_id=RT100_ATI_ID; 117 break; 118 case RT200_ATI_ID: 119 t->theatre_num=i; 120 t->theatre_id=RT200_ATI_ID; 121 break; 122 } 123 } else { 124 xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, "No response from device %d on VIP bus\n",i); 125 } 126 } 127 if(t->theatre_num>=0)xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, 128 "Detected Rage Theatre as device %d on VIP bus with id 0x%08x\n", 129 t->theatre_num, (unsigned)t->theatre_id); 130 131 if(t->theatre_num < 0) 132 { 133 free(t); 134 return NULL; 135 } 136 137 RT_regr(VIP_VIP_REVISION_ID, &val); 138 xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, "Detected Rage Theatre revision %8.8X\n", 139 (unsigned)val); 140 141#if 0 142DumpRageTheatreRegsByName(t); 143#endif 144 145 return t; 146} 147 148