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