1 /* drm_ioctl.h -- IOCTL processing for DRM -*- linux-c -*-
2 * Created: Fri Jan 8 09:01:26 1999 by faith@valinux.com
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
28 * Rickard E. (Rik) Faith <faith@valinux.com>
29 * Gareth Hughes <gareth@valinux.com>
31 * $FreeBSD: src/sys/dev/drm/drm_ioctl.h,v 1.4.2.1 2003/04/26 07:05:28 anholt Exp $
32 * $DragonFly: src/sys/dev/drm/Attic/drm_ioctl.h,v 1.3 2004/02/13 01:23:57 joerg Exp $
35 #include "dev/drm/drmP.h"
37 int DRM(irq_busid)( DRM_IOCTL_ARGS )
39 #if defined(__DragonFly__) || defined(__FreeBSD__)
44 int error, i, num_kids;
46 DRM_COPY_FROM_USER_IOCTL( id, (drm_irq_busid_t *)data, sizeof(id) );
48 pci = devclass_find("pci");
51 bus = devclass_get_device(pci, id.busnum);
54 error = device_get_children(bus, &kids, &num_kids);
59 for (i = 0; i < num_kids; i++) {
61 if (pci_get_slot(dev) == id.devnum
62 && pci_get_function(dev) == id.funcnum)
69 id.irq = pci_get_irq(dev);
72 DRM_DEBUG("%d:%d:%d => IRQ %d\n",
73 id.busnum, id.devnum, id.funcnum, id.irq);
75 DRM_COPY_TO_USER_IOCTL( (drm_irq_busid_t *)data, id, sizeof(id) );
79 /* don't support interrupt-driven drivers on Net yet */
84 int DRM(getunique)( DRM_IOCTL_ARGS )
89 DRM_COPY_FROM_USER_IOCTL( u, (drm_unique_t *)data, sizeof(u) );
91 if (u.unique_len >= dev->unique_len) {
92 if (DRM_COPY_TO_USER(u.unique, dev->unique, dev->unique_len))
93 return DRM_ERR(EFAULT);
95 u.unique_len = dev->unique_len;
97 DRM_COPY_TO_USER_IOCTL( (drm_unique_t *)data, u, sizeof(u) );
102 int DRM(setunique)( DRM_IOCTL_ARGS )
107 if (dev->unique_len || dev->unique)
108 return DRM_ERR(EBUSY);
110 DRM_COPY_FROM_USER_IOCTL( u, (drm_unique_t *)data, sizeof(u) );
112 if (!u.unique_len || u.unique_len > 1024)
113 return DRM_ERR(EINVAL);
115 dev->unique_len = u.unique_len;
116 dev->unique = DRM(alloc)(u.unique_len + 1, DRM_MEM_DRIVER);
118 if(!dev->unique) return DRM_ERR(ENOMEM);
120 if (DRM_COPY_FROM_USER(dev->unique, u.unique, dev->unique_len))
121 return DRM_ERR(EFAULT);
123 dev->unique[dev->unique_len] = '\0';
129 int DRM(getmap)( DRM_IOCTL_ARGS )
133 drm_local_map_t *mapinlist;
134 drm_map_list_entry_t *list;
138 DRM_COPY_FROM_USER_IOCTL( map, (drm_map_t *)data, sizeof(map) );
145 return DRM_ERR(EINVAL);
148 TAILQ_FOREACH(list, dev->maplist, link) {
149 mapinlist = list->map;
151 map.offset = mapinlist->offset;
152 map.size = mapinlist->size;
153 map.type = mapinlist->type;
154 map.flags = mapinlist->flags;
155 map.handle = mapinlist->handle;
156 map.mtrr = mapinlist->mtrr;
167 DRM_COPY_TO_USER_IOCTL( (drm_map_t *)data, map, sizeof(map) );
172 int DRM(getclient)( DRM_IOCTL_ARGS )
180 DRM_COPY_FROM_USER_IOCTL( client, (drm_client_t *)data, sizeof(client) );
184 TAILQ_FOREACH(pt, &dev->files, link) {
187 client.auth = pt->authenticated;
188 client.pid = pt->pid;
189 client.uid = pt->uid;
190 client.magic = pt->magic;
191 client.iocs = pt->ioctl_count;
194 *(drm_client_t *)data = client;
201 DRM_COPY_TO_USER_IOCTL( (drm_client_t *)data, client, sizeof(client) );
206 int DRM(getstats)( DRM_IOCTL_ARGS )
212 memset(&stats, 0, sizeof(stats));
216 for (i = 0; i < dev->counters; i++) {
217 if (dev->types[i] == _DRM_STAT_LOCK)
220 ? dev->lock.hw_lock->lock : 0);
222 stats.data[i].value = atomic_read(&dev->counts[i]);
223 stats.data[i].type = dev->types[i];
226 stats.count = dev->counters;
230 DRM_COPY_TO_USER_IOCTL( (drm_stats_t *)data, stats, sizeof(stats) );
235 int DRM(noop)(DRM_IOCTL_ARGS)