1 /* drm_fops.h -- File operations for DRM -*- linux-c -*-
2 * Created: Mon Jan 4 08:58:31 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 * Daryll Strauss <daryll@valinux.com>
30 * Gareth Hughes <gareth@valinux.com>
32 * $FreeBSD: src/sys/dev/drm/drm_fops.h,v 1.7.2.1 2003/04/26 07:05:28 anholt Exp $
33 * $DragonFly: src/sys/dev/drm/Attic/drm_fops.h,v 1.4 2004/02/13 01:23:57 joerg Exp $
36 #include "dev/drm/drmP.h"
38 drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p)
40 #if defined(__FreeBSD__) && __FreeBSD_version >= 500021
41 uid_t uid = p->td_ucred->cr_svuid;
42 pid_t pid = p->td_proc->p_pid;
44 uid_t uid = p->td_proc->p_ucred->cr_svuid;
45 pid_t pid = p->td_proc->p_pid;
49 TAILQ_FOREACH(priv, &dev->files, link)
50 if (priv->pid == pid && priv->uid == uid)
55 /* DRM(open) is called whenever a process opens /dev/drm. */
57 int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p,
64 return EBUSY; /* No exclusive opens */
67 DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
69 /* FIXME: linux mallocs and bzeros here */
70 priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p);
74 priv = (drm_file_t *) DRM(alloc)(sizeof(*priv), DRM_MEM_FILES);
75 bzero(priv, sizeof(*priv));
76 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
77 priv->uid = p->td_ucred->cr_svuid;
78 priv->pid = p->td_proc->p_pid;
80 priv->uid = p->td_proc->p_ucred->cr_svuid;
81 priv->pid = p->td_proc->p_pid;
87 priv->ioctl_count = 0;
88 priv->authenticated = !DRM_SUSER(p);
90 TAILQ_INSERT_TAIL(&dev->files, priv, link);
93 #if defined(__DragonFly__) || defined(__FreeBSD__)
100 /* The DRM(read) and DRM(poll) are stubs to prevent spurious errors
101 * on older X Servers (4.3.0 and earlier) */
103 int DRM(read)(dev_t kdev, struct uio *uio, int ioflag)
108 int DRM(poll)(dev_t kdev, int events, DRM_STRUCTPROC *p)