aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/cx18/cx18-av-core.c143
-rw-r--r--drivers/media/video/cx18/cx18-av-core.h2
-rw-r--r--drivers/media/video/cx18/cx18-av-vbi.c147
3 files changed, 147 insertions, 145 deletions
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c
index 12401425356..3b0a2c45060 100644
--- a/drivers/media/video/cx18/cx18-av-core.c
+++ b/drivers/media/video/cx18/cx18-av-core.c
@@ -166,6 +166,147 @@ static void cx18_av_initialize(struct cx18 *cx)
166 166
167/* ----------------------------------------------------------------------- */ 167/* ----------------------------------------------------------------------- */
168 168
169void cx18_av_std_setup(struct cx18 *cx)
170{
171 struct cx18_av_state *state = &cx->av_state;
172 v4l2_std_id std = state->std;
173 int hblank, hactive, burst, vblank, vactive, sc;
174 int vblank656, src_decimation;
175 int luma_lpf, uv_lpf, comb;
176 u32 pll_int, pll_frac, pll_post;
177
178 /* datasheet startup, step 8d */
179 if (std & ~V4L2_STD_NTSC)
180 cx18_av_write(cx, 0x49f, 0x11);
181 else
182 cx18_av_write(cx, 0x49f, 0x14);
183
184 if (std & V4L2_STD_625_50) {
185 hblank = 132;
186 hactive = 720;
187 burst = 93;
188 vblank = 36;
189 vactive = 580;
190 vblank656 = 40;
191 src_decimation = 0x21f;
192
193 luma_lpf = 2;
194 if (std & V4L2_STD_PAL) {
195 uv_lpf = 1;
196 comb = 0x20;
197 sc = 688739;
198 } else if (std == V4L2_STD_PAL_Nc) {
199 uv_lpf = 1;
200 comb = 0x20;
201 sc = 556453;
202 } else { /* SECAM */
203 uv_lpf = 0;
204 comb = 0;
205 sc = 672351;
206 }
207 } else {
208 hactive = 720;
209 hblank = 122;
210 vactive = 487;
211 luma_lpf = 1;
212 uv_lpf = 1;
213 vblank = 26;
214 vblank656 = 26;
215
216 src_decimation = 0x21f;
217 if (std == V4L2_STD_PAL_60) {
218 burst = 0x5b;
219 luma_lpf = 2;
220 comb = 0x20;
221 sc = 688739;
222 } else if (std == V4L2_STD_PAL_M) {
223 burst = 0x61;
224 comb = 0x20;
225 sc = 555452;
226 } else {
227 burst = 0x5b;
228 comb = 0x66;
229 sc = 556063;
230 }
231 }
232
233 /* DEBUG: Displays configured PLL frequency */
234 pll_int = cx18_av_read(cx, 0x108);
235 pll_frac = cx18_av_read4(cx, 0x10c) & 0x1ffffff;
236 pll_post = cx18_av_read(cx, 0x109);
237 CX18_DEBUG_INFO("PLL regs = int: %u, frac: %u, post: %u\n",
238 pll_int, pll_frac, pll_post);
239
240 if (pll_post) {
241 int fin, fsc;
242 int pll = 28636363L * ((((u64)pll_int) << 25) + pll_frac);
243
244 pll >>= 25;
245 pll /= pll_post;
246 CX18_DEBUG_INFO("PLL = %d.%06d MHz\n",
247 pll / 1000000, pll % 1000000);
248 CX18_DEBUG_INFO("PLL/8 = %d.%06d MHz\n",
249 pll / 8000000, (pll / 8) % 1000000);
250
251 fin = ((u64)src_decimation * pll) >> 12;
252 CX18_DEBUG_INFO("ADC Sampling freq = %d.%06d MHz\n",
253 fin / 1000000, fin % 1000000);
254
255 fsc = (((u64)sc) * pll) >> 24L;
256 CX18_DEBUG_INFO("Chroma sub-carrier freq = %d.%06d MHz\n",
257 fsc / 1000000, fsc % 1000000);
258
259 CX18_DEBUG_INFO("hblank %i, hactive %i, "
260 "vblank %i , vactive %i, vblank656 %i, src_dec %i,"
261 "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x,"
262 " sc 0x%06x\n",
263 hblank, hactive, vblank, vactive, vblank656,
264 src_decimation, burst, luma_lpf, uv_lpf, comb, sc);
265 }
266
267 /* Sets horizontal blanking delay and active lines */
268 cx18_av_write(cx, 0x470, hblank);
269 cx18_av_write(cx, 0x471, 0xff & (((hblank >> 8) & 0x3) |
270 (hactive << 4)));
271 cx18_av_write(cx, 0x472, hactive >> 4);
272
273 /* Sets burst gate delay */
274 cx18_av_write(cx, 0x473, burst);
275
276 /* Sets vertical blanking delay and active duration */
277 cx18_av_write(cx, 0x474, vblank);
278 cx18_av_write(cx, 0x475, 0xff & (((vblank >> 8) & 0x3) |
279 (vactive << 4)));
280 cx18_av_write(cx, 0x476, vactive >> 4);
281 cx18_av_write(cx, 0x477, vblank656);
282
283 /* Sets src decimation rate */
284 cx18_av_write(cx, 0x478, 0xff & src_decimation);
285 cx18_av_write(cx, 0x479, 0xff & (src_decimation >> 8));
286
287 /* Sets Luma and UV Low pass filters */
288 cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30));
289
290 /* Enables comb filters */
291 cx18_av_write(cx, 0x47b, comb);
292
293 /* Sets SC Step*/
294 cx18_av_write(cx, 0x47c, sc);
295 cx18_av_write(cx, 0x47d, 0xff & sc >> 8);
296 cx18_av_write(cx, 0x47e, 0xff & sc >> 16);
297
298 /* Sets VBI parameters */
299 if (std & V4L2_STD_625_50) {
300 cx18_av_write(cx, 0x47f, 0x01);
301 state->vbi_line_offset = 5;
302 } else {
303 cx18_av_write(cx, 0x47f, 0x00);
304 state->vbi_line_offset = 8;
305 }
306}
307
308/* ----------------------------------------------------------------------- */
309
169static void input_change(struct cx18 *cx) 310static void input_change(struct cx18 *cx)
170{ 311{
171 struct cx18_av_state *state = &cx->av_state; 312 struct cx18_av_state *state = &cx->av_state;
@@ -323,7 +464,7 @@ static int set_v4lstd(struct cx18 *cx)
323 } 464 }
324 cx18_av_and_or(cx, 0x400, ~0x2f, fmt | 0x20); 465 cx18_av_and_or(cx, 0x400, ~0x2f, fmt | 0x20);
325 cx18_av_and_or(cx, 0x403, ~0x3, pal_m); 466 cx18_av_and_or(cx, 0x403, ~0x3, pal_m);
326 cx18_av_vbi_setup(cx); 467 cx18_av_std_setup(cx);
327 input_change(cx); 468 input_change(cx);
328 return 0; 469 return 0;
329} 470}
diff --git a/drivers/media/video/cx18/cx18-av-core.h b/drivers/media/video/cx18/cx18-av-core.h
index 49e31bccc55..eb61fa1e096 100644
--- a/drivers/media/video/cx18/cx18-av-core.h
+++ b/drivers/media/video/cx18/cx18-av-core.h
@@ -306,6 +306,7 @@ u32 cx18_av_read4(struct cx18 *cx, u16 addr);
306int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value); 306int cx18_av_and_or(struct cx18 *cx, u16 addr, unsigned mask, u8 value);
307int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value); 307int cx18_av_and_or4(struct cx18 *cx, u16 addr, u32 mask, u32 value);
308int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg); 308int cx18_av_cmd(struct cx18 *cx, unsigned int cmd, void *arg);
309void cx18_av_std_setup(struct cx18 *cx);
309 310
310/* ----------------------------------------------------------------------- */ 311/* ----------------------------------------------------------------------- */
311/* cx18_av-firmware.c */ 312/* cx18_av-firmware.c */
@@ -318,7 +319,6 @@ void cx18_av_audio_set_path(struct cx18 *cx);
318 319
319/* ----------------------------------------------------------------------- */ 320/* ----------------------------------------------------------------------- */
320/* cx18_av-vbi.c */ 321/* cx18_av-vbi.c */
321void cx18_av_vbi_setup(struct cx18 *cx);
322int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg); 322int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg);
323 323
324#endif 324#endif
diff --git a/drivers/media/video/cx18/cx18-av-vbi.c b/drivers/media/video/cx18/cx18-av-vbi.c
index 0c92f123686..02fdf57bb67 100644
--- a/drivers/media/video/cx18/cx18-av-vbi.c
+++ b/drivers/media/video/cx18/cx18-av-vbi.c
@@ -83,145 +83,6 @@ static int decode_vps(u8 *dst, u8 *p)
83 return err & 0xf0; 83 return err & 0xf0;
84} 84}
85 85
86void cx18_av_vbi_setup(struct cx18 *cx)
87{
88 struct cx18_av_state *state = &cx->av_state;
89 v4l2_std_id std = state->std;
90 int hblank, hactive, burst, vblank, vactive, sc;
91 int vblank656, src_decimation;
92 int luma_lpf, uv_lpf, comb;
93 u32 pll_int, pll_frac, pll_post;
94
95 /* datasheet startup, step 8d */
96 if (std & ~V4L2_STD_NTSC)
97 cx18_av_write(cx, 0x49f, 0x11);
98 else
99 cx18_av_write(cx, 0x49f, 0x14);
100
101 if (std & V4L2_STD_625_50) {
102 hblank = 0x084;
103 hactive = 0x2d0;
104 burst = 0x5d;
105 vblank = 0x024;
106 vactive = 0x244;
107 vblank656 = 0x28;
108 src_decimation = 0x21f;
109
110 luma_lpf = 2;
111 if (std & V4L2_STD_PAL) {
112 uv_lpf = 1;
113 comb = 0x20;
114 sc = 0x0a8263;
115 } else if (std == V4L2_STD_PAL_Nc) {
116 uv_lpf = 1;
117 comb = 0x20;
118 sc = 0x087da5;
119 } else { /* SECAM */
120 uv_lpf = 0;
121 comb = 0;
122 sc = 0x0a425f;
123 }
124 } else {
125 hactive = 720;
126 hblank = 122;
127 vactive = 487;
128 luma_lpf = 1;
129 uv_lpf = 1;
130 vblank = 26;
131 vblank656 = 26;
132
133 src_decimation = 0x21f;
134 if (std == V4L2_STD_PAL_60) {
135 burst = 0x5b;
136 luma_lpf = 2;
137 comb = 0x20;
138 sc = 0x0a8263;
139 } else if (std == V4L2_STD_PAL_M) {
140 burst = 0x61;
141 comb = 0x20;
142 sc = 555452;
143 } else {
144 burst = 0x5b;
145 comb = 0x66;
146 sc = 556063;
147 }
148 }
149
150 /* DEBUG: Displays configured PLL frequency */
151 pll_int = cx18_av_read(cx, 0x108);
152 pll_frac = cx18_av_read4(cx, 0x10c) & 0x1ffffff;
153 pll_post = cx18_av_read(cx, 0x109);
154 CX18_DEBUG_INFO("PLL regs = int: %u, frac: %u, post: %u\n",
155 pll_int, pll_frac, pll_post);
156
157 if (pll_post) {
158 int fin, fsc;
159 int pll = 28636363L * ((((u64)pll_int) << 25) + pll_frac);
160
161 pll >>= 25;
162 pll /= pll_post;
163 CX18_DEBUG_INFO("PLL = %d.%06d MHz\n",
164 pll / 1000000, pll % 1000000);
165 CX18_DEBUG_INFO("PLL/8 = %d.%06d MHz\n",
166 pll / 8000000, (pll / 8) % 1000000);
167
168 fin = ((u64)src_decimation * pll) >> 12;
169 CX18_DEBUG_INFO("ADC Sampling freq = %d.%06d MHz\n",
170 fin / 1000000, fin % 1000000);
171
172 fsc = (((u64)sc) * pll) >> 24L;
173 CX18_DEBUG_INFO("Chroma sub-carrier freq = %d.%06d MHz\n",
174 fsc / 1000000, fsc % 1000000);
175
176 CX18_DEBUG_INFO("hblank %i, hactive %i, "
177 "vblank %i , vactive %i, vblank656 %i, src_dec %i,"
178 "burst 0x%02x, luma_lpf %i, uv_lpf %i, comb 0x%02x,"
179 " sc 0x%06x\n",
180 hblank, hactive, vblank, vactive, vblank656,
181 src_decimation, burst, luma_lpf, uv_lpf, comb, sc);
182 }
183
184 /* Sets horizontal blanking delay and active lines */
185 cx18_av_write(cx, 0x470, hblank);
186 cx18_av_write(cx, 0x471, 0xff & (((hblank >> 8) & 0x3) |
187 (hactive << 4)));
188 cx18_av_write(cx, 0x472, hactive >> 4);
189
190 /* Sets burst gate delay */
191 cx18_av_write(cx, 0x473, burst);
192
193 /* Sets vertical blanking delay and active duration */
194 cx18_av_write(cx, 0x474, vblank);
195 cx18_av_write(cx, 0x475, 0xff & (((vblank >> 8) & 0x3) |
196 (vactive << 4)));
197 cx18_av_write(cx, 0x476, vactive >> 4);
198 cx18_av_write(cx, 0x477, vblank656);
199
200 /* Sets src decimation rate */
201 cx18_av_write(cx, 0x478, 0xff & src_decimation);
202 cx18_av_write(cx, 0x479, 0xff & (src_decimation >> 8));
203
204 /* Sets Luma and UV Low pass filters */
205 cx18_av_write(cx, 0x47a, luma_lpf << 6 | ((uv_lpf << 4) & 0x30));
206
207 /* Enables comb filters */
208 cx18_av_write(cx, 0x47b, comb);
209
210 /* Sets SC Step*/
211 cx18_av_write(cx, 0x47c, sc);
212 cx18_av_write(cx, 0x47d, 0xff & sc >> 8);
213 cx18_av_write(cx, 0x47e, 0xff & sc >> 16);
214
215 /* Sets VBI parameters */
216 if (std & V4L2_STD_625_50) {
217 cx18_av_write(cx, 0x47f, 0x01);
218 state->vbi_line_offset = 5;
219 } else {
220 cx18_av_write(cx, 0x47f, 0x00);
221 state->vbi_line_offset = 8;
222 }
223}
224
225int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg) 86int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
226{ 87{
227 struct cx18_av_state *state = &cx->av_state; 88 struct cx18_av_state *state = &cx->av_state;
@@ -287,8 +148,8 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
287 /* raw VBI */ 148 /* raw VBI */
288 memset(svbi, 0, sizeof(*svbi)); 149 memset(svbi, 0, sizeof(*svbi));
289 150
290 /* Setup VBI */ 151 /* Setup standard */
291 cx18_av_vbi_setup(cx); 152 cx18_av_std_setup(cx);
292 153
293 /* VBI Offset */ 154 /* VBI Offset */
294 cx18_av_write(cx, 0x47f, vbi_offset); 155 cx18_av_write(cx, 0x47f, vbi_offset);
@@ -299,8 +160,8 @@ int cx18_av_vbi(struct cx18 *cx, unsigned int cmd, void *arg)
299 for (x = 0; x <= 23; x++) 160 for (x = 0; x <= 23; x++)
300 lcr[x] = 0x00; 161 lcr[x] = 0x00;
301 162
302 /* Setup VBI */ 163 /* Setup standard */
303 cx18_av_vbi_setup(cx); 164 cx18_av_std_setup(cx);
304 165
305 /* Sliced VBI */ 166 /* Sliced VBI */
306 cx18_av_write(cx, 0x404, 0x32); /* Ancillary data */ 167 cx18_av_write(cx, 0x404, 0x32); /* Ancillary data */