msmb_camera.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. #ifndef __UAPI_LINUX_MSMB_CAMERA_H
  2. #define __UAPI_LINUX_MSMB_CAMERA_H
  3. #include <linux/videodev2.h>
  4. #include <linux/types.h>
  5. #include <linux/ioctl.h>
  6. #include <linux/media.h>
  7. #define MSM_CAM_LOGSYNC_FILE_NAME "logsync"
  8. #define MSM_CAM_LOGSYNC_FILE_BASEDIR "camera"
  9. #define MSM_CAM_V4L2_IOCTL_NOTIFY \
  10. _IOW('V', BASE_VIDIOC_PRIVATE + 30, struct msm_v4l2_event_data)
  11. #define MSM_CAM_V4L2_IOCTL_NOTIFY_META \
  12. _IOW('V', BASE_VIDIOC_PRIVATE + 31, struct msm_v4l2_event_data)
  13. #define MSM_CAM_V4L2_IOCTL_CMD_ACK \
  14. _IOW('V', BASE_VIDIOC_PRIVATE + 32, struct msm_v4l2_event_data)
  15. #define MSM_CAM_V4L2_IOCTL_NOTIFY_ERROR \
  16. _IOW('V', BASE_VIDIOC_PRIVATE + 33, struct msm_v4l2_event_data)
  17. #define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG \
  18. _IOW('V', BASE_VIDIOC_PRIVATE + 34, struct msm_v4l2_event_data)
  19. #define MSM_CAM_V4L2_IOCTL_DAEMON_DISABLED \
  20. _IOW('V', BASE_VIDIOC_PRIVATE + 35, struct msm_v4l2_event_data)
  21. #define QCAMERA_VNODE_GROUP_ID MEDIA_ENT_F_IO_V4L
  22. #define MSM_CAMERA_NAME "msm_camera"
  23. #define MSM_CONFIGURATION_NAME "msm_config"
  24. //#define MSM_CAMERA_SUBDEV_BASE (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
  25. #define MSM_CAMERA_SUBDEV_BASE (MEDIA_ENT_F_OLD_BASE + 0xF00)
  26. #define MSM_CAMERA_SUBDEV_CSIPHY (MSM_CAMERA_SUBDEV_BASE + 0)
  27. //#define MSM_CAMERA_SUBDEV_CSID (MSM_CAMERA_SUBDEV_BASE + 1)
  28. #define MSM_CAMERA_SUBDEV_CSID (MSM_CAMERA_SUBDEV_BASE + 13)
  29. #define MSM_CAMERA_SUBDEV_ISPIF (MSM_CAMERA_SUBDEV_BASE + 2)
  30. #define MSM_CAMERA_SUBDEV_VFE (MSM_CAMERA_SUBDEV_BASE + 3)
  31. #define MSM_CAMERA_SUBDEV_AXI (MSM_CAMERA_SUBDEV_BASE + 4)
  32. #define MSM_CAMERA_SUBDEV_VPE (MSM_CAMERA_SUBDEV_BASE + 5)
  33. #define MSM_CAMERA_SUBDEV_SENSOR (MSM_CAMERA_SUBDEV_BASE + 6)
  34. #define MSM_CAMERA_SUBDEV_ACTUATOR (MSM_CAMERA_SUBDEV_BASE + 7)
  35. #define MSM_CAMERA_SUBDEV_EEPROM (MSM_CAMERA_SUBDEV_BASE + 8)
  36. #define MSM_CAMERA_SUBDEV_CPP (MSM_CAMERA_SUBDEV_BASE + 9)
  37. #define MSM_CAMERA_SUBDEV_CCI (MSM_CAMERA_SUBDEV_BASE + 10)
  38. #define MSM_CAMERA_SUBDEV_LED_FLASH (MSM_CAMERA_SUBDEV_BASE + 11)
  39. #define MSM_CAMERA_SUBDEV_STROBE_FLASH (MSM_CAMERA_SUBDEV_BASE + 12)
  40. #define MSM_CAMERA_SUBDEV_BUF_MNGR (MSM_CAMERA_SUBDEV_BASE + 1)
  41. //#define MSM_CAMERA_SUBDEV_BUF_MNGR (MSM_CAMERA_SUBDEV_BASE + 13)
  42. #define MSM_CAMERA_SUBDEV_SENSOR_INIT (MSM_CAMERA_SUBDEV_BASE + 14)
  43. #define MSM_CAMERA_SUBDEV_OIS (MSM_CAMERA_SUBDEV_BASE + 15)
  44. #define MSM_CAMERA_SUBDEV_FLASH (MSM_CAMERA_SUBDEV_BASE + 16)
  45. #define MSM_CAMERA_SUBDEV_IR_LED (MSM_CAMERA_SUBDEV_BASE + 17)
  46. #define MSM_CAMERA_SUBDEV_IR_CUT (MSM_CAMERA_SUBDEV_BASE + 18)
  47. #define MSM_CAMERA_SUBDEV_EXT (MSM_CAMERA_SUBDEV_BASE + 19)
  48. #define MSM_CAMERA_SUBDEV_TOF (MSM_CAMERA_SUBDEV_BASE + 20)
  49. #define MSM_CAMERA_SUBDEV_LASER_LED (MSM_CAMERA_SUBDEV_BASE + 21)
  50. #define MSM_MAX_CAMERA_SENSORS 5
  51. /* The below macro is defined to put an upper limit on maximum
  52. * number of buffer requested per stream. In case of extremely
  53. * large value for number of buffer due to data structure corruption
  54. * we return error to avoid integer overflow. Group processing
  55. * can have max of 9 groups of 8 bufs each. This value may be
  56. * configured in future
  57. */
  58. #define MSM_CAMERA_MAX_STREAM_BUF 72
  59. /* Max batch size of processing */
  60. #define MSM_CAMERA_MAX_USER_BUFF_CNT 16
  61. /* featur base */
  62. #define MSM_CAMERA_FEATURE_BASE 0x00010000
  63. #define MSM_CAMERA_FEATURE_SHUTDOWN (MSM_CAMERA_FEATURE_BASE + 1)
  64. #define MSM_CAMERA_STATUS_BASE 0x00020000
  65. #define MSM_CAMERA_STATUS_FAIL (MSM_CAMERA_STATUS_BASE + 1)
  66. #define MSM_CAMERA_STATUS_SUCCESS (MSM_CAMERA_STATUS_BASE + 2)
  67. /* event type */
  68. #define MSM_CAMERA_V4L2_EVENT_TYPE (V4L2_EVENT_PRIVATE_START + 0x00002000)
  69. /* event id */
  70. #define MSM_CAMERA_EVENT_MIN 0
  71. #define MSM_CAMERA_NEW_SESSION (MSM_CAMERA_EVENT_MIN + 1)
  72. #define MSM_CAMERA_DEL_SESSION (MSM_CAMERA_EVENT_MIN + 2)
  73. #define MSM_CAMERA_SET_PARM (MSM_CAMERA_EVENT_MIN + 3)
  74. #define MSM_CAMERA_GET_PARM (MSM_CAMERA_EVENT_MIN + 4)
  75. #define MSM_CAMERA_MAPPING_CFG (MSM_CAMERA_EVENT_MIN + 5)
  76. #define MSM_CAMERA_MAPPING_SES (MSM_CAMERA_EVENT_MIN + 6)
  77. #define MSM_CAMERA_MSM_NOTIFY (MSM_CAMERA_EVENT_MIN + 7)
  78. #define MSM_CAMERA_EVENT_MAX (MSM_CAMERA_EVENT_MIN + 8)
  79. /* data.command */
  80. #define MSM_CAMERA_PRIV_S_CROP (V4L2_CID_PRIVATE_BASE + 1)
  81. #define MSM_CAMERA_PRIV_G_CROP (V4L2_CID_PRIVATE_BASE + 2)
  82. #define MSM_CAMERA_PRIV_G_FMT (V4L2_CID_PRIVATE_BASE + 3)
  83. #define MSM_CAMERA_PRIV_S_FMT (V4L2_CID_PRIVATE_BASE + 4)
  84. #define MSM_CAMERA_PRIV_TRY_FMT (V4L2_CID_PRIVATE_BASE + 5)
  85. #define MSM_CAMERA_PRIV_METADATA (V4L2_CID_PRIVATE_BASE + 6)
  86. #define MSM_CAMERA_PRIV_QUERY_CAP (V4L2_CID_PRIVATE_BASE + 7)
  87. #define MSM_CAMERA_PRIV_STREAM_ON (V4L2_CID_PRIVATE_BASE + 8)
  88. #define MSM_CAMERA_PRIV_STREAM_OFF (V4L2_CID_PRIVATE_BASE + 9)
  89. #define MSM_CAMERA_PRIV_NEW_STREAM (V4L2_CID_PRIVATE_BASE + 10)
  90. #define MSM_CAMERA_PRIV_DEL_STREAM (V4L2_CID_PRIVATE_BASE + 11)
  91. #define MSM_CAMERA_PRIV_SHUTDOWN (V4L2_CID_PRIVATE_BASE + 12)
  92. #define MSM_CAMERA_PRIV_STREAM_INFO_SYNC \
  93. (V4L2_CID_PRIVATE_BASE + 13)
  94. #define MSM_CAMERA_PRIV_G_SESSION_ID (V4L2_CID_PRIVATE_BASE + 14)
  95. #define MSM_CAMERA_PRIV_CMD_MAX 20
  96. /* data.status - success */
  97. #define MSM_CAMERA_CMD_SUCCESS 0x00000001
  98. #define MSM_CAMERA_BUF_MAP_SUCCESS 0x00000002
  99. /* data.status - error */
  100. #define MSM_CAMERA_ERR_EVT_BASE 0x00010000
  101. #define MSM_CAMERA_ERR_CMD_FAIL (MSM_CAMERA_ERR_EVT_BASE + 1)
  102. #define MSM_CAMERA_ERR_MAPPING (MSM_CAMERA_ERR_EVT_BASE + 2)
  103. #define MSM_CAMERA_ERR_DEVICE_BUSY (MSM_CAMERA_ERR_EVT_BASE + 3)
  104. /* The msm_v4l2_event_data structure should match the
  105. * v4l2_event.u.data field.
  106. * should not exceed 16 elements
  107. */
  108. struct msm_v4l2_event_data {
  109. /*word 0*/
  110. unsigned int command;
  111. /*word 1*/
  112. unsigned int status;
  113. /*word 2*/
  114. unsigned int session_id;
  115. /*word 3*/
  116. unsigned int stream_id;
  117. /*word 4*/
  118. unsigned int map_op;
  119. /*word 5*/
  120. unsigned int map_buf_idx;
  121. /*word 6*/
  122. unsigned int notify;
  123. /*word 7*/
  124. unsigned int arg_value;
  125. /*word 8*/
  126. unsigned int ret_value;
  127. /*word 9*/
  128. unsigned int v4l2_event_type;
  129. /*word 10*/
  130. unsigned int v4l2_event_id;
  131. /*word 11*/
  132. unsigned int handle;
  133. /*word 12*/
  134. unsigned int nop6;
  135. /*word 13*/
  136. unsigned int nop7;
  137. /*word 14*/
  138. unsigned int nop8;
  139. /*word 15*/
  140. unsigned int nop9;
  141. };
  142. /* map to v4l2_format.fmt.raw_data */
  143. struct msm_v4l2_format_data {
  144. enum v4l2_buf_type type;
  145. unsigned int width;
  146. unsigned int height;
  147. unsigned int pixelformat; /* FOURCC */
  148. unsigned char num_planes;
  149. unsigned int plane_sizes[VIDEO_MAX_PLANES];
  150. };
  151. /* MSM Four-character-code (FOURCC) */
  152. #define msm_v4l2_fourcc(a, b, c, d)\
  153. ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) |\
  154. ((__u32)(d) << 24))
  155. /* Composite stats */
  156. #define MSM_V4L2_PIX_FMT_STATS_COMB v4l2_fourcc('S', 'T', 'C', 'M')
  157. /* AEC stats */
  158. #define MSM_V4L2_PIX_FMT_STATS_AE v4l2_fourcc('S', 'T', 'A', 'E')
  159. /* AF stats */
  160. #define MSM_V4L2_PIX_FMT_STATS_AF v4l2_fourcc('S', 'T', 'A', 'F')
  161. /* AWB stats */
  162. #define MSM_V4L2_PIX_FMT_STATS_AWB v4l2_fourcc('S', 'T', 'W', 'B')
  163. /* IHIST stats */
  164. #define MSM_V4L2_PIX_FMT_STATS_IHST v4l2_fourcc('I', 'H', 'S', 'T')
  165. /* Column count stats */
  166. #define MSM_V4L2_PIX_FMT_STATS_CS v4l2_fourcc('S', 'T', 'C', 'S')
  167. /* Row count stats */
  168. #define MSM_V4L2_PIX_FMT_STATS_RS v4l2_fourcc('S', 'T', 'R', 'S')
  169. /* Bayer Grid stats */
  170. #define MSM_V4L2_PIX_FMT_STATS_BG v4l2_fourcc('S', 'T', 'B', 'G')
  171. /* Bayer focus stats */
  172. #define MSM_V4L2_PIX_FMT_STATS_BF v4l2_fourcc('S', 'T', 'B', 'F')
  173. /* Bayer hist stats */
  174. #define MSM_V4L2_PIX_FMT_STATS_BHST v4l2_fourcc('B', 'H', 'S', 'T')
  175. enum smmu_attach_mode {
  176. NON_SECURE_MODE = 0x01,
  177. SECURE_MODE = 0x02,
  178. MAX_PROTECTION_MODE = 0x03,
  179. };
  180. struct msm_camera_smmu_attach_type {
  181. enum smmu_attach_mode attach;
  182. };
  183. struct msm_camera_user_buf_cont_t {
  184. unsigned int buf_cnt;
  185. unsigned int buf_idx[MSM_CAMERA_MAX_USER_BUFF_CNT];
  186. };
  187. struct msm_camera_return_buf {
  188. __u32 index;
  189. __u32 reserved;
  190. };
  191. #define MSM_CAMERA_PRIV_IOCTL_ID_BASE 0
  192. #define MSM_CAMERA_PRIV_IOCTL_ID_RETURN_BUF 1
  193. struct msm_camera_private_ioctl_arg {
  194. __u32 id;
  195. __u32 size;
  196. __u32 result;
  197. __u32 reserved;
  198. __u64 ioctl_ptr;
  199. };
  200. #define VIDIOC_MSM_CAMERA_PRIVATE_IOCTL_CMD \
  201. _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_camera_private_ioctl_arg)
  202. #endif