qxl_object.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2013 Red Hat Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: Dave Airlie
  23. * Alon Levy
  24. */
  25. #ifndef QXL_OBJECT_H
  26. #define QXL_OBJECT_H
  27. #include "qxl_drv.h"
  28. static inline int qxl_bo_reserve(struct qxl_bo *bo)
  29. {
  30. int r;
  31. r = ttm_bo_reserve(&bo->tbo, true, false, NULL);
  32. if (unlikely(r != 0)) {
  33. if (r != -ERESTARTSYS) {
  34. struct drm_device *ddev = bo->tbo.base.dev;
  35. dev_err(ddev->dev, "%p reserve failed\n", bo);
  36. }
  37. return r;
  38. }
  39. return 0;
  40. }
  41. static inline void qxl_bo_unreserve(struct qxl_bo *bo)
  42. {
  43. ttm_bo_unreserve(&bo->tbo);
  44. }
  45. static inline unsigned long qxl_bo_size(struct qxl_bo *bo)
  46. {
  47. return bo->tbo.base.size;
  48. }
  49. extern int qxl_bo_create(struct qxl_device *qdev,
  50. unsigned long size,
  51. bool kernel, bool pinned, u32 domain,
  52. u32 priority,
  53. struct qxl_surface *surf,
  54. struct qxl_bo **bo_ptr);
  55. int qxl_bo_pin_and_vmap(struct qxl_bo *bo, struct iosys_map *map);
  56. int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map);
  57. int qxl_bo_vunmap_and_unpin(struct qxl_bo *bo);
  58. void qxl_bo_vunmap_locked(struct qxl_bo *bo);
  59. void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int page_offset);
  60. void qxl_bo_kunmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, void *map);
  61. extern struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo);
  62. extern void qxl_bo_unref(struct qxl_bo **bo);
  63. extern int qxl_bo_pin_locked(struct qxl_bo *bo);
  64. extern void qxl_bo_unpin_locked(struct qxl_bo *bo);
  65. extern int qxl_bo_pin(struct qxl_bo *bo);
  66. extern int qxl_bo_unpin(struct qxl_bo *bo);
  67. extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain);
  68. extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo);
  69. #endif