camif-regs.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * Register definition file for s3c24xx/s3c64xx SoC CAMIF driver
  3. *
  4. * Copyright (C) 2012 Sylwester Nawrocki <sylvester.nawrocki@gmail.com>
  5. * Copyright (C) 2012 Tomasz Figa <tomasz.figa@gmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef CAMIF_REGS_H_
  12. #define CAMIF_REGS_H_
  13. #include "camif-core.h"
  14. #include <media/s3c_camif.h>
  15. /*
  16. * The id argument indicates the processing path:
  17. * id = 0 - codec (FIMC C), 1 - preview (FIMC P).
  18. */
  19. /* Camera input format */
  20. #define S3C_CAMIF_REG_CISRCFMT 0x00
  21. #define CISRCFMT_ITU601_8BIT (1 << 31)
  22. #define CISRCFMT_ITU656_8BIT (0 << 31)
  23. #define CISRCFMT_ORDER422_YCBYCR (0 << 14)
  24. #define CISRCFMT_ORDER422_YCRYCB (1 << 14)
  25. #define CISRCFMT_ORDER422_CBYCRY (2 << 14)
  26. #define CISRCFMT_ORDER422_CRYCBY (3 << 14)
  27. #define CISRCFMT_ORDER422_MASK (3 << 14)
  28. #define CISRCFMT_SIZE_CAM_MASK (0x1fff << 16 | 0x1fff)
  29. /* Window offset */
  30. #define S3C_CAMIF_REG_CIWDOFST 0x04
  31. #define CIWDOFST_WINOFSEN (1 << 31)
  32. #define CIWDOFST_CLROVCOFIY (1 << 30)
  33. #define CIWDOFST_CLROVRLB_PR (1 << 28)
  34. /* #define CIWDOFST_CLROVPRFIY (1 << 27) */
  35. #define CIWDOFST_CLROVCOFICB (1 << 15)
  36. #define CIWDOFST_CLROVCOFICR (1 << 14)
  37. #define CIWDOFST_CLROVPRFICB (1 << 13)
  38. #define CIWDOFST_CLROVPRFICR (1 << 12)
  39. #define CIWDOFST_OFST_MASK (0x7ff << 16 | 0x7ff)
  40. /* Window offset 2 */
  41. #define S3C_CAMIF_REG_CIWDOFST2 0x14
  42. #define CIWDOFST2_OFST2_MASK (0xfff << 16 | 0xfff)
  43. /* Global control */
  44. #define S3C_CAMIF_REG_CIGCTRL 0x08
  45. #define CIGCTRL_SWRST (1 << 31)
  46. #define CIGCTRL_CAMRST (1 << 30)
  47. #define CIGCTRL_TESTPATTERN_NORMAL (0 << 27)
  48. #define CIGCTRL_TESTPATTERN_COLOR_BAR (1 << 27)
  49. #define CIGCTRL_TESTPATTERN_HOR_INC (2 << 27)
  50. #define CIGCTRL_TESTPATTERN_VER_INC (3 << 27)
  51. #define CIGCTRL_TESTPATTERN_MASK (3 << 27)
  52. #define CIGCTRL_INVPOLPCLK (1 << 26)
  53. #define CIGCTRL_INVPOLVSYNC (1 << 25)
  54. #define CIGCTRL_INVPOLHREF (1 << 24)
  55. #define CIGCTRL_IRQ_OVFEN (1 << 22)
  56. #define CIGCTRL_HREF_MASK (1 << 21)
  57. #define CIGCTRL_IRQ_LEVEL (1 << 20)
  58. /* IRQ_CLR_C, IRQ_CLR_P */
  59. #define CIGCTRL_IRQ_CLR(id) (1 << (19 - (id)))
  60. #define CIGCTRL_FIELDMODE (1 << 2)
  61. #define CIGCTRL_INVPOLFIELD (1 << 1)
  62. #define CIGCTRL_CAM_INTERLACE (1 << 0)
  63. /* Y DMA output frame start address. n = 0..3. */
  64. #define S3C_CAMIF_REG_CIYSA(id, n) (0x18 + (id) * 0x54 + (n) * 4)
  65. /* Cb plane output DMA start address. n = 0..3. Only codec path. */
  66. #define S3C_CAMIF_REG_CICBSA(id, n) (0x28 + (id) * 0x54 + (n) * 4)
  67. /* Cr plane output DMA start address. n = 0..3. Only codec path. */
  68. #define S3C_CAMIF_REG_CICRSA(id, n) (0x38 + (id) * 0x54 + (n) * 4)
  69. /* CICOTRGFMT, CIPRTRGFMT - Target format */
  70. #define S3C_CAMIF_REG_CITRGFMT(id, _offs) (0x48 + (id) * (0x34 + (_offs)))
  71. #define CITRGFMT_IN422 (1 << 31) /* only for s3c24xx */
  72. #define CITRGFMT_OUT422 (1 << 30) /* only for s3c24xx */
  73. #define CITRGFMT_OUTFORMAT_YCBCR420 (0 << 29) /* only for s3c6410 */
  74. #define CITRGFMT_OUTFORMAT_YCBCR422 (1 << 29) /* only for s3c6410 */
  75. #define CITRGFMT_OUTFORMAT_YCBCR422I (2 << 29) /* only for s3c6410 */
  76. #define CITRGFMT_OUTFORMAT_RGB (3 << 29) /* only for s3c6410 */
  77. #define CITRGFMT_OUTFORMAT_MASK (3 << 29) /* only for s3c6410 */
  78. #define CITRGFMT_TARGETHSIZE(x) ((x) << 16)
  79. #define CITRGFMT_FLIP_NORMAL (0 << 14)
  80. #define CITRGFMT_FLIP_X_MIRROR (1 << 14)
  81. #define CITRGFMT_FLIP_Y_MIRROR (2 << 14)
  82. #define CITRGFMT_FLIP_180 (3 << 14)
  83. #define CITRGFMT_FLIP_MASK (3 << 14)
  84. /* Preview path only */
  85. #define CITRGFMT_ROT90_PR (1 << 13)
  86. #define CITRGFMT_TARGETVSIZE(x) ((x) << 0)
  87. #define CITRGFMT_TARGETSIZE_MASK ((0x1fff << 16) | 0x1fff)
  88. /* CICOCTRL, CIPRCTRL. Output DMA control. */
  89. #define S3C_CAMIF_REG_CICTRL(id, _offs) (0x4c + (id) * (0x34 + (_offs)))
  90. #define CICTRL_BURST_MASK (0xfffff << 4)
  91. /* xBURSTn - 5-bits width */
  92. #define CICTRL_YBURST1(x) ((x) << 19)
  93. #define CICTRL_YBURST2(x) ((x) << 14)
  94. #define CICTRL_RGBBURST1(x) ((x) << 19)
  95. #define CICTRL_RGBBURST2(x) ((x) << 14)
  96. #define CICTRL_CBURST1(x) ((x) << 9)
  97. #define CICTRL_CBURST2(x) ((x) << 4)
  98. #define CICTRL_LASTIRQ_ENABLE (1 << 2)
  99. #define CICTRL_ORDER422_MASK (3 << 0)
  100. /* CICOSCPRERATIO, CIPRSCPRERATIO. Pre-scaler control 1. */
  101. #define S3C_CAMIF_REG_CISCPRERATIO(id, _offs) (0x50 + (id) * (0x34 + (_offs)))
  102. /* CICOSCPREDST, CIPRSCPREDST. Pre-scaler control 2. */
  103. #define S3C_CAMIF_REG_CISCPREDST(id, _offs) (0x54 + (id) * (0x34 + (_offs)))
  104. /* CICOSCCTRL, CIPRSCCTRL. Main scaler control. */
  105. #define S3C_CAMIF_REG_CISCCTRL(id, _offs) (0x58 + (id) * (0x34 + (_offs)))
  106. #define CISCCTRL_SCALERBYPASS (1 << 31)
  107. /* s3c244x preview path only, s3c64xx both */
  108. #define CIPRSCCTRL_SAMPLE (1 << 31)
  109. /* 0 - 16-bit RGB, 1 - 24-bit RGB */
  110. #define CIPRSCCTRL_RGB_FORMAT_24BIT (1 << 30) /* only for s3c244x */
  111. #define CIPRSCCTRL_SCALEUP_H (1 << 29) /* only for s3c244x */
  112. #define CIPRSCCTRL_SCALEUP_V (1 << 28) /* only for s3c244x */
  113. /* s3c64xx */
  114. #define CISCCTRL_SCALEUP_H (1 << 30)
  115. #define CISCCTRL_SCALEUP_V (1 << 29)
  116. #define CISCCTRL_SCALEUP_MASK (0x3 << 29)
  117. #define CISCCTRL_CSCR2Y_WIDE (1 << 28)
  118. #define CISCCTRL_CSCY2R_WIDE (1 << 27)
  119. #define CISCCTRL_LCDPATHEN_FIFO (1 << 26)
  120. #define CISCCTRL_INTERLACE (1 << 25)
  121. #define CISCCTRL_SCALERSTART (1 << 15)
  122. #define CISCCTRL_INRGB_FMT_RGB565 (0 << 13)
  123. #define CISCCTRL_INRGB_FMT_RGB666 (1 << 13)
  124. #define CISCCTRL_INRGB_FMT_RGB888 (2 << 13)
  125. #define CISCCTRL_INRGB_FMT_MASK (3 << 13)
  126. #define CISCCTRL_OUTRGB_FMT_RGB565 (0 << 11)
  127. #define CISCCTRL_OUTRGB_FMT_RGB666 (1 << 11)
  128. #define CISCCTRL_OUTRGB_FMT_RGB888 (2 << 11)
  129. #define CISCCTRL_OUTRGB_FMT_MASK (3 << 11)
  130. #define CISCCTRL_EXTRGB_EXTENSION (1 << 10)
  131. #define CISCCTRL_ONE2ONE (1 << 9)
  132. #define CISCCTRL_MAIN_RATIO_MASK (0x1ff << 16 | 0x1ff)
  133. /* CICOTAREA, CIPRTAREA. Target area for DMA (Hsize x Vsize). */
  134. #define S3C_CAMIF_REG_CITAREA(id, _offs) (0x5c + (id) * (0x34 + (_offs)))
  135. #define CITAREA_MASK 0xfffffff
  136. /* Codec (id = 0) or preview (id = 1) path status. */
  137. #define S3C_CAMIF_REG_CISTATUS(id, _offs) (0x64 + (id) * (0x34 + (_offs)))
  138. #define CISTATUS_OVFIY_STATUS (1 << 31)
  139. #define CISTATUS_OVFICB_STATUS (1 << 30)
  140. #define CISTATUS_OVFICR_STATUS (1 << 29)
  141. #define CISTATUS_OVF_MASK (0x7 << 29)
  142. #define CIPRSTATUS_OVF_MASK (0x3 << 30)
  143. #define CISTATUS_VSYNC_STATUS (1 << 28)
  144. #define CISTATUS_FRAMECNT_MASK (3 << 26)
  145. #define CISTATUS_FRAMECNT(__reg) (((__reg) >> 26) & 0x3)
  146. #define CISTATUS_WINOFSTEN_STATUS (1 << 25)
  147. #define CISTATUS_IMGCPTEN_STATUS (1 << 22)
  148. #define CISTATUS_IMGCPTENSC_STATUS (1 << 21)
  149. #define CISTATUS_VSYNC_A_STATUS (1 << 20)
  150. #define CISTATUS_FRAMEEND_STATUS (1 << 19) /* 17 on s3c64xx */
  151. /* Image capture enable */
  152. #define S3C_CAMIF_REG_CIIMGCPT(_offs) (0xa0 + (_offs))
  153. #define CIIMGCPT_IMGCPTEN (1 << 31)
  154. #define CIIMGCPT_IMGCPTEN_SC(id) (1 << (30 - (id)))
  155. /* Frame control: 1 - one-shot, 0 - free run */
  156. #define CIIMGCPT_CPT_FREN_ENABLE(id) (1 << (25 - (id)))
  157. #define CIIMGCPT_CPT_FRMOD_ENABLE (0 << 18)
  158. #define CIIMGCPT_CPT_FRMOD_CNT (1 << 18)
  159. /* Capture sequence */
  160. #define S3C_CAMIF_REG_CICPTSEQ 0xc4
  161. /* Image effects */
  162. #define S3C_CAMIF_REG_CIIMGEFF(_offs) (0xb0 + (_offs))
  163. #define CIIMGEFF_IE_ENABLE(id) (1 << (30 + (id)))
  164. #define CIIMGEFF_IE_ENABLE_MASK (3 << 30)
  165. /* Image effect: 1 - after scaler, 0 - before scaler */
  166. #define CIIMGEFF_IE_AFTER_SC (1 << 29)
  167. #define CIIMGEFF_FIN_MASK (7 << 26)
  168. #define CIIMGEFF_FIN_BYPASS (0 << 26)
  169. #define CIIMGEFF_FIN_ARBITRARY (1 << 26)
  170. #define CIIMGEFF_FIN_NEGATIVE (2 << 26)
  171. #define CIIMGEFF_FIN_ARTFREEZE (3 << 26)
  172. #define CIIMGEFF_FIN_EMBOSSING (4 << 26)
  173. #define CIIMGEFF_FIN_SILHOUETTE (5 << 26)
  174. #define CIIMGEFF_PAT_CBCR_MASK ((0xff << 13) | 0xff)
  175. #define CIIMGEFF_PAT_CB(x) ((x) << 13)
  176. #define CIIMGEFF_PAT_CR(x) (x)
  177. /* MSCOY0SA, MSPRY0SA. Y/Cb/Cr frame start address for input DMA. */
  178. #define S3C_CAMIF_REG_MSY0SA(id) (0xd4 + ((id) * 0x2c))
  179. #define S3C_CAMIF_REG_MSCB0SA(id) (0xd8 + ((id) * 0x2c))
  180. #define S3C_CAMIF_REG_MSCR0SA(id) (0xdc + ((id) * 0x2c))
  181. /* MSCOY0END, MSCOY0END. Y/Cb/Cr frame end address for input DMA. */
  182. #define S3C_CAMIF_REG_MSY0END(id) (0xe0 + ((id) * 0x2c))
  183. #define S3C_CAMIF_REG_MSCB0END(id) (0xe4 + ((id) * 0x2c))
  184. #define S3C_CAMIF_REG_MSCR0END(id) (0xe8 + ((id) * 0x2c))
  185. /* MSPRYOFF, MSPRYOFF. Y/Cb/Cr offset. n: 0 - codec, 1 - preview. */
  186. #define S3C_CAMIF_REG_MSYOFF(id) (0x118 + ((id) * 0x2c))
  187. #define S3C_CAMIF_REG_MSCBOFF(id) (0x11c + ((id) * 0x2c))
  188. #define S3C_CAMIF_REG_MSCROFF(id) (0x120 + ((id) * 0x2c))
  189. /* Real input DMA data size. n = 0 - codec, 1 - preview. */
  190. #define S3C_CAMIF_REG_MSWIDTH(id) (0xf8 + (id) * 0x2c)
  191. #define AUTOLOAD_ENABLE (1 << 31)
  192. #define ADDR_CH_DIS (1 << 30)
  193. #define MSHEIGHT(x) (((x) & 0x3ff) << 16)
  194. #define MSWIDTH(x) ((x) & 0x3ff)
  195. /* Input DMA control. n = 0 - codec, 1 - preview */
  196. #define S3C_CAMIF_REG_MSCTRL(id) (0xfc + (id) * 0x2c)
  197. #define MSCTRL_ORDER422_M_YCBYCR (0 << 4)
  198. #define MSCTRL_ORDER422_M_YCRYCB (1 << 4)
  199. #define MSCTRL_ORDER422_M_CBYCRY (2 << 4)
  200. #define MSCTRL_ORDER422_M_CRYCBY (3 << 4)
  201. /* 0 - camera, 1 - DMA */
  202. #define MSCTRL_SEL_DMA_CAM (1 << 3)
  203. #define MSCTRL_INFORMAT_M_YCBCR420 (0 << 1)
  204. #define MSCTRL_INFORMAT_M_YCBCR422 (1 << 1)
  205. #define MSCTRL_INFORMAT_M_YCBCR422I (2 << 1)
  206. #define MSCTRL_INFORMAT_M_RGB (3 << 1)
  207. #define MSCTRL_ENVID_M (1 << 0)
  208. /* CICOSCOSY, CIPRSCOSY. Scan line Y/Cb/Cr offset. */
  209. #define S3C_CAMIF_REG_CISSY(id) (0x12c + (id) * 0x0c)
  210. #define S3C_CAMIF_REG_CISSCB(id) (0x130 + (id) * 0x0c)
  211. #define S3C_CAMIF_REG_CISSCR(id) (0x134 + (id) * 0x0c)
  212. #define S3C_CISS_OFFS_INITIAL(x) ((x) << 16)
  213. #define S3C_CISS_OFFS_LINE(x) ((x) << 0)
  214. /* ------------------------------------------------------------------ */
  215. void camif_hw_reset(struct camif_dev *camif);
  216. void camif_hw_clear_pending_irq(struct camif_vp *vp);
  217. void camif_hw_clear_fifo_overflow(struct camif_vp *vp);
  218. void camif_hw_set_lastirq(struct camif_vp *vp, int enable);
  219. void camif_hw_set_input_path(struct camif_vp *vp);
  220. void camif_hw_enable_scaler(struct camif_vp *vp, bool on);
  221. void camif_hw_enable_capture(struct camif_vp *vp);
  222. void camif_hw_disable_capture(struct camif_vp *vp);
  223. void camif_hw_set_camera_bus(struct camif_dev *camif);
  224. void camif_hw_set_source_format(struct camif_dev *camif);
  225. void camif_hw_set_camera_crop(struct camif_dev *camif);
  226. void camif_hw_set_scaler(struct camif_vp *vp);
  227. void camif_hw_set_flip(struct camif_vp *vp);
  228. void camif_hw_set_output_dma(struct camif_vp *vp);
  229. void camif_hw_set_target_format(struct camif_vp *vp);
  230. void camif_hw_set_test_pattern(struct camif_dev *camif, unsigned int pattern);
  231. void camif_hw_set_effect(struct camif_dev *camif, unsigned int effect,
  232. unsigned int cr, unsigned int cb);
  233. void camif_hw_set_output_addr(struct camif_vp *vp, struct camif_addr *paddr,
  234. int index);
  235. void camif_hw_dump_regs(struct camif_dev *camif, const char *label);
  236. static inline u32 camif_hw_get_status(struct camif_vp *vp)
  237. {
  238. return readl(vp->camif->io_base + S3C_CAMIF_REG_CISTATUS(vp->id,
  239. vp->offset));
  240. }
  241. #endif /* CAMIF_REGS_H_ */