m5mols_reg.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /*
  2. * Register map for M-5MOLS 8M Pixel camera sensor with ISP
  3. *
  4. * Copyright (C) 2011 Samsung Electronics Co., Ltd.
  5. * Author: HeungJun Kim <riverful.kim@samsung.com>
  6. *
  7. * Copyright (C) 2009 Samsung Electronics Co., Ltd.
  8. * Author: Dongsoo Nathaniel Kim <dongsoo45.kim@samsung.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. */
  15. #ifndef M5MOLS_REG_H
  16. #define M5MOLS_REG_H
  17. #define M5MOLS_I2C_MAX_SIZE 4
  18. #define M5MOLS_BYTE_READ 0x01
  19. #define M5MOLS_BYTE_WRITE 0x02
  20. #define I2C_CATEGORY(__cat) ((__cat >> 16) & 0xff)
  21. #define I2C_COMMAND(__comm) ((__comm >> 8) & 0xff)
  22. #define I2C_SIZE(__reg_s) ((__reg_s) & 0xff)
  23. #define I2C_REG(__cat, __cmd, __reg_s) ((__cat << 16) | (__cmd << 8) | __reg_s)
  24. /*
  25. * Category section register
  26. *
  27. * The category means set including relevant command of M-5MOLS.
  28. */
  29. #define CAT_SYSTEM 0x00
  30. #define CAT_PARAM 0x01
  31. #define CAT_MONITOR 0x02
  32. #define CAT_AE 0x03
  33. #define CAT_WB 0x06
  34. #define CAT_EXIF 0x07
  35. #define CAT_FD 0x09
  36. #define CAT_LENS 0x0a
  37. #define CAT_CAPT_PARM 0x0b
  38. #define CAT_CAPT_CTRL 0x0c
  39. #define CAT_FLASH 0x0f /* related to FW, revisions, booting */
  40. /*
  41. * Category 0 - SYSTEM mode
  42. *
  43. * The SYSTEM mode in the M-5MOLS means area available to handle with the whole
  44. * & all-round system of sensor. It deals with version/interrupt/setting mode &
  45. * even sensor's status. Especially, the M-5MOLS sensor with ISP varies by
  46. * packaging & manufacturer, even the customer and project code. And the
  47. * function details may vary among them. The version information helps to
  48. * determine what methods shall be used in the driver.
  49. *
  50. * There is many registers between customer version address and awb one. For
  51. * more specific contents, see definition if file m5mols.h.
  52. */
  53. #define SYSTEM_VER_CUSTOMER I2C_REG(CAT_SYSTEM, 0x00, 1)
  54. #define SYSTEM_VER_PROJECT I2C_REG(CAT_SYSTEM, 0x01, 1)
  55. #define SYSTEM_VER_FIRMWARE I2C_REG(CAT_SYSTEM, 0x02, 2)
  56. #define SYSTEM_VER_HARDWARE I2C_REG(CAT_SYSTEM, 0x04, 2)
  57. #define SYSTEM_VER_PARAMETER I2C_REG(CAT_SYSTEM, 0x06, 2)
  58. #define SYSTEM_VER_AWB I2C_REG(CAT_SYSTEM, 0x08, 2)
  59. #define SYSTEM_SYSMODE I2C_REG(CAT_SYSTEM, 0x0b, 1)
  60. #define REG_SYSINIT 0x00 /* SYSTEM mode */
  61. #define REG_PARAMETER 0x01 /* PARAMETER mode */
  62. #define REG_MONITOR 0x02 /* MONITOR mode */
  63. #define REG_CAPTURE 0x03 /* CAPTURE mode */
  64. #define SYSTEM_CMD(__cmd) I2C_REG(CAT_SYSTEM, cmd, 1)
  65. #define SYSTEM_VER_STRING I2C_REG(CAT_SYSTEM, 0x0a, 1)
  66. #define REG_SAMSUNG_ELECTRO "SE" /* Samsung Electro-Mechanics */
  67. #define REG_SAMSUNG_OPTICS "OP" /* Samsung Fiber-Optics */
  68. #define REG_SAMSUNG_TECHWIN "TB" /* Samsung Techwin */
  69. /* SYSTEM mode status */
  70. #define SYSTEM_STATUS I2C_REG(CAT_SYSTEM, 0x0c, 1)
  71. /* Interrupt pending register */
  72. #define SYSTEM_INT_FACTOR I2C_REG(CAT_SYSTEM, 0x10, 1)
  73. /* interrupt enable register */
  74. #define SYSTEM_INT_ENABLE I2C_REG(CAT_SYSTEM, 0x11, 1)
  75. #define REG_INT_MODE (1 << 0)
  76. #define REG_INT_AF (1 << 1)
  77. #define REG_INT_ZOOM (1 << 2)
  78. #define REG_INT_CAPTURE (1 << 3)
  79. #define REG_INT_FRAMESYNC (1 << 4)
  80. #define REG_INT_FD (1 << 5)
  81. #define REG_INT_LENS_INIT (1 << 6)
  82. #define REG_INT_SOUND (1 << 7)
  83. #define REG_INT_MASK 0x0f
  84. /*
  85. * category 1 - PARAMETER mode
  86. *
  87. * This category supports function of camera features of M-5MOLS. It means we
  88. * can handle with preview(MONITOR) resolution size/frame per second/interface
  89. * between the sensor and the Application Processor/even the image effect.
  90. */
  91. /* Resolution in the MONITOR mode */
  92. #define PARM_MON_SIZE I2C_REG(CAT_PARAM, 0x01, 1)
  93. /* Frame rate */
  94. #define PARM_MON_FPS I2C_REG(CAT_PARAM, 0x02, 1)
  95. #define REG_FPS_30 0x02
  96. /* Video bus between the sensor and a host processor */
  97. #define PARM_INTERFACE I2C_REG(CAT_PARAM, 0x00, 1)
  98. #define REG_INTERFACE_MIPI 0x02
  99. /* Image effects */
  100. #define PARM_EFFECT I2C_REG(CAT_PARAM, 0x0b, 1)
  101. #define REG_EFFECT_OFF 0x00
  102. #define REG_EFFECT_NEGA 0x01
  103. #define REG_EFFECT_EMBOSS 0x06
  104. #define REG_EFFECT_OUTLINE 0x07
  105. #define REG_EFFECT_WATERCOLOR 0x08
  106. /*
  107. * Category 2 - MONITOR mode
  108. *
  109. * The MONITOR mode is same as preview mode as we said. The M-5MOLS has another
  110. * mode named "Preview", but this preview mode is used at the case specific
  111. * vider-recording mode. This mmode supports only YUYV format. On the other
  112. * hand, the JPEG & RAW formats is supports by CAPTURE mode. And, there are
  113. * another options like zoom/color effect(different with effect in PARAMETER
  114. * mode)/anti hand shaking algorithm.
  115. */
  116. /* Target digital zoom position */
  117. #define MON_ZOOM I2C_REG(CAT_MONITOR, 0x01, 1)
  118. /* CR value for color effect */
  119. #define MON_CFIXR I2C_REG(CAT_MONITOR, 0x0a, 1)
  120. /* CB value for color effect */
  121. #define MON_CFIXB I2C_REG(CAT_MONITOR, 0x09, 1)
  122. #define REG_CFIXB_SEPIA 0xd8
  123. #define REG_CFIXR_SEPIA 0x18
  124. #define MON_EFFECT I2C_REG(CAT_MONITOR, 0x0b, 1)
  125. #define REG_COLOR_EFFECT_OFF 0x00
  126. #define REG_COLOR_EFFECT_ON 0x01
  127. /* Chroma enable */
  128. #define MON_CHROMA_EN I2C_REG(CAT_MONITOR, 0x10, 1)
  129. /* Chroma level */
  130. #define MON_CHROMA_LVL I2C_REG(CAT_MONITOR, 0x0f, 1)
  131. #define REG_CHROMA_OFF 0x00
  132. #define REG_CHROMA_ON 0x01
  133. /* Sharpness on/off */
  134. #define MON_EDGE_EN I2C_REG(CAT_MONITOR, 0x12, 1)
  135. /* Sharpness level */
  136. #define MON_EDGE_LVL I2C_REG(CAT_MONITOR, 0x11, 1)
  137. #define REG_EDGE_OFF 0x00
  138. #define REG_EDGE_ON 0x01
  139. /* Set color tone (contrast) */
  140. #define MON_TONE_CTL I2C_REG(CAT_MONITOR, 0x25, 1)
  141. /*
  142. * Category 3 - Auto Exposure
  143. *
  144. * The M-5MOLS exposure capbility is detailed as which is similar to digital
  145. * camera. This category supports AE locking/various AE mode(range of exposure)
  146. * /ISO/flickering/EV bias/shutter/meteoring, and anything else. And the
  147. * maximum/minimum exposure gain value depending on M-5MOLS firmware, may be
  148. * different. So, this category also provide getting the max/min values. And,
  149. * each MONITOR and CAPTURE mode has each gain/shutter/max exposure values.
  150. */
  151. /* Auto Exposure locking */
  152. #define AE_LOCK I2C_REG(CAT_AE, 0x00, 1)
  153. #define REG_AE_UNLOCK 0x00
  154. #define REG_AE_LOCK 0x01
  155. /* Auto Exposure algorithm mode */
  156. #define AE_MODE I2C_REG(CAT_AE, 0x01, 1)
  157. #define REG_AE_OFF 0x00 /* AE off */
  158. #define REG_AE_ALL 0x01 /* calc AE in all block integral */
  159. #define REG_AE_CENTER 0x03 /* calc AE in center weighted */
  160. #define REG_AE_SPOT 0x06 /* calc AE in specific spot */
  161. #define AE_ISO I2C_REG(CAT_AE, 0x05, 1)
  162. #define REG_ISO_AUTO 0x00
  163. #define REG_ISO_50 0x01
  164. #define REG_ISO_100 0x02
  165. #define REG_ISO_200 0x03
  166. #define REG_ISO_400 0x04
  167. #define REG_ISO_800 0x05
  168. /* EV (scenemode) preset for MONITOR */
  169. #define AE_EV_PRESET_MONITOR I2C_REG(CAT_AE, 0x0a, 1)
  170. /* EV (scenemode) preset for CAPTURE */
  171. #define AE_EV_PRESET_CAPTURE I2C_REG(CAT_AE, 0x0b, 1)
  172. #define REG_SCENE_NORMAL 0x00
  173. #define REG_SCENE_PORTRAIT 0x01
  174. #define REG_SCENE_LANDSCAPE 0x02
  175. #define REG_SCENE_SPORTS 0x03
  176. #define REG_SCENE_PARTY_INDOOR 0x04
  177. #define REG_SCENE_BEACH_SNOW 0x05
  178. #define REG_SCENE_SUNSET 0x06
  179. #define REG_SCENE_DAWN_DUSK 0x07
  180. #define REG_SCENE_FALL 0x08
  181. #define REG_SCENE_NIGHT 0x09
  182. #define REG_SCENE_AGAINST_LIGHT 0x0a
  183. #define REG_SCENE_FIRE 0x0b
  184. #define REG_SCENE_TEXT 0x0c
  185. #define REG_SCENE_CANDLE 0x0d
  186. /* Manual gain in MONITOR mode */
  187. #define AE_MAN_GAIN_MON I2C_REG(CAT_AE, 0x12, 2)
  188. /* Maximum gain in MONITOR mode */
  189. #define AE_MAX_GAIN_MON I2C_REG(CAT_AE, 0x1a, 2)
  190. /* Manual gain in CAPTURE mode */
  191. #define AE_MAN_GAIN_CAP I2C_REG(CAT_AE, 0x26, 2)
  192. #define AE_INDEX I2C_REG(CAT_AE, 0x38, 1)
  193. #define REG_AE_INDEX_20_NEG 0x00
  194. #define REG_AE_INDEX_15_NEG 0x01
  195. #define REG_AE_INDEX_10_NEG 0x02
  196. #define REG_AE_INDEX_05_NEG 0x03
  197. #define REG_AE_INDEX_00 0x04
  198. #define REG_AE_INDEX_05_POS 0x05
  199. #define REG_AE_INDEX_10_POS 0x06
  200. #define REG_AE_INDEX_15_POS 0x07
  201. #define REG_AE_INDEX_20_POS 0x08
  202. /*
  203. * Category 6 - White Balance
  204. */
  205. /* Auto Whitebalance locking */
  206. #define AWB_LOCK I2C_REG(CAT_WB, 0x00, 1)
  207. #define REG_AWB_UNLOCK 0x00
  208. #define REG_AWB_LOCK 0x01
  209. #define AWB_MODE I2C_REG(CAT_WB, 0x02, 1)
  210. #define REG_AWB_AUTO 0x01 /* AWB off */
  211. #define REG_AWB_PRESET 0x02 /* AWB preset */
  212. /* Manual WB (preset) */
  213. #define AWB_MANUAL I2C_REG(CAT_WB, 0x03, 1)
  214. #define REG_AWB_INCANDESCENT 0x01
  215. #define REG_AWB_FLUORESCENT_1 0x02
  216. #define REG_AWB_FLUORESCENT_2 0x03
  217. #define REG_AWB_DAYLIGHT 0x04
  218. #define REG_AWB_CLOUDY 0x05
  219. #define REG_AWB_SHADE 0x06
  220. #define REG_AWB_HORIZON 0x07
  221. #define REG_AWB_LEDLIGHT 0x09
  222. /*
  223. * Category 7 - EXIF information
  224. */
  225. #define EXIF_INFO_EXPTIME_NU I2C_REG(CAT_EXIF, 0x00, 4)
  226. #define EXIF_INFO_EXPTIME_DE I2C_REG(CAT_EXIF, 0x04, 4)
  227. #define EXIF_INFO_TV_NU I2C_REG(CAT_EXIF, 0x08, 4)
  228. #define EXIF_INFO_TV_DE I2C_REG(CAT_EXIF, 0x0c, 4)
  229. #define EXIF_INFO_AV_NU I2C_REG(CAT_EXIF, 0x10, 4)
  230. #define EXIF_INFO_AV_DE I2C_REG(CAT_EXIF, 0x14, 4)
  231. #define EXIF_INFO_BV_NU I2C_REG(CAT_EXIF, 0x18, 4)
  232. #define EXIF_INFO_BV_DE I2C_REG(CAT_EXIF, 0x1c, 4)
  233. #define EXIF_INFO_EBV_NU I2C_REG(CAT_EXIF, 0x20, 4)
  234. #define EXIF_INFO_EBV_DE I2C_REG(CAT_EXIF, 0x24, 4)
  235. #define EXIF_INFO_ISO I2C_REG(CAT_EXIF, 0x28, 2)
  236. #define EXIF_INFO_FLASH I2C_REG(CAT_EXIF, 0x2a, 2)
  237. #define EXIF_INFO_SDR I2C_REG(CAT_EXIF, 0x2c, 2)
  238. #define EXIF_INFO_QVAL I2C_REG(CAT_EXIF, 0x2e, 2)
  239. /*
  240. * Category 9 - Face Detection
  241. */
  242. #define FD_CTL I2C_REG(CAT_FD, 0x00, 1)
  243. #define BIT_FD_EN 0
  244. #define BIT_FD_DRAW_FACE_FRAME 4
  245. #define BIT_FD_DRAW_SMILE_LVL 6
  246. #define REG_FD(shift) (1 << shift)
  247. #define REG_FD_OFF 0x0
  248. /*
  249. * Category A - Lens Parameter
  250. */
  251. #define AF_MODE I2C_REG(CAT_LENS, 0x01, 1)
  252. #define REG_AF_NORMAL 0x00 /* Normal AF, one time */
  253. #define REG_AF_MACRO 0x01 /* Macro AF, one time */
  254. #define REG_AF_POWEROFF 0x07
  255. #define AF_EXECUTE I2C_REG(CAT_LENS, 0x02, 1)
  256. #define REG_AF_STOP 0x00
  257. #define REG_AF_EXE_AUTO 0x01
  258. #define REG_AF_EXE_CAF 0x02
  259. #define AF_STATUS I2C_REG(CAT_LENS, 0x03, 1)
  260. #define REG_AF_FAIL 0x00
  261. #define REG_AF_SUCCESS 0x02
  262. #define REG_AF_IDLE 0x04
  263. #define REG_AF_BUSY 0x05
  264. #define AF_VERSION I2C_REG(CAT_LENS, 0x0a, 1)
  265. /*
  266. * Category B - CAPTURE Parameter
  267. */
  268. #define CAPP_YUVOUT_MAIN I2C_REG(CAT_CAPT_PARM, 0x00, 1)
  269. #define REG_YUV422 0x00
  270. #define REG_BAYER10 0x05
  271. #define REG_BAYER8 0x06
  272. #define REG_JPEG 0x10
  273. #define CAPP_MAIN_IMAGE_SIZE I2C_REG(CAT_CAPT_PARM, 0x01, 1)
  274. #define CAPP_JPEG_SIZE_MAX I2C_REG(CAT_CAPT_PARM, 0x0f, 4)
  275. #define CAPP_JPEG_RATIO I2C_REG(CAT_CAPT_PARM, 0x17, 1)
  276. #define CAPP_MCC_MODE I2C_REG(CAT_CAPT_PARM, 0x1d, 1)
  277. #define REG_MCC_OFF 0x00
  278. #define REG_MCC_NORMAL 0x01
  279. #define CAPP_WDR_EN I2C_REG(CAT_CAPT_PARM, 0x2c, 1)
  280. #define REG_WDR_OFF 0x00
  281. #define REG_WDR_ON 0x01
  282. #define REG_WDR_AUTO 0x02
  283. #define CAPP_LIGHT_CTRL I2C_REG(CAT_CAPT_PARM, 0x40, 1)
  284. #define REG_LIGHT_OFF 0x00
  285. #define REG_LIGHT_ON 0x01
  286. #define REG_LIGHT_AUTO 0x02
  287. #define CAPP_FLASH_CTRL I2C_REG(CAT_CAPT_PARM, 0x41, 1)
  288. #define REG_FLASH_OFF 0x00
  289. #define REG_FLASH_ON 0x01
  290. #define REG_FLASH_AUTO 0x02
  291. /*
  292. * Category C - CAPTURE Control
  293. */
  294. #define CAPC_MODE I2C_REG(CAT_CAPT_CTRL, 0x00, 1)
  295. #define REG_CAP_NONE 0x00
  296. #define REG_CAP_ANTI_SHAKE 0x02
  297. /* Select single- or multi-shot capture */
  298. #define CAPC_SEL_FRAME I2C_REG(CAT_CAPT_CTRL, 0x06, 1)
  299. #define CAPC_START I2C_REG(CAT_CAPT_CTRL, 0x09, 1)
  300. #define REG_CAP_START_MAIN 0x01
  301. #define REG_CAP_START_THUMB 0x03
  302. #define CAPC_IMAGE_SIZE I2C_REG(CAT_CAPT_CTRL, 0x0d, 4)
  303. #define CAPC_THUMB_SIZE I2C_REG(CAT_CAPT_CTRL, 0x11, 4)
  304. /*
  305. * Category F - Flash
  306. *
  307. * This mode provides functions about internal flash stuff and system startup.
  308. */
  309. /* Starts internal ARM core booting after power-up */
  310. #define FLASH_CAM_START I2C_REG(CAT_FLASH, 0x12, 1)
  311. #define REG_START_ARM_BOOT 0x01 /* write value */
  312. #define REG_IN_FLASH_MODE 0x00 /* read value */
  313. #endif /* M5MOLS_REG_H */