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