xref: /linux/Documentation/admin-guide/media/ipu6-isys.rst (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1ba124c8cSBingbu Cao.. SPDX-License-Identifier: GPL-2.0
2ba124c8cSBingbu Cao
3ba124c8cSBingbu Cao.. include:: <isonum.txt>
4ba124c8cSBingbu Cao
5ba124c8cSBingbu Cao========================================================
6ba124c8cSBingbu CaoIntel Image Processing Unit 6 (IPU6) Input System driver
7ba124c8cSBingbu Cao========================================================
8ba124c8cSBingbu Cao
9ba124c8cSBingbu CaoCopyright |copy| 2023--2024 Intel Corporation
10ba124c8cSBingbu Cao
11ba124c8cSBingbu CaoIntroduction
12ba124c8cSBingbu Cao============
13ba124c8cSBingbu Cao
14ba124c8cSBingbu CaoThis file documents the Intel IPU6 (6th generation Image Processing Unit)
15ba124c8cSBingbu CaoInput System (MIPI CSI2 receiver) drivers located under
16ba124c8cSBingbu Caodrivers/media/pci/intel/ipu6.
17ba124c8cSBingbu Cao
18ba124c8cSBingbu CaoThe Intel IPU6 can be found in certain Intel SoCs but not in all SKUs:
19ba124c8cSBingbu Cao
20ba124c8cSBingbu Cao* Tiger Lake
21ba124c8cSBingbu Cao* Jasper Lake
22ba124c8cSBingbu Cao* Alder Lake
23ba124c8cSBingbu Cao* Raptor Lake
24ba124c8cSBingbu Cao* Meteor Lake
25ba124c8cSBingbu Cao
26ba124c8cSBingbu CaoIntel IPU6 is made up of two components - Input System (ISYS) and Processing
27ba124c8cSBingbu CaoSystem (PSYS).
28ba124c8cSBingbu Cao
29ba124c8cSBingbu CaoThe Input System mainly works as MIPI CSI-2 receiver which receives and
30ba124c8cSBingbu Caoprocesses the image data from the sensors and outputs the frames to memory.
31ba124c8cSBingbu Cao
32ba124c8cSBingbu CaoThere are 2 driver modules - intel-ipu6 and intel-ipu6-isys. intel-ipu6 is an
33ba124c8cSBingbu CaoIPU6 common driver which does PCI configuration, firmware loading and parsing,
34ba124c8cSBingbu Caofirmware authentication, DMA mapping and IPU-MMU (internal Memory mapping Unit)
35ba124c8cSBingbu Caoconfiguration. intel_ipu6_isys implements V4L2, Media Controller and V4L2
36ba124c8cSBingbu Caosub-device interfaces. The IPU6 ISYS driver supports camera sensors connected
37ba124c8cSBingbu Caoto the IPU6 ISYS through V4L2 sub-device sensor drivers.
38ba124c8cSBingbu Cao
39ba124c8cSBingbu Cao.. Note:: See Documentation/driver-api/media/drivers/ipu6.rst for more
40ba124c8cSBingbu Cao	  information about the IPU6 hardware.
41ba124c8cSBingbu Cao
42ba124c8cSBingbu CaoInput system driver
43ba124c8cSBingbu Cao===================
44ba124c8cSBingbu Cao
45ba124c8cSBingbu CaoThe Input System driver mainly configures CSI-2 D-PHY, constructs the firmware
46ba124c8cSBingbu Caostream configuration, sends commands to firmware, gets response from hardware
47ba124c8cSBingbu Caoand firmware and then returns buffers to user.  The ISYS is represented as
48ba124c8cSBingbu Caoseveral V4L2 sub-devices as well as video nodes.
49ba124c8cSBingbu Cao
50ba124c8cSBingbu Cao.. kernel-figure::  ipu6_isys_graph.svg
51ba124c8cSBingbu Cao   :alt: ipu6 isys media graph with multiple streams support
52ba124c8cSBingbu Cao
53ba124c8cSBingbu Cao   IPU6 ISYS media graph with multiple streams support
54ba124c8cSBingbu Cao
55ba124c8cSBingbu CaoThe graph has been produced using the following command:
56ba124c8cSBingbu Cao
57ba124c8cSBingbu Cao.. code-block:: none
58ba124c8cSBingbu Cao
59ba124c8cSBingbu Cao   fdp -Gsplines=true -Tsvg < dot > dot.svg
60ba124c8cSBingbu Cao
61ba124c8cSBingbu CaoCapturing frames with IPU6 ISYS
62ba124c8cSBingbu Cao-------------------------------
63ba124c8cSBingbu Cao
64ba124c8cSBingbu CaoIPU6 ISYS is used to capture frames from the camera sensors connected to the
65ba124c8cSBingbu CaoCSI2 ports. The supported input formats of ISYS are listed in table below:
66ba124c8cSBingbu Cao
67ba124c8cSBingbu Cao.. tabularcolumns:: |p{0.8cm}|p{4.0cm}|p{4.0cm}|
68ba124c8cSBingbu Cao
69ba124c8cSBingbu Cao.. flat-table::
70ba124c8cSBingbu Cao    :header-rows: 1
71ba124c8cSBingbu Cao
72ba124c8cSBingbu Cao    * - IPU6 ISYS supported input formats
73ba124c8cSBingbu Cao
74ba124c8cSBingbu Cao    * - RGB565, RGB888
75ba124c8cSBingbu Cao
76ba124c8cSBingbu Cao    * - UYVY8, YUYV8
77ba124c8cSBingbu Cao
78ba124c8cSBingbu Cao    * - RAW8, RAW10, RAW12
79ba124c8cSBingbu Cao
80ba124c8cSBingbu Cao.. _ipu6_isys_capture_examples:
81ba124c8cSBingbu Cao
82ba124c8cSBingbu CaoExamples
83ba124c8cSBingbu Cao~~~~~~~~
84ba124c8cSBingbu Cao
85ba124c8cSBingbu CaoHere is an example of IPU6 ISYS raw capture on Dell XPS 9315 laptop. On this
86ba124c8cSBingbu Caomachine, ov01a10 sensor is connected to IPU ISYS CSI-2 port 2, which can
87ba124c8cSBingbu Caogenerate images at sBGGR10 with resolution 1280x800.
88ba124c8cSBingbu Cao
89ba124c8cSBingbu CaoUsing the media controller APIs, we can configure ov01a10 sensor by
90ba124c8cSBingbu Caomedia-ctl [#f1]_ and yavta [#f2]_ to transmit frames to IPU6 ISYS.
91ba124c8cSBingbu Cao
92ba124c8cSBingbu Cao.. code-block:: none
93ba124c8cSBingbu Cao
94ba124c8cSBingbu Cao    # Example 1 capture frame from ov01a10 camera sensor
95ba124c8cSBingbu Cao    # This example assumes /dev/media0 as the IPU ISYS media device
96ba124c8cSBingbu Cao    export MDEV=/dev/media0
97ba124c8cSBingbu Cao
98ba124c8cSBingbu Cao    # Establish the link for the media devices using media-ctl
99ba124c8cSBingbu Cao    media-ctl -d $MDEV -l "\"ov01a10 3-0036\":0 -> \"Intel IPU6 CSI2 2\":0[1]"
100ba124c8cSBingbu Cao
101ba124c8cSBingbu Cao    # Set the format for the media devices
102ba124c8cSBingbu Cao    media-ctl -d $MDEV -V "ov01a10:0 [fmt:SBGGR10/1280x800]"
103ba124c8cSBingbu Cao    media-ctl -d $MDEV -V "Intel IPU6 CSI2 2:0 [fmt:SBGGR10/1280x800]"
104ba124c8cSBingbu Cao    media-ctl -d $MDEV -V "Intel IPU6 CSI2 2:1 [fmt:SBGGR10/1280x800]"
105ba124c8cSBingbu Cao
106ba124c8cSBingbu CaoOnce the media pipeline is configured, desired sensor specific settings
107ba124c8cSBingbu Cao(such as exposure and gain settings) can be set, using the yavta tool.
108ba124c8cSBingbu Cao
109ba124c8cSBingbu Caoe.g
110ba124c8cSBingbu Cao
111ba124c8cSBingbu Cao.. code-block:: none
112ba124c8cSBingbu Cao
113ba124c8cSBingbu Cao    # and that ov01a10 sensor is connected to i2c bus 3 with address 0x36
114ba124c8cSBingbu Cao    export SDEV=$(media-ctl -d $MDEV -e "ov01a10 3-0036")
115ba124c8cSBingbu Cao
116ba124c8cSBingbu Cao    yavta -w 0x009e0903 400 $SDEV
117ba124c8cSBingbu Cao    yavta -w 0x009e0913 1000 $SDEV
118ba124c8cSBingbu Cao    yavta -w 0x009e0911 2000 $SDEV
119ba124c8cSBingbu Cao
120ba124c8cSBingbu CaoOnce the desired sensor settings are set, frame captures can be done as below.
121ba124c8cSBingbu Cao
122ba124c8cSBingbu Caoe.g
123ba124c8cSBingbu Cao
124ba124c8cSBingbu Cao.. code-block:: none
125ba124c8cSBingbu Cao
126ba124c8cSBingbu Cao    yavta --data-prefix -u -c10 -n5 -I -s 1280x800 --file=/tmp/frame-#.bin \
127ba124c8cSBingbu Cao            -f SBGGR10 $(media-ctl -d $MDEV -e "Intel IPU6 ISYS Capture 0")
128ba124c8cSBingbu Cao
129ba124c8cSBingbu CaoWith the above command, 10 frames are captured at 1280x800 resolution with
130ba124c8cSBingbu CaosBGGR10 format. The captured frames are available as /tmp/frame-#.bin files.
131ba124c8cSBingbu Cao
132ba124c8cSBingbu CaoHere is another example of IPU6 ISYS RAW and metadata capture from camera
133ba124c8cSBingbu Caosensor ov2740 on Lenovo X1 Yoga laptop.
134ba124c8cSBingbu Cao
135ba124c8cSBingbu Cao.. code-block:: none
136ba124c8cSBingbu Cao
137ba124c8cSBingbu Cao    media-ctl -l "\"ov2740 14-0036\":0 -> \"Intel IPU6 CSI2 1\":0[1]"
138*9123419cSSamuel Wein    media-ctl -l "\"Intel IPU6 CSI2 1\":1 -> \"Intel IPU6 ISYS Capture 0\":0[1]"
139*9123419cSSamuel Wein    media-ctl -l "\"Intel IPU6 CSI2 1\":2 -> \"Intel IPU6 ISYS Capture 1\":0[1]"
140ba124c8cSBingbu Cao
141ba124c8cSBingbu Cao    # set routing
142*9123419cSSamuel Wein    media-ctl -R "\"Intel IPU6 CSI2 1\" [0/0->1/0[1],0/1->2/1[1]]"
143ba124c8cSBingbu Cao
144*9123419cSSamuel Wein    media-ctl -V "\"Intel IPU6 CSI2 1\":0/0 [fmt:SGRBG10/1932x1092]"
145*9123419cSSamuel Wein    media-ctl -V "\"Intel IPU6 CSI2 1\":0/1 [fmt:GENERIC_8/97x1]"
146*9123419cSSamuel Wein    media-ctl -V "\"Intel IPU6 CSI2 1\":1/0 [fmt:SGRBG10/1932x1092]"
147*9123419cSSamuel Wein    media-ctl -V "\"Intel IPU6 CSI2 1\":2/1 [fmt:GENERIC_8/97x1]"
148ba124c8cSBingbu Cao
149ba124c8cSBingbu Cao    CAPTURE_DEV=$(media-ctl -e "Intel IPU6 ISYS Capture 0")
150ba124c8cSBingbu Cao    ./yavta --data-prefix -c100 -n5 -I -s1932x1092 --file=/tmp/frame-#.bin \
151ba124c8cSBingbu Cao        -f SGRBG10 ${CAPTURE_DEV}
152ba124c8cSBingbu Cao
153ba124c8cSBingbu Cao    CAPTURE_META=$(media-ctl -e "Intel IPU6 ISYS Capture 1")
154ba124c8cSBingbu Cao    ./yavta --data-prefix -c100 -n5 -I -s97x1 -B meta-capture \
155ba124c8cSBingbu Cao        --file=/tmp/meta-#.bin -f GENERIC_8 ${CAPTURE_META}
156ba124c8cSBingbu Cao
157ba124c8cSBingbu CaoReferences
158ba124c8cSBingbu Cao==========
159ba124c8cSBingbu Cao
160ba124c8cSBingbu Cao.. [#f1] https://git.ideasonboard.org/media-ctl.git
161ba124c8cSBingbu Cao.. [#f2] https://git.ideasonboard.org/yavta.git
162