From cd5cb8b7cf49463c10dafe32c148b8ddb416b9f1 Mon Sep 17 00:00:00 2001 From: Harry de Boer Date: Mon, 26 Nov 2012 22:36:23 +0100 Subject: [PATCH 4/4] Return valid DisplayModePtr list for tv outputs. When creating a list of DisplayModePtr the ->next and ->prev pointers should point to the next/previous item in the list or only the first modeline will be recognised. This patch changes via_tv_get_modes to use the xf86ModesAdd and xf86DuplicateMode helpers to create correct modeline lists from a DisplayModeRec array. --- src/via_ch7xxx.c | 2 ++ src/via_ch7xxx.h | 4 ---- src/via_outputs.c | 10 +++++++++- src/via_ums.h | 1 + src/via_vt162x.c | 3 +++ src/via_vt162x.h | 5 ----- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/via_ch7xxx.c b/src/via_ch7xxx.c index 7686aa6..48689a6 100644 --- a/src/via_ch7xxx.c +++ b/src/via_ch7xxx.c @@ -614,6 +614,7 @@ ViaCH7xxxInit(ScrnInfoPtr pScrn) pBIOSInfo->TVModeCrtc = CH7xxxModeCrtc; pBIOSInfo->TVPower = CH7xxxTVPower; pBIOSInfo->TVModes = CH7011Modes; + pBIOSInfo->TVNumModes = sizeof(CH7011Modes) / sizeof(DisplayModeRec); pBIOSInfo->LCDPower = NULL; pBIOSInfo->TVNumRegs = CH_7011_MAX_NUM_REG; #ifdef HAVE_DEBUG @@ -630,6 +631,7 @@ ViaCH7xxxInit(ScrnInfoPtr pScrn) pBIOSInfo->TVModeCrtc = CH7xxxModeCrtc; pBIOSInfo->TVPower = CH7xxxTVPower; pBIOSInfo->TVModes = CH7019Modes; + pBIOSInfo->TVNumModes = sizeof(CH7019Modes) / sizeof(DisplayModeRec); pBIOSInfo->LCDPower = CH7019LCDPower; pBIOSInfo->TVNumRegs = CH_7019_MAX_NUM_REG; #ifdef HAVE_DEBUG diff --git a/src/via_ch7xxx.h b/src/via_ch7xxx.h index 68df1b5..f54ac5e 100644 --- a/src/via_ch7xxx.h +++ b/src/via_ch7xxx.h @@ -86,8 +86,6 @@ static DisplayModeRec CH7011Modes[]={ { MODEPREFIX("720x576"), 28500, 720, 728, 744, 760, 0, 576, 635, 643, 750, 0, V_NHSYNC | V_PVSYNC, MODESUFFIXPAL }, { MODEPREFIX("720x480Noscale"), 27972, 720, 736, 768, 888, 0, 480, 480, 483, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXNTSC }, { MODEPREFIX("720x576Noscale"), 28000, 720, 728, 864, 896, 0, 576, 576, 579, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL }, - - { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC }, }; static DisplayModeRec CH7019Modes[]={ @@ -103,8 +101,6 @@ static DisplayModeRec CH7019Modes[]={ { MODEPREFIX("800x600Over"), 32500, 800, 832, 928, 1000, 0, 600, 600, 604, 650, 0, V_PHSYNC | V_PVSYNC, MODESUFFIXPAL }, { MODEPREFIX("1024x768Over"), 50400, 1024, 1040, 1112, 1200, 0, 768, 772, 776, 840, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXNTSC }, { MODEPREFIX("1024x768Over"), 49500, 1024, 1032, 1112, 1200, 0, 768, 771, 776, 825, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL }, - - { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC }, }; diff --git a/src/via_outputs.c b/src/via_outputs.c index 0620a12..4e2ffaa 100644 --- a/src/via_outputs.c +++ b/src/via_outputs.c @@ -351,7 +351,15 @@ via_tv_get_modes(xf86OutputPtr output) ScrnInfoPtr pScrn = output->scrn; VIAPtr pVia = VIAPTR(pScrn); - return pVia->pBIOSInfo->TVModes; + DisplayModePtr modes = NULL; + DisplayModePtr mode = NULL; + + for (int i = 0; i < pVia->pBIOSInfo->TVNumModes; i++) { + mode = xf86DuplicateMode(&pVia->pBIOSInfo->TVModes[i]); + modes = xf86ModesAdd(modes, mode); + } + + return modes; } static void diff --git a/src/via_ums.h b/src/via_ums.h index db7c7de..411d52d 100644 --- a/src/via_ums.h +++ b/src/via_ums.h @@ -177,6 +177,7 @@ typedef struct _VIABIOSINFO { void (*TVPower) (ScrnInfoPtr pScrn, Bool On); void (*LCDPower) (ScrnInfoPtr pScrn, Bool On); DisplayModePtr TVModes; + int TVNumModes; void (*TVPrintRegs) (ScrnInfoPtr pScrn); } VIABIOSInfoRec, *VIABIOSInfoPtr; diff --git a/src/via_vt162x.c b/src/via_vt162x.c index 0c558f4..8aab54a 100644 --- a/src/via_vt162x.c +++ b/src/via_vt162x.c @@ -883,6 +883,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn) pBIOSInfo->TVModeCrtc = VT1622ModeCrtc; pBIOSInfo->TVPower = VT1622Power; pBIOSInfo->TVModes = VT1622Modes; + pBIOSInfo->TVNumModes = sizeof(VT1622Modes) / sizeof(DisplayModeRec); pBIOSInfo->TVPrintRegs = VT162xPrintRegs; pBIOSInfo->TVNumRegs = 0x68; break; @@ -895,6 +896,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn) pBIOSInfo->TVModeCrtc = VT1622ModeCrtc; pBIOSInfo->TVPower = VT1622Power; pBIOSInfo->TVModes = VT1623Modes; + pBIOSInfo->TVNumModes = sizeof(VT1623Modes) / sizeof(DisplayModeRec); pBIOSInfo->TVPrintRegs = VT162xPrintRegs; pBIOSInfo->TVNumRegs = 0x6C; break; @@ -907,6 +909,7 @@ ViaVT162xInit(ScrnInfoPtr pScrn) pBIOSInfo->TVModeCrtc = VT1622ModeCrtc; pBIOSInfo->TVPower = VT1625Power; pBIOSInfo->TVModes = VT1625Modes; + pBIOSInfo->TVNumModes = sizeof(VT1625Modes) / sizeof(DisplayModeRec); pBIOSInfo->TVPrintRegs = VT162xPrintRegs; pBIOSInfo->TVNumRegs = 0x82; break; diff --git a/src/via_vt162x.h b/src/via_vt162x.h index b39134f..f5ae92e 100644 --- a/src/via_vt162x.h +++ b/src/via_vt162x.h @@ -65,7 +65,6 @@ static DisplayModeRec VT1621Modes[] = { { MODEPREFIX("640x480Over"), 24000, 640, 672, 888, 960, 0, 480, 485, 491, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL }, { MODEPREFIX("800x600Over"), 36400, 800, 840, 960, 1040, 0, 600, 602, 604, 700, 0, V_PHSYNC | V_PVSYNC, MODESUFFIXNTSC }, { MODEPREFIX("800x600Over"), 29500, 800, 824, 896, 944, 0, 600, 599, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIXPAL }, - { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC }, }; struct VT1621TableRec { @@ -185,7 +184,6 @@ static DisplayModeRec VT1622Modes[] = { { MODEPREFIX("720x576Over"), 30000, 720, 728, 864, 1000, 0, 576, 576, 579, 600, 0, V_NHSYNC | V_PVSYNC, MODESUFFIXPAL }, { MODEPREFIX("720x480Noscale"), 27972, 720, 736, 768, 888, 0, 480, 480, 483, 525, 0, V_NHSYNC | V_PVSYNC, MODESUFFIXNTSC }, { MODEPREFIX("720x576Noscale"), 28000, 720, 728, 864, 896, 0, 576, 576, 579, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL }, - { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC }, }; struct VT162XTableRec { @@ -466,7 +464,6 @@ static DisplayModeRec VT1623Modes[] = { { MODEPREFIX("720x576Noscale"), 28000, 720, 736, 768, 896, 0, 576, 576, 579, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL }, { MODEPREFIX("720x480Noscale"), 27972, 720, 736, 768, 888, 0, 480, 480, 483, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXNTSC }, { MODEPREFIX("720x480pal"), 27972, 720, 736, 768, 888, 0, 480, 480, 483, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIXPAL }, - { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC }, }; static struct VT162XTableRec @@ -772,8 +769,6 @@ static DisplayModeRec VT1625Modes[] = { { MODEPREFIX("720x480Under"), 28224, 720, 728, 744, 784, 0, 480, 490, 496, 600, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX480P }, { MODEPREFIX("720x480Fit"), 28980, 720, 728, 776, 840, 0, 480, 484, 499, 575, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX480P }, { MODEPREFIX("720x480Over"), 27027, 720, 784, 808, 858, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX480P }, - - { MODEPREFIX(NULL), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, MODESUFFIXNTSC }, }; static struct VT162XTableRec -- 1.7.10.4