Module Name:    src
Committed By:   martin
Date:           Fri Nov 14 22:23:28 UTC 2014

Modified Files:
        src/sys/arch/arm/allwinner [netbsd-7]: awin_debe.c awin_fb.c awin_var.h
        src/sys/arch/evbarm/awin [netbsd-7]: awin_machdep.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #238):
        sys/arch/evbarm/awin/awin_machdep.c: revision 1.28
        sys/arch/arm/allwinner/awin_debe.c: revision 1.7
        sys/arch/arm/allwinner/awin_var.h: revision 1.23
        sys/arch/arm/allwinner/awin_fb.c: revision 1.5
Allow the DEBE layer and output sizes to be set independently. Now you can
pass fb.margin=<n> in bootargs to add a border to the framebuffer, in case
your display doesn't let you turn off overscan and you really want to see
the whole screen.


To generate a diff of this commit:
cvs rdiff -u -r1.6.2.2 -r1.6.2.3 src/sys/arch/arm/allwinner/awin_debe.c
cvs rdiff -u -r1.4.2.2 -r1.4.2.3 src/sys/arch/arm/allwinner/awin_fb.c
cvs rdiff -u -r1.10.2.2 -r1.10.2.3 src/sys/arch/arm/allwinner/awin_var.h
cvs rdiff -u -r1.8.2.6 -r1.8.2.7 src/sys/arch/evbarm/awin/awin_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/allwinner/awin_debe.c
diff -u src/sys/arch/arm/allwinner/awin_debe.c:1.6.2.2 src/sys/arch/arm/allwinner/awin_debe.c:1.6.2.3
--- src/sys/arch/arm/allwinner/awin_debe.c:1.6.2.2	Fri Nov 14 13:26:46 2014
+++ src/sys/arch/arm/allwinner/awin_debe.c	Fri Nov 14 22:23:28 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_debe.c,v 1.6.2.2 2014/11/14 13:26:46 martin Exp $ */
+/* $NetBSD: awin_debe.c,v 1.6.2.3 2014/11/14 22:23:28 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill <jmcne...@invisible.ca>
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.6.2.2 2014/11/14 13:26:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_debe.c,v 1.6.2.3 2014/11/14 22:23:28 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -63,6 +63,8 @@ struct awin_debe_softc {
 	bus_size_t sc_dmasize;
 	bus_dmamap_t sc_dmamap;
 	void *sc_dmap;
+
+	uint16_t sc_margin;
 };
 
 #define DEBE_READ(sc, reg) \
@@ -98,6 +100,7 @@ awin_debe_attach(device_t parent, device
 	struct awin_debe_softc *sc = device_private(self);
 	struct awinio_attach_args * const aio = aux;
 	const struct awin_locators * const loc = &aio->aio_loc;
+	prop_dictionary_t cfg = device_properties(self);
 	int error;
 
 	sc->sc_dev = self;
@@ -112,6 +115,8 @@ awin_debe_attach(device_t parent, device
 	aprint_naive("\n");
 	aprint_normal(": Display Engine Backend (BE%d)\n", loc->loc_port);
 
+	prop_dictionary_get_uint16(cfg, "margin", &sc->sc_margin);
+
 	if (awin_chip_id() == AWIN_CHIP_ID_A31) {
 		awin_reg_set_clear(aio->aio_core_bst, aio->aio_ccm_bsh,
 		    AWIN_A31_AHB_RESET1_REG,
@@ -202,6 +207,8 @@ awin_debe_alloc_videomem(struct awin_deb
 	if (error)
 		goto destroy;
 
+	memset(sc->sc_dmap, 0, sc->sc_dmasize);
+
 	return 0;
 
 destroy:
@@ -220,12 +227,19 @@ free:
 static void
 awin_debe_setup_fbdev(struct awin_debe_softc *sc, const struct videomode *mode)
 {
+	if (mode == NULL)
+		return;
+
+	const u_int interlace_p = !!(mode->flags & VID_INTERLACE);
+	const u_int fb_width = mode->hdisplay - (sc->sc_margin * 2);
+	const u_int fb_height = (mode->vdisplay << interlace_p) -
+				(sc->sc_margin * 2);
+
 	if (mode && sc->sc_fbdev == NULL) {
-		const u_int interlace_p = !!(mode->flags & VID_INTERLACE);
 		struct awinfb_attach_args afb = {
 			.afb_fb = sc->sc_dmap,
-			.afb_width = mode->hdisplay,
-			.afb_height = (mode->vdisplay << interlace_p),
+			.afb_width = fb_width,
+			.afb_height = fb_height,
 			.afb_dmat = sc->sc_dmat,
 			.afb_dmasegs = sc->sc_dmasegs,
 			.afb_ndmasegs = 1
@@ -235,7 +249,7 @@ awin_debe_setup_fbdev(struct awin_debe_s
 	}
 #if NGENFB > 0
 	else if (sc->sc_fbdev != NULL) {
-		awin_fb_set_videomode(sc->sc_fbdev, mode);
+		awin_fb_set_videomode(sc->sc_fbdev, fb_width, fb_height);
 	}
 #endif
 }
@@ -287,6 +301,8 @@ awin_debe_set_videomode(const struct vid
 		const u_int interlace_p = !!(mode->flags & VID_INTERLACE);
 		const u_int width = mode->hdisplay;
 		const u_int height = (mode->vdisplay << interlace_p);
+		const u_int fb_width = width - (sc->sc_margin * 2);
+		const u_int fb_height = height - (sc->sc_margin * 2);
 		uint32_t vmem = width * height * 4;
 
 		if (vmem > sc->sc_dmasize) {
@@ -310,8 +326,10 @@ awin_debe_set_videomode(const struct vid
 		DEBE_WRITE(sc, AWIN_DEBE_DISSIZE_REG,
 		    ((height - 1) << 16) | (width - 1));
 		DEBE_WRITE(sc, AWIN_DEBE_LAYSIZE_REG,
-		    ((height - 1) << 16) | (width - 1));
-		DEBE_WRITE(sc, AWIN_DEBE_LAYLINEWIDTH_REG, (width << 5));
+		    ((fb_height - 1) << 16) | (fb_width - 1));
+		DEBE_WRITE(sc, AWIN_DEBE_LAYCOOR_REG,
+		    (sc->sc_margin << 16) | sc->sc_margin);
+		DEBE_WRITE(sc, AWIN_DEBE_LAYLINEWIDTH_REG, (fb_width << 5));
 		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_L32ADD_REG, pa << 3);
 		DEBE_WRITE(sc, AWIN_DEBE_LAYFB_H4ADD_REG, pa >> 29);
 

Index: src/sys/arch/arm/allwinner/awin_fb.c
diff -u src/sys/arch/arm/allwinner/awin_fb.c:1.4.2.2 src/sys/arch/arm/allwinner/awin_fb.c:1.4.2.3
--- src/sys/arch/arm/allwinner/awin_fb.c:1.4.2.2	Fri Nov 14 13:26:46 2014
+++ src/sys/arch/arm/allwinner/awin_fb.c	Fri Nov 14 22:23:28 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_fb.c,v 1.4.2.2 2014/11/14 13:26:46 martin Exp $ */
+/* $NetBSD: awin_fb.c,v 1.4.2.3 2014/11/14 22:23:28 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_fb.c,v 1.4.2.2 2014/11/14 13:26:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_fb.c,v 1.4.2.3 2014/11/14 22:23:28 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -182,17 +182,10 @@ awin_fb_ddb_trap_callback(int where)
 }
 
 void
-awin_fb_set_videomode(device_t dev, const struct videomode *mode)
+awin_fb_set_videomode(device_t dev, u_int width, u_int height)
 {
 	struct awin_fb_softc *sc = device_private(dev);
 
-	if (mode == NULL)
-		return;
-
-	const u_int interlace_p = !!(mode->flags & VID_INTERLACE);
-	const u_int width = mode->hdisplay;
-	const u_int height = (mode->vdisplay << interlace_p);
-
 	if (sc->sc_gen.sc_width != width || sc->sc_gen.sc_height != height) {
 		device_printf(sc->sc_gen.sc_dev,
 		    "mode switching not yet supported\n");

Index: src/sys/arch/arm/allwinner/awin_var.h
diff -u src/sys/arch/arm/allwinner/awin_var.h:1.10.2.2 src/sys/arch/arm/allwinner/awin_var.h:1.10.2.3
--- src/sys/arch/arm/allwinner/awin_var.h:1.10.2.2	Fri Nov 14 13:26:46 2014
+++ src/sys/arch/arm/allwinner/awin_var.h	Fri Nov 14 22:23:28 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_var.h,v 1.10.2.2 2014/11/14 13:26:46 martin Exp $ */
+/* $NetBSD: awin_var.h,v 1.10.2.3 2014/11/14 22:23:28 martin Exp $ */
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -131,7 +131,7 @@ void	awin_tcon_set_videomode(const struc
 void	awin_tcon_enable(bool);
 void	awin_debe_set_videomode(const struct videomode *);
 void	awin_debe_enable(bool);
-void	awin_fb_set_videomode(device_t, const struct videomode *);
+void	awin_fb_set_videomode(device_t, u_int, u_int);
 void	awin_fb_ddb_trap_callback(int);
 
 void	awin_wdog_reset(void);

Index: src/sys/arch/evbarm/awin/awin_machdep.c
diff -u src/sys/arch/evbarm/awin/awin_machdep.c:1.8.2.6 src/sys/arch/evbarm/awin/awin_machdep.c:1.8.2.7
--- src/sys/arch/evbarm/awin/awin_machdep.c:1.8.2.6	Fri Nov 14 13:26:46 2014
+++ src/sys/arch/evbarm/awin/awin_machdep.c	Fri Nov 14 22:23:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: awin_machdep.c,v 1.8.2.6 2014/11/14 13:26:46 martin Exp $ */
+/*	$NetBSD: awin_machdep.c,v 1.8.2.7 2014/11/14 22:23:28 martin Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.8.2.6 2014/11/14 13:26:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_machdep.c,v 1.8.2.7 2014/11/14 22:23:28 martin Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -761,6 +761,14 @@ awin_device_register(device_t self, void
 		return;
 	}
 
+	if (device_is_a(self, "awindebe")) {
+		int margin;
+		if (get_bootconf_option(boot_args, "fb.margin",
+		    BOOTOPT_TYPE_INT, &margin) && margin > 0) {
+			prop_dictionary_set_uint16(dict, "margin", margin);
+		}
+	}
+
 #if NGENFB > 0
 	if (device_is_a(self, "genfb")) {
 #ifdef DDB

Reply via email to