|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | + |
| 3 | +/* |
| 4 | + * Copyright 2019 Raspberry Pi (Trading) Ltd. All rights reserved. |
| 5 | + * |
| 6 | + * Based on vmcs_sm_ioctl.h Copyright Broadcom Corporation. |
| 7 | + */ |
| 8 | + |
| 9 | +#ifndef __VC_SM_CMA_IOCTL_H |
| 10 | +#define __VC_SM_CMA_IOCTL_H |
| 11 | + |
| 12 | +/* ---- Include Files ---------------------------------------------------- */ |
| 13 | + |
| 14 | +#if defined(__KERNEL__) |
| 15 | +#include <linux/types.h> /* Needed for standard types */ |
| 16 | +#else |
| 17 | +#include <stdint.h> |
| 18 | +#endif |
| 19 | + |
| 20 | +#include <linux/ioctl.h> |
| 21 | + |
| 22 | +/* ---- Constants and Types ---------------------------------------------- */ |
| 23 | + |
| 24 | +#define VC_SM_CMA_RESOURCE_NAME 32 |
| 25 | +#define VC_SM_CMA_RESOURCE_NAME_DEFAULT "sm-host-resource" |
| 26 | + |
| 27 | +/* Type define used to create unique IOCTL number */ |
| 28 | +#define VC_SM_CMA_MAGIC_TYPE 'J' |
| 29 | + |
| 30 | +/* IOCTL commands on /dev/vc-sm-cma */ |
| 31 | +enum vc_sm_cma_cmd_e { |
| 32 | + VC_SM_CMA_CMD_ALLOC = 0x5A, /* Start at 0x5A arbitrarily */ |
| 33 | + |
| 34 | + VC_SM_CMA_CMD_IMPORT_DMABUF, |
| 35 | + |
| 36 | + VC_SM_CMA_CMD_CLEAN_INVALID2, |
| 37 | + |
| 38 | + VC_SM_CMA_CMD_LAST /* Do not delete */ |
| 39 | +}; |
| 40 | + |
| 41 | +/* Cache type supported, conveniently matches the user space definition in |
| 42 | + * user-vcsm.h. |
| 43 | + */ |
| 44 | +enum vc_sm_cma_cache_e { |
| 45 | + VC_SM_CMA_CACHE_NONE, |
| 46 | + VC_SM_CMA_CACHE_HOST, |
| 47 | + VC_SM_CMA_CACHE_VC, |
| 48 | + VC_SM_CMA_CACHE_BOTH, |
| 49 | +}; |
| 50 | + |
| 51 | +/* IOCTL Data structures */ |
| 52 | +struct vc_sm_cma_ioctl_alloc { |
| 53 | + /* user -> kernel */ |
| 54 | + __u32 size; |
| 55 | + __u32 num; |
| 56 | + __u32 cached; /* enum vc_sm_cma_cache_e */ |
| 57 | + __u32 pad; |
| 58 | + __u8 name[VC_SM_CMA_RESOURCE_NAME]; |
| 59 | + |
| 60 | + /* kernel -> user */ |
| 61 | + __s32 handle; |
| 62 | + __u32 vc_handle; |
| 63 | + __u64 dma_addr; |
| 64 | +}; |
| 65 | + |
| 66 | +struct vc_sm_cma_ioctl_import_dmabuf { |
| 67 | + /* user -> kernel */ |
| 68 | + __s32 dmabuf_fd; |
| 69 | + __u32 cached; /* enum vc_sm_cma_cache_e */ |
| 70 | + __u8 name[VC_SM_CMA_RESOURCE_NAME]; |
| 71 | + |
| 72 | + /* kernel -> user */ |
| 73 | + __s32 handle; |
| 74 | + __u32 vc_handle; |
| 75 | + __u32 size; |
| 76 | + __u32 pad; |
| 77 | + __u64 dma_addr; |
| 78 | +}; |
| 79 | + |
| 80 | +/* |
| 81 | + * Cache functions to be set to struct vc_sm_cma_ioctl_clean_invalid2 |
| 82 | + * invalidate_mode. |
| 83 | + */ |
| 84 | +#define VC_SM_CACHE_OP_NOP 0x00 |
| 85 | +#define VC_SM_CACHE_OP_INV 0x01 |
| 86 | +#define VC_SM_CACHE_OP_CLEAN 0x02 |
| 87 | +#define VC_SM_CACHE_OP_FLUSH 0x03 |
| 88 | + |
| 89 | +struct vc_sm_cma_ioctl_clean_invalid2 { |
| 90 | + __u32 op_count; |
| 91 | + __u32 pad; |
| 92 | + struct vc_sm_cma_ioctl_clean_invalid_block { |
| 93 | + __u32 invalidate_mode; |
| 94 | + __u32 block_count; |
| 95 | + void * __user start_address; |
| 96 | + __u32 block_size; |
| 97 | + __u32 inter_block_stride; |
| 98 | + } s[0]; |
| 99 | +}; |
| 100 | + |
| 101 | +/* IOCTL numbers */ |
| 102 | +#define VC_SM_CMA_IOCTL_MEM_ALLOC\ |
| 103 | + _IOR(VC_SM_CMA_MAGIC_TYPE, VC_SM_CMA_CMD_ALLOC,\ |
| 104 | + struct vc_sm_cma_ioctl_alloc) |
| 105 | + |
| 106 | +#define VC_SM_CMA_IOCTL_MEM_IMPORT_DMABUF\ |
| 107 | + _IOR(VC_SM_CMA_MAGIC_TYPE, VC_SM_CMA_CMD_IMPORT_DMABUF,\ |
| 108 | + struct vc_sm_cma_ioctl_import_dmabuf) |
| 109 | + |
| 110 | +#define VC_SM_CMA_IOCTL_MEM_CLEAN_INVALID2\ |
| 111 | + _IOR(VC_SM_CMA_MAGIC_TYPE, VC_SM_CMA_CMD_CLEAN_INVALID2,\ |
| 112 | + struct vc_sm_cma_ioctl_clean_invalid2) |
| 113 | + |
| 114 | +#endif /* __VC_SM_CMA_IOCTL_H */ |
0 commit comments