CVS commit: src/sys/arch/evbppc/wii

2024-02-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 10 17:41:00 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii: machdep.c

Log Message:
wii: Simplify available memory logic.

Use usable MEM2 fields in Broadway / IOS Global memory locations to
determine available memory.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbppc/wii/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/evbppc/wii/machdep.c
diff -u src/sys/arch/evbppc/wii/machdep.c:1.4 src/sys/arch/evbppc/wii/machdep.c:1.5
--- src/sys/arch/evbppc/wii/machdep.c:1.4	Wed Jan 24 21:53:34 2024
+++ src/sys/arch/evbppc/wii/machdep.c	Sat Feb 10 17:41:00 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.4 2024/01/24 21:53:34 jmcneill Exp $ */
+/* $NetBSD: machdep.c,v 1.5 2024/02/10 17:41:00 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2002, 2024 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #define _POWERPC_BUS_DMA_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.4 2024/01/24 21:53:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.5 2024/02/10 17:41:00 jmcneill Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -228,7 +228,7 @@ initppc(u_int startkernel, u_int endkern
 	extern u_long ticks_per_sec;
 	extern unsigned char edata[], end[];
 	extern struct wii_argv wii_argv;
-	uint32_t mem2_size;
+	uint32_t mem2_start, mem2_end;
 	register_t scratch;
 
 	memset(, 0, end - edata); /* clear BSS */
@@ -240,7 +240,8 @@ initppc(u_int startkernel, u_int endkern
 		}
 	}
 
-	mem2_size = in32(GLOBAL_MEM2_SIZE);
+	mem2_start = in32(GLOBAL_MEM2_AVAIL_START) & ~0x8000;
+	mem2_end = in32(GLOBAL_MEM2_AVAIL_END) & ~0x8000;
 
 	/* MEM1 24MB 1T-SRAM */
 	physmemr[0].start = WII_MEM1_BASE;
@@ -248,7 +249,7 @@ initppc(u_int startkernel, u_int endkern
 
 	/* MEM2 64MB GDDR3 */
 	physmemr[1].start = WII_MEM2_BASE;
-	physmemr[1].size = mem2_size;
+	physmemr[1].size = WII_MEM2_SIZE;
 
 	physmemr[2].size = 0;
 
@@ -259,16 +260,8 @@ initppc(u_int startkernel, u_int endkern
 	availmemr[0].size -= XFB_SIZE;
 
 	/* MEM2 available memory */
-	availmemr[1].start = physmemr[1].start;
-	availmemr[1].size = physmemr[1].size;
-	if (mem2_size != 0) {
-		/* DSP uses 16KB at the start of MEM2 */
-		availmemr[1].start += DSP_MEM_SIZE;
-		availmemr[1].size -= DSP_MEM_SIZE;
-		/* IPC and Starlet use memory at the end of MEM2 */
-		availmemr[1].size -= IPC_SIZE;
-		availmemr[1].size -= ARM_SIZE;
-	}
+	availmemr[1].start = mem2_start;
+	availmemr[1].size = mem2_end - mem2_start;
 
 	availmemr[2].size = 0;
 



CVS commit: src/sys/arch/evbppc/wii

2024-02-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 10 17:41:00 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii: machdep.c

Log Message:
wii: Simplify available memory logic.

Use usable MEM2 fields in Broadway / IOS Global memory locations to
determine available memory.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbppc/wii/machdep.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-02-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 10 11:00:16 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: exi.c exi.h rtcsram.c

Log Message:
wii: Explicitly set EXI frequency when selecting a device.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/exi.c \
src/sys/arch/evbppc/wii/dev/exi.h src/sys/arch/evbppc/wii/dev/rtcsram.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/evbppc/wii/dev/exi.c
diff -u src/sys/arch/evbppc/wii/dev/exi.c:1.1 src/sys/arch/evbppc/wii/dev/exi.c:1.2
--- src/sys/arch/evbppc/wii/dev/exi.c:1.1	Thu Jan 25 11:47:53 2024
+++ src/sys/arch/evbppc/wii/dev/exi.c	Sat Feb 10 11:00:15 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: exi.c,v 1.1 2024/01/25 11:47:53 jmcneill Exp $ */
+/* $NetBSD: exi.c,v 1.2 2024/02/10 11:00:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exi.c,v 1.1 2024/01/25 11:47:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exi.c,v 1.2 2024/02/10 11:00:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: exi.c,v 1.1 
 
 #define	EXI_CSR(n)		(0x00 + (n) * 0x14)
 #define	 EXI_CSR_CS		__BITS(9,7)
+#define	 EXI_CSR_CLK		__BITS(6,4)
 #define	EXI_MAR(n)		(0x04 + (n) * 0x14)
 #define	EXI_LENGTH(n)		(0x08 + (n) * 0x14)
 #define	EXI_CR(n)		(0x0c + (n) * 0x14)
@@ -162,7 +163,7 @@ exi_rescan(device_t self, const char *if
 continue;
 			}
 
-			exi_select(chan, dev);
+			exi_select(chan, dev, EXI_FREQ_8MHZ);
 			exi_send_imm(chan, dev, , sizeof(command));
 			exi_recv_imm(chan, dev, , sizeof(id));
 			exi_unselect(chan);
@@ -199,7 +200,7 @@ exi_print(void *aux, const char *pnp)
 }
 
 void
-exi_select(uint8_t chan, uint8_t dev)
+exi_select(uint8_t chan, uint8_t dev, exi_freq_t freq)
 {
 	struct exi_channel *ch;
 	uint32_t val;
@@ -213,6 +214,8 @@ exi_select(uint8_t chan, uint8_t dev)
 	val = RD4(exi_softc, EXI_CSR(chan));
 	val &= ~EXI_CSR_CS;
 	val |= __SHIFTIN(__BIT(dev), EXI_CSR_CS);
+	val &= ~EXI_CSR_CLK;
+	val |= __SHIFTIN(freq, EXI_CSR_CLK);
 	WR4(exi_softc, EXI_CSR(chan), val);
 }
 
Index: src/sys/arch/evbppc/wii/dev/exi.h
diff -u src/sys/arch/evbppc/wii/dev/exi.h:1.1 src/sys/arch/evbppc/wii/dev/exi.h:1.2
--- src/sys/arch/evbppc/wii/dev/exi.h:1.1	Thu Jan 25 11:47:53 2024
+++ src/sys/arch/evbppc/wii/dev/exi.h	Sat Feb 10 11:00:15 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: exi.h,v 1.1 2024/01/25 11:47:53 jmcneill Exp $ */
+/* $NetBSD: exi.h,v 1.2 2024/02/10 11:00:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -29,13 +29,22 @@
 #ifndef _WII_DEV_EXI_H_
 #define _WII_DEV_EXI_H_
 
+typedef enum {
+	EXI_FREQ_1MHZ = 0,
+	EXI_FREQ_2MHZ = 1,
+	EXI_FREQ_4MHZ = 2,
+	EXI_FREQ_8MHZ = 3,
+	EXI_FREQ_16MHZ = 4,
+	EXI_FREQ_32MHZ = 5,
+} exi_freq_t;
+
 struct exi_attach_args {
 	uint32_t	eaa_id;
 	uint8_t		eaa_chan;
 	uint8_t		eaa_device;
 };
 
-void exi_select(uint8_t, uint8_t);
+void exi_select(uint8_t, uint8_t, exi_freq_t);
 void exi_unselect(uint8_t);
 void exi_send_imm(uint8_t, uint8_t, const void *, size_t);
 void exi_recv_imm(uint8_t, uint8_t, void *, size_t);
Index: src/sys/arch/evbppc/wii/dev/rtcsram.c
diff -u src/sys/arch/evbppc/wii/dev/rtcsram.c:1.1 src/sys/arch/evbppc/wii/dev/rtcsram.c:1.2
--- src/sys/arch/evbppc/wii/dev/rtcsram.c:1.1	Thu Jan 25 11:47:53 2024
+++ src/sys/arch/evbppc/wii/dev/rtcsram.c	Sat Feb 10 11:00:15 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: rtcsram.c,v 1.1 2024/01/25 11:47:53 jmcneill Exp $ */
+/* $NetBSD: rtcsram.c,v 1.2 2024/02/10 11:00:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.1 2024/01/25 11:47:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 1.2 2024/02/10 11:00:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: rtcsram.c,v 
 #include "exi.h"
 
 #define	WII_RTCSRAM_ID		0xf308
+#define	WII_RTCSRAM_FREQ	EXI_FREQ_8MHZ
 
 #define	RTC_BASE		0x2000
 #define	SRAM_BASE		0x2100
@@ -124,7 +125,7 @@ rtcsram_read_4(struct rtcsram_softc *sc,
 {
 	uint32_t val;
 
-	exi_select(sc->sc_chan, sc->sc_device);
+	exi_select(sc->sc_chan, sc->sc_device, WII_RTCSRAM_FREQ);
 	exi_send_imm(sc->sc_chan, sc->sc_device, , sizeof(offset));
 	exi_recv_imm(sc->sc_chan, sc->sc_device, , sizeof(val));
 	exi_unselect(sc->sc_chan);
@@ -137,7 +138,7 @@ rtcsram_write_4(struct rtcsram_softc *sc
 {
 	offset |= WRITE_OFFSET;
 
-	exi_select(sc->sc_chan, sc->sc_device);
+	exi_select(sc->sc_chan, sc->sc_device, WII_RTCSRAM_FREQ);
 	exi_send_imm(sc->sc_chan, sc->sc_device, , sizeof(offset));
 	exi_send_imm(sc->sc_chan, sc->sc_device, , sizeof(val));
 	exi_unselect(sc->sc_chan);
@@ -147,7 +148,7 @@ static void
 rtcsram_read_buf(struct rtcsram_softc *sc, uint32_t offset, void *data,
 size_t datalen)
 {
-	exi_select(sc->sc_chan, 

CVS commit: src/sys/arch/evbppc/wii/dev

2024-02-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 10 11:00:16 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: exi.c exi.h rtcsram.c

Log Message:
wii: Explicitly set EXI frequency when selecting a device.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/exi.c \
src/sys/arch/evbppc/wii/dev/exi.h src/sys/arch/evbppc/wii/dev/rtcsram.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-02-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb  5 23:48:35 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: wiifb.c

Log Message:
wiifb: Misc fixes.

Add a 16-pixel border on the top and bottom of the FB, and fix an error
path to properly blink the slot LED when the current video mode is not
supported.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbppc/wii/dev/wiifb.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/evbppc/wii/dev/wiifb.c
diff -u src/sys/arch/evbppc/wii/dev/wiifb.c:1.5 src/sys/arch/evbppc/wii/dev/wiifb.c:1.6
--- src/sys/arch/evbppc/wii/dev/wiifb.c:1.5	Sat Jan 27 17:44:37 2024
+++ src/sys/arch/evbppc/wii/dev/wiifb.c	Mon Feb  5 23:48:35 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wiifb.c,v 1.5 2024/01/27 17:44:37 hgutch Exp $ */
+/* $NetBSD: wiifb.c,v 1.6 2024/02/05 23:48:35 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.5 2024/01/27 17:44:37 hgutch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.6 2024/02/05 23:48:35 jmcneill Exp $");
 
 #include 
 #include 
@@ -43,7 +43,14 @@ __KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.
 #include "vireg.h"
 #include "viio.h"
 
-#define	WIIFB_ERROR_BLINK_INTERVAL	100
+#define WIIFB_ERROR_BLINK_INTERVAL	100
+
+#define WIIFB_TOP_BOTTOM_BORDER		16
+#define WIIFB_EFFECTIVE_START(p, w)	\
+	((uintptr_t)(p) + WIIFB_TOP_BOTTOM_BORDER * (w) * 2)
+#define WIIFB_EFFECTIVE_HEIGHT(h)	\
+	((h) - WIIFB_TOP_BOTTOM_BORDER * 2)
+
 
 struct wiifb_mode {
 	const char *		name;
@@ -151,6 +158,8 @@ wiifb_attach(device_t parent, device_t s
 	struct wiifb_softc *sc = device_private(self);
 	prop_dictionary_t dict = device_properties(self);
 	struct mainbus_attach_args *maa = aux;
+	u_int offset;
+	uint32_t *p;
 	int error;
 
 	sc->sc_gen.sc_dev = self;
@@ -162,15 +171,26 @@ wiifb_attach(device_t parent, device_t s
 	}
 	sc->sc_bits = mapiodev(XFB_START, XFB_SIZE, true);
 
+	/*
+	 * Paint the entire FB black. Use 4-byte accesses as the Wii will
+	 * ignore 1- and 2- byte writes to uncached memory.
+	 */
+	for (p = sc->sc_bits, offset = 0;
+	 offset < XFB_SIZE;
+	 offset += 4, p++) {
+		*p = 0x00800080;
+	}
+
 	wiifb_init(sc);
 	wiifb_set_mode(sc, sc->sc_format, sc->sc_interlaced);
 
 	prop_dictionary_set_uint32(dict, "width", sc->sc_curmode->width);
-	prop_dictionary_set_uint32(dict, "height", sc->sc_curmode->height);
+	prop_dictionary_set_uint32(dict, "height",
+	WIIFB_EFFECTIVE_HEIGHT(sc->sc_curmode->height));
 	prop_dictionary_set_uint8(dict, "depth", 16);
 	prop_dictionary_set_uint32(dict, "address", XFB_START);
 	prop_dictionary_set_uint32(dict, "virtual_address",
-	(uintptr_t)sc->sc_bits);
+	WIIFB_EFFECTIVE_START(sc->sc_bits, sc->sc_curmode->width));
 	prop_dictionary_set_uint64(dict, "devcmap", (uintptr_t)wiifb_devcmap);
 
 	genfb_init(>sc_gen);
@@ -212,12 +232,6 @@ wiifb_set_mode(struct wiifb_softc *sc, u
 	u_int strides, reads;
 
 	modeidx = WIIFB_MODE_INDEX(format, interlaced);
-	if (modeidx >= WIIFB_NMODES || wiifb_modes[modeidx].name == NULL) {
-		panic("Unsupported format (0x%x) / interlaced (%d) settings",
-		sc->sc_format, sc->sc_interlaced);
-	}
-	sc->sc_curmode = _modes[modeidx];
-
 	if (modeidx == WIIFB_MODE_INDEX(VI_DCR_FMT_NTSC, 1)) {
 		/* NTSC 480i Magic numbers from YAGCD. */
 		WR2(sc, VI_VTR, 0x0f06);
@@ -253,6 +267,12 @@ wiifb_set_mode(struct wiifb_softc *sc, u
 		wii_slot_led_blink(WIIFB_ERROR_BLINK_INTERVAL);
 	}
 
+	if (modeidx >= WIIFB_NMODES || wiifb_modes[modeidx].name == NULL) {
+		panic("Unsupported format (0x%x) / interlaced (%d) settings",
+		sc->sc_format, sc->sc_interlaced);
+	}
+	sc->sc_curmode = _modes[modeidx];
+
 	/* Picture configuration */
 	strides = (sc->sc_curmode->width * 2) / (interlaced ? 16 : 32);
 	reads = (sc->sc_curmode->width * 2) / 32;
@@ -322,11 +342,12 @@ wiifb_ioctl(void *v, void *vs, u_long cm
 		 * devcmap, so fill out fbinfo manually instead of relying
 		 * on wsdisplayio_get_fbinfo.
 		 */
-		fbi->fbi_fbsize = XFB_SIZE;
 		fbi->fbi_fboffset = 0;
 		fbi->fbi_width = sc->sc_curmode->width;
-		fbi->fbi_height = sc->sc_curmode->height;
+		fbi->fbi_height =
+		WIIFB_EFFECTIVE_HEIGHT(sc->sc_curmode->height);
 		fbi->fbi_stride = fbi->fbi_width * 2;
+		fbi->fbi_fbsize = fbi->fbi_height * fbi->fbi_stride;
 		fbi->fbi_bitsperpixel = 16;
 		fbi->fbi_pixeltype = WSFB_YUY2;
 		fbi->fbi_flags = WSFB_VRAM_IS_RAM;
@@ -384,11 +405,17 @@ static paddr_t
 wiifb_mmap(void *v, void *vs, off_t off, int prot)
 {
 	struct wiifb_softc *sc = v;
+	bus_addr_t start;
+	bus_size_t size;
+
+	start = WIIFB_EFFECTIVE_START(XFB_START, sc->sc_curmode->width);
+	size = WIIFB_EFFECTIVE_HEIGHT(sc->sc_curmode->height) *
+	   sc->sc_curmode->width * 2;
 
-	if (off < 0 || off >= XFB_SIZE) {
+	if (off < 0 || off >= size) {
 		return -1;
 	}
 
-	return 

CVS commit: src/sys/arch/evbppc/wii/dev

2024-02-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb  5 23:48:35 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: wiifb.c

Log Message:
wiifb: Misc fixes.

Add a 16-pixel border on the top and bottom of the FB, and fix an error
path to properly blink the slot LED when the current video mode is not
supported.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbppc/wii/dev/wiifb.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-27 Thread Harold Gutch
Module Name:src
Committed By:   hgutch
Date:   Sat Jan 27 17:44:37 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: wiifb.c

Log Message:
Add support for "PAL" (576i) mode on Wii.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbppc/wii/dev/wiifb.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-27 Thread Harold Gutch
Module Name:src
Committed By:   hgutch
Date:   Sat Jan 27 17:44:37 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: wiifb.c

Log Message:
Add support for "PAL" (576i) mode on Wii.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbppc/wii/dev/wiifb.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/evbppc/wii/dev/wiifb.c
diff -u src/sys/arch/evbppc/wii/dev/wiifb.c:1.4 src/sys/arch/evbppc/wii/dev/wiifb.c:1.5
--- src/sys/arch/evbppc/wii/dev/wiifb.c:1.4	Tue Jan 23 00:13:37 2024
+++ src/sys/arch/evbppc/wii/dev/wiifb.c	Sat Jan 27 17:44:37 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wiifb.c,v 1.4 2024/01/23 00:13:37 jmcneill Exp $ */
+/* $NetBSD: wiifb.c,v 1.5 2024/01/27 17:44:37 hgutch Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.4 2024/01/23 00:13:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.5 2024/01/27 17:44:37 hgutch Exp $");
 
 #include 
 #include 
@@ -86,6 +86,13 @@ static const struct wiifb_mode wiifb_mod
 		.height = 480,
 		.lines = 525,
 	},
+	[WIIFB_MODE_INDEX(VI_DCR_FMT_PAL, 1)] = {
+		.name = "PAL 576i",
+		.width = 640,
+		.height = 574,
+		.lines = 625,
+	},
+
 };
 #define WIIFB_NMODES	__arraycount(wiifb_modes)
 
@@ -229,6 +236,15 @@ wiifb_set_mode(struct wiifb_softc *sc, u
 		WR4(sc, VI_VTE, 0x00060030);
 		WR4(sc, VI_BBOI, 0x81d881d8);
 		WR4(sc, VI_BBEI, 0x81d881d8);
+	} else if (modeidx == WIIFB_MODE_INDEX(VI_DCR_FMT_PAL, 1)) {
+		/* PAL 576i */
+		WR2(sc, VI_VTR, 0x11f5);
+		WR4(sc, VI_HTR0, 0x4b6a01b0);
+		WR4(sc, VI_HTR1, 0x02f85640);
+		WR4(sc, VI_VTO, 0x00010023);
+		WR4(sc, VI_VTE, 0x0024);
+		WR4(sc, VI_BBOI, 0x4d2b4d6d);
+		WR4(sc, VI_BBEI, 0x4d8a4d4c);
 	} else {
 		/*
 		 * Display mode is not supported. Blink the slot LED to



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 23 21:56:07 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: bwai.c ehci_hollywood.c hollywood.c
hollywood.h ohci_hollywood.c resetbtn.c sdhc_hollywood.c

Log Message:
wii: provide device names to intr_establish

wii$ intrctl list
interrupt id  CPU0  device name(s)
pi irq 1464769* hollywood0
hollywood irq 36  5872* ehci0
hollywood irq 39 58907* sdhc0
hollywood irq 40 4* sdhc1
hollywood irq 49 0* resetbtn0
pi irq 5 0* bwai0


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbppc/wii/dev/bwai.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.h \
src/sys/arch/evbppc/wii/dev/ohci_hollywood.c \
src/sys/arch/evbppc/wii/dev/resetbtn.c \
src/sys/arch/evbppc/wii/dev/sdhc_hollywood.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/evbppc/wii/dev/bwai.c
diff -u src/sys/arch/evbppc/wii/dev/bwai.c:1.2 src/sys/arch/evbppc/wii/dev/bwai.c:1.3
--- src/sys/arch/evbppc/wii/dev/bwai.c:1.2	Tue Jan 23 21:49:20 2024
+++ src/sys/arch/evbppc/wii/dev/bwai.c	Tue Jan 23 21:56:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bwai.c,v 1.2 2024/01/23 21:49:20 jmcneill Exp $ */
+/* $NetBSD: bwai.c,v 1.3 2024/01/23 21:56:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bwai.c,v 1.2 2024/01/23 21:49:20 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bwai.c,v 1.3 2024/01/23 21:56:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -118,7 +118,8 @@ bwai_dsp_init(kmutex_t *intr_lock)
 
 	sc->sc_intr_lock = intr_lock;
 
-	intr_establish(sc->sc_irq, IST_LEVEL, IPL_AUDIO, bwai_intr, sc);
+	intr_establish_xname(sc->sc_irq, IST_LEVEL, IPL_AUDIO, bwai_intr, sc,
+	device_xname(dev));
 
 	return >sc_dai;
 }

Index: src/sys/arch/evbppc/wii/dev/ehci_hollywood.c
diff -u src/sys/arch/evbppc/wii/dev/ehci_hollywood.c:1.1 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c:1.2
--- src/sys/arch/evbppc/wii/dev/ehci_hollywood.c:1.1	Sat Jan 20 21:36:00 2024
+++ src/sys/arch/evbppc/wii/dev/ehci_hollywood.c	Tue Jan 23 21:56:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci_hollywood.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
+/* $NetBSD: ehci_hollywood.c,v 1.2 2024/01/23 21:56:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ehci_hollywood.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci_hollywood.c,v 1.2 2024/01/23 21:56:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -84,7 +84,8 @@ ehci_hollywood_attach(device_t parent, d
 	sc->sc_offs = EREAD1(sc, EHCI_CAPLENGTH);
 	EOWRITE4(sc, EHCI_USBINTR, 0);
 
-	hollywood_intr_establish(haa->haa_irq, IPL_USB, ehci_intr, sc);
+	hollywood_intr_establish(haa->haa_irq, IPL_USB, ehci_intr, sc,
+	device_xname(self));
 
 	error = ehci_init(sc);
 	if (error != 0) {
Index: src/sys/arch/evbppc/wii/dev/hollywood.c
diff -u src/sys/arch/evbppc/wii/dev/hollywood.c:1.1 src/sys/arch/evbppc/wii/dev/hollywood.c:1.2
--- src/sys/arch/evbppc/wii/dev/hollywood.c:1.1	Sat Jan 20 21:36:00 2024
+++ src/sys/arch/evbppc/wii/dev/hollywood.c	Tue Jan 23 21:56:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: hollywood.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
+/* $NetBSD: hollywood.c,v 1.2 2024/01/23 21:56:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hollywood.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hollywood.c,v 1.2 2024/01/23 21:56:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -206,15 +206,16 @@ hollywood_intr_init(int irq)
 
 	pic_add(_pic);
 
-	intr_establish(irq, IST_LEVEL, IPL_SCHED, pic_handle_intr,
-	_pic);
+	intr_establish_xname(irq, IST_LEVEL, IPL_SCHED, pic_handle_intr,
+	_pic, "hollywood0");
 }
 
 void *
-hollywood_intr_establish(int irq, int ipl, int (*func)(void *), void *arg)
+hollywood_intr_establish(int irq, int ipl, int (*func)(void *), void *arg,
+const char *name)
 {
 	KASSERT(hollywood_pic.pic_intrbase != 0);
 
-	return intr_establish(hollywood_pic.pic_intrbase + irq,
-	IST_LEVEL, ipl, func, arg);
+	return intr_establish_xname(hollywood_pic.pic_intrbase + irq,
+	IST_LEVEL, ipl, func, arg, name);
 }
Index: src/sys/arch/evbppc/wii/dev/hollywood.h
diff -u src/sys/arch/evbppc/wii/dev/hollywood.h:1.1 src/sys/arch/evbppc/wii/dev/hollywood.h:1.2
--- src/sys/arch/evbppc/wii/dev/hollywood.h:1.1	Sat Jan 20 21:36:00 2024
+++ src/sys/arch/evbppc/wii/dev/hollywood.h	Tue Jan 23 21:56:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: hollywood.h,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
+/* $NetBSD: hollywood.h,v 1.2 2024/01/23 21:56:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 

CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 23 21:56:07 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: bwai.c ehci_hollywood.c hollywood.c
hollywood.h ohci_hollywood.c resetbtn.c sdhc_hollywood.c

Log Message:
wii: provide device names to intr_establish

wii$ intrctl list
interrupt id  CPU0  device name(s)
pi irq 1464769* hollywood0
hollywood irq 36  5872* ehci0
hollywood irq 39 58907* sdhc0
hollywood irq 40 4* sdhc1
hollywood irq 49 0* resetbtn0
pi irq 5 0* bwai0


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbppc/wii/dev/bwai.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/ehci_hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.c \
src/sys/arch/evbppc/wii/dev/hollywood.h \
src/sys/arch/evbppc/wii/dev/ohci_hollywood.c \
src/sys/arch/evbppc/wii/dev/resetbtn.c \
src/sys/arch/evbppc/wii/dev/sdhc_hollywood.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 23 21:49:51 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: bwdsp.c

Log Message:
wii: Simply DSP driver - no interrupt handler required.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/bwdsp.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 23 21:49:51 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: bwdsp.c

Log Message:
wii: Simply DSP driver - no interrupt handler required.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/bwdsp.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/evbppc/wii/dev/bwdsp.c
diff -u src/sys/arch/evbppc/wii/dev/bwdsp.c:1.1 src/sys/arch/evbppc/wii/dev/bwdsp.c:1.2
--- src/sys/arch/evbppc/wii/dev/bwdsp.c:1.1	Mon Jan 22 21:28:15 2024
+++ src/sys/arch/evbppc/wii/dev/bwdsp.c	Tue Jan 23 21:49:51 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bwdsp.c,v 1.1 2024/01/22 21:28:15 jmcneill Exp $ */
+/* $NetBSD: bwdsp.c,v 1.2 2024/01/23 21:49:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bwdsp.c,v 1.1 2024/01/22 21:28:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bwdsp.c,v 1.2 2024/01/23 21:49:51 jmcneill Exp $");
 
 #include 
 #include 
@@ -44,13 +44,6 @@ __KERNEL_RCSID(0, "$NetBSD: bwdsp.c,v 1.
 
 #define	BWDSP_MAP_FLAGS		BUS_DMA_NOCACHE
 
-#define	DSP_CONTROL_STATUS	0x0a
-#define	 DSP_CONTROL_STATUS_DSPINT	__BIT(7)
-#define	 DSP_CONTROL_STATUS_ARINT	__BIT(5)
-#define  DSP_CONTROL_STATUS_AIDINTMASK	__BIT(4)
-#define	 DSP_CONTROL_STATUS_AIDINT	__BIT(3)
-#define	 DSP_CONTROL_STATUS_HALT	__BIT(2)
-#define	 DSP_CONTROL_STATUS_PIINT	__BIT(1)
 #define DSP_DMA_START_ADDR_H	0x30
 #define	DSP_DMA_START_ADDR_L	0x32
 #define DSP_DMA_CONTROL_LENGTH	0x36
@@ -339,24 +332,6 @@ static const struct audio_hw_if bwdsp_hw
 	.get_locks = bwdsp_get_locks,
 };
 
-static int
-bwdsp_intr(void *priv)
-{
-	struct bwdsp_softc * const sc = priv;
-	uint16_t val;
-
-	val = RD2(sc, DSP_CONTROL_STATUS);
-	if ((val & DSP_CONTROL_STATUS_AIDINT) != 0) {
-		/* Acknowledge audio interrupt */
-		val &= ~(DSP_CONTROL_STATUS_DSPINT |
-			 DSP_CONTROL_STATUS_ARINT |
-			 DSP_CONTROL_STATUS_PIINT);
-		WR2(sc, DSP_CONTROL_STATUS, val);
-	}
-
-	return 1;
-}
-
 static void
 bwdsp_late_attach(device_t dev)
 {
@@ -386,7 +361,6 @@ bwdsp_attach(device_t parent, device_t s
 	struct mainbus_attach_args * const maa = aux;
 	bus_addr_t addr = maa->maa_addr;
 	bus_size_t size = 0x200;
-	uint16_t val;
 
 	sc->sc_dev = self;
 	sc->sc_bst = maa->maa_bst;
@@ -411,13 +385,6 @@ bwdsp_attach(device_t parent, device_t s
 	sc->sc_format.frequency_type = 1;
 	sc->sc_format.frequency[0] = 48000;
 
-	val = RD2(sc, DSP_CONTROL_STATUS);
-	val |= DSP_CONTROL_STATUS_AIDINTMASK;
-	val |= DSP_CONTROL_STATUS_PIINT;
-	WR2(sc, DSP_CONTROL_STATUS, val);
-
-	intr_establish(maa->maa_irq, IST_LEVEL, IPL_AUDIO, bwdsp_intr, sc);
-
 	config_defer(self, bwdsp_late_attach);
 }
 



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 23 21:49:20 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: bwai.c

Log Message:
wii: Use A/V encoder volume controls instead of using a software filter.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/bwai.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/evbppc/wii/dev/bwai.c
diff -u src/sys/arch/evbppc/wii/dev/bwai.c:1.1 src/sys/arch/evbppc/wii/dev/bwai.c:1.2
--- src/sys/arch/evbppc/wii/dev/bwai.c:1.1	Mon Jan 22 21:28:15 2024
+++ src/sys/arch/evbppc/wii/dev/bwai.c	Tue Jan 23 21:49:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bwai.c,v 1.1 2024/01/22 21:28:15 jmcneill Exp $ */
+/* $NetBSD: bwai.c,v 1.2 2024/01/23 21:49:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bwai.c,v 1.1 2024/01/22 21:28:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bwai.c,v 1.2 2024/01/23 21:49:20 jmcneill Exp $");
 
 #include 
 #include 
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: bwai.c,v 1.1
 #include 
 
 #include "mainbus.h"
+#include "avenc.h"
 #include "bwai.h"
 
 #define	AI_CONTROL		0x00
@@ -62,7 +63,6 @@ struct bwai_softc {
 
 	struct audio_dai_device	sc_dai;
 
-	uint8_t			sc_swvol;
 	void			(*sc_intr)(void *);
 	void			*sc_intrarg;
 
@@ -123,36 +123,16 @@ bwai_dsp_init(kmutex_t *intr_lock)
 	return >sc_dai;
 }
 
-static void
-bwai_swvol_codec(audio_filter_arg_t *arg)
-{
-	struct bwai_softc * const sc = arg->context;
-	const aint_t *src;
-	int16_t *dst;
-	u_int sample_count;
-	u_int i;
-
-	src = arg->src;
-	dst = arg->dst;
-	sample_count = arg->count * arg->srcfmt->channels;
-	for (i = 0; i < sample_count; i++) {
-		aint2_t v = (aint2_t)(*src++);
-		v = v * sc->sc_swvol / 255;
-		*dst++ = (aint_t)v;
-	}
-}
-
 static int
 bwai_set_port(void *priv, mixer_ctrl_t *mc)
 {
-	struct bwai_softc * const sc = priv;
-
 	if (mc->dev != BWAI_OUTPUT_MASTER_VOLUME &&
 	mc->dev != BWAI_INPUT_DAC_VOLUME) {
 		return ENXIO;
 	}
 
-	sc->sc_swvol = mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT];
+	avenc_set_volume(mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT],
+			 mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT]);
 
 	return 0;
 }
@@ -160,15 +140,13 @@ bwai_set_port(void *priv, mixer_ctrl_t *
 static int
 bwai_get_port(void *priv, mixer_ctrl_t *mc)
 {
-	struct bwai_softc * const sc = priv;
-
 	if (mc->dev != BWAI_OUTPUT_MASTER_VOLUME &&
 	mc->dev != BWAI_INPUT_DAC_VOLUME) {
 		return ENXIO;
 	}
 
-	mc->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = sc->sc_swvol;
-	mc->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = sc->sc_swvol;
+	avenc_get_volume(>un.value.level[AUDIO_MIXER_LEVEL_LEFT],
+			 >un.value.level[AUDIO_MIXER_LEVEL_RIGHT]);
 
 	return 0;
 }
@@ -220,11 +198,6 @@ bwai_set_format(void *priv, int setmode,
 const audio_params_t *play, const audio_params_t *rec,
 audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
 {
-	struct bwai_softc * const sc = priv;
-
-	pfil->codec = bwai_swvol_codec;
-	pfil->context = sc;
-
 	return 0;
 }
 
@@ -308,7 +281,6 @@ bwai_attach(device_t parent, device_t se
 	sc->sc_dai.dai_hw_if = _hw_if;
 	sc->sc_dai.dai_dev = self;
 	sc->sc_dai.dai_priv = sc;
-	sc->sc_swvol = 255;
 }
 
 CFATTACH_DECL_NEW(bwai, sizeof(struct bwai_softc),



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 23 21:49:20 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: bwai.c

Log Message:
wii: Use A/V encoder volume controls instead of using a software filter.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/bwai.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jan 22 23:07:43 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: wiifb.c

Log Message:
wii: Add screenblank support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbppc/wii/dev/wiifb.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/evbppc/wii/dev/wiifb.c
diff -u src/sys/arch/evbppc/wii/dev/wiifb.c:1.2 src/sys/arch/evbppc/wii/dev/wiifb.c:1.3
--- src/sys/arch/evbppc/wii/dev/wiifb.c:1.2	Sun Jan 21 13:05:29 2024
+++ src/sys/arch/evbppc/wii/dev/wiifb.c	Mon Jan 22 23:07:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wiifb.c,v 1.2 2024/01/21 13:05:29 jmcneill Exp $ */
+/* $NetBSD: wiifb.c,v 1.3 2024/01/22 23:07:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.2 2024/01/21 13:05:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.3 2024/01/22 23:07:43 jmcneill Exp $");
 
 #include 
 #include 
@@ -118,6 +118,7 @@ static void	wiifb_attach(device_t, devic
 static void	wiifb_init(struct wiifb_softc *);
 static void	wiifb_set_mode(struct wiifb_softc *, uint8_t, bool);
 static void	wiifb_set_fb(struct wiifb_softc *);
+static void	wiifb_set_picconf(struct wiifb_softc *, u_int, bool);
 
 static int	wiifb_ioctl(void *, void *, u_long, void *, int, lwp_t *);
 static paddr_t	wiifb_mmap(void *, void *, off_t, int);
@@ -202,7 +203,6 @@ static void
 wiifb_set_mode(struct wiifb_softc *sc, uint8_t format, bool interlaced)
 {
 	u_int modeidx;
-	u_int strides, reads;
 
 	modeidx = WIIFB_MODE_INDEX(format, interlaced);
 	if (modeidx >= WIIFB_NMODES || wiifb_modes[modeidx].name == NULL) {
@@ -238,11 +238,7 @@ wiifb_set_mode(struct wiifb_softc *sc, u
 	}
 
 	/* Picture configuration */
-	strides = (sc->sc_curmode->width * 2) / (interlaced ? 16 : 32);
-	reads = (sc->sc_curmode->width * 2) / 32;
-	WR2(sc, VI_PICCONF,
-	__SHIFTIN(strides, VI_PICCONF_STRIDES) |
-	__SHIFTIN(reads, VI_PICCONF_READS));
+	wiifb_set_picconf(sc, sc->sc_curmode->width, interlaced);
 
 	/* Horizontal scaler configuration */
 	if (interlaced) {
@@ -282,6 +278,18 @@ wiifb_set_fb(struct wiifb_softc *sc)
 	WR4(sc, VI_BFBR, 0);
 }
 
+static void
+wiifb_set_picconf(struct wiifb_softc *sc, u_int width, bool interlaced)
+{
+	u_int strides, reads;
+
+	strides = (width * 2) / (interlaced ? 16 : 32);
+	reads = (width * 2) / 32;
+	WR2(sc, VI_PICCONF,
+	__SHIFTIN(strides, VI_PICCONF_STRIDES) |
+	__SHIFTIN(reads, VI_PICCONF_READS));
+}
+
 static int
 wiifb_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l)
 {
@@ -289,6 +297,7 @@ wiifb_ioctl(void *v, void *vs, u_long cm
 	struct wsdisplayio_bus_id *busid;
 	struct wsdisplayio_fbinfo *fbi;
 	struct vi_regs *vr;
+	u_int video;
 
 	switch (cmd) {
 	case WSDISPLAYIO_GTYPE:
@@ -315,6 +324,20 @@ wiifb_ioctl(void *v, void *vs, u_long cm
 		fbi->fbi_flags = WSFB_VRAM_IS_RAM;
 		return 0;
 
+	case WSDISPLAYIO_SVIDEO:
+		video = *(u_int *)data;
+		switch (video) {
+		case WSDISPLAYIO_VIDEO_OFF:
+			wiifb_set_picconf(sc, 0, sc->sc_interlaced);
+			return 0;
+		case WSDISPLAYIO_VIDEO_ON:
+			wiifb_set_picconf(sc, sc->sc_curmode->width,
+			sc->sc_interlaced);
+			return 0;
+		default:
+			return EINVAL;
+		}
+
 	case VIIO_GETREGS:
 	case VIIO_SETREGS:
 		vr = data;



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jan 22 23:07:43 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: wiifb.c

Log Message:
wii: Add screenblank support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbppc/wii/dev/wiifb.c

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



CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 21 13:05:29 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: vireg.h wiifb.c
Added Files:
src/sys/arch/evbppc/wii/dev: viio.h

Log Message:
wii: Add NTSC 480p support.

In addition to this, add VIIO_{GET,SET}REGS ioctl support to allow for
poking at video interface registers from userland. This is helpful for
debugging display issues.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbppc/wii/dev/viio.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/vireg.h \
src/sys/arch/evbppc/wii/dev/wiifb.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/evbppc/wii/dev/vireg.h
diff -u src/sys/arch/evbppc/wii/dev/vireg.h:1.1 src/sys/arch/evbppc/wii/dev/vireg.h:1.2
--- src/sys/arch/evbppc/wii/dev/vireg.h:1.1	Sat Jan 20 21:36:00 2024
+++ src/sys/arch/evbppc/wii/dev/vireg.h	Sun Jan 21 13:05:29 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vireg.h,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
+/* $NetBSD: vireg.h,v 1.2 2024/01/21 13:05:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -163,7 +163,8 @@
 
 /* [2B] VISEL - VI DTV Status Register */
 #define VI_VISEL	0x6e
-#define	 VI_VISEL_SEL	__BIT(2)
+#define	 VI_VISEL_SEL			__BIT(2)
+#define	 VI_VISEL_COMPONENT_CABLE	__BIT(0)
 
 /* [2B] VI_HSCALINGW - Horizontal Scaling Width */
 #define VI_HSCALINGW	0x70
Index: src/sys/arch/evbppc/wii/dev/wiifb.c
diff -u src/sys/arch/evbppc/wii/dev/wiifb.c:1.1 src/sys/arch/evbppc/wii/dev/wiifb.c:1.2
--- src/sys/arch/evbppc/wii/dev/wiifb.c:1.1	Sat Jan 20 21:36:00 2024
+++ src/sys/arch/evbppc/wii/dev/wiifb.c	Sun Jan 21 13:05:29 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wiifb.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $ */
+/* $NetBSD: wiifb.c,v 1.2 2024/01/21 13:05:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2024 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.1 2024/01/20 21:36:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.2 2024/01/21 13:05:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: wiifb.c,v 1.
 
 #include "mainbus.h"
 #include "vireg.h"
+#include "viio.h"
 
 #define	WIIFB_ERROR_BLINK_INTERVAL	100
 
@@ -179,30 +180,22 @@ static void
 wiifb_init(struct wiifb_softc *sc)
 {
 	uint16_t dcr;
+	uint16_t visel;
 
-#if notyet
 	/* Read current display format and interlaced settings. */
 	dcr = RD2(sc, VI_DCR);
-	sc->sc_format = __SHIFTOUT(dcr, VI_DCR_FMT);
-	sc->sc_interlaced = (dcr & VI_DCR_NIN) == 0;
+	if ((dcr & VI_DCR_ENB) != 0) {
+		sc->sc_format = __SHIFTOUT(dcr, VI_DCR_FMT);
+		sc->sc_interlaced = (dcr & VI_DCR_NIN) == 0;
+	} else {
+		visel = RD2(sc, VI_VISEL);
+		sc->sc_format = VI_DCR_FMT_NTSC;
+		sc->sc_interlaced = (visel & VI_VISEL_COMPONENT_CABLE) == 0;
+	}
 
 	/* Reset video interface. */
 	WR2(sc, VI_DCR, dcr | VI_DCR_RST);
 	WR2(sc, VI_DCR, dcr & ~VI_DCR_RST);
-#else
-	/* Force NTSC 480i and reset video interface. */
-	dcr = RD2(sc, VI_DCR);
-	dcr |= VI_DCR_RST;
-	WR2(sc, VI_DCR, dcr);
-	dcr &= ~VI_DCR_RST;
-	dcr &= ~VI_DCR_FMT;
-	dcr |= __SHIFTIN(VI_DCR_FMT_NTSC, VI_DCR_FMT);
-	dcr &= ~VI_DCR_NIN;
-	WR2(sc, VI_DCR, dcr);
-
-	sc->sc_format = VI_DCR_FMT_NTSC;
-	sc->sc_interlaced = 1;
-#endif
 }
 
 static void
@@ -219,7 +212,7 @@ wiifb_set_mode(struct wiifb_softc *sc, u
 	sc->sc_curmode = _modes[modeidx];
 
 	if (modeidx == WIIFB_MODE_INDEX(VI_DCR_FMT_NTSC, 1)) {
-		/* Magic numbers from YAGCD. */
+		/* NTSC 480i Magic numbers from YAGCD. */
 		WR2(sc, VI_VTR, 0x0f06);
 		WR4(sc, VI_HTR0, 0x476901AD);
 		WR4(sc, VI_HTR1, 0x02EA5140);
@@ -227,6 +220,15 @@ wiifb_set_mode(struct wiifb_softc *sc, u
 		WR4(sc, VI_VTE, 0x00020019);
 		WR4(sc, VI_BBOI, 0x410C410C);
 		WR4(sc, VI_BBEI, 0x40ED40ED);
+	} else if (modeidx == WIIFB_MODE_INDEX(VI_DCR_FMT_NTSC, 0)) {
+		/* NTSC 480p */
+		WR2(sc, VI_VTR, 0x1e0c);
+		WR4(sc, VI_HTR0, 0x476901ad);
+		WR4(sc, VI_HTR1, 0x030a4940);
+		WR4(sc, VI_VTO, 0x00060030);
+		WR4(sc, VI_VTE, 0x00060030);
+		WR4(sc, VI_BBOI, 0x81d881d8);
+		WR4(sc, VI_BBEI, 0x81d881d8);
 	} else {
 		/*
 		 * Display mode is not supported. Blink the slot LED to
@@ -242,7 +244,12 @@ wiifb_set_mode(struct wiifb_softc *sc, u
 	__SHIFTIN(strides, VI_PICCONF_STRIDES) |
 	__SHIFTIN(reads, VI_PICCONF_READS));
 
-	WR2(sc, VI_HSR, __SHIFTIN(256, VI_HSR_STP));
+	/* Horizontal scaler configuration */
+	if (interlaced) {
+		WR2(sc, VI_HSR, __SHIFTIN(256, VI_HSR_STP));
+	} else {
+		WR2(sc, VI_HSR, __SHIFTIN(244, VI_HSR_STP) | VI_HSR_HS_EN);
+	}
 
 	/* Video clock configuration */
 	WR2(sc, VI_VICLK,
@@ -281,6 +288,7 @@ wiifb_ioctl(void *v, void *vs, u_long cm
 	struct wiifb_softc *sc = v;
 	struct wsdisplayio_bus_id *busid;
 	struct wsdisplayio_fbinfo *fbi;
+	struct vi_regs *vr;
 
 	switch (cmd) {
 	case WSDISPLAYIO_GTYPE:
@@ -306,6 +314,35 @@ wiifb_ioctl(void *v, void *vs, u_long cm
 		

CVS commit: src/sys/arch/evbppc/wii/dev

2024-01-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jan 21 13:05:29 UTC 2024

Modified Files:
src/sys/arch/evbppc/wii/dev: vireg.h wiifb.c
Added Files:
src/sys/arch/evbppc/wii/dev: viio.h

Log Message:
wii: Add NTSC 480p support.

In addition to this, add VIIO_{GET,SET}REGS ioctl support to allow for
poking at video interface registers from userland. This is helpful for
debugging display issues.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/evbppc/wii/dev/viio.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbppc/wii/dev/vireg.h \
src/sys/arch/evbppc/wii/dev/wiifb.c

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