| @@ -299,27 +299,31 @@ static struct drm_agp_mem *drm_agp_looku | | | @@ -299,27 +299,31 @@ static struct drm_agp_mem *drm_agp_looku |
299 | * entry and passes it to the unbind_agp() function. | | 299 | * entry and passes it to the unbind_agp() function. |
300 | */ | | 300 | */ |
301 | int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request) | | 301 | int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request) |
302 | { | | 302 | { |
303 | struct drm_agp_mem *entry; | | 303 | struct drm_agp_mem *entry; |
304 | int ret; | | 304 | int ret; |
305 | | | 305 | |
306 | if (!dev->agp || !dev->agp->acquired) | | 306 | if (!dev->agp || !dev->agp->acquired) |
307 | return -EINVAL; | | 307 | return -EINVAL; |
308 | if (!(entry = drm_agp_lookup_entry(dev, request->handle))) | | 308 | if (!(entry = drm_agp_lookup_entry(dev, request->handle))) |
309 | return -EINVAL; | | 309 | return -EINVAL; |
310 | if (!entry->bound) | | 310 | if (!entry->bound) |
311 | return -EINVAL; | | 311 | return -EINVAL; |
| | | 312 | #ifdef __NetBSD__ |
| | | 313 | ret = drm_unbind_agp(dev->agp->bridge, entry->memory); |
| | | 314 | #else |
312 | ret = drm_unbind_agp(entry->memory); | | 315 | ret = drm_unbind_agp(entry->memory); |
| | | 316 | #endif |
313 | if (ret == 0) | | 317 | if (ret == 0) |
314 | entry->bound = 0; | | 318 | entry->bound = 0; |
315 | return ret; | | 319 | return ret; |
316 | } | | 320 | } |
317 | EXPORT_SYMBOL(drm_agp_unbind); | | 321 | EXPORT_SYMBOL(drm_agp_unbind); |
318 | | | 322 | |
319 | | | 323 | |
320 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, | | 324 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
321 | struct drm_file *file_priv) | | 325 | struct drm_file *file_priv) |
322 | { | | 326 | { |
323 | struct drm_agp_binding *request = data; | | 327 | struct drm_agp_binding *request = data; |
324 | | | 328 | |
325 | return drm_agp_unbind(dev, request); | | 329 | return drm_agp_unbind(dev, request); |
| @@ -341,28 +345,33 @@ int drm_agp_unbind_ioctl(struct drm_devi | | | @@ -341,28 +345,33 @@ int drm_agp_unbind_ioctl(struct drm_devi |
341 | int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) | | 345 | int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request) |
342 | { | | 346 | { |
343 | struct drm_agp_mem *entry; | | 347 | struct drm_agp_mem *entry; |
344 | int retcode; | | 348 | int retcode; |
345 | int page; | | 349 | int page; |
346 | | | 350 | |
347 | if (!dev->agp || !dev->agp->acquired) | | 351 | if (!dev->agp || !dev->agp->acquired) |
348 | return -EINVAL; | | 352 | return -EINVAL; |
349 | if (!(entry = drm_agp_lookup_entry(dev, request->handle))) | | 353 | if (!(entry = drm_agp_lookup_entry(dev, request->handle))) |
350 | return -EINVAL; | | 354 | return -EINVAL; |
351 | if (entry->bound) | | 355 | if (entry->bound) |
352 | return -EINVAL; | | 356 | return -EINVAL; |
353 | page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; | | 357 | page = (request->offset + PAGE_SIZE - 1) / PAGE_SIZE; |
| | | 358 | #ifdef __NetBSD__ |
| | | 359 | if ((retcode = drm_bind_agp(dev->agp->bridge, entry->memory, page))) |
| | | 360 | return retcode; |
| | | 361 | #else |
354 | if ((retcode = drm_bind_agp(entry->memory, page))) | | 362 | if ((retcode = drm_bind_agp(entry->memory, page))) |
355 | return retcode; | | 363 | return retcode; |
| | | 364 | #endif |
356 | entry->bound = dev->agp->base + (page << PAGE_SHIFT); | | 365 | entry->bound = dev->agp->base + (page << PAGE_SHIFT); |
357 | DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n", | | 366 | DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n", |
358 | dev->agp->base, entry->bound); | | 367 | dev->agp->base, entry->bound); |
359 | return 0; | | 368 | return 0; |
360 | } | | 369 | } |
361 | EXPORT_SYMBOL(drm_agp_bind); | | 370 | EXPORT_SYMBOL(drm_agp_bind); |
362 | | | 371 | |
363 | | | 372 | |
364 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, | | 373 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
365 | struct drm_file *file_priv) | | 374 | struct drm_file *file_priv) |
366 | { | | 375 | { |
367 | struct drm_agp_binding *request = data; | | 376 | struct drm_agp_binding *request = data; |
368 | | | 377 | |
| @@ -382,31 +391,39 @@ int drm_agp_bind_ioctl(struct drm_device | | | @@ -382,31 +391,39 @@ int drm_agp_bind_ioctl(struct drm_device |
382 | * AGP memory entry. If the memory it's currently bound, unbind it via | | 391 | * AGP memory entry. If the memory it's currently bound, unbind it via |
383 | * unbind_agp(). Frees it via free_agp() as well as the entry itself | | 392 | * unbind_agp(). Frees it via free_agp() as well as the entry itself |
384 | * and unlinks from the doubly linked list it's inserted in. | | 393 | * and unlinks from the doubly linked list it's inserted in. |
385 | */ | | 394 | */ |
386 | int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) | | 395 | int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request) |
387 | { | | 396 | { |
388 | struct drm_agp_mem *entry; | | 397 | struct drm_agp_mem *entry; |
389 | | | 398 | |
390 | if (!dev->agp || !dev->agp->acquired) | | 399 | if (!dev->agp || !dev->agp->acquired) |
391 | return -EINVAL; | | 400 | return -EINVAL; |
392 | if (!(entry = drm_agp_lookup_entry(dev, request->handle))) | | 401 | if (!(entry = drm_agp_lookup_entry(dev, request->handle))) |
393 | return -EINVAL; | | 402 | return -EINVAL; |
394 | if (entry->bound) | | 403 | if (entry->bound) |
| | | 404 | #ifdef __NetBSD__ |
| | | 405 | drm_unbind_agp(dev->agp->bridge, entry->memory); |
| | | 406 | #else |
395 | drm_unbind_agp(entry->memory); | | 407 | drm_unbind_agp(entry->memory); |
| | | 408 | #endif |
396 | | | 409 | |
397 | list_del(&entry->head); | | 410 | list_del(&entry->head); |
398 | | | 411 | |
| | | 412 | #ifdef __NetBSD__ |
| | | 413 | drm_free_agp(dev->agp->bridge, entry->memory, entry->pages); |
| | | 414 | #else |
399 | drm_free_agp(entry->memory, entry->pages); | | 415 | drm_free_agp(entry->memory, entry->pages); |
| | | 416 | #endif |
400 | kfree(entry); | | 417 | kfree(entry); |
401 | return 0; | | 418 | return 0; |
402 | } | | 419 | } |
403 | EXPORT_SYMBOL(drm_agp_free); | | 420 | EXPORT_SYMBOL(drm_agp_free); |
404 | | | 421 | |
405 | | | 422 | |
406 | | | 423 | |
407 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, | | 424 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
408 | struct drm_file *file_priv) | | 425 | struct drm_file *file_priv) |
409 | { | | 426 | { |
410 | struct drm_agp_buffer *request = data; | | 427 | struct drm_agp_buffer *request = data; |
411 | | | 428 | |
412 | return drm_agp_free(dev, request); | | 429 | return drm_agp_free(dev, request); |