18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci.. include:: <isonum.txt> 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciOMAP 3 Image Signal Processor (ISP) driver 68c2ecf20Sopenharmony_ci========================================== 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciCopyright |copy| 2010 Nokia Corporation 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciCopyright |copy| 2009 Texas Instruments, Inc. 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciContacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>, 138c2ecf20Sopenharmony_ciSakari Ailus <sakari.ailus@iki.fi>, David Cohen <dacohen@gmail.com> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciEvents 178c2ecf20Sopenharmony_ci------ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ciThe OMAP 3 ISP driver does support the V4L2 event interface on CCDC and 208c2ecf20Sopenharmony_cistatistics (AEWB, AF and histogram) subdevs. 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciThe CCDC subdev produces V4L2_EVENT_FRAME_SYNC type event on HS_VS 238c2ecf20Sopenharmony_ciinterrupt which is used to signal frame start. Earlier version of this 248c2ecf20Sopenharmony_cidriver used V4L2_EVENT_OMAP3ISP_HS_VS for this purpose. The event is 258c2ecf20Sopenharmony_citriggered exactly when the reception of the first line of the frame starts 268c2ecf20Sopenharmony_ciin the CCDC module. The event can be subscribed on the CCDC subdev. 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci(When using parallel interface one must pay account to correct configuration 298c2ecf20Sopenharmony_ciof the VS signal polarity. This is automatically correct when using the serial 308c2ecf20Sopenharmony_cireceivers.) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciEach of the statistics subdevs is able to produce events. An event is 338c2ecf20Sopenharmony_cigenerated whenever a statistics buffer can be dequeued by a user space 348c2ecf20Sopenharmony_ciapplication using the VIDIOC_OMAP3ISP_STAT_REQ IOCTL. The events available 358c2ecf20Sopenharmony_ciare: 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci- V4L2_EVENT_OMAP3ISP_AEWB 388c2ecf20Sopenharmony_ci- V4L2_EVENT_OMAP3ISP_AF 398c2ecf20Sopenharmony_ci- V4L2_EVENT_OMAP3ISP_HIST 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciThe type of the event data is struct omap3isp_stat_event_status for these 428c2ecf20Sopenharmony_ciioctls. If there is an error calculating the statistics, there will be an 438c2ecf20Sopenharmony_cievent as usual, but no related statistics buffer. In this case 448c2ecf20Sopenharmony_ciomap3isp_stat_event_status.buf_err is set to non-zero. 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ciPrivate IOCTLs 488c2ecf20Sopenharmony_ci-------------- 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ciThe OMAP 3 ISP driver supports standard V4L2 IOCTLs and controls where 518c2ecf20Sopenharmony_cipossible and practical. Much of the functions provided by the ISP, however, 528c2ecf20Sopenharmony_cidoes not fall under the standard IOCTLs --- gamma tables and configuration of 538c2ecf20Sopenharmony_cistatistics collection are examples of such. 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciIn general, there is a private ioctl for configuring each of the blocks 568c2ecf20Sopenharmony_cicontaining hardware-dependent functions. 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ciThe following private IOCTLs are supported: 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci- VIDIOC_OMAP3ISP_CCDC_CFG 618c2ecf20Sopenharmony_ci- VIDIOC_OMAP3ISP_PRV_CFG 628c2ecf20Sopenharmony_ci- VIDIOC_OMAP3ISP_AEWB_CFG 638c2ecf20Sopenharmony_ci- VIDIOC_OMAP3ISP_HIST_CFG 648c2ecf20Sopenharmony_ci- VIDIOC_OMAP3ISP_AF_CFG 658c2ecf20Sopenharmony_ci- VIDIOC_OMAP3ISP_STAT_REQ 668c2ecf20Sopenharmony_ci- VIDIOC_OMAP3ISP_STAT_EN 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ciThe parameter structures used by these ioctls are described in 698c2ecf20Sopenharmony_ciinclude/linux/omap3isp.h. The detailed functions of the ISP itself related to 708c2ecf20Sopenharmony_cia given ISP block is described in the Technical Reference Manuals (TRMs) --- 718c2ecf20Sopenharmony_cisee the end of the document for those. 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciWhile it is possible to use the ISP driver without any use of these private 748c2ecf20Sopenharmony_ciIOCTLs it is not possible to obtain optimal image quality this way. The AEWB, 758c2ecf20Sopenharmony_ciAF and histogram modules cannot be used without configuring them using the 768c2ecf20Sopenharmony_ciappropriate private IOCTLs. 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciCCDC and preview block IOCTLs 808c2ecf20Sopenharmony_ci----------------------------- 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciThe VIDIOC_OMAP3ISP_CCDC_CFG and VIDIOC_OMAP3ISP_PRV_CFG IOCTLs are used to 838c2ecf20Sopenharmony_ciconfigure, enable and disable functions in the CCDC and preview blocks, 848c2ecf20Sopenharmony_cirespectively. Both IOCTLs control several functions in the blocks they 858c2ecf20Sopenharmony_cicontrol. VIDIOC_OMAP3ISP_CCDC_CFG IOCTL accepts a pointer to struct 868c2ecf20Sopenharmony_ciomap3isp_ccdc_update_config as its argument. Similarly VIDIOC_OMAP3ISP_PRV_CFG 878c2ecf20Sopenharmony_ciaccepts a pointer to struct omap3isp_prev_update_config. The definition of 888c2ecf20Sopenharmony_ciboth structures is available in [#]_. 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ciThe update field in the structures tells whether to update the configuration 918c2ecf20Sopenharmony_cifor the specific function and the flag tells whether to enable or disable the 928c2ecf20Sopenharmony_cifunction. 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciThe update and flag bit masks accept the following values. Each separate 958c2ecf20Sopenharmony_cifunctions in the CCDC and preview blocks is associated with a flag (either 968c2ecf20Sopenharmony_cidisable or enable; part of the flag field in the structure) and a pointer to 978c2ecf20Sopenharmony_ciconfiguration data for the function. 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ciValid values for the update and flag fields are listed here for 1008c2ecf20Sopenharmony_ciVIDIOC_OMAP3ISP_CCDC_CFG. Values may be or'ed to configure more than one 1018c2ecf20Sopenharmony_cifunction in the same IOCTL call. 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_ALAW 1048c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_LPF 1058c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_BLCLAMP 1068c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_BCOMP 1078c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_FPC 1088c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_CULL 1098c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_CONFIG_LSC 1108c2ecf20Sopenharmony_ci- OMAP3ISP_CCDC_TBL_LSC 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ciThe corresponding values for the VIDIOC_OMAP3ISP_PRV_CFG are here: 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_LUMAENH 1158c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_INVALAW 1168c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_HRZ_MED 1178c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_CFA 1188c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_CHROMA_SUPP 1198c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_WB 1208c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_BLKADJ 1218c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_RGB2RGB 1228c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_COLOR_CONV 1238c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_YC_LIMIT 1248c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_DEFECT_COR 1258c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_GAMMABYPASS 1268c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_DRK_FRM_CAPTURE 1278c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_DRK_FRM_SUBTRACT 1288c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_LENS_SHADING 1298c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_NF 1308c2ecf20Sopenharmony_ci- OMAP3ISP_PREV_GAMMA 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ciThe associated configuration pointer for the function may not be NULL when 1338c2ecf20Sopenharmony_cienabling the function. When disabling a function the configuration pointer is 1348c2ecf20Sopenharmony_ciignored. 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ciStatistic blocks IOCTLs 1388c2ecf20Sopenharmony_ci----------------------- 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ciThe statistics subdevs do offer more dynamic configuration options than the 1418c2ecf20Sopenharmony_ciother subdevs. They can be enabled, disable and reconfigured when the pipeline 1428c2ecf20Sopenharmony_ciis in streaming state. 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ciThe statistics blocks always get the input image data from the CCDC (as the 1458c2ecf20Sopenharmony_cihistogram memory read isn't implemented). The statistics are dequeueable by 1468c2ecf20Sopenharmony_cithe user from the statistics subdev nodes using private IOCTLs. 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ciThe private IOCTLs offered by the AEWB, AF and histogram subdevs are heavily 1498c2ecf20Sopenharmony_cireflected by the register level interface offered by the ISP hardware. There 1508c2ecf20Sopenharmony_ciare aspects that are purely related to the driver implementation and these are 1518c2ecf20Sopenharmony_cidiscussed next. 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ciVIDIOC_OMAP3ISP_STAT_EN 1548c2ecf20Sopenharmony_ci----------------------- 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ciThis private IOCTL enables/disables a statistic module. If this request is 1578c2ecf20Sopenharmony_cidone before streaming, it will take effect as soon as the pipeline starts to 1588c2ecf20Sopenharmony_cistream. If the pipeline is already streaming, it will take effect as soon as 1598c2ecf20Sopenharmony_cithe CCDC becomes idle. 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ciVIDIOC_OMAP3ISP_AEWB_CFG, VIDIOC_OMAP3ISP_HIST_CFG and VIDIOC_OMAP3ISP_AF_CFG 1628c2ecf20Sopenharmony_ci----------------------------------------------------------------------------- 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ciThose IOCTLs are used to configure the modules. They require user applications 1658c2ecf20Sopenharmony_cito have an in-depth knowledge of the hardware. Most of the fields explanation 1668c2ecf20Sopenharmony_cican be found on OMAP's TRMs. The two following fields common to all the above 1678c2ecf20Sopenharmony_ciconfigure private IOCTLs require explanation for better understanding as they 1688c2ecf20Sopenharmony_ciare not part of the TRM. 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ciomap3isp_[h3a_af/h3a_aewb/hist]\_config.buf_size: 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ciThe modules handle their buffers internally. The necessary buffer size for the 1738c2ecf20Sopenharmony_cimodule's data output depends on the requested configuration. Although the 1748c2ecf20Sopenharmony_cidriver supports reconfiguration while streaming, it does not support a 1758c2ecf20Sopenharmony_cireconfiguration which requires bigger buffer size than what is already 1768c2ecf20Sopenharmony_ciinternally allocated if the module is enabled. It will return -EBUSY on this 1778c2ecf20Sopenharmony_cicase. In order to avoid such condition, either disable/reconfigure/enable the 1788c2ecf20Sopenharmony_cimodule or request the necessary buffer size during the first configuration 1798c2ecf20Sopenharmony_ciwhile the module is disabled. 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ciThe internal buffer size allocation considers the requested configuration's 1828c2ecf20Sopenharmony_ciminimum buffer size and the value set on buf_size field. If buf_size field is 1838c2ecf20Sopenharmony_ciout of [minimum, maximum] buffer size range, it's clamped to fit in there. 1848c2ecf20Sopenharmony_ciThe driver then selects the biggest value. The corrected buf_size value is 1858c2ecf20Sopenharmony_ciwritten back to user application. 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ciomap3isp_[h3a_af/h3a_aewb/hist]\_config.config_counter: 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ciAs the configuration doesn't take effect synchronously to the request, the 1908c2ecf20Sopenharmony_cidriver must provide a way to track this information to provide more accurate 1918c2ecf20Sopenharmony_cidata. After a configuration is requested, the config_counter returned to user 1928c2ecf20Sopenharmony_cispace application will be an unique value associated to that request. When 1938c2ecf20Sopenharmony_ciuser application receives an event for buffer availability or when a new 1948c2ecf20Sopenharmony_cibuffer is requested, this config_counter is used to match a buffer data and a 1958c2ecf20Sopenharmony_ciconfiguration. 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ciVIDIOC_OMAP3ISP_STAT_REQ 1988c2ecf20Sopenharmony_ci------------------------ 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ciSend to user space the oldest data available in the internal buffer queue and 2018c2ecf20Sopenharmony_cidiscards such buffer afterwards. The field omap3isp_stat_data.frame_number 2028c2ecf20Sopenharmony_cimatches with the video buffer's field_count. 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ciReferences 2068c2ecf20Sopenharmony_ci---------- 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci.. [#] include/linux/omap3isp.h 209