1*4882a593Smuzhiyun=============================================== 2*4882a593Smuzhiyun drm/tegra NVIDIA Tegra GPU and display driver 3*4882a593Smuzhiyun=============================================== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunNVIDIA Tegra SoCs support a set of display, graphics and video functions via 6*4882a593Smuzhiyunthe host1x controller. host1x supplies command streams, gathered from a push 7*4882a593Smuzhiyunbuffer provided directly by the CPU, to its clients via channels. Software, 8*4882a593Smuzhiyunor blocks amongst themselves, can use syncpoints for synchronization. 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunUp until, but not including, Tegra124 (aka Tegra K1) the drm/tegra driver 11*4882a593Smuzhiyunsupports the built-in GPU, comprised of the gr2d and gr3d engines. Starting 12*4882a593Smuzhiyunwith Tegra124 the GPU is based on the NVIDIA desktop GPU architecture and 13*4882a593Smuzhiyunsupported by the drm/nouveau driver. 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunThe drm/tegra driver supports NVIDIA Tegra SoC generations since Tegra20. It 16*4882a593Smuzhiyunhas three parts: 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun - A host1x driver that provides infrastructure and access to the host1x 19*4882a593Smuzhiyun services. 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun - A KMS driver that supports the display controllers as well as a number of 22*4882a593Smuzhiyun outputs, such as RGB, HDMI, DSI, and DisplayPort. 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun - A set of custom userspace IOCTLs that can be used to submit jobs to the 25*4882a593Smuzhiyun GPU and video engines via host1x. 26*4882a593Smuzhiyun 27*4882a593SmuzhiyunDriver Infrastructure 28*4882a593Smuzhiyun===================== 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunThe various host1x clients need to be bound together into a logical device in 31*4882a593Smuzhiyunorder to expose their functionality to users. The infrastructure that supports 32*4882a593Smuzhiyunthis is implemented in the host1x driver. When a driver is registered with the 33*4882a593Smuzhiyuninfrastructure it provides a list of compatible strings specifying the devices 34*4882a593Smuzhiyunthat it needs. The infrastructure creates a logical device and scan the device 35*4882a593Smuzhiyuntree for matching device nodes, adding the required clients to a list. Drivers 36*4882a593Smuzhiyunfor individual clients register with the infrastructure as well and are added 37*4882a593Smuzhiyunto the logical host1x device. 38*4882a593Smuzhiyun 39*4882a593SmuzhiyunOnce all clients are available, the infrastructure will initialize the logical 40*4882a593Smuzhiyundevice using a driver-provided function which will set up the bits specific to 41*4882a593Smuzhiyunthe subsystem and in turn initialize each of its clients. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunSimilarly, when one of the clients is unregistered, the infrastructure will 44*4882a593Smuzhiyundestroy the logical device by calling back into the driver, which ensures that 45*4882a593Smuzhiyunthe subsystem specific bits are torn down and the clients destroyed in turn. 46*4882a593Smuzhiyun 47*4882a593SmuzhiyunHost1x Infrastructure Reference 48*4882a593Smuzhiyun------------------------------- 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun.. kernel-doc:: include/linux/host1x.h 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun.. kernel-doc:: drivers/gpu/host1x/bus.c 53*4882a593Smuzhiyun :export: 54*4882a593Smuzhiyun 55*4882a593SmuzhiyunHost1x Syncpoint Reference 56*4882a593Smuzhiyun-------------------------- 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun.. kernel-doc:: drivers/gpu/host1x/syncpt.c 59*4882a593Smuzhiyun :export: 60*4882a593Smuzhiyun 61*4882a593SmuzhiyunKMS driver 62*4882a593Smuzhiyun========== 63*4882a593Smuzhiyun 64*4882a593SmuzhiyunThe display hardware has remained mostly backwards compatible over the various 65*4882a593SmuzhiyunTegra SoC generations, up until Tegra186 which introduces several changes that 66*4882a593Smuzhiyunmake it difficult to support with a parameterized driver. 67*4882a593Smuzhiyun 68*4882a593SmuzhiyunDisplay Controllers 69*4882a593Smuzhiyun------------------- 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunTegra SoCs have two display controllers, each of which can be associated with 72*4882a593Smuzhiyunzero or more outputs. Outputs can also share a single display controller, but 73*4882a593Smuzhiyunonly if they run with compatible display timings. Two display controllers can 74*4882a593Smuzhiyunalso share a single framebuffer, allowing cloned configurations even if modes 75*4882a593Smuzhiyunon two outputs don't match. A display controller is modelled as a CRTC in KMS 76*4882a593Smuzhiyunterms. 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunOn Tegra186, the number of display controllers has been increased to three. A 79*4882a593Smuzhiyundisplay controller can no longer drive all of the outputs. While two of these 80*4882a593Smuzhiyuncontrollers can drive both DSI outputs and both SOR outputs, the third cannot 81*4882a593Smuzhiyundrive any DSI. 82*4882a593Smuzhiyun 83*4882a593SmuzhiyunWindows 84*4882a593Smuzhiyun~~~~~~~ 85*4882a593Smuzhiyun 86*4882a593SmuzhiyunA display controller controls a set of windows that can be used to composite 87*4882a593Smuzhiyunmultiple buffers onto the screen. While it is possible to assign arbitrary Z 88*4882a593Smuzhiyunordering to individual windows (by programming the corresponding blending 89*4882a593Smuzhiyunregisters), this is currently not supported by the driver. Instead, it will 90*4882a593Smuzhiyunassume a fixed Z ordering of the windows (window A is the root window, that 91*4882a593Smuzhiyunis, the lowest, while windows B and C are overlaid on top of window A). The 92*4882a593Smuzhiyunoverlay windows support multiple pixel formats and can automatically convert 93*4882a593Smuzhiyunfrom YUV to RGB at scanout time. This makes them useful for displaying video 94*4882a593Smuzhiyuncontent. In KMS, each window is modelled as a plane. Each display controller 95*4882a593Smuzhiyunhas a hardware cursor that is exposed as a cursor plane. 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunOutputs 98*4882a593Smuzhiyun------- 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunThe type and number of supported outputs varies between Tegra SoC generations. 101*4882a593SmuzhiyunAll generations support at least HDMI. While earlier generations supported the 102*4882a593Smuzhiyunvery simple RGB interfaces (one per display controller), recent generations no 103*4882a593Smuzhiyunlonger do and instead provide standard interfaces such as DSI and eDP/DP. 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunOutputs are modelled as a composite encoder/connector pair. 106*4882a593Smuzhiyun 107*4882a593SmuzhiyunRGB/LVDS 108*4882a593Smuzhiyun~~~~~~~~ 109*4882a593Smuzhiyun 110*4882a593SmuzhiyunThis interface is no longer available since Tegra124. It has been replaced by 111*4882a593Smuzhiyunthe more standard DSI and eDP interfaces. 112*4882a593Smuzhiyun 113*4882a593SmuzhiyunHDMI 114*4882a593Smuzhiyun~~~~ 115*4882a593Smuzhiyun 116*4882a593SmuzhiyunHDMI is supported on all Tegra SoCs. Starting with Tegra210, HDMI is provided 117*4882a593Smuzhiyunby the versatile SOR output, which supports eDP, DP and HDMI. The SOR is able 118*4882a593Smuzhiyunto support HDMI 2.0, though support for this is currently not merged. 119*4882a593Smuzhiyun 120*4882a593SmuzhiyunDSI 121*4882a593Smuzhiyun~~~ 122*4882a593Smuzhiyun 123*4882a593SmuzhiyunAlthough Tegra has supported DSI since Tegra30, the controller has changed in 124*4882a593Smuzhiyunseveral ways in Tegra114. Since none of the publicly available development 125*4882a593Smuzhiyunboards prior to Dalmore (Tegra114) have made use of DSI, only Tegra114 and 126*4882a593Smuzhiyunlater are supported by the drm/tegra driver. 127*4882a593Smuzhiyun 128*4882a593SmuzhiyuneDP/DP 129*4882a593Smuzhiyun~~~~~~ 130*4882a593Smuzhiyun 131*4882a593SmuzhiyuneDP was first introduced in Tegra124 where it was used to drive the display 132*4882a593Smuzhiyunpanel for notebook form factors. Tegra210 added support for full DisplayPort 133*4882a593Smuzhiyunsupport, though this is currently not implemented in the drm/tegra driver. 134*4882a593Smuzhiyun 135*4882a593SmuzhiyunUserspace Interface 136*4882a593Smuzhiyun=================== 137*4882a593Smuzhiyun 138*4882a593SmuzhiyunThe userspace interface provided by drm/tegra allows applications to create 139*4882a593SmuzhiyunGEM buffers, access and control syncpoints as well as submit command streams 140*4882a593Smuzhiyunto host1x. 141*4882a593Smuzhiyun 142*4882a593SmuzhiyunGEM Buffers 143*4882a593Smuzhiyun----------- 144*4882a593Smuzhiyun 145*4882a593SmuzhiyunThe ``DRM_IOCTL_TEGRA_GEM_CREATE`` IOCTL is used to create a GEM buffer object 146*4882a593Smuzhiyunwith Tegra-specific flags. This is useful for buffers that should be tiled, or 147*4882a593Smuzhiyunthat are to be scanned out upside down (useful for 3D content). 148*4882a593Smuzhiyun 149*4882a593SmuzhiyunAfter a GEM buffer object has been created, its memory can be mapped by an 150*4882a593Smuzhiyunapplication using the mmap offset returned by the ``DRM_IOCTL_TEGRA_GEM_MMAP`` 151*4882a593SmuzhiyunIOCTL. 152*4882a593Smuzhiyun 153*4882a593SmuzhiyunSyncpoints 154*4882a593Smuzhiyun---------- 155*4882a593Smuzhiyun 156*4882a593SmuzhiyunThe current value of a syncpoint can be obtained by executing the 157*4882a593Smuzhiyun``DRM_IOCTL_TEGRA_SYNCPT_READ`` IOCTL. Incrementing the syncpoint is achieved 158*4882a593Smuzhiyunusing the ``DRM_IOCTL_TEGRA_SYNCPT_INCR`` IOCTL. 159*4882a593Smuzhiyun 160*4882a593SmuzhiyunUserspace can also request blocking on a syncpoint. To do so, it needs to 161*4882a593Smuzhiyunexecute the ``DRM_IOCTL_TEGRA_SYNCPT_WAIT`` IOCTL, specifying the value of 162*4882a593Smuzhiyunthe syncpoint to wait for. The kernel will release the application when the 163*4882a593Smuzhiyunsyncpoint reaches that value or after a specified timeout. 164*4882a593Smuzhiyun 165*4882a593SmuzhiyunCommand Stream Submission 166*4882a593Smuzhiyun------------------------- 167*4882a593Smuzhiyun 168*4882a593SmuzhiyunBefore an application can submit command streams to host1x it needs to open a 169*4882a593Smuzhiyunchannel to an engine using the ``DRM_IOCTL_TEGRA_OPEN_CHANNEL`` IOCTL. Client 170*4882a593SmuzhiyunIDs are used to identify the target of the channel. When a channel is no 171*4882a593Smuzhiyunlonger needed, it can be closed using the ``DRM_IOCTL_TEGRA_CLOSE_CHANNEL`` 172*4882a593SmuzhiyunIOCTL. To retrieve the syncpoint associated with a channel, an application 173*4882a593Smuzhiyuncan use the ``DRM_IOCTL_TEGRA_GET_SYNCPT``. 174*4882a593Smuzhiyun 175*4882a593SmuzhiyunAfter opening a channel, submitting command streams is easy. The application 176*4882a593Smuzhiyunwrites commands into the memory backing a GEM buffer object and passes these 177*4882a593Smuzhiyunto the ``DRM_IOCTL_TEGRA_SUBMIT`` IOCTL along with various other parameters, 178*4882a593Smuzhiyunsuch as the syncpoints or relocations used in the job submission. 179