aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_bufs.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2005-07-10 01:38:56 -0400
committerDave Airlie <airlied@linux.ie>2005-07-10 01:38:56 -0400
commit9c8da5ebbf6f87293cf8555182da271449889a69 (patch)
treec036835be2ec09249f960518ff2703316257d815 /drivers/char/drm/drm_bufs.c
parentd59431bf96d1e8a3d6d240343f559f5e2ace7f1d (diff)
drm: update support for drm pci buffers
The DRM needs to change the drm_pci interface for FreeBSD compatiblity, this patch introduces the drm_dma_handle_t and uses it in the Linux code. From: Tonnerre Lombard, Eric Anholt, and Sergey Vlasov Signed-off-by: David Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_bufs.c')
-rw-r--r--drivers/char/drm/drm_bufs.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index eb3cf550626d..be54efbefe84 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -90,6 +90,7 @@ int drm_addmap( struct inode *inode, struct file *filp,
90 drm_map_t *map; 90 drm_map_t *map;
91 drm_map_t __user *argp = (void __user *)arg; 91 drm_map_t __user *argp = (void __user *)arg;
92 drm_map_list_t *list; 92 drm_map_list_t *list;
93 drm_dma_handle_t *dmah;
93 94
94 if ( !(filp->f_mode & 3) ) return -EACCES; /* Require read/write */ 95 if ( !(filp->f_mode & 3) ) return -EACCES; /* Require read/write */
95 96
@@ -181,21 +182,19 @@ int drm_addmap( struct inode *inode, struct file *filp,
181 map->offset += dev->sg->handle; 182 map->offset += dev->sg->handle;
182 break; 183 break;
183 case _DRM_CONSISTENT: 184 case _DRM_CONSISTENT:
184 {
185 /* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G, 185 /* dma_addr_t is 64bit on i386 with CONFIG_HIGHMEM64G,
186 * As we're limit the address to 2^32-1 (or lses), 186 * As we're limiting the address to 2^32-1 (or less),
187 * casting it down to 32 bits is no problem, but we 187 * casting it down to 32 bits is no problem, but we
188 * need to point to a 64bit variable first. */ 188 * need to point to a 64bit variable first. */
189 dma_addr_t bus_addr; 189 dmah = drm_pci_alloc(dev, map->size, map->size, 0xffffffffUL);
190 map->handle = drm_pci_alloc(dev, map->size, map->size, 190 if (!dmah) {
191 0xffffffffUL, &bus_addr);
192 map->offset = (unsigned long)bus_addr;
193 if (!map->handle) {
194 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 191 drm_free(map, sizeof(*map), DRM_MEM_MAPS);
195 return -ENOMEM; 192 return -ENOMEM;
196 } 193 }
194 map->handle = dmah->vaddr;
195 map->offset = (unsigned long)dmah->busaddr;
196 kfree(dmah);
197 break; 197 break;
198 }
199 default: 198 default:
200 drm_free( map, sizeof(*map), DRM_MEM_MAPS ); 199 drm_free( map, sizeof(*map), DRM_MEM_MAPS );
201 return -EINVAL; 200 return -EINVAL;
@@ -286,6 +285,8 @@ int drm_rmmap(struct inode *inode, struct file *filp,
286 } 285 }
287 286
288 if(!found_maps) { 287 if(!found_maps) {
288 drm_dma_handle_t dmah;
289
289 switch (map->type) { 290 switch (map->type) {
290 case _DRM_REGISTERS: 291 case _DRM_REGISTERS:
291 case _DRM_FRAME_BUFFER: 292 case _DRM_FRAME_BUFFER:
@@ -307,7 +308,10 @@ int drm_rmmap(struct inode *inode, struct file *filp,
307 case _DRM_SCATTER_GATHER: 308 case _DRM_SCATTER_GATHER:
308 break; 309 break;
309 case _DRM_CONSISTENT: 310 case _DRM_CONSISTENT:
310 drm_pci_free(dev, map->size, map->handle, map->offset); 311 dmah.vaddr = map->handle;
312 dmah.busaddr = map->offset;
313 dmah.size = map->size;
314 __drm_pci_free(dev, &dmah);
311 break; 315 break;
312 } 316 }
313 drm_free(map, sizeof(*map), DRM_MEM_MAPS); 317 drm_free(map, sizeof(*map), DRM_MEM_MAPS);