omap3isp-uapi.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. include:: <isonum.txt>
  3. OMAP 3 Image Signal Processor (ISP) driver
  4. ==========================================
  5. Copyright |copy| 2010 Nokia Corporation
  6. Copyright |copy| 2009 Texas Instruments, Inc.
  7. Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
  8. Sakari Ailus <sakari.ailus@iki.fi>, David Cohen <dacohen@gmail.com>
  9. Events
  10. ------
  11. The OMAP 3 ISP driver does support the V4L2 event interface on CCDC and
  12. statistics (AEWB, AF and histogram) subdevs.
  13. The CCDC subdev produces V4L2_EVENT_FRAME_SYNC type event on HS_VS
  14. interrupt which is used to signal frame start. Earlier version of this
  15. driver used V4L2_EVENT_OMAP3ISP_HS_VS for this purpose. The event is
  16. triggered exactly when the reception of the first line of the frame starts
  17. in the CCDC module. The event can be subscribed on the CCDC subdev.
  18. (When using parallel interface one must pay account to correct configuration
  19. of the VS signal polarity. This is automatically correct when using the serial
  20. receivers.)
  21. Each of the statistics subdevs is able to produce events. An event is
  22. generated whenever a statistics buffer can be dequeued by a user space
  23. application using the VIDIOC_OMAP3ISP_STAT_REQ IOCTL. The events available
  24. are:
  25. - V4L2_EVENT_OMAP3ISP_AEWB
  26. - V4L2_EVENT_OMAP3ISP_AF
  27. - V4L2_EVENT_OMAP3ISP_HIST
  28. The type of the event data is struct omap3isp_stat_event_status for these
  29. ioctls. If there is an error calculating the statistics, there will be an
  30. event as usual, but no related statistics buffer. In this case
  31. omap3isp_stat_event_status.buf_err is set to non-zero.
  32. Private IOCTLs
  33. --------------
  34. The OMAP 3 ISP driver supports standard V4L2 IOCTLs and controls where
  35. possible and practical. Much of the functions provided by the ISP, however,
  36. does not fall under the standard IOCTLs --- gamma tables and configuration of
  37. statistics collection are examples of such.
  38. In general, there is a private ioctl for configuring each of the blocks
  39. containing hardware-dependent functions.
  40. The following private IOCTLs are supported:
  41. - VIDIOC_OMAP3ISP_CCDC_CFG
  42. - VIDIOC_OMAP3ISP_PRV_CFG
  43. - VIDIOC_OMAP3ISP_AEWB_CFG
  44. - VIDIOC_OMAP3ISP_HIST_CFG
  45. - VIDIOC_OMAP3ISP_AF_CFG
  46. - VIDIOC_OMAP3ISP_STAT_REQ
  47. - VIDIOC_OMAP3ISP_STAT_EN
  48. The parameter structures used by these ioctls are described in
  49. include/linux/omap3isp.h. The detailed functions of the ISP itself related to
  50. a given ISP block is described in the Technical Reference Manuals (TRMs) ---
  51. see the end of the document for those.
  52. While it is possible to use the ISP driver without any use of these private
  53. IOCTLs it is not possible to obtain optimal image quality this way. The AEWB,
  54. AF and histogram modules cannot be used without configuring them using the
  55. appropriate private IOCTLs.
  56. CCDC and preview block IOCTLs
  57. -----------------------------
  58. The VIDIOC_OMAP3ISP_CCDC_CFG and VIDIOC_OMAP3ISP_PRV_CFG IOCTLs are used to
  59. configure, enable and disable functions in the CCDC and preview blocks,
  60. respectively. Both IOCTLs control several functions in the blocks they
  61. control. VIDIOC_OMAP3ISP_CCDC_CFG IOCTL accepts a pointer to struct
  62. omap3isp_ccdc_update_config as its argument. Similarly VIDIOC_OMAP3ISP_PRV_CFG
  63. accepts a pointer to struct omap3isp_prev_update_config. The definition of
  64. both structures is available in [#]_.
  65. The update field in the structures tells whether to update the configuration
  66. for the specific function and the flag tells whether to enable or disable the
  67. function.
  68. The update and flag bit masks accept the following values. Each separate
  69. functions in the CCDC and preview blocks is associated with a flag (either
  70. disable or enable; part of the flag field in the structure) and a pointer to
  71. configuration data for the function.
  72. Valid values for the update and flag fields are listed here for
  73. VIDIOC_OMAP3ISP_CCDC_CFG. Values may be or'ed to configure more than one
  74. function in the same IOCTL call.
  75. - OMAP3ISP_CCDC_ALAW
  76. - OMAP3ISP_CCDC_LPF
  77. - OMAP3ISP_CCDC_BLCLAMP
  78. - OMAP3ISP_CCDC_BCOMP
  79. - OMAP3ISP_CCDC_FPC
  80. - OMAP3ISP_CCDC_CULL
  81. - OMAP3ISP_CCDC_CONFIG_LSC
  82. - OMAP3ISP_CCDC_TBL_LSC
  83. The corresponding values for the VIDIOC_OMAP3ISP_PRV_CFG are here:
  84. - OMAP3ISP_PREV_LUMAENH
  85. - OMAP3ISP_PREV_INVALAW
  86. - OMAP3ISP_PREV_HRZ_MED
  87. - OMAP3ISP_PREV_CFA
  88. - OMAP3ISP_PREV_CHROMA_SUPP
  89. - OMAP3ISP_PREV_WB
  90. - OMAP3ISP_PREV_BLKADJ
  91. - OMAP3ISP_PREV_RGB2RGB
  92. - OMAP3ISP_PREV_COLOR_CONV
  93. - OMAP3ISP_PREV_YC_LIMIT
  94. - OMAP3ISP_PREV_DEFECT_COR
  95. - OMAP3ISP_PREV_GAMMABYPASS
  96. - OMAP3ISP_PREV_DRK_FRM_CAPTURE
  97. - OMAP3ISP_PREV_DRK_FRM_SUBTRACT
  98. - OMAP3ISP_PREV_LENS_SHADING
  99. - OMAP3ISP_PREV_NF
  100. - OMAP3ISP_PREV_GAMMA
  101. The associated configuration pointer for the function may not be NULL when
  102. enabling the function. When disabling a function the configuration pointer is
  103. ignored.
  104. Statistic blocks IOCTLs
  105. -----------------------
  106. The statistics subdevs do offer more dynamic configuration options than the
  107. other subdevs. They can be enabled, disable and reconfigured when the pipeline
  108. is in streaming state.
  109. The statistics blocks always get the input image data from the CCDC (as the
  110. histogram memory read isn't implemented). The statistics are dequeueable by
  111. the user from the statistics subdev nodes using private IOCTLs.
  112. The private IOCTLs offered by the AEWB, AF and histogram subdevs are heavily
  113. reflected by the register level interface offered by the ISP hardware. There
  114. are aspects that are purely related to the driver implementation and these are
  115. discussed next.
  116. VIDIOC_OMAP3ISP_STAT_EN
  117. -----------------------
  118. This private IOCTL enables/disables a statistic module. If this request is
  119. done before streaming, it will take effect as soon as the pipeline starts to
  120. stream. If the pipeline is already streaming, it will take effect as soon as
  121. the CCDC becomes idle.
  122. VIDIOC_OMAP3ISP_AEWB_CFG, VIDIOC_OMAP3ISP_HIST_CFG and VIDIOC_OMAP3ISP_AF_CFG
  123. -----------------------------------------------------------------------------
  124. Those IOCTLs are used to configure the modules. They require user applications
  125. to have an in-depth knowledge of the hardware. Most of the fields explanation
  126. can be found on OMAP's TRMs. The two following fields common to all the above
  127. configure private IOCTLs require explanation for better understanding as they
  128. are not part of the TRM.
  129. omap3isp_[h3a_af/h3a_aewb/hist]\_config.buf_size:
  130. The modules handle their buffers internally. The necessary buffer size for the
  131. module's data output depends on the requested configuration. Although the
  132. driver supports reconfiguration while streaming, it does not support a
  133. reconfiguration which requires bigger buffer size than what is already
  134. internally allocated if the module is enabled. It will return -EBUSY on this
  135. case. In order to avoid such condition, either disable/reconfigure/enable the
  136. module or request the necessary buffer size during the first configuration
  137. while the module is disabled.
  138. The internal buffer size allocation considers the requested configuration's
  139. minimum buffer size and the value set on buf_size field. If buf_size field is
  140. out of [minimum, maximum] buffer size range, it's clamped to fit in there.
  141. The driver then selects the biggest value. The corrected buf_size value is
  142. written back to user application.
  143. omap3isp_[h3a_af/h3a_aewb/hist]\_config.config_counter:
  144. As the configuration doesn't take effect synchronously to the request, the
  145. driver must provide a way to track this information to provide more accurate
  146. data. After a configuration is requested, the config_counter returned to user
  147. space application will be an unique value associated to that request. When
  148. user application receives an event for buffer availability or when a new
  149. buffer is requested, this config_counter is used to match a buffer data and a
  150. configuration.
  151. VIDIOC_OMAP3ISP_STAT_REQ
  152. ------------------------
  153. Send to user space the oldest data available in the internal buffer queue and
  154. discards such buffer afterwards. The field omap3isp_stat_data.frame_number
  155. matches with the video buffer's field_count.
  156. References
  157. ----------
  158. .. [#] include/linux/omap3isp.h