From 0194e3fc17971a9cec1e8d995e6d9c4298dab73c Mon Sep 17 00:00:00 2001 From: Andrei-Liviu Simion Date: Mon, 26 Jan 2015 17:27:47 -0800 Subject: [PATCH] video_common: Fixed pixel clock calculation for interlaced modes. In interlaced mode, the vertical total lines for frames 0 and 1 may not necessarily be equal (off by 1). The pixel clock calculation needs to take this into account by taking their average. Signed-off-by: Andrei-Liviu Simion --- .../drivers/video_common/src/xvidc.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/XilinxProcessorIPLib/drivers/video_common/src/xvidc.c b/XilinxProcessorIPLib/drivers/video_common/src/xvidc.c index beb870d4..727f89d2 100644 --- a/XilinxProcessorIPLib/drivers/video_common/src/xvidc.c +++ b/XilinxProcessorIPLib/drivers/video_common/src/xvidc.c @@ -93,24 +93,27 @@ u32 XVidC_GetPixelClockHzByVmId(XVidC_VideoMode VmId) VmPtr = &XVidC_VideoTimingModes[VmId]; - /* For pixel clock calculation, use frame with the larger vertical - * total. This is useful for interlaced modes with frames that don't - * have exactly the same vertical total. For progressive modes, - * F0PVTotal will be used since F1PVTotal will be equal to 0. */ - if (VmPtr->Timing.F0PVTotal >= VmPtr->Timing.F1VTotal) { - ClkHz = VmPtr->Timing.F0PVTotal; + if (XVidC_IsInterlaced(VmId)) { + /* For interlaced mode, use both frame 0 and frame 1 vertical + * totals. */ + ClkHz = VmPtr->Timing.F0PVTotal + VmPtr->Timing.F1VTotal; + + /* Multiply the number of pixels by the frame rate of each + * individual frame (half of the total frame rate). */ + ClkHz *= VmPtr->FrameRate / 2; } else { - ClkHz = VmPtr->Timing.F1VTotal; + /* For progressive mode, use only frame 0 vertical total. */ + ClkHz = VmPtr->Timing.F0PVTotal; + + /* Multiply the number of pixels by the frame rate. */ + ClkHz *= VmPtr->FrameRate; } /* Multiply the vertical total by the horizontal total for number of * pixels. */ ClkHz *= VmPtr->Timing.HTotal; - /* Multiply the number of pixels by the frame rate. */ - ClkHz *= VmPtr->FrameRate; - return ClkHz; }