122851890Sopenharmony_ci/****************************************************************************
222851890Sopenharmony_ci ****************************************************************************
322851890Sopenharmony_ci ***
422851890Sopenharmony_ci ***   This header was automatically generated from a Linux kernel header
522851890Sopenharmony_ci ***   of the same name, to make information necessary for userspace to
622851890Sopenharmony_ci ***   call into the kernel available to libc.  It contains only constants,
722851890Sopenharmony_ci ***   structures, and macros generated from the original header, and thus,
822851890Sopenharmony_ci ***   contains no copyrightable information.
922851890Sopenharmony_ci ***
1022851890Sopenharmony_ci ***   To edit the content of this header, modify the corresponding
1122851890Sopenharmony_ci ***   source file (e.g. under external/kernel-headers/original/) then
1222851890Sopenharmony_ci ***   run bionic/libc/kernel/tools/update_all.py
1322851890Sopenharmony_ci ***
1422851890Sopenharmony_ci ***   Any manual change here will be lost the next time this script will
1522851890Sopenharmony_ci ***   be run. You've been warned!
1622851890Sopenharmony_ci ***
1722851890Sopenharmony_ci ****************************************************************************
1822851890Sopenharmony_ci ****************************************************************************/
1922851890Sopenharmony_ci#ifndef _UAPI_LINUX_DMABUF_POOL_H
2022851890Sopenharmony_ci#define _UAPI_LINUX_DMABUF_POOL_H
2122851890Sopenharmony_ci#include <linux/ioctl.h>
2222851890Sopenharmony_ci#include <linux/types.h>
2322851890Sopenharmony_ci#include <stddef.h>
2422851890Sopenharmony_ci#define DMA_HEAP_VALID_FD_FLAGS (O_CLOEXEC | O_ACCMODE)
2522851890Sopenharmony_ci#define DMA_HEAP_VALID_HEAP_FLAGS (0)
2622851890Sopenharmony_cistruct dma_heap_allocation_data {
2722851890Sopenharmony_ci  __u64 len;
2822851890Sopenharmony_ci  __u32 fd;
2922851890Sopenharmony_ci  __u32 fd_flags;
3022851890Sopenharmony_ci  __u64 heap_flags;
3122851890Sopenharmony_ci};
3222851890Sopenharmony_ci#define DMA_HEAP_IOC_MAGIC 'H'
3322851890Sopenharmony_ci
3422851890Sopenharmony_cienum dma_heap_flag_owner_id {
3522851890Sopenharmony_ci	OWNER_DEFAULT = 0,
3622851890Sopenharmony_ci	OWNER_GPU,
3722851890Sopenharmony_ci	OWNER_MEDIA_CODEC,
3822851890Sopenharmony_ci	COUNT_DMA_HEAP_FLAG_OWNER,
3922851890Sopenharmony_ci};
4022851890Sopenharmony_ci
4122851890Sopenharmony_ci#define OWNER_OFFSET_BIT 27 /* 27 bit */
4222851890Sopenharmony_ci#define OWNER_MASK (0xfUL << OWNER_OFFSET_BIT)
4322851890Sopenharmony_ci
4422851890Sopenharmony_ci/* Use the 27-30 bits of heap flags as owner_id flag */
4522851890Sopenharmony_cistatic inline void set_owner_id_for_heap_flags(__u64 *heap_flags, __u64 owner_id)
4622851890Sopenharmony_ci{
4722851890Sopenharmony_ci    if (heap_flags == NULL || owner_id >= COUNT_DMA_HEAP_FLAG_OWNER) {
4822851890Sopenharmony_ci        return;
4922851890Sopenharmony_ci    }
5022851890Sopenharmony_ci    *heap_flags |= owner_id << OWNER_OFFSET_BIT;
5122851890Sopenharmony_ci}
5222851890Sopenharmony_ci
5322851890Sopenharmony_ci/* To get the binary number of owner_id */
5422851890Sopenharmony_cistatic inline __u64 get_owner_id_from_heap_flags(__u64 heap_flags)
5522851890Sopenharmony_ci{
5622851890Sopenharmony_ci    return (heap_flags & OWNER_MASK) >> OWNER_OFFSET_BIT;
5722851890Sopenharmony_ci}
5822851890Sopenharmony_ci
5922851890Sopenharmony_ci#define DMA_HEAP_IOCTL_ALLOC _IOWR(DMA_HEAP_IOC_MAGIC, 0x0, struct dma_heap_allocation_data)
6022851890Sopenharmony_ci#endif
61