CRT Switchres on PC Monitor

Hi, I was trying to get the Switchres working with a PC monitor and I have a problem.

So, I made all the NTSC super resolutions from 2560x192 to 2560x480 in the Nvidia control panel, they all work at 138Hz, and setup in the retroarch config the refresh rate ar retroarch.cfg.

video_refresh_rate = "120.000000"

I also modified the video fullscreen parameter like this.

video_fullscreen_x = "2560"
video_fullscreen_y = "240"

And It works with SNES, NES; Atari, N64 games, but when I run the PSX or Dreamcast cores the image shows really tiny on the width, what can I do to fix this?.

I tried doing the same in Linux with custom modelines and I get the same result.

3 Likes

@Kuipumu I know this maybe a stupid question so please don’t get offended. Have you turned on the CRT option? I only ask as this as it uses an auto aspect algorithm to fit the resolution correctly!

Some people have got this working by enabling insert blank frames option.

Having said this, I am currently working on a 31khz version of CRT Switch. I have many other projects going on at the same time so there is no completion date yet.

1 Like

Hahaha, It’s not to stupid, yes I have it turned on, I have not put the option insert black frames, when I did that I only got this black frame on the screen, but that does not change the aspect ratio.

Another thing is, do you know how to make Retroarch to not change the refresh rate?, everytime I enter to the emulator the setting gets changed to 60hz.

How much its still needed for the project?, It could be really useful, Im trying to get a Rasperry Pi to try to do this with a composite out in a proper 15khz, but, Rasperry Pi would never be as powerful has the PC.

@Kuipumu I’ve been working on a Raspberry PI version since I released this. There are many limitations, the main one being on the fly switching. Unless you have found a way around that? we could collaborate.

In all honesty I have not done much, just theory work really. I need to get and setup a 31khz monitor to get it off the ground. There is not much to do really, things like adjusting the refresh ranges and resolutions.

My main problem is time. I have so many other thing going on ATM this has kind of had to take a back seat.

I can take a look on the Rasperry Pi, Is Xorg the limitation with the fly switching?, I know xrandr can switch resolutions from the cli in the fly.

The only problem I see with 31Khz is this with the PSX, Dreamcast, Saturn, Dolphin cores, maybe its has something to do with the HW rendering, with everything else just works perfectly.

Currently as it stands xorg will switch fine using xrandr. For xrandr to work you need to change the RPi video driver to the experimental GL driver. In doing this you can run retroarch with the GL driver so you need to compile with dispmanx.

The second limitation is RGB. So I was aiming to use the gertVGA adaptor but to do the you need to run the vga666 overly which then breaks xrandr.

For composite it would work great.

The last limitation for trying to keep RGB is to use the standard video driver and then call vcgencmd command to switch the res. But this crashes the PI if done while Retroarch is running. But you can switch using this me then before running Retroarch and everlth8ng and it will work

Does it work with an HDMI-to-VGA adapter?

That is something I’m trying out. However, my finding so far are that you can’t use custom timings with a HDMI to VGA device. But I’ve not looked into it too much yet, I tried it out for 5 mins as an initial test.

I haven’t tried it through xrandr, only through the hdmi_cvt stuff in the RPi’s config.txt. I think there may be a runtime interface for that. I’ll look into it.

It would be good if there was as this would fix the main switching issue. However, to get the correct ratio porches are normally adjusted. This just means I might have to play around with the aspect ratio of the image instead.

Hopefully you’ll find some good info

Do you have some documentation of the options that the Opengl driver supports in Xorg.conf?, I know that for Nvidia are a bunch of options to force any modeline.

I have not had a look into this but as I mentioned above it does work fine when you are not using the VGA666 overlay. but that means you need to use hdmi.

@hunterk I’ve just had a quick go at hdni_cvt but I cant seem to get the resolutions to sync on 15hkz. What options are you using?

Looks like you can use this command at runtime (using 320x240 example): vcgencmd hdmi_timings 320 1 25 30 30 240 1 9 3 10 0 0 0 60 0 6400000 6

the hdmi_timings syntax is apparently:

hdmi_timings <h_active_pixels> <h_sync_polarity <h_front_porch> <h_sync_pulse> <h_back_porch> <v_active_lines> <v_sync_polarity> <v_front_porch> <v_sync_pulse> <v_back_porch> <v_sync_offset_a> <v_sync_offset_b> <pixel_rep> <frame_rate> <interlaced> <pixel_freq> <aspect_ratio>

I haven’t looked at my config.txt in a while but IIRC I had to set one of the sync parameters to negative…?

For reference, here are the hdmi_timings lines used with the retrotink:

hdmi_timings=2048 1 180 202 300 240 1 3 5 14 0 0 0 60 0 42954545 1 #240p - NTSC perfect clock based on SNES/NES timings
#hdmi_timings=2048 1 180 202 300 480 1 6 10 28 0 0 0 60 0 85909090 1 #480p
#hdmi_timings=2048 1 180 202 300 240 1 3 5 14 0 0 0 120 0 85909090 1 #240p at 120Hz
#hdmi_timings=2048 1 40 442 200 240 1 3 10 8 0 0 0 120 0 85909090 1 #240p at 120 Hz. modified timings for Apple 21in CRT
#hdmi_timings=1280 1 80 72 216 720 1 5 3 22 0 0 0 60 0 74239049 1 #720p

@hunterk thanks for the info man. Unfortunately this is one of the methods I’ve tested. It works great if you run the commands before loading RA. However, when RA is running and you attempt this it crashes.

I did have a breakthrough last night though, using a HDMI to VGA adaptor and xrandr. In sort it working! But there is a lot to do.

Speeding up switching is the most important one.

Here is a short video.

https://youtu.be/vfa8gml5f5E

2 Likes

Hi, I’m trying to get the super resolution of 2560 to work on Linux with Xorg, but I’m having a problem, when RA goes to the menu it starts fine but when I try to launch a content I get the following error from X.

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (XFree86-VidModeExtension)
  Minor opcode of failed request:  10 (XF86VidModeSwitchToMode)
  Value in failed request:  0x1800001
  Serial number of failed request:  21156
  Current serial number in output stream:  21159

I could make CRT Switchres work on a 31khz monitor in Linux, here is a video:

I took the CRT switchres files under GFX and made it work at 138hz, made all the NTSC super resolutions in that refresh rate, the problem right now is that I keep getting this error everytime that I close a content or even sometimes when I try to load a content:

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  151 (XFree86-VidModeExtension)
  Minor opcode of failed request:  10 (XF86VidModeSwitchToMode)
  Value in failed request:  0x1800001
  Serial number of failed request:  21156
  Current serial number in output stream:  21159

I think the problem is somehow related to the Nvidia driver, I’m not sure because I tried running with the nouveau driver and I still get this error, the only moment that it worked perfectly in nouveau was running only with the CRT monitor connected, so, I’m going to keep trying to fix this.

OK so the way the Linux switching should work is that it creates the resolutions for you. If you are adding resolutions to Linux manually there will be errors.This is because RA will attempt to add and delete the resolutions on the fly. The reason for deleting them is because some resolutions will have different porches and refresh rates.

this error may also occur on first boot. This will be due to the resolution delete code, it will not find one to delete as the first one has only just been created.

Also what variable for refresh have you changed? I asked this as I can see that it is still setting the game to 60.000000! This will cause vsync issues down the line. Also why have you choosen 138hz? should that not be 120hz!

Just to clarify you are keeping the original resolutions but with 138hz? like 2560x224@138

Not all the code for switching in that file, it is just the setup code.

1 Like

@Alphanu Ok, I will try to delete the resolutions from Xorg.conf, for some reason.

I changed the file gfx/video_crt_switch.c in the line where it says:

static void switch_crt_hz(void)
{
   if (ra_core_hz == ra_tmp_core_hz)
      return;
   /* set hz float to an int for windows switching */
   if (ra_core_hz < 53)
      ra_set_core_hz = 50;	
   if (ra_core_hz >= 53  &&  ra_core_hz < 57)
      ra_set_core_hz = 55;	
   if (ra_core_hz >= 57)
      ra_set_core_hz = 60;	
	
   video_monitor_set_refresh_rate(ra_set_core_hz);
   
   ra_tmp_core_hz = ra_core_hz;
}

I replaced it with:

static void switch_crt_hz(void)
{
   if (ra_core_hz == ra_tmp_core_hz)
      return;
   /* set hz float to an int for windows switching */
   if (ra_core_hz < 53)
      ra_set_core_hz = 138;	
   if (ra_core_hz >= 53  &&  ra_core_hz < 57)
      ra_set_core_hz = 138;	
   if (ra_core_hz >= 57)
      ra_set_core_hz = 138;	
	
   video_monitor_set_refresh_rate(ra_set_core_hz);
   
   ra_tmp_core_hz = ra_core_hz;
}

The reason I used a refresh rate of 138hz is that in 120hz 2560x192 doesn’t work, the khz are to low for the screen to support, and setting up something higher than 138hz made 2560x480 not work, the khz are to high with this.

All the resolutions are the same original 2560x192 to 480 but at 138hz of refresh rates.

I saw that 60.00hz been setup, since Linux was running at the 138hz resolution I thought It was unrelated, where else the refresh rates are setup?, also, do you have any idea if PC CRT’s supports 480 interlaced resolution?, every way I try to setup a interlaced resolution either the screen goes blank ot the whole PC freeze, and I mean the whole PC not only Xorg.conf. Thanks, have a good day :slightly_smiling_face:.

So firstly you have edited the wrong section. if you read the notes,this is for windows. I guess the reason it works for you at the moment is that the resolution you have installed match the ones asked for by RA.

The section you want to edit is below. Starting from line 76 in the same file you have been editing. this sends the height, width and refresh to the algorithm to generate the modeline.

static void switch_res_crt(unsigned width, unsigned height)
{
   if (height > 100)
   {
      video_display_server_switch_resolution(width, height,
            ra_set_core_hz, ra_core_hz);
      video_driver_apply_state_changes();
   }
}

The variable ra_core_hz is what is used for Linux so if you want to hard set that to 138.0f it will then generate all the modeling at 138hz

static void switch_res_crt(unsigned width, unsigned height)
{
   if (height > 100)
   {
      video_display_server_switch_resolution(width, height,
            ra_set_core_hz, 138.0f);
      video_driver_apply_state_changes();
   }
}

I am not sure about interlaced resolution, but the modeline generator will create one and attempt to switch to it. Also this will switch the game to 138hz which mean it will run over twice as fast as it should.

Modelines are tricky to get right, through my testing I found similar issue you have but with 240p as well. The pixelclock, hz, max height and max width all need to calculated together. Also limitations on you GPU can also cause this issue.

Lastly if the limitation is the pixel clock needing to be higher for a 31khz monitor use 3840 as the super resolution. This will keep the pixel clock higher and allow you to reduce the hz. This can be changed in the retroarch.cfg located at ~/.config/retroarch/

1 Like

Oh, I did not saw that, I will try with that, thanks, I really apreciate your help, I will try with 3840 to see if I can reduce the hz to 120hz.

Currently the game does not show any sync issues, and the framerate runs always at the original speed, of course 138hz or 120hz is not the ideal, the best would be to run at the native resolutions but, yes, PC monitor.

Been off-topic here, I have another big 15khz CRT but I have no idea how to connect it to the pc via VGA, I tried to do it by sending a RGB and H-Sync signal to the VGA cable but I just got a bunch of crazy colors on the CRT, do you have some information around in how to make it work or is to complicated?.