162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci.. include:: <isonum.txt>
462306a36Sopenharmony_ci
562306a36Sopenharmony_ciThe Samsung S5P/Exynos4 FIMC driver
662306a36Sopenharmony_ci===================================
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciCopyright |copy| 2012 - 2013 Samsung Electronics Co., Ltd.
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciThe FIMC (Fully Interactive Mobile Camera) device available in Samsung
1162306a36Sopenharmony_ciSoC Application Processors is an integrated camera host interface, color
1262306a36Sopenharmony_cispace converter, image resizer and rotator.  It's also capable of capturing
1362306a36Sopenharmony_cidata from LCD controller (FIMD) through the SoC internal writeback data
1462306a36Sopenharmony_cipath.  There are multiple FIMC instances in the SoCs (up to 4), having
1562306a36Sopenharmony_cislightly different capabilities, like pixel alignment constraints, rotator
1662306a36Sopenharmony_ciavailability, LCD writeback support, etc. The driver is located at
1762306a36Sopenharmony_cidrivers/media/platform/samsung/exynos4-is directory.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciSupported SoCs
2062306a36Sopenharmony_ci--------------
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciS5PC100 (mem-to-mem only), S5PV210, Exynos4210
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciSupported features
2562306a36Sopenharmony_ci------------------
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci- camera parallel interface capture (ITU-R.BT601/565);
2862306a36Sopenharmony_ci- camera serial interface capture (MIPI-CSI2);
2962306a36Sopenharmony_ci- memory-to-memory processing (color space conversion, scaling, mirror
3062306a36Sopenharmony_ci  and rotation);
3162306a36Sopenharmony_ci- dynamic pipeline re-configuration at runtime (re-attachment of any FIMC
3262306a36Sopenharmony_ci  instance to any parallel video input or any MIPI-CSI front-end);
3362306a36Sopenharmony_ci- runtime PM and system wide suspend/resume
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciNot currently supported
3662306a36Sopenharmony_ci-----------------------
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci- LCD writeback input
3962306a36Sopenharmony_ci- per frame clock gating (mem-to-mem)
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ciUser space interfaces
4262306a36Sopenharmony_ci---------------------
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciMedia device interface
4562306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ciThe driver supports Media Controller API as defined at :ref:`media_controller`.
4862306a36Sopenharmony_ciThe media device driver name is "Samsung S5P FIMC".
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ciThe purpose of this interface is to allow changing assignment of FIMC instances
5162306a36Sopenharmony_cito the SoC peripheral camera input at runtime and optionally to control internal
5262306a36Sopenharmony_ciconnections of the MIPI-CSIS device(s) to the FIMC entities.
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ciThe media device interface allows to configure the SoC for capturing image
5562306a36Sopenharmony_cidata from the sensor through more than one FIMC instance (e.g. for simultaneous
5662306a36Sopenharmony_civiewfinder and still capture setup).
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ciReconfiguration is done by enabling/disabling media links created by the driver
5962306a36Sopenharmony_ciduring initialization. The internal device topology can be easily discovered
6062306a36Sopenharmony_cithrough media entity and links enumeration.
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciMemory-to-memory video node
6362306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~~~~~~
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ciV4L2 memory-to-memory interface at /dev/video? device node.  This is standalone
6662306a36Sopenharmony_civideo device, it has no media pads. However please note the mem-to-mem and
6762306a36Sopenharmony_cicapture video node operation on same FIMC instance is not allowed.  The driver
6862306a36Sopenharmony_cidetects such cases but the applications should prevent them to avoid an
6962306a36Sopenharmony_ciundefined behaviour.
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciCapture video node
7262306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciThe driver supports V4L2 Video Capture Interface as defined at
7562306a36Sopenharmony_ci:ref:`devices`.
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ciAt the capture and mem-to-mem video nodes only the multi-planar API is
7862306a36Sopenharmony_cisupported. For more details see: :ref:`planar-apis`.
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciCamera capture subdevs
8162306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~~
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ciEach FIMC instance exports a sub-device node (/dev/v4l-subdev?), a sub-device
8462306a36Sopenharmony_cinode is also created per each available and enabled at the platform level
8562306a36Sopenharmony_ciMIPI-CSI receiver device (currently up to two).
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_cisysfs
8862306a36Sopenharmony_ci~~~~~
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ciIn order to enable more precise camera pipeline control through the sub-device
9162306a36Sopenharmony_ciAPI the driver creates a sysfs entry associated with "s5p-fimc-md" platform
9262306a36Sopenharmony_cidevice. The entry path is: /sys/platform/devices/s5p-fimc-md/subdev_conf_mode.
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ciIn typical use case there could be a following capture pipeline configuration:
9562306a36Sopenharmony_cisensor subdev -> mipi-csi subdev -> fimc subdev -> video node
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ciWhen we configure these devices through sub-device API at user space, the
9862306a36Sopenharmony_ciconfiguration flow must be from left to right, and the video node is
9962306a36Sopenharmony_ciconfigured as last one.
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ciWhen we don't use sub-device user space API the whole configuration of all
10262306a36Sopenharmony_cidevices belonging to the pipeline is done at the video node driver.
10362306a36Sopenharmony_ciThe sysfs entry allows to instruct the capture node driver not to configure
10462306a36Sopenharmony_cithe sub-devices (format, crop), to avoid resetting the subdevs' configuration
10562306a36Sopenharmony_ciwhen the last configuration steps at the video node is performed.
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ciFor full sub-device control support (subdevs configured at user space before
10862306a36Sopenharmony_cistarting streaming):
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci.. code-block:: none
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci	# echo "sub-dev" > /sys/platform/devices/s5p-fimc-md/subdev_conf_mode
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ciFor V4L2 video node control only (subdevs configured internally by the host
11562306a36Sopenharmony_cidriver):
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci.. code-block:: none
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci	# echo "vid-dev" > /sys/platform/devices/s5p-fimc-md/subdev_conf_mode
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ciThis is a default option.
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci5. Device mapping to video and subdev device nodes
12462306a36Sopenharmony_ci--------------------------------------------------
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ciThere are associated two video device nodes with each device instance in
12762306a36Sopenharmony_cihardware - video capture and mem-to-mem and additionally a subdev node for
12862306a36Sopenharmony_cimore precise FIMC capture subsystem control. In addition a separate v4l2
12962306a36Sopenharmony_cisub-device node is created per each MIPI-CSIS device.
13062306a36Sopenharmony_ci
13162306a36Sopenharmony_ciHow to find out which /dev/video? or /dev/v4l-subdev? is assigned to which
13262306a36Sopenharmony_cidevice?
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ciYou can either grep through the kernel log to find relevant information, i.e.
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci.. code-block:: none
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci	# dmesg | grep -i fimc
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci(note that udev, if present, might still have rearranged the video nodes),
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_cior retrieve the information from /dev/media? with help of the media-ctl tool:
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci.. code-block:: none
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	# media-ctl -p
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci7. Build
14962306a36Sopenharmony_ci--------
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ciIf the driver is built as a loadable kernel module (CONFIG_VIDEO_SAMSUNG_S5P_FIMC=m)
15262306a36Sopenharmony_citwo modules are created (in addition to the core v4l2 modules): s5p-fimc.ko and
15362306a36Sopenharmony_cioptional s5p-csis.ko (MIPI-CSI receiver subdev).
154