]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/dev/drm2/i915/i915_ioc32.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / dev / drm2 / i915 / i915_ioc32.c
1 /*-
2  * Copyright (C) Paul Mackerras 2005
3  * Copyright (C) Alan Hourihane 2005
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the next
14  * paragraph) shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23  * IN THE SOFTWARE.
24  *
25  * Authors:
26  *    Paul Mackerras <paulus@samba.org>
27  *    Alan Hourihane <alanh@fairlite.demon.co.uk>
28  */
29
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
32
33 #include "opt_compat.h"
34
35 #ifdef COMPAT_FREEBSD32
36
37 /** @file i915_ioc32.c
38  * 32-bit ioctl compatibility routines for the i915 DRM.
39  */
40
41 #include <dev/drm2/drmP.h>
42 #include <dev/drm2/drm.h>
43 #include <dev/drm2/i915/i915_drm.h>
44 #include <dev/drm2/i915/i915_drv.h>
45 #include <dev/drm2/i915/intel_drv.h>
46
47 typedef struct _drm_i915_batchbuffer32 {
48         int start;              /* agp offset */
49         int used;               /* nr bytes in use */
50         int DR1;                /* hw flags for GFX_OP_DRAWRECT_INFO */
51         int DR4;                /* window origin for GFX_OP_DRAWRECT_INFO */
52         int num_cliprects;      /* mulitpass with multiple cliprects? */
53         u32 cliprects;          /* pointer to userspace cliprects */
54 } drm_i915_batchbuffer32_t;
55
56 static int compat_i915_batchbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
57 {
58         drm_i915_batchbuffer32_t *batchbuffer32 = data;
59         drm_i915_batchbuffer_t batchbuffer;
60
61         batchbuffer.start = batchbuffer32->start;
62         batchbuffer.used = batchbuffer32->used;
63         batchbuffer.DR1 = batchbuffer32->DR1;
64         batchbuffer.DR4 = batchbuffer32->DR4;
65         batchbuffer.num_cliprects = batchbuffer32->num_cliprects;
66         batchbuffer.cliprects = (void *)(unsigned long)batchbuffer32->cliprects;
67
68         return i915_batchbuffer(dev, (void *)&batchbuffer, file_priv);
69 }
70
71 typedef struct _drm_i915_cmdbuffer32 {
72         u32 buf;                /* pointer to userspace command buffer */
73         int sz;                 /* nr bytes in buf */
74         int DR1;                /* hw flags for GFX_OP_DRAWRECT_INFO */
75         int DR4;                /* window origin for GFX_OP_DRAWRECT_INFO */
76         int num_cliprects;      /* mulitpass with multiple cliprects? */
77         u32 cliprects;          /* pointer to userspace cliprects */
78 } drm_i915_cmdbuffer32_t;
79
80 static int compat_i915_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
81 {
82         drm_i915_cmdbuffer32_t *cmdbuffer32 = data;
83         drm_i915_cmdbuffer_t cmdbuffer;
84
85         cmdbuffer.sz = cmdbuffer32->sz;
86         cmdbuffer.DR1 = cmdbuffer32->DR1;
87         cmdbuffer.DR4 = cmdbuffer32->DR4;
88         cmdbuffer.num_cliprects = cmdbuffer32->num_cliprects;
89         cmdbuffer.cliprects = (void *)(unsigned long)cmdbuffer32->cliprects;
90
91         return i915_cmdbuffer(dev, (void *)&cmdbuffer, file_priv);
92 }
93
94 typedef struct drm_i915_irq_emit32 {
95         u32 irq_seq;
96 } drm_i915_irq_emit32_t;
97
98 static int compat_i915_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv)
99 {
100         drm_i915_irq_emit32_t *req32 = data;
101         drm_i915_irq_emit_t request;
102
103         request.irq_seq = (int *)(unsigned long)req32->irq_seq;
104
105         return i915_irq_emit(dev, (void *)&request, file_priv);
106 }
107 typedef struct drm_i915_getparam32 {
108         int param;
109         u32 value;
110 } drm_i915_getparam32_t;
111
112 static int compat_i915_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv)
113 {
114         drm_i915_getparam32_t *req32 = data;
115         drm_i915_getparam_t request;
116
117         request.param = req32->param;
118         request.value = (void *)(unsigned long)req32->value;
119
120         return i915_getparam(dev, (void *)&request, file_priv);
121 }
122
123 typedef struct drm_i915_mem_alloc32 {
124         int region;
125         int alignment;
126         int size;
127         u32 region_offset;      /* offset from start of fb or agp */
128 } drm_i915_mem_alloc32_t;
129
130 drm_ioctl_desc_t i915_compat_ioctls[] = {
131         DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, compat_i915_batchbuffer, DRM_AUTH),
132         DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, compat_i915_cmdbuffer, DRM_AUTH),
133         DRM_IOCTL_DEF(DRM_I915_GETPARAM, compat_i915_getparam, DRM_AUTH),
134         DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, compat_i915_irq_emit, DRM_AUTH)
135 };
136 int i915_compat_ioctls_nr = DRM_ARRAY_SIZE(i915_compat_ioctls);
137
138 #endif