omap3isp.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. .. include:: <isonum.txt>
  2. OMAP 3 Image Signal Processor (ISP) driver
  3. ==========================================
  4. Copyright |copy| 2010 Nokia Corporation
  5. Copyright |copy| 2009 Texas Instruments, Inc.
  6. Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
  7. Sakari Ailus <sakari.ailus@iki.fi>, David Cohen <dacohen@gmail.com>
  8. Introduction
  9. ------------
  10. This file documents the Texas Instruments OMAP 3 Image Signal Processor (ISP)
  11. driver located under drivers/media/platform/omap3isp. The original driver was
  12. written by Texas Instruments but since that it has been rewritten (twice) at
  13. Nokia.
  14. The driver has been successfully used on the following versions of OMAP 3:
  15. - 3430
  16. - 3530
  17. - 3630
  18. The driver implements V4L2, Media controller and v4l2_subdev interfaces.
  19. Sensor, lens and flash drivers using the v4l2_subdev interface in the kernel
  20. are supported.
  21. Split to subdevs
  22. ----------------
  23. The OMAP 3 ISP is split into V4L2 subdevs, each of the blocks inside the ISP
  24. having one subdev to represent it. Each of the subdevs provide a V4L2 subdev
  25. interface to userspace.
  26. - OMAP3 ISP CCP2
  27. - OMAP3 ISP CSI2a
  28. - OMAP3 ISP CCDC
  29. - OMAP3 ISP preview
  30. - OMAP3 ISP resizer
  31. - OMAP3 ISP AEWB
  32. - OMAP3 ISP AF
  33. - OMAP3 ISP histogram
  34. Each possible link in the ISP is modelled by a link in the Media controller
  35. interface. For an example program see [#f2]_.
  36. Controlling the OMAP 3 ISP
  37. --------------------------
  38. In general, the settings given to the OMAP 3 ISP take effect at the beginning
  39. of the following frame. This is done when the module becomes idle during the
  40. vertical blanking period on the sensor. In memory-to-memory operation the pipe
  41. is run one frame at a time. Applying the settings is done between the frames.
  42. All the blocks in the ISP, excluding the CSI-2 and possibly the CCP2 receiver,
  43. insist on receiving complete frames. Sensors must thus never send the ISP
  44. partial frames.
  45. Autoidle does have issues with some ISP blocks on the 3430, at least.
  46. Autoidle is only enabled on 3630 when the omap3isp module parameter autoidle
  47. is non-zero.
  48. Events
  49. ------
  50. The OMAP 3 ISP driver does support the V4L2 event interface on CCDC and
  51. statistics (AEWB, AF and histogram) subdevs.
  52. The CCDC subdev produces V4L2_EVENT_FRAME_SYNC type event on HS_VS
  53. interrupt which is used to signal frame start. Earlier version of this
  54. driver used V4L2_EVENT_OMAP3ISP_HS_VS for this purpose. The event is
  55. triggered exactly when the reception of the first line of the frame starts
  56. in the CCDC module. The event can be subscribed on the CCDC subdev.
  57. (When using parallel interface one must pay account to correct configuration
  58. of the VS signal polarity. This is automatically correct when using the serial
  59. receivers.)
  60. Each of the statistics subdevs is able to produce events. An event is
  61. generated whenever a statistics buffer can be dequeued by a user space
  62. application using the VIDIOC_OMAP3ISP_STAT_REQ IOCTL. The events available
  63. are:
  64. - V4L2_EVENT_OMAP3ISP_AEWB
  65. - V4L2_EVENT_OMAP3ISP_AF
  66. - V4L2_EVENT_OMAP3ISP_HIST
  67. The type of the event data is struct omap3isp_stat_event_status for these
  68. ioctls. If there is an error calculating the statistics, there will be an
  69. event as usual, but no related statistics buffer. In this case
  70. omap3isp_stat_event_status.buf_err is set to non-zero.
  71. Private IOCTLs
  72. --------------
  73. The OMAP 3 ISP driver supports standard V4L2 IOCTLs and controls where
  74. possible and practical. Much of the functions provided by the ISP, however,
  75. does not fall under the standard IOCTLs --- gamma tables and configuration of
  76. statistics collection are examples of such.
  77. In general, there is a private ioctl for configuring each of the blocks
  78. containing hardware-dependent functions.
  79. The following private IOCTLs are supported:
  80. - VIDIOC_OMAP3ISP_CCDC_CFG
  81. - VIDIOC_OMAP3ISP_PRV_CFG
  82. - VIDIOC_OMAP3ISP_AEWB_CFG
  83. - VIDIOC_OMAP3ISP_HIST_CFG
  84. - VIDIOC_OMAP3ISP_AF_CFG
  85. - VIDIOC_OMAP3ISP_STAT_REQ
  86. - VIDIOC_OMAP3ISP_STAT_EN
  87. The parameter structures used by these ioctls are described in
  88. include/linux/omap3isp.h. The detailed functions of the ISP itself related to
  89. a given ISP block is described in the Technical Reference Manuals (TRMs) ---
  90. see the end of the document for those.
  91. While it is possible to use the ISP driver without any use of these private
  92. IOCTLs it is not possible to obtain optimal image quality this way. The AEWB,
  93. AF and histogram modules cannot be used without configuring them using the
  94. appropriate private IOCTLs.
  95. CCDC and preview block IOCTLs
  96. -----------------------------
  97. The VIDIOC_OMAP3ISP_CCDC_CFG and VIDIOC_OMAP3ISP_PRV_CFG IOCTLs are used to
  98. configure, enable and disable functions in the CCDC and preview blocks,
  99. respectively. Both IOCTLs control several functions in the blocks they
  100. control. VIDIOC_OMAP3ISP_CCDC_CFG IOCTL accepts a pointer to struct
  101. omap3isp_ccdc_update_config as its argument. Similarly VIDIOC_OMAP3ISP_PRV_CFG
  102. accepts a pointer to struct omap3isp_prev_update_config. The definition of
  103. both structures is available in [#f1]_.
  104. The update field in the structures tells whether to update the configuration
  105. for the specific function and the flag tells whether to enable or disable the
  106. function.
  107. The update and flag bit masks accept the following values. Each separate
  108. functions in the CCDC and preview blocks is associated with a flag (either
  109. disable or enable; part of the flag field in the structure) and a pointer to
  110. configuration data for the function.
  111. Valid values for the update and flag fields are listed here for
  112. VIDIOC_OMAP3ISP_CCDC_CFG. Values may be or'ed to configure more than one
  113. function in the same IOCTL call.
  114. - OMAP3ISP_CCDC_ALAW
  115. - OMAP3ISP_CCDC_LPF
  116. - OMAP3ISP_CCDC_BLCLAMP
  117. - OMAP3ISP_CCDC_BCOMP
  118. - OMAP3ISP_CCDC_FPC
  119. - OMAP3ISP_CCDC_CULL
  120. - OMAP3ISP_CCDC_CONFIG_LSC
  121. - OMAP3ISP_CCDC_TBL_LSC
  122. The corresponding values for the VIDIOC_OMAP3ISP_PRV_CFG are here:
  123. - OMAP3ISP_PREV_LUMAENH
  124. - OMAP3ISP_PREV_INVALAW
  125. - OMAP3ISP_PREV_HRZ_MED
  126. - OMAP3ISP_PREV_CFA
  127. - OMAP3ISP_PREV_CHROMA_SUPP
  128. - OMAP3ISP_PREV_WB
  129. - OMAP3ISP_PREV_BLKADJ
  130. - OMAP3ISP_PREV_RGB2RGB
  131. - OMAP3ISP_PREV_COLOR_CONV
  132. - OMAP3ISP_PREV_YC_LIMIT
  133. - OMAP3ISP_PREV_DEFECT_COR
  134. - OMAP3ISP_PREV_GAMMABYPASS
  135. - OMAP3ISP_PREV_DRK_FRM_CAPTURE
  136. - OMAP3ISP_PREV_DRK_FRM_SUBTRACT
  137. - OMAP3ISP_PREV_LENS_SHADING
  138. - OMAP3ISP_PREV_NF
  139. - OMAP3ISP_PREV_GAMMA
  140. The associated configuration pointer for the function may not be NULL when
  141. enabling the function. When disabling a function the configuration pointer is
  142. ignored.
  143. Statistic blocks IOCTLs
  144. -----------------------
  145. The statistics subdevs do offer more dynamic configuration options than the
  146. other subdevs. They can be enabled, disable and reconfigured when the pipeline
  147. is in streaming state.
  148. The statistics blocks always get the input image data from the CCDC (as the
  149. histogram memory read isn't implemented). The statistics are dequeueable by
  150. the user from the statistics subdev nodes using private IOCTLs.
  151. The private IOCTLs offered by the AEWB, AF and histogram subdevs are heavily
  152. reflected by the register level interface offered by the ISP hardware. There
  153. are aspects that are purely related to the driver implementation and these are
  154. discussed next.
  155. VIDIOC_OMAP3ISP_STAT_EN
  156. -----------------------
  157. This private IOCTL enables/disables a statistic module. If this request is
  158. done before streaming, it will take effect as soon as the pipeline starts to
  159. stream. If the pipeline is already streaming, it will take effect as soon as
  160. the CCDC becomes idle.
  161. VIDIOC_OMAP3ISP_AEWB_CFG, VIDIOC_OMAP3ISP_HIST_CFG and VIDIOC_OMAP3ISP_AF_CFG
  162. -----------------------------------------------------------------------------
  163. Those IOCTLs are used to configure the modules. They require user applications
  164. to have an in-depth knowledge of the hardware. Most of the fields explanation
  165. can be found on OMAP's TRMs. The two following fields common to all the above
  166. configure private IOCTLs require explanation for better understanding as they
  167. are not part of the TRM.
  168. omap3isp_[h3a_af/h3a_aewb/hist]\_config.buf_size:
  169. The modules handle their buffers internally. The necessary buffer size for the
  170. module's data output depends on the requested configuration. Although the
  171. driver supports reconfiguration while streaming, it does not support a
  172. reconfiguration which requires bigger buffer size than what is already
  173. internally allocated if the module is enabled. It will return -EBUSY on this
  174. case. In order to avoid such condition, either disable/reconfigure/enable the
  175. module or request the necessary buffer size during the first configuration
  176. while the module is disabled.
  177. The internal buffer size allocation considers the requested configuration's
  178. minimum buffer size and the value set on buf_size field. If buf_size field is
  179. out of [minimum, maximum] buffer size range, it's clamped to fit in there.
  180. The driver then selects the biggest value. The corrected buf_size value is
  181. written back to user application.
  182. omap3isp_[h3a_af/h3a_aewb/hist]\_config.config_counter:
  183. As the configuration doesn't take effect synchronously to the request, the
  184. driver must provide a way to track this information to provide more accurate
  185. data. After a configuration is requested, the config_counter returned to user
  186. space application will be an unique value associated to that request. When
  187. user application receives an event for buffer availability or when a new
  188. buffer is requested, this config_counter is used to match a buffer data and a
  189. configuration.
  190. VIDIOC_OMAP3ISP_STAT_REQ
  191. ------------------------
  192. Send to user space the oldest data available in the internal buffer queue and
  193. discards such buffer afterwards. The field omap3isp_stat_data.frame_number
  194. matches with the video buffer's field_count.
  195. Technical reference manuals (TRMs) and other documentation
  196. ----------------------------------------------------------
  197. OMAP 3430 TRM:
  198. <URL:http://focus.ti.com/pdfs/wtbu/OMAP34xx_ES3.1.x_PUBLIC_TRM_vZM.zip>
  199. Referenced 2011-03-05.
  200. OMAP 35xx TRM:
  201. <URL:http://www.ti.com/litv/pdf/spruf98o> Referenced 2011-03-05.
  202. OMAP 3630 TRM:
  203. <URL:http://focus.ti.com/pdfs/wtbu/OMAP36xx_ES1.x_PUBLIC_TRM_vQ.zip>
  204. Referenced 2011-03-05.
  205. DM 3730 TRM:
  206. <URL:http://www.ti.com/litv/pdf/sprugn4h> Referenced 2011-03-06.
  207. References
  208. ----------
  209. .. [#f1] include/linux/omap3isp.h
  210. .. [#f2] http://git.ideasonboard.org/?p=media-ctl.git;a=summary