RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    how does emulationstation go around the need from drmsetmaster drmdropmaster ?

    Scheduled Pinned Locked Moved General Discussion and Gaming
    emulationstatiokmsdrmsource code
    13 Posts 3 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      joyrider3774
      last edited by joyrider3774

      Hello,

      I'm just wondering about this ... attract mode and mainly sfml-pi has gotten updates to run in kms/drm mode i tried it out and with a few minor code changes could get it to display outside x and on my raspberry pi 4. Now everything seems to be working except there seems to be one requirement attract must be run as root in order to be able to call drmsetmaster drmdropmaster functions. these get called before starting a program (emulator) and after returning from running a program. Basically if these don't get called with attract any other program using KMS / DRM (launched by attract) fails opening the displays and gives errors and these functions can only be called by root.

      So this made me wonder about emulationstation, i know the code is publically available but i'm no expert when it comes to such code and i though someone might have a clear answer without me having to search throught its source code so am asking here. I could not find any trace of drmsetmaster / drmdropmaster function calls within emulationstation repo yet as far as i'm aware it is running (can run) under KMS / DRM and not using sudo but running as normal pi user if i'm not mistaken so how does this work within emulation station is there some other way around the need for calling drmsetmaster drmdropmaster which needs root to be able to have other emulators (started by emulationstation) running in a kms / drm mode be able to setup / use the screen ? As this might help attract as well then because the need to run it as sudo can cause problems with files being created and such (rights problems) and emulators using a different home path (emulators started also run as root if attract is started with sudo)

      or is the screen reset up after every emulator launch ? (which might be problematic for attract as the screen code is in the library sfml-pi)

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by mitu

        The simple answer is that EmulationStation doesn't have any specific code for KMS/DRM, it relies on the SDL library to initialize the display with the platform specific drivers (KMS/DRM, X11, RPI, etc.).
        However, when running a game - through runcommand -, EmulationStation video rendering/output is disabled (among other things), so there's no need for any drop/setMaster calls to the KMS layer.

        1 Reply Last reply Reply Quote 0
        • J
          joyrider3774
          last edited by joyrider3774

          i understand that emulation station is not having code for drm / kms explictly but if using SDL2 on a rpi 4 i'm guessing the DRM / KMS backend of SDL2 is used and sdl opens the device, or does it use another backend with the rpi4 ? if not could you point me to the file where the rendering and "other things" get disabled i wonder if the same could be achieved in attract mode.

          PS. the patch i applied to make it work is now also in master and attract works out of the box now with sfml-pi except for the requirement of sudo

          mituM 1 Reply Last reply Reply Quote 0
          • mituM
            mitu Global Moderator @joyrider3774
            last edited by mitu

            @joyrider3774 said in how does emulationstation go around the need from drmsetmaster drmdropmaster ?:

            i understand that emulation station is not having code for drm / kms explictly but if using SDL2 on a rpi 4 i'm guessing the DRM / KMS backend of SDL2 is used and sdl opens the device, or does it use another backend with the rpi4 ?

            No, the DRM/KMS video backend of SDL2 is used on a Pi4. Right now it even uses OpenGL (instead of GLES), since the open source MESA driver supports it.

            if not could you point me to the file where the rendering and "other things" get disabled i wonder if the same could be achieved in attract mode.

            This is where a game starts, calling window->deinit(), which in turn deactivates the GL renderer.

            1 Reply Last reply Reply Quote 1
            • J
              joyrider3774
              last edited by joyrider3774

              ok thanks for the info, in theory the same should be achievable with attract but might depend on the libsfml-pi how it handles sound / video etc and if it can be easily temporary deinitted and afterwards reinnited.

              PS. attract by default also uses OPENGL in DRM mode, but can be compiled with opengl es as well both seem to work fine when i tested

              1 Reply Last reply Reply Quote 0
              • J
                joyrider3774
                last edited by

                @mitu author of attract used another way offloading the calls to seperate binary and making sure it has enough rights. Just tested i can run attract again without root and emulators do start

                https://github.com/mickelson/attract/commit/6a7ade43656967d038f6e3ab9e1d505da6f00c11

                would this mean attract can be added again eventually to experimental packages ?

                mituM 1 Reply Last reply Reply Quote 0
                • mituM
                  mitu Global Moderator @joyrider3774
                  last edited by

                  @joyrider3774 said in how does emulationstation go around the need from drmsetmaster drmdropmaster ?:

                  would this mean attract can be added again eventually to experimental packages ?

                  Well, it was never gone, just that it was masked for the Pi4 platform. I'll see what we can do to bring it back for all Pi platforms - including the Pi4.

                  With the recent changes, it's probably worth testing it on other SBC platforms that might be supporting KMS/DRM.

                  J 1 Reply Last reply Reply Quote 0
                  • J
                    joyrider3774 @mitu
                    last edited by joyrider3774

                    @mitu when adding compile flags, on rpi building attract you need now to explicitly set USE_MMAL=1 and USE_DRM=1 for it to use mmal hw video decoding and drm backend on the pi4 (or at least have that option) when having build ffmpeg with mmal support, also don't forget to compile that helper program i linked in previous message or no emulators can start when running as the pi user. It's in attract/util/linux/drm folder and just needs make and sudo make install.

                    SFML-PI also needs an explict parameter for building DRM version on pi4

                    1 Reply Last reply Reply Quote 0
                    • mituM
                      mitu Global Moderator
                      last edited by mitu

                      Hm, looking at the changes, it looks like the new DRM support overrides the previous RPI support - this will break support for older/existing models where DRM/KMS is not used (Pi0 - Pi3).

                      EDIT: or maybe not - will have to test and see.

                      1 Reply Last reply Reply Quote 0
                      • J
                        joyrider3774
                        last edited by

                        @mitu it's still possible to compile using old way needs different set of params its documented on github but i have not tried building a version for my rpi 3 it should not break things, only needs different compile parameters on a rpi4 for both sfml pi and attract

                        1 Reply Last reply Reply Quote 0
                        • mituM
                          mitu Global Moderator
                          last edited by

                          @joyrider3774 attractmode should be now installable on the Pi4 again. One deviation from upstream is that the launching script will try and pre-set the video resolution based on the system's current video resolution instead of relying on DRM's detected preferred video mode.

                          ClydeC 1 Reply Last reply Reply Quote 1
                          • ClydeC
                            Clyde @mitu
                            last edited by

                            @mitu I just updated Retropie on my Pi 4 and attract mode is back in the experimental packages. Although I don't use it myself in the forseeable future, thanks for bringing it back!

                            mituM 1 Reply Last reply Reply Quote 0
                            • mituM
                              mitu Global Moderator @Clyde
                              last edited by

                              @Clyde I just added some small changed the the RetroPie scriptmodule, the hard work was done upstream, by the AttractMode developer.

                              1 Reply Last reply Reply Quote 1
                              • First post
                                Last post

                              Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                              Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.