diff options
author | Dave Airlie <airlied@starflyer.(none)> | 2005-09-25 00:28:13 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2005-09-25 00:28:13 -0400 |
commit | b5e89ed53ed8d24f83ba1941c07382af00ed238e (patch) | |
tree | 747bae7a565f88a2e1d5974776eeb054a932c505 /drivers/char/drm/ati_pcigart.c | |
parent | 99a2657a29e2d623c3568cd86b27cac13fb63140 (diff) |
drm: lindent the drm directory.
I've been threatening this for a while, so no point hanging around.
This lindents the DRM code which was always really bad in tabbing department.
I've also fixed some misnamed files in comments and removed some trailing
whitespace.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/ati_pcigart.c')
-rw-r--r-- | drivers/char/drm/ati_pcigart.c | 123 |
1 files changed, 63 insertions, 60 deletions
diff --git a/drivers/char/drm/ati_pcigart.c b/drivers/char/drm/ati_pcigart.c index 957596c63934..d07ce96e9f4b 100644 --- a/drivers/char/drm/ati_pcigart.c +++ b/drivers/char/drm/ati_pcigart.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * \file ati_pcigart.h | 2 | * \file ati_pcigart.c |
3 | * ATI PCI GART support | 3 | * ATI PCI GART support |
4 | * | 4 | * |
5 | * \author Gareth Hughes <gareth@valinux.com> | 5 | * \author Gareth Hughes <gareth@valinux.com> |
@@ -52,87 +52,91 @@ | |||
52 | # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ | 52 | # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ |
53 | # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ | 53 | # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ |
54 | 54 | ||
55 | static unsigned long drm_ati_alloc_pcigart_table( void ) | 55 | static unsigned long drm_ati_alloc_pcigart_table(void) |
56 | { | 56 | { |
57 | unsigned long address; | 57 | unsigned long address; |
58 | struct page *page; | 58 | struct page *page; |
59 | int i; | 59 | int i; |
60 | DRM_DEBUG( "%s\n", __FUNCTION__ ); | 60 | DRM_DEBUG("%s\n", __FUNCTION__); |
61 | 61 | ||
62 | address = __get_free_pages( GFP_KERNEL, ATI_PCIGART_TABLE_ORDER ); | 62 | address = __get_free_pages(GFP_KERNEL, ATI_PCIGART_TABLE_ORDER); |
63 | if ( address == 0UL ) { | 63 | if (address == 0UL) { |
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | 66 | ||
67 | page = virt_to_page( address ); | 67 | page = virt_to_page(address); |
68 | 68 | ||
69 | for ( i = 0 ; i < ATI_PCIGART_TABLE_PAGES ; i++, page++ ) { | 69 | for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { |
70 | get_page(page); | 70 | get_page(page); |
71 | SetPageReserved( page ); | 71 | SetPageReserved(page); |
72 | } | 72 | } |
73 | 73 | ||
74 | DRM_DEBUG( "%s: returning 0x%08lx\n", __FUNCTION__, address ); | 74 | DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address); |
75 | return address; | 75 | return address; |
76 | } | 76 | } |
77 | 77 | ||
78 | static void drm_ati_free_pcigart_table( unsigned long address ) | 78 | static void drm_ati_free_pcigart_table(unsigned long address) |
79 | { | 79 | { |
80 | struct page *page; | 80 | struct page *page; |
81 | int i; | 81 | int i; |
82 | DRM_DEBUG( "%s\n", __FUNCTION__ ); | 82 | DRM_DEBUG("%s\n", __FUNCTION__); |
83 | 83 | ||
84 | page = virt_to_page( address ); | 84 | page = virt_to_page(address); |
85 | 85 | ||
86 | for ( i = 0 ; i < ATI_PCIGART_TABLE_PAGES ; i++, page++ ) { | 86 | for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) { |
87 | __put_page(page); | 87 | __put_page(page); |
88 | ClearPageReserved( page ); | 88 | ClearPageReserved(page); |
89 | } | 89 | } |
90 | 90 | ||
91 | free_pages( address, ATI_PCIGART_TABLE_ORDER ); | 91 | free_pages(address, ATI_PCIGART_TABLE_ORDER); |
92 | } | 92 | } |
93 | 93 | ||
94 | int drm_ati_pcigart_cleanup(drm_device_t *dev, drm_ati_pcigart_info *gart_info) | 94 | int drm_ati_pcigart_cleanup(drm_device_t * dev, |
95 | drm_ati_pcigart_info * gart_info) | ||
95 | { | 96 | { |
96 | drm_sg_mem_t *entry = dev->sg; | 97 | drm_sg_mem_t *entry = dev->sg; |
97 | unsigned long pages; | 98 | unsigned long pages; |
98 | int i; | 99 | int i; |
99 | 100 | ||
100 | /* we need to support large memory configurations */ | 101 | /* we need to support large memory configurations */ |
101 | if ( !entry ) { | 102 | if (!entry) { |
102 | DRM_ERROR( "no scatter/gather memory!\n" ); | 103 | DRM_ERROR("no scatter/gather memory!\n"); |
103 | return 0; | 104 | return 0; |
104 | } | 105 | } |
105 | 106 | ||
106 | if (gart_info->bus_addr) { | 107 | if (gart_info->bus_addr) { |
107 | if (gart_info->gart_table_location==DRM_ATI_GART_MAIN) { | 108 | if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { |
108 | pci_unmap_single(dev->pdev, gart_info->bus_addr, | 109 | pci_unmap_single(dev->pdev, gart_info->bus_addr, |
109 | ATI_PCIGART_TABLE_PAGES * PAGE_SIZE, | 110 | ATI_PCIGART_TABLE_PAGES * PAGE_SIZE, |
110 | PCI_DMA_TODEVICE); | 111 | PCI_DMA_TODEVICE); |
111 | } | 112 | } |
112 | 113 | ||
113 | pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES ) | 114 | pages = (entry->pages <= ATI_MAX_PCIGART_PAGES) |
114 | ? entry->pages : ATI_MAX_PCIGART_PAGES; | 115 | ? entry->pages : ATI_MAX_PCIGART_PAGES; |
115 | 116 | ||
116 | for ( i = 0 ; i < pages ; i++ ) { | 117 | for (i = 0; i < pages; i++) { |
117 | if ( !entry->busaddr[i] ) break; | 118 | if (!entry->busaddr[i]) |
119 | break; | ||
118 | pci_unmap_single(dev->pdev, entry->busaddr[i], | 120 | pci_unmap_single(dev->pdev, entry->busaddr[i], |
119 | PAGE_SIZE, PCI_DMA_TODEVICE); | 121 | PAGE_SIZE, PCI_DMA_TODEVICE); |
120 | } | 122 | } |
121 | 123 | ||
122 | if (gart_info->gart_table_location==DRM_ATI_GART_MAIN) | 124 | if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) |
123 | gart_info->bus_addr=0; | 125 | gart_info->bus_addr = 0; |
124 | } | 126 | } |
125 | 127 | ||
126 | if (gart_info->gart_table_location==DRM_ATI_GART_MAIN && gart_info->addr) { | 128 | if (gart_info->gart_table_location == DRM_ATI_GART_MAIN |
129 | && gart_info->addr) { | ||
127 | drm_ati_free_pcigart_table(gart_info->addr); | 130 | drm_ati_free_pcigart_table(gart_info->addr); |
128 | gart_info->addr=0; | 131 | gart_info->addr = 0; |
129 | } | 132 | } |
130 | 133 | ||
131 | return 1; | 134 | return 1; |
132 | } | 135 | } |
136 | |||
133 | EXPORT_SYMBOL(drm_ati_pcigart_cleanup); | 137 | EXPORT_SYMBOL(drm_ati_pcigart_cleanup); |
134 | 138 | ||
135 | int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) | 139 | int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info * gart_info) |
136 | { | 140 | { |
137 | drm_sg_mem_t *entry = dev->sg; | 141 | drm_sg_mem_t *entry = dev->sg; |
138 | unsigned long address = 0; | 142 | unsigned long address = 0; |
@@ -140,58 +144,56 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) | |||
140 | u32 *pci_gart, page_base, bus_address = 0; | 144 | u32 *pci_gart, page_base, bus_address = 0; |
141 | int i, j, ret = 0; | 145 | int i, j, ret = 0; |
142 | 146 | ||
143 | if ( !entry ) { | 147 | if (!entry) { |
144 | DRM_ERROR( "no scatter/gather memory!\n" ); | 148 | DRM_ERROR("no scatter/gather memory!\n"); |
145 | goto done; | 149 | goto done; |
146 | } | 150 | } |
147 | 151 | ||
148 | if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) | 152 | if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { |
149 | { | ||
150 | DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n"); | 153 | DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n"); |
151 | 154 | ||
152 | address = drm_ati_alloc_pcigart_table(); | 155 | address = drm_ati_alloc_pcigart_table(); |
153 | if ( !address ) { | 156 | if (!address) { |
154 | DRM_ERROR( "cannot allocate PCI GART page!\n" ); | 157 | DRM_ERROR("cannot allocate PCI GART page!\n"); |
155 | goto done; | 158 | goto done; |
156 | } | 159 | } |
157 | 160 | ||
158 | if ( !dev->pdev ) { | 161 | if (!dev->pdev) { |
159 | DRM_ERROR( "PCI device unknown!\n" ); | 162 | DRM_ERROR("PCI device unknown!\n"); |
160 | goto done; | 163 | goto done; |
161 | } | 164 | } |
162 | 165 | ||
163 | bus_address = pci_map_single(dev->pdev, (void *)address, | 166 | bus_address = pci_map_single(dev->pdev, (void *)address, |
164 | ATI_PCIGART_TABLE_PAGES * PAGE_SIZE, | 167 | ATI_PCIGART_TABLE_PAGES * |
165 | PCI_DMA_TODEVICE); | 168 | PAGE_SIZE, PCI_DMA_TODEVICE); |
166 | if (bus_address == 0) { | 169 | if (bus_address == 0) { |
167 | DRM_ERROR( "unable to map PCIGART pages!\n" ); | 170 | DRM_ERROR("unable to map PCIGART pages!\n"); |
168 | drm_ati_free_pcigart_table( address ); | 171 | drm_ati_free_pcigart_table(address); |
169 | address = 0; | 172 | address = 0; |
170 | goto done; | 173 | goto done; |
171 | } | 174 | } |
172 | } | 175 | } else { |
173 | else | ||
174 | { | ||
175 | address = gart_info->addr; | 176 | address = gart_info->addr; |
176 | bus_address = gart_info->bus_addr; | 177 | bus_address = gart_info->bus_addr; |
177 | DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", bus_address, address); | 178 | DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", |
179 | bus_address, address); | ||
178 | } | 180 | } |
179 | 181 | ||
180 | pci_gart = (u32 *)address; | 182 | pci_gart = (u32 *) address; |
181 | 183 | ||
182 | pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES ) | 184 | pages = (entry->pages <= ATI_MAX_PCIGART_PAGES) |
183 | ? entry->pages : ATI_MAX_PCIGART_PAGES; | 185 | ? entry->pages : ATI_MAX_PCIGART_PAGES; |
184 | 186 | ||
185 | memset( pci_gart, 0, ATI_MAX_PCIGART_PAGES * sizeof(u32) ); | 187 | memset(pci_gart, 0, ATI_MAX_PCIGART_PAGES * sizeof(u32)); |
186 | 188 | ||
187 | for ( i = 0 ; i < pages ; i++ ) { | 189 | for (i = 0; i < pages; i++) { |
188 | /* we need to support large memory configurations */ | 190 | /* we need to support large memory configurations */ |
189 | entry->busaddr[i] = pci_map_single(dev->pdev, | 191 | entry->busaddr[i] = pci_map_single(dev->pdev, |
190 | page_address( entry->pagelist[i] ), | 192 | page_address(entry-> |
191 | PAGE_SIZE, | 193 | pagelist[i]), |
192 | PCI_DMA_TODEVICE); | 194 | PAGE_SIZE, PCI_DMA_TODEVICE); |
193 | if (entry->busaddr[i] == 0) { | 195 | if (entry->busaddr[i] == 0) { |
194 | DRM_ERROR( "unable to map PCIGART pages!\n" ); | 196 | DRM_ERROR("unable to map PCIGART pages!\n"); |
195 | drm_ati_pcigart_cleanup(dev, gart_info); | 197 | drm_ati_pcigart_cleanup(dev, gart_info); |
196 | address = 0; | 198 | address = 0; |
197 | bus_address = 0; | 199 | bus_address = 0; |
@@ -201,9 +203,9 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) | |||
201 | 203 | ||
202 | for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { | 204 | for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { |
203 | if (gart_info->is_pcie) | 205 | if (gart_info->is_pcie) |
204 | *pci_gart = (cpu_to_le32(page_base)>>8) | 0xc; | 206 | *pci_gart = (cpu_to_le32(page_base) >> 8) | 0xc; |
205 | else | 207 | else |
206 | *pci_gart++ = cpu_to_le32( page_base ); | 208 | *pci_gart++ = cpu_to_le32(page_base); |
207 | page_base += ATI_PCIGART_PAGE_SIZE; | 209 | page_base += ATI_PCIGART_PAGE_SIZE; |
208 | } | 210 | } |
209 | } | 211 | } |
@@ -216,9 +218,10 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) | |||
216 | mb(); | 218 | mb(); |
217 | #endif | 219 | #endif |
218 | 220 | ||
219 | done: | 221 | done: |
220 | gart_info->addr = address; | 222 | gart_info->addr = address; |
221 | gart_info->bus_addr = bus_address; | 223 | gart_info->bus_addr = bus_address; |
222 | return ret; | 224 | return ret; |
223 | } | 225 | } |
226 | |||
224 | EXPORT_SYMBOL(drm_ati_pcigart_init); | 227 | EXPORT_SYMBOL(drm_ati_pcigart_init); |