vmwgfx_resource_priv.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**************************************************************************
  2. *
  3. * Copyright © 2012-2014 VMware, Inc., Palo Alto, CA., USA
  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
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #ifndef _VMWGFX_RESOURCE_PRIV_H_
  28. #define _VMWGFX_RESOURCE_PRIV_H_
  29. #include "vmwgfx_drv.h"
  30. enum vmw_cmdbuf_res_state {
  31. VMW_CMDBUF_RES_COMMITTED,
  32. VMW_CMDBUF_RES_ADD,
  33. VMW_CMDBUF_RES_DEL
  34. };
  35. /**
  36. * struct vmw_user_resource_conv - Identify a derived user-exported resource
  37. * type and provide a function to convert its ttm_base_object pointer to
  38. * a struct vmw_resource
  39. */
  40. struct vmw_user_resource_conv {
  41. enum ttm_object_type object_type;
  42. struct vmw_resource *(*base_obj_to_res)(struct ttm_base_object *base);
  43. void (*res_free) (struct vmw_resource *res);
  44. };
  45. /**
  46. * struct vmw_res_func - members and functions common for a resource type
  47. *
  48. * @res_type: Enum that identifies the lru list to use for eviction.
  49. * @needs_backup: Whether the resource is guest-backed and needs
  50. * persistent buffer storage.
  51. * @type_name: String that identifies the resource type.
  52. * @backup_placement: TTM placement for backup buffers.
  53. * @may_evict Whether the resource may be evicted.
  54. * @create: Create a hardware resource.
  55. * @destroy: Destroy a hardware resource.
  56. * @bind: Bind a hardware resource to persistent buffer storage.
  57. * @unbind: Unbind a hardware resource from persistent
  58. * buffer storage.
  59. * @commit_notify: If the resource is a command buffer managed resource,
  60. * callback to notify that a define or remove command
  61. * has been committed to the device.
  62. */
  63. struct vmw_res_func {
  64. enum vmw_res_type res_type;
  65. bool needs_backup;
  66. const char *type_name;
  67. struct ttm_placement *backup_placement;
  68. bool may_evict;
  69. int (*create) (struct vmw_resource *res);
  70. int (*destroy) (struct vmw_resource *res);
  71. int (*bind) (struct vmw_resource *res,
  72. struct ttm_validate_buffer *val_buf);
  73. int (*unbind) (struct vmw_resource *res,
  74. bool readback,
  75. struct ttm_validate_buffer *val_buf);
  76. void (*commit_notify)(struct vmw_resource *res,
  77. enum vmw_cmdbuf_res_state state);
  78. };
  79. int vmw_resource_alloc_id(struct vmw_resource *res);
  80. void vmw_resource_release_id(struct vmw_resource *res);
  81. int vmw_resource_init(struct vmw_private *dev_priv, struct vmw_resource *res,
  82. bool delay_id,
  83. void (*res_free) (struct vmw_resource *res),
  84. const struct vmw_res_func *func);
  85. void vmw_resource_activate(struct vmw_resource *res,
  86. void (*hw_destroy) (struct vmw_resource *));
  87. #endif