1/* 2 * Copyright 2007 George Sapountzis 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 */ 23 24/** 25 * Macros for porting drivers from legacy xfree86 PCI code to the pciaccess 26 * library. The main purpose being to facilitate source code compatibility. 27 */ 28 29#ifndef ATIPCIRENAME_H 30#define ATIPCIRENAME_H 31 32enum region_type { 33 REGION_MEM, 34 REGION_IO 35}; 36 37typedef struct pci_device *pciVideoPtr; 38 39#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor_id) 40#define PCI_DEV_DEVICE_ID(_pcidev) ((_pcidev)->device_id) 41#define PCI_DEV_REVISION(_pcidev) ((_pcidev)->revision) 42 43#define PCI_SUB_VENDOR_ID(_pcidev) ((_pcidev)->subvendor_id) 44#define PCI_SUB_DEVICE_ID(_pcidev) ((_pcidev)->subdevice_id) 45 46/* pci-rework functions take a 'pci_device' parameter instead of a tag */ 47#define PCI_DEV_TAG(_pcidev) (_pcidev) 48 49/* PCI_DEV macros, typically used in printf's, add domain ? XXX */ 50#define PCI_DEV_BUS(_pcidev) ((_pcidev)->bus) 51#define PCI_DEV_DEV(_pcidev) ((_pcidev)->dev) 52#define PCI_DEV_FUNC(_pcidev) ((_pcidev)->func) 53 54/* pci-rework functions take a 'pci_device' parameter instead of a tag */ 55#define PCI_CFG_TAG(_pcidev) (_pcidev) 56 57/* PCI_CFG macros, typically used in DRI init, contain the domain */ 58#define PCI_CFG_BUS(_pcidev) (((_pcidev)->domain << 8) | \ 59 (_pcidev)->bus) 60#define PCI_CFG_DEV(_pcidev) ((_pcidev)->dev) 61#define PCI_CFG_FUNC(_pcidev) ((_pcidev)->func) 62 63#define PCI_REGION_BASE(_pcidev, _b, _type) ((_pcidev)->regions[(_b)].base_addr) 64#define PCI_REGION_SIZE(_pcidev, _b) ((_pcidev)->regions[(_b)].size) 65 66#define PCI_READ_BYTE(_pcidev, _value_ptr, _offset) \ 67 pci_device_cfg_read_u8((_pcidev), (_value_ptr), (_offset)) 68 69#define PCI_READ_LONG(_pcidev, _value_ptr, _offset) \ 70 pci_device_cfg_read_u32((_pcidev), (_value_ptr), (_offset)) 71 72#define PCI_WRITE_LONG(_pcidev, _value, _offset) \ 73 pci_device_cfg_write_u32((_pcidev), (_value), (_offset)) 74 75#define ATI_DEVICE_MATCH(d, i) \ 76 { PCI_VENDOR_ATI, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) } 77 78#endif /* ATIPCIRENAME_H */ 79