blob: fdc56ee07e2a8370ebfbcd1932a61b8a892aa533 [file] [log] [blame]
Jing Zhou8184f312017-01-31 14:06:30 -08001#ifndef __UAPI_CAM_DEFS_H__
2#define __UAPI_CAM_DEFS_H__
3
4#include <linux/videodev2.h>
5#include <linux/types.h>
6#include <linux/ioctl.h>
7
8
9/* camera op codes */
Lakshmi Narayana Kalavalac2fac452017-06-12 12:38:07 -070010#define CAM_COMMON_OPCODE_BASE 0x100
11#define CAM_QUERY_CAP (CAM_COMMON_OPCODE_BASE + 0x1)
12#define CAM_ACQUIRE_DEV (CAM_COMMON_OPCODE_BASE + 0x2)
13#define CAM_START_DEV (CAM_COMMON_OPCODE_BASE + 0x3)
14#define CAM_STOP_DEV (CAM_COMMON_OPCODE_BASE + 0x4)
15#define CAM_CONFIG_DEV (CAM_COMMON_OPCODE_BASE + 0x5)
16#define CAM_RELEASE_DEV (CAM_COMMON_OPCODE_BASE + 0x6)
17#define CAM_SD_SHUTDOWN (CAM_COMMON_OPCODE_BASE + 0x7)
18#define CAM_COMMON_OPCODE_MAX (CAM_COMMON_OPCODE_BASE + 0x8)
Jing Zhou8184f312017-01-31 14:06:30 -080019
20/* camera handle type */
21#define CAM_HANDLE_USER_POINTER 1
22#define CAM_HANDLE_MEM_HANDLE 2
23
Pavan Kumar Chilamkurthi966dbf62017-08-15 01:38:00 -070024/* Generic Blob CmdBuffer header properties */
25#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK 0xFFFFFF00
26#define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT 8
27#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK 0xFF
28#define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT 0
29
Jing Zhou8184f312017-01-31 14:06:30 -080030/**
Junzhe Zou5773c192017-04-18 16:13:26 -070031 * struct cam_control - Structure used by ioctl control for camera
32 *
Jing Zhou8184f312017-01-31 14:06:30 -080033 * @op_code: This is the op code for camera control
Junzhe Zou5773c192017-04-18 16:13:26 -070034 * @size: Control command size
35 * @handle_type: User pointer or shared memory handle
36 * @reserved: Reserved field for 64 bit alignment
37 * @handle: Control command payload
Jing Zhou8184f312017-01-31 14:06:30 -080038 */
39struct cam_control {
40 uint32_t op_code;
41 uint32_t size;
42 uint32_t handle_type;
43 uint32_t reserved;
44 uint64_t handle;
45};
46
47/* camera IOCTL */
48#define VIDIOC_CAM_CONTROL \
49 _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control)
50
51/**
52 * struct cam_hw_version - Structure for HW version of camera devices
53 *
54 * @major : Hardware version major
55 * @minor : Hardware version minor
56 * @incr : Hardware version increment
Junzhe Zou5773c192017-04-18 16:13:26 -070057 * @reserved : Reserved for 64 bit aligngment
Jing Zhou8184f312017-01-31 14:06:30 -080058 */
59struct cam_hw_version {
60 uint32_t major;
61 uint32_t minor;
62 uint32_t incr;
63 uint32_t reserved;
64};
65
66/**
67 * struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices
68 *
69 * @non_secure: Device Non Secure IOMMU handle
70 * @secure: Device Secure IOMMU handle
71 *
72 */
73struct cam_iommu_handle {
74 int32_t non_secure;
75 int32_t secure;
76};
77
78/* camera secure mode */
79#define CAM_SECURE_MODE_NON_SECURE 0
80#define CAM_SECURE_MODE_SECURE 1
81
82/* Camera Format Type */
83#define CAM_FORMAT_BASE 0
84#define CAM_FORMAT_MIPI_RAW_6 1
85#define CAM_FORMAT_MIPI_RAW_8 2
86#define CAM_FORMAT_MIPI_RAW_10 3
87#define CAM_FORMAT_MIPI_RAW_12 4
88#define CAM_FORMAT_MIPI_RAW_14 5
89#define CAM_FORMAT_MIPI_RAW_16 6
90#define CAM_FORMAT_MIPI_RAW_20 7
91#define CAM_FORMAT_QTI_RAW_8 8
92#define CAM_FORMAT_QTI_RAW_10 9
93#define CAM_FORMAT_QTI_RAW_12 10
94#define CAM_FORMAT_QTI_RAW_14 11
95#define CAM_FORMAT_PLAIN8 12
96#define CAM_FORMAT_PLAIN16_8 13
97#define CAM_FORMAT_PLAIN16_10 14
98#define CAM_FORMAT_PLAIN16_12 15
99#define CAM_FORMAT_PLAIN16_14 16
100#define CAM_FORMAT_PLAIN16_16 17
101#define CAM_FORMAT_PLAIN32_20 18
102#define CAM_FORMAT_PLAIN64 19
103#define CAM_FORMAT_PLAIN128 20
104#define CAM_FORMAT_ARGB 21
105#define CAM_FORMAT_ARGB_10 22
106#define CAM_FORMAT_ARGB_12 23
107#define CAM_FORMAT_ARGB_14 24
108#define CAM_FORMAT_DPCM_10_6_10 25
109#define CAM_FORMAT_DPCM_10_8_10 26
110#define CAM_FORMAT_DPCM_12_6_12 27
111#define CAM_FORMAT_DPCM_12_8_12 28
112#define CAM_FORMAT_DPCM_14_8_14 29
113#define CAM_FORMAT_DPCM_14_10_14 30
114#define CAM_FORMAT_NV21 31
115#define CAM_FORMAT_NV12 32
116#define CAM_FORMAT_TP10 33
117#define CAM_FORMAT_YUV422 34
118#define CAM_FORMAT_PD8 35
119#define CAM_FORMAT_PD10 36
120#define CAM_FORMAT_UBWC_NV12 37
121#define CAM_FORMAT_UBWC_NV12_4R 38
122#define CAM_FORMAT_UBWC_TP10 39
123#define CAM_FORMAT_UBWC_P010 40
124#define CAM_FORMAT_PLAIN8_SWAP 41
125#define CAM_FORMAT_PLAIN8_10 42
126#define CAM_FORMAT_PLAIN8_10_SWAP 43
127#define CAM_FORMAT_YV12 44
128#define CAM_FORMAT_Y_ONLY 45
129#define CAM_FORMAT_MAX 46
130
Jing Zhou8184f312017-01-31 14:06:30 -0800131/* camera rotaion */
132#define CAM_ROTATE_CW_0_DEGREE 0
133#define CAM_ROTATE_CW_90_DEGREE 1
134#define CAM_RORATE_CW_180_DEGREE 2
135#define CAM_ROTATE_CW_270_DEGREE 3
136
137/* camera Color Space */
138#define CAM_COLOR_SPACE_BASE 0
139#define CAM_COLOR_SPACE_BT601_FULL 1
140#define CAM_COLOR_SPACE_BT601625 2
141#define CAM_COLOR_SPACE_BT601525 3
142#define CAM_COLOR_SPACE_BT709 4
143#define CAM_COLOR_SPACE_DEPTH 5
144#define CAM_COLOR_SPACE_MAX 6
145
146/* camera buffer direction */
147#define CAM_BUF_INPUT 1
148#define CAM_BUF_OUTPUT 2
Junzhe Zou5773c192017-04-18 16:13:26 -0700149#define CAM_BUF_IN_OUT 3
Jing Zhou8184f312017-01-31 14:06:30 -0800150
151/* camera packet device Type */
152#define CAM_PACKET_DEV_BASE 0
153#define CAM_PACKET_DEV_IMG_SENSOR 1
154#define CAM_PACKET_DEV_ACTUATOR 2
155#define CAM_PACKET_DEV_COMPANION 3
156#define CAM_PACKET_DEV_EEPOM 4
157#define CAM_PACKET_DEV_CSIPHY 5
158#define CAM_PACKET_DEV_OIS 6
159#define CAM_PACKET_DEV_FLASH 7
160#define CAM_PACKET_DEV_FD 8
161#define CAM_PACKET_DEV_JPEG_ENC 9
162#define CAM_PACKET_DEV_JPEG_DEC 10
163#define CAM_PACKET_DEV_VFE 11
164#define CAM_PACKET_DEV_CPP 12
165#define CAM_PACKET_DEV_CSID 13
166#define CAM_PACKET_DEV_ISPIF 14
167#define CAM_PACKET_DEV_IFE 15
168#define CAM_PACKET_DEV_ICP 16
169#define CAM_PACKET_DEV_LRME 17
170#define CAM_PACKET_DEV_MAX 18
171
172
173/* constants */
174#define CAM_PACKET_MAX_PLANES 3
175
176/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700177 * struct cam_plane_cfg - Plane configuration info
Jing Zhou8184f312017-01-31 14:06:30 -0800178 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700179 * @width: Plane width in pixels
180 * @height: Plane height in lines
181 * @plane_stride: Plane stride in pixel
182 * @slice_height: Slice height in line (not used by ISP)
183 * @meta_stride: UBWC metadata stride
184 * @meta_size: UBWC metadata plane size
185 * @meta_offset: UBWC metadata offset
186 * @packer_config: UBWC packer config
187 * @mode_config: UBWC mode config
188 * @tile_config: UBWC tile config
189 * @h_init: UBWC horizontal initial coordinate in pixels
190 * @v_init: UBWC vertical initial coordinate in lines
Jing Zhou8184f312017-01-31 14:06:30 -0800191 *
192 */
193struct cam_plane_cfg {
194 uint32_t width;
195 uint32_t height;
196 uint32_t plane_stride;
197 uint32_t slice_height;
Junzhe Zou5773c192017-04-18 16:13:26 -0700198 uint32_t meta_stride;
199 uint32_t meta_size;
200 uint32_t meta_offset;
201 uint32_t packer_config;
202 uint32_t mode_config;
203 uint32_t tile_config;
204 uint32_t h_init;
205 uint32_t v_init;
Jing Zhou8184f312017-01-31 14:06:30 -0800206};
207
208/**
209 * struct cam_cmd_buf_desc - Command buffer descriptor
210 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700211 * @mem_handle: Command buffer handle
212 * @offset: Command start offset
213 * @size: Size of the command buffer in bytes
214 * @length: Used memory in command buffer in bytes
215 * @type: Type of the command buffer
216 * @meta_data: Data type for private command buffer
217 * Between UMD and KMD
Jing Zhou8184f312017-01-31 14:06:30 -0800218 *
219 */
220struct cam_cmd_buf_desc {
221 int32_t mem_handle;
222 uint32_t offset;
223 uint32_t size;
224 uint32_t length;
225 uint32_t type;
226 uint32_t meta_data;
227};
228
229/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700230 * struct cam_buf_io_cfg - Buffer io configuration for buffers
Jing Zhou8184f312017-01-31 14:06:30 -0800231 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700232 * @mem_handle: Mem_handle array for the buffers.
233 * @offsets: Offsets for each planes in the buffer
234 * @planes: Per plane information
235 * @width: Main plane width in pixel
236 * @height: Main plane height in lines
237 * @format: Format of the buffer
238 * @color_space: Color space for the buffer
239 * @color_pattern: Color pattern in the buffer
240 * @bpp: Bit per pixel
241 * @rotation: Rotation information for the buffer
242 * @resource_type: Resource type associated with the buffer
243 * @fence: Fence handle
244 * @early_fence: Fence handle for early signal
245 * @aux_cmd_buf: An auxiliary command buffer that may be
246 * used for programming the IO
247 * @direction: Direction of the config
248 * @batch_size: Batch size in HFR mode
249 * @subsample_pattern: Subsample pattern. Used in HFR mode. It
250 * should be consistent with batchSize and
251 * CAMIF programming.
252 * @subsample_period: Subsample period. Used in HFR mode. It
253 * should be consistent with batchSize and
254 * CAMIF programming.
255 * @framedrop_pattern: Framedrop pattern
256 * @framedrop_period: Framedrop period
257 * @flag: Flags for extra information
258 * @direction: Buffer direction: input or output
259 * @padding: Padding for the structure
260 *
261 */
262struct cam_buf_io_cfg {
263 int32_t mem_handle[CAM_PACKET_MAX_PLANES];
264 uint32_t offsets[CAM_PACKET_MAX_PLANES];
265 struct cam_plane_cfg planes[CAM_PACKET_MAX_PLANES];
266 uint32_t format;
267 uint32_t color_space;
268 uint32_t color_pattern;
269 uint32_t bpp;
270 uint32_t rotation;
271 uint32_t resource_type;
272 int32_t fence;
273 int32_t early_fence;
274 struct cam_cmd_buf_desc aux_cmd_buf;
275 uint32_t direction;
276 uint32_t batch_size;
277 uint32_t subsample_pattern;
278 uint32_t subsample_period;
279 uint32_t framedrop_pattern;
280 uint32_t framedrop_period;
281 uint32_t flag;
282 uint32_t padding;
283};
284
285/**
286 * struct cam_packet_header - Camera packet header
287 *
288 * @op_code: Camera packet opcode
289 * @size: Size of the camera packet in bytes
290 * @request_id: Request id for this camera packet
291 * @flags: Flags for the camera packet
292 * @padding: Padding
Jing Zhou8184f312017-01-31 14:06:30 -0800293 *
294 */
295struct cam_packet_header {
296 uint32_t op_code;
Jing Zhou8184f312017-01-31 14:06:30 -0800297 uint32_t size;
Jing Zhou8184f312017-01-31 14:06:30 -0800298 uint64_t request_id;
Jing Zhou6562f692017-02-15 15:56:54 -0800299 uint32_t flags;
Junzhe Zou5773c192017-04-18 16:13:26 -0700300 uint32_t padding;
Jing Zhou8184f312017-01-31 14:06:30 -0800301};
302
303/**
304 * struct cam_patch_desc - Patch structure
305 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700306 * @dst_buf_hdl: Memory handle for the dest buffer
307 * @dst_offset: Offset byte in the dest buffer
308 * @src_buf_hdl: Memory handle for the source buffer
309 * @src_offset: Offset byte in the source buffer
Jing Zhou8184f312017-01-31 14:06:30 -0800310 *
311 */
312struct cam_patch_desc {
313 int32_t dst_buf_hdl;
314 uint32_t dst_offset;
315 int32_t src_buf_hdl;
316 uint32_t src_offset;
317};
318
319/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700320 * struct cam_packet - Camera packet structure
Jing Zhou8184f312017-01-31 14:06:30 -0800321 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700322 * @header: Camera packet header
323 * @cmd_buf_offset: Command buffer start offset
324 * @num_cmd_buf: Number of the command buffer in the packet
325 * @io_config_offset: Buffer io configuration start offset
326 * @num_io_configs: Number of the buffer io configurations
327 * @patch_offset: Patch offset for the patch structure
328 * @num_patches: Number of the patch structure
329 * @kmd_cmd_buf_index: Command buffer index which contains extra
330 * space for the KMD buffer
331 * @kmd_cmd_buf_offset: Offset from the beginning of the command
332 * buffer for KMD usage.
333 * @payload: Camera packet payload
Jing Zhou8184f312017-01-31 14:06:30 -0800334 *
335 */
336struct cam_packet {
337 struct cam_packet_header header;
338 uint32_t cmd_buf_offset;
339 uint32_t num_cmd_buf;
340 uint32_t io_configs_offset;
341 uint32_t num_io_configs;
342 uint32_t patch_offset;
343 uint32_t num_patches;
344 uint32_t kmd_cmd_buf_index;
345 uint32_t kmd_cmd_buf_offset;
346 uint64_t payload[1];
347
348};
349
Jing Zhou8184f312017-01-31 14:06:30 -0800350/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700351 * struct cam_release_dev_cmd - Control payload for release devices
Jing Zhou8184f312017-01-31 14:06:30 -0800352 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700353 * @session_handle: Session handle for the release
354 * @dev_handle: Device handle for the release
Jing Zhou8184f312017-01-31 14:06:30 -0800355 */
356struct cam_release_dev_cmd {
357 int32_t session_handle;
358 int32_t dev_handle;
359};
360
Jing Zhou8184f312017-01-31 14:06:30 -0800361/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700362 * struct cam_start_stop_dev_cmd - Control payload for start/stop device
Jing Zhou8184f312017-01-31 14:06:30 -0800363 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700364 * @session_handle: Session handle for the start/stop command
365 * @dev_handle: Device handle for the start/stop command
Jing Zhou8184f312017-01-31 14:06:30 -0800366 *
367 */
368struct cam_start_stop_dev_cmd {
369 int32_t session_handle;
370 int32_t dev_handle;
371};
372
Jing Zhou8184f312017-01-31 14:06:30 -0800373/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700374 * struct cam_config_dev_cmd - Command payload for configure device
Jing Zhou8184f312017-01-31 14:06:30 -0800375 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700376 * @session_handle: Session handle for the command
377 * @dev_handle: Device handle for the command
378 * @offset: Offset byte in the packet handle.
379 * @packet_handle: Packet memory handle for the actual packet:
380 * struct cam_packet.
Jing Zhou8184f312017-01-31 14:06:30 -0800381 *
382 */
383struct cam_config_dev_cmd {
384 int32_t session_handle;
385 int32_t dev_handle;
386 uint64_t offset;
387 uint64_t packet_handle;
388};
389
Jing Zhou6562f692017-02-15 15:56:54 -0800390/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700391 * struct cam_query_cap_cmd - Payload for query device capability
Jing Zhou6562f692017-02-15 15:56:54 -0800392 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700393 * @size: Handle size
394 * @handle_type: User pointer or shared memory handle
395 * @caps_handle: Device specific query command payload
Jing Zhou6562f692017-02-15 15:56:54 -0800396 *
397 */
398struct cam_query_cap_cmd {
399 uint32_t size;
400 uint32_t handle_type;
401 uint64_t caps_handle;
402};
403
Jing Zhou6562f692017-02-15 15:56:54 -0800404/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700405 * struct cam_acquire_dev_cmd - Control payload for acquire devices
Jing Zhou6562f692017-02-15 15:56:54 -0800406 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700407 * @session_handle: Session handle for the acquire command
408 * @dev_handle: Device handle to be returned
409 * @handle_type: Resource handle type:
410 * 1 = user pointer, 2 = mem handle
411 * @num_resources: Number of the resources to be acquired
412 * @resources_hdl: Resource handle that refers to the actual
413 * resource array. Each item in this
414 * array is device specific resource structure
Jing Zhou6562f692017-02-15 15:56:54 -0800415 *
416 */
417struct cam_acquire_dev_cmd {
418 int32_t session_handle;
419 int32_t dev_handle;
420 uint32_t handle_type;
421 uint32_t num_resources;
422 uint64_t resource_hdl;
423};
424
Jing Zhou8184f312017-01-31 14:06:30 -0800425#endif /* __UAPI_CAM_DEFS_H__ */