ion.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * drivers/staging/android/uapi/ion.h
  3. *
  4. * Copyright (C) 2011 Google, Inc.
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef _UAPI_LINUX_ION_H
  17. #define _UAPI_LINUX_ION_H
  18. #include <linux/ioctl.h>
  19. #include <linux/types.h>
  20. /**
  21. * enum ion_heap_types - list of all possible types of heaps
  22. * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc
  23. * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
  24. * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved
  25. * carveout heap, allocations are physically
  26. * contiguous
  27. * @ION_HEAP_TYPE_DMA: memory allocated via DMA API
  28. * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask
  29. * is used to identify the heaps, so only 32
  30. * total heap types are supported
  31. */
  32. enum ion_heap_type {
  33. ION_HEAP_TYPE_SYSTEM,
  34. ION_HEAP_TYPE_SYSTEM_CONTIG,
  35. ION_HEAP_TYPE_CARVEOUT,
  36. ION_HEAP_TYPE_CHUNK,
  37. ION_HEAP_TYPE_DMA,
  38. ION_HEAP_TYPE_CUSTOM, /*
  39. * must be last so device specific heaps always
  40. * are at the end of this enum
  41. */
  42. };
  43. #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
  44. /**
  45. * allocation flags - the lower 16 bits are used by core ion, the upper 16
  46. * bits are reserved for use by the heaps themselves.
  47. */
  48. /*
  49. * mappings of this buffer should be cached, ion will do cache maintenance
  50. * when the buffer is mapped for dma
  51. */
  52. #define ION_FLAG_CACHED 1
  53. /**
  54. * DOC: Ion Userspace API
  55. *
  56. * create a client by opening /dev/ion
  57. * most operations handled via following ioctls
  58. *
  59. */
  60. /**
  61. * struct ion_allocation_data - metadata passed from userspace for allocations
  62. * @len: size of the allocation
  63. * @heap_id_mask: mask of heap ids to allocate from
  64. * @flags: flags passed to heap
  65. * @handle: pointer that will be populated with a cookie to use to
  66. * refer to this allocation
  67. *
  68. * Provided by userspace as an argument to the ioctl
  69. */
  70. struct ion_allocation_data {
  71. __u64 len;
  72. __u32 heap_id_mask;
  73. __u32 flags;
  74. __u32 fd;
  75. __u32 unused;
  76. };
  77. #define MAX_HEAP_NAME 32
  78. /**
  79. * struct ion_heap_data - data about a heap
  80. * @name - first 32 characters of the heap name
  81. * @type - heap type
  82. * @heap_id - heap id for the heap
  83. */
  84. struct ion_heap_data {
  85. char name[MAX_HEAP_NAME];
  86. __u32 type;
  87. __u32 heap_id;
  88. __u32 reserved0;
  89. __u32 reserved1;
  90. __u32 reserved2;
  91. };
  92. /**
  93. * struct ion_heap_query - collection of data about all heaps
  94. * @cnt - total number of heaps to be copied
  95. * @heaps - buffer to copy heap data
  96. */
  97. struct ion_heap_query {
  98. __u32 cnt; /* Total number of heaps to be copied */
  99. __u32 reserved0; /* align to 64bits */
  100. __u64 heaps; /* buffer to be populated */
  101. __u32 reserved1;
  102. __u32 reserved2;
  103. };
  104. #define ION_IOC_MAGIC 'I'
  105. /**
  106. * DOC: ION_IOC_ALLOC - allocate memory
  107. *
  108. * Takes an ion_allocation_data struct and returns it with the handle field
  109. * populated with the opaque handle for the allocation.
  110. */
  111. #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
  112. struct ion_allocation_data)
  113. /**
  114. * DOC: ION_IOC_HEAP_QUERY - information about available heaps
  115. *
  116. * Takes an ion_heap_query structure and populates information about
  117. * available Ion heaps.
  118. */
  119. #define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
  120. struct ion_heap_query)
  121. #endif /* _UAPI_LINUX_ION_H */