diff options
Diffstat (limited to 'drivers/char/drm/sis_mm.c')
-rw-r--r-- | drivers/char/drm/sis_mm.c | 92 |
1 files changed, 38 insertions, 54 deletions
diff --git a/drivers/char/drm/sis_mm.c b/drivers/char/drm/sis_mm.c index cefbc3086d84..8c66838ff515 100644 --- a/drivers/char/drm/sis_mm.c +++ b/drivers/char/drm/sis_mm.c | |||
@@ -82,15 +82,12 @@ static unsigned long sis_sman_mm_offset(void *private, void *ref) | |||
82 | 82 | ||
83 | #endif /* CONFIG_FB_SIS */ | 83 | #endif /* CONFIG_FB_SIS */ |
84 | 84 | ||
85 | static int sis_fb_init(DRM_IOCTL_ARGS) | 85 | static int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv) |
86 | { | 86 | { |
87 | DRM_DEVICE; | ||
88 | drm_sis_private_t *dev_priv = dev->dev_private; | 87 | drm_sis_private_t *dev_priv = dev->dev_private; |
89 | drm_sis_fb_t fb; | 88 | drm_sis_fb_t *fb = data; |
90 | int ret; | 89 | int ret; |
91 | 90 | ||
92 | DRM_COPY_FROM_USER_IOCTL(fb, (drm_sis_fb_t __user *) data, sizeof(fb)); | ||
93 | |||
94 | mutex_lock(&dev->struct_mutex); | 91 | mutex_lock(&dev->struct_mutex); |
95 | #if defined(CONFIG_FB_SIS) | 92 | #if defined(CONFIG_FB_SIS) |
96 | { | 93 | { |
@@ -105,7 +102,7 @@ static int sis_fb_init(DRM_IOCTL_ARGS) | |||
105 | } | 102 | } |
106 | #else | 103 | #else |
107 | ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0, | 104 | ret = drm_sman_set_range(&dev_priv->sman, VIDEO_TYPE, 0, |
108 | fb.size >> SIS_MM_ALIGN_SHIFT); | 105 | fb->size >> SIS_MM_ALIGN_SHIFT); |
109 | #endif | 106 | #endif |
110 | 107 | ||
111 | if (ret) { | 108 | if (ret) { |
@@ -115,25 +112,22 @@ static int sis_fb_init(DRM_IOCTL_ARGS) | |||
115 | } | 112 | } |
116 | 113 | ||
117 | dev_priv->vram_initialized = 1; | 114 | dev_priv->vram_initialized = 1; |
118 | dev_priv->vram_offset = fb.offset; | 115 | dev_priv->vram_offset = fb->offset; |
119 | 116 | ||
120 | mutex_unlock(&dev->struct_mutex); | 117 | mutex_unlock(&dev->struct_mutex); |
121 | DRM_DEBUG("offset = %u, size = %u", fb.offset, fb.size); | 118 | DRM_DEBUG("offset = %u, size = %u", fb->offset, fb->size); |
122 | 119 | ||
123 | return 0; | 120 | return 0; |
124 | } | 121 | } |
125 | 122 | ||
126 | static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, | 123 | static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, |
127 | unsigned long data, int pool) | 124 | void *data, int pool) |
128 | { | 125 | { |
129 | drm_sis_private_t *dev_priv = dev->dev_private; | 126 | drm_sis_private_t *dev_priv = dev->dev_private; |
130 | drm_sis_mem_t __user *argp = (drm_sis_mem_t __user *) data; | 127 | drm_sis_mem_t *mem = data; |
131 | drm_sis_mem_t mem; | ||
132 | int retval = 0; | 128 | int retval = 0; |
133 | struct drm_memblock_item *item; | 129 | struct drm_memblock_item *item; |
134 | 130 | ||
135 | DRM_COPY_FROM_USER_IOCTL(mem, argp, sizeof(mem)); | ||
136 | |||
137 | mutex_lock(&dev->struct_mutex); | 131 | mutex_lock(&dev->struct_mutex); |
138 | 132 | ||
139 | if (0 == ((pool == 0) ? dev_priv->vram_initialized : | 133 | if (0 == ((pool == 0) ? dev_priv->vram_initialized : |
@@ -143,70 +137,62 @@ static int sis_drm_alloc(struct drm_device *dev, struct drm_file *file_priv, | |||
143 | return -EINVAL; | 137 | return -EINVAL; |
144 | } | 138 | } |
145 | 139 | ||
146 | mem.size = (mem.size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT; | 140 | mem->size = (mem->size + SIS_MM_ALIGN_MASK) >> SIS_MM_ALIGN_SHIFT; |
147 | item = drm_sman_alloc(&dev_priv->sman, pool, mem.size, 0, | 141 | item = drm_sman_alloc(&dev_priv->sman, pool, mem->size, 0, |
148 | (unsigned long)file_priv); | 142 | (unsigned long)file_priv); |
149 | 143 | ||
150 | mutex_unlock(&dev->struct_mutex); | 144 | mutex_unlock(&dev->struct_mutex); |
151 | if (item) { | 145 | if (item) { |
152 | mem.offset = ((pool == 0) ? | 146 | mem->offset = ((pool == 0) ? |
153 | dev_priv->vram_offset : dev_priv->agp_offset) + | 147 | dev_priv->vram_offset : dev_priv->agp_offset) + |
154 | (item->mm-> | 148 | (item->mm-> |
155 | offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT); | 149 | offset(item->mm, item->mm_info) << SIS_MM_ALIGN_SHIFT); |
156 | mem.free = item->user_hash.key; | 150 | mem->free = item->user_hash.key; |
157 | mem.size = mem.size << SIS_MM_ALIGN_SHIFT; | 151 | mem->size = mem->size << SIS_MM_ALIGN_SHIFT; |
158 | } else { | 152 | } else { |
159 | mem.offset = 0; | 153 | mem->offset = 0; |
160 | mem.size = 0; | 154 | mem->size = 0; |
161 | mem.free = 0; | 155 | mem->free = 0; |
162 | retval = -ENOMEM; | 156 | retval = -ENOMEM; |
163 | } | 157 | } |
164 | 158 | ||
165 | DRM_COPY_TO_USER_IOCTL(argp, mem, sizeof(mem)); | 159 | DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem->size, |
166 | 160 | mem->offset); | |
167 | DRM_DEBUG("alloc %d, size = %d, offset = %d\n", pool, mem.size, | ||
168 | mem.offset); | ||
169 | 161 | ||
170 | return retval; | 162 | return retval; |
171 | } | 163 | } |
172 | 164 | ||
173 | static int sis_drm_free(DRM_IOCTL_ARGS) | 165 | static int sis_drm_free(struct drm_device *dev, void *data, struct drm_file *file_priv) |
174 | { | 166 | { |
175 | DRM_DEVICE; | ||
176 | drm_sis_private_t *dev_priv = dev->dev_private; | 167 | drm_sis_private_t *dev_priv = dev->dev_private; |
177 | drm_sis_mem_t mem; | 168 | drm_sis_mem_t *mem = data; |
178 | int ret; | 169 | int ret; |
179 | 170 | ||
180 | DRM_COPY_FROM_USER_IOCTL(mem, (drm_sis_mem_t __user *) data, | ||
181 | sizeof(mem)); | ||
182 | |||
183 | mutex_lock(&dev->struct_mutex); | 171 | mutex_lock(&dev->struct_mutex); |
184 | ret = drm_sman_free_key(&dev_priv->sman, mem.free); | 172 | ret = drm_sman_free_key(&dev_priv->sman, mem->free); |
185 | mutex_unlock(&dev->struct_mutex); | 173 | mutex_unlock(&dev->struct_mutex); |
186 | DRM_DEBUG("free = 0x%lx\n", mem.free); | 174 | DRM_DEBUG("free = 0x%lx\n", mem->free); |
187 | 175 | ||
188 | return ret; | 176 | return ret; |
189 | } | 177 | } |
190 | 178 | ||
191 | static int sis_fb_alloc(DRM_IOCTL_ARGS) | 179 | static int sis_fb_alloc(struct drm_device *dev, void *data, |
180 | struct drm_file *file_priv) | ||
192 | { | 181 | { |
193 | DRM_DEVICE; | ||
194 | return sis_drm_alloc(dev, file_priv, data, VIDEO_TYPE); | 182 | return sis_drm_alloc(dev, file_priv, data, VIDEO_TYPE); |
195 | } | 183 | } |
196 | 184 | ||
197 | static int sis_ioctl_agp_init(DRM_IOCTL_ARGS) | 185 | static int sis_ioctl_agp_init(struct drm_device *dev, void *data, |
186 | struct drm_file *file_priv) | ||
198 | { | 187 | { |
199 | DRM_DEVICE; | ||
200 | drm_sis_private_t *dev_priv = dev->dev_private; | 188 | drm_sis_private_t *dev_priv = dev->dev_private; |
201 | drm_sis_agp_t agp; | 189 | drm_sis_agp_t *agp = data; |
202 | int ret; | 190 | int ret; |
203 | dev_priv = dev->dev_private; | 191 | dev_priv = dev->dev_private; |
204 | 192 | ||
205 | DRM_COPY_FROM_USER_IOCTL(agp, (drm_sis_agp_t __user *) data, | ||
206 | sizeof(agp)); | ||
207 | mutex_lock(&dev->struct_mutex); | 193 | mutex_lock(&dev->struct_mutex); |
208 | ret = drm_sman_set_range(&dev_priv->sman, AGP_TYPE, 0, | 194 | ret = drm_sman_set_range(&dev_priv->sman, AGP_TYPE, 0, |
209 | agp.size >> SIS_MM_ALIGN_SHIFT); | 195 | agp->size >> SIS_MM_ALIGN_SHIFT); |
210 | 196 | ||
211 | if (ret) { | 197 | if (ret) { |
212 | DRM_ERROR("AGP memory manager initialisation error\n"); | 198 | DRM_ERROR("AGP memory manager initialisation error\n"); |
@@ -215,16 +201,16 @@ static int sis_ioctl_agp_init(DRM_IOCTL_ARGS) | |||
215 | } | 201 | } |
216 | 202 | ||
217 | dev_priv->agp_initialized = 1; | 203 | dev_priv->agp_initialized = 1; |
218 | dev_priv->agp_offset = agp.offset; | 204 | dev_priv->agp_offset = agp->offset; |
219 | mutex_unlock(&dev->struct_mutex); | 205 | mutex_unlock(&dev->struct_mutex); |
220 | 206 | ||
221 | DRM_DEBUG("offset = %u, size = %u", agp.offset, agp.size); | 207 | DRM_DEBUG("offset = %u, size = %u", agp->offset, agp->size); |
222 | return 0; | 208 | return 0; |
223 | } | 209 | } |
224 | 210 | ||
225 | static int sis_ioctl_agp_alloc(DRM_IOCTL_ARGS) | 211 | static int sis_ioctl_agp_alloc(struct drm_device *dev, void *data, |
212 | struct drm_file *file_priv) | ||
226 | { | 213 | { |
227 | DRM_DEVICE; | ||
228 | 214 | ||
229 | return sis_drm_alloc(dev, file_priv, data, AGP_TYPE); | 215 | return sis_drm_alloc(dev, file_priv, data, AGP_TYPE); |
230 | } | 216 | } |
@@ -334,15 +320,13 @@ void sis_reclaim_buffers_locked(struct drm_device * dev, | |||
334 | return; | 320 | return; |
335 | } | 321 | } |
336 | 322 | ||
337 | drm_ioctl_desc_t sis_ioctls[] = { | 323 | struct drm_ioctl_desc sis_ioctls[] = { |
338 | [DRM_IOCTL_NR(DRM_SIS_FB_ALLOC)] = {sis_fb_alloc, DRM_AUTH}, | 324 | DRM_IOCTL_DEF(DRM_SIS_FB_ALLOC, sis_fb_alloc, DRM_AUTH), |
339 | [DRM_IOCTL_NR(DRM_SIS_FB_FREE)] = {sis_drm_free, DRM_AUTH}, | 325 | DRM_IOCTL_DEF(DRM_SIS_FB_FREE, sis_drm_free, DRM_AUTH), |
340 | [DRM_IOCTL_NR(DRM_SIS_AGP_INIT)] = | 326 | DRM_IOCTL_DEF(DRM_SIS_AGP_INIT, sis_ioctl_agp_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY), |
341 | {sis_ioctl_agp_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY}, | 327 | DRM_IOCTL_DEF(DRM_SIS_AGP_ALLOC, sis_ioctl_agp_alloc, DRM_AUTH), |
342 | [DRM_IOCTL_NR(DRM_SIS_AGP_ALLOC)] = {sis_ioctl_agp_alloc, DRM_AUTH}, | 328 | DRM_IOCTL_DEF(DRM_SIS_AGP_FREE, sis_drm_free, DRM_AUTH), |
343 | [DRM_IOCTL_NR(DRM_SIS_AGP_FREE)] = {sis_drm_free, DRM_AUTH}, | 329 | DRM_IOCTL_DEF(DRM_SIS_FB_INIT, sis_fb_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY), |
344 | [DRM_IOCTL_NR(DRM_SIS_FB_INIT)] = | ||
345 | {sis_fb_init, DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY} | ||
346 | }; | 330 | }; |
347 | 331 | ||
348 | int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls); | 332 | int sis_max_ioctl = DRM_ARRAY_SIZE(sis_ioctls); |