You are not logged in.

#1 2017-12-12 10:59:23

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 274

Force 50Hz display mode?

hi,
i need to set 50Hz refresh rate on my TV/Monitor VGA, but it doesn't support it:

$ xrandr 
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
VGA-1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 708mm x 398mm
   1280x720      50.00 +
   1024x768      75.03*   70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   640x480       75.00    72.81    66.67    59.94  
   720x400       70.08  
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)

(1280x720 resolution doesn't work: black screen and OSD shows "OUT OF RANGE")

$ xrandr -s 1024x768 -r 50
Rate 50.00 Hz not available for this size

Can i force it?

$ lspci|grep -i vga
00:02.0 VGA compatible controller: Intel Corporation Atom Processor Z36xxx/Z37xxx Series Graphics & Display (rev 0e)
$ pacman -Q|grep xf86-video
xf86-video-vesa 2.3.4-4

Last edited by quellen (2017-12-12 11:00:09)


sorry for my bad english

Offline

#2 2017-12-20 20:21:32

FelledTreeNo9
Member
Registered: 2015-05-05
Posts: 23

Re: Force 50Hz display mode?

You'll need to add that mode - that is, timings for it - to the X server first either by adding a modeline to xorg.conf or more dynamically with xrandr --newmode and --addmode. Like this:

# Generate timings for a new mode at the wanted size and refresh rate (you can alternatively use 'gtf' in the same way)
cvt 1024 768 50
# 1024x768 49.98 Hz (CVT 0.79M3) hsync: 39.63 kHz; pclk: 52.00 MHz
Modeline "1024x768_50.00"   52.00  1024 1072 1168 1312  768 771 775 793 -hsync +vsync

# Create a new mode in the running X server using the above timings
xrandr --newmode my50hzmode 52.00 1024 1072 1168 1312 768 771 775 793 -hsync +vsync

# Add that new mode to the VGA-1 output
xrandr --addmode VGA-1 my50hzmode

# Switch to the mode
xrandr --output VGA-1 --mode my50hzmode

Here's a small Python script I use to do the above more conveniently: https://pastebin.com/kWKFLGXD

Now hope that your monitor and graphics card respect you enough to try to do what you asked without further second guessing. (Example, I had a Dell U2410, lovely picture, but in 50 Hz even though "confirmed" by the OSD, it was still really 60 as the juddering when trying to scroll an old game at 50 Hz showed. Or the big Samsung living room TV which happily displayed domestic TV channels in PAL-50, but flat out refused with the black screen and complainy message when driven from the computer at that rate. Sigh. On the other hand, I've known a cheap little Hitachi LED TV that moved smoothly (albeit with a lot of blur because it wasn't a good panel), and I couldn't be happier right now with my Asus MX279H for this kind of thing.

Last edited by FelledTreeNo9 (2017-12-20 20:26:31)

Offline

#3 2017-12-20 21:28:13

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 274

Re: Force 50Hz display mode?

thank you very much FelledTreeNo9!
unfortunately when i launch "xrandr --output VGA-1 --mode my50hzmode" i have black screen and TV OSD shows "OUT OF RANGE".

$ cvt 1024 768 50
# 1024x768 49.98 Hz (CVT 0.79M3) hsync: 39.63 kHz; pclk: 52.00 MHz
Modeline "1024x768_50.00"   52.00  1024 1072 1168 1312  768 771 775 793 -hsync +vsync
$ xrandr --newmode  my50hzmode  52.00  1024 1072 1168 1312  768 771 775 793 -hsync +vsync
$ xrandr --addmode VGA-1 my50hzmode
$ xrandr --output VGA-1 --mode my50hzmode

i have tried to launch your script but it says error:

$ python 50hz.py 
  File "50hz.py", line 39
    print line
             ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(print line)?
$ python2 50hz.py 
Insufficient arguments.
$ cat 50hz.py 
#!/usr/bin/python2


# Python
import sys
import os
import subprocess
import time


def getOutputs():
    """
    For the first screen, get the names of the outputs and whether they're currently connected.

    Returns:
     (list)
     Each element is:
      (tuple)
      Tuple has elements:
       0:
        (str)
        Name of output
       1:
        (bool)
        Whether the output is currently connected.
    """
    # Run xrandr
    popen = subprocess.Popen(["xrandr", "--screen", "0", "--query"], stdout=subprocess.PIPE)
    popen.wait()
    (out, err) = popen.communicate()

    # Parse output
    lines = out.split("\n")
    if lines[0][:9] != "Screen 0:":
        raise RuntimeError("Unexpected preamble from xrandr --query")

    outputs = []
    for line in lines[1:]:
        print line
        if len(line) > 0 and line[1] != " ":
            lineFields = line.split(" ")
            outputs.append((lineFields[0], lineFields[1] == "connected"))

    return outputs

def generateTimings(i_timingCommand, i_width, i_height, i_fieldRate, i_interlaced=False):
    """
    Params:
     i_timingCommand:
      (str)
     i_width, i_height:
      Either (int)
      or (str)
       String representations of an integer.
     i_fieldRate:
      (str)
      String representations of a float.
     i_interlaced:
      (bool)
      True: Make an interlaced mode

    Returns:
     (list)
     eg. ['Modeline', '1920x1080i60.00', '86.5', '1920', '2048', '2248', '2576', '1080', '1083', '1088', '1120', '+hsync', '+vsync', 'Interlace']
    """
    # Run cvt or gtf
    popen = subprocess.Popen([i_timingCommand, str(i_width), str(i_height), i_fieldRate], stdout=subprocess.PIPE)
    popen.wait()
    (out, err) = popen.communicate()

    # Parse output
    lines = out.split("\n")
    modespec = None
    for line in lines:
        line = line.strip()
        if line.startswith("Modeline "):
            parts = line.split(" ")
            modespec = [p  for p in parts  if p != ""]
            break

    # Remove enclosing quotes in mode name
    modespec[1] = modespec[1].replace('"', '')

    # Modify mode name (which was generated by cvt/gtf)
    # to show whether progressive or interlaced,
    # and add actual interlacing options if desired
    if not i_interlaced:
        modespec[1] = modespec[1].replace('_', 'p')
    else:
        modespec[1] = modespec[1].replace('_', 'i')

        modespec.append("Interlace")
        modespec[2] = str(float(modespec[2]) / 2.0)

    #
    return modespec

def recreateMode(i_outputName, i_modespec, i_printXrandrCommands = False):
    """
    Params:
     i_outputName:
      (str)
     i_modespec:
      (list)
     i_printXrandrCommands:
      (bool)
    """
    #print "i_modespec: " + str(i_modespec)
    xrandrCommand = ["xrandr", "--delmode", i_outputName]
    xrandrCommand += [i_modespec[1]]
    if i_printXrandrCommands:
        print(subprocess.list2cmdline(xrandrCommand))
    subprocess.Popen(xrandrCommand)

    time.sleep(0.25)

    xrandrCommand = ["xrandr", "--rmmode"]
    xrandrCommand += [i_modespec[1]]
    if i_printXrandrCommands:
        print(subprocess.list2cmdline(xrandrCommand))
    subprocess.Popen(xrandrCommand)

    time.sleep(0.25)

    xrandrCommand = ["xrandr", "--newmode"]
    xrandrCommand += i_modespec[1:]
    if i_printXrandrCommands:
        print(subprocess.list2cmdline(xrandrCommand))
    subprocess.Popen(xrandrCommand)

    time.sleep(0.25)

    xrandrCommand = ["xrandr", "--addmode", i_outputName]
    xrandrCommand += [i_modespec[1]]
    if i_printXrandrCommands:
        print(subprocess.list2cmdline(xrandrCommand))
    subprocess.Popen(xrandrCommand)

def setMode(i_outputName, i_modespec, i_printXrandrCommands = False):
    """
    Params:
     i_outputName:
      (str)
     i_modespec:
      (list)
     i_printXrandrCommands:
      (bool)
    """
    xrandrCommand = ["xrandr", "--output", i_outputName]
    xrandrCommand += ["--mode", i_modespec[1]]
    if i_printXrandrCommands:
        print(subprocess.list2cmdline(xrandrCommand))
    subprocess.Popen(xrandrCommand)


if __name__ == "__main__":

    # + Parse command line {{{

    COMMAND_NAME = "easy_xrandr"

    def printUsage(i_outputStream):
        i_outputStream.write('''\
''' + COMMAND_NAME + ''' by Daniel Lopez, 04/12/2016
xrandr wrapper

Usage:
======
''' + COMMAND_NAME + ''' <action> <width> <height> <field rate> [options...]

Params:
 action:
  Either 'add'
   Just add the new mode to xrandr's list
  or 'set'
   Add the new mode and also switch to it now.
 width, height:
  Desired resolution width and height in integer pixels
  eg. 1024 and 768
 field rate:
  Desired field rate in floating point Hz
  eg. 60.1
  In non-interlaced modes, this is the same as the frame rate,
  and in interlaced modes, this is double the actual full frame rate.

Options:
 Output selection
  --output <name>
   Choose which output to control

 Interlace
  --interlace
   Create an interlaced mode.
   In this case the actual full frame rate will turn out to be half of
   the number given for the <field rate> parameter.

 Generating timings
  --cvt
   Use the 'cvt' command to generate the timings
   (This is the default).
  --gtf
   Use the 'gtf' command to generate the timings.
''')

    #
    param_action = None  # "add" or "set"
    param_width = None
    param_height = None
    param_fieldRate = None
    interlaced = False
    timingCommand = "cvt"
    outputName = "DVI-I-1"

    import sys
    argNo = 1
    while argNo < len(sys.argv):
        arg = sys.argv[argNo]
        argNo += 1

        if arg[0] == "-":

            if arg == "--help":
                printUsage(sys.stdout)
                sys.exit(0)

            if arg == "--cvt":
                timingCommand = "cvt"
            elif arg == "--gtf":
                timingCommand = "gtf"
            elif arg == "--interlace":
                interlaced = True
            elif arg == "--output":
                if argNo >= len(sys.argv):
                    print("--output requires an argument")
                    sys.exit(-1)

                arg = sys.argv[argNo]
                argNo += 1

                outputName = arg
            else:
                print("Unrecognised option: " + arg)
                sys.exit(-1)

        else:
            # Collect command-line arguments
            if param_action == None:
                param_action = arg
            elif param_width == None:
                param_width = arg
            elif param_height == None:
                param_height = arg
            elif param_fieldRate == None:
                param_fieldRate = arg
            else:
                print("Too many arguments.")
                sys.exit(-1)

    if param_fieldRate == None:
        print("Insufficient arguments.")
        sys.exit(-1)

    # + }}}

    # + Generate timings {{{

    print("Generating timings with " + timingCommand)
    modespec = generateTimings(timingCommand, param_width, param_height, param_fieldRate, interlaced)
    #print modespec
    if modespec == None:
        print("Failed to parse timings.")
        sys.exit(1)

    ##
    #modespec = modespec[:-2]
    #modespec.append("-hsync")
    #modespec.append("-vsync")

    #
    print modespec
    #sys.exit(0)

    # + }}}

    recreateMode(outputName, modespec, True)

    if param_action == "set":
        time.sleep(0.25)
        setMode(outputName, modespec)

p.s.
if i connect, with RCA connector,  an old PAL Video game console (like a SNES) it works perfectly. then my monitor/TV supports 50Hz but maybe only with RCA and not with VGA :-(

Last edited by quellen (2017-12-20 21:29:52)


sorry for my bad english

Offline

#4 2017-12-20 22:58:21

FelledTreeNo9
Member
Registered: 2015-05-05
Posts: 23

Re: Force 50Hz display mode?

That's a shame, I fear you could just have a stubborn TV. What's its model, out of interest?

As a sanity check, after running those xrandr commands, if you then run 'xrandr' by itself, do you then see the new mode in the list under "VGA-1" in addition to all the others you had to start with?

You could try generating the numbers with the 'gtf' program instead of 'cvt' - it uses a slightly different formula and results in slightly different numbers - there is some leeway to them. The meaning of the numbers is summarized here: https://en.wikipedia.org/wiki/XFree86_Modeline

You could add the word "Interlace" at the end of the "xrandr --newmode ..." command to make an interlaced mode (this is a shot in the dark really).

You could try generating a 100 Hz mode instead which might be an effective substitute for 50 Hz (again, it's a long shot I guess).

It's possible the video driver is reinterpreting or restricting you somehow. I have an Nvidia card and I had to look in the driver's readme and set some xorg.conf options before it would let me add modes that weren't already in the EDID (the monitor's own declaration about what modes it 'supports'). Though yours is Intel and it does sound most like the driver is obediently sending something different to the TV - ie. 50 Hz hopefully - but the TV is rejecting it.

If you have a Windows install handy you could try a program called Powerstrip (http://entechtaiwan.com/util/ps.shtm) which lets you tweak the timings by clicking in real time; though it's old and I'm not sure if it still works on modern Windows. The different OS would be a roundabout way of testing with a different video driver though.

Yeah that script is in Python 2, and the usual way to use it would be:
  50hz.py set 1024 768 50
Run it with --help to see some other options.

Yeah I'm mostly concerned with this for retrogaming myself, and it's infuriating how fickle and inconsistent displays can be, in a way where the newer/more expensive stuff isn't always better neutral

Offline

#5 2017-12-20 23:00:20

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,394

Re: Force 50Hz display mode?

Yeah, usually different connectors means different supported resolutions too.
My Flat-Panel TV supports 1280x720@(50,60,72,75)hz on HDMI, but only "Standard Vesa PC video timings" (whatever it means) via VGA, this means 1280x720@60hz, dot.

Fun fact:
I even tried to generate a custom modeline at lower resolutions, and it worked (sort-of), but it produced tearing and stuttering (pc output was fine!)... i mean, even if it accepted the 50hz modeline, it tried to display it on a 60hz display.
Then i got an hdmi cable smile


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#6 2017-12-21 09:04:10

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 274

Re: Force 50Hz display mode?

it's an old (2007) and cheap UNITED LTV LCD without HDMI connector.

FelledTreeNo9 wrote:

if you then run 'xrandr' by itself, do you then see the new mode in the list under "VGA-1" in addition to all the others you had to start with?

yes:

$ xrandr 
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 8192 x 8192
VGA-1 connected primary 1024x768+0+0 (normal left inverted right x axis y axis) 708mm x 398mm
   1280x720      50.00 +
   1024x768      75.03*   70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   640x480       75.00    72.81    66.67    59.94  
   720x400       70.08  
   my50hzmode    49.98  
   1024x768p100.00  99.97  
   1024x768p75.00  74.90  
   1024x768p60.00  59.92  
   1024x768i50.00  49.98  
   1024x768p50.00  49.98  
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)
FelledTreeNo9 wrote:

You could try generating the numbers with the 'gtf' program instead of 'cvt'
You could add the word "Interlace" at the end of the "xrandr --newmode ..." command to make an interlaced mode
You could try generating a 100 Hz mode instead which might be an effective substitute for 50 Hz (again, it's a long shot I guess).

tried. it always shows OUT OF RANGE. it works only with 60Hz and 75Hz.

FelledTreeNo9 wrote:

It's possible the video driver is reinterpreting or restricting you somehow. I have an Nvidia card and I had to look in the driver's readme and set some xorg.conf options before it would let me add modes that weren't already in the EDID (the monitor's own declaration about what modes it 'supports'). Though yours is Intel and it does sound most like the driver is obediently sending something different to the TV - ie. 50 Hz hopefully - but the TV is rejecting it.

i have already changed the EDID using these command:

# get-edid > 1024x768.bin
# parse-edid < 1024x768.bin
# cp 1024x768.bin /usr/lib/firmware/edid/

and adding this parameter to grub.cfg:

drm_kms_helper.edid_firmware=edid/1024x768.bin

without it on TTY i see black screen and OUT OF RANGE maybe because it set automatically 1280x720 resolution.

i wanted to set 50Hz refresh to emulate perfectly PAL games of Commodore Amiga:
https://fs-uae.net/perfectly-smooth-scrolling

Last edited by quellen (2017-12-21 09:31:35)


sorry for my bad english

Offline

#7 2017-12-21 16:21:33

FelledTreeNo9
Member
Registered: 2015-05-05
Posts: 23

Re: Force 50Hz display mode?

We're very much on the same page - that's pretty much my favourite emulator for how the author went out of his way to support this kind of thing well, and I use it on the aforementioned Asus monitor with flawless 50 Hz refresh and vsync.

Whereas, I also plugged a real Amiga via RCA into the Dell monitor I had and it even that way it was jerky; the monitor itself apparently awkwardly resampling it probably to 60. My last desperate action in that case was to google for whether the monitor had a service menu with advanced functions - it did (accessed by holding down some particular buttons while turning it on, or something like that), though ultimately nothing in there helped either.

I'm out of suggestions, sorry. Maybe some converter box which changes VGA (or DP/HDMI?) to RCA but of course it would lose quality and you'd have to consider the cost neutral

Offline

#8 2017-12-21 17:41:34

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 274

Re: Force 50Hz display mode?

i can't understand one thing: c64 games works at 50Hz too, but emulation (with vice) don't seems to have scrolling problem...why?

Last edited by quellen (2017-12-21 17:42:00)


sorry for my bad english

Offline

#9 2017-12-21 19:42:04

FelledTreeNo9
Member
Registered: 2015-05-05
Posts: 23

Re: Force 50Hz display mode?

Could you be running a 60 Hz game / the emulator in NTSC mode?

Uridium is my go to for testing C64 scrolling smile

I find that I need vice-sdl2 from the AUR to avoid tearing. It's smooth but even so there is a little audio pop every 20 seconds or so that I can't seem to get rid of with the settings.

Oh yeah, I also always turn off the desktop compositor before starting up Vice, UAE, MAME, whatever. Not to clash with the emulators' own screen updating schemes.

Offline

#10 2017-12-24 09:07:59

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 274

Re: Force 50Hz display mode?

title screen of "Giana sisters" is also good for testing scrolling fluidity :-)
if i set C64 NTSC model on vice the games are too speed and they have graphic problems.


sorry for my bad english

Offline

#11 2017-12-29 12:40:20

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 274

Re: Force 50Hz display mode?

strangely i noticed that if i disable edid on boot and set 1024x768 75Hz refresh rate, scrolling of c64 and amiga games works much better than 60hz. it almost seems 50HZ refresh!


sorry for my bad english

Offline

#12 2017-12-29 16:51:28

kokoko3k
Member
Registered: 2008-11-14
Posts: 2,394

Re: Force 50Hz display mode?

Not all of the pal games runs at 50fps... some do 25fps, which is 75/3 so it fits perfectly.
That said, the higher the refresh rate, the better is the aproximation, so 75 is expected ro performs better than 60.


Help me to improve ssh-rdp !
Retroarch User? Try my koko-aio shader !

Offline

#13 2018-02-01 21:23:05

quellen
Member
From: Italy
Registered: 2014-05-24
Posts: 274

Re: Force 50Hz display mode?

kokoko3k wrote:

Not all of the pal games runs at 50fps... some do 25fps, which is 75/3 so it fits perfectly.
That said, the higher the refresh rate, the better is the aproximation, so 75 is expected ro performs better than 60.

the only problem is that NTSC 60Hz games doesn't work good with 75Hz, then every time I have to switch refresh rate :-|

Last edited by quellen (2018-02-01 21:23:21)


sorry for my bad english

Offline

Board footer

Powered by FluxBB