aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2008-07-25 14:03:08 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-26 11:54:19 -0400
commit35f92b2af8230ffc1146e2317e2068fefd7caacb (patch)
treea93b3228c65d4f1f9af49716c2ac178d1836b4c9 /drivers
parentf8f6296adad30cadd65555dfde489d1080b2001c (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/cx18/cx18-av-audio.c80
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 7245d37ef34f..0b55837880a7 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)
51 51
52 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */ 52 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
53 cx18_av_write(cx, 0x127, 0x54); 53 cx18_av_write(cx, 0x127, 0x54);
54
55 /* AUD_COUNT = 0x2fff = 8 samples * 4 * 384 - 1 */
56 cx18_av_write4(cx, 0x12c, 0x11202fff);
57
58 /*
59 * EN_AV_LOCK = 1
60 * VID_COUNT = 0x0d2ef8 = 107999.000 * 8 =
61 * ((8 samples/32,000) * (13,500,000 * 8) * 4 - 1) * 8
62 */
63 cx18_av_write4(cx, 0x128, 0xa10d2ef8);
54 break; 64 break;
55 65
56 case 44100: 66 case 44100:
@@ -58,14 +68,24 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
58 cx18_av_write4(cx, 0x108, 0x1009040f); 68 cx18_av_write4(cx, 0x108, 0x1009040f);
59 69
60 /* AUX_PLL_FRAC */ 70 /* AUX_PLL_FRAC */
61 /* 0x9.7635eb * 28,636,363 / 0x10 = 44100 * 384 */ 71 /* 0x9.7635e7 * 28,636,363.63 / 0x10 = 44100 * 384 */
62 cx18_av_write4(cx, 0x110, 0x00ec6bd6); 72 cx18_av_write4(cx, 0x110, 0x00ec6bce);
63 73
64 /* src3/4/6_ctl */ 74 /* src3/4/6_ctl */
65 /* 0x1.6d59 = (4 * 15734.26) / 44100 */ 75 /* 0x1.6d59 = (4 * 15734.26) / 44100 */
66 cx18_av_write4(cx, 0x900, 0x08016d59); 76 cx18_av_write4(cx, 0x900, 0x08016d59);
67 cx18_av_write4(cx, 0x904, 0x08016d59); 77 cx18_av_write4(cx, 0x904, 0x08016d59);
68 cx18_av_write4(cx, 0x90c, 0x08016d59); 78 cx18_av_write4(cx, 0x90c, 0x08016d59);
79
80 /* AUD_COUNT = 0x92ff = 49 samples * 2 * 384 - 1 */
81 cx18_av_write4(cx, 0x12c, 0x112092ff);
82
83 /*
84 * EN_AV_LOCK = 1
85 * VID_COUNT = 0x1d4bf8 = 239999.000 * 8 =
86 * ((49 samples/44,100) * (13,500,000 * 8) * 2 - 1) * 8
87 */
88 cx18_av_write4(cx, 0x128, 0xa11d4bf8);
69 break; 89 break;
70 90
71 case 48000: 91 case 48000:
@@ -73,14 +93,24 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
73 cx18_av_write4(cx, 0x108, 0x100a040f); 93 cx18_av_write4(cx, 0x108, 0x100a040f);
74 94
75 /* AUX_PLL_FRAC */ 95 /* AUX_PLL_FRAC */
76 /* 0xa.4c6b728 * 28,636,363 / 0x10 = 48000 * 384 */ 96 /* 0xa.4c6b6ea * 28,636,363.63 / 0x10 = 48000 * 384 */
77 cx18_av_write4(cx, 0x110, 0x0098d6e5); 97 cx18_av_write4(cx, 0x110, 0x0098d6dd);
78 98
79 /* src3/4/6_ctl */ 99 /* src3/4/6_ctl */
80 /* 0x1.4faa = (4 * 15734.26) / 48000 */ 100 /* 0x1.4faa = (4 * 15734.26) / 48000 */
81 cx18_av_write4(cx, 0x900, 0x08014faa); 101 cx18_av_write4(cx, 0x900, 0x08014faa);
82 cx18_av_write4(cx, 0x904, 0x08014faa); 102 cx18_av_write4(cx, 0x904, 0x08014faa);
83 cx18_av_write4(cx, 0x90c, 0x08014faa); 103 cx18_av_write4(cx, 0x90c, 0x08014faa);
104
105 /* AUD_COUNT = 0x5fff = 4 samples * 16 * 384 - 1 */
106 cx18_av_write4(cx, 0x12c, 0x11205fff);
107
108 /*
109 * EN_AV_LOCK = 1
110 * VID_COUNT = 0x1193f8 = 143999.000 * 8 =
111 * ((4 samples/48,000) * (13,500,000 * 8) * 16 - 1) * 8
112 */
113 cx18_av_write4(cx, 0x128, 0xa11193f8);
84 break; 114 break;
85 } 115 }
86 } else { 116 } else {
@@ -90,8 +120,8 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
90 cx18_av_write4(cx, 0x108, 0x1e08040f); 120 cx18_av_write4(cx, 0x108, 0x1e08040f);
91 121
92 /* AUX_PLL_FRAC */ 122 /* AUX_PLL_FRAC */
93 /* 0x8.9504348 * 28,636,363 / 0x1e = 32000 * 256 */ 123 /* 0x8.9504318 * 28,636,363.63 / 0x1e = 32000 * 256 */
94 cx18_av_write4(cx, 0x110, 0x012a0869); 124 cx18_av_write4(cx, 0x110, 0x012a0863);
95 125
96 /* src1_ctl */ 126 /* src1_ctl */
97 /* 0x1.0000 = 32000/32000 */ 127 /* 0x1.0000 = 32000/32000 */
@@ -105,6 +135,16 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
105 135
106 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */ 136 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
107 cx18_av_write(cx, 0x127, 0x54); 137 cx18_av_write(cx, 0x127, 0x54);
138
139 /* AUD_COUNT = 0x1fff = 8 samples * 4 * 256 - 1 */
140 cx18_av_write4(cx, 0x12c, 0x11201fff);
141
142 /*
143 * EN_AV_LOCK = 1
144 * VID_COUNT = 0x0d2ef8 = 107999.000 * 8 =
145 * ((8 samples/32,000) * (13,500,000 * 8) * 4 - 1) * 8
146 */
147 cx18_av_write4(cx, 0x128, 0xa10d2ef8);
108 break; 148 break;
109 149
110 case 44100: 150 case 44100:
@@ -112,8 +152,8 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
112 cx18_av_write4(cx, 0x108, 0x1809040f); 152 cx18_av_write4(cx, 0x108, 0x1809040f);
113 153
114 /* AUX_PLL_FRAC */ 154 /* AUX_PLL_FRAC */
115 /* 0x9.76346B * 28,636,363 / 0x18 = 44100 * 256 */ 155 /* 0x9.7635e74 * 28,636,363.63 / 0x18 = 44100 * 256 */
116 cx18_av_write4(cx, 0x110, 0x00ec6bd6); 156 cx18_av_write4(cx, 0x110, 0x00ec6bce);
117 157
118 /* src1_ctl */ 158 /* src1_ctl */
119 /* 0x1.60cd = 44100/32000 */ 159 /* 0x1.60cd = 44100/32000 */
@@ -124,6 +164,16 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
124 cx18_av_write4(cx, 0x900, 0x08017385); 164 cx18_av_write4(cx, 0x900, 0x08017385);
125 cx18_av_write4(cx, 0x904, 0x08017385); 165 cx18_av_write4(cx, 0x904, 0x08017385);
126 cx18_av_write4(cx, 0x90c, 0x08017385); 166 cx18_av_write4(cx, 0x90c, 0x08017385);
167
168 /* AUD_COUNT = 0x61ff = 49 samples * 2 * 256 - 1 */
169 cx18_av_write4(cx, 0x12c, 0x112061ff);
170
171 /*
172 * EN_AV_LOCK = 1
173 * VID_COUNT = 0x1d4bf8 = 239999.000 * 8 =
174 * ((49 samples/44,100) * (13,500,000 * 8) * 2 - 1) * 8
175 */
176 cx18_av_write4(cx, 0x128, 0xa11d4bf8);
127 break; 177 break;
128 178
129 case 48000: 179 case 48000:
@@ -131,8 +181,8 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
131 cx18_av_write4(cx, 0x108, 0x180a040f); 181 cx18_av_write4(cx, 0x108, 0x180a040f);
132 182
133 /* AUX_PLL_FRAC */ 183 /* AUX_PLL_FRAC */
134 /* 0xa.4c6b728 * 28,636,363 / 0x18 = 48000 * 256 */ 184 /* 0xa.4c6b6ea * 28,636,363.63 / 0x18 = 48000 * 256 */
135 cx18_av_write4(cx, 0x110, 0x0098d6e5); 185 cx18_av_write4(cx, 0x110, 0x0098d6dd);
136 186
137 /* src1_ctl */ 187 /* src1_ctl */
138 /* 0x1.8000 = 48000/32000 */ 188 /* 0x1.8000 = 48000/32000 */
@@ -143,6 +193,16 @@ static int set_audclk_freq(struct cx18 *cx, u32 freq)
143 cx18_av_write4(cx, 0x900, 0x08015555); 193 cx18_av_write4(cx, 0x900, 0x08015555);
144 cx18_av_write4(cx, 0x904, 0x08015555); 194 cx18_av_write4(cx, 0x904, 0x08015555);
145 cx18_av_write4(cx, 0x90c, 0x08015555); 195 cx18_av_write4(cx, 0x90c, 0x08015555);
196
197 /* AUD_COUNT = 0x3fff = 4 samples * 16 * 256 - 1 */
198 cx18_av_write4(cx, 0x12c, 0x11203fff);
199
200 /*
201 * EN_AV_LOCK = 1
202 * VID_COUNT = 0x1193f8 = 143999.000 * 8 =
203 * ((4 samples/48,000) * (13,500,000 * 8) * 16 - 1) * 8
204 */
205 cx18_av_write4(cx, 0x128, 0xa11193f8);
146 break; 206 break;
147 } 207 }
148 } 208 }