1 /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 2 /* 3 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. 4 */ 5 6 #ifndef __UAPI_CAM_SYNC_H__ 7 #define __UAPI_CAM_SYNC_H__ 8 9 #include <linux/videodev2.h> 10 #include <linux/types.h> 11 #include <linux/ioctl.h> 12 #include <linux/media.h> 13 14 #define CAM_SYNC_DEVICE_NAME "cam_sync_device" 15 16 /* V4L event which user space will subscribe to */ 17 #define CAM_SYNC_V4L_EVENT (V4L2_EVENT_PRIVATE_START + 0) 18 19 /* Specific event ids to get notified in user space */ 20 #define CAM_SYNC_V4L_EVENT_ID_CB_TRIG 0 21 22 /* Size of opaque payload sent to kernel for safekeeping until signal time */ 23 #define CAM_SYNC_USER_PAYLOAD_SIZE 2 24 25 /* Device type for sync device needed for device discovery */ 26 #define CAM_SYNC_DEVICE_TYPE (MEDIA_ENT_F_OLD_BASE) 27 28 #define CAM_SYNC_GET_PAYLOAD_PTR(ev, type) \ 29 (type *)((char *)ev.u.data + sizeof(struct cam_sync_ev_header)) 30 31 #define CAM_SYNC_GET_HEADER_PTR(ev) \ 32 ((struct cam_sync_ev_header *)ev.u.data) 33 34 #define CAM_SYNC_STATE_INVALID 0 35 #define CAM_SYNC_STATE_ACTIVE 1 36 #define CAM_SYNC_STATE_SIGNALED_SUCCESS 2 37 #define CAM_SYNC_STATE_SIGNALED_ERROR 3 38 39 /** 40 * struct cam_sync_ev_header - Event header for sync event notification 41 * 42 * @sync_obj: Sync object 43 * @status: Status of the object 44 */ 45 struct cam_sync_ev_header { 46 int32_t sync_obj; 47 int32_t status; 48 }; 49 50 /** 51 * struct cam_sync_info - Sync object creation information 52 * 53 * @name: Optional string representation of the sync object 54 * @sync_obj: Sync object returned after creation in kernel 55 */ 56 struct cam_sync_info { 57 char name[64]; 58 int32_t sync_obj; 59 }; 60 61 /** 62 * struct cam_sync_signal - Sync object signaling struct 63 * 64 * @sync_obj: Sync object to be signaled 65 * @sync_state: State of the sync object to which it should be signaled 66 */ 67 struct cam_sync_signal { 68 int32_t sync_obj; 69 uint32_t sync_state; 70 }; 71 72 /** 73 * struct cam_sync_merge - Merge information for sync objects 74 * 75 * @sync_objs: Pointer to sync objects 76 * @num_objs: Number of objects in the array 77 * @merged: Merged sync object 78 */ 79 struct cam_sync_merge { 80 __u64 sync_objs; 81 uint32_t num_objs; 82 int32_t merged; 83 }; 84 85 /** 86 * struct cam_sync_userpayload_info - Payload info from user space 87 * 88 * @sync_obj: Sync object for which payload has to be registered for 89 * @reserved: Reserved 90 * @payload: Pointer to user payload 91 */ 92 struct cam_sync_userpayload_info { 93 int32_t sync_obj; 94 uint32_t reserved; 95 __u64 payload[CAM_SYNC_USER_PAYLOAD_SIZE]; 96 }; 97 98 /** 99 * struct cam_sync_wait - Sync object wait information 100 * 101 * @sync_obj: Sync object to wait on 102 * @reserved: Reserved 103 * @timeout_ms: Timeout in milliseconds 104 */ 105 struct cam_sync_wait { 106 int32_t sync_obj; 107 uint32_t reserved; 108 uint64_t timeout_ms; 109 }; 110 111 /** 112 * struct cam_private_ioctl_arg - Sync driver ioctl argument 113 * 114 * @id: IOCTL command id 115 * @size: Size of command payload 116 * @result: Result of command execution 117 * @reserved: Reserved 118 * @ioctl_ptr: Pointer to user data 119 */ 120 struct cam_private_ioctl_arg { 121 __u32 id; 122 __u32 size; 123 __u32 result; 124 __u32 reserved; 125 __u64 ioctl_ptr; 126 }; 127 128 #define CAM_PRIVATE_IOCTL_CMD \ 129 _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_private_ioctl_arg) 130 131 #define CAM_SYNC_CREATE 0 132 #define CAM_SYNC_DESTROY 1 133 #define CAM_SYNC_SIGNAL 2 134 #define CAM_SYNC_MERGE 3 135 #define CAM_SYNC_REGISTER_PAYLOAD 4 136 #define CAM_SYNC_DEREGISTER_PAYLOAD 5 137 #define CAM_SYNC_WAIT 6 138 139 #endif /* __UAPI_CAM_SYNC_H__ */ 140