xref: /openbmc/linux/Documentation/gpu/tegra.rst (revision c25141062a82ae8bddced1b3ce2b57a1c0efabe0)
1*fa6d095eSThierry Reding===============================================
2*fa6d095eSThierry Reding drm/tegra NVIDIA Tegra GPU and display driver
3*fa6d095eSThierry Reding===============================================
4*fa6d095eSThierry Reding
5*fa6d095eSThierry RedingNVIDIA Tegra SoCs support a set of display, graphics and video functions via
6*fa6d095eSThierry Redingthe host1x controller. host1x supplies command streams, gathered from a push
7*fa6d095eSThierry Redingbuffer provided directly by the CPU, to its clients via channels. Software,
8*fa6d095eSThierry Redingor blocks amongst themselves, can use syncpoints for synchronization.
9*fa6d095eSThierry Reding
10*fa6d095eSThierry RedingUp until, but not including, Tegra124 (aka Tegra K1) the drm/tegra driver
11*fa6d095eSThierry Redingsupports the built-in GPU, comprised of the gr2d and gr3d engines. Starting
12*fa6d095eSThierry Redingwith Tegra124 the GPU is based on the NVIDIA desktop GPU architecture and
13*fa6d095eSThierry Redingsupported by the drm/nouveau driver.
14*fa6d095eSThierry Reding
15*fa6d095eSThierry RedingThe drm/tegra driver supports NVIDIA Tegra SoC generations since Tegra20. It
16*fa6d095eSThierry Redinghas three parts:
17*fa6d095eSThierry Reding
18*fa6d095eSThierry Reding  - A host1x driver that provides infrastructure and access to the host1x
19*fa6d095eSThierry Reding    services.
20*fa6d095eSThierry Reding
21*fa6d095eSThierry Reding  - A KMS driver that supports the display controllers as well as a number of
22*fa6d095eSThierry Reding    outputs, such as RGB, HDMI, DSI, and DisplayPort.
23*fa6d095eSThierry Reding
24*fa6d095eSThierry Reding  - A set of custom userspace IOCTLs that can be used to submit jobs to the
25*fa6d095eSThierry Reding    GPU and video engines via host1x.
26*fa6d095eSThierry Reding
27*fa6d095eSThierry RedingDriver Infrastructure
28*fa6d095eSThierry Reding=====================
29*fa6d095eSThierry Reding
30*fa6d095eSThierry RedingThe various host1x clients need to be bound together into a logical device in
31*fa6d095eSThierry Redingorder to expose their functionality to users. The infrastructure that supports
32*fa6d095eSThierry Redingthis is implemented in the host1x driver. When a driver is registered with the
33*fa6d095eSThierry Redinginfrastructure it provides a list of compatible strings specifying the devices
34*fa6d095eSThierry Redingthat it needs. The infrastructure creates a logical device and scan the device
35*fa6d095eSThierry Redingtree for matching device nodes, adding the required clients to a list. Drivers
36*fa6d095eSThierry Redingfor individual clients register with the infrastructure as well and are added
37*fa6d095eSThierry Redingto the logical host1x device.
38*fa6d095eSThierry Reding
39*fa6d095eSThierry RedingOnce all clients are available, the infrastructure will initialize the logical
40*fa6d095eSThierry Redingdevice using a driver-provided function which will set up the bits specific to
41*fa6d095eSThierry Redingthe subsystem and in turn initialize each of its clients.
42*fa6d095eSThierry Reding
43*fa6d095eSThierry RedingSimilarly, when one of the clients is unregistered, the infrastructure will
44*fa6d095eSThierry Redingdestroy the logical device by calling back into the driver, which ensures that
45*fa6d095eSThierry Redingthe subsystem specific bits are torn down and the clients destroyed in turn.
46*fa6d095eSThierry Reding
47*fa6d095eSThierry RedingHost1x Infrastructure Reference
48*fa6d095eSThierry Reding-------------------------------
49*fa6d095eSThierry Reding
50*fa6d095eSThierry Reding.. kernel-doc:: include/linux/host1x.h
51*fa6d095eSThierry Reding
52*fa6d095eSThierry Reding.. kernel-doc:: drivers/gpu/host1x/bus.c
53*fa6d095eSThierry Reding   :export:
54*fa6d095eSThierry Reding
55*fa6d095eSThierry RedingHost1x Syncpoint Reference
56*fa6d095eSThierry Reding--------------------------
57*fa6d095eSThierry Reding
58*fa6d095eSThierry Reding.. kernel-doc:: drivers/gpu/host1x/syncpt.c
59*fa6d095eSThierry Reding   :export:
60*fa6d095eSThierry Reding
61*fa6d095eSThierry RedingKMS driver
62*fa6d095eSThierry Reding==========
63*fa6d095eSThierry Reding
64*fa6d095eSThierry RedingThe display hardware has remained mostly backwards compatible over the various
65*fa6d095eSThierry RedingTegra SoC generations, up until Tegra186 which introduces several changes that
66*fa6d095eSThierry Redingmake it difficult to support with a parameterized driver.
67*fa6d095eSThierry Reding
68*fa6d095eSThierry RedingDisplay Controllers
69*fa6d095eSThierry Reding-------------------
70*fa6d095eSThierry Reding
71*fa6d095eSThierry RedingTegra SoCs have two display controllers, each of which can be associated with
72*fa6d095eSThierry Redingzero or more outputs. Outputs can also share a single display controller, but
73*fa6d095eSThierry Redingonly if they run with compatible display timings. Two display controllers can
74*fa6d095eSThierry Redingalso share a single framebuffer, allowing cloned configurations even if modes
75*fa6d095eSThierry Redingon two outputs don't match. A display controller is modelled as a CRTC in KMS
76*fa6d095eSThierry Redingterms.
77*fa6d095eSThierry Reding
78*fa6d095eSThierry RedingOn Tegra186, the number of display controllers has been increased to three. A
79*fa6d095eSThierry Redingdisplay controller can no longer drive all of the outputs. While two of these
80*fa6d095eSThierry Redingcontrollers can drive both DSI outputs and both SOR outputs, the third cannot
81*fa6d095eSThierry Redingdrive any DSI.
82*fa6d095eSThierry Reding
83*fa6d095eSThierry RedingWindows
84*fa6d095eSThierry Reding~~~~~~~
85*fa6d095eSThierry Reding
86*fa6d095eSThierry RedingA display controller controls a set of windows that can be used to composite
87*fa6d095eSThierry Redingmultiple buffers onto the screen. While it is possible to assign arbitrary Z
88*fa6d095eSThierry Redingordering to individual windows (by programming the corresponding blending
89*fa6d095eSThierry Redingregisters), this is currently not supported by the driver. Instead, it will
90*fa6d095eSThierry Redingassume a fixed Z ordering of the windows (window A is the root window, that
91*fa6d095eSThierry Redingis, the lowest, while windows B and C are overlaid on top of window A). The
92*fa6d095eSThierry Redingoverlay windows support multiple pixel formats and can automatically convert
93*fa6d095eSThierry Redingfrom YUV to RGB at scanout time. This makes them useful for displaying video
94*fa6d095eSThierry Redingcontent. In KMS, each window is modelled as a plane. Each display controller
95*fa6d095eSThierry Redinghas a hardware cursor that is exposed as a cursor plane.
96*fa6d095eSThierry Reding
97*fa6d095eSThierry RedingOutputs
98*fa6d095eSThierry Reding-------
99*fa6d095eSThierry Reding
100*fa6d095eSThierry RedingThe type and number of supported outputs varies between Tegra SoC generations.
101*fa6d095eSThierry RedingAll generations support at least HDMI. While earlier generations supported the
102*fa6d095eSThierry Redingvery simple RGB interfaces (one per display controller), recent generations no
103*fa6d095eSThierry Redinglonger do and instead provide standard interfaces such as DSI and eDP/DP.
104*fa6d095eSThierry Reding
105*fa6d095eSThierry RedingOutputs are modelled as a composite encoder/connector pair.
106*fa6d095eSThierry Reding
107*fa6d095eSThierry RedingRGB/LVDS
108*fa6d095eSThierry Reding~~~~~~~~
109*fa6d095eSThierry Reding
110*fa6d095eSThierry RedingThis interface is no longer available since Tegra124. It has been replaced by
111*fa6d095eSThierry Redingthe more standard DSI and eDP interfaces.
112*fa6d095eSThierry Reding
113*fa6d095eSThierry RedingHDMI
114*fa6d095eSThierry Reding~~~~
115*fa6d095eSThierry Reding
116*fa6d095eSThierry RedingHDMI is supported on all Tegra SoCs. Starting with Tegra210, HDMI is provided
117*fa6d095eSThierry Redingby the versatile SOR output, which supports eDP, DP and HDMI. The SOR is able
118*fa6d095eSThierry Redingto support HDMI 2.0, though support for this is currently not merged.
119*fa6d095eSThierry Reding
120*fa6d095eSThierry RedingDSI
121*fa6d095eSThierry Reding~~~
122*fa6d095eSThierry Reding
123*fa6d095eSThierry RedingAlthough Tegra has supported DSI since Tegra30, the controller has changed in
124*fa6d095eSThierry Redingseveral ways in Tegra114. Since none of the publicly available development
125*fa6d095eSThierry Redingboards prior to Dalmore (Tegra114) have made use of DSI, only Tegra114 and
126*fa6d095eSThierry Redinglater are supported by the drm/tegra driver.
127*fa6d095eSThierry Reding
128*fa6d095eSThierry RedingeDP/DP
129*fa6d095eSThierry Reding~~~~~~
130*fa6d095eSThierry Reding
131*fa6d095eSThierry RedingeDP was first introduced in Tegra124 where it was used to drive the display
132*fa6d095eSThierry Redingpanel for notebook form factors. Tegra210 added support for full DisplayPort
133*fa6d095eSThierry Redingsupport, though this is currently not implemented in the drm/tegra driver.
134*fa6d095eSThierry Reding
135*fa6d095eSThierry RedingUserspace Interface
136*fa6d095eSThierry Reding===================
137*fa6d095eSThierry Reding
138*fa6d095eSThierry RedingThe userspace interface provided by drm/tegra allows applications to create
139*fa6d095eSThierry RedingGEM buffers, access and control syncpoints as well as submit command streams
140*fa6d095eSThierry Redingto host1x.
141*fa6d095eSThierry Reding
142*fa6d095eSThierry RedingGEM Buffers
143*fa6d095eSThierry Reding-----------
144*fa6d095eSThierry Reding
145*fa6d095eSThierry RedingThe ``DRM_IOCTL_TEGRA_GEM_CREATE`` IOCTL is used to create a GEM buffer object
146*fa6d095eSThierry Redingwith Tegra-specific flags. This is useful for buffers that should be tiled, or
147*fa6d095eSThierry Redingthat are to be scanned out upside down (useful for 3D content).
148*fa6d095eSThierry Reding
149*fa6d095eSThierry RedingAfter a GEM buffer object has been created, its memory can be mapped by an
150*fa6d095eSThierry Redingapplication using the mmap offset returned by the ``DRM_IOCTL_TEGRA_GEM_MMAP``
151*fa6d095eSThierry RedingIOCTL.
152*fa6d095eSThierry Reding
153*fa6d095eSThierry RedingSyncpoints
154*fa6d095eSThierry Reding----------
155*fa6d095eSThierry Reding
156*fa6d095eSThierry RedingThe current value of a syncpoint can be obtained by executing the
157*fa6d095eSThierry Reding``DRM_IOCTL_TEGRA_SYNCPT_READ`` IOCTL. Incrementing the syncpoint is achieved
158*fa6d095eSThierry Redingusing the ``DRM_IOCTL_TEGRA_SYNCPT_INCR`` IOCTL.
159*fa6d095eSThierry Reding
160*fa6d095eSThierry RedingUserspace can also request blocking on a syncpoint. To do so, it needs to
161*fa6d095eSThierry Redingexecute the ``DRM_IOCTL_TEGRA_SYNCPT_WAIT`` IOCTL, specifying the value of
162*fa6d095eSThierry Redingthe syncpoint to wait for. The kernel will release the application when the
163*fa6d095eSThierry Redingsyncpoint reaches that value or after a specified timeout.
164*fa6d095eSThierry Reding
165*fa6d095eSThierry RedingCommand Stream Submission
166*fa6d095eSThierry Reding-------------------------
167*fa6d095eSThierry Reding
168*fa6d095eSThierry RedingBefore an application can submit command streams to host1x it needs to open a
169*fa6d095eSThierry Redingchannel to an engine using the ``DRM_IOCTL_TEGRA_OPEN_CHANNEL`` IOCTL. Client
170*fa6d095eSThierry RedingIDs are used to identify the target of the channel. When a channel is no
171*fa6d095eSThierry Redinglonger needed, it can be closed using the ``DRM_IOCTL_TEGRA_CLOSE_CHANNEL``
172*fa6d095eSThierry RedingIOCTL. To retrieve the syncpoint associated with a channel, an application
173*fa6d095eSThierry Redingcan use the ``DRM_IOCTL_TEGRA_GET_SYNCPT``.
174*fa6d095eSThierry Reding
175*fa6d095eSThierry RedingAfter opening a channel, submitting command streams is easy. The application
176*fa6d095eSThierry Redingwrites commands into the memory backing a GEM buffer object and passes these
177*fa6d095eSThierry Redingto the ``DRM_IOCTL_TEGRA_SUBMIT`` IOCTL along with various other parameters,
178*fa6d095eSThierry Redingsuch as the syncpoints or relocations used in the job submission.
179