| Summary: | [patch] Override the video device index from the environment | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Wladimir J. van der Laan <laanwj> |
| Component: | video | Assignee: | Brandon Schaefer <brandontschaefer> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | brandontschaefer, stephen.jin.yee |
| Version: | HG 2.1 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | video: Override the video device index from environment | ||
We should just be looping from 0 -> 99 and checking that this device exists on the file system before attempting to open it with stat or something.
SDL_snprintf(devname, 16, "/dev/dri/card%d", vdata->devindex);
Mainly check if the devindex is a valid card. Else loop from 0 -> 99 looking for a card.
Much better for a platform specific issue to be in its platform specific area.
I think this option is necessary and it is not platform specific. In my scenario, I'm using an intel CPU with an nVidia graphics card, desktop. Both "/dev/dri/card0"(intel) and "/dev/dr/card1"(nv) are valid cards. Monitors are only available to the physically connected card. It would be great it could automatically select the first available... setup, but there should be some way to override the default behaviour. Maybe the name of envvar could be more specific such as SDL_VIDEODRIVERINDEX or SDL_VIDEODEVINDEX or something else, and looping is not enough to solve the problem. Problem with that is, looking at X11_CreateDeivce or WIN_CreateDevice both dont even use the device index passed through. Quickly looking, I dont see any other backend that uses the devindex. Not that they could do much with that information AFAIK, but I could be wrong. Specific to X11 not sure how given the device ID how you would tell the display server to now render using that GPU over your other one possibly selected. Seems awfully driver specific, or the server setup (ie. having different GPUs have their own X11 server and just DISPLAY=:<n> for which ever display you want to render on) The reason I see this specific to to kms/drm is we are having to maintain that open FD for a device we select. If one is not around (even from the given index) we should still attempt to look around for the first valid one. You're right this is a problem specific to kms/drm. I'm sorry I have misunderstood you a little. I thought you mean hardware platform by platform specific. Freescale(now part of NXP) i.MX6 is an SoC, ARM cortex A7/A9 CPU with on-chip GPU. My point is, not only these "special" hardwares could encounter multiple dri devices but also common pc. And you're right, this is a specific to kms/drm. Videodriver x11, wayland indeed ingnored the devindex argument, probably any other videodrvier except kms/drm ignores it. But kms/drm is somehow lightweight in contrast to a full-blown xserver. Thus we need some method to config it. X11 has DISPLAY, wayland has WAYLAND_DISPLAY, but with kms/drm we have nothing. Well, it is not accurate to compare these ones. In X11 scenario, DISPLAY is used to select Xserver session - which Xserver to use. In addition to the "real" one, we can spawn virtual framebuffer xserver, ssh forward xserver, even direct connect a remote xserver by ip address. And the "real" one would occupy every physical graphics cards as RandR provider. If I remember right, desktop is randered on single GPU, and with some extensions other GPU may work in some special mode receiving drawing commands from the main GPU and draw on its own output port. It seems that until RandR 1.4, only property graphics drivers could achieve that. Since kms/drm is the lowlevel interface without a full display abstraction layer we need an option. Occasionally, there is the devindex argument in struct VideoBootStrap which is part of SDL_sysvideo, whether should we make use of it? Otherwise, could we have an env var override the filename(maybe fullpath) of the device file to be used, if a kmsdrm specific solution is prefered? |
Created attachment 3151 [details] video: Override the video device index from environment Make it possible to override the video device index, that gets passed to the videodriver from the environment with `SDL_VIDEOINDEX`. This is useful with KMSDRM on i.MX6 which only has card1 usable for scanout purposes.