Home | History | Annotate | Download | only in media
      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_EXT_OPCODE_BASE                     0x200
     22 #define CAM_CONFIG_DEV_EXTERNAL                 (CAM_EXT_OPCODE_BASE + 0x1)
     23 
     24 /* camera handle type */
     25 #define CAM_HANDLE_USER_POINTER                 1
     26 #define CAM_HANDLE_MEM_HANDLE                   2
     27 
     28 /* Generic Blob CmdBuffer header properties */
     29 #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK    0xFFFFFF00
     30 #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT   8
     31 #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK    0xFF
     32 #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT   0
     33 
     34 /* Command Buffer Types */
     35 #define CAM_CMD_BUF_DMI                     0x1
     36 #define CAM_CMD_BUF_DMI16                   0x2
     37 #define CAM_CMD_BUF_DMI32                   0x3
     38 #define CAM_CMD_BUF_DMI64                   0x4
     39 #define CAM_CMD_BUF_DIRECT                  0x5
     40 #define CAM_CMD_BUF_INDIRECT                0x6
     41 #define CAM_CMD_BUF_I2C                     0x7
     42 #define CAM_CMD_BUF_FW                      0x8
     43 #define CAM_CMD_BUF_GENERIC                 0x9
     44 #define CAM_CMD_BUF_LEGACY                  0xA
     45 
     46 /**
     47  * enum flush_type_t - Identifies the various flush types
     48  *
     49  * @CAM_FLUSH_TYPE_REQ:    Flush specific request
     50  * @CAM_FLUSH_TYPE_ALL:    Flush all requests belonging to a context
     51  * @CAM_FLUSH_TYPE_MAX:    Max enum to validate flush type
     52  *
     53  */
     54 enum flush_type_t {
     55 	CAM_FLUSH_TYPE_REQ,
     56 	CAM_FLUSH_TYPE_ALL,
     57 	CAM_FLUSH_TYPE_MAX
     58 };
     59 
     60 /**
     61  * struct cam_control - Structure used by ioctl control for camera
     62  *
     63  * @op_code:            This is the op code for camera control
     64  * @size:               Control command size
     65  * @handle_type:        User pointer or shared memory handle
     66  * @reserved:           Reserved field for 64 bit alignment
     67  * @handle:             Control command payload
     68  */
     69 struct cam_control {
     70 	uint32_t        op_code;
     71 	uint32_t        size;
     72 	uint32_t        handle_type;
     73 	uint32_t        reserved;
     74 	uint64_t        handle;
     75 };
     76 
     77 /* camera IOCTL */
     78 #define VIDIOC_CAM_CONTROL \
     79 	_IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control)
     80 
     81 /**
     82  * struct cam_hw_version - Structure for HW version of camera devices
     83  *
     84  * @major    : Hardware version major
     85  * @minor    : Hardware version minor
     86  * @incr     : Hardware version increment
     87  * @reserved : Reserved for 64 bit aligngment
     88  */
     89 struct cam_hw_version {
     90 	uint32_t major;
     91 	uint32_t minor;
     92 	uint32_t incr;
     93 	uint32_t reserved;
     94 };
     95 
     96 /**
     97  * struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices
     98  *
     99  * @non_secure: Device Non Secure IOMMU handle
    100  * @secure:     Device Secure IOMMU handle
    101  *
    102  */
    103 struct cam_iommu_handle {
    104 	int32_t non_secure;
    105 	int32_t secure;
    106 };
    107 
    108 /* camera secure mode */
    109 #define CAM_SECURE_MODE_NON_SECURE             0
    110 #define CAM_SECURE_MODE_SECURE                 1
    111 
    112 /* Camera Format Type */
    113 #define CAM_FORMAT_BASE                         0
    114 #define CAM_FORMAT_MIPI_RAW_6                   1
    115 #define CAM_FORMAT_MIPI_RAW_8                   2
    116 #define CAM_FORMAT_MIPI_RAW_10                  3
    117 #define CAM_FORMAT_MIPI_RAW_12                  4
    118 #define CAM_FORMAT_MIPI_RAW_14                  5
    119 #define CAM_FORMAT_MIPI_RAW_16                  6
    120 #define CAM_FORMAT_MIPI_RAW_20                  7
    121 #define CAM_FORMAT_QTI_RAW_8                    8
    122 #define CAM_FORMAT_QTI_RAW_10                   9
    123 #define CAM_FORMAT_QTI_RAW_12                   10
    124 #define CAM_FORMAT_QTI_RAW_14                   11
    125 #define CAM_FORMAT_PLAIN8                       12
    126 #define CAM_FORMAT_PLAIN16_8                    13
    127 #define CAM_FORMAT_PLAIN16_10                   14
    128 #define CAM_FORMAT_PLAIN16_12                   15
    129 #define CAM_FORMAT_PLAIN16_14                   16
    130 #define CAM_FORMAT_PLAIN16_16                   17
    131 #define CAM_FORMAT_PLAIN32_20                   18
    132 #define CAM_FORMAT_PLAIN64                      19
    133 #define CAM_FORMAT_PLAIN128                     20
    134 #define CAM_FORMAT_ARGB                         21
    135 #define CAM_FORMAT_ARGB_10                      22
    136 #define CAM_FORMAT_ARGB_12                      23
    137 #define CAM_FORMAT_ARGB_14                      24
    138 #define CAM_FORMAT_DPCM_10_6_10                 25
    139 #define CAM_FORMAT_DPCM_10_8_10                 26
    140 #define CAM_FORMAT_DPCM_12_6_12                 27
    141 #define CAM_FORMAT_DPCM_12_8_12                 28
    142 #define CAM_FORMAT_DPCM_14_8_14                 29
    143 #define CAM_FORMAT_DPCM_14_10_14                30
    144 #define CAM_FORMAT_NV21                         31
    145 #define CAM_FORMAT_NV12                         32
    146 #define CAM_FORMAT_TP10                         33
    147 #define CAM_FORMAT_YUV422                       34
    148 #define CAM_FORMAT_PD8                          35
    149 #define CAM_FORMAT_PD10                         36
    150 #define CAM_FORMAT_UBWC_NV12                    37
    151 #define CAM_FORMAT_UBWC_NV12_4R                 38
    152 #define CAM_FORMAT_UBWC_TP10                    39
    153 #define CAM_FORMAT_UBWC_P010                    40
    154 #define CAM_FORMAT_PLAIN8_SWAP                  41
    155 #define CAM_FORMAT_PLAIN8_10                    42
    156 #define CAM_FORMAT_PLAIN8_10_SWAP               43
    157 #define CAM_FORMAT_YV12                         44
    158 #define CAM_FORMAT_Y_ONLY                       45
    159 #define CAM_FORMAT_MAX                          46
    160 
    161 /* camera rotaion */
    162 #define CAM_ROTATE_CW_0_DEGREE                  0
    163 #define CAM_ROTATE_CW_90_DEGREE                 1
    164 #define CAM_RORATE_CW_180_DEGREE                2
    165 #define CAM_ROTATE_CW_270_DEGREE                3
    166 
    167 /* camera Color Space */
    168 #define CAM_COLOR_SPACE_BASE                    0
    169 #define CAM_COLOR_SPACE_BT601_FULL              1
    170 #define CAM_COLOR_SPACE_BT601625                2
    171 #define CAM_COLOR_SPACE_BT601525                3
    172 #define CAM_COLOR_SPACE_BT709                   4
    173 #define CAM_COLOR_SPACE_DEPTH                   5
    174 #define CAM_COLOR_SPACE_MAX                     6
    175 
    176 /* camera buffer direction */
    177 #define CAM_BUF_INPUT                           1
    178 #define CAM_BUF_OUTPUT                          2
    179 #define CAM_BUF_IN_OUT                          3
    180 
    181 /* camera packet device Type */
    182 #define CAM_PACKET_DEV_BASE                     0
    183 #define CAM_PACKET_DEV_IMG_SENSOR               1
    184 #define CAM_PACKET_DEV_ACTUATOR                 2
    185 #define CAM_PACKET_DEV_COMPANION                3
    186 #define CAM_PACKET_DEV_EEPOM                    4
    187 #define CAM_PACKET_DEV_CSIPHY                   5
    188 #define CAM_PACKET_DEV_OIS                      6
    189 #define CAM_PACKET_DEV_FLASH                    7
    190 #define CAM_PACKET_DEV_FD                       8
    191 #define CAM_PACKET_DEV_JPEG_ENC                 9
    192 #define CAM_PACKET_DEV_JPEG_DEC                 10
    193 #define CAM_PACKET_DEV_VFE                      11
    194 #define CAM_PACKET_DEV_CPP                      12
    195 #define CAM_PACKET_DEV_CSID                     13
    196 #define CAM_PACKET_DEV_ISPIF                    14
    197 #define CAM_PACKET_DEV_IFE                      15
    198 #define CAM_PACKET_DEV_ICP                      16
    199 #define CAM_PACKET_DEV_LRME                     17
    200 #define CAM_PACKET_DEV_MAX                      18
    201 
    202 
    203 /* constants */
    204 #define CAM_PACKET_MAX_PLANES                   3
    205 
    206 /**
    207  * struct cam_plane_cfg - Plane configuration info
    208  *
    209  * @width:                      Plane width in pixels
    210  * @height:                     Plane height in lines
    211  * @plane_stride:               Plane stride in pixel
    212  * @slice_height:               Slice height in line (not used by ISP)
    213  * @meta_stride:                UBWC metadata stride
    214  * @meta_size:                  UBWC metadata plane size
    215  * @meta_offset:                UBWC metadata offset
    216  * @packer_config:              UBWC packer config
    217  * @mode_config:                UBWC mode config
    218  * @tile_config:                UBWC tile config
    219  * @h_init:                     UBWC horizontal initial coordinate in pixels
    220  * @v_init:                     UBWC vertical initial coordinate in lines
    221  *
    222  */
    223 struct cam_plane_cfg {
    224 	uint32_t                width;
    225 	uint32_t                height;
    226 	uint32_t                plane_stride;
    227 	uint32_t                slice_height;
    228 	uint32_t                meta_stride;
    229 	uint32_t                meta_size;
    230 	uint32_t                meta_offset;
    231 	uint32_t                packer_config;
    232 	uint32_t                mode_config;
    233 	uint32_t                tile_config;
    234 	uint32_t                h_init;
    235 	uint32_t                v_init;
    236 };
    237 
    238 /**
    239  * struct cam_cmd_buf_desc - Command buffer descriptor
    240  *
    241  * @mem_handle:                 Command buffer handle
    242  * @offset:                     Command start offset
    243  * @size:                       Size of the command buffer in bytes
    244  * @length:                     Used memory in command buffer in bytes
    245  * @type:                       Type of the command buffer
    246  * @meta_data:                  Data type for private command buffer
    247  *                              Between UMD and KMD
    248  *
    249  */
    250 struct cam_cmd_buf_desc {
    251 	int32_t                 mem_handle;
    252 	uint32_t                offset;
    253 	uint32_t                size;
    254 	uint32_t                length;
    255 	uint32_t                type;
    256 	uint32_t                meta_data;
    257 };
    258 
    259 /**
    260  * struct cam_buf_io_cfg - Buffer io configuration for buffers
    261  *
    262  * @mem_handle:                 Mem_handle array for the buffers.
    263  * @offsets:                    Offsets for each planes in the buffer
    264  * @planes:                     Per plane information
    265  * @width:                      Main plane width in pixel
    266  * @height:                     Main plane height in lines
    267  * @format:                     Format of the buffer
    268  * @color_space:                Color space for the buffer
    269  * @color_pattern:              Color pattern in the buffer
    270  * @bpp:                        Bit per pixel
    271  * @rotation:                   Rotation information for the buffer
    272  * @resource_type:              Resource type associated with the buffer
    273  * @fence:                      Fence handle
    274  * @early_fence:                Fence handle for early signal
    275  * @aux_cmd_buf:                An auxiliary command buffer that may be
    276  *                              used for programming the IO
    277  * @direction:                  Direction of the config
    278  * @batch_size:                 Batch size in HFR mode
    279  * @subsample_pattern:          Subsample pattern. Used in HFR mode. It
    280  *                              should be consistent with batchSize and
    281  *                              CAMIF programming.
    282  * @subsample_period:           Subsample period. Used in HFR mode. It
    283  *                              should be consistent with batchSize and
    284  *                              CAMIF programming.
    285  * @framedrop_pattern:          Framedrop pattern
    286  * @framedrop_period:           Framedrop period
    287  * @flag:                       Flags for extra information
    288  * @direction:                  Buffer direction: input or output
    289  * @padding:                    Padding for the structure
    290  *
    291  */
    292 struct cam_buf_io_cfg {
    293 	int32_t                         mem_handle[CAM_PACKET_MAX_PLANES];
    294 	uint32_t                        offsets[CAM_PACKET_MAX_PLANES];
    295 	struct cam_plane_cfg            planes[CAM_PACKET_MAX_PLANES];
    296 	uint32_t                        format;
    297 	uint32_t                        color_space;
    298 	uint32_t                        color_pattern;
    299 	uint32_t                        bpp;
    300 	uint32_t                        rotation;
    301 	uint32_t                        resource_type;
    302 	int32_t                         fence;
    303 	int32_t                         early_fence;
    304 	struct cam_cmd_buf_desc         aux_cmd_buf;
    305 	uint32_t                        direction;
    306 	uint32_t                        batch_size;
    307 	uint32_t                        subsample_pattern;
    308 	uint32_t                        subsample_period;
    309 	uint32_t                        framedrop_pattern;
    310 	uint32_t                        framedrop_period;
    311 	uint32_t                        flag;
    312 	uint32_t                        padding;
    313 };
    314 
    315 /**
    316  * struct cam_packet_header - Camera packet header
    317  *
    318  * @op_code:                    Camera packet opcode
    319  * @size:                       Size of the camera packet in bytes
    320  * @request_id:                 Request id for this camera packet
    321  * @flags:                      Flags for the camera packet
    322  * @padding:                    Padding
    323  *
    324  */
    325 struct cam_packet_header {
    326 	uint32_t                op_code;
    327 	uint32_t                size;
    328 	uint64_t                request_id;
    329 	uint32_t                flags;
    330 	uint32_t                padding;
    331 };
    332 
    333 /**
    334  * struct cam_patch_desc - Patch structure
    335  *
    336  * @dst_buf_hdl:                Memory handle for the dest buffer
    337  * @dst_offset:                 Offset byte in the dest buffer
    338  * @src_buf_hdl:                Memory handle for the source buffer
    339  * @src_offset:                 Offset byte in the source buffer
    340  *
    341  */
    342 struct cam_patch_desc {
    343 	int32_t                 dst_buf_hdl;
    344 	uint32_t                dst_offset;
    345 	int32_t                 src_buf_hdl;
    346 	uint32_t                src_offset;
    347 };
    348 
    349 /**
    350  * struct cam_packet - Camera packet structure
    351  *
    352  * @header:                     Camera packet header
    353  * @cmd_buf_offset:             Command buffer start offset
    354  * @num_cmd_buf:                Number of the command buffer in the packet
    355  * @io_config_offset:           Buffer io configuration start offset
    356  * @num_io_configs:             Number of the buffer io configurations
    357  * @patch_offset:               Patch offset for the patch structure
    358  * @num_patches:                Number of the patch structure
    359  * @kmd_cmd_buf_index:          Command buffer index which contains extra
    360  *                              space for the KMD buffer
    361  * @kmd_cmd_buf_offset:         Offset from the beginning of the command
    362  *                              buffer for KMD usage.
    363  * @payload:                    Camera packet payload
    364  *
    365  */
    366 struct cam_packet {
    367 	struct cam_packet_header        header;
    368 	uint32_t                        cmd_buf_offset;
    369 	uint32_t                        num_cmd_buf;
    370 	uint32_t                        io_configs_offset;
    371 	uint32_t                        num_io_configs;
    372 	uint32_t                        patch_offset;
    373 	uint32_t                        num_patches;
    374 	uint32_t                        kmd_cmd_buf_index;
    375 	uint32_t                        kmd_cmd_buf_offset;
    376 	uint64_t                        payload[1];
    377 
    378 };
    379 
    380 /**
    381  * struct cam_release_dev_cmd - Control payload for release devices
    382  *
    383  * @session_handle:             Session handle for the release
    384  * @dev_handle:                 Device handle for the release
    385  */
    386 struct cam_release_dev_cmd {
    387 	int32_t                 session_handle;
    388 	int32_t                 dev_handle;
    389 };
    390 
    391 /**
    392  * struct cam_start_stop_dev_cmd - Control payload for start/stop device
    393  *
    394  * @session_handle:             Session handle for the start/stop command
    395  * @dev_handle:                 Device handle for the start/stop command
    396  *
    397  */
    398 struct cam_start_stop_dev_cmd {
    399 	int32_t                 session_handle;
    400 	int32_t                 dev_handle;
    401 };
    402 
    403 /**
    404  * struct cam_config_dev_cmd - Command payload for configure device
    405  *
    406  * @session_handle:             Session handle for the command
    407  * @dev_handle:                 Device handle for the command
    408  * @offset:                     Offset byte in the packet handle.
    409  * @packet_handle:              Packet memory handle for the actual packet:
    410  *                              struct cam_packet.
    411  *
    412  */
    413 struct cam_config_dev_cmd {
    414 	int32_t                 session_handle;
    415 	int32_t                 dev_handle;
    416 	uint64_t                offset;
    417 	uint64_t                packet_handle;
    418 };
    419 
    420 /**
    421  * struct cam_query_cap_cmd - Payload for query device capability
    422  *
    423  * @size:               Handle size
    424  * @handle_type:        User pointer or shared memory handle
    425  * @caps_handle:        Device specific query command payload
    426  *
    427  */
    428 struct cam_query_cap_cmd {
    429 	uint32_t        size;
    430 	uint32_t        handle_type;
    431 	uint64_t        caps_handle;
    432 };
    433 
    434 /**
    435  * struct cam_acquire_dev_cmd - Control payload for acquire devices
    436  *
    437  * @session_handle:     Session handle for the acquire command
    438  * @dev_handle:         Device handle to be returned
    439  * @handle_type:        Resource handle type:
    440  *                      1 = user pointer, 2 = mem handle
    441  * @num_resources:      Number of the resources to be acquired
    442  * @resources_hdl:      Resource handle that refers to the actual
    443  *                      resource array. Each item in this
    444  *                      array is device specific resource structure
    445  *
    446  */
    447 struct cam_acquire_dev_cmd {
    448 	int32_t         session_handle;
    449 	int32_t         dev_handle;
    450 	uint32_t        handle_type;
    451 	uint32_t        num_resources;
    452 	uint64_t        resource_hdl;
    453 };
    454 
    455 /**
    456  * struct cam_flush_dev_cmd - Control payload for flush devices
    457  *
    458  * @version:           Version
    459  * @session_handle:    Session handle for the acquire command
    460  * @dev_handle:        Device handle to be returned
    461  * @flush_type:        Flush type:
    462  *                     0 = flush specific request
    463  *                     1 = flush all
    464  * @reserved:          Reserved for 64 bit aligngment
    465  * @req_id:            Request id that needs to cancel
    466  *
    467  */
    468 struct cam_flush_dev_cmd {
    469 	uint64_t       version;
    470 	int32_t        session_handle;
    471 	int32_t        dev_handle;
    472 	uint32_t       flush_type;
    473 	uint32_t       reserved;
    474 	int64_t        req_id;
    475 };
    476 
    477 #endif /* __UAPI_CAM_DEFS_H__ */
    478