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 $ 2568105dcbSveego * Revision 1.1.1.3 2012/09/23 19:49:19 veego 2668105dcbSveego * initial import of xf86-video-ati-6.14.6. 2768105dcbSveego * 2868105dcbSveego * NetBSD note: The libdrm requirement seems to be KMS related which we do 2968105dcbSveego * not have. 3068105dcbSveego * 3168105dcbSveego * * 6.15.6 3268105dcbSveego * This version requires the latest libdrm 2.4.36 release, and fixes a few 3368105dcbSveego * other bugs seen since 6.14.5. 3468105dcbSveego * * 6.14.5 3568105dcbSveego * - add solid picture accel 3668105dcbSveego * - tiling fixes 3768105dcbSveego * - new pci ids 3868105dcbSveego * - 6xx-9xx Xv improvements 3968105dcbSveego * - support for upcoming xserver API changes 4068105dcbSveego * - bug fixes 41209ff23fSmrg * 42209ff23fSmrg * Revision 1.4 2005/08/28 18:00:23 bogdand 43209ff23fSmrg * Modified the licens type from GPL to a X/MIT one 44209ff23fSmrg * 45209ff23fSmrg * Revision 1.3 2005/07/11 02:29:45 ajax 46209ff23fSmrg * Prep for modular builds by adding guarded #include "config.h" everywhere. 47209ff23fSmrg * 48209ff23fSmrg * Revision 1.2 2005/07/01 22:43:11 daniels 49209ff23fSmrg * Change all misc.h and os.h references to <X11/foo.h>. 50209ff23fSmrg * 51209ff23fSmrg * 52209ff23fSmrg ************************************************************************************/ 53209ff23fSmrg 54209ff23fSmrg#ifdef HAVE_CONFIG_H 55209ff23fSmrg#include "config.h" 56209ff23fSmrg#endif 57209ff23fSmrg 58209ff23fSmrg#include <string.h> 59209ff23fSmrg#include "xf86.h" 60209ff23fSmrg#include "generic_bus.h" 61209ff23fSmrg#include "theatre.h" 62209ff23fSmrg#include "theatre_reg.h" 63209ff23fSmrg#include "theatre_detect.h" 64209ff23fSmrg 65209ff23fSmrgstatic Bool theatre_read(TheatrePtr t,uint32_t reg, uint32_t *data) 66209ff23fSmrg{ 67209ff23fSmrg if(t->theatre_num<0)return FALSE; 68209ff23fSmrg return t->VIP->read(t->VIP, ((t->theatre_num & 0x3)<<14) | reg,4, (uint8_t *) data); 69209ff23fSmrg} 70209ff23fSmrg 71209ff23fSmrg/* Unused code - reference */ 72209ff23fSmrg#if 0 73209ff23fSmrgstatic Bool theatre_write(TheatrePtr t,uint32_t reg, uint32_t data) 74209ff23fSmrg{ 75209ff23fSmrg if(t->theatre_num<0)return FALSE; 76209ff23fSmrg return t->VIP->write(t->VIP,((t->theatre_num & 0x03)<<14) | reg,4, (uint8_t *) &data); 77209ff23fSmrg} 78209ff23fSmrg#define RT_regw(reg,data) theatre_write(t,(reg),(data)) 79209ff23fSmrg#endif 80209ff23fSmrg 81209ff23fSmrg#define RT_regr(reg,data) theatre_read(t,(reg),(data)) 82209ff23fSmrg#define VIP_TYPE "ATI VIP BUS" 83209ff23fSmrg 84209ff23fSmrg 85209ff23fSmrg_X_EXPORT TheatrePtr DetectTheatre(GENERIC_BUS_Ptr b) 86209ff23fSmrg{ 87209ff23fSmrg TheatrePtr t; 88209ff23fSmrg int i; 89209ff23fSmrg uint32_t val; 90209ff23fSmrg char s[20]; 91209ff23fSmrg 92209ff23fSmrg b->ioctl(b,GB_IOCTL_GET_TYPE,20,s); 93209ff23fSmrg if(strcmp(VIP_TYPE, s)){ 9468105dcbSveego xf86DrvMsg(b->pScrn->scrnIndex, X_ERROR, "DetectTheatre must be called with bus of type \"%s\", not \"%s\"\n", 95209ff23fSmrg VIP_TYPE, s); 96209ff23fSmrg return NULL; 97209ff23fSmrg } 98209ff23fSmrg 990974d292Smrg t = calloc(1,sizeof(TheatreRec)); 100209ff23fSmrg t->VIP = b; 101209ff23fSmrg t->theatre_num = -1; 102209ff23fSmrg t->mode=MODE_UNINITIALIZED; 103209ff23fSmrg 104209ff23fSmrg b->read(b, VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val); 105209ff23fSmrg for(i=0;i<4;i++) 106209ff23fSmrg { 107209ff23fSmrg if(b->read(b, ((i & 0x03)<<14) | VIP_VIP_VENDOR_DEVICE_ID, 4, (uint8_t *)&val)) 108209ff23fSmrg { 10968105dcbSveego if(val)xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, 110209ff23fSmrg "Device %d on VIP bus ids as 0x%08x\n", i, 111209ff23fSmrg (unsigned)val); 112209ff23fSmrg if(t->theatre_num>=0)continue; /* already found one instance */ 113209ff23fSmrg switch(val){ 114209ff23fSmrg case RT100_ATI_ID: 115209ff23fSmrg t->theatre_num=i; 116209ff23fSmrg t->theatre_id=RT100_ATI_ID; 117209ff23fSmrg break; 118209ff23fSmrg case RT200_ATI_ID: 119209ff23fSmrg t->theatre_num=i; 120209ff23fSmrg t->theatre_id=RT200_ATI_ID; 121209ff23fSmrg break; 122209ff23fSmrg } 123209ff23fSmrg } else { 12468105dcbSveego xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, "No response from device %d on VIP bus\n",i); 125209ff23fSmrg } 126209ff23fSmrg } 12768105dcbSveego if(t->theatre_num>=0)xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, 128209ff23fSmrg "Detected Rage Theatre as device %d on VIP bus with id 0x%08x\n", 129209ff23fSmrg t->theatre_num, (unsigned)t->theatre_id); 130209ff23fSmrg 131209ff23fSmrg if(t->theatre_num < 0) 132209ff23fSmrg { 1330974d292Smrg free(t); 134209ff23fSmrg return NULL; 135209ff23fSmrg } 136209ff23fSmrg 137209ff23fSmrg RT_regr(VIP_VIP_REVISION_ID, &val); 13868105dcbSveego xf86DrvMsg(b->pScrn->scrnIndex, X_INFO, "Detected Rage Theatre revision %8.8X\n", 139209ff23fSmrg (unsigned)val); 140209ff23fSmrg 141209ff23fSmrg#if 0 142209ff23fSmrgDumpRageTheatreRegsByName(t); 143209ff23fSmrg#endif 144209ff23fSmrg 145209ff23fSmrg return t; 146209ff23fSmrg} 147209ff23fSmrg 148