Lines Matching +full:dev +full:- +full:handle

35 #include <dev/drm2/drmP.h>
51 int drm_agp_info(struct drm_device *dev, struct drm_agp_info *info) in drm_agp_info() argument
55 if (!dev->agp || !dev->agp->acquired) in drm_agp_info()
56 return -EINVAL; in drm_agp_info()
58 kern = &dev->agp->agp_info; in drm_agp_info()
59 agp_get_info(dev->agp->bridge, kern); in drm_agp_info()
60 info->agp_version_major = 1; in drm_agp_info()
61 info->agp_version_minor = 0; in drm_agp_info()
62 info->mode = kern->ai_mode; in drm_agp_info()
63 info->aperture_base = kern->ai_aperture_base; in drm_agp_info()
64 info->aperture_size = kern->ai_aperture_size; in drm_agp_info()
65 info->memory_allowed = kern->ai_memory_allowed; in drm_agp_info()
66 info->memory_used = kern->ai_memory_used; in drm_agp_info()
67 info->id_vendor = kern->ai_devid & 0xffff; in drm_agp_info()
68 info->id_device = kern->ai_devid >> 16; in drm_agp_info()
75 int drm_agp_info_ioctl(struct drm_device *dev, void *data, in drm_agp_info_ioctl() argument
81 err = drm_agp_info(dev, info); in drm_agp_info_ioctl()
91 * \param dev DRM device that is to acquire AGP.
97 int drm_agp_acquire(struct drm_device * dev) in drm_agp_acquire() argument
101 if (!dev->agp) in drm_agp_acquire()
102 return -ENODEV; in drm_agp_acquire()
103 if (dev->agp->acquired) in drm_agp_acquire()
104 return -EBUSY; in drm_agp_acquire()
105 retcode = agp_acquire(dev->agp->bridge); in drm_agp_acquire()
107 return -retcode; in drm_agp_acquire()
108 dev->agp->acquired = 1; in drm_agp_acquire()
126 int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, in drm_agp_acquire_ioctl() argument
129 return drm_agp_acquire((struct drm_device *) file_priv->minor->dev); in drm_agp_acquire_ioctl()
135 * \param dev DRM device that is to release AGP.
140 int drm_agp_release(struct drm_device * dev) in drm_agp_release() argument
142 if (!dev->agp || !dev->agp->acquired) in drm_agp_release()
143 return -EINVAL; in drm_agp_release()
144 agp_release(dev->agp->bridge); in drm_agp_release()
145 dev->agp->acquired = 0; in drm_agp_release()
150 int drm_agp_release_ioctl(struct drm_device *dev, void *data, in drm_agp_release_ioctl() argument
153 return drm_agp_release(dev); in drm_agp_release_ioctl()
159 * \param dev DRM device that has previously acquired AGP.
166 int drm_agp_enable(struct drm_device * dev, struct drm_agp_mode mode) in drm_agp_enable() argument
168 if (!dev->agp || !dev->agp->acquired) in drm_agp_enable()
169 return -EINVAL; in drm_agp_enable()
171 dev->agp->mode = mode.mode; in drm_agp_enable()
172 agp_enable(dev->agp->bridge, mode.mode); in drm_agp_enable()
173 dev->agp->enabled = 1; in drm_agp_enable()
179 int drm_agp_enable_ioctl(struct drm_device *dev, void *data, in drm_agp_enable_ioctl() argument
184 return drm_agp_enable(dev, *mode); in drm_agp_enable_ioctl()
199 int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request) in drm_agp_alloc() argument
207 if (!dev->agp || !dev->agp->acquired) in drm_agp_alloc()
208 return -EINVAL; in drm_agp_alloc()
210 return -ENOMEM; in drm_agp_alloc()
214 pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE; in drm_agp_alloc()
215 type = (u32) request->type; in drm_agp_alloc()
216 if (!(memory = agp_alloc_memory(dev->agp->bridge, type, pages << PAGE_SHIFT))) { in drm_agp_alloc()
218 return -ENOMEM; in drm_agp_alloc()
221 entry->handle = (unsigned long)memory; in drm_agp_alloc()
222 entry->memory = memory; in drm_agp_alloc()
223 entry->bound = 0; in drm_agp_alloc()
224 entry->pages = pages; in drm_agp_alloc()
225 list_add(&entry->head, &dev->agp->memory); in drm_agp_alloc()
227 agp_memory_info(dev->agp->bridge, entry->memory, &info); in drm_agp_alloc()
229 request->handle = entry->handle; in drm_agp_alloc()
230 request->physical = info.ami_physical; in drm_agp_alloc()
237 int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, in drm_agp_alloc_ioctl() argument
242 return drm_agp_alloc(dev, request); in drm_agp_alloc_ioctl()
246 * Search for the AGP memory entry associated with a handle.
248 * \param dev DRM device structure.
249 * \param handle AGP memory handle.
250 * \return pointer to the drm_agp_mem structure associated with \p handle.
252 * Walks through drm_agp_head::memory until finding a matching handle.
254 static struct drm_agp_mem *drm_agp_lookup_entry(struct drm_device * dev, in drm_agp_lookup_entry() argument
255 unsigned long handle) in drm_agp_lookup_entry() argument
259 list_for_each_entry(entry, &dev->agp->memory, head) { in drm_agp_lookup_entry()
260 if (entry->handle == handle) in drm_agp_lookup_entry()
275 * Verifies the AGP device is present and acquired, looks-up the AGP memory
278 int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request) in drm_agp_unbind() argument
283 if (!dev->agp || !dev->agp->acquired) in drm_agp_unbind()
284 return -EINVAL; in drm_agp_unbind()
285 if (!(entry = drm_agp_lookup_entry(dev, request->handle))) in drm_agp_unbind()
286 return -EINVAL; in drm_agp_unbind()
287 if (!entry->bound) in drm_agp_unbind()
288 return -EINVAL; in drm_agp_unbind()
289 ret = drm_unbind_agp(entry->memory); in drm_agp_unbind()
291 entry->bound = 0; in drm_agp_unbind()
297 int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, in drm_agp_unbind_ioctl() argument
302 return drm_agp_unbind(dev, request); in drm_agp_unbind_ioctl()
315 * is currently bound into the GATT. Looks-up the AGP memory entry and passes
318 int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) in drm_agp_bind() argument
324 if (!dev->agp || !dev->agp->acquired) in drm_agp_bind()
325 return -EINVAL; in drm_agp_bind()
326 if (!(entry = drm_agp_lookup_entry(dev, request->handle))) in drm_agp_bind()
327 return -EINVAL; in drm_agp_bind()
328 if (entry->bound) in drm_agp_bind()
329 return -EINVAL; in drm_agp_bind()
330 page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; in drm_agp_bind()
331 if ((retcode = drm_bind_agp(entry->memory, page))) in drm_agp_bind()
333 entry->bound = dev->agp->base + (page << PAGE_SHIFT); in drm_agp_bind()
334 DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n", in drm_agp_bind()
335 dev->agp->base, entry->bound); in drm_agp_bind()
341 int drm_agp_bind_ioctl(struct drm_device *dev, void *data, in drm_agp_bind_ioctl() argument
346 return drm_agp_bind(dev, request); in drm_agp_bind_ioctl()
363 int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) in drm_agp_free() argument
367 if (!dev->agp || !dev->agp->acquired) in drm_agp_free()
368 return -EINVAL; in drm_agp_free()
369 if (!(entry = drm_agp_lookup_entry(dev, request->handle))) in drm_agp_free()
370 return -EINVAL; in drm_agp_free()
371 if (entry->bound) in drm_agp_free()
372 drm_unbind_agp(entry->memory); in drm_agp_free()
374 list_del(&entry->head); in drm_agp_free()
376 drm_free_agp(entry->memory, entry->pages); in drm_agp_free()
384 int drm_agp_free_ioctl(struct drm_device *dev, void *data, in drm_agp_free_ioctl() argument
389 return drm_agp_free(dev, request); in drm_agp_free_ioctl()
401 struct drm_agp_head *drm_agp_init(struct drm_device *dev) in drm_agp_init() argument
408 head->bridge = agp_find_device(); in drm_agp_init()
409 if (!head->bridge) { in drm_agp_init()
413 agp_get_info(head->bridge, &head->agp_info); in drm_agp_init()
415 INIT_LIST_HEAD(&head->memory); in drm_agp_init()
416 head->cant_use_aperture = 0; in drm_agp_init()
417 head->base = head->agp_info.ai_aperture_base; in drm_agp_init()
426 * No reference is held on the pages during this time -- it is up to the
427 * caller to handle that.
430 drm_agp_bind_pages(struct drm_device *dev, in drm_agp_bind_pages() argument
441 mem = agp_allocate_memory(dev->agp->bridge, num_pages, in drm_agp_bind_pages()
450 mem->pages[i] = pages[i]; in drm_agp_bind_pages()
451 mem->page_count = num_pages; in drm_agp_bind_pages()
453 mem->is_flushed = true; in drm_agp_bind_pages()