rpi4: custom modes on a CRT TV, the “Holy Grail” ?

I’m a big fan of old arcade games and hardware, i did even build a few cabinets myself (among a lot of other related things..) and always wanted to use my CRT TV, used for my retro consoles, as an “arcade monitor” with a Raspberry Pi. Time was missing (and probably motivation), but i did finally take a closer look, and found that it was pretty straightforward from what i have read.

So i ordered a Raspberry Pi 4 for this task as it’s the more powerful device in the family yet (and the same price as an rpi3 for the 2g version), and a Pi2SCART to hook up at my CRT TV. The Pi2SCART use the “vga666” overlay as many other adapter in the wild, so any adapter using the “vga666” overlay will work the same.

After a few days of waiting, i was able to assemble the thing, and do my first testing, just to see a black screen… Of course, i did follow the install instruction before, and i was sure of my steps. After a few research, i discovered that my RGB SCART cable was not fully wired… The next day I was able to find a working SCART cable, and it worked straight away… you’re warned 🙂

RPi-4, pibow case, Argon ONE  fan and Pi2SCART
RPi-4, pibow case, Argon ONE fan and Pi2SCART

Now, to the real problem: i discovered, after some testing and probably like many other, that people were still using the pi3 for this task, because the (f)kms driver doesn’t handle resolution switching as the pi3 does, and it will never support vcgencmd timings commands to do so.

Fine, let’s try to modify the vc4 fkms kernel module to see if we can add/load custom timings (drm modes) to the drm backend! While this seemed to work at a first look (kms/drm apps where able to see the custom modes/timings and create the appropriate framebuffer), the TV resolution was in fact not switching at all… What a lost of time!

But, then, someone from the RGB-Pi team pointed me to a work from “sigmaris” about an “rpi dpi dac” (a dpi bridge, thanks him) for the pi3, which allow the vc4 kms (full kms, not fake kms) driver to correctly recognize the monitor (or the CRT TV in my case). After a very few changes and testing, the (my?) “Holy Grail” was here 🙂

This doesn’t solve the problem with CRT TV (and probably monitors) who doesn’t have an “edid”, so we still only have one possible resolution, or they have to be hard coded in the new vc4-vga666 overlay. The problem was solved by writing a custom mode loader in the rpi-dpidac module.

So, you’ll find below a link to a test version of recalbox (7.1) with the rpi-dpidac module and vc4-vga666 overlay (please, do not ask support to the recalbox team as this is not yet officially supported, but it’s in the work). Please note that the vc4 kms module was also patched to support interlaced modes, so 640x480i is possible!

Here are the steps to enable the dpi dac/bridge in this image, as it’s not enabled by default. You’ll need to modify two files (/boot/config.txt and /etc/modules.conf) and create your custom timings file (/boot/timings.txt) which will be used for adding custom resolutions/modes/timings. While “hdmi_timings” are not a thing with the drm/kms driver, i did choose to keep this format as people are used to it (drm_display_mode is used, todo: use drm_display_mode for timings.txt?).

  • /boot/config.txt
dtoverlay=vc4-kms-v3d
dtoverlay=vc4-vga666
  • /etc/modules.conf (add the rpi-dpidac module)
rpi-dpidac
  • /boot/timings.txt (adjust to your needs)
640 0 30 60 72 480 0 22 5 24 0 0 0 60 1 12800000 1	# 640	x 480i
320 1 12 32 44 240 1 6 10 6 0 0 0 60 0 6400000 1	# 320	x 240p
320 1 8 29 47 224 1 10 14 16 0 0 0 60 0 6400000 1	# 320	x 224p
1920 1 152 247 280 224 1 8 7 23 0 0 0 60 0 40860000 1	# 1920	x 224p
1920 1 52 208 260 240 1 6 10 6 0 0 0 60 0 38400000 1	# 1920	x 240p

When using the rpi-dpidac module and overlay, you won’t need the “crt_switch_resolution” stuff and such in retroarch configuration (nor “videomode” in recalbox.conf), just use this sort of configuration:

  • system/configs/retroarch/fbneo.cfg
video_fullscreen = true
video_fullscreen_x = 320
video_fullscreen_y = 224
video_refresh_rate = 60
aspect_ratio_index = 23
custom_viewport_x = 0
custom_viewport_y = 0
custom_viewport_width = 304
custom_viewport_height = 224

More information will be added here when i’ll find the time to do so, including direction to build and use the rpi-dpidac on Raspberry OS. In the meantime, you can download a compiled module and overlay on the github releases page.

I hope you’ll now enjoy your Raspberry Pi 4 as much as i (and my son) do! 🙂

Dark Mode

rpi-dpidac (this link opens in a new window) by Cpasjuste (this link opens in a new window)

Support for Raspberry Pi DPI to Analogue bridges like the VGA666, Pi2SCART, Pi2JAMMA, RGB-Pi, RPI2SCART.

43 thoughts on “rpi4: custom modes on a CRT TV, the “Holy Grail” ?

  1. Hello,

    Je suis actuellement en train d’ajouter le support pour le rgb-pi, il me semble que celui ci utilise la mĂȘme configuration gpio que le pi2jamma (Ă  vĂ©rifier). J’espĂšre pouvoir sortir cela pendant des vacances !

  2. Salut,

    Alors en fait, il me semble que pi2jamma fonctionne comme le pi2scart, cela devrait donc fonctionner. Par contre je me demande si je n’ai pas un bug sur mon image qui empĂȘche le 480i (il manque peut ĂȘtre un patch que j’ai ajoutĂ© plus tard, ou alors ton Ă©cran ne supporte pas le 480i ?!).
    Pour en ĂȘtre sĂ»r, et si tu as bien suivi toutes les Ă©tapes, il faudrait que tu supprimes la premiĂšre ligne dans le fichier “timings.txt” afin de virer le 480i et tester de nouveau.

  3. Je n’ai pas du tout la mĂȘme architecture que toi,

    j’ai un dossier recalbox Ă  la racine
    un autre share

    je n’ai donc pas /etc/modules.conf

    ni system/configs/retroarch/fbneo.cfg

  4. tu aurais un autre moyen pour communiquer ? 🙂
    donc en gros
    – je flash ma sd
    – je dĂ©marre normalement sur un Ă©cran standard ( en hdmi ? )
    – je configure mon rĂ©seaux sur le pi
    – je me connecte en SSH
    – j’effectue les modifications
    – je reboot 🙂

    c’est partit

  5. Ok j’ai rĂ©ussis, j’arrive jusqu’a l’interface de recalbox ( non centrĂ©e mais pas grave, je vais tester des jeux et mapper mes controlleurs )

    1. Nice, je pense que c’est bon pour toi 🙂
      Je vais essayer de faire intégrer tout cela sur les versions officielles prochainement (il faudra toujours éditer les fichiers).

  6. On ça fonctionne 🙂
    J’arrive a lancer les jeux dreamcast mais les contrĂŽleurs ne sont pas reconnus ( toujours avec le pi2jamma )

  7. Quelques retours , image pas cadrĂ© correctement sur tous les jeux ( de la mĂȘme console )
    ProblĂšme de contrĂŽleur.
    Le reste a l’air nickel đŸ˜»
    Sacrée avancée car la Dreamcast tourne nickel !

    1. Pour le cadrage, tu dois le rĂ©gler manuellement dans les fichiers de configurations retroarch (le viewport, comme pour le fbneo.cfg, par contre il faut rester en “integer scale”. C’est les mĂȘme manipulations que sur le rpi3, tu devrais trouver pas mal d’informations Ă  ce sujet Ă  droite Ă  gauche.
      Pour les contrĂŽles, je suppose que cela passe par le gpio, ce qui doit poser problĂšme avec mon overlay. J’essaierais de jeter un oeil prochainement mais cela prendra surement quelques jours/semaines.

      1. Ok, bon hé bien ça avance pas mal ce sujet, recalbox sur astro, ça va claquer !
        ( les controlleurs fonctionnent bien en usb )

        tu peux me contacter par email si besoins.

        Merci encore

    1. Oui, pas Ă©tonnant en effet. L’overlay (vc4-vga666) entre en conflit entre le mode dpi et les gpios pour les contrĂŽles. Par contre je n’ai pas trouvĂ© un schĂ©ma des gpio utilisĂ©s pour l’overlay du pi2jamma, il faudrait trouver ça…

  8. tiré de la doc du pi2jamma ( avec la distribution regambox ) :

    So the first Game Controller Interface is the Pi2jamma Interface. It is made with Shift Registers and the pikeyd165 driver must be active. Find the configuration file for pikeyd165 driver in folder /etc/pikeyd165.conf

    Player 1 Start + Player 1 Button 1 = ESC (Quit Game)
    Player 1 Start + Player 1 Up = Coin
    Player 1 Up = Arrow Up
    Player 1 Down = Arrow Down
    Player 1 Left = Arrow Left
    Player 1 Right = Arrow Right
    Player 1 Button 1 = LEFT CTRL
    Player 1 Button 2 = LEFT ALT
    Player 1 Button 3 = SPACE
    Player 1 Button 4 = LEFT SHIFT
    Player 1 Button 5 = Z
    Player 1 Button 6 = X
    Player 1 Start = 1
    Player 1 Coin = 5
    Player 2 Up = R
    Player 2 Down = F
    Player 2 Left = D
    Player 2 Right = G
    Player 2 Button 1 = A
    Player 2 Button 2 = S
    Player 2 Button 3 = Q
    Player 2 Button 4 = W
    Player 2 Button 5 = I
    Player 2 Button 6 = K
    Player 2 Start = 2

    Si ça peut aider

  9. As tu déjà fait fonctionner ton pi2jamma sur recalbox ?
    => oui grave a tes informations sur lesquelles ont a Ă©changĂ© 🙂

    il ne me reste que les controllers Ă  faire fonctionner

    1. Oui donc je pense que ton problĂšme est propre au pi2jamma et recalbox, il doit y avoir de l’aide trouvable sur des forums (dont le lien que je t’ai filĂ©, mais je ne sais pas si les informations sont toujours bonnes).

      1. En cours , alors installation du drivers ok
        Mapping des touches pas bon , va falloir que je trouve les bonnes :/
        Bug lors de l’extinction ( en passant par le menu )

        je te tiens au courant 🙂

  10. Salut et meilleurs voeux de santĂ© et bonheur … et d’avancĂ©es pour ce projet !
    J’aimerai savoir, si on se base sur les timings du fichiers timings.txt, on peut sĂ©lectionner le 480i uniquement pour openbor, la naomi… ou emulationstation indĂ©pendament des fba etc (dont on a dĂ©jĂ  fait la config sous retroarch) ?
    merci de ton aide !

    1. Salut Lipide,

      Alors de mémoire la premiÚre ligne/résolution que tu entres dans le fichier timings.txt sera la résolution par défaut (celle utilisée par emulationstation du coup).

  11. Salut,

    Merci Cpasjuste pour la solution que tu proposes.
    Je n’ai pas encore de RPI 4 mais je compte en acheter un cette semaine car mon rpi3 vient de me lĂącher et pour le remplacer rien de mieux que le RPI4 qui est au mĂȘme prix que son grand frĂšre. Ce serait pour l’utiliser sur ma vieille TV cathodique et un RGP-pi ou pi2scart (j’ai les 2).

    La solution que tu proposes fonctionne toujours ou tu as rencontrĂ© des bugs majeurs depuis ? Je pose la question car sur le forum RGBPI j’ai l’impression qu’ils galĂšrent un peu pour rendre compatible leur OS vers pi4.

  12. Hi, cpasjuste: Thank you very much for the tutorial you shared, which helped me a lot! And forgive my newbie request: If possible, could you give me advice on how to compile the rpi-dpidac module from source code at your convenience? I want to adapt to the latest linux kernel version. Thank you very much again and ignore my poor english please.

  13. Hey. Thanks for the article. It works fine for me too using the pi2scart. But when I start Kodi, there is no video output (only sound, and subtitle). Any ideas why this would be? I tried in 480i, but also tested the progressive modes – there is no video output in Kodi. Any ideas what I am doing wrong?

    (All I would want to do is watch movies on my old CRT and sony PVM from my network in 480i.)

    1. Did you figure this out? I am in the same boat and don’t wanna use shitty HDMI to scart converters, and rather not composite either.

  14. Bonjour Cpasjuste, peut-ĂȘtre peux-tu m’Ă©clairer: je n’arrive pas Ă  Ă©diter le fichier modules.conf car il est en lecture seule. J’ai essayĂ© la commande “mount -o remount, rw /etc” mais çà ne marche pas.

    Merci d’avance

      1. Super, merci beaucoup j’ai rĂ©ussi. Et j’en profite pour te fĂ©liciter pour ton taf, maintenant j’ai une putain de borne parfaitement fonctionnelle grĂące Ă  toi. (Pi4 + Pi2jamma + Hantarex MTC 9000)
        J’ai essayĂ© des 10Ăšnes d’OS et de mĂ©thodes, la tienne est vraiment la meilleure.

  15. Awesome work. I have played with the image and it looks great.

    When triggering a resolution from retroarch, is the refresh rate taken into account?

    Ie core in cfg file defines timing 1920 x 240 @ 55
    Timing file has 1920 x 240 @55 and 1920 x 240 @ 60

    Is the 55hz one taken then?

    Cheers

  16. Hi, I’m using this image and it works like a charm. One question, I apoligize for my ignorance, is it possible to upgrade to Recalbox 7.2? I tried to update and i can’t see anything anymore on the screen (I guess the custom things get lost in the update). But I’m sure there is a way to make it work. Please let me know.

    Cheers^^^^
    Andre

  17. BONJOUR
    Serait il possible d’avoir une traduction de ton super tuto en francais car google translate pas top

    Enfin serait il possible d’avoir la maj 7.2.1 recalbox

  18. I’ve got a Raspberry Pi 4, VGA666, and a 15KHz CRT monitor with RGBHV inputs. I would love to be able to output 480i with this setup, but only have 240p so far.

    I have some web dev experience, but know nearly nothing about kernel programming. Would you be able to give rough steps on how to alter the default rpi kernel source tree (https://github.com/raspberrypi/linux) to be able to output 480i?

  19. hello congratulations for the job. is it possible to use pi2scart also with retropie? could you work on a configuration also for retropie?
    thanks

Leave a Reply to TheRealGrooveTrain Cancel reply

Your email address will not be published. Required fields are marked *