msmb_isp.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. #ifndef __MSMB_ISP__
  2. #define __MSMB_ISP__
  3. #include <linux/videodev2.h>
  4. #define MAX_PLANES_PER_STREAM 3
  5. #define MAX_NUM_STREAM 7
  6. #define ISP_VERSION_40 40
  7. #define ISP_VERSION_32 32
  8. #define ISP_NATIVE_BUF_BIT 0x10000
  9. #define ISP0_BIT 0x20000
  10. #define ISP1_BIT 0x40000
  11. #define ISP_META_CHANNEL_BIT 0x80000
  12. #define ISP_STATS_STREAM_BIT 0x80000000
  13. #define MSM_VFE_REG_CFG_FRAME_ID_NOT_MATCH_ERROR 0xCACFC
  14. enum ISP_START_PIXEL_PATTERN {
  15. ISP_BAYER_RGRGRG,
  16. ISP_BAYER_GRGRGR,
  17. ISP_BAYER_BGBGBG,
  18. ISP_BAYER_GBGBGB,
  19. ISP_YUV_YCbYCr,
  20. ISP_YUV_YCrYCb,
  21. ISP_YUV_CbYCrY,
  22. ISP_YUV_CrYCbY,
  23. ISP_PIX_PATTERN_MAX
  24. };
  25. enum msm_vfe_plane_fmt {
  26. Y_PLANE,
  27. CB_PLANE,
  28. CR_PLANE,
  29. CRCB_PLANE,
  30. CBCR_PLANE,
  31. VFE_PLANE_FMT_MAX
  32. };
  33. enum msm_vfe_input_src {
  34. VFE_PIX_0,
  35. VFE_RAW_0,
  36. VFE_RAW_1,
  37. VFE_RAW_2,
  38. VFE_SRC_MAX,
  39. };
  40. enum msm_vfe_axi_stream_src {
  41. PIX_ENCODER,
  42. PIX_VIEWFINDER,
  43. CAMIF_RAW,
  44. IDEAL_RAW,
  45. RDI_INTF_0,
  46. RDI_INTF_1,
  47. RDI_INTF_2,
  48. VFE_AXI_SRC_MAX
  49. };
  50. enum msm_vfe_frame_skip_pattern {
  51. NO_SKIP,
  52. EVERY_2FRAME,
  53. EVERY_3FRAME,
  54. EVERY_4FRAME,
  55. EVERY_5FRAME,
  56. EVERY_6FRAME,
  57. EVERY_7FRAME,
  58. EVERY_8FRAME,
  59. #ifdef CONFIG_MSMB_CAMERA_MM
  60. EVERY_9FRAME,
  61. EVERY_10FRAME,
  62. EVERY_11FRAME,
  63. EVERY_12FRAME,
  64. EVERY_13FRAME,
  65. EVERY_14FRAME,
  66. EVERY_15FRAME,
  67. #endif
  68. EVERY_16FRAME,
  69. EVERY_32FRAME,
  70. SKIP_ALL,
  71. MAX_SKIP,
  72. };
  73. enum msm_vfe_camif_input {
  74. CAMIF_DISABLED,
  75. CAMIF_PAD_REG_INPUT,
  76. CAMIF_MIDDI_INPUT,
  77. CAMIF_MIPI_INPUT,
  78. };
  79. struct msm_vfe_camif_cfg {
  80. uint32_t lines_per_frame;
  81. uint32_t pixels_per_line;
  82. uint32_t first_pixel;
  83. uint32_t last_pixel;
  84. uint32_t first_line;
  85. uint32_t last_line;
  86. uint32_t epoch_line0;
  87. uint32_t epoch_line1;
  88. enum msm_vfe_camif_input camif_input;
  89. };
  90. enum msm_vfe_inputmux {
  91. CAMIF,
  92. TESTGEN,
  93. EXTERNAL_READ,
  94. };
  95. struct msm_vfe_pix_cfg {
  96. struct msm_vfe_camif_cfg camif_cfg;
  97. enum msm_vfe_inputmux input_mux;
  98. enum ISP_START_PIXEL_PATTERN pixel_pattern;
  99. };
  100. struct msm_vfe_rdi_cfg {
  101. uint8_t cid;
  102. uint8_t frame_based;
  103. };
  104. struct msm_vfe_input_cfg {
  105. union {
  106. struct msm_vfe_pix_cfg pix_cfg;
  107. struct msm_vfe_rdi_cfg rdi_cfg;
  108. } d;
  109. enum msm_vfe_input_src input_src;
  110. uint32_t input_pix_clk;
  111. };
  112. struct msm_vfe_axi_plane_cfg {
  113. uint32_t output_width; /*Include padding*/
  114. uint32_t output_height;
  115. uint32_t output_stride;
  116. uint32_t output_scan_lines;
  117. uint32_t output_plane_format; /*Y/Cb/Cr/CbCr*/
  118. uint32_t plane_addr_offset;
  119. uint8_t csid_src; /*RDI 0-2*/
  120. uint8_t rdi_cid;/*CID 1-16*/
  121. };
  122. struct msm_vfe_axi_stream_request_cmd {
  123. uint32_t session_id;
  124. uint32_t stream_id;
  125. uint32_t output_format;/*Planar/RAW/Misc*/
  126. enum msm_vfe_axi_stream_src stream_src; /*CAMIF/IDEAL/RDIs*/
  127. struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
  128. uint32_t burst_count;
  129. uint32_t hfr_mode;
  130. uint8_t frame_base;
  131. uint32_t init_frame_drop; /*MAX 31 Frames*/
  132. enum msm_vfe_frame_skip_pattern frame_skip_pattern;
  133. uint8_t buf_divert; /* if TRUE no vb2 buf done. */
  134. /*Return values*/
  135. uint32_t axi_stream_handle;
  136. };
  137. struct msm_vfe_axi_stream_release_cmd {
  138. uint32_t stream_handle;
  139. };
  140. enum msm_vfe_axi_stream_cmd {
  141. STOP_STREAM,
  142. START_STREAM,
  143. };
  144. struct msm_vfe_axi_stream_cfg_cmd {
  145. uint8_t num_streams;
  146. uint32_t stream_handle[MAX_NUM_STREAM];
  147. enum msm_vfe_axi_stream_cmd cmd;
  148. #ifdef CONFIG_MSMB_CAMERA_MM
  149. int32_t recording_hint;
  150. #endif
  151. };
  152. enum msm_vfe_axi_stream_update_type {
  153. #ifdef CONFIG_MSMB_CAMERA_MM
  154. AXI_STREAM_UPDATE_INVALID,
  155. #endif
  156. ENABLE_STREAM_BUF_DIVERT,
  157. DISABLE_STREAM_BUF_DIVERT,
  158. UPDATE_STREAM_FRAMEDROP_PATTERN,
  159. UPDATE_STREAM_AXI_CONFIG,
  160. };
  161. struct msm_vfe_axi_stream_cfg_update_info {
  162. uint32_t stream_handle;
  163. uint32_t output_format;
  164. enum msm_vfe_frame_skip_pattern skip_pattern;
  165. struct msm_vfe_axi_plane_cfg plane_cfg[MAX_PLANES_PER_STREAM];
  166. };
  167. struct msm_vfe_axi_halt_cmd {
  168. uint32_t stop_camif; //Boolean whether stop camif is to be done
  169. uint32_t overflow_detected;
  170. };
  171. struct msm_vfe_axi_reset_cmd {
  172. uint32_t blocking; //Boolean whether stop camif is to be done
  173. unsigned long frame_id;
  174. };
  175. struct msm_vfe_axi_restart_cmd {
  176. uint32_t enable_camif; //Boolean whether stop camif is to be done
  177. };
  178. struct msm_vfe_axi_stream_update_cmd {
  179. uint32_t num_streams;
  180. enum msm_vfe_axi_stream_update_type update_type;
  181. struct msm_vfe_axi_stream_cfg_update_info update_info[MAX_NUM_STREAM];
  182. };
  183. enum msm_vfe_stats_pipeline_policy {
  184. STATS_COMP_ALL,
  185. STATS_COMP_NONE,
  186. MAX_STATS_POLICY,
  187. };
  188. enum msm_isp_stats_type {
  189. MSM_ISP_STATS_AEC, /* legacy based AEC */
  190. MSM_ISP_STATS_AF, /* legacy based AF */
  191. MSM_ISP_STATS_AWB, /* legacy based AWB */
  192. MSM_ISP_STATS_RS, /* legacy based RS */
  193. MSM_ISP_STATS_CS, /* legacy based CS */
  194. MSM_ISP_STATS_IHIST, /* legacy based HIST */
  195. MSM_ISP_STATS_SKIN, /* legacy based SKIN */
  196. MSM_ISP_STATS_BG, /* Bayer Grids */
  197. MSM_ISP_STATS_BF, /* Bayer Focus */
  198. MSM_ISP_STATS_BE, /* Bayer Exposure*/
  199. MSM_ISP_STATS_BHIST, /* Bayer Hist */
  200. MSM_ISP_STATS_MAX /* MAX */
  201. };
  202. struct msm_vfe_stats_stream_request_cmd {
  203. uint32_t session_id;
  204. uint32_t stream_id;
  205. enum msm_isp_stats_type stats_type;
  206. uint32_t composite_flag;
  207. uint32_t framedrop_pattern;
  208. uint32_t irq_subsample_pattern;
  209. uint32_t buffer_offset;
  210. uint32_t stream_handle;
  211. };
  212. struct msm_vfe_stats_stream_release_cmd {
  213. uint32_t stream_handle;
  214. };
  215. struct msm_vfe_stats_stream_cfg_cmd {
  216. uint8_t num_streams;
  217. uint32_t stream_handle[MSM_ISP_STATS_MAX];
  218. uint8_t enable;
  219. };
  220. struct msm_vfe_stats_comp_policy_cfg {
  221. enum msm_vfe_stats_pipeline_policy stats_pipeline_policy;
  222. uint32_t comp_framedrop_pattern;
  223. uint32_t comp_irq_subsample_pattern;
  224. };
  225. enum msm_vfe_reg_cfg_type {
  226. VFE_WRITE,
  227. VFE_WRITE_MB,
  228. VFE_READ,
  229. VFE_CFG_MASK,
  230. VFE_WRITE_DMI_16BIT,
  231. VFE_WRITE_DMI_32BIT,
  232. VFE_WRITE_DMI_64BIT,
  233. VFE_READ_DMI_16BIT,
  234. VFE_READ_DMI_32BIT,
  235. VFE_READ_DMI_64BIT,
  236. };
  237. struct msm_vfe_cfg_cmd2 {
  238. uint16_t num_cfg;
  239. uint16_t cmd_len;
  240. #if (defined(CONFIG_MSMB_CAMERA_MM) || defined(CONFIG_SEC_LT03_PROJECT)) && !defined(CONFIG_SEC_S_PROJECT)
  241. uint32_t frame_id;
  242. #endif
  243. void __user *cfg_data;
  244. void __user *cfg_cmd;
  245. };
  246. struct msm_vfe_reg_rw_info {
  247. uint32_t reg_offset;
  248. uint32_t cmd_data_offset;
  249. uint32_t len;
  250. };
  251. struct msm_vfe_reg_mask_info {
  252. uint32_t reg_offset;
  253. uint32_t mask;
  254. uint32_t val;
  255. };
  256. struct msm_vfe_reg_dmi_info {
  257. uint32_t hi_tbl_offset; /*Optional*/
  258. uint32_t lo_tbl_offset; /*Required*/
  259. uint32_t len;
  260. };
  261. struct msm_vfe_reg_cfg_cmd {
  262. union {
  263. struct msm_vfe_reg_rw_info rw_info;
  264. struct msm_vfe_reg_mask_info mask_info;
  265. struct msm_vfe_reg_dmi_info dmi_info;
  266. } u;
  267. enum msm_vfe_reg_cfg_type cmd_type;
  268. };
  269. enum msm_isp_buf_type {
  270. ISP_PRIVATE_BUF,
  271. ISP_SHARE_BUF,
  272. MAX_ISP_BUF_TYPE,
  273. };
  274. struct msm_isp_buf_request {
  275. uint32_t session_id;
  276. uint32_t stream_id;
  277. uint8_t num_buf;
  278. uint32_t handle;
  279. enum msm_isp_buf_type buf_type;
  280. };
  281. struct msm_isp_qbuf_info {
  282. uint32_t handle;
  283. int buf_idx;
  284. /*Only used for prepare buffer*/
  285. struct v4l2_buffer buffer;
  286. /*Only used for diverted buffer*/
  287. uint32_t dirty_buf;
  288. };
  289. struct msm_vfe_axi_src_state {
  290. enum msm_vfe_input_src input_src;
  291. uint32_t src_active;
  292. };
  293. enum msm_isp_event_idx {
  294. ISP_REG_UPDATE = 0,
  295. ISP_START_ACK = 1,
  296. ISP_STOP_ACK = 2,
  297. ISP_IRQ_VIOLATION = 3,
  298. ISP_WM_BUS_OVERFLOW = 4,
  299. ISP_STATS_OVERFLOW = 5,
  300. ISP_CAMIF_ERROR = 6,
  301. ISP_SOF = 7,
  302. ISP_EOF = 8,
  303. ISP_ERROR = 9,
  304. ISP_EVENT_MAX = 10
  305. };
  306. #define ISP_EVENT_OFFSET 8
  307. #define ISP_EVENT_BASE (V4L2_EVENT_PRIVATE_START)
  308. #define ISP_BUF_EVENT_BASE (ISP_EVENT_BASE + (1 << ISP_EVENT_OFFSET))
  309. #define ISP_STATS_EVENT_BASE (ISP_EVENT_BASE + (2 << ISP_EVENT_OFFSET))
  310. #define ISP_EVENT_REG_UPDATE (ISP_EVENT_BASE + ISP_REG_UPDATE)
  311. #define ISP_EVENT_START_ACK (ISP_EVENT_BASE + ISP_START_ACK)
  312. #define ISP_EVENT_STOP_ACK (ISP_EVENT_BASE + ISP_STOP_ACK)
  313. #define ISP_EVENT_IRQ_VIOLATION (ISP_EVENT_BASE + ISP_IRQ_VIOLATION)
  314. #define ISP_EVENT_WM_BUS_OVERFLOW (ISP_EVENT_BASE + ISP_WM_BUS_OVERFLOW)
  315. #define ISP_EVENT_STATS_OVERFLOW (ISP_EVENT_BASE + ISP_STATS_OVERFLOW)
  316. #define ISP_EVENT_CAMIF_ERROR (ISP_EVENT_BASE + ISP_CAMIF_ERROR)
  317. #define ISP_EVENT_SOF (ISP_EVENT_BASE + ISP_SOF)
  318. #define ISP_EVENT_EOF (ISP_EVENT_BASE + ISP_EOF)
  319. #define ISP_EVENT_ERROR (ISP_EVENT_BASE + ISP_ERROR)
  320. #define ISP_EVENT_BUF_DIVERT (ISP_BUF_EVENT_BASE)
  321. #define ISP_EVENT_STATS_NOTIFY (ISP_STATS_EVENT_BASE)
  322. #define ISP_EVENT_COMP_STATS_NOTIFY (ISP_EVENT_STATS_NOTIFY + MSM_ISP_STATS_MAX)
  323. /* The msm_v4l2_event_data structure should match the
  324. * v4l2_event.u.data field.
  325. * should not exceed 64 bytes */
  326. struct msm_isp_buf_event {
  327. uint32_t session_id;
  328. uint32_t stream_id;
  329. uint32_t handle;
  330. uint32_t output_format;
  331. int8_t buf_idx;
  332. };
  333. struct msm_isp_stats_event {
  334. uint32_t stats_mask; /* 4 bytes */
  335. uint8_t stats_buf_idxs[MSM_ISP_STATS_MAX]; /* 11 bytes */
  336. };
  337. struct msm_isp_stream_ack {
  338. uint32_t session_id;
  339. uint32_t stream_id;
  340. uint32_t handle;
  341. };
  342. struct msm_isp_error_info {
  343. uint32_t error_mask; /* 1 << msm_isp_event_idx */
  344. };
  345. struct msm_isp_event_data {
  346. /*Wall clock except for buffer divert events
  347. *which use monotonic clock
  348. */
  349. struct timeval timestamp;
  350. /* if pix is a src frame_id is from camif */
  351. uint32_t frame_id;
  352. #ifdef CONFIG_MSMB_CAMERA_MM
  353. enum msm_vfe_input_src input_src;
  354. #endif
  355. union {
  356. /* START_ACK, STOP_ACK */
  357. struct msm_isp_stream_ack stream_ack;
  358. /* REG_UPDATE_TRIGGER, bus over flow */
  359. #ifdef CONFIG_MSMB_CAMERA_LL
  360. enum msm_vfe_input_src input_src;
  361. #endif
  362. /* stats notify */
  363. struct msm_isp_stats_event stats;
  364. /* IRQ_VIOLATION, STATS_OVER_FLOW, WM_OVER_FLOW */
  365. uint32_t irq_status_mask;
  366. struct msm_isp_buf_event buf_done;
  367. #ifdef CONFIG_MSMB_CAMERA_MM
  368. struct msm_isp_error_info error_info;
  369. #endif
  370. } u; /* union can have max 52 bytes */
  371. };
  372. #define V4L2_PIX_FMT_QBGGR8 v4l2_fourcc('Q', 'B', 'G', '8')
  373. #define V4L2_PIX_FMT_QGBRG8 v4l2_fourcc('Q', 'G', 'B', '8')
  374. #define V4L2_PIX_FMT_QGRBG8 v4l2_fourcc('Q', 'G', 'R', '8')
  375. #define V4L2_PIX_FMT_QRGGB8 v4l2_fourcc('Q', 'R', 'G', '8')
  376. #define V4L2_PIX_FMT_QBGGR10 v4l2_fourcc('Q', 'B', 'G', '0')
  377. #define V4L2_PIX_FMT_QGBRG10 v4l2_fourcc('Q', 'G', 'B', '0')
  378. #define V4L2_PIX_FMT_QGRBG10 v4l2_fourcc('Q', 'G', 'R', '0')
  379. #define V4L2_PIX_FMT_QRGGB10 v4l2_fourcc('Q', 'R', 'G', '0')
  380. #define V4L2_PIX_FMT_QBGGR12 v4l2_fourcc('Q', 'B', 'G', '2')
  381. #define V4L2_PIX_FMT_QGBRG12 v4l2_fourcc('Q', 'G', 'B', '2')
  382. #define V4L2_PIX_FMT_QGRBG12 v4l2_fourcc('Q', 'G', 'R', '2')
  383. #define V4L2_PIX_FMT_QRGGB12 v4l2_fourcc('Q', 'R', 'G', '2')
  384. #define V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A')
  385. #define V4L2_PIX_FMT_NV14 v4l2_fourcc('N', 'V', '1', '4')
  386. #define V4L2_PIX_FMT_NV41 v4l2_fourcc('N', 'V', '4', '1')
  387. #define V4L2_PIX_FMT_NV46 v4l2_fourcc('N', 'V', '4', '6')
  388. #define V4L2_PIX_FMT_NV64 v4l2_fourcc('N', 'V', '6', '4')
  389. #define VIDIOC_MSM_VFE_REG_CFG \
  390. _IOWR('V', BASE_VIDIOC_PRIVATE, struct msm_vfe_cfg_cmd2)
  391. #define VIDIOC_MSM_ISP_REQUEST_BUF \
  392. _IOWR('V', BASE_VIDIOC_PRIVATE+1, struct msm_isp_buf_request)
  393. #define VIDIOC_MSM_ISP_ENQUEUE_BUF \
  394. _IOWR('V', BASE_VIDIOC_PRIVATE+2, struct msm_isp_qbuf_info)
  395. #define VIDIOC_MSM_ISP_RELEASE_BUF \
  396. _IOWR('V', BASE_VIDIOC_PRIVATE+3, struct msm_isp_buf_request)
  397. #define VIDIOC_MSM_ISP_REQUEST_STREAM \
  398. _IOWR('V', BASE_VIDIOC_PRIVATE+4, struct msm_vfe_axi_stream_request_cmd)
  399. #define VIDIOC_MSM_ISP_CFG_STREAM \
  400. _IOWR('V', BASE_VIDIOC_PRIVATE+5, struct msm_vfe_axi_stream_cfg_cmd)
  401. #define VIDIOC_MSM_ISP_RELEASE_STREAM \
  402. _IOWR('V', BASE_VIDIOC_PRIVATE+6, struct msm_vfe_axi_stream_release_cmd)
  403. #define VIDIOC_MSM_ISP_INPUT_CFG \
  404. _IOWR('V', BASE_VIDIOC_PRIVATE+7, struct msm_vfe_input_cfg)
  405. #define VIDIOC_MSM_ISP_SET_SRC_STATE \
  406. _IOWR('V', BASE_VIDIOC_PRIVATE+8, struct msm_vfe_axi_src_state)
  407. #define VIDIOC_MSM_ISP_REQUEST_STATS_STREAM \
  408. _IOWR('V', BASE_VIDIOC_PRIVATE+9, \
  409. struct msm_vfe_stats_stream_request_cmd)
  410. #define VIDIOC_MSM_ISP_CFG_STATS_STREAM \
  411. _IOWR('V', BASE_VIDIOC_PRIVATE+10, struct msm_vfe_stats_stream_cfg_cmd)
  412. #define VIDIOC_MSM_ISP_RELEASE_STATS_STREAM \
  413. _IOWR('V', BASE_VIDIOC_PRIVATE+11, \
  414. struct msm_vfe_stats_stream_release_cmd)
  415. #define VIDIOC_MSM_ISP_CFG_STATS_COMP_POLICY \
  416. _IOWR('V', BASE_VIDIOC_PRIVATE+12, \
  417. struct msm_vfe_stats_comp_policy_cfg)
  418. #define VIDIOC_MSM_ISP_UPDATE_STREAM \
  419. _IOWR('V', BASE_VIDIOC_PRIVATE+13, struct msm_vfe_axi_stream_update_cmd)
  420. #define VIDIOC_MSM_ISP_AXI_HALT \
  421. _IOWR('V', BASE_VIDIOC_PRIVATE+14, struct msm_vfe_axi_halt_cmd)
  422. #define VIDIOC_MSM_ISP_AXI_RESET \
  423. _IOWR('V', BASE_VIDIOC_PRIVATE+15, struct msm_vfe_axi_reset_cmd)
  424. #define VIDIOC_MSM_ISP_AXI_RESTART \
  425. _IOWR('V', BASE_VIDIOC_PRIVATE+16, struct msm_vfe_axi_restart_cmd)
  426. #endif /* __MSMB_ISP__ */