1dfb999e7SDaniel Scally.. SPDX-License-Identifier: GPL-2.0 2dfb999e7SDaniel Scally 3dfb999e7SDaniel Scally========================================== 4dfb999e7SDaniel ScallyARM Mali-C55 Image Signal Processor driver 5dfb999e7SDaniel Scally========================================== 6dfb999e7SDaniel Scally 7dfb999e7SDaniel ScallyIntroduction 8dfb999e7SDaniel Scally============ 9dfb999e7SDaniel Scally 10dfb999e7SDaniel ScallyThis file documents the driver for ARM's Mali-C55 Image Signal Processor. The 11dfb999e7SDaniel Scallydriver is located under drivers/media/platform/arm/mali-c55. 12dfb999e7SDaniel Scally 13dfb999e7SDaniel ScallyThe Mali-C55 ISP receives data in either raw Bayer format or RGB/YUV format from 14dfb999e7SDaniel Scallysensors through either a parallel interface or a memory bus before processing it 15dfb999e7SDaniel Scallyand outputting it through an internal DMA engine. Two output pipelines are 16dfb999e7SDaniel Scallypossible (though one may not be fitted, depending on the implementation). These 17dfb999e7SDaniel Scallyare referred to as "Full resolution" and "Downscale", but the naming is historic 18dfb999e7SDaniel Scallyand both pipes are capable of cropping/scaling operations. The full resolution 19dfb999e7SDaniel Scallypipe is also capable of outputting RAW data, bypassing much of the ISP's 20dfb999e7SDaniel Scallyprocessing. The downscale pipe cannot output RAW data. An integrated test 21dfb999e7SDaniel Scallypattern generator can be used to drive the ISP and produce image data in the 22dfb999e7SDaniel Scallyabsence of a connected camera sensor. The driver module is named mali_c55, and 23dfb999e7SDaniel Scallyis enabled through the CONFIG_VIDEO_MALI_C55 config option. 24dfb999e7SDaniel Scally 25dfb999e7SDaniel ScallyThe driver implements V4L2, Media Controller and V4L2 Subdevice interfaces and 26dfb999e7SDaniel Scallyexpects camera sensors connected to the ISP to have V4L2 subdevice interfaces. 27dfb999e7SDaniel Scally 28dfb999e7SDaniel ScallyMali-C55 ISP hardware 29dfb999e7SDaniel Scally===================== 30dfb999e7SDaniel Scally 31dfb999e7SDaniel ScallyA high level functional view of the Mali-C55 ISP is presented below. The ISP 32dfb999e7SDaniel Scallytakes input from either a live source or through a DMA engine for memory input, 33dfb999e7SDaniel Scallydepending on the SoC integration.:: 34dfb999e7SDaniel Scally 35dfb999e7SDaniel Scally +---------+ +----------+ +--------+ 36dfb999e7SDaniel Scally | Sensor |--->| CSI-2 Rx | "Full Resolution" | DMA | 37dfb999e7SDaniel Scally +---------+ +----------+ |\ Output +--->| Writer | 38dfb999e7SDaniel Scally | | \ | +--------+ 39dfb999e7SDaniel Scally | | \ +----------+ +------+---> Streaming I/O 40dfb999e7SDaniel Scally +------------+ +------->| | | | | 41dfb999e7SDaniel Scally | | | |-->| Mali-C55 |--+ 42dfb999e7SDaniel Scally | DMA Reader |--------------->| | | ISP | | 43dfb999e7SDaniel Scally | | | / | | | +---> Streaming I/O 44dfb999e7SDaniel Scally +------------+ | / +----------+ | | 45dfb999e7SDaniel Scally |/ +------+ 46dfb999e7SDaniel Scally | +--------+ 47dfb999e7SDaniel Scally +--->| DMA | 48dfb999e7SDaniel Scally "Downscaled" | Writer | 49dfb999e7SDaniel Scally Output +--------+ 50dfb999e7SDaniel Scally 51dfb999e7SDaniel ScallyMedia Controller Topology 52dfb999e7SDaniel Scally========================= 53dfb999e7SDaniel Scally 54dfb999e7SDaniel ScallyAn example of the ISP's topology (as implemented in a system with an IMX415 55dfb999e7SDaniel Scallycamera sensor and generic CSI-2 receiver) is below: 56dfb999e7SDaniel Scally 57dfb999e7SDaniel Scally 58dfb999e7SDaniel Scally.. kernel-figure:: mali-c55-graph.dot 59dfb999e7SDaniel Scally :alt: mali-c55-graph.dot 60dfb999e7SDaniel Scally :align: center 61dfb999e7SDaniel Scally 62dfb999e7SDaniel ScallyThe driver has 4 V4L2 subdevices: 63dfb999e7SDaniel Scally 64dfb999e7SDaniel Scally- `mali_c55 isp`: Responsible for configuring input crop and color space 65dfb999e7SDaniel Scally conversion 66dfb999e7SDaniel Scally- `mali_c55 tpg`: The test pattern generator, emulating a camera sensor. 67dfb999e7SDaniel Scally- `mali_c55 resizer fr`: The Full-Resolution pipe resizer 68dfb999e7SDaniel Scally- `mali_c55 resizer ds`: The Downscale pipe resizer 69dfb999e7SDaniel Scally 70*b35d9f3eSDaniel ScallyThe driver has 3 V4L2 video devices: 71dfb999e7SDaniel Scally 72dfb999e7SDaniel Scally- `mali-c55 fr`: The full-resolution pipe's capture device 73dfb999e7SDaniel Scally- `mali-c55 ds`: The downscale pipe's capture device 74*b35d9f3eSDaniel Scally- `mali-c55 3a stats`: The 3A statistics capture device 75dfb999e7SDaniel Scally 76dfb999e7SDaniel ScallyFrame sequences are synchronised across to two capture devices, meaning if one 77dfb999e7SDaniel Scallypipe is started later than the other the sequence numbers returned in its 78dfb999e7SDaniel Scallybuffers will match those of the other pipe rather than starting from zero. 79dfb999e7SDaniel Scally 80dfb999e7SDaniel ScallyIdiosyncrasies 81dfb999e7SDaniel Scally-------------- 82dfb999e7SDaniel Scally 83dfb999e7SDaniel Scally**mali-c55 isp** 84dfb999e7SDaniel ScallyThe `mali-c55 isp` subdevice has a single sink pad to which all sources of data 85dfb999e7SDaniel Scallyshould be connected. The active source is selected by enabling the appropriate 86dfb999e7SDaniel Scallymedia link and disabling all others. The ISP has two source pads, reflecting the 87dfb999e7SDaniel Scallydifferent paths through which it can internally route data. Tap points within 88dfb999e7SDaniel Scallythe ISP allow users to divert data to avoid processing by some or all of the 89dfb999e7SDaniel Scallyhardware's processing steps. The diagram below is intended only to highlight how 90dfb999e7SDaniel Scallythe bypassing works and is not a true reflection of those processing steps; for 91dfb999e7SDaniel Scallya high-level functional block diagram see ARM's developer page for the 92dfb999e7SDaniel ScallyISP [3]_:: 93dfb999e7SDaniel Scally 94dfb999e7SDaniel Scally +--------------------------------------------------------------+ 95dfb999e7SDaniel Scally | Possible Internal ISP Data Routes | 96dfb999e7SDaniel Scally | +------------+ +----------+ +------------+ | 97dfb999e7SDaniel Scally +---+ | | | | | Colour | +---+ 98dfb999e7SDaniel Scally | 0 |--+-->| Processing |->| Demosaic |->| Space |--->| 1 | 99dfb999e7SDaniel Scally +---+ | | | | | | Conversion | +---+ 100dfb999e7SDaniel Scally | | +------------+ +----------+ +------------+ | 101dfb999e7SDaniel Scally | | +---+ 102dfb999e7SDaniel Scally | +---------------------------------------------------| 2 | 103dfb999e7SDaniel Scally | +---+ 104dfb999e7SDaniel Scally | | 105dfb999e7SDaniel Scally +--------------------------------------------------------------+ 106dfb999e7SDaniel Scally 107dfb999e7SDaniel Scally 108dfb999e7SDaniel Scally.. flat-table:: 109dfb999e7SDaniel Scally :header-rows: 1 110dfb999e7SDaniel Scally 111dfb999e7SDaniel Scally * - Pad 112dfb999e7SDaniel Scally - Direction 113dfb999e7SDaniel Scally - Purpose 114dfb999e7SDaniel Scally 115dfb999e7SDaniel Scally * - 0 116dfb999e7SDaniel Scally - sink 117dfb999e7SDaniel Scally - Data input, connected to the TPG and camera sensors 118dfb999e7SDaniel Scally 119dfb999e7SDaniel Scally * - 1 120dfb999e7SDaniel Scally - source 121dfb999e7SDaniel Scally - RGB/YUV data, connected to the FR and DS V4L2 subdevices 122dfb999e7SDaniel Scally 123dfb999e7SDaniel Scally * - 2 124dfb999e7SDaniel Scally - source 125dfb999e7SDaniel Scally - RAW bayer data, connected to the FR V4L2 subdevices 126dfb999e7SDaniel Scally 127dfb999e7SDaniel ScallyThe ISP is limited to both input and output resolutions between 640x480 and 128dfb999e7SDaniel Scally8192x8192, and this is reflected in the ISP and resizer subdevice's .set_fmt() 129dfb999e7SDaniel Scallyoperations. 130dfb999e7SDaniel Scally 131dfb999e7SDaniel Scally**mali-c55 resizer fr** 132dfb999e7SDaniel ScallyThe `mali-c55 resizer fr` subdevice has two _sink_ pads to reflect the different 133dfb999e7SDaniel Scallyinsertion points in the hardware (either RAW or demosaiced data): 134dfb999e7SDaniel Scally 135dfb999e7SDaniel Scally.. flat-table:: 136dfb999e7SDaniel Scally :header-rows: 1 137dfb999e7SDaniel Scally 138dfb999e7SDaniel Scally * - Pad 139dfb999e7SDaniel Scally - Direction 140dfb999e7SDaniel Scally - Purpose 141dfb999e7SDaniel Scally 142dfb999e7SDaniel Scally * - 0 143dfb999e7SDaniel Scally - sink 144dfb999e7SDaniel Scally - Data input connected to the ISP's demosaiced stream. 145dfb999e7SDaniel Scally 146dfb999e7SDaniel Scally * - 1 147dfb999e7SDaniel Scally - source 148dfb999e7SDaniel Scally - Data output connected to the capture video device 149dfb999e7SDaniel Scally 150dfb999e7SDaniel Scally * - 2 151dfb999e7SDaniel Scally - sink 152dfb999e7SDaniel Scally - Data input connected to the ISP's raw data stream 153dfb999e7SDaniel Scally 154dfb999e7SDaniel ScallyThe data source in use is selected through the routing API; two routes each of a 155dfb999e7SDaniel Scallysingle stream are available: 156dfb999e7SDaniel Scally 157dfb999e7SDaniel Scally.. flat-table:: 158dfb999e7SDaniel Scally :header-rows: 1 159dfb999e7SDaniel Scally 160dfb999e7SDaniel Scally * - Sink Pad 161dfb999e7SDaniel Scally - Source Pad 162dfb999e7SDaniel Scally - Purpose 163dfb999e7SDaniel Scally 164dfb999e7SDaniel Scally * - 0 165dfb999e7SDaniel Scally - 1 166dfb999e7SDaniel Scally - Demosaiced data route 167dfb999e7SDaniel Scally 168dfb999e7SDaniel Scally * - 2 169dfb999e7SDaniel Scally - 1 170dfb999e7SDaniel Scally - Raw data route 171dfb999e7SDaniel Scally 172dfb999e7SDaniel Scally 173dfb999e7SDaniel ScallyIf the demosaiced route is active then the FR pipe is only capable of output 174dfb999e7SDaniel Scallyin RGB/YUV formats. If the raw route is active then the output reflects the 175dfb999e7SDaniel Scallyinput (which may be either Bayer or RGB/YUV data). 176dfb999e7SDaniel Scally 177dfb999e7SDaniel ScallyUsing the driver to capture video 178dfb999e7SDaniel Scally================================= 179dfb999e7SDaniel Scally 180dfb999e7SDaniel ScallyUsing the media controller APIs we can configure the input source and ISP to 181dfb999e7SDaniel Scallycapture images in a variety of formats. In the examples below, configuring the 182dfb999e7SDaniel Scallymedia graph is done with the v4l-utils [1]_ package's media-ctl utility. 183dfb999e7SDaniel ScallyCapturing the images is done with yavta [2]_. 184dfb999e7SDaniel Scally 185dfb999e7SDaniel ScallyConfiguring the input source 186dfb999e7SDaniel Scally---------------------------- 187dfb999e7SDaniel Scally 188dfb999e7SDaniel ScallyThe first step is to set the input source that we wish by enabling the correct 189dfb999e7SDaniel Scallymedia link. Using the example topology above, we can select the TPG as follows: 190dfb999e7SDaniel Scally 191dfb999e7SDaniel Scally.. code-block:: none 192dfb999e7SDaniel Scally 193dfb999e7SDaniel Scally media-ctl -l "'lte-csi2-rx':1->'mali-c55 isp':0[0]" 194dfb999e7SDaniel Scally media-ctl -l "'mali-c55 tpg':0->'mali-c55 isp':0[1]" 195dfb999e7SDaniel Scally 196dfb999e7SDaniel ScallyConfiguring which video devices will stream data 197dfb999e7SDaniel Scally------------------------------------------------ 198dfb999e7SDaniel Scally 199dfb999e7SDaniel ScallyThe driver will wait for all video devices to have their VIDIOC_STREAMON ioctl 200dfb999e7SDaniel Scallycalled before it tells the sensor to start streaming. To facilitate this we need 201dfb999e7SDaniel Scallyto enable links to the video devices that we want to use. In the example below 202dfb999e7SDaniel Scallywe enable the links to both of the image capture video devices 203dfb999e7SDaniel Scally 204dfb999e7SDaniel Scally.. code-block:: none 205dfb999e7SDaniel Scally 206dfb999e7SDaniel Scally media-ctl -l "'mali-c55 resizer fr':1->'mali-c55 fr':0[1]" 207dfb999e7SDaniel Scally media-ctl -l "'mali-c55 resizer ds':1->'mali-c55 ds':0[1]" 208dfb999e7SDaniel Scally 209dfb999e7SDaniel ScallyCapturing bayer data from the source and processing to RGB/YUV 210dfb999e7SDaniel Scally-------------------------------------------------------------- 211dfb999e7SDaniel Scally 212dfb999e7SDaniel ScallyTo capture 1920x1080 bayer data from the source and push it through the ISP's 213dfb999e7SDaniel Scallyfull processing pipeline, we configure the data formats appropriately on the 214dfb999e7SDaniel Scallysource, ISP and resizer subdevices and set the FR resizer's routing to select 215dfb999e7SDaniel Scallyprocessed data. The media bus format on the resizer's source pad will be either 216dfb999e7SDaniel ScallyRGB121212_1X36 or YUV10_1X30, depending on whether you want to capture RGB or 217dfb999e7SDaniel ScallyYUV. The ISP's debayering block outputs RGB data natively, setting the source 218dfb999e7SDaniel Scallypad format to YUV10_1X30 enables the colour space conversion block. 219dfb999e7SDaniel Scally 220dfb999e7SDaniel ScallyIn this example we target RGB565 output, so select RGB121212_1X36 as the resizer 221dfb999e7SDaniel Scallysource pad's format: 222dfb999e7SDaniel Scally 223dfb999e7SDaniel Scally.. code-block:: none 224dfb999e7SDaniel Scally 225dfb999e7SDaniel Scally # Set formats on the TPG and ISP 226dfb999e7SDaniel Scally media-ctl -V "'mali-c55 tpg':0[fmt:SRGGB20_1X20/1920x1080]" 227dfb999e7SDaniel Scally media-ctl -V "'mali-c55 isp':0[fmt:SRGGB20_1X20/1920x1080]" 228dfb999e7SDaniel Scally media-ctl -V "'mali-c55 isp':1[fmt:SRGGB20_1X20/1920x1080]" 229dfb999e7SDaniel Scally 230dfb999e7SDaniel Scally # Set routing on the FR resizer 231dfb999e7SDaniel Scally media-ctl -R "'mali-c55 resizer fr'[0/0->1/0[1],2/0->1/0[0]]" 232dfb999e7SDaniel Scally 233dfb999e7SDaniel Scally # Set format on the resizer, must be done AFTER the routing. 234dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':1[fmt:RGB121212_1X36/1920x1080]" 235dfb999e7SDaniel Scally 236dfb999e7SDaniel ScallyThe downscale output can also be used to stream data at the same time. In this 237dfb999e7SDaniel Scallycase since only processed data can be captured through the downscale output no 238dfb999e7SDaniel Scallyrouting need be set: 239dfb999e7SDaniel Scally 240dfb999e7SDaniel Scally.. code-block:: none 241dfb999e7SDaniel Scally 242dfb999e7SDaniel Scally # Set format on the resizer 243dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer ds':1[fmt:RGB121212_1X36/1920x1080]" 244dfb999e7SDaniel Scally 245dfb999e7SDaniel ScallyFollowing which images can be captured from both the FR and DS output's video 246dfb999e7SDaniel Scallydevices (simultaneously, if desired): 247dfb999e7SDaniel Scally 248dfb999e7SDaniel Scally.. code-block:: none 249dfb999e7SDaniel Scally 250dfb999e7SDaniel Scally yavta -f RGB565 -s 1920x1080 -c10 /dev/video0 251dfb999e7SDaniel Scally yavta -f RGB565 -s 1920x1080 -c10 /dev/video1 252dfb999e7SDaniel Scally 253dfb999e7SDaniel ScallyCropping the image 254dfb999e7SDaniel Scally~~~~~~~~~~~~~~~~~~ 255dfb999e7SDaniel Scally 256dfb999e7SDaniel ScallyBoth the full resolution and downscale pipes can crop to a minimum resolution of 257dfb999e7SDaniel Scally640x480. To crop the image simply configure the resizer's sink pad's crop and 258dfb999e7SDaniel Scallycompose rectangles and set the format on the video device: 259dfb999e7SDaniel Scally 260dfb999e7SDaniel Scally.. code-block:: none 261dfb999e7SDaniel Scally 262dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':0[fmt:RGB121212_1X36/1920x1080 crop:(480,270)/640x480 compose:(0,0)/640x480]" 263dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':1[fmt:RGB121212_1X36/640x480]" 264dfb999e7SDaniel Scally yavta -f RGB565 -s 640x480 -c10 /dev/video0 265dfb999e7SDaniel Scally 266dfb999e7SDaniel ScallyDownscaling the image 267dfb999e7SDaniel Scally~~~~~~~~~~~~~~~~~~~~~ 268dfb999e7SDaniel Scally 269dfb999e7SDaniel ScallyBoth the full resolution and downscale pipes can downscale the image by up to 8x 270dfb999e7SDaniel Scallyprovided the minimum 640x480 output resolution is adhered to. For the best image 271dfb999e7SDaniel Scallyresult the scaling ratio for each direction should be the same. To configure 272dfb999e7SDaniel Scallyscaling we use the compose rectangle on the resizer's sink pad: 273dfb999e7SDaniel Scally 274dfb999e7SDaniel Scally.. code-block:: none 275dfb999e7SDaniel Scally 276dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':0[fmt:RGB121212_1X36/1920x1080 crop:(0,0)/1920x1080 compose:(0,0)/640x480]" 277dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':1[fmt:RGB121212_1X36/640x480]" 278dfb999e7SDaniel Scally yavta -f RGB565 -s 640x480 -c10 /dev/video0 279dfb999e7SDaniel Scally 280dfb999e7SDaniel ScallyCapturing images in YUV formats 281dfb999e7SDaniel Scally~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 282dfb999e7SDaniel Scally 283dfb999e7SDaniel ScallyIf we need to output YUV data rather than RGB the color space conversion block 284dfb999e7SDaniel Scallyneeds to be active, which is achieved by setting MEDIA_BUS_FMT_YUV10_1X30 on the 285dfb999e7SDaniel Scallyresizer's source pad. We can then configure a capture format like NV12 (here in 286dfb999e7SDaniel Scallyits multi-planar variant) 287dfb999e7SDaniel Scally 288dfb999e7SDaniel Scally.. code-block:: none 289dfb999e7SDaniel Scally 290dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':1[fmt:YUV10_1X30/1920x1080]" 291dfb999e7SDaniel Scally yavta -f NV12M -s 1920x1080 -c10 /dev/video0 292dfb999e7SDaniel Scally 293dfb999e7SDaniel ScallyCapturing RGB data from the source and processing it with the resizers 294dfb999e7SDaniel Scally---------------------------------------------------------------------- 295dfb999e7SDaniel Scally 296dfb999e7SDaniel ScallyThe Mali-C55 ISP can work with sensors capable of outputting RGB data. In this 297dfb999e7SDaniel Scallycase although none of the image quality blocks would be used it can still 298dfb999e7SDaniel Scallycrop/scale the data in the usual way. For this reason RGB data input to the ISP 299dfb999e7SDaniel Scallystill goes through the ISP subdevice's pad 1 to the resizer. 300dfb999e7SDaniel Scally 301dfb999e7SDaniel ScallyTo achieve this, the ISP's sink pad's format is set to 302dfb999e7SDaniel ScallyMEDIA_BUS_FMT_RGB202020_1X60 - this reflects the format that data must be in to 303dfb999e7SDaniel Scallywork with the ISP. Converting the camera sensor's output to that format is the 304dfb999e7SDaniel Scallyresponsibility of external hardware. 305dfb999e7SDaniel Scally 306dfb999e7SDaniel ScallyIn this example we ask the test pattern generator to give us RGB data instead of 307dfb999e7SDaniel Scallybayer. 308dfb999e7SDaniel Scally 309dfb999e7SDaniel Scally.. code-block:: none 310dfb999e7SDaniel Scally 311dfb999e7SDaniel Scally media-ctl -V "'mali-c55 tpg':0[fmt:RGB202020_1X60/1920x1080]" 312dfb999e7SDaniel Scally media-ctl -V "'mali-c55 isp':0[fmt:RGB202020_1X60/1920x1080]" 313dfb999e7SDaniel Scally 314dfb999e7SDaniel ScallyCropping or scaling the data can be done in exactly the same way as outlined 315dfb999e7SDaniel Scallyearlier. 316dfb999e7SDaniel Scally 317dfb999e7SDaniel ScallyCapturing raw data from the source and outputting it unmodified 318dfb999e7SDaniel Scally----------------------------------------------------------------- 319dfb999e7SDaniel Scally 320dfb999e7SDaniel ScallyThe ISP can additionally capture raw data from the source and output it on the 321dfb999e7SDaniel Scallyfull resolution pipe only, completely unmodified. In this case the downscale 322dfb999e7SDaniel Scallypipe can still process the data normally and be used at the same time. 323dfb999e7SDaniel Scally 324dfb999e7SDaniel ScallyTo configure raw bypass the FR resizer's subdevice's routing table needs to be 325dfb999e7SDaniel Scallyconfigured, followed by formats in the appropriate places: 326dfb999e7SDaniel Scally 327dfb999e7SDaniel Scally.. code-block:: none 328dfb999e7SDaniel Scally 329dfb999e7SDaniel Scally media-ctl -R "'mali-c55 resizer fr'[0/0->1/0[0],2/0->1/0[1]]" 330dfb999e7SDaniel Scally media-ctl -V "'mali-c55 isp':0[fmt:RGB202020_1X60/1920x1080]" 331dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':2[fmt:RGB202020_1X60/1920x1080]" 332dfb999e7SDaniel Scally media-ctl -V "'mali-c55 resizer fr':1[fmt:RGB202020_1X60/1920x1080]" 333dfb999e7SDaniel Scally 334dfb999e7SDaniel Scally # Set format on the video device and stream 335dfb999e7SDaniel Scally yavta -f RGB565 -s 1920x1080 -c10 /dev/video0 336dfb999e7SDaniel Scally 337*b35d9f3eSDaniel Scally.. _mali-c55-3a-stats: 338*b35d9f3eSDaniel Scally 339*b35d9f3eSDaniel ScallyCapturing ISP Statistics 340*b35d9f3eSDaniel Scally======================== 341*b35d9f3eSDaniel Scally 342*b35d9f3eSDaniel ScallyThe ISP is capable of producing statistics for consumption by image processing 343*b35d9f3eSDaniel Scallyalgorithms running in userspace. These statistics can be captured by queueing 344*b35d9f3eSDaniel Scallybuffers to the `mali-c55 3a stats` V4L2 Device whilst the ISP is streaming. Only 345*b35d9f3eSDaniel Scallythe :ref:`V4L2_META_FMT_MALI_C55_STATS <v4l2-meta-fmt-mali-c55-stats>` 346*b35d9f3eSDaniel Scallyformat is supported, so no format-setting need be done: 347*b35d9f3eSDaniel Scally 348*b35d9f3eSDaniel Scally.. code-block:: none 349*b35d9f3eSDaniel Scally 350*b35d9f3eSDaniel Scally # We assume the media graph has been configured to support RGB565 capture 351*b35d9f3eSDaniel Scally # from the mali-c55 fr V4L2 Device, which is at /dev/video0. The statistics 352*b35d9f3eSDaniel Scally # V4L2 device is at /dev/video3 353*b35d9f3eSDaniel Scally 354*b35d9f3eSDaniel Scally yavta -f RGB565 -s 1920x1080 -c32 /dev/video0 && \ 355*b35d9f3eSDaniel Scally yavta -c10 -F /dev/video3 356*b35d9f3eSDaniel Scally 357*b35d9f3eSDaniel ScallyThe layout of the buffer is described by :c:type:`mali_c55_stats_buffer`, 358*b35d9f3eSDaniel Scallybut broadly statistics are generated to support three image processing 359*b35d9f3eSDaniel Scallyalgorithms; AEXP (Auto-Exposure), AWB (Auto-White Balance) and AF (Auto-Focus). 360*b35d9f3eSDaniel ScallyThese stats can be drawn from various places in the Mali C55 ISP pipeline, known 361*b35d9f3eSDaniel Scallyas "tap points". This high-level block diagram is intended to explain where in 362*b35d9f3eSDaniel Scallythe processing flow the statistics can be drawn from:: 363*b35d9f3eSDaniel Scally 364*b35d9f3eSDaniel Scally +--> AEXP-2 +----> AEXP-1 +--> AF-0 365*b35d9f3eSDaniel Scally | +----> AF-1 | 366*b35d9f3eSDaniel Scally | | | 367*b35d9f3eSDaniel Scally +---------+ | +--------------+ | +--------------+ | 368*b35d9f3eSDaniel Scally | Input +-+-->+ Digital Gain +---+-->+ Black Level +---+---+ 369*b35d9f3eSDaniel Scally +---------+ +--------------+ +--------------+ | 370*b35d9f3eSDaniel Scally +-----------------------------------------------------------------+ 371*b35d9f3eSDaniel Scally | 372*b35d9f3eSDaniel Scally | +--------------+ +---------+ +----------------+ 373*b35d9f3eSDaniel Scally +-->| Sinter Noise +-+ White +--+--->| Lens Shading +--+---------------+ 374*b35d9f3eSDaniel Scally | Reduction | | Balance | | | | | | 375*b35d9f3eSDaniel Scally +--------------+ +---------+ | +----------------+ | | 376*b35d9f3eSDaniel Scally +---> AEXP-0 (A) +--> AEXP-0 (B) | 377*b35d9f3eSDaniel Scally +--------------------------------------------------------------------------+ 378*b35d9f3eSDaniel Scally | 379*b35d9f3eSDaniel Scally | +----------------+ +--------------+ +----------------+ 380*b35d9f3eSDaniel Scally +-->| Tone mapping +-+--->| Demosaicing +->+ Purple Fringe +-+-----------+ 381*b35d9f3eSDaniel Scally | | | +--------------+ | Correction | | | 382*b35d9f3eSDaniel Scally +----------------+ +-> AEXP-IRIDIX +----------------+ +---> AWB-0 | 383*b35d9f3eSDaniel Scally +----------------------------------------------------------------------------+ 384*b35d9f3eSDaniel Scally | +-------------+ +-------------+ 385*b35d9f3eSDaniel Scally +------------------->| Colour +---+--->| Output | 386*b35d9f3eSDaniel Scally | Correction | | | Pipelines | 387*b35d9f3eSDaniel Scally +-------------+ | +-------------+ 388*b35d9f3eSDaniel Scally +--> AWB-1 389*b35d9f3eSDaniel Scally 390*b35d9f3eSDaniel ScallyAt present all statistics are drawn from the 0th tap point for each algorithm; 391*b35d9f3eSDaniel ScallyI.E. AEXP statistics from AEXP-0 (A), AWB statistics from AWB-0 and AF 392*b35d9f3eSDaniel Scallystatistics from AF-0. In the future this will be configurable. 393*b35d9f3eSDaniel Scally 394dfb999e7SDaniel ScallyReferences 395dfb999e7SDaniel Scally========== 396dfb999e7SDaniel Scally.. [1] https://git.linuxtv.org/v4l-utils.git/ 397dfb999e7SDaniel Scally.. [2] https://git.ideasonboard.org/yavta.git 398dfb999e7SDaniel Scally.. [3] https://developer.arm.com/Processors/Mali-C55 399