V4L/DVB (8462): cx18: Lock the aux PLL to the video pixle rate for analog captures

From: Linux Kernel Mailing List
Date: Monday, July 28, 2008 - 10:02 am

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=35f92b...
Commit:     35f92b2af8230ffc1146e2317e2068fefd7caacb
Parent:     f8f6296adad30cadd65555dfde489d1080b2001c
Author:     Andy Walls <awalls@radix.net>
AuthorDate: Fri Jul 25 15:03:08 2008 -0300
Committer:  Mauro Carvalho Chehab <mchehab@infradead.org>
CommitDate: Sat Jul 26 12:54:19 2008 -0300

    V4L/DVB (8462): cx18: Lock the aux PLL to the video pixle rate for analog captures
    
    cx18: Lock the aux PLL to the video pixel rate for analog captures.  The
    datasheet for the CX25840 says this is important for MPEG encoding applications.
    To ensure the PLL locking was correct, also fixed the aux PLL's multiplier to
    be computed based on a precise crystal freq of 4.5 MHz/286 * 455/2 * 8 =
    28636363.6363... instead of the imporperly rounded 28636363.
    
    Signed-off-by: Andy Walls <awalls@radix.net>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---
 drivers/media/video/cx18/cx18-av-audio.c |   80 ++++++++++++++++++++++++++----
 1 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/drivers/media/video/cx18/cx18-av-audio.c b/drivers/media/video/cx18/cx18-av-audio.c
index 7245d37..0b55837 100644
--- a/drivers/media/video/cx18/cx18-av-audio.c
+++ b/drivers/media/video/cx18/cx18-av-audio.c
@@ -51,6 +51,16 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
 
 			/* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
 			cx18_av_write(cx, 0x127, 0x54);
+
+			/* AUD_COUNT = 0x2fff = 8 samples * 4 * 384 - 1 */
+			cx18_av_write4(cx, 0x12c, 0x11202fff);
+
+			/*
+			 * EN_AV_LOCK = 1
+			 * VID_COUNT = 0x0d2ef8 = 107999.000 * 8 =
+			 *  ((8 samples/32,000) * (13,500,000 * 8) * 4 - 1) * 8
+			 */
+			cx18_av_write4(cx, 0x128, 0xa10d2ef8);
 			break;
 
 		case 44100:
@@ -58,14 +68,24 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
 			cx18_av_write4(cx, 0x108, 0x1009040f);
 
 			/* AUX_PLL_FRAC ...