~ubuntu-branches/ubuntu/trusty/xserver-xorg-video-mach64-lts-xenial/trusty-proposed

« back to all changes in this revision

Viewing changes to src/atipcirename.h

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2016-05-03 14:02:37 UTC
  • Revision ID: package-import@ubuntu.com-20160503140237-y946gbjc7p6fg9fn
Tags: upstream-6.9.5
ImportĀ upstreamĀ versionĀ 6.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
32
enum region_type {
 
33
    REGION_MEM,
 
34
    REGION_IO 
 
35
};
 
36
 
 
37
#ifndef XSERVER_LIBPCIACCESS
 
38
 
 
39
/* pciVideoPtr */
 
40
#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor)
 
41
#define PCI_DEV_DEVICE_ID(_pcidev) ((_pcidev)->chipType)
 
42
#define PCI_DEV_REVISION(_pcidev)  ((_pcidev)->chipRev)
 
43
 
 
44
#define PCI_SUB_VENDOR_ID(_pcidev) ((_pcidev)->subsysVendor)
 
45
#define PCI_SUB_DEVICE_ID(_pcidev) ((_pcidev)->subsysCard)
 
46
 
 
47
#define PCI_DEV_TAG(_pcidev) pciTag((_pcidev)->bus,    \
 
48
                                    (_pcidev)->device, \
 
49
                                    (_pcidev)->func)
 
50
#define PCI_DEV_BUS(_pcidev)       ((_pcidev)->bus)
 
51
#define PCI_DEV_DEV(_pcidev)       ((_pcidev)->device)
 
52
#define PCI_DEV_FUNC(_pcidev)      ((_pcidev)->func)
 
53
 
 
54
/* pciConfigPtr */
 
55
#define PCI_CFG_TAG(_pcidev)  (((pciConfigPtr)(_pcidev)->thisCard)->tag)
 
56
#define PCI_CFG_BUS(_pcidev)  (((pciConfigPtr)(_pcidev)->thisCard)->busnum)
 
57
#define PCI_CFG_DEV(_pcidev)  (((pciConfigPtr)(_pcidev)->thisCard)->devnum)
 
58
#define PCI_CFG_FUNC(_pcidev) (((pciConfigPtr)(_pcidev)->thisCard)->funcnum)
 
59
 
 
60
/* region addr: xfree86 uses different fields for memory regions and I/O ports */
 
61
#define PCI_REGION_BASE(_pcidev, _b, _type)             \
 
62
    (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] \
 
63
                             : (_pcidev)->ioBase[(_b)])
 
64
 
 
65
/* region size: xfree86 uses the log2 of the region size,
 
66
 * but with zero meaning no region, not size of one XXX */
 
67
#define PCI_REGION_SIZE(_pcidev, _b) \
 
68
    (((_pcidev)->size[(_b)] > 0) ? (1 << (_pcidev)->size[(_b)]) : 0)
 
69
 
 
70
/* read/write PCI configuration space */
 
71
#define PCI_READ_BYTE(_pcidev, _value_ptr, _offset) \
 
72
    *(_value_ptr) = pciReadByte(PCI_CFG_TAG(_pcidev), (_offset))
 
73
 
 
74
#define PCI_READ_LONG(_pcidev, _value_ptr, _offset) \
 
75
    *(_value_ptr) = pciReadLong(PCI_CFG_TAG(_pcidev), (_offset))
 
76
 
 
77
#define PCI_WRITE_LONG(_pcidev, _value, _offset) \
 
78
    pciWriteLong(PCI_CFG_TAG(_pcidev), (_offset), (_value))
 
79
 
 
80
#else /* XSERVER_LIBPCIACCESS */
 
81
 
 
82
typedef struct pci_device *pciVideoPtr;
 
83
 
 
84
#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor_id)
 
85
#define PCI_DEV_DEVICE_ID(_pcidev) ((_pcidev)->device_id)
 
86
#define PCI_DEV_REVISION(_pcidev)  ((_pcidev)->revision)
 
87
 
 
88
#define PCI_SUB_VENDOR_ID(_pcidev) ((_pcidev)->subvendor_id)
 
89
#define PCI_SUB_DEVICE_ID(_pcidev) ((_pcidev)->subdevice_id)
 
90
 
 
91
/* pci-rework functions take a 'pci_device' parameter instead of a tag */
 
92
#define PCI_DEV_TAG(_pcidev)        (_pcidev)
 
93
 
 
94
/* PCI_DEV macros, typically used in printf's, add domain ? XXX */
 
95
#define PCI_DEV_BUS(_pcidev)       ((_pcidev)->bus)
 
96
#define PCI_DEV_DEV(_pcidev)       ((_pcidev)->dev)
 
97
#define PCI_DEV_FUNC(_pcidev)      ((_pcidev)->func)
 
98
 
 
99
/* pci-rework functions take a 'pci_device' parameter instead of a tag */
 
100
#define PCI_CFG_TAG(_pcidev)        (_pcidev)
 
101
 
 
102
/* PCI_CFG macros, typically used in DRI init, contain the domain */
 
103
#define PCI_CFG_BUS(_pcidev)      (((_pcidev)->domain << 8) | \
 
104
                                    (_pcidev)->bus)
 
105
#define PCI_CFG_DEV(_pcidev)       ((_pcidev)->dev)
 
106
#define PCI_CFG_FUNC(_pcidev)      ((_pcidev)->func)
 
107
 
 
108
#define PCI_REGION_BASE(_pcidev, _b, _type) ((_pcidev)->regions[(_b)].base_addr)
 
109
#define PCI_REGION_SIZE(_pcidev, _b)        ((_pcidev)->regions[(_b)].size)
 
110
 
 
111
#define PCI_READ_BYTE(_pcidev, _value_ptr, _offset) \
 
112
    pci_device_cfg_read_u8((_pcidev), (_value_ptr), (_offset))
 
113
 
 
114
#define PCI_READ_LONG(_pcidev, _value_ptr, _offset) \
 
115
    pci_device_cfg_read_u32((_pcidev), (_value_ptr), (_offset))
 
116
 
 
117
#define PCI_WRITE_LONG(_pcidev, _value, _offset) \
 
118
    pci_device_cfg_write_u32((_pcidev), (_value), (_offset))
 
119
 
 
120
#define ATI_DEVICE_MATCH(d, i) \
 
121
    { PCI_VENDOR_ATI, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
 
122
 
 
123
#endif /* XSERVER_LIBPCIACCESS */
 
124
 
 
125
#endif /* ATIPCIRENAME_H */