ion.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * 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. /* This file is copied from drivers/staging/android/uapi/ion.h
  17. * This local copy is required for the selftest to pass, when build
  18. * outside the kernel source tree.
  19. * Please keep this file in sync with its original file until the
  20. * ion driver is moved outside the staging tree.
  21. */
  22. #ifndef _UAPI_LINUX_ION_H
  23. #define _UAPI_LINUX_ION_H
  24. #include <linux/ioctl.h>
  25. #include <linux/types.h>
  26. /**
  27. * enum ion_heap_types - list of all possible types of heaps
  28. * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc
  29. * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
  30. * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved
  31. * carveout heap, allocations are physically
  32. * contiguous
  33. * @ION_HEAP_TYPE_DMA: memory allocated via DMA API
  34. * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask
  35. * is used to identify the heaps, so only 32
  36. * total heap types are supported
  37. */
  38. enum ion_heap_type {
  39. ION_HEAP_TYPE_SYSTEM,
  40. ION_HEAP_TYPE_SYSTEM_CONTIG,
  41. ION_HEAP_TYPE_CARVEOUT,
  42. ION_HEAP_TYPE_CHUNK,
  43. ION_HEAP_TYPE_DMA,
  44. ION_HEAP_TYPE_CUSTOM, /*
  45. * must be last so device specific heaps always
  46. * are at the end of this enum
  47. */
  48. };
  49. #define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
  50. /**
  51. * allocation flags - the lower 16 bits are used by core ion, the upper 16
  52. * bits are reserved for use by the heaps themselves.
  53. */
  54. /*
  55. * mappings of this buffer should be cached, ion will do cache maintenance
  56. * when the buffer is mapped for dma
  57. */
  58. #define ION_FLAG_CACHED 1
  59. /**
  60. * DOC: Ion Userspace API
  61. *
  62. * create a client by opening /dev/ion
  63. * most operations handled via following ioctls
  64. *
  65. */
  66. /**
  67. * struct ion_allocation_data - metadata passed from userspace for allocations
  68. * @len: size of the allocation
  69. * @heap_id_mask: mask of heap ids to allocate from
  70. * @flags: flags passed to heap
  71. * @handle: pointer that will be populated with a cookie to use to
  72. * refer to this allocation
  73. *
  74. * Provided by userspace as an argument to the ioctl
  75. */
  76. struct ion_allocation_data {
  77. __u64 len;
  78. __u32 heap_id_mask;
  79. __u32 flags;
  80. __u32 fd;
  81. __u32 unused;
  82. };
  83. #define MAX_HEAP_NAME 32
  84. /**
  85. * struct ion_heap_data - data about a heap
  86. * @name - first 32 characters of the heap name
  87. * @type - heap type
  88. * @heap_id - heap id for the heap
  89. */
  90. struct ion_heap_data {
  91. char name[MAX_HEAP_NAME];
  92. __u32 type;
  93. __u32 heap_id;
  94. __u32 reserved0;
  95. __u32 reserved1;
  96. __u32 reserved2;
  97. };
  98. /**
  99. * struct ion_heap_query - collection of data about all heaps
  100. * @cnt - total number of heaps to be copied
  101. * @heaps - buffer to copy heap data
  102. */
  103. struct ion_heap_query {
  104. __u32 cnt; /* Total number of heaps to be copied */
  105. __u32 reserved0; /* align to 64bits */
  106. __u64 heaps; /* buffer to be populated */
  107. __u32 reserved1;
  108. __u32 reserved2;
  109. };
  110. #define ION_IOC_MAGIC 'I'
  111. /**
  112. * DOC: ION_IOC_ALLOC - allocate memory
  113. *
  114. * Takes an ion_allocation_data struct and returns it with the handle field
  115. * populated with the opaque handle for the allocation.
  116. */
  117. #define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
  118. struct ion_allocation_data)
  119. /**
  120. * DOC: ION_IOC_HEAP_QUERY - information about available heaps
  121. *
  122. * Takes an ion_heap_query structure and populates information about
  123. * available Ion heaps.
  124. */
  125. #define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
  126. struct ion_heap_query)
  127. #endif /* _UAPI_LINUX_ION_H */