0001 .. SPDX-License-Identifier: GPL-2.0
0002
0003 i.MX Video Capture Driver
0004 =========================
0005
0006 Introduction
0007 ------------
0008
0009 The Freescale i.MX5/6 contains an Image Processing Unit (IPU), which
0010 handles the flow of image frames to and from capture devices and
0011 display devices.
0012
0013 For image capture, the IPU contains the following internal subunits:
0014
0015 - Image DMA Controller (IDMAC)
0016 - Camera Serial Interface (CSI)
0017 - Image Converter (IC)
0018 - Sensor Multi-FIFO Controller (SMFC)
0019 - Image Rotator (IRT)
0020 - Video De-Interlacing or Combining Block (VDIC)
0021
0022 The IDMAC is the DMA controller for transfer of image frames to and from
0023 memory. Various dedicated DMA channels exist for both video capture and
0024 display paths. During transfer, the IDMAC is also capable of vertical
0025 image flip, 8x8 block transfer (see IRT description), pixel component
0026 re-ordering (for example UYVY to YUYV) within the same colorspace, and
0027 packed <--> planar conversion. The IDMAC can also perform a simple
0028 de-interlacing by interweaving even and odd lines during transfer
0029 (without motion compensation which requires the VDIC).
0030
0031 The CSI is the backend capture unit that interfaces directly with
0032 camera sensors over Parallel, BT.656/1120, and MIPI CSI-2 buses.
0033
0034 The IC handles color-space conversion, resizing (downscaling and
0035 upscaling), horizontal flip, and 90/270 degree rotation operations.
0036
0037 There are three independent "tasks" within the IC that can carry out
0038 conversions concurrently: pre-process encoding, pre-process viewfinder,
0039 and post-processing. Within each task, conversions are split into three
0040 sections: downsizing section, main section (upsizing, flip, colorspace
0041 conversion, and graphics plane combining), and rotation section.
0042
0043 The IPU time-shares the IC task operations. The time-slice granularity
0044 is one burst of eight pixels in the downsizing section, one image line
0045 in the main processing section, one image frame in the rotation section.
0046
0047 The SMFC is composed of four independent FIFOs that each can transfer
0048 captured frames from sensors directly to memory concurrently via four
0049 IDMAC channels.
0050
0051 The IRT carries out 90 and 270 degree image rotation operations. The
0052 rotation operation is carried out on 8x8 pixel blocks at a time. This
0053 operation is supported by the IDMAC which handles the 8x8 block transfer
0054 along with block reordering, in coordination with vertical flip.
0055
0056 The VDIC handles the conversion of interlaced video to progressive, with
0057 support for different motion compensation modes (low, medium, and high
0058 motion). The deinterlaced output frames from the VDIC can be sent to the
0059 IC pre-process viewfinder task for further conversions. The VDIC also
0060 contains a Combiner that combines two image planes, with alpha blending
0061 and color keying.
0062
0063 In addition to the IPU internal subunits, there are also two units
0064 outside the IPU that are also involved in video capture on i.MX:
0065
0066 - MIPI CSI-2 Receiver for camera sensors with the MIPI CSI-2 bus
0067 interface. This is a Synopsys DesignWare core.
0068 - Two video multiplexers for selecting among multiple sensor inputs
0069 to send to a CSI.
0070
0071 For more info, refer to the latest versions of the i.MX5/6 reference
0072 manuals [#f1]_ and [#f2]_.
0073
0074
0075 Features
0076 --------
0077
0078 Some of the features of this driver include:
0079
0080 - Many different pipelines can be configured via media controller API,
0081 that correspond to the hardware video capture pipelines supported in
0082 the i.MX.
0083
0084 - Supports parallel, BT.565, and MIPI CSI-2 interfaces.
0085
0086 - Concurrent independent streams, by configuring pipelines to multiple
0087 video capture interfaces using independent entities.
0088
0089 - Scaling, color-space conversion, horizontal and vertical flip, and
0090 image rotation via IC task subdevs.
0091
0092 - Many pixel formats supported (RGB, packed and planar YUV, partial
0093 planar YUV).
0094
0095 - The VDIC subdev supports motion compensated de-interlacing, with three
0096 motion compensation modes: low, medium, and high motion. Pipelines are
0097 defined that allow sending frames to the VDIC subdev directly from the
0098 CSI. There is also support in the future for sending frames to the
0099 VDIC from memory buffers via a output/mem2mem devices.
0100
0101 - Includes a Frame Interval Monitor (FIM) that can correct vertical sync
0102 problems with the ADV718x video decoders.
0103
0104
0105 Topology
0106 --------
0107
0108 The following shows the media topologies for the i.MX6Q SabreSD and
0109 i.MX6Q SabreAuto. Refer to these diagrams in the entity descriptions
0110 in the next section.
0111
0112 The i.MX5/6 topologies can differ upstream from the IPUv3 CSI video
0113 multiplexers, but the internal IPUv3 topology downstream from there
0114 is common to all i.MX5/6 platforms. For example, the SabreSD, with the
0115 MIPI CSI-2 OV5640 sensor, requires the i.MX6 MIPI CSI-2 receiver. But
0116 the SabreAuto has only the ADV7180 decoder on a parallel bt.656 bus, and
0117 therefore does not require the MIPI CSI-2 receiver, so it is missing in
0118 its graph.
0119
0120 .. _imx6q_topology_graph:
0121
0122 .. kernel-figure:: imx6q-sabresd.dot
0123 :alt: Diagram of the i.MX6Q SabreSD media pipeline topology
0124 :align: center
0125
0126 Media pipeline graph on i.MX6Q SabreSD
0127
0128 .. kernel-figure:: imx6q-sabreauto.dot
0129 :alt: Diagram of the i.MX6Q SabreAuto media pipeline topology
0130 :align: center
0131
0132 Media pipeline graph on i.MX6Q SabreAuto
0133
0134 Entities
0135 --------
0136
0137 imx6-mipi-csi2
0138 --------------
0139
0140 This is the MIPI CSI-2 receiver entity. It has one sink pad to receive
0141 the MIPI CSI-2 stream (usually from a MIPI CSI-2 camera sensor). It has
0142 four source pads, corresponding to the four MIPI CSI-2 demuxed virtual
0143 channel outputs. Multiple source pads can be enabled to independently
0144 stream from multiple virtual channels.
0145
0146 This entity actually consists of two sub-blocks. One is the MIPI CSI-2
0147 core. This is a Synopsys Designware MIPI CSI-2 core. The other sub-block
0148 is a "CSI-2 to IPU gasket". The gasket acts as a demultiplexer of the
0149 four virtual channels streams, providing four separate parallel buses
0150 containing each virtual channel that are routed to CSIs or video
0151 multiplexers as described below.
0152
0153 On i.MX6 solo/dual-lite, all four virtual channel buses are routed to
0154 two video multiplexers. Both CSI0 and CSI1 can receive any virtual
0155 channel, as selected by the video multiplexers.
0156
0157 On i.MX6 Quad, virtual channel 0 is routed to IPU1-CSI0 (after selected
0158 by a video mux), virtual channels 1 and 2 are hard-wired to IPU1-CSI1
0159 and IPU2-CSI0, respectively, and virtual channel 3 is routed to
0160 IPU2-CSI1 (again selected by a video mux).
0161
0162 ipuX_csiY_mux
0163 -------------
0164
0165 These are the video multiplexers. They have two or more sink pads to
0166 select from either camera sensors with a parallel interface, or from
0167 MIPI CSI-2 virtual channels from imx6-mipi-csi2 entity. They have a
0168 single source pad that routes to a CSI (ipuX_csiY entities).
0169
0170 On i.MX6 solo/dual-lite, there are two video mux entities. One sits
0171 in front of IPU1-CSI0 to select between a parallel sensor and any of
0172 the four MIPI CSI-2 virtual channels (a total of five sink pads). The
0173 other mux sits in front of IPU1-CSI1, and again has five sink pads to
0174 select between a parallel sensor and any of the four MIPI CSI-2 virtual
0175 channels.
0176
0177 On i.MX6 Quad, there are two video mux entities. One sits in front of
0178 IPU1-CSI0 to select between a parallel sensor and MIPI CSI-2 virtual
0179 channel 0 (two sink pads). The other mux sits in front of IPU2-CSI1 to
0180 select between a parallel sensor and MIPI CSI-2 virtual channel 3 (two
0181 sink pads).
0182
0183 ipuX_csiY
0184 ---------
0185
0186 These are the CSI entities. They have a single sink pad receiving from
0187 either a video mux or from a MIPI CSI-2 virtual channel as described
0188 above.
0189
0190 This entity has two source pads. The first source pad can link directly
0191 to the ipuX_vdic entity or the ipuX_ic_prp entity, using hardware links
0192 that require no IDMAC memory buffer transfer.
0193
0194 When the direct source pad is routed to the ipuX_ic_prp entity, frames
0195 from the CSI can be processed by one or both of the IC pre-processing
0196 tasks.
0197
0198 When the direct source pad is routed to the ipuX_vdic entity, the VDIC
0199 will carry out motion-compensated de-interlace using "high motion" mode
0200 (see description of ipuX_vdic entity).
0201
0202 The second source pad sends video frames directly to memory buffers
0203 via the SMFC and an IDMAC channel, bypassing IC pre-processing. This
0204 source pad is routed to a capture device node, with a node name of the
0205 format "ipuX_csiY capture".
0206
0207 Note that since the IDMAC source pad makes use of an IDMAC channel,
0208 pixel reordering within the same colorspace can be carried out by the
0209 IDMAC channel. For example, if the CSI sink pad is receiving in UYVY
0210 order, the capture device linked to the IDMAC source pad can capture
0211 in YUYV order. Also, if the CSI sink pad is receiving a packed YUV
0212 format, the capture device can capture a planar YUV format such as
0213 YUV420.
0214
0215 The IDMAC channel at the IDMAC source pad also supports simple
0216 interweave without motion compensation, which is activated if the source
0217 pad's field type is sequential top-bottom or bottom-top, and the
0218 requested capture interface field type is set to interlaced (t-b, b-t,
0219 or unqualified interlaced). The capture interface will enforce the same
0220 field order as the source pad field order (interlaced-bt if source pad
0221 is seq-bt, interlaced-tb if source pad is seq-tb).
0222
0223 For events produced by ipuX_csiY, see ref:`imx_api_ipuX_csiY`.
0224
0225 Cropping in ipuX_csiY
0226 ---------------------
0227
0228 The CSI supports cropping the incoming raw sensor frames. This is
0229 implemented in the ipuX_csiY entities at the sink pad, using the
0230 crop selection subdev API.
0231
0232 The CSI also supports fixed divide-by-two downscaling independently in
0233 width and height. This is implemented in the ipuX_csiY entities at
0234 the sink pad, using the compose selection subdev API.
0235
0236 The output rectangle at the ipuX_csiY source pad is the same as
0237 the compose rectangle at the sink pad. So the source pad rectangle
0238 cannot be negotiated, it must be set using the compose selection
0239 API at sink pad (if /2 downscale is desired, otherwise source pad
0240 rectangle is equal to incoming rectangle).
0241
0242 To give an example of crop and /2 downscale, this will crop a
0243 1280x960 input frame to 640x480, and then /2 downscale in both
0244 dimensions to 320x240 (assumes ipu1_csi0 is linked to ipu1_csi0_mux):
0245
0246 .. code-block:: none
0247
0248 media-ctl -V "'ipu1_csi0_mux':2[fmt:UYVY2X8/1280x960]"
0249 media-ctl -V "'ipu1_csi0':0[crop:(0,0)/640x480]"
0250 media-ctl -V "'ipu1_csi0':0[compose:(0,0)/320x240]"
0251
0252 Frame Skipping in ipuX_csiY
0253 ---------------------------
0254
0255 The CSI supports frame rate decimation, via frame skipping. Frame
0256 rate decimation is specified by setting the frame intervals at
0257 sink and source pads. The ipuX_csiY entity then applies the best
0258 frame skip setting to the CSI to achieve the desired frame rate
0259 at the source pad.
0260
0261 The following example reduces an assumed incoming 60 Hz frame
0262 rate by half at the IDMAC output source pad:
0263
0264 .. code-block:: none
0265
0266 media-ctl -V "'ipu1_csi0':0[fmt:UYVY2X8/640x480@1/60]"
0267 media-ctl -V "'ipu1_csi0':2[fmt:UYVY2X8/640x480@1/30]"
0268
0269 Frame Interval Monitor in ipuX_csiY
0270 -----------------------------------
0271
0272 See ref:`imx_api_FIM`.
0273
0274 ipuX_vdic
0275 ---------
0276
0277 The VDIC carries out motion compensated de-interlacing, with three
0278 motion compensation modes: low, medium, and high motion. The mode is
0279 specified with the menu control V4L2_CID_DEINTERLACING_MODE. The VDIC
0280 has two sink pads and a single source pad.
0281
0282 The direct sink pad receives from an ipuX_csiY direct pad. With this
0283 link the VDIC can only operate in high motion mode.
0284
0285 When the IDMAC sink pad is activated, it receives from an output
0286 or mem2mem device node. With this pipeline, the VDIC can also operate
0287 in low and medium modes, because these modes require receiving
0288 frames from memory buffers. Note that an output or mem2mem device
0289 is not implemented yet, so this sink pad currently has no links.
0290
0291 The source pad routes to the IC pre-processing entity ipuX_ic_prp.
0292
0293 ipuX_ic_prp
0294 -----------
0295
0296 This is the IC pre-processing entity. It acts as a router, routing
0297 data from its sink pad to one or both of its source pads.
0298
0299 This entity has a single sink pad. The sink pad can receive from the
0300 ipuX_csiY direct pad, or from ipuX_vdic.
0301
0302 This entity has two source pads. One source pad routes to the
0303 pre-process encode task entity (ipuX_ic_prpenc), the other to the
0304 pre-process viewfinder task entity (ipuX_ic_prpvf). Both source pads
0305 can be activated at the same time if the sink pad is receiving from
0306 ipuX_csiY. Only the source pad to the pre-process viewfinder task entity
0307 can be activated if the sink pad is receiving from ipuX_vdic (frames
0308 from the VDIC can only be processed by the pre-process viewfinder task).
0309
0310 ipuX_ic_prpenc
0311 --------------
0312
0313 This is the IC pre-processing encode entity. It has a single sink
0314 pad from ipuX_ic_prp, and a single source pad. The source pad is
0315 routed to a capture device node, with a node name of the format
0316 "ipuX_ic_prpenc capture".
0317
0318 This entity performs the IC pre-process encode task operations:
0319 color-space conversion, resizing (downscaling and upscaling),
0320 horizontal and vertical flip, and 90/270 degree rotation. Flip
0321 and rotation are provided via standard V4L2 controls.
0322
0323 Like the ipuX_csiY IDMAC source, this entity also supports simple
0324 de-interlace without motion compensation, and pixel reordering.
0325
0326 ipuX_ic_prpvf
0327 -------------
0328
0329 This is the IC pre-processing viewfinder entity. It has a single sink
0330 pad from ipuX_ic_prp, and a single source pad. The source pad is routed
0331 to a capture device node, with a node name of the format
0332 "ipuX_ic_prpvf capture".
0333
0334 This entity is identical in operation to ipuX_ic_prpenc, with the same
0335 resizing and CSC operations and flip/rotation controls. It will receive
0336 and process de-interlaced frames from the ipuX_vdic if ipuX_ic_prp is
0337 receiving from ipuX_vdic.
0338
0339 Like the ipuX_csiY IDMAC source, this entity supports simple
0340 interweaving without motion compensation. However, note that if the
0341 ipuX_vdic is included in the pipeline (ipuX_ic_prp is receiving from
0342 ipuX_vdic), it's not possible to use interweave in ipuX_ic_prpvf,
0343 since the ipuX_vdic has already carried out de-interlacing (with
0344 motion compensation) and therefore the field type output from
0345 ipuX_vdic can only be none (progressive).
0346
0347 Capture Pipelines
0348 -----------------
0349
0350 The following describe the various use-cases supported by the pipelines.
0351
0352 The links shown do not include the backend sensor, video mux, or mipi
0353 csi-2 receiver links. This depends on the type of sensor interface
0354 (parallel or mipi csi-2). So these pipelines begin with:
0355
0356 sensor -> ipuX_csiY_mux -> ...
0357
0358 for parallel sensors, or:
0359
0360 sensor -> imx6-mipi-csi2 -> (ipuX_csiY_mux) -> ...
0361
0362 for mipi csi-2 sensors. The imx6-mipi-csi2 receiver may need to route
0363 to the video mux (ipuX_csiY_mux) before sending to the CSI, depending
0364 on the mipi csi-2 virtual channel, hence ipuX_csiY_mux is shown in
0365 parenthesis.
0366
0367 Unprocessed Video Capture:
0368 --------------------------
0369
0370 Send frames directly from sensor to camera device interface node, with
0371 no conversions, via ipuX_csiY IDMAC source pad:
0372
0373 -> ipuX_csiY:2 -> ipuX_csiY capture
0374
0375 IC Direct Conversions:
0376 ----------------------
0377
0378 This pipeline uses the preprocess encode entity to route frames directly
0379 from the CSI to the IC, to carry out scaling up to 1024x1024 resolution,
0380 CSC, flipping, and image rotation:
0381
0382 -> ipuX_csiY:1 -> 0:ipuX_ic_prp:1 -> 0:ipuX_ic_prpenc:1 -> ipuX_ic_prpenc capture
0383
0384 Motion Compensated De-interlace:
0385 --------------------------------
0386
0387 This pipeline routes frames from the CSI direct pad to the VDIC entity to
0388 support motion-compensated de-interlacing (high motion mode only),
0389 scaling up to 1024x1024, CSC, flip, and rotation:
0390
0391 -> ipuX_csiY:1 -> 0:ipuX_vdic:2 -> 0:ipuX_ic_prp:2 -> 0:ipuX_ic_prpvf:1 -> ipuX_ic_prpvf capture
0392
0393
0394 Usage Notes
0395 -----------
0396
0397 To aid in configuration and for backward compatibility with V4L2
0398 applications that access controls only from video device nodes, the
0399 capture device interfaces inherit controls from the active entities
0400 in the current pipeline, so controls can be accessed either directly
0401 from the subdev or from the active capture device interface. For
0402 example, the FIM controls are available either from the ipuX_csiY
0403 subdevs or from the active capture device.
0404
0405 The following are specific usage notes for the Sabre* reference
0406 boards:
0407
0408
0409 i.MX6Q SabreLite with OV5642 and OV5640
0410 ---------------------------------------
0411
0412 This platform requires the OmniVision OV5642 module with a parallel
0413 camera interface, and the OV5640 module with a MIPI CSI-2
0414 interface. Both modules are available from Boundary Devices:
0415
0416 - https://boundarydevices.com/product/nit6x_5mp
0417 - https://boundarydevices.com/product/nit6x_5mp_mipi
0418
0419 Note that if only one camera module is available, the other sensor
0420 node can be disabled in the device tree.
0421
0422 The OV5642 module is connected to the parallel bus input on the i.MX
0423 internal video mux to IPU1 CSI0. It's i2c bus connects to i2c bus 2.
0424
0425 The MIPI CSI-2 OV5640 module is connected to the i.MX internal MIPI CSI-2
0426 receiver, and the four virtual channel outputs from the receiver are
0427 routed as follows: vc0 to the IPU1 CSI0 mux, vc1 directly to IPU1 CSI1,
0428 vc2 directly to IPU2 CSI0, and vc3 to the IPU2 CSI1 mux. The OV5640 is
0429 also connected to i2c bus 2 on the SabreLite, therefore the OV5642 and
0430 OV5640 must not share the same i2c slave address.
0431
0432 The following basic example configures unprocessed video capture
0433 pipelines for both sensors. The OV5642 is routed to ipu1_csi0, and
0434 the OV5640, transmitting on MIPI CSI-2 virtual channel 1 (which is
0435 imx6-mipi-csi2 pad 2), is routed to ipu1_csi1. Both sensors are
0436 configured to output 640x480, and the OV5642 outputs YUYV2X8, the
0437 OV5640 UYVY2X8:
0438
0439 .. code-block:: none
0440
0441 # Setup links for OV5642
0442 media-ctl -l "'ov5642 1-0042':0 -> 'ipu1_csi0_mux':1[1]"
0443 media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]"
0444 media-ctl -l "'ipu1_csi0':2 -> 'ipu1_csi0 capture':0[1]"
0445 # Setup links for OV5640
0446 media-ctl -l "'ov5640 1-0040':0 -> 'imx6-mipi-csi2':0[1]"
0447 media-ctl -l "'imx6-mipi-csi2':2 -> 'ipu1_csi1':0[1]"
0448 media-ctl -l "'ipu1_csi1':2 -> 'ipu1_csi1 capture':0[1]"
0449 # Configure pads for OV5642 pipeline
0450 media-ctl -V "'ov5642 1-0042':0 [fmt:YUYV2X8/640x480 field:none]"
0451 media-ctl -V "'ipu1_csi0_mux':2 [fmt:YUYV2X8/640x480 field:none]"
0452 media-ctl -V "'ipu1_csi0':2 [fmt:AYUV32/640x480 field:none]"
0453 # Configure pads for OV5640 pipeline
0454 media-ctl -V "'ov5640 1-0040':0 [fmt:UYVY2X8/640x480 field:none]"
0455 media-ctl -V "'imx6-mipi-csi2':2 [fmt:UYVY2X8/640x480 field:none]"
0456 media-ctl -V "'ipu1_csi1':2 [fmt:AYUV32/640x480 field:none]"
0457
0458 Streaming can then begin independently on the capture device nodes
0459 "ipu1_csi0 capture" and "ipu1_csi1 capture". The v4l2-ctl tool can
0460 be used to select any supported YUV pixelformat on the capture device
0461 nodes, including planar.
0462
0463 i.MX6Q SabreAuto with ADV7180 decoder
0464 -------------------------------------
0465
0466 On the i.MX6Q SabreAuto, an on-board ADV7180 SD decoder is connected to the
0467 parallel bus input on the internal video mux to IPU1 CSI0.
0468
0469 The following example configures a pipeline to capture from the ADV7180
0470 video decoder, assuming NTSC 720x480 input signals, using simple
0471 interweave (unconverted and without motion compensation). The adv7180
0472 must output sequential or alternating fields (field type 'seq-bt' for
0473 NTSC, or 'alternate'):
0474
0475 .. code-block:: none
0476
0477 # Setup links
0478 media-ctl -l "'adv7180 3-0021':0 -> 'ipu1_csi0_mux':1[1]"
0479 media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]"
0480 media-ctl -l "'ipu1_csi0':2 -> 'ipu1_csi0 capture':0[1]"
0481 # Configure pads
0482 media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x480 field:seq-bt]"
0483 media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x480]"
0484 media-ctl -V "'ipu1_csi0':2 [fmt:AYUV32/720x480]"
0485 # Configure "ipu1_csi0 capture" interface (assumed at /dev/video4)
0486 v4l2-ctl -d4 --set-fmt-video=field=interlaced_bt
0487
0488 Streaming can then begin on /dev/video4. The v4l2-ctl tool can also be
0489 used to select any supported YUV pixelformat on /dev/video4.
0490
0491 This example configures a pipeline to capture from the ADV7180
0492 video decoder, assuming PAL 720x576 input signals, with Motion
0493 Compensated de-interlacing. The adv7180 must output sequential or
0494 alternating fields (field type 'seq-tb' for PAL, or 'alternate').
0495
0496 .. code-block:: none
0497
0498 # Setup links
0499 media-ctl -l "'adv7180 3-0021':0 -> 'ipu1_csi0_mux':1[1]"
0500 media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]"
0501 media-ctl -l "'ipu1_csi0':1 -> 'ipu1_vdic':0[1]"
0502 media-ctl -l "'ipu1_vdic':2 -> 'ipu1_ic_prp':0[1]"
0503 media-ctl -l "'ipu1_ic_prp':2 -> 'ipu1_ic_prpvf':0[1]"
0504 media-ctl -l "'ipu1_ic_prpvf':1 -> 'ipu1_ic_prpvf capture':0[1]"
0505 # Configure pads
0506 media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x576 field:seq-tb]"
0507 media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x576]"
0508 media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/720x576]"
0509 media-ctl -V "'ipu1_vdic':2 [fmt:AYUV32/720x576 field:none]"
0510 media-ctl -V "'ipu1_ic_prp':2 [fmt:AYUV32/720x576 field:none]"
0511 media-ctl -V "'ipu1_ic_prpvf':1 [fmt:AYUV32/720x576 field:none]"
0512 # Configure "ipu1_ic_prpvf capture" interface (assumed at /dev/video2)
0513 v4l2-ctl -d2 --set-fmt-video=field=none
0514
0515 Streaming can then begin on /dev/video2. The v4l2-ctl tool can also be
0516 used to select any supported YUV pixelformat on /dev/video2.
0517
0518 This platform accepts Composite Video analog inputs to the ADV7180 on
0519 Ain1 (connector J42).
0520
0521 i.MX6DL SabreAuto with ADV7180 decoder
0522 --------------------------------------
0523
0524 On the i.MX6DL SabreAuto, an on-board ADV7180 SD decoder is connected to the
0525 parallel bus input on the internal video mux to IPU1 CSI0.
0526
0527 The following example configures a pipeline to capture from the ADV7180
0528 video decoder, assuming NTSC 720x480 input signals, using simple
0529 interweave (unconverted and without motion compensation). The adv7180
0530 must output sequential or alternating fields (field type 'seq-bt' for
0531 NTSC, or 'alternate'):
0532
0533 .. code-block:: none
0534
0535 # Setup links
0536 media-ctl -l "'adv7180 4-0021':0 -> 'ipu1_csi0_mux':4[1]"
0537 media-ctl -l "'ipu1_csi0_mux':5 -> 'ipu1_csi0':0[1]"
0538 media-ctl -l "'ipu1_csi0':2 -> 'ipu1_csi0 capture':0[1]"
0539 # Configure pads
0540 media-ctl -V "'adv7180 4-0021':0 [fmt:UYVY2X8/720x480 field:seq-bt]"
0541 media-ctl -V "'ipu1_csi0_mux':5 [fmt:UYVY2X8/720x480]"
0542 media-ctl -V "'ipu1_csi0':2 [fmt:AYUV32/720x480]"
0543 # Configure "ipu1_csi0 capture" interface (assumed at /dev/video0)
0544 v4l2-ctl -d0 --set-fmt-video=field=interlaced_bt
0545
0546 Streaming can then begin on /dev/video0. The v4l2-ctl tool can also be
0547 used to select any supported YUV pixelformat on /dev/video0.
0548
0549 This example configures a pipeline to capture from the ADV7180
0550 video decoder, assuming PAL 720x576 input signals, with Motion
0551 Compensated de-interlacing. The adv7180 must output sequential or
0552 alternating fields (field type 'seq-tb' for PAL, or 'alternate').
0553
0554 .. code-block:: none
0555
0556 # Setup links
0557 media-ctl -l "'adv7180 4-0021':0 -> 'ipu1_csi0_mux':4[1]"
0558 media-ctl -l "'ipu1_csi0_mux':5 -> 'ipu1_csi0':0[1]"
0559 media-ctl -l "'ipu1_csi0':1 -> 'ipu1_vdic':0[1]"
0560 media-ctl -l "'ipu1_vdic':2 -> 'ipu1_ic_prp':0[1]"
0561 media-ctl -l "'ipu1_ic_prp':2 -> 'ipu1_ic_prpvf':0[1]"
0562 media-ctl -l "'ipu1_ic_prpvf':1 -> 'ipu1_ic_prpvf capture':0[1]"
0563 # Configure pads
0564 media-ctl -V "'adv7180 4-0021':0 [fmt:UYVY2X8/720x576 field:seq-tb]"
0565 media-ctl -V "'ipu1_csi0_mux':5 [fmt:UYVY2X8/720x576]"
0566 media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/720x576]"
0567 media-ctl -V "'ipu1_vdic':2 [fmt:AYUV32/720x576 field:none]"
0568 media-ctl -V "'ipu1_ic_prp':2 [fmt:AYUV32/720x576 field:none]"
0569 media-ctl -V "'ipu1_ic_prpvf':1 [fmt:AYUV32/720x576 field:none]"
0570 # Configure "ipu1_ic_prpvf capture" interface (assumed at /dev/video2)
0571 v4l2-ctl -d2 --set-fmt-video=field=none
0572
0573 Streaming can then begin on /dev/video2. The v4l2-ctl tool can also be
0574 used to select any supported YUV pixelformat on /dev/video2.
0575
0576 This platform accepts Composite Video analog inputs to the ADV7180 on
0577 Ain1 (connector J42).
0578
0579 i.MX6Q SabreSD with MIPI CSI-2 OV5640
0580 -------------------------------------
0581
0582 Similarly to i.MX6Q SabreLite, the i.MX6Q SabreSD supports a parallel
0583 interface OV5642 module on IPU1 CSI0, and a MIPI CSI-2 OV5640
0584 module. The OV5642 connects to i2c bus 1 and the OV5640 to i2c bus 2.
0585
0586 The device tree for SabreSD includes OF graphs for both the parallel
0587 OV5642 and the MIPI CSI-2 OV5640, but as of this writing only the MIPI
0588 CSI-2 OV5640 has been tested, so the OV5642 node is currently disabled.
0589 The OV5640 module connects to MIPI connector J5. The NXP part number
0590 for the OV5640 module that connects to the SabreSD board is H120729.
0591
0592 The following example configures unprocessed video capture pipeline to
0593 capture from the OV5640, transmitting on MIPI CSI-2 virtual channel 0:
0594
0595 .. code-block:: none
0596
0597 # Setup links
0598 media-ctl -l "'ov5640 1-003c':0 -> 'imx6-mipi-csi2':0[1]"
0599 media-ctl -l "'imx6-mipi-csi2':1 -> 'ipu1_csi0_mux':0[1]"
0600 media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]"
0601 media-ctl -l "'ipu1_csi0':2 -> 'ipu1_csi0 capture':0[1]"
0602 # Configure pads
0603 media-ctl -V "'ov5640 1-003c':0 [fmt:UYVY2X8/640x480]"
0604 media-ctl -V "'imx6-mipi-csi2':1 [fmt:UYVY2X8/640x480]"
0605 media-ctl -V "'ipu1_csi0_mux':0 [fmt:UYVY2X8/640x480]"
0606 media-ctl -V "'ipu1_csi0':0 [fmt:AYUV32/640x480]"
0607
0608 Streaming can then begin on "ipu1_csi0 capture" node. The v4l2-ctl
0609 tool can be used to select any supported pixelformat on the capture
0610 device node.
0611
0612 To determine what is the /dev/video node correspondent to
0613 "ipu1_csi0 capture":
0614
0615 .. code-block:: none
0616
0617 media-ctl -e "ipu1_csi0 capture"
0618 /dev/video0
0619
0620 /dev/video0 is the streaming element in this case.
0621
0622 Starting the streaming via v4l2-ctl:
0623
0624 .. code-block:: none
0625
0626 v4l2-ctl --stream-mmap -d /dev/video0
0627
0628 Starting the streaming via Gstreamer and sending the content to the display:
0629
0630 .. code-block:: none
0631
0632 gst-launch-1.0 v4l2src device=/dev/video0 ! kmssink
0633
0634 The following example configures a direct conversion pipeline to capture
0635 from the OV5640, transmitting on MIPI CSI-2 virtual channel 0. It also
0636 shows colorspace conversion and scaling at IC output.
0637
0638 .. code-block:: none
0639
0640 # Setup links
0641 media-ctl -l "'ov5640 1-003c':0 -> 'imx6-mipi-csi2':0[1]"
0642 media-ctl -l "'imx6-mipi-csi2':1 -> 'ipu1_csi0_mux':0[1]"
0643 media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]"
0644 media-ctl -l "'ipu1_csi0':1 -> 'ipu1_ic_prp':0[1]"
0645 media-ctl -l "'ipu1_ic_prp':1 -> 'ipu1_ic_prpenc':0[1]"
0646 media-ctl -l "'ipu1_ic_prpenc':1 -> 'ipu1_ic_prpenc capture':0[1]"
0647 # Configure pads
0648 media-ctl -V "'ov5640 1-003c':0 [fmt:UYVY2X8/640x480]"
0649 media-ctl -V "'imx6-mipi-csi2':1 [fmt:UYVY2X8/640x480]"
0650 media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/640x480]"
0651 media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/640x480]"
0652 media-ctl -V "'ipu1_ic_prp':1 [fmt:AYUV32/640x480]"
0653 media-ctl -V "'ipu1_ic_prpenc':1 [fmt:ARGB8888_1X32/800x600]"
0654 # Set a format at the capture interface
0655 v4l2-ctl -d /dev/video1 --set-fmt-video=pixelformat=RGB3
0656
0657 Streaming can then begin on "ipu1_ic_prpenc capture" node.
0658
0659 To determine what is the /dev/video node correspondent to
0660 "ipu1_ic_prpenc capture":
0661
0662 .. code-block:: none
0663
0664 media-ctl -e "ipu1_ic_prpenc capture"
0665 /dev/video1
0666
0667
0668 /dev/video1 is the streaming element in this case.
0669
0670 Starting the streaming via v4l2-ctl:
0671
0672 .. code-block:: none
0673
0674 v4l2-ctl --stream-mmap -d /dev/video1
0675
0676 Starting the streaming via Gstreamer and sending the content to the display:
0677
0678 .. code-block:: none
0679
0680 gst-launch-1.0 v4l2src device=/dev/video1 ! kmssink
0681
0682 Known Issues
0683 ------------
0684
0685 1. When using 90 or 270 degree rotation control at capture resolutions
0686 near the IC resizer limit of 1024x1024, and combined with planar
0687 pixel formats (YUV420, YUV422p), frame capture will often fail with
0688 no end-of-frame interrupts from the IDMAC channel. To work around
0689 this, use lower resolution and/or packed formats (YUYV, RGB3, etc.)
0690 when 90 or 270 rotations are needed.
0691
0692
0693 File list
0694 ---------
0695
0696 drivers/staging/media/imx/
0697 include/media/imx.h
0698 include/linux/imx-media.h
0699
0700 References
0701 ----------
0702
0703 .. [#f1] http://www.nxp.com/assets/documents/data/en/reference-manuals/IMX6DQRM.pdf
0704 .. [#f2] http://www.nxp.com/assets/documents/data/en/reference-manuals/IMX6SDLRM.pdf
0705
0706
0707 Authors
0708 -------
0709
0710 - Steve Longerbeam <steve_longerbeam@mentor.com>
0711 - Philipp Zabel <kernel@pengutronix.de>
0712 - Russell King <linux@armlinux.org.uk>
0713
0714 Copyright (C) 2012-2017 Mentor Graphics Inc.