1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Copyright 2019 Raspberry Pi (Trading) Ltd. All rights reserved.
6 * Based on vmcs_sm_ioctl.h Copyright Broadcom Corporation.
9 #ifndef __VC_SM_CMA_IOCTL_H
10 #define __VC_SM_CMA_IOCTL_H
12 /* ---- Include Files ---------------------------------------------------- */
14 #if defined(__KERNEL__)
15 #include <linux/types.h> /* Needed for standard types */
20 #include <linux/ioctl.h>
22 /* ---- Constants and Types ---------------------------------------------- */
24 #define VC_SM_CMA_RESOURCE_NAME 32
25 #define VC_SM_CMA_RESOURCE_NAME_DEFAULT "sm-host-resource"
27 /* Type define used to create unique IOCTL number */
28 #define VC_SM_CMA_MAGIC_TYPE 'J'
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 */
34 VC_SM_CMA_CMD_IMPORT_DMABUF,
36 VC_SM_CMA_CMD_CLEAN_INVALID2,
38 VC_SM_CMA_CMD_LAST /* Do not delete */
41 /* Cache type supported, conveniently matches the user space definition in
44 enum vc_sm_cma_cache_e {
51 /* IOCTL Data structures */
52 struct vc_sm_cma_ioctl_alloc {
56 __u32 cached; /* enum vc_sm_cma_cache_e */
58 __u8 name[VC_SM_CMA_RESOURCE_NAME];
66 struct vc_sm_cma_ioctl_import_dmabuf {
69 __u32 cached; /* enum vc_sm_cma_cache_e */
70 __u8 name[VC_SM_CMA_RESOURCE_NAME];
81 * Cache functions to be set to struct vc_sm_cma_ioctl_clean_invalid2
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
89 struct vc_sm_cma_ioctl_clean_invalid2 {
92 struct vc_sm_cma_ioctl_clean_invalid_block {
93 __u32 invalidate_mode;
95 void * __user start_address;
97 __u32 inter_block_stride;
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)
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)
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)
114 #endif /* __VC_SM_CMA_IOCTL_H */