1 #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 */ 10 #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_FLUSH_REQ (CAM_COMMON_OPCODE_BASE + 0x8) 19 #define CAM_COMMON_OPCODE_MAX (CAM_COMMON_OPCODE_BASE + 0x9) 20 21 #define CAM_COMMON_OPCODE_BASE_v2 0x150 22 #define CAM_ACQUIRE_HW (CAM_COMMON_OPCODE_BASE_v2 + 0x1) 23 #define CAM_RELEASE_HW (CAM_COMMON_OPCODE_BASE_v2 + 0x2) 24 25 #define CAM_EXT_OPCODE_BASE 0x200 26 #define CAM_CONFIG_DEV_EXTERNAL (CAM_EXT_OPCODE_BASE + 0x1) 27 28 /* camera handle type */ 29 #define CAM_HANDLE_USER_POINTER 1 30 #define CAM_HANDLE_MEM_HANDLE 2 31 32 /* Generic Blob CmdBuffer header properties */ 33 #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK 0xFFFFFF00 34 #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT 8 35 #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK 0xFF 36 #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT 0 37 38 /* Command Buffer Types */ 39 #define CAM_CMD_BUF_DMI 0x1 40 #define CAM_CMD_BUF_DMI16 0x2 41 #define CAM_CMD_BUF_DMI32 0x3 42 #define CAM_CMD_BUF_DMI64 0x4 43 #define CAM_CMD_BUF_DIRECT 0x5 44 #define CAM_CMD_BUF_INDIRECT 0x6 45 #define CAM_CMD_BUF_I2C 0x7 46 #define CAM_CMD_BUF_FW 0x8 47 #define CAM_CMD_BUF_GENERIC 0x9 48 #define CAM_CMD_BUF_LEGACY 0xA 49 50 /* UBWC API Version */ 51 #define CAM_UBWC_CFG_VERSION_1 1 52 53 /** 54 * enum flush_type_t - Identifies the various flush types 55 * 56 * @CAM_FLUSH_TYPE_REQ: Flush specific request 57 * @CAM_FLUSH_TYPE_ALL: Flush all requests belonging to a context 58 * @CAM_FLUSH_TYPE_MAX: Max enum to validate flush type 59 * 60 */ 61 enum flush_type_t { 62 CAM_FLUSH_TYPE_REQ, 63 CAM_FLUSH_TYPE_ALL, 64 CAM_FLUSH_TYPE_MAX 65 }; 66 67 /** 68 * struct cam_control - Structure used by ioctl control for camera 69 * 70 * @op_code: This is the op code for camera control 71 * @size: Control command size 72 * @handle_type: User pointer or shared memory handle 73 * @reserved: Reserved field for 64 bit alignment 74 * @handle: Control command payload 75 */ 76 struct cam_control { 77 uint32_t op_code; 78 uint32_t size; 79 uint32_t handle_type; 80 uint32_t reserved; 81 uint64_t handle; 82 }; 83 84 /* camera IOCTL */ 85 #define VIDIOC_CAM_CONTROL \ 86 _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control) 87 88 /** 89 * struct cam_hw_version - Structure for HW version of camera devices 90 * 91 * @major : Hardware version major 92 * @minor : Hardware version minor 93 * @incr : Hardware version increment 94 * @reserved : Reserved for 64 bit aligngment 95 */ 96 struct cam_hw_version { 97 uint32_t major; 98 uint32_t minor; 99 uint32_t incr; 100 uint32_t reserved; 101 }; 102 103 /** 104 * struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices 105 * 106 * @non_secure: Device Non Secure IOMMU handle 107 * @secure: Device Secure IOMMU handle 108 * 109 */ 110 struct cam_iommu_handle { 111 int32_t non_secure; 112 int32_t secure; 113 }; 114 115 /* camera secure mode */ 116 #define CAM_SECURE_MODE_NON_SECURE 0 117 #define CAM_SECURE_MODE_SECURE 1 118 119 /* Camera Format Type */ 120 #define CAM_FORMAT_BASE 0 121 #define CAM_FORMAT_MIPI_RAW_6 1 122 #define CAM_FORMAT_MIPI_RAW_8 2 123 #define CAM_FORMAT_MIPI_RAW_10 3 124 #define CAM_FORMAT_MIPI_RAW_12 4 125 #define CAM_FORMAT_MIPI_RAW_14 5 126 #define CAM_FORMAT_MIPI_RAW_16 6 127 #define CAM_FORMAT_MIPI_RAW_20 7 128 #define CAM_FORMAT_QTI_RAW_8 8 129 #define CAM_FORMAT_QTI_RAW_10 9 130 #define CAM_FORMAT_QTI_RAW_12 10 131 #define CAM_FORMAT_QTI_RAW_14 11 132 #define CAM_FORMAT_PLAIN8 12 133 #define CAM_FORMAT_PLAIN16_8 13 134 #define CAM_FORMAT_PLAIN16_10 14 135 #define CAM_FORMAT_PLAIN16_12 15 136 #define CAM_FORMAT_PLAIN16_14 16 137 #define CAM_FORMAT_PLAIN16_16 17 138 #define CAM_FORMAT_PLAIN32_20 18 139 #define CAM_FORMAT_PLAIN64 19 140 #define CAM_FORMAT_PLAIN128 20 141 #define CAM_FORMAT_ARGB 21 142 #define CAM_FORMAT_ARGB_10 22 143 #define CAM_FORMAT_ARGB_12 23 144 #define CAM_FORMAT_ARGB_14 24 145 #define CAM_FORMAT_DPCM_10_6_10 25 146 #define CAM_FORMAT_DPCM_10_8_10 26 147 #define CAM_FORMAT_DPCM_12_6_12 27 148 #define CAM_FORMAT_DPCM_12_8_12 28 149 #define CAM_FORMAT_DPCM_14_8_14 29 150 #define CAM_FORMAT_DPCM_14_10_14 30 151 #define CAM_FORMAT_NV21 31 152 #define CAM_FORMAT_NV12 32 153 #define CAM_FORMAT_TP10 33 154 #define CAM_FORMAT_YUV422 34 155 #define CAM_FORMAT_PD8 35 156 #define CAM_FORMAT_PD10 36 157 #define CAM_FORMAT_UBWC_NV12 37 158 #define CAM_FORMAT_UBWC_NV12_4R 38 159 #define CAM_FORMAT_UBWC_TP10 39 160 #define CAM_FORMAT_UBWC_P010 40 161 #define CAM_FORMAT_PLAIN8_SWAP 41 162 #define CAM_FORMAT_PLAIN8_10 42 163 #define CAM_FORMAT_PLAIN8_10_SWAP 43 164 #define CAM_FORMAT_YV12 44 165 #define CAM_FORMAT_Y_ONLY 45 166 #define CAM_FORMAT_DPCM_12_10_12 46 167 #define CAM_FORMAT_MAX 47 168 169 /* camera rotaion */ 170 #define CAM_ROTATE_CW_0_DEGREE 0 171 #define CAM_ROTATE_CW_90_DEGREE 1 172 #define CAM_RORATE_CW_180_DEGREE 2 173 #define CAM_ROTATE_CW_270_DEGREE 3 174 175 /* camera Color Space */ 176 #define CAM_COLOR_SPACE_BASE 0 177 #define CAM_COLOR_SPACE_BT601_FULL 1 178 #define CAM_COLOR_SPACE_BT601625 2 179 #define CAM_COLOR_SPACE_BT601525 3 180 #define CAM_COLOR_SPACE_BT709 4 181 #define CAM_COLOR_SPACE_DEPTH 5 182 #define CAM_COLOR_SPACE_MAX 6 183 184 /* camera buffer direction */ 185 #define CAM_BUF_INPUT 1 186 #define CAM_BUF_OUTPUT 2 187 #define CAM_BUF_IN_OUT 3 188 189 /* camera packet device Type */ 190 #define CAM_PACKET_DEV_BASE 0 191 #define CAM_PACKET_DEV_IMG_SENSOR 1 192 #define CAM_PACKET_DEV_ACTUATOR 2 193 #define CAM_PACKET_DEV_COMPANION 3 194 #define CAM_PACKET_DEV_EEPOM 4 195 #define CAM_PACKET_DEV_CSIPHY 5 196 #define CAM_PACKET_DEV_OIS 6 197 #define CAM_PACKET_DEV_FLASH 7 198 #define CAM_PACKET_DEV_FD 8 199 #define CAM_PACKET_DEV_JPEG_ENC 9 200 #define CAM_PACKET_DEV_JPEG_DEC 10 201 #define CAM_PACKET_DEV_VFE 11 202 #define CAM_PACKET_DEV_CPP 12 203 #define CAM_PACKET_DEV_CSID 13 204 #define CAM_PACKET_DEV_ISPIF 14 205 #define CAM_PACKET_DEV_IFE 15 206 #define CAM_PACKET_DEV_ICP 16 207 #define CAM_PACKET_DEV_LRME 17 208 #define CAM_PACKET_DEV_MAX 18 209 210 211 /* constants */ 212 #define CAM_PACKET_MAX_PLANES 3 213 214 /** 215 * struct cam_plane_cfg - Plane configuration info 216 * 217 * @width: Plane width in pixels 218 * @height: Plane height in lines 219 * @plane_stride: Plane stride in pixel 220 * @slice_height: Slice height in line (not used by ISP) 221 * @meta_stride: UBWC metadata stride 222 * @meta_size: UBWC metadata plane size 223 * @meta_offset: UBWC metadata offset 224 * @packer_config: UBWC packer config 225 * @mode_config: UBWC mode config 226 * @tile_config: UBWC tile config 227 * @h_init: UBWC horizontal initial coordinate in pixels 228 * @v_init: UBWC vertical initial coordinate in lines 229 * 230 */ 231 struct cam_plane_cfg { 232 uint32_t width; 233 uint32_t height; 234 uint32_t plane_stride; 235 uint32_t slice_height; 236 uint32_t meta_stride; 237 uint32_t meta_size; 238 uint32_t meta_offset; 239 uint32_t packer_config; 240 uint32_t mode_config; 241 uint32_t tile_config; 242 uint32_t h_init; 243 uint32_t v_init; 244 }; 245 246 /** 247 * struct cam_ubwc_plane_cfg_v1 - UBWC Plane configuration info 248 * 249 * @port_type: Port Type 250 * @meta_stride: UBWC metadata stride 251 * @meta_size: UBWC metadata plane size 252 * @meta_offset: UBWC metadata offset 253 * @packer_config: UBWC packer config 254 * @mode_config_0: UBWC mode config 0 255 * @mode_config_1: UBWC 3 mode config 1 256 * @tile_config: UBWC tile config 257 * @h_init: UBWC horizontal initial coordinate in pixels 258 * @v_init: UBWC vertical initial coordinate in lines 259 * 260 */ 261 struct cam_ubwc_plane_cfg_v1 { 262 uint32_t port_type; 263 uint32_t meta_stride; 264 uint32_t meta_size; 265 uint32_t meta_offset; 266 uint32_t packer_config; 267 uint32_t mode_config_0; 268 uint32_t mode_config_1; 269 uint32_t tile_config; 270 uint32_t h_init; 271 uint32_t v_init; 272 }; 273 274 /** 275 * struct cam_cmd_buf_desc - Command buffer descriptor 276 * 277 * @mem_handle: Command buffer handle 278 * @offset: Command start offset 279 * @size: Size of the command buffer in bytes 280 * @length: Used memory in command buffer in bytes 281 * @type: Type of the command buffer 282 * @meta_data: Data type for private command buffer 283 * Between UMD and KMD 284 * 285 */ 286 struct cam_cmd_buf_desc { 287 int32_t mem_handle; 288 uint32_t offset; 289 uint32_t size; 290 uint32_t length; 291 uint32_t type; 292 uint32_t meta_data; 293 }; 294 295 /** 296 * struct cam_buf_io_cfg - Buffer io configuration for buffers 297 * 298 * @mem_handle: Mem_handle array for the buffers. 299 * @offsets: Offsets for each planes in the buffer 300 * @planes: Per plane information 301 * @width: Main plane width in pixel 302 * @height: Main plane height in lines 303 * @format: Format of the buffer 304 * @color_space: Color space for the buffer 305 * @color_pattern: Color pattern in the buffer 306 * @bpp: Bit per pixel 307 * @rotation: Rotation information for the buffer 308 * @resource_type: Resource type associated with the buffer 309 * @fence: Fence handle 310 * @early_fence: Fence handle for early signal 311 * @aux_cmd_buf: An auxiliary command buffer that may be 312 * used for programming the IO 313 * @direction: Direction of the config 314 * @batch_size: Batch size in HFR mode 315 * @subsample_pattern: Subsample pattern. Used in HFR mode. It 316 * should be consistent with batchSize and 317 * CAMIF programming. 318 * @subsample_period: Subsample period. Used in HFR mode. It 319 * should be consistent with batchSize and 320 * CAMIF programming. 321 * @framedrop_pattern: Framedrop pattern 322 * @framedrop_period: Framedrop period 323 * @flag: Flags for extra information 324 * @direction: Buffer direction: input or output 325 * @padding: Padding for the structure 326 * 327 */ 328 struct cam_buf_io_cfg { 329 int32_t mem_handle[CAM_PACKET_MAX_PLANES]; 330 uint32_t offsets[CAM_PACKET_MAX_PLANES]; 331 struct cam_plane_cfg planes[CAM_PACKET_MAX_PLANES]; 332 uint32_t format; 333 uint32_t color_space; 334 uint32_t color_pattern; 335 uint32_t bpp; 336 uint32_t rotation; 337 uint32_t resource_type; 338 int32_t fence; 339 int32_t early_fence; 340 struct cam_cmd_buf_desc aux_cmd_buf; 341 uint32_t direction; 342 uint32_t batch_size; 343 uint32_t subsample_pattern; 344 uint32_t subsample_period; 345 uint32_t framedrop_pattern; 346 uint32_t framedrop_period; 347 uint32_t flag; 348 uint32_t padding; 349 }; 350 351 /** 352 * struct cam_packet_header - Camera packet header 353 * 354 * @op_code: Camera packet opcode 355 * @size: Size of the camera packet in bytes 356 * @request_id: Request id for this camera packet 357 * @flags: Flags for the camera packet 358 * @padding: Padding 359 * 360 */ 361 struct cam_packet_header { 362 uint32_t op_code; 363 uint32_t size; 364 uint64_t request_id; 365 uint32_t flags; 366 uint32_t padding; 367 }; 368 369 /** 370 * struct cam_patch_desc - Patch structure 371 * 372 * @dst_buf_hdl: Memory handle for the dest buffer 373 * @dst_offset: Offset byte in the dest buffer 374 * @src_buf_hdl: Memory handle for the source buffer 375 * @src_offset: Offset byte in the source buffer 376 * 377 */ 378 struct cam_patch_desc { 379 int32_t dst_buf_hdl; 380 uint32_t dst_offset; 381 int32_t src_buf_hdl; 382 uint32_t src_offset; 383 }; 384 385 /** 386 * struct cam_packet - Camera packet structure 387 * 388 * @header: Camera packet header 389 * @cmd_buf_offset: Command buffer start offset 390 * @num_cmd_buf: Number of the command buffer in the packet 391 * @io_config_offset: Buffer io configuration start offset 392 * @num_io_configs: Number of the buffer io configurations 393 * @patch_offset: Patch offset for the patch structure 394 * @num_patches: Number of the patch structure 395 * @kmd_cmd_buf_index: Command buffer index which contains extra 396 * space for the KMD buffer 397 * @kmd_cmd_buf_offset: Offset from the beginning of the command 398 * buffer for KMD usage. 399 * @payload: Camera packet payload 400 * 401 */ 402 struct cam_packet { 403 struct cam_packet_header header; 404 uint32_t cmd_buf_offset; 405 uint32_t num_cmd_buf; 406 uint32_t io_configs_offset; 407 uint32_t num_io_configs; 408 uint32_t patch_offset; 409 uint32_t num_patches; 410 uint32_t kmd_cmd_buf_index; 411 uint32_t kmd_cmd_buf_offset; 412 uint64_t payload[1]; 413 414 }; 415 416 /** 417 * struct cam_release_dev_cmd - Control payload for release devices 418 * 419 * @session_handle: Session handle for the release 420 * @dev_handle: Device handle for the release 421 */ 422 struct cam_release_dev_cmd { 423 int32_t session_handle; 424 int32_t dev_handle; 425 }; 426 427 /** 428 * struct cam_start_stop_dev_cmd - Control payload for start/stop device 429 * 430 * @session_handle: Session handle for the start/stop command 431 * @dev_handle: Device handle for the start/stop command 432 * 433 */ 434 struct cam_start_stop_dev_cmd { 435 int32_t session_handle; 436 int32_t dev_handle; 437 }; 438 439 /** 440 * struct cam_config_dev_cmd - Command payload for configure device 441 * 442 * @session_handle: Session handle for the command 443 * @dev_handle: Device handle for the command 444 * @offset: Offset byte in the packet handle. 445 * @packet_handle: Packet memory handle for the actual packet: 446 * struct cam_packet. 447 * 448 */ 449 struct cam_config_dev_cmd { 450 int32_t session_handle; 451 int32_t dev_handle; 452 uint64_t offset; 453 uint64_t packet_handle; 454 }; 455 456 /** 457 * struct cam_query_cap_cmd - Payload for query device capability 458 * 459 * @size: Handle size 460 * @handle_type: User pointer or shared memory handle 461 * @caps_handle: Device specific query command payload 462 * 463 */ 464 struct cam_query_cap_cmd { 465 uint32_t size; 466 uint32_t handle_type; 467 uint64_t caps_handle; 468 }; 469 470 /** 471 * struct cam_acquire_dev_cmd - Control payload for acquire devices 472 * 473 * @session_handle: Session handle for the acquire command 474 * @dev_handle: Device handle to be returned 475 * @handle_type: Resource handle type: 476 * 1 = user pointer, 2 = mem handle 477 * @num_resources: Number of the resources to be acquired 478 * @resources_hdl: Resource handle that refers to the actual 479 * resource array. Each item in this 480 * array is device specific resource structure 481 * 482 */ 483 struct cam_acquire_dev_cmd { 484 int32_t session_handle; 485 int32_t dev_handle; 486 uint32_t handle_type; 487 uint32_t num_resources; 488 uint64_t resource_hdl; 489 }; 490 491 /* 492 * In old version, while acquiring device the num_resources in 493 * struct cam_acquire_dev_cmd will be a valid value. During ACQUIRE_DEV 494 * KMD driver will return dev_handle as well as associate HW to handle. 495 * If num_resources is set to the constant below, we are using 496 * the new version and we do not acquire HW in ACQUIRE_DEV IOCTL. 497 * ACQUIRE_DEV will only return handle and we should receive 498 * ACQUIRE_HW IOCTL after ACQUIRE_DEV and that is when the HW 499 * is associated with the dev_handle. 500 * 501 * (Data type): uint32_t 502 */ 503 #define CAM_API_COMPAT_CONSTANT 0xFEFEFEFE 504 505 #define CAM_ACQUIRE_HW_STRUCT_VERSION_1 1 506 507 /** 508 * struct cam_acquire_hw_cmd_v1 - Control payload for acquire HW IOCTL (Ver 1) 509 * 510 * @struct_version: = CAM_ACQUIRE_HW_STRUCT_VERSION_1 for this struct 511 * This value should be the first 32-bits in any structure 512 * related to this IOCTL. So that if the struct needs to 513 * change, we can first read the starting 32-bits, get the 514 * version number and then typecast the data to struct 515 * accordingly. 516 * @reserved: Reserved field for 64-bit alignment 517 * @session_handle: Session handle for the acquire command 518 * @dev_handle: Device handle to be returned 519 * @handle_type: Tells you how to interpret the variable resource_hdl- 520 * 1 = user pointer, 2 = mem handle 521 * @data_size: Total size of data contained in memory pointed 522 * to by resource_hdl 523 * @resource_hdl: Resource handle that refers to the actual 524 * resource data. 525 */ 526 struct cam_acquire_hw_cmd_v1 { 527 uint32_t struct_version; 528 uint32_t reserved; 529 int32_t session_handle; 530 int32_t dev_handle; 531 uint32_t handle_type; 532 uint32_t data_size; 533 uint64_t resource_hdl; 534 }; 535 536 #define CAM_RELEASE_HW_STRUCT_VERSION_1 1 537 538 /** 539 * struct cam_release_hw_cmd_v1 - Control payload for release HW IOCTL (Ver 1) 540 * 541 * @struct_version: = CAM_RELEASE_HW_STRUCT_VERSION_1 for this struct 542 * This value should be the first 32-bits in any structure 543 * related to this IOCTL. So that if the struct needs to 544 * change, we can first read the starting 32-bits, get the 545 * version number and then typecast the data to struct 546 * accordingly. 547 * @reserved: Reserved field for 64-bit alignment 548 * @session_handle: Session handle for the release 549 * @dev_handle: Device handle for the release 550 */ 551 struct cam_release_hw_cmd_v1 { 552 uint32_t struct_version; 553 uint32_t reserved; 554 int32_t session_handle; 555 int32_t dev_handle; 556 }; 557 558 /** 559 * struct cam_flush_dev_cmd - Control payload for flush devices 560 * 561 * @version: Version 562 * @session_handle: Session handle for the acquire command 563 * @dev_handle: Device handle to be returned 564 * @flush_type: Flush type: 565 * 0 = flush specific request 566 * 1 = flush all 567 * @reserved: Reserved for 64 bit aligngment 568 * @req_id: Request id that needs to cancel 569 * 570 */ 571 struct cam_flush_dev_cmd { 572 uint64_t version; 573 int32_t session_handle; 574 int32_t dev_handle; 575 uint32_t flush_type; 576 uint32_t reserved; 577 int64_t req_id; 578 }; 579 580 /** 581 * struct cam_ubwc_config - UBWC Configuration Payload 582 * 583 * @api_version: UBWC config api version 584 * @num_ports: Number of ports to be configured 585 * @ubwc_plane_config: Array of UBWC configurations per port 586 * Size [CAM_PACKET_MAX_PLANES - 1] per port 587 * as UBWC is supported on Y & C planes 588 * and therefore a max size of 2 planes 589 * 590 */ 591 struct cam_ubwc_config { 592 uint32_t api_version; 593 uint32_t num_ports; 594 struct cam_ubwc_plane_cfg_v1 595 ubwc_plane_cfg[1][CAM_PACKET_MAX_PLANES - 1]; 596 }; 597 598 /** 599 * struct cam_cmd_mem_region_info - 600 * Cmd buffer region info 601 * 602 * @mem_handle : Memory handle of the region 603 * @offset : Offset if any 604 * @size : Size of the region 605 * @flags : Flags if any 606 */ 607 struct cam_cmd_mem_region_info { 608 int32_t mem_handle; 609 uint32_t offset; 610 uint32_t size; 611 uint32_t flags; 612 }; 613 614 /** 615 * struct cam_cmd_mem_regions - 616 * List of multiple memory descriptors of 617 * of different regions 618 * 619 * @version : Version number 620 * @num_regions : Number of regions 621 * @map_info_array : Array of all the regions 622 */ 623 struct cam_cmd_mem_regions { 624 uint32_t version; 625 uint32_t num_regions; 626 struct cam_cmd_mem_region_info map_info_array[1]; 627 }; 628 629 630 #endif /* __UAPI_CAM_DEFS_H__ */ 631