blob: 9a767ddf6b48e2d9e23c69005245960068ced4bc [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
Suresh Vankadara34494fc2017-08-12 18:18:09 +053030/* Command Buffer Types */
31#define CAM_CMD_BUF_DMI 0x1
32#define CAM_CMD_BUF_DMI16 0x2
33#define CAM_CMD_BUF_DMI32 0x3
34#define CAM_CMD_BUF_DMI64 0x4
35#define CAM_CMD_BUF_DIRECT 0x5
36#define CAM_CMD_BUF_INDIRECT 0x6
37#define CAM_CMD_BUF_I2C 0x7
38#define CAM_CMD_BUF_FW 0x8
39#define CAM_CMD_BUF_GENERIC 0x9
40#define CAM_CMD_BUF_LEGACY 0xA
41
Jing Zhou8184f312017-01-31 14:06:30 -080042/**
Junzhe Zou5773c192017-04-18 16:13:26 -070043 * struct cam_control - Structure used by ioctl control for camera
44 *
Jing Zhou8184f312017-01-31 14:06:30 -080045 * @op_code: This is the op code for camera control
Junzhe Zou5773c192017-04-18 16:13:26 -070046 * @size: Control command size
47 * @handle_type: User pointer or shared memory handle
48 * @reserved: Reserved field for 64 bit alignment
49 * @handle: Control command payload
Jing Zhou8184f312017-01-31 14:06:30 -080050 */
51struct cam_control {
52 uint32_t op_code;
53 uint32_t size;
54 uint32_t handle_type;
55 uint32_t reserved;
56 uint64_t handle;
57};
58
59/* camera IOCTL */
60#define VIDIOC_CAM_CONTROL \
61 _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control)
62
63/**
64 * struct cam_hw_version - Structure for HW version of camera devices
65 *
66 * @major : Hardware version major
67 * @minor : Hardware version minor
68 * @incr : Hardware version increment
Junzhe Zou5773c192017-04-18 16:13:26 -070069 * @reserved : Reserved for 64 bit aligngment
Jing Zhou8184f312017-01-31 14:06:30 -080070 */
71struct cam_hw_version {
72 uint32_t major;
73 uint32_t minor;
74 uint32_t incr;
75 uint32_t reserved;
76};
77
78/**
79 * struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices
80 *
81 * @non_secure: Device Non Secure IOMMU handle
82 * @secure: Device Secure IOMMU handle
83 *
84 */
85struct cam_iommu_handle {
86 int32_t non_secure;
87 int32_t secure;
88};
89
90/* camera secure mode */
91#define CAM_SECURE_MODE_NON_SECURE 0
92#define CAM_SECURE_MODE_SECURE 1
93
94/* Camera Format Type */
95#define CAM_FORMAT_BASE 0
96#define CAM_FORMAT_MIPI_RAW_6 1
97#define CAM_FORMAT_MIPI_RAW_8 2
98#define CAM_FORMAT_MIPI_RAW_10 3
99#define CAM_FORMAT_MIPI_RAW_12 4
100#define CAM_FORMAT_MIPI_RAW_14 5
101#define CAM_FORMAT_MIPI_RAW_16 6
102#define CAM_FORMAT_MIPI_RAW_20 7
103#define CAM_FORMAT_QTI_RAW_8 8
104#define CAM_FORMAT_QTI_RAW_10 9
105#define CAM_FORMAT_QTI_RAW_12 10
106#define CAM_FORMAT_QTI_RAW_14 11
107#define CAM_FORMAT_PLAIN8 12
108#define CAM_FORMAT_PLAIN16_8 13
109#define CAM_FORMAT_PLAIN16_10 14
110#define CAM_FORMAT_PLAIN16_12 15
111#define CAM_FORMAT_PLAIN16_14 16
112#define CAM_FORMAT_PLAIN16_16 17
113#define CAM_FORMAT_PLAIN32_20 18
114#define CAM_FORMAT_PLAIN64 19
115#define CAM_FORMAT_PLAIN128 20
116#define CAM_FORMAT_ARGB 21
117#define CAM_FORMAT_ARGB_10 22
118#define CAM_FORMAT_ARGB_12 23
119#define CAM_FORMAT_ARGB_14 24
120#define CAM_FORMAT_DPCM_10_6_10 25
121#define CAM_FORMAT_DPCM_10_8_10 26
122#define CAM_FORMAT_DPCM_12_6_12 27
123#define CAM_FORMAT_DPCM_12_8_12 28
124#define CAM_FORMAT_DPCM_14_8_14 29
125#define CAM_FORMAT_DPCM_14_10_14 30
126#define CAM_FORMAT_NV21 31
127#define CAM_FORMAT_NV12 32
128#define CAM_FORMAT_TP10 33
129#define CAM_FORMAT_YUV422 34
130#define CAM_FORMAT_PD8 35
131#define CAM_FORMAT_PD10 36
132#define CAM_FORMAT_UBWC_NV12 37
133#define CAM_FORMAT_UBWC_NV12_4R 38
134#define CAM_FORMAT_UBWC_TP10 39
135#define CAM_FORMAT_UBWC_P010 40
136#define CAM_FORMAT_PLAIN8_SWAP 41
137#define CAM_FORMAT_PLAIN8_10 42
138#define CAM_FORMAT_PLAIN8_10_SWAP 43
139#define CAM_FORMAT_YV12 44
140#define CAM_FORMAT_Y_ONLY 45
141#define CAM_FORMAT_MAX 46
142
Jing Zhou8184f312017-01-31 14:06:30 -0800143/* camera rotaion */
144#define CAM_ROTATE_CW_0_DEGREE 0
145#define CAM_ROTATE_CW_90_DEGREE 1
146#define CAM_RORATE_CW_180_DEGREE 2
147#define CAM_ROTATE_CW_270_DEGREE 3
148
149/* camera Color Space */
150#define CAM_COLOR_SPACE_BASE 0
151#define CAM_COLOR_SPACE_BT601_FULL 1
152#define CAM_COLOR_SPACE_BT601625 2
153#define CAM_COLOR_SPACE_BT601525 3
154#define CAM_COLOR_SPACE_BT709 4
155#define CAM_COLOR_SPACE_DEPTH 5
156#define CAM_COLOR_SPACE_MAX 6
157
158/* camera buffer direction */
159#define CAM_BUF_INPUT 1
160#define CAM_BUF_OUTPUT 2
Junzhe Zou5773c192017-04-18 16:13:26 -0700161#define CAM_BUF_IN_OUT 3
Jing Zhou8184f312017-01-31 14:06:30 -0800162
163/* camera packet device Type */
164#define CAM_PACKET_DEV_BASE 0
165#define CAM_PACKET_DEV_IMG_SENSOR 1
166#define CAM_PACKET_DEV_ACTUATOR 2
167#define CAM_PACKET_DEV_COMPANION 3
168#define CAM_PACKET_DEV_EEPOM 4
169#define CAM_PACKET_DEV_CSIPHY 5
170#define CAM_PACKET_DEV_OIS 6
171#define CAM_PACKET_DEV_FLASH 7
172#define CAM_PACKET_DEV_FD 8
173#define CAM_PACKET_DEV_JPEG_ENC 9
174#define CAM_PACKET_DEV_JPEG_DEC 10
175#define CAM_PACKET_DEV_VFE 11
176#define CAM_PACKET_DEV_CPP 12
177#define CAM_PACKET_DEV_CSID 13
178#define CAM_PACKET_DEV_ISPIF 14
179#define CAM_PACKET_DEV_IFE 15
180#define CAM_PACKET_DEV_ICP 16
181#define CAM_PACKET_DEV_LRME 17
182#define CAM_PACKET_DEV_MAX 18
183
184
185/* constants */
186#define CAM_PACKET_MAX_PLANES 3
187
188/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700189 * struct cam_plane_cfg - Plane configuration info
Jing Zhou8184f312017-01-31 14:06:30 -0800190 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700191 * @width: Plane width in pixels
192 * @height: Plane height in lines
193 * @plane_stride: Plane stride in pixel
194 * @slice_height: Slice height in line (not used by ISP)
195 * @meta_stride: UBWC metadata stride
196 * @meta_size: UBWC metadata plane size
197 * @meta_offset: UBWC metadata offset
198 * @packer_config: UBWC packer config
199 * @mode_config: UBWC mode config
200 * @tile_config: UBWC tile config
201 * @h_init: UBWC horizontal initial coordinate in pixels
202 * @v_init: UBWC vertical initial coordinate in lines
Jing Zhou8184f312017-01-31 14:06:30 -0800203 *
204 */
205struct cam_plane_cfg {
206 uint32_t width;
207 uint32_t height;
208 uint32_t plane_stride;
209 uint32_t slice_height;
Junzhe Zou5773c192017-04-18 16:13:26 -0700210 uint32_t meta_stride;
211 uint32_t meta_size;
212 uint32_t meta_offset;
213 uint32_t packer_config;
214 uint32_t mode_config;
215 uint32_t tile_config;
216 uint32_t h_init;
217 uint32_t v_init;
Jing Zhou8184f312017-01-31 14:06:30 -0800218};
219
220/**
221 * struct cam_cmd_buf_desc - Command buffer descriptor
222 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700223 * @mem_handle: Command buffer handle
224 * @offset: Command start offset
225 * @size: Size of the command buffer in bytes
226 * @length: Used memory in command buffer in bytes
227 * @type: Type of the command buffer
228 * @meta_data: Data type for private command buffer
229 * Between UMD and KMD
Jing Zhou8184f312017-01-31 14:06:30 -0800230 *
231 */
232struct cam_cmd_buf_desc {
233 int32_t mem_handle;
234 uint32_t offset;
235 uint32_t size;
236 uint32_t length;
237 uint32_t type;
238 uint32_t meta_data;
239};
240
241/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700242 * struct cam_buf_io_cfg - Buffer io configuration for buffers
Jing Zhou8184f312017-01-31 14:06:30 -0800243 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700244 * @mem_handle: Mem_handle array for the buffers.
245 * @offsets: Offsets for each planes in the buffer
246 * @planes: Per plane information
247 * @width: Main plane width in pixel
248 * @height: Main plane height in lines
249 * @format: Format of the buffer
250 * @color_space: Color space for the buffer
251 * @color_pattern: Color pattern in the buffer
252 * @bpp: Bit per pixel
253 * @rotation: Rotation information for the buffer
254 * @resource_type: Resource type associated with the buffer
255 * @fence: Fence handle
256 * @early_fence: Fence handle for early signal
257 * @aux_cmd_buf: An auxiliary command buffer that may be
258 * used for programming the IO
259 * @direction: Direction of the config
260 * @batch_size: Batch size in HFR mode
261 * @subsample_pattern: Subsample pattern. Used in HFR mode. It
262 * should be consistent with batchSize and
263 * CAMIF programming.
264 * @subsample_period: Subsample period. Used in HFR mode. It
265 * should be consistent with batchSize and
266 * CAMIF programming.
267 * @framedrop_pattern: Framedrop pattern
268 * @framedrop_period: Framedrop period
269 * @flag: Flags for extra information
270 * @direction: Buffer direction: input or output
271 * @padding: Padding for the structure
272 *
273 */
274struct cam_buf_io_cfg {
275 int32_t mem_handle[CAM_PACKET_MAX_PLANES];
276 uint32_t offsets[CAM_PACKET_MAX_PLANES];
277 struct cam_plane_cfg planes[CAM_PACKET_MAX_PLANES];
278 uint32_t format;
279 uint32_t color_space;
280 uint32_t color_pattern;
281 uint32_t bpp;
282 uint32_t rotation;
283 uint32_t resource_type;
284 int32_t fence;
285 int32_t early_fence;
286 struct cam_cmd_buf_desc aux_cmd_buf;
287 uint32_t direction;
288 uint32_t batch_size;
289 uint32_t subsample_pattern;
290 uint32_t subsample_period;
291 uint32_t framedrop_pattern;
292 uint32_t framedrop_period;
293 uint32_t flag;
294 uint32_t padding;
295};
296
297/**
298 * struct cam_packet_header - Camera packet header
299 *
300 * @op_code: Camera packet opcode
301 * @size: Size of the camera packet in bytes
302 * @request_id: Request id for this camera packet
303 * @flags: Flags for the camera packet
304 * @padding: Padding
Jing Zhou8184f312017-01-31 14:06:30 -0800305 *
306 */
307struct cam_packet_header {
308 uint32_t op_code;
Jing Zhou8184f312017-01-31 14:06:30 -0800309 uint32_t size;
Jing Zhou8184f312017-01-31 14:06:30 -0800310 uint64_t request_id;
Jing Zhou6562f692017-02-15 15:56:54 -0800311 uint32_t flags;
Junzhe Zou5773c192017-04-18 16:13:26 -0700312 uint32_t padding;
Jing Zhou8184f312017-01-31 14:06:30 -0800313};
314
315/**
316 * struct cam_patch_desc - Patch structure
317 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700318 * @dst_buf_hdl: Memory handle for the dest buffer
319 * @dst_offset: Offset byte in the dest buffer
320 * @src_buf_hdl: Memory handle for the source buffer
321 * @src_offset: Offset byte in the source buffer
Jing Zhou8184f312017-01-31 14:06:30 -0800322 *
323 */
324struct cam_patch_desc {
325 int32_t dst_buf_hdl;
326 uint32_t dst_offset;
327 int32_t src_buf_hdl;
328 uint32_t src_offset;
329};
330
331/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700332 * struct cam_packet - Camera packet structure
Jing Zhou8184f312017-01-31 14:06:30 -0800333 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700334 * @header: Camera packet header
335 * @cmd_buf_offset: Command buffer start offset
336 * @num_cmd_buf: Number of the command buffer in the packet
337 * @io_config_offset: Buffer io configuration start offset
338 * @num_io_configs: Number of the buffer io configurations
339 * @patch_offset: Patch offset for the patch structure
340 * @num_patches: Number of the patch structure
341 * @kmd_cmd_buf_index: Command buffer index which contains extra
342 * space for the KMD buffer
343 * @kmd_cmd_buf_offset: Offset from the beginning of the command
344 * buffer for KMD usage.
345 * @payload: Camera packet payload
Jing Zhou8184f312017-01-31 14:06:30 -0800346 *
347 */
348struct cam_packet {
349 struct cam_packet_header header;
350 uint32_t cmd_buf_offset;
351 uint32_t num_cmd_buf;
352 uint32_t io_configs_offset;
353 uint32_t num_io_configs;
354 uint32_t patch_offset;
355 uint32_t num_patches;
356 uint32_t kmd_cmd_buf_index;
357 uint32_t kmd_cmd_buf_offset;
358 uint64_t payload[1];
359
360};
361
Jing Zhou8184f312017-01-31 14:06:30 -0800362/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700363 * struct cam_release_dev_cmd - Control payload for release devices
Jing Zhou8184f312017-01-31 14:06:30 -0800364 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700365 * @session_handle: Session handle for the release
366 * @dev_handle: Device handle for the release
Jing Zhou8184f312017-01-31 14:06:30 -0800367 */
368struct cam_release_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_start_stop_dev_cmd - Control payload for start/stop device
Jing Zhou8184f312017-01-31 14:06:30 -0800375 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700376 * @session_handle: Session handle for the start/stop command
377 * @dev_handle: Device handle for the start/stop command
Jing Zhou8184f312017-01-31 14:06:30 -0800378 *
379 */
380struct cam_start_stop_dev_cmd {
381 int32_t session_handle;
382 int32_t dev_handle;
383};
384
Jing Zhou8184f312017-01-31 14:06:30 -0800385/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700386 * struct cam_config_dev_cmd - Command payload for configure device
Jing Zhou8184f312017-01-31 14:06:30 -0800387 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700388 * @session_handle: Session handle for the command
389 * @dev_handle: Device handle for the command
390 * @offset: Offset byte in the packet handle.
391 * @packet_handle: Packet memory handle for the actual packet:
392 * struct cam_packet.
Jing Zhou8184f312017-01-31 14:06:30 -0800393 *
394 */
395struct cam_config_dev_cmd {
396 int32_t session_handle;
397 int32_t dev_handle;
398 uint64_t offset;
399 uint64_t packet_handle;
400};
401
Jing Zhou6562f692017-02-15 15:56:54 -0800402/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700403 * struct cam_query_cap_cmd - Payload for query device capability
Jing Zhou6562f692017-02-15 15:56:54 -0800404 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700405 * @size: Handle size
406 * @handle_type: User pointer or shared memory handle
407 * @caps_handle: Device specific query command payload
Jing Zhou6562f692017-02-15 15:56:54 -0800408 *
409 */
410struct cam_query_cap_cmd {
411 uint32_t size;
412 uint32_t handle_type;
413 uint64_t caps_handle;
414};
415
Jing Zhou6562f692017-02-15 15:56:54 -0800416/**
Junzhe Zou5773c192017-04-18 16:13:26 -0700417 * struct cam_acquire_dev_cmd - Control payload for acquire devices
Jing Zhou6562f692017-02-15 15:56:54 -0800418 *
Junzhe Zou5773c192017-04-18 16:13:26 -0700419 * @session_handle: Session handle for the acquire command
420 * @dev_handle: Device handle to be returned
421 * @handle_type: Resource handle type:
422 * 1 = user pointer, 2 = mem handle
423 * @num_resources: Number of the resources to be acquired
424 * @resources_hdl: Resource handle that refers to the actual
425 * resource array. Each item in this
426 * array is device specific resource structure
Jing Zhou6562f692017-02-15 15:56:54 -0800427 *
428 */
429struct cam_acquire_dev_cmd {
430 int32_t session_handle;
431 int32_t dev_handle;
432 uint32_t handle_type;
433 uint32_t num_resources;
434 uint64_t resource_hdl;
435};
436
Jing Zhou8184f312017-01-31 14:06:30 -0800437#endif /* __UAPI_CAM_DEFS_H__ */