For most systems, handling which screen device to output to is dependent on the GPU or some other video display controller. All interfacing with the video device(s) on the system is handled by the Direct Rending Manager (DMS) and the closely related Kernel Mode Setting (KMS) kernel subsystems.
From the Wikipedia page on the topic:
In computing, the Direct Rendering Manager (DRM), a subsystem of the Linux kernel, interfaces with the GPUs of modern video cards. DRM exposes an API that user-space programs can use to send commands and data to the GPU, and to perform operations such as configuring the mode setting of the display. DRM was first developed as the kernel space component of the X Server's Direct Rendering Infrastructure, but since then it has been used by other graphic stack alternatives such as Wayland.
User-space programs can use the DRM API to command the GPU to do hardware-accelerated 3D rendering and video decoding as well as GPGPU computing.
The official Linux docs can be found in the source repository under
Documentation/gpu. Here is the github link, for your convenience.
Additionally, the Wikipedia article seems quite extensive. Depending on your goals, this resource alone might be sufficient, and it is certainly easier and less technical reading than the official documentation is.