Lines Matching refs:dev
32 __FBSDID("$FreeBSD: releng/11.0/sys/dev/drm/drm_context.c 207066 2010-04-22 18:21:25Z rnoland $");
38 #include "dev/drm/drmP.h"
44 void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle)
47 dev->ctx_bitmap == NULL) {
54 clear_bit(ctx_handle, dev->ctx_bitmap);
55 dev->context_sareas[ctx_handle] = NULL;
60 int drm_ctxbitmap_next(struct drm_device *dev)
64 if (dev->ctx_bitmap == NULL)
68 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
74 set_bit(bit, dev->ctx_bitmap);
76 if ((bit+1) > dev->max_context) {
80 ctx_sareas = realloc(dev->context_sareas,
81 max_ctx * sizeof(*dev->context_sareas),
84 clear_bit(bit, dev->ctx_bitmap);
89 dev->max_context = max_ctx;
90 dev->context_sareas = ctx_sareas;
91 dev->context_sareas[bit] = NULL;
97 int drm_ctxbitmap_init(struct drm_device *dev)
103 dev->ctx_bitmap = malloc(PAGE_SIZE, DRM_MEM_CTXBITMAP,
105 if (dev->ctx_bitmap == NULL) {
109 dev->context_sareas = NULL;
110 dev->max_context = -1;
114 temp = drm_ctxbitmap_next(dev);
121 void drm_ctxbitmap_cleanup(struct drm_device *dev)
124 if (dev->context_sareas != NULL)
125 free(dev->context_sareas, DRM_MEM_SAREA);
126 free(dev->ctx_bitmap, DRM_MEM_CTXBITMAP);
134 int drm_getsareactx(struct drm_device *dev, void *data,
141 if (dev->max_context < 0 ||
142 request->ctx_id >= (unsigned) dev->max_context) {
147 map = dev->context_sareas[request->ctx_id];
155 int drm_setsareactx(struct drm_device *dev, void *data,
162 TAILQ_FOREACH(map, &dev->maplist, link) {
164 if (dev->max_context < 0)
166 if (request->ctx_id >= (unsigned) dev->max_context)
168 dev->context_sareas[request->ctx_id] = map;
183 int drm_context_switch(struct drm_device *dev, int old, int new)
185 if (test_and_set_bit(0, &dev->context_flag)) {
192 if (new == dev->last_context) {
193 clear_bit(0, &dev->context_flag);
200 int drm_context_switch_complete(struct drm_device *dev, int new)
202 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
204 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
211 clear_bit(0, &dev->context_flag);
216 int drm_resctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
236 int drm_addctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
240 ctx->handle = drm_ctxbitmap_next(dev);
243 ctx->handle = drm_ctxbitmap_next(dev);
252 if (dev->driver->context_ctor && ctx->handle != DRM_KERNEL_CONTEXT) {
254 dev->driver->context_ctor(dev, ctx->handle);
261 int drm_modctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
267 int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
277 int drm_switchctx(struct drm_device *dev, void *data,
283 return drm_context_switch(dev, dev->last_context, ctx->handle);
286 int drm_newctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
291 drm_context_switch_complete(dev, ctx->handle);
296 int drm_rmctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
302 if (dev->driver->context_dtor) {
304 dev->driver->context_dtor(dev, ctx->handle);
308 drm_ctxbitmap_free(dev, ctx->handle);