2 Copyright 2010, The AROS Development Team. All rights reserved.
9 extern struct drm_driver
* current_drm_driver
;
11 /* FIXME: Array for now, list maybe in future */
12 extern struct drm_file
* drm_files
[128];
14 /* FIXME: this should be generic, not nouveau specific */
15 #include "nouveau_drv.h"
16 void * drmMMap(int fd
, uint32_t handle
)
18 struct drm_file
* f
= drm_files
[fd
];
19 struct drm_gem_object
* gem_object
= NULL
;
20 struct nouveau_bo
* nvbo
= NULL
;
26 /* Get GEM objects from handle */
27 gem_object
= drm_gem_object_lookup(current_drm_driver
->dev
, f
, handle
);
31 /* Translate to nouveau_bo */
32 nvbo
= nouveau_gem_object(gem_object
);
36 /* Perform mapping if not already done */
37 if (!nvbo
->kmap
.virtual)
40 addr
= nvbo
->kmap
.virtual;
43 /* Release the acquired reference */
44 mutex_lock(¤t_drm_driver
->dev
->struct_mutex
);
45 drm_gem_object_unreference(gem_object
);
46 mutex_unlock(¤t_drm_driver
->dev
->struct_mutex
);
48 /* Return virtual address */
52 void drmMUnmap(int fd
, uint32_t handle
)
54 struct drm_file
* f
= drm_files
[fd
];
55 struct drm_gem_object
* gem_object
= NULL
;
56 struct nouveau_bo
* nvbo
= NULL
;
60 /* Get GEM objects from handle */
61 gem_object
= drm_gem_object_lookup(current_drm_driver
->dev
, f
, handle
);
62 if (!gem_object
) return;
64 /* Translate to nouveau_bo */
65 nvbo
= nouveau_gem_object(gem_object
);
68 /* Perform unmapping if not already done */
69 if (nvbo
->kmap
.virtual)
70 nouveau_bo_unmap(nvbo
);
73 /* Release the acquired reference */
74 mutex_lock(¤t_drm_driver
->dev
->struct_mutex
);
75 drm_gem_object_unreference(gem_object
);
76 mutex_unlock(¤t_drm_driver
->dev
->struct_mutex
);