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