Subject: Re: SGI Indy full-screen console mode
To: Michal Wirski <hippo@sdf.lonestar.org>
From: Steve Rumble <rumble@ephemeral.org>
List: port-sgimips
Date: 12/26/2004 12:26:34
--98e8jtXdkpgskNou
Content-Type: multipart/mixed; boundary="HcAYCG3uE/tztfnV"
Content-Disposition: inline


--HcAYCG3uE/tztfnV
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Dec 26, 2004 at 03:26:20PM +0000, Michal Wirski wrote:
> I am running NetBSD 2.0 on an SGI Indy 4600K.
> I run it in full-screen console mode through a normal monitor=20
> and keyboard.
> Everything works fine except for the orange square cursor.
>=20
> When I am presented with a shell, or login prompt, or when working in Vi,
> the cursor behavour is the same and problematic.
>=20
> When I type a letter at the shell prompt, the letter  that was just typed=
=20
> is hidden by the cursor, to see that letter I have to type in a new lette=
r.
>=20
> I tried both vt100 and vt220 terminal emulation. I dont know if the probl=
em=20
> is with wscons, gettytab or tty.
>=20
> Is anyone having the same problem?

It's a known issue with the newport driver. There is a hardware bug
that effects the cursor offset, and while the driver has workarounds
for it, apparently they're incorrect. I believe that this may be
due to there being insufficient, or incorrect data as to which
revisions are broken in what way. Ilpo can probably expand on
the exact situation.

I've thrown together a sysctl that allows you to override the
cursor offset. The patch is attached, and a 2.0 GENERIC_IP2x kernel
with it already applied can be found here:
http://www.ephemeral.org/doodads/GENERIC32_IP2x_NEWPORT_X_OFFSET

To make use of it, try:
"sysctl -w hw.newport.x_offset_override=3Dx", where x is typically
one of 21, 29, or 31. You can experiment with other values. 0
turns the override off. You can add "hw.newport.x_offset_override=3Dx"
to /etc/sysctl.conf to take effect on boot.

If you find a value that works well, I'd appreciate to hear the
value used as well as the newport dmesg lines.

Steve

--HcAYCG3uE/tztfnV
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="newport.c.diff"
Content-Transfer-Encoding: quoted-printable

--- newport.c	2004-02-06 23:34:34.000000000 -0500
+++ /home/rumble/src/sys/arch/sgimips/gio/newport.c	2004-12-26 12:04:05.000=
000000 -0500
@@ -36,6 +36,7 @@
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
+#include <sys/sysctl.h>
=20
 #include <dev/wscons/wsconsio.h>
 #include <dev/wscons/wsdisplayvar.h>
@@ -243,6 +244,8 @@
 	0xff, 0xff, 0xff, /* white */
 };
=20
+static int x_offset_override;
+
 /**** Low-level hardware register groveling functions ****/
 static void
 rex3_write(struct newport_devconfig *dc, bus_size_t rexreg, uint32_t val)
@@ -689,7 +692,9 @@
 		    control & ~VC2_CONTROL_CURSOR_ENABLE);
 	} else {
 		/* Work around bug in some board revisions */
-		if (dc->dc_boardrev < 6)
+		if (x_offset_override)
+			x_offset =3D x_offset_override;
+		else if (dc->dc_boardrev < 6)
 			x_offset =3D 21;
 		else if (dc->dc_vc2rev =3D=3D 0)=20
 			x_offset =3D 29;
@@ -900,9 +905,82 @@
 {
 	panic("newport_free_screen");
 }
+
 static int
 newport_show_screen(void *c, void *cookie, int waitok,
     void (*cb)(void *, int, int), void *cbarg)
 {
 	return 0;
 }
+
+/*
+ * sysctl(3) MIB routines for hw.newport.*.
+ * Ripped from dev/pci/if_bge.c.
+ */
+static int
+sysctl_newport_verify(SYSCTLFN_ARGS)
+{
+	int error, t;
+	struct sysctlnode node;
+
+	node =3D *rnode;
+	t =3D *(int *)rnode->sysctl_data;
+	node.sysctl_data =3D &t;
+	error =3D sysctl_lookup(SYSCTLFN_CALL(&node));
+	if (error || newp =3D=3D NULL)
+		return (error);
+
+#if 0
+	DPRINTF2(("%s: t =3D %d, nodenum =3D %d, rnodenum =3D %d\n", __func__, t,
+	    node.sysctl_num, rnode->sysctl_num));
+#endif
+
+	/*
+	 * Restrict to somewhat reasonable limits.
+	 * 0 turns offset override off.
+	 */
+	if (t < 0 || t > 48)=20
+		return (EINVAL);
+
+	*(int *)rnode->sysctl_data =3D t;
+
+	return (0);
+}
+
+SYSCTL_SETUP(sysctl_newport, "sysctl newport subtree setup")
+{
+	int rc, newport_root_num;
+	struct sysctlnode *node;
+
+	if ((rc =3D sysctl_createv(clog, 0, NULL, NULL,
+	    CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw", NULL,
+	    NULL, 0, NULL, 0, CTL_HW, CTL_EOL)) !=3D 0) {
+		goto err;
+	}
+
+	if ((rc =3D sysctl_createv(clog, 0, NULL, &node,
+	    CTLFLAG_PERMANENT, CTLTYPE_NODE, "newport",
+	    SYSCTL_DESCR("newport graphics controls"),
+	    NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL)) !=3D 0) {
+		goto err;
+	}
+
+	newport_root_num =3D node->sysctl_num;
+
+	/* BGE Rx interrupt mitigation level */
+	if ((rc =3D sysctl_createv(clog, 0, NULL, &node,=20
+	    CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+	    CTLTYPE_INT, "x_offset_override",
+	    SYSCTL_DESCR("newport cursor x-axis offset"),
+	    sysctl_newport_verify, 0,
+	    &x_offset_override,
+	    0, CTL_HW, newport_root_num, CTL_CREATE,
+	    CTL_EOL)) !=3D 0) {
+		goto err;
+	}
+
+	return;
+
+err:
+	printf("%s: sysctl_createv failed (rc =3D %d)\n", __func__, rc);
+}

--HcAYCG3uE/tztfnV--

--98e8jtXdkpgskNou
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iQEVAwUBQc70SsuCaQyb9VOkAQI98gf+K6f52RUYn9rDDZ4VpgIkCYApheQ2WKIT
gKeIw5i+rrzSXAE2+BlI3tLFyy4LcrvFK7KFHTNzb2pHZ7uo9SLDOUed5D4LT/KN
m5jIjRUeqQathU6/uK1IYk+5QkgtpCtmayf22EVMHNnmzWMZ+YO/SmmCpfM9szo+
hdHmQXHI5oYkzdyY4N6LdWKKDwls9vSTU7oMCU3P3Fb40/alFgI4AGDybZ8sIVcY
ARrYBQQSE/dl1K/amy9lRPZIiF/wnyoXz3b9HUMgptummPCVzUKlDLm/P60Iai6k
pyMhU7Ve5i+q7a5JGX4hsOJGk1alGqqk8xZ2PHsMD2OOXz0L1Cx2qQ==
=TroC
-----END PGP SIGNATURE-----

--98e8jtXdkpgskNou--