1*4882a593Smuzhiyun /**
2*4882a593Smuzhiyun * \file mga_ioc32.c
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * 32-bit ioctl compatibility routines for the MGA DRM.
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * \author Dave Airlie <airlied@linux.ie> with code from patches by Egbert Eich
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * Copyright (C) Paul Mackerras 2005
10*4882a593Smuzhiyun * Copyright (C) Egbert Eich 2003,2004
11*4882a593Smuzhiyun * Copyright (C) Dave Airlie 2005
12*4882a593Smuzhiyun * All Rights Reserved.
13*4882a593Smuzhiyun *
14*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a
15*4882a593Smuzhiyun * copy of this software and associated documentation files (the "Software"),
16*4882a593Smuzhiyun * to deal in the Software without restriction, including without limitation
17*4882a593Smuzhiyun * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18*4882a593Smuzhiyun * and/or sell copies of the Software, and to permit persons to whom the
19*4882a593Smuzhiyun * Software is furnished to do so, subject to the following conditions:
20*4882a593Smuzhiyun *
21*4882a593Smuzhiyun * The above copyright notice and this permission notice (including the next
22*4882a593Smuzhiyun * paragraph) shall be included in all copies or substantial portions of the
23*4882a593Smuzhiyun * Software.
24*4882a593Smuzhiyun *
25*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26*4882a593Smuzhiyun * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28*4882a593Smuzhiyun * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29*4882a593Smuzhiyun * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30*4882a593Smuzhiyun * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31*4882a593Smuzhiyun * IN THE SOFTWARE.
32*4882a593Smuzhiyun */
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun #include <linux/compat.h>
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun #include <drm/drm.h>
37*4882a593Smuzhiyun #include <drm/drm_ioctl.h>
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun #include "nouveau_ioctl.h"
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun /**
42*4882a593Smuzhiyun * Called whenever a 32-bit process running under a 64-bit kernel
43*4882a593Smuzhiyun * performs an ioctl on /dev/dri/card<n>.
44*4882a593Smuzhiyun *
45*4882a593Smuzhiyun * \param filp file pointer.
46*4882a593Smuzhiyun * \param cmd command.
47*4882a593Smuzhiyun * \param arg user argument.
48*4882a593Smuzhiyun * \return zero on success or negative number on failure.
49*4882a593Smuzhiyun */
nouveau_compat_ioctl(struct file * filp,unsigned int cmd,unsigned long arg)50*4882a593Smuzhiyun long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
51*4882a593Smuzhiyun unsigned long arg)
52*4882a593Smuzhiyun {
53*4882a593Smuzhiyun unsigned int nr = DRM_IOCTL_NR(cmd);
54*4882a593Smuzhiyun drm_ioctl_compat_t *fn = NULL;
55*4882a593Smuzhiyun int ret;
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun if (nr < DRM_COMMAND_BASE)
58*4882a593Smuzhiyun return drm_compat_ioctl(filp, cmd, arg);
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun #if 0
61*4882a593Smuzhiyun if (nr < DRM_COMMAND_BASE + ARRAY_SIZE(mga_compat_ioctls))
62*4882a593Smuzhiyun fn = nouveau_compat_ioctls[nr - DRM_COMMAND_BASE];
63*4882a593Smuzhiyun #endif
64*4882a593Smuzhiyun if (fn != NULL)
65*4882a593Smuzhiyun ret = (*fn)(filp, cmd, arg);
66*4882a593Smuzhiyun else
67*4882a593Smuzhiyun ret = nouveau_drm_ioctl(filp, cmd, arg);
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun return ret;
70*4882a593Smuzhiyun }
71