cam_defs.h 18 KB

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