18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci.. _mem2mem: 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci******************************** 68c2ecf20Sopenharmony_ciVideo Memory-To-Memory Interface 78c2ecf20Sopenharmony_ci******************************** 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciA V4L2 memory-to-memory device can compress, decompress, transform, or 108c2ecf20Sopenharmony_ciotherwise convert video data from one format into another format, in memory. 118c2ecf20Sopenharmony_ciSuch memory-to-memory devices set the ``V4L2_CAP_VIDEO_M2M`` or 128c2ecf20Sopenharmony_ci``V4L2_CAP_VIDEO_M2M_MPLANE`` capability. Examples of memory-to-memory 138c2ecf20Sopenharmony_cidevices are codecs, scalers, deinterlacers or format converters (i.e. 148c2ecf20Sopenharmony_ciconverting from YUV to RGB). 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciA memory-to-memory video node acts just like a normal video node, but it 178c2ecf20Sopenharmony_cisupports both output (sending frames from memory to the hardware) 188c2ecf20Sopenharmony_ciand capture (receiving the processed frames from the hardware into 198c2ecf20Sopenharmony_cimemory) stream I/O. An application will have to setup the stream I/O for 208c2ecf20Sopenharmony_ciboth sides and finally call :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>` 218c2ecf20Sopenharmony_cifor both capture and output to start the hardware. 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ciMemory-to-memory devices function as a shared resource: you can 248c2ecf20Sopenharmony_ciopen the video node multiple times, each application setting up their 258c2ecf20Sopenharmony_ciown properties that are local to the file handle, and each can use 268c2ecf20Sopenharmony_ciit independently from the others. The driver will arbitrate access to 278c2ecf20Sopenharmony_cithe hardware and reprogram it whenever another file handler gets access. 288c2ecf20Sopenharmony_ciThis is different from the usual video node behavior where the video 298c2ecf20Sopenharmony_ciproperties are global to the device (i.e. changing something through one 308c2ecf20Sopenharmony_cifile handle is visible through another file handle). 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciOne of the most common memory-to-memory device is the codec. Codecs 338c2ecf20Sopenharmony_ciare more complicated than most and require additional setup for 348c2ecf20Sopenharmony_citheir codec parameters. This is done through codec controls. 358c2ecf20Sopenharmony_ciSee :ref:`mpeg-controls`. More details on how to use codec memory-to-memory 368c2ecf20Sopenharmony_cidevices are given in the following sections. 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci.. toctree:: 398c2ecf20Sopenharmony_ci :maxdepth: 1 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci dev-decoder 428c2ecf20Sopenharmony_ci dev-encoder 438c2ecf20Sopenharmony_ci dev-stateless-decoder 44