Add support for interlaced video modes.diff -r1.5 -r1.6 src/sys/arch/arm/allwinner/awin_debe.c
(jmcneill)
--- src/sys/arch/arm/allwinner/Attic/awin_debe.c 2014/11/12 23:12:27 1.5
+++ src/sys/arch/arm/allwinner/Attic/awin_debe.c 2014/11/14 00:31:54 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: awin_debe.c,v 1.5 2014/11/12 23:12:27 jmcneill Exp $ */ | 1 | /* $NetBSD: awin_debe.c,v 1.6 2014/11/14 00:31:54 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include "opt_allwinner.h" | 29 | #include "opt_allwinner.h" | |
30 | #include "genfb.h" | 30 | #include "genfb.h" | |
31 | 31 | |||
32 | #ifndef AWIN_DEBE_VIDEOMEM | 32 | #ifndef AWIN_DEBE_VIDEOMEM | |
33 | #define AWIN_DEBE_VIDEOMEM (16 * 1024 * 1024) | 33 | #define AWIN_DEBE_VIDEOMEM (16 * 1024 * 1024) | |
34 | #endif | 34 | #endif | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.5 2014/11/12 23:12:27 jmcneill Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.6 2014/11/14 00:31:54 jmcneill Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/bus.h> | 40 | #include <sys/bus.h> | |
41 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
42 | #include <sys/intr.h> | 42 | #include <sys/intr.h> | |
43 | #include <sys/systm.h> | 43 | #include <sys/systm.h> | |
44 | #include <sys/kernel.h> | 44 | #include <sys/kernel.h> | |
45 | #include <sys/mutex.h> | 45 | #include <sys/mutex.h> | |
46 | #include <sys/condvar.h> | 46 | #include <sys/condvar.h> | |
47 | 47 | |||
48 | #include <arm/allwinner/awin_reg.h> | 48 | #include <arm/allwinner/awin_reg.h> | |
49 | #include <arm/allwinner/awin_var.h> | 49 | #include <arm/allwinner/awin_var.h> | |
50 | 50 | |||
@@ -211,30 +211,31 @@ unmap: | @@ -211,30 +211,31 @@ unmap: | |||
211 | free: | 211 | free: | |
212 | bus_dmamem_free(sc->sc_dmat, sc->sc_dmasegs, nsegs); | 212 | bus_dmamem_free(sc->sc_dmat, sc->sc_dmasegs, nsegs); | |
213 | 213 | |||
214 | sc->sc_dmasize = 0; | 214 | sc->sc_dmasize = 0; | |
215 | sc->sc_dmap = NULL; | 215 | sc->sc_dmap = NULL; | |
216 | 216 | |||
217 | return error; | 217 | return error; | |
218 | } | 218 | } | |
219 | 219 | |||
220 | static void | 220 | static void | |
221 | awin_debe_setup_fbdev(struct awin_debe_softc *sc, const struct videomode *mode) | 221 | awin_debe_setup_fbdev(struct awin_debe_softc *sc, const struct videomode *mode) | |
222 | { | 222 | { | |
223 | if (mode && sc->sc_fbdev == NULL) { | 223 | if (mode && sc->sc_fbdev == NULL) { | |
224 | const u_int interlace_p = !!(mode->flags & VID_INTERLACE); | |||
224 | struct awinfb_attach_args afb = { | 225 | struct awinfb_attach_args afb = { | |
225 | .afb_fb = sc->sc_dmap, | 226 | .afb_fb = sc->sc_dmap, | |
226 | .afb_width = mode->hdisplay, | 227 | .afb_width = mode->hdisplay, | |
227 | .afb_height = mode->vdisplay, | 228 | .afb_height = (mode->vdisplay << interlace_p), | |
228 | .afb_dmat = sc->sc_dmat, | 229 | .afb_dmat = sc->sc_dmat, | |
229 | .afb_dmasegs = sc->sc_dmasegs, | 230 | .afb_dmasegs = sc->sc_dmasegs, | |
230 | .afb_ndmasegs = 1 | 231 | .afb_ndmasegs = 1 | |
231 | }; | 232 | }; | |
232 | sc->sc_fbdev = config_found_ia(sc->sc_dev, "awindebe", | 233 | sc->sc_fbdev = config_found_ia(sc->sc_dev, "awindebe", | |
233 | &afb, NULL); | 234 | &afb, NULL); | |
234 | } | 235 | } | |
235 | #if NGENFB > 0 | 236 | #if NGENFB > 0 | |
236 | else if (sc->sc_fbdev != NULL) { | 237 | else if (sc->sc_fbdev != NULL) { | |
237 | awin_fb_set_videomode(sc->sc_fbdev, mode); | 238 | awin_fb_set_videomode(sc->sc_fbdev, mode); | |
238 | } | 239 | } | |
239 | #endif | 240 | #endif | |
240 | } | 241 | } | |
@@ -273,64 +274,71 @@ awin_debe_set_videomode(const struct vid | @@ -273,64 +274,71 @@ awin_debe_set_videomode(const struct vid | |||
273 | { | 274 | { | |
274 | struct awin_debe_softc *sc; | 275 | struct awin_debe_softc *sc; | |
275 | device_t dev; | 276 | device_t dev; | |
276 | uint32_t val; | 277 | uint32_t val; | |
277 | 278 | |||
278 | dev = device_find_by_driver_unit("awindebe", 0); | 279 | dev = device_find_by_driver_unit("awindebe", 0); | |
279 | if (dev == NULL) { | 280 | if (dev == NULL) { | |
280 | printf("DEBE: no driver found\n"); | 281 | printf("DEBE: no driver found\n"); | |
281 | return; | 282 | return; | |
282 | } | 283 | } | |
283 | sc = device_private(dev); | 284 | sc = device_private(dev); | |
284 | 285 | |||
285 | if (mode) { | 286 | if (mode) { | |
286 | uint32_t vmem = mode->vdisplay * mode->hdisplay * 4; | 287 | const u_int interlace_p = !!(mode->flags & VID_INTERLACE); | |
288 | const u_int width = mode->hdisplay; | |||
289 | const u_int height = (mode->vdisplay << interlace_p); | |||
290 | uint32_t vmem = width * height * 4; | |||
287 | 291 | |||
288 | if (vmem > sc->sc_dmasize) { | 292 | if (vmem > sc->sc_dmasize) { | |
289 | device_printf(sc->sc_dev, | 293 | device_printf(sc->sc_dev, | |
290 | "not enough memory for %ux%u fb (req %u have %u)\n", | 294 | "not enough memory for %ux%u fb (req %u have %u)\n", | |
291 | mode->hdisplay, mode->vdisplay, | 295 | width, height, vmem, (unsigned int)sc->sc_dmasize); | |
292 | vmem, (unsigned int)sc->sc_dmasize); | |||
293 | return; | 296 | return; | |
294 | } | 297 | } | |
295 | 298 | |||
296 | paddr_t pa = sc->sc_dmamap->dm_segs[0].ds_addr; | 299 | paddr_t pa = sc->sc_dmamap->dm_segs[0].ds_addr; | |
297 | /* | 300 | /* | |
298 | * On 2GB systems, we need to subtract AWIN_SDRAM_PBASE from | 301 | * On 2GB systems, we need to subtract AWIN_SDRAM_PBASE from | |
299 | * the phys addr. | 302 | * the phys addr. | |
300 | */ | 303 | */ | |
301 | if (pa >= AWIN_SDRAM_PBASE) | 304 | if (pa >= AWIN_SDRAM_PBASE) | |
302 | pa -= AWIN_SDRAM_PBASE; | 305 | pa -= AWIN_SDRAM_PBASE; | |
303 | 306 | |||
304 | /* notify fb */ | 307 | /* notify fb */ | |
305 | awin_debe_setup_fbdev(sc, mode); | 308 | awin_debe_setup_fbdev(sc, mode); | |
306 | 309 | |||
307 | DEBE_WRITE(sc, AWIN_DEBE_DISSIZE_REG, | 310 | DEBE_WRITE(sc, AWIN_DEBE_DISSIZE_REG, | |
308 | ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1)); | 311 | ((height - 1) << 16) | (width - 1)); | |
309 | DEBE_WRITE(sc, AWIN_DEBE_LAYSIZE_REG, | 312 | DEBE_WRITE(sc, AWIN_DEBE_LAYSIZE_REG, | |
310 | ((mode->vdisplay - 1) << 16) | (mode->hdisplay - 1)); | 313 | ((height - 1) << 16) | (width - 1)); | |
311 | DEBE_WRITE(sc, AWIN_DEBE_LAYLINEWIDTH_REG, mode->hdisplay << 5); | 314 | DEBE_WRITE(sc, AWIN_DEBE_LAYLINEWIDTH_REG, (width << 5)); | |
312 | DEBE_WRITE(sc, AWIN_DEBE_LAYFB_L32ADD_REG, pa << 3); | 315 | DEBE_WRITE(sc, AWIN_DEBE_LAYFB_L32ADD_REG, pa << 3); | |
313 | DEBE_WRITE(sc, AWIN_DEBE_LAYFB_H4ADD_REG, pa >> 29); | 316 | DEBE_WRITE(sc, AWIN_DEBE_LAYFB_H4ADD_REG, pa >> 29); | |
314 | 317 | |||
315 | val = DEBE_READ(sc, AWIN_DEBE_ATTCTL1_REG); | 318 | val = DEBE_READ(sc, AWIN_DEBE_ATTCTL1_REG); | |
316 | val &= ~AWIN_DEBE_ATTCTL1_LAY_FBFMT; | 319 | val &= ~AWIN_DEBE_ATTCTL1_LAY_FBFMT; | |
317 | val |= __SHIFTIN(AWIN_DEBE_ATTCTL1_LAY_FBFMT_XRGB8888, | 320 | val |= __SHIFTIN(AWIN_DEBE_ATTCTL1_LAY_FBFMT_XRGB8888, | |
318 | AWIN_DEBE_ATTCTL1_LAY_FBFMT); | 321 | AWIN_DEBE_ATTCTL1_LAY_FBFMT); | |
319 | val &= ~AWIN_DEBE_ATTCTL1_LAY_BRSWAPEN; | 322 | val &= ~AWIN_DEBE_ATTCTL1_LAY_BRSWAPEN; | |
320 | val &= ~AWIN_DEBE_ATTCTL1_LAY_FBPS; | 323 | val &= ~AWIN_DEBE_ATTCTL1_LAY_FBPS; | |
321 | DEBE_WRITE(sc, AWIN_DEBE_ATTCTL1_REG, val); | 324 | DEBE_WRITE(sc, AWIN_DEBE_ATTCTL1_REG, val); | |
322 | 325 | |||
323 | val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG); | 326 | val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG); | |
324 | val |= AWIN_DEBE_MODCTL_LAY0_EN; | 327 | val |= AWIN_DEBE_MODCTL_LAY0_EN; | |
328 | if (interlace_p) { | |||
329 | val |= AWIN_DEBE_MODCTL_ITLMOD_EN; | |||
330 | } else { | |||
331 | val &= ~AWIN_DEBE_MODCTL_ITLMOD_EN; | |||
332 | } | |||
325 | DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val); | 333 | DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val); | |
326 | } else { | 334 | } else { | |
327 | /* disable */ | 335 | /* disable */ | |
328 | val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG); | 336 | val = DEBE_READ(sc, AWIN_DEBE_MODCTL_REG); | |
329 | val &= ~AWIN_DEBE_MODCTL_LAY0_EN; | 337 | val &= ~AWIN_DEBE_MODCTL_LAY0_EN; | |
330 | val &= ~AWIN_DEBE_MODCTL_START_CTL; | 338 | val &= ~AWIN_DEBE_MODCTL_START_CTL; | |
331 | DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val); | 339 | DEBE_WRITE(sc, AWIN_DEBE_MODCTL_REG, val); | |
332 | 340 | |||
333 | /* notify fb */ | 341 | /* notify fb */ | |
334 | awin_debe_setup_fbdev(sc, mode); | 342 | awin_debe_setup_fbdev(sc, mode); | |
335 | } | 343 | } | |
336 | } | 344 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_fb.c 2014/11/10 17:55:25 1.3
+++ src/sys/arch/arm/allwinner/Attic/awin_fb.c 2014/11/14 00:31:54 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: awin_fb.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $ */ | 1 | /* $NetBSD: awin_fb.c,v 1.4 2014/11/14 00:31:54 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -17,27 +17,27 @@ | @@ -17,27 +17,27 @@ | |||
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include <sys/cdefs.h> | 29 | #include <sys/cdefs.h> | |
30 | __KERNEL_RCSID(0, "$NetBSD: awin_fb.c,v 1.3 2014/11/10 17:55:25 jmcneill Exp $"); | 30 | __KERNEL_RCSID(0, "$NetBSD: awin_fb.c,v 1.4 2014/11/14 00:31:54 jmcneill Exp $"); | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/bus.h> | 33 | #include <sys/bus.h> | |
34 | #include <sys/device.h> | 34 | #include <sys/device.h> | |
35 | #include <sys/intr.h> | 35 | #include <sys/intr.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/kernel.h> | 37 | #include <sys/kernel.h> | |
38 | #include <sys/mutex.h> | 38 | #include <sys/mutex.h> | |
39 | #include <sys/condvar.h> | 39 | #include <sys/condvar.h> | |
40 | 40 | |||
41 | #include <arm/allwinner/awin_reg.h> | 41 | #include <arm/allwinner/awin_reg.h> | |
42 | #include <arm/allwinner/awin_var.h> | 42 | #include <arm/allwinner/awin_var.h> | |
43 | 43 | |||
@@ -179,19 +179,22 @@ awin_fb_ddb_trap_callback(int where) | @@ -179,19 +179,22 @@ awin_fb_ddb_trap_callback(int where) | |||
179 | } else { | 179 | } else { | |
180 | genfb_disable_polling(awin_fb_consoledev); | 180 | genfb_disable_polling(awin_fb_consoledev); | |
181 | } | 181 | } | |
182 | } | 182 | } | |
183 | 183 | |||
184 | void | 184 | void | |
185 | awin_fb_set_videomode(device_t dev, const struct videomode *mode) | 185 | awin_fb_set_videomode(device_t dev, const struct videomode *mode) | |
186 | { | 186 | { | |
187 | struct awin_fb_softc *sc = device_private(dev); | 187 | struct awin_fb_softc *sc = device_private(dev); | |
188 | 188 | |||
189 | if (mode == NULL) | 189 | if (mode == NULL) | |
190 | return; | 190 | return; | |
191 | 191 | |||
192 | if (sc->sc_gen.sc_width != mode->hdisplay || | 192 | const u_int interlace_p = !!(mode->flags & VID_INTERLACE); | |
193 | sc->sc_gen.sc_height != mode->vdisplay) { | 193 | const u_int width = mode->hdisplay; | |
194 | const u_int height = (mode->vdisplay << interlace_p); | |||
195 | ||||
196 | if (sc->sc_gen.sc_width != width || sc->sc_gen.sc_height != height) { | |||
194 | device_printf(sc->sc_gen.sc_dev, | 197 | device_printf(sc->sc_gen.sc_dev, | |
195 | "mode switching not yet supported\n"); | 198 | "mode switching not yet supported\n"); | |
196 | } | 199 | } | |
197 | } | 200 | } |
--- src/sys/arch/arm/allwinner/Attic/awin_hdmi.c 2014/11/12 17:38:14 1.10
+++ src/sys/arch/arm/allwinner/Attic/awin_hdmi.c 2014/11/14 00:31:54 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: awin_hdmi.c,v 1.10 2014/11/12 17:38:14 jmcneill Exp $ */ | 1 | /* $NetBSD: awin_hdmi.c,v 1.11 2014/11/14 00:31:54 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include "opt_allwinner.h" | 29 | #include "opt_allwinner.h" | |
30 | #include "opt_ddb.h" | 30 | #include "opt_ddb.h" | |
31 | 31 | |||
32 | #define AWIN_HDMI_PLL 3 /* PLL7 or PLL3 */ | 32 | #define AWIN_HDMI_PLL 3 /* PLL7 or PLL3 */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.10 2014/11/12 17:38:14 jmcneill Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: awin_hdmi.c,v 1.11 2014/11/14 00:31:54 jmcneill Exp $"); | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/bus.h> | 38 | #include <sys/bus.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/intr.h> | 40 | #include <sys/intr.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/kernel.h> | 42 | #include <sys/kernel.h> | |
43 | #include <sys/proc.h> | 43 | #include <sys/proc.h> | |
44 | #include <sys/mutex.h> | 44 | #include <sys/mutex.h> | |
45 | #include <sys/kthread.h> | 45 | #include <sys/kthread.h> | |
46 | 46 | |||
47 | #include <arm/allwinner/awin_reg.h> | 47 | #include <arm/allwinner/awin_reg.h> | |
48 | #include <arm/allwinner/awin_var.h> | 48 | #include <arm/allwinner/awin_var.h> | |
@@ -591,49 +591,41 @@ awin_hdmi_set_videomode(struct awin_hdmi | @@ -591,49 +591,41 @@ awin_hdmi_set_videomode(struct awin_hdmi | |||
591 | 591 | |||
592 | HDMI_WRITE(sc, AWIN_HDMI_PAD_CTRL0_REG, pad_ctrl0); | 592 | HDMI_WRITE(sc, AWIN_HDMI_PAD_CTRL0_REG, pad_ctrl0); | |
593 | HDMI_WRITE(sc, AWIN_HDMI_PAD_CTRL1_REG, pad_ctrl1); | 593 | HDMI_WRITE(sc, AWIN_HDMI_PAD_CTRL1_REG, pad_ctrl1); | |
594 | HDMI_WRITE(sc, AWIN_HDMI_PLL_CTRL_REG, pll_ctrl); | 594 | HDMI_WRITE(sc, AWIN_HDMI_PLL_CTRL_REG, pll_ctrl); | |
595 | #if AWIN_HDMI_PLL == 7 | 595 | #if AWIN_HDMI_PLL == 7 | |
596 | HDMI_WRITE(sc, AWIN_HDMI_PLL_DBG0_REG, (1<<21)); | 596 | HDMI_WRITE(sc, AWIN_HDMI_PLL_DBG0_REG, (1<<21)); | |
597 | #elif AWIN_HDMI_PLL == 3 | 597 | #elif AWIN_HDMI_PLL == 3 | |
598 | HDMI_WRITE(sc, AWIN_HDMI_PLL_DBG0_REG, (0<<21)); | 598 | HDMI_WRITE(sc, AWIN_HDMI_PLL_DBG0_REG, (0<<21)); | |
599 | #endif | 599 | #endif | |
600 | 600 | |||
601 | val = HDMI_READ(sc, AWIN_HDMI_VID_CTRL_REG); | 601 | val = HDMI_READ(sc, AWIN_HDMI_VID_CTRL_REG); | |
602 | val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_HDMI_MODE_HDMI, | 602 | val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_HDMI_MODE_HDMI, | |
603 | AWIN_HDMI_VID_CTRL_HDMI_MODE); | 603 | AWIN_HDMI_VID_CTRL_HDMI_MODE); | |
604 | val &= ~AWIN_HDMI_VID_CTRL_OUTPUT_FMT; | |||
604 | if (dblscan_p) { | 605 | if (dblscan_p) { | |
605 | val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_REPEATER_SEL_2X, | 606 | val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_REPEATER_SEL_2X, | |
606 | AWIN_HDMI_VID_CTRL_REPEATER_SEL); | 607 | AWIN_HDMI_VID_CTRL_REPEATER_SEL); | |
607 | } else { | |||
608 | val &= ~AWIN_HDMI_VID_CTRL_REPEATER_SEL; | |||
609 | } | 608 | } | |
610 | if (interlace_p) { | 609 | if (interlace_p) { | |
611 | val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_OUTPUT_FMT_INTERLACE, | 610 | val |= __SHIFTIN(AWIN_HDMI_VID_CTRL_OUTPUT_FMT_INTERLACE, | |
612 | AWIN_HDMI_VID_CTRL_OUTPUT_FMT); | 611 | AWIN_HDMI_VID_CTRL_OUTPUT_FMT); | |
613 | } else { | |||
614 | val &= ~AWIN_HDMI_VID_CTRL_OUTPUT_FMT; | |||
615 | } | 612 | } | |
616 | HDMI_WRITE(sc, AWIN_HDMI_VID_CTRL_REG, val); | 613 | HDMI_WRITE(sc, AWIN_HDMI_VID_CTRL_REG, val); | |
617 | 614 | |||
618 | val = __SHIFTIN((mode->hdisplay << dblscan_p) - 1, | 615 | val = __SHIFTIN((mode->hdisplay << dblscan_p) - 1, | |
619 | AWIN_HDMI_VID_TIMING_0_ACT_H); | 616 | AWIN_HDMI_VID_TIMING_0_ACT_H); | |
620 | if (interlace_p) { | 617 | val |= __SHIFTIN(mode->vdisplay - 1, | |
621 | val |= __SHIFTIN((mode->vdisplay / 2) - 1, | 618 | AWIN_HDMI_VID_TIMING_0_ACT_V); | |
622 | AWIN_HDMI_VID_TIMING_0_ACT_V); | |||
623 | } else { | |||
624 | val |= __SHIFTIN(mode->vdisplay - 1, | |||
625 | AWIN_HDMI_VID_TIMING_0_ACT_V); | |||
626 | } | |||
627 | HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_0_REG, val); | 619 | HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_0_REG, val); | |
628 | 620 | |||
629 | val = __SHIFTIN((hbp << dblscan_p) - 1, | 621 | val = __SHIFTIN((hbp << dblscan_p) - 1, | |
630 | AWIN_HDMI_VID_TIMING_1_HBP); | 622 | AWIN_HDMI_VID_TIMING_1_HBP); | |
631 | val |= __SHIFTIN(vbp - 1, | 623 | val |= __SHIFTIN(vbp - 1, | |
632 | AWIN_HDMI_VID_TIMING_1_VBP); | 624 | AWIN_HDMI_VID_TIMING_1_VBP); | |
633 | HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_1_REG, val); | 625 | HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_1_REG, val); | |
634 | 626 | |||
635 | val = __SHIFTIN((hfp << dblscan_p) - 1, | 627 | val = __SHIFTIN((hfp << dblscan_p) - 1, | |
636 | AWIN_HDMI_VID_TIMING_2_HFP); | 628 | AWIN_HDMI_VID_TIMING_2_HFP); | |
637 | val |= __SHIFTIN(vfp - 1, | 629 | val |= __SHIFTIN(vfp - 1, | |
638 | AWIN_HDMI_VID_TIMING_2_VFP); | 630 | AWIN_HDMI_VID_TIMING_2_VFP); | |
639 | HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_2_REG, val); | 631 | HDMI_WRITE(sc, AWIN_HDMI_VID_TIMING_2_REG, val); |
--- src/sys/arch/arm/allwinner/Attic/awin_reg.h 2014/11/11 17:00:59 1.48
+++ src/sys/arch/arm/allwinner/Attic/awin_reg.h 2014/11/14 00:31:54 1.49
@@ -1737,32 +1737,37 @@ struct awin_mmc_idma_descriptor { | @@ -1737,32 +1737,37 @@ struct awin_mmc_idma_descriptor { | |||
1737 | #define AWIN_TCON_CMAP_EVEN1_REG 0x019C | 1737 | #define AWIN_TCON_CMAP_EVEN1_REG 0x019C | |
1738 | #define AWIN_TCON_MUX_CTL_REG 0x0200 | 1738 | #define AWIN_TCON_MUX_CTL_REG 0x0200 | |
1739 | 1739 | |||
1740 | #define AWIN_TCON_GCTL_EN __BIT(31) | 1740 | #define AWIN_TCON_GCTL_EN __BIT(31) | |
1741 | #define AWIN_TCON_GCTL_GAMMA_EN __BIT(30) | 1741 | #define AWIN_TCON_GCTL_GAMMA_EN __BIT(30) | |
1742 | #define AWIN_TCON_GCTL_IO_MAP_SEL __BIT(0) | 1742 | #define AWIN_TCON_GCTL_IO_MAP_SEL __BIT(0) | |
1743 | #define AWIN_TCON_GCTL_IO_MAP_SEL_TCON0 0 | 1743 | #define AWIN_TCON_GCTL_IO_MAP_SEL_TCON0 0 | |
1744 | #define AWIN_TCON_GCTL_IO_MAP_SEL_TCON1 1 | 1744 | #define AWIN_TCON_GCTL_IO_MAP_SEL_TCON1 1 | |
1745 | 1745 | |||
1746 | #define AWIN_TCON_GINT1_TCON0_LINENO __BITS(27,16) | 1746 | #define AWIN_TCON_GINT1_TCON0_LINENO __BITS(27,16) | |
1747 | #define AWIN_TCON_GINT1_TCON1_LINENO __BITS(11,0) | 1747 | #define AWIN_TCON_GINT1_TCON1_LINENO __BITS(11,0) | |
1748 | 1748 | |||
1749 | #define AWIN_TCON_CTL_EN __BIT(31) | 1749 | #define AWIN_TCON_CTL_EN __BIT(31) | |
1750 | #define AWIN_TCON_CTL_INTERLACE_EN __BIT(20) | |||
1750 | #define AWIN_TCON_CTL_START_DELAY __BITS(8,4) | 1751 | #define AWIN_TCON_CTL_START_DELAY __BITS(8,4) | |
1751 | #define AWIN_TCON_CTL_SRC_SEL __BITS(1,0) | 1752 | #define AWIN_TCON_CTL_SRC_SEL __BITS(1,0) | |
1752 | #define AWIN_TCON_CTL_SRC_SEL_DE0 0 | 1753 | #define AWIN_TCON_CTL_SRC_SEL_DE0 0 | |
1753 | #define AWIN_TCON_CTL_SRC_SEL_DE1 1 | 1754 | #define AWIN_TCON_CTL_SRC_SEL_DE1 1 | |
1754 | #define AWIN_TCON_CTL_SRC_SEL_BLUEDATA 2 | 1755 | #define AWIN_TCON_CTL_SRC_SEL_BLUEDATA 2 | |
1755 | 1756 | |||
1757 | #define AWIN_TCON_IO_POL_IO2_INV __BIT(26) | |||
1758 | #define AWIN_TCON_IO_POL_PVSYNC __BIT(25) | |||
1759 | #define AWIN_TCON_IO_POL_PHSYNC __BIT(24) | |||
1760 | ||||
1756 | #define AWIN_TCON_IO_TRI_IO3 __BIT(27) | 1761 | #define AWIN_TCON_IO_TRI_IO3 __BIT(27) | |
1757 | #define AWIN_TCON_IO_TRI_IO2 __BIT(26) | 1762 | #define AWIN_TCON_IO_TRI_IO2 __BIT(26) | |
1758 | #define AWIN_TCON_IO_TRI_IO1 __BIT(25) | 1763 | #define AWIN_TCON_IO_TRI_IO1 __BIT(25) | |
1759 | #define AWIN_TCON_IO_TRI_IO0 __BIT(24) | 1764 | #define AWIN_TCON_IO_TRI_IO0 __BIT(24) | |
1760 | #define AWIN_TCON_IO_TRI_DATA __BITS(23,0) | 1765 | #define AWIN_TCON_IO_TRI_DATA __BITS(23,0) | |
1761 | 1766 | |||
1762 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC __BITS(9,8) | 1767 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC __BITS(9,8) | |
1763 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC_LCDC0_TCON1 0 | 1768 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC_LCDC0_TCON1 0 | |
1764 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC_LCDC1_TCON1 1 | 1769 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC_LCDC1_TCON1 1 | |
1765 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC_CLOSE 2 | 1770 | #define AWIN_TCON_MUX_CTL_HDMI_OUTPUT_SRC_CLOSE 2 | |
1766 | 1771 | |||
1767 | /* HDMI */ | 1772 | /* HDMI */ | |
1768 | #define AWIN_HDMI_VERSION_ID_REG 0x0000 | 1773 | #define AWIN_HDMI_VERSION_ID_REG 0x0000 |
--- src/sys/arch/arm/allwinner/Attic/awin_tcon.c 2014/11/11 19:22:32 1.4
+++ src/sys/arch/arm/allwinner/Attic/awin_tcon.c 2014/11/14 00:31:54 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: awin_tcon.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $ */ | 1 | /* $NetBSD: awin_tcon.c,v 1.5 2014/11/14 00:31:54 jmcneill Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | 4 | * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca> | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -19,42 +19,44 @@ | @@ -19,42 +19,44 @@ | |||
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | #include "opt_allwinner.h" | 29 | #include "opt_allwinner.h" | |
30 | 30 | |||
31 | #include <sys/cdefs.h> | 31 | #include <sys/cdefs.h> | |
32 | __KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.4 2014/11/11 19:22:32 jmcneill Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: awin_tcon.c,v 1.5 2014/11/14 00:31:54 jmcneill Exp $"); | |
33 | 33 | |||
34 | #include <sys/param.h> | 34 | #include <sys/param.h> | |
35 | #include <sys/bus.h> | 35 | #include <sys/bus.h> | |
36 | #include <sys/device.h> | 36 | #include <sys/device.h> | |
37 | #include <sys/intr.h> | 37 | #include <sys/intr.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/kernel.h> | 39 | #include <sys/kernel.h> | |
40 | #include <sys/mutex.h> | 40 | #include <sys/mutex.h> | |
41 | #include <sys/condvar.h> | 41 | #include <sys/condvar.h> | |
42 | 42 | |||
43 | #include <arm/allwinner/awin_reg.h> | 43 | #include <arm/allwinner/awin_reg.h> | |
44 | #include <arm/allwinner/awin_var.h> | 44 | #include <arm/allwinner/awin_var.h> | |
45 | 45 | |||
46 | #include <dev/videomode/videomode.h> | 46 | #include <dev/videomode/videomode.h> | |
47 | 47 | |||
48 | #define DIVIDE(x,y) (((x) + ((y) / 2)) / (y)) | |||
49 | ||||
48 | struct awin_tcon_softc { | 50 | struct awin_tcon_softc { | |
49 | device_t sc_dev; | 51 | device_t sc_dev; | |
50 | bus_space_tag_t sc_bst; | 52 | bus_space_tag_t sc_bst; | |
51 | bus_space_handle_t sc_bsh; | 53 | bus_space_handle_t sc_bsh; | |
52 | bus_space_handle_t sc_ch1clk_bsh; | 54 | bus_space_handle_t sc_ch1clk_bsh; | |
53 | unsigned int sc_port; | 55 | unsigned int sc_port; | |
54 | unsigned int sc_clk_div; | 56 | unsigned int sc_clk_div; | |
55 | bool sc_clk_dbl; | 57 | bool sc_clk_dbl; | |
56 | }; | 58 | }; | |
57 | 59 | |||
58 | #define TCON_READ(sc, reg) \ | 60 | #define TCON_READ(sc, reg) \ | |
59 | bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) | 61 | bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) | |
60 | #define TCON_WRITE(sc, reg, val) \ | 62 | #define TCON_WRITE(sc, reg, val) \ | |
@@ -224,65 +226,95 @@ awin_tcon_set_videomode(const struct vid | @@ -224,65 +226,95 @@ awin_tcon_set_videomode(const struct vid | |||
224 | { | 226 | { | |
225 | struct awin_tcon_softc *sc; | 227 | struct awin_tcon_softc *sc; | |
226 | device_t dev; | 228 | device_t dev; | |
227 | uint32_t val; | 229 | uint32_t val; | |
228 | 230 | |||
229 | dev = device_find_by_driver_unit("awintcon", 0); | 231 | dev = device_find_by_driver_unit("awintcon", 0); | |
230 | if (dev == NULL) { | 232 | if (dev == NULL) { | |
231 | printf("TCON: no driver found\n"); | 233 | printf("TCON: no driver found\n"); | |
232 | return; | 234 | return; | |
233 | } | 235 | } | |
234 | sc = device_private(dev); | 236 | sc = device_private(dev); | |
235 | 237 | |||
236 | if (mode) { | 238 | if (mode) { | |
239 | const u_int interlace_p = !!(mode->flags & VID_INTERLACE); | |||
240 | const u_int phsync_p = !!(mode->flags & VID_PHSYNC); | |||
241 | const u_int pvsync_p = !!(mode->flags & VID_PVSYNC); | |||
237 | const u_int hspw = mode->hsync_end - mode->hsync_start; | 242 | const u_int hspw = mode->hsync_end - mode->hsync_start; | |
238 | const u_int hbp = mode->htotal - mode->hsync_start; | 243 | const u_int hbp = mode->htotal - mode->hsync_start; | |
239 | const u_int vspw = mode->vsync_end - mode->vsync_start; | 244 | const u_int vspw = mode->vsync_end - mode->vsync_start; | |
240 | const u_int vbp = mode->vtotal - mode->vsync_start; | 245 | const u_int vbp = mode->vtotal - mode->vsync_start; | |
246 | const u_int vblank_len = | |||
247 | ((mode->vtotal << interlace_p) >> 1) - mode->vdisplay - 2; | |||
248 | const u_int start_delay = | |||
249 | vblank_len >= 32 ? 30 : vblank_len - 2; | |||
241 | 250 | |||
242 | val = TCON_READ(sc, AWIN_TCON_GCTL_REG); | 251 | val = TCON_READ(sc, AWIN_TCON_GCTL_REG); | |
243 | val |= AWIN_TCON_GCTL_IO_MAP_SEL; | 252 | val |= AWIN_TCON_GCTL_IO_MAP_SEL; | |
244 | TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val); | 253 | TCON_WRITE(sc, AWIN_TCON_GCTL_REG, val); | |
245 | 254 | |||
246 | /* enable */ | 255 | /* enable */ | |
247 | val = AWIN_TCON_CTL_EN; | 256 | val = AWIN_TCON_CTL_EN; | |
248 | val |= __SHIFTIN(0x1e, AWIN_TCON_CTL_START_DELAY); | 257 | if (interlace_p) | |
258 | val |= AWIN_TCON_CTL_INTERLACE_EN; | |||
259 | val |= __SHIFTIN(start_delay, AWIN_TCON_CTL_START_DELAY); | |||
249 | #ifdef AWIN_TCON_BLUEDATA | 260 | #ifdef AWIN_TCON_BLUEDATA | |
250 | val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_BLUEDATA, | 261 | val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_BLUEDATA, | |
251 | AWIN_TCON_CTL_SRC_SEL); | 262 | AWIN_TCON_CTL_SRC_SEL); | |
252 | #else | 263 | #else | |
253 | val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_DE0, | 264 | val |= __SHIFTIN(AWIN_TCON_CTL_SRC_SEL_DE0, | |
254 | AWIN_TCON_CTL_SRC_SEL); | 265 | AWIN_TCON_CTL_SRC_SEL); | |
255 | #endif | 266 | #endif | |
256 | TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val); | 267 | TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val); | |
257 | 268 | |||
258 | /* Source width/height */ | 269 | /* Source width/height */ | |
259 | TCON_WRITE(sc, AWIN_TCON1_BASIC0_REG, | 270 | TCON_WRITE(sc, AWIN_TCON1_BASIC0_REG, | |
260 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 271 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | |
261 | /* Scaler width/height */ | 272 | /* Scaler width/height */ | |
262 | TCON_WRITE(sc, AWIN_TCON1_BASIC1_REG, | 273 | TCON_WRITE(sc, AWIN_TCON1_BASIC1_REG, | |
263 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 274 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | |
264 | /* Output width/height */ | 275 | /* Output width/height */ | |
265 | TCON_WRITE(sc, AWIN_TCON1_BASIC2_REG, | 276 | TCON_WRITE(sc, AWIN_TCON1_BASIC2_REG, | |
266 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 277 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | |
267 | /* Horizontal total + back porch */ | 278 | /* Horizontal total + back porch */ | |
268 | TCON_WRITE(sc, AWIN_TCON1_BASIC3_REG, | 279 | TCON_WRITE(sc, AWIN_TCON1_BASIC3_REG, | |
269 | ((mode->htotal - 1) << 16) | (hbp - 1)); | 280 | ((mode->htotal - 1) << 16) | (hbp - 1)); | |
270 | /* Vertical total + back porch */ | 281 | /* Vertical total + back porch */ | |
282 | u_int vtotal = mode->vtotal * 2; | |||
283 | if (interlace_p) { | |||
284 | u_int framerate = | |||
285 | DIVIDE(DIVIDE(mode->dot_clock * 1000, mode->htotal), | |||
286 | mode->vtotal); | |||
287 | u_int clk = mode->htotal * (mode->vtotal * 2 + 1) * | |||
288 | framerate; | |||
289 | if ((clk / 2) == mode->dot_clock * 1000) | |||
290 | vtotal += 1; | |||
291 | } | |||
271 | TCON_WRITE(sc, AWIN_TCON1_BASIC4_REG, | 292 | TCON_WRITE(sc, AWIN_TCON1_BASIC4_REG, | |
272 | ((mode->vtotal * 2) << 16) | (vbp - 1)); | 293 | (vtotal << 16) | (vbp - 1)); | |
294 | ||||
273 | /* Sync */ | 295 | /* Sync */ | |
274 | TCON_WRITE(sc, AWIN_TCON1_BASIC5_REG, | 296 | TCON_WRITE(sc, AWIN_TCON1_BASIC5_REG, | |
275 | ((hspw - 1) << 16) | (vspw - 1)); | 297 | ((hspw - 1) << 16) | (vspw - 1)); | |
298 | /* Polarity */ | |||
299 | val = AWIN_TCON_IO_POL_IO2_INV; | |||
300 | if (phsync_p) | |||
301 | val |= AWIN_TCON_IO_POL_PHSYNC; | |||
302 | if (pvsync_p) | |||
303 | val |= AWIN_TCON_IO_POL_PVSYNC; | |||
304 | TCON_WRITE(sc, AWIN_TCON1_IO_POL_REG, val); | |||
305 | ||||
306 | TCON_WRITE(sc, AWIN_TCON_GINT1_REG, | |||
307 | __SHIFTIN(start_delay + 2, AWIN_TCON_GINT1_TCON1_LINENO)); | |||
276 | 308 | |||
277 | /* Setup LCDx CH1 PLL */ | 309 | /* Setup LCDx CH1 PLL */ | |
278 | awin_tcon_set_pll(sc, mode); | 310 | awin_tcon_set_pll(sc, mode); | |
279 | } else { | 311 | } else { | |
280 | /* disable */ | 312 | /* disable */ | |
281 | val = TCON_READ(sc, AWIN_TCON1_CTL_REG); | 313 | val = TCON_READ(sc, AWIN_TCON1_CTL_REG); | |
282 | val &= ~AWIN_TCON_CTL_EN; | 314 | val &= ~AWIN_TCON_CTL_EN; | |
283 | TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val); | 315 | TCON_WRITE(sc, AWIN_TCON1_CTL_REG, val); | |
284 | } | 316 | } | |
285 | } | 317 | } | |
286 | 318 | |||
287 | unsigned int | 319 | unsigned int | |
288 | awin_tcon_get_clk_div(void) | 320 | awin_tcon_get_clk_div(void) |