Linux – Writing Xorg custom modeline for 1366×768 with nvidia driver

debian-jessielinuxmodelinenvidia-graphics-cardxorg

I've recently bought a Dell e1914h monitor 18.5" and supports 1366×768@60Hz display. The problem with proprietary nvidia driver is 1366×768 resolution is not supported by default due to some nvidia specific thing(resolution not dividable by 8). So, I get 1368×768 resolution with nvidia driver. I booted with nouveau on the live cd and copied the modelines to /etc/X11/xorg.conf and is working. Yes – 1366×768@60Hz mode with Nvidia is working after copying custom modeline from lmde live cd which uses nouveau driver module. But, what I want is, how to calculate the modeline when values like horizontal/vertical front porche, back porche etc are not known although I've some details about the monitor available:
http://cdn2.bhphotovideo.com/lit_files/94125.pdf

What I wanted to achieve is a custom edid binary generated with 1366×768@60 supported for nvidia. What I have is the monitor specifications like horizontal, vertical sync range, Pixel Clock etc. I cannot find values like horizontal front porch etc to write the modeline manually. Can someone knowledgeable help? The problem with videogen, cvt, gtf etc are they all generated 1368×768 modeline instead of 1366×768. gtf output:

:~$ gtf 1366 768 60
# 1368x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 85.86 MHz 
Modeline "1368x768_60.00"  85.86  1368 1440 1584 1800  768 769 772 795  -HSync +Vsync

I've seen a post here, but does not explain all the horizontal and vertical values. I need to manually write a custom modeline which is confusing. Can someone shed some light on this?

These are the details of the monitor:

**Dell E1914H:**
  • Horizontal resolution: 47.7Khz

  • Vertical resolution: 59.8Hz

  • Pixel Clock: 85.5Mhz

  • Sync polarity: +/+ Scan range

  • Horizontal: 30 kHz to 83 kHz (automatic) 30 kHz to 83 kHz (automatic)

  • Vertical Maximum preset resolution: 56 Hz to 75 Hz (automatic)

  • Maximum preset resolution: 1366 x 768 at 60 Hz

  • Pixel pitch 0.30 (H) mm x 0.30 (V) mm

  • Brightness (typical) 200 cd/m2

  • Color gamut (typical) 83%

  • Color depth 16.7 million colors

  • Contrast ratio (typical) 600:1

Supported resolutions:
Supported Resolution Dell E1914H

This is the custom modeline I have copied from LMDE livecd:

    Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Dell"
    ModelName      "Dell E1914H"
    HorizSync      30.0 - 83.0
    VertRefresh    56.0 - 75.0
    DisplaySize    409.8  230.4
Modeline "1366x768"   85.50  1366 1436 1579 1792  768 771 774 798 +Hsync +Vsync
    Option         "DPMS"
EndSection

Nvidia specific things like disabling edid on /etc/X11/xorg.conf.d/20-nvidia.conf:

    Section "Screen"
    Identifier     "Screen0"
    Device         "Nvidia 7300GT"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "UseEdidDpi" "FALSE"
    Option "ModeDebug" "true"
    Option "ExactModeTimingsDVI" "true"
    Option         "ModeValidation" "NoWidthAlignmentCheck, NoDFPNativeResolutionCheck"
#    Option "ModeValidation"    "AllowInterlacecModes, NoTotalSizeCheck,AllowNon60HzDFPModes,NoEdidMaxPClkCheck,NoVertRefreshCheck,NoHorizSyncCheck,NoDFPNativeResolutionCheck,NoVesaModes,NoEdidModes,NoXServerModes,NoPredefinedModes,NoMaxSizeCheck,NoVirtualSizeCheck,NoMaxPclkCheck,NoVertRefreshCheck"
    Option "UseEDID" "False"
    Option         "TwinView" "0"
    SubSection     "Display"
        Depth       24
        Modes   "1366x768"
    EndSubSection
EndSection

From Xorg.0.log:

    [     8.847] (II) NVIDIA(GPU-0):   Validating Mode "1366x768":
[     8.847] (II) NVIDIA(GPU-0):     1366 x 768 @ 60 Hz
[     8.847] (II) NVIDIA(GPU-0):     Mode Source: X Configuration file ModeLine
[     8.847] (II) NVIDIA(GPU-0):       Pixel Clock      : 85.50 MHz
[     8.847] (II) NVIDIA(GPU-0):       HRes, HSyncStart : 1366, 1436
[     8.847] (II) NVIDIA(GPU-0):       HSyncEnd, HTotal : 1579, 1792
[     8.847] (II) NVIDIA(GPU-0):       VRes, VSyncStart :  768,  771
[     8.847] (II) NVIDIA(GPU-0):       VSyncEnd, VTotal :  774,  798
[     8.847] (II) NVIDIA(GPU-0):       H/V Polarity     : +/+
[     8.847] (II) NVIDIA(GPU-0):     Mode is valid.

Present modelines hsyncstart hsyncend etc are not probably correct. According to XFree86 Wiki, I am missing hsyncstart hsyncend and vsyncstart vsyncend.

Modeline syntax: pclk hdisp hsyncstart hsyncend htotal vdisp vsyncstart vsyncend vtotal [flags]
 Flags (optional): +HSync, -HSync, +VSync, -VSync, Interlace, DoubleScan, CSync, +CSync, -CSync

I did calculate these values after looking here:

"1366x768" 85.5 1366 hsyncstart hsyncend 1792 768 vsyncstart 795 vtotal +Hsync +Vsync

Best Answer

The frequency and the 4 horizontal values scale with the horizontal resolution, while the 4 vertical values scale with the vertical resolution.

So you can just ask for double the resolution (1366*2 = 2736)

gtf 2736 768 60

And divide all the horizontal values, and the frequency, by two.

Related Question